Skip to content

fix(gateway): stop GitHub readiness from copying whole agent databases - #188025

Merged
obviyus merged 3 commits into
mainfrom
fix/session-inventory-copy-scope
Oct 30, 2026
Merged

obviyus merged 3 commits into
mainfrom
fix/session-inventory-copy-scope

Conversation

@obviyus

@obviyus obviyus commented Oct 30, 2026 •

Copy link
Copy Markdown
Collaborator

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 fix(plugins): show tool guidance only while the tool is callable #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.

sessions.github.readiness ran inside the offline-inspection copy scope, so every
read on a live Gateway full-copied agent databases and stalled all writers.
Read through the live owner instead, and guard Gateway code against the scope.
@clawsweeper

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

@github-actions

github-actions Bot commented Oct 30, 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: d0e1275a111c8ddbac4458ec9e53dd76de14127a
  • Maintainer: @obviyus
  • Repository role: admin

These security sensitive changes were made:

  • src/gateway/server-methods.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: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. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. 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 Oct 30, 2026
@clawsweeper

clawsweeper Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

GitHub publication readiness reads live agent databases without copying them, while preserving worker-based path checks and source-retirement checks.

Example: An agent calls github_publish readiness with a 35 GB agent database.

  • Before: The reported production behavior copied the database and stalled unrelated Gateway requests for minutes.
  • After: Readiness uses the live database owner without staging an agent snapshot and refuses results if that source retires or changes.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Focused repair with both prior findings resolved and successful exact-head checks; behavior evidence is a production-path in-process harness rather than a deployed Gateway capture.
Proof confidence 🦐 gold shrimp (3/6) Sufficient (none): The authority-specific production-path harness uses the registered Gateway handler, real SQLite readers, and real registry owners to exercise allowed reads and rejection after source closure, removal, replacement, grant revocation, and visibility changes; response assertions require no disclosed payload on refusal, and the PR records passing current-head cases. Ordinary deployed-flow proof is exempt for this maintainer-authored PR; no large-database after-fix benchmark is claimed.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Calling publication readiness can freeze chat, session updates, and Control UI requests while filling disk with database copies.
Reason: The maintainer-authored repair removes a demonstrated source of unnecessary work and explicitly accepts the narrower sidecar-preservation contract.

Regression provenance

Possible regression — suspected (reviewed change). No predecessor PR is attributed.

Merge readiness

✅ Ready for maintainer review

This PR addresses a current Gateway stall and resolves both prior findings; no new actionable defect was found.

Priority: P1
Reviewed head: d0e1275a111c8ddbac4458ec9e53dd76de14127a

Before merge

None.

Findings

None.

Agent review details

How this fits together

The Gateway accepts readiness requests from clients and the github_publish tool, reads session authority and publication facts through database workers, and returns observational readiness without initiating publication or credential refresh.

flowchart TD
A[Client or github_publish] --> B[Gateway readiness dispatch]
B --> C[Worker path qualification]
C --> D[Live agent database owner]
D --> E[Session and registry authority]
E --> F[Readiness response]
Loading

Technical review

Best possible solution:

Use the existing live database owners for readiness, retain source and disclosure revocation checks, and reserve whole-database copies for offline inspection.

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

Fetched main explicitly enables whole-agent-database inspection copies for readiness, matching the reported production stalls; no target code was executed during this read-only review.

Is this the best way to solve the issue?

The patch is the smallest complete repair: remove offline copying, retain worker qualification, and reuse existing registry and retirement owners rather than introducing another database path.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Readiness observation and source custody changes intended behavior with a stated reason (e242709: Preserve source artifacts during observational readiness and recheck current authority after asynchronous reads.)
  • Session discovery and physical qualification keeps the original intent (e242709: Qualify inspection paths in workers and carry original-source identity through private reads; the patch retains qualification while separating copying.)
  • Artifact-preserving Doctor scope keeps the original intent (3be8851: Keep lint and JSON Doctor inspection from modifying existing database artifacts.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

  • Copy scope removed at the request boundary: The introduced diff removes agentDatabases from readiness dispatch and removes the duplicate scope inside the readiness reader; fetched main still contains both copying scopes. (src/gateway/server-methods.ts:597, d0e1275a111c)
  • Prior source-retirement finding resolved: The latest commit restores the registry witness and native retirement resource for observational live reads; current-session checks consume these guards after awaited receipt reads. (src/gateway/github-publication-availability.ts:205, d0e1275a111c)
  • Authority proof reaches the response boundary: Registered-method cases hold a real shared-state read, close or unregister the source, or replace and register its file, then assert failure with no payload; same-source registration and presentation-only changes retain successful responses. (src/gateway/server-methods/sessions-github-readiness.test.ts:492, d0e1275a111c)
  • Original behavior and accepted tradeoff: feat(github): expose observational publication readiness #187152 established source-preserving observational readiness; this maintainer-authored PR explicitly accepts normal cold-open WAL/SHM creation while retaining database-content preservation, no agent copies, and live disclosure checks. (src/gateway/github-publication-readiness.ts:47, e2427099948c)
  • Exact-head checks: The exact-head openclaw/ci-gate, production types, lint, guards, and changed-test checks report success; downloading an individual job log was blocked by the proxy's artifact-host allowlist, so no log inspection is claimed. (d0e1275a111c)
  • Offline inspection remains separately owned: The original inspection scope was introduced for read-only Doctor preservation; the patch keeps agent-copy flags in Doctor-scoped callers and separates them from observational worker qualification. (src/state/artifact-preserving-state-reads.ts:25, 3be885108e5e)

Likely related people:

  • Jason (Json): Raw commit e242709 adds src/gateway/github-publication-readiness.ts:46 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: e2427099948c; files: src/gateway/github-publication-readiness.ts)
  • Peter Steinberger: Raw commit 3be8851 adds src/state/artifact-preserving-state-reads.ts:20 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 3be885108e5e; files: src/state/artifact-preserving-state-reads.ts)

PR surface

Source +16, Tests +5, Docs +1. Total +22 across 12 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 9 152 136 +16
Tests 2 69 64 +5
Docs 1 1 0 +1
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 12 222 200 +22

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp 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: 🧂 unranked krab: Current PR rating is rating: 🦐 gold shrimp, 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:

  • P1: Ordinary readiness calls reportedly stall unrelated Gateway requests and consume substantial disk space on large active databases.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp 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-10-30T02:00:01.865Z sha aea1dbf :: needs changes before merge. :: [P2] Keep readiness path qualification off the Gateway thread
  • reviewed 2026-10-30T03:11:54.396Z sha 0ed33e8 :: needs real behavior proof before merge. :: [P2] Retain physical-source revocation through readiness publication

Reviewed October 30, 2026, 12:28 AM ET / 04:28 UTC (Revision 3).

Split session discovery's inspection flag: artifact-preserving reads check paths
in workers, and only the Doctor agent scope reads private copies.
@obviyus

obviyus commented Oct 30, 2026

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 30, 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. 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 rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. 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 Oct 30, 2026
Observational readiness keeps the registry witness and native retirement signal
for the selected agent database without copying it; restore the retired,
removed and replaced source cases.
@obviyus

obviyus commented Oct 30, 2026

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 30, 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. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. 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-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 30, 2026
@obviyus
obviyus merged commit bdaf7df into main Oct 30, 2026
162 of 163 checks passed
@obviyus
obviyus deleted the fix/session-inventory-copy-scope branch October 30, 2026 04:31
@obviyus

obviyus commented Oct 30, 2026

Copy link
Copy Markdown
Collaborator Author

Landed.

  • Bug: sessions.github.readiness, which the agent github_publish tool calls, ran inside the Doctor-only agentDatabases inspection scope. Every call copied the whole agent database. On the team Gateway that meant a 35 GB copy per call: the disk saturated, writers waited 5–10 minutes, and about 640 GB of snapshot copies built up.
  • Fix: readiness reads live databases through their owner. Session-store path checks stay in discovery workers. The source-retirement checks for closed, unregistered or replaced databases stay in place; they copy nothing. Doctor inspection keeps its copy scope.
  • So it doesn't happen again: a boundary test fails if Gateway code enters withArtifactPreservingStateReads({ agentDatabases: true }), and src/gateway/AGENTS.md states the rule.
  • Proof:
    • The readiness tests fail on main and pass here: readiness reads the source, not a private image, and the Gateway thread runs no path checks.
    • The retired-, removed- and replaced-source cases are refused, and each asserts zero snapshot copies.
    • CI is green, and the ClawSweeper review is ready on the exact head.

Thanks @fuller-stack-dev for the readiness work in #187152, and for #188009/#188070. With this landed, readiness no longer goes through the copy path; those PRs may still be useful for the remaining Doctor inspection copies.

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]>
RomneyDa added a commit that referenced this pull request Nov 17, 2026
Backport bdaf7df (#188025).
Separate off-thread path qualification from private Doctor inspection copies,
retaining source retirement and post-await authority guards.

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

Labels

gateway Gateway runtime P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. 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