Skip to content

feat!: v0.5.0 Wave 2 — mds-cli output surface + watch (pipe/exit contract, panic hook, typed paths, anchored writes, lint result sink, watch robustness) - #438

Draft
dean0x wants to merge 248 commits into
mainfrom
feat/v050-wave2-cli-watch
Draft

dean0x wants to merge 248 commits into
mainfrom
feat/v050-wave2-cli-watch

Conversation

@dean0x

@dean0x dean0x commented Sep 29, 2026

Copy link
Copy Markdown
Owner

Draft — v0.5.0 Wave 2 in progress. Phases 1–2 (test nets only) have landed; no product behaviour has changed yet. The full description (breaking changes, fixes per issue, verification and soak tables) replaces this text before the PR leaves draft.

Problem being solved

mds-cli's output and watch layer crashed on closed pipes, leaked raw panic text and absolute paths, followed planted symlinks on writes and deletes, deleted hand-written files in directory watch, published empty outputs mid-save, and hid lint output bugs behind duplicated code paths.

Progress

Test Plan

  • TP-1 (AC-1) Build of a file to stdout with the pipe reader dropped before spawn exits 0 with no panic text, and the same run into an open pipe receives the compiled bytes — method:ci [files: crates/mds-cli/tests/broken_pipe.rs]
  • TP-2 (AC-1) Table over build stdin, fmt stdin, fmt diff, fmt check diff, lint json on file, directory and stdin, and lint fix stdin exits with closed stdout exactly as with an open pipe — method:ci [files: crates/mds-cli/tests/broken_pipe.rs]
  • TP-3 (AC-1) Observe build dash-o dash into a closed pipe exiting 101 with the std print panic on the unfixed tree and record the stderr line — method:local [files: crates/mds-cli/src/build.rs]
  • TP-4 (AC-2) Build file and directory, check, fmt, fmt check, lint human on file, directory and stdin, lint fix and init with stderr closed exit with their verdict and write every output — method:ci [files: crates/mds-cli/tests/broken_pipe.rs]
  • TP-5 (AC-2) Observe build with an output file and check of a broken template exiting 101 under closed stderr on the unfixed tree — method:local
  • TP-6 (AC-3) On Windows stdout as a read only handle makes build to stdout, fmt stdin, lint json on a clean file and lint fix stdin exit 2 with one io error naming stdout — method:ci [files: crates/mds-cli/tests/broken_pipe.rs]
  • TP-7 (AC-3) On Linux stdout redirected to dev full gives exit 2 for a clean lint json run and for output without a trailing newline, and exit 3 for a resource limited run — method:ci [files: crates/mds-cli/tests/broken_pipe.rs]
  • TP-8 (AC-3) Observe a clean lint json run into dev full exiting 0 on the unfixed code in the Linux CI leg, recorded in phase — method:manual
  • TP-9 (AC-4) Output write failure in build file mode, build directory mode, fmt, lint fix and init exits 2 with the io code, and the directory run still writes the other files — method:ci [files: crates/mds-cli/tests/broken_pipe.rs]
  • TP-10 (AC-4) Unreadable stdin, a directory handle on Unix and a write only handle on Windows, fails build, check, fmt and lint with the io code and exit 2 — method:ci [files: crates/mds-cli/tests/broken_pipe.rs]
  • TP-11 (AC-4) Directory build with one template error and one mkdir failure exits 2, a template error alone still exits 1, and a stale delete failure on Unix exits 2 — method:ci [files: crates/mds-cli/tests/dir_build.rs]
  • TP-12 (AC-4) Observe write and mkdir failures exiting 1 under build, check and fmt on the unfixed tree and record the uncoded message — method:local
  • TP-13 (AC-5) Stdin of the cap plus one byte fails build, check, fmt, lint human and lint json with the resource limit code and exit 3, and exactly the cap passes the size gate — method:ci [files: crates/mds-cli/tests/broken_pipe.rs, crates/mds-cli/tests/security.rs]
  • TP-14 (AC-5) Observe oversized stdin exiting 1 under build, check and fmt and 2 under lint on the unfixed tree — method:local
  • TP-15 (AC-6) Lexical guard finds process exit only in the output exit funnel, flags a planted call and an imported alias, and proves it scanned every source file — method:ci [files: crates/mds-cli/tests/print_discipline.rs, crates/mds-cli/src/output.rs]
  • TP-16 (AC-6) A run whose verdict is 0 but whose stdout write failed exits 2 through the sticky failure state in single file and directory lint and in build — method:ci [files: crates/mds-cli/tests/broken_pipe.rs]
  • TP-17 (AC-7) Print discipline registers the writer macro, keeps per file site floors counted over it, and flags a planted raw eprintln and a planted sink writeln — method:ci [files: crates/mds-cli/tests/print_discipline.rs]
  • TP-18 (AC-7) Allowlist liveness passes with the lint status names, and no second stdout helper or raw std print macro remains outside the writer body — method:ci [files: crates/mds-cli/tests/print_discipline.rs, crates/mds-cli/src/*.rs]
  • TP-19 (AC-8) The fmt closed pipe test drops the reader before spawn, asserts exit 0 and pairs it with an open pipe control that receives the formatted bytes — method:ci [files: crates/mds-cli/tests/cli_fmt.rs]
  • TP-20 (AC-8) The issue comment records that fmt check piped into head never writes stdout and names the replacement tests — method:manual
  • TP-21 (AC-9) Spec exit code sections state the closed pipe rule, io exit 2 for every subcommand and oversized stdin exit 3, and the changelog has the breaking CLI entry — method:local [files: spec.md, CHANGELOG.md]
  • TP-22 (AC-10) A debug trigger panics in main with a sentinel, a tempdir path and an ESC payload, and stderr is exactly the internal compiler error text with exit 101 — method:ci [files: crates/mds-cli/tests/panic_hook.rs]
  • TP-23 (AC-10) Observe the default hook printing a panicked-at location and payload for the closed stdout build panic on the unfixed tree — method:local
  • TP-24 (AC-11) With RUST_BACKTRACE set to 1 and to full the output adds only an escaped backtrace, never the payload sentinel, and passes the control character check — method:ci [files: crates/mds-cli/tests/panic_hook.rs]
  • TP-25 (AC-11) Every spawn in the panic tests removes or sets RUST_BACKTRACE explicitly, checked lexically, so the CI global setting cannot flip an arm — method:ci [files: crates/mds-cli/tests/panic_hook.rs]
  • TP-26 (AC-12) A panic with stderr closed exits with code 101 and not by a signal, proving the hook writer never panics — method:ci [files: crates/mds-cli/tests/panic_hook.rs]
  • TP-27 (AC-12) Lexical pin shows the hook body is one write_all of a constant with no print macro, no format, no miette and no payload formatting — method:ci [files: crates/mds-cli/tests/panic_hook.rs, crates/mds-cli/src/main.rs, crates/mds-cli/src/output.rs]
  • TP-28 (AC-13) A panic in a watch helper thread makes the watcher print the internal compiler error text once and exit 101 within the bound — method:ci [files: crates/mds-cli/tests/panic_hook.rs]
  • TP-29 (AC-14) Directory build, check, fmt and lint with a compile panic in one of three files finish the other two, print the error text once, report an internal error entry and exit 101 — method:ci [files: crates/mds-cli/tests/panic_hook.rs]
  • TP-30 (AC-14) Watch file and directory mode survive a compile panic, rebuild on the next edit, print the error text once per panic and exit 101 when stopped — method:ci [files: crates/mds-cli/tests/panic_hook.rs]
  • TP-31 (AC-14) Lexical check that each catch unwind closure wraps only the compile call, with no write, delete or state mutation inside — method:ci [files: crates/mds-cli/tests/panic_hook.rs]
  • TP-32 (AC-15) The panic trigger compiles only under debug assertions, pinned lexically with a planted ungated control — method:ci [files: crates/mds-cli/tests/panic_hook.rs]
  • TP-33 (AC-15) A release build with the trigger variable set exits 0 while the debug build exits 101, and no workflow enables the debug panics feature — method:local [files: .github/workflows/*.yml, crates/mds-cli/Cargo.toml]
  • TP-34 (AC-15) Security policy and spec describe the CLI panic output, exit 101 and the never shipped payload feature — method:local [files: SECURITY.md, spec.md]
  • TP-35 (AC-16) The spec carries one surface to form label table, and a test maps every row to an existing named test by set equality — method:ci [files: spec.md, crates/mds-cli/tests/path_labels.rs]
  • TP-36 (AC-17) Watching, Watching directory and Compiled to under out-dir show the typed form through a symlinked or relative alias while the canonical form is absent — method:ci [files: crates/mds-cli/tests/path_labels.rs]
  • TP-37 (AC-17) The canonical status line pins in the directory build and watch dot form tests change in the same commit as the product change — method:local [files: crates/mds-cli/tests/dir_build.rs, crates/mds-cli/tests/cli_watch.rs]
  • TP-38 (AC-18) Every command surface run from a tempdir with relative arguments emits no tempdir prefix on stdout or stderr, each with a control that its sink fired — method:ci [files: crates/mds-cli/tests/path_labels.rs]
  • TP-39 (AC-18) Error sinks for write, temp file, stat, mkdir, delete, the source map line and the Recompiled line name the typed path and never the absolute one — method:ci [files: crates/mds-cli/tests/path_labels.rs]
  • TP-40 (AC-18) Path free helpers for io, notify and tempfile errors drop embedded paths, proven by unit tests with synthetic errors carrying a sentinel path — method:ci [files: crates/mds-cli/src/output.rs]
  • TP-41 (AC-18) On Windows no stdout or stderr line of any surface carries the verbatim path prefix, including the watch banner and the out-dir status line — method:ci [files: crates/mds-cli/tests/path_labels.rs]
  • TP-42 (AC-18) Record the absolute path leak of every census sink on the unfixed tree as the leak baseline — method:local
  • TP-43 (AC-19) With the working directory deleted, a relative out-dir build and watch fail with the core current directory wording, io code and exit 2, writing nothing — method:ci [files: crates/mds-cli/tests/path_labels.rs]
  • TP-44 (AC-19) Auto detect in an unreadable working directory names it as a dot and exits 2 with the io code — method:ci [files: crates/mds-cli/tests/path_labels.rs]
  • TP-45 (AC-19) Observe the dot fallback on the unfixed tree for the relative out-dir build with a deleted working directory — method:local
  • TP-46 (AC-20) Lexical guard rejects display, to_string_lossy and raw error interpolation outside the named helper set, with planted controls and live allowlist entries — method:ci [files: crates/mds-cli/tests/print_discipline.rs]
  • TP-47 (AC-21) Directory mode source maps without out-dir list the same sources as the file mode build of the same nested file — method:ci [files: crates/mds-cli/tests/cli_source_map.rs]
  • TP-48 (AC-21) Observe root relative sources in the directory mode map on the unfixed tree — method:local
  • TP-49 (AC-22) An out-dir argument that is not valid UTF-8 is refused with the io code and exit 2 before any directory is created — method:ci [files: crates/mds-cli/tests/forbidden_paths.rs]
  • TP-50 (AC-22) Two distinct non UTF-8 paths map to distinct graph keys in a Linux unit test that fails on the lossy mapping — method:ci [files: crates/mds-cli/src/watch.rs]
  • TP-51 (AC-23) A symlink planted at the readiness marker temp path does not redirect the marker write, and the victim file keeps its bytes — method:ci [files: crates/mds-cli/tests/cli_watch.rs]
  • TP-52 (AC-24) The fmt directory diff header for a nested file equals the file mode header for the same file — method:ci [files: crates/mds-cli/tests/cli_fmt.rs]
  • TP-53 (AC-24) Sanitized error rendering falls back to plain text when a Display impl returns an error, where the unfixed code panics — method:ci [files: crates/mds-cli/src/output.rs]
  • TP-54 (AC-25) Closing comment records items one and three as unreachable with the reason, and no test is written for them — method:manual
  • TP-55 (AC-26) A symlink planted below the out-dir anchor is refused with the io code naming the typed path, exit 2, and the victim directory stays empty — method:ci [files: crates/mds-cli/tests/anchored_writes.rs]
  • TP-56 (AC-26) The same planted link is refused on watch directory rebuilds, fmt directory rewrites and lint fix directory rewrites — method:ci [files: crates/mds-cli/tests/anchored_writes.rs]
  • TP-57 (AC-26) A symlinked anchor typed as the out-dir is still followed and written through as before — method:ci [files: crates/mds-cli/tests/anchored_writes.rs]
  • TP-58 (AC-26) Observe the planted link being followed and the victim written with exit 0 on the unfixed tree — method:local
  • TP-59 (AC-27) A thread swapping a component below the anchor between a directory and a link while the writer runs a bounded loop never lands a byte in the victim — method:ci [files: crates/mds-cli/src/write.rs]
  • TP-60 (AC-27) Observe a nonzero landing count for a black box CLI swap loop against the phase base binary in the anchored write phase and record the rate — method:local
  • TP-61 (AC-28) A rewrite keeps an existing 0o600 mode, a new file follows the umask, and an injected write failure leaves no temp file behind — method:ci [files: crates/mds-cli/src/write.rs]
  • TP-62 (AC-28) Write funnel pins file and directory fsync for the durable tier on the new primitive and finds no path based permission call — method:ci [files: crates/mds-cli/tests/write_funnel.rs]
  • TP-63 (AC-29) A stale output delete whose parent below the anchor is a planted link is refused, and the victim json survives — method:ci [files: crates/mds-cli/tests/anchored_writes.rs]
  • TP-64 (AC-29) Observe the unfixed stale sibling cleanup deleting the victim json through the planted link — method:local
  • TP-65 (AC-30) The no clobber commit refuses when the target appears after the check and keeps its bytes, while force still replaces — method:ci [files: crates/mds-cli/src/write.rs, crates/mds-cli/src/main.rs]
  • TP-66 (AC-31) A file edited between read and commit is not overwritten by fmt or lint fix, the run exits 2 with the io code and the edit survives — method:ci [files: crates/mds-cli/src/write.rs, crates/mds-cli/tests/anchored_writes.rs]
  • TP-67 (AC-31) A parent swapped after the read cannot make fmt or lint fix write the first file content over a second file — method:ci [files: crates/mds-cli/tests/anchored_writes.rs]
  • TP-68 (AC-32) Out-dir removed during watch is recreated on the next rebuild, a replaced real directory is accepted, and a retargeted one is refused with a restart message — method:ci [files: crates/mds-cli/tests/cli_watch.rs]
  • TP-69 (AC-32) Observe the retargeted out-dir being written through on the unfixed tree — method:local
  • TP-70 (AC-33) On Windows a directory symlink below the anchor is refused as a reparse point with the io code — method:ci [files: crates/mds-cli/tests/anchored_writes.rs]
  • TP-71 (AC-33) Security policy and spec scope the Windows race residual, and the lock file gains no new package — method:local [files: SECURITY.md, spec.md, Cargo.lock, Cargo.toml]
  • TP-72 (AC-33) Five hundred file watch startup and the watch suite wall time stay within 20 percent of the unfixed tree on the same machine — method:local
  • TP-73 (AC-34) Deleting a source keeps hand written json and md siblings with one notice each, in both the incremental and the vars change batch paths — method:ci [files: crates/mds-cli/tests/cli_watch.rs]
  • TP-74 (AC-34) A session written unchanged output is removed with the Removed line, and one the user edited after the write is kept with a notice — method:ci [files: crates/mds-cli/tests/cli_watch.rs]
  • TP-75 (AC-34) Partial stems never lose an md sibling, and an unlink then create save or a branch checkout keeps hand written files — method:ci [files: crates/mds-cli/tests/cli_watch.rs]
  • TP-76 (AC-34) Observe the unfixed watcher deleting the hand written json when its source is deleted — method:local
  • TP-77 (AC-35) Build with out-dir deletes a stale json only when it is exactly the messages array mds writes, keeps any other json, and keeps a stale md with a warning — method:ci [files: crates/mds-cli/tests/dir_build.rs]
  • TP-78 (AC-35) Observe the unfixed out-dir build deleting a hand written json — method:local
  • TP-79 (AC-36) Build file mode, directory mode and watch refuse to replace an existing md whose frontmatter declares type mds, exit 2 naming the typed path, bytes unchanged — method:ci [files: crates/mds-cli/tests/cli_build.rs, crates/mds-cli/tests/dir_build.rs, crates/mds-cli/tests/cli_watch.rs]
  • TP-80 (AC-36) An existing md without that frontmatter is still overwritten as before — method:ci [files: crates/mds-cli/tests/cli_build.rs]
  • TP-81 (AC-36) Observe the unfixed tree overwriting the md module, or record that it does not reproduce and drop the fix — method:local
  • TP-82 (AC-37) Characterization goldens pin exit, stdout, stderr and file bytes for every enumerated lint cell and pass on the unfixed code — method:ci [files: crates/mds-cli/tests/lint_golden*.rs]
  • TP-83 (AC-37) Coverage self check asserts the literal cell count, one golden per cell, no dead golden, fixture markers and a comparator that catches a one byte change — method:ci [files: crates/mds-cli/tests/lint_golden*.rs]
  • TP-84 (AC-37) Each later commit that edits goldens lists the changed cell ids in its body, and they match the cells its criterion names — method:manual
  • TP-85 (AC-38) Lint sink funnel test finds the writer macro, the stdout path and exit only in the sink module and the driver, with planted controls — method:ci [files: crates/mds-cli/tests/print_discipline.rs, crates/mds-cli/src/lint_sink.rs, crates/mds-cli/src/lint.rs]
  • TP-86 (AC-38) One reverify gate serves apply and preview, the tally holds by construction, no expect remains in rendering and JSON diagnostics are moved not cloned — method:ci [files: crates/mds-cli/src/lint.rs, crates/mds-cli/src/lint_sink.rs]
  • TP-87 (AC-38) All existing lint CLI tests pass, and any edited test is listed with the golden cell it now follows — method:ci [files: crates/mds-cli/tests/cli_lint.rs]
  • TP-88 (AC-39) Every non usage exit of json mode, including setup failures, empty and all excluded directories and write failures, prints exactly one JSON document — method:ci [files: crates/mds-cli/tests/cli_lint.rs]
  • TP-89 (AC-39) Stdin with fix and json is refused with the JSON error envelope and exit 2, and fix diff json prints the diffs then exactly one document — method:ci [files: crates/mds-cli/tests/cli_lint.rs]
  • TP-90 (AC-39) Observe the unfixed tree printing no envelope in json mode for a vars error, an empty directory and oversized stdin — method:local
  • TP-91 (AC-40) A single file fix in json mode with a failing write prints an envelope carrying the io error and exits 2, never a clean envelope — method:ci [files: crates/mds-cli/tests/cli_lint.rs]
  • TP-92 (AC-40) Observe the unfixed tree printing a clean envelope and exiting 2 for that failing write — method:local
  • TP-93 (AC-41) Residual findings after a partial fix point at lines and columns of the written file, where the removed block shifts them — method:ci [files: crates/mds-cli/tests/cli_lint.rs]
  • TP-94 (AC-41) Observe pre fix line numbers or the failed to read contents frame in the residual on the unfixed tree — method:local
  • TP-95 (AC-42) Lint fix of a directory holding a partial with an unreachable branch and an unused define applies the fix and reports no unused function — method:ci [files: crates/mds-cli/tests/cli_lint.rs]
  • TP-96 (AC-42) The new core lint under a filename treats an underscore name as a partial, refuses forbidden characters with the io code, and the old API is byte identical — method:ci [files: crates/mds-core/src/lib.rs, crates/mds-core/tests/*.rs]
  • TP-97 (AC-42) The new function is pinned in the API surface test and carries a doctest that runs — method:ci [files: crates/mds-core/tests/api_surface.rs, crates/mds-core/src/lib.rs]
  • TP-98 (AC-42) Observe the unfixed tree rejecting the partial fix or reporting a bogus unused function — method:local
  • TP-99 (AC-43) An oversized file exits 3 in directory human, directory json and single file modes alike — method:ci [files: crates/mds-cli/tests/cli_lint.rs]
  • TP-100 (AC-43) Observe exit 2 for the oversized file in directory human mode on the unfixed tree — method:local
  • TP-101 (AC-44) A fix write failure uses one wording that names the path once across single file, directory, human and json modes — method:ci [files: crates/mds-cli/tests/lint_golden*.rs]
  • TP-102 (AC-45) Truncated reflects the residual list in every mode, false after a fix clears a capped fixable set and true for a capped residual — method:ci [files: crates/mds-cli/tests/cli_lint.rs]
  • TP-103 (AC-46) The diagnostic cap notice appears in human report only mode and every other mode, and is suppressed under quiet — method:ci [files: crates/mds-cli/tests/cli_lint.rs]
  • TP-104 (AC-47) A fix refused because it would change compiled output says so with the io code instead of the reparse wording, and the spec row matches — method:ci [files: crates/mds-cli/tests/cli_lint.rs, spec.md]
  • TP-105 (AC-48) Clean names the file as typed, stdin keeps its lint local label, and quiet output matches the spec status table in every golden cell — method:ci [files: crates/mds-cli/tests/lint_golden*.rs]
  • TP-106 (AC-48) Issue comments record the changed I-16 criterion and the completed core API criterion — method:manual
  • TP-107 (AC-49) A held truncate of the entry for 500 ms at debounce 0 never leaves the output empty and prints one Recompiled line for the final content — method:ci [files: crates/mds-cli/tests/cli_watch_truncate.rs]
  • TP-108 (AC-49) The same hold at the default debounce and with poll interval 0 also never publishes an empty output — method:ci [files: crates/mds-cli/tests/cli_watch_truncate.rs]
  • TP-109 (AC-49) Observe the empty output published during the hold in a Linux soak of a throwaway ref carrying only the new tests, recording the failing line and the rate — method:manual
  • TP-110 (AC-49) Run the truncate tests ten times on macOS after the fix, all exit 0, and record whether the unfixed run reproduced there — method:local
  • TP-111 (AC-50) A held truncate of an imported partial or of the vars file triggers no compile, no error line and no rebuild until the file is written — method:ci [files: crates/mds-cli/tests/cli_watch_truncate.rs]
  • TP-112 (AC-50) In directory mode a held truncate defers the whole batch, so another source changed alongside publishes only after the write — method:ci [files: crates/mds-cli/tests/cli_watch_truncate.rs]
  • TP-113 (AC-51) Truncate and close with no write publishes the empty output within the one second deadline plus margin and prints one notice — method:ci [files: crates/mds-cli/tests/cli_watch_truncate.rs]
  • TP-114 (AC-51) Repeated truncation of the already empty entry every 100 ms for five seconds still publishes the empty output before the stream ends, at poll interval 0 and 1000 — method:ci [files: crates/mds-cli/tests/cli_watch_truncate.rs]
  • TP-115 (AC-51) A source already empty at startup compiles to empty immediately, and deferral prints nothing — method:ci [files: crates/mds-cli/tests/cli_watch_truncate.rs]
  • TP-116 (AC-51) The debounce amendment is in the ledger and no ADR or PF number appears in added tracked lines — method:local [files: crates/mds-cli/src/watch.rs]
  • TP-117 (AC-52) Wait for tap panics on a missing needle within its timeout and names the caller line, proven by a self test that reads the caught panic message — method:ci [files: crates/mds-cli/tests/common/mod.rs, crates/mds-cli/tests/cli_watch.rs]
  • TP-118 (AC-52) The vacuous stderr contains helper has no definition and no call site in any test file, and every wait helper carries track caller — method:local [files: crates/mds-cli/tests/*.rs]
  • TP-119 (AC-53) Duplicate warning counts in I8 and I9 are exact over the finished stream, and the I18 and I20 zero counts wait for a later ordered marker first — method:ci [files: crates/mds-cli/tests/cli_watch.rs]
  • TP-120 (AC-53) Planting the forbidden warning makes each anchored zero count assertion fail, observed once and recorded — method:local
  • TP-121 (AC-54) The quiet error test waits on the diagnostic instead of sleeping, and each remaining fixed sleep is a negative window with a later anchor or is removed — method:ci [files: crates/mds-cli/tests/cli_watch.rs]
  • TP-122 (AC-55) Pure schedule unit tests with synthetic instants prove quiet end, cap end at exactly the cap under an endless stream, message limit and tick due first — method:ci [files: crates/mds-cli/src/watch.rs]
  • TP-123 (AC-55) The former wall clock debounce unit tests run on synthetic instants with no sleep, keeping one real clock smoke test — method:ci [files: crates/mds-cli/src/watch.rs]
  • TP-124 (AC-55) Disabling the cap in the state machine makes the cap proof fail, observed once and recorded — method:local
  • TP-125 (AC-56) The cap binary asserts rebuilds while writes last several caps and an upper bound from the measured writer gaps, with no skip path and a logged conclusive flag — method:ci [files: crates/mds-cli/tests/cli_watch_cap.rs]
  • TP-126 (AC-56) Removing the cap from the product makes the cap binary fail on the rebuild while writing assertion, observed once and recorded — method:local
  • TP-127 (AC-57) Soak validation rejects a test input outside the allowlist, and its skip counter counts one planted skip line in a self check step — method:local [files: .github/workflows/watch-soak.yml]
  • TP-128 (AC-57) The soak summary reports passed, failed and skipped separately, and the workflow stays dispatch only with no new required context — method:local [files: .github/workflows/watch-soak.yml]
  • TP-129 (AC-58) Both watch modes run through the type state phases, watch source has no too many arguments allowance, and the refactor commits touch no test — method:local [files: crates/mds-cli/src/watch.rs]
  • TP-130 (AC-58) The full watch suite and the startup race probe leg pass unchanged after the refactor — method:ci [files: crates/mds-cli/tests/cli_watch.rs, .github/workflows/ci.yml]
  • TP-131 (AC-59) One settle enum is used at all eleven settle sites, with unit tests for rebaseline, mark errored, defer, compile failed and write failed — method:ci [files: crates/mds-cli/src/watch.rs]
  • TP-132 (AC-60) After a directory startup write failure is cleared, an event for the unchanged source writes the output, and startup compiles each source once — method:ci [files: crates/mds-cli/tests/cli_watch.rs]
  • TP-133 (AC-60) Observe the unfixed watcher never writing that output until the content changes — method:local
  • TP-134 (AC-61) A messages template whose json write fails at startup never produces an md file, and writes json once the cause is removed — method:ci [files: crates/mds-cli/tests/cli_watch.rs]
  • TP-135 (AC-61) Observe the unfixed watcher writing json content into the md file — method:local
  • TP-136 (AC-62) Watch to stdout with the reader dropped before spawn prints the stopped watching stdout closed line and exits 0, silent under quiet — method:ci [files: crates/mds-cli/tests/cli_watch.rs]
  • TP-137 (AC-62) Watch to stdout whose reader closes after the first output stops with the same line and exit 0 on the next rebuild — method:ci [files: crates/mds-cli/tests/cli_watch.rs]
  • TP-138 (AC-62) Observe the unfixed watcher exiting 101 for a closed stdout — method:local
  • TP-139 (AC-63) Watch with stderr closed reaches readiness, rebuilds the output file on an edit and keeps running until stopped — method:ci [files: crates/mds-cli/tests/cli_watch.rs]
  • TP-140 (AC-63) Observe the unfixed watcher exiting 101 before readiness with stderr closed — method:local
  • TP-141 (AC-64) Watch to a stdout failing with a non pipe error reports it, keeps watching, and retries the write on a same content save — method:ci [files: crates/mds-cli/tests/cli_watch.rs]
  • TP-142 (AC-64) Observe the unfixed watcher exiting 101 when stdout is dev full in the Linux CI leg, recorded in phase — method:manual
  • TP-143 (AC-65) Final suite counts are at least the baseline for nextest, doctests, npm, wasm pack, pytest and gates, with every moved or removed test listed — method:local
  • TP-144 (AC-65) Per binary CLI counts match the baseline plus listed additions, and skipped counts rise only by listed platform gated tests — method:local
  • TP-145 (AC-66) Print discipline, write funnel, forbidden paths, security, producer discipline and all new guards pass with planted controls and live allowlists — method:ci [files: crates/mds-cli/tests/*.rs]
  • TP-146 (AC-67) The branch diff touches none of the six release surface paths and adds no required check context — method:local
  • TP-147 (AC-67) The lock file package list is unchanged apart from dependency edges, with rustix a direct dependency on Unix only — method:local [files: Cargo.lock, Cargo.toml, crates/mds-cli/Cargo.toml]
  • TP-148 (AC-68) Local WASM size delta against the unfixed tree with the CI command and pinned toolchain is zero or explained, and CI measures at most 850000 bytes — method:local [files: crates/mds-wasm/**, .github/workflows/ci.yml]
  • TP-149 (AC-69) Format check, workspace clippy with warnings denied, probe feature clippy, Windows cross clippy, the rustdoc gate and the 1.88 check all pass — method:local
  • TP-150 (AC-70) Control byte scan passes with a planted byte control, the ledger citation gate passes, and no plan local id appears in added tracked lines — method:local [files: scripts/verify-no-control-bytes.mjs, scripts/verify-ledger-citations.mjs]
  • TP-151 (AC-71) The Windows Rust leg passes, including the pipe tests, the reparse point refusal and the label tests — method:ci [files: .github/workflows/ci.yml]
  • TP-152 (AC-72) Soak before the watch fixes and at the final head runs 50 iterations per leg with identical bounds, and the final runs show zero failures and zero skips — method:manual [files: .github/workflows/watch-soak.yml]
  • TP-153 (AC-72) Soak summaries carry the sha of the ref they measured, and both legs ran the same test binaries and filters — method:manual
  • TP-154 (AC-73) Changelog has one entry per issue with breaking leads for streams, paths, anchors and lint json, and spec, security policy and readme match the code — method:local [files: CHANGELOG.md, spec.md, SECURITY.md, README.md]
  • TP-155 (AC-73) Knowledge bases for the CLI, lint and fmt are refreshed in the last branch commit and reviewed against the final code — method:manual [files: .devflow/features/**]
  • TP-156 (AC-74) Follow up issues exist and are linked, the roadmap has the new slot, and the issue comments and body edits are posted — method:local
  • TP-157 (AC-74) The PR body has exactly one closing line for each of the eleven issues and GitHub links all eleven — method:local
  • TP-158 (AC-75) Black box QA runs the twelve user journeys against the final build and records exit codes, streams and file states — method:manual
  • TP-159 (AC-64) A failed rebuild write or a non pipe stdout error during a watch session still exits 0 when the session is stopped with SIGINT — method:ci [files: crates/mds-cli/tests/cli_watch.rs]
  • TP-160 (AC-51) Pure schedule unit tests prove the empty hold deadline is fixed at the first empty observation and never extended by later events — method:ci [files: crates/mds-cli/src/watch.rs]

Closes #157

Closes #389

Closes #390

Closes #160

Closes #309

Closes #173

Closes #380

Closes #381

Closes #397

Closes #256

Closes #257

dean0x and others added 30 commits September 29, 2026 15:57
Characterization goldens for `mds lint`, added before any lint or stream
change so every later commit that alters lint output has to regenerate
them and name the cells it changed. They deliberately pin TODAY's output,
including output that is known to be wrong (a clean JSON envelope printed
before a failed write, residual diagnostics rendered against the pre-fix
source, a partial module's safe fix rejected, no cap notice in report-only
mode, the stdin `--fix --format json` refusal as plain text).

What is pinned, per cell: exit code, exact stdout, exact stderr and the
source file's bytes after the run (unchanged / rewritten bytes / missing).
Matrix: input (stdin with cwd = the fixture dir so mds.json applies, or a
relative `x.mds`) x format (human, json) x --quiet (off, on) x fix mode
(none, --fix, --fix --check, --fix --diff, --fix --check --diff) x 13
fixtures: clean, warn, error (mds.json raises unused-variable), fixed (an
always-false @if), partial (fixed + an unfixable warning after the removed
block), rejected (the reverify gate refuses it), cap (1,001 unused keys),
cap-fixable (1,001 empty @if blocks), analysis-fail (unterminated @if),
limit (10 MiB + 1, generated at runtime), config-fail (mds.json = `{`),
write-fail (0o555 dir, unix; skipped with a reason where a read-only dir
still accepts files) and partial-module (`_p.mds`).
Cells: 520 on unix (260 stdin + 260 file), 480 on Windows (240 + 240; no
write-fail cells). One test per (input, fixture) group.

Normalization, on the recorded streams only: every spelling of the cell's
temp dir (as created, canonical, with/without /private, with/without a
verbatim prefix, doubled or forward-slash separators) -> `$TMP`, counted in
the golden; `.mds-tmp-` + six alphanumerics + `.tmp` -> `.mds-tmp-RANDOM.tmp`,
counted; on Windows only, separators -> `/` (an escaped doubled backslash
first). No sorting, trimming or line-ending rewrite. The child runs with a
cleared environment plus PATH (and SystemRoot/TEMP on Windows) and
NO_COLOR=1, piped streams, relative arguments. Fixture dirs live under
/tmp on unix so a leaked absolute path is never wrapped by the renderer at
machine-dependent positions.

Path-leak baseline: 4 `$TMP` replacements (and 4 temp-name replacements)
over all 520 cells, all in the four file-mode `--fix` write-fail cells.

Storage: 126 deduplicated goldens plus a cell -> golden table, generated
into tests/lint_golden/single.rs as single-line literals (Debug-escaped,
braced escapes only) via `MDS_GOLDEN_PRINT=1 cargo nextest run -p mds-cli
--test lint_golden golden_print_mode --no-capture`, which prints and never
writes files. Streams over 16 KiB are stored as a digest: length, line
count, FNV-1a-64, the first 40 lines (at most 4 KiB) and the last 20 lines
(at most 2 KiB). Golden data: 125,778 bytes (capped at 1 MiB by a
self-check).

Self-checks: literal cell counts per platform; every cell maps to exactly
one golden, no golden is unreferenced or duplicated; storage bounds, no
control character but newline and no backslash in any golden; a comparator
that detects a one-byte change in exit, stdout, stderr, file bytes and
both replacement counts (inline and digest) and reports only the cell id,
lengths and the first differing line with three lines of context; the
normalizer's tempdir and temp-name rules; fixture markers checked against
the tool rather than the goldens.

Co-Authored-By: Claude <noreply@anthropic.com>
Add the directory cells of the lint characterization matrix: `mds lint ... d`
(relative, cwd = the fixture's parent) x human/json x --quiet off/on x the
five fix modes x 16 directory fixtures: the 13 outcome fixtures placed inside
d/, plus an empty tree, an all-excluded tree (d/node_modules/a.mds only) and
a mixed tree. 320 cells on unix, 300 on Windows (write-fail is unix-only);
with the stdin and file cells the whole matrix is 840 / 780.

Each directory cell runs twice, creating the fixture files in opposite
orders, and the two normalized runs must be byte-identical before the result
is compared with its golden. A directory golden records the exit code, exact
stdout, exact stderr and the state of every file under the fixture directory
(unchanged, new bytes, or missing), sorted by relative path. Normalization,
storage, digests and the generator are shared with the single-file cells;
single.rs is unchanged, and regenerating it still reproduces it byte for
byte.

Fixtures:
- mixed: files with every outcome (clean, warning, fixable error, partial
  fix, unterminated @if, one byte over the size limit), a nested mds.json
  raising unused-variable to an error, a nested malformed mds.json, names
  whose byte order differs from path-component and case-insensitive order
  (B.mds, _unterminated.mds, api-utils.mds, api/x.mds), a hidden directory,
  node_modules and a non-.mds file.
- write-fail, directory form: d/ at 0o555 holding the fixable x.mds,
  unreadable.mds at 0o000, and unreadable/ at 0o000 holding y.mds. It is the
  only unix-only group, so the chmod-000 cases live here to keep the planned
  counts. The permissions are probed after they are set; when they do not
  hold (euid 0, a filesystem that ignores mode bits) the cell is skipped with
  a printed reason.

Goldens: 108 deduplicated directory goldens holding 128,293 bytes of golden
text; 254,071 bytes across both tables (cap 1 MiB). Temp-directory
replacements over the directory cells: 4, temp-name replacements: 4, all in
dir/{human,json}/{loud,quiet}/fix/write-fail. That is the directory-mode
path-leak baseline.

Today's output is pinned deliberately, including output that is known to be
wrong: an over-size file exits 2 and is counted "with errors" in human
directory mode (3 and "resource-limited" in JSON); a directory-mode write
failure prints the path twice and leaks the absolute temp path; empty and
all-excluded trees emit no JSON envelope; a .mds file inside an unlistable
directory is skipped without a word (#437).

Self-checks: literal counts (840 / 780 by cfg, and per input), exactly one
golden per cell across both tables, no dead or duplicate golden, fixture
markers checked against the tool (positive controls for the skipped entries
and the permission layout, at most one @define per fixture), storage bounds
over both tables, and one-byte mutation detection for the directory
comparator and the double-run check. The no-backslash rule now covers every
golden that a cell running on Windows maps to; a golden that only unix-only
cells map to may hold a backslash only as JSON's escaped quote, because the
directory JSON write-failure message quotes the temp path.

Co-Authored-By: Claude <noreply@anthropic.com>
Reduce duplication between the single-file/stdin and directory runners
in lint_golden/harness.rs, with no behavior change:

- Cell::id/DirCell::id and Cell::args/DirCell::args shared their
  "format/quiet/fix-mode/fixture" id suffix and their "lint" +
  format/quiet/fix flags via new variant_id and lint_args helpers.
- group_cells/dir_group_cells shared their (format, quiet, fix mode)
  cartesian product via a new variant_combinations helper.
- compare/compare_dir shared the ExpectedOutputs/ObservedOutputs
  construction from Golden/DirGolden and Observed/DirObserved via new
  expected_outputs/dir_expected_outputs/observed_outputs/
  dir_observed_outputs helpers, following this file's existing
  xxx/dir_xxx naming convention (golden_data_bytes/
  dir_golden_data_bytes, golden_strings/dir_golden_strings, etc.).

Generated data files (single.rs, dir.rs) are untouched and confirmed
byte-identical to a fresh MDS_GOLDEN_PRINT=1 regeneration.

Co-Authored-By: Claude <noreply@anthropic.com>
Two ways the characterization goldens could mislead, closed without
changing any golden (single.rs and dir.rs are untouched; no cell id
changes):

- An mds.json above the fixture directory applied to every cell.
  mds lint walks every ancestor for the nearest mds.json, and on unix
  the fixture directories live under the shared, world-writable /tmp,
  so a stray /tmp/mds.json turned every cell into a golden diff with no
  hint at the cause (with one raising unused-variable to error:
  "20 of 20 cells differ ... exit: expected 1, actual 2"), and during
  generation it would have been baked into the goldens. fixture_dir()
  now stops with the offending path; ancestor_config() does the lookup
  on the canonical path, as the product does, and a new test plants an
  mds.json one level up as its positive control.

- A skipped cell passed silently. When a permission precondition does
  not hold (euid 0, or a filesystem that ignores mode bits) the 60
  write-fail cells and the write-fail markers were skipped with a line
  on captured stderr only, so a green run hid their loss. Skips are now
  announced as a SKIPPED line and, under GitHub Actions, a job-summary
  warning with the skipped/total count (the cli_watch.rs convention),
  and a group in which no cell ran or was skipped fails instead of
  passing with nothing compared.

Co-Authored-By: Claude <noreply@anthropic.com>
The watch suite waited on stderr with a helper that returned whatever it
had when the time ran out, so a line that never appeared was reported by
a later assertion as if it were a final answer, and several counts and
absences were read from a snapshot of a live pipe.

tests/common/mod.rs:
- wait_for_tap and wait_for_tap_count panic on timeout; #[track_caller]
  and the message opens with the caller's file:line:column and ends with
  what the tap held. wait_for_tap_count is the former cli_watch.rs
  wait_for_stderr_count, moved and renamed (it polls any pipe tap).
- poll_tap_until: the non-panicking poll both are built on, for the cap
  test, which treats "no rebuild yet" as data.
- ORDER_MARKER_SOURCE / ORDER_MARKER_LINE: a source whose compile fails
  with one diagnostic. The watch loop finishes a rebuild before it takes
  the next event, so once the marker's diagnostic is on the tap every
  earlier rebuild's lines are too: an ordered anchor for exact counts.
- tap_reader is public so the waits can be tested without a process;
  ChildGuard::wait_status is #[track_caller].

tests/cli_watch.rs:
- wait_for_stderr_contains_str is gone; its 21 call sites use
  wait_for_tap, except the cap test, which uses poll_tap_until.
- Every wait_* helper is #[track_caller].
- I8 and I9 read their exact final counts with finish_text behind the
  order marker; I18's two zero counts wait for the Compiled to /
  Recompiled line that follows the warning; I20's zero waits for the
  marker, since --quiet silences every status line. The burst test and
  the single-status-line test take their exact counts the same way.
- The 500 ms sleeps: the three that stood in for an event are waits on
  it (quiet error, compile error, missing partial at startup); the two
  first windows of the error-settle tests now start from the first error
  they measure; the remaining four are negative windows, commented, each
  with a later positive anchor.
- Self-tests catch the waits' panics with catch_unwind (no panic hook)
  and assert the message names this file's line of the call.

Mutation controls, not committed: an extra duplicate-warning emit at the
rebuild sites of watch.rs fails I8, I9, I18 and I20 at their count
assertions; one at the file-mode startup site fails I18's startup zero
and I20; dropping #[track_caller] from the waits fails both panic
self-tests. Product source is unchanged.

Co-Authored-By: Claude <noreply@anthropic.com>
When every attempt of the watch cap test is inconclusive it skips by
returning early. cargo test counts that as a pass and never shows a
passing test's stderr, so the skip was invisible in CI logs and the
watch soak tallied it as a pass.

tests/cli_watch.rs:
- The writer thread records when each write completed; every attempt
  logs a gap breakdown on stderr: write count and span, max / median /
  p99 gap, gaps at or over the window, and when the first rebuild was
  seen with the largest gap before it. The precondition still judges the
  same metric, the largest gap measured from the writer's start, so the
  test behaves as before.
- A skip goes through record_skip: the SKIPPED line on stderr (kept),
  one line appended to the file MDS_TEST_SKIP_LOG names (a set variable
  that cannot be written fails the test, since whoever set it is
  counting), and the job-summary warning under GitHub Actions. The line
  carries every attempt's largest gap and the last attempt's breakdown.

.github/workflows/watch-soak.yml (still workflow_dispatch only; no new
job, both legs keep identical bounds):
- A `test` input, allowlisted to cli_watch, cli_watch_cap and
  cli_watch_truncate and validated beside `iterations`, replaces the
  hard-coded `--test cli_watch`; a value outside the allowlist, or a
  test file absent at the dispatched ref, fails before the build.
- MDS_TEST_SKIP_LOG is set per iteration; an iteration that passed but
  logged a skip is SKIP, tallied apart from pass and fail in summary.txt
  and the step summary, with its log kept in the artifact.
- The tally lives in one shell helper sourced by the soak and by a new
  self-check step, which plants one skip line and asserts it counts as
  exactly one skipped iteration before anything is built.

Checked locally: the three new run blocks, extracted verbatim, pass bash
-n; the self-check passes and fails when the helper counts a skip as a
pass; the loop, driven by a fake cargo, reports PASS, SKIP, FAIL, PASS
with both summaries; the validation accepts cli_watch and rejects
cli_lint, an empty value and a value with a newline (printed on one
line). A temporary change that forced the skip path appended exactly
one line to MDS_TEST_SKIP_LOG, which the tally counted as one SKIP.

Co-Authored-By: Claude <noreply@anthropic.com>
The earlier #381 anchors left four count checks, and one negative window,
unable to see the failure they guard; seven other zero-count or absence
checks read the stream the same unordered way.

- I16, I17 and I19 stopped the watcher the moment the expected count was
  reached, and I18's final count stopped at its second Recompiled line: a
  surplus warning printed just after was cut off by the kill. Each final
  count is now read behind the order marker and gains a Recompiled control.
  I16's startup and first-rebuild counts are anchored on the line file mode
  prints after them (Compiled to, Recompiled).
- watch_import_removal_stops_tracking_dep could not observe the rebuild it
  forbids: the entry rendered the same text either way, and a rebuild that
  changes nothing is silent. Once it drops the import, the entry now
  @includes an empty module, so every compile of it warns; the test runs
  without -q and without the idle tick, and counts that warning across the
  helper edit behind the marker.
- R3 read its absences from a live snapshot. The three startup
  no-spurious-rebuild tests, both idle tests and the 500-file idle test read
  a zero after a fixed window, with nothing proving the loop was still live.
  Each now writes the order marker after its window and reads behind it.
- common: the order marker's line can print several times for one edit;
  wait for it, never count it.
- watch-soak.yml: a rejected iterations value is printed with %q, as a
  rejected test value already was. Echoed raw, a value holding a newline
  started a line the runner reads as a workflow command.

Mutation controls (product source restored and identical to bff9843 after
each): a delayed second vars-file warning after every rebuild fails the new
I16, I17, I18 and I19 at their final counts, while the previous I17, I18
and I19 passed; keeping a removed import tracked fails the import-removal
test (previous passed); a late .tmp- status line fails R3 (previous
passed); a loop that stalls after readiness fails all six window tests at
the marker wait (previous passed).

Co-Authored-By: Claude <noreply@anthropic.com>
… exit funnel

`eprintln!` panics when stderr is gone, so a run whose stderr reader had
exited ended with exit 101 whatever its verdict. This adds the machinery
the #157 conversions build on, and moves main.rs and the error and
warning helpers onto it:

- output.rs: `ewrite!` / `ewriteln!` over `write_stderr_fmt`, which never
  panics. A closed pipe records a sticky stderr-closed fact and drops every
  later stderr write; any other failure records a sticky I/O-failed fact.
  The facts live in `OutputState` (one atomic); everything that decides
  from them takes `&OutputState`, so unit tests build their own.
- `StdoutOutcome { Written, Closed, Failed }` and `write_stdout`, which
  writes and flushes and is Written only when both succeed. Its callers
  arrive with the build and fmt conversion.
- `final_exit_code(verdict, &OutputState, ExitPolicy)`: a closed pipe never
  changes the code; under Batch any other output failure lifts it to
  max(verdict, 2); WatchSession keeps the verdict. `exit(verdict)` is the
  funnel, and `main` now ends in it.
- main.rs: its 8 stderr prints and 6 `process::exit` calls go through the
  writer and the funnel.
- `eprint_error` and `eprint_warning` write through `ewriteln!`.
- `render_error_sanitized` no longer panics when a Display fails. The
  sanitized wrapper renders every text surface (code and url now included)
  without `to_string()`: a failing optional surface is dropped, a failing
  message becomes a placeholder. The frame renders through `fmt::Write`,
  and a render that fails part-way falls back to escaped plain text.
- print_discipline.rs lists `ewriteln!` / `ewrite!` with the print macros,
  so every converted site stays under the guard, and adds per-file site
  floors for main.rs (11) and output.rs (7): with the macros unlisted, the
  crate-wide floor still passed (98 >= 80) while ten sites had left it.

Tests: tests/broken_pipe.rs runs `check` (file, broken file, stdin,
directory), `init` and `lint --format yaml` with stderr as a pipe whose
reader is dropped before spawn, each beside an open-stderr control, and
asserts the exit code, stdout and the files written. Unit tests pin the
writer's sticky states through an injected sink, the stdout outcome
mapping, a final_exit_code table for both policies, and the renderer
fallback.

RED at the parent: all six broken_pipe rows exited Some(101) with stderr
closed while their open-stderr controls passed; the renderer tests
panicked in to_string ("a Display implementation returned an error
unexpectedly") and in format! ("a formatting trait implementation
returned an error when the underlying stream did not").

Co-Authored-By: Claude <noreply@anthropic.com>
print_discipline scans the stderr writer macros by name, but not the
function they expand to. `write_stderr_fmt` is crate-visible and takes a
`format_args!`, which is not a print site, so a direct call wrote to
stderr with nothing it interpolated scanned, and so would every site of a
new macro built on it under a name the guard does not list. A planted
`output::write_stderr_fmt(format_args!("RED {}\n", dir.display()))` in
run_check_directory passed all 12 print_discipline tests: the per-file
floors only see a site leave a floored file, and main.rs kept its 11.

- print_discipline.rs: `the_stderr_writer_fn_is_called_only_by_the_writer_macros`
  fails on any mention of `write_stderr_fmt` outside its `fn` definition
  and the bodies of the `macro_rules!` definitions PRINT_MACROS names, a
  renamed `use` of it included, and asserts it found the definition and
  the writer macros' bodies in output.rs.
  `the_writer_fn_guard_flags_direct_calls_aliases_and_unlisted_macros`
  pins the accepted shapes, the reported ones (a direct call, a renamed
  import, an unlisted macro built on it) and that comments, strings and
  longer identifiers are not mentions. `matching_delim` extends
  `matching_paren` to `[]` and `{}` for the macro bodies. The module doc
  lists the new coverage and records renaming a print macro on import as
  an accepted limit, the same shape as a renamed sanitizer.
- output.rs: the module doc names the writer macros as the stderr choke
  point and eprint_error as the error-report choke point; two test
  comments said eprint_warning calls eprintln!, where it calls ewriteln!.

Controls: with the planted call the new guard fails naming main.rs:396
while the 12 existing tests pass; accepting every macro body fails the
self-test (stray [3, 5] instead of [3, 5, 8]); a writer name that does
not exist fails the non-vacuity check (found 0). No product behaviour
changes; the lint goldens are unchanged.

Co-Authored-By: Claude <noreply@anthropic.com>
…mmary

GitHub starts every run: block as `bash --noprofile --norc -eo pipefail`,
so the soak loop's plain `cargo test` call followed by a read of `$?`
ended the whole soak at the first failing iteration, before summary.txt
and the step summary were written; the loop's own `set -uo pipefail`
cannot clear -e. The loop body now lives in one sourced file, captures
each exit code with `|| rc=$?`, runs every iteration, writes both
summaries, and fails the step only at the end. The self-check now
drives that real loop under the runner's exact flags with a planted
cargo stand-in (pass, fail, skip, pass, zero tests) and fails against
the old loop shape. The `filter` input is validated to A-Z, a-z, 0-9,
_ and :, rejected values are printed with %q, and an iteration that
runs no test (a filter matching nothing, or no test count at all)
counts as a failure. The `iterations` check rejects over-long values,
which `[` could not compare and which ran zero iterations. Proven live
on a throwaway ref before this commit: smoke passed, a `filter=--list`
dispatch failed at input validation, and a 50-iteration soak passed on
both legs.

Co-Authored-By: Claude <noreply@anthropic.com>
mds build and mds fmt printed through std's eprintln!/print!, which panic
when the write fails: a closed stderr or a closed stdout ended the run with
exit 101, and a directory build stopped at its first status line, so the
files after it were never written.

- build.rs and fmt.rs print every status line through output::ewriteln!
  and end the run through output::exit.
- write_output's stdout arm writes through output::write_stdout. A closed
  stdout is not an error: nothing more is written and the verdict stands.
  Any other stdout failure is mds::io.
- fmt's own write_stdout/print_diff are gone; its filter output and diffs go
  through output::write_stdout the same way.
- StdoutOutcome::into_batch_result maps an outcome for a run that ends on
  its own. It records nothing; the error reaches the exit code through the
  caller.

Tests:
- broken_pipe.rs closes stdout or stderr per row. New rows: build to stdout
  from a file and from stdin (stdout closed), build a file, with a source
  map, a directory that compiles and one with a broken file (stderr closed,
  every output still written), fmt a file and fmt --check (stderr closed),
  fmt stdin, --diff and --check --diff on a file and a directory (stdout
  closed). The build and fmt stderr rows and both build stdout rows exited
  101 before this change. The fmt stdout rows passed already: fmt's old
  helper treated a closed pipe as success, and they now guard its removal.
- Two Linux-only rows put stdout on /dev/full: build -o - and fmt - must exit
  2 with one mds::io error naming stdout. They are ignored off Linux.
- cli_fmt.rs: the closed-pipe test drops the reader before the spawn,
  asserts exit 0 and compares against an open-pipe run that receives the
  formatted text.
- print_discipline.rs: per-file floors for build.rs (30) and fmt.rs (11);
  the allowlist entry for build.rs's old print! of the compiled output is
  deleted.

mds watch -o - shares write_output: when its stdout reader goes away it now
keeps watching instead of panicking. Stopping the session there is the
watch half of #157.

Lint goldens are unchanged.

Co-Authored-By: Claude <noreply@anthropic.com>
A failed write, a failed mkdir and an unreadable stdin were uncoded
miette! errors, so build, check, fmt and init exited 1 for them - the
template-error code. A stale sibling that could not be removed only
warned (exit 0), and stdin over the 10 MiB cap exited 1 (2 under lint)
where a file over the same cap exits 3.

- atomic_write_file returns MdsError::Io (mds::io, exit 2) with its
  wording unchanged; so do an output directory that cannot be created, a
  stale sidecar or sibling that cannot be removed (now an error), and a
  stdout write that fails for another reason than a closed pipe.
- read_stdin: over the cap is mds::resource_limit (exit 3); a read that
  fails and bytes that are not UTF-8 are mds::io (exit 2). lint's stdin
  path exits with the code's class (its human error is unchanged).
- output::note_io_failure records an I/O failure for the exit funnel, and
  output::eprint_io_failure reports and records it. Directory builds and
  fmt <dir> use it and carry on with the other files, exiting 2; a
  template error alone still exits 1. write_output records nothing.
- main parses with Cli::try_parse and prints clap's help, version or
  usage error under the same rule: a closed pipe changes nothing, a
  failed stdout write is mds::io and exits 2.
- watch keeps its stale-sibling warning text (a rebuild's failure does
  not change how a session exits); lint.rs and watch.rs change only
  where atomic_write_file / read_stdin / probe_and_remove_stale changed.

Tests updated from exit 1 to exit 2 on a write failure:
- cli_commands.rs init_force_symlink_target_refused_plain_path_created
- cli_commands.rs init_dangling_symlink_refused_without_force
- cli_build.rs build_refuses_every_output_route_that_lands_on_the_entry
  (symlink at the -o path)
Strengthened from "not 0" to exit 2 and mds::io:
- cli_build.rs build_o_write_failure_preserves_existing_output_no_temp_residue
- dir_build.rs dir_build_write_failure_preserves_existing_outputs
- dir_build.rs dir_build_source_map_sidecar_symlink_target_rejected
- security.rs stdin_size_limit_rejects_oversized_input (now exit 3)
- build.rs unit read_stdin_holds_at_most_the_cap_plus_one_byte

New tests: broken_pipe.rs rows for an unwritable output (build file,
build dir, fmt file, fmt dir, lint --fix, init), stdin that cannot be
read (a directory handle on unix, a write-only handle on Windows), stdin
that is not UTF-8, stdin over the cap (build, check, fmt, lint, lint
--format json) and exactly at the cap, clap's --help and --version with
stdout closed and a usage error with stderr closed, and --help into
/dev/full (Linux only). dir_build.rs: a template error plus a failed
mkdir exits 2 (a template error alone exits 1), and a stale sibling that
cannot be removed exits 2. build.rs unit: a stale map that cannot be
removed is mds::io.

print_discipline.rs floors: build.rs 30 -> 27 (four prints became
mds::io reports; one unit-test skip line counts), output.rs 7 -> 6 (the
stale-sibling warning moved to its watch caller).

Lint goldens changed only in these cells (goldens 49, 120, 121 of
single.rs; dir.rs byte-identical):
- file/human/loud/fix/write-fail, file/human/quiet/fix/write-fail,
  file/json/loud/fix/write-fail, file/json/quiet/fix/write-fail
  (stderr gains the mds::io code line)
- stdin/human/{loud,quiet}/{report,fix,fix-check,fix-diff,fix-check-diff}/limit
  and stdin/json/{loud,quiet}/report/limit (exit 2 -> 3, stderr now
  mds::resource_limit)

Docs: spec.md section 5 (a "Streams and I/O failures" rule, the mds::io
and mds::resource_limit rows), 7.2 (continue-on-error, stale-flip
cleanup, --quiet, output writing), 7.4, 7.6 and 7.9; README exit codes;
CHANGELOG BREAKING (CLI) entry. The build.rs "documented limitation"
comment is gone: the stale-unlink failure is now an error.

Co-Authored-By: Claude <noreply@anthropic.com>
exit_after_clap_output's match on the print-and-flush result used a
guarded Err arm plus a catch-all `Ok(()) | Err(_) => {}` to do nothing on
success and on a closed pipe. An `if let Err(e) = printed { if e.kind()
!= BrokenPipe { ... } }` says the same thing without the empty arm.

Reviewed the rest of the #157 stream-handling diff (output.rs, build.rs,
fmt.rs, and the broken_pipe/cli_build/cli_commands/cli_fmt/dir_build/
security test files) for slop, duplication and unclear naming; found
none worth changing. Behaviour, exit codes, and message wording are
unchanged.

Co-Authored-By: Claude <noreply@anthropic.com>
…tdout stays closed

A directory build, check or fmt reported a source it could not read as
mds::io but exited 1, while the same file given alone exits 2, and spec
sections 5 and 7.9, the README and the fmt module doc promise 2. Each
per-file failure now goes through output::eprint_file_failure, which
records an I/O failure for the exit code when the error is in the
exit-2 class (mds::io, mds::file_not_found, mds::not_mds) and then
reports it. A directory run therefore exits 2 for a source that cannot
be read, a path carrying a forbidden character (#265) or an @import of
a file that does not exist, as that file alone does; a run whose
failures are only template errors or resource limits still exits 1.
Four walker tests in forbidden_paths.rs and one in security.rs pinned
exit 1 for the forbidden-character refusal in directory mode; they now
expect 2.

write_stdout now remembers a closed stdout: once a write hits a closed
pipe, OutputState records it and every later write returns Closed
without writing. A stdout that fails for another reason is recorded
too, and a repeat of that failure returns the new
StdoutOutcome::FailedAgain, which a batch run does not report again:
mds fmt --diff <dir> into a full device prints one mds::io frame, not
one per file, and counts every file whose diff was lost as failed.

A stale .map sidecar that could not be read (its metadata, open or read
failing for a reason other than not-found) was reported as "not a
tool-generated SMv3 map" and left in place with exit 0. It is now
mds::io, "cannot read stale map <path>: <cause>", exit 2.

The oversized-stdin message names the cap it enforces, 10 MiB, instead
of 10 MB. Golden 49 of lint_golden/single.rs changed (message text
only); its cells:
stdin/human/loud/report/limit, stdin/human/loud/fix/limit,
stdin/human/loud/fix-check/limit, stdin/human/loud/fix-diff/limit,
stdin/human/loud/fix-check-diff/limit, stdin/human/quiet/report/limit,
stdin/human/quiet/fix/limit, stdin/human/quiet/fix-check/limit,
stdin/human/quiet/fix-diff/limit, stdin/human/quiet/fix-check-diff/limit,
stdin/json/loud/report/limit, stdin/json/quiet/report/limit.
lint_golden/dir.rs regenerated byte-identical.

The CHANGELOG #157 entry no longer says a closed stdout used to panic
under mds fmt (fmt already tolerated it), names the directory-mode
change, and scopes its "every other I/O failure" to the failures it
lists, as spec sections 5, 7.2, 7.4 and 7.9 and the README now do: an
unreadable mds.json stays an uncoded exit 1. The closed_pipe() test
helper moves to tests/common/mod.rs, shared by broken_pipe.rs and
cli_fmt.rs.

Co-Authored-By: Claude <noreply@anthropic.com>
…iled stdout write

mds lint printed its status lines, its directory summary and its own
usage errors with eprintln!, so a closed stderr ended a lint run with a
Rust panic and exit 101: `mds lint ok.mds` (Clean:), `mds lint <dir>`
(the summary), `mds lint --fix` (Fixed:), `mds lint --fix --check -`
(Would fix:). Its local write_stdout treated a closed pipe as success,
but every caller dropped any other stdout failure, so a clean
`mds lint --format json` into a failing stdout exited 0 with its report
lost.

Every stderr print in lint.rs now goes through the non-panicking stderr
writer, and every exit through the exit funnel. The local write_stdout
is gone: the JSON report, the --diff output and the fixed source are
written with output::write_stdout, and lint handles the outcome in one
place. A closed stdout keeps the verdict. The first other failure is
reported as one mds::io error naming stdout and recorded, so the funnel
lifts the exit code to at least 2; a repeat is not reported again, and
a resource limit keeps its 3.

broken_pipe.rs gains the lint rows: stderr closed (a clean file, a file,
a directory and stdin with warnings, --fix, --fix --check -) and stdout
closed (--format json on a file, a directory and stdin, --fix -,
--fix --diff) keep their verdicts; on Linux, stdout on /dev/full makes a
clean JSON report of a file or a directory and --fix - exit 2, keeps 3
for a file over the size cap, and reports two lost diffs once.

The lint goldens are unchanged. README and the #157 CHANGELOG entry now
cover mds lint.

Co-Authored-By: Claude <noreply@anthropic.com>
mds fmt --diff <dir> counts a file whose diff a stdout failing other
than by a closed pipe lost as failed. mds lint --fix --diff <dir>
reported the same failure once and lifted the exit code, but left the
file in its findings bucket, so its summary read "2 clean, 0 with
warnings, 0 with errors, 0 resource-limited" above exit 2.

Decision: one rule for both, the one every directory run already
applies to a file whose output fails. A file whose own diff a failing
stdout lost counts as failed: "N failed" under fmt, "with errors" under
lint, which is where lint already counts a --fix rewrite that fails.
The failure is still reported once for the run. A closed stdout loses
nothing and moves no file. Run-level writes (lint's JSON envelope, the
single-file and stdin output) belong to no one file; the recorded
failure lifts their exit code as before. fmt already followed the rule
and is unchanged.

lint's emit_stdout now says whether a failing stdout lost its text, and
both directory emitters, human and JSON, count such a file under "with
errors".

broken_pipe.rs: every unix now has a stdout failure that is not a
closed pipe, a regular file the child may not grow (file-size limit 0,
SIGXFSZ ignored, so writes fail with EFBIG), beside Linux's /dev/full.
The lint failing-stdout rows run on it, so they run on macOS too, and
were renamed from "into a full device" to "into a failing stdout". New
rows pin the rule for fmt and for both lint directory emitters, and
that a closed stdout moves no lint directory file, for both emitters.
The fmt /dev/full directory row became the fmt case of the shared rule.

spec: the "Streams and I/O failures on the CLI" block names mds lint,
the directory counting rule, and the one exception to mds::io (a
directory rewrite failure under --format human prints "error
writing"); lint's "with errors" bucket and its exit-2 row list these
I/O failures. README dates lint's old exit 0 and states the counting
rule; the #157 CHANGELOG entry scopes lint's mds::io rewrite report to
a file argument and adds the counting rule.

The lint goldens are unchanged.

Co-Authored-By: Claude <noreply@anthropic.com>
…- loses its reader

mds watch printed its status lines with std's eprint macros, which panic
when the write fails: a closed stderr ended the session with exit 101 at
its first line, before it was watching. Every status line now goes
through the CLI's stderr writer, which never panics; with stderr closed
the session reaches readiness, rebuilds on every edit, and exits 0 at
Ctrl+C. `ewrite!` gets its first caller (the --clear sequence).

With -o -, stdout is the session's product. A write that finds its
reader gone (a closed pipe) now ends the session: one
`Stopped watching (stdout closed).` line, suppressed by --quiet, and
exit 0, at startup or on a rebuild. Since the stream writer landed, such
a session kept watching and printed `Recompiled <stdout>` for writes that
went nowhere. The session reads each stdout outcome itself instead of
through the batch reading, which takes a closed pipe and a repeated
failure for success:

- the first stdout failure for another reason is reported once as
  mds::io naming stdout, and watching continues;
- a repeat of it is not reported again, is not announced as
  `Recompiled`, and is not recorded as written, so the content-dedup
  baseline keeps what was last written and a save of the same text
  writes again.

Exit policy: a watch session that goes live (every watch armed, every
baseline captured) records it in the output state, and the exit funnel
then applies the watch-session rule, so an output failure during the
session (a failed rebuild write, a stdout or stderr that fails other
than by a closed pipe) never changes the Ctrl+C exit. A session that
ends before going live keeps the batch rule. The go-live point is one
function, shared by file and directory mode, which switches the policy
before it writes the readiness marker. The output state stays private
to output.rs.

Tests (cli_watch.rs): stdout's reader gone before the spawn stops the
session with the line and exit 0, silent under --quiet (open-pipe
control); a reader that goes away after the first output stops it at the
next rebuild; stderr closed from the start keeps watching in file and
directory mode and exits 0 at Ctrl+C (open-stderr control); a stdout
file the child may not grow is reported once, a repeat claims no
rebuild, and a same-text save after room is made writes the output; a
rebuild write that fails and a stderr that fails other than by a closed
pipe leave the Ctrl+C exit at 0 (control: that stderr lifts mds check to
2). Unit tests pin the session's reading of each stdout outcome and the
policy switch. The file-size-limit helper moves to tests/common so
cli_watch and broken_pipe share it; the stream file is opened at its end
rather than for appending, since macOS checks the limit against the
descriptor offset. print_discipline gains a watch.rs site floor (18).
README and the CHANGELOG #157 entry describe the watch behaviour.

Co-Authored-By: Claude <noreply@anthropic.com>
…writer and the funnel

print_discipline gains the two lexical bans the stream rule rests on.

no_raw_print_macro_outside_the_writer: println!, print!, eprintln!,
eprint! and dbg! panic when their write fails, which is how a closed or
failing stream ended a run with exit 101. None may be named anywhere in
crates/mds-cli/src: not called (path-qualified included), not renamed on
import, not wrapped in another macro. There is no exemption, neither for
test modules nor for the writer macros' own bodies: the writer expands
to write_stderr_fmt and needs none, and a writer body that reached for
eprintln! would bring the panic back. A method of that name (clap's
err.print()), a function definition and a longer identifier are not
mentions; clap's own output stays outside the scan by construction, as
the guard doc now says.

process_exit_only_in_the_funnel: std::process::exit may appear only in
the body of output::exit, the funnel that applies the output-failure
rule (EXIT_FUNNELS lists it; a second funnel is added there, never
exempted elsewhere). std::process::abort appears nowhere, and a use item
that would let a call avoid naming process::exit (renamed, braced,
globbed, or a renamed process module) is reported.

Both bans read every module the crate compiles: the source list is
checked against each `mod name;` resolved from main.rs, and a #[path]
module fails closed. every_printing_file_has_a_site_floor requires a
SITE_FLOORS entry or a written reason in FLOORS_PENDING for each file
that prints; lint.rs is the one pending file, until the lint pipeline
refactor (#309) settles its site count. Synthetic positive and negative
controls cover each scanner.

Product-side change, test code only: the ban has no test-module
exemption, so the four test-only skip notices (two in build.rs's tests,
two in output.rs's tests) move from eprintln! to the writer macro. They
print only when a test cannot run its vector (running as root, or
Windows without symlink rights), and they now reach the real stderr
uncaptured. No production code changes.

broken_pipe.rs: the subcommand x closed-stream table is complete. The
two missing cells are commands that write nothing to stdout, check and
init; their rows assert the open run's stdout is empty and that closing
it changes nothing. TABLE names one row per subcommand and stream (the
watch rows live in cli_watch.rs), and
every_subcommand_has_a_row_for_each_closed_stream fails for a subcommand
`mds --help` lists without both rows, a row whose subcommand is gone,
and a row that names no #[test] function.

Co-Authored-By: Claude <noreply@anthropic.com>
stop_watching's StopReason match had one braced arm and one bare
expression arm for what are both single ewriteln! calls; make both
arms the same shape.

Co-Authored-By: Claude <noreply@anthropic.com>
spec.md described no watch stream behaviour. Section 5's "Streams and I/O
failures on the CLI" now has a paragraph for `mds watch`: a closed stderr
keeps it watching; with `-o -` a gone reader ends the session with
`Stopped watching (stdout closed).` (not under --quiet) and exit 0; another
stdout failure is reported once and not recorded as written, so a save of
unchanged content retries it; once the session is live no output failure
changes the Ctrl+C exit; a session that ends before it is live follows the
batch rule.

Two of those promises had no test:
- the batch rule before the session is live. A new unix test stops a
  session at startup on a gone stdout reader while stderr fails with EFBIG:
  exit 2, with an open-stderr control that exits 0. Marking the session
  live at the top of file mode makes it fail (exit 0).
- `--quiet` for a reader that goes away mid-session. The mid-session test
  now runs a loud and a quiet arm. Passing `false` for quiet at the file
  loop's stop line makes the quiet arm fail.

The print-discipline guards had gaps:
- the exit ban missed a `process` renamed through a braced `self`
  (`use std::process::{self as p, Command};`) and a rename after another
  `process` path in the same braces. Both are now reported. The synthetic
  control failed on both lines before the scanner change.
- nothing kept a second writer from holding its own stdout or stderr
  handle, which would skip the closed-pipe and report-once state, as lint's
  duplicate `write_stdout` did. A new ban allows `stdout`/`stderr` only in
  `write_stdout`, `write_stderr_fmt` and main's exit after clap's output,
  or for an `.is_terminal()` query. It has synthetic controls, a check that
  each owner holds its handle, and a planted handle in watch.rs makes it
  fail.

watch.rs doc comments that said every stop exits 0 now name the startup
exception.

Co-Authored-By: Claude <noreply@anthropic.com>
…recovers

A stdout write that failed for a reason other than a closed pipe was
reported once for the whole process: the stdout-failed fact was sticky,
so every later failure came back as a silent repeat. For a batch run that
is the intended report-once. For a long `mds watch -o -` session it hid
failures: stdout failed (reported), recovered (a rebuild wrote and printed
`Recompiled`), then failed again with no report and no `Recompiled`.

Now the report is once per failure: a stdout write that lands clears the
stdout-failed fact, so the next failure is `Failed` again and reported. A
write of no bytes proves nothing about stdout and clears nothing. A closed
stdout stays closed. The fact that lifts a batch run's exit code to 2 is a
separate bit and is never cleared, so a batch run that lost a stdout write
still exits 2 after stdout recovers; a batch stdout that keeps failing is
reported once, as before.

Tests: a unit test drives the writer through fail, repeat, empty write,
recovery, fail, repeat and checks the exit-lifting fact survives; a unix
watch test makes stdout fail at startup, recover for one rebuild and fail
again, and expects two reports, one `Recompiled` and exit 0 at Ctrl+C.

Docs: spec §5 (the batch list, the watch paragraph) and the `mds fmt`
directory sentence say "once while it keeps failing"; README and the #157
CHANGELOG entry say the same, and now state the exception spec already
had: a session that stops at the startup write while stderr has also
failed other than by a closed pipe exits 2, as the other commands do.
Lint goldens unchanged.

Co-Authored-By: Claude <noreply@anthropic.com>
`LintSource` in lint.rs is the one place a lint input gets its names:
`Stdin`, `File { typed, name }` and `DirEntry { path, key }`, with
`display_label()` (the name its diagnostics carry: each diag.file, the
JSON files[].file key, the name a human frame renders the source under)
and `diff_label()` (the escaped name a --fix --diff header shows).

What moved:
- stdin: 7 of the 9 STDIN_DISPLAY_LABEL sites now go through
  `LintSource::Stdin`: the diagnostic relabel, the preview and apply
  labels, the three named sources and the diff header. The `Would fix:`
  and `Partially fixed:` status lines keep the constant inside the
  writer macro: print_discipline accepts only an escape call or an
  allowlisted name there, and its allowlist liveness check fails once
  lint.rs stops naming STDIN_DISPLAY_LABEL in a macro argument (planted
  and observed failing).
- single file: the `<file>` fallback label is gone. `LintSource::file`
  parses the typed path into its UTF-8 file name once, after the read;
  the relabel, the named source, the preview and apply labels, both
  `Clean:` lines and the diff header use it.
- directory: both per-file functions build a `DirEntry` from the walked
  path and its root-relative key; the relabel, the error-entry JSON key,
  the named source, the preview and apply labels and the diff header use
  it.
- Status lines that name a path keep `safe_path(..)` inside the macro.

The `<file>` fallback was dead. `run_lint_file` has one caller, reached
only after `ensure_existing_mds_file` accepted the path, so its
extension is `Some("mds")` and `file_name()` is `Some` (the extension is
read from it). The fallback was evaluated after `read_source_file`
succeeded: `NativeFs::check_symlink` refuses a final-component symlink
and canonicalizes `canonicalize(parent).join(file_name)`, requiring the
result's parent to be that canonical parent, so the canonical path ends
in the file's own name; `read_canonical_source` then refuses a canonical
path that is not valid UTF-8 ("path is not valid UTF-8", exit 2, pinned
on Linux by cli_lint's lint_single_file_non_utf8_path_exits_2). The file
name was therefore always UTF-8 where the fallback ran. `LintSource::file`
keeps an `mds::io` refusal for that impossible case instead of a label.

No behaviour change: goldens and tests unchanged (crates/mds-cli/tests
is byte-identical to the parent commit; lint_golden 52/52, cli_lint 129,
print_discipline 22, mds-cli nextest 1124 passed + 3 skipped, bin 196).

Co-Authored-By: Claude <noreply@anthropic.com>
PR CI run 36703033927 failed in three jobs on one clippy error under Rust 1.98.0: clippy::byte_char_slices ("can be more succinctly written as a byte str") at crates/mds-cli/tests/print_discipline.rs, where asks_is_terminal loops over [b'(', b')', b'.']. The loop now iterates *b"().", clippy's suggestion; it yields the same three u8 values in the same order, so the guard behaves identically.

The error slipped through because the local default stable toolchain is Rust 1.96.0, whose clippy predates the lint, while CI's stable is 1.98.0. Local fmt and clippy gates now run with +1.98 to match CI.

Co-Authored-By: Claude <noreply@anthropic.com>
`run_lint_file` names its input with `LintSource::file` once `mds::lint`
has accepted the path, instead of straight after the read.

`mds::lint` refuses a path that is not valid UTF-8 before it reads
anything, so once it has returned the typed file name is UTF-8 and the
`mds::io` refusal in `LintSource::file` cannot be reached. The read
before it does not guarantee that on its own: it validates the canonical
path it opens, not the path as typed. In this order every refusal on
this path is `mds::lint`'s own, exactly as before `LintSource` existed.
The doc of `LintSource::file` now gives this reason.

No behaviour change: goldens and tests unchanged (crates/mds-cli/tests
is byte-identical to the parent commit).

Co-Authored-By: Claude <noreply@anthropic.com>
…arator

Four broken_pipe rows failed on Windows in their open-stream control: the
expected text hard-coded `/` in a path mds builds by joining components,
which Windows prints with `\` (`Compiled to .\ok.md`, `+++ fixes\b.mds`).
The product's output is right on each OS; the expectations were not.

The expected paths are now built with `native()`, which writes a path
spelled with `/` in `std::path::MAIN_SEPARATOR_STR`, and `diff_header()`
(`+++ <path>\n` through `native()`), so each control is still an exact match
on every OS. `Row` and `FullRow` borrow their expected text for a lifetime
instead of `'static`, to hold the built strings.

Changed expectations (unix text unchanged; Windows now `\`):
- build_a_file_with_stderr_closed_exits_0_and_writes_the_output:
  "Compiled to ./ok.md\n"
- build_with_a_source_map_and_stderr_closed_exits_0_and_writes_both_files:
  "Source map written to ./ok.md.map\n"
- lint_fix_diff_of_a_directory_with_stdout_closed_exits_1 and
  lint_json_fix_diff_of_a_directory_with_stdout_closed_exits_1:
  "+++ fixes/b.mds\n"
- fmt_check_diff_on_a_directory_with_stdout_closed_exits_1: the path-less
  "messy.mds\n" becomes the exact header "+++ m/messy.mds\n"
- the failing-stdout directory rows (unix only today):
  "+++ two/a.mds\n", "+++ two/b.mds\n", "+++ fixes/a.mds\n",
  "+++ fixes/b.mds\n", so they stay exact if a Windows vector is added

Paths compared as `Path` (`written()`, `files_under()`) and typed paths
printed as given ("+++ fix.mds\n", "Clean: ok.mds\n") need no change.

Co-Authored-By: Claude <noreply@anthropic.com>
`mds lint --fix` and its preview (`--fix --check` / `--fix --diff`) ran
the fix pipeline through two copies: plan_and_apply_fixes returned a
FixFileOutcome, preview_fixes a PreviewOutcome, and each built its own
reverify closure, the two identical in behaviour.

- ReverifyGate replaces the two closures. It is built once per plan
  (the original's compiled output, kept only when every planned edit is
  output-neutral) and its verify() is what apply_fixes_incremental
  calls for each candidate: the candidate must lint, and when the
  output check applies it must compile to the same output. The refusal
  keeps its wording.
- run_fix_pipeline(&LintSource, ...) replaces both functions, and
  FixPipelineOutcome { Fixed, PartiallyFixed, Rejected, NothingToFix }
  replaces both outcome enums. The pipeline borrows the lint result
  instead of handing it back, so Rejected and NothingToFix carry no
  copy of it. `--fix` writes the source of Fixed and PartiallyFixed;
  the preview reads either as "would fix", exactly as it read its own
  WouldFix before.
- Stdin, single-file and both directory modes call run_fix_pipeline
  with their LintSource in place of a display-label string.

In-module tests ported one to one (same fixtures, same assertions):
preview_fixes_surfaces_rejected_on_overlap ->
fix_pipeline_surfaces_rejected_on_overlap, and
preview_fixes_would_fix_relabels_residual_display_path ->
fix_pipeline_would_fix_relabels_residual_display_path. Their labels
come from LintSource::DirEntry values with the same names.

No behaviour change: goldens and tests unchanged.

Co-Authored-By: Claude <noreply@anthropic.com>
The reverify gate's compiled-output check refuses a fix that would change
what a template compiles to when every planned edit is meant to leave the
output alone. No test had seen it refuse anything: with the check disabled
the whole mds-cli suite stayed green. No known `mds lint --fix` input
reaches the refusal end to end, so these in-module tests drive it directly:

- reverify_gate_refuses_a_candidate_that_changes_compiled_output: a gate
  built from a real, all output-neutral plan refuses a crafted candidate
  that still lints but compiles to different output, as an mds::io error
  with today's message. The plan's own fix, which keeps the output, is
  accepted.
- reverify_gate_skips_the_output_check_for_a_plan_that_changes_output: a
  plan that also carries a legacy-interpolation edit accepts the same kind
  of candidate; the plan's output-neutral edits alone refuse it.
- fix_pipeline_rejects_a_fix_that_would_change_compiled_output: a crafted
  output-neutral removal of a line of text comes out of run_fix_pipeline
  as Rejected, with the gate's message inside the reason `fix rejected:`
  prints. The real findings of the same source are fixed.

Disabling the check fails all three; counting one output-neutral edit as
enough fails the second; inverting the comparison fails the controls.

Tests only: no product code, output or golden changes.

Co-Authored-By: Claude <noreply@anthropic.com>
…not duplicate lines

`no_raw_print_macro_outside_the_writer` requires a minimum number of
`ewriteln!` / `ewrite!` calls across mds-cli/src. That number is a
non-vacuity check only: it shows the scan found the registered writer
macros at all, so the raw-print ban cannot pass by reading nothing. It is
not a coverage count. Which files print through the writer is guarded file
by file by `SITE_FLOORS`, with `lint.rs` pending in `FLOORS_PENDING` until
its status lines move to the result sinks.

At 80 the floor sat 5 under the crate's real count (85), so it had become a
coverage count by accident. The lint refactor that follows gives stdin, a
file argument and each directory entry one spine, which removes 16
duplicated status lines from lint.rs, and that alone would have failed the
floor. Lower it to 60 and say in the comment what it guards.

Planted control: pointing the scan at a macro name that does not exist
fails the test with "non-vacuity: expected at least 60 `ewriteln!` /
`ewrite!` calls across mds-cli/src, found 0".

Co-Authored-By: Claude <noreply@anthropic.com>
…ntry

Every input of `mds lint` now goes through one per-input spine,
`lint_input`. It names the findings for the input, announces a capped
result, then reports the findings, or runs the fix pipeline and applies
`--fix` (`apply_fix`, with stdin's filter in `fix_stdin`) or previews it
(`preview_fix`). It returns an `InputVerdict` (tally, would-fix,
truncated): stdin and a file argument exit with its code, a directory
counts it in its summary.

The spine replaces the twin directory functions `lint_one_file_accumulating`
and `lint_one_file_human`, and the report, fix and preview bodies of
`run_lint_stdin` and `run_lint_file`, which now only load their input; a
directory entry loads through `load_dir_entry`. `exit_by_severity` and
`preview_exit_code` fold into `InputVerdict::exit_code`, and `emit_result`
also collects a directory entry's findings into the directory's JSON
document.

Divergences kept, each an explicit branch:
- A directory under human output reads each source first, so an oversized
  entry counts under "with errors" (exit 2) rather than resource-limited;
  JSON output reads a source only to fix it, after linting.
- A directory's JSON document records a rewritten file's findings only once
  the rewrite succeeded; a file argument and a directory's human output
  show the residual first, then write.
- A failed rewrite ends a file argument's run with the error (exit 2),
  prints `error writing` for a directory's human output, and becomes an
  error entry in a directory's JSON document.
- `mds lint --fix -` stays a filter: its findings render against the source
  it emits, and it prints no `Fixed:`.
- `Clean:` is printed for a file argument only, and a directory's status
  lines name the file (`<path>: fix rejected:`, the cap notice).

No behaviour change: goldens and tests unchanged.

Co-Authored-By: Claude <noreply@anthropic.com>
lint_input's SourceText::Unread read-failure arm bound an intermediate
`tally` variable only to move it, unchanged, into the following
InputVerdict literal one line later. Inline the dir_entry_failed(...)
call directly into the tally field, matching the sibling arm 12 lines
above (which already inlines tally_from_result(&result)) and
load_dir_entry's two analogous Err arms. No move-ordering hazard here
(unlike load_dir_entry's other call site, where failure_tally(&e) must
be evaluated before e is moved into dir_entry_failed, so that
intermediate stays). Output, exit codes and control flow unchanged.

Co-Authored-By: Claude <noreply@anthropic.com>
dean0x and others added 30 commits November 10, 2026 19:30
…nical path

The example of a path that display_native_path respells was an I/O
failure below a canonicalized out-dir. Since the CLI names a written
output as typed, no such error shows a canonical path. The example is
now the directory of a dependency outside the entry's directory and the
directory argument, which a failed-to-watch warning names by the path
the compile reported.

Co-Authored-By: Claude <noreply@anthropic.com>
Under --format json, mds lint prints exactly one JSON document on every
exit but a usage error and a panic that ends the run: the panic prints
the fixed internal-compiler-error text and no document. The spec's
section 7 summary line, the lint module doc and the changelog entry
said "except a usage error" only. The spec's detailed paragraph already
named the panic, and now all four places agree.

Co-Authored-By: Claude <noreply@anthropic.com>
…ning

mds lint's warning for an unknown rule in mds.json names the file as the
run reached it (warning: in ./mds.json: ...), but section 7.10 had no
row for it. The new row cites the test that pins the form, and
LABEL_TABLE in tests/path_labels.rs gets the matching entry, which the
table check requires for every row. Mutation control: without the
entry the table check fails with "spec.md section 7.10 cites tests
LABEL_TABLE does not list".

Co-Authored-By: Claude <noreply@anthropic.com>
The spec said that an unreadable, oversized or malformed mds.json has no
error code and exits 1 under build, check and fmt and 2 under lint. Lint
wraps such a failure as mds::io for a file argument, for stdin and for
each entry of a directory, so under lint the error has a code. The
paragraph and the lint.rules row of the config table now say so.

Co-Authored-By: Claude <noreply@anthropic.com>
Without the feature, a panic prints the fixed internal-compiler-error text,
and an escaped backtrace only when RUST_BACKTRACE is set.

Co-Authored-By: Claude <noreply@anthropic.com>
The look of a directory batch stamped only the sources among the paths
the batch names. A dependency outside the root that the batch names, and
that a source of the same batch imports for the first time, was not
stamped. A truncation after the look and before that source's read was
then compiled as read, and the empty output was written.

The look now stamps every path the batch names. Of the errored paths it
still stamps only the sources. The baseline keeps its domain: a path
nothing reads is stamped at the look and dropped when the batch ends, so
its emptying still holds nothing.

This holds the batch whose compile read the file. The batch that the
truncation's own event starts compiles the file as it is, because the
dependency is outside the baseline.

Test: a_dependency_outside_the_root_a_batch_names_is_held_when_truncated_after_the_look
runs a batch in a child process, stopped after its look by the debug
build's pause. Before the change: watch.rs:10865:13, left "" right
"X one\n" (the empty read was written). The pause variable's name is now
visible to the test module.

Co-Authored-By: Claude <noreply@anthropic.com>
…nd that each deadline is its own

A compile that failed reports no dependencies, so the late look after a
failure covers the entry (or source), the --vars file and the files the
compile before it read. A file the failing edit itself starts to import,
truncated after the look, is not among them, and the failure is reported.
The spec now says so instead of "whether that read then failed or not"
alone.

The one-second deadline belongs to its hold. Once a hold has ended, a file
found emptied again, at a later rebuild's look or after the look of the
rebuild that found the file written, starts a hold of its own with a new
deadline. The spec says this next to "that deadline never moves".

Checked against EmptyHold::on_late_empty, run_file_rebuild and the
directory-mode late look for a failed compile.

Co-Authored-By: Claude <noreply@anthropic.com>
…test pins it

The module and input refusal comes at the write, after the directories
the write needs have been made, and removes none. `-o nd/../lib.md`, with
`nd` not there yet and `lib.md` a module or a file the run reads, is
refused and leaves an empty `nd`. Spec 7.2 now says so, naming the entry's
refusal as the one that comes before any directory is made.

A new test pins the leftover for both refusals: exit 2 with the cause,
the file keeps its content, `nd` is an empty directory, and nothing else
is created. A cleanup in the write that removed `nd` made it fail.

Co-Authored-By: Claude <noreply@anthropic.com>
Only `mds build` of a file argument removes a stale `.map` sidecar: the
reconciliation runs in run_build and not in the directory run, which
writes sidecars and leaves a stale one in place without a warning. The
Removals paragraph named the sidecar for every build. It now names a
build of a file argument, and says a directory run does not look for one.

Co-Authored-By: Claude <noreply@anthropic.com>
The note on replace-by-rename named crates/mds-cli/src/output.rs for
atomic_write_file, which lives in crates/mds-cli/src/write.rs. It also
left out the starter file of `mds init`: with --force it goes through
atomic_write_file, and without it create_new writes a starter that
never replaces a file. The note now names write.rs as the write funnel
and lists the starter file with the writes that rely on the rename alone.

Co-Authored-By: Claude <noreply@anthropic.com>
…an tag

A test comment or assertion message that cited another file by line
number (`lint.rs:1535`, `main.rs:31`, `fmt.rs:308`, `spec.md:938`,
`cli_watch.rs:520`) now names the live symbol instead: `run_check`,
`run_fmt_directory`, `Cli::quiet`, `ResultSink::fixed`,
`ResultSink::fix_rejected`, `ResultSink::cap_reached`,
`Rewrite::WriteFailed`, or the spec section. Three messages named
functions that no longer exist (`lint_one_file_accumulating`,
`lint_one_file_human`); they name the sink methods that gate the
output today. The block above the human `Fixed:` test no longer says
the human and JSON sinks are separate emitters: both use
`ResultSink::fixed`.

Plan tags in the same comments and messages are replaced by the rule
they stood for, or dropped: the unknown-rule block of cli_build.rs,
the preview-exit block, the rename-into-place tests, the dir_build.rs
coverage list and the print_discipline.rs self-test headings.

Comments and assertion message strings only: no code and no assertion
condition changed. No lint golden cell changed.

Co-Authored-By: Claude <noreply@anthropic.com>
… a plan tag

A source comment that cited a line of another file now names the
symbol: `run_check_directory`, `run_fmt_directory`, `write_compiled`,
`Cli::quiet`, `ResultSink::fixed`, `Rewrite::WriteFailed`. Comments
that named lint functions that no longer exist now name the
`ResultSink` methods (`HumanSink`, `JsonSink`) that hold the quiet
gates today.

The `mds check <dir>` doc in main.rs now states all three exit codes:
1 for a template error, 2 when an I/O or file-system failure is among
them, and 3 when a file failed with a resource limit.

Plan tags in the same comments are replaced by the rule they stood
for, or dropped.

Comments and doc comments only: no code changed.

Co-Authored-By: Claude <noreply@anthropic.com>
The entries for the write and removal below an anchor and for the
path in an error message no longer carry a label or a weakness
number. Each states what the CLI did and what it does now.

Co-Authored-By: Claude <noreply@anthropic.com>
…nges

The two entries that moved `mds lint` from exit 2 to exit 3 for a
file or a vars file over the 10 MiB cap were listed under Fixed.
They change an exit code a script can test, so they are now under
Changed with a BREAKING (CLI) lead.

Co-Authored-By: Claude <noreply@anthropic.com>
The refused-write test asserted one result on every OS: the write leaves an
empty nd. On Windows the write makes no nd. Windows resolves nd\.. by its
text, as the root, which exists, so no directory is made. The Windows CI job
failed on that assertion.

The test now states the result of each OS. On Unix nd stays, empty. On
Windows no nd exists, and the entry list stays as it was before the run.
Both OS keep the other assertions: exit 2, the refusal text, the file
content and no temporary file.

Spec 7.2 now says that nd is never made on Windows. No product code changes.

Co-Authored-By: Claude <noreply@anthropic.com>
A directory batch compiles a source that imports a dependency outside
the root for the first time. The dependency is truncated after the
batch's look and before the compile reads it, and the compile is held.
The truncation's own event starts a second batch that names the
dependency. The dependency is no source, no tracked dependency and not
among the sources held back, so the look of the second batch could not
find it emptied, and its compile published the empty output.

The files a held compile read empty now stay in the baseline's domain
until the hold ends, as the held sources do. The look of a later batch
stamps them, finds them emptied, and holds that batch too. The hold's
deadline rule is unchanged. A path that nothing reads, named by a held
batch, stays outside the domain and holds nothing when emptied.

A source that drops an import of such a file waits for the file to be
written, or for the deadline, as for any tracked dependency. The two
unit tests that left the module empty while the page was saved now write
the module whole with the page's save: each keeps its intent (the batch
that ends the hold rebuilds the held source; a held source emptied
before the hold ends is held again). Spec section 7.2 states the wait.

Co-Authored-By: Claude <noreply@anthropic.com>
A file the --vars load or a compile read, emptied after the rebuild
looked, holds the rebuild back. Six sites wrote that rule by hand. The
rule now lives in held_after_look: it finds the files that went empty,
reads the clock once, and returns them when the rebuild is held.

File mode loads the variables and compiles as one result
(load_and_compile) and takes one late look. It reads the files of
interest the compile reported when it succeeded, and the files of
interest of the compile before when the load or the compile failed.

Directory mode holds a batch whose --vars load failed through
DirWatchState::hold_after_vars_load_failed. Both holds in
compile_one_source call the helper; the success hold keeps the files the
helper returns as the files a held compile read empty.

Behaviour is unchanged and no test changed. any_went_empty is now used
by tests only, so it is compiled for tests only.

Co-Authored-By: Claude <noreply@anthropic.com>
…tested

A directory batch whose --vars load fails on a file emptied after the
batch looked is held with that file joined to it. No test pinned the
join: replacing it with the batch as it came passed every test, because
an integration test needs a lost event to reach it.

Three unit tests call DirWatchState::hold_after_vars_load_failed:
- an emptied dependency joins the held batch as a path;
- an emptied --vars file joins as a change to it, not as a path;
- nothing is held when no file went empty, or when the deadline ended
  the hold in this rebuild (a positive control holds the same file
  with the deadline ahead).

Test code only. Each test fails when its guard is removed: the join
dropped, the --vars file not told from a path, the deadline ignored,
the watched set empty.

Co-Authored-By: Claude <noreply@anthropic.com>
compile_one_source matched the compile's result and ran the whole
success path inside the Ok arm, six levels deep, with seven exits. The
failures are now guard clauses ahead of it: the deleted source is
retired, a failed compile is held or settled, each by a return. A
source that is a partial, one whose output is unchanged, one held by
the late look, one whose write is kept and one whose write failed each
return in turn. What is left is the write and its record, at depth one.

The two holds share DirWatchState::hold_back, which keeps what the
rebuild before kept from being written and holds the source. The late
look on the success path still runs only when the output would be
written.

Behaviour is unchanged: the same checks run in the same order, with the
same effects, and no test changed.

Co-Authored-By: Claude <noreply@anthropic.com>
The bullet in [Unreleased] said how a link came to be below the anchor
and pointed to SECURITY.md for the residuals. It now says what a write
or a removal did, and what every write and every removal does now.

Only that bullet changed. The text already on main is untouched.

Co-Authored-By: Claude <noreply@anthropic.com>
…gh one helper

File mode and directory mode each wrote a rebuilt output in the same three
ways and showed it with the same `Recompiled` line, in two copies. Each mode
now calls one function for each step.

- `write_rebuilt` refuses an out-dir that the typed path now leads elsewhere
  from. After a change of kind it writes only over a file the session wrote,
  and else keeps the file. Any other write goes below the checked out-dir and
  never over a file the compile read. It returns `Rewritten::Written`,
  `Rewritten::Kept` or the failure.
- `announce_recompiled` shows the `Recompiled` line, then the notice for an
  output the write emptied.
- Each mode keeps its own record of what it wrote, its own retirement of the
  other kind's output, and its own handling of a kept or failed write. Stdout
  stays in file mode: it has no out-dir and no change of kind.
- The late look does not move. File mode takes one look before it uses the
  compile's result, for every outcome. Directory mode takes one look after
  the dedup, only when the output would be written. Each look stays where it
  was, so no gating parameter is needed.

The behaviour of both modes is the same as before. No test changed: the
print-site floor and the allowlist keys of the print guard still hold.

Co-Authored-By: Claude <noreply@anthropic.com>
The write funnel's Commit enum took a type parameter for the stamp a
rewrite is held to. Every use gave it the platform's own stamp
reference, so the parameter named one type in every place.

Replace(Option<&Stamp>) now names that type directly, and every
signature that took Commit<'_, &Stamp> takes Commit<'_>. The unix
and windows modules keep their own Stamp; the enum reaches it through
the platform alias. No behaviour changes and no test changes.

Co-Authored-By: Claude <noreply@anthropic.com>
A watch compile ran inside a panic catch at two places: the compile of
a watched path, and the compile of a dependency outside the root. Each
site repeated the same catch, the same default options and the same
mapping of a panic and an error to a compile failure.

compile_caught is now the one place a watch compile runs, so it is the
one place a panic in it is caught. Both sites call it. Their order of
checks and what they report do not change.

The panic-catch pin in panic_hook.rs lists one watch.rs place,
compile_caught, in place of the two it listed before. No other test
changes.

Co-Authored-By: Claude <noreply@anthropic.com>
Directory watch threaded a batch as a pair, its paths and whether one
of them changed the --vars file, and rebound the pair three times as
the look, the hold and the release each returned a new one.

Batch holds the two. join_emptied and HeldBatch::release return one,
and HeldBatch::hold takes one, so each step names the batch it works
on and the rebinds are plain shadowing of one value. A batch kept for
the next one while no hold runs, because the --vars file could not be
read, is carried (HeldBatch::carry), not held; the two keep a batch the
same way and release it the same way.

rebuild_dir_batch keeps its signature. The unit tests that called hold,
release, join_emptied and hold_after_vars_load_failed follow the new
signatures and assert the same paths and flags. No behaviour changes.

Co-Authored-By: Claude <noreply@anthropic.com>
The result sink's other failure methods are verbs: setup_failed,
failed, write_failed and panicked. analysis_failure was a noun.

It is now analysis_failed, in the trait, the human and JSON sinks, the
recording sink of the lint unit tests and the doc lines that name it.
The helper in lint.rs that shows the error and returns the exit code
already had that name and keeps it. Output, exit codes and every lint
golden are unchanged.

Co-Authored-By: Claude <noreply@anthropic.com>
process_dir_batch, its two passes and compile_one_source each took the
watched directory, the output base, the batch's variables and --quiet
as separate parameters: seven parameters for the first, the clippy
limit, and six for each of the others.

BatchCtx holds the four. run_dir_batch builds it once for a batch, from
the session's context and the variables it has just resolved, and each
function takes it with the changed paths and the state. The unit tests
that call process_dir_batch and process_dir_batch_incremental build one
in place of the four arguments. No behaviour changes.

Co-Authored-By: Claude <noreply@anthropic.com>
Directory watch derived what a path is in four places: the event filter, the
batch's source lists, the compile dispatch and the deleted-source retirement.
Each place used its own mix of the starts_with, extension, excluded-directory,
partial and external-directory tests.

classify(root, path, external_dirs) is now the one answer, a Node: Source,
Partial, InRootModule, ExternalDep, ExcludedDep or Unrelated. The event
filter, the incremental batch's dispatch (a match on the Node, with the
dependency refresh as refresh_dependency) and retire_deleted take it.
names_a_source is the source view of it, for the callers that hold no
external directories.

No behaviour changes. Tests that cover it run unchanged: the unit tests of
the batches, the idle tick and the ghost dependency prune, and cli_watch.

tests/print_discipline.rs: the path-text table no longer lists
handle_fs_event_dir. The extension comparison it pinned moved into
has_mds_extension, which compares the extension without turning it into
text, so the listed count was no longer true. The rule and its assertions
are unchanged.

output.rs: the doc of is_within_default_excluded_dir names classify as its
caller.

Co-Authored-By: Claude <noreply@anthropic.com>
…, not only at the tick

The event filter of a directory watch took .mds paths alone. An edit to a
type: mds .md module that a source imports, below the directory argument or
outside it, named no rebuild: only the idle tick's content check found it,
and with --poll-interval 0, which runs no tick, nothing rebuilt the importers
until one of them was edited.

The filter now also takes any file a source imports (a graph-key lookup in the
dependencies the sources recorded, built once per event and only when a path
is no .mds file in scope). A file no source imports, such as a README.md beside
the sources, still names no rebuild. The batch rebuilds the importers and,
as before, never compiles the module as a source.

Tests:
- cli_watch: watch_dir_mode_event_rebuilds_the_importer_of_an_md_module_below_or_outside_the_root
  runs at --poll-interval 0 and edits one module below the root and one outside
  it; it failed before the fix at the first edit.
- watch.rs unit test an_event_for_an_md_file_rebuilds_only_when_a_source_imports_it.
- The tick test for the same module gets a barrier before its check that the
  module is never compiled, so an output written later in the batch cannot
  slip past, and its doc says that either the event or the tick delivers the
  edit.

Docs: one CHANGELOG Fixed bullet; the older bullet for the module no longer
says the tick alone finds it; one README directory-watch bullet for .md
modules. The doc of a unit test no longer says the event path keeps .mds
paths alone.

Co-Authored-By: Claude <noreply@anthropic.com>
…ot that is no source

A rebuild with a change compiled every affected dependency outside the root,
or in a directory the walk skips, as an entry, quietly, to refresh its own
edges. A type: mds .md module outside the root that was edited into a plain
.md (or emptied) is no MDS file, so that compile failed: the module was
marked errored and refused under its own canonical path. Errored files are
seeded into every later rebuild with a change, so the same refusal printed
again in each of them, next to the refusal of each source that imports it.

Such a dependency is now left to its importers, as a module below the root
is: only a dependency that is a .mds file gets the quiet refresh. The edges
from the importers to it stay, so the edit that makes it a module again
still rebuilds them.

Test: cli_watch watch_dir_mode_never_compiles_an_md_dependency_outside_the_root_as_an_entry
edits the module into a plain .md, makes two more rebuilds with a change,
repairs the module, and counts the refusals that name something other than
the import as written. It failed before the fix with 14 such refusals
and passes with none.

Docs: one CHANGELOG Fixed bullet; the README bullet for .md modules.

Co-Authored-By: Claude <noreply@anthropic.com>
The operating system sends an event that names no path when it lost
events: an overflowed inotify queue, or a macOS event stream that must
rescan. The directory watch kept the event's paths and dropped the fact
that events were lost, so the event became an empty batch and nothing
was rebuilt. A source created, a source removed, a dependency edited or
a --vars edit in that gap was found only by the idle tick, and under
--poll-interval 0, which runs no tick, not at all.

The debounce window now carries the flag to its result, and the event
handler acts on it. The idle tick's look for changes it was not told of
is one function, scan_directory: the content check of the watched files
and, with walk, the walk that finds sources that appeared or were
removed. The tick calls it as before. An event that says events were lost
calls it with the walk, and its findings join the batch of the event.

Test: watch::tests::a_rescan_event_finds_what_the_lost_events_would_have_said
creates a source and edits the --vars file with no event, then sends a
rescan event as the first event of a batch and as an event of its
debounce window. It failed before the fix on "the rescan event
rebuilds" and passes with the source built and the vars edit rebuilt.
A control in it shows that an event with no path and no flag rebuilds
nothing. watch::tests::a_debounce_window_keeps_that_an_event_said_events_were_lost
covers the flag in the window.

Docs: one CHANGELOG Fixed bullet; a README bullet for lost events.

Co-Authored-By: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment