Repository navigation
fix: hooks reject new agents after config hot reload - #125490
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 17, 2026, 9:19 PM ET / August 18, 2026, 01:19 UTC. ClawSweeper reviewWhat this changesThe PR refreshes Gateway hook target policy after agent or session ownership hot reloads while keeping hook transform modules cached unless hook configuration itself changes. Regression provenancePossible regression — probable (reviewed change; failure trace). No predecessor PR is attributed. Merge readinessKeep open. The branch cleanly repairs a current-main Gateway hot-reload gap, with no blocking patch findings; it still needs exact-head CI completion before landing. Priority: P2 Review scores
Verification
How this fits togetherGateway config reload turns changed configuration paths into a reload plan and publishes a replacement runtime state. The hook HTTP endpoint reads that state to validate agent targets before dispatching work. flowchart LR
A[Operator changes config] --> B[Config path diff]
B --> C[Gateway reload plan]
C --> D[Hot reload prepares hook policy]
D --> E[Gateway runtime state]
E --> F[Hook HTTP request]
F --> G[Agent target validation]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +114, Tests +183. Total +297 across 8 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Land the policy-only snapshot refresh after exact-head CI confirms it preserves hook transforms and completes the real Gateway transition without a restart. Do we have a high-confidence way to reproduce the issue? Yes. Current main resolves hooks only for hooks-owned reload plans, while the branch's local-Gateway regression test exercises the stale-policy transition through the HTTP hook endpoint. Is this the best way to solve the issue? Yes. Refreshing the already-owned resolved hook snapshot at the Gateway commit edge fixes the stale state without unnecessarily clearing hook transform modules. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 1ca4103fe9ec. LabelsLabel changes:
Label 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
|
|
Land-ready verification for exact head
|
|
Merged via squash.
|
What Problem This Solves
Fixes an issue where operators hot-reloading the Gateway after changing the agent roster, agent ownership, session-store owner, or session store/scope could have direct hooks reject newly configured agents against the previous policy snapshot. The runtime config was current, but hook target validation remained stale until a Gateway restart.
Why This Change Was Made
Gateway config diffing now preserves the exact hook-policy ownership boundaries hidden by whole-object changes. The hot-reload plan refreshes the atomic hook policy snapshot for those boundaries while keeping hook transform-cache invalidation limited to actual
hooks.*changes.User Impact
Direct hook target validation immediately reflects hot-reloaded agent and session ownership configuration. Operators do not need to restart the Gateway after these supported configuration changes, and existing hook transform modules remain cached when only target policy changes.
Evidence
Before the fix, the real Gateway hot-reload regression command failed after adding agent
new: expectedagentId is not allowed by hooks.allowedAgentIds, but receivedunknown agentId "new".After the fix, the same real Gateway flow passes and verifies both sides of the policy transition:
newis recognized and evaluated by the refreshed allowlist, while removed agentoldbecomes unknown. Focused validation completed successfully:node scripts/run-vitest.mjs src/gateway/config-reload.test.ts— 193 tests passed.node scripts/run-vitest.mjs src/gateway/gateway.test.ts -t "refreshes direct hook target policy"— real Gateway hot-reload regression passed.node scripts/run-vitest.mjs src/gateway/server-reload-handlers.test.ts -t "preserves the active hook transform cache"— transform-cache regression passed.node scripts/run-vitest.mjs run --config test/vitest/vitest.e2e.config.ts src/gateway/gateway-wizard.e2e.test.ts— 2 moved wizard E2E tests passed in their owning lane.node scripts/check-changed.mjs— passed.git diff --check— passed.Raw LOC: production
+40/-17(net+23); tests/test support+513/-239. Most test churn moves existing Gateway setup and wizard E2E coverage intogateway.test-support.tsandgateway-wizard.e2e.test.tsso the cases remain in the owning E2E lane and the main Gateway test stays within the max-lines guard.