Repository navigation
fix: let input policy hooks inspect prepared images - #196337
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. What this changesThis PR lets input-policy hooks inspect prepared images and reuses those bytes for approved submissions and CLI recovery. Example: A user sends “Inspect ./picture.png” to a vision-capable agent.
Review scores
ProductKind: Feature · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this maintainer-authored PR adds useful image-policy coverage that current main lacks, and no actionable introduced defect remains. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherEmbedded, CLI, and Gateway worker runners prepare user input, invoke plugin admission policy, and then persist approved input and dispatch it to the model. flowchart TD
A[User prompt and attachments] --> B[Existing image preparation owners]
B --> C[Run-owned image snapshot]
C --> D[Input policy hook with detached copy]
D --> E[Blocked replacement transcript]
D --> F[Approved input persistence]
F --> G[Model submission and CLI recovery]
Technical reviewBest possible solution: Extend the existing admission hook with a detached image snapshot and reuse that snapshot through approved submission and recovery. Do we have a high-confidence way to reproduce the issue? Current-main source shows the missing image field and pre-image gate ordering; supplied red/green cases exercise ./picture.png, but this read-only review did not rerun them. Is this the best way to solve the issue? The patch uses existing media and admission owners, removes post-gate reloading, and preserves independent transport contracts without adding a competing policy path. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 9387dfe9910b. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +18, Tests +162, Docs +6, Other +2. Total +188 across 19 files. Added test files: 0. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. Review metrics
LabelsLabel changes: No label changes. Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (2 earlier review cycles)
Reviewed November 9, 2026, 8:05 PM ET / November 10, 2026, 01:05 UTC (Revision 3). |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
* fix: let input policy hooks inspect prepared images * fix: preserve CLI execution defaults and satisfy ratchets * test: remove unused CLI fixture import
d7aaafe (#196337) deferred legacy worker input persistence until after the policy gate and dropped the missing-admission check with the early persistence path. Input that the runtime already persisted without a readable canonical anchor then acquired credentials, started a tunnel and launched from the stale leaf. Restore the fail-closed check before credentials for already-persisted input; unpersisted input is still admitted after the gate. Update the detached-context fixtures for the intended ordering: unpersisted input reads its prefix through the transcript open, so the authority-change probes hook that read. Co-authored-by: obviyus <[email protected]>
d7aaafe (#196337) deferred legacy worker input persistence until after the policy gate and dropped the missing-admission check with the early persistence path. Input that the runtime already persisted without a readable canonical anchor then acquired credentials, started a tunnel and launched from the stale leaf. Restore the fail-closed check before credentials for already-persisted input; unpersisted input is still admitted after the gate. Update the detached-context fixtures for the intended ordering: unpersisted input reads its prefix through the transcript open, so the authority-change probes hook that read. Co-authored-by: obviyus <[email protected]>
…tests broken on main (#196702) * test(gateway): expect participation refusal after retained sharing facts Since d53921a (#194129), a broad sessions catalog notification no longer invalidates retained sharing facts; the commit guard rereads membership and refuses the fork with SESSION_PARTICIPATION_REQUIRED, matching the writer-fault variant. The fork still fails with SessionMutationAuthorizationChangedError and leaves storage unchanged. Co-authored-by: obviyus <[email protected]> * fix(gateway): reject worker turns with persisted input but no admission d7aaafe (#196337) deferred legacy worker input persistence until after the policy gate and dropped the missing-admission check with the early persistence path. Input that the runtime already persisted without a readable canonical anchor then acquired credentials, started a tunnel and launched from the stale leaf. Restore the fail-closed check before credentials for already-persisted input; unpersisted input is still admitted after the gate. Update the detached-context fixtures for the intended ordering: unpersisted input reads its prefix through the transcript open, so the authority-change probes hook that read. Co-authored-by: obviyus <[email protected]> * test(qa): prove worker turn admission and authority on the paired-node path Add a QA script scenario that dispatches a managed-worktree session to a proof-owned paired-node worker through an isolated Gateway and exercises the production credential, transport and launch path: - chat.send and qa-channel turns with a readable admission launch once, reach the mock model once and commit their reply; - cancelling the run or reclaiming the placement while the launch frame is held on the node makes the Gateway cancel the launch before the node handles it: no worker process starts, the model sees no request and no worker transcript or live event is acknowledged. Co-authored-by: obviyus <[email protected]> --------- Co-authored-by: obviyus <[email protected]>
…tests broken on main (openclaw#196702) * test(gateway): expect participation refusal after retained sharing facts Since 4d6df47 (openclaw#194129), a broad sessions catalog notification no longer invalidates retained sharing facts; the commit guard rereads membership and refuses the fork with SESSION_PARTICIPATION_REQUIRED, matching the writer-fault variant. The fork still fails with SessionMutationAuthorizationChangedError and leaves storage unchanged. Co-authored-by: obviyus <[email protected]> * fix(gateway): reject worker turns with persisted input but no admission 1acafee (openclaw#196337) deferred legacy worker input persistence until after the policy gate and dropped the missing-admission check with the early persistence path. Input that the runtime already persisted without a readable canonical anchor then acquired credentials, started a tunnel and launched from the stale leaf. Restore the fail-closed check before credentials for already-persisted input; unpersisted input is still admitted after the gate. Update the detached-context fixtures for the intended ordering: unpersisted input reads its prefix through the transcript open, so the authority-change probes hook that read. Co-authored-by: obviyus <[email protected]> * test(qa): prove worker turn admission and authority on the paired-node path Add a QA script scenario that dispatches a managed-worktree session to a proof-owned paired-node worker through an isolated Gateway and exercises the production credential, transport and launch path: - chat.send and qa-channel turns with a readable admission launch once, reach the mock model once and commit their reply; - cancelling the run or reclaiming the placement while the launch frame is held on the node makes the Gateway cancel the launch before the node handles it: no worker process starts, the model sees no request and no worker transcript or live event is acknowledged. Co-authored-by: obviyus <[email protected]> --------- Co-authored-by: obviyus <[email protected]>
#197210) Fresh recorder input is persisted only after image-aware policy admission from #196337. Bootstrap and assembly therefore have no fence yet; retain final admission, exact candidate receipt and after-turn settlement assertions. Three affected-file tests pass. Co-authored-by: obviyus <[email protected]>
openclaw#197210) Fresh recorder input is persisted only after image-aware policy admission from openclaw#196337. Bootstrap and assembly therefore have no fence yet; retain final admission, exact candidate receipt and after-turn settlement assertions. Three affected-file tests pass. Co-authored-by: obviyus <[email protected]>
Expose the exact prepared image snapshot to input policy hooks across embedded, CLI, and Gateway worker runners. Reuse CLI prepared input across retries and isolate hook mutations from submitted input. Release adaptation: retain the existing hook type owner and runtime generation scope. Include the required missing-admission refusal from #196702, selected-branch recorder hydration from #196487, and deferred context-admission assertions from #197210. Do not import unrelated session rewind, prompt continuity, or cold-start owners. Selected source commits: (cherry picked from commit d7aaafe) (partial companion from commit e212ede) (partial companion from commit ebf6c06) (partial companion from commit eafa247) Co-authored-by: obviyus <[email protected]> Co-authored-by: Peter Steinberger <[email protected]> Co-authored-by: RomneyDa <[email protected]>
Refresh the complete v2026.11.3..09aa644 history: 99 in-range PRs, 35 issues, and direct-commit editorial coverage. Preserve all 62 prior contribution records and original main PR credits. Include typed Telegram callbacks, worker-heartbeat lease renewal, and the narrow large-store startup adaptations without claiming post-ready recovery. Source product: 09aa644 Source tree: f10a88c Main metadata: 3577724 Notes tooling: 514a224 Release provenance: 3768440 -> openclaw#194840, openclaw#179219, openclaw#196984, openclaw#196337 Release provenance: 00275d2 -> openclaw#194362 Release provenance: 66f0339 -> openclaw#186998 Release provenance: 915956a -> openclaw#186998 Co-authored-by: vincentkoc <[email protected]> Co-authored-by: RomneyDa <[email protected]>
What Problem This Solves
Input policy plugins cannot inspect images loaded from local prompt references before an agent turn reaches the model.
User Impact
Plugins using
before_agent_runcan inspect the prepared current-turn images on embedded, CLI, and Gateway worker runs. Allowed turns submit the inspected bytes, including during CLI recovery; blocked turns stop before inference and input persistence.Image preparation now performs I/O before the policy decision. The hook's optional
imagesfield is absent on older hosts; paired-node CLI images and runners without this hook remain unsupported. No configuration migration is required.Why This Change Was Made
Prepare images through the existing media owners before calling the gate, give hooks an isolated event copy, and reuse the prepared snapshot for submission and retries. Gateway worker gates use Gateway-owned images, and legacy worker input persistence waits for approval.
This removes post-gate image reloading from the policy-enabled CLI flow and the early legacy-worker persistence path. Production TypeScript changes total +135/-117 lines (net +18); regression tests and fixtures total +240/-78 (net +162). The hook event and CLI fixture now live in existing sibling modules, preserving the public export and test coverage while keeping oversized owners from growing.
Evidence
a8d7470fbdcc8c9558dda60a9571697d3976f3f9, snapshot tree09b7e72e3d9415cc797fd674c3a0525de5347f6a, at P0–P2. Result: scoped-clean, no actionable findings. A fresh P0–P2 autoreview also covered the complete follow-up againstbeb3731dd31387238b365c5d009f0198321a99f6, tree9015305e18dd6b472463557731637c5e30a378cd: scoped-clean, no actionable findings. Reviewers did not execute tests; the test results above were run separately.Sanitized output from the Gateway proof:
{ "blockedProviderRequests": 0, "allowedImageSnapshotMatches": true, "sourceDeletedDuringGate": true, "hookMutationIsolated": true }CI and review follow-up
The first CI run found two branch-related failures. The follow-up preserves the existing undefined execution-options argument for control/isolated paths and reduces the stale assertion allowance from two to one. Both failing CLI cases were reproduced locally before repair and passed afterward.
The first hosted review also requested file-size cleanup. The event type and unchanged CLI fixture were moved into existing sibling modules; strict local line-cap, assertion-safety, and test-line ratchets now pass. No limits or test assertions were weakened.
One concurrent local run hit timeout/unknown recovery failures after over two seconds in fixtures with a one-second retry budget. The unchanged fixture move was verified byte-for-byte apart from export keywords. All four retry cases passed in isolation, followed by all 63 reliability cases in their original order after other checks finished. Load sensitivity remains; these passing reruns are not claimed as a timing fix.
The second hosted review, covering
72d54e273aaa8569a4d256c2b3cbfe973cff5de8, resolved all prior findings and reported no actionable defects. The second CI run found one unused test import left by the fixture move. The mechanical correction removes that import and reduces the exact test-line allocation to 162. Focused CI-mode oxlint checked the affected test with all 293 rules and returned no diagnostics; formatting, the test-line ratchet, and diff checks passed. That run finished with the build and all test shards passing; the unused import was its only substantive failure. The correction is ind72e49c195307b355fc82383d4254158c288e0eb; the final-head CI run completed successfully, including build-artifact checks andopenclaw/ci-gate. The final hosted review covers that exact commit and reports no actionable findings; it is ready for maintainer review. Live external-model and Windows-native behavior were not exercised. The AWS build covered the initial implementation and emitted existing Control UI size-budget warnings; the follow-up changes CLI option defaults, type placement, and test structure, with final-head build-artifact checks passing in CI.