Skip to content

feat(pm-service): PM tenant store schema + migrations (component A slice 1, #12825) - #13054

Merged
dezren39 merged 1 commit into
mainfrom
xaltha/12825-tenant-store
Nov 24, 2026
Merged

dezren39 merged 1 commit into
mainfrom
xaltha/12825-tenant-store

Conversation

@dezren39

@dezren39 dezren39 commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

Component A slice 1 (design §8 item 1, under #9079): the PM tenant store — schema + migrations for the hosted PM service.

What lands

New package pm-stack/pm-service (PM service, Workers edition) with src/tenant-store/:

Acceptance mapping (#12825)

  • Migrations create the full PM store schema in a tenant Turso DB; schema version recorded — migration 0001 creates all 10 store tables + the bookkeeping table; the suite asserts the recorded version and idempotent re-runs.
  • Registry/pool/link-record shapes match pm stack: multi-board hierarchy + full task genealogy #9060 exactly (conformance-checked against laptop collector output shapes) — the suite's fixtures are the collector's landed shapes: the three PROJECT_BOARDS registry entries round-trip as rows, a ProjectPoolItem stores byte-faithful JSON with extracted keys, §11 historical/removed fencing (until + reason) is enforced by both validator and CHECK constraints, and the §12 worked-example Metadata block validates and round-trips.
  • No PM content in the central tenancy DB; no tokens/keys in any table (E §2.3) — these migrations target a per-tenant DB only; the suite scans every table's columns and fails if any names a token, secret, password, credential, or key.

Sequencing note

No dependency on E1 (#12796): that issue is the central tenancy DB schema — a different plane. This slice neither reads nor writes the tenancy DB; siblings #12796/#12803 are untouched.

Evidence

  • bun test in pm-stack/pm-service: 15 pass, 0 fail, 45 assertions (run locally in the sandbox against bun:sqlite; the suite's venue is CI — see below).
  • bun run typecheck: clean.
  • Suite wired into the nightly pm-stack-tests.yml in the same assert-exists style as the decision-events-worker suite, and registered in .github/test-suite-registry.json as pm-service.tenant-store.

Closes #12825


Get evidence
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

…ice 1, #12825)

New pm-stack/pm-service package (PM service, Workers edition —
component A of #9078, design §8 slice 1). The tenant store is one
schema in the tenant's Turso DB (component E tenant plane):

- migrations/0001_pm_tenant_store.sql: board registry rows (#9060
  §1 BoardDef as data), collector snapshots, the merged item pool,
  hierarchy/link records (#9060 §11), Metadata copies (#9060 §12),
  roadmap rows, milestones + release close-out snapshots (#9060
  §4), reconcile findings, and the writer-of-record lease row
  (design §5).
- migrate.ts: version-ordered runner; each migration applies in a
  transaction and is recorded in pm_schema_migrations (the schema
  version record); recorded-name drift fails loudly.
- schema.ts: the wire shapes + validators the store holds, mirrored
  field-for-field from #9060 and the laptop collector's landed
  output types (aggregator model.ts / board-registry.ts).
- test/tenant-store.test.ts: 15 conformance tests (45 assertions)
  against bun:sqlite — migration idempotence + drift, the landed
  board registry round-trip, pool-item byte-faithful JSON with
  extracted keys, §11 until/reason fencing, the §12 example block,
  lease fencing, §4 accounting checks, and the E §2.3 guard: no
  token/key/secret/credential column in any table.

Suite wired into pm-stack-tests.yml (nightly) in the same
assert-exists style as the decision-events-worker suite, and
registered in .github/test-suite-registry.json.

No dependency on E1 (#12796): that is the central tenancy DB
schema, a different plane — these migrations target a per-tenant
DB only and neither read nor write the tenancy DB.
@coderabbitai

coderabbitai Bot commented Nov 23, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 17 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 84ace95d-a671-40c7-9e83-3d2a4a576486
Commits

Reviewing files that changed from the base of the PR and between f93acb4 and 3d8f9d0.

Files ignored due to path filters: 1

  • pm-stack/pm-service/bun.lock is excluded by !**/*.lock
Files selected for processing: 12

  • .github/test-suite-registry.json
  • .github/workflows/pm-stack-tests.yml
  • pm-stack/pm-service/README.md
  • pm-stack/pm-service/package.json
  • pm-stack/pm-service/src/bun.d.ts
  • pm-stack/pm-service/src/tenant-store/load.ts
  • pm-stack/pm-service/src/tenant-store/migrate.ts
  • pm-stack/pm-service/src/tenant-store/migrations/0001_pm_tenant_store.sql
  • pm-stack/pm-service/src/tenant-store/schema.ts
  • pm-stack/pm-service/src/tenant-store/sqlite.ts
  • pm-stack/pm-service/test/tenant-store.test.ts
  • pm-stack/pm-service/tsconfig.json
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-23T07:40:40.095700Z 3d8f9d0 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

dezren39 added a commit that referenced this pull request Nov 23, 2026
…st + IngestDO (component A slice 2, #12826)

Stacked on slice 1 (PR #13054): the collector imports the tenant
store's SqlDb surface and lands rows in the tables slice 1's
migration defines (pm_boards registry in, pm_snapshots/pm_items/
pm_item_metadata/pm_reconcile_findings out); pm-stack/pm-service
does not exist on main yet, so this branch bases on
xaltha/12825-tenant-store and the PR retargets to main when #13054
merges.

Per design §3 (doc/2026-11-23T03-22-03Z_design_pm-service-workers-edition):

- pool.ts: the SAME GraphQL pool query the laptop collector runs
  (fields, views, parent, blockedBy/blocking, labels, milestones,
  subIssuesSummary), parameterized by board node id, plus the
  parser mapping it to the ProjectPoolItem/ProjectAudit shapes
  slice 1 pinned. A port, not an import — pm-service deploys as
  one Worker bundle; slice 8's conformance suite pins parity.
- fetch.ts: one board's paginated snapshot fetch; the stored ETag
  rides page 1 as If-None-Match and a 304 ends the run with no
  page fetches and no writes; rate-budget headers captured.
- ingest-do.ts: IngestDO, one per board — serializes the board's
  runs and holds its cursors (ETag/last-snapshot watermark) and
  GitHub rate-budget state. Derived state only (invariant 6).
- store.ts: registry reads (validated BoardDefs), snapshot landing
  (per-board pool replacement, so a failed board keeps its prior
  pool), §12 Metadata-copy upserts, ingest findings.
- collector.ts: runHostedCollector — per board, a per-org App
  installation token is minted through the injected tenancy seam,
  used for that board's fetch, and dropped; epic/spawn ancestry
  resolves over the MERGED pool so cross-board chains resolve;
  snapshots land with writer='hosted' + lease epoch provenance.

Acceptance (test/collector.test.ts, 9 tests): a run ingests every
registry board; a forced failure on one board leaves the other
boards' pools intact and records an ingest-failure finding;
cursors make a second run incremental (one conditional request
per board, no writes); no token value persists in any tenant-DB
table, DO state, or the run report (E §2.3, test-pinned). Plus
cross-board epic resolution, Metadata copies, rate-budget
deferral, and IngestDO serialization.

Suite registered as pm-service.collector and the pm-stack-tests
step renamed to cover both pm-service suites. Full package:
24 tests pass (15 slice-1 + 9 new), tsc --noEmit clean, both run
in the sandbox with bun.
@dezren39
dezren39 merged commit cdbdd6d into main Nov 24, 2026
2 checks passed
@dezren39
dezren39 deleted the xaltha/12825-tenant-store branch November 24, 2026 00:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

impl(pm-stack): PM tenant store — schema + migrations (component A slice 1, from #9079)

1 participant