Skip to content

refactor(gateway): simplify operator run authority capture - #169607

Merged
steipete merged 2 commits into
mainfrom
refactor/operator-run-capture
Oct 12, 2026
Merged

steipete merged 2 commits into
mainfrom
refactor/operator-run-capture

Conversation

@steipete

@steipete steipete commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

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:

Command Result Wall time
pnpm test src/gateway/operator-run-authority.worker.test.ts --maxWorkers=1 19 passed 101.91 s
pnpm test src/gateway/operator-role-policy.test.ts --maxWorkers=1 26 passed 235.91 s
pnpm test src/gateway/operator-run-recovery.test.ts --maxWorkers=1 26 passed 179.80 s
node scripts/run-oxlint.mjs --tsconfig config/tsconfig/oxlint.core.json src/gateway/operator-run-authority.ts src/gateway/operator-run-authority.worker.test.ts Passed 21.79 s
pnpm exec oxfmt --check src/gateway/operator-run-authority.ts src/gateway/operator-run-authority.worker.test.ts Passed 1.85 s
git diff --check Passed 2.50 s

Wall 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_01m4q07vfkeapz6tn139b26ra3 remained queued beyond 15 minutes and was stopped before running checks. The authorized AWS fallback used lease cbx_dfbe7918fbcf. After the wrapper stalled during source staging/sync, the installed Crabbox CLI cloned the pushed branch and verified commit 9878959dd0d045e31e3de8e7e504342ccff02da2 and its parent before executing the same gate:

  • node scripts/check-changed.mjs --base e4822908bfda6aaade172729045c5f0797b5d3dc: run run_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.mts on unchanged base e4822908bfda6aaade172729045c5f0797b5d3dc: same 111 findings, 96.25 s.
  • All nine commands planned after the failed scan (focused lint, schema, storage, media, runtime-sidecar, import-cycle, and auth guards) passed separately on the candidate. Base comparison plus remaining checks: run 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: OptionCard is imported by ui/src/pages/custodian/custodian-surface.tsx but was not exported by ui/src/components/option-card.tsx. This occurs before tests or Gateway execution. The actual tested merge is 9c4b78130e9767fed86f1603b10f587a615b9d8f, with baseline 50792af5c1542c231421b8e1ed2f3706cd1a31e4 and 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 030ebfbff345d52a4bed645c889e616c7df75914 with 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.

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.
@clawsweeper

clawsweeper Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime size: S labels Oct 12, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Oct 12, 2026
@clawsweeper

clawsweeper Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

What this changes

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

  • Before: The intermediate policy change permanently revokes the pending capture.
  • After: Capture accepts the restored policy, while explicit assignment changes and source revocations remain terminal.

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The focused implementation has no concrete findings, but supplied authority-owner tests do not settle final-effect authorization.
Proof confidence 🦪 silver shellfish (2/6) Real behavior proof is necessary before merge. See Before merge.
Patch quality 🦐 gold shrimp (3/6) Security review found an item that needs attention.

Product

Kind: Refactor · Worth it: Yes · Fix scope: Complete
User problem: Pending admission retains intermediate policy snapshots to reject a downgrade that has already been restored.
Reason: The maintainer explicitly accepts current-policy capture after preparation, and the patch removes the superseded replay path without creating another authority owner.

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
Reviewed head: 030ebfbff345d52a4bed645c889e616c7df75914

Before merge

  • Add real behavior proof - Authority-chain proof required: the supplied tests exercise real profile and recovery owners, but the changed pending-capture scenario ends at a mocked effect. Provide redacted terminal output or logs through production execution showing restored-policy admission and persistent scope downgrade rejection, plus source revocation or role reassignment preventing retained work from reaching provider I/O or a durable mutation. The body declines the previous request because dispatch is unchanged; that explains the decision but does not supply the required final-effect evidence. Redact credentials, IPs, phone numbers, and non-public endpoints. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Resolve security review attention item - No concrete authorization bypass was found, but the changed admission baseline remains security-sensitive.

Findings

None.

Tests

  • Missing end-to-end proof: Missing production final-effect evidence for restored-policy admission and persistent downgrade or revoked/reassigned retained authority rejecting before provider I/O or a durable mutation.
Agent review details

How this fits together

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

Technical review

Best 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

  • Intermediate role-policy replay during profile preparation changes intended behavior with a stated reason (ed81a70: Preserve authorization changes across worker-backed profile preparation so revocation cannot disappear behind restoration.)
  • Pre-await model-policy baseline changes intended behavior with a stated reason (2a30561: Consolidate model-policy preparation while preserving distinct original, channel, and recovery ceilings; this PR explicitly moves the original Gateway baseline after preparation.)
  • Source custody and assignment revocation keeps the original intent (715077a: Keep accepted, queued, and delegated work attached to its original operator and current authorization.)

Testing

Proof path: in-process harness.

Security

Needs attention: No concrete authorization bypass was found, but the changed admission baseline remains security-sensitive.

Evidence

What I checked:

Likely related people:

  • Dallin Romney: Raw commit 2a30561 adds src/gateway/operator-run-authority.ts:593 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 2a305612539c; files: src/gateway/operator-run-authority.ts)

PR surface

Source -35, Tests +8. Total -27 across 2 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 17 52 -35
Tests 1 10 2 +8
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 27 54 -27

Labels

Label changes:

No label changes.

Label justifications:

  • P2: Focused internal admission simplification with an accepted timing tradeoff and no established urgent regression.
  • merge-risk: 🚨 security-boundary: Moves the role and model authorization baseline across an await; the timing tradeoff is accepted, while final-effect authority proof remains required.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🦐 gold shrimp.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Rank-up moves

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

  • Add final-effect proof for restored-policy admission and revoked or reassigned retained execution, showing rejection before provider I/O or a durable write.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (2 earlier review cycles)
  • reviewed 2026-10-12T04:36:44.053Z sha 9878959 :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-12T04:53:25.965Z sha 030ebfb :: needs real behavior proof before merge. :: none

Reviewed October 12, 2026, 1:23 AM ET / 05:23 UTC (Revision 3).

@openclaw-barnacle openclaw-barnacle Bot removed the docs Improvements or additions to documentation label Oct 12, 2026
@steipete
steipete marked this pull request as ready for review October 12, 2026 04:46
@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Security sensitive changes

This maintainer PR changes sensitive security components.

No secops approval is required. This comment is informational because the PR author has Maintain or Admin access.

  • Current SHA: 030ebfbff345d52a4bed645c889e616c7df75914
  • Maintainer: @steipete
  • Repository role: admin

These security sensitive changes were made:

  • src/gateway/operator-run-authority.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.

Carefully review these changes before merging.

@steipete
steipete merged commit b38650a into main Oct 12, 2026
167 of 200 checks passed
@steipete
steipete deleted the refactor/operator-run-capture branch October 12, 2026 05:24
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via explicitly authorized admin squash with attributed pre-existing CI failures.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 13, 2026
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. security-sensitive-changed size: S status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant