Skip to content

fix: preserve queued send permissions across Gateway restarts - #196540

Merged
joshavant merged 1 commit into
mainfrom
fix/queued-app-authority
Nov 10, 2026
Merged

joshavant merged 1 commit into
mainfrom
fix/queued-app-authority

Conversation

@joshavant

@joshavant joshavant commented Nov 10, 2026 •

Copy link
Copy Markdown
Collaborator

What Problem This Solves

Queued sends can resume under the sender’s broader current permissions after a Gateway restart instead of retaining the source that accepted each input.

User Impact

Each queued send keeps its original app, membership, scope, and model limits. Replay requires that source’s current authorization. Missing or revoked sources become failed sends that can be submitted again; older markers without source evidence also require resubmission.

Why This Change Was Made

Capture the accepted source on the existing pending-input owner before request shutdown, retain it in the private restart marker, and restore it through the existing authority owner. This preserves FIFO replay and keeps live authorization checks through execution. It requires no database schema migration.

Evidence

  • The original regression replayed both inputs with administrator scope; the repair preserves each input’s separate scope ceiling. Missing sources, mismatched run IDs, and device revocation cancel replay. Existing delivery, runtime settings, mentions, and restart-admission tests remain covered: 93 tests passed across 7 files. Two additional recovery-owner tests passed for intersecting the original model ceiling with current policy and preserving live channel work at recovery bounds (38 unrelated cases intentionally unselected).
  • An isolated issuer/Discovery/native-ID/Gateway composition passed real app consent, a file-write positive control, actual process restart and automatic queued replay. Both a held-model run and a stronger held-filesystem-admission run refused the queued effect after signed membership removal. In the latter, the model supplied the actual write tool call, the write reached filesystem admission with the original ID source, membership advanced from sequence 3 to 4 while the write was paused, and the ordinary product path refused it after resuming. The run settled with an error, no file was created, and the separate app remained usable. Sanitized receipt output is included below. This uses a retained Gateway source fixture with the changed owner modules, a synthetic external relay, and a deterministic model; it is not a full-package or deployed-service attestation.
  • Core and Gateway-test typechecks, targeted lint/format, docs MDX/link checks, and diff checks passed.
  • The repository CI-artifact build and test-line ratchet passed. Package Acceptance built an installable package from the exact candidate commit and passed package integrity checks. The npm 12 install.sh step passed, but its separate installed-tree budget check failed: 50,913 entries against a 47,500 budget. This branch leaves dependency manifests and packaging scripts unchanged; the exact base count has not been independently reproduced. Release publication and deployed services were not tested.
  • Local autoreview of the final staged change against 802f67d8d410f4f48cb57c954ab84350a921290a, covering P0–P3, found no actionable defects. It reviewed the full diff and supplied owner code; it did not independently verify runtime evidence or cover every unchanged admission/final-effect implementation. Local ClawSweeper was unavailable. The completed hosted re-review of this exact head accepted the runtime and stable-upgrade evidence, found no actionable findings, and marked the PR ready for maintainer review. The red CI gates remain recorded below.
  • CI for 512886c5a869 has an inherited formatting failure in scripts/lib/full-release-child-reuse.mjs, test/scripts/full-release-receipt-recovery.test.ts, test/scripts/plugin-npm-cli-process.test.ts, and test/scripts/plugin-npm-cli-recovery.test-support.mjs. All four files are byte-identical between CI's main base b85de3162b1d92beefd2bbae220ff7a3599f88b6 and merge 2ca64dd2f95b7152cca7cf85f8c3724aa8ba29c4; checking those exact main files reproduced the same four failures. This branch changes no formatter code, configuration, or dependencies. The CI helper initially classified it as new against an older passing scheduled main job; exact-base inspection established that it is inherited. All other selected CI jobs passed, including builds, test/type/lint shards, and all three PostgreSQL conformance shards; the final CI gate failed solely on this formatting job.

The test-line allocation grants exactly 101 net lines for the distinct per-input scope, source-rejection, and revocation regressions and updated restart expectations. The source change adds 42 net production lines and reuses existing pending-input custody and recovery ownership.

Sanitized native process-restart and filesystem-admission receipt

The following allowlisted fields were extracted from the actual runtime receipt. Private fixtures and credentials are omitted; the archive hashes identify retained local evidence and do not make those private archives public. All twelve source modules in the candidate archive were verified byte-for-byte against this commit. The observation hook pauses the real filesystem operation before its normal authorization check; it does not simulate the write or its refusal.

{
  "candidateCommit": "512886c5a869a6cabcfeb3a6066b38434a503dce",
  "candidateOwnerArchiveSha256": "443b8a046272042f693586398826df19d6e943d313a2f57c1904d439f0c5ad16",
  "privateRuntimeArchiveSha256": "ff7ae550e7162ea77e9eb0d31e13916605849b88fd0a09daa1f473c33490b22d",
  "startedAt": "2026-11-10T09:23:02.283Z",
  "finishedAt": "2026-11-10T09:23:23.286Z",
  "status": "passed",
  "stage": "completed",
  "cleanupJoined": true,
  "phases": [
    {
      "phase": 0,
      "status": "passed",
      "normalStartup": true,
      "actualPluginHandshake": true,
      "startupAdmissionReady": true,
      "finalAuthoritySeq": 1,
      "ownersClosed": true
    },
    {
      "phase": 1,
      "status": "passed",
      "normalStartup": true,
      "actualPluginHandshake": true,
      "startupAdmissionReady": true,
      "actualMemberConsents": 2,
      "realAppAgentWrite": true,
      "queuedOriginalAppAndMembershipRetained": true,
      "queueRetainedForRealShutdown": true,
      "controlAppUsable": true,
      "finalAuthoritySeq": 3,
      "ownersClosed": true
    },
    {
      "phase": 2,
      "status": "passed",
      "normalStartup": true,
      "actualPluginHandshake": true,
      "startupAdmissionReady": true,
      "queuedRunReachedProviderBeforeRemoval": true,
      "queuedWriteReachedFilesystemAdmission": true,
      "queuedWriteResumedAfterMembershipRemoval": true,
      "originalSourceRestoreRefused": true,
      "queueProviderWriteSupplied": true,
      "queuedEffectObserved": false,
      "removedQueuedInputDenied": true,
      "controlAppUsable": true,
      "finalAuthoritySeq": 4,
      "ownersClosed": true,
      "queuedRunCompletion": {
        "status": "error",
        "startedAt": 1794302602828,
        "endedAt": 1794302602924,
        "stopReason": "rpc"
      }
    }
  ],
  "gatewayFixtureBase": "78b4d953dbd8985eba02bea7d3f112b987c53056",
  "candidateModulesMatchCommit": true,
  "matchedSourceModules": 12,
  "wholeCandidatePackage": false,
  "limitations": [
    "Retained Gateway fixture plus the twelve verified source modules; not a full-current-package or deployed-service attestation.",
    "Actual issuer, Discovery, native transport, app consent, agent and filesystem write; local external relay and deterministic SSE model fixtures.",
    "NODE_ENV=test enables an observation hook that only pauses the actual filesystem admission and reads source identity. It performs no authority validation or simulated refusal. No Vitest or module mocks."
  ]
}

Latest-stable upgrade proof passed in the published-upgrade-survivor lane, with inspectable summary and logs. The published [email protected] updater replaced its release build with candidate source 512886c5a869a6cabcfeb3a6066b38434a503dce. Candidate and installed-package identity checks, automatic migration, seeded configuration/session/transcript survival assertions, and Gateway startup/readiness/status all passed. This was the base scenario with manual Gateway startup after the update; it does not attest a managed service restart or live deployment. The overall Package Acceptance run failed solely on the separate installed-tree budget check described above. The stable source (b556fdf457b026574bf0f1e7b4914b15f3f179ce) contains none of resumeAfterRestart, queuedInputIds, or continueSessionQueuedInputs: this restart marker is a pre-release mechanism. Source-less pre-release marker rejection is covered by the committed restart and per-input regression tests; a source-less marker cannot be generated by that stable release.

Published-package upgrade receipt

The following fields are projected from the admission record and successful upgrade receipt. The before/after build IDs establish that the source package replaced the stable release even though their manifest versions match.

{
  "status": "passed",
  "runId": 42789639049,
  "candidateCommit": "512886c5a869a6cabcfeb3a6066b38434a503dce",
  "toolingCommit": "0b9114291429df561ed41340cdc035f51e0f163b",
  "candidatePackageSha256": "0998b29271acf82e29cff9bc527751ec5e4cd4021316e6311b471217228151e1",
  "baseline": "[email protected]",
  "beforeBuildId": "2026.11.2-release-b556fdf457b0-2026-11-07T15-35-25.381Z",
  "afterBuildId": "2026.11.2-512886c5a869-2026-11-10T09-22-02.457Z",
  "scenario": "base",
  "candidateInstallMode": "updater",
  "updateRestartMode": "manual",
  "updateOutcome": "success",
  "passedPhases": [
    "candidate-package-identity",
    "update-candidate",
    "installed-package-identity",
    "assert-automatic-migration",
    "validate-post-doctor-config",
    "assert-survival",
    "gateway-start",
    "gateway-probes",
    "gateway-status"
  ],
  "gatewayTimings": {
    "startupSeconds": 32,
    "updateRestartSeconds": null,
    "idempotenceSeconds": null,
    "idempotenceBudgetSeconds": null,
    "healthzSeconds": 1,
    "readyzSeconds": 1,
    "statusSeconds": 2
  }
}

@clawsweeper

clawsweeper Bot commented Nov 10, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@joshavant
joshavant marked this pull request as ready for review November 10, 2026 08:59
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime size: M labels Nov 10, 2026
@joshavant

Copy link
Copy Markdown
Collaborator Author

@clawsweeper review

Please review commit 512886c5a869a6cabcfeb3a6066b38434a503dce and the current PR evidence. Focus on retaining each accepted input's original app, membership, scope, and model limits through graceful shutdown and queued replay, including revocation before tool effects.

@clawsweeper

clawsweeper Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 10, 2026
@clawsweeper

clawsweeper Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR preserves each queued send’s original authenticated source and permission limits across Gateway restarts.

Example: One person queues a send with operator.read and operator.write, then sends another with operator.admin before a Gateway restart.

  • Before: Both queued inputs can replay with administrator authority.
  • After: Each input retains its separate scope ceiling, and a revoked original source cannot execute.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, correct repair with meaningful restart and final-effect authority proof, explicit fixture limits, and stable-upgrade evidence.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The candidate-bound receipt exercises normal Gateway startup, consent, an authorized write, actual process restart, automatic queued replay, and membership revocation while the real write waits at filesystem admission; the effect is refused and a separate app remains usable. This proves the changed owner path within the disclosed retained-source composition, rather than a full-current-package deployment. Public receipts and REST job metadata were inspected; storage-host restrictions prevented downloading linked Actions logs.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: A queued send can acquire broader permissions or lose its original app and membership restrictions after a Gateway restart.
Reason: The maintainer-authored change restores the accepted input’s authority boundary using existing owners and explicitly documents rejection of source-less preview markers.

Merge readiness

✅ Ready for maintainer review

This PR fixes a current-main authority gap in queued replay; no actionable patch defects were found, and the supplied restart, revocation, and upgrade evidence is sufficient.

Priority: P1
Reviewed head: 512886c5a869a6cabcfeb3a6066b38434a503dce

Before merge

None.

Findings

None.

Agent review details

How this fits together

Chat admission places accepted messages under the pending-input owner; shutdown records their source evidence, and startup restores current authority before replaying them through ordinary chat dispatch.

flowchart LR
  A[Authenticated send] --> B[Pending input owner]
  B --> C[Private shutdown marker]
  C --> D[Current source authorization]
  D --> E[FIFO chat dispatch]
  E --> F[Live tool effect checks]
Loading

Technical review

Best possible solution:

Retain original source ceilings in existing input custody and restore them through the shared authority owner while preserving live checks at execution.

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

Current main visibly restores authority from sender attribution, and the committed regression distinguishes two accepted scope ceilings that the old path collapses to administrator authority; no target code was executed during this review.

Is this the best way to solve the issue?

The patch is a focused repair using existing custody, serialization, recovery authorization, and dispatch owners, with no competing queue or policy implementation.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Queued replay authorization and restart documentation changes intended behavior with a stated reason (9344233: The restart redesign replaced reconstruction machinery with one ordinary resume input and FIFO replay under each sender’s current authority.)
  • Pending-input owner construction keeps the original intent (a823a52: Registered input custody protects accepted and committed replay inputs from unrelated announcement adoption independently of execution permission.)
  • Pending-input authority and settlement keeps the original intent (bc3092f: Accepted input remains durable while execution and settlement use current session authority and cannot clear a successor’s state.)
  • Shutdown marker persistence keeps the original intent (86d7963: Capture queued inputs before shutdown cancellation and preserve interrupted work when shutdown preparation is incomplete.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

  • Pinned introduction and clean checkout: The merge-base-to-head diff contains the source capture, private marker extension, replay restoration, regressions, and documentation changes; the checkout remained clean. (512886c5a869)
  • Current-main gap remains: Fetched main still reconstructs queued authority from the sender profile through prepareSessionPrincipalRunAuthority rather than the input’s original authenticated source. (src/gateway/queued-chat-inputs.ts:73, d553516036b6)
  • Original source restored through existing owner: Replay requires matching input/run evidence, restores it through restoreGatewayQueuedOperatorRecovery, verifies the sender identity, and passes the resulting authority into ordinary dispatch. (src/gateway/queued-chat-inputs.ts:78, 512886c5a869)
  • Authority and privacy boundaries: The existing recovery owner revalidates grants, devices, membership, and current policy while intersecting original model limits; session projection removes the entire private restart marker. (src/gateway/operator-run-recovery.ts:465, 512886c5a869)
  • Final-effect evidence: The full PR body supplies a candidate-bound native Gateway receipt showing actual process restart, an authorized file-write control, queued replay retaining app/membership identity, and membership removal while an actual write waits at filesystem admission; resumption produces an error and no file, while a separate app remains usable. The retained Gateway fixture, deterministic model, and observation-only hook are explicitly disclosed. (512886c5a869)
  • Stable upgrade compatibility: The published-upgrade-survivor job succeeded, and the body’s receipt binds the installed candidate to this head with seeded configuration, session, and transcript survival. REST inspection of the stable session types confirms that resumeAfterRestart and queuedInputIds are absent, supporting the documented treatment of source-less preview markers. (src/config/sessions/types.ts:686, 512886c5a869)

PR surface

Source +42, Tests +101, Docs +6, Other +2. Total +151 across 14 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 9 82 40 +42
Tests 2 103 2 +101
Docs 2 31 25 +6
Config 0 0 0 0
Generated 0 0 0 0
Other 1 2 0 +2
Total 14 218 67 +151

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Review metrics

Metric Value Why it matters
Production versus regression growth Production +42 net lines; tests +101 net lines The production growth carries per-input source evidence through existing owners; the regression growth covers separate scope ceilings, missing or mismatched sources, and device revocation.

Labels

Label changes:

No label changes.

Label justifications:

  • P1: Current-main restart replay can replace an accepted send’s restricted source with broader profile authority.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

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-11-10T09:15:26.946Z sha 512886c :: needs real behavior proof before merge. :: none
  • reviewed 2026-11-10T10:04:19.892Z sha 512886c :: needs maintainer review before merge. :: none

Reviewed November 10, 2026, 5:11 AM ET / 10:11 UTC (Revision 3).

@joshavant

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

Please review the unchanged head 512886c5a869a6cabcfeb3a6066b38434a503dce with the completed evidence in the current PR description.

  • The inspectable native receipt now includes the actual filesystem write reaching admission under the retained ID source, signed membership removal while paused, and the ordinary product path denying the write after resume. The hook only observes identity and waits; it does not perform authority validation or simulate refusal. The separate app remains usable. Fixture limits are explicit.
  • The published [email protected] upgrade passed: candidate and installed-package identity, seeded settings/session/transcript survival, and Gateway readiness. The linked artifact and projected receipt show the release build replaced by this exact candidate despite matching manifest versions.
  • That stable release predates resumeAfterRestart, queuedInputIds, and continueSessionQueuedInputs, so it cannot produce a source-less queued marker. Committed regressions cover rejection of source-less preview markers.
  • Two additional recovery-owner model-ceiling tests passed. All selected branch CI passed except the exact-base inherited formatting failure. Package Acceptance is red on a separate npm 12 installed-tree budget failure (50,913 entries / 47,500 budget); installation and the upgrade lane passed. No package-budget exception is claimed, and its base count has not been independently reproduced.

@clawsweeper

clawsweeper Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 10, 2026
@clawsweeper clawsweeper Bot added status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 10, 2026
@joshavant
joshavant merged commit 67a327f into main Nov 10, 2026
300 of 304 checks passed
@joshavant
joshavant deleted the fix/queued-app-authority branch November 10, 2026 10:24
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 11, 2026
RomneyDa added a commit that referenced this pull request Nov 12, 2026
Adapt the original-source recovery contract to the release's existing
workspace and graceful-restart owners. Revalidate retained scope ceilings
and current grants before dispatch; missing or mismatched provenance fails
the queued input instead of adopting current administrator privileges.

Independent local review omitted by explicit release-owner instruction.

(cherry picked from commit 67a327f)

Co-authored-by: RomneyDa <[email protected]>
Co-authored-by: vincentkoc <[email protected]>
(cherry picked from commit a5d208a64db8837af6a599063bc8aebd985c42b2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation gateway Gateway runtime P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. 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