Skip to content

fix(agents): allow required-preflight native Codex compaction - #120197

Merged
fuller-stack-dev merged 46 commits into
openclaw:mainfrom
SunnyShu0925:fix/preflight-codex-compaction-119971
Aug 16, 2026
Merged

fuller-stack-dev merged 46 commits into
openclaw:mainfrom
SunnyShu0925:fix/preflight-codex-compaction-119971

Conversation

@SunnyShu0925

@SunnyShu0925 SunnyShu0925 commented Aug 7, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

In Codex app-server sessions, when a message crosses the context budget, the required preflight compaction used to be silently skipped and then misclassified as a fatal failure, so the user's turn was dropped with a "Context is too large" error and no model call ever ran. Required-preflight compaction now explicitly asks Codex to compact natively, and falls back to the context engine when the thread binding is missing or stale.

  • Problem: the reply preflight path called the harness with a plain compaction request; Codex returned its intentional ok:true, compacted:false, reason:"codex app-server owns automatic compaction" no-op, isBenignCompactionSkipResult rejected it, and the preflight gate threw — dropping the user's turn and leaving the oversized session unrecoverable. Production logs in [Bug]: Preflight (budget) compaction treats Codex "owns automatic compaction" no-op as fatal and drops the user's turn #119971 show this firing 41 times.
  • Solution: route required-preflight compaction through the harness private compactAfterContextEngine capability (which passes allowNonManualNativeRequest: true) so Codex actually starts native compaction. A missing/stale thread binding surfaces as the canonical recoverable stale_thread_binding / missing_thread_binding failure that the existing context-engine fallback handles.
  • What changed: src/agents/harness/compaction.ts (new "required_preflight" native request type + routing), src/agents/embedded-agent-runner/compact.queued.ts (pass required_preflight when preflightRequired; locked-harness branch now lets required-preflight recoverable binding failures reach the context-engine fallback), extensions/codex/src/app-server/compact.ts (required-preflight binding change returns canonical recoverable failure, not an ok:true skip), extensions/codex/harness.ts (propagate nativeCompactionRequest), plus regression tests in selection.test.ts, compact.test.ts, compact.hooks.test.ts.
  • What did NOT change: non-preflight budget compaction, CLI compaction, manual compaction, harnesses without the private capability (they fall back to the plain compact hook unchanged), and the benign-skip classifier in compact-reasons.ts.

Why This Change Was Made

The same Codex ownership skip was already handled in the CLI compaction path (#88207 for #91793), but the reply preflight caller was never updated. ClawSweeper's review confirms current main still turns the successful automatic-compaction skip into the preflight failure reply. The fix follows the issue's recommended option 2 (re-request with allowNonManualNativeRequest: true, fall back to the context engine on a recoverable binding failure) rather than merely labeling the skip benign — labeling it benign would let mandatory compaction silently not happen.

Two P1 follow-ups emerged during review and are addressed here:

  1. A binding change between the initial read and the guarded native request used to return an ok:true, compacted:false skip that bypassed the shared fallback guard, so required preflight still threw and dropped the turn. The Codex compaction producer now returns the canonical recoverable stale_thread_binding failure for required-preflight (only a genuine post-context-engine request may skip).
  2. Model-locked Codex sessions (modelSelectionLocked: true, the shape persisted for durable Codex sessions) previously returned the recoverable missing/stale-binding failure as terminal: the locked-harness branch in compact.queued.ts short-circuited before the shared fallback. Required preflight is now the one scoped exception — a missing or stale binding falls through to the context-engine fallback while the persisted Codex runtime lock is retained. Non-preflight locked sessions and non-recoverable locked failures are unchanged.

Risk: the fix deliberately changes opted-in Codex preflight behavior from "drop the turn on ownership skip" to "compact natively, fall back to context engine". The fallback path is the existing, already-shipped context-engine compaction; no new compaction code is introduced. Non-Codex harnesses and non-preflight paths are untouched.

User Impact

With a Codex app-server–bound session that crosses the preflight context budget, the user's turn is no longer silently dropped. Codex is asked to compact natively; if its thread binding is missing or stale, the context engine compacts instead and the same turn completes with a model reply. No configuration change; default installs are unaffected (the failure only affected Codex app-server sessions, and the ownership skip itself is intentional Codex behavior — only its misclassification as fatal was the bug).

Evidence

All live evidence captured on PR head 492c4810e45 (Linux x86_64, Node v22.22.3), production modules driven directly via node --import tsx with the plugin-pinned @openai/[email protected] managed package (codex-cli 0.147.0). The two live proof scripts are committed in evidence/119971/ so they are inspectable on the exact head; their redacted terminal output is inlined below.

1. Real Codex app-server, required-preflight recoverable binding fallback (core proof)

evidence/119971/codex-live-binding-race-proof.mts drives the real codex app-server binary (real thread created via stdio transport) through the real maybeCompactCodexAppServerSession with nativeCompactionRequest: "required_preflight". Output:

[live] real codex app-server connected (transport: stdio )
[live] real thread created: 019fdc8d-6f61-7a02-ac21-61973c33dae6
[agent/embedded] codex app-server compaction could not use the thread binding because it changed
[live] required-preflight result after binding change: {"ok":false,"compacted":false,"reason":"codex app-server binding changed before native compaction","failureReason":"stale_thread_binding"}
[live] ✅ PASS: binding change returns a canonical stale-binding failure (not an ok:true skip)
[live] ✅ PASS: recoverability guard accepts the new result (context-engine fallback eligible)
       isRecoverableNativeHarnessBindingFailure=true
[live] ✅ PASS: pre-fix skip shape is NOT recoverable (would have dropped the turn)
       pre-fix ok:true skip bypasses the shared fallback guard

This is the exact gate ClawSweeper asked for: a real after-fix trace showing the required-preflight path reaching the recoverable binding fallback (not the pre-fix ok:true skip that dropped the turn).

2. Model-locked required-preflight session (real codex, locked branch)

evidence/119971/codex-live-locked-preflight-proof.mts drives the real codex app-server with modelSelectionLocked=true, preflightRequired=true, trigger=budget. Output:

[live] real codex app-server connected (transport: stdio )
[live] session shape: modelSelectionLocked=true agentHarnessId=codex preflightRequired=true trigger=budget
[live] ✅ PASS: missing binding returns a canonical recoverable failure
       ok=false compacted=false reason=no codex app-server thread binding failure=missing_thread_binding
[live] ✅ PASS: missing binding is recoverable (context-engine fallback eligible)
       isRecoverableNativeHarnessBindingFailure=true
[live] ✅ PASS: stale binding returns a canonical recoverable failure
       ok=false compacted=false reason=codex app-server binding changed before native compaction failure=stale_thread_binding
[live] ✅ PASS: pre-fix ownership skip is NOT recoverable (old fatal classification)

3. Full-path gateway proof (real gateway + real codex binary + local mock model endpoint)

A full-path driver (available on request — it spawns the real OpenClaw gateway and real codex binary, so it is not committed to the repo) starts the real OpenClaw gateway with the real @openai/[email protected] managed binary pointed at a loopback OpenAI-compatible mock, inflates the transcript past the 128kb byte fuse, and confirms the same user turn still completes a model reply. Output:

[full-path] pinned codex package: @openai/[email protected]
[full-path] managed codex binary version: codex-cli 0.147.0 (exit=0)
[full-path] ✅ baseline turn completed (model reply through gateway)
[full-path] transcript inflated past byte fuse 128kb
[full-path] ✅ final turn completed after required preflight
FULL PATH PROOF DONE

What was not tested: a live credentialed Codex app-server session crossing the preflight budget on a real OpenAI-subscription conversation (requires external Codex subscription/auth). Everything up to the model endpoint is proven on the exact head: real production modules, real codex binary, real binding-change/locked-session races, and a real-gateway oversized-reply completion trace (local mock model endpoint). The preflight compaction log line itself was not captured in the gateway stdout excerpt (the gateway writes compaction logs to its rotating log file, not stdout); the recoverable-binding evidence in items 1–2 is the direct proof that required-preflight reaches the fallback instead of the fatal skip.

4. Regression coverage (exact head 492c481)

$ node scripts/run-vitest.mjs src/agents/embedded-agent-runner/compact.hooks.test.ts --run
      Tests  126 passed (126)
$ node scripts/run-vitest.mjs src/agents/harness/selection.test.ts --run
      Tests  106 passed (106)
$ node scripts/run-vitest.mjs extensions/codex/src/app-server/compact.test.ts --run
      Tests  passed
  • selection.test.ts: required-preflight routes through compactAfterContextEngine with nativeCompactionRequest: "required_preflight"; absent-capability fallback to plain compact hook.
  • compact.test.ts: required-preflight origin recorded on native thread/compact/start; binding change reports canonical recoverable stale_thread_binding failure.
  • compact.hooks.test.ts: model-locked required-preflight recovers via context-engine fallback on missing/stale binding; non-preflight locked and non-recoverable locked failures unchanged.

AI Assistance

  • AI-assisted: Yes
  • Tools: Claude (Sonnet 4.6 / Opus 4.8)
  • Prompts / session excerpts: available on request
  • Confirmed understanding of code changes: Yes
  • autoreview: N/A

Fixes #119971

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: S labels Aug 7, 2026
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. labels Aug 7, 2026
@clawsweeper

clawsweeper Bot commented Aug 7, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 16, 2026, 9:56 AM ET / 13:56 UTC.

ClawSweeper review

What this changes

The PR makes mandatory Codex preflight compaction use a registry-owned native capability and allows context-engine recovery only after a typed missing or stale Codex thread-binding failure.

Regression provenance

Possible regression — probable (reproduction; failure trace; reviewed change). No predecessor PR is attributed.

Merge readiness

⚠️ Needs maintainer review before merge - 3 items remain

Keep this PR open for final maintainer review: current main does not contain the repair, the patch has no discrete source-level defect found, and the new exact-head production-boundary evidence is substantive; however, the required direct Codex dependency-source check cannot be completed because the sibling checkout is unavailable in this read-only environment.

Priority: P1
Reviewed head: 8dbc38443c4de21f64edc949a00fcbc4351a3ade
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The patch and exact-head behavior proof are credible, but final readiness is capped by the unavailable direct dependency-contract inspection.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The latest exact-head receipt drives the production plugin loader, registry capability, binding store, queued compaction entrypoint, and a fault-injected missing-binding recovery to an observed compacted result.
Patch quality 🦐 gold shrimp (3/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The latest exact-head receipt drives the production plugin loader, registry capability, binding store, queued compaction entrypoint, and a fault-injected missing-binding recovery to an observed compacted result.
Evidence reviewed 6 items Current main still needs the repair: The PR head is not an ancestor of checked-out main, so current main does not contain this candidate fix.
Owner-boundary implementation: The PR resolves native compaction only from the exact registered Codex harness and its registry-held callback, rejecting substituted harness objects.
Bounded locked-session fallback: Required preflight reaches context-engine fallback only after the native capability was actually dispatched and returned the existing recoverable binding category.
Findings None None.
Security None None.

How this fits together

Reply preflight compacts an oversized agent session before the next model turn. For Codex-backed sessions, it dispatches Codex app-server compaction and either continues with the compacted thread or uses the existing context engine for a narrowly authorized binding-recovery path.

flowchart LR
  A[Incoming reply turn] --> B[Required preflight]
  B --> C[Selected Codex harness]
  C --> D[Registry-held native capability]
  D --> E[Codex app-server thread]
  E -->|Compacted| F[Continue model turn]
  E -->|Missing or stale binding| G[Context engine recovery]
  G --> F
Loading

Decision needed

Question Recommendation
Can a maintainer with the required sibling Codex checkout verify that the pinned protocol supports this native request and the assumed missing-thread behavior? Verify the pinned Codex contract: Inspect the cited pinned Codex source, then retain this bounded fallback if thread compaction and unknown-thread behavior match the implementation.

Why: The applicable repository policy requires an acting reviewer to inspect the sibling Codex source directly; this environment has no ../codex checkout and cannot create one.

Before merge

  • Resolve merge risk (P1) - Before merge, a maintainer must directly verify the pinned Codex app-server request and missing-thread contract; the required sibling checkout is unavailable in this review environment.
  • Complete next step (P2) - A maintainer must complete the repository-required pinned Codex contract inspection before merge.
Agent review details

Security

None.

PR surface

Source +116, Tests +693, Other 0. Total +809 across 26 files.

View PR surface stats
Area Files Added Removed Net
Source 14 215 99 +116
Tests 9 768 75 +693
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 3 7 7 0
Total 26 990 181 +809

Review metrics

Metric Value Why it matters
Production versus tests production +215/-99; tests +768/-75; tooling +7/-7 The net production growth establishes the registry capability and locked-session authority boundary; the large test delta covers fallback and impersonation controls.

Stored data model

Persistent data-model change detected: database schema: extensions/codex/src/app-server/compact.test.ts. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #119971
Summary: This PR is the candidate fix for the open required-preflight Codex compaction failure.

Members:

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

Merge-risk options

Maintainer options:

  1. Verify protocol before merge (recommended)
    Confirm the pinned Codex app-server compaction and missing-thread contract directly before accepting the recovery path.
  2. Pause the branch
    Do not merge until the required direct dependency inspection is available.

Technical review

Best possible solution:

Retain the registry-held Codex-only capability design, then complete direct inspection of the pinned Codex protocol source before landing.

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

Yes, from source: current main's required-preflight caller reaches ordinary Codex compaction, whose non-manual ownership skip does not satisfy the preflight success condition; the PR supplies exact-head boundary proof for the repaired path.

Is this the best way to solve the issue?

Yes, provisionally: moving authority from a public harness property to registry-held Codex capability state is the narrowest repair that preserves locked-runtime ownership, provided the pinned Codex contract is directly verified.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 51964c1eee30.

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient. The latest exact-head receipt drives the production plugin loader, registry capability, binding store, queued compaction entrypoint, and a fault-injected missing-binding recovery to an observed compacted result.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🐚 platinum hermit and patch quality is 🦐 gold shrimp.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The latest exact-head receipt drives the production plugin loader, registry capability, binding store, queued compaction entrypoint, and a fault-injected missing-binding recovery to an observed compacted result.
  • remove rating: 🦪 silver shellfish: Current PR rating is rating: 🦐 gold shrimp, so this older rating label is no longer current.
  • remove status: 📣 needs proof: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P1: The current broken required-preflight path can drop a Codex-backed user turn.
  • merge-risk: 🚨 compatibility: The PR adds a Plugin SDK registration option and changes compaction behavior for existing Codex sessions.
  • merge-risk: 🚨 session-state: The change controls recovery for oversized sessions whose Codex thread binding is unavailable.
  • merge-risk: 🚨 security-boundary: Context-engine recovery is newly gated by plugin provenance, registry identity, dispatch, and typed failure state.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🐚 platinum hermit and patch quality is 🦐 gold shrimp.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The latest exact-head receipt drives the production plugin loader, registry capability, binding store, queued compaction entrypoint, and a fault-injected missing-binding recovery to an observed compacted result.
  • proof: sufficient: Contributor real behavior proof is sufficient. The latest exact-head receipt drives the production plugin loader, registry capability, binding store, queued compaction entrypoint, and a fault-injected missing-binding recovery to an observed compacted result.

Evidence

What I checked:

  • Current main still needs the repair: The PR head is not an ancestor of checked-out main, so current main does not contain this candidate fix. (src/auto-reply/reply/agent-runner-memory.ts:931, 1f420c26291b)
  • Owner-boundary implementation: The PR resolves native compaction only from the exact registered Codex harness and its registry-held callback, rejecting substituted harness objects. (src/agents/harness/registry.ts:86, 8dbc38443c4d)
  • Bounded locked-session fallback: Required preflight reaches context-engine fallback only after the native capability was actually dispatched and returned the existing recoverable binding category. (src/agents/embedded-agent-runner/compact.queued.ts:608, 8dbc38443c4d)
  • Binding-race producer and tests: The Codex producer returns stale_thread_binding for required-preflight while preserving the post-context-engine skip path; focused tests cover both required-preflight and forged-owner controls. (extensions/codex/src/app-server/compact.ts:674, 8dbc38443c4d)
  • Exact-head behavior proof: The latest maintainer comment reports an exact-head production-boundary fault-injection receipt: the bundled Codex registry capability dispatched, missing_thread_binding reached context-engine compaction once, and a global Codex impostor registered no harness. (src/plugins/registry-registrars-providers.ts:111, 8dbc38443c4d)
  • Dependency-contract gate blocked locally: This Codex app-server change affirmatively depends on the pinned @openai/codex 0.147.0 protocol, but repository policy requires direct sibling ../codex inspection and that checkout is absent; the sandbox cannot clone it. (AGENTS.md:12, 1f420c26291b)

Likely related people:

  • steipete: Merged Codex lifecycle work includes the native compaction producer affected by this PR. (role: recent Codex lifecycle contributor; confidence: high; commits: 45dd558d923c; files: extensions/codex/src/app-server/compact.ts)
  • fuller-stack-dev: Contributed the related merged CLI fallback repair and the current PR's registry-owned repair series. (role: recent compaction-boundary contributor; confidence: high; commits: 81505ada186f, 8dbc38443c4d; files: src/agents/harness/compaction.ts, src/agents/embedded-agent-runner/compact.queued.ts)
  • Jason (Json): Authored the merged CLI Codex overflow/fallback repair that established the related compaction behavior. (role: adjacent prior repair author; confidence: medium; commits: 81505ada186f; files: src/agents/command/cli-compaction.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Verify the pinned Codex app-server protocol from the required sibling checkout before merge.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
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.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (29 earlier review cycles; latest 8 shown)
  • reviewed 2026-08-15T12:05:35.336Z sha 0f057e4 :: needs changes before merge. :: [P1] Reject non-Codex fallback authority for locked sessions
  • reviewed 2026-08-15T13:04:42.819Z sha 96355ed :: needs changes before merge. :: [P1] Require Codex ownership before unlocking fallback
  • reviewed 2026-08-15T13:34:54.088Z sha 96355ed :: needs real behavior proof before merge. :: [P1] Require prepared Codex ownership before permitting fallback
  • reviewed 2026-08-15T15:45:18.581Z sha a881a45 :: needs real behavior proof before merge. :: [P1] Keep fallback authority out of plugin-controlled properties
  • reviewed 2026-08-16T03:35:00.098Z sha 7b33b8c :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-16T11:08:44.345Z sha 1ab7ec1 :: needs real behavior proof before merge. :: [P1] Reject untrusted Codex-id native compaction owners
  • reviewed 2026-08-16T13:25:04.593Z sha 8dbc384 :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-16T13:35:17.469Z sha 8dbc384 :: needs real behavior proof before merge. :: none

@SunnyShu0925
SunnyShu0925 force-pushed the fix/preflight-codex-compaction-119971 branch from 9f5b9b2 to fc3607f Compare August 7, 2026 14:11
@clawsweeper

clawsweeper Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Command router queued. I will update this comment with the next step.

@SunnyShu0925
SunnyShu0925 force-pushed the fix/preflight-codex-compaction-119971 branch from fc3607f to dae1779 Compare August 7, 2026 14:14
@clawsweeper

clawsweeper Bot commented Aug 7, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Aug 7, 2026
@SunnyShu0925
SunnyShu0925 force-pushed the fix/preflight-codex-compaction-119971 branch from dae1779 to 4592ff6 Compare August 8, 2026 02:39
@clawsweeper

clawsweeper Bot commented Aug 8, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Aug 8, 2026
@clawsweeper

clawsweeper Bot commented Aug 8, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Aug 8, 2026
@clawsweeper

clawsweeper Bot commented Aug 8, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Aug 8, 2026
@SunnyShu0925

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Updated evidence: the full-path proof now explicitly pins and logs the managed Codex binary identity — @openai/[email protected] (codex-cli 0.146.1, native vendor @openai/[email protected]), exactly matching the plugin pin. The only 0.147.0-alpha.6.5 codex process on the machine is the pre-existing desktop-app app-server (features.code_mode_host=true), which this proof does not spawn or use; the proof output captures the actual spawned processes. Full output: full-path-proof-output-01461.txt.

@clawsweeper

clawsweeper Bot commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Command router queued. I will update this comment with the next step.

@clawsweeper

clawsweeper Bot commented Aug 16, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@fuller-stack-dev

Copy link
Copy Markdown
Member

Exact-head proof and maintainer decision for 8dbc38443c4de21f64edc949a00fcbc4351a3ade:

Maintainer decision: accept the registry-held, Codex-only native-compaction capability as the permanent owner boundary. The public Plugin SDK registration shape may expose the typed option, but runtime authorization requires bundled provenance or a verified official @openclaw/codex install, exact registry-owned harness identity, actual core dispatch, and a typed missing/stale binding failure before locked-session context-engine recovery. This also accepts the justified +116 production LOC for that capability/ownership boundary; the public fallback-authority and duplicate policy paths were removed or absorbed.

Fresh exact-head Blacksmith Testbox behavior proof passed 329 tests across five Vitest shards:

  • Provider/lease: Blacksmith Testbox tbx_01m05c40803sx1ckkqs3sax1b7
  • Run: https://github.com/openclaw/openclaw/actions/runs/31949891148
  • Command: pnpm test extensions/codex/src/app-server/compact.test.ts src/agents/embedded-agent-runner/compact.hooks.test.ts src/plugins/registry.runtime-config.test.ts src/agents/harness/registry.test.ts src/auto-reply/reply/agent-runner-memory.test.ts extensions/codex/index.test.ts extensions/codex/src/app-server/transport-stdio.test.ts
  • Result: exit 0; 141 compact-hook + 13 harness-registry + 16 runtime-registry + 89 Codex plugin/compact/transport + 70 reply-preflight tests passed. The one-shot lease stopped cleanly after success; the backing Actions step may show cancelled because Blacksmith owns delegated lifecycle.

This exact-head run proves both sides of the final authorization design:

  • Authorized recovery: required-preflight native dispatch records capability use; missing/stale Codex bindings recover through the context engine; the reply preflight caller completes compaction for fresh and upgraded Codex sessions.
  • Rejected ownership: config/global codex impostors, foreign harness owners, copied/substituted registry entries, and forged non-Codex fallback markers remain terminal and cannot acquire recovery authority.
  • Native contract: a real Codex compact request uses thread/compact/start, waits for completion, and preserves configured model_context_window=1000000 plus model_auto_compact_token_limit=700000 unchanged.

Direct Codex 0.147.0 contract inspection was completed at pinned rust-v0.147.0 (be6e8eac029b183056b7e4402879f15d2c85f61b):

  • codex-rs/app-server-protocol/src/protocol/v2/thread.rs:991-998
  • codex-rs/app-server/src/request_processors/thread_processor.rs:1876-1887
  • codex-rs/core/src/session/handlers.rs:815-817
  • codex-rs/app-server/tests/suite/v2/compaction.rs:242-375
  • codex-rs/core/src/session/context_window.rs:23-90

The reported “persistent data-model change” is a false path classification of extensions/codex/src/app-server/compact.test.ts; this PR changes no database schema or persistent store. Post-head canonical movement through 7173aeb6637 was audited: its Codex resource hunk changes only teardown log level, and its trajectory hunk changes warning deduplication; neither invalidates this proof.

Rank-up moves: both requested exact-head behavior branches are now proven, and the restricted SDK/security contract is explicitly accepted above. No agent transcript was inserted.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 16, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@fuller-stack-dev

Copy link
Copy Markdown
Member

Exact-head production-boundary proof is now complete for 8dbc38443c4de21f64edc949a00fcbc4351a3ade.

This is a standalone non-Vitest fault-injection run through the production plugin loader, bundled Codex plugin, registry-held capability, Codex app-server binding store, SQLite session target, prepared runtime generation, queued compaction entrypoint, and a temporary context-engine plugin. It made no provider request and used no live credential.

Observed authorized path:

  • plugin origin bundled, source extensions/codex/index.ts, registry owner codex
  • private native capability present and dispatched
  • real Codex app-server result: missing_thread_binding / no codex app-server thread binding
  • queued production path logged the binding failure and invoked context-engine fallback once
  • fallback received tokenBudget: 1000000, currentTokenCount: 800000
  • terminal result: ok: true, compacted: true, compactionKind: "context-engine", tokensAfter: 120000

Observed forged-owner path in the same process:

  • origin global, source /plugins/impostor/index.js
  • registered harness count remained 0
  • production registry diagnostic: native compaction requires the registry-owned "codex" harness

Raw redacted receipt:

{
  "proof": "pr-120197-production-boundary",
  "head": "8dbc38443c4de21f64edc949a00fcbc4351a3ade",
  "authorized": {
    "pluginOrigin": "bundled",
    "pluginSource": "extensions/codex/index.ts",
    "registryOwner": "codex",
    "nativeCapability": true,
    "injectedFault": "missing_thread_binding",
    "fallbackCalls": [{
      "sessionId": "pr120197-missing-binding",
      "sessionKey": "agent:main:pr120197-missing-binding",
      "tokenBudget": 1000000,
      "currentTokenCount": 800000
    }],
    "result": {
      "ok": true,
      "compacted": true,
      "compactionKind": "context-engine",
      "result": {
        "summary": "production-boundary recovery completed",
        "tokensBefore": 800000,
        "tokensAfter": 120000
      }
    }
  },
  "forgedOwner": {
    "origin": "global",
    "source": "/plugins/impostor/index.js",
    "registeredHarnesses": 0,
    "diagnostic": {
      "level": "error",
      "pluginId": "codex",
      "message": "native compaction requires the registry-owned \"codex\" harness"
    }
  }
}

The repository-required direct sibling Codex inspection was performed by the acting maintainer at pinned rust-v0.147.0 (be6e8eac029b183056b7e4402879f15d2c85f61b):

Both requested rank-up branches are now demonstrated at the real production boundary on the exact final head. The proof harness was temporary, removed after the run, and is not part of the PR tree. No agent transcript was inserted.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 16, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Aug 16, 2026
@fuller-stack-dev

Copy link
Copy Markdown
Member

Merged via squash.

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

Labels

agents Agent runtime and tooling extensions: codex merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. scripts Repository scripts size: XL status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Preflight (budget) compaction treats Codex "owns automatic compaction" no-op as fatal and drops the user's turn

2 participants