Skip to content

fix: hooks reject new agents after config hot reload - #125490

Merged
steipete merged 1 commit into
mainfrom
steipete/elated-moser-860edc
Aug 18, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/elated-moser-860edc

Conversation

@steipete

Copy link
Copy Markdown
Contributor

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.

  • AI-assisted; the change was reviewed and its behavior is understood.
  • No agent transcript is attached or requested.

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: expected agentId is not allowed by hooks.allowedAgentIds, but received unknown agentId "new".

After the fix, the same real Gateway flow passes and verifies both sides of the policy transition: new is recognized and evaluated by the refreshed allowlist, while removed agent old becomes 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.
  • Two independent Codex autoreviews completed cleanly with no accepted/actionable findings.

Raw LOC: production +40/-17 (net +23); tests/test support +513/-239. Most test churn moves existing Gateway setup and wizard E2E coverage into gateway.test-support.ts and gateway-wizard.e2e.test.ts so the cases remain in the owning E2E lane and the main Gateway test stays within the max-lines guard.

@clawsweeper

clawsweeper Bot commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: L maintainer Maintainer-authored PR labels Aug 18, 2026
@steipete
steipete marked this pull request as ready for review August 18, 2026 01:12
@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 18, 2026
@clawsweeper

clawsweeper Bot commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 17, 2026, 9:19 PM ET / August 18, 2026, 01:19 UTC.

ClawSweeper review

What this changes

The 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 provenance

Possible regression — probable (reviewed change; failure trace). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

Keep 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
Reviewed head: 610acfe5d2d02b8ccef58644ed761a24c2680524

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused owner-boundary repair with boundary-level regression coverage; exact-head CI remains the material merge gate.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The PR body reports an after-fix local Gateway hot-reload run, and the added regression test exercises the actual Gateway HTTP hook path and observed policy transition.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The PR body reports an after-fix local Gateway hot-reload run, and the added regression test exercises the actual Gateway HTTP hook path and observed policy transition.
Evidence reviewed 6 items Current-main gap: On current main, an agents.entries change only restarts heartbeat; it does not request hook-policy resolution.
Current-main owner boundary: Current main refreshes hooks state only when reloadHooks is true, leaving non-hooks reload plans with the prior resolved policy snapshot.
Branch repair: The branch projects the agent and session fields consumed by hook resolution, then requests a policy-only refresh without committing the transform-cache invalidation.
Findings None None.
Security None None.

How this fits together

Gateway 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]
Loading

Before merge

  • Resolve merge risk (P1) - Hot-reloaded existing configurations now recompute hook policy for agent and session ownership changes, so the policy-only path must remain separate from hook transform-cache invalidation.
  • Resolve merge risk (P1) - The exact branch head has one failed compact-large check and several still-running checks; the failure cause was not available through read-only inspection.
  • Complete next step (P2) - No mechanical repair is identified; a maintainer should review the failed exact-head check and merge only after the check set is green.
Agent review details

Security

None.

PR surface

Source +114, Tests +183. Total +297 across 8 files.

View PR surface stats
Area Files Added Removed Net
Source 4 131 17 +114
Tests 4 422 239 +183
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 8 553 256 +297

Review metrics

Metric Value Why it matters
Production versus test delta production +40/-17 (net +23); tests/test support +513/-239 The production growth is bounded to reload-boundary projection and a policy-only action; most churn relocates existing Gateway test support and wizard coverage.

Stored data model

Persistent data-model change detected: persistent cache schema: src/gateway/server-reload-handlers.test.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Confirm the hot-reload compatibility path (recommended)
    Require the exact head to complete green after confirming the policy-only reload refreshes target validation without invalidating cached hook transforms.

Technical review

Best 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.

Labels

Label changes:

  • add P2: This is a bounded Gateway hot-reload regression that currently requires operators to restart after supported configuration changes.
  • add merge-risk: 🚨 compatibility: The change alters how existing agent and session configuration takes effect in a running Gateway during hot reload.
  • add proof: sufficient: Contributor real behavior proof is sufficient. The PR body reports an after-fix local Gateway hot-reload run, and the added regression test exercises the actual Gateway HTTP hook path and observed policy transition.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR body reports an after-fix local Gateway hot-reload run, and the added regression test exercises the actual Gateway HTTP hook path and observed policy transition.

