Repository navigation
refactor(gateway): keep admitted personal-profile requests running - #201083
Conversation
- Keep admitted personal reads and actions running across reconnects and role changes. - Bind personal credentials to identity and generation while preserving later callback admission and data fences. - Remove retained method reauthorization and rewrite obsolete revocation expectations.
|
🦞👀 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: needs changes before merge. What this changesThis PR lets admitted personal-profile requests finish after disconnects or role changes while preserving identity, credential, and target isolation. Example: A sessions.github.options request loses its WebSocket 3 ms after sending.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Needs changes before merge - 1 item remains Keep this PR open: it addresses a concrete admission-lifetime failure, but remaining consumer tests still enforce the superseded behavior and fail CI. Priority: P2 Before merge
Findings
Agent review detailsHow this fits togetherThe Gateway admits RPC callers, prepares profile and session facts, and supplies bounded authority to GitHub reads, publication, and personal account linking. flowchart TD
A[Gateway RPC caller] --> B[Method and profile admission]
B --> C[Captured request authority]
C --> D[Session and credential owners]
D --> E[GitHub read or publication]
C --> F[Account linking]
F --> G[Fresh OAuth callback admission]
Technical reviewBest possible solution: Keep the existing admission and identity owners, and finish migrating consumer tests to completion-under-admission plus next-request refusal. Do we have a high-confidence way to reproduce the issue? Current-main source shows socket cancellation and retained reauthorization reaching the reported refusal; the PR supplies matching real-Gateway base/head results, which were not rerun during this read-only review. Is this the best way to solve the issue? Capturing admission facts while retaining canonical identity, credential-generation, cancellation, and target guards is a focused solution using existing owners; the remaining consumer expectations must follow the same contract. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against c8da4b7fbc40. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceAcceptance criteria:
What I checked:
Likely related people:
PR surfaceSource -39, Tests +74, Docs +3. Total +38 across 14 files. Added test files: 0. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. LabelsLabel changes:
Label justifications:
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 Reviewed November 18, 2026, 3:45 AM ET / 08:45 UTC. |
- Restore the dispatch-ceiling fence without repeating source or role authorization. - Keep profile-admission expectations unchanged and verify admitted publication/read completion with fresh-request refusal controls.
- Preserve caller and admitted-run AbortSignals without restoring live policy or socket checks. - Reuse the admitted profile binding for personal read actions. - Update in-flight readiness/readback policy expectations and keep fresh-request denial controls.
|
Maintainer override: the red job is not caused by this PR.
Why it is unrelated:
The local ClawSweeper review on this exact head ( |
…penclaw#201083) Problem: a personal GitHub request (`sessions.github.options`, status, polls) was refused mid-request with "Personal profile request connection is no longer current; reconnect and try again." whenever its WebSocket closed, and retained requests could be refused with "Gateway requester authority changed". 21 such refusals were logged on one host in four days. Fix: personal-profile authority (profile, role/scope ceiling, credential owner) is checked once at admission and fixed for the request. A socket close, role edit or policy change applies to the next request. Explicit request cancellation, admitted-run cancellation, profile merge identity, credential generation and target fences still stop or refuse work. OAuth callbacks re-admit as a new start. The router's dispatch-scope check is unchanged. User impact: a started GitHub read or publication finishes even if the dashboard disconnects or the role changes meanwhile; the next request reflects the change. Proof: real Gateway from source: socket closed 3/5/10 ms after sending refuses with the exact logged error on base and finishes on head; closing before admission and a fresh request after real role revocation are refused on both. Regression and consumer tests cover cancellation, merge, generation and next-request refusal. Co-authored-by: Ayaan Zaidi <[email protected]>
…201083) Problem: a personal GitHub request (`sessions.github.options`, status, polls) was refused mid-request with "Personal profile request connection is no longer current; reconnect and try again." whenever its WebSocket closed, and retained requests could be refused with "Gateway requester authority changed". 21 such refusals were logged on one host in four days. Fix: personal-profile authority (profile, role/scope ceiling, credential owner) is checked once at admission and fixed for the request. A socket close, role edit or policy change applies to the next request. Explicit request cancellation, admitted-run cancellation, profile merge identity, credential generation and target fences still stop or refuse work. OAuth callbacks re-admit as a new start. The router's dispatch-scope check is unchanged. User impact: a started GitHub read or publication finishes even if the dashboard disconnects or the role changes meanwhile; the next request reflects the change. Proof: real Gateway from source: socket closed 3/5/10 ms after sending refuses with the exact logged error on base and finishes on head; closing before admission and a fresh request after real role revocation are refused on both. Regression and consumer tests cover cancellation, merge, generation and next-request refusal. Co-authored-by: Ayaan Zaidi <[email protected]> (cherry picked from commit 461319f) Co-authored-by: RomneyDa <[email protected]>
Problem
A plain
sessions.github.optionscall can outlive its WebSocket. No profile write, policy reload, or generation bump is required to reproduce T04:src/gateway/server/connection.ts:512aborts the connection signal when the socket closes;:256removes the socket from the client set.personal-profile-authorization.ts:34,40-43treats either event as lost personal authority.github-personal-authorization.ts:134-140retains that live check ascurrentClient, invoking it again after session preparation (:169) and during response reads (:186). An already-started read therefore throws the exact logged refusal:Personal profile request connection is no longer current; reconnect and try again.request-authorization.ts:285,518calls the sameauthorizeGatewayMethodfor one retained request. The later call can reachmethod-authorization.ts:56-57afterclient.invalidatedchanges and refuse withGateway requester authority changed.This reproduces a concrete socket-close cause; the aggregated historical logs alone do not prove that every T04 event had this cause.
Rule
Authority is decided when work starts and remains fixed for that request. A reconnect, revocation, or role edit affects the next request. Queued/retried/replayed work admits again when it actually starts. A completed read may have no socket left to receive its response.
Change
prepareUserProfileSelectionAuthorityAPI preserves canonical identity and physical-store safety. Personal credential readers use the already-existingcaptureUserProfileAuthorityRead(..., "identity")mode; secret account/generation ownership is unchanged.authorizeGatewayMethodat admission, but remove its retained-request source/role reauthorization. Preserve the separate broad-versus-session-only dispatch-ceiling comparison through a shared grant-only calculation; profile/catalog preparation must not replace the selected ceiling. Canonical profile preparation and the existing operator/session admission owners remain in place.Production remains net negative: the initial change removed 39 net lines; the dispatch-ceiling repair added 28 and the cancellation repair adds 6, leaving the PR at net -5 production lines. No exported production symbol is removed. Deleted private lifetime machinery: personal
assertConnection, publicationcurrentClient/resolveOwner, and the router's repeated full-methodauthorizeMethodclosure. The personal read action now reuses its admitted profile binding rather than capturing it twice. The test-onlyblockAlicefixture moved to the existing authority support module; the redundantpreparePollwrapper was removed to keep the test file within its existing lint cap.Threat model
Accepted edge case: the admitted request finishes after disconnect, but its result cannot be delivered to the closed socket. Closing before personal admission still refuses; the proof retains those negative controls.
Evidence
Base
6ec27bd739c7(merge base). Both arms: a real Gateway from source (ocx src), isolated state and ports, and a synthetic trusted-proxy Control UI-like identity. No predicates, thrown errors or Gateway handlers were injected.sessions.github.options, socket closes 3 ms after sendingusers.setRoletodenied, then a fresh requestFORBIDDEN: missing scope: operator.readGateway requester authority changedTests and checks
Obsolete tests were rewritten, not deleted: personal ingress/role changes, coverage/receipt/repository reads across disconnect, role edits during OAuth polling/status, and disconnect during an admitted OAuth callback now require completion. Their next-request controls still require refusal. Merge, credential generation, selected target/workspace, cancellation, expiry and replacement controls remain.
CI follow-up classification:
github-publication-native.test.ts, personal publisher custody / originalrequester-revoked: during the admitted publication. The action was admitted beforerequestPersonalForSessionV2, and the source disappears insideprepareRepositoryIntegrationduring that publication. Renamed the scenario torequester-disconnected; require successful publication with the same personal publisher, worker execution credential isolation, and exact physical CAS. A freshpreparePersonalPublicationFixtureActionafter disconnect must refuse at admission. Credential reselection and explicit cancellation scenarios still refuse.session-row-prepared-read.test.ts,settles startup discovery after revoked before dispatch: during the admitted request. Method admission already passed before the test pauses the runningprepareSqliteTargetFromSessionStorePathdiscovery. Its internal readiness loop resumes the same request, not a queued RPC or new execution. Require it to finish; the next call with the revoked scopes must be refused without starting another discovery. The adjacent bounded-startup test likewise keeps the original request's timeout result and refuses the next call.server-methods.profile-authorization.test.ts,models.list/sessions.groups.listscope permutations: before final profile/catalog dispatch admission completes. These tests enforce the retained pre-dispatch scope-ceiling selection fence. My change mistakenly deleted that comparison together with the source/role reauthorization, causing three base-passing cases to dispatch. The table is restored exactly to its base expectations.authorizeGatewayMethodScopesnow owns the existing grant-only calculation, shared with admission and the dispatch-ceiling comparison, without rereadingclient.invalidatedor current role policy. In particular, the groups read→session-read refusal also remained protected atb040dd4bbycaptureGatewayRequestOperatorGuard's live-scope comparison; that router-owned lifetime check is untouched and remains for a separate S1 PR with its own proof.server-methods.canonical-validation.test.ts/ exact-row authorization: during the admitted read. The scope mutation happens only afterwithSessionRowDatabaseFactshas entered and paused. The prepared authorization now finishes; a fresh call with those revoked scopes must returnMISSING_SCOPE. Bulk-validation independence, unavailable-method refusal, and corrupt-subscription fences remain unchanged.The fix does not restore retained source/role authorization or cut the router guard. The separate OAuth-callback later-start admission added in this PR remains in place.
5976f5173b1a0496adf0480c78c5e7b9ffc5722c: priority files 3 files / 76 tests passed (359.53 s Vitest duration); this includes the original profile-authorization expectations, the admitted-discovery controls, and personal publisher custody.tsgo:core, andtsgo:core:test.CI run
44297089334follow-up classification:Readiness post-await
connection/grant: during the admitted read. The grant is the Gateway operator-access policy signal, not a personal credential generation or data-store lease. The read finishes; the next request is denied. Profile/session/visibility/source replacement and registry custody controls remain.Cold configured locator (
shared.sqlite, role reader): initial allowed cold/warm reads were already passing. The failure was in the latersessions.otherspolicy-reload check, during an admitted observation. That observation finishes; the next read is denied before receipt observation (INVALID_REQUESTfor the now-hidden session). The separate named-role scope veto remains in its base form because the router guard is outside this PR.CLI-owner readiness: explicit supplied source/run cancellation, not a role-policy edit. Keep the existing allowed-path and cancellation assertions unchanged. Read cancellation now includes the admitted run's
AbortSignal; no live source/role predicate was restored.Legacy
DROP TABLE/DELETElifecycle recovery: explicit request cancellation after a durable claim. This was a production regression: ignoringoptions.signalallowed publication aftercontroller.abort(). Personal actions again honor the request/caller cancellation signal, including before/after profile preparation. Both legacy recovery tests stay unchanged.revoked-after-create: during the admitted confirmation/readback, after the remote effect. The existing closed-PR observation is now delivered as the original request's terminalgithub_rejectedresult, retaining its observed PR effect and URL. Fresh publish/confirm requests with the reduced grant are refused and add no effects. This is not a credential-identity or generation change.CI repair
7b9b97c9ca3f88e3daab69cf9f871d2fac931ecaverifies 4 reported files / 49 unique tests, plus 11 profile-read ownership/control tests. The unchanged legacy-recovery and CLI-owner cancellation assertions pass with the production fix. After the final test-only denial-code/observation assertion correction, readiness passes all 34 cases; other unchanged passing results are reused.Changed-file format/lint and
tsgo:core:testpassed for the cancellation repair. No further declaration-generating lint/typecheck cycle was run after the final readiness-test-only change.Base regressions: four personal read/role cases fail on base; the retained-method regression fails with the exact requester-authority error.
Initial runtime head
b040dd4b: six focused files, 148 passed.tsgo:core,tsgo:core:test, every baseline sub-ratchet, changed-file oxfmt/oxlint: pass.Lifetime ratchet (chore(ci): ratchet mid-request authority re-checks #201072): no per-file growth against the merge base; current changed-production-file count is 5. The restored scope-selection refusal remains in the inventory; source/role reauthorization remains removed.
LSP references and consumer sweeps cover changed owners and removed private helpers; no export removed.
Tier
full: the initial runtime headb040dd4bpassedocx build --dtsand a packed tarball install into a clean prefix (CLI, doctor). Packaging proof has not been repeated for the scope-fence follow-up.