Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 3.8k
improvement(ship): pre-flight regenerate artifacts + parallel audit suite#5927
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Uh oh!
There was an error while loading. Please reload this page.
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
e66baa9
improvement(ship): pre-flight regenerate artifacts + parallel audit s…
waleedlatif1 b1c173a
fix(ship): scope Phase A to in-repo generators + propagate failures
waleedlatif1 f6cb728
fix(ship): make pre-flight status checks exit non-zero on failure
waleedlatif1 fcab4a2
fix(ship): gate lint exit in Phase B pre-flight
waleedlatif1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -35,10 +35,47 @@ When the user runs `/ship`: | ||
| 5. **Run migration safety** — only if the diff touches `packages/db/migrations/**` or `packages/db/schema.ts`: | ||
| - Run `/db-migrate` to review the migration for zero-downtime safety (expand/contract phasing, backward-compatibility with the deployed app version). | ||
| - `bun run check:migrations origin/staging` must pass (staging is the PR base). Do not silence a flagged statement with a `-- migration-safe:` annotation unless `/db-migrate` confirmed the old code no longer depends on it; otherwise split the destructive change into a later deploy. | ||
| 6. **Run pre-ship checks** from the repo root before staging: | ||
| - `bun run lint` to fix formatting issues | ||
| - `bun run check:api-validation:strict` to catch boundary contract failures before CI | ||
| 7. **Stage and commit** the changes with the generated message | ||
| 6. **Run pre-ship checks** from the repo root before staging. This has two phases: first **regenerate** every committed artifact so generated files never drift into a CI failure (this is what catches things like `agent-stream-docs` going stale after a `models.ts` edit), then run the **full audit suite** CI's `Lint and Test` job enforces. Both phases parallelize — but only across commands that write **disjoint** outputs — and a bare `wait` swallows child exit codes, so both phases below explicitly collect each job's status and abort ship if any failed. | ||
| **Phase A — regenerate the always-in-repo committed artifacts (parallel), then let step 7 stage whatever changed.** Regenerate only the generators whose inputs live entirely in this repo and that any ordinary code change can drift — `agent-stream-docs:generate` (derives from the provider model registry) and `skills:sync` (derives from `.agents/skills/**`). They write disjoint trees (`apps/docs/…/agent.mdx` vs the `.claude`/`.cursor` command projections), so they parallelize safely, and each is idempotent (a no-op when already in sync): | ||
| ```bash | ||
| rm -f /tmp/ship-gen-results | ||
| for g in agent-stream-docs:generate skills:sync; do | ||
| ( bun run "$g" >"/tmp/ship-gen-${g//:/-}.log" 2>&1; echo "$? $g" >>/tmp/ship-gen-results ) & | ||
| done | ||
| wait | ||
waleedlatif1 marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| # any non-zero line is a FAILED generator — read /tmp/ship-gen-<name>.log and fix before shipping; | ||
| # a silently-failed generate leaves a stale artifact that Phase B / CI then rejects. | ||
| # The `exit 1` makes this block itself exit non-zero on failure, so anything gating on the | ||
| # command's status (an agent, or a wrapping script) actually stops — do NOT collapse it to | ||
| # `grep … && echo ❌ || echo ✅`, which always exits 0 and silently lets ship continue. | ||
| if grep -vE '^0 ' /tmp/ship-gen-results; then echo "❌ generator(s) failed — do not ship"; exit 1; fi | ||
| echo "✅ artifacts regenerated" | ||
| ``` | ||
| Then `git status --short` to see what regenerated — those files must be staged in step 7 alongside your own changes. | ||
| **Do NOT blanket-run the domain generators here.** `mship:generate` (`generate-mship-contracts.ts`) is an **umbrella** that drives all nine mothership contract generators (`mship-contracts`, `billing-protocol-contract`, `mship-tools`, the four `trace-*`, `metrics-contract`, `vfs-snapshot-contract`) and biome-formats `apps/sim/lib/copilot/generated/` — never run it *and* its constituents (they write the same files and corrupt each other in parallel), and never run it on an ordinary ship: it reads an **external** copilot-contract source that isn't checked out in most worktrees, so it hard-fails with `ENOENT` and would abort ship for an unrelated reason. `generate:pi-model-catalog` (under `apps/sim`) likewise regenerates from the installed Pi package, not repo source. Only when **this PR's diff actually touches** a domain generator's input do you regenerate it deliberately and run its matching `:check` (`bun run mship:check` / the individual `*:check`) — with the external source present. | ||
| **Phase B — run lint + every audit CI enforces, in parallel, and abort ship if any fails.** `bun run lint` first (it autofixes formatting and mutates files, so don't parallelize it with the read-only audits), then fan the rest out and collect exit codes. This is exactly the read-only audit set from CI's `Lint and Test` job (all in-repo, runnable in any worktree): | ||
| ```bash | ||
| # autofix formatting first (mutating; not parallel-safe with the audits). Gate its exit too — | ||
| # a non-zero lint (unfixable errors) must abort before the audits run, not be ignored. | ||
| bun run lint || { echo "❌ lint failed — do not ship"; exit 1; } | ||
| rm -f /tmp/ship-audit-results | ||
| for s in check:boundaries check:api-validation:strict check:utils check:zustand-v5 \ | ||
| check:react-query check:client-boundary check:bare-icons check:icon-paths \ | ||
| check:realtime-prune skills:check agent-stream-docs:check; do | ||
| ( bun run "$s" >"/tmp/ship-audit-${s//:/-}.log" 2>&1; echo "$? $s" >>/tmp/ship-audit-results ) & | ||
| done | ||
| wait | ||
| # any non-zero line is a failing audit — read its /tmp/ship-audit-<name>.log and fix before shipping. | ||
| # `exit 1` on failure preserves the original sequential checks' semantics (their non-zero exit is | ||
| # what an agent gates on); never use `grep … && echo ❌ || echo ✅` here — it always exits 0. | ||
| if grep -vE '^0 ' /tmp/ship-audit-results; then echo "❌ audit(s) failed — do not ship"; exit 1; fi | ||
| echo "✅ all audits passed" | ||
waleedlatif1 marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| ``` | ||
| If Phase A regenerated a file, its matching `:check` in Phase B now passes trivially — that parity is the point. Do not ship with any generator or audit failing; fix the cause (never silence it) and re-run. `check:migrations` and `type-check` are covered by steps 5 and CI respectively and are not repeated here. | ||
| 7. **Stage and commit** the changes with the generated message — including any files Phase A regenerated in step 6 | ||
| 8. **Push to origin** using the current branch name — `--force-with-lease` if step 2's sync | ||
| check did any history rewrite (a clean rebase or a cherry-pick rebuild) on a branch that had | ||
| already been pushed once; a plain push would be rejected in exactly the polluted-remote case | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.