Repository navigation
fix(compaction): heartbeat sessions ignore the active transcript byte cap - #136533
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs real behavior proof before merge. Reviewed September 5, 2026, 10:58 AM ET / 14:58 UTC. ClawSweeper reviewWhat this changesEnforces the transcript byte limit during heartbeats and adds fenced Codex host compaction with atomic accounting, documentation, and Gateway regression coverage. Merge readiness⛔ Blocked before merge - 3 items remain This repair remains necessary on current main. The previous wording finding is resolved, and no new blocking code defect was found; the captured proof still does not cover the final atomic-persistence restart boundary. Priority: P1 Review scores
Verification
How this fits togetherHeartbeat and chat admission check OpenClaw’s stored conversation before starting another turn. Host compaction summarizes that transcript, while the Codex plugin separately controls its native conversation. flowchart TD
A[Heartbeat or chat turn] --> B[Read active transcript size]
B --> C{Byte limit reached and unlatched?}
C -->|No| G[Admit next turn]
C -->|Yes| D[Validate session and writer]
D --> E[Compact host transcript and commit accounting]
E --> F[Optional eligible Codex synchronization]
F --> G
Before merge
Agent review detailsSecurityNone. PR surfaceSource +358, Tests +2789, Docs +9, Other +38. Total +3194 across 27 files. View PR surface stats
Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep one semantic compaction pipeline with atomic transcript/accounting commits and proven restart recovery; the private authority and transaction boundaries justify growth beyond a guard-only fix. Do we have a high-confidence way to reproduce the issue? Yes, from source: heartbeat admission returns before reading the configured byte cap on current main. The discussion supplies earlier before/after Gateway observations; this review executed no runtime reproduction. Is this the best way to solve the issue? Yes at the owner boundary: reusing semantic host compaction preserves the byte guard, whereas accepting native declines alone leaves host growth unresolved. Final persistence recovery still needs observed proof. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 0f54c8698228. 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 (37 earlier review cycles; latest 8 shown)
|
|
CI note: |
|
Added real behavior proof (requested by the ClawSweeper review) — live before/after runs of the actual heartbeat pipeline, PR body Evidence section updated: Setup (identical for both runs): real Before (unpatched After (this PR head Focused suite on this head is green, including the five-row runtime/heartbeat table covering embedded + Codex over/under cap. |
|
Exact-head proof is complete for
The PR body now maps this evidence to the previous ClawSweeper authority, |
|
@clawsweeper re-review Exact-head proof for |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Exact-head Codex owner-boundary proof completed on Command:
Result: 2 files passed, 93/93 tests passed. The focused run directly covers the remaining ClawSweeper authority concerns:
This supplements the fresh exact-head Crabbox proof in the PR body. It does not |
|
@clawsweeper re-review Exact-head evidence is now attached in the PR body for It covers every remaining proof request from the latest review:
The task-owned proof lease was released after artifact verification. Run 697 and |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper re-review Exact head remains |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Merged via squash.
|
Additional instructions
MUST: Keep Allow edits from maintainers enabled for this PR so maintainers
can help update the branch when needed.
Fixes #136452
Thanks @LiuwqGit for the original report and contributor implementation context.
What Problem This Solves
Heartbeat admission returned before evaluating
agents.defaults.compaction.maxActiveTranscriptBytes. An authoritative hosttranscript could remain above the configured byte cap, and a Codex session could
later dead-end when native compaction correctly declined a host-isolated
transcript.
Root Cause And Owner
The agent compaction owner split transcript append, compaction accounting, and
the byte latch across separate persistence steps. That made the host commit
observable before all authoritative session state was durable and let secondary
Codex synchronization look like part of the success boundary.
The canonical fix keeps one host-owned semantic compaction path:
compaction count, and byte-latch state commit in one OpenClaw agent write
transaction;
from stale in-memory state;
cannot overturn or duplicate it.
No consumer-side fallback, parallel compaction pipeline, dependency change,
configuration surface, or schema change was added.
User Impact
Heartbeat traffic now honors the active-transcript byte cap. Restricted Codex
sessions compact the host transcript without issuing a native compact request
and continue in the same session. Upgraded sessions retain the committed host
result even when optional native synchronization rejects. Writer substitution
and revocation fail before provider traffic or transcript mutation.
Exact-Head Proof
ec44630c4ecb4d2a2ab588fda5f490154a379ac8SHA256:OIEOnMWCJeKhWpBNlB42wwPuUG5gsC8Crq1ibnt7ylQf6f24b109f4a87cef6d173d3cf7e74065adac691d5992278b3b8a8f3e1e37c23749b86efec65215fefead35e6ca501f4c86087d242354c1bfb002dc1run_2a4f0374e55ehttps://crabbox.openclaw.ai/portal/runs/run_2a4f0374e55e
cbx_f5216c34d61b(pr136533-ec44630c)Node
v24.19.0, pnpm12.1.09450cf4f4a69bce6af345e1e0d297c1d0a33370c12896737b85dfe99c18707dce899a6ef3bd8c389c228a990fab954a53409c74b193e0f5dd1be423c84d3a778180d57102b2521ce02a2c24273ad1510c568ec85a28c48b0b00f3567b06ea159c2a76306b39f302b4fd9602cb4d3483a181a3fea3e25f7fac720e2c37f965e70482783bytes; allSHA256SUMSentries verified locallyRun 697 and proof from
4ee3a708or any other superseded head are historicalonly. None is used as current-head proof.
Phase Results
The original fresh run completed every product/test phase, then failed only in
the evidence validator because it asserted the superseded restart shape. The
first tail validator also failed only because an empty checkpoint list was
omitted rather than serialized as
[]. The final tail preserved both failedattempts in the archive, corrected the validator, reverified the immutable
source tuple, ran the not-yet-reached real systemd scenario, and finished green.
check:changedAuth proof included the relevant SecretRef/auth E2E, exec-provider path, and
Windows ACL fail-closed contract tests. Producer proof covered
doctor-gateway-startup-recovery.Joined Heartbeat QA
Schema v2; suite
total=1,passed=1,failed=0, statuscompleted.okokokerrorskippedRedacted joined validator output:
{"schemaVersion":2,"suiteStatus":"completed","suiteCounts":{"total":1,"passed":1,"failed":0,"skipped":0},"cases":{"heartbeat-fresh-restricted":{"status":"pass","terminalStatus":"ok","providerSummary":2,"nativeCompact":0,"checkpoints":1,"compactionCount":1},"heartbeat-upgraded-native-failure":{"status":"pass","terminalStatus":"ok","providerSummary":2,"nativeCompact":1,"checkpoints":1,"compactionCount":1},"heartbeat-upgraded-restart":{"status":"pass","terminalStatus":"ok","providerSummary":2,"nativeCompact":0,"checkpoints":0,"compactionCount":1},"heartbeat-substituted":{"status":"pass","terminalStatus":"error","providerSummary":0,"nativeCompact":0,"checkpoints":0,"compactionCount":0},"heartbeat-revoked":{"status":"pass","terminalStatus":"skipped","providerSummary":0,"nativeCompact":0,"checkpoints":0,"compactionCount":0}}}Real Systemd QA
Schema v2; primary coverage:
cli.port-and-startup-diagnosis,cli.restart-guidance; suitetotal=1,passed=1,failed=0, statuscompleted.restartCount=3startLimitObserved=truestartLimitResult=exit-coderestartGuidanceObserved=trueforeignPortDiagnosed=truecleanupVerified=trueRedacted systemd validator output:
{"schemaVersion":2,"entryStatuses":["pass"],"primaryCoverage":["cli.port-and-startup-diagnosis","cli.restart-guidance"],"suiteCounts":{"total":1,"passed":1,"failed":0,"skipped":0},"suiteStatus":"completed","summary":{"cleanupVerified":true,"foreignPortDiagnosed":true,"independentHealthHealthy":true,"independentStatusHealthy":true,"restartCount":3,"restartGuidanceObserved":true,"startLimitObserved":true,"startLimitResult":"exit-code"},"runtimeStatus":"running","rpcOk":true,"healthOk":true}Evidence Hashes
heartbeat-qa-evidence.json:5ce22e8ea0a36b3b5047b09220912cb4deafcd2a98072b0f1c01153471ae34a5heartbeat-qa-suite-summary.json:c345f73af7ccd1bcbce7b9e68cca656b18be4b5b1f5784f3968ca68a0c716c32320304591eb27ece3a4f570ba2f222bae29a432dbff6bcf7c414dd42dc3e5fb19be0351a46c77c5953769fd27642936cf00a34d210e5442b6a45a28693413115ce1eb9954a596560f0aad3f158c9bf6a6505fb8d773ecd689f0fe18b291016b31adeef29185497e50110031d2e7f384c059caf3ee51fd61616934f693d118c4d3515ee9e598915fa38530dca45dbfd1cd1d481f5f458d7e43a40e0e419337fa4systemd-qa-evidence.json:5a47cfe43174e49c1e4cf2645688f092663608fdff5a39b3dda762742184d505systemd-qa-suite-summary.json:3667be2d254068e77919ad731477c311840a0324b0b916d0590470623fa03b4ddoctor-gateway-startup-summary.json:a97b8b4a95b8970f0ed975874e373dfda5ab029a5d7812d67dbdd014366aae08gateway-status.json:a0302ea88df8db514e2c069bc534a2e5a1bfe350d887eca563b3d9d10320c59agateway-health.json:bfe46858d77655576a23afcdb533c8c7233db8acf3cad09a109d0ed77180ce6aHosted Gates
ec44630c4ecb4d2a2ab588fda5f490154a379ac8173success,0failure,0pending,37skipped,1neutralopenclaw/ci-gate: passremaining evidence blockers were the stale old-head body and missing
pre-checkpoint crash/restart result; both are addressed above with the
corrected table, redacted validator output, portal run, and archive hashes.
Coverage And Size
Sibling coverage includes fresh restricted, upgraded native rejection,
pre-checkpoint restart, substituted writer, revoked writer, auto-reply memory,
queued compaction, hook cancellation, transcript authority, transaction
rollback/reopen, writer-close rollback, and one-shot claim non-vacuity.
+503/-145, net+358+2839/-50, net+2789+18/-9, net+9+38/-0, net+3827The positive production delta establishes the authority boundary, atomic
persistence, lifecycle/writer fencing, and shared accounting projection. It
replaces split ownership rather than adding a downstream guard.
Codex Contract
Direct source inspection used Codex
ddf04ad26789d040f9ef6a96736f76602e35a6cc:codex-rs/app-server-protocol/src/protocol/v2/thread.rs:1116-1126defines
thread/compact/startas a thread-id request with an empty response.codex-rs/app-server/src/request_processors/thread_processor.rs:2371-2383validates direct-input ownership, submits
Op::Compact, and acknowledgessubmission.
codex-rs/core/src/session/handlers.rs:675-677dispatches the asynchronouscompaction operation.
The RPC acknowledges async submission rather than durable completion. OpenClaw
therefore owns host-transcript durability; native synchronization remains
secondary.