Skip to content

feat(fix): say when the baseline is unhealthy and verification can only compare - #98

Merged
lucasbraum merged 2 commits into
mainfrom
upt-25-baseline-health
Oct 13, 2026
Merged

lucasbraum merged 2 commits into
mainfrom
upt-25-baseline-health

Conversation

@lucasbraum

Copy link
Copy Markdown
Collaborator

UPT-25.

On a repository that does not type-check before the upgrade, fix printed verification failed with nothing to say the repository was already broken, so it read as Uptide's fault. papermark/papermark @ed19717 has 205 type errors before anything changes.

What changes

  • Baseline health (packages/core/src/fix/baseline.ts), measured from what fix already collects before the bump: type errors, test runs that failed or timed out, and TS2307 grouped by where the specifier points (a path alias folder like @/ee/, or a package).
  • Unhealthy baseline goes first: one warning line at the top of the terminal summary, and a quote at the top of the PR body and migration page.
  • Verdict
    • healthy baseline and it passes: verification passed, as before
    • unhealthy baseline and nothing new: no new errors
    • it fails with new type errors: verification failed: N type errors introduced by the upgrade, M pre-existing
    • The Types row reads (205 pre-existing, 56 introduced by the upgrade).
  • Gate unchanged: passed and the exit code are computed exactly as before, so it stays strict for healthy baselines. An unhealthy baseline only changes the wording.
  • check prints the pre-existing count on the coverage line under each compiled package.
  • JSON: verification.baselineHealth = { healthy, typeErrors, failingTests, missingModules: [{ under, errors, modules }] }. The field is optional; stored runs without it are measured from baseline and baselineTests (baselineHealthOf).

Files PR #92 touches (core/src/action, fix/publish.ts, run-report/*) are untouched. publish.ts still says "verification failed" when it refuses to publish; changing that wording is left for after #92.

papermark @ed19717, --no-llm

Run locally on a scratch clone, uptide fix zod zod-openapi --target 4.6.7 --no-llm (zod-openapi because check reports it as a peer blocker). Nothing pushed, no PR opened there.

Before:

uptide fix · zod 3.25.76 → 4.6.7 (requested) · verification failed · 5m 12s

  Types     ❌ 260 errors after the bump → 247 (205 pre-existing)

After:

uptide fix · zod 3.25.76 → 4.6.7 (requested) · verification failed: 56 type errors introduced by the upgrade, 205 pre-existing · 4m 43s

⚠ this repository does not type-check before the upgrade (205 errors, 129 from missing modules: 108 under @/ee/, 11 under @/lib/, …); verification can only compare, not prove

  Risk      High: manual sites left; unverified sites; behavior changes
  Changes   57 sites · 6 changed files · 4 auto-fixed · 0 fixed by the agent (LLM) · 53 manual
  Types     ❌ 260 errors after the bump → 247 (205 pre-existing, 56 introduced by the upgrade)
  Behavior  ⚠️ 2 schemas identical · 9 not checked · 1 with differences · 0/4 custom-message assertions
  Tests     ⚠️ no tests ran: no test script or runner configuration for the repository · lint clean (prettier, eslint)
  With      @chronark/zod-bird 0.3.10 → 1.0.0, zod-openapi 4.2.4 → 5.1.0
  Coverage  33 importing files not analyzed (memory cap); findings in them may be missed

PR body head:

## Upgrade zod 3.25.76 → 4.6.7

> ⚠️ This repository does not type-check before the upgrade (205 errors, 129 from missing modules: 108 under @/ee/, 11 under @/lib/, …); verification can only compare, not prove.

check zod on the same tree:

zod   57 breaking · compiled against 4.6.7: 62 new type errors
  compiled 275 of 275 files in 1 workspace with the repo's TypeScript 5.9.3 · 509 pre-existing type errors in these files (subtracted)

With --no-llm, 53 of 57 sites stay manual, so this run still fails on its own errors (56 introduced). It now says so instead of blaming the repository's 205.

Notes for review

  • The brief's example said "129 missing modules under @/ee/". Measured: 129 TS2307 errors, 108 under @/ee/; the rest are @/lib/ (11), @react-email/components (8) and @/public/ (2).
  • The check and fix counts differ (509 vs 205) because their scopes differ. Check compiles only the files that use the package, and never writes to the checkout, so the Prisma client stays ungenerated. Fix generates clients in its clone first. Plain tsc on the ungenerated tree reports 1596. Check's line says "in these files" to keep the scope visible.
  • Failing baseline tests also make a baseline unhealthy. They were already marked preexisting and didn't fail the gate; now they show in the headline too.

Tests

baseline.test.ts builds healthy, unhealthy and missing-module repositories on disk (a @/* path alias and an undeclared package) and measures them with the same diagnostics fix uses. It covers health, grouping, headline, verdict, the PR body and the Types cell, plus a stored run without the field. The CLI tests cover the warning line and verdict in the fix summary and the check line. The storefront-zod snapshot gains the warning and the split Types cell. pnpm test, pnpm typecheck, pnpm lint and public:check all pass.

🤖 Generated with Claude Code

lucasbraum and others added 2 commits October 12, 2026 20:55
… compare

On a repository that does not type-check before the upgrade, `fix` said
"verification failed", which read as Uptide's fault. It now measures the
baseline (type errors, failing test runs, TS2307 grouped by path alias or
package), puts an unhealthy baseline first in the terminal summary and the
PR body, reads `no new errors` instead of `verification passed` when such a
run adds nothing, and splits a failure into errors introduced by the
upgrade and pre-existing ones. The gate is unchanged. `check` prints the
pre-existing count under each compiled package, and the stored report
carries `verification.baselineHealth`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Lucas Braum <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Lucas Braum <[email protected]>
@lucasbraum
lucasbraum merged commit ef7a1ae into main Oct 13, 2026
10 checks passed
@lucasbraum
lucasbraum deleted the upt-25-baseline-health branch October 13, 2026 04:22
@uptide-release uptide-release Bot mentioned this pull request Oct 13, 2026
lucasbraum pushed a commit that referenced this pull request Oct 13, 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]

### Patch Changes

- [#98](#98)
[`ef7a1ae`](ef7a1ae)
Thanks [@lucasbraum](https://github.com/lucasbraum)! - `fix` measures
the repository before the upgrade and says first when it is unhealthy:
"this repository does not type-check before the upgrade (205 errors, 129
from missing modules: …); verification can only compare, not prove". On
such a baseline, a run that adds no error reads `no new errors` instead
of `verification passed`, and a failing run says how many type errors
the upgrade introduced and how many were already there. The gate is
unchanged. `check` prints the pre-existing type errors under each
compiled package, and the stored report carries
`verification.baselineHealth` (type errors, failing test runs, missing
modules grouped by path alias or package).

Co-authored-by: uptide-release[bot] <338861287+uptide-release[bot]@users.noreply.github.com>
@uptide-release uptide-release Bot mentioned this pull request Oct 13, 2026
lucasbraum pushed a commit that referenced this pull request Oct 13, 2026
…om pre-existing

publicationBlockers said "verification failed: N new type errors" and
listed every failing test run, including runs that were already failing
before the upgrade. On an unhealthy baseline that blames the migration
for what was already broken. It now uses #98's wording: "N type errors
introduced by the upgrade, M pre-existing", and names a pre-existing
failing run as "already failing before the upgrade".

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01RniwUAvitpghJF4MuodRZz
Signed-off-by: Claude <[email protected]>
lucasbraum added a commit that referenced this pull request Oct 13, 2026
…mp; the App's bot as commit author (#107)

UPT-19

## What and why

The rest of the engine work behind the first Action run on
uptide-test/saas-starter-kit. There is one commit per item; each can be
reviewed on its own.

### 1. Companions analyzed at the versions their lead gives them
(`fix(check)`)

**Cause.** No later companion plan overrode react-dom. The plan was
correct: react moved `react-dom` and `@types/react` to 19. The bug was
in how `check` builds the lead's group for each workspace. It built the
group only from the workspace's *analyzable* packages, and that list
leaves out `@types/*` and anything the workspace never imports. In a
Next app, `react-dom` is never imported and `@types/react` is
types-only, so both fell out of react's group before analysis. Each then
hit the "type-only / never imported, skipped" early return, which
reports the **installed** version as the target. That produced `18.3.1 →
18.3.1, up to date`. #104 fixed only how this was shown, not the cause.

Reproduced locally on boxyhq/saas-starter-kit @abc9b68 (`npm ci
--ignore-scripts`). I ran the same `check` the Action makes, with the
first 10 used packages from `uptide list` (next, next-i18next,
@prisma/client, react, svix, zod, stripe, react-i18next, @sentry/nextjs,
nodemailer):

| | before | after |
| --- | --- | --- |
| `react` | `18.3.1 → 19.3.0`; react-dom and @types/react only in
`companions` | `18.3.1 → 19.3.0`, members `@types/react 18.3.13 →
19.3.0`, `react-dom 18.3.1 → 19.3.0` |
| `react-dom` | own row, `18.3.1 → 18.3.1 not-imported` | no own row:
analyzed in react's group |
| `@types/react` | own row, `18.3.13 → 18.3.13 not-imported` | no own
row: analyzed in react's group |
| `nodemailer` | `@types/nodemailer` in `companions` only | members
`nodemailer`, `@types/nodemailer 7.0.4 → 8.0.2` |

**Fix.**
- A lead's companions join its group whether or not the workspace
imports them, and they are no longer skipped on their own.
- In `checkGroup`, a companion with no usages of its own is linked into
the target overlay, and the baseline, at the version the plan gives it.
That is the install `fix` makes. It is also listed in the report's
`members`.
- A types package that the lead is typed through (`@types/react` for
`react`) is linked once, as the lead's declarations. Linking it twice
failed with `EEXIST` on the real repo.
- The Action gives a companion analyzed this way its own row, `moves
with react`, as #104 does for the old shape.

### 2. `verification.typecheck.afterUpgrade` (`feat(report)`)

These are the errors right after the version bump and before any fix:
the `verification.target` that `fix` already records.
- `uptide.run/v1` and `schema/uptide.run.v1.json`: optional and
additive, next to `before` and `after`.
- Job summary: `types 0 → 4 with the upgrade → 0 after Uptide`.
- PR body and terminal: `✅ the upgrade broke 4 · Uptide left 0`. When
the baseline had errors, it adds `(1 pre-existing, not counted)`.
"Broke" counts errors after the bump that the baseline did not have. The
bump moves no source line, so they compare as they are.
- README and `docs/commands/fix.md` examples are updated to the new
line.

### 3. Commits authored by the App's own bot (`fix(action)`)

The Action resolves the bot with the installation token:
- The slug comes from the token-exchange answer (`appSlug`, read when
present). Otherwise the Action tries `GET /app` with the installation
token, if GitHub answers it.
- The id comes from `GET /users/<slug>[bot]`, which must answer with
that exact login.

Commits in `fix` and in `uptide pr` are authored and committed as
`<slug>[bot] <<id>+<slug>[bot]@users.noreply.github.com>`. If the
identity cannot be resolved, they keep `uptide[bot]
<[email protected]>` and the job log gets a `::warning`.
The token never appears in a URL or message. `docs/ci.md` describes
this.

**Needs the app side:** GitHub documents `GET /app` as JWT-only, so the
reliable source is the Uptide app adding `appSlug` to its
`/api/action/token` answer. Until it does, expect the fallback and its
warning.

### 4. `verification.baselineHealth` in `uptide.run/v1` (`feat(report)`)

Counts only: `typeErrors`, `failingTests`, `missingModules { local,
packages }`. These are the TS2307 errors among the baseline's errors,
split between the repository's own paths (relative imports, path
aliases) and packages. No specifier or alias group name leaves the fix
report, and a test checks that. The field is optional, and the schema is
regenerated.

The `uptide/report` declarations embed the schema as a literal type, so
items 2 and 4 together pushed `index.d.ts` to 17.3 KB. Its budget in
`libs-export.test.ts` goes from 16 KB to 20 KB; the JS budget is
unchanged at 9.8 of 24 KB.

### 5. Refusal wording (`fix(publish)`)

`publicationBlockers` now uses #98's words: `1 type error introduced by
the upgrade, 2 pre-existing` instead of `1 new type error`. A test run
that was already failing before the upgrade is named `tests in X already
failing before the upgrade`. Before, it was listed as a failure of the
migration.

### Sample job summary: a stripe fix run

Rendered by `renderSummary` from the stripe fix fixture in this repo
(`packages/core/src/fix/__fixtures__/stripe.json`: 0 errors before, 4
after the bump, 0 after), with the versions set to 17.7.0 → 23.0.0:

```markdown
| Package | Upgrade | Status | Breaking sites | Verification | Pull request | LLM cost |
| --- | --- | --- | --- | --- | --- | --- |
| `stripe` | 17.7.0 → 23.0.0 (major) | fixed | 4 | types 0 → 4 with the upgrade → 0 after Uptide, lint 0 → 0, no tests | [#2](https://github.com/acme/saas/pull/2) | $0.05 |
```

## How it was verified

- **Item 1:** `check/companion-group.test.ts` is a synthetic `ui` /
`ui-dom` / `@types/ui` repo shaped like react. It checks one report with
all three members at 2.0.0, `[email protected]` fetched into the overlay, and
`@types/[email protected]` fetched once. It fails on main and passes here. The
real-repo before and after are in the table above. `action/run.test.ts`
checks companion rows when `check` returns only the lead.
- **Item 2:** `run-report/report.test.ts` covers the new field, the
summary wording, a report without the field, and schema rejection of a
negative value. The PR-body snapshots and terminal tests are updated.
- **Item 3:** `action/github.test.ts` covers the slug from the exchange,
the `GET /app` fallback on a GHE API URL, and undefined for: no slug, a
malformed slug, 404, network down, another login, a non-integer id.
`oidc.test.ts` covers `appSlug` from the exchange and `engineEnv` /
`publishEnv` with an identity. `run.test.ts` checks the bot passed to
`fix` and `pr`, and the fallback with its warning.
- **Item 4:** `report.test.ts` checks the counts, that no module or
alias name appears, and that older reports still validate.
- **Item 5:** `publish.test.ts` covers an unhealthy baseline with one
new and one pre-existing failing run.
- `pnpm lint && pnpm typecheck && pnpm test` pass: core 1387 passed (32
skipped), CLI 433 passed. Lint shows one warning, an unused import in
`fix/report.test.ts` that is already on main. `scripts/public-tree.mjs`
and `scripts/check-links.mjs` are clean. `scripts/private-material.mjs`
needs the `UPTIDE_PRIVATE_DENYLIST` secret, so it runs in CI.

## Checklist

- [x] Tests for the change (a bug fix starts with a failing test)
- [x] `pnpm lint && pnpm typecheck && pnpm test` pass
- [x] README and docs updated if behavior changed (`README.md`,
`docs/ci.md`, `docs/commands/fix.md`)
- [x] Changeset added if a user would notice (one per item)
- [x] No new dependency, or it was agreed in an issue
- [x] No private code, names or paths in fixtures, tests or docs
- [x] The rules in CONTRIBUTING.md ("Rules that do not bend") still hold

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_01RniwUAvitpghJF4MuodRZz

---
_Generated by [Claude
Code](https://claude.ai/code/session_01RniwUAvitpghJF4MuodRZz)_

---------

Signed-off-by: Claude <[email protected]>
Co-authored-by: Claude <[email protected]>
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.

1 participant