feat(goals): characterize Goal instance bindings - #4930
Conversation
Signed-off-by: duanjialing.777 <duanjialing.777@bytedance.com>
huangruiteng
left a comment
There was a problem hiding this comment.
评审 exact head:cbbdd837f65c8ba28161115cc4ce39093bfa2951。结论:APPROVE(限 #4927 的 M1 观察与盘点,不宣称已解决同名 Goal 的 ABA)。
动机
#4914 RFC 的 M1 需要一个被真实生命周期入口调用的 typed Goal lifetime 比较,以及 first-party binding/effect owner 盘点;此前 goal-actions 只有 alias 和生命周期动作,没有实例匹配结果。此 PR 让源记录 B 与保留的全局投影 A 在同一长驻 Effect runtime 中显示 goal_instance_mismatch,同时保留原动作。M2 的事务/提交 fence、M3 的 effect-owner 资格仍是明确未交付项;M1 是可独立验收的前置切片,不是 ABA 修复完成声明。
改动思路
项目源 registry 是身份权威,global registry 只是投影/绑定;Python 沿用 _source_and_target 与现有 codec 读取事实,经 goal.operator_actions.project 的一个粗粒度请求交给 TypeScript 纯分类器。分类结果只进入现有 catalog 的附加 JSON goal_binding,不参与 lifecycleAction、授权或写入。对 malformed、缺源、缺目标和 stale 投影分别给 typed 结果,避免从路径、hash 或 lease 推断 lifetime。未引入新 capability、持久化状态或平行 Python 决策器。
具体改动
goal_instance_identity.ts实现七种 RFCBindingMatch结果与输入校验;operator_actions.py/.ts传递 source/global 事实并把结果加入 catalog,内部请求升到 v3,外部 catalog 仍为 v1。goal_instance_binding_inventory_v1.json枚举 11 类一方绑定/效果 owner;架构测试核验路径与符号,registry I/O manifest 更新读点;TS config 纳入新模块与测试。- Python/TS 测试覆盖真实 CLI、legacy/strict-envelope-v1、缺源、stale global、长驻 runtime、旧动作/Markdown 兼容。
关键代码讲解
projectGoalBindingMatch(line 159):在 TS 内以 discriminated unions 做精确实例比较,invalid优先于后续状态匹配;它是只读分类,不是 admission。_identity_observation(line 47)和build_goal_action_catalog(line 79):将既有 route 的源/投影状态送入同一 Effect 请求,不 mint ID、不写 registry。projectGoalOperatorActions(line 88):附加goal_binding,仍无条件使用原lifecycleAction分支与 argv;即使 mismatch 也不伪装成已执行 fence。
对主干的风险
最重要的回归是新增观察暗中改变非激活 Goal 的动作,或把 stale global A 与 source B 错报为 current。我在同一路径、同一合成 registry 上对 base/head 实跑 goal-actions:删去唯一新增的 goal_binding 后,整个旧 JSON(含 fingerprint、动作 argv)完全相同。长驻 runtime 的 A→B、缺失/不可读源、legacy 与 strict envelope、无效 id 分支由 focused 测试覆盖:Python 17/17、TS 4/4、TS typecheck 通过;风险 canary 14/14 通过、无 warning。初次 inventory 测试仅因新 worktree 未装 Node parser 依赖失败,npm ci --ignore-scripts 后重跑全过。按 Goal wait_for_ci=false 未查询远端 CI。
语义与 CI 对齐
新增的是 RFC 已定义的 GoalRef/BindingMatch 观察语义。resolution_in_progress 目前只有 typed 分类与测试,没有 M2 journal 生产者;11 类 owner 盘点也不等于这些 owner 已被 fence。observe_only 与现存仍可执行的 legacy action 一起暴露,调用方不可把此字段当授权回执。
我的整体评价
9 文件、约 1.3k 行看起来较大,但行为代码约 315 行,其余主要是可审计 owner 盘点与正/负/兼容测试;相对 #4927 明确的 M1 验收是相称的。未来小范围重构应继续收敛在这个 TS Goal 边界,避免 M2 再造 Python 匹配规则;此 PR 本身无需扩为未准备好的 activation。未发现本切片的阻断性问题,批准此 exact head。合并与后续真实 ABA/并发/恢复验收仍需独立审查。
English verdict: APPROVE - At cbbdd837f65c8ba28161115cc4ce39093bfa2951, typed M1 observation and the owner inventory match #4927; real CLI base/head parity, 21 focused tests, typecheck and 14 risk canaries pass. No enforcement or ABA protection is claimed.
Signed-off-by: duanjialing.777 <duanjialing.777@bytedance.com>
Goal And Delivered Outcome
goal-actionsJSON now includes an observation-onlygoal_bindingresult with all seven RFC variants. A reused Effect runtime classifies retained instance A against current instance B asgoal_instance_mismatchwhile preserving the existing action and argv.main.Scope And Continuation
Validation
cbbdd837funitpassednode --experimental-strip-types --test tests/control_plane_ts/goal_instance_identity.test.ts: 4 tests cover all seven variants, malformed identity precedence, legacy/stamped mismatch, and request-local warm-process behavior.integrationpassedintegrationpassedtests/control_plane_ts/authority_store.test.ts: 274 tests passed in isolation with the supported Python environment, including the four file-provider cases that failed during an earlier resource-contended full-suite run.real_entrypointpassedtests/control_plane/test_goal_operator_actions.pyexercises the realgoal-actionsCLI and executes its projected lifecycle argv verbatim.regression_paritypassedgoal_bindingyields the complete prior catalog payload; mismatch does not change actions.staticpassednpm run typecheck:control-plane, Ruff on changed Python files,git diff --check, repository hygiene, and a public-boundary scan of all 9 changed files passed.staticpassedloopx canary premerge --from-git-diff --git-diff-base origin/main: 5 direct checks and 14 selected checks passed with zero warnings.staticfailedpython examples/docs-governance-smoke.pystill fails on the unmodifiedautomatic-execution-admission-v0.mdsemantic-mirror marker. This PR has no documentation diff and does not change that baseline.See validation disclosure guidance.
Frontend / Visual Evidence
Type of Change
LoopX Area
Technical Direction
Shared-authority RFC fixture impact
Boundary Checklist
.loopx/,.codex/goals/, and liveACTIVE_GOAL_STATE.md).none.Signed-off-bytrailer (git commit -s).