Repository navigation
TML-2573: chain-aware upgrade-coverage gate (accepts skip-publish releases) - #535
Conversation
… gate
The gate previously assumed the last-published version and the version
being published differ by exactly one minor, requiring a single
`<prev.minor>-to-<head.minor>/` directory. When a minor is bumped
in-tree but never actually shipped to npm, the next publish crosses
two minor steps in one release; the previous shape demanded a
synthetic merged directory and rejected the per-step entries authors
were taught to write.
Replace `coverageTransitionLabel` with `coverageTransitionChain`
returning the ordered list of consecutive `M.N-to-M.N+1` directories
covering `prev.minor → head.minor`. Coverage rule loops over the
chain (one violation per missing directory, naming each so the author
sees exactly which steps the gate wants). New-entries allow-set
widens to `chain ∪ {in-flight head→head+1}` so an entry in any chain
step is a valid landing spot.
Refs: TML-2573
(TML-2573)
Signed-off-by: Will Madden <[email protected]>
Author one entry per single-step transition; the coverage gate aggregates consecutive directories into a chain when a minor was bumped in-tree but never actually shipped to npm. Refs: TML-2573 (TML-2573) Signed-off-by: Will Madden <[email protected]>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughThe PR replaces single-step coverage logic with an ordered minor-version transition chain: adds COVERAGE_SUBSTRATES, exposes coverageTransitionChain(head, prev), iterates coverageChain in runCheck to require each upgrades// directory, expands new-entries acceptance, updates tests, and amends docs. ChangesUpgrade Coverage Chain Validation
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint skipped: no ESLint configuration detected in root package.json. To enable, add Comment |
@prisma-next/extension-author-tools
@prisma-next/mongo-runtime
@prisma-next/family-mongo
@prisma-next/sql-runtime
@prisma-next/family-sql
@prisma-next/extension-arktype-json
@prisma-next/extension-cipherstash
@prisma-next/middleware-cache
@prisma-next/mongo
@prisma-next/extension-paradedb
@prisma-next/extension-pgvector
@prisma-next/extension-postgis
@prisma-next/postgres
@prisma-next/sql-orm-client
@prisma-next/sqlite
@prisma-next/target-mongo
@prisma-next/adapter-mongo
@prisma-next/driver-mongo
@prisma-next/contract
@prisma-next/utils
@prisma-next/config
@prisma-next/errors
@prisma-next/framework-components
@prisma-next/operations
@prisma-next/ts-render
@prisma-next/contract-authoring
@prisma-next/ids
@prisma-next/psl-parser
@prisma-next/psl-printer
@prisma-next/cli
@prisma-next/emitter
@prisma-next/migration-tools
prisma-next
@prisma-next/vite-plugin-contract-emit
@prisma-next/mongo-codec
@prisma-next/mongo-contract
@prisma-next/mongo-value
@prisma-next/mongo-contract-psl
@prisma-next/mongo-contract-ts
@prisma-next/mongo-emitter
@prisma-next/mongo-schema-ir
@prisma-next/mongo-query-ast
@prisma-next/mongo-orm
@prisma-next/mongo-query-builder
@prisma-next/mongo-lowering
@prisma-next/mongo-wire
@prisma-next/sql-contract
@prisma-next/sql-errors
@prisma-next/sql-operations
@prisma-next/sql-schema-ir
@prisma-next/sql-contract-psl
@prisma-next/sql-contract-ts
@prisma-next/sql-contract-emitter
@prisma-next/sql-lane-query-builder
@prisma-next/sql-relational-core
@prisma-next/sql-builder
@prisma-next/target-postgres
@prisma-next/target-sqlite
@prisma-next/adapter-postgres
@prisma-next/adapter-sqlite
@prisma-next/driver-postgres
@prisma-next/driver-sqlite
commit: |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
scripts/check-upgrade-coverage.mjs (1)
280-308: ⚡ Quick winMove substrate coverage rules to a declarative table.
The
examples/andpackages/3-extensions/coverage blocks are duplicated and hardcoded. A small substrate config array would keep rule changes in one place and reduce drift risk.Refactor sketch
+const COVERAGE_SUBSTRATES = [ + { substrate: 'examples/', pathspec: 'examples/', skillPkg: USER_SKILL_PKG }, + { + substrate: 'packages/3-extensions/', + pathspec: 'packages/3-extensions/', + skillPkg: EXT_SKILL_PKG, + }, +]; + -const examplesDiff = diffPaths(repoRoot, prev, head, ['examples/']); -if (examplesDiff.length > 0) { - for (const transition of coverageChain) { - const requiredDir = `${USER_SKILL_PKG}/upgrades/${transition}`; - ... - } -} - -const extDiff = diffPaths(repoRoot, prev, head, ['packages/3-extensions/']); -if (extDiff.length > 0) { - for (const transition of coverageChain) { - const requiredDir = `${EXT_SKILL_PKG}/upgrades/${transition}`; - ... - } -} +for (const { substrate, pathspec, skillPkg } of COVERAGE_SUBSTRATES) { + const substrateDiff = diffPaths(repoRoot, prev, head, [pathspec]); + if (substrateDiff.length === 0) continue; + for (const transition of coverageChain) { + const requiredDir = `${skillPkg}/upgrades/${transition}`; + if (!existsSync(`${repoRoot}/${requiredDir}`)) { + violations.push({ + rule: 'coverage', + substrate, + requiredDir, + sampleDiffPaths: substrateDiff.slice(0, 5), + }); + } + } +}As per coding guidelines: "
scripts/**/*.mjs: Prefer declarative data structures ... over hardcoded conditionals for validation rules, constraints, and configuration logic."🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@scripts/check-upgrade-coverage.mjs` around lines 280 - 308, Extract the duplicated coverage checks for examplesDiff and extDiff into a declarative array (e.g., an array of substrate descriptors containing the diffPaths arg, substrate label, and pkg prefix such as USER_SKILL_PKG and EXT_SKILL_PKG), then iterate that array to call diffPaths(repoRoot, prev, head, descriptor.diffPath) and, if length > 0, loop coverageChain to build requiredDir from descriptor.pkgPrefix and transition and push the same violation object (use existing symbols examplesDiff/extDiff only where helpful during refactor). Replace the two hardcoded blocks with this single generic loop so the validation logic (diffPaths, existsSync, violations push) is centralized and driven by the new substrate config array.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@scripts/check-upgrade-coverage.mjs`:
- Around line 108-120: The function coverageTransitionChain doesn't handle the
case where head.major === prev.major but head.minor < prev.minor; add an
explicit check in coverageTransitionChain to fail fast for reversed same-major
ranges (e.g., if (head.major === prev.major && head.minor < prev.minor) throw
new Error(...)) or return a strict fallback label, and include details of head
and prev in the error message to make the invalid range obvious; place this
check before generating labels so the rest of the logic (the inFlight and
ascending loop) can assume head.minor >= prev.minor.
---
Nitpick comments:
In `@scripts/check-upgrade-coverage.mjs`:
- Around line 280-308: Extract the duplicated coverage checks for examplesDiff
and extDiff into a declarative array (e.g., an array of substrate descriptors
containing the diffPaths arg, substrate label, and pkg prefix such as
USER_SKILL_PKG and EXT_SKILL_PKG), then iterate that array to call
diffPaths(repoRoot, prev, head, descriptor.diffPath) and, if length > 0, loop
coverageChain to build requiredDir from descriptor.pkgPrefix and transition and
push the same violation object (use existing symbols examplesDiff/extDiff only
where helpful during refactor). Replace the two hardcoded blocks with this
single generic loop so the validation logic (diffPaths, existsSync, violations
push) is centralized and driven by the new substrate config array.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
Run ID: ba06ad53-9ace-4ad5-8739-94c15e7e7c9a
📒 Files selected for processing (3)
scripts/check-upgrade-coverage.mjsscripts/check-upgrade-coverage.test.mjsskills-contrib/record-upgrade-instructions/SKILL.md
…nChain Previously, when `head.major === prev.major` and `head.minor < prev.minor`, `coverageTransitionChain` silently returned an empty array. The empty chain then caused the coverage-rule loop to find nothing to require, which could mask missing directories on a misordered run (refs supplied in reverse, unexpected rebase state, etc.). Fail fast with an explicit Error naming both versions instead, so the operator sees the misordering rather than a silently-passing gate. Signed-off-by: Will Madden <[email protected]>
The two coverage blocks (examples/ + packages/3-extensions/) were identical modulo their substrate label, diff pathspec, and skill package. Extract the varying parts into a small COVERAGE_SUBSTRATES table and iterate it once. Adding a new substrate is now a one-line table entry instead of a copy-paste block, and the validation logic (diffPaths, existsSync, violations push) lives in one place. Matches the scripts/**/*.mjs declarative-data-structure coding guideline. No behaviour change; the full upgrade-coverage test suite (30 cases) stays green and the live publish-mode gate against v0.7.0 still exits 0. Signed-off-by: Will Madden <[email protected]>
|
Done (CodeRabbit nitpick on Inline thread on |
Linked issue
Refs TML-2573
At a glance
A publish from a previously-shipped
v0.7.0to a head at0.9.0now passes the coverage gate against the two consecutive directories authors already wrote:Previously the gate demanded a synthetic
upgrades/0.7-to-0.9/and rejected the per-step0.7-to-0.8/+0.8-to-0.9/directories as stale — exactly the entries the authoring skill teaches contributors to write. The failing run that surfaced this was GH Actions run 26090222604.Decision
The gate's transition model becomes a chain instead of a single step:
coverageTransitionLabel(head, prev)(returned one string) withcoverageTransitionChain(head, prev)returning the ordered list of consecutiveM.N-to-M.N+1directories spanningprev.minor → head.minor. PR-mode steady-state (prev.minor === head.minor) collapses to a one-element list naming the in-flight directory — preserving today's behaviour.[coverage]violation per missing directory, naming each so the author sees exactly which steps the gate wants.{coverage, in-flight}to{...chain, in-flight}— an entry in any chain step is a valid landing spot during a skip-publish release.record-upgrade-instructions/SKILL.mdgets one paragraph noting the skip-publish chain: authoring stays one directory per minor bump; the gate aggregates.Major-boundary chains (
prev.major !== head.major) keep the existing single-steptransitionLabel(prev, head)behaviour — the minor counter resets, so a literal chain doesn't compose. Revisit before a major bump.How it fits together
The model:
package.json.versionon a ref is the currently published version on that ref. Whenpnpm bump-minorruns and the resulting publish workflow succeeds, the published tag catches up topackage.json. If a bump landed onmainbut the publish workflow failed and was never re-run, the next successful publish crosses two minor steps in one release —prev(lastv[0-9]*tag) is atM,headis atM+2, and the diff describes everything shipped over the two-minor span.scripts/check-upgrade-coverage.mjsintroducescoverageTransitionChain; the rule loop walks the returned list.prevadds.skills-contrib/record-upgrade-instructions/SKILL.mdgains a## Skipped publishesparagraph that says: keep writing per single-step transition; the gate aggregates. No author behaviour change.Behavior changes & evidence
<prev.minor>-to-<head.minor>/directory; a skip-publish release was unsatisfiable. Impl:scripts/check-upgrade-coverage.mjscoverageTransitionChain+ the coverage-rule loop. Evidence:check-upgrade-coverage — skip-publish chaindescribe block inscripts/check-upgrade-coverage.test.mjs(coverage with both / one / neither directory present).allowedTransitionsconstruction. Evidence:new-entries: accepts an added file in any chain transition or in-flightandnew-entries: rejects an added file in a pre-prev (stale) transition directoryin the same describe block.[coverage]violation per substrate. Evidence:--json envelope: one violation per missing chain directory.skills-contrib/record-upgrade-instructions/SKILL.md## Skipped publishessection. No code evidence; doc-only paragraph.Reviewer notes
0.7-to-0.8/and0.8-to-0.9/directories already on this branch are untouched — they were exactly the per-step entries the authoring skill teaches contributors to write, and the chain-aware gate accepts them as-is. No aggregation, no merge, no rewrite.scripts/check-upgrade-coverage.mjs—runCheck'smodeparameter has been unused since before this PR. Left as-is per the "only fix pre-existing lints if necessary" convention; happy to fix in a follow-up.coverageTransitionfield replaced bycoverageChain; one[coverage]violation per missing directory instead of one combined). No external consumer of the envelope exists in this repo (rg coverageTransitionandrg coverageChainoutside the script come back empty), so I treated this as free to change. If downstream tooling reads this, flag and I'll add a compatibility shim.prev.major !== head.major) keeps the existing single-step label. The minor counter resets at majors so a literal chain doesn't compose. The function carries an inline comment noting this; before any planned major bump, a follow-up should decide what the major-boundary semantics actually are.Compatibility / migration / risk
No on-disk migration needed. Existing per-step directories continue to satisfy the gate. PR-mode + consecutive-publish modes are unchanged behaviour (single-element chain == previous single-step). The only diagnostic-shape change is in the skip-publish case, which previously errored unconditionally.
Verification
node --test scripts/check-upgrade-coverage.test.mjs— 29 cases pass (5 new in theskip-publish chaindescribe block + updated assertion in thein-flight minor source-of-truthcase for the chain shape).pnpm check:upgrade-coverage --mode publish --prev v0.7.0— exits 0 on this branch (was 8 violations onmain).pnpm check:upgrade-coverage --mode pr— exits 0.pnpm biome check scripts/check-upgrade-coverage.{mjs,test.mjs}— clean modulo the pre-existingmodewarning noted above.Follow-ups
modeparameter fromrunCheckin a follow-up cleanup PR.Skill update
skills-contrib/record-upgrade-instructions/SKILL.mdgains a## Skipped publishesparagraph documenting the chain semantics — the only user-facing surface this PR touches.Alternatives considered
0.7-to-0.9/. Faster to unblock the release, but throws away the per-version-step authoring model the receiving skills are built around, and re-encodes the same fragility next time a publish is skipped. The downstream upgrade skills expect one set of instructions per minor — aggregating into a synthetic directory would either lose detail or force the receiving skill to learn to split.[coverage]violation block per substrate. Tidier output for the common case (1 missing dir), but obscures which specific steps are missing in the skip case. The line-oriented one-per-missing format trades brevity for diagnostic specificity, which seemed worth it.Checklist
git commit -s) per the DCO. The DCO status check will block merge if any commit is missing aSigned-off-by:trailer.TML-NNNN: <sentence-case title>form.Summary by CodeRabbit
Bug Fixes
Documentation