Skip to content

fix(cli): mds build/check exit 1 on a directory whose only .mds files are _-prefixed partials (#387) - #392

Merged
dean0x merged 3 commits into
mainfrom
fix/387-partials-only-dir-exits-one
Sep 15, 2026
Merged

dean0x merged 3 commits into
mainfrom
fix/387-partials-only-dir-exits-one

Conversation

@dean0x

@dean0x dean0x commented Sep 15, 2026

Copy link
Copy Markdown
Owner

Summary

BREAKING (CLI): mds build <dir> and mds check <dir> now exit 1 when every .mds file in the tree is a _-prefixed partial. The walker collects partials (they are inputs for watch, fmt and lint) but build/check never compile them, so a partials-only tree used to end 0 built, 0 failed with exit 0 — the same silent green pass #204 closed for the empty tree. It now prints <n> .mds file(s) found in <dir> but all are _-prefixed partials; nothing was built (… nothing was checked) on stderr, even under --quiet, and exits 1.

One predicate, two callers: output::partials_only(&[PathBuf]) -> Option<usize> (None for an empty list — the empty-tree arm owns that — or when any non-partial exists; Some(n) otherwise), consumed by a third nothing-to-do arm in run_build_directory and run_check_directory, placed after the empty-tree arm and before the loop, in the same shape as the all-excluded arm.

fmt / lint / watch unchanged. mds fmt <dir> and mds lint <dir> format and lint partials, so a partials-only library is real work for them (pinned by two new tests). mds watch <dir> has no nothing-to-do arm and still starts. A partials library that is only ever imported from elsewhere should not be passed to build/check on its own.

Commits

  1. test(cli): RED — predicate scaffold (unconditional None, with a temporary #[allow(dead_code)] because mds-cli is a bin-only crate and the scaffold has no non-test caller yet) + unit test partials_only_answers + five integration tests in tests/dir_build.rs: build partials-only → exit 1; build --quiet still emits the diagnostic; check partials-only → exit 1; fmt and lint pinned unchanged. RED evidence: 6 tests run: 2 passed, 4 failed (the four behaviour tests failing on Some(0) vs expected Some(1) / None vs Some(1)).
  2. fix(cli) — predicate body, the two arms, the build.rs doc block enumerating the three diagnostics; the #[allow] comes off. The interpolated count is named partials_only_count and registered in tests/print_discipline.rs ALLOWED_UNSANITIZED for both call sites (integer counter, same convention as the sibling arms); the path goes through safe_path.
  3. docs — CHANGELOG BREAKING bullet as the sibling of build: empty directory build exits 0 — silent success hazard in CI #204, spec §7.2 (new bullet) / §7.3 (three nothing-to-process exits) / §7.9 (exit-1 row), README.

Gates (local, on 344f037)

  • cargo fmt --all -- --check clean; cargo clippy --workspace --all-targets -- -D warnings clean; cargo clippy -p mds-cli --all-targets --features startup-race-probe -- -D warnings clean
  • cargo nextest run -p mds-core -p mds-cli: 2361 passed (mds-core 1465, mds-cli 896; +6 vs main)
  • cargo test --doc -p mds-core: 53 passed; cargo +1.88 check -p mds-core -p mds-cli clean
  • npm run test:gates: 212 pass / 0 fail; node scripts/verify-no-control-bytes.mjs ✓ (563 files)
  • Added-lines ledger-id check and release-surface diff check: both empty, each with a planted positive control
  • Behaviour smoke (debug binary, scratch dir): build src/ → exit 1 with the diagnostic; build --quiet src/ → exit 1, same stderr; check src/ → exit 1, nothing was checked; fmt src/ → exit 0, 0 formatted, 1 unchanged, 0 failed; with real.mds added, build src/ --out-dir out/ → exit 0, out/real.md present, out/_only.md absent

Snyk code scan unavailable (MCP ENOENT); the security/snyk CI check is SCA-only.

Not a release-surface PR. The mds-cli feature knowledge base refresh is deferred to the D2 docs bundle.

Related Issues

Closes #387

… a count diagnostic; fmt/lint pinned unchanged (#387)
… partials — third nothing-to-do arm via output::partials_only (#387)
…HANGELOG (BREAKING sibling of #204), spec §7.2/§7.3/§7.9, README (#387)
@dean0x
dean0x merged commit 440b0af into main Sep 15, 2026
46 checks passed
@dean0x
dean0x deleted the fix/387-partials-only-dir-exits-one branch September 15, 2026 21:36
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.

mds build/check/fmt/lint <dir> exits 0 when the only .mds files are partials (_foo.mds) — same silent-green shape as #204

1 participant