Status: blocked
Waits for: VB-380
Priority: 3
Size: S
Arch: yardstick
Phase: implement
Design ref: none (code structure). docs/typescript-plan.md (P9); the survey in backlog/VB-055.md.
Goal: The lint holds a module’s exports to 15 and a function’s formatted length to 60 lines, each with a baseline that only falls (tests/width-baseline.json, updated with node tests/lint.js --update, a ratchet as the lint’s), and no cap on a module’s length. A function is a declaration, expression or arrow with a block body; a one-line arrow is not counted. Counted from the source (export declarations and the names of export { ... }). Today’s numbers, from the code on 12 November, to be recounted by the task (exports are counted on the loaded namespaces, constants included; functions on the formatted copy described in VB-380): 62 modules export, median 9, 18 over 15: sim 106 (the facade), sim/rules 56, sim/records 52, sim/agents 34, sim/relations 32, sim/stores 32, sim/herds 30, sim/fields 22, culture 20, sim/lifecycle 19, sim/layout, sim/claims, sim/plans 18 each, sim/hunger, sim/meadows, sim/heirs, sim/commands 17 each, sim/farmclaims 16. Functions over 60 formatted lines: 26 in src/sim, src/gen and the root modules (generate 486, gen/geology.lay 186, sim/scenarios.makeState 186, sim/lifecycle.marriageRound 159, sim/saves.encode 134, sim/scenarios.seedHeirs 134, sim/layout.layVillage 133, gen.bakeChunk 126, sim/heirs.heirRanking 116, …). heirRanking (116 formatted lines) is among them; movingRound, which Kim also named, is exported by sim/lifecycle but did not appear among the longest functions in the survey’s count (it is probably a short wrapper over roundPhase; not checked), and the task says what it measures.
Acceptance criteria:
tests/lint.js fails a function longer than 60 lines, unless the baseline allows it; the baseline holds today’s offenders at today’s numbers and only falls; a new function starts at the limit.sim.js facade is handled as Kim’s answer to question 4 says.AGENTS.md (Conventions) and BACKLOG.md’s refactor rules (“stays under 400 lines” at line 221 of BACKLOG.md on 12 November) give the two measures in place of the cap.docs/architecture/modules.md, “Adding things”: the same, one line.docs/typescript-plan.md, where this task is P9): waits for Kim’s answers to QUESTIONS.md, “VB-055: the move to TypeScript” (the formatter, the bundler, the hook, the width measures, when, the page and the tests, strict), which may change its criteria; the three rules common to these tasks are at the top of the plan.tests/lint.js.tests/lint-baseline.json holds long lines only). This task’s own criteria are unchanged; where they name the 400 lines, only the report and its mentions are left to remove.tests/width-baseline.json, may add one only while an open “Refactor: …” task names it; the sim facade is not counted. Left for this task: a function’s length, the count from export declarations, and the same mechanism or a ratchet for functions, to decide then.