Skip to content

feat(audit): record admitted model routing decisions - #129092

Merged
joshavant merged 11 commits into
mainfrom
codex/agent-id-p0-model-credential-selection
Aug 26, 2026
Merged

joshavant merged 11 commits into
mainfrom
codex/agent-id-p0-model-credential-selection

Conversation

@joshavant

@joshavant joshavant commented Aug 25, 2026 •

Copy link
Copy Markdown
Collaborator

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.inspect display. 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

  • Head: 548d3405f98acf27c8f2d671c57f17b4e3f47c3c
  • Parent/reviewed P2 head: 3e6c8c92a40a62d59e98fcfebe86c7641460f1b2
  • Tree: 0db53169d1b82409697e78214914f6d5c2bd1586
  • Correction patch SHA-256 (git diff --binary --full-index HEAD^ HEAD): 480e12ec723f8ea54edd17c6a45117f90b55daf356d9436dcdfc7dcc8968ca37
  • Frozen-base-to-head patch SHA-256: 04cc43d896f28bd456c7b25ea8f0988e97d7628ac0d429e737212e7882e8863e

Exact fallback-cause correction

  • Root cause: the fallback owner carried the canonical closed FailoverReason, but model-routing-decision.ts reduced every cause to model_route_selected_after_fallback.
  • Fail-before on parent production bytes: CLI expected rate_limit and embedded expected overloaded; both received the same generic marker.
  • Pass on this head: CLI 113/113, embedded fallback 20/20, and routing owner 2/2; the later producer-boundary adjustment reran 27/27 embedded/fault-sequence tests, including closure and replacement zero-receipt fences.
  • The durable decision.reasonCode now stores only the closed FailoverReason. A separate runtime fallback diagnostic remains an arbitrary private string only for generic fallback detection and can never populate the receipt.
  • Correction LOC: production +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.
  • Full proportional proof: 545/545 changed-owner tests, production and all core-test type shards, formatter, type-aware lint, direct selected ratchets, exact-staged autoreview clean at 0.98 confidence, and TruffleHog clean. The aggregate check:changed itself 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

  • Fail-before against parent production bytes: both regressions completed provider dispatch instead of rejecting when the admission was closed or replaced during awaited preparation.
  • Pass on this head: closure and same-run replacement both reject with admitted run authority is no longer active, queue zero routing decision work, and make zero provider dispatch calls.
  • Focused lifecycle/fallback/admission/registry proof: 40 tests passed.
  • Full changed-owner proof: 545 tests passed across seven Vitest shards, including the real 20-case embedded fallback E2E and both lifecycle regressions.

Gates and review

  • Core and all core-test TypeScript shards passed.
  • Selected formatter, type-aware lint, conflict, assertion, dependency-pin, plugin-boundary, schema-version, database-first, dead-export, import-cycle, sidecar, auth-order, and related changed-path ratchets passed directly.
  • node scripts/check-changed.mjs --staged --timed was 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.
  • Exact-staged ordinary autoreview: no findings, patch correct, confidence 0.98.
  • TruffleHog: clean.
  • Test-audit closure: the regressions exercise real awaited preparation at the embedded owner boundary, failed on the pre-fix production bytes for the intended dispatch race, add no test-only production seam, and protect observable zero-enqueue/zero-dispatch behavior.

Production versus tests

  • P2 correction production: +12/-1 (net +11).
  • P2 correction tests: +101/-3 (net +98).
  • The positive production delta is the canonical active-assertion import, exact pre-await assertion capture, and the explicit token-bearing fail-closed validation immediately before enqueue. The token can remain present after authority closes, so the token-without-live-assertion branch cannot safely be removed or collapsed into an optional receipt object.

Existing clean-environment and dependency evidence

  • Clean Blacksmith Testbox: tbx_01m0vtxngzjee3k7xxydxp5vjc — https://github.com/openclaw/openclaw/actions/runs/32818703404
  • Testbox passed exact branch/head/tree custody, frozen install, full private build, core/src typechecks, restart-stable FIFO/HMAC proof, Gateway/direct-local lifecycle proof, CLI producer/handoff tests, and the real embedded fallback E2E (20/20), then POST custody.
  • Prior focused local owner suite: 438/438; exact-staged autoreview and TruffleHog clean.
  • Direct Codex contract inspected at ../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 :332 and :516.
  • Exact Codex lifecycle source at f1087ff inspected in codex-rs/core/src/tasks/mod.rs, codex-rs/core/src/state/turn.rs, codex-rs/core/src/session/mod.rs, and codex-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

  • Root cause: five fake fallback owners/test-support fixtures bypassed the canonical outer fallback owner and invoked the admitted run callback without the required typed model-routing provenance. Production callers remain owner-complete and unchanged.
  • Fail-before: compact-large-14 job 97748138419 reproduced 6/11 prepared-harness failures settling to the generic dispatcher error; compact-large-16 job 97748138596 reproduced 101/126 live-model-switch failures at the fail-closed provenance invariant. The same failures reproduced locally on parent head 548d3405f98acf27c8f2d671c57f17b4e3f47c3c.
  • Fix: simulated admitted attempts now carry requested provider/model plus explicit initial, or fallback with the fake owner's exact closed FailoverReason. No production, public protocol, config, schema, or display-boundary byte changed.
  • Pass: original prepared-harness regression 11/11; original live-model-switch regression 126/126; embedded run-entry owner 20/20; complete affected embedded overflow group 16/16; complete affected compact-large-16 agent group 310/310.
  • Gates: exact-staged check-changed green, 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.
  • Test-audit: preserves behavior-level owner tests, adds no production seam, and rejects every two-argument fake fallback invocation in the five authorized surfaces. The compaction fixture is five lines smaller than its parent after removing a one-use transcript mapper.
  • Production LOC: +0/-0. Tests/test support: +200/-72.
  • Head: b43658a8c13acfdb1f78af1d09984dc810637c1f
  • Parent: 548d3405f98acf27c8f2d671c57f17b4e3f47c3c
  • Tree: 025f8a9b4edbef555d1eee2d7892397c0a467c01
  • Correction binary patch SHA-256: 875a97ebf2d438089ce4db390c60579aaf03711b7437bae11d094ff95b25af24
  • Stable patch-id: f2b04680a07467a20ead18d095f19655392e70e4

Final test-fixture correction (2026-08-25)

  • Fail-before custody: jobs 97764077042 (38e7641245dfc71fb37fab3ffce7904520e71323527bf86371148b9f8176aea4), 97764077095 (b8e18feb22485839052da597246694372eef06beaee194875e823167360a01be), and 97764077147 (957f7056e44bb4991a6e55bc1afc19b64b7428d41b794127add6f3befcf6bb17) exposed stale test-only fallback owners that omitted required admitted-attempt routing provenance.
  • Repair: every equivalent fake owner now passes canonical typed initial/fallback provenance, including the fake owner’s exact preceding closed FailoverReason; the shared test contract rejects new two-argument fakes. Production/protocol/config/schema bytes are unchanged.
  • Proof: 258/258 changed-owner tests; non-incremental messaging and agents-root type shards; frozen-base check:changed substantive 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.
  • Candidate: head 0c478268359b04fb64099ad3f9f198bb5062cf92; tree 02ef08ac7c76fe11e77efe733baf1b0c55b9c30a; parent b43658a8c13acfdb1f78af1d09984dc810637c1f; binary patch SHA-256 106210d569f3f27802cb01b40c6251d97dc0d0e031c3d6751265b8e2a75a5300; full-index binary patch SHA-256 85a96b773a6bf5a60b927c229d814ba9a3e1939990d6eef7b781c49917016af2; stable patch-id bce35e7c892653f1846e3d9f4227166bb629609b; production +0/-0, tests/test-support +360/-170.
  • Review disposition: no additional @clawsweeper re-review request. 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)

  • Fail-before: Ready CI job 97777247729 (checks-node-compact-small-15) produced 75 auto-reply failures (71 misc, 4 media); retained log SHA-256 31f57fce8f9afcdeed081b5712cfa88cee5a45319b26de2b7017f0e410a40acf. The two 120s waits were cascades after the stale fake owner threw before candidate settlement.
  • Root cause/fix: production always supplies required 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 closed FailoverReason. 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.
  • Proof: 620/620 focused and sibling tests across four shards (52 unit-fast, 95 cron, 316 auto-reply, 157 E2E), SHA-256 78384fb7546158646844e73a7a10e52150e5b37c30f752a22f61af4faa3427e6; five relevant nonincremental type shards; static rejection SHA-256 148ea5f02ed6d499e061b9da1040ad89733f9eb380ba2bfd8dfcef7cb5ca4237; formatter, type-aware lint, diff and direct ratchets green. The staged aggregate check:changed wrapper 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-256 0cb8fde8b92afab4166739b76273861c47b743c8d72e70fe4cba8d4dc81f4b18.
  • Candidate: head ac2b76e03c8f22ad50e3286ad7bdee574aca1be8; tree 6f812d30d0feb61674020fd092adbc5800984fde; parent 0c478268359b04fb64099ad3f9f198bb5062cf92; binary patch SHA-256 8e5731b55b559b229b947c43061a0071ee124e7be707abf7604ce6cdfb1903f1; full-index binary patch SHA-256 ab54d299fc5b6bdc1178d899a843280c2fe4e67c82ba86cf9a38c2c591a52e54; stable patch-id ec6588b7f6b7b1aad642a761d3e9aa8759fce97e; production +0/-0, tests/test-support +357/-320.
  • Review disposition: no additional @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)

  • Root cause: both CLI model-routing receipt producers awaited admission preparation, then queued private routing work with correlation facts after the exact admitted operational instance could close or be replaced. The immutable token was not authority.
  • Canonical repair: recordAdmittedModelRoutingDecision now 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.
  • Fail-before: real admission/caller tests covered normal + side-question producers × close + same-run replacement. Pre-fix all 4 cases wrongly enqueued one receipt and dispatched once; log SHA-256 fa57fbae41e26d4e9aa4f671fab62957b110556e1f0eeca4e0969ad7523bcc83.
  • Passing proof: wider affected suite 253/253 (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. Aggregate check:changed selected 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.
  • Review/privacy: ordinary autoreview clean (0.97) and TruffleHog clean; log SHA-256 a2ccda5b32af66d331811e863a53893e4c457418e999e950cbf63e986124380e. Private generic retention/display-boundary decision remains unchanged; no raw refs or Agent Transcript added.
  • LOC: production +21/-18 (net +3) centralizes one exact-authority boundary while deleting the embedded duplicate; tests +268/-42.
  • Custody: head c465155ae6b6cbcab130e054afc51c7058c457f9; tree 5c9cb96dd5246f00ca3cff7b38e435e72c2177af; parent ac2b76e03c8f22ad50e3286ad7bdee574aca1be8; binary full-index patch SHA-256 8182ed92ac8b52119a06a55eca750e3e3f742b9c4236be3aec746b46ecca2999; stable patch-id 5de15e74ec7e82404953c4d2b760bb56129d2304.
  • Dependency proof: Codex 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, and codex-rs/app-server/src/request_processors/thread_lifecycle.rs:217-305,420-449 confirm closure/replacement authority is exact-instance and cancellation-bound, not bearer-token authority.

Campaign scope decision

  • Hosted reviewer infrastructure limitation accepted. Changes to the ClawSweeper repository are outside this campaign. Its hosted worker's unavailable sibling Codex checkout is not a C01 dependency and no further ClawSweeper review will be requested for that limitation.
  • Direct Codex evidence retained. Acting OpenClaw agents personally inspected pinned sibling Codex commit 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)

  • Frozen integration base: 6b5b75aa01942a23ac3bd1e6d8dc7274a8f0c4a9; its full CI run 32911227450 is green. No later moving-main observation was used.
  • Rebase: the nine C01 commits were replayed linearly with no merge. One import-only test conflict preserved current-main removal of obsolete cron task-run-id plumbing while retaining C01 typed fallback provenance. Commits 1-6 and 9 retained stable patch IDs; commits 7-8 changed only where current-main test evolution was absorbed.
  • Attributable reconciliation repair: frozen main added provider-owned retired-auth-profile resolution to the embedded auth path. C01's shared plugin-free E2E provider-runtime mock now supplies the canonical empty deprecated-profile set. Production bytes are unchanged by this repair (+0/-0); test support is +1/-0.
  • Focused proof: 520/520 C01 owner tests; real embedded fallback E2E 20/20; embedded fault/lifecycle E2E 7/7, including closure and same-run replacement zero-receipt fences. The missing-export fail-before reproduced before the one-line mock repair; both E2Es pass independently after it.
  • Clean changed gate: Blacksmith Testbox tbx_01m0xtjjt7029p3zradwwpafsg, run 32918726450, exact candidate tree custody before/after, check:changed green 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.
  • Ordinary frozen-base autoreview: clean, patch correct, confidence 0.98. TruffleHog: clean.
  • Published head: 2feda8335e03bd5184971fa3eac3d599fbf839e9; tree 1b3d8b628ce401a081df85a45b4faa753a85e023; parent dcde2ae8b048faff5051db24f7f6f69f3f26bd87; frozen-base full-index binary patch SHA-256 69ee42021af71c8c37a74b69c62a20edba73894751eb0e32ee45a0a10f4b1755.
  • Hosted review limitation remains accepted: the unavailable sibling Codex checkout in the hosted reviewer is infrastructure-only and no further ClawSweeper review is requested. Direct evidence was inspected at pinned Codex 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, and codex-rs/app-server/src/request_processors/thread_lifecycle.rs:217-305,420-449.

