Repository navigation
fix(gateway): preserve connections and turns on harmless role reloads - #175251
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex review: needs real behavior proof before merge. What this changesThis PR preserves operator connections and accepted turns across role-scope reloads that leave their admitted permissions intact. Example: The contributor role changes from operator.write to operator.admin while a contributor turn and a maintainer connection are active.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Blocked before merge - 3 items remain Keep open: this maintainer-directed fix addresses interrupted operator workflows, and the previous HTTP, approval, and access-policy findings are addressed without a new concrete defect identified. Priority: P1 Before merge
FindingsNone. Tests
Agent review detailsHow this fits togetherGateway admission captures operator permissions; committed configuration reloads reconcile connected clients and retained run authority before subsequent protected operations. flowchart TD
A[Committed role configuration] --> B[Per-profile role resolver]
B --> C[Connection reconciliation]
B --> D[Active run authority]
B --> E[Recovery authority]
C --> F[Protected request dispatch]
D --> F
E --> F
Technical reviewBest possible solution: Preserve harmless reloads through per-profile scope reconciliation while retaining admission ceilings and irreversible revocation at protected operations. Do we have a high-confidence way to reproduce the issue? Current-main source explains both failures: every role edit changes the shared transport fingerprint, and exact role-policy equality rejects harmless scope changes; incident logs and reported baseline regression failures corroborate those paths. Is this the best way to solve the issue? Per-profile reconciliation uses existing role and scope owners, shares active/recovery comparison, and restores the HTTP, approval, and handshake fences affected by removing global invalidation. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against ca07b1b0d5e1. Merge-risk optionsMaintainer options:
Provenance checked
TestingProof path: in-process harness. SecurityNeeds attention: No reachable bypass was established, but the changed authority lifetime still needs final-effect revocation evidence. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +73, Tests +285, Docs +6. Total +364 across 18 files. Added test files: 0. View PR surface stats
Review metrics
LabelsLabel changes: No label changes. Label justifications:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (3 earlier review cycles)
Reviewed October 17, 2026, 4:12 AM ET / 08:12 UTC (Revision 4). |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 884f523e78
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7bacb8aedf
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Merged via squash.
|
…openclaw#175251) * fix(gateway): preserve connections and turns on harmless role reloads * fix(gateway): preserve role revocation at request authority boundaries * fix(gateway): retain HTTP role-definition authority fences * fix(gateway): retain required access policy on role reloads
What Problem This Solves
Fixes role-definition hot reloads disconnecting unrelated operators and aborting accepted work even when its effective scopes did not narrow.
User Impact
Editing one role no longer disconnects operators in another role. Reordering or widening a role's scopes preserves existing connections and accepted turns. Removing a scope still immediately retires affected connections and work, and restoring it cannot revive a revoked source. Existing work retains its admission ceiling.
Why This Change Was Made
On baseline
d739d3592ba4,src/gateway/auth-policy.ts:39included the entire role table in every connection's transport fingerprint.src/gateway/server/ws-origin-policy.ts:55consequently sent code 4001 for every role edit. Separately,src/gateway/operator-run-authority.ts:493compared the captured role policy for exact equality;src/gateway/operator-run-recovery.ts:237repeated that comparison for recovered work. Both rejected harmless scope changes.The role path was retained by #160909 rather than introduced by a regression to its unrelated-reload fix. That change separated accepted access grants from transport reauthentication, but left the global role fingerprint and the exact role-source checks in place.
Role scopes now use the existing per-profile resolver and operator-scope implication rules. Active and recovered sources share one comparison of current permission against their admitted scopes. Non-scope source restrictions keep their existing checks. The pending-handshake owner retains the superseded-role check before device approval or registration; established connections no longer use it as a global disconnect signal. Pending approval requests recheck the caller through the existing role-scope authorizer, retaining irreversible revocation across a committed revoke/restore. HTTP response authority keeps its existing conservative role-definition fence during preparation, including when roles were already enabled. The HTTP owner captures the same model-independent role-policy projection that the shared fingerprint previously carried.
Accepted boundary: explicit profile role reassignment, non-scope source-policy changes, pending handshakes, and HTTP request preparation retain their existing conservative revocation/retry behavior. This change concerns committed role-definition scope edits. Changes to a required access-policy plugin retire only affected connections: the access-authority owner records the admitted requirement independently of durable grant IDs. No configuration, storage, protocol, or dependency changes.
Evidence
The current-boot journal for deployed build
66ffabc522accontains:There were 15 webchat disconnects across 10 users within 180 ms. The excerpt omits user identities, session keys, run IDs, and model identifiers.
The managed-reload regression failed against main
d739d3592ba472096b23aa5908ed8187deb66ca3: widening only the contributor role disconnected the unchanged maintainer and aborted an accepted contributor source with the exact role-change error. The maintainer's accepted source itself remained valid on current main; the regression distinguishes that from its incorrectly closed connection. The existing model-only reload test passed.Validation of the change:
pnpm test src/gateway/server-reload-handlers.operator-model-policy.test.ts src/gateway/operator-run-recovery.test.ts src/gateway/operator-role-policy.test.ts src/gateway/server/ws-origin-policy.test.ts src/gateway/control-ui-plugin-auth-cookie.test.ts --maxWorkers=1— 106 tests passed across five files.pnpm test src/gateway/server/ws-connection/connect-device-pairing.test.ts --maxWorkers=1 -t 'keeps local pairing pending'— all four selected cases passed, including role-policy revocation before device approval commits; eight unrelated cases were excluded by the name filter.node scripts/run-tsgo.mjs -p "$TMPDIR/tsconfig.json"— passed. The temporary config extendstest/tsconfig/tsconfig.core.test.shard.json, includes all 17 changed TypeScript files, and checks their transitive dependencies.node scripts/run-oxlint.mjs --tsconfig config/tsconfig/oxlint.core.json <17 changed TypeScript files>— passed.pnpm exec oxfmt --check <18 changed files>,pnpm lint:docs docs/gateway/configuration/hot-reload.md, andgit diff --check— passed.pnpm test:ci-failed 175251 --run— both previously failing approval revoke/restore cases and the existing named-role plugin HTTP effect test passed unchanged after the corrections. The plugin test permits the effect after an unrelated edit and rejects it after role/default, assignment, or proxy changes.pnpm test src/gateway/server-http.authority-outcomes.test.ts --maxWorkers=1 -t 'role boundary enabled|role scope revoked'— both selected real HTTP response cases passed. Owner probes reproduced stale authority before the fixes; the response tests verify rejection after enabling roles and narrowing an already-enabled role.ecb0bdc32de3eddae010d89c78bffb7c9af7d7da: scoped-clean through P2, no actionable findings. The branch review included the unchanged HTTP, scope, profile-role, connection invalidation, pairing, recovery, approval, and request-dispatch contracts.The simplification pass removes the global role-table fence and moves the duplicate profile-lifecycle handshake check into the shared handshake owner. The additional production code performs per-identity scope reconciliation and shares the active/recovery comparison; no new manager, persistent state, or compatibility path. Delta against the base: production +90/-17 (net +73), tests +298/-13 (net +285), documentation +6/-0.
Initial CI run
39010674590exposed two approval-request revoke/restore regressions; the follow-up fixes the approval authority owner without relaxing those tests. The same run also reportedTS2741atsrc/config/io.health-state-scope.test.ts:71and:78after an unrelated main-branch disposal change. Upstream commit7b727f04d23f76d0aefcb4c1c5a0f5b071d8e7affixes those exact two lines; this PR does not edit that config-health code.The GitHub review of
884f523e7813correctly identified that the HTTP assignment revision alone did not cover role-definition edits. The HTTP follow-up keeps the complete role-policy preparation fence locally, rather than relying on that revision; WebSocket and accepted-run scope reconciliation remain per identity.CI run
39012238838exposed the existing plugin HTTP effect regression on the intermediate head. Its unchanged test now passes on7bacb8aedfad240127103421935dc2f33a9d45d8; 115 selected cases had passed at that head; the final total is recorded below.The next review identified a required-access-policy transition missed by the scope-only connection check. A managed-reload regression reproduced the retained socket when a contributor gained a required plugin without losing its admitted scope. Connection reconciliation now compares the admitted plugin requirement from the existing access-authority owner; unaffected maintainers remain live and a revoked socket cannot enter a new write handler.
Additional proof:
pnpm test src/gateway/server-reload-handlers.operator-model-policy.test.ts src/gateway/operator-access-policy.github-login.test.ts src/gateway/server/ws-origin-policy.test.ts --maxWorkers=1. All 30 cases passed across the three files; the three reload cases passed after correcting the test expectation to match silent dispatch rejection on a closed socket. The role-focused proof now covers 117 selected cases.CI run
39013836705passed its type/lint jobs and failed three cases inextensions/memory-core/src/tools.postgres.test.ts(stale lexical/vector results and a missing bounded result). The CI helper classified these as unknown, without a matching main-job signature. A scoped replay against a disposable PostgreSQL 17 instance with CI'sunaccent,pg_trgm, andvectorextensions passed all three:node scripts/test-database-conformance.mjs --engine postgres --connection <disposable-dsn> -- extensions/memory-core/src/tools.postgres.test.ts --maxWorkers=1 -t 'publishes body|publishes vector|keeps pathological'. This is diagnostic evidence, not a claimed fix or proof that the CI failures were inherited. No memory-search source or tests were changed.Final-head CI for
ecb0bdc32de3eddae010d89c78bffb7c9af7d7da: GREEN, zero pending checks, verified bynode scripts/watch-pr-ci.mjs 175251 ecb0bdc32de3eddae010d89c78bffb7c9af7d7da --timeout 2700. Run 39016172327 passed, including both PostgreSQL conformance jobs. The watcher classified 15 older-head checks as superseded. No CI rerun was requested.The final ClawSweeper review reports Findings: None and confirms that the prior HTTP, approval, and access-policy findings are addressed. It still requests an additional active/recovered final protected-operation trace before merge. This PR supplies the described owner-boundary, dispatch-rejection, and HTTP-effect tests; no live Team or provider run was performed. The PR remains open and is not merged.