Repository navigation
fix(gateway): keep chat admission bound to current session authority - #156941
galiniliev wants to merge 5 commits into
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: blocked before merge. Reviewed September 30, 2026, 6:05 PM ET / 22:05 UTC (Revision 22). ClawSweeper reviewWhat this changesThe branch makes Gateway chat admission recheck current session, membership, and storage authority before starting work, clears rejected upload reservations, and refreshes native session ownership reads. Merge readiness⛔ Blocked before merge - 3 items remain Current main does not contain the worker-retained chat authorization in this PR. The current source addresses the prior global-key finding, and the recorded Gateway proof covers allowed, revoked, and reassigned member turns. The assembled global-session cases that previously failed still need an exact-head result. Priority: P1 Review scores
Verification
How this fits togetherThe Gateway receives authenticated chat requests, resolves the selected session and its sharing permissions, then admits a turn. An admitted turn can write a transcript and call a model provider. flowchart LR
A[Authenticated chat request] --> B[Session and storage selection]
B --> C[Worker reads row and membership]
C --> D{Current authority?}
D -->|Yes| E[Reserve and admit turn]
D -->|No| F[Reject without effects]
E --> G[Transcript and model provider]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +1502, Tests +1538. Total +3040 across 51 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep the selected-store worker read and live authority guard, while confirming valid global sessions for both main and work agents can complete a chat turn and wrong-owner or revoked requests stop before side effects. Do we have a high-confidence way to reproduce the issue? Yes, at the source level: current main uses the older admission path, and the PR records a real Gateway client scenario for stale membership and reassignment. This read-only review did not execute that scenario. Is this the best way to solve the issue? Yes in principle: the patch reuses the Gateway's sharing and selected-store owners for revalidation. The integrated global-session chat result remains the specific validation gap. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 70219a1b6f2b. 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
HistoryReview history (21 earlier review cycles; latest 8 shown)
|
7855be2 to
c039048
Compare
|
c039048 to
8671700
Compare
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review Please review exact current head |
|
🦞👀 Re-review progress:
|
Reconcile the aggregate published repairs on current main.
3c00704 to
1748745
Compare
|
@clawsweeper re-review Please review exact current head |
|
🦞👀 Re-review progress:
|
|
Continuing this integration in #164682, retaining @galiniliev's original commits and human co-author credit. The replacement incorporates current main, improves the worker-backed lookup and authority checks, and adds reservation/callback cleanup regressions. Source review is complete; isolated execution proof and the schema-facts prerequisite are still pending. This PR will remain open until the replacement merges. |
|
Landed through the credited replacement #164682 as 00daeeb, verified on The completed repair moves initial chat/session and membership preparation through the existing database workers while preserving current caller, physical-session, reservation, and accepted-input authority across waits. It also joins accepted work during shutdown and preserves released synchronous SDK contracts. Focused regressions and the real Gateway/provider scenario ran in secretless GitHub CI; nine source-derived negative controls qualified the repaired boundaries. Exact-head CI passed 94 jobs, with only the independently reproduced main cron-authority failure and its aggregate admitted through the native admin exception. Details and evidence are in #164682. Thank you @galiniliev for the original work. Closing this source PR now that its improved replacement has merged. |
What Problem This Solves
Fixes chat admission that could consume stale session, member, or physical storage facts after a worker read. Rejected uploads also left a pending reservation that blocked corrected input using the same retry key.
User Impact
An authorized member can send a normal turn. Revoked membership and reassigned sessions reject input before transcript or provider effects; unrelated configuration changes preserve valid work. Rejected or failed upload admission releases only its own reservation, so a corrected request can reuse its key. No new configuration, stored format, schema migration, or operator action is required.
Why This Change Was Made
The existing sharing owner consumes exact worker-prepared rows and membership under the retained physical storage owner. The normal lifecycle owner revalidates before registering work, and the upload owner settles its exact reservation on rejection. Existing projection, queued Stop, recovery, and provider ownership contracts remain with their canonical owners.
Published repair head:
17487454baa68c8901b1c9c84393135e93748a55. This branch is rebased on main82949354d73c910a0b59ed7b2af6cfddde87c0ff; it has no source dependency on the separate native ownership PR.Evidence
chat.sendstarted, user and assistant messages persisted, and exactly one provider request contained the submitted input. Membership revoked during the held worker read rejected withINVALID_REQUEST, unchanged transcript, and no additional provider request. Reassignment to a successor session also rejected, with unchanged original transcript and an empty successor transcript.agent.waittimeout did not reproduce on this reconciled candidate, and no timeout or retry was added.The observed GitHub merge conflict was resolved against that pinned main, preserving its subscription access-only committed membership preparation/diagnostics and creator/admin archive requirement alongside retained chat admission. Fresh complete-diff review was scoped-clean through P2 (confidence 0.78); the rebased worker, real-client/provider, narrow mutation and scoped-read run passed 65/65 in 83.17 s wrapper (79.56 s Vitest, real-provider case 18.507 s). The existing assembled archive-tool case separately proved creator self-archive and assignee archive/restore denial (1/1 selected, 12 intentionally unselected, 23.35 s wrapper; case 3.091 s). Previous full-diff proof remains source-equivalent outside the two conflict seams; full suite/build was not repeated.
The final cap repair keeps the existing authorization parameter DTO with its existing authorization owner and reuses the identical predispatch argument object. It passed its own scoped-clean P2 review (confidence 0.94), final production types, scoped typed lint, formatting and type-edge Madge (zero cycles), without cap or baseline exceptions. The conflict replacement is published with a lease against verified prior head
3295154dbeb15c7afa62d810a2ce03a4d9d09be3; previous ratings and CI attempts do not qualify this new head.CI on
363819fd156a1fce9f7536d12a6954b59428d790(36772463343) found three ordinary Stop fixture admission failures in compact-small-11 (110082494113). Original-order replay reproduced 3 failures/37 passes; captured admission responses proved its complete session-utils mock removed the canonical model resolver. The fixture now preserves the real module and mocks only its owned lookup. All 40 original-order cases passed (38.22 s wrapper, 36.41 s Vitest); owning Gateway test types, exact CI-config typed lint, formatting and fresh P2 fixture review passed. Three equivalent admission-release expressions keep the existing file cap, with no suppression or weakened assertion.Remaining CI investigation: compact-large-2 (
110082501255) failedsetup-inference.first-signin.integration.test.ts:420expecting a reuse confirmation but receiving a note. One bounded existing-test replay reproduced that exact failure (76.96 s wrapper, 47.32 s Vitest). Its test/setup-admission/wizard source is unchanged against pinned main, which alone does not establish causality; the credential owner is investigating the actual provider context. Confirmation, owner isolation and revoked-retry/no-effect assertions remain intact. 128 CI checks succeeded and 31 were cancelled in that failed attempt; cancelled coverage is unproven. Durable prior-head ClawSweeper review reports overall4/proof5/patch4 with no actionable findings, historical after this fixture-only replacement; latest-head CI/rating remain pending.The sign-in investigation established a canonical dependency bug: setup supplied current host-authorized
existingProfiles, but Copilot reread an ambient runtime auth view and missed the reconnect credential. The vendor now consumes eligible host facts, treats explicitly empty/foreign profiles as unavailable, and carries the selected credential through its existing token/SecretRef resolver. Standalone absence still uses canonical store enumeration, including noninteractive setup; no SDK, config, state/schema, or permission expansion. Original registered sign-in passed with confirmation, same-owner replacement, other-owner isolation, stored-ref activation and revoked-retry no-effects assertions unchanged (61.80 s wrapper, 24.84 s Vitest). Three registered selected/empty/foreign authority cases passed (22.84 s wrapper) and all failed with original index bytes restored; token/interactive/tenant/noninteractive siblings passed 34 cases in 13.57 s wrapper. New cases add no timers, polling, or Gateway/process boots. Production types, scoped typed lint, formatting and fresh final P2 review passed (confidence 0.87).Known current CI gap: on
35b500088cc8afb71c8011d9b3b99ed7b46b08e3, run36775165544/job110091537327failed four existing global main/work seeded-chat QA cells at prepared authority before provider effects; the working agent-only sibling passed. One assembled replay reproduced the exact denial (687.24 s wrapper, dominated by 9m52s required first build; test49.29 s). A cheaper real qualified-worker/admission replay independently identified rawglobalversus qualifiedagent:owner:globalcomparison; the bounded codec repair is being verified separately and is not included in this Copilot-only commit. Required CI and durable exact-current ratings remain pending; historical35b5000review was overall4/proof5/patch4 without actionable findings.Final global repair: prepared admission now qualifies its expected original selected store key through the same
toAgentStoreSessionKeyowner asprepareQualifiedSessionEntryTarget. It preserves literal/raw aliases, exact logical agent, selected physical source and all original discovery/key-absence/lifecycle guards. Original assembled QA cell and cheaper actual qualified-worker consumer both rejected valid global work before the fix; fixed owning worker file passed 13 cases, then explicit main/work global plus qualified cases passed 3 (11.13 s wrapper), including independent wrong-owner no-effect controls. Fresh actual correction review was scoped-clean through P2 (confidence 0.87). Fixed assembled four seeded main/work cells and agent-only sibling were not completed locally: the wrapper forced a second full declaration build, stopped under the host limit with joined process-group cleanup (exit130). Those cells remain for required CI; no timeout, retry or assertion was weakened.The second actual merge conflict was reconciled on the pinned main above, preserving recovery commit
04f77bdb52bcf5b8b2669051e248e9d6bfb6cdfc. Main already contains canonical maintainer Copilot repair332e4d3ec02df53b18003155fe44a0a102b383e1; the superseded vendor commit was retired rather than retaining competing selection/secret readers or tests. Range-diff confirms all five retained Gateway commits are patch-identical. Final rebased worker/admission run passed 16 cases in 47.77 s wrapper (44.89 s Vitest); production types, line caps and type-edge Madge zero passed. Existing exact-head review/CI of older revisions is historical; durable replacement-head ratings and required CI remain pending.