FIFO pre-clone bounds correction (2026-08-25)

  • ClawSweeper P2 confirmed: private execution-decision refs and complete work envelopes were accepted and structured-cloned before the existing 4 KiB ref / 16 KiB envelope limits ran.
  • Fail-before on 2feda8335e03: both a 4,097-character raw ref and a valid-shaped envelope over 16 KiB returned true at the writer boundary; the regression failed 2/4 tests for that exact reason.
  • Canonical repair: the audit writer invokes the existing parseExecutionDecisionWork at FIFO acceptance immediately before structuredClone; asynchronous processing still revalidates the cloned work. No producer guard, schema, protocol, config, persistence, or display change was added.
  • Pass-after: private-work/writer/persistence/model-routing suites 36/36; direct-local and CLI authority siblings 5/5. Formatting, conflict, max-lines, assertion, dependency, plugin-boundary, coercion, dead-export, and related static gates passed. Local core typecheck was obscured only by the checkout's stale shared dependencies, with no changed-file diagnostic.
  • Clean-machine attempt: Blacksmith Testbox 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.
  • Review: ordinary autoreview clean, patch correct at 0.99; TruffleHog clean. No new ClawSweeper request: this change implements the under-12h exact-head finding and does not broaden behavior.
  • LOC: production +8/-3 (net +5), tests +41/-1. The production growth exports and calls the existing canonical parser at its missing acceptance boundary.
  • Head: 998e896ebdbc501261083f749def44b7470f7bce; tree 1e24594478bdcc847d2e079f4e1bffdaa66c42ce.
  • Codex contract rechecked directly at pinned f1087ff: codex-rs/app-server/src/request_processors/turn_processor.rs:1446-1508 rejects missing/mismatched active turns and defers success to TurnAborted; codex-rs/core/src/tasks/mod.rs:494-522 cancels the exact active task before clearing pending work.

@clawsweeper

clawsweeper Bot commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime commands Command implementations agents Agent runtime and tooling size: XL maintainer Maintainer-authored PR labels Aug 25, 2026
@joshavant

Copy link
Copy Markdown
Collaborator Author

@clawsweeper review

@clawsweeper

clawsweeper Bot commented Aug 25, 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 merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 25, 2026
@clawsweeper

clawsweeper Bot commented Aug 25, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 25, 2026, 10:40 PM ET / August 26, 2026, 02:40 UTC.

ClawSweeper review

What this changes

Adds private, pseudonymized audit receipts for admitted model-routing attempts and carries fallback provenance through CLI and embedded agent execution.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

