Repository navigation
Framework vocabulary ratchet: family terms may not grow in packages/1-framework - #918
Conversation
…w in packages/1-framework The framework domain is family-blind, but family vocabulary (nativeType, target names) has repeatedly leaked into framework types through review misses — the same defect class flagged across three review rounds on PR #906. This turns that review comment into a machine check. lint:framework-vocabulary mirrors the lint-casts merge-base ratchet: it counts occurrences of forbidden terms (declarative per-scope config; seeded with nativeType / native-type / postgres / sqlite / mysql under packages/1-framework, source files only) at HEAD and at the merge-base, and fails with the new sites listed when the count grows. The 200 pre-existing hits are grandfathered by construction and may only shrink. Wired into the CI Lint job beside lint:casts; fixture-repo tests mirror lint-casts.test.mjs. Two rulecards encode the discipline the ratchet enforces mechanically: - no-family-vocabulary-in-framework: the family-blindness test ("would Mongo populate or consume this meaningfully?"), the dressing tells, strategies as codec-owned hooks never string enums. - fix-the-class-not-the-instance (alwaysApply): a review comment names a class; sweep the whole diff and fix every instance in one round; new surface never inherits grandfathering; design is never settled. Co-Authored-By: Claude Opus 4.8 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
|
Warning Review limit reached
Next review available in: 21 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughAdds a framework vocabulary threshold lint, its config, CI/script wiring, tests, and related agent-rule and calibration updates. The check scans ChangesFramework vocabulary lint enforcement
Estimated code review effort: 4 (Complex) | ~45 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
size-limit report 📦
|
@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/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/extension-supabase
@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/cli-telemetry
@prisma-next/config-loader
@prisma-next/emitter
@prisma-next/language-server
@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: 2
🧹 Nitpick comments (1)
scripts/lint-framework-vocabulary.mjs (1)
56-58: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winLine-keyed hit dedup can misreport which sites are "new".
hitKeyincludes the line number, so if an unrelated edit shifts line numbers between merge-base and HEAD, a pre-existing (grandfathered) occurrence will appear as a "new" site in the printed diagnostic even though it merely moved. The exit code stays correct (it's driven by the raw count delta), but the reported "new forbidden vocabulary" list can mislead a developer trying to locate what they actually introduced, undermining the main value of the ratchet's output.Consider keying on
file:term:trimmedTextinstead of line number to be resilient to line shifts (accepting that identical duplicate lines will be deduped together, which is a reasonable trade-off for a substring-based scan).Also applies to: 134-144
🤖 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/lint-framework-vocabulary.mjs` around lines 56 - 58, The hit dedup key in hitKey is too dependent on line numbers, so shifted lines can make grandfathered forbidden-vocabulary matches look newly introduced in the diagnostic output. Update hitKey and the surrounding new-hit reporting in lint-framework-vocabulary.mjs to key on stable identifiers such as file, term, and the trimmed matched text instead of hit.line, so the printed “new” list stays resilient to unrelated line moves.
🤖 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/lint-framework-vocabulary.mjs`:
- Around line 31-38: isScannableFile currently excludes .test.ts but still
treats .test.tsx as scannable, so extend the test-file filtering in
isScannableFile to also reject .test.tsx files. Update the existing path checks
alongside the current .test.ts, .test-d.ts, test/, and dist/ exclusions so
foo.test.tsx is not included in the vocabulary scan.
- Around line 111-121: The worktree setup in the main scan flow can leave
baseHitsByScope undefined if git worktree add fails, leading to a later
TypeError instead of a clear failure. Update the logic around the
tmpDir/mergeBase worktree creation so the failure is handled immediately in the
try block for the scanScope path, and do not continue to the later
baseHitsByScope access unless initialization succeeded. Use the existing
scanScope and git worktree add/remove sequence as the place to catch/report the
error with a direct diagnostic.
---
Nitpick comments:
In `@scripts/lint-framework-vocabulary.mjs`:
- Around line 56-58: The hit dedup key in hitKey is too dependent on line
numbers, so shifted lines can make grandfathered forbidden-vocabulary matches
look newly introduced in the diagnostic output. Update hitKey and the
surrounding new-hit reporting in lint-framework-vocabulary.mjs to key on stable
identifiers such as file, term, and the trimmed matched text instead of
hit.line, so the printed “new” list stays resilient to unrelated line moves.
🪄 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: b07d9300-edcc-48e2-9140-ccb58329d178
📒 Files selected for processing (8)
.agents/rules/README.md.agents/rules/fix-the-class-not-the-instance.mdc.agents/rules/no-family-vocabulary-in-framework.mdc.github/workflows/ci.ymlpackage.jsonscripts/lint-framework-vocabulary.config.jsonscripts/lint-framework-vocabulary.mjsscripts/lint-framework-vocabulary.test.mjs
Project-context Drive advice for reviewer passes, paired with the vocabulary ratchet: drive/code/README.md gains the framework-vocabulary smell (the family-blindness test, the dressing tells, and the instruction that findings name the CLASS so responders sweep the whole diff), and the failure-mode catalogue gains F26 — review comment point-fixed, class re-ships next round — with detection signals, the class-first response protocol, and the PR #906 three-round reference incident. Co-Authored-By: Claude Opus 4.8 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…tching Replaces the merge-base ratchet with a high-water-mark threshold recorded in the config: fail when the live count exceeds it (remove the new vocabulary, or raise the threshold with justification) and fail when it drops below (lower the threshold to lock in the win). No git merge-base, worktree, or origin/main requirement — the check runs from any checkout and the number is visible and reviewable in the diff. Matching is now identifier-token aware rather than substring: a line is tokenized on camelCase and non-alphanumeric boundaries, and a term matches as a consecutive token subsequence (with plural tolerance). This rejects substring noise (abortable/urls no longer count as table/rls) while still catching camelCase leaks (parentColumns, MongoStorage). That makes it safe to expand the forbidden list to the full family/target vocabulary (postgres, mongo, column, table, sql, jsonb, primaryKey, …); the current baseline is 967 lines. Co-Authored-By: Claude Opus 4.8 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…ew rulecards This PR adds fix-the-class-not-the-instance.mdc and no-family-vocabulary-in-framework.mdc, taking the .cursor/rules total to 203,824 bytes — 324 over the previously tight-pinned 203,500. CI checks the footprint on the fully-synced rule tree (prepare → rules:sync), so it caught what a local unsynced tree missed. Raise the byte budget to 208,000 (~2% buffer). Only this budget was affected; lines and alwaysApply stay well under. Co-Authored-By: Claude Opus 4.8 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
isScannableFile only excluded .test.ts/.test-d.ts, so a .test.tsx file would be scanned as production code and its vocabulary would count toward the threshold. Match the .tsx variants too. No .tsx files exist under packages/1-framework, so the baseline stays 967. (CodeRabbit review.) Co-Authored-By: Claude Opus 4.8 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…amily-neutral #918's lint:framework-vocabulary ratchet (now on main) flagged five lines this PR added under packages/1-framework — all doc-comment prose naming family concepts (StorageColumn/computeColumnType/column.valueSet, and "native types … the SQL family's isSqlEntityRefResolution" as examples). Reword them to describe the same framework mechanism without family vocabulary, rather than raise the threshold for our own additions. Comment-only; count back to 967 = threshold. Co-Authored-By: Claude Opus 4.8 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
Linked issue
No ticket — review-process infrastructure, adopted as an intervention during the PR #906 review rounds.
At a glance
A PR that adds family vocabulary to the framework domain now fails CI with the offending line, instead of waiting for a human review round to catch it.
Decision
The framework domain (
packages/1-framework) is family-blind, but family vocabulary has repeatedly leaked into framework types through review misses — the identical defect class was flagged across three review rounds on PR #906 (CodecRef.nativeType, anativeTypeForframework hook, a strategy-enum field). This PR turns that review comment into a machine check, plus the rulecards that encode the discipline:lint:framework-vocabulary— a merge-base ratchet in the exact mold oflint:casts: counts forbidden-term occurrences (declarative per-scope config:nativeType,native-type,postgres,sqlite,mysqlunderpackages/1-framework, source files only) at HEAD vs the merge-base; growth fails with new sites listed; the 200 pre-existing hits are grandfathered and can only shrink. Wired into the CI Lint job besidelint:casts.no-family-vocabulary-in-framework.mdc— the rule the ratchet enforces: the family-blindness test (would Mongo populate or consume this meaningfully?), the "family-agnostic dressing" tells (never-param bridges, duplicated "structurally identical" shapes, strategy string-enums), strategies as codec-owned hooks.fix-the-class-not-the-instance.mdc(alwaysApply) — review-response discipline: a comment names a class, not a point-fix; sweep the whole diff, fix every instance in one round; new surface never inherits grandfathering; design is never settled.Reviewer notes
git ls-files-tracked*.ts/*.tsxunder each scope, excluding tests anddist/. Matching is substring, case-insensitive per config — deliberately blunt; the ratchet (not precision) is what makes it safe, since pre-existing hits never fail.packages/1-framework:postgres136 ·nativeType41 ·sqlite13 ·mysql8 ·native-type2 (200 total, 45 files). Shrinking these is tracked debt (TML-2966 covers thenativeTypeauthoring surface).packages/2-sql) — seeded with the one scope this intervention is about.Testing performed
scripts/lint-framework-vocabulary.test.mjs— 17 tests via thelint-casts.test.mjsfixture-repo pattern: baseline passes, new occurrence fails with site listed, negative delta passes, exclusions hold, scope isolation, worktree cleanup.pnpm test:scripts183/183 ·pnpm lint:framework-vocabularyexits 0 on this branch ·package.json/ci.ymlparse-validated.Alternatives considered
lint:castsalready made.Checklist
TML-NNNN:title — no ticket; process infrastructure (see Linked issue).Summary by CodeRabbit