Skip to content

test(ci): verify the packed SDK flow and Postgres races - #224

Merged
allisonmahmood merged 1 commit into
mainfrom
sdk/208-ci-e2e
Sep 12, 2026
Merged

allisonmahmood merged 1 commit into
mainfrom
sdk/208-ci-e2e

Conversation

@allisonmahmood

@allisonmahmood allisonmahmood commented Sep 11, 2026 •

Copy link
Copy Markdown
Owner

The SDK needs an end-to-end check of the shipped package and real-Postgres coverage for races that PGlite cannot prove.

Adds the packed init → dev → headless insert → stop → publish → authenticated runtime → additive republish flow, plus one real-Postgres block covering the seven concurrency invariants. Both run as unconditional CI checks with fatal startup failures; the test-tier docs explain the commands and isolation. Dev rows remain local, so the hosted flow inserts and reads its own row.

Stacked on sdk/207-patchy-dev (#223). This PR contains only the #208 commit above that branch.

Closes #208.

Verification

  • Packed e2e and platform/lifecycle/signal probes passed.
  • Real-Postgres concurrency: 3/3 passed; unavailable Postgres and missing Chromium controls exited 1.
  • Typecheck, lint and formatting passed; Standards and Spec reviews found no issues.
  • Full offline suite: 701/701 passed with --maxWorkers=4. The initial default-worker run hit a 5-second timeout in the unchanged Postgres runtime test; that test passed independently.

GitHub branch-protection settings were not changed; both workflow jobs are unconditional.

After this PR reaches main

  • After merge to main, added postgres-concurrency to the active main CI ruleset. cli-smoke was already required and contains the packed SDK flow. Verified the seven required contexts; strict up-to-date checks and all other rules remain enabled.

Implemented with GPT-6 Astra in the Oh My Pi harness.

@github-actions github-actions Bot added area:server Touches the server area area:ci CI, shared testing infrastructure, development scripts and tooling area:docs Touches the docs area size:l 501-1,000 changed lines labels Sep 11, 2026
@allisonmahmood

Copy link
Copy Markdown
Owner Author

Astra review

Reviewed 6634477 against origin/sdk/207-patchy-dev (e04849c) using git diff origin/sdk/207-patchy-dev...HEAD, with #208 as the spec. One pass, no subagents; merge blockers only.

Standards

No merge-blocking method or YAGNI findings.

Spec

  1. Intent — Make postgres-concurrency a required check on main. The new CI job runs unconditionally, but that does not make it a merge gate. ci: the packed e2e from init to a served tier 1 patch; real-Postgres concurrency #208 explicitly requires: “Both are required checks and green on main.” Reading GET /repos/allisonmahmood/patchy-cloud/rules/branches/main confirms active ruleset 22387632 requires test (22), test (24), lint, cli-smoke, clerk-live, and dependency-review—not postgres-concurrency. A failing concurrency suite therefore does not block an otherwise-green PR. Add this check to the active main ruleset, preserving the existing requirements, before merging; the documentation's instruction that both checks “must remain required” does not satisfy this acceptance criterion.

Verification: pnpm test:postgres-concurrency passed locally (1 file, 3 tests). Packed E2E reviewed statically, not rerun locally. No repository files or branch settings changed.

Summary: Standards: 0 blockers. Spec: 1 blocker—real-Postgres concurrency is not an enforced merge gate.

@allisonmahmood

Copy link
Copy Markdown
Owner Author

Sol review

Standards

No verified standards findings. The large concurrency file is justified by the seven required real-Postgres races: its timing seams stay local, prove distinct blocked sessions, and assert final caller-visible state. I found no avoidable abstraction, duplicated production mechanism, or YAGNI violation worth changing.

Spec

Blocking — make postgres-concurrency a required check on main. Issue #208 says, “Both are required checks and green on main.” .github/workflows/ci.yml:38-52 creates an unconditional job, and the current PR run is green, but the active main CI ruleset (22387632) requires cli-smoke and omits postgres-concurrency. A future failure in the real-Postgres suite therefore would not block a merge. Add the postgres-concurrency status context to that ruleset before merging; this is a repository-setting change, not another YAML change.

The packed init → dev shell → hosted shell → additive republish path and the other concurrency invariants trace cleanly to #208. I also verified the rollback test's direct pointer-change seam: no production rollback API exists, and the seam races the real publish row lock while asserting the observable pointer, content, cumulative inventory, and old/new-version behavior. No additional spec finding there.

Summary: Standards — 0 findings. Spec — 1 finding; worst is the missing postgres-concurrency merge gate.

@allisonmahmood

allisonmahmood commented Sep 11, 2026 •

Copy link
Copy Markdown
Owner Author

Updated disposition for the Astra review and Opus review. Opus is the current cross-family review, superseding Sol. Pulled merged base 97d40cc; fixes are committed and pushed as 539fed6.

Fixed

  • Postgres discovery: vitest.postgres.config.ts now includes **/src/**/*.postgres.test.ts, rather than one literal file. The shared offline exclusion **/*.postgres.test.ts and explicit fatal empty-suite guard remain intact.
  • Durable documentation: docs/DEVELOPMENT.md now describes marker discovery and states the lasting rule that main must require postgres-concurrency and cli-smoke. PR-specific activation timing was removed from the document; the unchecked rollout checklist remains in this PR description.
  • README: pnpm test:all now describes package tests, real-Postgres concurrency, and packed CLI e2e, with the Chromium/system-dependency installation prerequisite and live Clerk exclusion.
  • Both cheap simplifications: removed the redundant two-session startup handshake while retaining local URL, template, real server version, and database assertions. The actual races still prove blocked, distinct PostgreSQL sessions through pg_blocking_pids. openNotes returns the { rows, cursor } page directly; all four consumers were migrated.
  • Merged-base contract drift found by the packed run: removed the stale exact generated-file inventory assertion that expected deleted metadata.json, and corrected dev stop --json to the current receipt without baseline. JSON shape checks and the complete real init/dev/publish flow remain. No production code changes.

Kept, with reasons

  • The combined concurrency scenario and phase comments: later invariants need the old/current bindings produced by its publish race; splitting would duplicate setup. All seven invariants remain covered.
  • Local/hosted data isolation: publish does not migrate developer rows. The hosted flow still proves an empty store before inserting and reading its own row. The browser-native response capture fix is preserved.
  • Ruleset activation deferral: Astra's enforcement gap is accepted, not dismissed. The main ruleset is untouched, as instructed: enabling postgres-concurrency now would block thirteen lower stacked PRs. Activation after this reaches main remains tracked in the PR checklist. Packed e2e already runs inside required cli-smoke; no separate context is needed today.

Verification

  • Temporary marked probes in two different package/app source trees were excluded from offline discovery and included by the dedicated config. Both deliberately failing tests actually executed and caused exit 1. An empty dedicated selection also exited 1. Both probes were removed.
  • Real-Postgres concurrency: 3/3 passed. Complete packed CLI e2e: passed; owned temporary roots were removed.
  • Full offline suite: 725 tests / 75 files passed with --maxWorkers=4. Typecheck, lint, and formatting checks passed.
  • CI run 34605964183 completed successfully on the exact pushed SHA above. All current main-required contexts passed: test (22), test (24), lint, cli-smoke, clerk-live, and dependency-review. postgres-concurrency and label also passed: all eight checks green.
  • No newer review findings or formal change-request reviews were present. GitHub reports MERGEABLE / CLEAN against sdk/207-patchy-dev.

Unresolved merge blockers: none under the agreed disposition. The post-main ruleset step remains intentionally deferred and tracked. Ready to merge into the stack base; not merged.

@allisonmahmood

Copy link
Copy Markdown
Owner Author

Fixed the packed tier-1 response-body race reported by downstream #225 in run 34588317366. Final fix: 29b99b9, committed and pushed on sdk/208-ci-e2e.

The first attempt (cad481c) consumed JSON immediately after waitForResponse, but CI still reproduced the race: Chromium can discard its CDP response-body cache during an automatic shell reload even then. That attempt was insufficient.

The final harness captures the body inside the browser: the real native fetch response is cloned and decoded, and the value is copied through a Playwright binding before the original response returns to the broker. Node-side waiters consume these captured values, not navigation-scoped Playwright Response bodies. openNotes and both insert/list waits use this path. Actual HTTP requests, cookies, responses, and the existing status/principal/version/row/CSP assertions remain intact. No sleeps, retries, skipped assertions, mock responses, or production changes.

Verification of the final implementation:

  • Three consecutive complete pnpm test:packed-cli-e2e runs passed, each with fresh packed installation/server/browser state; all three temporary roots were removed.
  • Harness syntax and Prettier checks passed.
  • CI run 34591681395 succeeded on the exact final SHA. cli-smoke, postgres-concurrency, test (22), test (24), lint, clerk-live, and dependency-review all passed; label is green too.
  • GitHub reports MERGEABLE / CLEAN. No unresolved blockers for PR test(ci): verify the packed SDK flow and Postgres races #224 under the agreed ruleset disposition; post-main activation remains deferred and tracked. Not merged.

@allisonmahmood

Copy link
Copy Markdown
Owner Author

Opus review

Reviewed 29b99b9 against origin/sdk/207-patchy-dev with git diff origin/sdk/207-patchy-dev...HEAD; spec is #208. Read the Astra and Sol reviews and the replies first; I am not re-litigating the main ruleset, which is deliberately deferred until this reaches main. Nothing below repeats them.

Verified locally in the PR worktree: pnpm test:postgres-concurrency (1 file, 3 tests, 14.6 s) and pnpm lint both pass. Everything I call a defect below was reproduced, not reasoned about.

Spec

1. Blocking — the *.postgres.test.ts marker is a dead letter; the next such file runs nowhere. test/vitest.config.ts:10 excludes the glob **/*.postgres.test.ts from ordinary discovery, but vitest.postgres.config.ts:9 opts back in with a single literal path, packages/patches/src/SdkConcurrency.postgres.test.ts. The two never meet. Reproduced by dropping one scratch file, packages/primitives/src/ZzScratchProbe.postgres.test.ts, into the tree:

--- root pnpm test discovery ---
NOT discovered by root vitest.config.ts
--- postgres config discovery ---
NOT discovered by vitest.postgres.config.ts

Discovered by neither runner, with no error. passWithNoTests: false (vitest.postgres.config.ts:11) does not help: it only fires on a fully empty suite, and it is already Vitest's default — pnpm exec vitest run --config test/vitest.config.ts NoSuchTestFileXyz exits 1 today without it. So the second real-Postgres invariant anyone writes is silently skipped, which is the precise failure mode #208 legislates against ("A CI job that fails loudly when the e2e cannot start rather than skipping"), and it makes docs/DEVELOPMENT.md:455-456 inaccurate — the marker does not route anything, it only subtracts.

One line: include: ["**/src/**/*.postgres.test.ts"]. Then the marker in the filename means what the docs say it means, and passWithNoTests: false becomes a real guard rather than a decorative one.

Everything else traces to #208. All seven invariants are present and each asserts caller-visible state through Content, Patches, TableOperations and Files rather than SQL or a mock: first-publish race (SdkConcurrency.postgres.test.ts:228), whole-publish serialisation with cumulative inventory (:374-388), old bundle inserting during a column add (:355-402), insertMany unique winner (:440-476), same-name put (:512-541), rollback versus publish (:584-608), and the FOR UPDATE lost update (:635-660). blockedBy (:150) observing pg_blocking_pids instead of trusting fork order is the right call and is what makes these deterministic rather than hopeful.

The overlaps with the package suites are real but not duplication: the insertMany case races an old bundle's binding against a current one across schema revisions, which packages/primitives/src/TableOperations.test.ts:162 cannot express; likewise the file put against packages/primitives/src/Files.test.ts:41.

I also agree with the one deliberate deviation from the spec's prose. #208 says the hosted runtime call "returns the inserted row"; scripts/packed-cli-e2e.mjs:3308-3316 instead asserts the hosted store is empty and inserts its own row. That is the correct product answer — publish carries the application and its schema, not the developer's local data — and the comment says so. Keep it.

Standards

2. docs/DEVELOPMENT.md:469 is a PR-scoped work artifact in a durable doc. "Once PR #224 reaches main, add postgres-concurrency … defer this until then because the thirteen stacked PRs below it do not emit postgres-concurrency." CLAUDE.md § Plans and work artifacts: "Track active maintainer work in the GitHub issue or project item that owns it … A merged PR is the implementation record. Close or update its tracking item when the work lands; do not preserve a second checklist in the repository." This line is stale the moment it merges — the PR number and the stack below it both stop being facts — and the PR body checklist already carries it. Delete the sentence; the disposition lives in #208 and in this PR. (It is also the one unwrapped line in a doc otherwise wrapped at 82 columns or under; this one is 253.)

3. README.md:76 was not carried along. It still reads "pnpm test:all runs package tests plus the packed CLI e2e". As of scripts/test-all.sh:21 it also runs the real-Postgres concurrency block, and the packed e2e now needs pnpm exec playwright install --with-deps chromium first. A reader who follows the README into pnpm test:all hits a Chromium launch failure the README never mentioned. docs/DEVELOPMENT.md:446-451 got this right; the README needs the same sentence.

Method and YAGNI

Not blocking, but both would materially shrink the change:

  • SdkConcurrency.postgres.test.ts:68-97 tests the harness, not the product. The two-transaction pg_backend_pid() handshake — two Deferreds, an Effect.all at unbounded concurrency, a live-clock timeout — exists to prove the runner handed us real Postgres. Lines 92-93 already prove that far more cheaply (assert.notMatch(session.version, /pglite/i)), and every test in the block proves distinct backends for real through blockedBy/pg_blocking_pids; PGlite would fail them outright rather than pass them quietly. Dropping the handshake and keeping the URL, template and version() assertions removes ~30 lines of the densest Effect in the file without losing a guarantee.
  • The second it.effect (:300-549) is 250 lines covering three invariants in comment-delimited phases. I checked whether it splits: it does not cleanly, because the old/current bindings the later phases need are produced by the publish race in the first phase, and re-deriving them per test would cost more than it saves. Leaving it is the right trade. Worth knowing that a failure here will point at a 250-line effect, though — the phase comments at :404 and :478 are doing real work and should stay.
  • Tiny: scripts/packed-cli-e2e.mjs:3208 returns { rows: listed } where listed is itself a { rows, cursor } page, so all three call sites read (await openNotes(...)).rows and compare it to { rows: [], cursor: null }. return listed; reads straight.

Summary

Standards: 2 findings; worst is the PR-scoped activation note checked into docs/DEVELOPMENT.md. Spec: 1 finding; worst is the *.postgres.test.ts marker matching nothing in the runner that is supposed to honour it, so the next real-Postgres test silently never runs. Fix 1 before merge; 2 and 3 are one-line edits worth doing in the same push. No repository files or settings changed by this review.

Base automatically changed from sdk/207-patchy-dev to main September 12, 2026 12:59
@allisonmahmood
allisonmahmood merged commit ee39692 into main Sep 12, 2026
8 of 16 checks passed
@allisonmahmood
allisonmahmood deleted the sdk/208-ci-e2e branch September 12, 2026 13:07
allisonmahmood added a commit that referenced this pull request Sep 12, 2026
The SDK stack landed its docs ticket by ticket, leaving stale
tier-0-only claims and conflicting terminology. This pass reconciles the
product, glossaries, ADRs, guides and skills against the completed
stack, including the seven migration records and post-merge concurrency
gate. It also fixes nullable-array notation in the generated API
reference.

**Stacked on `sdk/208-ci-e2e` (#224).** This PR contains only the #209
reconciliation commit above that branch.

The prototype PRs remain closed with build-ticket pointers, their remote
branches are deleted, and the SDK map has its final build record.
Existing schema-revision and dev-inventory differences from the spec are
documented without changing runtime behavior.

Closes #209.

## Verification
- `pnpm lint` and `pnpm typecheck` passed (18 packages).
- `pnpm test`: 701 tests passed across 74 files.
- Generated API-doc test and before/after renderer smoke passed.
- Standards and spec reviews: no actionable findings remain.

Model: GPT-6 Astra. Harness: Oh My Pi.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:ci CI, shared testing infrastructure, development scripts and tooling area:docs Touches the docs area area:server Touches the server area size:l 501-1,000 changed lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ci: the packed e2e from init to a served tier 1 patch; real-Postgres concurrency

1 participant