Search / scripts /complexity-policy.md
vomebook
Apply a separate reviewed budget to JS program decisions
7db25c2
|
Raw History Blame Contribute Delete
2.37 kB

Source complexity budget

The goal is fewer decisions and less dead code, not smaller functions at any cost.

  • Measure owned source under static/ and scripts/; Space additionally measures backend/ and app.py. Pipeline v1 measures Python in scripts/. Tests, vendored code, types, assets, generated output, Pipeline's standalone JS tool, and Space's native C extension are not measured by v1. They retain their separate checks. Do not move source outside this inventory to avoid the budget.
  • JavaScript uses the lockfile-pinned ESLint complexity rule with inline directives disabled. Its function and class execution regions retain the v1 budget. The same run counts outer script/module decisions separately against quality/js-program-budget.json; nothing is added to or removed from the v1 account. The top-level default is zero new decisions per file. Python uses an AST decision count: branches, loop headers, except, assertions, Boolean short circuits, comprehensions, and non-default match arms. Module, class, function and lambda bodies are separate regions. These are static counts, not coverage or runtime cost; the two language scores are not directly comparable.
  • Each file has a default peak of 12. Existing files over 12 have grandfathered caps on both the peak and the sum of points above 12. The repository also caps the total number of decisions (scores minus each region's base point). Moving branches into helpers does not earn a reduction in that total.
  • Read hotspots with python3 -B scripts/check_complexity.py --scope frontend --mode report (use site in Space and pipeline in Pipeline). Use --mode tighten to lower checked-in caps after a reduction; it refuses a regression. Review baseline changes as policy changes: do not regenerate upward with sample to make a check green. The static gate runs quality/check_complexity_v2.py. An independent reviewer or CI can pass --base-budget and --base-program-budget to it from a trusted revision to reject edits that raise existing caps. Tighten a program cap only after reviewing report mode's exact proposal. Do not transfer room between the two budgets.
  • Tests still decide whether a change is correct. Keep site contracts, readbacks, sanitization, and rollback boundaries intact. Prove a compatibility branch has no current consumer before removing it.