Repository navigation
Description
Summary
A multi-PR stabilization effort (#58, #59) surfaced that "green CI" in this repo means "the projects a diff happened to touch are green," not "the repo is green." main reports green while carrying latent failures across lint, types, coverage, and tests that only execute when a PR drags a project into nx's "affected" set. Any substantial PR trips a cascade of these. This issue documents the structural causes and the remedies, so we fix the mechanism rather than patching symptoms forever.
Evidence (found while stabilizing)
Real bugs (now fixed in #58/#59):
- Schema-publish migration persisted a stale
docinto index columns (schema-registry: publishing a schema draft doesn't backfill new-field defaults into existing records #57) — reads returned the pre-migration doc. - Embedded-PGlite production builds shipped no runtime assets —
app/base,app/prm,examples/picksranvite buildwithoutcopy-pglite-assets.mjs, so the Docker runtime 500'd on boot forever. This made the Base Docker E2E fail 100% of runs. - Onboarding type error —
app/base/app/prmpassedkind/persistencetodefineOnboarding, fields the type dropped; green onmainonly because nothing there touches those apps.
Latent debt merely exposed by widening the affected set:
- oxlint violations in
store-postgresandcms-apithat hadn't run in ages. - knip failures (an unused
kody/spike, an app-resolved dependency). - Integration tests across ~20 projects at vitest's 5s default, flaking under CI load.
- Coverage-threshold debt in 7 packages (
cms-compat-wpat 45% vs its own 80% threshold,connect-atproto,cms-cli,prm,cms-api,cms-core) — each hard-codescoverage.thresholdsand fails when CI forces--coverage.include='src/**'on an affected PR. - A real SSE event-delivery issue in the Docker smoke under the cron snapshot worker's load (did not respond to a 10s→30s tolerance bump).
Structural causes
- PR CI is
nx affected, and nothing runs the full matrix.main's CI doesn't run everything either. Proof: the onboardingtest:typeserror exists on a cleanmainyetmainis green —base:test:typessimply never runs there. Green is therefore local to recent diffs. - Cross-cutting concerns checked per-project. Types, coverage, and the PGlite-asset build step are each handled per package. A change to a dependency doesn't reliably re-check dependents (graph edges / cache-input gaps), so cross-package breaks land silently.
- Nothing forces
maingreen.mainisn't branch-protected; admin-merging past red is routine. Every merge-past-red can bank a new dormant failure. - Config drift, no shared baseline. No shared vitest/build config → per-project
testTimeoutandcoverage.thresholdsset ad hoc (18% here, 85% there, 80% elsewhere), tuned to pass under whatever affected condition last ran. - Tests encode wall-clock as correctness. 5s vitest / 5s acquire / 10s SSE tolerances were calibrated for a fast, uncontended machine; the single-client embedded PGlite engine violates them under load.
- Critical build steps are opt-in per app. Shipping PGlite's WASM assets is a line each app must remember; nothing enforces it; only a (perpetually-red) smoke would catch the omission.
- A perpetually-red check gates nothing and hides the next layer. The Docker E2E was red 100% of the time; fixing the boot only then revealed the SSE issue behind it.
Amplifier: fast, largely agent-driven development (assembly-* workflows, admin-merges) optimizes for forward motion, so the cost — broken dormant projects — stays invisible until someone touches the right file.
Remedies
- Scheduled full-matrix run on
main(nx run-many --all --targets=test:types,test:oxlint,test:lib,test:build,test:knipnightly) so nothing stays dormant; triage its output to a known-debt baseline. - Branch protection on
main: require PRs + review + conversation resolution immediately; add required status checks once the debt behind them is cleared. - Shared vitest/build config so
testTimeout,coverage.thresholds, and the PGlite-asset copy can't drift or be forgotten (a vite plugin for the asset copy would make it automatic). - Decouple correctness from wall-clock where a test asserts behavior, not latency; raise/standardize timeouts for the single-client embedded engine.
- Reconcile the coverage gate: the per-project
thresholds+ forced--coverage.include='src/**'fail broadly; either rely solely on the merge-base regression check (coverage-check.mjs) or set realistic per-project numbers and stop forcing a global include. - Investigate the Docker SSE delivery under the cron worker (single-client contention vs a real dispatcher/transport bug).
Already landed
- fix(base): schema-publish migration no longer persists a stale doc into index columns (#57) #58 — schema-registry migration fix.
- chore: stabilize CI — onboarding type error, flaky timeouts, and embedded-PGlite production builds #59 — PGlite production assets (the Docker-boot fix), onboarding type error, embedded-engine acquire timeout, integration-test timeout bumps, lint/knip debt.
Activity
jherr commentedon Dec 1, 2026
Coverage gate — fix in #62
The per-project absolute
coverage.thresholdsconflict with CI's forced--coverage.include=src/**(needed for the apples-to-apples merge-base comparison). #62 zeros the absolute thresholds in the CI runs, leaving the regression check (coverage-check.mjs) as the sole gate — the design intent. Once a broad PR confirms Coverage green, addCoveragetomain's required checks.E2E Docker SSE — deep-dive conclusion
Investigated thoroughly; this is not a code bug with a clean fix, it's an interaction between the embedded engine and the CPU-starved CI runner:
cms_queryin the cron worker) completes; the schedule is also paused before the SSE test runs.packages/api/src/http.ts~L634) to honor revocation —resolveSession({fresh}) → auth.getUser → a read on the embedded engine's single connection. On the shared CI runner (CPU-starved, WASM PGlite), that per-event check serializes behind the write's own commit + dispatcher work and cumulatively exceeds the 30s SSE window.events.test.ts > "rechecks session revocation before emitting another event"requires the fresh check before each emit. The frame must not go out to a revoked session, so the DB revocation check can't be deferred or cached.Remediations (pick per appetite)