Repository navigation
refactor(gateway): simplify operator run authority capture - #169607
Conversation
Capture the role and model ceiling from current committed config after profile preparation. Accept role policy changes reverted during that lookup while preserving explicit assignment and source revocations.
|
🦞👀 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 real behavior proof before merge. What this changesThis PR captures operator role and model permissions after profile preparation instead of replaying intermediate policy changes. Example: While a reader's profile lookup is pending, its role loses operator.read and then regains it.
Review scores
ProductKind: Refactor · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Blocked before merge - 2 items remain Keep this PR open: it is a focused, maintainer-approved simplification, and no concrete introduced defect was found. Priority: P2 Before merge
FindingsNone. Tests
Agent review detailsHow this fits togetherGateway admission combines an authenticated client, prepared profile, and committed policy into retained authority consumed by agent execution and session mutations. flowchart TD
A[Authenticated Gateway client] --> B[Prepare profile identity]
B --> C[Capture committed role and model ceiling]
C --> D[Retained operator authority]
E[Source and policy changes] --> D
D --> F[Provider execution and session mutations]
Technical reviewBest possible solution: Keep one authority owner that selects committed policy after preparation and preserves live source, assignment, and effect-boundary checks. Do we have a high-confidence way to reproduce the issue? This is an intentional refactor; source inspection establishes the timing change, and the body reports negative controls against original production code. No target code was executed during this read-only review. Is this the best way to solve the issue? The change removes snapshot replay from the existing owner, preserves source and assignment revocation, and explains its intentional departure from the earlier pre-await ceiling. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against a3d06a628043. Provenance checked
TestingProof path: in-process harness. SecurityNeeds attention: No concrete authorization bypass was found, but the changed admission baseline remains security-sensitive. EvidenceWhat I checked:
Likely related people:
PR surfaceSource -35, Tests +8. Total -27 across 2 files. Added test files: 0. View PR surface stats
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 HistoryReviewed October 12, 2026, 1:23 AM ET / 05:23 UTC (Revision 3). |
|
|
Merged via explicitly authorized admin squash with attributed pre-existing CI failures.
|
…169607) * refactor(gateway): simplify operator run authority capture Capture the role and model ceiling from current committed config after profile preparation. Accept role policy changes reverted during that lookup while preserving explicit assignment and source revocations. * docs(gateway): drop internal capture timing note from operator scopes
What Problem This Solves
Simplifies operator run admission by removing intermediate role-policy snapshots taken while the profile lookup is pending.
User Impact
No user-visible change except the accepted tradeoff: a role-policy downgrade reverted while a turn's profile lookup is pending no longer revokes that turn. Capture uses the current role and model ceiling after the lookup. Explicit role-assignment changes, device/source revocations, persistent scope downgrades, and post-capture policy changes retain their existing checks.
Why This Change Was Made
The worker-backed profile read introduced snapshot/replay machinery to latch millisecond downgrade-and-restore races. The current profile and committed configuration provide the admission policy instead. Config/profile subscriptions remain registered before the await and recheck the captured policy afterward. The model-policy intersection semantics are unchanged.
Production: 17 additions / 52 deletions (net -35 lines). Tests: 10 additions / 2 deletions (net +8). Documentation: +6. Total: net -21 lines. One redundant outer capture assertion was removed; the source-callback guards and final assertion remain.
Evidence
The revised tests against the original production file fail in exactly the three intended cases (restored policy and widened/narrowed model ceiling): 16 pass, 3 fail, 157.94 s. The final candidate passes all 71 focused tests, run locally one file at a time:
pnpm test src/gateway/operator-run-authority.worker.test.ts --maxWorkers=1pnpm test src/gateway/operator-role-policy.test.ts --maxWorkers=1pnpm test src/gateway/operator-run-recovery.test.ts --maxWorkers=1node scripts/run-oxlint.mjs --tsconfig config/tsconfig/oxlint.core.json src/gateway/operator-run-authority.ts src/gateway/operator-run-authority.worker.test.tspnpm exec oxfmt --check src/gateway/operator-run-authority.ts src/gateway/operator-run-authority.worker.test.tsgit diff --checkWall times include worker compilation/cache verification and shared-host load. The unchanged recovery suite proves retained authority and model ceilings through the real profile/state owners. No broad local suite was run; CI test-job seconds are not yet available.
Independent Codex reviews: pre-commit and committed branch both scoped-clean at P1, with no accepted/actionable findings.
Remote changed gate: failed on an inherited dead-export scan; every other planned check passed. The candidate and unchanged base each report the same 111 unique unused-export findings, with no candidate-only or base-only entries. No failure was ignored or relabeled without the base comparison.
Testbox lease
tbx_01m4q07vfkeapz6tn139b26ra3remained queued beyond 15 minutes and was stopped before running checks. The authorized AWS fallback used leasecbx_dfbe7918fbcf. After the wrapper stalled during source staging/sync, the installed Crabbox CLI cloned the pushed branch and verified commit9878959dd0d045e31e3de8e7e504342ccff02da2and its parent before executing the same gate:node scripts/check-changed.mjs --base e4822908bfda6aaade172729045c5f0797b5d3dc: runrun_bb5cecfa9d598975ba81e70411f6edf5, 701.05 s for the gate (814.83 s outer wall); failed at dead exports after formatting, ratchets, core typecheck, and all 28 test typecheck graphs passed.node --import tsx scripts/check-deadcode-exports.mtson unchanged basee4822908bfda6aaade172729045c5f0797b5d3dc: same 111 findings, 96.25 s.run_07f0670e15f56d9bb7c8faa4cdcf406e, 326.71 s outer wall.The aggregate changed gate is therefore not green. No unrelated dead-export cleanup is included in this focused refactor. This PR remains draft.
Landing disposition
Current-head CI 38205185674, attempt 1 stopped at the UI bundle:
OptionCardis imported byui/src/pages/custodian/custodian-surface.tsxbut was not exported byui/src/components/option-card.tsx. This occurs before tests or Gateway execution. The actual tested merge is9c4b78130e9767fed86f1603b10f587a615b9d8f, with baseline50792af5c1542c231421b8e1ed2f3706cd1a31e4and this PR head as its ordered parents; its tree matches Git's merge of those parents. The failing UI sources, bundle setup, CI workflow, and cancellation monitor are identical between that baseline and the tested merge. The sole UI failure caused 28 sibling cancellations; those remain unrun coverage. Main already contains the independent repair 3eaac9c250a0. Landing uses the native inherited-failure exception; CI is not represented as green.ClawSweeper completed review of
030ebfbff345d52a4bed645c889e616c7df75914with no concrete findings. Its request for another final-effect demonstration is declined for this scoped simplification: the accepted timing change is proven at the real profile/authority owner, with original-production negative controls and the unchanged role-policy/recovery suites; the effect dispatch contract is unchanged. The lead-approved Codex review remains scoped-clean at P1. The independently enforced dependency and security-sensitive checks pass.