Skip to content

docs: surface file-size and module-split thresholds in code-guidelines - #1181

Merged
inureyes merged 5 commits into
mainfrom
docs/issue-1178-surface-file-size-thresholds
Aug 16, 2026
Merged

inureyes merged 5 commits into
mainfrom
docs/issue-1178-surface-file-size-thresholds

Conversation

@inureyes

@inureyes inureyes commented Aug 16, 2026 •

Copy link
Copy Markdown
Member

Summary

The file-size and module-split thresholds existed only in the agent-facing .claude/skills/mlxcel-code-structure/SKILL.md, with no contributor-facing document referencing them, which is how PR #1173's commit body ended up citing a nonexistent "500-line limit." This PR adds a "File Size and Module Structure" section to docs/code-guidelines.md as the single authoritative home for those numbers, and widens the places that describe that document so the guidance is reachable by the normal contributor path.

Option chosen

Option 1 from the issue: the thresholds live in docs/code-guidelines.md, and the section states as a rule that anything else citing them, agent-facing tooling under .claude/skills/ included, should link there rather than restate them. This is preferable because the thresholds are project convention that any human contributor needs, not agent-specific configuration; a document only agents read is the wrong home for a rule contributors are expected to follow. The tradeoff is that the skill file's structural rules are now split across two documents for a reader working through it top to bottom, but the pointer names exactly what moved and where, so that cost is small next to having one number that cannot drift.

The rule is written prescriptively rather than as a claim about what any particular consumer currently contains, because no such claim is verifiable from this repository.

Correction to the brief

The brief this implementation started from asserted that .claude/skills/ is tracked in this repository and instructed treating the skill-file edit as a real committed change. That is incorrect: .gitignore line 28 is /.claude/, committed at HEAD, and git ls-files .claude/ returns zero files, so the entire .claude/ directory is untracked here and ships no content with the repository. What was missing was therefore not de-duplication within this repository but a discoverable, contributor-facing home for the numbers, which this PR adds.

What changed

  • docs/code-guidelines.md: new "File Size and Module Structure" section before "Shared Function Comments", carrying the size table (under 800 fine as a single file, 800 to 1,200 acceptable with a helpers file, 1,200+ extract <name>_helpers.rs, 1,500+ consider a directory module, 2,000+ with no helpers file as the anti-pattern), the reason-based exception for nemotron_h.rs, llama4.rs as an illustration of the 1,200+ row, an explicit note that several files sit well past the thresholds and should be read as debt rather than as precedent, the inline-test-versus-sibling-_tests.rs threshold (roughly 100 lines to move, 200 at the latest) with the wiring both forms of which this repository already uses, and the <name>_helpers.rs / <name>_tests.rs naming convention.
  • CONTRIBUTING.md: widened the intro paragraph and the "Quick links" row describing docs/code-guidelines.md, which called it narrowly the shared-function rules, and added a "Code standards" bullet linking straight to the new section.
  • docs/README.md: widened entry 19, which described code-guidelines.md as covering only the // Used by: convention and the JIT kernel rule, so the docs index names the thresholds too.

Every line count quoted in the new section was measured against this branch rather than carried over, because the source this section was assembled from had gone stale: it recorded nemotron_h.rs at 2,342 lines (actually 2,914) and llama4.rs at 1,499 (actually 1,862), and its "complete model in one file" example, qwen2.rs, is a 31-line re-export shim over llama3, so dbrx.rs (606 lines, a full model through impl LanguageModel) replaced it. The section also tells readers the figures are approximate and to check the file rather than trust a number quoted anywhere, that section included.

What was deliberately left in the skill file rather than carried into docs/: the module-versus-directory trigger, trait-placement rules, the model-registration checklist, subsystem dependency-direction rules, error-handling and config-deserialization patterns, and the rest of the anti-patterns table. That material is about how to structure new code while implementing a model, not something a contributor looks up as a size or split threshold.

Out of scope, per the issue: the 0adb53c5 commit body on main is not rewritten, the PR #1173 technical report already records the discrepancy correctly, and the thresholds themselves are unchanged, only relocated and surfaced.

