Repository navigation
fix(daemon): report the first differing line when the action reference doc drifts - #422
Conversation
…e doc drifts When the generated docs drift from the catalogue, the old assert_eq! printed both 44 KB documents, forcing a scroll through near-identical Markdown to find the changed line. The failure now names the first differing line and shows both sides, keeps the regeneration command, and reports a truncated file as ending at '<end of file>' instead of swallowing the missing tail. Closes lacs-project#345
|
The CI workflows for the current head |
vladimirrott
left a comment
There was a problem hiding this comment.
Reviewed at b2ba4ad7943b5a163b33467300199ca25dd06aea.
First, an apology that is mine and not yours. Your four workflow runs have been sitting at action_required since 10 September:
$ gh run list --branch 'fix/action-reference-diff-message'
ci completed action_required 2026-09-10T18:52:52Z
e2e completed action_required 2026-09-10T18:52:52Z
CodeQL completed action_required 2026-09-10T18:52:52Z
secret-scan completed action_required 2026-09-10T18:52:52Z
First-time contributor runs need a maintainer to approve them, nobody did, and you have had four days of a blank check board with no way to tell whether your work passed. I have approved all four and they are running now. That was my delay to fix, and you had no lever to pull.
The change itself is good. Replacing assert_eq! on two 44 KB documents with a first-differing-line report is the right call, and the helper is written so it cannot panic on the inputs that usually break this kind of code:
committed_lines.iter().zip(generated_lines.iter())
.position(|(cli, gli)| cli != gli)
.map(|i| i + 1)
.or_else(|| (committed_lines.len() != generated_lines.len())
.then(|| committed_lines.len().min(generated_lines.len()) + 1))No indexing anywhere, so a truncated or empty document reports where the shorter side ends instead of panicking on a slice. diff_message then uses .nth(line - 1).unwrap_or("<end of file>"), and line is always at least 1, so the subtraction cannot underflow. I checked the case that worried me, which is whether the guard can now miss real drift: first_diff_line returns None only when every zipped pair matches and the lengths agree, and split('\n')/join round-trips, so equal line vectors mean equal strings. It still fails on every genuine difference.
I especially liked that you ran the mutations yourself and named them (M1 on the off-by-one, M2 on the length fallback) rather than asserting the tests were meaningful.
The baseline is mine, not yours
Your PR adds six tests, taking the suite from 1852 to 1858, and you left tests/evidence/workspace-tests.json and the three prose counts untouched. That is exactly right. CONTRIBUTING.md says so:
If you cannot install those, do not estimate a count or edit the evidence metadata by hand. Leave
tests/evidence/workspace-tests.jsonand the three prose files untouched. In the PR body, name the command you could not run and the missing tool or system library that blocked it. A maintainer will run the full suite and regenerate all four files before merge.
You named the command, named why your container could not produce a clean run, and named the seven failures you reproduced on a pristine main to show they were environmental. I will run UPDATE_TEST_BASELINE=1 scripts/test_baseline.sh on Ubuntu and update all four files in the merge commit. If rust goes red on the baseline, that is the expected state and not something for you to chase.
One optional note
All six new tests call first_diff_line and diff_message directly, and none of them exercises action_reference_doc_is_current. So if someone restored the old assert_eq! in the guard while leaving your helpers in place, all six stay green and nothing warns, because the helpers are still reached from the tests. The behavior the PR exists to deliver is the one line that is not pinned. Asserting on the guard's own panic payload, or extracting the compare-and-report into one function both the guard and the tests call, would close that. Not blocking, and the risk is small.
Approving. Once the runs finish I will regenerate the baseline and merge.
…sage tests
Measured, not computed:
Summary [11.837s] 1860 tests run: 1860 passed, 6 skipped
test_baseline: recorded 1860 rust tests in tests/evidence/workspace-tests.json
The three published figures are derived from the artifact rather than typed, and
tests/release/public-claims.test.sh agrees:
Published figures match the evidence artifacts.
vladimirrott
left a comment
There was a problem hiding this comment.
Re-approving at 228d3d4. Everything since your b2ba4ad is mine, and none of it is a change to your code.
Your six new tests move the workspace count, and in this repository that figure lives in four places that have to move together: tests/evidence/workspace-tests.json and one prose literal in README.md, docs/introduction.md and docs/distro-support.md. Bumping the artifact alone turns rust green and docs-and-hygiene red, which is a confusing way to find out. That coupling is not written down anywhere a first-time contributor would look, so it is not yours to have known.
I measured it rather than adding six to the old number:
Summary [11.837s] 1860 tests run: 1860 passed, 6 skipped
test_baseline: recorded 1860 rust tests in tests/evidence/workspace-tests.json
and derived the three published figures from the artifact, which the claim screen agrees with:
Published figures match the evidence artifacts.
Public claims contract passed.
I also merged main in, since seven pull requests landed here tonight and yours was behind all of them. No conflicts.
On the change itself, the thing I like is that the failure now names a line instead of printing two 44 KB documents at somebody. action_reference_doc_is_current was the check most likely to be hit by a contributor who had never seen it, and least likely to tell them what to do about it.
Nothing left for you. I will merge once the board is green.
|
Merged, and it is your first one here. The failure it replaces used to print two 44 KB documents side by side and leave you to find the difference. It now says which line and shows both versions of it, with the regeneration command still in the message. I hit that check myself last night resolving a conflict in It went in with an observed receipt, which for this repository means the gate ran your three Two open issues that fit what you just demonstrated, if you want another. #433 is one I filed tonight: Say which one and I will hold it for you. One last thing, since you now have a merged pull request here: your CI runs will start without me having to approve each push, so the loop gets faster from here. If you administer Linux machines yourself, the read-only side of SysKnife is worth ten minutes: |
Summary
action_reference_doc_is_currentcompared the committeddocs/action-reference.md(44 KB, 399 lines) with the generated document viaassert_eq!, so a drift printed both sides in full and the contributor had to scroll 88 KB to find the line that moved. It also reported a truncated file as a generic "out of date" without naming the missing tail.The failure now renders a short message with the first differing line, both sides, and the regeneration command, e.g.:
Implementation:
first_diff_line(committed, generated)finds the first 1-based differing line (with a length check so a truncated document reports where the shorter side ends),diff_messagerenders it, and the test panics with that message. The equal case is unchanged.Related Issue
Closes #345
Validation
All commands ran in a Debian bookworm container (
rust:bookworm,x86_64-unknown-linux-gnu, Rust 1.98.1, cargo-nextest 0.9.143) against the working tree, becausesysknife-daemonhas a Linux-onlyvsockdependency and does not compile on Windows.cargo nextest run -p sysknife-daemon --test action_reference_doc --locked— 7 tests run, 7 passed (6 new + the existing drift guard).i + 1):first_diff_line_names_a_differing_line,diff_message_names_the_line_and_both_sides,diff_message_names_the_missing_tail, and the truncation test go red.first_diff_line_reports_a_truncated_documentanddiff_message_names_the_missing_tailgo red.cargo clippy -p sysknife-daemon --all-targets -- -D warnings— clean.cargo fmt --all -- --check— clean.cargo nextest run --workspace --locked --no-fail-fast— 1858 tests run, 1851 passed, 7 failed, 6 skipped. All 7 failures are environmental to this container and reproduce on a pristinemaincheckout (61b3a87) with the same command: threeexecute_spectests and oneexecutortest fail withActionNotStopped { program: "sh", ... } (AliveReachable)(process-group stop confirmation under container semantics),transactions::tests::concurrent_record_keeps_chain_intact_and_seqs_contiguous(concurrency timing),sysknife-core path_behind_mode_000_directory_counts_as_presentandsysknife-brain current_user_returns_non_empty_string_in_normal_env(root/container environment). None of them touch this change.Baseline note: this PR adds 6 Rust tests, so the suite is 1858 vs the recorded 1852 in
tests/evidence/workspace-tests.json. I did not touch the evidence artifact or the prose counts:scripts/test_baseline.shrefuses to record a baseline from a non-zero-exit run, and this machine cannot produce one (the failures above are environment-specific, not fixable here).UPDATE_TEST_BASELINE=1 scripts/test_baseline.shon CI/Ubuntu should record 1858 andgrep -rn 'Rust tests' README.md docs/introduction.md docs/distro-support.mdupdated (the maintainer fallback documented in CONTRIBUTING.md).Notes for Reviewers
zipover the two line iterators plus a length check).diff_message_names_the_line_and_both_sides), which is the point of the issue: a contributor can see at a glance what changed..gitattributesissue tracked separately.