Skip to content

refactor(gateway): publication store worker kernels and receipts (ghpub 1/4, inactive) - #163523

Closed
steipete wants to merge 2 commits into
mainfrom
dbasync/ghpub-1
Closed

steipete wants to merge 2 commits into
mainfrom
dbasync/ghpub-1

Conversation

@steipete

@steipete steipete commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Status

Draft: the inactive scaffolding has been reviewed. The SQL-free grant audit passed, all 11 focused worker/lifecycle tests passed in 139.48 seconds after integrating main, and ClawSweeper found no actionable issues on the original head. This same PR will carry ghpub 3/4 (activation of all callers) once ghpub 2/4 (foreign-writer exclusion) lands. Landing the scaffolding with its runtime consumers will remove the Knip unused-file finding without an exception.

What Problem This Solves

Personal and repository GitHub publication stores still perform runtime SQLite work on the Gateway thread. The cutover needs admitted-connection kernels and exact mutation receipts before authority consumers can move together.

Why This Change Was Made

Factor the existing kernels without switching runtime callers. Register typed shared-state worker commands and independent read operations, preserve lazy schema admission and codecs, and return exact lifecycle-deletion tombstones. Add an inactive lexical publication scope that fences before COMMIT, rechecks live authority, preserves owner FIFO through settlement/publication, reconciles retained COMMIT receipts after reply loss, and drains accepted work on close.

Mutation admission checks retained action/result custody rather than recursively calling its own pending-fenced guard. Commit receipts use the existing native settlement channel.

The broker remains unchanged. Raw worker reads may observe newly committed rows before host publication; host authority must consume the fenced owner's facts. Unknown outcomes stay unavailable and are never blindly replayed.

User Impact

No user-visible activation or main-thread SQL reduction is claimed in PR1. No schema, retention, durability, public SDK, GitHub network, or update behavior changes; no migration or operator action is required. Personal claims now return their exact stored postimage, including updated_at_ms.

This PR contains reviewed stage 1 and will include stage 3 of the cutover sequence before it is ready to land.

Four-PR plan

  1. PR1 (this PR): admitted store kernels, typed worker/read commands, commit receipts, and inactive publication scope.
  2. PR2: coordinate foreign lifecycle/deletion writers before either database mutates, following refactor(sessions): plan lifecycle artifact cleanup in workers #163269.
  3. PR3 (will be included in this PR): activate publication ownership and switch all callers/callbacks together; remove superseded synchronous runtime paths. Seal action admission, drain accepted effects/observations/reporting, then close the worker scope.
  4. PR4: add the typed agent-local materialization bind, following refactor(sessions): move prepared metadata patches into workers #163378.

Evidence

  • Pinned base: 27592c2d0a9f6104e533a97d66600e4ebb189fb1.
  • node scripts/worktree-setup.mjs gateway: passed, including build stamps and built-module checks.
  • pnpm test src/state/github-publication.worker.test.ts --maxWorkers=1: 7 passed; final measured wall time 66.50 s, including worker-fixture compilation (about 3 s in the cases). Real worker admission, native COMMIT receipts, reply loss, worker exit, and close drainage require this boundary; the suite reuses its isolated database/actor except when a case intentionally retires the worker.
  • Existing personal, repository, pending-status, and lifecycle suites: 102 tests covered. The combined run took 247.28 s and passed 101/102; its lifecycle hook still matched the former undefined commit facts. After matching the exact tombstone instead, pnpm test src/gateway/github-personal-publication.lifecycle.test.ts --maxWorkers=1 passed all 4 cases in 62.13 s. This existing full lifecycle fixture proves native foreign-write admission, reset/archive retention, and permanent deletion.
  • node scripts/check-changed.mjs --base 27592c2d0a9f6104e533a97d66600e4ebb189fb1: passed, including core and all 27 test-typecheck shards, full lint, unused exports, and architecture/authentication guards.
  • pnpm check:madge-import-cycles: 0 cycles.
  • pnpm check:database-worker-ratchet --base 27592c2d0a9f6104e533a97d66600e4ebb189fb1: passed; no T1 growth, and no reduction claimed for inactive PR1.
  • Fresh independent Codex autoreview through P2, pinned to the same base: scoped-clean, no accepted/actionable findings.
  • Production diff: +931 / −173 / net +758 (1,104 changed lines), below the approved ~1,200 limit. Test/support changes are counted separately.
  • GitHub CI timings are pending at PR creation; the local wall times above are measured, not estimates of CI time.
  • Landing integration proof: merged main at a1566b2dbfde (including refactor(sessions): plan lifecycle artifact cleanup in workers #163269) locally without conflicts; the PR patch ID remained unchanged. The publication worker and personal-publication lifecycle suites passed 11/11 tests in 139.48 s against that combined tree.
  • Admission audit: the new publication authority recheck uses retained database/scope facts and the pending-publication fence is an in-memory set; no host SQL was found in the new grant callbacks.
  • CI found the intentionally inactive src/state/github-publication-worker.ts unused in production Knip. This PR-caused gate will be resolved by adding its runtime consumers in this PR; no Knip exception will be added.

Factor the canonical personal and repository kernels around admitted shared-state
connections, preserving synchronous runtime callers until the complete cutover.
Register inactive worker/read commands and retain exact mutation and deletion
receipts through commit fencing, native settlement, and owner publication.

Preserve lazy schemas, row codecs, branch lineage, and accepted-result custody.
Return the actual personal claim postimage, including its update timestamp.
@clawsweeper

clawsweeper Bot commented Oct 2, 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 gateway Gateway runtime agents Agent runtime and tooling size: XL labels Oct 2, 2026
@steipete

steipete commented Oct 2, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added 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. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 2, 2026
@clawsweeper

clawsweeper Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge. Reviewed October 2, 2026, 9:12 AM ET / 13:12 UTC (Revision 3).

ClawSweeper review

What this changes

The branch extracts GitHub publication database kernels, registers worker reads and writes, and adds exact commit and deletion receipts while preserving existing runtime callers.

Merge readiness

⛔ Needs changes before merge - 1 item remains

The staged patch remains useful and has no actionable correctness finding. The updated draft plan resolves the earlier staging-choice concern; current main does not contain this publication cutover.

Likely related people: steipete, a recent publication-area contributor (high-confidence routing).

Priority: P2
Reviewed head: a70f73cf5dd6542cc014eadf0db92c878e9cddb0

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The staged patch has meaningful native-worker proof and no actionable defect; draft status does not reduce its quality rating.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (terminal): The reported after-fix runs exercise the staged publication owner through actual SQLite Workers and native admission/settlement, with persisted-row observations after injected reply loss, refusal, exit, and closure. This proves the current worker boundary, not the future caller activation. Stored-data contracts are unchanged, so no migration proof is required.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The reported after-fix runs exercise the staged publication owner through actual SQLite Workers and native admission/settlement, with persisted-row observations after injected reply loss, refusal, exit, and closure. This proves the current worker boundary, not the future caller activation. Stored-data contracts are unchanged, so no migration proof is required.
Evidence reviewed 8 items Pinned introduced patch: Inspected the introduced delta from the pinned base to the exact head. Store changes extract existing operations into admitted-connection kernels; synchronous runtime entrypoints remain present.
Staging disposition and review continuity: The captured PR body explicitly keeps the branch draft until caller activation is included, and says the unused-file failure will be resolved through runtime consumers without a Knip exception. The worker scope and its tests are unchanged from the previous reviewed head. This supplies the staging resolution previously requested; it does not establish a completed cutover.
Production-boundary proof: Read the complete seven-case worker suite. It uses the actual Worker, SQLite store, admission channel, and native settlement owner, injecting held or corrupted replies, pre-COMMIT refusal, worker termination, and scope closure. Assertions inspect persisted rows, exact receipts, publication ordering, rollback, and drainage. The captured body reports seven cases passing in 66.50 seconds and the integrated worker/lifecycle selection passing 11/11 in 139.48 seconds. These results were inspected, not rerun.
Findings None None.
Security None None.

How this fits together

GitHub publication stores track requests, execution ownership, and outcomes for personal and repository publishing. This patch prepares those SQLite operations for workers whose committed results return to the Gateway for publication.

flowchart TD
  A[Publication requests] --> B[Existing Gateway callers]
  B --> C[Publication store kernels]
  D[Staged worker scope] --> E[Live admission checks]
  E --> C
  C --> F[Shared SQLite database]
  F --> G[Exact commit receipts]
  G --> D
Loading

Before merge

  • Complete next step (P2) - Complete the planned foreign-writer coordination and runtime caller activation, remove superseded synchronous paths, and re-review the resulting cutover before landing; resolve the inactive-scope Knip failure through its consumers without an exception.
Agent review details

Security

None.

PR surface

Source +758, Tests +575. Total +1333 across 21 files.

View PR surface stats
Area Files Added Removed Net
Source 18 931 173 +758
Tests 3 581 6 +575
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 21 1512 179 +1333

Review metrics

None.

Technical review

Best possible solution:

One publication owner should serve all runtime callers through the existing worker broker, preserving live authority, FIFO settlement, and exact committed facts.

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

Not applicable: this is a staged internal refactor. Source confirms the synchronous runtime path remains; no tests were executed during this read-only review.

Is this the best way to solve the issue?

Yes for the staged extraction: sharing existing kernels avoids competing store implementations. The planned caller cutover must complete before the branch achieves its operational goal.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This is bounded internal database-worker preparation with no claimed user-visible activation or urgent 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. Sufficient (terminal): The reported after-fix runs exercise the staged publication owner through actual SQLite Workers and native admission/settlement, with persisted-row observations after injected reply loss, refusal, exit, and closure. This proves the current worker boundary, not the future caller activation. Stored-data contracts are unchanged, so no migration proof is required.
  • proof: sufficient: Contributor real behavior proof is sufficient. The reported after-fix runs exercise the staged publication owner through actual SQLite Workers and native admission/settlement, with persisted-row observations after injected reply loss, refusal, exit, and closure. This proves the current worker boundary, not the future caller activation. Stored-data contracts are unchanged, so no migration proof is required.

Evidence

What I checked:

  • Pinned introduced patch: Inspected the introduced delta from the pinned base to the exact head. Store changes extract existing operations into admitted-connection kernels; synchronous runtime entrypoints remain present. (src/gateway/github-repository-publication-store.ts:457, a70f73cf5dd6)
  • Staging disposition and review continuity: The captured PR body explicitly keeps the branch draft until caller activation is included, and says the unused-file failure will be resolved through runtime consumers without a Knip exception. The worker scope and its tests are unchanged from the previous reviewed head. This supplies the staging resolution previously requested; it does not establish a completed cutover. (src/state/github-publication-worker.ts:18, a70f73cf5dd6)
  • Production-boundary proof: Read the complete seven-case worker suite. It uses the actual Worker, SQLite store, admission channel, and native settlement owner, injecting held or corrupted replies, pre-COMMIT refusal, worker termination, and scope closure. Assertions inspect persisted rows, exact receipts, publication ordering, rollback, and drainage. The captured body reports seven cases passing in 66.50 seconds and the integrated worker/lifecycle selection passing 11/11 in 139.48 seconds. These results were inspected, not rerun. (src/state/github-publication.worker.test.ts:1, a70f73cf5dd6)
  • Settlement and authority boundary: The staged scope checks retained source and caller authority at transaction and commit admission, fences facts before the commit grant, and reconciles the native receipt before publication. Existing production coordinators still call their original execution closures; this patch does not activate a new principal-to-GitHub effect path. (src/state/github-publication-worker.ts:87, a70f73cf5dd6)
  • Stored-state compatibility: The introduced store changes preserve row shapes, digest inputs, selection predicates, and deletion selection. RETURNING supplies exact postimages and transient tombstones; no DDL, persisted receipt format, retention policy, or migration is introduced. (src/state/github-personal-publication-lifecycle.ts:199, a70f73cf5dd6)
  • Current-main necessity: Current-main personal publication still performs its claim transaction through the synchronous store and constructs the returned claim from the prior row. It lacks this branch's admitted kernels and exact returned claim postimage. The related merged lifecycle-planning PR addresses another owner and does not supersede this work; no fixing release is established. (src/gateway/github-personal-publication-store.ts:151, 94cbbecd46cc)

Likely related people:

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

Rating scale

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

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

Workflow

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

History

Review history (2 earlier review cycles)
  • reviewed 2026-10-02T12:53:08.551Z sha 24eb7fd :: needs maintainer review before merge. :: none
  • reviewed 2026-10-02T13:01:51.543Z sha 24eb7fd :: blocked before merge. :: none

@steipete

Copy link
Copy Markdown
Contributor Author

Closing as superseded rather than landing; nothing here is lost.

This draft carried two halves of the GitHub publication worker move, and both now live elsewhere:

  • Commit receipts: landed on main as fix(storage): publish sandbox, worktree, and GitHub authority receipts #168025 (src/state/github-publication-receipts.ts), in the shared receipt shape the other storage owners use.
  • Worker kernels: the active S7 storage-worker lane is rebuilding these as live owners rather than an inactive scope. It creates the same new modules (src/state/github-publication-worker.ts, github-publication.worker.ts, github-publication.read.worker.ts, github-publication.worker-contract.ts) and also migrates every caller. That migration is the activation step this draft was parked on (grant callbacks needed prepared profile, session, placement and lease facts).

Landing this branch now would create a second owner for the same modules beneath that lane, and Knip already flags the inactive scope as unused. The branch head a70f73cf5dd6 and the parked activation attempt stay available locally if the S7 lane wants to reuse any of it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling gateway Gateway runtime 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. 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