No 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
Reviewed head: 998e896ebdbc501261083f749def44b7470f7bce

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The reviewed implementation is coherent and closes the prior bounded-before-clone concern; current-base refresh remains the material merge step.
Proof confidence 🌊 off-meta tidepool Not applicable: The repository context identifies this as a MEMBER-authored PR, so the external-contributor proof gate does not apply; the body nevertheless supplies focused after-fix audit and lifecycle evidence.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The repository context identifies this as a MEMBER-authored PR, so the external-contributor proof gate does not apply; the body nevertheless supplies focused after-fix audit and lifecycle evidence.
Evidence reviewed 6 items Current main does not implement this feature: Current main has neither the private decision-work envelope nor the model-routing producer, so this PR is not superseded or implemented on main.
Producer revalidates live admission: The routing producer captures the exact admitted-run assertion and invokes it immediately before the synchronous FIFO offer.
Prior FIFO-boundary finding is addressed: The audit writer parses and bounds decision work before structured cloning it into the queue; focused tests cover oversized refs and envelopes without reaching structuredClone.
Findings None None.
Security None None.

Live Verification

Command: pnpm test src/audit/execution-decision-work.test.ts

Result: FAIL (failed) — step 1 run pnpm test src/audit/execution-decision-work.test.ts: previous terminal command was still running after 30 seconds: "pnpm test src/audit/execution-decision-work.test.ts"

$ node --import tsx scripts/test-projects.mts src/audit/execution-decision-work.test.ts
[test] starting test/vitest/vitest.unit.config.ts

 RUN  v4.1.10 /tmp/clawsweeper-live-proof-129092-cGxSOf/target

 ✓  unit  src/audit/execution-decision-work.test.ts (4 tests) 10401ms
     ✓ rejects an oversized raw ref before the FIFO clone boundary  324ms
     ✓ keeps refs restart-stable, namespace-separated, and installation-local  9792ms

 Test Files  1 passed (1)
      Tests  4 passed (4)
   Start at  02:40:57
   Duration  13.79s (transform 2.52s, setup 913ms, import 2.10s, tests 10.40s, environment 0ms)

[test] passed 1 Vitest shard in 25.18s

Assertions:

  • FAIL expect_output: rejects an oversized raw ref before the FIFO clone boundary

How this fits together

The 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]
Loading

Before merge

  • Resolve merge risk (P1) - The head is behind main and this PR persists credential-routing metadata; rebase and refresh exact-head checks before merge, with a maintainer confirming the intended private-record boundary.
  • Complete next step (P2) - The protected maintainer/security boundary and stale merge base require human confirmation rather than an automated repair.
Agent review details

Security

None.

PR surface

Source +556, Tests +1130. Total +1686 across 62 files.

View PR surface stats
Area Files Added Removed Net
Source 21 581 25 +556
Tests 41 1857 727 +1130
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 62 2438 752 +1686

Review metrics

Metric Value Why it matters
Private audit bounds 16 KiB work envelope; 4 KiB per raw reference; 160-character displayed route ref These caps limit queued and retained routing metadata before private references reach the FIFO.
Production versus test LOC Not independently classifiable from the locally grafted head; GitHub reports +2,438/-752 aggregate The shallow review checkout lacks the PR merge base, so maintainers should retain the deterministic PR surface statistics for the final scope check.

Stored data model

Persistent data-model change detected: database schema: src/audit/execution-decision-work.test.ts, persistent cache schema: src/agents/model-fallback.run-embedded.e2e.test.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Refresh the private audit-boundary review (recommended)
    Rebase onto current main, rerun exact-head checks, and have the audit/authority owner confirm that the new credential-routing records remain private and generic.

Technical review

Best 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.

Labels

Label changes:

  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The repository context identifies this as a MEMBER-authored PR, so the external-contributor proof gate does not apply; the body nevertheless supplies focused after-fix audit and lifecycle evidence.
  • remove proof: sufficient: Current real behavior proof status is not_applicable, not sufficient.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove merge-risk: 🚨 availability: Current PR review merge-risk labels are merge-risk: 🚨 security-boundary.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: This is a bounded operator-audit feature with no supported user-facing regression in the reviewed head.
  • merge-risk: 🚨 security-boundary: The PR introduces persistence handling for credential-profile and selected-route references, even though the reviewed path bounds and HMAC-projects them.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The repository context identifies this as a MEMBER-authored PR, so the external-contributor proof gate does not apply; the body nevertheless supplies focused after-fix audit and lifecycle evidence.

Evidence

What I checked:

  • Current main does not implement this feature: Current main has neither the private decision-work envelope nor the model-routing producer, so this PR is not superseded or implemented on main. (src/audit/execution-decision-work.ts, a9303f27e982)
  • Producer revalidates live admission: The routing producer captures the exact admitted-run assertion and invokes it immediately before the synchronous FIFO offer. (src/agents/model-routing-decision.ts:45, 998e896ebdbc)
  • Prior FIFO-boundary finding is addressed: The audit writer parses and bounds decision work before structured cloning it into the queue; focused tests cover oversized refs and envelopes without reaching structuredClone. (src/audit/audit-event-writer.ts:295, 998e896ebdbc)
  • Private data is projected at the audit owner: Raw credential and route refs are HMAC-projected only in the writer path, and the focused storage test asserts neither raw value is retained. (src/audit/execution-decision-work.ts:181, 998e896ebdbc)
  • Current owner provenance: Current main attributes the shared audit-writer decision path and admitted-run assertion to the same recent audit/authority commit. (src/agents/admitted-run-context.ts:68, d3c5d8e33aed)
  • Codex contract check unavailable: The PR body relies on Codex lifecycle behavior as supporting proof, but the required sibling checkout is absent and the network cannot resolve GitHub; no Codex-dependent proof conclusion was made.

Likely related people:

  • Peter Steinberger: Current main attributes the shared audit writer and active-admission assertion to the same audit/authority introduction commit. (role: recent audit and admitted-run-authority owner; confidence: high; commits: d3c5d8e33aed; files: src/audit/audit-event-writer.ts, src/agents/admitted-run-context.ts)

Rank-up moves

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

  • Rebase onto current main and rerun the focused audit/agent checks on the exact merge head.
  • Complete the direct Codex-source contract check in an environment where the required sibling checkout is available.

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 (13 earlier review cycles; latest 8 shown)
  • reviewed 2026-08-25T10:13:31.533Z sha b43658a :: found issues before merge. :: [P1] Revalidate CLI admission immediately before enqueue
  • reviewed 2026-08-25T10:49:01.525Z sha 0c47826 :: needs changes before merge. :: [P1] Propagate provenance through the cron fallback callback
  • reviewed 2026-08-25T12:54:14.723Z sha c465155 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-25T13:18:46.301Z sha c465155 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-25T14:22:13.511Z sha c465155 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-26T00:57:17.097Z sha c465155 :: found issues before merge. :: [P2] Validate private refs before cloning them into the FIFO
  • reviewed 2026-08-26T01:02:54.656Z sha c465155 :: found issues before merge. :: [P2] Bound routing refs before enqueueing the FIFO work
  • reviewed 2026-08-26T01:48:35.737Z sha 2feda83 :: found issues before merge. :: [P2] Validate routing refs before FIFO cloning

@joshavant

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 25, 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:

@joshavant

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 25, 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 merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. labels Aug 25, 2026
@joshavant
joshavant marked this pull request as ready for review August 25, 2026 09:10
@joshavant
joshavant marked this pull request as draft August 25, 2026 09:24
@joshavant

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 25, 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 rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 25, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. proof: sufficient ClawSweeper judged the real behavior proof convincing. labels Aug 26, 2026
@joshavant
joshavant force-pushed the codex/agent-id-p0-model-credential-selection branch from c465155 to 2feda83 Compare August 26, 2026 01:41
@joshavant
joshavant marked this pull request as ready for review August 26, 2026 01:42
@joshavant
joshavant marked this pull request as draft August 26, 2026 02:25
@joshavant
joshavant marked this pull request as ready for review August 26, 2026 02:34
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 26, 2026
@joshavant
joshavant merged commit 96de6f4 into main Aug 26, 2026
275 checks passed
@joshavant
joshavant deleted the codex/agent-id-p0-model-credential-selection branch August 26, 2026 06:12
alfredjbclaw added a commit to alfredjbclaw/openclaw that referenced this pull request Aug 26, 2026
…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.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 27, 2026
* 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling commands Command implementations gateway Gateway runtime maintainer Maintainer-authored PR merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. 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.

1 participant