Repository navigation
fix(config): ignore discarded SecretRefs when applying batches - #131656
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 28, 2026, 4:36 AM ET / 08:36 UTC. ClawSweeper reviewWhat this changesThe PR makes batch config mutations validate only surviving SecretRefs and providers from the final candidate configuration, avoiding resolution or execution of values overwritten later in the batch. Merge readinessKeep open. Current main still derives dry-run references from intermediate operations, while this branch validates the completed candidate; the refactor is coherent and has no supported correctness finding, but exact-head CI and the planned CLI probe should finish before landing. Priority: P2 Review scores
Verification
Live VerificationCommand: Result: PASS (completed) Assertions:
How this fits togetherThe Config CLI turns batch input into mutations, applies them to an in-memory candidate configuration, then validates it before writing or returning dry-run output. SecretRef resolution and exec-provider path checks occur in that validation boundary and affect whether a configuration can be accepted. flowchart LR
A[Batch config input] --> B[Mutation parser]
B --> C[Candidate configuration]
C --> D[SecretRef and provider selection]
D --> E[Validation and dry-run result]
E --> F[Config write or rejection]
F --> G[Gateway reload planning]
Before merge
Agent review detailsSecurityNone. PR surfaceSource -118, Tests +179, Docs +2, Other 0. Total +63 across 11 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Use the completed candidate as the single source for SecretRef and provider validation, retain the registry and roster normalization paths, and land after exact-head checks and a redacted CLI dry-run demonstrate the observable result. Do we have a high-confidence way to reproduce the issue? Yes, source-reproducible: current main records SecretRefs from every submitted operation before final candidate composition, so an earlier overwritten exec reference remains selected. This read-only review did not execute the reproduction. Is this the best way to solve the issue? Yes. Moving selection to the final candidate in the mutation validator removes the stale operation metadata source while preserving registered sibling-reference precedence, provider checks, and roster-normalized paths. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 1dba34be9be1. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
Unwind already-reported config failures through the shared CLI finalizer so resources close and piped JSON drains before the requested exit. Preserve injected runtime ownership and avoid rendering typed exits twice. Cover full 1 MiB pipe output, exact status, and config error contracts.
|
@clawsweeper re-review The final head is 5165970. Since the reviewed head, a real config dry-run probe exposed truncated JSON on a failing piped command. Config failures now unwind through the shared CLI finalizer so cleanup completes and output drains before exit, without reporting the same error twice. The full branch and the final guard cleanup have fresh Codex reviews with no actionable findings. The config/CLI lifecycle run passed 569 tests; all 228 config command tests passed again after removing the obsolete boolean guard contract. The previous review's remaining items—final built-CLI probes and exact-head hosted CI—are still being completed and will be recorded before landing. The storage heuristic on |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Final maintainer verification passed at 516597002b345662dce1ed7f0b5bcee4e7368c2b. CI run 33157895894 and its required openclaw/ci-gate succeeded. Fresh consolidated Codex review found no actionable P0–P2 findings. The final built CLI passed all 15 fixture-isolated real command probes with actual pipes. Overwritten leaf/ancestor refs neither resolved nor executed; successful writes persisted the final literal. Surviving invalid refs, normalized model keys, renamed agents, and changed/unset defaults were still validated. All failures and dry runs preserved config bytes. Failed get/validate/mutation commands emitted exactly one complete JSON document. The formerly truncated failure now emits 629 parseable bytes instead of stopping at 512; the large get error emits 8,351 bytes with empty stderr. Separate subprocess coverage verifies a full 1 MiB JSON response and exact exit code 7. {"head":"516597002b345662dce1ed7f0b5bcee4e7368c2b","builtCliCasesPassed":15,"discardedExecMarkerCreated":false,"failureAndDryRunConfigBytesPreserved":true,"jsonResponsesComplete":true,"requiredCi":"success"}The config/CLI lifecycle run passed 569 tests, followed by a 228-test config rerun after the final guard cleanup. Final build, production/test types, lint, formatting, export scans, and architecture/auth/storage guards passed as recorded in the PR body. Production net -109 lines; tests/support net +249; docs +2. No new config, dependency, storage, or execution-policy surface. This completes the prior ClawSweeper review's two remaining requests: exact-head CI and changed-behavior CLI proof. Its storage heuristic only refers to a JSON-writer test spy, so migration proof is not applicable. A refresh was requested for the additional output-exit repair; the publisher is not a landing blocker. Windows live execution remains outside this proof; its existing policy tests are unchanged. Post-merge verification: all 228 config command tests passed again on main commit 3f31f271d5ac, which includes merge 2d625dad30e1 and the concurrent config-test fixture consolidation. The local checkout is synced and clean. |
|
Merged via squash.
|
…law#131656) * fix(config): validate surviving batch values through one mutation flow * fix(cli): drain config failure output before exit Unwind already-reported config failures through the shared CLI finalizer so resources close and piped JSON drains before the requested exit. Preserve injected runtime ownership and avoid rendering typed exits twice. Cover full 1 MiB pipe output, exact status, and config error contracts. * refactor(config): make snapshot validation throw on failure
Related: #117128 (exec-provider preflight parity), #117051 (validation accepting a command startup rejects).
What Problem This Solves
Fixes ordered config batches validating discarded SecretRefs. A ref assigned early and replaced later—either at the same field or by replacing its parent—could still reject the final config or execute an obsolete provider during
--dry-run --allow-exec.Real CLI verification also exposed truncated JSON on failed commands: config handlers immediately exited after an asynchronous pipe write. One failing dry run emitted only 512 bytes. This follow-up repairs both ownership boundaries while simplifying the surrounding code.
Why This Change Was Made
The mutation validator now selects references and affected providers from the completed candidate. It preserves registry-owned sibling-ref precedence, changed-default behavior, canonical model keys, and references that move during an agent rename. Persistence retains its explicit write paths, include ownership, roster protections, and no-op handling.
Input parsing, validation decisions, output formatting, and persistence have separate owners. The cleanup removes four derived operation fields, duplicate assignment builders and mode selection, redundant config/schema cloning, and the separate dry-run validation branch. Existing integration coverage is split by behavior without adding test-only production seams.
Already-reported config failures now unwind through the shared CLI finalizer. Resources close and output drains before exit; typed exits retain their status and are not formatted as another error. Injected runtimes keep ownership of their own exit behavior. The snapshot guard's obsolete boolean result and caller branch are removed.
User Impact
Overwritten refs no longer block writes, execute credential commands, or inflate dry-run counters. Surviving invalid refs still fail. Targeted edits can still repair config without checking unrelated dormant providers; whole provider-collection edits check all remaining providers. Model-provider IDs are not mistaken for SecretRef provider aliases.
Failed machine-readable config commands emit complete JSON through pipes. No CLI flags, config keys, environment options, schema/storage contracts, dependencies, or plugin execution policies are added or removed. The CLI reference documents final-candidate batch validation. JSON and human output retain their existing shapes.
Evidence
AI-assisted maintainer refactor with direct source review and independent review.
pnpm buildpassed. The final CLI artifact refresh (node --import ./scripts/tsx.mjs scripts/build-all.mts cliStartup) passed at516597002b345662dce1ed7f0b5bcee4e7368c2b.Final hosted CI: passed, run 33157895894, head
516597002b345662dce1ed7f0b5bcee4e7368c2b. The first run hit npm tarball timeouts for the already-pinned Tlon native package, also reproduced on main. The intermediate head caught the boolean-contract lint issue fixed above.The prior ClawSweeper review's remaining requests were exact-head CI and real CLI proof; both are now complete. A fresh review was requested because the output-exit repair adds behavior beyond that review. Its storage heuristic refers only to capturing
writeJsonin a test harness: no store or migration changes exist.Windows live execution is outside this proof. Existing command-path policy and deterministic Windows tests are unchanged. No release artifact is published by this PR.
Provenance and Follow-ups
The stale-operation selection originated in #49296 (
e99963100d2, authored and merged by @joshavant on March 17), then moved into the validation module in #113248. The immediate dry-run exit was carried forward by #116833 (c50a6119efc, authored and merged by @steipete on July 31). Source inspection confirms both mechanisms in shipped tagv2026.7.1-2, atsrc/cli/config-cli.ts:1739and:2347. The existing finalizer dates to #113112; this PR routes already-reported typed exits through that owner.Deferred separately: plugin metadata reuse needs a config-wide snapshot contract, including missing-file and multi-workspace cases. Main CI also exposed an unrelated Gmail watcher fixture race: existence-only readiness can read an empty PID file as
NaNbefore its shell writes the PID. That fixture should publish PID files atomically while retaining its shutdown assertions.