Repository navigation
fix(gateway): preserve restart intent across coalesced config writes - #110397
Patrick-Erichsen merged 6 commits into
Conversation
|
Codex review: needs maintainer review before merge. Reviewed July 27, 2026, 10:27 PM ET / July 28, 2026, 02:27 UTC. ClawSweeper reviewWhat this changesThe PR changes gateway configuration reload coalescing so that a restart required by an unapplied committed write survives a later non-restart write while the newest configuration remains the one applied. Merge readinessThis is still necessary: it addresses a real gateway convergence gap that current main has not absorbed. The branch has unusually strong focused and production-path proof, but the restart-intent provenance is race-sensitive and the branch is behind current main, so it should receive an owner review and exact-merge-head gate rather than an automated close or repair. Priority: P2 Review scores
Verification
How this fits togetherGateway configuration changes arrive through in-process writes and filesystem watcher events, which the reloader coalesces while an earlier reload is active. The reloader chooses the newest configuration payload but must preserve any still-unapplied restart requirement before it either hot-reloads or restarts the running gateway. flowchart LR
A[Config write A active] --> B[Pending committed write]
B --> C[Filesystem watcher echo]
C --> D[Coalescing reload state]
E[Newer config write] --> D
D --> F{Pending restart required?}
F -->|Yes| G[Restart with newest config]
F -->|No| H[Hot reload or no-op]
Decision needed
Why: The patch is narrow and well-proven, but it changes lifecycle semantics across asynchronous writer and watcher paths; choosing that reliability boundary is not a mechanical repair decision. Before merge
Agent review detailsSecurityNone. PR surfaceSource +22, Tests +113. Total +135 across 2 files. View PR surface stats
Review metricsNone. Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Copy recommended automerge instructionTechnical reviewBest possible solution: Keep the narrow pending-origin invariant, land it only after gateway ownership review and exact-merge-head focused validation confirm that pending restart intent survives coalescing without allowing obsolete active intent to leak. Do we have a high-confidence way to reproduce the issue? Yes, source-reproducible: the added deterministic tests define the active A, pending restart B, and newer C interleavings, including a watcher echo. The supplied production-path transcript independently reports the same before/after behavior, although this review did not rerun it locally. Is this the best way to solve the issue? Yes, with owner confirmation: retaining only an unapplied pending restart obligation while keeping the latest config avoids the broader FIFO queue proposed in the linked issue and preserves the existing protection against obsolete active intent leaking forward. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 6de4b47203a3. LabelsLabel justifications:
EvidenceWhat 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 (8 earlier review cycles)
|
|
Runtime behavior proof for the final commit ( I exercised the production config path with a temporary, uncommitted driver using:
The only injected control was a gate in Redacted output: This same production-path proof failed before the watcher-provenance follow-up: the watcher echo moved B out of the pending slot, C cleared its restart intent, and the driver timed out waiting for Final focused suite: 408/408 tests passed across |
|
Current-main lifecycle and validation follow-up I completed the requested source-level review against
Lifecycle audit results:
The linked issue's maintainer-oriented analysis explicitly defines the desired policy as latest-state coalescing plus preservation of the strongest required pending follow-up, while rejecting a broader FIFO queue and rejecting intent leakage from obsolete active writes. The implementation and neighboring tests match that boundary. Additional final-head validation:
No additional production or test change was made in this follow-up because the audit and stress pass did not produce a new failing invariant; avoiding speculative churn keeps the PR focused. |
26ed9d0 to
b5e266d
Compare
|
Current-main refresh exposed a focused test-type failure: the two new race fixtures still used the removed Exact-head focused coverage passes 159/159 tests. Oxfmt and |
|
@clawsweeper re-review |
|
🦞👀 Command router queued. I will update this comment with the next step. |
|
Merged via squash.
|
* origin/main: (57 commits) docs: document gateway and memory chat wizards (#115487) fix(agents): restore subagent completion delivery on CLI runtimes (#115422) fix(sandbox): stop provisioning failures from exhausting fallbacks (#115481) refactor: remove duplicate runtime and plugin paths (#115483) fix(ui): canonicalize agent model identity (#115480) fix(ui): preview model picker interactions live (#115477) fix(ui): match disabled microphone picker background (#115472) refactor(code-mode): split focused runtime stress suites (#115462) fix(gateway): preserve restart intent across coalesced config writes (#110397) fix: scope subagent handoff to direct tools (#115466) docs: explain native subagent handoff fix: clarify native subagent completion handoff fix(config): respect agent directory filesystem case (#105402) refactor(code-mode): unify safe OpenAI tool filtering (#115460) refactor(code-mode): prepare MCP namespaces once per run (#115459) fix(ollama): preserve selected model capabilities during onboarding (#115467) refactor(chat): remove duplicate session projection paths (#115461) refactor(code-mode): make tool catalogs run-owned (#115458) fix(cli): preserve mid-turn text in durable replies (#115455) fix(memory): fall back to keyword search when embeddings cannot start (#115397) ...
…penclaw#110397) * fix(gateway): preserve pending restart intent * fix(gateway): retain restart intent across watcher echoes * test(gateway): cover missing-file restart coalescing * test(gateway): update reload fixtures for current config
Closes #105623
What Problem This Solves
The gateway config reloader coalesces writes that arrive while an earlier write is still being applied. The pending slot correctly keeps the newest config payload, but it also replaced the entire
afterWriteintent.That creates a reliability gap for this sequence:
Before this change, C could erase B's restart requirement either directly from the pending slot or after the watcher had claimed B. The reloader then applied C without restarting, even though one of the committed, not-yet-applied writes had already established that the running gateway could not safely converge through hot reload alone.
Why This Change Was Made
This change gives coalesced, not-yet-applied writes two intentionally different merge rules:
restartintent is retained until the pending state is processed, unless the newer write also supplies its own restart intent;The provenance is deliberately narrow: only a watcher candidate known to have come from the pending slot can donate its restart intent to a newer write. A restart intent from an obsolete active write is still discarded. The change does not alter config schemas, debounce behavior, watcher lifecycle, hot-reload planning, or restart handling after processing begins.
An existing regression test proves that a restart intent from an obsolete active write must not leak into a newer pending write. The new cases cover the complementary invariant: a restart intent from an unapplied pending committed write must not be erased by a later coalesced non-restart write, either before or after a watcher echo.
User Impact
Rapid successive config writes no longer leave the gateway running with stale process state when an intermediate committed write required a restart. The latest config still wins, and ordinary
none/autobehavior is unchanged when no pending restart exists.Tests
Added deterministic three-write regression cases that block write A during plugin-record loading, queue restart-requiring write B, then coalesce newer write C. One case coalesces directly; the other emits B's watcher echo before C. They verify that:
Evidence
onRestartwas called 0 times instead of 1.pnpm test src/gateway/config-reload.test.tspassed 136/136, while the direct three-project Vitest matrix passed 408/408 acrossgateway-core,gateway-server, andgateway-client.replaceConfigFile, runtime write bus, gateway reloader, filesystem watcher, and snapshot reader. With only plugin-record loading gated to make the race deterministic, writes A/B/C produced exactly one restart; its reason wasproof pending B requires restart, while the restarted and persisted config was C (channelHealthCheckMinutes=3,hooks.enabled=false). The same proof failed before the watcher-provenance change by timing out after C was processed withmode: none.pnpm buildpassed in 3m04s, including unified/package bundles, runtime postbuild, plugin SDK export guards, and Control UI performance budgets.pnpm checkpassed, including all 80 npm shrinkwrap checks, core/UI/extensions/scripts/test typechecks, lint across core/extensions/scripts, formatting across 23,249 files, policy guards, and the zero-runtime-import-cycle check.origin/mainat6aee6417usinggit merge-tree --write-tree. The merge was conflict-free, the two affected blobs were byte-identical to the tested PR head, and the merged worktree passed the full three-project gateway file matrix (408/408). This validates the current merge result without repeatedly rebasing a live PR to chase a moving target.ae96413b83completed with 80 passing checks, 34 scope skips, zero pending checks, zero cancellations, and zero failures. The passing set includes production/test typechecks, lint, repository guards, all Node test shards, QA smoke profiles, security checks, native static analysis, andReal behavior proof.pnpm testrun was also attempted on macOS. It is not reported as a green signal because unrelated platform/environment failures occurred (/varvs/private/var, Bash 3.2 incompatibilities, unavailable loopback aliases/incomplete optional workspace dependencies), and the iMessage extension shard stopped making progress. The affected gateway tests above remained green; clean GitHub CI is the authoritative full-run gate for this PR.config-reload.test.tsran 402 tests in 5.59s; the final patched file ran 408 tests in 6.01s. These timings are included only as a regression check, not as a performance claim.Branch refresh
On July 25, GitHub safely updated the conflict-free branch from current
main. The fresh merge-head CI exposed two new test fixtures that still used the removedgateway.reload.debounceMsfield. Follow-up commitff96fa01changes only those fixtures togateway.reload: {}, matching the surrounding current-main tests.Exact-head validation for the follow-up: the focused gateway file passed 159/159 tests; Oxfmt and
git diff --checkpassed; fresh repository autoreview reported no findings and assessed the patch correct with 0.94 confidence. The full local test-type command was stopped after more than 15 minutes without diagnostics, and a narrower attempt encountered unrelated dependency-version errors from the shared localnode_modules; fresh hosted CI is the authoritative full typecheck.AI Assistance
This change was developed with assistance from OpenAI Codex. I reviewed the relevant reloader state transitions, neighboring tests, and final diff, and ran the validation commands documented above.