Label justifications:

  • P2: This is a bounded Gateway hot-reload regression that currently requires operators to restart after supported configuration changes.
  • merge-risk: 🚨 compatibility: The change alters how existing agent and session configuration takes effect in a running Gateway during hot reload.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR body reports an after-fix local Gateway hot-reload run, and the added regression test exercises the actual Gateway HTTP hook path and observed policy transition.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body reports an after-fix local Gateway hot-reload run, and the added regression test exercises the actual Gateway HTTP hook path and observed policy transition.

Evidence

What I checked:

  • Current-main gap: On current main, an agents.entries change only restarts heartbeat; it does not request hook-policy resolution. (src/gateway/config-reload-plan.ts:119, 1ca4103fe9ec)
  • Current-main owner boundary: Current main refreshes hooks state only when reloadHooks is true, leaving non-hooks reload plans with the prior resolved policy snapshot. (src/gateway/server-reload-hot.ts:107, 1ca4103fe9ec)
  • Branch repair: The branch projects the agent and session fields consumed by hook resolution, then requests a policy-only refresh without committing the transform-cache invalidation. (src/gateway/config-diff.ts:38, 610acfe5d2d0)
  • Boundary-level regression coverage: The added test starts a real local Gateway, atomically changes the agent roster and session-store owner, and verifies that the new agent reaches allowlist validation while the removed agent is unknown. (src/gateway/gateway.test.ts:341, 610acfe5d2d0)
  • Provenance: Blame ties the pre-fix reload rule and hook-resolution guard to the current-main feature commit associated with the preceding agent configuration work. (src/gateway/config-reload-plan.ts:120, 6e458d84bfc1)
  • Current release context: The latest supplied release is v2026.7.1-2 at 0790d9f; this open branch is not release provenance. (0790d9f593ad)

Likely related people:

  • steipete: Introduced the immediately preceding agent/config reload surface and authored the current repair. (role: recent Gateway config-reload contributor; confidence: high; commits: 6e458d84bfc1, 610acfe5d2d0; files: src/gateway/config-diff.ts, src/gateway/config-reload-plan.ts, src/gateway/server-reload-hot.ts)
  • Vincent Koc: History records a recent reload-plan refactor in the same Gateway planning surface. (role: adjacent reload-plan contributor; confidence: medium; commits: b8bb08a1ad37; files: src/gateway/config-reload-plan.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Resolve or rerun the failed compact-large check and wait for the in-progress exact-head checks to finish.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@steipete

Copy link
Copy Markdown
Contributor Author

Land-ready verification for exact head 610acfe5d2d02b8ccef58644ed761a24c2680524:

  • Before: after hot-reloading the agent roster/session owner, direct hook target new was rejected as unknown agentId "new" even though runtime config had published it.
  • After: the real isolated Gateway HTTP hook flow recognizes new, evaluates it against hooks.allowedAgentIds, and treats removed agent old as unknown. No Gateway restart is required.
  • Focused proof: node scripts/run-vitest.mjs src/gateway/config-reload.test.ts (193 passed); node scripts/run-vitest.mjs src/gateway/gateway.test.ts -t "refreshes direct hook target policy"; node scripts/run-vitest.mjs src/gateway/server-reload-handlers.test.ts -t "preserves the active hook transform cache"; node scripts/run-vitest.mjs run --config test/vitest/vitest.e2e.config.ts src/gateway/gateway-wizard.e2e.test.ts (2 passed); node scripts/check-changed.mjs; git diff --check; two clean Codex autoreviews.
  • Exact-head CI: run 32087374098 is green after retrying one unrelated timing flake. The failed test and its production/test-support owners are byte-identical on current origin/main; the focused case passed locally, then retry job 95564208606 passed. node scripts/watch-pr-ci.mjs 125490 610acfe5d2d02b8ccef58644ed761a24c2680524 reports GREEN with zero pending checks.
  • ClawSweeper: 4/6 platinum hermit, no findings. Its rank-up move to resolve/rerun compact-large and finish exact-head CI is complete. The policy-only refresh remains separate from transform-cache invalidation and has focused regression coverage. The reported “persistent cache schema” is a filename heuristic on server-reload-handlers.test.ts; this PR changes no persistent schema or storage contract.
  • Raw LOC: production +40/-17 (net +23); tests/test support +513/-239.
  • Proof gap: no external provider/channel was involved or required. The behavior is covered through a real isolated Gateway HTTP hot-reload flow; there is no visual UI surface, so screenshots are not applicable.

@steipete
steipete merged commit 6f6691c into main Aug 18, 2026
446 of 448 checks passed
@steipete
steipete deleted the steipete/elated-moser-860edc branch August 18, 2026 01:29
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: L status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant