Skip to content

fix: preserve context-engine advancement after steering - #168394

Merged
steipete merged 2 commits into
mainfrom
fix/steer-confirm-keeps-turn-advancement
Oct 10, 2026
Merged

steipete merged 2 commits into
mainfrom
fix/steer-confirm-keeps-turn-advancement

Conversation

@steipete

@steipete steipete commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #168014

What Problem This Solves

Steering a running turn can permanently prevent a durable context engine from committing that turn, even though the user receives its answer.

User Impact

Successfully steered turns advance durable context once, with the original input, steering message, and responses included. Content, provenance, branch changes, and real transcript replacements still invalidate stale admissions.

Existing terminally blocked outbox rows are unchanged. Private steering metadata is published through the existing transcript update event; delta cursors already past the row do not replay that metadata-only correction.

Why This Change Was Made

Steering confirmation rewrote the user row and rotated the transcript generation. The running turn retained its original admission, so its closed-turn read returned session-rebound and left advancement permanently blocked.

The canonical transcript writer now preserves generation only when the complete before-and-after user events differ solely in a valid steerTargetRunId. Exact-row compare-and-swap, mutation timestamps, and all other rewrite fences remain intact.

Evidence

  • Fresh-machine live proof: AWS Crabbox cbx_4fd21a690d45, r7a.xlarge, Node 24.21.0, 30.6 GiB. Separate real Gateway processes used isolated state/config and ephemeral loopback ports, the QA mock OpenAI provider, and a durable SQLite-backed context-engine plugin. The production-reverted baseline confirmed one steer but made zero commitTurn calls and retained one blocked session-rebound row (124.492s). The fix committed exactly once with all four input/response messages and left the outbox empty (126.836s). Both delivered the steered answer. A subsequent recovery-probe turn was aborted before completion.

  • Negative control: reverting only the production writer made the new acceptance regression fail with the intended assertion and durable turn advancement is blocked ... transcript range is session-rebound warning (38.006s).

  • Full module proof: 448 explicit test files, 5,027 tests, nine routed Vitest shards passed in 4,594.225s. Coverage includes all session-storage, session, and harness module tests, direct importers, and cursor/display siblings. The new acceptance regression took 4.660s; the five new genuine-mutation fence cases took 0.356–0.494s each. These exercise real SQLite workers and the durable acceptance/outbox boundary without timers, sleeps, or polling in the new tests.

  • Checks: core types and all three required test-type graphs passed on the lease. Targeted oxlint, formatting, and git diff --check passed locally. Independent Codex autoreview is scoped-clean through P2; the final deslop pass required no additional source changes. ClawSweeper’s exact-head review reported zero findings and complete fix scope.

  • Inherited failure: check:changed on the tested base failed only on the stale max-lines entry for src/commands/doctor-memory-search.test.ts; conflict-marker and line-growth ratchets passed. The stale entry was removed upstream in 72eafadc01a0. Neither that test nor its baseline file is changed by this PR.

  • Inherited hosted CI failure: check-test-types-core-4 reports TS2345 at src/gateway/control-ui-public-session-refresh.test.ts:51. Upstream 06c6e83f4351 extracts renderedEntryScript[1] without narrowing that capture before runInNewContext. The failing test and renderer are byte-identical between CI's main parent (86bc4f7df36b) and the tested merge; neither is changed by this PR. Main now contains the coordinator's fix 8420f82cbbf8, which narrows the captured script before runInNewContext. Landing uses the native inherited-failure exception for exactly check-test-types-core-4 and its aggregate openclaw/ci-gate. The gateway-root graph is the failing graph; the other, plugin-SDK, commands, and agents/sessions graphs in that CI job passed. No CI rerun or extra push was requested.

Proof identity, commands, and size

Reviewed/tested head: 2e6a59aa1d6568a46863dda3907aed48204a35b8.
Last main merge and production-reverted baseline: 56521b610f441ae4f7190a2d82b7acd4feba2991.
Crabbox run: run_0070108ed195ae637c34a2bb41cf9157.
The bootstrap verified the full head, tree, clean tracked files, production hash, no instance-role credentials, and pinned toolchain before proof, then reverified the source afterward.

The module run used node scripts/run-vitest.mjs with all 448 explicit paths. Two existing synthetic benchmark files were enabled with OPENCLAW_SESSION_ENTRY_SNAPSHOTS_BENCH=1 and OPENCLAW_SESSION_PUBLICATIONS_BENCH=1.

pnpm tsgo:core
pnpm tsgo:core:test --ci-graphs-json '["core-test-agents-sessions","core-test-agents-tools","core-test-other"]' --concurrency 1
pnpm check:changed

The live comparison used the same source tree with only session-accessor.sqlite-transcript-store.ts reverted for the baseline, followed by the unchanged candidate. Source hashes and terminal/outbox/commit observations were recorded separately for both processes.

Production: +38/-1 (net +37); tests: +102/-1; docs: +5/-0. The production growth provides complete-event validation that keeps genuine stale ranges rejected. Hosted PR CI is separate from this completed lease proof.

Preserve transcript generation only for a validated steering-target metadata confirmation, retaining content, provenance, branch, and replacement fences. Remove an unused internal transcript read wrapper. Fixes #168014.
@clawsweeper

clawsweeper Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation agents Agent runtime and tooling size: S labels Oct 10, 2026
@steipete
steipete marked this pull request as ready for review October 10, 2026 10:36
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 10, 2026
@clawsweeper

clawsweeper Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

Preserve transcript generation when a user-event rewrite changes only valid steering correlation metadata.

Example: A user sends “Include the correction” while “Start the answer” is running.

  • Before: Steering confirmation rotates generation, leaving the answered turn permanently blocked with session-rebound.
  • After: The accepted turn commits once with its original input, steering message, and answer.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A focused producer repair with recorded shipped-entry-point proof, a failing negative control, and meaningful invalidation coverage.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The exact-head Gateway comparison exercises steering through real transcript persistence and durable-engine settlement, recording one complete commit and an empty outbox after the fix. The inspected UI image only demonstrates ordering; video preparation failed with ffprobe ENOENT and is not relied upon.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: A steered answer reaches the user but never advances durable context, leaving gaps in the engine’s conversation state.
Reason: The focused change restores the accepted-turn contract without adding configuration, APIs, schemas, or a parallel owner.

Merge readiness

✅ Ready for maintainer review

This PR repairs a current durable-context advancement bug at its transcript producer, with no actionable introduced defects found.

Priority: P1
Reviewed head: 2e6a59aa1d6568a46863dda3907aed48204a35b8

Before merge

None.

Findings

None.

Agent review details

How this fits together

The canonical SQLite transcript writer maintains the generation fences consumed by transcript admissions, closed-turn reads, and durable context-engine advancement.

flowchart TD
A[Running turn and steering input] --> B[Transcript recorder]
B --> C[Canonical SQLite rewrite]
C --> D[Closed turn reader]
D --> E[Durable turn outbox]
E --> F[Context engine commitTurn]
Loading

Technical review

Best possible solution:

Land the narrow canonical-writer repair while preserving genuine mutation fences and existing blocked-row retention.

Do we have a high-confidence way to reproduce the issue?

Current-main source establishes the steering rewrite, generation mismatch, and blocked advancement path; the contributor also records a failing Gateway baseline and regression negative control.

Is this the best way to solve the issue?

The repair belongs at the existing transcript writer and is safer than broadly accepting stale generations or refreshing competing admission receipts.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 1cb9b5aeac88.

Provenance checked

  • Generation invalidation for exact transcript rewrites changes intended behavior with a stated reason (5e12310: The prior optimization deliberately retained generation invalidation while avoiding unnecessary index rebuilding; this identifies preserved intent, not the earliest introduction.)
  • Confirmed steering provenance keeps the original intent (08622cd: Confirmed exact-run provenance keeps streamed replies and persisted user turns causally ordered.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 6461c18 adds src/sessions/user-turn-transcript-updates.ts:25 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 6461c186e518; files: src/sessions/user-turn-transcript-updates.ts)
  • Vito Cappello: Raw commit 5621979 adds docs/concepts/context-engine.md:233 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: 5621979a469a; files: docs/concepts/context-engine.md)
  • Josh Lehman: Raw commit 2f4dff7 adds docs/concepts/context-engine.md:229 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: 2f4dff742812; files: docs/concepts/context-engine.md)

PR surface

Source +37, Tests +101, Docs +5. Total +143 across 5 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 38 1 +37
Tests 3 102 1 +101
Docs 1 5 0 +5
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 145 2 +143

Review metrics

Metric Value Why it matters
Production versus tests Production +38/-1; tests +102/-1. Complete-event equivalence checking justifies the production growth; tests exercise durable acceptance and distinct mutation fences.

Root-cause cluster

Relationship: same_root_cause
Canonical: #168014
Summary: The canonical report identifies the steering-generation producer failure repaired here; sibling retry and reload work addresses related consequences.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Labels

Label changes:

No label changes.

Label justifications:

  • P1: Ordinary steering can silently omit a successfully answered turn from durable context-engine state on current main.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only; repair and merge need explicit maintainer commands such as @clawsweeper autofix or @clawsweeper automerge.

History

