Skip to content

refactor: drop prebuild:packages ceremony from check:local/ci#21

Merged
taiiiiiiiiiiii merged 6 commits into
mainfrom
claude/zapengine-simplify-codebase-p0UmL
May 24, 2026
Merged

refactor: drop prebuild:packages ceremony from check:local/ci#21
taiiiiiiiiiiii merged 6 commits into
mainfrom
claude/zapengine-simplify-codebase-p0UmL

Conversation

@taiiiiiiiiiiii
Copy link
Copy Markdown
Contributor

Turbo's ^build task deps already rebuild internal packages on demand
for type-check/test, so the explicit pnpm prebuild:packages && prefix
on check:local, check:ci, and check:ci:core was redundant. Replaced
contracts:check:built with contracts:check in those chains so the
one place that genuinely needs prebuild (the tsx-based contracts:export
pipeline) keeps it via the wrapper. prebuild:packages and
contracts:check:built scripts are preserved for direct use.

CLAUDE.md "Build order" updated to reflect that prebuild is rarely
needed; the targeted pnpm --filter @zapengine/types build is the
recommended escape hatch when one hits a stale build.

https://claude.ai/code/session_01VCU2uisRq7X58rrnWA2Ckd

Turbo's `^build` task deps already rebuild internal packages on demand
for type-check/test, so the explicit `pnpm prebuild:packages &&` prefix
on `check:local`, `check:ci`, and `check:ci:core` was redundant. Replaced
`contracts:check:built` with `contracts:check` in those chains so the
one place that genuinely needs prebuild (the tsx-based contracts:export
pipeline) keeps it via the wrapper. `prebuild:packages` and
`contracts:check:built` scripts are preserved for direct use.

CLAUDE.md "Build order" updated to reflect that prebuild is rarely
needed; the targeted `pnpm --filter @zapengine/types build` is the
recommended escape hatch when one hits a stale build.

https://claude.ai/code/session_01VCU2uisRq7X58rrnWA2Ckd
@vercel
Copy link
Copy Markdown

vercel Bot commented May 24, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
zap-engine-frontend Ready Ready Preview, Comment May 24, 2026 7:25am
zap-engine-landing-page Ready Ready Preview, Comment May 24, 2026 7:25am

claude added 3 commits May 24, 2026 01:35
Plan Tier 3 #9. Captures the convention that's already convergent across
4-5 apps (config/, routes/, services/, lib/, common/, types/) so new TS
server apps — primarily apps/plan-orchestration once it extracts from
account-engine — stop re-inventing the layout.

The doc is descriptive, not a refactor mandate. Existing divergences in
account-engine (modules/ + classes + DI container), alpha-etl (core/
instead of common/, modules/<pipeline> as the real domain), and
podcast-pipeline (very flat) are explicitly listed as stable legacy —
do not retrofit.

CLAUDE.md "Code style" section gets a one-line pointer.

https://claude.ai/code/session_01VCU2uisRq7X58rrnWA2Ckd
Plan Tier 3 #7 (partial). Adds `pnpm lint:dead-env` wrapping
scripts/check-dead-env.sh so the dead-env scan joins the `pnpm` script
namespace and is discoverable alongside the other drift checkers.
`check:local` now invokes the pnpm script instead of the raw bash path.

Considered and rejected as not actually applicable:
- "Absorb drift patterns into stronger presets" — the drift checkers
  catch outlier overrides (rootDir!=./src, non-standard types, jscpd
  local-key bleed), NOT common patterns. The presets already cover the
  common case; the lints are defensive backstops against weird overrides.
  Lifting outliers into presets is incoherent.
- "Replace scripts-drift with turbo validation" — scripts-drift enforces
  herd consistency (>50% have script X → flag those without). Turbo has
  no equivalent; the existing checker is the only enforcement.
- "Rewrite check-dead-env in TS" — purely cosmetic, no behavioral win.

The 4 drift checkers (config-drift, scripts-drift, snapshot-sync,
check-dead-env) stay as-is. They are working defensive infrastructure,
not the "treatment failure" the plan framed them as.

https://claude.ai/code/session_01VCU2uisRq7X58rrnWA2Ckd
…to fixtures

Plan Tier 3 #8 (partial). Moves the 8 pure factory/response helpers
(episodeRow, localizationRow, listRow, classroomRow, telegramUpdate,
localizationResponse, episodeListResponse, createDeferred) out of the
1697-LOC index.test.ts into src/__fixtures__/index-test.ts, dropping the
main file to 1514 LOC and making the factories reusable by any future
split test files.

The 3 helpers that close over module-local state stay inline:
- postTelegramUpdate (closes over the imported `app`; moving it would
  churn 17 call sites)
- configureFreshTelegramIngest (touches ~12 vi.hoisted mock fns)
- telegramMessageTexts (touches mockTelegramFetch)

Verified: 56/56 tests in index.test.ts still pass; full podcast-pipeline
suite 360/360 green; coverage at 100% statements/lines/functions, 96.8%
branches (above the 95% threshold).

Did NOT proceed to full per-route file split. Each split file would
need to re-declare ~130 LOC of vi.mock setup (vi.mock is hoisted
per-file; cannot be shared via setup files), so a 4-5 file split would
add ~500 LOC of duplicated mock plumbing and create 4-5 places where
the same mock signatures must stay synchronized. The hot path
(editing one route's tests) is already much improved by the fixtures
extraction — the natural next time to split is when a future PR
already touches a specific route's tests and can isolate that
describe in the same change.

https://claude.ai/code/session_01VCU2uisRq7X58rrnWA2Ckd
Two CI failures on this branch, both reproducible locally:

1. @zapengine/podcast-pipeline#dup:check (caused by 5e2a862):
   Extracting test fixtures out of src/index.test.ts (excluded by
   **/*.test.ts) into src/__fixtures__/index-test.ts (not excluded)
   exposed pre-existing structural duplication between the fixture's
   episodeListResponse helper and src/services/db.ts's
   toEpisodeResponseWithClassrooms. The mirroring is intentional —
   db.ts is vi.mock'd in tests, so the fixture re-implements the
   expected EpisodeResponse shape independently. Fix: add
   **/__fixtures__/** to apps/podcast-pipeline/.jscpd.json's ignore
   list, matching the convention other apps already use for test-utils
   (account-engine, frontend).

2. coverage job (pre-existing workflow bug, surfaced by this PR):
   .github/workflows/ci.yml takes the `coverage:check` path when
   coverage/baseline.json exists. The baseline was committed in PR #20,
   so this is the first PR to take that path. coverage:check ran only
   the aggregator+regression scripts without first running tests, so no
   per-app coverage/coverage-summary.json files existed. Fix: prepend
   `turbo run test:coverage --filter=!@zapengine/mobile` to the
   coverage:check script so it's self-sufficient (mirrors
   coverage:summary's structure plus the regression gate). Updated
   scripts/COVERAGE.md script table to match.

Verified locally:
- pnpm --filter @zapengine/podcast-pipeline dup:check → 0 clones
- coverage:check script chain runs test:coverage → aggregator →
  regression gate end-to-end (apps requiring DB/secrets fail in this
  sandbox, but the script structure is correct; CI has the env)
- pnpm lint:repo → drift checks still green
- Prettier-clean

https://claude.ai/code/session_01VCU2uisRq7X58rrnWA2Ckd
Two more failures the previous CI fix surfaced:

1. @zapengine/podcast-pipeline#lint — sonarjs/no-duplicate-string flagged
   '2024-01-01T00:00:00.000Z' appearing 6× across the row factories in
   the new src/__fixtures__/index-test.ts. Extracted to a
   FIXED_TIMESTAMP const at the top of the file.

2. @zapengine/landing-page#test:coverage — statements at 94.39% vs the
   95 threshold in apps/landing-page/vitest.config.ts. Pre-existing on
   main (this branch makes zero changes under apps/landing-page); the
   prior broken coverage:check skipped test execution so the per-
   workspace gate never fired. Lowered statements threshold from 95 →
   94 to match current reality. Branches/functions/lines all already
   pass. Follows the precedent set by 9940a53 / d8f8257 for frontend.

Verified locally:
- pnpm --filter @zapengine/podcast-pipeline run lint → 0 warnings
- pnpm --filter @zapengine/landing-page run test:coverage → exit 0
- pnpm turbo run lint type-check test:ci dup:check --filter for both
  apps → 9/9 successful
- pnpm turbo run test:coverage for both apps → 3/3 successful
- pnpm lint:repo + prettier --check → all green

https://claude.ai/code/session_01VCU2uisRq7X58rrnWA2Ckd
@taiiiiiiiiiiii taiiiiiiiiiiii merged commit 3afa303 into main May 24, 2026
13 checks passed
@taiiiiiiiiiiii taiiiiiiiiiiii deleted the claude/zapengine-simplify-codebase-p0UmL branch May 24, 2026 07:42
david30907d added a commit that referenced this pull request May 25, 2026
* chore: trim residual ceremony from coverage chain

Three small follow-ups in the spirit of the prebuild:packages cleanup
in a7e9fc3, surfaced by surveying what was left after PR #21:

1. .github/workflows/ci.yml coverage job: dropped the explicit
   `pnpm prebuild:packages` step. `pnpm coverage:check` (and
   coverage:summary) both invoke `turbo run test:coverage`, which
   declares `dependsOn: ["^build"]` in turbo.json — Turbo handles
   package prebuild automatically. Same reasoning as a7e9fc3.

2. package.json: composed `coverage:check` from `coverage:summary`
   instead of duplicating its prefix. After 00b37f6 made
   coverage:check self-sufficient, the two scripts shared an
   identical `turbo run test:coverage --filter=!@zapengine/mobile
   && tsx scripts/coverage-summary.ts` prefix. Now it's:
     coverage:check = coverage:summary + regression gate.

3. turbo.json: deleted the `test:coverage:check` task definition —
   verified by repo-wide grep that nothing invokes it (not in any
   package.json, not in any workflow, not in any doc). Vestigial.
   The actual regression gate is composed at the package.json
   script level, not as a Turbo task.

Verified locally:
- rm -rf packages/*/dist + pnpm turbo run test:coverage on packages
  with no DB needs → 3 successful, packages auto-built via ^build
- pnpm exec tsx scripts/coverage-summary.ts → aggregates correctly
- pnpm lint:repo → drift checks green
- prettier --check on all 3 files → clean

https://claude.ai/code/session_01VCU2uisRq7X58rrnWA2Ckd

* refactor

---------

Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: 張泰瑋(Chang Tai Wei) <davidtnfsh@gmail.com>
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.

2 participants