Test plan

  • Documentation-only change; no code or test files touched, so there is nothing for cargo test to exercise.
  • Every file path and line count cited in the new section verified against this branch with wc -l, including that nemotron_h.rs has no sibling _helpers.rs and llama4.rs does.
  • Confirmed gemma3n_helpers.rs, llama4_helpers.rs and qwen3_next_helpers.rs are the only *_helpers.rs files under src/models/.
  • Confirmed dbrx.rs is a complete model (Attention, SparseMoeBlock, DecoderLayer, DbrxModel, impl LanguageModel) rather than a re-export shim.
  • Confirmed the outlier claim: gemma4.rs 6,680 lines and qwen3_5.rs 3,451 lines both with no helpers file, gemma3n.rs 5,594 lines, and nine files under src/models/ over 2,000 lines.
  • Confirmed the CONTRIBUTING.md anchor #file-size-and-module-structure matches the ## File Size and Module Structure heading, with no duplicate heading that would shift the slug.
  • Confirmed the described sibling-test wiring matches this repository: both #[cfg(test)] mod <name>_tests; and the #[path = "..."] form are in use.

Closes #1178

The file-size and module-split thresholds (800/1,200/1,500-line table, the nemotron_h.rs and llama4.rs exceptions, and the inline-test-to-sibling-file tiering) previously existed only in the agent-facing .claude/skills/mlxcel-code-structure/SKILL.md, which no contributor-facing document referenced. PR #1173's commit body cited a nonexistent "500-line limit" because the real guidance was not discoverable from docs/ or CONTRIBUTING.md.

Add a "File Size and Module Structure" section to docs/code-guidelines.md as the single authoritative home for these numbers, covering the size table, the two documented exceptions with their reasons, the inline-test-versus-sibling-file threshold, and the helpers/tests naming convention. Widen CONTRIBUTING.md's three references to docs/code-guidelines.md, which previously described it narrowly as "the shared-function rules," to also cover the new section, and add a Code standards bullet pointing at it directly.

The local .claude/skills/mlxcel-code-structure/SKILL.md was also edited to link to the new section instead of restating the numbers, but that path is gitignored repo-wide (see .gitignore) and is not part of this commit.
@inureyes inureyes added status:review Under review type:docs Documentation improvements or additions priority:low Low priority area:docs User and developer documentation labels Aug 16, 2026
…bout an untracked file

The section asserted that .claude/skills/mlxcel-code-structure/SKILL.md links here instead of restating the thresholds. That is not verifiable from this repository: .gitignore line 28 ignores /.claude/, so the skill file ships no tracked content here, and the copy that is tracked lives in the internal development repository where it still carries the table.

Restates the sentence as the rule it was meant to express: this section is authoritative, and anything citing the numbers should link here rather than repeat them. That is true today and stays true regardless of what any particular consumer currently contains.
Three of the four examples were wrong against the current tree. qwen2.rs is a 31-line re-export shim over llama3, not a 600-line complete model, so it was replaced with dbrx.rs (606 lines, 15 struct/impl definitions, no re-export). nemotron_h.rs is about 2,900 lines rather than 2,342, and llama4.rs about 1,860 rather than 1,499.

The llama4 entry was also miscast. It has a llama4_helpers.rs, so it is not a file that ignored the guidance; it is the 1,200+ row working as intended, which is a more useful thing to show than a second exception. nemotron_h.rs remains the standing exception and is the only one of the two with no helpers file.

Adds a line telling readers the figures are approximate and to check the file, since these numbers went stale once already in the source this section was assembled from.
The File Size and Module Structure section called `src/models/nemotron_h.rs` the standing exception, which is false on this tree. Measured with `wc -l`, `src/models/gemma4.rs` is 6,680 lines with no helpers file, `src/models/gemma3n.rs` is 5,594 and `src/models/qwen3_5.rs` is 3,451 with no helpers file, all larger than nemotron_h.rs at 2,914. Nine files under `src/models/` exceed 2,000 lines and seven of those carry no helpers file, so the singular framing told a contributor the tree has one carve-out when it has many, and it left the real outliers unnamed. The replacement demotes nemotron_h.rs to a documented exception, names gemma4.rs, qwen3_5.rs and gemma3n.rs as debt rather than precedent, and says explicitly that the largest file in the tree is not a number to cite in a review.

