fix: refresh prompt fence after compaction writes#90775
Conversation
|
Codex review: needs real behavior proof before merge. Reviewed June 5, 2026, 7:59 PM ET / 23:59 UTC. Summary PR surface: Source +97, Tests +270. Total +367 across 5 files. Reproducibility: yes. source inspection gives a clear reproduction path: current main refreshes the prompt fence for message persistence but not for Review metrics: none identified. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Proof guidance:
Risk before merge
Maintainer options:
Next step before merge
Security Review detailsBest possible solution: Land the narrow guarded compaction-owned write path after maintainer review plus redacted live compaction proof or an explicit proof override, while preserving rejection of raw external session edits. Do we have a high-confidence way to reproduce the issue? Yes, source inspection gives a clear reproduction path: current main refreshes the prompt fence for message persistence but not for Is this the best way to solve the issue? Yes, the proposed shape is the best fix I found: it threads compaction persistence through the existing guarded AGENTS.md: found and applied where relevant. Codex review notes: model gpt-5.5, reasoning high; reviewed against a4f7e4cbb946. Label changesLabel justifications:
Evidence reviewedPR surface: Source +97, Tests +270. Total +367 across 5 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
|
327a3e1 to
054ea49
Compare
|
Updated proof for the current head SHA Behavior addressed: owned auto-compaction session-manager appends no longer trip embedded prompt-fence takeover detection after the prompt lock is released, while unowned or interleaved external session-file edits are still rejected. Real environment tested: Blacksmith Testbox through Crabbox on Linux. Exact steps or command run after this patch:
Evidence after fix:
Observed result after fix: focused session-lock regression tests passed ( What was not tested: this proof does not drive a full provider/model embedded agent run all the way through threshold-triggered auto-compaction. It directly exercises the production session manager, compaction guard, embedded lock controller, and session write-lock paths that own the issue invariant. |
|
Land-ready verification for head
Known proof scope: the Testbox proof directly exercises the production session manager, compaction guard, embedded lock controller, and session write-lock paths. It does not run a full live provider/model turn through threshold auto-compaction. |
|
Landed via squash merge onto
Thanks @jalehman. |
Summary
type: "compaction"session entry while the prompt fence is released.SessionManagerowned-write callback path, matching the existing message-persisted fence refresh behavior.guardSessionManagerand the session-lock regression coverage.Linked context
Closes #90729
Related #88348 and #88653 for prior benign rewrite handling; those do not cover same-file owned compaction appends.
Requested by Josh in this maintainer thread.
Real behavior proof (required for external PRs)
EmbeddedAttemptSessionTakeoverErrorwhen the embedded prompt fence is released.blacksmith-testbox.node scripts/crabbox-wrapper.mjs run --provider blacksmith-testbox -- env OPENCLAW_CHECK_CHANGED_REMOTE_CHILD=1 OPENCLAW_CHANGED_LANES_RAW_SYNC=1 corepack pnpm check:changedtbx_01ktcyq66htgrbs2yer89p0s7f, Actions runhttps://github.com/openclaw/openclaw/actions/runs/27043607767, exit 0.core, coreTests; core typecheck, core test typecheck, lint on changed files, import-cycle guard, and related runtime guards passed.tbx_01ktcnjft8yk11w7ar9mdnv1yr, Actions runhttps://github.com/openclaw/openclaw/actions/runs/27036822896, withEmbeddedAttemptSessionTakeoverError.Tests and validation
node scripts/run-vitest.mjs src/agents/embedded-agent-runner/run/attempt.session-lock.test.ts -- --reporter=verbosenode scripts/run-vitest.mjs src/agents/session-tool-result-guard.test.ts src/agents/session-tool-result-guard.transcript-events.test.ts -- --reporter=verbosegit diff --checknode scripts/crabbox-wrapper.mjs run --provider blacksmith-testbox -- env OPENCLAW_CHECK_CHANGED_REMOTE_CHILD=1 OPENCLAW_CHANGED_LANES_RAW_SYNC=1 corepack pnpm check:changed.agents/skills/autoreview/scripts/autoreview --mode localRegression coverage added:
SessionManager.appendCompaction(...)refreshes the prompt fence before post-prompt cleanup reacquires the session lock.type: "compaction"JSONL appends still throwEmbeddedAttemptSessionTakeoverError.Failed before fix:
EmbeddedAttemptSessionTakeoverErrorbefore the compaction persistence hook was wired.Risk checklist
Did user-visible behavior change? (
Yes/No)Yes. Auto-compaction during embedded attempts should no longer produce a false takeover error.
Did config, environment, or migration behavior change? (
Yes/No)No.
Did security, auth, secrets, network, or tool execution behavior change? (
Yes/No)No.
What is the highest-risk area?
The session-file ownership boundary while an embedded attempt has released the prompt lock.
How is that risk mitigated?
The hook only marks writes made through the guarded
SessionManager.appendCompactionpath as owned. The negative test proves raw external compaction-looking writes remain takeover errors.Current review state
What is the next action?
Review and CI.
What is still waiting on author, maintainer, CI, or external proof?
Waiting on PR CI after creation.
Which bot or reviewer comments were addressed?
Local autoreview P3 finding about a weak compaction persistence fixture was accepted and fixed. Final autoreview reported no accepted/actionable findings.