From 2852907038c9ae25ccd072c3d2a14495e6d96b69 Mon Sep 17 00:00:00 2001 From: Bertalan Ivan <2826311+bertalan@users.noreply.github.com> Date: Tue, 24 Nov 2026 21:04:24 +0100 Subject: [PATCH 1/5] Close the twelve minor points moved from PR #3 PR #3 moved twelve minor points to this PR, under the minor-round rule. This commit closes them. Review round 13: - CLAUDE.md, step 5: "It reviews" becomes "The reviewer reviews". - The reviewer prompt's description is split into short sentences. - Roadmap 0.5 says that its last item, the review trace, is an open point for the owner to decide, not a missing test. - The auditor prompt accepts a note in the first commit message as the way to close a moved point on a pushed commit message. - The message of 5244cbe did not name the reworded sentence on brackets at the top of docs/design.md. Noted here. Review round 14: - The reviewer prompt knows the minor-round rule: findings that are all minor give APPROVED, and each point on personal data, confirmation or writing files is marked. - CLAUDE.md says what the count covers: the minor rounds before one commit. A CHANGES NEEDED round in between does not restart it; the next commit starts a new count; the points of the third minor round move too. "Its verdict comment" becomes "The verdict comment of that round". A point on the message of a commit already pushed is closed by a note in the next commit message (owner's decisions, 2026-11-24). - CLAUDE.md, the points that never move: "confirmation or writing files" becomes "or on confirmation or writing files". They are fixed and reviewed before the commit; the reviewer prompt says so too. - The message of 5244cbe lists "After each commit, a PR comment names the commit" under the owner's decisions; CLAUDE.md does not. Noted here. - The reviewer prompt lists the commands that run from a script as a sub-list. Review of the 0.4 mark: - docs/design.md: the 25 requirement labels lose their bold (owner's decision, 2026-11-24). - Roadmap intro: CI is green on all four jobs "on its last commit". - The message of 6fe7029 says nine minor points move; twelve moved. Noted here. Co-Authored-By: Claude Opus 5.5 --- .claude/agents/coherence-auditor.md | 5 +-- .claude/agents/fable-reviewer.md | 14 +++++--- CLAUDE.md | 18 +++++++---- docs/design.md | 50 ++++++++++++++--------------- docs/roadmap.md | 15 +++++---- 5 files changed, 57 insertions(+), 45 deletions(-) diff --git a/.claude/agents/coherence-auditor.md b/.claude/agents/coherence-auditor.md index 411702d..90cd4e7 100644 --- a/.claude/agents/coherence-auditor.md +++ b/.claude/agents/coherence-auditor.md @@ -58,8 +58,9 @@ Read first: `CLAUDE.md`, `docs/design.md`, `docs/roadmap.md`, the latest report - fixed and reviewed; - written into the roadmap step that will fix it; - declared wrong by the owner, with the reason in a PR comment; - - every minor point a verdict comment lists as moved to the next PR is fixed, or written into - a roadmap step, by the first commit of that PR. + - every minor point a verdict comment lists as moved to the next PR is closed by the first + commit of that PR: fixed, written into a roadmap step, or, for a point on the message of a + pushed commit, noted in the message of that first commit. 7. Health. Run `cargo fmt --check`, `cargo clippy --all-targets -- -D warnings`, `cargo nextest run`, `cargo test --doc` and `cargo deny check`. Report the actual results. diff --git a/.claude/agents/fable-reviewer.md b/.claude/agents/fable-reviewer.md index 36d417c..8336b0b 100644 --- a/.claude/agents/fable-reviewer.md +++ b/.claude/agents/fable-reviewer.md @@ -1,6 +1,6 @@ --- name: fable-reviewer -description: Independent reviewer on a different model (Fable), of equal or higher capability than the author's. Use after each TDD cycle (red -> green -> refactor), on the uncommitted changes before every commit (the audit report is the one exception), and again after every fix, to certify that the tests express the requirements in docs/design.md and that the code is correct. Read-only: it reports, it never edits. +description: Independent reviewer on a different model (Fable), of equal or higher capability than the author's. Use it on the uncommitted changes before every commit; the audit report is the one exception. Use it after each TDD cycle (red -> green -> refactor) and again after every fix. It certifies that the tests express the requirements in docs/design.md and that the code is correct. Read-only: it reports, it never edits. model: fable tools: Read, Grep, Glob, Bash --- @@ -77,9 +77,11 @@ The brief holds: - can write a document outside the selected folder; - lets `--plan` write or download anything; - treats a non-terminal input as a yes; - - confirms anything from a script (only `check` in an ordinary run, `check --plan`, - `extract --plan` in an ordinary run, and the `--plan` lists of `undo`, the menus and - `uninstall` run there); + - confirms anything from a script. Only these run from a script: + - `check` in an ordinary run; + - `check --plan`; + - `extract --plan` in an ordinary run; + - the `--plan` lists of `undo`, the menus and `uninstall`; - judges time from the signer's claimed signing time; - skips the native dialog of a context-menu run; - counts several selected folders wrongly (a row each, the total typed, overlaps counted @@ -127,3 +129,7 @@ Start with one line: `VERDICT: APPROVED` or `VERDICT: CHANGES NEEDED`. Then list most severe first. Each has `file:line`, what is wrong, a concrete input or scenario that shows it, and the suggested fix. Separate "bug" from "missing test" from "minor". No praise, no summary of what the code does. Write the report in English. + +When every finding is minor, the verdict is `VERDICT: APPROVED`, with the minor points listed. +Mark each point on personal data, or on confirmation or writing files (R28–R34): such a point +never moves to a later PR. It is fixed and reviewed before the commit (`CLAUDE.md`, step 5). diff --git a/CLAUDE.md b/CLAUDE.md index b865051..4bb2674 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -37,8 +37,8 @@ the CI workflow. There is no exception for "infrastructure". Never give the reviewer other conclusions of the author or earlier findings. The owner decided the brief and these rules on 2026-11-24: - - It reviews the uncommitted changes, before the commit. After CHANGES NEEDED, the fixed - changes get a new review. + - The reviewer reviews the uncommitted changes, before the commit. After CHANGES NEEDED, the + fixed changes get a new review. - Commit and push only when the checks are complete. The review must be APPROVED. When a coherence audit is due, it runs first, and each of its findings must be closed. - A finding of a review or an audit is closed in one of three ways: @@ -48,11 +48,15 @@ the CI workflow. There is no exception for "infrastructure". - The audit report is committed alone first, without a `fable-reviewer` review. It is pushed with the commit that closes its findings, or alone when no commit is needed. - Minor rounds have a limit. A round that is APPROVED with only minor points is a minor - round. After the third minor round on the same changes, the minor points left move to the - next PR, and no new round runs for them. Its verdict comment lists them as moved. The first - commit of the next PR fixes them or writes them into the roadmap step that will fix them. - - Some points never move: bugs, missing tests, and points on personal data, confirmation or - writing files (R28–R34). They are fixed and reviewed. + round. The count is of the minor rounds before one commit. A CHANGES NEEDED round in + between does not restart it; the next commit starts a new count. After the third minor + round, the minor points left move to the next PR. Those of the third round move too. No + new round runs for them. The verdict comment of that round lists them as moved. The + first commit of the next PR fixes them or writes them into the roadmap step that will fix + them. A point on the message of a commit already pushed is closed by a note in the message + of the next commit; history is not rewritten. + - Some points never move: bugs, missing tests, and points on personal data, or on + confirmation or writing files (R28–R34). They are fixed and reviewed before the commit. Post every verdict as a comment on the pull request, as soon as the PR exists: APPROVED or CHANGES NEEDED, the findings in short, how each was closed. After the commit, a comment names diff --git a/docs/design.md b/docs/design.md index 3b1a76f..6c5303b 100644 --- a/docs/design.md +++ b/docs/design.md @@ -67,7 +67,7 @@ saves the signed documents beside the originals, ready to open. only. With `--report `, one file for the whole run instead. `--no-report` skips it; R16 says when it does not apply. - R15. With `--json `, a JSON file with the same information, for scripts. -- R16. **What each command writes.** +- R16. What each command writes. - `check` (the default) writes no document. It writes only the HTML report (R14), the JSON file (R15) and the tool's own cache of trusted lists and CRLs (R47). - `extract` writes the signed documents beside the originals (`Relazione.pdf.p7m` -> @@ -88,7 +88,7 @@ saves the signed documents beside the originals, ready to open. - R32 has the rules for valid names. ### How is it used? -- R19. **Command line.** Commands: `check ...` (default), `extract ...`, +- R19. Command line. Commands: `check ...` (default), `extract ...`, `undo `, `install-menu`, `uninstall-menu`, `uninstall`. There is no `--apply`, `--yes` or `--expect`. - Every command that changes files or the system shows the exact plan first and acts only @@ -128,7 +128,7 @@ saves the signed documents beside the originals, ready to open. `--threads`, `--offline`, `--trust-lists `, `--trust-list `, `--lang `, `--interactive`, `--plain`, `--no-color`, `--plan`. Help is translated (R27). -- R20. **Interactive end of run** (double-click on Windows, context menu, `--interactive`). +- R20. Interactive end of run (double-click on Windows, context menu, `--interactive`). After the analysis, the tool offers to view the report or to extract. An extraction goes through the write plan and its confirmation (R29) and reuses the analysis already done. - The first report is never rewritten. The extraction writes a second report beside it (next @@ -169,7 +169,7 @@ No document is written without a second, separate confirmation on the full write There is never an implicit yes: R30 says how each kind of run confirms, and what runs from a script. R31 says how every file is created and which files may ever be replaced. -- R28. **Confirm before analysing.** After the folders are chosen, the tool only counts (no +- R28. Confirm before analysing. After the folders are chosen, the tool only counts (no envelope is opened) and asks a yes/no question (R30). - The question shows: folder, number of files to process (the envelopes, R1a), number of files of any kind, total size, number of subfolders, unreadable folders that will be @@ -186,12 +186,12 @@ script. R31 says how every file is created and which files may ever be replaced. hidden folders, behind symbolic links met during the walk, or in unreadable folders are not counted. A file in overlapping folders counts once. - Each kind of sensitive folder is judged on the path after resolving symbolic links. -- R29. **Confirm before writing.** An extraction first builds the complete write plan and shows +- R29. Confirm before writing. An extraction first builds the complete write plan and shows it: new documents, documents already present with identical content (not rewritten), documents saved under an alternative name `x (1).pdf`, and "existing files modified: 0" (always zero, shown as a guarantee). The full list can be viewed. To proceed, the user types the number of documents to write (language-neutral, cannot be confirmed by a stray key). -- R30. **Three ways to confirm, never an implicit yes.** +- R30. Three ways to confirm, never an implicit yes. - Terminal (`std::io::IsTerminal` on input and output): questions in the console (R19, R28, R29). "Terminal" means both input and output are a terminal. With output redirected (`| tee log`, `> file`) the run counts as a script. Yes/no questions default to No, and @@ -216,7 +216,7 @@ script. R31 says how every file is created and which files may ever be replaced. not a confirmation. Only these run: `check` in an ordinary run, `check --plan` (also in a risky run), `extract --plan` in an ordinary run, and `--plan` of `undo`, the menus and `uninstall` (a list). -- R31. **Never overwrite, never write outside.** This is the one place for these rules. +- R31. Never overwrite, never write outside. This is the one place for these rules. - In code, writing a document requires a `ConfirmedPlan` that only the confirmation step can build (typestate): a path that writes without confirmation does not compile. Originals are held in a read-only `Original` type that write functions do not accept. @@ -240,7 +240,7 @@ script. R31 says how every file is created and which files may ever be replaced. resolving `..` and symbolic links. - Free disk space is checked before starting. Ctrl+C finishes the current file, stops, and the report records what was done. -- R32. **Portable file names.** Names taken from envelopes (and the `(n)` variants) must be +- R32. Portable file names. Names taken from envelopes (and the `(n)` variants) must be valid on Windows, macOS and Linux at the same time, and on FAT32 and exFAT, whatever system the tool runs on (archives move between systems): - removed or replaced: `/` `\` `:` `*` `?` `"` `<` `>` `|`, NUL and control characters @@ -256,13 +256,13 @@ script. R31 says how every file is created and which files may ever be replaced. APFS default are case-insensitive; APFS treats NFC and NFD as the same name), so two documents never compete for names that the file system sees as equal; - the original name, when changed, is shown in the report. -- R33. **Undo.** The report written by an extraction records every document written, with its +- R33. Undo. The report written by an extraction records every document written, with its SHA-256 (R16, R20). `signspector undo ` removes only files written by SignSpector whose content still matches that hash. Changed or missing files are listed and left alone; originals are never touched. It shows what it would remove and removes it after a yes/no question (R30); never from a script. On a report that records no document it removes nothing and says so. -- R34. **Proof by tests.** A shared test helper snapshots the whole folder (paths and SHA-256) +- R34. Proof by tests. A shared test helper snapshots the whole folder (paths and SHA-256) before and after every end-to-end test: originals identical, nothing changed but the confirmed plan. - Writing and undo (R29, R31, R32, R33): at the count of documents (R29), an empty answer, @@ -348,7 +348,7 @@ Romania, France and the others. The LOTL points to each national trusted list an certificates that sign it. Checked on 2026-11-22: LOTL no. 398, 43 pointers (EU-27, Iceland, Liechtenstein, Norway, United Kingdom). -- R44. **Chain of trust.** The executable embeds the LOTL and the Commission's LOTL signing +- R44. Chain of trust. The executable embeds the LOTL and the Commission's LOTL signing certificates (published in the Official Journal of the EU). - The LOTL is used only if it verifies against the embedded Commission certificates. - A national list is used only if its XAdES signature verifies against the certificates the @@ -358,15 +358,15 @@ Liechtenstein, Norway, United Kingdom). network the tool refreshes them into its cache (R47). - XAdES needs XML canonicalisation (exclusive C14N) and XML signature verification. No mature pure-Rust library exists, so we write it here, test first, as carefully as the BER reader. -- R45. **Automatic choice.** The analysis collects the country of every certifier found in the +- R45. Automatic choice. The analysis collects the country of every certifier found in the files (`C=` of the issuing CA) and loads only those lists: from the cache if still valid, otherwise downloaded. The write plan (R29) and the report name them, for example "signatures from 3 countries: Italy, Romania, France; lists: Italy and France up to date, Romania downloaded now". -- R46. **Settable.** `--trust-lists auto` (default), `all` or `it,ro,fr`. `--trust-list ` +- R46. Settable. `--trust-lists auto` (default), `all` or `it,ro,fr`. `--trust-list ` loads a list by hand. `--offline` uses only the embedded copies and the cache. A missing list is reported as such ("list of Romania not available offline"), never as an invalid signature. -- R47. **Cache.** This is the one place for the cache rules. +- R47. Cache. This is the one place for the cache rules. - Lists, and the CRLs of R49, are cached in the SignSpector cache folder and refreshed when their own `NextUpdate` date passes. A cached list that verifies (R44) takes precedence over the embedded copy. Removing the cache is R40. @@ -378,12 +378,12 @@ Liechtenstein, Norway, United Kingdom). taken from the input. - It never replaces another file found in that folder. A cache file is replaced only as R31 says: a new file, a rename, no symbolic link. -- R48. **Verdicts.** Qualified status is checked at the reference time (R9) using the service +- R48. Verdicts. Qualified status is checked at the reference time (R9) using the service history in the list: a service withdrawn later still validates an earlier signature. A certifier on no list is reported as "not on a European trusted list", distinct from "invalid signature". Any country listed in the official LOTL is accepted, the United Kingdom included. The report names every list used (country, sequence number, issue date). -- R49. **Revocation without a query per signature.** Network traffic grows with the number of +- R49. Revocation without a query per signature. Network traffic grows with the number of certificates, never with the number of files. There is one result per certificate: the same certificate in a thousand files is checked once. A CRL is fetched at most once per CA per run (partitioned CRLs: question "Before 3.9"). @@ -424,7 +424,7 @@ WCAG 2.2 level AA for the HTML report and the user guide. Whoever deploys the to public administration checks the applicable obligations (for example an accessibility statement). -- R35. **Console.** +- R35. Console. - Information is never conveyed by colour or symbols alone. Every status is a word ("OK", "Warning", "Error" in the user's language); colours only reinforce it, with sufficient contrast on both light and dark terminals, never red/green as the only difference. Colours @@ -438,7 +438,7 @@ statement). out in words; keyboard only; no time limits on any prompt. - Messages in plain language. Every error says what happened, which file, and what the user can do. -- R36. **HTML report (WCAG 2.2 AA).** +- R36. HTML report (WCAG 2.2 AA). - `lang` set to the report language; a meaningful ``; landmarks (`header`, `main`, `nav`) and a "skip to content" link; headings in order, no level skipped. - Real tables with `<caption>` and `<th scope>`. Status is shown as text (with an optional @@ -449,29 +449,29 @@ statement). data tables, which scroll on their own). - Fully keyboard operable (`<details>` and `<summary>` for expandable parts), visible focus, no keyboard traps; works without JavaScript; descriptive link texts; prints readably. -- R37. **Documentation and help** (EN 301 549 ch. 12): `--help` and the user guide are plain text +- R37. Documentation and help (EN 301 549 ch. 12): `--help` and the user guide are plain text or HTML (no scanned or untagged PDF), translated, and include a section on the accessibility features (`--plain`, `--no-color`, keyboard use, screen readers). -- R38. **Context menu and dialogs**: only native OS menus and native dialogs, which inherit the +- R38. Context menu and dialogs: only native OS menus and native dialogs, which inherit the OS accessibility (screen readers, keyboard), with clear labels in the user's language. The dialogs ask the confirmations of R30 for runs started from the context menu. No custom-drawn GUI, no PowerShell. Helper programs that show a dialog are run from fixed system paths (`/usr/bin/osascript`, `/usr/bin/zenity`...), never found through `PATH`. Folder names reach them as arguments, never spliced into script source or markup. -- R39. **Verification.** Automated: unit tests on the HTML structure (lang, headings, table +- R39. Verification. Automated: unit tests on the HTML structure (lang, headings, table headers, no colour-only status), an accessibility checker on sample reports in CI (for example `axe-core` or `pa11y`), and console tests with `NO_COLOR` and `--plain`. Manual before each release: NVDA on Windows, VoiceOver on macOS, Orca on Linux, keyboard only, 200% zoom, Windows high contrast. Results are recorded in `docs/accessibility.md`. ### How is it uninstalled? -- R40. **`signspector uninstall`** removes everything SignSpector added to the system, and only +- R40. `signspector uninstall` removes everything SignSpector added to the system, and only that: context menu entries, the Windows "Installed apps" entry (R42), the trust-list and CRL cache, and the install manifest (R41). SignSpector saves no preferences and keeps no log files; the record of written documents is in the report (R33). As every command that changes something (R19), it shows the exact list of what it would remove and removes it after a yes/no question; never from a script (R30); accessible like the rest (R35). -- R41. **Only what we installed.** +- R41. Only what we installed. - `install-menu` records every item it creates (path or registry key, plus a hash of the content) in a manifest in the SignSpector config folder. `uninstall` removes only manifest items that still match; it reports changed or foreign items and leaves them. @@ -487,7 +487,7 @@ statement). Running `install-menu` twice is harmless. - `install-menu` and `uninstall-menu` are the only commands that replace the manifest (R31); `uninstall` removes it (R40). -- R42. **Per platform.** +- R42. Per platform. - Windows: per-user, no admin. Registry keys under `HKCU`, plus an uninstall entry in `HKCU\Software\Microsoft\Windows\CurrentVersion\Uninstall\SignSpector`, so the user finds it in Settings -> Apps. Its `UninstallString` runs @@ -500,7 +500,7 @@ statement). manifest in `~/.config/signspector`. `.deb` and `.rpm` remove only system files they installed; the per-user items are removed by `signspector uninstall` (the package's removal message says so). -- R43. **User data is never removed**: originals, extracted documents and reports stay. At the +- R43. User data is never removed: originals, extracted documents and reports stay. At the end the tool lists what it left in place on purpose and where the executable is. ## How is the code organised? diff --git a/docs/roadmap.md b/docs/roadmap.md index eee2fe5..f52a26a 100644 --- a/docs/roadmap.md +++ b/docs/roadmap.md @@ -4,12 +4,12 @@ Each step is test-driven: red, green, refactor. A new `fable-reviewer` agent reviews the changes of each commit before they are committed; the audit report is the one exception (`CLAUDE.md`). A -step is done when the review of its last changes is APPROVED and CI is green on all four jobs. -Only then is its PR merged (owner's decision, 2026-11-24). Each step writes the tests of R34 for -the commands and modules it introduces, as soon as they can be tested. R34 is the only list of -these tests; the review of each step checks the step against it (owner's decision, 2026-11-24). -Mark the step done here (`[x]`) in the PR that completes it; the coherence audit checks that the -mark is true. Requirements (R…) are in `docs/design.md`. +step is done when the review of its last changes is APPROVED and CI is green on all four jobs on +its last commit. Only then is its PR merged (owner's decision, 2026-11-24). Each step writes the +tests of R34 for the commands and modules it introduces, as soon as they can be tested. R34 is +the only list of these tests; the review of each step checks the step against it (owner's +decision, 2026-11-24). Mark the step done here (`[x]`) in the PR that completes it; the +coherence audit checks that the mark is true. Requirements (R…) are in `docs/design.md`. ## Why this order? @@ -75,7 +75,8 @@ in the script tests. 3.9, 4.2, 4.4, 5.1, 5.2, 5.3. - [ ] 0.5 Remaining gaps in the rule-script tests. The reviews of PR #1, PR #2 and PR #3 found them, and they are accepted as known limits for now. Each needs a test before the code - changes. + changes, except the last item. That one, the review trace, is an open point on the review + process, for the owner to decide. - `check-public.sh`: - failures of `git show`, `ls-tree` and `diff-tree` are not each tested; - names of people, phone numbers, IPs, base64 content and branch names are not detected From 39635f6b88d4337c90bd4627785ba3db4b8e349a Mon Sep 17 00:00:00 2001 From: Bertalan Ivan <2826311+bertalan@users.noreply.github.com> Date: Tue, 24 Nov 2026 23:44:45 +0100 Subject: [PATCH 2/5] Tie each APPROVED verdict to the tree of its commit Owner's decision of 2026-11-24 on the review trace: it becomes a rule. The reviewer reports the tree of its staged copy (git write-tree), on a TREE line after the verdict. The verdict comment quotes it, with the subject line of the reviewed message. After the commit, git rev-parse HEAD^{tree} must give the same tree. If it does not, nothing is pushed: the commit is undone locally and reviewed again. The auditor compares tree and subject for every commit from 2852907 on. The open item in roadmap 0.5 is gone. Where moved points go (owner's decision, 2026-11-24): to the next commit of the same PR when more commits are planned in it, otherwise to the first commit of the next PR. .gitignore now ignores .claude/worktrees/, where agents working in parallel keep their copies. The reviewer leaves that folder out of its scratch copy, so the reported tree never picks them up. This commit also closes the two minor points that round 3 of the review of 2852907 moved on: - CLAUDE.md and the auditor prompt now agree on the note for a point on a pushed commit message: a note in the message of a later commit, listed as one of the ways to close a finding. - The lead-in of roadmap 0.5 says "except where an item says otherwise", since its "Rust" section lists items that are not tested by the owner's decision. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --- .claude/agents/coherence-auditor.md | 12 ++++++++---- .claude/agents/fable-reviewer.md | 18 +++++++++++------- .gitignore | 3 ++- CLAUDE.md | 22 +++++++++++++++------- docs/roadmap.md | 8 +------- 5 files changed, 37 insertions(+), 26 deletions(-) diff --git a/.claude/agents/coherence-auditor.md b/.claude/agents/coherence-auditor.md index 90cd4e7..dfabdb4 100644 --- a/.claude/agents/coherence-auditor.md +++ b/.claude/agents/coherence-auditor.md @@ -54,13 +54,17 @@ Read first: `CLAUDE.md`, `docs/design.md`, `docs/roadmap.md`, the latest report - every commit after 79025cd (audit 0010) follows an APPROVED verdict that a comment ties to it. Earlier commits predate the rule. The one exception is an audit report: a commit that adds only one file under `docs/audits/` (check with `git show --stat`); - - every finding of the previous audit and of the reviews is closed in one of three ways: + - for every such commit from 2852907 on, the tree its last APPROVED verdict comment quotes + equals `git rev-parse <commit>^{tree}`. When that comment quotes a subject line, it equals + `git log -1 --format=%s <commit>`; + - every finding of the previous audit and of the reviews is closed in one of these ways: - fixed and reviewed; - written into the roadmap step that will fix it; - declared wrong by the owner, with the reason in a PR comment; - - every minor point a verdict comment lists as moved to the next PR is closed by the first - commit of that PR: fixed, written into a roadmap step, or, for a point on the message of a - pushed commit, noted in the message of that first commit. + - for a point on the message of a pushed commit, a note in the message of a later commit; + - every minor point a verdict comment lists as moved is closed, in one of the ways above, by + the commit it moved to. That is the next commit of the same PR, or the first commit of the + next PR. 7. Health. Run `cargo fmt --check`, `cargo clippy --all-targets -- -D warnings`, `cargo nextest run`, `cargo test --doc` and `cargo deny check`. Report the actual results. diff --git a/.claude/agents/fable-reviewer.md b/.claude/agents/fable-reviewer.md index 8336b0b..dee00fb 100644 --- a/.claude/agents/fable-reviewer.md +++ b/.claude/agents/fable-reviewer.md @@ -103,9 +103,12 @@ The brief holds: 6. Nothing reaches the public repository that could carry personal or sensitive data (see the section "What may never reach the public repository?" of `CLAUDE.md`). No mode of the public check reads the working tree: `--staged` reads the index, and you must not touch the - repository's index. Copy the repository to the scratchpad (without `target/`, `tests/corpus/` - and `tests/out/`), run `git add -A` in the copy, then `sh scripts/check-public.sh --staged` - there. Check the planned commit message with `sh scripts/check-public.sh --message <file>`. + repository's index. Copy the repository to the scratchpad (without `target/`, `tests/corpus/`, + `tests/out/` and `.claude/worktrees/`), run `git add -A` in the copy, then + `sh scripts/check-public.sh --staged` there. Check the planned commit message with + `sh scripts/check-public.sh --message <file>`. + In the same copy, run `git write-tree` and report the tree: it ties your verdict to the + commit (`CLAUDE.md`, step 5). ## How is TDD proved? @@ -125,10 +128,11 @@ fails. Report every rule whose breakage no test notices. ## What does the report look like? -Start with one line: `VERDICT: APPROVED` or `VERDICT: CHANGES NEEDED`. Then list the findings, -most severe first. Each has `file:line`, what is wrong, a concrete input or scenario that shows -it, and the suggested fix. Separate "bug" from "missing test" from "minor". No praise, no -summary of what the code does. Write the report in English. +Start with one line: `VERDICT: APPROVED` or `VERDICT: CHANGES NEEDED`. The next line gives the +tree of the reviewed copy: `TREE: <hash>`. Then list the findings, most severe first. Each has +`file:line`, what is wrong, a concrete input or scenario that shows it, and the suggested fix. +Separate "bug" from "missing test" from "minor". No praise, no summary of what the code does. +Write the report in English. When every finding is minor, the verdict is `VERDICT: APPROVED`, with the minor points listed. Mark each point on personal data, or on confirmation or writing files (R28–R34): such a point diff --git a/.gitignore b/.gitignore index 4e2f2a1..b385c05 100644 --- a/.gitignore +++ b/.gitignore @@ -8,5 +8,6 @@ .DS_Store -# Claude Code personal settings +# Claude Code personal settings, and worktrees of agents working in parallel /.claude/settings.local.json +/.claude/worktrees/ diff --git a/CLAUDE.md b/CLAUDE.md index 4bb2674..6d2ac68 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -41,22 +41,30 @@ the CI workflow. There is no exception for "infrastructure". fixed changes get a new review. - Commit and push only when the checks are complete. The review must be APPROVED. When a coherence audit is due, it runs first, and each of its findings must be closed. - - A finding of a review or an audit is closed in one of three ways: + - A finding of a review or an audit is closed in one of these ways: - fixed and reviewed; - written into the roadmap step that will fix it; - - declared wrong by the owner, with the reason in a PR comment. + - declared wrong by the owner, with the reason in a PR comment; + - for a point on the message of a commit already pushed, a note in the message of a later + commit. History is not rewritten. - The audit report is committed alone first, without a `fable-reviewer` review. It is pushed with the commit that closes its findings, or alone when no commit is needed. - Minor rounds have a limit. A round that is APPROVED with only minor points is a minor round. The count is of the minor rounds before one commit. A CHANGES NEEDED round in between does not restart it; the next commit starts a new count. After the third minor - round, the minor points left move to the next PR. Those of the third round move too. No - new round runs for them. The verdict comment of that round lists them as moved. The - first commit of the next PR fixes them or writes them into the roadmap step that will fix - them. A point on the message of a commit already pushed is closed by a note in the message - of the next commit; history is not rewritten. + round, the minor points left move on. Those of the third round move too. No new round runs + for them. They move to the next commit of the same PR when more commits are planned in it + (owner's decision, 2026-11-24). Otherwise they move to the first commit of the next PR. The + verdict comment of that round lists them as moved. The commit they move to fixes them or + writes them into the roadmap step that will fix them. For a point on the message of a + pushed commit, that commit carries the note. - Some points never move: bugs, missing tests, and points on personal data, or on confirmation or writing files (R28–R34). They are fixed and reviewed before the commit. + - The review leaves a trace of what it approved. The reviewer reports the tree of its + staged copy (`git write-tree`). The verdict comment quotes it, with the subject line of the + reviewed commit message. After the commit, `git rev-parse HEAD^{tree}` must give the same + tree. If it does not, nothing is pushed: the commit is undone locally and the changes get + a new review. The comment that names the commit quotes the tree too. Post every verdict as a comment on the pull request, as soon as the PR exists: APPROVED or CHANGES NEEDED, the findings in short, how each was closed. After the commit, a comment names diff --git a/docs/roadmap.md b/docs/roadmap.md index f52a26a..f2bee19 100644 --- a/docs/roadmap.md +++ b/docs/roadmap.md @@ -75,8 +75,7 @@ in the script tests. 3.9, 4.2, 4.4, 5.1, 5.2, 5.3. - [ ] 0.5 Remaining gaps in the rule-script tests. The reviews of PR #1, PR #2 and PR #3 found them, and they are accepted as known limits for now. Each needs a test before the code - changes, except the last item. That one, the review trace, is an open point on the review - process, for the owner to decide. + changes, except where an item says otherwise. - `check-public.sh`: - failures of `git show`, `ls-tree` and `diff-tree` are not each tested; - names of people, phone numbers, IPs, base64 content and branch names are not detected @@ -130,11 +129,6 @@ in the script tests. - `core.commentChar` other than `#`: `git commit -v` is refused (fails closed); - untested: `cleanup.sh` `--no-merged` with a detached HEAD at an unmerged commit; a refused push and a crashing hook both exit 1. - - Review trace (review of the closing changes of audit 0010, 2026-11-24): nothing ties an - APPROVED verdict to the content of the commit that follows. A change made between the - verdict and the commit cannot be seen later. Proposal for the owner to decide: the reviewer - reports `git write-tree` of its staged copy, and the auditor compares it with - `git rev-parse <commit>^{tree}`. ## Phase 1: how do we write files safely, before any cryptography? From 74cb34c799acb5454f01896a9c1d6f82c4b22b46 Mon Sep 17 00:00:00 2001 From: Bertalan Ivan <2826311+bertalan@users.noreply.github.com> Date: Wed, 25 Nov 2026 11:34:49 +0100 Subject: [PATCH 3/5] Close the gaps in the rule-script tests Roadmap 0.5, test first; the step is marked done. Three agents worked in parallel git worktrees; their changes are merged here, with the fixes of the reviews of this commit. check-public.sh and the hooks: - A failing git command stops the check with exit 2, never a silent pass: show, ls-tree, diff-tree, cat-file, log, rev-list and diff (13 tests, plus 2 controls of the git wrapper). - A failing git rev-list --parents let a merge commit through unscanned, since the exit status was that of wc (bug found in review, test first). - A failing git cat-file -t on a tag skipped the tag scan and passed (bug, test first). - Nested annotated tags are scanned to the innermost one. Before, only the outer message was scanned (bug, test first; 7 tests, up to three levels). - Every hook refuses when its check finds a problem, is missing or cannot run, for check-public.sh and audit-status.sh alike (16 tests). cleanup.sh (tests only, no change to the script): - the "still merged into main" check just before deletion, with a branch that moves while the script runs; - a branch created at main is removed (audit 0003, F6); - a detached HEAD at an unmerged commit; - the skip counts of the blocks skipped on Windows are still written by hand. Off Windows they are now checked: a block that runs a different number of checks fails. audit-status.sh: - Everything that is not green counts as red (owner's decision, 2026-11-24). The rule is an allowlist. A check run is red when its conclusion is not empty and not SUCCESS, NEUTRAL or SKIPPED. A status is red when its state is not empty and not SUCCESS, PENDING or EXPECTED. So STALE and any value GitHub adds later are red; a row of an unknown type is judged by the same lists. NEUTRAL and SKIPPED are green, as in GitHub's branch protection: the report flags what would block a merge. - Only the latest attempt of each check counts (owner's decision, 2026-11-25). An attempt not started yet, with empty values, is the latest, so a queued re-run is not red (owner's decision: a queued re-run is in progress). A finished attempt with no start time is older than any with a time. Each type has its own green list. - A check is one pull request, one type, one workflow and one name. Without the workflow or the type, a red check could hide behind a green one of the same name (two bugs found in review, test first). - When a gh call fails (network, API limit), the report says "not read" for open pull requests, their checks, the CI runs and the interaction limit, never "no open pull requests", "no CI runs" or "interaction limit not active". - A red check is printed as "workflow / name", and "(no name)" when it has none. - The hooks check accepts core.hooksPath set to ".githooks" or to the absolute path of this repository's .githooks, in POSIX or Windows drive-letter form. The two paths are compared as files (test -ef), not as strings. - The CI runs on main and the open pull requests are tested under their headings. - The gh stub returns raw data, so the tests check which checks are selected as red, including equal start times and the type guards. - New tests for uncommitted changes, stashes and the unpushed and not-pulled counts. A test that checks a line is absent now fails when its section prints nothing, except in the "Rust" section. The "no warning with hooks" test checks that the report printed. Roadmap 0.5 now lists what this step closed and the known limits that remain. The owner marked the step done with them listed. Eight limits are new: - the jq projection in the gh call is not tested; - gh gives no event, so a green manual run of a job hides a failed run of the same job; - a check name with a backslash prints doubled; - gh pr list reads at most 30 open pull requests; - the exit status of the awk that selects red checks is not checked; - start times are compared as strings; - a commit held only by a detached HEAD is not reported; - nothing checks that every off_windows block ends with end_off_windows. Roadmap 0.6 is new: the four changes to the way of working that the owner adopted on 2026-11-25 ("Done when" for every step, a merge-ready script, the model chosen by risk with PRs of about 400 lines, and a lessons file with no CI watching by agents). Minor points moved from round 3 of the review of 39635f6: - CLAUDE.md names the command to undo a commit whose tree does not match (git reset --soft HEAD~1), and says "when the author plans more commits". - The auditor prompt checks the tree in the comment that names the commit, and the subject line from 39635f6 on. - CLAUDE.md points to the known limits of roadmap 0.5 as the other untested parts of the rule scripts. - CLAUDE.md says where parallel agents work and who removes their worktrees: after comparing the worktree with the patch it took, git worktree remove --force and git branch -D. - Note on the message of 39635f6: the ignore rule keeps .claude/worktrees/ out of the reported tree; the reviewer leaving that folder out of its copy only avoids copying other work. The message of 39635f6 also says the auditor compares tree and subject from 2852907 on; the subject is compared from 39635f6 on. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --- .claude/agents/coherence-auditor.md | 5 +- CLAUDE.md | 26 +- docs/roadmap.md | 114 ++++---- scripts/audit-status.sh | 120 +++++++- scripts/check-public.sh | 19 +- scripts/test-cleanup.sh | 63 ++++- scripts/test-hooks.sh | 78 ++++++ scripts/test-scripts.sh | 408 ++++++++++++++++++++++++++-- 8 files changed, 737 insertions(+), 96 deletions(-) diff --git a/.claude/agents/coherence-auditor.md b/.claude/agents/coherence-auditor.md index dfabdb4..498b416 100644 --- a/.claude/agents/coherence-auditor.md +++ b/.claude/agents/coherence-auditor.md @@ -54,8 +54,9 @@ Read first: `CLAUDE.md`, `docs/design.md`, `docs/roadmap.md`, the latest report - every commit after 79025cd (audit 0010) follows an APPROVED verdict that a comment ties to it. Earlier commits predate the rule. The one exception is an audit report: a commit that adds only one file under `docs/audits/` (check with `git show --stat`); - - for every such commit from 2852907 on, the tree its last APPROVED verdict comment quotes - equals `git rev-parse <commit>^{tree}`. When that comment quotes a subject line, it equals + - for every such commit from 2852907 on, the tree in its last APPROVED verdict comment + equals `git rev-parse <commit>^{tree}`. The comment that names the commit quotes the same + tree. From 39635f6 on, the verdict comment also quotes the subject line. It equals `git log -1 --format=%s <commit>`; - every finding of the previous audit and of the reviews is closed in one of these ways: - fixed and reviewed; diff --git a/CLAUDE.md b/CLAUDE.md index 6d2ac68..9d2aec9 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -26,7 +26,8 @@ the CI workflow. There is no exception for "infrastructure". Rules that protect (scripts under `scripts/`, safety code) are also checked by breaking each rule on a copy and seeing at least one test fail. A rule that no test notices gets a test. One exception, decided by the owner: in the "Rust" section of `audit-status.sh`, a breakage - that shows no bug is listed, not tested (`docs/roadmap.md`, 0.5). + that shows no bug is listed, not tested. The other known limits of the rule scripts are + listed in `docs/roadmap.md`, 0.5; the owner marked that step done with them listed. 5. Independent review, by a newly started `fable-reviewer` agent for every review: a different model, of equal or higher capability than the author's. Never resume the reviewer. The brief holds only: @@ -53,18 +54,19 @@ the CI workflow. There is no exception for "infrastructure". round. The count is of the minor rounds before one commit. A CHANGES NEEDED round in between does not restart it; the next commit starts a new count. After the third minor round, the minor points left move on. Those of the third round move too. No new round runs - for them. They move to the next commit of the same PR when more commits are planned in it - (owner's decision, 2026-11-24). Otherwise they move to the first commit of the next PR. The - verdict comment of that round lists them as moved. The commit they move to fixes them or - writes them into the roadmap step that will fix them. For a point on the message of a - pushed commit, that commit carries the note. + for them. They move to the next commit of the same PR when the author plans more commits + in it (owner's decision, 2026-11-24). Otherwise they move to the first commit of the next + PR. The verdict comment of that round lists them as moved. The commit they move to fixes + them or writes them into the roadmap step that will fix them. For a point on the message + of a pushed commit, that commit carries the note. - Some points never move: bugs, missing tests, and points on personal data, or on confirmation or writing files (R28–R34). They are fixed and reviewed before the commit. - The review leaves a trace of what it approved. The reviewer reports the tree of its staged copy (`git write-tree`). The verdict comment quotes it, with the subject line of the reviewed commit message. After the commit, `git rev-parse HEAD^{tree}` must give the same - tree. If it does not, nothing is pushed: the commit is undone locally and the changes get - a new review. The comment that names the commit quotes the tree too. + tree. If it does not, nothing is pushed. Undo the commit with `git reset --soft HEAD~1`, + which keeps the changes, and send them to a new review. The comment that names the commit + quotes the tree too. Post every verdict as a comment on the pull request, as soon as the PR exists: APPROVED or CHANGES NEEDED, the findings in short, how each was closed. After the commit, a comment names @@ -124,6 +126,14 @@ do, references point to functions or options that never existed, work is left ha only lists them. The main session runs the removing form after an audit; agents (auditor, reviewer) run only `sh scripts/cleanup.sh --plan`. - Worktrees, backups (`*.bak`), editor files and other untracked files are only listed. + - Agents that work in parallel each get a git worktree under `.claude/worktrees/` (ignored by + git). They never commit there; the main session takes their changes as a patch. When the + changes are committed, the main session removes the worktree and its branch, locally. + First it compares `git -C <worktree> diff HEAD` and + `git -C <worktree> status --porcelain --untracked-files=all` with the patch it took: a change + made after the patch is taken again or reported, never lost. Then + `git worktree remove --force` and `git branch -D`. `--force` is needed because the worktree + still has uncommitted files. - Ignored folders are never touched. `tests/corpus/`, `tests/out/` and `target/` are protected even if `.gitignore` lacks them. - Deletion happens only locally, from the development environment, never on GitHub. Merged diff --git a/docs/roadmap.md b/docs/roadmap.md index f2bee19..eb1052e 100644 --- a/docs/roadmap.md +++ b/docs/roadmap.md @@ -23,8 +23,8 @@ Two ideas set it: ## Phase 0: what must be in place before the code? -The repository, CI, the writing guide and the fixture generator, plus a list of the known gaps -in the script tests. +The repository, CI, the writing guide and the fixture generator, a list of the known gaps in the +script tests, and the changes to the way of working adopted on 2026-11-25. - [x] 0.1 First commit and push to `main`, after a review of the file list. From then on: one branch and one draft PR per step, a coherence audit every 5 commits, merges by local @@ -73,62 +73,76 @@ in the script tests. The questions these decisions opened are in "What is still open?" in `docs/design.md`. Each names the roadmap step that needs the answer: 1.4, 1.5, 1.6, 1.7, 3.1, 3.2, 3.5, 3.6, 3.7, 3.9, 4.2, 4.4, 5.1, 5.2, 5.3. -- [ ] 0.5 Remaining gaps in the rule-script tests. The reviews of PR #1, PR #2 and PR #3 found - them, and they are accepted as known limits for now. Each needs a test before the code - changes, except where an item says otherwise. - - `check-public.sh`: - - failures of `git show`, `ls-tree` and `diff-tree` are not each tested; - - names of people, phone numbers, IPs, base64 content and branch names are not detected - (header "Known limits"). - - `cleanup.sh`: +- [x] 0.5 Remaining gaps in the rule-script tests. The reviews of PR #1, PR #2 and PR #3 found + them. This step closed the ones below that are not listed as known limits. The owner marked + the step done with these limits listed (2026-11-25). Each known limit needs a test before the + code it names changes. + - Closed in this step, test first: + - `check-public.sh`: a failing `git show`, `ls-tree`, `diff-tree`, `cat-file`, `log`, + `rev-list` or `diff` stops the check with exit 2. Two of them passed in silence before: + `rev-list --parents` on a merge commit and `cat-file -t` on a tag. Nested annotated tags + are scanned to the innermost one; + - hooks: a check that finds a problem, is missing or cannot run makes every hook refuse; + - `cleanup.sh`: the "still merged into main" check just before deletion, a branch created + at `main` (audit 0003, F6), a detached HEAD at an unmerged commit, checked skip counts; + - `audit-status.sh`, what counts as red: everything that is not green, and only the latest + attempt of each check (owner's decisions, 2026-11-24 and 2026-11-25). NEUTRAL and SKIPPED + are green, as in GitHub's branch protection: the report flags what would block a merge; + - `audit-status.sh`, other tests: uncommitted changes, stashes and the unpushed and + not-pulled counts now have tests. A test that checks a line is absent now fails when its + section prints nothing, except in the "Rust" section (below); + - `audit-status.sh`, failures said: a failing `gh` call prints "not read" for open pull + requests, their checks, the CI runs and the interaction limit. `core.hooksPath` may be the + absolute path of this repository's `.githooks`, in POSIX or drive-letter form. + - Known limits of `check-public.sh`: the list is in the header of the script, "Known limits" + (for example names of people, phone numbers and IPs are not detected). + - Known limits of `cleanup.sh`: - on Windows 5 checks are skipped: names with `\` cannot exist there, and a read-only folder does not stop `rm`. Those rules are tested on macOS and Linux only; - on Windows the double-quote check runs but does not exercise git's quoting; - - the numbers passed to `skip` are written by hand; - the GitHub section duplicates `audit-status.sh`; - "never asks" is checked on the script's text (a word list) and with input on a pipe, never at a real terminal; - - the check "still merged into main" (with full ref names) just before a branch is deleted - has no test. It guards a race; - - no test fixes the choice that a branch just created at `main` is removed (audit 0003, F6). - - `audit-status.sh`, unfinished-work section: - - uncommitted changes, stashes and the unpushed / not pulled counts have no test; - - these have one: - - the "AUDIT DUE" and "RED CHECKS" lines; - - the current branch name; - - unmerged local and remote branches; - - a missing `main` or `origin/main`; - - the `origin/HEAD` filter; - - "no tags or other refs"; - - the "RED CHECKS" test covers the printed line and its absence, not which checks are - selected as red (the `gh` stub returns the formatted line); - - only `FAILURE` counts as red today, not cancelled or timed-out jobs nor commit statuses: - decide and test; - - the negative RED CHECKS case does not assert that the GitHub section ran, and its stub has - a dead first line; - - report-mode tests pass if the script prints nothing in that section. - - `audit-status.sh`, "Rust" section: - - five review rounds on PR #3. The reviews of 2557e7f and 1ac9d1d found minor bugs. All but - one were fixed in 1ac9d1d and c3f070e; the one left is the missing time limit on - `rustup check` (below); - - the reviews of c3f070e, 1363b18 and fb41029 found no bug, only breakages no test noticed. - The owner decided (2026-11-23) to stop the rounds there. A breakage of this section that - shows no bug is listed on the PR and here, not closed with another round; - - known limit: `rustup check` has no time limit. It runs only in report mode, after the hook - gates, so no commit or push waits on it; - - three rules are correct today, but breaking them on a copy leaves all tests green (review - of 40e2d4c): - - unescaping the first dot of the x.y.z check (`1x100.0` would then pass); - - accepting only a single digit for the major and patch numbers (`10.0.0` would then be - "not x.y.z"); - - letting the captured rustup version start with a dot. - - From the targeted review of the third-round fixes: + - nothing checks that every `off_windows` block ends with `end_off_windows`; + - a commit that only a detached HEAD holds is not mentioned in any report. Nothing removes + it. + - Known limits of `audit-status.sh`: + - the `jq` projection inside the `gh` call is not tested: the stub returns its output; + - `gh` gives no event for a check. Two runs of the same workflow and job on one head count + as one check. Example: a green manual `workflow_dispatch` run hides a failed + `pull_request` run; + - start times are compared as strings, which holds for GitHub's whole-second times; + - a check name with a backslash is printed with the backslash doubled (`@tsv` escapes it); + - `gh pr list` reads at most 30 open pull requests, its default; + - the exit status of the `awk` that selects the red checks is not checked; + - "Rust" section: the owner decided (2026-11-23) that a breakage of this section that shows + no bug is listed here, not tested. These are listed: + - `rustup check` has no time limit. It runs only in report mode, after the hook gates; + - its negative tests pass on a section that prints nothing; + - three rules are correct today, but breaking them on a copy leaves all tests green + (review of 40e2d4c): + - unescaping the first dot of the x.y.z check (`1x100.0` would then pass); + - accepting only a single digit for the major and patch numbers (`10.0.0` would then + be "not x.y.z"); + - letting the captured rustup version start with a dot. + - Known limits of the hooks: - the first push to a new remote scans the whole history and stops on the accepted exception `cd3620d` (`CLAUDE.md`). Encode the exception if a second remote is ever added; - - nested annotated tags: only the outer message is scanned; - - `core.commentChar` other than `#`: `git commit -v` is refused (fails closed); - - untested: `cleanup.sh` `--no-merged` with a detached HEAD at an unmerged commit; a refused - push and a crashing hook both exit 1. + - `core.commentChar` other than `#`: `git commit -v` is refused (fails closed). + +- [ ] 0.6 Way of working: the four changes the owner adopted on 2026-11-25. + - "Done when" for every step: a list of checks that prove the step is done. The PR + description maps each item to its evidence: a test, a commit or a file. The reviewer and + the auditor check that list. The open steps get theirs in this step. + - `scripts/merge-ready.sh`, test first. It waits until the four CI jobs are green on the + exact head of the PR, and stops if the head moves. It also checks that the last verdict + comment is APPROVED and quotes the tree of that head. The merge goes ahead only after it. + - Model by risk. Sonnet writes routine code: scripts, their tests, docs. Opus writes the code + for cryptography and for R28–R34. Reviews and audits stay on Fable. A PR holds about 400 + changed lines; a bigger step is split into slices, and the PR says what is left. + - `docs/lessons.md`: lessons learnt on the way of working, each with its date and what to do. + Agents never watch CI themselves; only the main session does, so that GitHub's API limit is + not used up. ## Phase 1: how do we write files safely, before any cryptography? diff --git a/scripts/audit-status.sh b/scripts/audit-status.sh index 2a49ee2..85cd52f 100755 --- a/scripts/audit-status.sh +++ b/scripts/audit-status.sh @@ -60,7 +60,23 @@ esac section() { printf '\n== %s\n' "$1"; } -if [ "$(git config core.hooksPath)" != .githooks ]; then +# The hooks run from this repository's .githooks folder, named relative or by absolute path. +hooks_path=$(git config core.hooksPath || true) +hooks_ok=no +if [ "$hooks_path" = .githooks ]; then + hooks_ok=yes +else + case "$hooks_path" in + /*|[A-Za-z]:/*|[A-Za-z]:\\*) + # Same folder by identity (-ef), not by path text. On Windows runners the temporary + # folder may be reached by a short 8.3 name (RUNNER~1) on one side and the long name + # on the other. + hooks_top=$(git rev-parse --show-toplevel) + [ -d "$hooks_path" ] && [ -d "$hooks_top/.githooks" ] && + [ "$hooks_path" -ef "$hooks_top/.githooks" ] && hooks_ok=yes ;; + esac +fi +if [ "$hooks_ok" != yes ]; then echo "HOOKS NOT ENABLED in this clone: nothing stops a commit or push with personal data." echo "Run: git config core.hooksPath .githooks" fi @@ -136,23 +152,103 @@ exec </dev/null if command -v gh >/dev/null 2>&1 && gh auth status >/dev/null 2>&1; then # Only collaborators may open PRs, issues and comments; GitHub limits this to 6 months. repo=$(gh repo view --json nameWithOwner --jq .nameWithOwner 2>/dev/null) - expires=$(gh api "repos/$repo/interaction-limits" --jq '.expires_at // ""' 2>/dev/null | cut -c1-10) + # A failing gh api is said: it is not a missing limit. + limit_read=yes + expires=$(gh api "repos/$repo/interaction-limits" --jq '.expires_at // ""' 2>/dev/null) || + limit_read=no + expires=$(printf '%s' "$expires" | cut -c1-10) warn_from=$(date -u -v+30d +%Y-%m-%d 2>/dev/null || date -u -d '+30 days' +%Y-%m-%d) - if [ -z "$expires" ]; then + if [ "$limit_read" = no ]; then + echo "interaction limit not read (gh api failed)" + elif [ -z "$expires" ]; then echo "INTERACTION LIMIT NOT ACTIVE: anyone can open PRs and issues. Renew it on GitHub:" echo " Settings > Moderation options > Interaction limits > Limit to repository collaborators (6 months)" elif [ "$expires" != "$warn_from" ] && [ "$(printf '%s\n%s\n' "$expires" "$warn_from" | sort | head -n 1)" = "$expires" ]; then echo "INTERACTION LIMIT EXPIRES on $expires: renew it on GitHub (Settings > Moderation options)." fi - prs=$(gh pr list --state open --json number,title,isDraft,updatedAt,headRefName \ - --jq '.[] | "#\(.number) \(if .isDraft then "DRAFT" else "open" end) \(.headRefName) updated \(.updatedAt[:10]): \(.title)"' 2>/dev/null) - [ -n "$prs" ] && { echo "open pull requests:"; printf '%s\n' "$prs"; } || echo "no open pull requests" - failing=$(gh pr list --state open --json number,statusCheckRollup \ - --jq '.[] | select([.statusCheckRollup[]? | select(.conclusion == "FAILURE")] | length > 0) | "#\(.number) failing: \([.statusCheckRollup[] | select(.conclusion == "FAILURE") | .name] | join(", "))"' 2>/dev/null) - [ -n "$failing" ] && { echo "RED CHECKS on open pull requests:"; printf '%s\n' "$failing"; } - runs=$(gh run list --branch main --limit 3 --json conclusion,status,displayTitle,createdAt \ - --jq '.[] | "\(.createdAt[:10]) \(.status)/\(.conclusion // "-"): \(.displayTitle)"' 2>/dev/null) - [ -n "$runs" ] && { echo "last CI runs on main:"; printf '%s\n' "$runs"; } || echo "no CI runs on main" + if prs=$(gh pr list --state open --json number,title,isDraft,updatedAt,headRefName \ + --jq '.[] | "#\(.number) \(if .isDraft then "DRAFT" else "open" end) \(.headRefName) " + + "updated \(.updatedAt[:10]): \(.title)"' 2>/dev/null); then + if [ -n "$prs" ]; then + echo "open pull requests:"; printf '%s\n' "$prs" + else + echo "no open pull requests" + fi + else + echo "open pull requests not read (gh pr list failed)" + fi + # Everything that is not green is red (owner's decision, 2026-11-24). gh gives one line per + # attempt of a check: PR number, type, workflow, name, conclusion of a check run, state of + # a commit status, start time. + # The rule is an allowlist, compared whole: + # - A check run is red when its conclusion is not empty and not SUCCESS, NEUTRAL or SKIPPED. + # - A commit status is red when its state is not empty and not SUCCESS, PENDING or EXPECTED. + # - A row of any other type is red when its conclusion or its state is not empty and not one + # of the green values of either list (SUCCESS, NEUTRAL, SKIPPED, PENDING, EXPECTED). + # So STALE, and any value GitHub adds later, is red. Running and pending checks are not red + # yet. NEUTRAL and SKIPPED stay green because the owner's rule is read as GitHub's branch + # protection reads it: skipped and neutral jobs pass. + # The workflow is the name of the workflow of a check run. It is empty for a check that is + # not from a workflow, and for a commit status. Two checks of the same name in different + # workflows are different checks. gh gives no event for them. + # Only the latest attempt of each check counts (owner's decision, 2026-11-25): a failure + # re-run green is not red. A check is one PR, type, workflow and name. The latest attempt + # is the one that started last. + # The start times are ISO 8601 in UTC and are compared as strings. That is correct for + # GitHub's times, which have whole seconds. + # An attempt not started yet (no conclusion, no state, and no time or GitHub's zero time) + # is the latest. A finished attempt with no time is older than any attempt with a time. + # On equal times, and between attempts with no time, the later line wins. + if rollup=$(gh pr list --state open --json number,statusCheckRollup \ + --jq '.[] | .number as $n | .statusCheckRollup[]? + | [$n, .__typename, (.workflowName // ""), (.name // .context // ""), + (.conclusion // ""), (.state // ""), (.startedAt // "")] | @tsv' 2>/dev/null); then + failing=$(printf '%s\n' "$rollup" | + awk -F '\t' ' + { + notime = ($7 == "" || $7 ~ /^0001-/) + if (!notime) at = $7 + else if ($5 == "" && $6 == "") at = "9999" + else at = "" + key = $1 SUBSEP $2 SUBSEP $3 SUBSEP $4 + if (!(key in when)) { + keys[++k] = key; pr[key] = $1 + name[key] = ($3 != "" ? $3 " / " : "") ($4 != "" ? $4 : "(no name)") + } + else if (at < when[key]) next + when[key] = at + red[key] = ($2 == "CheckRun" && $5 != "" && $5 !~ /^(SUCCESS|NEUTRAL|SKIPPED)$/) || + ($2 == "StatusContext" && $6 != "" && + $6 !~ /^(SUCCESS|PENDING|EXPECTED)$/) || + ($2 != "CheckRun" && $2 != "StatusContext" && + (($5 != "" && $5 !~ /^(SUCCESS|NEUTRAL|SKIPPED|PENDING|EXPECTED)$/) || + ($6 != "" && $6 !~ /^(SUCCESS|NEUTRAL|SKIPPED|PENDING|EXPECTED)$/))) + } + END { + for (i = 1; i <= k; i++) { + key = keys[i] + if (!red[key]) continue + p = pr[key] + if (!(p in list)) { order[++n] = p; list[p] = name[key] } + else list[p] = list[p] ", " name[key] + } + for (i = 1; i <= n; i++) print "#" order[i] " failing: " list[order[i]] + }') + [ -n "$failing" ] && { echo "RED CHECKS on open pull requests:"; printf '%s\n' "$failing"; } + else + echo "checks not read (gh pr list failed)" + fi + if runs=$(gh run list --branch main --limit 3 --json conclusion,status,displayTitle,createdAt \ + --jq '.[] | "\(.createdAt[:10]) \(.status)/\(.conclusion // "-"): " + + "\(.displayTitle)"' 2>/dev/null); then + if [ -n "$runs" ]; then + echo "last CI runs on main:"; printf '%s\n' "$runs" + else + echo "no CI runs on main" + fi + else + echo "CI runs not read (gh run list failed)" + fi else echo "gh not available or not logged in: pull requests and CI not checked" fi diff --git a/scripts/check-public.sh b/scripts/check-public.sh index a1fa2ee..8fa9fe6 100755 --- a/scripts/check-public.sh +++ b/scripts/check-public.sh @@ -7,7 +7,8 @@ # other remotes never hide commits # BASE = tip TIP only (scheduled runs) # For each commit: the files it adds or changes, its message, author and committer; -# then the whole tree of TIP, and the tag message and tagger when TIP is an annotated tag. +# then the whole tree of TIP, and when TIP is an annotated tag, the message and tagger of +# that tag and of every tag it points to through other tags. # Shallow clones are refused (exit 2): they cannot see the history. # scripts/check-public.sh --message FILE a commit message being written (commit-msg hook) # Exit 0 clean, 1 content blocked, 2 cannot check (bad revision, git error): never a silent pass. @@ -100,7 +101,8 @@ check_meta() { # Files a commit adds or changes (whole tree for merges). commit_files() { - parents=$(git rev-list --parents -n 1 "$1" | wc -w) || cannot "git rev-list failed on $1" + line=$(git rev-list --parents -n 1 "$1") || cannot "git rev-list failed on $1" + parents=$(printf '%s\n' "$line" | wc -w) if [ "$parents" -gt 2 ]; then git -c core.quotepath=off ls-tree -r --name-only "$1" || cannot "git ls-tree failed on $1" else @@ -136,10 +138,15 @@ case "${1:-}" in files=$(tree_files "$tip") || exit 2 check_files "$tip:" "$files" check_meta "$tip" - if [ "$(git cat-file -t "$tip")" = tag ]; then - git cat-file -p "$tip" > "$tmp" || cannot "cannot read tag $tip" - scan_tmp "tag $tip" - fi + # A tag can point to another tag: every message and tagger down the chain is published. + obj=$tip + while :; do + kind=$(git cat-file -t "$obj") || cannot "cannot read object $obj" + [ "$kind" = tag ] || break + git cat-file tag "$obj" > "$tmp" || cannot "cannot read tag $obj" + scan_tmp "tag $obj" + obj=$(sed -n '1s/^object //p' "$tmp") # if empty, the next cat-file -t fails: exit 2 + done echo "public check: $n commits and the tree of $(git rev-parse --short "$tip") scanned" ;; --message) [ -f "${2:-}" ] && [ -r "$2" ] || cannot "message file missing or not a file" diff --git a/scripts/test-cleanup.sh b/scripts/test-cleanup.sh index 1b0706c..4e496b8 100755 --- a/scripts/test-cleanup.sh +++ b/scripts/test-cleanup.sh @@ -30,6 +30,18 @@ skipped=0 skip() { skipped=$((skipped + $1)); echo "SKIP ($1 checks): $2" >&2; } on_windows=0 case $(uname -s) in MINGW*|MSYS*|CYGWIN*) on_windows=1 ;; esac +# A block that cannot run on Windows: +# if off_windows <checks> <reason>; then ...; end_off_windows; fi +# On Windows it counts <checks> as skipped. Elsewhere the block runs, and end_off_windows +# fails if the block did not run exactly <checks> checks: a wrong skip count is noticed. +off_windows() { + if [ "$on_windows" -eq 1 ]; then skip "$1" "$2"; return 1; fi + block_checks=$1; block_start=$((passed + failed)); return 0 +} +end_off_windows() { + ran=$((passed + failed - block_start)) + [ "$ran" -eq "$block_checks" ] || bad "skip count: the block says $block_checks checks, it ran $ran" +} git init -q --bare "$work/remote.git" mkdir -p "$work/r/scripts" && cd "$work/r" || exit 2 @@ -156,7 +168,7 @@ check "same-named tag: current branch said as checked out here" 'printf "%s" "$o git switch -q main; git branch -q -D cur; git tag -d cur >/dev/null # Names git has to quote (backslash, double quote): never removed, listed on one line. -if [ "$on_windows" -eq 1 ]; then skip 4 "names with a backslash cannot exist on Windows"; else +if off_windows 4 "names with a backslash cannot exist on Windows"; then echo mine > 'odd\nname.txt'; echo junk > 'odd\name.orig' out=$(sh scripts/cleanup.sh 2>&1) check "quoted name: junk not removed" '[ -f "odd\\name.orig" ]' @@ -164,6 +176,7 @@ check "quoted name: not reported as removed" '! printf "%s\n" "$out" | grep -q check "quoted name: listed for review" 'printf "%s\n" "$out" | grep -q "^review (special characters, not removed): .*odd.*name.orig"' check "quoted name: printed on one line" 'printf "%s\n" "$out" | grep -q "^review.*odd.*nname.txt"' rm -f 'odd\nname.txt' 'odd\name.orig' +end_off_windows fi # Names that must not be expanded, split or matched loosely. @@ -208,6 +221,25 @@ sh scripts/cleanup.sh >/dev/null 2>&1 check "main kept when run from another branch" 'git rev-parse -q --verify refs/heads/main >/dev/null' git switch -q main +# A branch just created at main, with no commit of its own, is removed (audit 0003, F6). It +# looks the same as a branch fast-forwarded into main, and it holds no commit that main lacks. +git branch born main +out=$(sh scripts/cleanup.sh --plan 2>&1) +check "branch created at main: listed for removal" 'printf "%s\n" "$out" | grep -q "^would remove local branch (merged): born$"' +out=$(sh scripts/cleanup.sh 2>&1); r=$? +check "branch created at main: removed" '[ $r -eq 0 ] && printf "%s\n" "$out" | grep -q "^removed local branch (merged): born$" && ! git rev-parse -q --verify refs/heads/born >/dev/null' + +# Detached HEAD at a commit that no branch holds: cleanup.sh does not touch HEAD or that +# commit, lists only real branches as not merged, and still removes merged branches. +git switch -q --detach main && echo d > d.txt && git add d.txt && git commit -qm detached +head=$(git rev-parse HEAD) +git branch gone main +out=$(sh scripts/cleanup.sh 2>&1); r=$? +check "detached unmerged HEAD: exit 0, merged branch removed" '[ $r -eq 0 ] && ! git rev-parse -q --verify refs/heads/gone >/dev/null' +check "detached unmerged HEAD: HEAD and its commit kept" '! git symbolic-ref -q HEAD >/dev/null && [ "$(git rev-parse HEAD)" = "$head" ] && [ -f d.txt ]' +check "detached unmerged HEAD: only real branches listed" 'printf "%s\n" "$out" | grep -q "^keep local branch (not merged): wip$" && ! printf "%s\n" "$out" | grep -q "(HEAD"' +git switch -q main + # Inside a hook (temporary index): refuse, delete nothing. echo junk > f.orig # env: a variable put before a shell function would stay set for the rest of this file. @@ -223,11 +255,12 @@ check "outside a repository: exit 2" '[ $r -eq 2 ]' check "unknown option refused" '! sh scripts/cleanup.sh --force >/dev/null 2>&1' # A removal that fails is reported in the exit status. -if [ "$on_windows" -eq 1 ]; then skip 1 "a read-only folder does not stop rm on Windows"; else +if off_windows 1 "a read-only folder does not stop rm on Windows"; then mkdir -p locked && echo junk > locked/g.orig && chmod 555 locked sh scripts/cleanup.sh >/dev/null 2>&1; r=$? chmod 755 locked check "failed removal: exit 1" '[ $r -eq 1 ] && [ -f locked/g.orig ]' +end_off_windows fi rm -rf locked f.orig @@ -239,6 +272,32 @@ out=$(sh scripts/cleanup.sh 2>&1); r=$? check "merged into main, not into HEAD: removed" '[ $r -eq 0 ] && ! git rev-parse -q --verify refs/heads/merged-later >/dev/null' git switch -q main +# Race: a branch merged when listed gets a new commit before it is deleted. It is checked +# again just before deletion, so it is kept. The listing comes before the GitHub section and +# the deletion after it, so a gh stand-in adds the commit in between: no seam in cleanup.sh. +# Variant 2 adds a tag with the branch's name at main and a tag "main" at the new commit: a +# check with short names would read the tags and delete the branch. +mkdir -p "$work/raceshim" +cat > "$work/raceshim/gh" <<'SHIM' +#!/bin/sh +# Signed in. On "pr list", move the branch named in RACE_BRANCH to a new commit. +[ "$1" = pr ] || exit 0 +b=$RACE_BRANCH +new=$(git commit-tree -p "refs/heads/$b" -m race "refs/heads/$b^{tree}") || exit 1 +git update-ref "refs/heads/$b" "$new" || exit 1 +if [ "$RACE_TAGS" -eq 1 ]; then git tag "$b" refs/heads/main && git tag main "$new"; fi +exit 0 +SHIM +chmod +x "$work/raceshim/gh" +for variant in 1 2; do + git branch "racer$variant" main + out=$(env RACE_BRANCH="racer$variant" RACE_TAGS=$((variant - 1)) PATH="$work/raceshim:$PATH" sh scripts/cleanup.sh 2>&1); r=$? + check "race $variant: listed as merged, then kept" 'printf "%s\n" "$out" | grep -q "^keep branch (no longer merged into main, or git refused): racer$variant$"' + check "race $variant: not removed, exit 1" '[ $r -eq 1 ] && ! printf "%s\n" "$out" | grep -q "^removed local branch (merged): racer$variant$"' + check "race $variant: new commit still on the branch" '[ "$(git log -1 --format=%s "refs/heads/racer$variant" 2>/dev/null)" = race ]' + git branch -q -D "racer$variant"; git tag -d "racer$variant" main >/dev/null 2>&1 +done + # Without a local main there is nothing to compare with: stop before removing anything. git branch -q -m main trunk echo junk > h.orig diff --git a/scripts/test-hooks.sh b/scripts/test-hooks.sh index ff72c7e..92af97b 100755 --- a/scripts/test-hooks.sh +++ b/scripts/test-hooks.sh @@ -76,6 +76,24 @@ new_repo git tag -a v0 -m "release by $leak" git push -q origin v0 >/dev/null 2>&1; expect "annotated tag message scanned" 1 $? +# Nested annotated tags: the inner tag's message and tagger are published with the outer tag. +new_repo +git tag -a inner -m "clean inner"; git tag -a outer -m "clean outer" inner 2>/dev/null +git push -q origin outer >/dev/null 2>&1; expect "nested tags, all clean: push allowed" 0 $? +new_repo +git tag -a inner -m "release by $leak"; git tag -a outer -m "clean outer" inner 2>/dev/null +sh scripts/check-public.sh --range tip outer >/dev/null 2>&1; expect "nested tags: inner message scanned" 1 $? +git push -q origin outer >/dev/null 2>&1; expect "nested tags: push with a leak in the inner tag refused" 1 $? +# Three levels: the leak sits in the innermost tag, two tags below the one that is pushed. +new_repo +git tag -a t1 -m "clean t1"; git tag -a t2 -m "clean t2" t1 2>/dev/null; git tag -a t3 -m "clean t3" t2 2>/dev/null +sh scripts/check-public.sh --range tip t3 >/dev/null 2>&1; expect "three nested tags, all clean: check passes" 0 $? +git push -q origin t3 >/dev/null 2>&1; expect "three nested tags, all clean: push allowed" 0 $? +new_repo +git tag -a t1 -m "release by $leak"; git tag -a t2 -m "clean t2" t1 2>/dev/null; git tag -a t3 -m "clean t3" t2 2>/dev/null +sh scripts/check-public.sh --range tip t3 >/dev/null 2>&1; expect "three nested tags: innermost message scanned" 1 $? +git push -q origin t3 >/dev/null 2>&1; expect "three nested tags: push with a leak in the innermost tag refused" 1 $? + new_repo git switch -q -c gone; git push -q origin gone >/dev/null 2>&1 git push -q origin --delete gone >/dev/null 2>&1; expect "branch deletion allowed" 0 $? @@ -111,6 +129,66 @@ printf 'fix\n# ------------------------ >8 ------------------------\n# Do not mo hook_commit -F "$work/msg"; expect "two-line scissors block: commit-msg cuts it (known limit)" 0 $? git push -q origin main >/dev/null 2>&1; expect "two-line scissors block: push refused" 1 $? +# --- refusals and crashes ---------------------------------------------------------------------- +# Does a hook refuse when its check finds a problem, and when the check crashes? git reports +# exit 1 for any hook failure, so each hook is also run directly: its own exit must be non-zero. +refused() { # refused <description> <actual exit>: any non-zero exit is a refusal + if [ "$2" -ne 0 ]; then passed=$((passed + 1)); else + failed=$((failed + 1)); echo "FAIL: $1 (expected a non-zero exit, got 0)" >&2; fi +} +# Runs .githooks/pre-push as `git push origin main` would. +pre_push() { + printf 'refs/heads/main %s refs/heads/main %s\n' "$(git rev-parse HEAD)" "$(git rev-parse origin/main)" \ + | sh .githooks/pre-push origin "$work/origin.git" >/dev/null 2>&1 +} +pre_commit() { PATH="$work/cargo-stub:$PATH" sh .githooks/pre-commit >/dev/null 2>&1; } +remote_main() { git --git-dir="$work/origin.git" rev-parse main; } + +new_repo +add_doc clean "nothing personal" +pre_push; expect "pre-push run directly: clean push allowed" 0 $? +add_doc leak "$leak" +pre_push; refused "pre-push run directly: leak refused" $? + +new_repo +add_doc clean "nothing personal" +was=$(remote_main) +rm scripts/check-public.sh +pre_push; refused "pre-push: check-public.sh missing refused" $? +git push -q origin main >/dev/null 2>&1; refused "pre-push: push without check-public.sh refused" $? +[ "$(remote_main)" = "$was" ]; expect "pre-push: nothing reached the remote without the check" 0 $? +printf 'if then\n' > scripts/check-public.sh # cannot run: syntax error +pre_push; refused "pre-push: check-public.sh that cannot run refused" $? +git checkout -q -- scripts/check-public.sh +printf 'if then\n' > scripts/audit-status.sh # cannot run: syntax error +pre_push; refused "pre-push: audit-status.sh that cannot run refused" $? +git checkout -q -- scripts/audit-status.sh +rm scripts/audit-status.sh +pre_push; refused "pre-push: audit-status.sh missing refused" $? + +new_repo +echo x > docs/x.md; git add docs +pre_commit; expect "pre-commit run directly: clean commit allowed" 0 $? +rm scripts/check-public.sh +pre_commit; refused "pre-commit: check-public.sh missing refused" $? +printf 'if then\n' > scripts/check-public.sh +pre_commit; refused "pre-commit: check-public.sh that cannot run refused" $? +git checkout -q -- scripts/check-public.sh +printf 'if then\n' > scripts/audit-status.sh # cannot run: syntax error +pre_commit; refused "pre-commit: audit-status.sh that cannot run refused" $? +git checkout -q -- scripts/audit-status.sh +rm scripts/audit-status.sh +pre_commit; refused "pre-commit: audit-status.sh missing refused" $? +git checkout -q -- scripts/audit-status.sh + +echo "clean message" > "$work/msg" +sh .githooks/commit-msg "$work/msg" >/dev/null 2>&1; expect "commit-msg run directly: clean message allowed" 0 $? +rm scripts/check-public.sh +sh .githooks/commit-msg "$work/msg" >/dev/null 2>&1; refused "commit-msg: check-public.sh missing refused" $? +printf 'if then\n' > scripts/check-public.sh +sh .githooks/commit-msg "$work/msg" >/dev/null 2>&1; refused "commit-msg: check-public.sh that cannot run refused" $? +git checkout -q -- scripts/check-public.sh + # --- pre-commit (cargo replaced by a stub: the rule steps are what is tested here) --------- new_repo printf '%s\n' "$leak" > docs/leak.md; git add docs diff --git a/scripts/test-scripts.sh b/scripts/test-scripts.sh index 52265f4..c41a359 100755 --- a/scripts/test-scripts.sh +++ b/scripts/test-scripts.sh @@ -33,6 +33,23 @@ expect_reason() { failed=$((failed + 1)); echo "FAIL: $desc (exit $r, expected 1 with \"$reason\"; got: $err)" >&2; fi } +# report_section <heading start> <report>: the non-blank lines of the first report section whose +# heading starts with "== <heading start>", without the heading. +report_section() { + printf '%s\n' "$2" | awk -v h="== $1" ' + on && /^== / { exit } + on && NF { print } + index($0, h) == 1 { on = 1 }' +} + +# expect_absent <description> <heading start> <extended regex> <report>: the section has at +# least one line, and no line matches. A section that prints nothing is a failure, never a pass. +expect_absent() { + lines=$(report_section "$2" "$4") + if [ -n "$lines" ] && ! printf '%s\n' "$lines" | grep -Eq -- "$3"; then passed=$((passed + 1)); else + failed=$((failed + 1)); echo "FAIL: $1 (section \"$2\" is empty or has \"$3\")" >&2; fi +} + # Report-mode tests never call the real gh (network, user account): default gh says "not logged in". unset GH_REPO GH_HOST GH_TOKEN GITHUB_TOKEN GH_ENTERPRISE_TOKEN mkdir -p "$work/nogh"; printf '#!/bin/sh\necho "$*" >> "%s/gh-stub.log"\nexit 1\n' "$work" > "$work/nogh/gh"; chmod +x "$work/nogh/gh" @@ -340,8 +357,55 @@ git reset -q; rm -rf docs new_repo sh scripts/audit-status.sh 2>/dev/null | grep -q "HOOKS NOT ENABLED"; expect "warning without hooks" 0 $? git config core.hooksPath .githooks -sh scripts/audit-status.sh 2>/dev/null | grep -q "HOOKS NOT ENABLED"; expect "no warning with hooks" 1 $? -sh scripts/audit-status.sh 2>/dev/null | grep -q "== Audit cadence"; expect "report ran (hooks enabled)" 0 $? +out=$(sh scripts/audit-status.sh 2>/dev/null) +printf '%s\n' "$out" | grep -q "HOOKS NOT ENABLED"; expect "no warning with hooks" 1 $? +printf '%s\n' "$out" | grep -qx "== Audit cadence"; expect "report printed with hooks enabled" 0 $? +# The hooks path may also be the absolute path of this repository's own .githooks folder. +mkdir -p .githooks other +git config core.hooksPath "$(pwd)/.githooks" +out=$(sh scripts/audit-status.sh 2>/dev/null) +printf '%s\n' "$out" | grep -q "HOOKS NOT ENABLED"; expect "no warning with the absolute path of .githooks" 1 $? +printf '%s\n' "$out" | grep -qx "== Audit cadence"; expect "report printed with the absolute path of .githooks" 0 $? +# The same folder under another spelling counts: compared by identity, not by path text (Windows +# gives short 8.3 names such as RUNNER~1; a case-insensitive file system gives other letter case). +# Only a case-insensitive file system lets this test make the spelling differ. +if [ .githooks -ef .GITHOOKS ]; then + git config core.hooksPath "$(pwd)/.GITHOOKS" + out=$(sh scripts/audit-status.sh 2>/dev/null) + printf '%s\n' "$out" | grep -q "HOOKS NOT ENABLED"; expect "no warning with another spelling of the same folder" 1 $? + printf '%s\n' "$out" | grep -qx "== Audit cadence"; expect "report printed with another spelling of the same folder" 0 $? +fi +mkdir -p "$work/elsewhere/.githooks" +git config core.hooksPath "$work/elsewhere/.githooks" +sh scripts/audit-status.sh 2>/dev/null | grep -q "HOOKS NOT ENABLED"; expect "warning with a .githooks folder elsewhere" 0 $? +git config core.hooksPath "$(pwd)/other" +sh scripts/audit-status.sh 2>/dev/null | grep -q "HOOKS NOT ENABLED"; expect "warning with another folder of this repository" 0 $? +rmdir .githooks +git config core.hooksPath "$(pwd)/.githooks" +sh scripts/audit-status.sh 2>/dev/null | grep -q "HOOKS NOT ENABLED"; expect "warning with an absolute path to a missing .githooks" 0 $? +# A drive-letter path (git config stores C:/... in Git Bash) counts as absolute: it reaches the +# resolve step. On Windows, pwd -W gives this folder in that form. Elsewhere a symlink named +# "C:" in the current folder lets the resolve step succeed; such a name cannot exist on Windows. +mkdir .githooks +if dl=$(pwd -W 2>/dev/null) && [ -n "$dl" ]; then + dl_hooks="$dl/.githooks"; dl_back=$(printf '%s\n' "$dl_hooks" | tr '/' '\\'); dl_other="$dl/other" +else + ln -s . "C:"; ln -s .githooks 'C:\.githooks'; dl_links=yes + dl_hooks="C:/.githooks"; dl_back='C:\.githooks'; dl_other="C:/other" +fi +git config core.hooksPath "$dl_hooks" +out=$(sh scripts/audit-status.sh 2>/dev/null) +printf '%s\n' "$out" | grep -q "HOOKS NOT ENABLED"; expect "no warning with a drive-letter path of .githooks" 1 $? +printf '%s\n' "$out" | grep -qx "== Audit cadence"; expect "report printed with a drive-letter path of .githooks" 0 $? +git config core.hooksPath "$dl_back" +out=$(sh scripts/audit-status.sh 2>/dev/null) +printf '%s\n' "$out" | grep -q "HOOKS NOT ENABLED"; expect "no warning with a drive-letter path, backslash" 1 $? +printf '%s\n' "$out" | grep -qx "== Audit cadence"; expect "report printed with a drive-letter path, backslash" 0 $? +git config core.hooksPath "$dl_other" +sh scripts/audit-status.sh 2>/dev/null | grep -q "HOOKS NOT ENABLED"; expect "warning with a drive-letter path of another folder" 0 $? +[ "${dl_links:-}" = yes ] && rm -f "C:" 'C:\.githooks' +rmdir .githooks +git config core.hooksPath .githooks # The session report warns before the limit on who can open PRs and issues expires. new_repo @@ -354,12 +418,22 @@ fake_gh() { # fake_gh <expires_at or empty> soon=$(date -u -v+10d +%Y-%m-%d 2>/dev/null || date -u -d '+10 days' +%Y-%m-%d) far=$(date -u -v+100d +%Y-%m-%d 2>/dev/null || date -u -d '+100 days' +%Y-%m-%d) fake_gh "${soon}T00:00:00Z" -PATH="$work/ghshim:$PATH" sh scripts/audit-status.sh 2>/dev/null | grep -q "INTERACTION LIMIT EXPIRES"; expect "limit expiring within 30 days" 0 $? +# The warning names the date only, not the full time stamp. +PATH="$work/ghshim:$PATH" sh scripts/audit-status.sh 2>/dev/null | + grep -q "^INTERACTION LIMIT EXPIRES on $soon: " +expect "limit expiring within 30 days" 0 $? fake_gh "${far}T00:00:00Z" -PATH="$work/ghshim:$PATH" sh scripts/audit-status.sh 2>/dev/null | grep -q "INTERACTION LIMIT"; expect "limit far away: no warning" 1 $? -PATH="$work/ghshim:$PATH" sh scripts/audit-status.sh 2>/dev/null | grep -q "== GitHub"; expect "GitHub section ran (limit far away)" 0 $? +out=$(PATH="$work/ghshim:$PATH" sh scripts/audit-status.sh 2>/dev/null) +expect_absent "limit far away: no warning" GitHub "INTERACTION LIMIT" "$out" +report_section GitHub "$out" | grep -qx "no open pull requests"; expect "GitHub section ran (limit far away)" 0 $? fake_gh "" PATH="$work/ghshim:$PATH" sh scripts/audit-status.sh 2>/dev/null | grep -q "INTERACTION LIMIT NOT ACTIVE"; expect "limit missing" 0 $? +# A failing gh api (network, API limit) is said, never read as a missing limit. +printf '#!/bin/sh\ncase "$*" in\n "auth status"*) exit 0 ;;\n *nameWithOwner*) echo owner/repo ;;\n *interaction-limits*) exit 1 ;;\n *) exit 0 ;;\nesac\n' > "$work/ghshim/gh" +out=$(PATH="$work/ghshim:$PATH" sh scripts/audit-status.sh 2>/dev/null) +report_section GitHub "$out" | grep -qx "interaction limit not read (gh api failed)" +expect "limit: a failing gh api is said" 0 $? +expect_absent "limit: a failing gh api is not a missing limit" GitHub "INTERACTION LIMIT NOT ACTIVE" "$out" # The report says when a newer stable Rust exists than the pinned one (rust-toolchain.toml). new_repo printf '[toolchain]\nchannel = "1.100.0"\n' > rust-toolchain.toml @@ -485,16 +559,10 @@ printf '[toolchain]\nchannel = "1.100.0"\n' > rust-toolchain.toml # The report says when an audit is due (5 commits since the last one), and not before. new_repo commit a; commit b; commit c; commit d -sh scripts/audit-status.sh 2>&1 | grep -qx "AUDIT DUE"; expect "report: 4 commits, no AUDIT DUE" 1 $? +expect_absent "report: 4 commits, no AUDIT DUE" "Audit cadence" "^AUDIT DUE$" "$(sh scripts/audit-status.sh 2>&1)" commit e sh scripts/audit-status.sh 2>&1 | grep -qx "AUDIT DUE"; expect "report: 5 commits, AUDIT DUE" 0 $? -# Red checks on an open pull request are reported (this line is what must stop new work). -printf '#!/bin/sh\ncase "$*" in\n "auth status"*) exit 0 ;;\n *statusCheckRollup*) echo "#2 failing: Test (x86_64-pc-windows-gnu)" ;;\n *) exit 0 ;;\nesac\n' > "$work/ghshim/gh" -chmod +x "$work/ghshim/gh" -out=$(PATH="$work/ghshim:$PATH" sh scripts/audit-status.sh 2>&1) -printf '%s\n' "$out" | grep -A1 "^RED CHECKS on open pull requests:" | grep -qx "#2 failing: Test (x86_64-pc-windows-gnu)"; expect "report: red checks on a PR shown" 0 $? -printf '#!/bin/sh\n[ "$1 $2" = "auth status" ] && exit 0\nexit 0\n' > "$work/ghshim/gh"; chmod +x "$work/ghshim/gh" -PATH="$work/ghshim:$PATH" sh scripts/audit-status.sh 2>&1 | grep -q "RED CHECKS"; expect "report: no red checks, no RED CHECKS line" 1 $? +# Red checks on open pull requests: see the section "step 0.5" at the end. # A tag called "main" does not hide unmerged branches or garble branch names in the report. new_repo git switch -q -c feat && echo f > f.txt && git add f.txt && git commit -qm feat && git tag main feat && git tag feat @@ -504,15 +572,15 @@ out=$(sh scripts/audit-status.sh 2>&1) printf '%s\n' "$out" | grep -A1 "local branches not merged into main:" | grep -qx " feat"; expect "report: tag main does not hide unmerged branches" 0 $? printf '%s\n' "$out" | grep -q "^branch feat:"; expect "report: current branch named without heads/" 0 $? printf '%s\n' "$out" | grep -A3 "remote branches not merged into main:" | grep -qx " origin/feat"; expect "report: unmerged remote branch listed" 0 $? -printf '%s\n' "$out" | grep -Eq "^ origin/(HEAD|main)$"; expect "report: no origin/HEAD or origin/main line" 1 $? -printf '%s\n' "$out" | grep -q "refs/"; expect "report: only branches listed, no tags or other refs" 1 $? +expect_absent "report: no origin/HEAD or origin/main line" "Unfinished local work" "^ origin/(HEAD|main)$" "$out" +expect_absent "report: only branches listed, no tags or other refs" "Unfinished local work" "refs/" "$out" # Without origin/main the remote list says it cannot check, instead of staying silent. git update-ref -d refs/remotes/origin/main sh scripts/audit-status.sh 2>&1 | grep -q "no origin/main: unmerged remote branches not checked"; expect "report: missing origin/main is said" 0 $? rm -rf "$work/origin.git" # With no origin remote there is nothing to say about remote branches. git remote remove origin -sh scripts/audit-status.sh 2>&1 | grep -q "no origin/main"; expect "report: no origin remote, no origin/main line" 1 $? +expect_absent "report: no origin remote, no origin/main line" "Unfinished local work" "no origin/main" "$(sh scripts/audit-status.sh 2>&1)" # Without a local branch main the report says it cannot check, instead of staying silent. git branch -q -m main trunk sh scripts/audit-status.sh 2>&1 | grep -q "no local branch main: unmerged local branches not checked"; expect "report: missing main is said" 0 $? @@ -523,5 +591,313 @@ rm -f "$work/gh-ask.log" echo typed | PATH="$work/ghshim:$PATH" sh scripts/audit-status.sh >/dev/null 2>&1 [ -s "$work/gh-ask.log" ] && ! grep -vx "prompt=1 stdin=" "$work/gh-ask.log" | grep -q .; expect "report: gh never prompts or reads input" 0 $? +# --- step 0.5: check-public.sh git failures ------------------------------------------------ +# What happens when git fails inside check-public.sh? It stops with exit 2 and names the failed +# command, never a silent pass. A git wrapper on PATH fails for one subcommand only and runs +# the real git for everything else. +gf_git=$(command -v git) +mkdir -p "$work/gf-shim" +gf_fail() { # gf_fail <word>: the wrapper fails whenever one of its arguments is that word + printf '#!/bin/sh\nfor a in "$@"; do [ "$a" = %s ] && { echo "fatal: test failure" >&2; exit 128; }; done\nexec "%s" "$@"\n' \ + "$1" "$gf_git" > "$work/gf-shim/git" + chmod +x "$work/gf-shim/git" +} +# gf_expect <description> <reason in stderr> <check-public.sh arguments...>: exit 2 for that reason. +gf_expect() { + gf_desc=$1; gf_reason=$2; shift 2 + gf_err=$(PATH="$work/gf-shim:$PATH" sh scripts/check-public.sh "$@" 2>&1 >/dev/null); gf_r=$? + if [ "$gf_r" -eq 2 ] && printf '%s\n' "$gf_err" | grep -q "$gf_reason"; then passed=$((passed + 1)); else + failed=$((failed + 1)); echo "FAIL: $gf_desc (exit $gf_r, expected 2 with \"$gf_reason\"; got: $gf_err)" >&2; fi +} +new_repo +mkdir -p docs; echo a > docs/a.md; git add docs; git commit -qm a +gf_base=$(git rev-parse HEAD~1) +# Control: the wrapper itself runs git normally when the failing subcommand is not used. +gf_fail no-such-subcommand +PATH="$work/gf-shim:$PATH" sh scripts/check-public.sh --range "$gf_base" HEAD >/dev/null 2>&1 +expect "git failures: the wrapper alone passes a clean range" 0 $? +gf_fail show +echo b > docs/b.md; git add docs +gf_expect "git show fails on a staged file" "cannot check: cannot read :docs/b.md" --staged +git reset -q; rm -f docs/b.md +gf_expect "git show fails on a file of the range" "cannot check: cannot read $(git rev-parse HEAD):" --range "$gf_base" HEAD +gf_fail ls-tree +gf_expect "git ls-tree fails on the tip tree" "cannot check: git ls-tree failed on HEAD" --range tip HEAD +git switch -q -c gf-side; echo c > docs/c.md; git add docs; git commit -qm c +git switch -q main; git merge -q --no-ff --no-edit gf-side +gf_expect "git ls-tree fails on a merge commit" "cannot check: git ls-tree failed on $(git rev-parse HEAD)" --range "$gf_base" HEAD +gf_fail diff-tree +gf_expect "git diff-tree fails on a commit" "cannot check: git diff-tree failed on" --range "$gf_base" HEAD +# A failing git rev-list --parents must stop the run, also for a merge commit (whose files are +# listed from the whole tree): the count of parents is never taken from a failed command. +gf_fail --parents +gf_expect "git rev-list --parents fails on a merge commit" "cannot check: git rev-list failed on $(git rev-parse HEAD)" --range "$gf_base" HEAD +gf_fail log +gf_expect "git log fails on a commit" "cannot check: git log failed on" --range "$gf_base" HEAD +gf_fail "$gf_base..HEAD" +gf_expect "git rev-list fails on a range" "cannot check: git rev-list failed$" --range "$gf_base" HEAD +gf_fail --not +gf_expect "git rev-list fails on a remote range" "cannot check: git rev-list failed$" --range remote:origin HEAD +gf_fail diff +gf_expect "git diff fails on the staged files" "cannot check: git diff failed" --staged +# Annotated tags, also nested: reading the type or the content of each tag can fail too. +git tag -a gf-inner -m inner; git tag -a gf-outer -m outer gf-inner 2>/dev/null +gf_fail no-such-subcommand +PATH="$work/gf-shim:$PATH" sh scripts/check-public.sh --range tip gf-outer >/dev/null 2>&1 +expect "git failures: the wrapper alone passes nested tags" 0 $? +gf_fail cat-file +gf_expect "git cat-file fails on the type of a tag" "cannot check: cannot read object gf-outer" --range tip gf-outer +gf_fail tag +gf_expect "git cat-file fails on an outer tag" "cannot check: cannot read tag gf-outer" --range tip gf-outer +# The inner tag is reached by its id: the wrapper fails only for that id. +gf_inner=$(git rev-parse gf-inner) +gf_fail "$gf_inner" +gf_expect "git cat-file fails on an inner tag" "cannot check: cannot read object $gf_inner" --range tip gf-outer + +# --- step 0.5: audit-status.sh gaps --------------------------------------------------------- +new_repo +# gh_checks <file>: a logged-in gh with one open pull request. For the checks of the open pull +# requests it returns the file, one line per check, as the script's own gh call returns them. +# The fields are number, type, workflow, name, conclusion, state and start time, separated by +# tabs. The script selects the red ones. +gh_checks() { + printf '#!/bin/sh\ncase "$*" in\n "auth status"*) exit 0 ;;\n *statusCheckRollup*) cat "%s" ;;\n *isDraft*) echo "#2 open step/x updated 2026-11-24: Test" ;;\n *) exit 0 ;;\nesac\n' "$1" > "$work/ghshim/gh" + chmod +x "$work/ghshim/gh" +} +# Owner's decision of 2026-11-24: everything that is not green is red. The rule is an allowlist: +# a check run is red when its conclusion is not empty and not SUCCESS, NEUTRAL or SKIPPED; a +# commit status is red when its state is not empty and not SUCCESS, PENDING or EXPECTED. So +# STALE, and any value GitHub adds later, is red. Running or pending ones (empty conclusion, +# PENDING, EXPECTED) are not red yet. The values are compared whole. +t=' ' +{ + printf '2%sCheckRun%s%sLint%sFAILURE%s\n' "$t" "$t" "$t" "$t" "$t" + printf '2%sCheckRun%s%sBuild%sSUCCESS%s\n' "$t" "$t" "$t" "$t" "$t" + printf '2%sCheckRun%s%sTest (a)%sCANCELLED%s\n' "$t" "$t" "$t" "$t" "$t" + printf '2%sCheckRun%s%sTest (b)%sTIMED_OUT%s\n' "$t" "$t" "$t" "$t" "$t" + printf '2%sCheckRun%s%sDeploy%sACTION_REQUIRED%s\n' "$t" "$t" "$t" "$t" "$t" + printf '2%sCheckRun%s%sDocs%sSTARTUP_FAILURE%s\n' "$t" "$t" "$t" "$t" "$t" + printf '2%sCheckRun%s%sFmt%sNEUTRAL%s\n' "$t" "$t" "$t" "$t" "$t" + printf '2%sCheckRun%s%sFuzz%sSKIPPED%s\n' "$t" "$t" "$t" "$t" "$t" + printf '2%sCheckRun%s%sStill running%s%s\n' "$t" "$t" "$t" "$t" "$t" + printf '2%sStatusContext%s%sci/a%s%sERROR\n' "$t" "$t" "$t" "$t" "$t" + printf '2%sStatusContext%s%sci/b%s%sFAILURE\n' "$t" "$t" "$t" "$t" "$t" + printf '2%sStatusContext%s%sci/c%s%sPENDING\n' "$t" "$t" "$t" "$t" "$t" + printf '2%sStatusContext%s%sci/d%s%sSUCCESS\n' "$t" "$t" "$t" "$t" "$t" + printf '2%sStatusContext%s%sci/e%s%sEXPECTED\n' "$t" "$t" "$t" "$t" "$t" + printf '2%sCheckRun%s%sStale one%sSTALE%s\n' "$t" "$t" "$t" "$t" "$t" + printf '2%sCheckRun%s%sNew one%sWEIRD_NEW%s\n' "$t" "$t" "$t" "$t" "$t" + printf '2%sStatusContext%s%sci/s%s%sSTALE\n' "$t" "$t" "$t" "$t" "$t" + printf '2%sStatusContext%s%sci/w%s%sWEIRD_NEW\n' "$t" "$t" "$t" "$t" "$t" + printf '5%sCheckRun%s%sBuild%sSUCCESS%s\n' "$t" "$t" "$t" "$t" "$t" + printf '5%sCheckRun%s%sQueued%s%s\n' "$t" "$t" "$t" "$t" "$t" + printf '5%sStatusContext%s%sci/x%s%sPENDING\n' "$t" "$t" "$t" "$t" "$t" + printf '7%sStatusContext%s%sci/z%s%sERROR\n' "$t" "$t" "$t" "$t" "$t" +} > "$work/checks-red.tsv" +gh_checks "$work/checks-red.tsv" +out=$(PATH="$work/ghshim:$PATH" sh scripts/audit-status.sh 2>&1) +report_section GitHub "$out" | awk '/^RED CHECKS/ { on = 1; print; next } on && /^#/ { print; next } { on = 0 }' > "$work/red.txt" +printf 'RED CHECKS on open pull requests:\n#2 failing: Lint, Test (a), Test (b), Deploy, Docs, ci/a, ci/b, Stale one, New one, ci/s, ci/w\n#7 failing: ci/z\n' | cmp -s - "$work/red.txt"; expect "report: red checks selected (not green, not pending)" 0 $? +# Owner's decision of 2026-11-25: for each check of a pull request, only its latest attempt +# counts. The latest is the one that started last; one not started yet (no start time, or +# GitHub's zero time) is the latest. The lines are not in time order: the script must compare +# the times. A check of the same name on another pull request does not count. +{ + printf '3%sCheckRun%s%sLint%sFAILURE%s%s2026-11-24T10:00:00Z\n' "$t" "$t" "$t" "$t" "$t" "$t" + printf '3%sCheckRun%s%sLint%sSUCCESS%s%s2026-11-24T11:00:00Z\n' "$t" "$t" "$t" "$t" "$t" "$t" + printf '3%sCheckRun%s%sTest%sFAILURE%s%s2026-11-24T12:00:00Z\n' "$t" "$t" "$t" "$t" "$t" "$t" + printf '3%sCheckRun%s%sTest%sSUCCESS%s%s2026-11-24T09:00:00Z\n' "$t" "$t" "$t" "$t" "$t" "$t" + printf '3%sCheckRun%s%sBuild%sFAILURE%s%s2026-11-24T10:00:00Z\n' "$t" "$t" "$t" "$t" "$t" "$t" + printf '3%sCheckRun%s%sBuild%s%s%s0001-01-01T00:00:00Z\n' "$t" "$t" "$t" "$t" "$t" "$t" + printf '3%sCheckRun%s%sDocs%sFAILURE%s%s2026-11-24T10:00:00Z\n' "$t" "$t" "$t" "$t" "$t" "$t" + printf '3%sCheckRun%s%sDocs%s%s%s\n' "$t" "$t" "$t" "$t" "$t" "$t" + printf '3%sStatusContext%s%sci/a%s%sERROR%s2026-11-24T10:00:00Z\n' "$t" "$t" "$t" "$t" "$t" "$t" + printf '3%sStatusContext%s%sci/a%s%sSUCCESS%s2026-11-24T11:00:00Z\n' "$t" "$t" "$t" "$t" "$t" "$t" + printf '3%sStatusContext%s%sci/b%s%sSUCCESS%s2026-11-24T10:00:00Z\n' "$t" "$t" "$t" "$t" "$t" "$t" + printf '3%sStatusContext%s%sci/b%s%sFAILURE%s2026-11-24T11:00:00Z\n' "$t" "$t" "$t" "$t" "$t" "$t" + printf '3%sCheckRun%s%sEq-a%sFAILURE%s%s2026-11-24T10:00:00Z\n' "$t" "$t" "$t" "$t" "$t" "$t" + printf '3%sCheckRun%s%sEq-a%sSUCCESS%s%s2026-11-24T10:00:00Z\n' "$t" "$t" "$t" "$t" "$t" "$t" + printf '3%sCheckRun%s%sEq-b%sSUCCESS%s%s2026-11-24T10:00:00Z\n' "$t" "$t" "$t" "$t" "$t" "$t" + printf '3%sCheckRun%s%sEq-b%sFAILURE%s%s2026-11-24T10:00:00Z\n' "$t" "$t" "$t" "$t" "$t" "$t" + printf '3%sStatusContext%s%sci/g1%sFAILURE%sSUCCESS%s\n' "$t" "$t" "$t" "$t" "$t" "$t" + printf '3%sCheckRun%s%sG2%sSUCCESS%sERROR%s\n' "$t" "$t" "$t" "$t" "$t" "$t" + printf '3%sCheckRun%s%sG3%sSUCCESS_X%s%s\n' "$t" "$t" "$t" "$t" "$t" "$t" + printf '3%sCheckRun%s%sG4%sXSUCCESS%s%s\n' "$t" "$t" "$t" "$t" "$t" "$t" + printf '3%sStatusContext%s%sci/g5%s%sPENDINGISH%s\n' "$t" "$t" "$t" "$t" "$t" "$t" + printf '3%sStatusContext%s%sci/g6%s%sXEXPECTED%s\n' "$t" "$t" "$t" "$t" "$t" "$t" + printf '9%sCheckRun%sCI%sbuild%sFAILURE%s%s2026-11-24T10:00:00Z\n' "$t" "$t" "$t" "$t" "$t" "$t" + printf '9%sCheckRun%sDocs%sbuild%sSUCCESS%s%s2026-11-24T10:00:05Z\n' "$t" "$t" "$t" "$t" "$t" "$t" + printf '8%sCheckRun%s%sTest%sSUCCESS%s%s2026-11-24T13:00:00Z\n' "$t" "$t" "$t" "$t" "$t" "$t" +} > "$work/checks-rerun.tsv" +gh_checks "$work/checks-rerun.tsv" +out=$(PATH="$work/ghshim:$PATH" sh scripts/audit-status.sh 2>&1) +report_section GitHub "$out" | awk '/^RED CHECKS/ { on = 1; print; next } on && /^#/ { print; next } { on = 0 }' > "$work/red.txt" +printf 'RED CHECKS on open pull requests:\n#3 failing: Test, ci/b, Eq-b, G3, G4, ci/g5, ci/g6\n#9 failing: CI / build\n' | cmp -s - "$work/red.txt"; expect "report: only the latest attempt of each check counts" 0 $? +# Each type has its own green list: PENDING and EXPECTED are green only for a status, NEUTRAL and +# SKIPPED only for a check run. A value from the other list is red. +{ + printf '2%sCheckRun%s%sCR-pending%sPENDING%s%s\n' "$t" "$t" "$t" "$t" "$t" "$t" + printf '2%sCheckRun%s%sCR-expected%sEXPECTED%s%s\n' "$t" "$t" "$t" "$t" "$t" "$t" + printf '2%sStatusContext%s%sst-neutral%s%sNEUTRAL%s\n' "$t" "$t" "$t" "$t" "$t" "$t" + printf '2%sStatusContext%s%sst-skipped%s%sSKIPPED%s\n' "$t" "$t" "$t" "$t" "$t" "$t" +} > "$work/checks-lists.tsv" +gh_checks "$work/checks-lists.tsv" +out=$(PATH="$work/ghshim:$PATH" sh scripts/audit-status.sh 2>&1) +report_section GitHub "$out" | awk '/^RED CHECKS/ { on = 1; print; next } on && /^#/ { print; next } { on = 0 }' > "$work/red.txt" +printf 'RED CHECKS on open pull requests:\n#2 failing: CR-pending, CR-expected, st-neutral, st-skipped\n' | cmp -s - "$work/red.txt"; expect "report: each type has its own green list" 0 $? +# A commit status and a check run that has no workflow have the same (empty) workflow: the type +# is part of the key, so a green check run never hides a red status of the same name. +{ + printf '4%sCheckRun%s%sci%sSUCCESS%s%s2026-11-24T11:00:00Z\n' "$t" "$t" "$t" "$t" "$t" "$t" + printf '4%sStatusContext%s%sci%s%sFAILURE%s2026-11-24T10:00:00Z\n' "$t" "$t" "$t" "$t" "$t" "$t" +} > "$work/checks-type.tsv" +gh_checks "$work/checks-type.tsv" +out=$(PATH="$work/ghshim:$PATH" sh scripts/audit-status.sh 2>&1) +report_section GitHub "$out" | awk '/^RED CHECKS/ { on = 1; print; next } on && /^#/ { print; next } { on = 0 }' > "$work/red.txt" +printf 'RED CHECKS on open pull requests:\n#4 failing: ci\n' | cmp -s - "$work/red.txt"; expect "report: a red status is not hidden by a green check run of the same name" 0 $? +# A row of a type the script does not know is judged by the same rule: red when its conclusion +# or its state is not empty and not a green value of either list (SUCCESS, NEUTRAL, SKIPPED, +# PENDING, EXPECTED); not red when both are empty. +{ + printf '6%sOther%s%sunk/red1%sFAILURE%s\n' "$t" "$t" "$t" "$t" "$t" + printf '6%sOther%s%sunk/red2%s%sERROR\n' "$t" "$t" "$t" "$t" "$t" + printf '6%sOther%s%sunk/red3%sSUCCESS%sSTALE\n' "$t" "$t" "$t" "$t" "$t" + printf '6%sOther%s%sunk/ok1%s%s\n' "$t" "$t" "$t" "$t" "$t" + printf '6%sOther%s%sunk/ok2%sNEUTRAL%sEXPECTED\n' "$t" "$t" "$t" "$t" "$t" + printf '6%sOther%s%sunk/ok3%sPENDING%s\n' "$t" "$t" "$t" "$t" "$t" + printf '6%sOther%s%sunk/red4%sSUCCESS_X%s\n' "$t" "$t" "$t" "$t" "$t" + printf '6%sOther%s%sunk/red5%s%sXPENDING\n' "$t" "$t" "$t" "$t" "$t" + printf '6%sOther%s%sunk/red6%sSTALE%s\n' "$t" "$t" "$t" "$t" "$t" +} > "$work/checks-unknown.tsv" +gh_checks "$work/checks-unknown.tsv" +out=$(PATH="$work/ghshim:$PATH" sh scripts/audit-status.sh 2>&1) +report_section GitHub "$out" | awk '/^RED CHECKS/ { on = 1; print; next } on && /^#/ { print; next } { on = 0 }' > "$work/red.txt" +printf 'RED CHECKS on open pull requests:\n#6 failing: unk/red1, unk/red2, unk/red3, unk/red4, unk/red5, unk/red6\n' | cmp -s - "$work/red.txt"; expect "report: a row of an unknown type is red unless green or empty" 0 $? +# A failing gh pr list (network, API limit) is said, never silent. +printf '#!/bin/sh\ncase "$*" in\n "auth status"*) exit 0 ;;\n *statusCheckRollup*) echo "API rate limit exceeded" >&2; exit 1 ;;\n *isDraft*) echo "#2 open step/x updated 2026-11-24: Test" ;;\n *) exit 0 ;;\nesac\n' > "$work/ghshim/gh" +out=$(PATH="$work/ghshim:$PATH" sh scripts/audit-status.sh 2>&1) +report_section GitHub "$out" | grep -qx "checks not read (gh pr list failed)"; expect "report: a failing gh pr list is said" 0 $? +# A check that finished and has no start time is older than any check with a time; between +# finished checks without a time, the later line wins. Only a check that is not started yet +# (no conclusion, no state) counts as the latest without a time. +{ + printf '2%sCheckRun%s%sLint%sSUCCESS%s%s\n' "$t" "$t" "$t" "$t" "$t" "$t" + printf '2%sCheckRun%s%sLint%sFAILURE%s%s2026-11-25T10:00:00Z\n' "$t" "$t" "$t" "$t" "$t" "$t" + printf '2%sCheckRun%s%sBuild%sFAILURE%s%s0001-01-01T00:00:00Z\n' "$t" "$t" "$t" "$t" "$t" "$t" + printf '2%sCheckRun%s%sBuild%sSUCCESS%s%s2026-11-25T10:00:00Z\n' "$t" "$t" "$t" "$t" "$t" "$t" + printf '2%sCheckRun%s%sDocs%sSUCCESS%s%s\n' "$t" "$t" "$t" "$t" "$t" "$t" + printf '2%sCheckRun%s%sDocs%sFAILURE%s%s\n' "$t" "$t" "$t" "$t" "$t" "$t" + printf '2%sCheckRun%s%sFmt%sFAILURE%s%s\n' "$t" "$t" "$t" "$t" "$t" "$t" + printf '2%sCheckRun%s%sFmt%sSUCCESS%s%s\n' "$t" "$t" "$t" "$t" "$t" "$t" +} > "$work/checks-notime.tsv" +gh_checks "$work/checks-notime.tsv" +out=$(PATH="$work/ghshim:$PATH" sh scripts/audit-status.sh 2>&1) +report_section GitHub "$out" | awk '/^RED CHECKS/ { on = 1; print; next } on && /^#/ { print; next } { on = 0 }' > "$work/red.txt" +printf 'RED CHECKS on open pull requests:\n#2 failing: Lint, Docs\n' | cmp -s - "$work/red.txt"; expect "report: a finished check with no time is older than one with a time" 0 $? +# The same holds for commit statuses: a finished status with no time is older than one with a +# time, in either line order. +{ + printf '2%sStatusContext%s%sci/x%s%sSUCCESS%s\n' "$t" "$t" "$t" "$t" "$t" "$t" + printf '2%sStatusContext%s%sci/x%s%sFAILURE%s2026-11-25T10:00:00Z\n' "$t" "$t" "$t" "$t" "$t" "$t" + printf '2%sStatusContext%s%sci/y%s%sFAILURE%s2026-11-25T10:00:00Z\n' "$t" "$t" "$t" "$t" "$t" "$t" + printf '2%sStatusContext%s%sci/y%s%sSUCCESS%s\n' "$t" "$t" "$t" "$t" "$t" "$t" +} > "$work/checks-notime-status.tsv" +gh_checks "$work/checks-notime-status.tsv" +out=$(PATH="$work/ghshim:$PATH" sh scripts/audit-status.sh 2>&1) +report_section GitHub "$out" | awk '/^RED CHECKS/ { on = 1; print; next } on && /^#/ { print; next } { on = 0 }' > "$work/red.txt" +printf 'RED CHECKS on open pull requests:\n#2 failing: ci/x, ci/y\n' | cmp -s - "$work/red.txt"; expect "report: a finished status with no time is older than one with a time" 0 $? +# A check not started yet is the latest in either line order. +{ + printf '2%sCheckRun%s%sLint%s%s%s\n' "$t" "$t" "$t" "$t" "$t" "$t" + printf '2%sCheckRun%s%sLint%sFAILURE%s%s2026-11-25T10:00:00Z\n' "$t" "$t" "$t" "$t" "$t" "$t" + printf '2%sCheckRun%s%sBuild%s%s%s0001-01-01T00:00:00Z\n' "$t" "$t" "$t" "$t" "$t" "$t" + printf '2%sCheckRun%s%sBuild%sFAILURE%s%s2026-11-25T10:00:00Z\n' "$t" "$t" "$t" "$t" "$t" "$t" +} > "$work/checks-order.tsv" +gh_checks "$work/checks-order.tsv" +out=$(PATH="$work/ghshim:$PATH" sh scripts/audit-status.sh 2>&1) +expect_absent "report: a check not started yet is the latest, also when listed first" GitHub "RED CHECKS" "$out" +# Two red checks of the same name in two workflows are told apart, and a red check with no name +# is said. +{ + printf '9%sCheckRun%sCI%sbuild%sFAILURE%s%s2026-11-25T10:00:00Z\n' "$t" "$t" "$t" "$t" "$t" "$t" + printf '9%sCheckRun%sDocs%sbuild%sFAILURE%s%s2026-11-25T10:00:00Z\n' "$t" "$t" "$t" "$t" "$t" "$t" + printf '9%sCheckRun%s%slint%sFAILURE%s%s2026-11-25T10:00:00Z\n' "$t" "$t" "$t" "$t" "$t" "$t" + printf '9%sCheckRun%s%s%sFAILURE%s%s2026-11-25T10:00:00Z\n' "$t" "$t" "$t" "$t" "$t" "$t" +} > "$work/checks-names.tsv" +gh_checks "$work/checks-names.tsv" +out=$(PATH="$work/ghshim:$PATH" sh scripts/audit-status.sh 2>&1) +report_section GitHub "$out" | awk '/^RED CHECKS/ { on = 1; print; next } on && /^#/ { print; next } { on = 0 }' > "$work/red.txt" +printf 'RED CHECKS on open pull requests:\n#9 failing: CI / build, Docs / build, lint, (no name)\n' | cmp -s - "$work/red.txt"; expect "report: red checks named with workflow, empty name said" 0 $? +# A failing gh pr list is said, never silent. +printf '#!/bin/sh\ncase "$*" in\n "auth status"*) exit 0 ;;\n *"pr list"*) echo "API rate limit exceeded" >&2; exit 1 ;;\n *) exit 0 ;;\nesac\n' > "$work/ghshim/gh" +out=$(PATH="$work/ghshim:$PATH" sh scripts/audit-status.sh 2>&1) +report_section GitHub "$out" | grep -qx "open pull requests not read (gh pr list failed)"; expect "report: a failing gh pr list says open pull requests not read" 0 $? +expect_absent "report: a failing gh pr list does not say no open pull requests" GitHub "^no open pull requests" "$out" +# A failing gh run list is said too, and does not claim there are no runs. +printf '#!/bin/sh\ncase "$*" in\n "auth status"*) exit 0 ;;\n *"run list"*) echo "HTTP 502" >&2; exit 1 ;;\n *) exit 0 ;;\nesac\n' > "$work/ghshim/gh" +out=$(PATH="$work/ghshim:$PATH" sh scripts/audit-status.sh 2>&1) +report_section GitHub "$out" | grep -qx "CI runs not read (gh run list failed)"; expect "report: a failing gh run list says CI runs not read" 0 $? +expect_absent "report: a failing gh run list does not say no CI runs" GitHub "^no CI runs on main" "$out" +# A gh run list with runs prints them, exactly, under the heading. With no runs it says so. +printf '#!/bin/sh\ncase "$*" in\n "auth status"*) exit 0 ;;\n *"run list"*) printf "%%s\\n" "2026-11-25 completed/success: Run one" "2026-11-24 in_progress/-: Run two" ;;\n *) exit 0 ;;\nesac\n' > "$work/ghshim/gh" +out=$(PATH="$work/ghshim:$PATH" sh scripts/audit-status.sh 2>&1) +report_section GitHub "$out" | awk '/^last CI runs on main:$/ { on = 1; print; next } on { print }' > "$work/runs.txt" +printf 'last CI runs on main:\n2026-11-25 completed/success: Run one\n2026-11-24 in_progress/-: Run two\n' | cmp -s - "$work/runs.txt"; expect "report: last CI runs listed under the heading" 0 $? +printf '#!/bin/sh\ncase "$*" in\n "auth status"*) exit 0 ;;\n *) exit 0 ;;\nesac\n' > "$work/ghshim/gh" +out=$(PATH="$work/ghshim:$PATH" sh scripts/audit-status.sh 2>&1) +report_section GitHub "$out" | grep -qx "no CI runs on main"; expect "report: no CI runs said" 0 $? +# Only green, pending and running checks: the GitHub section runs, and has no RED CHECKS line. +{ + printf '2%sCheckRun%s%sBuild%sSUCCESS%s\n' "$t" "$t" "$t" "$t" "$t" + printf '2%sCheckRun%s%sFmt%sNEUTRAL%s\n' "$t" "$t" "$t" "$t" "$t" + printf '2%sCheckRun%s%sFuzz%sSKIPPED%s\n' "$t" "$t" "$t" "$t" "$t" + printf '2%sCheckRun%s%sStill running%s%s\n' "$t" "$t" "$t" "$t" "$t" + printf '2%sStatusContext%s%sci/c%s%sPENDING\n' "$t" "$t" "$t" "$t" "$t" + printf '2%sStatusContext%s%sci/d%s%sSUCCESS\n' "$t" "$t" "$t" "$t" "$t" + printf '2%sStatusContext%s%sci/e%s%sEXPECTED\n' "$t" "$t" "$t" "$t" "$t" + printf '2%sStatusContext%s%sci/f%s%s\n' "$t" "$t" "$t" "$t" "$t" + printf '2%sOther%s%sunk/a%s%s\n' "$t" "$t" "$t" "$t" "$t" + printf '2%sOther%s%sunk/b%sSUCCESS%s\n' "$t" "$t" "$t" "$t" "$t" + printf '2%sOther%s%sunk/c%s%sEXPECTED\n' "$t" "$t" "$t" "$t" "$t" + printf '2%sOther%s%sunk/d%sSKIPPED%sPENDING\n' "$t" "$t" "$t" "$t" "$t" + printf '2%sOther%s%sunk/e%sEXPECTED%s\n' "$t" "$t" "$t" "$t" "$t" + printf '2%sOther%s%sunk/f%s%sSUCCESS\n' "$t" "$t" "$t" "$t" "$t" + printf '2%sOther%s%sunk/g%s%sNEUTRAL\n' "$t" "$t" "$t" "$t" "$t" + printf '2%sOther%s%sunk/h%s%sSKIPPED\n' "$t" "$t" "$t" "$t" "$t" +} > "$work/checks-green.tsv" +gh_checks "$work/checks-green.tsv" +out=$(PATH="$work/ghshim:$PATH" sh scripts/audit-status.sh 2>&1) +report_section GitHub "$out" | grep -qx "#2 open step/x updated 2026-11-24: Test"; expect "report: GitHub section ran with the gh stub" 0 $? +report_section GitHub "$out" | grep -qx "open pull requests:"; expect "report: open pull requests heading printed" 0 $? +expect_absent "report: no red checks, no RED CHECKS line" GitHub "RED CHECKS" "$out" +# Unfinished local work: uncommitted changes, stashes, unpushed and not pulled commits. +new_repo +commit a +out=$(sh scripts/audit-status.sh 2>&1) +report_section "Unfinished local work" "$out" | grep -qx "working tree clean"; expect "report: clean working tree said" 0 $? +expect_absent "report: clean tree, no uncommitted changes" "Unfinished local work" "^uncommitted changes:" "$out" +expect_absent "report: no stash, no stashes line" "Unfinished local work" "^stashes:" "$out" +report_section "Unfinished local work" "$out" | grep -qx "branch main: no upstream"; expect "report: no upstream said" 0 $? +echo changed > a.txt; echo new > new.txt +out=$(sh scripts/audit-status.sh 2>&1) +report_section "Unfinished local work" "$out" | grep -A2 -x "uncommitted changes:" > "$work/dirty.txt" +printf 'uncommitted changes:\n M a.txt\n?? new.txt\n' | cmp -s - "$work/dirty.txt"; expect "report: uncommitted changes listed" 0 $? +expect_absent "report: changes, no working tree clean" "Unfinished local work" "^working tree clean$" "$out" +git stash push -q -m "test stash" +out=$(sh scripts/audit-status.sh 2>&1) +report_section "Unfinished local work" "$out" | grep -A1 -x "stashes:" > "$work/stashes.txt" +printf 'stashes:\nstash@{0}: On main: test stash\n' | cmp -s - "$work/stashes.txt"; expect "report: stash listed" 0 $? +git stash drop -q; rm -f new.txt +# Upstream counts: commits not pushed, and commits fetched but not pulled. +git init -q --bare -b main "$work/up.git"; git remote add origin "$work/up.git" +git push -q -u origin main 2>/dev/null +commit b; commit c +report_section "Unfinished local work" "$(sh scripts/audit-status.sh 2>&1)" | grep -qx "branch main: 2 unpushed, 0 not pulled"; expect "report: unpushed commits counted" 0 $? +git clone -q "$work/up.git" "$work/other" 2>/dev/null +(cd "$work/other" && commit x && commit y && commit z && git push -q origin main 2>/dev/null) +git fetch -q origin +report_section "Unfinished local work" "$(sh scripts/audit-status.sh 2>&1)" | grep -qx "branch main: 2 unpushed, 3 not pulled"; expect "report: not pulled commits counted" 0 $? +rm -rf "$work/up.git" "$work/other" + echo "scripts tests: $passed passed, $failed failed" [ "$failed" -eq 0 ] From 29643bd8edd7d8ad6704b597900065b2746cda60 Mon Sep 17 00:00:00 2001 From: Bertalan Ivan <2826311+bertalan@users.noreply.github.com> Date: Wed, 25 Nov 2026 11:53:13 +0100 Subject: [PATCH 4/5] audit: 0011 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --- docs/audits/0011-2026-11-25.md | 194 +++++++++++++++++++++++++++++++++ 1 file changed, 194 insertions(+) create mode 100644 docs/audits/0011-2026-11-25.md diff --git a/docs/audits/0011-2026-11-25.md b/docs/audits/0011-2026-11-25.md new file mode 100644 index 0000000..c8614c8 --- /dev/null +++ b/docs/audits/0011-2026-11-25.md @@ -0,0 +1,194 @@ +# Coherence audit 0011 (2026-11-25) +Range: 79025cd..74cb34c (5244cbe and 6fe7029 on `main`, merged from PR #3; 2852907, 39635f6 and 74cb34c on `step/0.5-script-test-gaps`, PR #4, draft; working tree clean) Verdict: DRIFT FOUND + +Auditor: `coherence-auditor` agent, fresh context, read-only, run because the cadence is due (5 commits since audit 0010). + +The drift is small. No claim about code is false, and every commit of the range follows an APPROVED verdict whose tree matches. Seven findings: + +- F1 is a latent bug in `scripts/audit-status.sh`: the marker search reads `tests/corpus/` and `tests/out/`. It is older than the range and no earlier audit reported it. +- F2 and F3 are the two points that round 10 of the last review moved to the next commit of PR #4. F2 is a contradiction inside roadmap 0.5 that 39635f6 had closed and 74cb34c brought back. +- F4 to F7 are minor: how verdicts are posted on PR #4, Italian quotes in two PR comments, one sentence of the reviewer prompt, one long sentence. + +## Unfinished work + +`sh scripts/audit-status.sh` (exit 0): + +``` +== Audit cadence +commits since last audit: 5 (audit every 5) +last audit: 79025cd 2026-11-24 audit: 0010 +AUDIT DUE + +== Rust +pinned Rust 1.100.0 is the latest stable + +== Unfinished local work +working tree clean +branch step/0.5-script-test-gaps: 0 unpushed, 0 not pulled +local branches not merged into main: + step/0.5-script-test-gaps +remote branches not merged into main: + origin/step/0.5-script-test-gaps + +== Markers in code +none + +== Leftovers (scripts/cleanup.sh --plan; run scripts/cleanup.sh to remove the local ones) +would remove local branch (merged): step/0.4-writing-guide +keep local branch (not merged): step/0.5-script-test-gaps +on GitHub, merged (kept, nothing is deleted on GitHub): origin/step/0.2-ci +on GitHub, merged (kept, nothing is deleted on GitHub): origin/step/0.2.1-confirmation-rules +on GitHub, merged (kept, nothing is deleted on GitHub): origin/step/0.4-writing-guide +on GitHub, draft PR (not closed here): #4 updated 2026-11-25: Roadmap 0.5: remaining gaps in the rule-script tests + +== GitHub +open pull requests: +#4 DRAFT step/0.5-script-test-gaps updated 2026-11-25: Roadmap 0.5: remaining gaps in the rule-script tests +last CI runs on main: +2026-11-24 completed/success: Mark roadmap step 0.4 done +2026-11-23 completed/success: Guard the Windows skips; test the report with no red checks +2026-11-23 completed/success: CI +``` + +- Local work: nothing uncommitted (`git status --porcelain` empty), no stash, one worktree, nothing unpushed. `.claude/worktrees/` is empty. +- Cadence: `sh scripts/audit-status.sh --gate-push HEAD` exits 0. `--gate-commit` exits 1 ("5 commits since the last coherence audit (limit 5)") until this report is committed alone. +- PR #4 (draft, opened 2026-11-24 20:04 UTC, under one day old, head 74cb34c, 5 comments): + - What it is for: roadmap 0.5 (`docs/roadmap.md:76-131`), the gaps in the rule-script tests. It also holds the twelve minor points moved from PR #3, the review-trace rule and the new step 0.6. + - Done: 2852907 (the twelve points), 39635f6 (the tree rule), 74cb34c (tests and fixes of the rule scripts, 0.5 marked `[x]`, 0.6 added). + - Missing: the commit that closes this audit and the two points of round 10 (F2, F3); then the PR marked ready and the merge. + - State comment: present and true. The last comment (2026-11-25 10:35 UTC) says audit 0011 runs next, then the closing commit, then CI, ready and merge. + - Still relevant: yes, it is the one open step. +- The `[x]` on 0.5 (`docs/roadmap.md:76`): true by the letter of `docs/roadmap.md:7-8` at the end of this audit. Round 10 is APPROVED and the four jobs are green on 74cb34c. One more commit is planned in this PR, so CI must be green again on that commit before the merge. +- CI job lists (`gh run view <id> --json jobs`), each with Repository rules, Linux musl, macOS arm64 and Windows gnu: + + | Commit | Run | Result | + |---|---|---| + | 5244cbe | 45438927876 | four jobs `success` | + | 6fe7029 (PR #3) | 45456030987 | four jobs `success` | + | 6fe7029 (`main`) | 45474562813 | four jobs `success` | + | 2852907 | 45476955225 | four jobs `success` | + | 39635f6 | 45503809545 | four jobs `success` | + | 74cb34c (head) | 45596510329 | four jobs `success` | + + The Windows job of the head was still running when the audit started and finished green by 10:50 UTC. GitGuardian passes. No red check, no missing run. +- Pull requests (`gh pr list --state all`): #1, #2 and #3 merged, #4 open as a draft. PR #3 was merged on 2026-11-24 19:51 UTC, after the four jobs were green on 6fe7029. +- Branches: local `main`, `step/0.4-writing-guide` (merged) and the step branch. On GitHub: `main`, three merged step branches (kept) and the step branch. Nothing stale. +- Markers: none in `src`, `scripts`, `.githooks`, `.github`, `Cargo.toml`. The only match is the pattern itself at `scripts/audit-status.sh:142`. +- Leftovers: `sh scripts/cleanup.sh --plan` (exit 0) lists one thing to remove, the local branch `step/0.4-writing-guide`, merged into `main`. The developer removes it locally with `sh scripts/cleanup.sh`. Nothing is deleted on GitHub. +- Tracked files that belong to the work, not the product: none. `git ls-files` shows 41 files; the only reports are the ten under `docs/audits/`. + +## Findings + +### F1. `rule broken` (latent bug, older than the range): the marker search of the session report reads `tests/corpus/` and `tests/out/` +- `scripts/audit-status.sh:142`: `grep -rnE 'TODO|FIXME|XXX|todo!\(|unimplemented!\(|#\[ignore' src tests 2>/dev/null | grep -v '^tests/fixtures/'`. It walks all of `tests/`, so also the two ignored folders that hold real and extracted documents. +- Probe on a scratch copy outside the repository, with two synthetic files: + + ``` + == Markers in code + tests/out/fake.txt:1:TODO fake extracted line + tests/corpus/fake.txt:1:Mario Rossi Test XXX synthetic line + ``` + + A text line of a real document that holds `XXX` or `TODO` would be printed in the session report, which agents read and repeat. +- `CLAUDE.md` ("Which test data may we use?") keeps real documents out of every agent's reach; both prompts say never to read `tests/corpus/`. On the Mac the folder does not exist, so nothing leaked. On the Windows PC it does. +- The line dates from 844cb25 (2026-11-22). No earlier audit reports it. It is not among the known limits of `docs/roadmap.md:109-127`, and no test covers it (`grep -n corpus scripts/test-scripts.sh` finds only the allowlist tests). +- Change: code and test, test first. The search skips `tests/corpus/` and `tests/out/` (or reads only tracked files). A bug never moves to a later commit (`CLAUDE.md`, step 5). + +### F2. `contradiction` (moved by review round 10, open): the lead-in of roadmap 0.5 contradicts its own "Rust" item +- `docs/roadmap.md:78-79`: "Each known limit needs a test before the code it names changes." +- `docs/roadmap.md:118-119`: "a breakage of this section that shows no bug is listed here, not tested". `CLAUDE.md`, step 4, says the same. +- 39635f6 had closed this point: the lead-in then read "except where an item says otherwise" (`git show 39635f6:docs/roadmap.md`, line 78). 74cb34c rewrote the lead-in and lost the exception. +- Round 10 of the review of 74cb34c lists it as moved to the next commit of PR #4 (comment of 2026-11-25 10:34 UTC). +- Change: doc, in the next commit of PR #4. + +### F3. `unfinished` (moved by review round 10, open): roadmap 0.6 says more than the owner's decision it quotes +- `docs/roadmap.md:140`: "Sonnet writes routine code: scripts, their tests, docs." +- `CLAUDE.md`, step 4, calls the scripts under `scripts/` "rules that protect". The reviewer could match only "Sonnet for routine code" to the owner's decision (same comment, round 10). +- Change: the owner chooses. Either the examples go, or the owner confirms that the rule scripts are routine code. Then doc, in the next commit of PR #4. + +### F4. `drift` (minor): on PR #4 the verdicts are posted in one comment per commit, not round by round +- `CLAUDE.md`, step 5: "Post every verdict as a comment on the pull request, as soon as the PR exists: APPROVED or CHANGES NEEDED, the findings in short, how each was closed." +- 39635f6: rounds 1 to 3 are in one comment (2026-11-24 22:44:38 UTC), seven seconds before the commit. +- 74cb34c: rounds 1 to 10 are in one comment (2026-11-25 10:34:30 UTC). The comment of 00:20 UTC says of rounds 1 to 3: "Their verdicts will be posted with the commit." +- On PR #3 each round had its own comment (comments of 2026-11-24 11:22 to 16:35 UTC). +- Effect: the findings of rounds 1 to 7 are summaries ("Three tests were missing", "Some git calls had no guard"). An audit cannot check each of them; it can only read "Each finding was fixed test first and reviewed again in the next round." +- No rule on trees or approvals is broken (see the table under "Verified and found true"). +- Change: the owner chooses. Either `CLAUDE.md` says that the rounds of one commit may be posted together, or each round is posted when it ends. + +### F5. `rule broken` (minor): two comments of PR #4 quote the owner in Italian +- First comment (2026-11-24 20:04 UTC): "Confermo, dal terzo" and "Sì, nota". Second comment (22:44 UTC): "Stessa PR se ci sono commit". +- `CLAUDE.md`, "Which rules hold everywhere?": "Italian is used only when talking to the user (the developer) in the conversation." PR texts follow the same rules as the repository. +- The quotes hold no personal data; `sh scripts/check-public.sh --message <file>` exits 0 on each comment. +- Change: later comments give the owner's decisions in English. The owner decides whether the two comments are edited. + +### F6. `drift` (minor): the reviewer prompt names only one of the two places a point can move to +- `.claude/agents/fable-reviewer.md:138-139`: "such a point never moves to a later PR." +- `CLAUDE.md`, step 5, since 39635f6: points move "to the next commit of the same PR" or to the first commit of the next PR, and "Some points never move". +- Change: doc. "never moves" without the place. + +### F7. `minor`: texts that break `docs/writing.md` +- `CLAUDE.md:129-130`, new in 74cb34c: one sentence of 33 words with two commands ("First it compares `git -C <worktree> diff HEAD` and ..."). +- Carried over, unchanged in the range: `CLAUDE.md:102` (33 words), `docs/roadmap.md:182-184` (36 words). +- No em dash, curly quote or bold in `CLAUDE.md`, `README.md`, `docs/roadmap.md`, `docs/writing.md` or the prompts; `docs/design.md` has no bold left (`grep -c '\*\*'`: 0). + +### Follow-up of audit 0010 +- F1 (head not reviewed, prompts not rewritten): closed. Both prompts are rewritten in 5244cbe, approved in round 14. +- F2 (review before or after the commit): closed by the owner's decision of 2026-11-24, in `CLAUDE.md`, step 5. +- F3 (PR #3 description): closed. The description lists the rewrites, says "risky runs" and names the decisions of 2026-11-24. +- F4 (writing): closed. R34 "Writing and undo" and "Dialogs" are sub-lists (`docs/design.md:268-276,322-330`); "my conclusions" and "(proposal)" are gone; the "Before" headings are a fixed format (`docs/writing.md:87-88`); the note on the message of f8c0ac2 is in 5244cbe. +- F5 (R34 items named by no step): closed by one rule (`docs/roadmap.md:8-11`, `284`), owner's decision of 2026-11-24. +- F6: closed. `README.md:165` is a question; `assert_cmd` and `predicates` are in roadmap 2.3 (`docs/roadmap.md:211-212`); the test of 0003-F6 exists ("branch created at main", `scripts/test-cleanup.sh`). + +### Verified and found true +- Every commit of the range follows an APPROVED verdict that a comment ties to it. Trees are from `git rev-parse <commit>^{tree}`, subjects from `git log -1 --format=%s`: + + | Commit | Committed (UTC) | Last APPROVED verdict | Tree in the verdict and in the naming comment | Subject quoted | + |---|---|---|---|---| + | 5244cbe | 11-24 16:35:15 | PR #3, round 14, 16:35:01 | `1768b0c0...`, equal | not required | + | 6fe7029 | 18:06:59 | PR #3, round 5 of the mark, 18:06:53 | `dfbc229c...` in the naming comment, equal | not required | + | 2852907 | 20:04:24 | PR #4, round 3, posted 20:04:48 (the PR opened at 20:04:41) | `594ec9f6...`, equal in both | not required | + | 39635f6 | 22:44:45 | PR #4, round 3, 22:44:38 | `3279a210...`, equal in both | equal | + | 74cb34c | 11-25 10:34:49 | PR #4, round 10, 10:34:30 | `33882b4b...`, equal in both | equal | + +- Moved minor points are closed by the commit they moved to: + - twelve points from PR #3 to 2852907: eight fixed in the files (checked with `git show 2852907:<file>`: "The reviewer reviews", the split description, the 0.5 lead-in, the minor-round rule in the reviewer prompt, "The verdict comment of that round", "or on confirmation or writing files", the script sub-list, "on its last commit"); the 25 bold labels gone (`grep -c '\*\*'`: 25 at 6fe7029, 0 at 2852907); three notes in the message; + - two points from round 3 of 2852907 to 39635f6: both fixed (the note is the fourth way to close a finding in `CLAUDE.md` and the auditor prompt; the lead-in, but see F2); + - four points from round 3 of 39635f6 to 74cb34c: all closed (`git reset --soft HEAD~1`, "when the author plans more commits", the auditor's tree and subject checks, the worktree rules, two notes in the message); + - two points from round 10 of 74cb34c: open, due in the next commit (F2, F3). +- Roadmap 0.5, "Closed in this step": each item has tests, none ignored, all pass. Sixteen rules were broken one at a time on a scratch copy; a test failed each time: + - `check-public.sh`: the old `rev-list | wc` line; tags scanned one level only; + - hooks: `--gate-push` ignored; pre-push passing on exit 2 or a missing script; `--gate-commit` passing when it cannot run; commit-msg passing when the check is missing; + - `cleanup.sh`: the `merge-base --is-ancestor` check before deletion removed; + - `audit-status.sh`: a denylist for red checks; no "latest attempt" rule; the key without the workflow; an absolute hooks path accepted without `-ef`; "not read" replaced for pull requests and for CI runs; stashes, unpushed count and uncommitted changes not shown. +- The message of 74cb34c against the diff: 13 tests and 2 controls for failing git commands (`scripts/test-scripts.sh:594-655`); 7 nested-tag tests and 16 refusal tests (hook tests 24 to 47); totals 233, 90 and 47 as the PR states; the eight new limits are all at `docs/roadmap.md:99-117`. +- Known limits named by the roadmap exist: the "Known limits" header (`scripts/check-public.sh:17-20`); 5 checks skipped on Windows (`scripts/test-cleanup.sh:171,258`: 4 and 1). +- References: every path named in `CLAUDE.md`, `README.md`, `docs/`, the prompts, the scripts and the hooks exists, except planned ones in open steps (`scripts/make-fixtures.sh`, `scripts/merge-ready.sh`, `docs/lessons.md`, `docs/accessibility.md`) and names used as test data. `assert_cmd` 2.2.2 and `predicates` 3.1.4 are in `Cargo.toml` and `Cargo.lock`. +- Docs against each other: the hooks do what `CLAUDE.md`, step 6, says; the six rules and the seven exceptions are counted right (`CLAUDE.md`, `docs/writing.md:73`); the fifteen "Before" headings match `docs/roadmap.md:74-75`; the auditor prompt and `CLAUDE.md` agree on the four ways to close a finding. +- Roadmap marks: 0.1, 0.2, 0.2.1, 0.4, 0.5 and 1.0 hold. `src/` did not change in the range: `is_envelope` (`src/lib.rs:10`, R1a) is the only public function, with six tests, none ignored. No scope drift in code. +- Safety, accessibility, uninstall (R28–R43): still no code; nothing is claimed done. +- Language rule: all text added to the repository in the range is English (F5 is on GitHub only). +- Public-repository rule: `sh scripts/check-public.sh --range tip HEAD` exits 0; the five commits have no-reply author and committer addresses; the description of PR #3 and PR #4 and the 25 comments of the range pass `--message`. `tests/corpus/` was not read. +- Not checkable from the files: that each review ran on a newly started agent of a different, equal or higher model; that three agents worked in worktrees for 74cb34c. +- Not re-checked: the GitHub settings; the workflow against roadmap 0.2 (`.github/workflows/ci.yml` unchanged in the range); the LOTL numbers, the candidate crates, and the laws and standards cited in `docs/design.md` (text unchanged in the range). + +## Health + +Run on macOS arm64 at 74cb34c, working tree clean. Script tests and rule-breaking probes ran on a scratch copy (`git archive HEAD`) outside the repository. + +| Command | Result | +|---|---| +| `cargo fmt --check` | clean (exit 0) | +| `cargo clippy --all-targets -- -D warnings` | no issues (exit 0) | +| `cargo nextest run` | 5 passed (2 binaries), exit 0 | +| `cargo test --doc` | 0 doctests (none exist), exit 0 | +| `cargo deny check` | `advisories ok, bans ok, licenses ok, sources ok` (exit 0); warning for an allowed licence not used yet (`Zlib`, `deny.toml:22`) | +| `sh scripts/test-scripts.sh` | 233 passed, 0 failed | +| `sh scripts/test-cleanup.sh` | 90 passed, 0 failed, 0 skipped | +| `sh scripts/test-hooks.sh` | 47 passed, 0 failed | +| `sh scripts/check-public.sh --range tip HEAD` | exit 0 ("0 commits and the tree of 74cb34c scanned") | +| `sh scripts/audit-status.sh --gate-push HEAD` | exit 0 | +| `sh scripts/audit-status.sh --gate-commit` | exit 1: "5 commits since the last coherence audit (limit 5)" | +| CI on 74cb34c (PR #4) | all four jobs green (run 45596510329) | +| CI on `main` (6fe7029) | all four jobs green (run 45474562813) | + +The repository was not modified by the audit: `git status --porcelain` is empty before and after, no stash, HEAD still 74cb34c. `cleanup.sh` was run with `--plan` only. Nothing was posted or changed on GitHub. From 72b89f37ad21fc183544f0c52eb752cc5d34422e Mon Sep 17 00:00:00 2001 From: Bertalan Ivan <2826311+bertalan@users.noreply.github.com> Date: Wed, 25 Nov 2026 15:06:28 +0100 Subject: [PATCH 5/5] Close audit 0011 and the two points moved from round 10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit F1, bug, test first: the marker search of audit-status.sh read tests/corpus/ and tests/out/, which hold real and extracted documents. A marker word in a real document would be printed in the session report. For a binary document, such as a signed file, grep printed its file name. find now prunes both folders, in any case of their names. It prunes tests/fixtures too, in that exact case. So the two folders are never read, even when .gitignore lacks them. Before, the marker section had no test. New tests: - a tracked and an untracked marker are listed; - fixtures, corpus and output are not listed, binary files and capital names (tests/CORPUS, tests/OUT) included; - symbolic links into the corpus are not followed; - each of the six marker words is listed; - with a single file to search, its name is still printed; - grep never searches recursively and is never given a file in the two folders (a grep stand-in logs its options and files); - a repository with no marker says "none". Roadmap 0.5 lists one more known limit, added after the owner marked the step done: the marker search prints "none" when find or grep cannot run. F2, moved from round 10: the lead-in of roadmap 0.5 again carries the exception, and now names the "Rust" section. The audit leaves F3 and F4 to the owner. The owner delegated such choices on 2026-11-25: choose the solution that serves the goal and is coherent with earlier choices. F3, moved from round 10: roadmap 0.6 no longer counts scripts as routine code. The owner's decision says only "Sonnet for routine code"; the rule scripts protect. Step 0.6 decides whether the rule scripts and the hooks count as routine code. F4 and F5 are written into roadmap 0.6 as the first lessons of docs/lessons.md: post each verdict when its round ends; give the owner's decisions in English on GitHub. At the owner's request, the two PR #4 comments with Italian quotes now give them in English, with a note that says so. F6: the reviewer prompt says a point on personal data or R28–R34 "never moves", without naming a place. F7: the three long sentences the audit names are split: in CLAUDE.md, marking a PR ready and the worktree removal; in roadmap 1.5, sensitive folders and the risky run. The session-start sentence of CLAUDE.md is split too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --- .claude/agents/fable-reviewer.md | 2 +- CLAUDE.md | 29 +++++----- docs/roadmap.md | 22 +++++--- scripts/audit-status.sh | 8 ++- scripts/test-scripts.sh | 91 ++++++++++++++++++++++++++++++++ 5 files changed, 129 insertions(+), 23 deletions(-) diff --git a/.claude/agents/fable-reviewer.md b/.claude/agents/fable-reviewer.md index dee00fb..b5ba8ec 100644 --- a/.claude/agents/fable-reviewer.md +++ b/.claude/agents/fable-reviewer.md @@ -136,4 +136,4 @@ Write the report in English. When every finding is minor, the verdict is `VERDICT: APPROVED`, with the minor points listed. Mark each point on personal data, or on confirmation or writing files (R28–R34): such a point -never moves to a later PR. It is fixed and reviewed before the commit (`CLAUDE.md`, step 5). +never moves. It is fixed and reviewed before the commit (`CLAUDE.md`, step 5). diff --git a/CLAUDE.md b/CLAUDE.md index 9d2aec9..e012b2d 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -97,17 +97,18 @@ With the six rules below. Long work across sessions drifts: docs claim things th do, references point to functions or options that never existed, work is left half-done. - Session start: run `sh scripts/audit-status.sh` and tell the user what it shows. Unfinished - work comes first: uncommitted changes, stashes, unpushed commits, unmerged branches, open or - draft PRs, red CI. Finish it, or close it with a written reason, before starting anything new. + work comes first. Finish it, or close it with a written reason, before starting anything new. + Unfinished work is: uncommitted changes, stashes, unpushed commits, unmerged branches, open or + draft PRs, red CI. - Branches and PRs (after the first push): one branch per roadmap step - (`step/1.1-portable-names`), pushed early as a draft PR. Mark it ready only when CI is green - on all four jobs (read in the job list, never assumed from a pending run) and `fable-reviewer` - approved, with its verdict posted on the PR. Merge it into `main` locally by fast-forward: - `git switch main && git merge --ff-only step/x && git push`. The merged commits are the same - ones CI checked, history stays linear and the pre-push hook runs. The GitHub merge button is - not used: it rewrites commits. One step is open at a time. A session never ends with a draft - PR without a comment saying its state and next step. Abandoned work is closed with the reason, - never left open. + (`step/1.1-portable-names`), pushed early as a draft PR. Mark it ready only when two things + hold. CI is green on all four jobs, read in the job list, never assumed from a pending run. + `fable-reviewer` approved, with its verdict posted on the PR. Merge it into `main` locally by + fast-forward: `git switch main && git merge --ff-only step/x && git push`. The merged commits + are the same ones CI checked, history stays linear and the pre-push hook runs. The GitHub merge + button is not used: it rewrites commits. One step is open at a time. A session never ends with + a draft PR without a comment saying its state and next step. Abandoned work is closed with the + reason, never left open. - Every 5 commits, a coherence audit by the `coherence-auditor` agent (Fable, a different model of equal or higher capability than the author's, fresh context, read-only). It checks requirements, tests and code against each other, the existence of every concrete reference, @@ -129,9 +130,11 @@ do, references point to functions or options that never existed, work is left ha - Agents that work in parallel each get a git worktree under `.claude/worktrees/` (ignored by git). They never commit there; the main session takes their changes as a patch. When the changes are committed, the main session removes the worktree and its branch, locally. - First it compares `git -C <worktree> diff HEAD` and - `git -C <worktree> status --porcelain --untracked-files=all` with the patch it took: a change - made after the patch is taken again or reported, never lost. Then + First it compares the worktree with the patch it took, with these two commands: + - `git -C <worktree> diff HEAD`; + - `git -C <worktree> status --porcelain --untracked-files=all`. + + A change made after the patch is taken again or reported, never lost. Then `git worktree remove --force` and `git branch -D`. `--force` is needed because the worktree still has uncommitted files. - Ignored folders are never touched. `tests/corpus/`, `tests/out/` and `target/` are protected diff --git a/docs/roadmap.md b/docs/roadmap.md index eb1052e..c12fe6d 100644 --- a/docs/roadmap.md +++ b/docs/roadmap.md @@ -76,7 +76,7 @@ script tests, and the changes to the way of working adopted on 2026-11-25. - [x] 0.5 Remaining gaps in the rule-script tests. The reviews of PR #1, PR #2 and PR #3 found them. This step closed the ones below that are not listed as known limits. The owner marked the step done with these limits listed (2026-11-25). Each known limit needs a test before the - code it names changes. + code it names changes, except in the "Rust" section (below). - Closed in this step, test first: - `check-public.sh`: a failing `git show`, `ls-tree`, `diff-tree`, `cat-file`, `log`, `rev-list` or `diff` stops the check with exit 2. Two of them passed in silence before: @@ -115,6 +115,8 @@ script tests, and the changes to the way of working adopted on 2026-11-25. - a check name with a backslash is printed with the backslash doubled (`@tsv` escapes it); - `gh pr list` reads at most 30 open pull requests, its default; - the exit status of the `awk` that selects the red checks is not checked; + - the marker search prints "none" when `find` or `grep` cannot run. This limit was added + after the owner marked the step done, by the review of the commit that closes audit 0011; - "Rust" section: the owner decided (2026-11-23) that a breakage of this section that shows no bug is listed here, not tested. These are listed: - `rustup check` has no time limit. It runs only in report mode, after the hook gates; @@ -137,12 +139,15 @@ script tests, and the changes to the way of working adopted on 2026-11-25. - `scripts/merge-ready.sh`, test first. It waits until the four CI jobs are green on the exact head of the PR, and stops if the head moves. It also checks that the last verdict comment is APPROVED and quotes the tree of that head. The merge goes ahead only after it. - - Model by risk. Sonnet writes routine code: scripts, their tests, docs. Opus writes the code - for cryptography and for R28–R34. Reviews and audits stay on Fable. A PR holds about 400 - changed lines; a bigger step is split into slices, and the PR says what is left. + - Model by risk. Sonnet writes routine code. Opus writes the code for cryptography and for + R28–R34. The rule scripts and the hooks protect, so this step decides whether they count as + routine code. Reviews and audits stay on Fable. A PR holds about 400 changed lines; a bigger + step is split into slices, and the PR says what is left. - `docs/lessons.md`: lessons learnt on the way of working, each with its date and what to do. Agents never watch CI themselves; only the main session does, so that GitHub's API limit is - not used up. + not used up. The first lessons come from audit 0011: + - post each review verdict on the PR when its round ends, not together with the commit (F4); + - give the owner's decisions in English in PR texts and comments (F5). ## Phase 1: how do we write files safely, before any cryptography? @@ -179,9 +184,10 @@ With pure functions for names and confirmation, and a writer that never overwrit resolved), and hidden folders are skipped; both are listed in the report. Unreadable folders are listed. - Two counts (files to process, files of any kind), total size, subfolders. - - Detection of sensitive folders (drive roots, home, Desktop, Documents, system folders, - network share roots) and of a risky run: a sensitive folder, or more than 10,000 files of - any kind over all the folders, subfolders included. + - Detection of sensitive folders: drive roots, home, Desktop, Documents, system folders, + network share roots. + - Detection of a risky run: a sensitive folder, or more than 10,000 files of any kind over all + the folders, subfolders included. - [ ] 1.6 Confirmation logic (R28–R30). First decide the questions "Before 1.6" in `docs/design.md`. - Pure functions turn the counts, the folder, the way the run started (terminal, dialog via diff --git a/scripts/audit-status.sh b/scripts/audit-status.sh index 85cd52f..223ba4d 100755 --- a/scripts/audit-status.sh +++ b/scripts/audit-status.sh @@ -139,7 +139,13 @@ elif git remote | grep -qx origin; then fi section "Markers in code" -markers=$(grep -rnE 'TODO|FIXME|XXX|todo!\(|unimplemented!\(|#\[ignore' src tests 2>/dev/null | grep -v '^tests/fixtures/' || true) +# tests/corpus/ and tests/out/ hold real and extracted documents: their files are never read, +# not only hidden from the output. +# Any case: on macOS and Windows tests/Corpus is tests/corpus (find -ipath is not POSIX). +markers=$(find src tests -path 'tests/[Cc][Oo][Rr][Pp][Uu][Ss]' -prune \ + -o -path 'tests/[Oo][Uu][Tt]' -prune \ + -o -path tests/fixtures -prune -o -type f \ + -exec grep -nHE 'TODO|FIXME|XXX|todo!\(|unimplemented!\(|#\[ignore' {} + 2>/dev/null || true) [ -n "$markers" ] && printf '%s\n' "$markers" || echo "none" section "Leftovers (scripts/cleanup.sh --plan; run scripts/cleanup.sh to remove the local ones)" diff --git a/scripts/test-scripts.sh b/scripts/test-scripts.sh index c41a359..bbb322b 100755 --- a/scripts/test-scripts.sh +++ b/scripts/test-scripts.sh @@ -899,5 +899,96 @@ git fetch -q origin report_section "Unfinished local work" "$(sh scripts/audit-status.sh 2>&1)" | grep -qx "branch main: 2 unpushed, 3 not pulled"; expect "report: not pulled commits counted" 0 $? rm -rf "$work/up.git" "$work/other" +# Markers in code: src and tests are searched, tracked or not. The fixtures are skipped, and so +# are tests/corpus/ and tests/out/, which hold real and extracted documents, even when +# .gitignore lacks them (audit 0011, F1). +new_repo +mkdir -p src tests/fixtures tests/corpus tests/out +printf '// TODO tracked marker\n' > src/lib.rs +printf '// FIXME untracked marker\n' > tests/new.rs +printf 'TODO fixture line\n' > tests/fixtures/f.txt +printf 'TODO corpus line\n' > tests/corpus/c.txt +printf 'XXX extracted line\n' > tests/out/o.txt +# Binary files, as real signed documents are: a search that reads them prints their names. +printf 'TODO\000corpus binary\n' > tests/corpus/b.p7m +printf 'TODO\000extracted binary\n' > tests/out/b.pdf +git add src/lib.rs && git commit -qm markers +out=$(sh scripts/audit-status.sh 2>/dev/null) +report_section "Markers in code" "$out" | grep -q '^src/lib.rs:1:// TODO tracked marker$' +expect "markers: a tracked file in src is listed" 0 $? +report_section "Markers in code" "$out" | grep -q '^tests/new.rs:1:// FIXME untracked marker$' +expect "markers: an untracked file in tests is listed" 0 $? +expect_absent "markers: fixtures, corpus and output skipped" "Markers in code" \ + 'fixtures|corpus|tests/out|extracted' "$out" +# Each marker word is listed. +printf '// XXX word\ntodo!(a)\nunimplemented!(b)\n#[ignore]\n' > src/words.rs +out=$(sh scripts/audit-status.sh 2>/dev/null) +for w in "src/words.rs:1:// XXX word" "src/words.rs:2:todo!(a)" "src/words.rs:3:unimplemented!(b)" \ + "src/words.rs:4:#[ignore]"; do + report_section "Markers in code" "$out" | grep -qxF "$w"; expect "markers: listed: $w" 0 $? +done +# With a single file to search, the line still starts with the file name. +rm -f src/lib.rs src/words.rs tests/new.rs +printf '// XXX alone\n' > src/one.rs +out=$(sh scripts/audit-status.sh 2>/dev/null) +report_section "Markers in code" "$out" | grep -qxF "src/one.rs:1:// XXX alone" +expect "markers: a single file is named" 0 $? +# The two folders are skipped whatever the case of their names: on macOS and Windows, +# tests/CORPUS is tests/corpus. Every letter is in capitals here and in lower case in the test +# above, so a pattern that drops either case of any letter fails. Only the capital folders exist +# here, so the test also holds on Linux, where the names differ. +new_repo +mkdir -p src tests/CORPUS tests/OUT +printf '// TODO kept\n' > src/lib.rs +printf 'XXX cased corpus\n' > tests/CORPUS/c.txt +printf 'TODO\000cased binary\n' > tests/OUT/o.pdf +out=$(sh scripts/audit-status.sh 2>/dev/null) +report_section "Markers in code" "$out" | grep -qxF "src/lib.rs:1:// TODO kept" +expect "markers: cased folders: the search ran" 0 $? +expect_absent "markers: cased corpus and output skipped" "Markers in code" 'CORPUS|OUT|cased' "$out" +# Symbolic links into the corpus are not followed: a link to a corpus file and a link to the +# corpus folder print nothing. Git Bash on Windows may copy instead of linking; there the test +# is skipped, and only there. +new_repo +mkdir -p src tests/corpus +printf '// TODO kept\n' > src/lib.rs +printf 'XXX linked corpus\n' > tests/corpus/c.txt +ln -s corpus/c.txt tests/filelink.txt 2>/dev/null +ln -s ../tests/corpus src/dirlink 2>/dev/null +if [ -L tests/filelink.txt ] && [ -L src/dirlink ]; then + out=$(sh scripts/audit-status.sh 2>/dev/null) + report_section "Markers in code" "$out" | grep -qxF "src/lib.rs:1:// TODO kept" + expect "markers: links: the search ran" 0 $? + expect_absent "markers: links into the corpus not followed" "Markers in code" 'linked' "$out" +elif pwd -W >/dev/null 2>&1; then + echo "skipped on Windows: ln -s made no symbolic link" +else + expect "markers: symbolic links created" 0 1 +fi +# The files of the two folders are never read, not only hidden from the output. A grep +# stand-in logs every recursive option and every argument that names an existing file, then +# runs the real grep. Grep reads a folder only when it searches recursively. Patterns, such as +# the one cleanup.sh uses to protect these folders, name no file and are not logged. +new_repo +mkdir -p src tests/corpus tests/out tests/CORPUS "$work/grepshim" +printf '// TODO kept\n' > src/lib.rs +printf 'XXX corpus\n' > tests/corpus/c.txt +printf 'XXX upper corpus\n' > tests/CORPUS/c.txt +printf 'TODO\000out binary\n' > tests/out/o.pdf +real_grep=$(command -v grep) +rm -f "$work/grep.log" +printf '#!/bin/sh\nfor a in "$@"; do\n case "$a" in\n --recursive|--dereference-recursive) echo "recursive: $a" ;;\n --*) ;;\n -*[rR]*) echo "recursive: $a" ;;\n esac >> "%s/grep.log"\n [ -f "$a" ] && echo "path: $a" >> "%s/grep.log"\ndone\nexec "%s" "$@"\n' \ + "$work" "$work" "$real_grep" > "$work/grepshim/grep" +chmod +x "$work/grepshim/grep" +out=$(PATH="$work/grepshim:$PATH" sh scripts/audit-status.sh 2>/dev/null) +grep -qx "path: src/lib.rs" "$work/grep.log"; expect "markers: grep stand-in was used" 0 $? +grep -Eiq '^recursive: |tests/(corpus|out)' "$work/grep.log" +expect "markers: no recursive grep and no corpus or output file given to grep" 1 $? +# A repository with no marker says so. +new_repo +mkdir -p src; printf 'fn main() {}\n' > src/main.rs +out=$(sh scripts/audit-status.sh 2>/dev/null) +[ "$(report_section "Markers in code" "$out")" = none ]; expect "markers: none said" 0 $? + echo "scripts tests: $passed passed, $failed failed" [ "$failed" -eq 0 ]