Repository navigation
fix(cli): detect CLI/gateway state-dir split-brain before credential writes - #134403
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs changes before merge. Reviewed September 1, 2026, 9:40 AM ET / 13:40 UTC. ClawSweeper reviewWhat this changesThe PR adds a CLI pre-action check that compares local state paths with a local Gateway or installed service before selected setup and credential commands run. Regression provenancePossible regression — probable (reviewed change; failure trace). No predecessor PR is attributed. Merge readinessThe PR remains necessary, but its parent-level model-auth policy blocks read-only commands and bare help whenever the local Gateway/service uses another state tree. Priority: P1 Review scores
Verification
How this fits togetherCLI setup and authentication commands write local state, while the Gateway and its installed service choose the state tree the running bot consumes. The new guard queries those paths before a command action and permits, warns, or refuses execution. flowchart LR
A[CLI command] --> B[Command-path policy]
B --> C[Pre-action state check]
C --> D[Gateway hello]
C --> E[Installed service state]
D --> F{Paths match?}
E --> F
F -->|Yes or unknown| G[Run command]
F -->|Proven mismatch| H[Refuse execution]
Decision needed
Why: The PR is marked maintainer and changes credential/config startup behavior, so a maintainer must make the final merge decision. Before merge
Findings
Agent review detailsSecurityNone. PR surfaceSource +196, Tests +540, Docs +6. Total +742 across 17 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Copy recommended automerge instructionTechnical reviewBest possible solution: Mark only write-capable Do we have a high-confidence way to reproduce the issue? Yes—source-reproducible: run Is this the best way to solve the issue? No. A parent policy overmatches read-only inspection and help; explicit write-capable auth leaves preserve the stated protection boundary without blocking recovery commands. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against d4354ffc8e91. LabelsLabel changes:
Label justifications:
EvidenceAcceptance criteria:
What 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 (22 earlier review cycles; latest 8 shown)
|
|
@clawsweeper re-review Both P1 findings are fixed at head |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper re-review — all four state-dir waiver alias gaps are closed at |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
008d8f9 to
633e62d
Compare
P1 resolved: missing config leaves now canonicalize through their nearest existing parentHead Root cause. Fix.
Regression test. Pre-fix (production file reverted to Post-fix: Production LOC. +18/-10 for this commit; the rename is mechanical, the added lines are the ancestor walk and its invariant comment. @clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
b0d4f00 to
091a157
Compare
091a157 to
b0d4f00
Compare
Co-authored-by: Ayaan Zaidi <[email protected]>
b0d4f00 to
41d56a7
Compare
|
Land-ready proof for
Commands: Production Known gap: local build and TypeScript checks were not run under the host safety rule. Exact-head CI/Testbox passed those gates. |
|
Merged via squash.
|
|
Thanks @obviyus! Proof: A real
|
…4403) Co-authored-by: Ayaan Zaidi <[email protected]>
What Problem This Solves
Local credential and configuration commands could report success while writing to a state directory that the running Gateway never reads. This happens when the CLI and Gateway use different
OPENCLAW_STATE_DIRorOPENCLAW_CONFIG_PATHvalues.Why This Change Was Made
The CLI command catalog now marks
models auth,channels add,channels login, andconfigureas local state writers. One global Commander pre-action checks those commands before bootstrap or action code can persist state.The check uses this evidence order:
Proven path mismatches refuse the write. Remote or unverifiable Gateway paths warn. An offline host with no installed service stays silent. The check adds no waiver flag, config key, protocol field, or storage migration.
Doctor reuses the same path comparison in warning mode after its existing authenticated status hello.
User Impact
Operators no longer get a false success from the guarded local setup and credential commands when a live or installed Gateway uses another state tree. The refusal shows the exact quoted state/config environment needed to target the Gateway.
Intentional writes to another local tree require stopping the running Gateway, or uninstalling or reconfiguring the divergent installed service first.
Evidence
e44c4b8a3e0e9e8bae58ebf1a50e239176d8e4cd: a realchannels addcommand returned success and wrote the Telegram token into the CLI config while an authenticated admin hello reported a different Gateway state directory. The refusal contract failed.41d56a74efa55ad36634fa4f87ff7138db1ced09: the same command raisedNo credentials or configuration were written; the CLI config contained no token; the same authenticated hello still reported the different Gateway directory.git diff --checkpassed. Local TypeScript build/typecheck commands were not run under the host safety rule; exact-head CI owns them.+198/-2, tests and test support+548/-8, docs+6.