The llama4 bullet also overstated its own extraction. `src/models/llama4_helpers.rs` is 84 lines against llama4.rs at 1,862, so calling it the bulk that could be lifted out was wrong, and llama4.rs does cross the 1,500+ row without splitting into a directory module, so framing it as the table working overclaimed. The bullet now names what actually moved (mask construction and weight loading) and drops the claim that the file is not an exception.

`docs/README.md` entry 19 still described `code-guidelines.md` as covering only the `// Used by:` convention and the JIT kernel rule, so a contributor browsing the docs index would not learn that the thresholds live there. That is the same discoverability gap this branch set out to close. The entry now leads with the file-size and module-split thresholds, including the `<name>_helpers.rs` extraction point and the inline-tests-to-`_tests.rs` move.

Refs #1178
@inureyes

Copy link
Copy Markdown
Member Author

Implementation Review Summary

Intent

Give the file-size and module-split thresholds a contributor-facing home in docs/code-guidelines.md, so nobody cites a threshold the project never set (as PR #1173's commit body did with a nonexistent "500-line limit").

Independent verification of every factual claim in the new section

All measured against the branch with wc -l. Every claim the previous correction commit made is accurate:

Claim Verified
dbrx.rs about 600 lines, a real complete model 606 lines; Attention, SparseMoeBlock, DecoderLayer, DbrxModel, impl LanguageModel. Not a shim
heartbeat.rs about 310 lines 311; HeartbeatConfig / HeartbeatPayload / HeartbeatService
nemotron_h.rs about 2,900, no helpers file 2,914; no nemotron_h_helpers.rs
llama4.rs about 1,860, has a helpers file 1,862; llama4_helpers.rs present
gemma3n_helpers.rs + qwen3_next_helpers.rs the only others under src/models/ Confirmed, exactly three *_helpers.rs there

The threshold table is a faithful transcription of the source (< 800 / 800-1,200 / 1,200+ / 1,500+), with the 2000+ line single file without helpers anti-pattern row folded in as a fifth row. No silent change of meaning. The inline-test guidance matches the source's Tier 1 (< 100 lines) and the Inline test > 200 lines anti-pattern row, and both wiring forms it describes (#[cfg(test)] mod config_tests; and #[path = "..."]) are in active use in this repo. The CONTRIBUTING.md anchor #file-size-and-module-structure resolves against ## File Size and Module Structure with no duplicate heading to shift the slug.

Findings addressed

  • HIGH. The section called src/models/nemotron_h.rs "the standing exception", which is false. gemma4.rs is 6,680 lines with no helpers file, gemma3n.rs is 5,594, qwen3_5.rs is 3,451 with no helpers file. Nine files under src/models/ exceed 2,000 lines and seven of those have no helpers file. The singular framing told a contributor the tree has one carve-out when it has many, and left the real outliers unnamed. Fixed in 5a5ed9ce: nemotron_h is now "a documented exception", the three outliers are named as debt rather than precedent, and the section says outright that the largest file in the tree is not a number you can cite in a review.
  • MEDIUM. The llama4 bullet claimed "the bulk that could be lifted out" went to llama4_helpers.rs. That file is 84 lines against llama4.rs's 1,862. It also called llama4 "not an exception but an illustration of the table working", while llama4 does cross the 1,500+ row without splitting into a directory module. Fixed: the bullet now names what actually moved (mask construction and weight loading) and drops the overclaim.
  • MEDIUM. docs/README.md entry 19, the GitHub-facing docs index, still described code-guidelines.md as covering only the // Used by: convention and the JIT kernel rule. A contributor browsing the index would not learn the thresholds live there, which is the same discoverability gap this PR set out to close. Widened in 5a5ed9ce.
  • MEDIUM. The PR body was stale against the branch tip: it still quoted nemotron_h.rs at 2,342 and llama4.rs at 1,499 (both corrected two commits earlier) and still asserted that the skill file "links to that section instead of restating the numbers", the exact claim 59c06872 removed from the doc as unverifiable. Since the body becomes the squash commit message, that would have reproduced the original failure mode: a wrong number frozen into permanent history. Rewritten to match the tip.
  • LOW. "the other two extractions" now scoped explicitly to src/models/ (there is also a src/vision/encoders/gemma3n_helpers.rs).

Curation judgment

The subset carried over is right. The issue's Technical Considerations names four things that should travel with the thresholds (the 200-line inline-test rule, the <name>_helpers.rs and <name>_tests.rs naming conventions, and the documented exceptions); all four are present. The agent-workflow material left behind (trait placement, registration checklist, dependency direction, error handling, config deserialization) is correctly out of scope for contributor docs. The one arguable gap is that the 1,500+ row says "consider a directory module" without carrying over the skill file's "3+ files or 2+ distinct concerns" trigger, so that row is slightly less actionable than the others. Minor, and a reasonable line to draw.

Cross-repo duplication

Within this repository the numbers now live in exactly one tracked place: .gitignore line 28 ignores /.claude/ and git ls-files .claude/ returns zero files. The tracked copy in the internal repository still carries the original table, so across the two repositories they still exist twice. That is out of scope here, and the section's wording handles it honestly: it states the single-source rule prescriptively ("anything else that cites them ... should link here rather than restate them") rather than asserting anything about what any consumer currently contains. That claim is true today and stays true regardless of the internal file's state, which is exactly right given it cannot be verified from this repository.

Verification

  • All stated requirements implemented (all four acceptance criteria met)
  • No placeholder or mock content
  • Integrated into the contributor path: CONTRIBUTING.md intro, quick-links row, code-standards bullet with a working anchor, plus the docs/README.md index
  • Project conventions followed: no AI attribution, no em dashes in any added line, Closes #1178 present, commit bodies unwrapped
  • Documentation-only; nothing under src/ touched, so no test run applies

@inureyes inureyes added status:done Completed and removed status:review Under review labels Aug 16, 2026
Bilingual report covering the relocation of the file-size thresholds into contributor-facing docs: why the guidance was unreachable rather than merely hard to find, why the numbers had to be verified rather than transcribed, and the cross-repository duplication that remains because the tracked copy of the skill file lives in the internal development repository. Records the four figures that were stale and the exception framing that survived the first correction.
@inureyes
inureyes merged commit 2d0938f into main Aug 16, 2026
7 checks passed
@inureyes
inureyes deleted the docs/issue-1178-surface-file-size-thresholds branch August 16, 2026 06:13
@inureyes inureyes self-assigned this Aug 27, 2026
be-free-snowboy pushed a commit to freestylejs/snowbrain-mlxcel that referenced this pull request Oct 27, 2026
lablup#1181)

## Summary

The file-size and module-split thresholds existed only in the agent-facing `.claude/skills/mlxcel-code-structure/SKILL.md`, with no contributor-facing document referencing them, which is how PR lablup#1173's commit body ended up citing a nonexistent "500-line limit." This PR adds a "File Size and Module Structure" section to `docs/code-guidelines.md` as the single authoritative home for those numbers, and widens the places that describe that document so the guidance is reachable by the normal contributor path.

## Option chosen

Option 1 from the issue: the thresholds live in `docs/code-guidelines.md`, and the section states as a rule that anything else citing them, agent-facing tooling under `.claude/skills/` included, should link there rather than restate them. This is preferable because the thresholds are project convention that any human contributor needs, not agent-specific configuration; a document only agents read is the wrong home for a rule contributors are expected to follow. The tradeoff is that the skill file's structural rules are now split across two documents for a reader working through it top to bottom, but the pointer names exactly what moved and where, so that cost is small next to having one number that cannot drift.

The rule is written prescriptively rather than as a claim about what any particular consumer currently contains, because no such claim is verifiable from this repository.

## Correction to the brief

The brief this implementation started from asserted that `.claude/skills/` is tracked in this repository and instructed treating the skill-file edit as a real committed change. That is incorrect: `.gitignore` line 28 is `/.claude/`, committed at `HEAD`, and `git ls-files .claude/` returns zero files, so the entire `.claude/` directory is untracked here and ships no content with the repository. What was missing was therefore not de-duplication within this repository but a discoverable, contributor-facing home for the numbers, which this PR adds.

## What changed

- `docs/code-guidelines.md`: new "File Size and Module Structure" section before "Shared Function Comments", carrying the size table (under 800 fine as a single file, 800 to 1,200 acceptable with a helpers file, 1,200+ extract `<name>_helpers.rs`, 1,500+ consider a directory module, 2,000+ with no helpers file as the anti-pattern), the reason-based exception for `nemotron_h.rs`, `llama4.rs` as an illustration of the 1,200+ row, an explicit note that several files sit well past the thresholds and should be read as debt rather than as precedent, the inline-test-versus-sibling-`_tests.rs` threshold (roughly 100 lines to move, 200 at the latest) with the wiring both forms of which this repository already uses, and the `<name>_helpers.rs` / `<name>_tests.rs` naming convention.
- `CONTRIBUTING.md`: widened the intro paragraph and the "Quick links" row describing `docs/code-guidelines.md`, which called it narrowly the shared-function rules, and added a "Code standards" bullet linking straight to the new section.
- `docs/README.md`: widened entry 19, which described `code-guidelines.md` as covering only the `// Used by:` convention and the JIT kernel rule, so the docs index names the thresholds too.

Every line count quoted in the new section was measured against this branch rather than carried over, because the source this section was assembled from had gone stale: it recorded `nemotron_h.rs` at 2,342 lines (actually 2,914) and `llama4.rs` at 1,499 (actually 1,862), and its "complete model in one file" example, `qwen2.rs`, is a 31-line re-export shim over `llama3`, so `dbrx.rs` (606 lines, a full model through `impl LanguageModel`) replaced it. The section also tells readers the figures are approximate and to check the file rather than trust a number quoted anywhere, that section included.

What was deliberately left in the skill file rather than carried into `docs/`: the module-versus-directory trigger, trait-placement rules, the model-registration checklist, subsystem dependency-direction rules, error-handling and config-deserialization patterns, and the rest of the anti-patterns table. That material is about how to structure new code while implementing a model, not something a contributor looks up as a size or split threshold.

Out of scope, per the issue: the `0adb53c5` commit body on `main` is not rewritten, the PR lablup#1173 technical report already records the discrepancy correctly, and the thresholds themselves are unchanged, only relocated and surfaced.

## Test plan

- [x] Documentation-only change; no code or test files touched, so there is nothing for `cargo test` to exercise.
- [x] Every file path and line count cited in the new section verified against this branch with `wc -l`, including that `nemotron_h.rs` has no sibling `_helpers.rs` and `llama4.rs` does.
- [x] Confirmed `gemma3n_helpers.rs`, `llama4_helpers.rs` and `qwen3_next_helpers.rs` are the only `*_helpers.rs` files under `src/models/`.
- [x] Confirmed `dbrx.rs` is a complete model (`Attention`, `SparseMoeBlock`, `DecoderLayer`, `DbrxModel`, `impl LanguageModel`) rather than a re-export shim.
- [x] Confirmed the outlier claim: `gemma4.rs` 6,680 lines and `qwen3_5.rs` 3,451 lines both with no helpers file, `gemma3n.rs` 5,594 lines, and nine files under `src/models/` over 2,000 lines.
- [x] Confirmed the `CONTRIBUTING.md` anchor `#file-size-and-module-structure` matches the `## File Size and Module Structure` heading, with no duplicate heading that would shift the slug.
- [x] Confirmed the described sibling-test wiring matches this repository: both `#[cfg(test)] mod <name>_tests;` and the `#[path = "..."]` form are in use.

Closes lablup#1178
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:docs User and developer documentation priority:low Low priority status:done Completed type:docs Documentation improvements or additions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

docs: Surface the file-size and module-split thresholds in contributor-facing docs

1 participant