Repository navigation
feat(audit): record admitted model routing decisions - #129092
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
@clawsweeper review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Codex review: needs maintainer review before merge. Reviewed August 25, 2026, 10:40 PM ET / August 26, 2026, 02:40 UTC. ClawSweeper reviewWhat this changesAdds private, pseudonymized audit receipts for admitted model-routing attempts and carries fallback provenance through CLI and embedded agent execution. Merge readinessNo concrete defect was found in the current head, including the prior FIFO-boundary concern. This protected maintainer audit/security change should remain open for human review and an exact-head rebase/check refresh. Priority: P2 Review scores
Verification
Live VerificationCommand: Result: FAIL (failed) — step 1 Assertions:
How this fits togetherThe agent fallback loop selects an attempted model route, then dispatches it through the CLI or embedded runtime. The new audit path sends bounded private routing references through the existing writer, which persists only HMAC pseudonyms and generic receipts. flowchart LR
A[Requested model route] --> B[Fallback selection]
B --> C[Admitted agent attempt]
C --> D[CLI or embedded dispatch]
C --> E[Bounded private audit work]
E --> F[Audit FIFO writer]
F --> G[Pseudonymized decision record]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +556, Tests +1130. Total +1686 across 62 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep routing facts private, bounded, and HMAC-projected through the single audit writer, then land only after a current-base review confirms that boundary. Do we have a high-confidence way to reproduce the issue? Not applicable: this PR adds an opt-in audit capability rather than repairing a reported current-main failure; focused source tests cover its queue, persistence, and lifecycle boundaries. Is this the best way to solve the issue? Unclear: the owner-boundary design is coherent and the previous queue-boundary finding is fixed, but final approval needs a current-base maintainer review of the private audit scope. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against a9303f27e982. LabelsLabel changes:
Label 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 (13 earlier review cycles; latest 8 shown)
|
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
c465155 to
2feda83
Compare
…lear case Upstream openclaw#129092 added a third routing-provenance argument to the model fallback runner and updated every fixture in this file. The auth-boundary clear case added by this PR still called params.run with two arguments, so merging with main failed check-test-types-core-4 (TS2554) and, because the mock never forwarded the attempt options, the clear never ran and checks-node-compact-large-20 saw the stale binding survive.
* feat(audit): record admitted model routing decisions * fix(audit): preserve fallback route provenance * test(audit): align execution routing fixtures * fix(audit): revalidate routing receipt admission * fix(audit): retain exact model fallback reason * test(agents): pass fallback routing provenance * test(agents): complete fallback provenance fixtures * test(agents): repair fallback runner fixtures * fix(audit): fence CLI routing receipts * test(agents): update embedded provider runtime mock * fix(audit): bound private work before enqueue
What Problem This Solves
Execution audit lacked a restart-stable, privacy-preserving private record and generic selector for each actual admitted model-routing attempt, forcing the audit owner to rely on transient execution state.
Why This Change Was Made
Records one private, restart-stable decision receipt for each actual admitted model-routing attempt through the existing installation-local FIFO/HMAC owner. The original requested route, selected route, fallback stage, and exact preceding reason are carried from the fallback owner; skipped/cooldown/exhausted non-runs remain structured routing outcomes outside run audit. Raw credential/profile references are never persisted or displayed.
The exact-head review found a lifecycle race in the embedded producer: asynchronous attempt preparation could outlive closure, cancellation, same-run replacement, or lifecycle rotation, while the subsequent receipt enqueue relied only on the immutable correlation token. The fix captures the canonical exact admitted-run active assertion before preparation awaits and revalidates it immediately before the FIFO enqueue. Invalid authority fails closed, queues no routing work, and never reaches provider dispatch.
User Impact
With execution audit collection enabled, operators get durable generic selectors for actual model-routing attempts across Gateway and direct-local flows. Defaults, public protocol/config, SQLite schema/version, and disabled-collection behavior are unchanged.
Evidence
Maintainer display-boundary decision
The exact-head review asked whether to expose requested/selected routes and fallback details through an owner-allowlisted public
audit.run.inspectdisplay. The explicit maintainer decision is to keep C01 private and generic: these remain private audit records with generic selectors, and the supported inspection surface does not reveal route, credential-profile, or fallback details. No new safe-display producer or protocol surface is authorized. The review finding is therefore dispositioned as an intentional product/security boundary, not missing implementation.Pre-fixture Ready-CI candidate
548d3405f98acf27c8f2d671c57f17b4e3f47c3c3e6c8c92a40a62d59e98fcfebe86c7641460f1b20db53169d1b82409697e78214914f6d5c2bd1586git diff --binary --full-index HEAD^ HEAD):480e12ec723f8ea54edd17c6a45117f90b55daf356d9436dcdfc7dcc8968ca3704cc43d896f28bd456c7b25ea8f0988e97d7628ac0d429e737212e7882e8863eExact fallback-cause correction
FailoverReason, butmodel-routing-decision.tsreduced every cause tomodel_route_selected_after_fallback.rate_limitand embedded expectedoverloaded; both received the same generic marker.decision.reasonCodenow stores only the closedFailoverReason. A separate runtime fallback diagnostic remains an arbitrary private string only for generic fallback detection and can never populate the receipt.+9/-8(net+1), tests+4/-4. The one production line is the explicit closed-cause versus arbitrary-diagnostic boundary; no public/protocol/config/schema field changed.check:changeditself is not called green: after printing the successful max-lines verdict, its pnpm wrapper remained alive and was stopped with exit 130; every selected attributable owner ran directly and passed.Lifecycle regression
admitted run authority is no longer active, queue zero routing decision work, and make zero provider dispatch calls.Gates and review
node scripts/check-changed.mjs --staged --timedwas not reported green: after the max-lines check printed its successful verdict (max-lines ratchet OK: 897 grandfathered suppressions), that child remained alive and the aggregate was stopped, exiting 130. Every selected attributable gate was then executed directly and passed.Production versus tests
+12/-1(net+11).+101/-3(net+98).Existing clean-environment and dependency evidence
tbx_01m0vtxngzjee3k7xxydxp5vjc— https://github.com/openclaw/openclaw/actions/runs/32818703404../codex/codex-rs/app-server-protocol/src/protocol/v2/thread.rs:59(provider fallback is opt-in/default false), plus distinct resume/fork contracts at:332and:516.f1087ffinspected incodex-rs/core/src/tasks/mod.rs,codex-rs/core/src/state/turn.rs,codex-rs/core/src/session/mod.rs, andcodex-rs/app-server/src/thread_state.rs: cancellation/replacement is bound to the exact live task/turn and lifecycle generation, not a reusable correlation token.No Agent Transcript section is included because user consent was not provided.
Ready-CI test-fixture correction
548d3405f98acf27c8f2d671c57f17b4e3f47c3c.initial, orfallbackwith the fake owner's exact closedFailoverReason. No production, public protocol, config, schema, or display-boundary byte changed.check-changedgreen, including core-test type shards, type-aware changed-file lint, formatter, max-lines/assertion ratchets, dead-export scan, and zero staged temp-directory warnings. Ordinary autoreview clean in one pass at 0.99 confidence; TruffleHog clean.+0/-0. Tests/test support:+200/-72.b43658a8c13acfdb1f78af1d09984dc810637c1f548d3405f98acf27c8f2d671c57f17b4e3f47c3c025f8a9b4edbef555d1eee2d7892397c0a467c01875a97ebf2d438089ce4db390c60579aaf03711b7437bae11d094ff95b25af24f2b04680a07467a20ead18d095f19655392e70e4Final test-fixture correction (2026-08-25)
38e7641245dfc71fb37fab3ffce7904520e71323527bf86371148b9f8176aea4), 97764077095 (b8e18feb22485839052da597246694372eef06beaee194875e823167360a01be), and 97764077147 (957f7056e44bb4991a6e55bc1afc19b64b7428d41b794127add6f3befcf6bb17) exposed stale test-only fallback owners that omitted required admitted-attempt routing provenance.FailoverReason; the shared test contract rejects new two-argument fakes. Production/protocol/config/schema bytes are unchanged.check:changedsubstantive lanes including all core-test type shards; formatter, type-aware lint, diff and ratchets. The staged aggregate wrapper was stopped after a post-verdict hang even though its max-lines ratchet had printed green; direct selected gates pass. Ordinary autoreview: clean (0.99); TruffleHog: clean.0c478268359b04fb64099ad3f9f198bb5062cf92; tree02ef08ac7c76fe11e77efe733baf1b0c55b9c30a; parentb43658a8c13acfdb1f78af1d09984dc810637c1f; binary patch SHA-256106210d569f3f27802cb01b40c6251d97dc0d0e031c3d6751265b8e2a75a5300; full-index binary patch SHA-25685a96b773a6bf5a60b927c229d814ba9a3e1939990d6eef7b781c49917016af2; stable patch-idbce35e7c892653f1846e3d9f4227166bb629609b; production+0/-0, tests/test-support+360/-170.@clawsweeper re-reviewrequest. The durable review is under 12 hours old, its findings are resolved, and this head changes only test/test-support fixtures for exact CI findings—no product behavior—so root review policy treats the existing review as covering this mechanical correction. The private generic retention/display-boundary decision above remains unchanged.Exhaustive fake fallback-runner fixture correction (2026-08-25)
checks-node-compact-small-15) produced 75 auto-reply failures (71 misc, 4 media); retained log SHA-25631f57fce8f9afcdeed081b5712cfa88cee5a45319b26de2b7017f0e410a40acf. The two 120s waits were cascades after the stale fake owner threw before candidate settlement.ModelFallbackRunOptions; test fakes bypassed that owner. One typed test-support helper now constructs exact requested-route initial provenance or fallback provenance with the fixture-owned closedFailoverReason. Source audit found 42 equivalent two-argument calls in the authorized ten files (one more than the initial 41-count); all 42 are repaired and static rejection finds zero remaining equivalent calls or fake signatures.78384fb7546158646844e73a7a10e52150e5b37c30f752a22f61af4faa3427e6; five relevant nonincremental type shards; static rejection SHA-256148ea5f02ed6d499e061b9da1040ad89733f9eb380ba2bfd8dfcef7cb5ca4237; formatter, type-aware lint, diff and direct ratchets green. The staged aggregatecheck:changedwrapper was stopped after recurring post-verdict silence even though max-lines printed green; no retry masked it. Ordinary autoreview clean (0.99), TruffleHog clean; review log SHA-2560cb8fde8b92afab4166739b76273861c47b743c8d72e70fe4cba8d4dc81f4b18.ac2b76e03c8f22ad50e3286ad7bdee574aca1be8; tree6f812d30d0feb61674020fd092adbc5800984fde; parent0c478268359b04fb64099ad3f9f198bb5062cf92; binary patch SHA-2568e5731b55b559b229b947c43061a0071ee124e7be707abf7604ce6cdfb1903f1; full-index binary patch SHA-256ab54d299fc5b6bdc1178d899a843280c2fe4e67c82ba86cf9a38c2c591a52e54; stable patch-idec6588b7f6b7b1aad642a761d3e9aa8759fce97e; production+0/-0, tests/test-support+357/-320.@clawsweeper re-review; the current clean review is under 12 hours old and this correction changes no product behavior bytes. The existing private generic retention/display-boundary decision remains unchanged.Exact-head CLI live-authority correction (c465155)
recordAdmittedModelRoutingDecisionnow accepts the live admitted-run context plus abort signal, resolves the canonical active assertion, and revalidates immediately beside the FIFO enqueue. Both CLI producers and the embedded producer use that owner; the duplicate embedded caller fence was deleted. No public/config/schema/protocol surface changed.fa57fbae41e26d4e9aa4f671fab62957b110556e1f0eeca4e0969ad7523bcc83.bc49621c250abf76c0e77aa2cfec573874780785bb8914f4a86cccdd05d45332); exact-byte focused lifecycle/fallback suite 36/36 (570a599efd82fde48c7e1ebb20f6bcbfe9cda5c43c4b53f69c1279c3ac7c2687); core production typecheck, complete nonincremental core-test type shards, formatter, type-aware lint, schema/storage/import/auth ratchets, and diff check passed. Aggregatecheck:changedselected the expected core lanes and printed the max-lines verdict, then hung after verdict; it was stopped and is not represented as green (89ce70facc9061fd30bf357b64da7ff403bb0b4f9b28a8fbd853a25a45569e32). Direct selected gates supplied the attributable verdicts.a2ccda5b32af66d331811e863a53893e4c457418e999e950cbf63e986124380e. Private generic retention/display-boundary decision remains unchanged; no raw refs or Agent Transcript added.c465155ae6b6cbcab130e054afc51c7058c457f9; tree5c9cb96dd5246f00ca3cff7b38e435e72c2177af; parentac2b76e03c8f22ad50e3286ad7bdee574aca1be8; binary full-index patch SHA-2568182ed92ac8b52119a06a55eca750e3e3f742b9c4236be3aec746b46ecca2999; stable patch-id5de15e74ec7e82404953c4d2b760bb56129d2304.codex-rs/core/src/tasks/mod.rs:279-288,390-410,494-522,codex-rs/core/src/state/turn.rs:74-84,codex-rs/core/src/session/mod.rs:2236-2245,4088-4094, andcodex-rs/app-server/src/request_processors/thread_lifecycle.rs:217-305,420-449confirm closure/replacement authority is exact-instance and cancellation-bound, not bearer-token authority.Campaign scope decision
f1087ff151b06e781ecb086068d45fcc62d02da3, including the active-turn/task cancellation and terminal interruption owners cited above. That direct source inspection is the accepted contract evidence for this campaign.Frozen-main reconciliation (2026-08-25)
6b5b75aa01942a23ac3bd1e6d8dc7274a8f0c4a9; its full CI run 32911227450 is green. No later moving-main observation was used.+0/-0); test support is+1/-0.tbx_01m0xtjjt7029p3zradwwpafsg, run 32918726450, exact candidate tree custody before/after,check:changedgreen in 18m24s. This includes core and all core-test type shards, type-aware lint, formatter, dead-export/import-cycle/schema/storage/auth guards, and max-lines/assertion/dependency/plugin ratchets.2feda8335e03bd5184971fa3eac3d599fbf839e9; tree1b3d8b628ce401a081df85a45b4faa753a85e023; parentdcde2ae8b048faff5051db24f7f6f69f3f26bd87; frozen-base full-index binary patch SHA-25669ee42021af71c8c37a74b69c62a20edba73894751eb0e32ee45a0a10f4b1755.f1087ff151b06e781ecb086068d45fcc62d02da3:codex-rs/core/src/tasks/mod.rs:279-288,311-431,494-522,codex-rs/core/src/state/turn.rs:74-84,codex-rs/core/src/session/mod.rs:2236-2245,4088-4094, andcodex-rs/app-server/src/request_processors/thread_lifecycle.rs:217-305,420-449.FIFO pre-clone bounds correction (2026-08-25)
2feda8335e03: both a 4,097-character raw ref and a valid-shaped envelope over 16 KiB returnedtrueat the writer boundary; the regression failed 2/4 tests for that exact reason.parseExecutionDecisionWorkat FIFO acceptance immediately beforestructuredClone; asynchronous processing still revalidates the cloned work. No producer guard, schema, protocol, config, persistence, or display change was added.tbx_01m0xy7f6ywcjqckb4tm7t9h37, run 32922715878, stopped before tests after targeted sync and the automatic full-sync fallback both missed their completion markers. No proof result is claimed from that infrastructure attempt. Hosted exact-head CI owns fresh dependency/type validation.+8/-3(net+5), tests+41/-1. The production growth exports and calls the existing canonical parser at its missing acceptance boundary.998e896ebdbc501261083f749def44b7470f7bce; tree1e24594478bdcc847d2e079f4e1bffdaa66c42ce.f1087ff:codex-rs/app-server/src/request_processors/turn_processor.rs:1446-1508rejects missing/mismatched active turns and defers success toTurnAborted;codex-rs/core/src/tasks/mod.rs:494-522cancels the exact active task before clearing pending work.