Review history (2 earlier review cycles)
  • reviewed 2026-10-10T10:42:32.542Z sha 2e6a59a :: needs maintainer review before merge. :: none
  • reviewed 2026-10-10T10:53:34.227Z sha 2e6a59a :: needs maintainer review before merge. :: none

Reviewed October 10, 2026, 7:09 AM ET / 11:09 UTC (Revision 3).

@steipete
steipete merged commit b0e5f30 into main Oct 10, 2026
220 of 224 checks passed
@steipete
steipete deleted the fix/steer-confirm-keeps-turn-advancement branch October 10, 2026 11:30
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via explicitly authorized admin squash with attributed pre-existing CI failures.

steipete added a commit that referenced this pull request Oct 10, 2026
…168569)

#168394 stopped steering confirmation from rotating the transcript
generation, so the foreground admission stays valid. Retries after
accepted steering with a new run, a reset native binding, or a new
context budget now reread the same admission-fenced prefix and finish
ok instead of failing with "Current-turn transcript admission identity
changed". Assert that contract: same-run retries reuse retained history,
rescoped retries reread once without widening it, and cancelled or
revoked retries keep their terminal outcomes.

Co-authored-by: Peter Steinberger <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 11, 2026
)

* fix(sessions): keep steered turns advancing durable context

Preserve transcript generation only for a validated steering-target metadata confirmation, retaining content, provenance, branch, and replacement fences. Remove an unused internal transcript read wrapper. Fixes openclaw#168014.

* chore: defer unrelated transcript export cleanup
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 11, 2026
…penclaw#168569)

openclaw#168394 stopped steering confirmation from rotating the transcript
generation, so the foreground admission stays valid. Retries after
accepted steering with a new run, a reset native binding, or a new
context budget now reread the same admission-fenced prefix and finish
ok instead of failing with "Current-turn transcript admission identity
changed". Assert that contract: same-run retries reuse retained history,
rescoped retries reread once without widening it, and cancelled or
revoked retries keep their terminal outcomes.

Co-authored-by: Peter Steinberger <[email protected]>
RomneyDa pushed a commit that referenced this pull request Oct 11, 2026
* fix(sessions): keep steered turns advancing durable context

Preserve transcript generation only for a validated steering-target metadata confirmation, retaining content, provenance, branch, and replacement fences. Remove an unused internal transcript read wrapper. Fixes #168014.

* chore: defer unrelated transcript export cleanup

(cherry picked from commit b0e5f30)
RomneyDa pushed a commit that referenced this pull request Oct 11, 2026
…168569)

#168394 stopped steering confirmation from rotating the transcript
generation, so the foreground admission stays valid. Retries after
accepted steering with a new run, a reset native binding, or a new
context budget now reread the same admission-fenced prefix and finish
ok instead of failing with "Current-turn transcript admission identity
changed". Assert that contract: same-run retries reuse retained history,
rescoped retries reread once without widening it, and cancelled or
revoked retries keep their terminal outcomes.

Co-authored-by: Peter Steinberger <[email protected]>
(cherry picked from commit aec6e7a)
RomneyDa pushed a commit that referenced this pull request Oct 14, 2026
* fix(sessions): keep steered turns advancing durable context

Preserve transcript generation only for a validated steering-target metadata confirmation, retaining content, provenance, branch, and replacement fences. Remove an unused internal transcript read wrapper. Fixes #168014.

* chore: defer unrelated transcript export cleanup

(cherry picked from commit b0e5f30)
RomneyDa pushed a commit that referenced this pull request Oct 14, 2026
…168569)

#168394 stopped steering confirmation from rotating the transcript
generation, so the foreground admission stays valid. Retries after
accepted steering with a new run, a reset native binding, or a new
context budget now reread the same admission-fenced prefix and finish
ok instead of failing with "Current-turn transcript admission identity
changed". Assert that contract: same-run retries reuse retained history,
rescoped retries reread once without widening it, and cancelled or
revoked retries keep their terminal outcomes.

Co-authored-by: Peter Steinberger <[email protected]>
(cherry picked from commit aec6e7a)
scribe-dandelion-cult added a commit to karmaterminal/openclaw that referenced this pull request Oct 15, 2026
Three fork-only test copies still asserted contracts upstream changed:
- usage.sessions-usage-details: openclaw#163182 usage target (red since before the absorb)
- provider-catalog-live-runtime.config: stale split of upstream's rewritten test (openclaw#167462, step 11)
- user-turn-transcript.recorder: openclaw#168394 keeps the admission generation (step 20)

Test files only. GREEN/RED/GREEN, neighbours and static gates recorded in the lane's .lane/DONE.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Jhynq2GVpzuVQQieebEubg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

1 participant