Skip to content

Expose journal-backed Turn evidence chains - #8789

Open
cocolord wants to merge 1 commit into
mainfrom
codex/turn-journal-evidence-chain
Open

cocolord wants to merge 1 commit into
mainfrom
codex/turn-journal-evidence-chain

Conversation

@cocolord

Copy link
Copy Markdown
Member

Problem boundary

LoopX already persists governed Turn execution, validation, writeback, and settlement facts in the Turn journal, but evaluators do not have one exact-identity readback that keeps those facts aligned. Planning or replan references alone must not be promoted into execution progress.

Change boundary

  • Add a settlement-addressed, read-only Turn journal evidence-chain projection.
  • Reuse the journal transaction phase owner and existing status, host_result, task_validation, writeback, settlement_result, and receipt fields.
  • Preserve recorded, missing, unknown, and not_applicable distinctions.
  • Expose the projection through the Effect runtime and the Python journal-store readback.
  • Keep exact GoalRef and settlement-identity matching and the existing ambiguity/corruption refusal behavior.

Non-goals: no new runtime capture, observer migration, sidecar joins, causal attribution, native-score inference, or aggregate trajectory score.

Validation

  • Targeted TypeScript: 68 passed.
  • Python journal readback: 36 passed.
  • Strict targeted TypeScript typecheck: passed.
  • Ruff and git diff checks: passed.
  • Semantic vocabulary advisory and semantic-vocabulary-drift smoke: passed.
  • Full TypeScript control-plane suite: 6494 passed, 85 skipped, 1 unrelated existing failure in content_digest_single_owner.test.ts, which reports the unchanged native_child_result_inbox.ts:109 matcher.
  • Full repository typecheck remains blocked by the unchanged coordination_runtime_shadow.test.ts:380 string-or-undefined error.

Signed-off-by: lusendong.6789 <lusendong.6789@bytedance.com>
Co-authored-by: TRAE CLI <traecli@bytedance.com>

@loopx-agent loopx-agent left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer: model_agent · gpt-6.1-sol · OpenAI · runtime_reported · reasoning_effort=max

评审提交 ce5a1370d088e29ef78cb646996b6756184c0ede,目标主干 2592d4a2a5e8ef4947ea1c0194d6ffe4ac37d7f0。实际差异基线为 74ca883d5bd3e4bc64671bac54210eac9e97ed05。

[P2] 终态收尾失败缺少对应的阶段条目。 用受控 provider 驱动真实 run_loopx_turn_once 写出失败 journal。持久回执和新读口顶层的 failed_phase 都是 terminal_closeout,settlement_result 也记录同一步失败;phases 却没有这个阶段,所有 failed 都为 false。原轮重试只重做收尾,写回和扣额各一次。 从现有 settlement step 和 journal 解释层投影适用的 terminal_closeout,使 phases 与 failed_phase 一致。也可显式分开固定阶段和条件结算步骤,并让调用者从同一个结构找到失败节点。保留原顺序、身份和失败回执。 发生位置

动机 / Motivation

已有 journal 能按原 Turn 和 GoalRef 找到解释结果、回执及恢复位置,但没有一份按结算身份对齐的评估链。 需要用同一 Turn 的记录比较验证、写回和收尾结果的评估器和维护者。 同一受管 Turn 完成验证、写回和扣额,随后 terminal_closeout 被拒绝。评估器读取该 Turn 的阶段链。 用受控 provider 驱动真实 run_loopx_turn_once 写出失败 journal。持久回执和新读口顶层的 failed_phase 都是 terminal_closeout,settlement_result 也记录同一步失败;phases 却没有这个阶段,所有 failed 都为 false。原轮重试只重做收尾,写回和扣额各一次。 系统摘要可能把失败放在未归类状态;读者要拼接另两处字段才能定位该修复原轮收尾,之后的跨样本比较也容易漏计。 已覆盖本地真实 journal 写和读,结算 provider 使用可控注入。没有用实际登录宿主或新评估下游代替本轮证据。

改动思路 / Approach

Effect runtime 新增一个只读方法。Python 验证外层传输形状;TS 复用文件查找、精确身份和现有 journal 一致性判断,再展开已记录事实。 本次边界为现有 journal 的因果无关事实投影。没有新采集、重规划计分、自动执行、权限或面向用户的 UI;更广评估接入仍由消费者决定。 从现有 settlement step 和 journal 解释层投影适用的 terminal_closeout,使 phases 与 failed_phase 一致。也可显式分开固定阶段和条件结算步骤,并让调用者从同一个结构找到失败节点。保留原顺序、身份和失败回执。

具体改动 / Changes

完整差异 6 文件,新增 395 行、删除 1 行:三处运行时代码与三处测试。

关键代码讲解

  • projectEvidenceChain。把 canonical journal 的状态、阶段和已记录对象展开为统一视图。 固定事务阶段不包含条件 terminal_closeout 的条目。 对齐条件收尾和阶段状态,同时保留只读事实。 源码
  • journalPhaseViolation。解释 journal 状态和有序阶段。 沿用现有规则,允许 quota_spend 后发生 terminal_closeout 失败。 原失败 journal 合法并可读回。 源码
  • turn_journal_evidence_chain。从 Python 调用 Effect runtime 并检查外层返回。 添加精确 identity 的可选读取入口,不替换历史接口。 实际读回不改写持久 journal,错误来源依旧拒绝。 源码

验收沿用 原有契约。结果由本地真实入口读回。

  • original-boundary。沿原读写 owner,真实可验证的来源与响应。68 项定向 TypeScript、37 项 Python 通过。真实受控 Turn 的读回保留同一身份和原日志字节;恢复后为 committed,原写回和扣额未重复。
  • boundary-negative。终态收尾失败缺少对应的阶段条目。用受控 provider 驱动真实 run_loopx_turn_once 写出失败 journal。持久回执和新读口顶层的 failed_phase 都是 terminal_closeout,settlement_result 也记录同一步失败;phases 却没有这个阶段,所有 failed 都为 false。原轮重试只重做收尾,写回和扣额各一次。 用真实执行器制造已扣额但收尾失败的 journal,从 Effect/Python 新入口读回。断言表中有且只有一个失败的 terminal_closeout;再按原轮恢复,确认不会再次写回或扣额。

对主干的风险 / Risks

68 项定向 TypeScript、37 项 Python 通过。真实受控 Turn 的读回保留同一身份和原日志字节;恢复后为 committed,原写回和扣额未重复。 新读口须显式调用。既有查找和能力读回的响应形状,以及拒绝错误 GoalRef 和坏 journal 的行为保持不变。

回归验证:用真实执行器制造已扣额但收尾失败的 journal,从 Effect/Python 新入口读回。断言表中有且只有一个失败的 terminal_closeout;再按原轮恢复,确认不会再次写回或扣额。 托管 CI 未查询。

我的整体评价 / Verdict

系统摘要可能把失败放在未归类状态;读者要拼接另两处字段才能定位该修复原轮收尾,之后的跨样本比较也容易漏计。 最小修复见上。已覆盖本地真实 journal 写和读,结算 provider 使用可控注入。没有用实际登录宿主或新评估下游代替本轮证据。

English verdict: REQUEST_CHANGES at ce5a1370d088e29ef78cb646996b6756184c0ede. A real journal records terminal_closeout as failed after quota spend, but the new phase table has no failed row. Project the conditional step from the existing settlement owner; the original retry already avoids a second debit.

result_kind: typeof journal.result_kind === "string" ? journal.result_kind : null,
completed_phases: [...completedPhases],
failed_phase: failedPhase,
phases: transactionPhases.map(phase => ({

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] 终态收尾失败缺少对应的阶段条目。 用受控 provider 驱动真实 run_loopx_turn_once 写出失败 journal。持久回执和新读口顶层的 failed_phase 都是 terminal_closeout,settlement_result 也记录同一步失败;phases 却没有这个阶段,所有 failed 都为 false。原轮重试只重做收尾,写回和扣额各一次。 从现有 settlement step 和 journal 解释层投影适用的 terminal_closeout,使 phases 与 failed_phase 一致。也可显式分开固定阶段和条件结算步骤,并让调用者从同一个结构找到失败节点。保留原顺序、身份和失败回执。

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants