Skip to content

refactor: consolidate operator recovery admission - #166759

Merged
RomneyDa merged 1 commit into
mainfrom
refactor/operator-recovery-dedup
Oct 7, 2026
Merged

RomneyDa merged 1 commit into
mainfrom
refactor/operator-recovery-dedup

Conversation

@RomneyDa

@RomneyDa RomneyDa commented Oct 7, 2026 •

Copy link
Copy Markdown
Member

Related: #166553 — preserve authenticated operator access after Control UI restart recovery.

What Problem This Solves

Maintainer-requested follow-up removes duplicate model-policy preparation, recovery type definitions, and authority construction from the merged restart-recovery repair.

User Impact

No user-visible behavior change. Automatic recovery retains the original authenticated basis and scope/model ceilings; source-less claims remain restricted. No new durable fields, configuration options, SQLite schema/version, migration, protocol, or setup action.

Why This Change Was Made

  • Original Gateway and channel/recovered admissions now share one lifecycle-cached model-policy reader. The Gateway's pre-await baseline, channel admission baseline, and recovery's additional original ceiling remain distinct.
  • Recovery types derive from the existing strict schemas; the duplicated handwritten type module is removed. Runtime schema restrictions and stored shape are unchanged.
  • Capture the recovery snapshot from the narrow prepared admission facts, then issue one host authority instead of building and wrapping two. Preserve the frozen original grant and source checks before/after capture.

Production LOC: +99/-128 (net -29). Tests: +8/-0. No generated, lockfile, or documentation changes.

Intentional repetition retained: identity/source checks around policy callbacks, subscriptions before awaited preparation, exact source-claim reread, original/re-admission/current model ceilings, and first resumed access-owner retention. These protect observable revocation and ordering contracts rather than duplicating policy.

Evidence

  • Original production baseline: 69 tests passed across model policy, original/recovered admission, actual Cron creator transport mutations, and runtime recovery.
  • Extended the existing recovery boundary test with post-restoration policy widening. It passed against unchanged production code before the refactor, proving preservation of both admission ceilings rather than inventing new behavior.
  • Final focused owner/sibling test run: 82 passed across seven files, including inherited host-issuance identity and channel ingress siblings. Wrapper exit 0.
  • pnpm build: passed (exit 0). Changed-check guards, formatting, production/test typing, and dead-export scans passed. Full core lint found two shadowed local names in the new call site; after renaming the binding, focused typed lint and production typing passed (exit 0). No remaining accepted/actionable findings.
  • Build report-only note / separate follow-up: the unchanged Control UI startup bundle reports 364.8 KiB gzip against a 364.7 KiB budget. No UI source, asset budget, or baseline is changed here; this is not claimed as a passing UI performance check.
  • Patch-identical rebase (git range-diff reports =) onto 38c96048a56, which only changes unrelated CLI schema handling. Published head: e3633085263fd4524699096cbf8f2e40b8304d55.
  • Fresh AutoReview: P0 scoped-clean, no accepted/actionable findings; the reviewer explicitly notes its supplied-diff scope. Independent hands-on source audit found no actionable behavior-preservation issue.
  • Behavior-neutral internal refactor: focused owner/boundary proof; no new live-provider or UI recording claimed.
Focused validation commands
node scripts/run-vitest.mjs src/gateway/operator-run-authority.worker.test.ts src/gateway/operator-run-recovery.test.ts src/gateway/server-methods/cron-creator-transports.integration.test.ts src/gateway/server-instance-runtime.operator-recovery.test.ts src/agents/operator-model-policy.test.ts src/gateway/operator-run-authority.module-identity.test.ts src/channels/message-access/participant-input.test.ts
node scripts/check-changed.mjs
pnpm build
# Focused repeat after the lexical binding rename:
node --import ./scripts/tsx.mjs scripts/run-oxlint.mts --tsconfig config/tsconfig/oxlint.core.json src/gateway/operator-run-authority.ts
node scripts/run-tsgo.mjs -p tsconfig.core.json --incremental --tsBuildInfoFile .artifacts/tsgo-cache/core.tsbuildinfo
.agents/skills/autoreview/scripts/autoreview --mode uncommitted

CI Recovery

The original head e3633085263fd4524699096cbf8f2e40b8304d55 reproduced the five CI failures in directive-handling.mixed-inline.test.ts: session model selection now performs a placement read through the shared-state broker, but the test still ran in the thread-based auto-reply suite. The CI fail-fast job then cancelled the remaining selected lanes.

Main already repaired the test owner in 3cbd049ccfd8: the three directive consumers run in the forked SQLite-host suite, preserving every assertion and production behavior. Rebased this follow-up onto 06a1b56f5c9b8d39ff895a6cb60ff5954a7160bb; git range-diff reports =. No additional production or test edits.

Current head: 4c9512f595ab3f6a628c6d6dbcb5fc0b3bcf7ecf.

Verification:

  • Before rebase: node scripts/run-vitest.mjs src/auto-reply/reply/directive-handling.mixed-inline.test.ts — 5 failed, 21 passed; same broker error as CI.
  • After rebase: node scripts/run-vitest.mjs src/auto-reply/reply/directive-handling.mixed-inline.test.ts src/auto-reply/reply/directive-handling.model.test.ts src/auto-reply/reply/get-reply-native-slash-fast-path.test.ts — 172 passed, wrapper exit 0 (84.51s).
  • git diff --check — passed.
  • Main CI at the new base: 37693510359 — succeeded.

Exact-head CI run 37693961635 completed successfully on 4c9512f595ab3f6a628c6d6dbcb5fc0b3bcf7ecf, including the previously failing shard, build, UI E2E, production/test typing, and lint. Prior-head CI remains prior-head evidence. PR remains unmerged.

@clawsweeper

clawsweeper Bot commented Oct 7, 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.

@RomneyDa
RomneyDa marked this pull request as ready for review October 7, 2026 21:47
@github-actions

github-actions Bot commented Oct 7, 2026 •

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: 4c9512f595ab3f6a628c6d6dbcb5fc0b3bcf7ecf
  • Maintainer: @RomneyDa
  • Repository role: maintain

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.

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime agents Agent runtime and tooling size: M labels Oct 7, 2026
@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 7, 2026
@clawsweeper

clawsweeper Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed October 7, 2026, 6:12 PM ET / 22:12 UTC (Revision 2).

ClawSweeper review

What this changes

The PR consolidates operator model-policy preparation, derives restart-recovery types from existing validation schemas, and captures recovery facts before issuing one host authority.

Merge readiness

✅ Ready for maintainer review

This remains a useful maintainer-authored cleanup that current main does not contain. No actionable correctness or security defect was found; ordinary exact-head CI and landing gates remain.

Priority: P3
Reviewed head: 4c9512f595ab3f6a628c6d6dbcb5fc0b3bcf7ecf

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, maintainable cleanup with meaningful boundary coverage and no supported blocking finding.
Proof confidence 🌊 off-meta tidepool Not applicable: The member-authored behavior-preserving refactor is exempt from external-contributor runtime proof. Reported owner/sibling validation exercises admission and recovery, and source inspection found no material authority expansion requiring additional final-effect proof. Schema-derived types retain the unchanged stored format; tests and builds were not rerun by this reviewer.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The member-authored behavior-preserving refactor is exempt from external-contributor runtime proof. Reported owner/sibling validation exercises admission and recovery, and source inspection found no material authority expansion requiring additional final-effect proof. Schema-derived types retain the unchanged stored format; tests and builds were not rerun by this reviewer.
Evidence reviewed 7 items Pinned introduction and merge ownership: The introduced delta contains only the seven declared recovery/admission paths. Raw test-merge parents are the pinned main SHA followed by the exact PR head; its resulting delta retains the same scope.
Preserved admission and revocation behavior: The shared reader preserves the original policy and intersects refreshed committed config/metadata. Gateway admission still subscribes before awaited preparation, freezes the captured grant, checks authority around snapshot capture, and issues the same source token with the existing retention and revocation closures.
Stored format and complete type cutover: Recovery types now derive from unchanged strict schemas. The snapshot capture receives only the facts it consumes; serialized fields, validation bounds, and decoding remain unchanged. Repository search found no remaining references to the removed type module.
Findings None None.
Security None None.

How this fits together

Operator admission carries an authenticated caller’s permissions into agent execution. Restart recovery uses the captured source facts to restore interrupted work under current policy while preserving the original permission ceilings.

flowchart TD
  A[Authenticated operator input] --> B[Prepare admission facts]
  B --> C[Capture recovery snapshot]
  C --> D[Issue host authority]
  D --> E[Agent execution]
  C --> F[Restart recovery]
  F --> G[Current policy and original ceilings]
  G --> E
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source -29, Tests +8. Total -21 across 7 files.

View PR surface stats
Area Files Added Removed Net
Source 6 99 128 -29
Tests 1 8 0 +8
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 7 107 128 -21

Review metrics

None.

Technical review

Best possible solution:

Keep one admission-policy reader and schema-owned recovery types while preserving live revocation, source custody, and both model ceilings.

Do we have a high-confidence way to reproduce the issue?

Not applicable: this PR preserves existing behavior rather than reporting a new defect; source inspection and the extended boundary test establish the intended invariants.

Is this the best way to solve the issue?

Yes: consolidating existing preparation and deriving types from their validation owner removes duplication without adding another authority or changing the recovery contract.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 90d30a1178a7.

Labels

Label changes:

No label changes.

Label justifications:

  • P3: This is a behavior-preserving internal cleanup with no new configuration, setup action, or user-facing capability.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The member-authored behavior-preserving refactor is exempt from external-contributor runtime proof. Reported owner/sibling validation exercises admission and recovery, and source inspection found no material authority expansion requiring additional final-effect proof. Schema-derived types retain the unchanged stored format; tests and builds were not rerun by this reviewer.

Evidence

What I checked:

  • Pinned introduction and merge ownership: The introduced delta contains only the seven declared recovery/admission paths. Raw test-merge parents are the pinned main SHA followed by the exact PR head; its resulting delta retains the same scope. (2d5668f6bbf4)
  • Preserved admission and revocation behavior: The shared reader preserves the original policy and intersects refreshed committed config/metadata. Gateway admission still subscribes before awaited preparation, freezes the captured grant, checks authority around snapshot capture, and issues the same source token with the existing retention and revocation closures. (src/gateway/operator-run-authority.ts:129, 4c9512f595ab)
  • Stored format and complete type cutover: Recovery types now derive from unchanged strict schemas. The snapshot capture receives only the facts it consumes; serialized fields, validation bounds, and decoding remain unchanged. Repository search found no remaining references to the removed type module. (src/gateway/operator-run-recovery-source.ts:70, 4c9512f595ab)
  • Meaningful boundary-test extension: The existing recovery test now widens current policy after restoration and verifies that only the intersection of original and re-admission ceilings remains available. It adds no fixture boot, timer, or production test seam. (src/gateway/operator-run-recovery.test.ts:505, 4c9512f595ab)
  • Current-main necessity and feature history: Current main still builds an authority and then wraps it to attach the recovery snapshot. Its history includes the merged recovery repair by RomneyDa and earlier role-policy work by Peter Steinberger. GitHub independently confirms fix: preserve operator access after Control UI restart recovery #166553 merged; that repair establishes the behavior this distinct cleanup preserves. (src/gateway/operator-run-authority.ts:546, 90d30a1178a7)
  • Re-review continuity: GitHub contents API blob hashes for the authority owner, recovery-source owner, and changed test at the earlier reviewed head exactly match the current checkout. Local inspection of that older commit failed because required objects could not be fetched; the independent GitHub blob comparison recovered the relevant continuity evidence. The prior structured review contains no findings or published rank-up moves. (src/gateway/operator-run-authority.ts, 4c9512f595ab)

Likely related people:

  • RomneyDa: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (1 earlier review cycle)
  • reviewed 2026-10-07T21:53:10.614Z sha e363308 :: needs maintainer review before merge. :: none

@RomneyDa
RomneyDa force-pushed the refactor/operator-recovery-dedup branch from e363308 to 4c9512f Compare October 7, 2026 22:06
@RomneyDa
RomneyDa merged commit 2a30561 into main Oct 7, 2026
141 checks passed
@RomneyDa
RomneyDa deleted the refactor/operator-recovery-dedup branch October 7, 2026 22:24
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling gateway Gateway runtime P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. security-sensitive-changed size: M status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant