Repository navigation
fix(agents): restore manual and preflight native compaction - #157977
Conversation
Carry the original host-issued model authority through compaction and retain it through native completion and cleanup. Preserve caller cancellation, prepared plugin generations, and actual-provider model authorization. Add registered handoff, model-policy, and credential-free native regressions while keeping shipped callback types compatible.
|
🦞👀 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: blocked before merge. Reviewed September 25, 2026, 2:20 PM ET / 18:20 UTC (Revision 14). ClawSweeper reviewWhat this changesThe branch carries caller model authority into manual and preflight compaction for the Codex and Copilot plugins and adds lifecycle and authorization coverage. Merge readiness⛔ Blocked before merge - 1 item remains Keep this PR open for source landing. Native compaction and final provider authorization have focused proof, and CI passed on the pinned head. The earlier plugin API floor finding remains a real publication concern, but the maintainer explicitly limited this source merge to shipping with a capable host and retained the independent-publication requirement. Priority: P1 Review scores
Verification
How this fits togetherGateway requests, chat commands, queued runs, and CLI preflight can ask the agent harness to compact a session. The host selects the runtime and supplies authority; the plugin performs native compaction and returns the outcome to the session owner. flowchart LR
A[Compaction request] --> B[Session and model selection]
B --> C[Host source authority]
C --> D[Codex or Copilot plugin]
D --> E[Native compaction]
E --> F[Provider authorization]
F --> G[Session outcome]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +478, Tests +1589, Docs +12, Other -1. Total +2078 across 47 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Technical reviewBest possible solution: Keep host-issued authority as compaction’s source of truth and enforce model policy at provider I/O; before either changed plugin is independently published, set and verify its minimum capable host version. Do we have a high-confidence way to reproduce the issue? No direct current-main run was performed in this read-only review. Current-main source lacks the handoff, and the PR records a baseline native refusal before provider egress plus passing after-fix native and proxy scenarios. Is this the best way to solve the issue? Yes for source repair: the host supplies existing caller authority to the native compaction owner, which checks it at the final provider boundary. The separately approved release process must enforce the compatible plugin floor. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against cac0c021273a. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (13 earlier review cycles; latest 8 shown)
|
Incorporate the landed Doctor reader/staging-worker assertion repair and current main while preserving the reviewed compaction source-authority fix. Retain the foreground resource settlement test correction from main.
Temporary diagnostic for the config-patch hook timeout on CI 36142271883. Preserve the original assertions and deadlines; record only fixed phase labels and settlement. Remove this trace before landing the compaction repair.
The hosted diagnostic passed all 81 cases with all 146 fixture phase spans settled. Restore the exact pre-diagnostic source tree; no Gateway timeout fix is claimed. The unchanged compaction implementation retains its completed review and attributed proof.
Temporarily classify the hidden wizard retry error and observe callback listener and abort ordering for CI 36161094489. Keep the existing assertions, port reuse, deadlines, and cleanup. Exclude raw errors, URLs, ports, and credentials; remove this diagnostic before landing.
The original 14-file tooling group passed all 881 cases on the hosted Node 24.19 two-worker runner. Restore the exact reviewed pre-diagnostic source tree. The original retry error remains nonreproduced; no authentication repair is claimed.
|
@clawsweeper re-review Please reassess exact head The plugin distribution concern is real if these plugin bytes are independently published with the current floor. This PR is authorized source repair and landing, and does not publish packages or choose a release version. The release requirement is retained in the PR body: both changed plugins must first ship with a host that supplies compaction source authority, and any independent publication must select and verify a compatible host floor first. No mixed-version success or automatic standalone capability check is claimed. The source evidence distinguishes the two publication routes:
I reject choosing an unapproved future release version as a prerequisite for this source merge. That does not waive the documented publication requirement, invent a release-owner acknowledgment, or authorize standalone publication. Please evaluate source-merge readiness on that scope and retain the explicit release follow-up. The separate data-model classification is a false positive: |
|
🦞👀 Re-review progress:
|
|
Merged via squash.
|
…#157977) * fix(agents): restore manual and preflight native compaction Carry the original host-issued model authority through compaction and retain it through native completion and cleanup. Preserve caller cancellation, prepared plugin generations, and actual-provider model authorization. Add registered handoff, model-policy, and credential-free native regressions while keeping shipped callback types compatible. * fix(compaction): preserve cleanup ordering and repair CI contracts * test(compaction): require source retention in Copilot fixture * test(compaction): verify model policy at provider write boundary * test(gateway): trace config fixture hook settlement Temporary diagnostic for the config-patch hook timeout on CI 36142271883. Preserve the original assertions and deadlines; record only fixed phase labels and settlement. Remove this trace before landing the compaction repair. * test(gateway): remove completed config hook diagnostic The hosted diagnostic passed all 81 cases with all 146 fixture phase spans settled. Restore the exact pre-diagnostic source tree; no Gateway timeout fix is claimed. The unchanged compaction implementation retains its completed review and attributed proof. * test(auth): observe SIWC retry setup failures Temporarily classify the hidden wizard retry error and observe callback listener and abort ordering for CI 36161094489. Keep the existing assertions, port reuse, deadlines, and cleanup. Exclude raw errors, URLs, ports, and credentials; remove this diagnostic before landing. * test(auth): remove completed SIWC diagnostic The original 14-file tooling group passed all 881 cases on the hosted Node 24.19 two-worker runner. Restore the exact reviewed pre-diagnostic source tree. The original retry error remains nonreproduced; no authentication repair is claimed.
Follow-up to the b1c68b9 back-merge (c2c131b). Every change here is a consequence of that absorb; the per-hunk journal lives on #1396. Measured baselines (measure, never derive): - config baseline: core 2480 = our +17 continuation surface (base/upstream 2463); channel 3742 and plugin 4349 are upstream's exactly. - plugin SDK surface: 4592 public / 2693 callable = upstream's measured 4580/2688 plus our unchanged +12/+5. Upstream contract adoption: - openclaw#157977: compaction requires host source authority. Both continuation request_compaction callers now pass the requesting run's own admission (command attempt: opts.operatorAuthority; reply turn: followupRun.operatorAuthority), never an undefined System-work source. - TypeScript 7 (native): our AST tests and the continuation guard-callsite script move to typescript/unstable/ast and the native parser owner. The guard script was runtime-broken by the bump; it now pins 22 call sites. - task-flow store: private copies of bind/upsert/read that shadowed the kernel owner (and dropped chain_id on conflict) are removed; the kernel owns them. Semantic test conflicts fixed across registry, maintenance, reply and codex tests (typed ownership results, upstream fixtures, required fields). The reply-path compaction test now asserts the compaction source authority. Known red, deliberately not papered over: volatile-map-allowlist (#1398) — stale since 2026-09-20 on the pre-absorb candidate, needs reviewed entries. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Fq5EX9ESA3CG9cuZxVoKAK
What Problem This Solves
Standalone harness compaction starts a new native turn, but the dispatcher did not carry the caller's host capability or register model-source ownership for that turn. Codex refused inference before provider egress even after an ordinary turn completed successfully.
Core now retains the original caller authority in a compaction admission and passes the existing host capability to the plugin. Codex registers that source with its native monitor, binds the actual compaction turn, and retains authority and resources through terminal completion. Manual Gateway requests,
/compact, queued compaction, and CLI preflight share this handoff.User Impact
Manual and required-preflight compaction can use the caller's existing model authority. Revocation, FIFO ordering, binding checks, and ambiguous-write cleanup remain enforced. A confirmed native result retains precedence over a later caller abort. A monitor first created by compaction also retains clients and parent subscriptions for subsequent child work.
The default callback types and capability version remain source-compatible. Version 2 of the existing compaction parameter types requires the capability; the default preserves the legacy source shape. No SDK export names are added. An older host omitting the capability receives an actionable refusal before native work; omitted authority never becomes System authority. This is a runtime compatibility requirement for independently installed plugins, described below. There is no new configuration, permission, schema, durable store, or update migration.
Why This Change Was Made
The host owns source authority and prepared plugin generation; plugins consume the existing capability. The repair reuses the native monitor, per-thread queue, binding lease, and asynchronous resource owner. Native aliases require matching host-prepared provider/model evidence and the actual inference request tuple. Persisted model names cannot grant another provider's permissions.
Evidence
Both temporary diagnostics are removed in
91382d08. Its complete source tree exactly matches pre-diagnostic headb9d8895a; the compaction implementation and prior review inputs are unchanged. The bounded investigations did not establish a Gateway or authentication fix. Fresh ordinary CI 36168978713 passed on exact restored head91382d08925ea6681d823117a6c9237e6b0fdce3. The native maintainer workflow merged this exact head as34ddb38956688e338123978753559e7990bc067e; the publication restriction below remains.Compaction refresh
b9d8895amerges maine2d2e9fd, including the Doctor reader/staging-worker assertion fix. The compaction repair is unchanged; current-main validation and foreground-resource test improvements are retained. Evidence below remains attributed to the exact revisions that ran it. The first CI on this merged head stopped in the Gateway config-test hook described below; the later restored-head CI passed before landing.9074e048merged with mainf0eae1f5. It failed on immutable-parameter/unbound-method lint, native-fixture typing, a hooks fixture import cycle and stale options expectation, strict fixture teardown, and a hosted-tail planner assertion. Native cancellation passed all five cases. Other test and static-check results are being reconciled; unrun groups are not passes.runtimeModelassertion while addingsourceAuthorityto its expected options. Successful fixture teardown now joins normal retained release: the resource owner can return a logical result before its final cleanup. Failed or unfinished tests still cancel and drain owned fake turns; a predecessor gate releases infinallyso assertion failures cannot strand later cases.449fc2e6). The old assertion counted dist jobs against the 70-Node limit; the correction checks 70 Node jobs and 90 total jobs separately, preserving both limits. No budget is raised here. Attribution is based on source and the owning fix's CI; no pure-base replay is claimed.898dfd78.d874a364, including full declarations and CLI/session checks. Subsequent changes affect test fixtures only. The exact-base SDK API comparison is now complete; fresh overall PR CI remains required after incorporating the owning Doctor test fix.beforeRequestcallback and requires rejection before writing. Only the final provider transport is mocked. This stronger test-only delta passed independent P0–P2 review and CI job 108006941511. The two denied-provider rows passed in 74/14 ms, the alias row in 30 ms, and original-source revocation in 28 ms. Their assertions require HTTP 403 and zero final writes for both denied models and the revoked source; the allowed alias makes one write. The exact test file matches both published head46a6c71aand tested merge8c9e9d8c(base34e8976aplus that head). The shared group passed 245 cases across 11 files in 99.20 s Vitest / 101.07 s wrapper time. The stock-native sibling also passed in 5.253 s with its setup host closed, compaction completed, and native process exited. This is real proxy/authority proof with a synthetic final transport, not authenticated provider-service proof.doctor-config-preflight.pending-read.test.ts:89): one child expected, two observed. That sequential group passed 299 cases and failed 1; later packed groups did not run. The unchanged test is now corrected on main by fix(doctor): finish state migration after legacy install repair #145043 (d069a6cf): it requires one reused reader while separately checking balanced staging-worker requests and clean closure of every child. The owning repair observed those roles on Linux and passed 312 cases in its original 21-file cohort, then exact-head CI 36121989679. Its pre-fix test bytes match this failure. This supports incorporating the owning fix; it is not a reproduction of this PR’s exact failing merge. Fresh PR CI remains required.691d2e5cto46a6c71acompleted in 333.95 seconds on isolated Linux with Node 24.19.0 and pnpm 12.4.2. No SDK entrypoints or exports were added or removed. Two compaction type aliases gain an opt-in version parameter; the default preserves existing callback shapes. The 121 other affected exports retain identical top-level declarations; their report changes come from reachable internal declarations and declaration-emission ordering. Root and an independent source audit inspected the full report (digest2d0a208b9c00ed867134f75cf994cf2b7287092de3c3c2aaf797732687ca3fb1). This confirms the declaration scope; the independent-plugin runtime requirement below remains. Source stayed unchanged, child processes joined, temporary worktrees were removed, and the Testbox lease completed.dd8d95be(headb9d8895aplus basedcc9fb95). Itschecks-node-changed-compact-small-1group contained onlyserver.config-patch.test.ts: six cases passed, then the approved include-only operation case hit the existing 180-second hook timeout. The runner later stopped the stalled process after 300 seconds without output; subsequent work was skipped or cancelled. The test, its Gateway fixture, and the inspected reload/close owners are unchanged from that base. No causal link to compaction has been established, and the log does not distinguish startup from teardown. The bounded observation below did not reproduce the timeout. No deadline, assertion, or required gate has been weakened; the original failed CI remains part of the evidence.dd8d95bepassed 81/81 cases, including the original stalled case. All 448 phase events balanced: 26 startup settlements, client stops, Gateway closes, state cleanups, and reloader shutdowns completed. The unchanged test file ran in its original order with Node 24.19.0, pnpm 12.4.2, two workers, the original deadlines, and a freshqaRuntime/compiled-worker build after the private observer was applied. Vitest took 157.32 s; the complete shard command took 211.38 s including preparation. The Testbox had 16.55 GB RAM and four physical CPUs restricted to two available CPUs; original CI had 8.22 GB RAM and two CPUs, so this is not an identical hardware reproduction. The observer was removed, source restoration and child settlement were verified, the temporary worktree was removed, and the lease completed. No Gateway timeout fix is claimed.49fd7963(trace head1efc76bdplus main8c5b7c2a) on Node 24.19.0 with the original two CPUs and 8.22 GB RAM. The full file passed 81/81 cases in 161.11 s Vitest time, with all 146 fixture spans settled, including 26 complete startup, client-stop, Gateway-close, and state-cleanup cycles. No stalled phase reproduced and no Gateway fix is claimed. The trace was removed once this targeted diagnostic completed; unfinished jobs in that temporary run are not claimed as passes. Source restoration passed formatting/diff checks and exactly restored the reviewed tree; the unchanged compaction review is reused, not represented as newly rerun.63058e1a(headf9748599plus main43759b18). Its originating failure was intest/provider-auth-method.openai-siwc.integration.test.ts:79: after the expired sign-in flow settled, the retry returneddone: true, status: errorinstead of a pending authorization note. The original 14-file tooling group passed 880 cases and failed this one; the next packed group did not run, and remaining CI was cancelled. This is distinct from the Gateway hook diagnostic. The bounded investigation below did not reproduce this failure; no cause, compaction attribution, or successful repair is claimed.c6bd8676(temporary head40b26416plus maine124d77e) with the exact original 14-file manifest, Node 24.19.0, two workers, and 8.22 GB RAM. All 881 cases passed in 194.82 s, including the retry case in 132 ms; the following packed file also passed its five cases. The failure did not reproduce, so the failure-only context yielded no new error classification. The diagnostic was removed after that target completed, restoring the exact reviewed source tree. No retry, deadline, assertion, or required gate was weakened, and no authentication repair is claimed.The native regression uses the managed Codex binary with a synthetic final Responses endpoint and no API credentials. Core selection and the isolated client factory are fixture inputs; this is not authenticated live-provider proof.
Related: #140630. This repair does not establish that separate framing proposal's behavioral claims.
Compatibility scope
The new
memory-flush-errors.tsfile is an exact extraction of four error-formatting/filtering helpers and their existing limits. It has no vector/embedding data, storage access, schema, retention, or migration behavior. This patch changes no updater, Doctor, service, plugin-loading implementation, package dependencies, or stored-data contract; a full published-updater campaign is not warranted by that filename-based classification. No installed mixed-version success is claimed.Published OpenClaw v2026.9.6 does not pass the required compaction capability, while both source manifests still declare
pluginApi >=2026.9.6. Independently packaging these new plugin bytes with that old floor would allow installation and then refuse compaction. No regression in the already-published v2026.9.6 artifacts is claimed. These plugin changes must ship with the first host release containing the handoff: the maintained release preparation and generated-artifact gate raise lower official plugin API floors to that approved host version (scripts/sync-plugin-versions.ts,scripts/release-preflight.mts, anddocs/plugins/manifest/package-json.md). Supported plugin-only publication has its own approval and does not run that synchronization; it requires a separately approved compatible host floor before publication. This source PR chooses no release version and authorizes no independent plugin publication.