Skip to content

Add tests for guarantees L2, L7, L8 - #108

Merged
willkg merged 4 commits into
mainfrom
test/guarantees
Aug 29, 2026
Merged

Add tests for guarantees L2, L7, L8#108
willkg merged 4 commits into
mainfrom
test/guarantees

Conversation

@willkg

@willkg willkg commented Aug 29, 2026

Copy link
Copy Markdown
Member

Summary

Closes gaps identified in docs/guarantees.md where a guarantee was marked Holds but no test actually proved the specific claim, even where the underlying mechanism was sound (tracked in #107):

  • L7 (output-is-valid-markdown): feeds every storage2md golden and the larger forward-regression corpus through a fresh StorageToMarkdown conversion and a real GFM parser, confirming the bracket/table syntax markfluence emitted is actually recognized as such — not the static golden text, which would only prove one committed snapshot parses forever regardless of whether the converter still produces it. Includes a bracket-balance sanity check for the case a rendering bug mangles output so badly nothing resembling a link is left to compare against.
  • L8 (no-layout-inference): a unit test and a batch-level test confirming page hierarchy is never inferred from directory nesting, even in the most tempting shape (a file named after a sibling directory).
  • L2 (invocation-independent): cwd-independence and batch-independence tests for project.Discover/Cache — root resolution for a given file must not depend on the process's working directory or on which other files are in the same batch.

Every test was verified by deliberately introducing the bug it's meant to catch and confirming it fails, including two cases where that process caught a real flaw in the test's own design before it shipped (a false positive from GFM's "bare space is not a valid destination" rule, and a batch-independence test whose fixture shared one project root across both directories, which would have let a contamination bug pass by accident).

One commit (38d5e0f) is a self-review fix: the L7 test's fenced-code exclusion was applied inconsistently across its three checks, leaving two of them exposed to false positives from example markdown syntax shown inside a code fence.

Test plan

  • make check passes after every commit in this branch
  • Every new test verified via mutation testing to actually catch the regression it claims to guard against
  • No production behavior changes — test-only, aside from the L7 self-review fix which is itself test-only

willkg added 4 commits August 29, 2026 16:27
Nothing parsed markfluence's own written output back through a markdown
parser -- what was tested was the encoding mechanism, not the guarantee
itself. Feeds every storage2md golden and the larger forward-regression
corpus through a fresh StorageToMarkdown conversion (not the static
golden text, which would only prove one committed snapshot parses
forever) and a real GFM parser, checking that the bracket/table syntax
markfluence emitted was actually recognized, plus a bracket-balance
sanity check outside fenced code for the case a rendering bug mangles
the syntax badly enough that nothing resembling a link is left to flag.
Both checks confirmed via mutation testing against a broken destination
encoder and a broken link-format string.
No test asserted that page hierarchy is never inferred from directory
structure. Added a unit-level case at the most tempting shape to
"helpfully" infer from (a file named after the directory its sibling
lives one level under) and a batch-level case with files nested several
directories deep alongside plausible-looking ancestors, both confirming
no parent relationship forms unless a parent: field or --parent said so.
Verified by temporarily introducing a directory-based inference into
resolveParent and confirming both tests fail.
No test proved either half of the claim -- that root resolution depends
only on the files on disk, not on the working directory or on which
other files are in the same batch. Added a cwd-independence test
(Discover from an unrelated working directory must still resolve an
absolute path correctly) and a batch-independence test (resolving one
file through a Cache that also resolved an unrelated file from a
different project must not change its result). The batch test
deliberately uses two distinct projects: an earlier draft shared one
project root across both directories, which let a contamination bug that
just returns whatever the cache last resolved pass by accident. Both
verified by introducing the corresponding bug and confirming the test
that should catch it fails.
…just one

assertParsesCleanly's bracket-balance check already stripped fenced code
before comparing, but the image/link floor count and the table-separator
check still ran against the raw source -- so example markdown syntax
shown inside a code fence (e.g. "![alt](url)" as documentation text)
could inflate the expected count or trip the table check, a false
positive this test would blame on the converter instead of on itself.
Compute prose once and use it for all three checks.
@willkg
willkg merged commit 3e050d5 into main Aug 29, 2026
1 check passed
@willkg
willkg deleted the test/guarantees branch August 29, 2026 21:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant