Check user doc cycle counts against source of truth (#3111) - #3262
Check user doc cycle counts against source of truth (#3111)#3262crazywriter1 wants to merge 20 commits into
Conversation
b03909c to
0ec8721
Compare
|
@huitseeker Thanks for the detailed issue. The suggested shape (explicit mapping + Rationale: User docs repeat cycle counts by hand, so they drift from generated core-lib MASM docs. This adds a guardrail before that drift lands on What’s in the PR:
Heads-up: Follow-ups (broader mappings, more assembly fixtures, generated reference blocks) are in the PR description. Happy to iterate on the assembly measurement approach if you prefer something else. |
| ASSEMBLY_FIXTURES = Path(__file__).resolve().parent / "assembly-cycle-fixtures.toml" | ||
|
|
||
|
|
||
| def extract_cycles_from_description(description: str) -> str: |
There was a problem hiding this comment.
Could we avoid adding a second Markdown parser here? The core library already has a source-of-truth path: MASM doc comments generate crates/lib/core/docs/** when MIDEN_BUILD_LIB_DOCS=1 cargo check -p miden-core-lib runs.
A simpler check would be:
- keep cycle text in the MASM doc comments,
- regenerate the core docs in CI,
- fail if
crates/lib/core/docs/**has a diff, - make the user docs link to, include, or stay thin around those generated tables.
That would let us delete this Python normalizer and scripts/user-doc-cycle-mappings.toml, and it avoids maintaining a second Markdown grammar just to compare prose back to prose.
For the one assembly case, I think the same idea applies: a direct Rust assertion for u32popcnt cycle metadata, or one inline MASM test, is enough. The TOML fixture plus parser feels heavier than the check it buys us.
de5ae2c to
64c661b
Compare
|
@huitseeker Pushed a fix for the stack overflow: the assembly fixture test in On the Python parser / mapping TOML feedback: agreed that generated-doc diff + thinner user docs is the better long-term shape. Should I refactor this PR to that approach, or merge this guardrail and follow up separately? Happy to do whichever you prefer. |
Verify core-lib user docs against generated MASM docs via explicit mappings, and assembly instruction cycles via clk fixtures.
Run the assembly fixture test with TEST_RUST_MIN_STACK so make check-user-doc-cycles matches the processor test harness. Rebase CHANGELOG onto v0.25.0 with the 0xMiden#3111 entry only under unreleased.
64c661b to
7e80145
Compare
|
@huitseeker Thanks for the follow-up review addressed both points in the latest push:
On the earlier stack overflow feedback: the assembly fixture test in Still happy to pivot to the generated-doc diff approach in this PR or a follow-up let me know which you prefer. |
b47b137 to
6e6bce5
Compare
|
Addressed: restored |
huitseeker
left a comment
There was a problem hiding this comment.
Thanks, this is much closer now.
I think there are two remaining issues to fix before merge.
The first issue is in the assembly cycle check. It still proves that the expected text appears somewhere in the marked row. It does not prove that the cycle value itself matches. A later row can pass for the wrong reason if the same number appears in the note text. The fix is to compare the cycle cell, not the whole row.
The second issue is the fixture path in the processor test. The test includes a file from ../../../scripts, which is outside the miden-processor crate. That works in this workspace, but it can fail when the crate is packaged and tested by itself. The fixture should live under a path that is packaged with the crate, and the script should read that same file.
The other comments are cleanup. I would not block on them.
Addressed all remaining review points in the latest push:
The documentation cycle checker and processor assembly fixture test both pass. @huitseeker |
Rationale
User-facing core-lib docs copy cycle counts by hand and drift from generated MASM docs. This PR adds CI to catch that drift via explicit mappings, plus a starting assembly check with
clkfixtures.Summary
scripts/check-user-doc-cycles.sh, a Python parser, and an explicituser-doc-cycle-mappings.tomlto compare user-facing core-lib docs against generated MASM docs (MIDEN_BUILD_LIB_DOCS=1 cargo check -p miden-core-lib).<!-- cycle-check: ... -->markers and a processor test that measures instruction cost viaclk(with a baseline program to isolate the target instruction).make check-user-doc-cyclesand a new CI job.u32popcntfrom 32 to 38 cycles based onclkmeasurement.Test plan
make check-user-doc-cyclescargo test -p miden-processor --lib tests::user_doc_assembly_cycle_fixtures_match_documentation -- --exactFollow-up (out of scope for this PR)
user-doc-cycle-mappings.tomlto cover remaining core-lib procedures with cycle text (e.g.find_key_value,log_precompile_request,math/u64helpers) once generated docs expose comparableCycles:entries.cycle-checkmarkers andclkfixtures beyond the initialu32popcntexample.Closes #3111