Repository navigation
fix(copilot): keep tool transcript groups structurally complete - #114403
Conversation
|
Codex review: needs real behavior proof before merge. Reviewed July 27, 2026, 3:28 PM ET / 19:28 UTC. ClawSweeper reviewWhat this changesThis PR replaces Copilot’s best-effort transcript mirroring with an SQLite-backed journal that atomically stores an assistant tool call together with all of its tool results, preventing incomplete replay transcripts after interrupted Copilot turns. Merge readiness⛔ Blocked until stronger real behavior proof is added - 5 items remain Keep this PR open for explicit maintainer review. The central Copilot transcript-integrity repair is not shown to be redundant with current Priority: P2 Review scores
Verification
How this fits togetherThe Copilot extension turns SDK session events into OpenClaw agent messages and persists them in the canonical session transcript. The new journal buffers tool-using assistant turns, then uses the session-transcript runtime to commit a complete ordered group or leave no partial group behind. flowchart LR
A[Copilot SDK events] --> B[Copilot event bridge]
B --> C[Transcript journal]
C --> D{Tool group complete?}
D -->|Yes| E[Atomic SQLite transcript append]
D -->|No or failed| F[Drop open group and mark replay invalid]
E --> G[Canonical session transcript]
F --> G
Decision needed
Why: The branch changes persisted session binding state and exposes a reusable plugin-SDK batch transcript API; the submitted real run predates later replay/provenance changes, so source and CI evidence cannot settle the upgrade-policy choice alone. Before merge
Agent review detailsSecurityNone. PR surfaceSource +1153, Tests +1442, Other +12. Total +2607 across 26 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Copy recommended automerge instructionTechnical reviewBest possible solution: Keep the atomic journal design only if current-head proof demonstrates complete commit, interrupted-group omission, and resumed-session behavior against existing stored Copilot bindings, with the resulting replay-invalid state and recovery path visible to reviewers. Do we have a high-confidence way to reproduce the issue? Yes for the source-defined failure mode: an assistant tool call can be observed before all result events arrive, and interruption or persistence failure can leave an incomplete group. The submitted real reproduction is credible, but it predates later latest-head provenance and resume changes. Is this the best way to solve the issue? Unclear: atomic group persistence is a strong solution for structural transcript validity, but the shared SDK contract and persisted replay behavior still need current-head upgrade proof before this can be called the best final path. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 52e519220cea. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (7 earlier review cycles)
|
|
Live Copilot interruption proof is now available on the current product head. Provider: direct AWS Crabbox Observed redacted summary: {
"prefixRoles": ["user", "assistant", "toolResult", "assistant"],
"afterRoles": ["user", "assistant", "toolResult", "assistant", "user"],
"suffixRoles": ["user"],
"terminalKind": "aborted",
"replaySafe": false,
"toolCalls": ["complete-prefix", "interrupted-group"]
}The first live tool turn committed a complete replayable prefix. The second live tool was observed and then externally aborted while its assistant/tool group was open. The canonical transcript retained only that turn's pre-dispatch user row: no assistant tool call and no tool result survived, so there is no dangling tool call. The attempt retained fail-closed replay metadata. Maintainer decisions from the task brief are resolved: the generic session-transcript batch seam is explicitly authorized, and the fail-closed policy that drops an open group while retaining/replay-invalidating the native checkpoint is accepted. @clawsweeper re-review |
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
Maintainer decision record for the remaining ClawSweeper items:
No prepare or merge action has been run. |
71e65b6 to
610a6c0
Compare
2cad501 to
8e08d2d
Compare
|
Maintainer decision for the latest ClawSweeper review on head 8e08d2d:
This records the designated owner acceptance requested by the review and explains why the optional current-head live-proof rank-up move is not required for this landing. |
|
Merged via squash.
|
…claw#114403) * refactor(copilot): make SQLite own transcripts * fix(copilot): harden transcript event projection * test(copilot): tighten transcript journal types * fix(copilot): retain unmatched usage metadata * refactor(copilot): commit tool groups atomically * fix(copilot): break journal bridge import cycle * fix(copilot): preserve grouped transcript replay * test(copilot): cover opaque replay state * fix(copilot): invalidate lossy transcript replay * fix(copilot): guard transcript rewrite topology * fix(copilot): drain transcript finalization * fix(copilot): preserve resumed session history * fix(copilot): dedupe replayed transcript snapshots * fix(copilot): isolate transcript write hooks * fix(copilot): track staged transcript identities * fix(copilot): isolate ephemeral transcript events * fix(copilot): coalesce assistant snapshots * fix(copilot): invalidate unprojected SDK context * fix(copilot): guard resumed transcript replay * fix(plugin-sdk): expose strict transcript append * fix(copilot): persist journal provenance safely * fix(copilot): separate live and durable deltas * fix(copilot): require durable projection ownership * fix(copilot): preserve strict append typing * fix(copilot): gate deferred session deletion * fix(copilot): preserve transcript replay identity * fix(copilot): retain cited replay history * fix(copilot): require complete replay provenance * fix(copilot): reject ambiguous assistant snapshots * fix(copilot): return latest assistant snapshot * chore(copilot): align transcript lint gates * test(lint): cover Copilot line budgets * test(ci): dedupe Codex prewarm shard
… removed dual-write mirror (#125599) * docs(copilot): describe the transcript journal, not the removed dual-write mirror The new copilot plugin doc described transcript persistence through extensions/copilot/src/dual-write-transcripts.ts with session-scoped content-fingerprint keys and best-effort failure containment. That module was removed in #114403 (Jul 27): attempts now own an attempt-transcript-journal keyed by run id and SDK event id, journaled in structurally complete groups, and persistence failures fail closed by aborting the SDK session and flagging replay as unvalidated. Rewrite the section around the current journal, and update the two "transcript mirror" references that pointed at it. * docs(copilot): clarify invalid replay starts a fresh session Co-authored-by: Santhi Prakash <[email protected]> --------- Co-authored-by: Peter Steinberger <[email protected]>
… removed dual-write mirror (openclaw#125599) * docs(copilot): describe the transcript journal, not the removed dual-write mirror The new copilot plugin doc described transcript persistence through extensions/copilot/src/dual-write-transcripts.ts with session-scoped content-fingerprint keys and best-effort failure containment. That module was removed in openclaw#114403 (Jul 27): attempts now own an attempt-transcript-journal keyed by run id and SDK event id, journaled in structurally complete groups, and persistence failures fail closed by aborting the SDK session and flagging replay as unvalidated. Rewrite the section around the current journal, and update the two "transcript mirror" references that pointed at it. * docs(copilot): clarify invalid replay starts a fresh session Co-authored-by: Santhi Prakash <[email protected]> --------- Co-authored-by: Peter Steinberger <[email protected]>
Additional instructions
Allow edits from maintainers is enabled. This PR is AI-assisted; I reviewed the implementation and proof.
What Problem This Solves
Fixes an issue where Copilot-backed turns could durably record an assistant tool call without all of its tool results when a timeout, abort, process failure, or write failure interrupted the turn. That left the canonical transcript structurally incomplete and unsafe to replay.
Why This Change Was Made
Copilot now journals the initial user turn before provider dispatch, but buffers any assistant message that requests tools. Once the final result arrives, the assistant plus results are appended in request order through a new session-transcript batch facade backed by one existing SQLite transaction. There is no schema or protocol-version change.
All redaction, stable identity preparation, and
before_message_writehooks finish beforeBEGIN; the transaction synchronously revalidates the session and all-or-none idempotency state before inserting rows. A steady-state replay preflight avoids rerunning hooks. Because hooks are forbidden inside the transaction, concurrent processes can both evaluate hooks before one transaction wins; the transaction still prevents a partial or duplicate group.An authoritative hook block on any group member suppresses the entire assistant/result group. This intentionally trades that group's audit detail for structural validity; the native checkpoint is retained but marked replay-invalid. Timeout, abort, detach, partial identity, and append failures likewise drop the open buffer and fail closed. Finalize-time reconstruction and the old dual-write path are deleted.
User Impact
Copilot transcripts are always valid prefixes ending between complete tool groups. Operators no longer get a canonical transcript with dangling tool calls after interrupted turns, and post-run persistence does not duplicate runtime-owned assistant messages.
Audit Completeness
Diff Size and Justification
Exact numstat against
origin/main: +1908/-1263, net +645 overall; +913/-447, net +466 production; +995/-816, net +179 tests.The production delta remains above the rough target because the accepted design revision adds a reusable atomic accessor and retains complete event audit coverage. The former finalize reconstruction and dual-write implementations are fully removed; the remaining blocks map directly to audit completeness, fail-closed ownership, structural atomicity, or the cycle-free bridge contract.
Evidence
run_ccfc2b7414c3. Complete prefix roles wereuser, assistant, toolResult, assistant; the aborted turn left only its user row; terminal wasaborted; replay was unsafe; no dangling tool call survived.30246269248succeeded on71e65b6f39a3444ecffc04317f75f7a6a6291c10with no failed or cancelled jobs.tbx_01kyh5mhpf0rbpyh2ezrhbx0a3:pnpm check:changedpassed every selected core, extension, SDK surface, typecheck, lint, database-first, and import-cycle gate in 20m59s.pnpm check:architectureand 43 journal/bridge tests passed on Testboxtbx_01kyh7dbbx3a992fww8nwa8fgq.autoreview clean: no accepted/actionable findings reported.git diff --checkpasses on head71e65b6f39a3444ecffc04317f75f7a6a6291c10.