Skip to content
This repository was archived by the owner on Nov 25, 2026. It is now read-only.

TML-2764: harden check:upgrade-coverage to verify per-PR entry correspondence - #723

Merged
wmadden-electric merged 6 commits into
mainfrom
tml-2764-harden-checkupgrade-coverage-to-verify-per-pr-entry-not-just
Jun 5, 2026
Merged

wmadden-electric merged 6 commits into
mainfrom
tml-2764-harden-checkupgrade-coverage-to-verify-per-pr-entry-not-just

Conversation

@wmadden-electric

@wmadden-electric wmadden-electric commented Jun 4, 2026 •

Copy link
Copy Markdown
Contributor

Harden scripts/check-upgrade-coverage.mjs so the upgrade-coverage gate verifies entry↔substrate correspondence per PR, not just that the in-flight transition directory exists.

Why

The gate only asserted that upgrades/<M>-to-<M+1>/ exists when a PR touched a cluster's substrate (examples/ → user skill; packages/3-extensions/ → extension-author skill). Once any earlier PR created that directory, a later PR could introduce a real breaking change with no upgrade entry and still pass — which is exactly how the domain-plane slice (#653 / TML-2751) shipped a breaking change with no entries. The gate was necessary-but-not-sufficient; the missing-entry case was left to human review.

Change

Layered a per-PR correspondence check on top of the existing directory-existence precondition (which is unchanged, as are the new-entries rule, the coverage-chain logic, and the --mode/--prev/--head interface). When git diff <base>..HEAD touches a cluster's substrate:

  1. That cluster's in-flight instructions.md must be in the PR's changed files — forcing a deliberate per-PR act, so a prior PR's entry can no longer cover a later PR.
  2. Its frontmatter changes: must be a present array — either a real entry, or an explicit changes: [] no-op (the documented escape hatch for genuinely incidental substrate diffs such as dev-dep bumps).

A new exported parseChangesFrontmatter handles the YAML spellings (changes: [], non-empty flow arrays [a, b], and block sequences regardless of which key leads each entry). Missing/malformed changes: while substrate is touched → violation.

Scope / verification

  • Two-file diff: the script + its test.
  • node --test scripts/check-upgrade-coverage.test.mjs → 45/45 (15 new, including all six correspondence cases + flow/block-order parser cases). pnpm check:upgrade-coverage --mode pr passes on this branch; biome clean.
  • Additive hardening only — no existing rule weakened; incidental diffs remain satisfiable via changes: [].

Refs: TML-2764

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Tests

    • Added comprehensive test coverage for upgrade documentation validation and frontmatter parsing.
  • Chores

    • Enhanced validation to enforce stricter requirements for documenting changes in upgrade paths.
    • Improved error messages for missing or malformed upgrade documentation declarations.

wmadden-electric and others added 2 commits June 4, 2026 17:22
…heck

Layer a second check on top of the existing directory-existence rule: when a
cluster substrate is touched in the diff, the in-flight instructions.md must
also appear in the diff for this PR, and its frontmatter `changes:` key must be
a valid array (empty `[]` for incidental diffs, or non-empty for real entries).
This prevents a transition directory created by an earlier PR from silently
satisfying the gate for a later substrate-touching PR.

Exports `parseChangesFrontmatter` for unit testing, consistent with the file's
existing export-for-test pattern. Adds 10 new tests (4 unit, 6 integration).

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Signed-off-by: wmadden-electric <[email protected]>
…er-agnostic block entries

Two review findings hardened in parseChangesFrontmatter:

Finding 1: A non-empty flow array (e.g. `changes: [foo]`) was
false-rejected as "not an array" because only `changes: []` had an
inline-array branch. Add a non-empty flow-array branch before the
block-sequence path; parse elements by splitting on comma.

Finding 2: A block entry whose first key is not `id:` (e.g.
`- summary: foo\n  id: bar`) was false-rejected because the block
detection counted entries by `- id:` bullet matches, not by `- `
bullets. Count entries by bullet lines at list indentation; key order
is now unrestricted.

Regressions kept: `changes: []` → ok/empty; absent `changes:` → not ok.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Signed-off-by: wmadden-electric <[email protected]>
@wmadden-electric
wmadden-electric requested a review from a team as a code owner June 4, 2026 15:45
@coderabbitai

coderabbitai Bot commented Jun 4, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

Run ID: 575eab6b-fd67-473c-b90f-491376b48bee

📥 Commits

Reviewing files that changed from the base of the PR and between b9c7119 and d4bc68f.

📒 Files selected for processing (2)
  • scripts/check-upgrade-coverage.mjs
  • scripts/check-upgrade-coverage.test.mjs

📝 Walkthrough

Walkthrough

The PR strengthens the upgrade-coverage gating script by adding per-PR validation: it parses changes: frontmatter from instructions.md, computes changed paths once per run, and enforces that when substrate files are touched, the corresponding instructions.md is included in the PR with valid changes: declarations, rendering a dedicated violation type for frontmatter issues.

Changes

Upgrade Coverage Validation

Layer / File(s) Summary
Frontmatter parsing contract and unit tests
scripts/check-upgrade-coverage.mjs (lines 48–116), scripts/check-upgrade-coverage.test.mjs (lines 13, 614–665)
New exported parseChangesFrontmatter(src) handles inline changes: [], block-sequence lists, and malformed frontmatter; returns { ok, changes } or { ok: false, reason }. Unit tests verify multiple formats including regressions.
File read and path diffing infrastructure
scripts/check-upgrade-coverage.mjs (lines 249–261, 370–373)
Adds tryReadFileAtRef for safe git reads and diffAllChangedPaths to precompute changed paths; integrates into runCheck for consistent per-file membership tests throughout the validation run.
Per-transition validation enforcement
scripts/check-upgrade-coverage.mjs (lines 400–427)
Main coverage loop now requires PR-changed instructions.md in each touched transition and validates its changes: frontmatter; records per-pr-declaration violations with malformed flag and parse failure reason.
Violation rendering for frontmatter issues
scripts/check-upgrade-coverage.mjs (lines 490–509)
Updated renderViolations distinguishes missing/invalid changes: frontmatter from missing PR declaration; includes sample diff paths for context.
Per-PR correspondence integration tests
scripts/check-upgrade-coverage.test.mjs (lines 667–784)
End-to-end validation of the per-PR rule: violations occur when substrate is touched but instructions.md is missing or lacks changes:; positive cases confirm no false positives when substrate is untouched.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

The changes span two files with moderate logic density: a new parsing function with clear structure, infrastructure helpers, a revised validation loop integrating these pieces, and updated rendering logic. The test suites are substantial but follow consistent patterns. Heterogeneous changes across parsing, infrastructure, validation, and rendering require separate reasoning for each layer, and the integration tests are large enough to demand careful review.

Possibly related PRs

Poem

🐰 Frontmatter parsed with care, per-PR validation runs fair,
Changed paths diffed once, violations render with finesse,
Transition checks now stronger, tests prove it won't stray longer—
A rabbit hops through coverage gates, one changelog at a time! 📋✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 28.57% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'TML-2764: harden check:upgrade-coverage to verify per-PR entry correspondence' directly and specifically describes the main change: hardening the upgrade coverage check to verify per-PR entry correspondence with substrate files. This accurately reflects the primary goal stated in the PR objectives.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch tml-2764-harden-checkupgrade-coverage-to-verify-per-pr-entry-not-just

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions

github-actions Bot commented Jun 4, 2026 •

Copy link
Copy Markdown

size-limit report 📦

Path Size
postgres / no-emit 145.22 KB (0%)
postgres / emit 117.03 KB (0%)
mongo / no-emit 75.97 KB (0%)
mongo / emit 70.78 KB (0%)
cf-worker / no-emit 174.93 KB (0%)
cf-worker / emit 143.71 KB (0%)

Comment thread scripts/check-upgrade-coverage.mjs Fixed
Comment thread scripts/check-upgrade-coverage.mjs Fixed
wmadden and others added 2 commits June 4, 2026 18:50
…upgrade-coverage-to-verify-per-pr-entry-not-just
… line walk to eliminate ReDoS

The nested quantifiers in `(?:[ \t]+-[ \t]+[\s\S]*?)*` caused exponential
backtracking on adversarial inputs. Replace with a simple line-by-line
scan: find the `changes:` key, then iterate subsequent lines collecting
bullet entries until the first non-blank, non-indented line.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Signed-off-by: Will Madden <[email protected]>
@wmadden-electric

Copy link
Copy Markdown
Contributor Author

CodeQL findings resolved (both findings, IDs 3357241270 + 3357241276):

The multi-line block-sequence regex /^changes:\s*\n((?:[ \t]+-[ \t]+[\s\S]*?)*)(?=\n\S|$)/m at the former line 89 had nested quantifiers ([\s\S]*? inside (?:...)*) that caused exponential backtracking on adversarial inputs like changes:\n\t-\t-\t-\t....

Fix: replaced with a linear line walk — fm.split('\n'), find the changes: line by index, then iterate subsequent lines collecting /^\s+-\s/ bullet lines until the first non-blank, non-indented line. No nested quantifiers, O(n) in the number of frontmatter lines.

All 45 tests pass. Commit d4bc68f69.

@pkg-pr-new

pkg-pr-new Bot commented Jun 4, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

@prisma-next/extension-author-tools

npm i https://pkg.pr.new/@prisma-next/extension-author-tools@723

@prisma-next/mongo-runtime

npm i https://pkg.pr.new/@prisma-next/mongo-runtime@723

@prisma-next/family-mongo

npm i https://pkg.pr.new/@prisma-next/family-mongo@723

@prisma-next/sql-runtime

npm i https://pkg.pr.new/@prisma-next/sql-runtime@723

@prisma-next/family-sql

npm i https://pkg.pr.new/@prisma-next/family-sql@723

@prisma-next/extension-arktype-json

npm i https://pkg.pr.new/@prisma-next/extension-arktype-json@723

@prisma-next/middleware-cache

npm i https://pkg.pr.new/@prisma-next/middleware-cache@723

@prisma-next/mongo

npm i https://pkg.pr.new/@prisma-next/mongo@723

@prisma-next/extension-paradedb

npm i https://pkg.pr.new/@prisma-next/extension-paradedb@723

@prisma-next/extension-pgvector

npm i https://pkg.pr.new/@prisma-next/extension-pgvector@723

@prisma-next/extension-postgis

npm i https://pkg.pr.new/@prisma-next/extension-postgis@723

@prisma-next/postgres

npm i https://pkg.pr.new/@prisma-next/postgres@723

@prisma-next/sql-orm-client

npm i https://pkg.pr.new/@prisma-next/sql-orm-client@723

@prisma-next/sqlite

npm i https://pkg.pr.new/@prisma-next/sqlite@723

@prisma-next/target-mongo

npm i https://pkg.pr.new/@prisma-next/target-mongo@723

@prisma-next/adapter-mongo

npm i https://pkg.pr.new/@prisma-next/adapter-mongo@723

@prisma-next/driver-mongo

npm i https://pkg.pr.new/@prisma-next/driver-mongo@723

@prisma-next/contract

npm i https://pkg.pr.new/@prisma-next/contract@723

@prisma-next/utils

npm i https://pkg.pr.new/@prisma-next/utils@723

@prisma-next/config

npm i https://pkg.pr.new/@prisma-next/config@723

@prisma-next/errors

npm i https://pkg.pr.new/@prisma-next/errors@723

@prisma-next/framework-components

npm i https://pkg.pr.new/@prisma-next/framework-components@723

@prisma-next/operations

npm i https://pkg.pr.new/@prisma-next/operations@723

@prisma-next/ts-render

npm i https://pkg.pr.new/@prisma-next/ts-render@723

@prisma-next/contract-authoring

npm i https://pkg.pr.new/@prisma-next/contract-authoring@723

@prisma-next/ids

npm i https://pkg.pr.new/@prisma-next/ids@723

@prisma-next/psl-parser

npm i https://pkg.pr.new/@prisma-next/psl-parser@723

@prisma-next/psl-printer

npm i https://pkg.pr.new/@prisma-next/psl-printer@723

@prisma-next/cli

npm i https://pkg.pr.new/@prisma-next/cli@723

@prisma-next/cli-telemetry

npm i https://pkg.pr.new/@prisma-next/cli-telemetry@723

@prisma-next/emitter

npm i https://pkg.pr.new/@prisma-next/emitter@723

@prisma-next/migration-tools

npm i https://pkg.pr.new/@prisma-next/migration-tools@723

prisma-next

npm i https://pkg.pr.new/prisma-next@723

@prisma-next/vite-plugin-contract-emit

npm i https://pkg.pr.new/@prisma-next/vite-plugin-contract-emit@723

@prisma-next/mongo-codec

npm i https://pkg.pr.new/@prisma-next/mongo-codec@723

@prisma-next/mongo-contract

npm i https://pkg.pr.new/@prisma-next/mongo-contract@723

@prisma-next/mongo-value

npm i https://pkg.pr.new/@prisma-next/mongo-value@723

@prisma-next/mongo-contract-psl

npm i https://pkg.pr.new/@prisma-next/mongo-contract-psl@723

@prisma-next/mongo-contract-ts

npm i https://pkg.pr.new/@prisma-next/mongo-contract-ts@723

@prisma-next/mongo-emitter

npm i https://pkg.pr.new/@prisma-next/mongo-emitter@723

@prisma-next/mongo-schema-ir

npm i https://pkg.pr.new/@prisma-next/mongo-schema-ir@723

@prisma-next/mongo-query-ast

npm i https://pkg.pr.new/@prisma-next/mongo-query-ast@723

@prisma-next/mongo-orm

npm i https://pkg.pr.new/@prisma-next/mongo-orm@723

@prisma-next/mongo-query-builder

npm i https://pkg.pr.new/@prisma-next/mongo-query-builder@723

@prisma-next/mongo-lowering

npm i https://pkg.pr.new/@prisma-next/mongo-lowering@723

@prisma-next/mongo-wire

npm i https://pkg.pr.new/@prisma-next/mongo-wire@723

@prisma-next/sql-contract

npm i https://pkg.pr.new/@prisma-next/sql-contract@723

@prisma-next/sql-errors

npm i https://pkg.pr.new/@prisma-next/sql-errors@723

@prisma-next/sql-operations

npm i https://pkg.pr.new/@prisma-next/sql-operations@723

@prisma-next/sql-schema-ir

npm i https://pkg.pr.new/@prisma-next/sql-schema-ir@723

@prisma-next/sql-contract-psl

npm i https://pkg.pr.new/@prisma-next/sql-contract-psl@723

@prisma-next/sql-contract-ts

npm i https://pkg.pr.new/@prisma-next/sql-contract-ts@723

@prisma-next/sql-contract-emitter

npm i https://pkg.pr.new/@prisma-next/sql-contract-emitter@723

@prisma-next/sql-lane-query-builder

npm i https://pkg.pr.new/@prisma-next/sql-lane-query-builder@723

@prisma-next/sql-relational-core

npm i https://pkg.pr.new/@prisma-next/sql-relational-core@723

@prisma-next/sql-builder

npm i https://pkg.pr.new/@prisma-next/sql-builder@723

@prisma-next/target-postgres

npm i https://pkg.pr.new/@prisma-next/target-postgres@723

@prisma-next/target-sqlite

npm i https://pkg.pr.new/@prisma-next/target-sqlite@723

@prisma-next/adapter-postgres

npm i https://pkg.pr.new/@prisma-next/adapter-postgres@723

@prisma-next/adapter-sqlite

npm i https://pkg.pr.new/@prisma-next/adapter-sqlite@723

@prisma-next/driver-postgres

npm i https://pkg.pr.new/@prisma-next/driver-postgres@723

@prisma-next/driver-sqlite

npm i https://pkg.pr.new/@prisma-next/driver-sqlite@723

commit: 4a95acd

@wmadden-electric
wmadden-electric enabled auto-merge (squash) June 5, 2026 03:18
@wmadden-electric
wmadden-electric merged commit 230f440 into main Jun 5, 2026
28 of 29 checks passed
@wmadden-electric
wmadden-electric deleted the tml-2764-harden-checkupgrade-coverage-to-verify-per-pr-entry-not-just branch June 5, 2026 03:43
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants