Repository navigation
refactor(lint): split rule-explanations.ts into one file per rule family - #38808
Conversation
Move-only: every entry moves verbatim from the 7,680-line table into packages/lint/src/rule-explanations/<family>.ts (one file per section header), the paragraphs several families reference move to shared.ts, and rule-explanations.ts becomes the index that assembles RULE_EXPLANATIONS in the same key order. The imports-nothing test now holds the split's shape: the index imports only its family files, and a family file imports only its siblings plus the RuleExplanation type. Claude-Session: https://claude.ai/code/session_01J8VVAoVoLCk7JiHvytWEqY Co-authored-by: Claude <noreply@anthropic.com>
…erface The family imports now follow the RuleExplanation interface, so the module docblock stays the interface's leading comment and the published rule-explanations declaration files stay byte-identical; the one-file-per-family note is its own comment above the imports. Claude-Session: https://claude.ai/code/session_01J8VVAoVoLCk7JiHvytWEqY Co-authored-by: Claude <noreply@anthropic.com>
The bundled rule-explanations and index entries change bytes (module order, source-path comments) with no behaviour or declaration change, so the package ships a patch note. Claude-Session: https://claude.ai/code/session_01J8VVAoVoLCk7JiHvytWEqY Co-authored-by: Claude <noreply@anthropic.com>
…y files The explanation entries ADR-0055 and ADR-0141 anchor now live in rule-explanations/security-posture.ts and rule-explanations/list-view-field-refs.ts; path only, the sentences are unchanged. Claude-Session: https://claude.ai/code/session_01J8VVAoVoLCk7JiHvytWEqY Co-authored-by: Claude <noreply@anthropic.com>
📓 Docs Drift CheckThis PR changes 1 package(s): 31 hand-written doc(s) name something this change touched — list omitted above 15 rows. Re-derive on the tree named below: ⛔ 13 release-owned page(s) also affected — read-only, see AGENTS.md Documentation Guardrails. What this run could not see
Coarse fallback — 4 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): Which tree this was computed onThis run read A worktree cut from an older # while this PR is open — GitHub drops the merge commit once it closes
git fetch origin 1ed9c3d8199f1709b958fb3599ce5ccfea0cb167 && git checkout 1ed9c3d8199f1709b958fb3599ce5ccfea0cb167
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 0fc9eab9006ec5756a29e0c66b79ab4c717b1993 22efc34785b40c1b4da2883988c71452d2fbd4b5 && git checkout -B drift-repro 0fc9eab9006ec5756a29e0c66b79ab4c717b1993 && git merge --no-ff 22efc34785b40c1b4da2883988c71452d2fbd4b5
node scripts/docs-audit/affected-docs.mjs --json 0fc9eab9006ec5756a29e0c66b79ab4c717b1993
|
|
repo:objectstack@huangyiirene · huangyiirene · session_01J8VVAmaT5PwLmXgonaxjYG 维护者速读
席位意见:同意落地。 席位核对ACCEPT · repo:objectstack@huangyiirene · PR #38808 @
|
|
repo:objectstack@huangyiirene · huangyiirene · session_01J8VVAmaT5PwLmXgonaxjYG Contract reviewServed-tier: Read: card #38666 (body and all five comments: triage 7266717711 and 7277925353, claim 7295777114, amendments 7295823844 and 7296411486, os-dev-report 7296788095), PR #38808 (body, 72 files, net diff against Check-runs on the head: 73 runs, all completed; 61 Why the security line reads no: the ADR 0055 anchor sentence is about owner-keyed update policy on a ① Derived judgmentsAccept-set changes: none. Public-surface changes: none.
② Semver level
The ③ Boundary flags
④ Design judgmentNo must-fix, no should-fix. N1 (nit) — the index's module docblock keeps its section title "Why this module imports nothing" verbatim while the source file now carries 66 import statements. It is kept on purpose (the docblock is the leading comment of the published The index against the original object. Tried to break it:
Cross-family shared constants ( ADR anchors. Implemented-by: VERDICT: PASS |
|
repo:objectstack@huangyiirene · huangyiirene · session_01J8VVAmaT5PwLmXgonaxjYG Hand-off for approval (Tier H: governed by |
Requested by Irene · project thread
Fixes #38666
Clause-②: no
Metadata-protocol: none
维护者速读
What changes
packages/lint/src/rule-explanations.tswas one 7,680-line table. It is now the index: the module docblock and theRuleExplanationinterface (both verbatim), the family imports,RULE_EXPLANATIONS(the same object literal, so the same keys in the same insertion order) andexplainRule(verbatim). A comment above the imports says a new entry goes into its family's file and a new family gets its own file.packages/lint/src/rule-explanations/holds one file per family: one per// ──section header of the old file (65), plusfield-consumers.tsforfield-no-consumers, which sat above the first header. Each entry moved verbatim; the only edit on a moved line isexportin front of itsconst.rule-explanations/shared.tsholds the three paragraphs more than one family references (UNPROVISIONED_ANCHOR_CAUSEandUNPROVISIONED_ANCHOR_REMEDY, used by 7 families, andAGGREGATE_PAIR_ROWS, used by 2), moved with their docblocks.security-owd-unset(above the first header) intosecurity-posture.ts, the family of the rule file that produces it, andseed-value-outside-state-machine(inside the assignment-rules section) under its own header, which was empty, inseed-state-machine.ts.rule-explanations.test.ts: only the case "the module imports nothing" changes, to the split's equivalent invariant (claim amendment 7295823844): the index imports only./rule-explanations/*.jsas values; every family file reached from it imports only siblings, plusRuleExplanationfrom the index asimport type; no file re-exports with export-from. Every other lint test is byte-unchanged.docs/adr/0055-…mdanddocs/adr/0141-…md: one symbol anchor each re-pointed fromrule-explanations.ts#NAMEto the family file that now declaresNAME, path only, sentence unchanged (claim amendment 7296411486).check:adr-symbol-anchorsreds without it.patchchangeset for@objectstack/lint: the bundledrule-explanationsandindexentries change bytes (module order, source-path comments), with no behaviour or declaration change.record-writes.tsat 623, and the index is 745. There is nofacade-delegation-registry.jsonrow: this is a table, not a facade.Tests
os explainfor every rule id: 292 of 292 byte-identicalThe CLI was built once at the base (
3000662c), thenos explain IDran for every key ofRULE_EXPLANATIONS(292 ids, stdout, stderr and the exit code captured per id) against the lintdistbuilt from the base and again against the lintdistbuilt from this branch. The CLI reads the table only through@objectstack/lint/rule-explanations, so the lint build is the only variable.Result:
ALL 292 IDENTICAL; every output exits 0 and opens with itsRule:header; the per-file sha256 manifest hashes toc0705a6eac1357072ee4593b166a969264aeab25c0450ef5e2cdea8eb97a0350on both sides.JSON.stringify(RULE_EXPLANATIONS)from the ESM and the CJS entry hashes tod031c3c5771bb2e806719a5fe5c1fd291cd643d24c979248999d9baefefa0d29before and after (key order included).Public declaration: all 8
.d.ts/.d.ctsfiles byte-identicalcmpofpackages/lint/dist/{index,runtime,runtime-HASH,rule-explanations}.d.{ts,cts}before and after:IDENTICALfor all eight. (A first cut put the imports above the interface, which dropped the module docblock fromrule-explanations.d.ts; the imports now follow the interface, so the docblock stays its leading comment.)The published entry still imports nothing
A count of import statements and
require(calls indist/rule-explanations.jsanddist/rule-explanations.cjsreads0and0: withsplitting: falsethe bundle inlines the family files. The bundles grow by about 3 KB (source-path comments).Lint suite, typecheck, build
At
939ffdd2(the last source change; later commits are the changeset and the two ADR anchors):pnpm --filter @objectstack/lint build: exit 0,check-dts-emitted: 6/6.pnpm --filter @objectstack/lint typecheck(tsc pluscheck:test-typecheck): exit 0.pnpm --filter @objectstack/lint exec vitest run --maxWorkers=2:Test Files 255 passed (255),Tests 10185 passed (10185).The rewritten test can fail (three mutations, each restored to HEAD)
Through
scripts/ablation-replace.mjs, runningvitest run src/rule-explanations.test.ts -t imports:view-refs.ts) gains a value import of../validate-field-consumers.js: red, "view-refs.js imports outside its family directory".import { type RuleExplanation }): red, "view-refs.js imports the index as a value"../validate-field-consumers.js: red, "expected 66 to be 67" (an import the reader cannot parse fails the count).Each run ended "restored: blob == HEAD,
git diff HEADis empty".Acceptance notes
packages/lint/tsup.config.tsandpackages/cli/src/utils/format.tsstill say in a comment that the entry "imports nothing". That stays true of the published bundle, so they are untouched.Verification
Read first, by risk:
packages/lint/src/rule-explanations.ts(the index: the imports and the unchangedRULE_EXPLANATIONSliteral),packages/lint/src/rule-explanations.test.ts(the one rewritten case),packages/lint/src/rule-explanations/shared.ts.Two-minute check:
pnpm --filter @objectstack/lint build && node packages/cli/bin/run.js explain field-no-consumersprints the same text as onmain.Derived gates: 77 derived, 75 run green, 2 NOT MEASURED (local reconciliation)
node scripts/pm/dispatch-gates.mjs --commandson this branch derived 77 commands (71 atbe77abe2, plus 6 the ADR edit added at22efc3478;be77abe2and22efc3478differ only by the two ADR anchor lines).--ranreconciliation: "77 derived, 75 run, 2 NOT-MEASURED, 0 UNRUN". Two reds were seen and cleared:check:adr-symbol-anchors(the two ADR anchors, fixed in22efc3478, re-run green on that head) andcheck-plugin-teardown-shape.mjs --self-test(its pinned fixture commit was missing from the shallow clone; green after fetching it). The two NOT MEASURED gates need every package'sdist, which a whole-repo build would give; CI runs them.Every family CI runs is read from this PR's check runs, not re-run here.
Generated by Claude Code