Skip to content

feat(github): expose observational publication readiness - #187152

Merged
fuller-stack-dev merged 11 commits into
mainfrom
openclaw/vivid-shrimp
Oct 29, 2026
Merged

fuller-stack-dev merged 11 commits into
mainfrom
openclaw/vivid-shrimp

Conversation

@fuller-stack-dev

@fuller-stack-dev fuller-stack-dev commented Oct 29, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Add a read-only publication-readiness action for the current session, with separate policy, source custody, target, request and remedy information.
  • Reuse canonical session/worktree qualification while preserving the original source and rechecking current authority after awaited reads.
  • Keep credential/account preparation and publication effects out of readiness; preserve legacy options/status behavior and closed receipt projections.

Verification

All runtime evidence below ran on source 3a731751 (tree 1a514e06, integrated with main at 50bb9ed9). The PR head 7af9f26f is the publication commit for that source, with the identical tree. The aliases A, B and C are synthetic fixture sessions. Proof record SHA-256: 63788dbd22fa62763ab3ce37b2be3fa1741ca067c262dadc23ba23cba634a1ba.

Changes since the first published revision

  • Import cycles: shared session and worker-reader types moved into leaf contract files, and the target adapter moved with a byte-identical body. The architecture (madge) scan went from 2 cycles to 0.
  • Main integration: the merge with main had no conflicts. Its only resolution moved one PublicationSessionIdentity type import to the neutral leaf file.
  • Perf hook: scripts/perf/github-options-measure-preload.ts now tracks the renamed qualifyGitHubPublicationSource export (+1/−1). Before the fix the preloader failed on the missing old name; after it, the hook resolves all of its owners and boundaries. This is not a performance measurement.

Session access through github_publish and the registered sessions.github.readiness method

Caller A reads its own session, its persisted child C, and an unrelated session B (public-safe excerpt):

{"caller":"A","selected":"A","toolReturns":1,"toolThrows":0,"rpcResponseCount":1,"rpc":[{"ok":true,"payloadPresent":true,"receiptPresent":false}],"facets":{"policy":{"read":"admitted","write":"unknown"},"custody":{"kind":"unbound_workspace"},"target":{"kind":"unknown","reason":"not-qualified"},"request":{"kind":"none","selection":"current"},"remedies":[{"kind":"select_bound_session"}]},"foreignReads":0}
{"caller":"A","selected":"C","toolReturns":1,"toolThrows":0,"rpcResponseCount":1,"rpc":[{"ok":true,"payloadPresent":true,"receiptPresent":false}],"facets":{"policy":{"read":"admitted","write":"unknown"},"custody":{"kind":"unbound_workspace"},"target":{"kind":"unknown","reason":"not-qualified"},"request":{"kind":"none","selection":"current"},"remedies":[{"kind":"select_bound_session"}]},"foreignReads":0}
{"caller":"A","selected":"B","toolReturns":0,"toolThrows":1,"error":"The publishing session is not a child of this conversation.","rpcResponseCount":1,"rpc":[{"ok":false,"payloadPresent":false,"errorCode":"FORBIDDEN","receiptPresent":false}],"facets":null,"sharedPoolTasks":0,"latestReceiptCalls":0,"exactReceiptCalls":0,"foreignReads":0}

Session B's stored receipt sentinel was present and was never read.

Revocation after a completed read

A human reader with operator.sessions.read completed one shared read. Their access to the session was then changed from view to none through the supported sessions update, and their next readiness request was refused. The scopes and the connection were unchanged. Public-safe excerpt; the session key is omitted:

{"case":"human-view-to-none","surface":"handleGatewayRequest -> registered sessions.github.readiness","readCompletedBeforeMutation":true,"roleBefore":"view","roleAfter":"none","scopes":["operator.sessions.read"],"connectedThroughout":true,"responseCount":1,"ok":false,"error":{"code":"FORBIDDEN","message":"GitHub publication session access changed; select the session again."},"payloadPresent":false,"receiptPresent":false,"returns":1,"throws":0,"sharedObservationTasks":1}

That run exited 0 (1 test passed, 7.4 s; 137 s total). All ten fail-if-called effect guards recorded zero calls. The human agent database, the shared database and their WAL and journal files were unchanged; shared-memory lock bytes are excluded from that comparison.

Review and local checks

  • The original full feature review stands. Independent reviews of the main integration and of the perf-hook fix found no actionable new code issues; three inherited upstream UI and test nits are outside this PR.
  • Lint, format and commit hooks passed on the current source. The local typecheck wrapper refused before analysis, so no local typecheck pass is claimed; exact-head CI covers types, architecture and tests.

Limitations

  • The A/C/B traces and the revocation trace come from separate runs on the same source. The A/C/B run exited 1 overall because its own human case settled before its barrier, for a reason that was not recorded; the separate revocation run above covers that case. This is combined coverage across separate runs, not one all-pass job.
  • Earlier attempts that failed (an anonymous outer client, timeouts and the early barrier) remain recorded as failures of those attempts.
  • The runs used a candidate in-process Gateway and tool composition with a warm shared read pool. They are not a WebSocket deployment, live GitHub provider or auth check, a cold-start performance measurement, or a universal privacy proof.
  • No CI pass is claimed here.

No live deployment, OAuth refresh, account selection or publication is performed by the readiness action.

@clawsweeper

clawsweeper Bot commented Oct 29, 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 app: web-ui App: web-ui gateway Gateway runtime agents Agent runtime and tooling size: XL labels Oct 29, 2026
@github-actions

github-actions Bot commented Oct 29, 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: 7af9f26fcf0394423b14886289f283583f00d8da
  • Maintainer: @fuller-stack-dev
  • Repository role: maintain

These security sensitive changes were made:

  • src/gateway/methods/core-descriptors.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.
  • src/gateway/server-methods.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.
  • src/gateway/server-methods/github-personal-authorization.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.
  • src/gateway/session-method-policy.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.
  • src/shared/session-method-scopes-base.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.

Carefully review these changes before merging.

@clawsweeper clawsweeper Bot added clawsweeper:intake:feature Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. 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:feature Preliminary submission classification; full source review pending. labels Oct 29, 2026
@clawsweeper

clawsweeper Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR adds a read-only GitHub publication-readiness action reporting session custody, target support, shared receipts, and remedies.

Example: Caller A requests readiness for its persisted child session C.

  • Before: github_publish has no readiness action separating source qualification from account discovery.
  • After: The action returns admitted read access, unbound_workspace custody, and select_bound_session guidance without preparing credentials or publishing.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Useful, coherent implementation with sufficient production-boundary authority evidence; prior findings are resolved, while exact-head CI is still pending.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (terminal): Current-tree terminal traces exercise github_publish through the registered Gateway method: own and child sessions succeed, unrelated B is rejected before receipt reads, and a human reader loses disclosure after view-to-none revocation. Effect guards remain unused. This satisfies the authority-boundary proof for this maintainer-authored PR; the evidence explicitly uses in-process composition rather than a WebSocket deployment.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Feature · Worth it: Yes · Fix scope: Complete
User problem: Agents need to distinguish publication source, target support, and existing request state without preparing accounts or initiating publication.
Reason: Maintainer authorship establishes direction, and the bounded observation addresses a distinct need documented in the user model.

Merge readiness

✅ Ready for maintainer review

Keep open: this maintainer-authored feature provides useful publication observation, and the prior actionable findings are resolved.

Priority: P2
Reviewed head: 7af9f26fcf0394423b14886289f283583f00d8da

Before merge

None.

Findings

None.

Agent review details

How this fits together

The agent tool calls a registered Gateway method that checks current session access, reads existing session and publication state through workers, and returns a bounded observation.

flowchart TD
 A[Agent publication tool] --> B[Gateway readiness method]
 B --> C[Current access and lineage checks]
 C --> D[Session and workspace readers]
 C --> E[Shared receipt reader]
 D --> F[Readiness response]
 E --> F
Loading

Technical review

Best possible solution:

Retain one shared target qualifier and the existing authority owners while exposing readiness through existing-only readers.

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

This is an additive feature: inspected main exposes options/status but lacks the readiness action; no target code was executed during this read-only review.

Is this the best way to solve the issue?

The implementation preserves existing publication ownership and separates observation from credential discovery and effects; the worker changes support artifact-preserving reads.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Shared publication read authorization keeps the original intent (92b4421: Allow session-scoped readers to inspect shared publication data without exposing personal account data.)
  • Worker-owned session discovery and retained source facts keeps the original intent (949dbc5: Move durable target discovery off the Gateway thread while retaining physical source identity, writer receipts, and live disclosure authority.)
  • Imported-PR worktree qualification keeps the original intent (b0e4320: Permit prepared original-PR publication while preserving its source and rejecting incomplete preparation.)
  • Current publication reader checks keeps the original intent (3be098d: Remove duplicate identity-policy work while retaining live checks at every returned reader boundary.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

  • Pinned production change: The introduced diff adds the tool action and registered RPC, reuses the existing target qualifier, and keeps credential preparation and publication effects outside readiness. (src/gateway/github-publication-readiness.ts:48, 7af9f26fcf03)
  • Current-tree runtime evidence: The public PR body supplies successful own-session and child-session responses, unrelated-session denial before receipt reads, and view-to-none revocation denial. Separate runs and their failed attempts are disclosed. The source and publication commits both resolve to tree 1a514e06b747fa5a80e07200b4b77dc7242270ef. (7af9f26fcf03)
  • Prior findings addressed: The benchmark hook now targets qualifyGitHubPublicationSource; worktree ownership and worker-reader contracts use leaf modules rather than the previously reported backward imports. (scripts/perf/github-options-measure-preload.ts:181, 7af9f26fcf03)
  • Existing publication contract: fix: allow session-scoped shared publication reads #162984 established session-scoped shared publication reads while preserving personal-data isolation; readiness extends that observation boundary rather than replacing it. (src/gateway/server-methods/github-personal-authorization.ts:174, 92b4421b38bf)
  • History and provenance limitation: Feature-history searches identify Peter Steinberger's publication and worker refactors and Shakker's shared-read and imported-PR work. Local blame could not read an older authorization blob; commit patches and linked PR rationale supplied the relevant provenance instead. (src/gateway/server-methods/github-personal-authorization.ts:256, 90a5029e4278)
  • Merge and validation state: GitHub reports the reviewed head mergeable, with mergeable_state blocked. Paginated current-head checks remain in progress; no completed failing check was observed, and no CI pass is claimed. (7af9f26fcf03)

PR surface

Source +1424, Tests +1417, Docs +25, Other 0. Total +2866 across 68 files. Added test files: 4.

View PR surface stats
Area Files Added Removed Net
Source 57 3780 2356 +1424
Tests 9 1458 41 +1417
Docs 1 25 0 +25
Config 0 0 0 0
Generated 0 0 0 0
Other 1 1 1 0
Total 68 5264 2398 +2866

Review metrics

Metric Value Why it matters
Protocol surface 1 additive RPC; 0 new configuration settings sessions.github.readiness observes existing sessions and requests without changing options/status contracts.

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • remove rating: 🦪 silver shellfish: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove merge-risk: 🚨 security-boundary: Current PR review selected no merge-risk labels.
  • remove status: 📣 needs proof: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: Useful publication diagnostics with a bounded scope and no established urgent user-facing regression.
  • 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 (3 earlier review cycles)
  • reviewed 2026-10-29T01:40:44.361Z sha 840cd61 :: needs real behavior proof before merge. :: [P2] Keep readiness identity checks off the Gateway thread
  • reviewed 2026-10-29T16:03:55.971Z sha c6aa5b4 :: needs real behavior proof before merge. :: [P2] Remove the worktree owner's backward import | [P2] Keep worker dispatch dependencies out of target inventory
  • reviewed 2026-10-29T16:51:01.557Z sha 90913ca :: needs real behavior proof before merge. :: [P3] Update the benchmark hook when renaming the target qualifier

Reviewed October 29, 2026, 1:31 PM ET / 17:31 UTC (Revision 4).

@openclaw-barnacle openclaw-barnacle Bot reopened this Oct 29, 2026
@openclaw-barnacle openclaw-barnacle Bot reopened this Oct 29, 2026
@fuller-stack-dev

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:feature Preliminary submission classification; full source review pending. and removed clawsweeper:intake:feature Preliminary submission classification; full source review pending. labels Oct 29, 2026
OpenClaw-Publication: 73f640e8-910a-4177-ba41-4dd3e10ef7ef
OpenClaw-Publication: 5fbeadc2-e8ae-40e9-8257-06efe69cb913
@openclaw-barnacle openclaw-barnacle Bot added the scripts Repository scripts label Oct 29, 2026
@fuller-stack-dev

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:feature 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. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. 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:feature Preliminary submission classification; full source review pending. labels Oct 29, 2026
@fuller-stack-dev
fuller-stack-dev merged commit e242709 into main Oct 29, 2026
196 checks passed
@fuller-stack-dev
fuller-stack-dev deleted the openclaw/vivid-shrimp branch October 29, 2026 17:38
obviyus added a commit that referenced this pull request Oct 30, 2026
#188025)

## What Problem This Solves

Since `sessions.github.readiness` shipped (e242709), every readiness read on a busy Gateway froze the whole Gateway for minutes.

The agent `github_publish` tool calls readiness. The Gateway ran that request inside `withArtifactPreservingStateReads({ agentDatabases: true })`. That scope exists for offline Doctor inspection: it turns every agent-database read into a private whole-file copy. With a live 35 GB agent database, each readiness call:

- copied the full database (about 9 minutes at about 1.6 GB/s; disk queue saturated);
- held up writers. Session patches waited 400–600 s, session creates about 480 s, and simple reads (`users.prefs.get`, `board.get`) hit their 30 s timeouts;
- left the copy behind. About 30 copies (about 640 GB) built up in the snapshot cache in 4 hours.

Production trace on the team Gateway: each `github_publish` failure line has a matching 34 GB snapshot directory with the same timestamp, to the second (for example 21:18:22, 22:08:35, 22:16:07, 22:27:52). At each of those instants every stalled `board.get` completed at once. The copies started at the first readiness call after the build containing e242709 went live. Before that, only occasional state-database snapshots existed.

## Why This Change Was Made

The Gateway owns its live databases. A Gateway request reads them through that owner, as `sessions.github.options` and `status` already do. Private copies are for outside, offline readers.

- `sessions.github.readiness` dispatch keeps the shared observation scope. That scope gives the existing guarantee that readiness never starts a login refresh, and a test covers it. The `agentDatabases: true` option is removed.
- The duplicate scope inside `readGitHubPublicationReadiness` is removed; dispatch already provides it.
- `qualifyGitHubPublicationSource` keeps the source-retirement watch: a registry witness plus the native retirement signal for the selected agent database. It now applies to every observational (artifact-preserving) read rather than only to copied readers. The watch copies nothing. If the source is closed, unregistered or replaced while readiness is pending, the request is refused before any response, so a replacement database cannot leave an obsolete visibility decision in place.

So that this does not happen again:

- A boundary test fails if any production file under `src/gateway/` requests `agentDatabases: true`.
- `withArtifactPreservingStateReads` documents that the option is for offline inspection only.
- `src/gateway/AGENTS.md` states the rule for Gateway code.

The old scope did two jobs: it checked session-store paths in discovery workers, and it copied agent databases. This change keeps the first and drops the second:

- In session discovery (`session-utils-store-worker.ts`, `session-sharing-preparation.ts`, `session-entry-read-runtime.ts`, `session-store-read-candidates.ts`), any artifact-preserving read now checks paths in a worker. Readiness keeps that scope.
- Only the Doctor-only `agentDatabases` scope adds `preserveSourceArtifacts` or reads a private copy.
- Discovery workers no longer force `preserveSourceArtifacts` on every prepared inventory. Callers add it under that scope.

Doctor and update inspection keep the copy scope, with unchanged results.

@fuller-stack-dev this changes one readiness guarantee from #187152. Readiness no longer promises byte-identical `-wal`/`-shm` sidecars for a cold agent database. SQLite creates those files when the owner opens the database for a normal read. Stored database bytes stay unchanged, and readiness now creates no snapshot copies; both are still tested. The alternative is a whole-database copy on every call, which stalls a production Gateway.

## User Impact

On Gateways with large agent databases, agents calling `github_publish` no longer freeze chat, session updates and the Control UI for minutes, and no longer fill the disk with snapshot copies.

## Evidence

- **Regression, red then green.** In `src/gateway/server-methods/sessions-github-readiness.test.ts`, the configured-locator test drives real readiness reads through the registered Gateway method and instruments native SQLite opens in the read workers. It previously asserted "readiness must open private images, not the source". It now asserts that readiness reads the source through its owner.
  - Against `main`'s production code: 3/3 variants **fail** (`expected 0 to be greater than 0`).
  - With this change: **pass**.
- **Path checks stay off the Gateway thread, red then green.** The same configured-locator test now spies on Gateway-thread session-store path checks (`prepareSessionStoreTargetInventory`, `captureSessionStoreReadCandidates`, `captureSessionStoreReadCandidate`) during cold and warm readiness reads.
  - Without the split above, it fails with `[4, 4, 16]` calls.
  - With it: zero.
  - Remaining Gateway-thread `stat`/`realpath` calls on the source are the per-read admission identity checks that every live Gateway session read makes (`sessions.github.options`, chat). Avoiding those would require reading a private copy, which is the bug.
- **Guard, red then green.** `src/state/artifact-preserving-state-reads.boundary.test.ts`:
  - with `main`'s `server-methods.ts`: fails, naming `server-methods.ts`;
  - now: passes (3 s wall).
- **Custody tests:**
  - "Preserves cold DB…" and "keeps an absent shared database absent" now compare the stored database files and the count of private snapshot copies; both pass.
  - The login-refresh, connection, profile, grant, session, visibility and session-metadata post-await checks are unchanged and pass.
  - The `source`, `registry-remove`, `published-replacement` and `registry-same` post-await cases are kept and run against live reads; each now also asserts zero agent snapshot copies. Without the source-retirement watch, the first three fail (the request is not refused); with it they pass.
- **Suites:**
  - `pnpm test src/gateway/server-methods/sessions-github-readiness.test.ts --maxWorkers=1`: 33 passed, 55 s wall.
  - Related publication, session-access, availability, store-lookup and `github_publish` tool suites: 193 passed.
  - Session discovery, entry-read, sharing, store-worker and Doctor lint/database-inspection suites: 342 passed across 35 files.
- `pnpm check:changed` passes typecheck, lint and guards. The wrapper-shadowing check fails on `src/agents/skill-workshop-prompt.ts` / `src/plugin-sdk/agent-harness-runtime.ts`. This PR does not touch those files, and the failure is already on `main` (from #187661).

No overlap with Pash/Sarah changes.

**Merge danger:** two-way door. No schema, config or stored-state change; a revert restores the copy scope. **Blast radius:** only `sessions.github.readiness` (the `github_publish` readiness action). If this change were wrong, readiness would report from the live database, as `options` and `status` already do.

**Follow-up:** with no Gateway caller left, the `preserveSourceArtifacts` plumbing that e242709 added to session discovery (`session-store-target-inventory.ts` and related readers) runs only under Doctor scopes. It can be reviewed for removal separately.

Co-authored-by: Ayaan Zaidi <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 31, 2026
openclaw#188025)

## What Problem This Solves

Since `sessions.github.readiness` shipped (f345b6d), every readiness read on a busy Gateway froze the whole Gateway for minutes.

The agent `github_publish` tool calls readiness. The Gateway ran that request inside `withArtifactPreservingStateReads({ agentDatabases: true })`. That scope exists for offline Doctor inspection: it turns every agent-database read into a private whole-file copy. With a live 35 GB agent database, each readiness call:

- copied the full database (about 9 minutes at about 1.6 GB/s; disk queue saturated);
- held up writers. Session patches waited 400–600 s, session creates about 480 s, and simple reads (`users.prefs.get`, `board.get`) hit their 30 s timeouts;
- left the copy behind. About 30 copies (about 640 GB) built up in the snapshot cache in 4 hours.

Production trace on the team Gateway: each `github_publish` failure line has a matching 34 GB snapshot directory with the same timestamp, to the second (for example 21:18:22, 22:08:35, 22:16:07, 22:27:52). At each of those instants every stalled `board.get` completed at once. The copies started at the first readiness call after the build containing f345b6d went live. Before that, only occasional state-database snapshots existed.

## Why This Change Was Made

The Gateway owns its live databases. A Gateway request reads them through that owner, as `sessions.github.options` and `status` already do. Private copies are for outside, offline readers.

- `sessions.github.readiness` dispatch keeps the shared observation scope. That scope gives the existing guarantee that readiness never starts a login refresh, and a test covers it. The `agentDatabases: true` option is removed.
- The duplicate scope inside `readGitHubPublicationReadiness` is removed; dispatch already provides it.
- `qualifyGitHubPublicationSource` keeps the source-retirement watch: a registry witness plus the native retirement signal for the selected agent database. It now applies to every observational (artifact-preserving) read rather than only to copied readers. The watch copies nothing. If the source is closed, unregistered or replaced while readiness is pending, the request is refused before any response, so a replacement database cannot leave an obsolete visibility decision in place.

So that this does not happen again:

- A boundary test fails if any production file under `src/gateway/` requests `agentDatabases: true`.
- `withArtifactPreservingStateReads` documents that the option is for offline inspection only.
- `src/gateway/AGENTS.md` states the rule for Gateway code.

The old scope did two jobs: it checked session-store paths in discovery workers, and it copied agent databases. This change keeps the first and drops the second:

- In session discovery (`session-utils-store-worker.ts`, `session-sharing-preparation.ts`, `session-entry-read-runtime.ts`, `session-store-read-candidates.ts`), any artifact-preserving read now checks paths in a worker. Readiness keeps that scope.
- Only the Doctor-only `agentDatabases` scope adds `preserveSourceArtifacts` or reads a private copy.
- Discovery workers no longer force `preserveSourceArtifacts` on every prepared inventory. Callers add it under that scope.

Doctor and update inspection keep the copy scope, with unchanged results.

@fuller-stack-dev this changes one readiness guarantee from openclaw#187152. Readiness no longer promises byte-identical `-wal`/`-shm` sidecars for a cold agent database. SQLite creates those files when the owner opens the database for a normal read. Stored database bytes stay unchanged, and readiness now creates no snapshot copies; both are still tested. The alternative is a whole-database copy on every call, which stalls a production Gateway.

## User Impact

On Gateways with large agent databases, agents calling `github_publish` no longer freeze chat, session updates and the Control UI for minutes, and no longer fill the disk with snapshot copies.

## Evidence

- **Regression, red then green.** In `src/gateway/server-methods/sessions-github-readiness.test.ts`, the configured-locator test drives real readiness reads through the registered Gateway method and instruments native SQLite opens in the read workers. It previously asserted "readiness must open private images, not the source". It now asserts that readiness reads the source through its owner.
  - Against `main`'s production code: 3/3 variants **fail** (`expected 0 to be greater than 0`).
  - With this change: **pass**.
- **Path checks stay off the Gateway thread, red then green.** The same configured-locator test now spies on Gateway-thread session-store path checks (`prepareSessionStoreTargetInventory`, `captureSessionStoreReadCandidates`, `captureSessionStoreReadCandidate`) during cold and warm readiness reads.
  - Without the split above, it fails with `[4, 4, 16]` calls.
  - With it: zero.
  - Remaining Gateway-thread `stat`/`realpath` calls on the source are the per-read admission identity checks that every live Gateway session read makes (`sessions.github.options`, chat). Avoiding those would require reading a private copy, which is the bug.
- **Guard, red then green.** `src/state/artifact-preserving-state-reads.boundary.test.ts`:
  - with `main`'s `server-methods.ts`: fails, naming `server-methods.ts`;
  - now: passes (3 s wall).
- **Custody tests:**
  - "Preserves cold DB…" and "keeps an absent shared database absent" now compare the stored database files and the count of private snapshot copies; both pass.
  - The login-refresh, connection, profile, grant, session, visibility and session-metadata post-await checks are unchanged and pass.
  - The `source`, `registry-remove`, `published-replacement` and `registry-same` post-await cases are kept and run against live reads; each now also asserts zero agent snapshot copies. Without the source-retirement watch, the first three fail (the request is not refused); with it they pass.
- **Suites:**
  - `pnpm test src/gateway/server-methods/sessions-github-readiness.test.ts --maxWorkers=1`: 33 passed, 55 s wall.
  - Related publication, session-access, availability, store-lookup and `github_publish` tool suites: 193 passed.
  - Session discovery, entry-read, sharing, store-worker and Doctor lint/database-inspection suites: 342 passed across 35 files.
- `pnpm check:changed` passes typecheck, lint and guards. The wrapper-shadowing check fails on `src/agents/skill-workshop-prompt.ts` / `src/plugin-sdk/agent-harness-runtime.ts`. This PR does not touch those files, and the failure is already on `main` (from openclaw#187661).

No overlap with Pash/Sarah changes.

**Merge danger:** two-way door. No schema, config or stored-state change; a revert restores the copy scope. **Blast radius:** only `sessions.github.readiness` (the `github_publish` readiness action). If this change were wrong, readiness would report from the live database, as `options` and `status` already do.

**Follow-up:** with no Gateway caller left, the `preserveSourceArtifacts` plumbing that f345b6d added to session discovery (`session-store-target-inventory.ts` and related readers) runs only under Doctor scopes. It can be reviewed for removal separately.

Co-authored-by: Ayaan Zaidi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling app: web-ui App: web-ui clawsweeper:intake:feature Preliminary submission classification; full source review pending. docs Improvements or additions to documentation gateway Gateway runtime P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. scripts Repository scripts security-sensitive-changed size: XL 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