Skip to content

xtask: stop committing modules.json and modules.mmd while keeping live boundary checks - #1946

Merged
eric8810 merged 1 commit into
mainfrom
xtask/drop-committed-module-graphs
Nov 20, 2026
Merged

eric8810 merged 1 commit into
mainfrom
xtask/drop-committed-module-graphs

Conversation

@eric8810

@eric8810 eric8810 commented Nov 20, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Stops committing docs/architecture/rust-agent/generated/modules.json (58,183 lines, 1.6 MiB) and docs/architecture/rust-agent/generated/modules.mmd (5,301 lines, 100 KiB) and stops diff-checking them for staleness in xtask check, while keeping 100% of live crate and syn-AST module boundary enforcement. Refs #1945 (keeping #1945 open for any follow-up decision on crates.json / instances.json).

Why

  • In the last 100 commits on main, modules.json changed 42 times and modules.mmd 19 times (even adding a single internal/test module mutates the 1.6 MiB file), creating constant merge conflicts across parallel PRs, extra rebases, and repeated CI runs.
  • Neither file is referenced by any design or architecture document, and a 5,301-line Mermaid diagram cannot be rendered readably.
  • xtask/src/modules.rs already computes the AST graph and asserts all boundary rules (check_boundaries()) live in memory from source on every run — the committed snapshots added zero enforcement.

Changes

  • xtask/src/modules.rs: split analyze() into modules::check() (live crate + syn-AST boundary verification without serializing 1.7 MiB of JSON/Mermaid) and modules::generate() (on-demand emission), and assert both paths in business_boundaries_follow_source_aliases_and_preserve_builtin_contracts.
  • xtask/src/main.rs:
    • Call modules::check(&root())? in boundaries() for both xtask check and xtask graph, keeping crates.json and crates.mmd committed and freshness-checked.
    • Add cargo run --locked -p xtask -- module-graph DIR to write modules.json and modules.mmd on demand to any directory outside Git.
  • Remove committed docs/architecture/rust-agent/generated/modules.json and docs/architecture/rust-agent/generated/modules.mmd (keeping catalog.md, crates.*, services.*, instances.*, and npm/branch-services.d.ts intact).
  • Update AGENTS.md and docs/architecture/README.md to document module-graph DIR and live module-boundary checking.

Design rule checklist

All plugin/runtime design rules are n/a: this change only affects xtask graph output/check behavior and its documentation, with no runtime, Timeline, or plugin behavior changes.

  • Scope: n/a — xtask development tooling only.
  • Commands and results: n/a — xtask development tooling only.
  • Handover: n/a — xtask development tooling only.
  • Timeline before callbacks: n/a — xtask development tooling only.
  • Infrastructure: n/a — xtask development tooling only.
  • Core mechanisms and consumers: n/a — xtask development tooling only.
  • Batch: n/a — xtask development tooling only.
  • Context: n/a — xtask development tooling only.
  • No reading another plugin's internal state: n/a — xtask development tooling only.
  • Cross-language faces: n/a — xtask development tooling only.
  • Business configuration: n/a — xtask development tooling only.
  • Missing mechanism capabilities: n/a — xtask development tooling only.
  • Timeline holds only facts later decisions use: n/a — xtask development tooling only.

Documentation

  • No accepted ADR is modified or deleted (ADR 008).
  • No other module's design is changed.
  • Delivery status is not added to an ADR, index or roadmap.

Verification

  • cargo fmt --all -- --check --config error_on_line_overflow=true — passed.
  • cargo clippy --locked -p xtask --all-targets -- -D warnings — passed.
  • cargo test --locked -p xtask -- modules:: — 4 passed (covering both check() and generate() boundary assertions).
  • cargo run --locked -p xtask -- check — passed (live module source boundaries, crate boundaries, plugin docs, service catalog, service declarations, plugin locks, comment links, literal main).
  • cargo run --locked -p xtask -- module-graph /tmp/dim-test-module-graph — emitted modules.json and modules.mmd on demand.
  • node scripts/adr-check.mjs --base origin/main & node --test scripts/ci-changes.test.mjs — passed.

@zerob13 zerob13 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified on the exact PR merge tree on Linux. xtask check still enforces the Cargo and source-derived module boundaries, and all four module tests passed. xtask module-graph DIR reproduced both previous snapshots byte for byte, and xtask graph kept them out of the generated directory while preserving the remaining outputs. I found no downstream consumer tied to the removed paths. The CI path selection includes xtask check, and the macOS verify job is still queued.

@zerob13 zerob13 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I traced xtask check through modules::check to check_boundaries(). Both live boundary checks still run, and the existing CI path rules still select xtask check.

The remaining issue is the closing reference. The current acceptance criteria for #1945 also cover unused intermediate JSON snapshots. This PR still generates crates.json and instances.json, and it still checks crates.json for freshness. Please use Refs #1945 or narrow the issue's acceptance criteria to the two module snapshots before merging.

Comment thread xtask/src/modules.rs
)
.unwrap();
let checked = check(&workspace);
let result = generate(&workspace);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both calls reach the same analyze() path and rerun cargo metadata for each of the seven fixtures. Please use check() for these boundary assertions. The existing graph tests already cover generate() output. This is a non-blocking cleanup.

@yyhhyyyyyy yyhhyyyyyy left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved. I verified the full main...head diff at 2ebe95ef.

Snapshot removal

git ls-tree at HEAD shows no modules.json or modules.mmd under docs/architecture/rust-agent/generated/. A repo-wide search finds only the intended new references in AGENTS.md:96, docs/architecture/README.md:110, and xtask/src/modules.rs:72,128. crates.*, instances.*, services.*, catalog.md, and the app-server/local service snapshots remain committed.

Boundary enforcement

modules::check() (xtask/src/modules.rs:60) and modules::generate() (xtask/src/modules.rs:73) both call analyze(), which still runs resolve_symbols(), resolve_edges(), and check_boundaries() (xtask/src/modules.rs:244-246). The move is verbatim and no rule changed. boundaries() calls modules::check() (xtask/src/main.rs:409) for both xtask check (xtask/src/main.rs:69) and xtask graph (xtask/src/main.rs:363), and the Cargo restrictions remain at xtask/src/main.rs:383-398. Only crates.json/crates.mmd are written and freshness-checked now (xtask/src/main.rs:405-410), which matches the updated docs.

On-demand output

module-graph DIR writes only inside DIR (xtask/src/main.rs:86-100). I ran it to a directory under my review data dir; both files were byte-identical to the removed base snapshots (1,629,664-byte modules.json, 102,245-byte modules.mmd), and the worktree generated directory stayed free of both files.

Verification on this head

git diff --check, git merge-tree, cargo fmt --all -- --check, node scripts/adr-check.mjs --base origin/main, cargo test --locked -p xtask -- modules:: (4 passed), cargo run --locked -p xtask -- check (743 modules, 4555 edges, all other checks passed), and module-graph all passed. CI at this head: changes and dependencies pass, verify is still pending.

Optional notes

  1. The PR body says "Fixes #1945", but #1945's acceptance criteria also mention unused intermediate .json snapshots, and this PR still commits and checks crates.json (xtask/src/main.rs:406,409) and keeps instances.json. Agree with zerob13: use Refs #1945 or narrow the issue scope before merging. This does not affect the code.
  2. docs/architecture/README.md:110 says graph is "the only command that writes committed files", but xtask types also writes the committed npm/branch-services.d.ts. Consider "the only command that writes the generated architecture files".
  3. The inline cleanup at xtask/src/modules.rs:880 is not blocking. The fixture test runs in 0.22s, and asserting both check() and generate() keeps coverage that both entry points reject boundary violations.

I did not run xtask graph end to end because it assembles an agent. Its module check path is xtask/src/main.rs:363 -> 409, and xtask check exercised the same modules::check() successfully.

Stop writing and freshness-checking the 58k-line modules.json and
5.3k-line modules.mmd snapshots under docs/architecture/rust-agent/generated/.
Both files had zero documentation readers while causing frequent merge
conflicts across parallel pull requests, and `xtask check` already
computes and enforces every crate and syn-AST module boundary rule live
from source.

- Split `modules::check` (live AST boundary enforcement without
  serializing JSON/Mermaid) from `modules::generate`.
- Run `modules::check` inside `boundaries` for both `xtask check` and
  `xtask graph`, keeping `crates.json` and `crates.mmd` committed and
  freshness-checked.
- Add `xtask module-graph DIR` to emit `modules.json` and `modules.mmd`
  on demand into an arbitrary directory without committing them.
- Remove `docs/architecture/rust-agent/generated/modules.{json,mmd}` and
  update `AGENTS.md` and `docs/architecture/README.md`.

Refs #1945

# Conflicts:
#	docs/architecture/rust-agent/generated/modules.json
#	docs/architecture/rust-agent/generated/modules.mmd
@eric8810
eric8810 force-pushed the xtask/drop-committed-module-graphs branch from 2ebe95e to b6f6cff Compare November 20, 2026 09:10
@eric8810

Copy link
Copy Markdown
Collaborator Author

Thanks @zerob13 and @yyhhyyyyyy for the reviews!

  • Rebased onto origin/main (14cc130b2) to resolve the modify/delete conflict on modules.json and modules.mmd introduced by Move Scheduler, EventHub and Modality to pluginFiles #1901.
  • Updated the PR description from Fixes #1945 to Refs #1945 so xtask: stop committing modules.json and modules.mmd while keeping live boundary checks #1945 stays open for any follow-up decision on crates.json / instances.json.
  • Clarified docs/architecture/README.md (writes the generated architecture files rather than writes committed files, since xtask types writes npm/branch-services.d.ts).
  • Re-ran cargo fmt --all -- --check, cargo test --locked -p xtask -- modules::, cargo run --locked -p xtask -- check, and node scripts/adr-check.mjs --base origin/main on the rebased head — all passing.

@eric8810
eric8810 merged commit a43607b into main Nov 20, 2026
yyhhyyyyyy added a commit that referenced this pull request Nov 20, 2026
Main stops committing the generated module graph (#1946); accept that
deletion here and keep the rest of the resolve as the merge produced it.
soulmachine pushed a commit to soulmachine/dim that referenced this pull request Nov 24, 2026
The parent's head carries the attach reply's default cursor (arcships#1917) and moves the generated module files out of the tree (arcships#1946), so the resolution drops both files, as a sync with main does.
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.

3 participants