Skip to content

feat(spec,validate)!: add §20.5 1000-line source file cap with opt-in exception marker#37

Merged
niclaslindstedt merged 1 commit intomainfrom
feat/spec-file-size-limit
Apr 19, 2026
Merged

feat(spec,validate)!: add §20.5 1000-line source file cap with opt-in exception marker#37
niclaslindstedt merged 1 commit intomainfrom
feat/spec-file-size-limit

Conversation

@niclaslindstedt
Copy link
Copy Markdown
Owner

Summary

Adds a new mandate to OSS_SPEC.md (§20.5) capping non-test source files at 1000 physical lines, with an opt-in exception via oss-spec:allow-large-file: <reason> in a comment within the file's first 20 lines (non-empty reason required).

  • Spec — bumped to v2.3.0; §20 retitled "Source and test organization"; new §20.5 covers the rule, rationale, exception mechanism, and explicit auto-fix scope.
  • Validator — new check in src/validate/content.rs walks src//lib/, skips files whose stem matches the §20.2 test regex, and honours the marker only when the reason is non-empty.
  • Refactor (breaking internal layout)src/validate.rs (1151 lines) is split into src/validate/{mod,structural,content,agent_skills,toolchain}.rs so the reference impl exemplifies §20.5 rather than using its own escape hatch. Public re-exports (Report, Violation, AiFinding, run, check_*, version_ge, …) keep the external API stable; internal callers that did use crate::validate::foo continue to work.
  • Auto-fixprompts/fix-conformance bumped to 1.2.0. Guidance: only resolve §20.5 when the file also has a §20 inline-test violation (extracting the test block typically brings it back under the cap); otherwise leave the file alone and surface for manual split or marker annotation.
  • Docs synced — README spec badge, AGENTS.md (architecture, "Source file size" section, sync-points), templates/_common/AGENTS.md.tmpl, docs/architecture.md, and the update-spec / sync-oss-spec skill mapping tables (both repo and template versions).

Test plan

  • make build — clean
  • make test — 76 validator tests pass (70 previous + 6 new: over-limit flags, test-file exempt, marker-with-reason exempts, empty-reason marker doesn't exempt, exact-1000 boundary clean, marker-beyond-line-20 doesn't exempt); self-conformance passes
  • make lint — zero clippy warnings
  • make fmt-check — applied
  • Manual: bootstrap fresh demo project → validate clean; inject 1050-line src/bloat.rs → §20.5 violation with correct message; add marker with reason → clean

Checklist

  • Tests added/updated (tests/validate_test.rs + tests/prompts_test.rs)
  • Documentation updated:
    • README.md (spec version badge)
    • OSS_SPEC.md (v2.3.0, §20 retitle, §20.5)
    • AGENTS.md + templates/_common/AGENTS.md.tmpl
    • docs/architecture.md
    • .agent/skills/{update-spec,sync-oss-spec}/SKILL.md + template versions
  • Commit message follows conventional commit style (feat! — breaking because existing repos with >1000-line files now fail oss-spec validate)

… exception marker

Bumps OSS_SPEC.md to v2.3.0 and retitles §20 to "Source and test
organization". The new §20.5 caps non-test source files at 1000
physical lines and lets files opt out with
`oss-spec:allow-large-file: <reason>` in any comment within the
first 20 lines (non-empty reason required).

The validator enforces the rule; `oss-spec fix` only auto-resolves
the easy case (extracting inline test blocks that push a file over
the cap). Genuinely large source files are left for humans to split
or annotate.

`src/validate.rs` (1151 lines) is split into `src/validate/{mod,
structural,content,agent_skills,toolchain}.rs` so the reference impl
exemplifies the new mandate instead of using its own escape hatch.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@niclaslindstedt niclaslindstedt merged commit 9e1f068 into main Apr 19, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant