Repository navigation
fix(claws): refuse local writes while a Gateway owns the state - #168586
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. |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Codex review: needs changes before merge. What this changesThis PR requires exclusive offline state ownership for six Claw CLI commands and their previews. Example: Run claws add ./claw.json while a Gateway owns the same state directory.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Needs changes before merge - 2 items remain Keep this PR open: the ownership fix is useful, but both prior findings remain unresolved at the unchanged head. Priority: P2 Before merge
Findings
Tests
Agent review detailsHow this fits togetherClaw CLI commands turn package manifests and installed-agent state into plans, configuration changes, workspace files, and provenance; the shared local-state owner now admits these operations before their existing implementations run. flowchart TD
A[Claw CLI command] --> B[Offline action adapter]
B --> C[Local state owner]
C --> D[Live owner refusal]
C --> E[Exclusive offline custody]
E --> F[Existing Claw operations]
F --> G[Config workspace and provenance]
Technical reviewBest possible solution: Keep the shared ownership adapter, reject Gateway-dependent cron actions before offline mutation, and make the CLI documentation consistently describe the supported offline operations. Do we have a high-confidence way to reproduce the issue? Source inspection confirms both the original missing admission boundary and the introduced cron failure path; no target code or tests were executed during this read-only review. Is this the best way to solve the issue? Reusing the existing state owner is a proportionate repair, provided planning rejects operations whose required Gateway cannot run while offline custody is held. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 171df4e1c5a0. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceAcceptance criteria:
What I checked:
Likely related people:
PR surfaceSource +31, Tests +156, Docs +11. Total +198 across 7 files. Added test files: 1. View PR surface stats
Review metrics
LabelsLabel 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 (1 earlier review cycle)
Reviewed October 10, 2026, 2:13 PM ET / 18:13 UTC (Revision 2). |
|
Lander proof for The completed ClawSweeper review has no P0/P1 findings. Its P2 cron-bearing offline partial-operation concern and P3 older live-Gateway documentation conflict remain follow-ups under the explicit P0/P1-only mechanical landing order. No source changes or new commits were made by the lander. |
|
Merged via squash.
|
What Problem This Solves
Fixes local Claw commands writing configuration, provenance, and indexes while a Gateway owns the same state. The regression reproduced a live-owner add creating a workspace and committing configuration before a later database write failed.
User Impact
claws add,update,remove,migrate,status, andexportnow refuse while a Gateway owns the state and explain how to stop it and retry. The guard includes previews because planning and status reconciliation can write. Offline commands retain exclusive ownership through the existing local-state owner and run the existing domain code unchanged. Package-only authoring and inspection remain available online.Full removal of a Claw-created agent still requires Gateway monitor drainage and is unavailable through this offline CLI path; removal of adopted ownership works offline and preserves the existing agent and workspace. No new RPC, receipt, worker refactor, schema, or persistence contract is introduced.
Why This Change Was Made
This is the requested small replacement for the 13-PR Claw chain #168421–#168433 (
dbasync/ow2branches). One adapter uses the existingrunWithLocalStateOwnerrefusal/offline paths before any command body can access state. The lander can retire that chain after landing this replacement.Lane:
clawsimple. Status: pending lander.Evidence
The regression covers all six commands and their previews against a real held Gateway lock, compares the complete fixture tree byte-for-byte including a populated SQLite database, and verifies no Gateway RPC is attempted. Offline integration coverage exercises add, update, status, export, migration, and adopted-ownership removal. The test uses the existing host-broker lane because the real SQLite broker requires the application host thread.
Independent Codex autoreview: no actionable P0–P2 findings.
pnpm test src/cli/claws-cli.state-owner.test.ts --maxWorkers=1: 3 passed; 223.34 s wall time including 131.33 s cold worker preparation, about 32.3 s in test bodies. This exercises real configuration/provenance writes and offline ownership across six commands; mocks would not prove the broker/custody boundary.pnpm build: passed, 14m 29.2s. The untouched UI bundle report prints a non-fatal startup gzip overage (366.2 KiB versus 366.1 KiB); build exits 0.pnpm tsgo:coreand the owning CLI test typecheck passed. Staged formatting and structural guards passed. Script lint and the remaining schema, database, import-cycle, sidecar, media, webhook, and pairing guards passed.pnpm check:changed --stagedstops at an inherited UI test graph budget failure: 722 roots against a 720-root limit. All 722 roots exist at the branch baseline, and this patch changes neither that shard nor its budget. The global test typecheck uses that same blocked graph; the owning CLI test shard passed directly.tools/solid-lint/index.mjs: default, andresolveSessionConversationStub/resolveSessionTargetStubinsrc/agents/tools/sessions-channel-fixture.test-support.ts. Their sources, consumers, and Knip configuration are unchanged; the production export scan passed.pnpm lint:corereports only inherited max-lines errors in 19 untouched files; none of the seven files in this patch has a lint finding.The initial regression failed on the original code after a live-owner add wrote configuration and workspace state. During verification, an unhosted test-worker run was moved to the existing host-broker lane, and a test/build overlap was rerun after serializing those commands. These were harness failures, not passing product proof.