Repository navigation
fix: preserve channel-owner revocation across recovery - #157709
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. |
|
Recording the previously approved campaign decision for this separate prerequisite: the shared-state SQLite bump from 18 to 19 is accepted, with:
This records the acceptance already granted in the coordinating session; it does not authorize merging. |
|
|
Codex review: needs maintainer review before merge. Reviewed September 24, 2026, 8:34 PM ET / September 25, 2026, 00:34 UTC (Revision 2). ClawSweeper reviewWhat this changesThe branch stores a versioned recovery reference and original plugin grant on a linked channel profile, retires them when authority changes, and advances shared-state SQLite to schema 19. Warning SQLite table change This PR modifies persisted SQLite tables in Merge readiness✅ Ready for maintainer review Current main still lacks durable channel-owner revocation history, and the two related open PRs address different parts of the workflow. The recorded schema decision and focused recovery evidence support keeping this prerequisite open; this review found no definite introduced defect. Priority: P1 Review scores
Verification
How this fits togetherChannel ingress connects a verified sender to a profile and Gateway operator permissions. The profile and state workers store the original authorization so recovery can return current authority or reject a retired reference. flowchart LR
A[Verified channel sender] --> B[Linked profile]
C[Gateway role and scope policy] --> D[Operator admission]
B --> D
D --> E[Stored recovery reference]
E --> F[Recovery authority check]
C --> F
F --> G[Current authority or rejection]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +410, Tests +511, Docs +44, Config 0, Generated +11, Other 0. Total +976 across 35 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Technical reviewBest possible solution: Keep recovery references with the linked-profile owner, then have the dependent final-delivery repair revalidate recovered authority immediately before adapter I/O. Do we have a high-confidence way to reproduce the issue? Yes. Current main has no durable recovery reference, and the PR supplies a focused revoke-and-restore regression path; this read-only review did not execute it. Is this the best way to solve the issue? Yes. The branch extends the existing profile, worker, and Gateway publication owners, with a separate consumer change reserved for final delivery. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against d9a69464657d. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
* commit '05edd36e124dc376f63475256f45e82ec437412c': (30 commits) refactor(matrix): reuse bounded direct-room cache insertion (#157775) fix: preserve channel-owner revocation across recovery (#157709) fix(ci): stop blocking CI during release validation (#157757) refactor(tlon): remove unreachable DM summary branches (#157789) chore: speed up worktree recovery tests with Bun (#157674) fix(sessions): release PR caches when pending viewers leave (#157776) refactor(twitch): reuse setup account selection (#157787) test: skip empty task ledger resets in cron fixtures (#157767) perf: reduce gateway and state test startup (#157711) fix: preserve maintenance leases during slow heartbeat renewal (#157696) fix(channels): match non-TTY setup advice to registered flags (#157551) fix: keep failed update report uploads in the CLI (#156633) fix: preserve rejected settings reason when opening config (#157731) test(update): load real filesystem dependencies in swap fixture fix(ci): prevent Security Review checkout retry collisions (#157652) fix(ci): recover interrupted Security Review response bodies (#157651) test(ui): capture live operator authority in guest question fixture refactor(agents): deslop runners, harness and recovery (#157294) fix(auth): preserve Copilot tenant credentials during Doctor repair (#139131) refactor(msteams): share stored service URL validation (#157706) ...
What Problem This Solves
Linked channel-owner admission through roles or identity scopes has no durable record of uninterrupted authorization, so a future recovery reader cannot distinguish an unchanged owner from one revoked and later restored.
Related: #157127. This is its standalone authorization prerequisite; it contains no pending-final or queue integration. PR #157298 improves live linked-person admission but does not supply durable revocation history.
User Impact
The native channel/profile owner can issue an opaque JSON reference and recover it only while the original authorization remains valid. Role/default/definition or configured identity-scope changes, profile role changes, link removal/replacement, profile merges, and original access-grant replacement retire or reject old references. Missing, corrupt, and unsupported references fail closed.
This advances shared-state SQLite from 18 to 19, under the recorded design acceptance. Agent schema is unchanged. Older builds must use a matching pre-upgrade backup in a separate state directory; lowering schema markers or removing the new fields is unsafe because it loses revocation history. Legacy links remain intact with no authorization backfill. References cannot be issued or recovered before schema 19 is published.
No final-delivery behavior changes in this PR. Recovery consumers will retain only
{version:1,id}, ask the command owner to recover authority, and revalidate that authority immediately before adapter I/O in the dependent repair. The reference carries no permission by itself and contains no raw channel identity, execution identity, or bearer secret.Why This Change Was Made
The existing channel-link row owns the reference and original access-policy grant. Existing profile mutations clear the reference in their original transaction; the existing machine-state record stores the active roles and identity-scope policy snapshot. Configuration activation and rollback now compute their exact target, commit retirement for changes to either policy under the existing activation lock, revalidate after the await, and publish synchronously. Failed or superseded publication reconciles durable policy with the surviving runtime snapshot.
The cutover removes duplicate rollback helpers and reuses the existing profile mutation publisher, worker operation, and read-worker path. It adds no production files, authority table, lifecycle registry, separate read/write wrapper family, or recovery fallback. Existing live authority and the intentional one-shot CLI path remain.
Evidence
Pre-fix owner regression: on
edf43e81630451bc6080779ea3040ed4d871016eplus the isolated Stage 1 activation refactor,node scripts/run-vitest.mjs src/channels/message-access/operator-authority.test.ts --maxWorkers=1 -t 'does not revive an admitted channel owner'exited 1: 2 failed, 11 skipped, 24.21s wall. After role-definition/default revoke-then-restore, the original command assertion incorrectly remained usable. The saved red patch is preserved separately.Fixed focused and sibling proof: after the identity-scope correction, 441 passed across 21 files, 293.62s wrapper wall. Covers normal activation, external and in-callback rollback, hook failure, publish failure, supersession, exact three-way merged successor, policy-write rollback, exact JSON recovery after reopen for both roles and identity scopes, role/scope/link/profile ABA, original-grant revocation/replacement/unavailability, missing/corrupt references, schema upgrade/deferred publication, profile/link/merge owners, requester/access-policy recovery, and command ACP/allowlist/plugin/config admission. Repository runtime build passed. After the mechanical lint cleanup, the 43 owner/schema cases passed again in 61.31s wrapper wall.
Real retained-v18 writer proof: candidate normal cold-open migration, Doctor migration, and deferred publication against the retained original v18 build all reject the old worker's revoke and restore operations with
SqliteSchemaVersionError. The deferred probe also rejects writes while published version is still 18 and content is 19. These use the ordinary worker and migration APIs, not an injected database. No lifecycle repair was needed or added.Published-driver compatibility: integrity-verified npm
[email protected]created its actual schema-15 update ledger; candidate Doctor applied content 19 with publication deferred; the shipped driver completed its ledger write and reopened/read the successful final record. This proves the affected updater/state boundary, not a full service installation.Actual bootstrap boundary: existing
server-startup-minimal-boot.test.ts, selected bootstrap case, passed (1 passed/1 intentionally unselected, 13.42s wrapper wall), exercising the real durable hook during startup.Diff secret scan: TruffleHog 3.97.8 exited 0 with zero verified or unverified secrets; verification stayed enabled.
git diff --checkpassed.Ordinary autoreview: completed at P2; one suggestion was rejected against the UUID contract and one was accepted and repaired, with red/green proof below. The full changed gate passed every type lane and all unused-export checks, then found only local lint issues. Those were fixed; the native proportional changed gate for the seven cleanup files completed with exit 0, including all 25 selected core/UI test type shards, all three unused-export scans, changed-file lint, the native schema guard, and zero runtime import cycles. Unchanged passing checks are retained as evidence, without skip flags or dependency changes.
Published exact-head checks and review: author, committer, authenticated writer, remote branch, and PR head verified as
joshavant/617436cece5a26c905b498108f493d0b8cd1bbee. Nativescripts/pr review-initsucceeded. All non-skipped initial checks passed; the initial CI run was Draft-skipped. Marking Ready attached CI run 36074654516 to the same head. Campaign disposition: non-attributable release-priority infrastructure.OPENCLAW_RELEASE_PRIORITY_RUN=36073359097; preflight was skipped;security-fastsucceeded;openclaw/ci-gateexplicitly reports that Full Release Validation holds hosted-runner priority. This run is excluded from campaign completion under the coordinating decision, not counted as passing test proof. No CI rerun, release-run monitoring, rebase, or branch change will be made for it. The already-running independent exact-head checks have settled; their disposition is recorded below. The ClawSweeper exact-head report found no code defects and cleared security review. Its sole rank-up request was a linked schema/downgrade acceptance record; that decision is now recorded. No score-driven code changes or duplicate review request were made.Independent exact-head checks: Security Review and iOS Periphery passed on
617436cece5a26c905b498108f493d0b8cd1bbee. Both platform scans in Shared OpenClawKit Periphery passed, but its intersection reports the pre-existingGatewayExternalAuthorizationError,init(), anderrorDescriptionatGatewayConnectionProblem.swift:4–7. Non-attributable: that file, both files containing its references, and the complete reference inventory are byte-identical between baseedf43e816304and this head. The declarations were introduced by ancestor commit be11b1a45e4; this PR's only Swift edit changes the separate native-state schema ceiling from 18 to 19. No unrelated declaration repair or CI rerun was made. The PR remains Ready under the campaign policy; excluded failures remain visible and are not represented as green.All runtime proof used isolated synthetic state and ports. No operator Gateway, real user data, dependency reconciliation, or Testbox was used. The already-classified unrelated Gateway/catalog CI timeout is out of scope and was not rerun or modified.
Owner boundary, size, and test cost
The invariant is uninterrupted original-owner authority, not equality of current identity or role. Existing live assertions and requester grant references did not preserve role-policy or identity-scope revocation across recovery. Tests exercise the existing native profile/worker boundaries; no test-only production seam was introduced.
Measured diff: production +762/−341 (net +421); tests/support +564/−53 (net +511); docs +44. This includes 116 moved preparation lines and 11 generated schema-type lines. The net-neutral absorbing refactor was attempted first: duplicate restore paths were removed, canonical table DDL/types replace feature-local duplicates, and redundant new-profile authority publications were removed.
Remaining net production blocks:
The owner file's 35 cases took 43.84s wrapper wall / 36.97s Vitest wall with
--maxWorkers=1; the schema file's 8 cases took 3.02s. They reuse existing isolated fixtures and native worker pools. No sleeps, polling, per-test Gateway boots, worker pin, or serial configuration was added. Native worker settlement and durable reopen behavior require this boundary; helper-only tests would miss the original defect. Local proof is complete. The published head is617436cece5a26c905b498108f493d0b8cd1bbee; this PR is Ready for maintainer review. CI test seconds are not yet available: the initial Draft run was skipped, and the Ready-state run is deferred by the repository-wide release-priority hold.Retained-v18 exclusion was personally traced through
sqlite-store.worker.ts,sqlite-worker-lifecycle-preparation.ts,openclaw-state.worker.ts,openclaw-state-db-cache.ts,openclaw-state-db-runtime-failure.ts, andopenclaw-state-db-schema-version.ts: the normal operation retains lifecycle admission and checks both published and content schema support before using a retained handle.Ordinary review dispositions
The independent review reported two P2 suggestions:
z.uuid()insrc/state/github-publication-requester.ts:14. Widening this codec would depart from that owner-native contract.gateway.rolesandgateway.auth.identityScopes; changes to either retire references through the same pre-publication hook. Identity-scope-only admission and recovery use that same fact, rather than treating null roles as continuity. The regression commandnode scripts/run-vitest.mjs src/channels/message-access/operator-authority.test.ts --maxWorkers=1 -t 'identity-scopes|original identity-grant'failed before the fix (3 failed/32 skipped, 12.65s wall): scope remove-and-restore kept the original assertion usable and produced no recovery reference. After the fix it passed (3 passed/32 skipped, 26.01s wall), including exact JSON reference recovery after database reopen and permanent retirement after removal/restoration. The behavioral correction adds 8 net production lines. Repository-required braces subsequently add 26 formatting lines across the prerequisite; no additional behavior or owner surface was added.The review used the supplied diff and source datasets; the first finding did not have the unchanged plugin type or durable-grant documentation in its bundle. No second ordinary review was run to seek a different verdict.