Skip to content

feat(packs): migration packs as a public, testable contract - #38

Merged
lucasbraum merged 5 commits into
mainfrom
claude/packs-public-contract-51k71t
Oct 7, 2026
Merged

lucasbraum merged 5 commits into
mainfrom
claude/packs-public-contract-51k71t

Conversation

@lucasbraum

Copy link
Copy Markdown
Collaborator

What and why

Packs were knowledge only the runner's authors could add, and the verified label rested on one synthetic fixture. This makes a pack a public contract anyone, or a scheduled agent, can meet and test:

  • Contract (packages/core/src/packs/contract.ts, docs/packs.md, zod as the reference): metadata (package, from/to ranges, sources, maintainer), mechanical rules (detect = the check findings a rule claims by kind/symbol, plus an optional source detect; rewrite at one reported site), behavior notes with how each is reported (finding / decision / test-follow-up), agent instructions, fixtures, ground truth. definePack builds the runner's hooks from that alone. Zod and stripe implement it by hand. Zod's rules now carry their own rewrite; stripe declares the rules its evidence classifies. check, fix, list and verify take packs from a generated registry instead of two hard-coded lists.
  • uptide pack new <pkg> --from <range> --to <range> scaffolds the pack, one example rule, a fixture pair, a test, empty ground truth and a verification record, and registers it. Its output passes pnpm lint and pnpm test as written.
  • uptide pack test [pkg] runs the fixtures, then check with the pack on every ground-truth repository. It prints precision and recall per rule, overall and for breaking findings, and lists every false positive and false negative as repo file:line rule (plus sites reported under another rule). It exits 1 on any false positive among breaking findings, a failing fixture, or a stale verification.json. Flags: --json, --offline, --fixtures-only, --write. pnpm uptide runs the CLI from source.
  • Ground truth: each entry is a public repo + the full SHA before its upgrade + the expected findings (file, line, rule). Optional directory covers a project below the repo root, and fixture entries for repositories in this tree are scored but never counted. Repos are fetched shallow at that commit, installed with scripts off (falling back to an unfrozen install, still scripts off, when the lockfile was already out of sync), and cached in ~/.cache/uptide/ground-truth. pnpm packs:fetch [--corpus] fills the cache, reusing fixtures/corpus.json. pnpm packs:truth drafts the expected findings from two non-Uptide sources: the repository's own TypeScript (errors and deprecations new with the target linked) and its upgrade commit's diff.
  • Verified gate, in code (statusOf, recordedStatus, activePacks) and docs: verified needs ground truth from ≥2 public repos, no false positive among breaking findings, and at least one breaking finding predicted. Otherwise the pack is a candidate: it ships, pack test scores it, and check/list/fix treat the dependency as generic. The CLI reads the recorded verification.json, which is tied to the ground truth's sha256. CI fails when that record no longer matches the evidence.
  • CI: .github/workflows/packs.yml runs pack test --json for every pack with the ground-truth cache restored. It always reports (passing without work when neither packs nor the engine they depend on changed), so it can be a required check.
  • Contributor path: "Write a pack" in CONTRIBUTING.md (≈1 hour), a pack PR template (?template=pack.md), the "Pack request" issue form, ADR 0015, and packs/queue.json built by pnpm packs:queue from public npm data. Ranking is weekly downloads × breaking majors in 2 years (capped at 3), leaving out tooling and packages reached transitively (> 50k weekly downloads per dependent).
  • Proof: packages/core/src/packs/tooling/scaffold.test.ts scaffolds a toy pack in a miniature checkout, lints it with the checkout's biome, runs its generated test with vitest, adds a rule plus fixture, and gets a passing pack test.

How it was verified

  • Outputs unchanged: check zod stripe --json on fixtures/repos/storefront is identical to main (timings stripped), and so is the text output and list. On the corpus, list on supabase@53a637a and check pino on documenso@80823ed are identical between main and this branch when run at the same moment. The assertion is also permanent: the storefront fixture is a ground-truth entry of both packs, and verification.json records precision and recall, so any change in what check reports there makes the record stale and fails the Packs job.
  • zod: ground truth from ugurkocde/AwesomeIntune, howardyang2009/PATH and band-ai/band-sdk-typescript, plus storefront. stripe: unkeyed/unkey (web/) and nextjs/saas-starter, plus storefront. Both verified.
uptide pack test zod · verified
fixtures      2 cases, 8 sites · pass
ground truth
  fixtures/repos/storefront                    zod 3.25.76 → 4.6.5  predicted 38, expected 38, false positives 0, false negatives 0
  ugurkocde/AwesomeIntune@dcf38603fd55         zod 3.25.76 → 4.6.5  predicted 12, expected 15, false positives 0, false negatives 3
  howardyang2009/PATH@bb171417d911             zod 3.25.76 → 4.6.5  predicted 39, expected 46, false positives 0, false negatives 7
  band-ai/band-sdk-typescript@5d9a66a1dde4     zod 3.25.76 → 4.6.5  predicted 29, expected 37, false positives 0, false negatives 8
  rule                         precision  recall    tp   fp   fn
  error-params                      100%     89%    24    0    3
  generic                            84%     84%    43    8    8
  ip                                100%    100%     1    0    0
  string-format                     100%    100%    26    0    0
  types                             100%     52%    16    0   15
  overall (sites)                   100%     87%   118    0   18
  breaking (sites)                  100%     76%    57    0   18
PASS zod: verified

uptide pack test stripe · verified
fixtures      0 cases, 0 sites · pass
ground truth
  fixtures/repos/storefront                    stripe 14.25.0 → 23.0.0  predicted 4, expected 4, false positives 0, false negatives 0
  unkeyed/unkey@37044fc57fe0                   stripe 14.23.0 → 22.2.0  predicted 13, expected 15, false positives 0, false negatives 2
  nextjs/saas-starter@3e5fd2bf626c             stripe 17.7.0 → 18.0.0  predicted 1, expected 1, false positives 0, false negatives 0
  rule                         precision  recall    tp   fp   fn
  api-version                       100%    100%     4    0    0
  fixture-cast                      100%    100%     1    0    0
  generic                             0%    100%     0   10    0
  sdk-surface                       100%      0%     0    0   11
  subscription-period               100%     75%     3    0    1
  overall (sites)                   100%     90%    18    0    2
  breaking (sites)                  100%     90%    18    0    2
PASS stripe: verified

The per-rule false positives under generic are real sites reported under another rule (the full lists of misses and "reported under another rule" are in the pack test output). Stripe and zod still file some sites under the compiler code instead of their own rule; changing that would change their check plan output, which this PR keeps identical.

  • pnpm lint and pnpm typecheck are clean, and every new test passes. Two tests fail here exactly as they do on unmodified main: fix.test.ts > checks workspace source under its own resolution mode (TS5107 moduleResolution=node10 deprecation from the installed TypeScript) and cli.test.ts > uptide verify > ends with the summary….

Checklist

  • Tests for the change
  • pnpm lint && pnpm typecheck pass; pnpm test passes except the two failures shared with main
  • README and docs updated (docs/packs.md, docs/cli.md, CONTRIBUTING.md, ADR 0015)
  • Changeset added (.changeset/packs-public-contract.md, minor)
  • No new dependency
  • No private code, names or paths: ground truth names public repositories only
  • The rules in CONTRIBUTING.md ("Rules that do not bend") still hold: nothing from a ground-truth repository is ever executed; installs run with scripts off

🤖 Generated with Claude Code

https://claude.ai/code/session_01B2T8GmEVnZwfNrugajEMqi


Generated by Claude Code

claude added 5 commits October 7, 2026 06:47
…implement it

Pack (meta with sources and maintainer, rules that claim check's findings
and rewrite one site, behavior notes with how they are reported, agent
instructions) on top of MigrationPack. check, fix, list and verify take
their packs from a generated registry, verified ones only. Zod's rules
carry their own rewrite; stripe declares the rules its evidence
classifies. Outputs on the storefront fixture and the corpus unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01B2T8GmEVnZwfNrugajEMqi
Signed-off-by: Claude <[email protected]>
pack new scaffolds a pack that lints and passes its tests as written and
registers it. pack test runs its fixtures, then check with the pack on
each ground-truth repository (fetched shallow at the pinned commit,
installed with scripts off, cached), and prints precision and recall per
rule, overall and for breaking findings, with every false positive and
false negative. --json for CI. pnpm uptide runs the CLI from source.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01B2T8GmEVnZwfNrugajEMqi
Signed-off-by: Claude <[email protected]>
… Packs workflow

docs/packs.md with zod as the reference; CONTRIBUTING.md "Write a pack";
a pack pull request template and the pack request issue form; ADR 0015;
packs/queue.json from public npm data (pnpm packs:queue); a Packs
workflow that runs pack test for every pack with the ground-truth cache.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01B2T8GmEVnZwfNrugajEMqi
Signed-off-by: Claude <[email protected]>
pnpm packs:truth lists, for one public repository, the diagnostics its
own TypeScript reports with the target linked in and not without it
(errors and deprecations), and the lines its upgrade commit changed.
Ground truth can name a project directory inside the repository; an
install whose lockfile was already out of sync falls back to an
unfrozen install, scripts still off.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01B2T8GmEVnZwfNrugajEMqi
Signed-off-by: Claude <[email protected]>
zod: AwesomeIntune, PATH and band-sdk-typescript at the commit before
their zod 4 upgrade; stripe: unkey and saas-starter before their
stripe-node majors; both also scored on the storefront fixture. No false
positive among breaking findings (zod 57 sites, recall 76%; stripe 18
sites, recall 90%).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01B2T8GmEVnZwfNrugajEMqi
Signed-off-by: Claude <[email protected]>
@lucasbraum
lucasbraum merged commit adaf8f9 into main Oct 7, 2026
7 checks passed
@lucasbraum
lucasbraum deleted the claude/packs-public-contract-51k71t branch October 7, 2026 18:41
lucasbraum pushed a commit that referenced this pull request Oct 7, 2026
main is this branch's base (#38, squash-merged) plus #40: the result
keeps this branch's tree and applies #40's changes on top.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01B2T8GmEVnZwfNrugajEMqi
Signed-off-by: Claude <[email protected]>
@uptide-release uptide-release Bot mentioned this pull request Oct 7, 2026
lucasbraum pushed a commit that referenced this pull request Oct 8, 2026
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and publish to npm
yourself or [setup this action to publish
automatically](https://github.com/changesets/action#with-publishing). If
you're not ready to do a release yet, that's fine, whenever you add more
changesets to main, this PR will be updated.


# Releases
## [email protected]

### Minor Changes

- [#39](#39)
[`b9f9974`](b9f9974)
Thanks [@lucasbraum](https://github.com/lucasbraum)! - A verified
migration pack for the AI SDK (`ai`) 6 → 7: the renamed options
(`system` →
`instructions`, `onFinish` → `onEnd`, `onStepFinish` → `onStepEnd`,
`experimental_telemetry`
→ `telemetry`), `stepCountIs` → `isStepCount`, `fullStream` → `stream`,
`totalUsage` → `usage`
and the removed `experimental_*` options are rewritten by rule;
telemetry `metadata`, tool
`context` and the stream result helpers go to the agent with the guide;
what the compiler
cannot see (telemetry registration, results that now cover every step,
rejected system
messages) is listed for review. Scored against vercel/chatbot and
miurla/morphic at the
commit before their own upgrade: no false positive. `uptide pack test`
gains
`--update-fixtures`, fixture markers take the compiler's `message`, and
ground-truth
  repositories can use bun.

- [#39](#39)
[`b9f9974`](b9f9974)
Thanks [@lucasbraum](https://github.com/lucasbraum)! - `check` and `fix`
upgrade a package together with the packages that must move with it,
using the groups `list` already draws (family, peer link, shared pin),
each at the version
that agrees with the target. `fix ai` also bumps `@ai-sdk/react`,
`@ai-sdk/provider` and the
installed `@ai-sdk/*` providers in one install and one commit; check's
plan, the fix summary
and the PR description say which and why, and `fix` stops before
changing anything when a
member has no release that agrees. npm and pnpm installs resolve the
exact version first,
so a `^` range keeps the version the target pins. Ground-truth entries
take `with`, the
packages the real upgrade moved, and `pack test` fails when check would
leave one behind.

- [#38](#38)
[`adaf8f9`](adaf8f9)
Thanks [@lucasbraum](https://github.com/lucasbraum)! - Migration packs
are a public, testable contract (docs/packs.md). `uptide pack new`
scaffolds
a pack (an example rule, a fixture pair, a test, empty ground truth) and
registers it;
`uptide pack test` scores packs against their fixtures and against
public repositories at the
commit before their upgrade, with precision and recall per rule, every
false positive and
false negative, and `--json` for CI. A pack is labeled verified only
with ground truth from at
least two public repositories and no false positive among its breaking
findings; otherwise it
ships as a candidate and `check`, `list` and `fix` treat the dependency
as generic.

### Patch Changes

- [#44](#44)
[`b4cc21f`](b4cc21f)
Thanks [@lucasbraum](https://github.com/lucasbraum)! - `check` no longer
dies with "Manipulation error: A syntax error was inserted." on packages
whose type aliases give their type parameters defaults (`type-fest` 4 →
5, `i18next` 23 → 26):
the alias body is read after the parameter list, not at the first
default's ` = `, so these
aliases are compared by the checker instead of breaking the comparison
program.

- [#40](#40)
[`3e3a5fa`](3e3a5fa)
Thanks [@lucasbraum](https://github.com/lucasbraum)! - `fix` verifies
with the repository's own TypeScript (its `node_modules/typescript`, or
an
ancestor's) or the bundled one, and never with a TypeScript that
`NODE_PATH` or Node's global
folders happen to provide. A machine with a global TypeScript 6 made
verification report
  TS5107 deprecations the repository never sees.

- [#37](#37)
[`3e7f744`](3e7f744)
Thanks [@lucasbraum](https://github.com/lucasbraum)! - Gemini is
labelled experimental: in `fix --help`, in the `LLM:` line `fix` prints,
and in the
docs. Its evaluation runs on the storefront fixture failed on service
errors (HTTP 503/429),
  so its migration quality is not established yet.

Co-authored-by: uptide-release[bot] <338861287+uptide-release[bot]@users.noreply.github.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