diff --git a/.claude/agents/coherence-auditor.md b/.claude/agents/coherence-auditor.md index 998ca49..411702d 100644 --- a/.claude/agents/coherence-auditor.md +++ b/.claude/agents/coherence-auditor.md @@ -1,50 +1,76 @@ --- name: coherence-auditor -description: Periodic coherence audit on a different model (Fable), every 5 commits and whenever unfinished work is suspected. Checks that requirements, roadmap, docs, code, tests and the GitHub state agree, to catch drift, hallucinated facts and interrupted or abandoned work. Read-only: returns a report to be saved in docs/audits/. +description: Periodic coherence audit on a different model (Fable), of equal or higher capability than the author's, every 5 commits and whenever unfinished work is suspected. Checks that requirements, roadmap, docs, code, tests and the GitHub state agree, to catch drift, hallucinated facts and interrupted or abandoned work. Read-only: returns a report to be saved in docs/audits/. model: fable tools: Read, Grep, Glob, Bash --- -You audit the coherence of SignSpector, a Rust command-line tool (see `CLAUDE.md`). The code -and docs were written by another model across many sessions. Your job is to find where they -have drifted apart or where something was asserted that is not true. You start with no -context on purpose: believe only what you can verify in files or command output. +You audit the coherence of SignSpector, a Rust command-line tool (see `CLAUDE.md`). Another +model wrote the code and docs across many sessions. Your job is to find where they have drifted +apart, or where something was asserted that is not true. You start with no context on purpose: +believe only what you can verify in files or command output. Read first: `CLAUDE.md`, `docs/design.md`, `docs/roadmap.md`, the latest report in `docs/audits/` (if any) and `git log` since that report. -## Checks - -1. **Unfinished work.** Run `sh scripts/audit-status.sh`. Report uncommitted changes, stashes, - unpushed commits, unmerged or stale branches, open and draft pull requests (with their - age), red or missing CI runs, `TODO`/`FIXME`/`todo!`/`unimplemented!`/`#[ignore]`. For each - draft or open PR: what it was for, what is missing, whether it is still relevant. -2. **Leftovers.** Run `sh scripts/cleanup.sh --plan` (lists only; without `--plan` the script removes) and report what it lists. Also look for - tracked files that belong to the work rather than the product: PR texts, notes, review or - audit drafts outside `docs/audits/`, scratch files, generated output. Say which should be - removed (locally, by the developer; nothing is ever deleted on GitHub). -3. **Requirements <-> tests <-> code.** For every requirement or roadmap step marked done: - tests exist, are not ignored, actually check the requirement, and pass. For every module - and public function: which requirement it serves. Code or options with no requirement are - scope drift; requirements claimed done with no code are false claims. -4. **Hallucination check.** Every concrete reference in docs, comments, commit messages and - agent prompts must exist: files, functions, types, modules, command-line options, crate - names and versions (in `Cargo.toml`/`Cargo.lock`), scripts, hook behaviour, standards - and laws cited. Verify each one; list those that do not exist or say something different. -5. **Docs agree with each other.** `CLAUDE.md`, `design.md`, `roadmap.md`, the agent prompts, - hooks and scripts must not contradict each other (numbering of requirements, rules, - commands, paths). Note anything outdated. -6. **Project rules.** Safety rules (R28–R34), accessibility (R35–R39), uninstall (R40–R43), - language rules (English in the repository, translated user interface), public-repository - rules (`sh scripts/check-public.sh --range tip HEAD`). -7. **Health.** `cargo fmt --check`, `cargo clippy --all-targets -- -D warnings`, - `cargo nextest run`, `cargo test --doc`, `cargo deny check`; report the actual results. - -Prepend `/opt/homebrew/opt/rustup/bin:/opt/homebrew/bin` to PATH if `cargo` is missing. -Throw-away probes only in `/tmp` or the scratchpad; never modify the repository; never read +## What do you check? + +1. Unfinished work. Run `sh scripts/audit-status.sh`. Report: + - uncommitted changes, stashes and unpushed commits; + - unmerged or stale branches; + - open and draft pull requests, with their age; + - red or missing CI runs; + - `TODO`, `FIXME`, `todo!`, `unimplemented!` or `#[ignore]` markers. + + For each draft or open PR, say what it was for, what is missing and whether it is + still relevant. +2. Leftovers. Run `sh scripts/cleanup.sh --plan` and report what it lists (`--plan` only lists; + without it the script removes). Also look for tracked files that belong to the work rather + than the product: PR texts, notes, review or audit drafts outside `docs/audits/`, scratch + files, generated output. Say which should be removed: locally, by the developer. Nothing is + ever deleted on GitHub. +3. Requirements against tests against code. For every requirement or roadmap step marked done, + tests exist, are not ignored, actually check the requirement, and pass. For every module and + public function, name the requirement it serves. Code or options with no requirement are + scope drift. Requirements claimed done with no code are false claims. +4. Every concrete reference exists. Docs, comments, commit messages and agent prompts name + files, functions, types, modules, command-line options, crate names and versions (in + `Cargo.toml` and `Cargo.lock`), scripts, hook behaviour, standards and laws. Verify each one. + List those that do not exist or say something different. +5. The docs agree with each other. `CLAUDE.md`, `docs/design.md`, `docs/roadmap.md`, the agent + prompts, the hooks and the scripts must not contradict each other: numbering of requirements, + rules, commands, paths. Note anything outdated. Report texts that break `docs/writing.md`, + with `file:line`. +6. The project rules hold: + - safety rules: R28–R34, and the dialog helpers in R38; + - accessibility: R35–R39; + - uninstall: R40–R43; + - language rules: English in the repository, a translated user interface; + - public-repository rules: `sh scripts/check-public.sh --range tip HEAD`. + + Read the pull request comments with + `GH_PROMPT_DISABLED=1 gh pr view --comments .. Verdict: COHERENT | DRIFT FOUND ## Health ``` -Every finding must carry its evidence: `file:line`, or the command and its output. A finding +Every finding carries its evidence: `file:line`, or the command and its output. A finding without evidence is not reported. Classify each as `false claim`, `drift`, `contradiction`, -`unfinished`, `rule broken` or `minor`, and say what should change (code, test or doc) without -deciding requirements: when docs and code disagree on what the tool should do, say so and -leave the choice to the user. The report is public: no personal data, no local paths with -user names. +`unfinished`, `rule broken` or `minor`. Say what should change: code, test or doc. Do not decide +requirements. When docs and code disagree on what the tool should do, say so and leave the +choice to the user. The report is public: no personal data, no local paths with user names. diff --git a/.claude/agents/fable-reviewer.md b/.claude/agents/fable-reviewer.md index 4a1862f..36d417c 100644 --- a/.claude/agents/fable-reviewer.md +++ b/.claude/agents/fable-reviewer.md @@ -1,73 +1,129 @@ --- name: fable-reviewer -description: Independent reviewer on a different model (Fable). Use after each TDD cycle (red -> green -> refactor) and before every commit, 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 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. model: fable tools: Read, Grep, Glob, Bash --- -You are the independent reviewer of SignSpector, a Rust command-line tool that finds signed and -time-stamped files (.p7m, .p7s, .tsd, .m7m) under a folder, verifies signatures and time stamps -against the European trusted lists (the countries of the certifiers found), writes an HTML report and, on request, extracts the signed -documents. The code was written by a different model; your value is an opinion that is not -anchored on its reasoning. Do not trust comments, commit messages or the brief you were given: -check the code and the tests yourself. +You are the independent reviewer of SignSpector. SignSpector is a Rust command-line tool. It +finds signed and time-stamped files (.p7m, .p7s, .tsd, .m7m) under a folder and verifies +signatures and time stamps against the European trusted lists (the countries of the certifiers +found). It writes an HTML report and, on request, extracts the signed documents. + +A different model wrote the code. Your value is an opinion that is not anchored on its +reasoning. Do not trust comments, commit messages or the brief you were given: check the code +and the tests yourself. Read first: `CLAUDE.md` and `docs/design.md` (requirements and safety rules). -## What to check - -1. **Tests first, and meaningful.** For each requirement touched by the change, is there a test - that would fail if the requirement were broken? Flag tautological tests, tests that only - repeat the implementation, missing edge cases (empty input, truncated or malformed BER, - huge lengths, wrong case, non-UTF-8 paths, Windows paths) and missing negative cases - (tampered content, wrong signature, expired or untrusted certificate). -2. **Correctness.** Logic errors, off-by-one, integer overflow on lengths read from input, - wrong cryptographic checks (digest compared to the wrong bytes, signed attributes not - re-encoded as SET, signature algorithm not matched to the key, time checked against the wrong - reference), anything that could report a forged or invalid file as valid. -3. **Safety rules.** Originals are never written, moved or renamed; nothing is written except - the report without `extract` and its typed confirmation; existing files are never - overwritten; no panic on malformed input (no `unwrap`/`expect`/indexing on untrusted data - outside tests); no PowerShell; no OpenSSL or C dependencies. Confirmation and write safety - (R28–R34 in `docs/design.md`) is a fixed point of every review: look for any path that - processes without the first confirmation, writes without a `ConfirmedPlan`, opens a file for - writing without `create_new`, can resolve outside the selected folder, treats a non-terminal - input as a yes, confirms anything from a script (only `check` on an ordinary folder, `check - --plan`, `extract --plan` on an ordinary folder, and the `--plan` lists of `undo`, the menus - and `uninstall` run there), 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 once), or produces a file name that is invalid on another OS - (Windows reserved names and characters, trailing dot/space, NFC/NFD or case collisions, - over-long names). -4. **Language**: code, comments, docs and developer messages in English. User-facing texts of - the tool go through the translation layer (R27 in `docs/design.md`), never hard-coded, and - every new text has its Italian translation. -5. **Accessibility and uninstall** (R35–R43): no information by colour or symbols alone, - `NO_COLOR`/`--plain` honoured, no prompt time limits, semantic and keyboard-operable HTML - with sufficient contrast; anything installed is recorded for `uninstall`, which removes - only what SignSpector installed and never user data. -6. **Public repository**: nothing that could carry personal or sensitive data (see the - "Public repository" section of `CLAUDE.md`); run `sh scripts/check-public.sh --staged` - when changes are staged. - -## Proof of TDD - -The PR description must quote the red run (the failing tests before the change) and the green -one. Missing proof is a finding. For code that protects (scripts under `scripts/`, safety -code), break each rule on a copy (outside the repository) and check that a test fails; report -every rule whose breakage no test notices. - -## How to work - -- Run: `cargo nextest run`, `cargo clippy --all-targets -- -D warnings`, `cargo fmt --check`. +## What do you review? + +The uncommitted changes in the working tree, before they are committed: + +- `git status --short --untracked-files=all` lists every changed and new file, also inside new + folders; +- `git diff HEAD` shows the changes to tracked files; +- you read every new file in full, except real documents: + - files under `tests/fixtures/` are synthetic: read them, and check that every identity in + them is obviously fake; + - never read anything under `tests/corpus/`; + - never read a signed document, or a document extracted from one, anywhere else: report it + unread, as a finding. + +After CHANGES NEEDED, the author fixes the findings and a new reviewer reviews the fixed changes. +A commit follows only an APPROVED verdict (`CLAUDE.md`). + +The brief holds: + +- the scope and where the requirements are; +- the planned commit message; +- the red and green runs, when no PR exists yet; +- any owner's decision the changes apply, quoted. + +## What do you check? + +1. Tests come first and mean something. For each requirement touched by the change, is there a + test that would fail if the requirement were broken? Flag tautological tests and tests that + only repeat the implementation. Flag missing edge cases: empty input, truncated or malformed + BER, huge lengths, wrong case, non-UTF-8 paths, Windows paths. Flag missing negative cases: + tampered content, wrong signature, expired or untrusted certificate. +2. The code is correct. Look for logic errors, off-by-one, and integer overflow on lengths read + from input. Look for wrong cryptographic checks: + - a digest compared to the wrong bytes; + - signed attributes not re-encoded as SET; + - a signature algorithm not matched to the key; + - time checked against the wrong reference. + + Flag anything that could report a forged or invalid file as valid. +3. The safety rules hold. + - Originals are never written, moved or renamed. + - `check` writes no document, only the report (HTML and JSON) and the tool's cache (R16). + Documents need an extraction confirmed by the typed number (`extract`, or the interactive + end of run, R20, R29). + - Existing files are never overwritten, not even a report. + - Malformed input never panics: no `unwrap`, `expect` or indexing on untrusted data outside + tests. + - No PowerShell; no OpenSSL or C dependencies. + - Confirmation and write safety (R28–R34 and the dialog helper rules of R38 in + `docs/design.md`) is a fixed point of every review. Look for any path that: + - processes without the first confirmation; + - writes a document without a `ConfirmedPlan`; + - breaks any part of R31: + - a file opened without `create_new`; + - a file replaced in place; + - a file replaced other than a cache file or the manifest; + - a symbolic link followed; + - a non-regular file replaced; + - 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); + - 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 + once); + - produces a file name that is invalid on another OS: Windows reserved names and + characters, trailing dot or space, NFC/NFD or case collisions, over-long names. + - The step writes the R34 tests for the commands and modules it introduces, as soon as they + can be tested. +4. The language rules hold. Code, comments, docs and developer messages are in English. + User-facing texts of the tool go through the translation layer (R27 in `docs/design.md`), + never hard-coded, and every new text has its Italian translation. Every changed text (docs, + comments, PR text, prompts, tool strings) follows `docs/writing.md`: report the patterns it + lists, with `file:line`. Check the planned commit message from the brief too, including every + claim it makes about the changes; a missing message is a finding. +5. Accessibility and uninstall hold (R35–R43). No information by colour or symbols alone. + `NO_COLOR` and `--plain` are honoured. Prompts have no time limit. The HTML is semantic, + keyboard operable and has sufficient contrast. Anything installed is recorded for + `uninstall`, which removes only what SignSpector installed and never user data. +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 `. + +## How is TDD proved? + +The PR description quotes the red run (the failing tests before the change) and the green one. +Missing proof is a finding. When no PR exists yet, look for the red and green runs in the brief. +If the brief does not hold them, report them missing. For code that protects (scripts under +`scripts/`, safety code), break each rule on a copy outside the repository and check that a test +fails. Report every rule whose breakage no test notices. + +## How do you work? + +- Run `cargo nextest run`, `cargo clippy --all-targets -- -D warnings` and `cargo fmt --check`. Report the actual results. -- If useful, write throw-away probes (extra tests, sample inputs) only under the scratchpad or - `/tmp`, never in the repository. You must not modify any file in the repository. +- Write throw-away probes (extra tests, sample inputs) only under the scratchpad or `/tmp`, + never in the repository. You must not modify any file in the repository. - Never read or copy anything from `tests/corpus/` (real documents with personal data). -## Report +## What does the report look like? -Start with one line: `VERDICT: APPROVED` or `VERDICT: CHANGES NEEDED`. -Then the findings, most severe first, each with `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`. 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. diff --git a/.githooks/pre-commit b/.githooks/pre-commit index b3504ae..f4b24a2 100755 --- a/.githooks/pre-commit +++ b/.githooks/pre-commit @@ -7,7 +7,7 @@ set -e # The repository is public: no personal data, keys or unexpected files (allowlist + content scan). sh "$(git rev-parse --show-toplevel)/scripts/check-public.sh" --staged -# Coherence audit every 5 commits (CLAUDE.md, "Coherence audits and unfinished work"). +# Coherence audit every 5 commits (CLAUDE.md, "How do we keep long work from drifting?"). sh "$(git rev-parse --show-toplevel)/scripts/audit-status.sh" --gate-commit # Changes to the rules themselves: run their tests. diff --git a/CLAUDE.md b/CLAUDE.md index 5307953..b865051 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -1,172 +1,237 @@ # SignSpector -Finds signed and time-stamped files (`.p7m`, `.p7s`, `.tsd`, `.m7m`) under a folder, verifies -signatures and time stamps (European trusted lists) and writes an HTML report; on request it extracts -the signed documents beside the originals. Runs on Windows, macOS and Linux. +SignSpector finds signed and time-stamped files (`.p7m`, `.p7s`, `.tsd`, `.m7m`) under a folder. +It verifies signatures and time stamps against the European trusted lists and writes an HTML +report. On request it extracts the signed documents beside the originals. It runs on Windows, +macOS and Linux. -A new project in Rust. It takes the idea of an earlier Windows-only tool by the same author -(`p7m-extract`, in C#, kept outside this repository in `../SignSpector-legacy/`), but it is -**not a port**: requirements and design are in `docs/design.md`, the order of work in -`docs/roadmap.md`; read both first. Look at the old code only when the user asks to. +It is a new project in Rust. It takes the idea of an earlier Windows-only tool by the same +author (`p7m-extract`, in C#, kept outside this repository in `../SignSpector-legacy/`), but it +is not a port. Requirements and design are in `docs/design.md`, the order of work in +`docs/roadmap.md`: read both first. Look at the old code only when the user asks to. After cloning, enable the hooks once: `git config core.hooksPath .githooks`. -## Way of working: TDD, for all code +## How do we write code? -TDD applies to **everything that has logic**: Rust, shell scripts, git hooks, the CI workflow. -No exception for "infrastructure". +Test first, always. TDD applies to everything that has logic: Rust, shell scripts, git hooks, +the CI workflow. There is no exception for "infrastructure". -1. **Red**: write the test for one small behaviour first; run it and see it fail for the right +1. Red: write the test for one small behaviour first. Run it and see it fail for the right reason. For the CI workflow the red is a failing run on GitHub. -2. **Green**: the smallest code that makes it pass. -3. **Refactor** with all tests green; `cargo clippy --all-targets -- -D warnings` and - `cargo fmt` clean. -4. **Proof**: every PR description quotes the red output (the failing test run) and the green - one. 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 nobody's test notices gets a - test. -5. **Independent review**: a **newly started** `fable-reviewer` agent (different model) for - every review, briefed only with the scope and where the requirements are: never resumed, - never given my conclusions or earlier findings. Fix its findings or explain to the user why - not. -6. Commit only when the user asks. Hooks (`.githooks/`): pre-commit runs the public-repository - check, the audit cadence gate, the script tests when scripts or hooks change, fmt, clippy - and tests; commit-msg scans the message; pre-push scans every commit not yet on the remote it pushes - to (other remotes never hide commits). Script and hook tests: `scripts/test-scripts.sh`, - `scripts/test-cleanup.sh`, `scripts/test-hooks.sh`. +2. Green: write the smallest code that makes it pass. +3. Refactor with all tests green; `cargo clippy --all-targets -- -D warnings` and `cargo fmt` + clean. +4. Proof: every PR description quotes the red output (the failing test run) and the green one. + 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). +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: + - the scope and where the requirements are; + - the planned commit message, which the reviewer checks as a claim, not a fact; + - the red and green runs, when no PR exists yet; + - any owner's decision the changes apply, quoted. + + 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. + - 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: + - fixed and reviewed; + - written into the roadmap step that will fix it; + - declared wrong by the owner, with the reason in a PR comment. + - 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. + + 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 + the commit that holds the approved changes. The approval then leaves a trace an audit can + check; the PR description alone is not enough. The comment is a summary written for the + public, with repository-relative paths, never the pasted report (reports carry local paths). + `check-public.sh` does not scan PR comments: save the comment to a file and run + `sh scripts/check-public.sh --message ` before posting. +6. Commit only when the user asks, and only when the checks of step 5 are complete. The hooks + (`.githooks/`) do this: + - pre-commit runs the public-repository check, the audit cadence gate, the script tests when + scripts or hooks change, fmt, clippy and tests; + - commit-msg scans the message; + - pre-push scans every commit not yet on the remote it pushes to (other remotes never hide + commits). + + Script and hook tests: `scripts/test-scripts.sh`, `scripts/test-cleanup.sh`, + `scripts/test-hooks.sh`. Logic lives in the library (`src/lib.rs` and modules); `src/main.rs` is only the command line. -Unit tests sit beside the code (`#[cfg(test)]`); end-to-end tests of the executable go in +Unit tests sit beside the code (`#[cfg(test)]`). End-to-end tests of the executable go in `tests/*.rs` (`assert_cmd`). Tools: `bacon` (tests on every save), `cargo nextest run`, `cargo llvm-cov nextest` (coverage), `cargo deny check` (licences, advisories, no OpenSSL). -## Coherence audits and unfinished work - -Long work across sessions drifts: docs claim things the code does not do, references to -functions or options that never existed, work left half-done. Rules against it: - -- **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. -- **Branches and PRs** (after the first push): one branch per roadmap step - (`step/1.1-portable-names`), pushed early as a **draft PR**; marked ready only when CI is - green and `fable-reviewer` approved; merged into `main` **locally by fast-forward** - (`git switch main && git merge --ff-only step/x && git push`): the same commits CI checked, - linear history, pre-push hook run. The GitHub merge button is not used (it rewrites commits). **One step 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: coherence audit** by the `coherence-auditor` agent (Fable, fresh context, - read-only): requirements vs tests vs code, every concrete reference checked for existence, - docs agreeing with each other, unfinished work, project rules, health. Its report is saved as +## How do we keep long work from drifting? + +With the six rules below. Long work across sessions drifts: docs claim things the code does not +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. +- 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. +- 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, + the docs against each other, unfinished work, project rules and health. Its report is saved as `docs/audits/NNNN-YYYY-MM-DD.md` and committed alone (`audit: NNNN`). The hooks enforce the cadence: pre-commit refuses a 6th commit without an audit, pre-push refuses to push past it. - The gate is a reminder, not a proof: any added report satisfies it; the review of the report - is what counts. -- **Findings are verified before acting**: the auditor can be wrong too. Each finding carries - evidence (`file:line` or command output); check it, then fix it in a normal TDD cycle. When a - doc and the code disagree on *what the tool should do*, ask the user which one is right; - never silently align the doc to the code or the code to the doc. -- **After every audit, remove leftovers**: `sh scripts/cleanup.sh` removes the local ones, - without asking, and says what it removed (`.DS_Store`, `*.orig`, `*.rej` anywhere outside - ignored folders, also inside untracked ones; local branches already merged into main); - `--plan` only lists them. The removing form is run by the main session 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; ignored folders are never touched, and `tests/corpus/`, `tests/out/`, `target/` - are protected even if `.gitignore` lacks them. Deletion happens **only - locally, from the development environment, never on GitHub**: merged remote branches stay - there as history; stale or draft PRs found on GitHub are reported to the user. Untracked - files that are not recognisable junk are listed for the user, never deleted silently. -- Also run an audit, outside the cadence, after an interrupted session, a long pause, or when - something "remembered" cannot be found in the files. - -## Public repository: no sensitive data, ever - -`github.com/bertalan/SignSpector` is **public**: everything committed is published and stays -in the history even if deleted later. Before every commit and push: - -- Never commit: real signed documents or anything extracted from them, names, codici fiscali, - email addresses, phone numbers, company or office names, local paths that reveal a user name - (write `~` or `%USERPROFILE%` instead), hostnames, IPs, credentials, tokens, private keys - (also test keys: fixtures generate them at test time), logs or reports produced on real files. -- Commit messages, issues and PR texts follow the same rules (they are public too). + The gate is a reminder, not a proof: any added report satisfies it. Checking the report's + findings is what counts. +- Findings are verified before acting, because the auditor can be wrong too. Each finding + carries evidence (`file:line` or command output). Check it, then fix it in a normal TDD cycle. + When a doc and the code disagree on what the tool should do, ask the user which one is right. + Never silently align the doc to the code or the code to the doc. +- After every audit, remove leftovers. `sh scripts/cleanup.sh` removes the local ones without + asking and says what it removed: `.DS_Store`, `*.orig`, `*.rej` anywhere outside ignored + folders (also inside untracked ones), and local branches already merged into main. `--plan` + 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. + - 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 + remote branches stay there as history. Stale or draft PRs found on GitHub are reported to + the user. + - Untracked files that are not recognisable junk are listed for the user, never deleted + silently. +- Also run an audit outside the cadence: after an interrupted session, after a long pause, or + when something "remembered" cannot be found in the files. + +## What may never reach the public repository? + +Anything that could carry personal or sensitive data. `github.com/bertalan/SignSpector` is +public: everything committed is published, and it stays in the history even if deleted later. +Before every commit and push: + +- Never commit real signed documents or anything extracted from them. Never commit names, codici + fiscali, email addresses, phone numbers, company or office names, hostnames, IPs, credentials, + tokens or private keys (also test keys: fixtures generate them at test time). Never commit + local paths that reveal a user name (write `~` or `%USERPROFILE%` instead), nor logs or + reports produced on real files. +- Commit messages, issues and PR texts follow the same rules: they are public too. - Fixtures are synthetic only, with obviously fake identities (`Mario Rossi Test`, `example.com`, invalid codici fiscali). -- `scripts/check-public.sh` enforces part of it: an allowlist of paths (a new kind of file - needs a deliberate change there; no PR texts, notes or key files) plus a content scan of - files, file names, commit messages and identities, run by the pre-commit, commit-msg and - pre-push hooks. Never bypass them with `--no-verify`; a false positive is fixed by changing - the script, reviewed like code. It does **not** detect names of people, phone numbers, host - names or IPs: those need review. -- **GitHub settings** (set 2026-11-22, changed only with the user's explicit authorisation): - `main` protected (the four CI jobs green on an up-to-date commit, also for admins; linear - history; no force-push, no deletion; no PR required, merges are local fast-forwards); merge - commits and squash disabled; no automatic branch deletion; **only collaborators may open - PRs, issues and comments** (interaction limit, 6 months at most: the session report warns 30 - days before it expires); fork PR workflows always need approval; only GitHub-owned actions - plus `Swatinem/rust-cache`, `taiki-e/install-action`, `EmbarkStudios/cargo-deny-action`, - pinned by SHA; wiki and projects off; vulnerability alerts on, no Dependabot PRs; secret - scanning with push protection on. The GitGuardian app installed on the owner's account adds - its own secret check to every PR (not a required check). -- **Accepted exception**: the repository's first commit (`cd3620d`, "Initial commit", made on - the GitHub website) has the owner's personal address as author. The owner accepted it - (2026-11-22); history is not rewritten. Every later commit uses the GitHub no-reply address. -- **The hooks are the barrier, CI is only an alarm**: when CI runs, the push is already public. - A pull request also runs its own version of the workflow, so changes to `.github/`, - `scripts/` and `.githooks/` get a careful review. +- `scripts/check-public.sh` enforces part of it. It has an allowlist of paths: a new kind of + file needs a deliberate change there, and PR texts, notes and key files are not allowed. It + also scans the content of files, file names, commit messages and identities. The pre-commit, + commit-msg and pre-push hooks run it. Never bypass them with `--no-verify`. A false positive + is fixed by changing the script, reviewed like code. The script does not detect names of + people, phone numbers, host names or IPs: those need review. +- GitHub settings were set on 2026-11-22. They change only with the user's explicit + authorisation. + - `main` is protected: the four CI jobs green on an up-to-date commit, also for admins; linear + history; no force-push, no deletion. No PR is required: merges are local fast-forwards. + - Merge commits and squash are disabled. There is no automatic branch deletion. + - Only collaborators may open PRs, issues and comments. This interaction limit lasts 6 months + at most; the session report warns 30 days before it expires. + - Fork PR workflows always need approval. + - Only GitHub-owned actions plus `Swatinem/rust-cache`, `taiki-e/install-action` and + `EmbarkStudios/cargo-deny-action` are allowed, pinned by SHA. + - Wiki and projects are off. Vulnerability alerts are on, with no Dependabot PRs. Secret + scanning with push protection is on. + - The GitGuardian app installed on the owner's account adds its own secret check to every PR. + It is not a required check. +- Accepted exception: the repository's first commit (`cd3620d`, "Initial commit", made on the + GitHub website) has the owner's personal address as author. The owner accepted it on + 2026-11-22; history is not rewritten. Every later commit uses the GitHub no-reply address. +- The hooks are the barrier; CI is only an alarm. When CI runs, the push is already public. A + pull request also runs its own version of the workflow, so changes to `.github/`, `scripts/` + and `.githooks/` get a careful review. - Before the first push of a session, review the exact file list (`git show --stat`) with the user. Pushing is always the user's decision. -## Conventions - -- **Language.** Everything in the repository is in English: code, comments, file headers, - docs, commit messages, script and hook messages, agent prompts and reports. Italian is used - only when talking to the user (the developer) in the conversation. -- **The tool's own interface is translated** (console messages, `--help`, HTML report, user - guide): it speaks the operating system's language, or the one chosen by the user - (`--lang`, see R27 in `docs/design.md`). Source strings are English; every user-facing text - goes through the translation layer, never hard-coded, and each new text gets its Italian - translation in the same change. -- `check` writes nothing but the report. **There is no `--apply`, `--yes` or `--expect`.** - Every command that changes files or the system shows the exact plan first. The number is - typed only for files found in a folder (risky folder, R28; documents to write, R29); `undo`, - menus and `uninstall` ask a yes/no question, default No, answers in words (R19, R35). From - the context menu the same confirmations come in a native dialog, focus on Cancel; from a script - they refuse (R30); `--plan` shows the plan and stops. These rules are for the tool; the - developer script `scripts/cleanup.sh` is the one exception (it removes only junk and merged - branches, without asking, see above). Never ask the developer to type numbers in chat: the - typed count is a rule of the tool, not of the conversation. -- Originals are only read, never modified, moved or renamed; existing files are never - overwritten ("x.pdf" exists with other content -> "x (1).pdf"). -- **Never process right after a person chooses a folder**: first count and ask for - confirmation (R28; from a script an ordinary folder is analysed without a question, a risky - one is refused); writing needs a second confirmation on the full write plan, with the number typed - (R29); no implicit yes, ever (R30: terminal, dialog from the context menu, refusal in - scripts). Writing only through a `ConfirmedPlan`, files created with `create_new`, never - outside the chosen folder (R31). File names valid on - Windows, macOS and Linux at once (R32). Any change here needs the tests of R34. -- **Accessibility is a requirement, not a polish step** (EN 301 549; WCAG 2.2 AA for the - report; R35–R39). Never convey information by colour or symbols alone; honour `NO_COLOR`, - `--no-color`, `--plain`; no spinners or rapid line rewriting; no time limits on prompts; - linear console text, no box drawing; the HTML report is semantic, keyboard operable, - contrast-checked, works without JavaScript. Every user-facing change keeps its tests green. -- **Uninstall is part of every install feature** (R40–R43): anything that adds something to - the system records it in the manifest and is removed by `signspector uninstall`, which - removes only what we installed and never user data. -- Malformed input never panics: it becomes an error for that file. No `unwrap`/`expect`/indexing - on untrusted data outside tests (enforced by clippy lints in `Cargo.toml`). -- No PowerShell in anything the tool runs on Windows: company PCs force Constrained Language Mode. -- Pure Rust dependencies (no OpenSSL, checked by `cargo deny`): one self-contained executable +## Which rules hold everywhere? + +These rules hold in every change. They cover texts and language, confirmation and writing +files, accessibility, uninstall, malformed input, PowerShell and dependencies. + +- Every text follows `docs/writing.md`: docs, comments, commit messages, PR texts, agent + prompts, the tool's strings. Texts answer the reader's questions, answer first, in short + sentences, with code and commands verbatim. +- Everything in the repository is in English: code, comments, file headers, docs, commit + messages, script and hook messages, agent prompts and reports. Italian is used only when + talking to the user (the developer) in the conversation. +- The tool's own interface is translated: console messages, `--help`, the HTML report, the user + guide. It speaks the operating system's language, or the one chosen by the user (`--lang`, R27 + in `docs/design.md`). Source strings are English. Every user-facing text goes through the + translation layer, never hard-coded, and each new text gets its Italian translation in the + same change. +- `check` writes no document: only the report (HTML and JSON) and the tool's cache of trusted + lists and CRLs (R16). Documents come only from an extraction confirmed through R29: `extract`, + or the interactive end of a `check` run (R20). There is no `--apply`, `--yes` or `--expect`. +- Every command that changes files or the system shows the exact plan first. The one exception + is `check` in an ordinary run from a script, which writes its report and the cache without a + question (R16, R30). +- The number is typed only for files found in a folder: files to process in a risky run (R28), + documents to write (R29). `undo`, menus and `uninstall` ask a yes/no question, default No, + with answers in words (R30, R35). From the context menu the same confirmations come in a + native dialog, focus on Cancel. From a script they refuse (R30). `--plan` shows the plan and + stops. +- The confirmation rules are for the tool. The developer script `scripts/cleanup.sh` is the one + exception: it removes only junk and merged branches, without asking (see above). Never ask the + developer to type numbers in chat: the typed count is a rule of the tool, not of the + conversation. +- Originals are only read, never modified, moved or renamed. Existing files are never + overwritten: if "x.pdf" exists with other content, the new file is "x (1).pdf". +- Never process right after a person chooses a folder. First count and ask for confirmation + (R28). From a script an ordinary run is analysed without a question, and a risky one is + refused. Writing needs a second confirmation on the full write plan, with the number typed + (R29). There is no implicit yes, ever (R30: terminal, dialog from the context menu, refusal in + scripts). +- How every file is written, and the only files ever replaced, is R31 in `docs/design.md`: read + it before touching any write path. File names are valid on Windows, macOS and Linux at once + (R32). Any change to counting, confirmation, write paths or file names, or to anything else + R34 covers, needs the tests R34 lists. +- Accessibility is a requirement, not a polish step (EN 301 549; WCAG 2.2 AA for the report; + R35–R39). Never convey information by colour or symbols alone. Honour `NO_COLOR`, `--no-color` + and `--plain`. No spinners or rapid line rewriting, no time limits on prompts. Console text is + linear, with no box drawing. The HTML report is semantic, keyboard operable and + contrast-checked, and works without JavaScript. Every user-facing change keeps its tests + green. +- Uninstall is part of every install feature (R40–R43). Anything that adds something to the + system records it in the manifest and is removed by `signspector uninstall`. That command + removes only what we installed, never user data. +- Malformed input never panics: it becomes an error for that file. No `unwrap`, `expect` or + indexing on untrusted data outside tests (enforced by clippy lints in `Cargo.toml`). +- No PowerShell in anything the tool runs on Windows: company PCs force Constrained Language + Mode. +- Pure Rust dependencies, no OpenSSL (checked by `cargo deny`): one self-contained executable per platform. -## Building +## How do we build it? -Toolchain: rustup (pinned in `rust-toolchain.toml`) with targets for macOS arm64/x86_64, -Windows (mingw-w64, linker in `.cargo/config.toml`) and Linux musl (`cargo zigbuild`). -Commands in `docs/design.md`. Development happens on the user's Mac; Windows tests on real +The toolchain is rustup, pinned in `rust-toolchain.toml`. Targets: macOS arm64 and x86_64, +Windows (mingw-w64, linker in `.cargo/config.toml`) and Linux musl (`cargo zigbuild`). The +commands are in `docs/design.md`. Development happens on the user's Mac. Windows tests on real files happen on the Windows PC, where `tests/corpus/` lives. -## Test data +## Which test data may we use? -Real signed documents contain personal data: never commit them, never copy them to the Mac. -They stay on the Windows PC in `tests/corpus/` (git-ignored). Unit tests use synthetic -fixtures only (`tests/fixtures/`). +Real signed documents contain personal data. Never commit them, never copy them to the Mac. They +stay on the Windows PC in `tests/corpus/` (git-ignored). Unit tests use synthetic fixtures only +(`tests/fixtures/`). diff --git a/README.md b/README.md index ce62863..df1d17e 100644 --- a/README.md +++ b/README.md @@ -1,82 +1,107 @@ # SignSpector -**Cross-platform batch verifier for CAdES signatures and time stamps** (`.p7m`, `.p7s`, `.tsd`, -`.m7m`) against the European trusted lists (Italy, Romania, France and every other EU/EEA -country), with an accessible HTML report and safe extraction of the signed documents. - -> **Status: early development.** Nothing is usable yet: the project is being built step by -> step, test first. See the [roadmap](docs/roadmap.md) for what is done and what comes next. - -## What it does - -Offices receive and archive documents that are digitally signed (CAdES `.p7m`, detached -`.p7s`) and time-stamped (`.tsd`, `.m7m`), often nested several layers deep. Opening them one by -one is slow and tells little about the signatures. - -Point SignSpector at a folder and it will: - -- **find** every signed or time-stamped file in it and its subfolders; -- **open** every layer: BER/DER envelopes (including indefinite lengths), base64 envelopes, - nested signatures, RFC 5544 time-stamped data; -- **verify** each signature (RSA, RSA-PSS, ECDSA; SHA-1/2), the signer's certificate - (validity, key usage, qualified status), the chain up to a CA of the - national trusted list of the certifier's country, reached through the - [EU List of Trusted Lists](https://ec.europa.eu/tools/lotl/eu-lotl.xml) and chosen - automatically from the signatures found, whether the certificate was revoked (from data in the - signature or the CA's revocation list, not one query per signature), countersignatures - and RFC 3161 time stamps; -- **report** the results on the console and in a self-contained HTML report (and JSON for +SignSpector checks signed and time-stamped files (`.p7m`, `.p7s`, `.tsd`, `.m7m`) in bulk. It +verifies CAdES signatures and time stamps against the European trusted lists (Italy, Romania, +France and every other country on the EU List of Trusted Lists). It writes an accessible HTML +report and, on request, extracts the signed documents safely. It is built for Windows, macOS +and Linux. + +> Status: early development. Nothing is usable yet. We build the project step by step, test +> first. The [roadmap](docs/roadmap.md) shows what is done and what comes next. + +## What does it do? + +It checks every signed or time-stamped file in a folder and writes one report. Offices receive +and archive CAdES `.p7m`, detached `.p7s` and time-stamped `.tsd` and `.m7m` files, often +nested several layers deep. Opening them one by one is slow and tells little about the +signatures. + +For each folder, SignSpector: + +- finds every signed or time-stamped file in it and its subfolders (hidden folders and + symbolic links met inside are skipped and listed in the report); +- opens every layer: BER/DER encoding (including indefinite lengths), base64 encoding, nested + signatures, RFC 5544 time-stamped data; +- verifies each signature (RSA, RSA-PSS, ECDSA; SHA-1/2) and the signer's certificate + (validity, key usage, qualified status); +- follows the chain up to a CA of the national trusted list of the certifier's country. It + reaches that list through the + [EU List of Trusted Lists](https://ec.europa.eu/tools/lotl/eu-lotl.xml) and chooses it + automatically from the signatures found; +- checks whether the certificate was revoked, from data in the signature or the CA's + revocation list (CRL): not one query per signature; +- verifies countersignatures and RFC 3161 time stamps; +- reports the results on the console and in a self-contained HTML report (and JSON for scripts); -- **extract**, only on request, the signed documents beside the originals: - `Relazione.pdf.p7m` → `Relazione.pdf`. - -## Safety by design - -Signed documents are often the only official copy. SignSpector is built so that it cannot -damage them: - -- **Dry run by default.** Without an explicit `extract`, nothing is written except the report. -- **Confirmation before anything happens.** After a folder is chosen, the tool only counts the - files and asks before analysing. Writing needs a second confirmation on the complete write - plan, by typing the number of documents to write. Folders such as a drive root or the home - folder, or more than 10,000 files, get a stronger warning and the number of files must be - typed. From the context menu the same confirmations appear in a window. In scripts only the - analysis of an ordinary folder, its report and `--plan` (for `extract`, on an ordinary - folder) run: extracting, undoing and - uninstalling need a person to confirm. -- **Originals are read-only.** They are never modified, moved or renamed. -- **Nothing is ever overwritten.** Every file is created with an exclusive "create new" - operation, so the operating system itself refuses to overwrite. Name clashes become - `x (1).pdf`. -- **Nothing is written outside the chosen folder.** File names taken from envelopes are made - valid on Windows, macOS and Linux at once: no forbidden characters, no reserved names, no - clashes that differ only in letter case or Unicode form. -- **Undo.** Every written file is logged with its SHA-256. `signspector undo` removes only - files that are still identical to what SignSpector wrote. -- **Clean uninstall.** `signspector uninstall` removes only what SignSpector installed, and - never user data. - -## Accessibility - -Accessibility is a requirement, not an afterthought. The targets are **EN 301 549**, the -standard referenced by the Italian accessibility law (Legge 4/2004) and the AgID guidelines, -and **WCAG 2.2 level AA** for the HTML report: +- extracts the signed documents beside the originals, only on request: + `Relazione.pdf.p7m` -> `Relazione.pdf`. + +## Can it damage my documents? + +No. Signed documents are often the only official copy, so SignSpector is built so that it +cannot damage them: + +- `check` writes no document. It writes only the HTML report (in each folder, or at the + `--report` path you name), the JSON file of `--json`, and its own cache of trusted lists and + CRLs. Documents are written only by an extraction you ask for and confirm. +- After you choose a folder, it only counts: the signed or time-stamped files (the tool calls + them "files to process") and the files of any kind. Then it asks before analysing. +- Writing documents needs a second confirmation on the complete write plan: you type the + number of documents to write. +- A risky run gets a stronger warning that says why. You type the number of files to + process. A run is risky when a chosen folder is a sensitive folder: + - the root of a drive or volume; + - the home folder, Desktop or Documents; + - a system folder; + - a network share root. + + A run is also risky when the folders chosen hold more than 10,000 files of any kind in all, + subfolders included. A run that is not risky is an ordinary run. Files the analysis skips are + not counted (hidden folders, symbolic links inside the folders, unreadable folders), and a file + in overlapping folders counts once. +- From the context menu, the same confirmations appear in a window. +- In scripts, only these run: + - `check` in an ordinary run, and `check --plan`; + - `extract --plan` in an ordinary run; + - the `--plan` lists of `undo`, the menu commands and `uninstall`. + + Everything else stops and says that a person must confirm. +- Originals are read-only. They are never modified, moved or renamed. +- Nothing is ever overwritten, not even an earlier report. Every file is created with an + exclusive "create new" operation, so the operating system itself refuses to overwrite. A + document, report or JSON file whose name is taken gets the next free name, for example + `x (1).pdf`. A menu entry that is not SignSpector's is reported and left alone. The only files + ever replaced are the tool's own cache and its list of what it installed; the full rule is R31 + in [docs/design.md](docs/design.md). +- Extracted documents are never written outside the chosen folder. File names taken from the + signed files are made valid on Windows, macOS and Linux at once: no forbidden characters, no + reserved names, no clashes that differ only in letter case or Unicode form. +- Every extracted document is recorded in the report with its SHA-256. An extraction never + rewrites an earlier report: it writes a new one. `signspector undo` removes only the files + that are still identical to what SignSpector wrote. +- `signspector uninstall` removes only what SignSpector installed, and never user data. + +## Is it accessible? + +Yes, by requirement. The target is EN 301 549, the standard referenced by the Italian +accessibility law (Legge 4/2004) and the AgID guidelines. The HTML report also targets WCAG 2.2 +level AA: - no information conveyed by colour or symbols alone; - `NO_COLOR`, `--no-color` and a `--plain` mode for screen readers; - no time limits on prompts; - a semantic, keyboard-operable report that works without JavaScript. -## Languages +## Which languages does it speak? -The interface speaks the operating system's language, or the one chosen with `--lang`. The -report is written in the same language, or in another one with `--report-lang`. English and Italian come first; more languages can be -added without code changes. +The operating system's language, or the one chosen with `--lang`. The report uses the same +language, or another one chosen with `--report-lang`. English and Italian come first. More +languages can be added without code changes. -## Platforms +## Which platforms will it run on? -One self-contained executable per platform, written in pure Rust (no OpenSSL, no runtime to -install): +Windows, macOS and Linux, with one self-contained executable per platform. It is written in +pure Rust: no OpenSSL, no runtime to install. | Platform | Package | |---|---| @@ -84,10 +109,10 @@ install): | macOS (Apple Silicon and Intel) | universal binary | | Linux x86_64 | `.deb`, `.rpm`, static `.tar.gz` | -Context-menu integration is planned for Explorer, Finder (Quick Actions), Nautilus and Dolphin, -and needs no administrator rights. +We plan context-menu entries for Explorer, Finder (Quick Actions), Nautilus and Dolphin. They +need no administrator rights. -## Planned usage +## How will it be used? ```sh signspector check ... # analyse and write a report in each folder (default) @@ -98,40 +123,45 @@ signspector uninstall-menu # remove only the context-menu entries signspector uninstall # remove everything SignSpector installed ``` -Every command that changes something shows its plan first and acts only after you confirm: -`extract` asks you to type the number of documents it will write; `undo`, `install-menu`, -`uninstall-menu` and `uninstall` ask a yes/no question, with No as the default. In scripts they -refuse; `--plan` -shows the plan and stops. From the context menu the same confirmations appear in a window, with -the focus on Cancel. There is no `--apply`, `--yes` or `--expect`. +Every command that changes something shows its plan first and acts only after you confirm. +The one exception is `check` in an ordinary run from a script, which writes its report and +the cache without a question. -## Building from source +- `extract` asks you to type the number of documents it will write. +- `undo`, `install-menu`, `uninstall-menu` and `uninstall` ask a yes/no question. The default + is No. +- In scripts, these commands refuse. `--plan` shows the plan and stops. +- From the context menu, the same confirmations appear in a window, with the focus on Cancel. -Requires [rustup](https://rustup.rs). The toolchain version is pinned in `rust-toolchain.toml`. +There is no `--apply`, `--yes` or `--expect`. + +## How do I build it? + +Install [rustup](https://rustup.rs). The toolchain version is pinned in `rust-toolchain.toml`. ```sh cargo build --release cargo nextest run # tests (cargo install cargo-nextest) ``` -Cross builds for all targets from macOS (mingw-w64, zig, cargo-zigbuild) are described in -[docs/design.md](docs/design.md#building-on-the-mac). +[docs/design.md](docs/design.md#how-do-i-build-it-on-the-mac) describes the cross builds for all +targets from macOS (mingw-w64, zig, cargo-zigbuild). -## Development +## How is it developed? -- **Test-driven:** every behaviour starts as a failing test. -- **Independent review:** each step is reviewed by a second AI model, different from the one - that wrote the code, so that the review is not anchored on the author's reasoning. -- **Coherence audits** every five commits: requirements, tests, code and documentation are - checked against each other. Every reference is verified to exist, and unfinished work is - surfaced. -- **Privacy:** this repository is public, so test data is synthetic only. Real signed documents - contain personal data and never enter the repository; local git hooks (pre-commit, - commit-msg, pre-push) refuse it. After cloning: `git config core.hooksPath .githooks`. +- Test first: every behaviour starts as a failing test. +- A second AI model reviews every step. It is not the model that wrote the code, so its review + is not anchored on the author's reasoning. +- Every five commits, a coherence audit checks requirements, tests, code and documentation + against each other. It verifies that every reference exists, and it surfaces unfinished work. +- This repository is public, so test data is synthetic only. Real signed documents contain + personal data and never enter the repository: local git hooks (pre-commit, commit-msg, + pre-push) refuse it. After cloning, run `git config core.hooksPath .githooks`. Requirements and design are in [docs/design.md](docs/design.md), the order of work in -[docs/roadmap.md](docs/roadmap.md), contributor rules in [CLAUDE.md](CLAUDE.md). +[docs/roadmap.md](docs/roadmap.md), contributor rules in [CLAUDE.md](CLAUDE.md). Every text +follows the writing guide, [docs/writing.md](docs/writing.md). -## License +## Which licence applies? [MIT](LICENSE) diff --git a/docs/audits/0005-2026-11-23.md b/docs/audits/0005-2026-11-23.md new file mode 100644 index 0000000..014eb30 --- /dev/null +++ b/docs/audits/0005-2026-11-23.md @@ -0,0 +1,210 @@ +# Coherence audit 0005 (2026-11-23) +Range: 3268fde..df7ee92 (5d29d9d and 8561ec5, merged into `main` with PR #2; 0121327, 4ab527f and df7ee92 on `step/0.4-writing-guide`, PR #3, draft) plus the uncommitted working tree (`scripts/audit-status.sh`, `scripts/test-scripts.sh`, `rust-toolchain.toml`, `docs/design.md`) Verdict: COHERENT + +Auditor: `coherence-auditor` agent, fresh context, read-only, run because the cadence is due (5 commits since audit 0004). + +The committed range holds no false claim and no broken rule. Step 0.2.1 is now truly done: PR #2 was merged by fast-forward with all four jobs green and its verdicts posted. The findings are about the uncommitted "Rust" section of the session report (F1 to F3, worth fixing before it is committed) and small disagreements between the new writing guide and the other documents (F4 to F6). Step 0.4 is open and unfinished, as its PR says. + +## Unfinished work + +`sh scripts/audit-status.sh` (exit 0): + +``` +== Audit cadence +commits since last audit: 5 (audit every 5) +last audit: 3268fde 2026-11-22 audit: 0004 +AUDIT DUE + +== Rust +pinned Rust 1.100.0 is the latest stable + +== Unfinished local work +uncommitted changes: + M docs/design.md + M rust-toolchain.toml + M scripts/audit-status.sh + M scripts/test-scripts.sh +branch step/0.4-writing-guide: 0 unpushed, 0 not pulled +local branches not merged into main: + step/0.4-writing-guide +remote branches not merged into main: + origin/step/0.4-writing-guide + +== Markers in code +none + +== Leftovers (scripts/cleanup.sh --plan; run scripts/cleanup.sh to remove the local ones) +keep local branch (not merged): step/0.4-writing-guide +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, draft PR (not closed here): #3 updated 2026-11-23: Roadmap 0.4: writing guide +nothing to remove + +== GitHub +open pull requests: +#3 DRAFT step/0.4-writing-guide updated 2026-11-23: Roadmap 0.4: writing guide +last CI runs on main: +2026-11-23 completed/success: Guard the Windows skips; test the report with no red checks +2026-11-23 completed/success: CI +2026-11-22 completed/success: Remove --apply everywhere, close review and audit 0002 findings +``` + +- **Uncommitted work**: four files, nothing staged, no stashes, nothing unpushed. + - `scripts/audit-status.sh:76-89`: new "Rust" section. It reads the pinned version, runs `rustup check` and prints one of three lines. + - `scripts/test-scripts.sh:361-371`: three checks for it, with a `rustup` stub. + - `rust-toolchain.toml:1-16`: comment (why pinned, how to update, which targets and why). The old inline comment on `channel` is gone. + - `docs/design.md:415`: two wrapped lines joined into one of 115 characters. No word changed. + - Committing it is the 6th commit: `sh scripts/audit-status.sh --gate-commit` exits 1 ("5 commits since the last coherence audit (limit 5)") until this report is committed alone. + - The change has no review yet, and PR #3 does not quote its red and green runs yet (`CLAUDE.md:24-25`). +- **PR #3** (draft, opened 2026-11-23, less than a day old, head df7ee92, 3 commits, 5 comments): + - What it is for: roadmap 0.4 (`docs/roadmap.md:34-38`): the writing guide, the rewrite of the documents to it, the `rust-toolchain.toml` comment, the session-report line for a newer Rust. + - Done: `docs/writing.md`, the pointers from `CLAUDE.md` and both agent prompts, the rule on verdict comments. + - Missing: + - a review of df7ee92. The only verdict posted is CHANGES NEEDED on 0121327 and 4ab527f; the last state comment says "Next session: a short review of that commit (verdict posted here)"; + - the commit, proof and review of the uncommitted change (F1 to F3); + - the rewrite of `README.md`, `docs/design.md`, `docs/roadmap.md`, `CLAUDE.md` and the agent prompts. Until then `CLAUDE.md:129-131` ("Every text ... follows `docs/writing.md`") describes the target, not the state: for example `README.md:10,33` have headings that are not questions and `README.md:38-57` is a list where every item starts with a bold label (`docs/writing.md:15-16,58-59`); + - the `[x]` mark at `docs/roadmap.md:34`, correctly absent. + - Still relevant: yes, it is the one open step. +- **PR #2** (merged 2026-11-23, head 8561ec5, not a draft when merged): `main`, `origin/main` and `origin/step/0.2.1-confirmation-rules` all point at 8561ec5, so the merge was a fast-forward of the commits CI checked. +- **CI job lists** (`gh pr checks `, `gh run list`): + + | Commit | Run | Repository rules | Linux musl | Windows gnu | macOS arm64 | + |---|---|---|---|---|---| + | 5d29d9d (PR #2) | 45078051669 | run result: success | | | | + | 8561ec5 (PR #2) | 45118069807 | pass | pass | pass | pass | + | 8561ec5 (`main`, push) | 45118709861 | pass | pass | pass | pass | + | 0121327 (PR #3) | 45118875896 | cancelled by the next push | | | | + | 4ab527f (PR #3) | 45119011124 | run result: success | | | | + | df7ee92 (PR #3) | 45119588761 | pass | pass | pass | pass | + + GitGuardian passes on both PRs. The weekly run on `main` (45117684619, at baa61c9) succeeded. No red run after 4fc97d8. +- **Verdict comments** (`gh pr view --comments`; rule at `CLAUDE.md:31-36`, in force since 0121327): + - PR #2: 4 comments. Verdict CHANGES NEEDED on 5d29d9d (round 7, findings A1 to A5), verdict APPROVED on 8561ec5 (round 8), the merged head. Two state comments. Rounds 1 to 6 have no verdict comment; they predate the rule and the first state comment says "approved up to 1c3fc05". + - PR #3: 5 comments. Verdict CHANGES NEEDED on 0121327 and 4ab527f (A1 to A6). Four state comments, the last one after df7ee92. No verdict on df7ee92 yet (see above). + - PR #1 (merged 2026-11-22 as a draft): 1 comment, no verdict. Already reported as 0003-F5; nothing can be changed now. +- **Branches**: local `main` and the step branch; on GitHub `main`, `step/0.2-ci` and `step/0.2.1-confirmation-rules` (both merged, kept) and the step branch. +- **Markers**: none. +- **Leftovers**: `sh scripts/cleanup.sh --plan` (exit 0) prints the four lines shown above and "nothing to remove". +- **Tracked files that belong to the work, not the product**: none. `git ls-files` shows 35 files; the only reports are the four under `docs/audits/`. + +## Findings + +### F1. `drift`: the script tests now call the real `rustup check`, over the network, 14 times +- `scripts/audit-status.sh:79` runs `rustup check` in every report-mode run. `scripts/test-scripts.sh` runs the report 19 times; only the three at lines 367, 369 and 371 put a `rustup` stub first in `PATH`. +- Probe on a scratch copy, with a counting `rustup` stub placed before the real one: + ``` + test-scripts exit 0 ; real-rustup calls (not the test's own shim): 14 + test-cleanup exit 0 ; real-rustup calls (not the test's own shim): 0 + test-hooks exit 0 ; real-rustup calls (not the test's own shim): 0 + ``` +- Consequences: the suite contacts the Rust release server from the pre-commit hook (`.githooks/pre-commit:14-18`) and from all three CI systems (`.github/workflows/ci.yml:47-51,120-125`); its result and duration depend on the network. The existing tests isolate `gh` with stubs for the same reason. +- In those 14 runs the test repository has no `rust-toolchain.toml`, so the report prints the wrong line of F2. +- Change (test): give the test repositories a default `rustup` stub, as for `gh`, or record the gap in roadmap 0.5. + +### F2. `minor`: the "Rust" section can print a statement that is not true +- `scripts/audit-status.sh:87-88`: the `else` branch prints `pinned Rust $pinned is the latest stable` for every case that is not "newer". +- Probes on a scratch repository with a `rustup` stub (line printed under "== Rust"): + + | `rust-toolchain.toml` | `rustup check` says | Printed | + |---|---|---| + | missing | `up to date: 1.100.0` | `pinned Rust is the latest stable` | + | `channel = "stable"` | `up to date: 1.100.0` | `pinned Rust is the latest stable` | + | `channel = "1.100.0"` | `up to date: 1.99.0` | `pinned Rust 1.100.0 is the latest stable` | + | `channel = "1.100"` | `up to date: 1.100.0` | `NEWER RUST STABLE: 1.100.0 (pinned: 1.100); see rust-toolchain.toml` | + | `channel = "1.100.0"` | `Up to date : 1.100.0` (older rustup wording) | `Rust release not checked (rustup check failed or no stable toolchain)` | + +- The real case works: here `rustup check` prints `stable-aarch64-apple-darwin - up to date: 1.100.0 (0ef1bc386 2026-11-09)` (rustup 1.29.3) and the report says `pinned Rust 1.100.0 is the latest stable`. Version order is numeric: 1.9.0 against 1.10.0 gives "NEWER RUST STABLE: 1.10.0". +- Change (code and test): a separate line when the pinned version cannot be read. Whether a pinned version ahead of the installed stable deserves its own line is the owner's choice. + +### F3. `minor`: two rules of the new section have no test, and one test name says the opposite of the code +- Rule breaking on the scratch copy, 8 mutations of `scripts/audit-status.sh:76-89`, `sh scripts/test-scripts.sh` after each: + + | Mutation | Tests failing | + |---|---| + | "NEWER RUST STABLE" line removed | 1 | + | "Rust release not checked" line removed | 1 | + | version-order condition (`sort ... tail -n 1`) removed | 0 | + | `"$latest" != "$pinned"` removed | 1 | + | "pinned Rust ... is the latest stable" line removed | 0 | + | "up to date" pattern removed from `sed` | 1 | + | whole section removed | 2 | + | pinned version read from a wrong file name | 1 | + +- `CLAUDE.md:25-27`: "a rule nobody's test notices gets a test". The two unnoticed ones are the order check (a pinned version newer than the installed stable must not be announced as "newer stable") and the positive line. +- `scripts/test-scripts.sh:369` is named "report: pinned Rust is the latest, nothing said", but the script does say something (`scripts/audit-status.sh:88`). The check only asserts that two other lines are absent, so it also passes if the section prints nothing: the known limit at `docs/roadmap.md:59`. +- `docs/roadmap.md:38` and the PR text promise "a line ... when a newer stable Rust exists"; the section prints a line in all three cases. Not a contradiction, but the roadmap does not describe the other two lines. +- Change (test): add the two cases, rename the check or assert the positive line; or list them in roadmap 0.5. + +### F4. `contradiction` (minor): the writing guide says only the tool's strings are translated; the user guide is translated too +- `docs/writing.md:3-5`: the texts are "docs, agent prompts, comments, commit messages, PR texts, the user guide and the strings the tool shows. Everything is in English; only the tool's own strings are translated". +- `CLAUDE.md` ("The tool's own interface is translated (console messages, `--help`, HTML report, user guide)"), R27 at `docs/design.md:130-133` and R37 at `docs/design.md:345-347` translate the user guide as well. +- The guide names the user guide and the tool's strings as two separate things, then translates only the second. +- Change (doc): `docs/writing.md:5`, for example "only the tool's interface (its strings and the user guide) is translated". + +### F5. `minor`: PR texts carry an emoji, which the guide forbids in PR texts +- `docs/writing.md:3-4` applies the guide to PR texts; `docs/writing.md:55` lists emojis among the patterns "we do not use". +- `gh pr view 3 --json body`: the last line is the robot emoji followed by "Generated with [Claude Code](...)". The same line closes the text of PR #2 (line 195 of its body). +- The line is an attribution footer, not prose. The owner decides: drop it from PR texts, or name it among the fixed formats at `docs/writing.md:81-84`. + +### F6. `minor`: the "State" section of PR #3 is out of date +- PR #3 text: "## State / Draft. Next: the writing guide." The guide was committed in 4ab527f and reviewed; the state comments are current (the last one names the review of df7ee92 as the next step). +- `CLAUDE.md:62-64` asks for a comment, and that exists. The text and the comments now tell two different states. +- Change: update the section with the next push, or replace it with a pointer to the comments. + +### F7. `minor`: carried over +- From 0001-F12, 0002-F9, 0003-F10, 0004-F8: `Cargo.toml:19-21` declares `assert_cmd` 2.2.2 and `predicates` 3.1.4; `tests/` holds only `fixtures/README.md`, no `tests/*.rs`. +- From 0003-F6, 0004-F8: no test fixes the choice that a branch just created at `main` is removed (`grep -n 'just created\|no commits' scripts/test-cleanup.sh` finds nothing). +- `docs/design.md:415` (uncommitted) is one line of 115 characters in a file wrapped at 100. Four other lines of that file are already longer (`docs/design.md:34,53,393,400`). No content changed. + +### Follow-up of audit 0004 +- F1: closed. `docs/roadmap.md:24` marks 0.2.1 done; PR #2 is merged and all four jobs are green on 8561ec5, in the PR run and in the `main` run. +- F2: closed. Windows is green on 5d29d9d and 8561ec5, every step of the job; 0121327 adds "green on all four jobs (read in the job list, never assumed from a pending run)" at `CLAUDE.md:57-59`. +- F3: closed. The fix was committed in 5d29d9d, guarded in 8561ec5 (`scripts/test-cleanup.sh:265-267`), reviewed in rounds 7 and 8. +- F4: closed. State and verdict comments exist on PR #2; the owner's decision is at `CLAUDE.md:31-36`. +- F5: closed. The double-quote check runs on Windows again; the skips are 4 + 1 (`scripts/test-cleanup.sh:159,226`), and `docs/roadmap.md:44-47` says 5 checks and that the double-quote check "does not exercise git's quoting". The hand-written numbers are listed at `docs/roadmap.md:46-47`. +- F6: closed (`.claude/agents/fable-reviewer.md:34-36`). +- F7: decided. `docs/design.md:163-164` says "a shorter summary than the console"; `README.md:43,105` and `CLAUDE.md:144` say "the same confirmations"; `docs/roadmap.md:143-146` lists what the shorter summary must still show. `grep -rn 'same questions'` finds nothing outside `docs/audits/`. +- F8: heading of 0.5 fixed (`docs/roadmap.md:39`), R28 speaks of folders (`docs/design.md:147`); the rest is F7 above. + +### Verified and found true +- **`docs/writing.md` against `CLAUDE.md`, `README.md`, `docs/design.md`**: apart from F4, no contradiction. + - Its examples match the design: "The release embeds the LOTL and the Italian list" (`docs/writing.md:65-66`, R44 at `docs/design.md:259-262`); "whether the company proxy needs NTLM" (`docs/writing.md:67`, `docs/design.md:446-448`). + - R27 and R35 are cited in their proper sense (`docs/writing.md:77-78`). + - "Yes, six" (`docs/writing.md:72`) is followed by six exceptions. + - The fixed formats it names exist: the `VERDICT:` line (`.claude/agents/fable-reviewer.md:71`), the audit skeleton (`.claude/agents/coherence-auditor.md:50-56`), the front matter of both prompts. + - "Who checks?" (`docs/writing.md:88-89`) is matched by `.claude/agents/fable-reviewer.md:44-46` and `.claude/agents/coherence-auditor.md:36-37`. + - `docs/roadmap.md:34-36` describes the guide as it is. The Wikipedia page "Signs of AI writing" exists under the address given. + - No em dash, curly quote or emoji in `docs/writing.md`, `CLAUDE.md`, `README.md`, `docs/design.md`, `docs/roadmap.md`, the agent prompts, the scripts, the hooks, `rust-toolchain.toml` or the five commit messages (en dashes appear only in ranges such as "R28–R34"). +- **Commit messages in the range**: every change they name exists. 5d29d9d: five checks skipped on Windows and counted, tests for "AUDIT DUE" and "RED CHECKS" (`scripts/test-scripts.sh:372-384`). 8561ec5: the skip guard with `OS=Windows_NT` (`scripts/test-cleanup.sh:267`), the negative RED CHECKS case. 0121327, 4ab527f, df7ee92: the texts listed above. The section list in the message of 4ab527f matches the headings of the guide. +- **`rust-toolchain.toml` comment**: the four targets are the ones in `targets` (lines 20-25) and in R24 (`docs/design.md:121`); R25 (`docs/design.md:122-124`) builds the packages from the musl binary; the mingw linker is in `.cargo/config.toml`; CI installs the pinned toolchain from this file (`.github/workflows/ci.yml:99-102`) and has four jobs. `sed` at `scripts/audit-status.sh:78` still reads the version after the inline comment was removed. +- **Rule on verdict comments**: `sh scripts/check-public.sh --message ` exists (it is what `.githooks/commit-msg:4` runs). The posted comments hold no local path and no personal data. +- **Requirement numbering**: every R number used in the texts changed in the range exists in `docs/design.md`. +- **Roadmap marks**: 0.1, 0.2, 0.2.1 and 1.0 hold. `is_envelope` is in `src/lib.rs:10` with six test functions, none ignored: five run on macOS, `windows_paths` is `#[cfg(windows)]` and `non_utf8_names` is `#[cfg(unix)]`. Files named by unmarked steps only (`scripts/make-fixtures.sh`, `docs/accessibility.md`) do not exist, as expected. +- **Hooks against `CLAUDE.md:37-41`**: `.githooks/pre-commit:8-30`, `commit-msg:4`, `pre-push:9-19` do what is described; unchanged in the range. +- **GitHub settings against `CLAUDE.md`**: protection of `main` (the four checks, strict, admins included, linear history, no force-push, no deletion); merge commits and squash off, no automatic branch deletion, wiki and projects off; interaction limit `collaborators_only`, expiring 2027-05-22. The actions allowlist and secret scanning were not re-queried. +- **Crate versions**: `assert_cmd` 2.2.2 and `predicates` 3.1.4 in `Cargo.toml` match `Cargo.lock`. Rust 1.100.0 is installed and is the current stable according to `rustup check`. +- **Safety, accessibility, uninstall (R28-R43)**: still no code; nothing is claimed done; the placeholder in `src/main.rs:3-10` reads and writes nothing and is the recorded exception (`docs/design.md:437-438`). +- **Language rule**: all text added in the range and in the working tree is English. +- **Public-repository rule**: `sh scripts/check-public.sh --range tip HEAD` exits 0; the five commits of the range have no-reply author and committer addresses. No `tests/corpus/` was read. + +## Health + +Run on macOS arm64 on the working tree (with the uncommitted change); script tests, probes and rule breaking on a scratch copy with a `gh` stub first in `PATH`. + +| 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`; warnings for allowed licences not used yet (for example `Zlib`, `deny.toml:22`) | +| `sh scripts/test-scripts.sh` | 140 passed, 0 failed (137 at 8561ec5 plus the 3 new checks) | +| `sh scripts/test-cleanup.sh` | 79 passed, 0 failed, 0 skipped | +| `sh scripts/test-hooks.sh` | 24 passed, 0 failed | +| `sh scripts/check-public.sh --range tip HEAD` | exit 0 ("0 commits and the tree of df7ee92 scanned") | +| `sh scripts/audit-status.sh --gate-push HEAD` | exit 0 (5 commits since audit 0004) | +| `sh scripts/audit-status.sh --gate-commit` | exit 1: "5 commits since the last coherence audit (limit 5)" | +| CI on df7ee92 (PR #3) | all four jobs green | +| CI on `main` (8561ec5) | all four jobs green | + +The repository was not modified by the audit: `git status --porcelain` shows the same four files before and after, nothing staged, no stash. diff --git a/docs/audits/0006-2026-11-23.md b/docs/audits/0006-2026-11-23.md new file mode 100644 index 0000000..dfcdfea --- /dev/null +++ b/docs/audits/0006-2026-11-23.md @@ -0,0 +1,183 @@ +# Coherence audit 0006 (2026-11-23) +Range: 2557e7f..fb41029 (five commits on `step/0.4-writing-guide`, PR #3, draft; working tree clean) Verdict: COHERENT + +Auditor: `coherence-auditor` agent, fresh context, read-only, run because the cadence is due (5 commits since audit 0005). + +The committed range holds no false claim and no broken rule. All five commits work on the "Rust" section of the session report and its tests, plus small text fixes. What the commit messages and the PR text say about them was checked and holds. The open points are on PR #3: its comments stop one step behind its head (F1), and a decision quoted in the PR text is not written in the project rules (F2). Step 0.4 is still open and unfinished, as its PR says. + +## Unfinished work + +`sh scripts/audit-status.sh` (exit 0): + +``` +== Audit cadence +commits since last audit: 5 (audit every 5) +last audit: 0f92512 2026-11-23 audit: 0005 +AUDIT DUE + +== Rust +pinned Rust 1.100.0 is the latest stable + +== Unfinished local work +working tree clean +branch step/0.4-writing-guide: 0 unpushed, 0 not pulled +local branches not merged into main: + step/0.4-writing-guide +remote branches not merged into main: + origin/step/0.4-writing-guide + +== Markers in code +none + +== Leftovers (scripts/cleanup.sh --plan; run scripts/cleanup.sh to remove the local ones) +keep local branch (not merged): step/0.4-writing-guide +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, draft PR (not closed here): #3 updated 2026-11-23: Roadmap 0.4: writing guide +nothing to remove + +== GitHub +open pull requests: +#3 DRAFT step/0.4-writing-guide updated 2026-11-23: Roadmap 0.4: writing guide +last CI runs on main: +2026-11-23 completed/success: Guard the Windows skips; test the report with no red checks +2026-11-23 completed/success: CI +2026-11-22 completed/success: Remove --apply everywhere, close review and audit 0002 findings +``` + +- **Local work**: nothing uncommitted, no stashes, nothing unpushed, one worktree. +- **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 #3** (draft, opened 2026-11-23, less than a day old, head fb41029, 9 commits, 10 comments): + - What it is for: roadmap 0.4 (`docs/roadmap.md:34-38`): the writing guide, the rewrite of the documents to it, the `rust-toolchain.toml` comment, the session-report line for a newer Rust. + - Done: `docs/writing.md`, the pointers to it, the rule on verdict comments, the `rust-toolchain.toml` comment, the "Rust" section with its tests. + - Missing: + - the comments that follow fb41029 (F1); + - an APPROVED verdict. PR #3 has five verdicts, all CHANGES NEEDED; `CLAUDE.md:57-59` makes a PR ready only after the reviewer approved; + - the rewrite of `README.md`, `docs/design.md`, `docs/roadmap.md`, `CLAUDE.md` and the agent prompts. Until then `CLAUDE.md:129-130` ("Every text ... follows `docs/writing.md`") describes the target, not the state. Example: the `README.md` headings at lines 10, 33, 59 are not questions, and `README.md:122-128` is a list with bold labels and colons (`docs/writing.md:16-18,59-60`). `README.md` does not name the guide (`grep -n writing README.md` finds nothing); + - the `[x]` mark at `docs/roadmap.md:34`, correctly absent. + - Still relevant: yes, it is the one open step. +- **CI job lists** (`gh pr checks 3`, `gh run list`): + + | Commit | Run | Result | + |---|---|---| + | 2557e7f | 45122270491 | run result: success | + | 1ac9d1d | 45158439855 | run result: success | + | c3f070e | 45161036812 | run result: success | + | 1363b18 | 45163358980 | run result: success | + | fb41029 (head) | 45165402536 | Repository rules, Linux musl, Windows gnu, macOS arm64: all four pass, read in the job list | + + The run on fb41029 was still pending at the start of the audit and finished green during it. GitGuardian passes. No red run in the range. `main` is unchanged at 8561ec5, green. +- **Branches**: local `main` and the step branch; on GitHub `main`, `step/0.2-ci` and `step/0.2.1-confirmation-rules` (both merged, kept) and the step branch. Nothing stale. +- **Pull requests**: #1 and #2 merged, #3 open as a draft. No other open PR. +- **Markers**: none. +- **Leftovers**: `sh scripts/cleanup.sh --plan` (exit 0) prints the four lines shown above and "nothing to remove". +- **Tracked files that belong to the work, not the product**: none. `git ls-files` shows 35 files; the only reports are the five under `docs/audits/`. + +## Findings + +### F1. `unfinished`: the comments of PR #3 stop before its head commit +- `GH_PROMPT_DISABLED=1 gh pr view 3 --comments `) left all tests green; it cannot change the result on a real rustup line, so it is not a finding. +- **PR #3 text**: the test names in the table of the "fifth review" are the names in `scripts/test-scripts.sh:448-479`. The counts match: 176 passed under `sh` and under `dash`. +- **`rust-toolchain.toml:1-17`**: CI installs the pinned toolchain with `rustup toolchain install` (`.github/workflows/ci.yml:98-100`) and has four jobs (`ci.yml:39,78` with three targets); the mingw linker is in `.cargo/config.toml`; the four targets are those at lines 21-26. +- **rustup line format**: here `rustup --version` says 1.29.3 and `rustup check` prints `stable-aarch64-apple-darwin - up to date: 1.100.0`, as the comment at `scripts/audit-status.sh:79` and the stub lines say. The older form "Up to date : X" could not be produced here; the code names no release for it. +- **Crate versions**: `assert_cmd` 2.2.2 and `predicates` 3.1.4 in `Cargo.toml` match `Cargo.lock`. Rust 1.100.0 is pinned, installed and the current stable. +- **Roadmap marks**: 0.1, 0.2, 0.2.1 and 1.0 hold; nothing was marked in the range. `is_envelope` is in `src/lib.rs:10` with six test functions, none ignored (`windows_paths` is `#[cfg(windows)]`, `non_utf8_names` is `#[cfg(unix)]`). `src/` did not change in the range. There is no other module or public function. +- **Requirement numbering**: R24, R25, R27, R35 as cited in the changed texts exist in `docs/design.md` in that sense. +- **Verdict comments** (`CLAUDE.md:31-36`): PR #3 carries verdicts on 0121327 and 4ab527f, on df7ee92 and 2557e7f, on 1ac9d1d, on c3f070e and on 1363b18, each by a "new fable-reviewer agent", each with the findings in short. The comments hold no local path and no personal data. PR #2: verdicts as reported in audit 0005. PR #1: no verdict (0003-F5, predates the rule). +- **Writing guide on the changed texts**: no em dash, curly quote or emoji found in the commit messages of the range or in the PR #3 text. The comment at `scripts/audit-status.sh:77-80` and the header of `rust-toolchain.toml` use short sentences and exact commands. +- **Safety, accessibility, uninstall (R28-R43)**: still no code; nothing is claimed done; the placeholder in `src/main.rs` reads and writes nothing and is the recorded exception (`docs/design.md:438-439`). +- **Language rule**: all text added in the range is English. +- **Public-repository rule**: `sh scripts/check-public.sh --range tip HEAD` exits 0; the five commits have no-reply author and committer addresses. No `tests/corpus/` was read. +- **Not re-queried**: the GitHub settings (branch protection, actions allowlist, secret scanning). The session report prints no interaction-limit warning, so the limit is active and more than 30 days from expiry. + +## Health + +Run on macOS arm64 at fb41029, working tree clean. Script tests, probes and rule breaking ran on a scratch copy (`git archive HEAD`) with `gh` and `rustup` stubs first in `PATH`. + +| Command | Result | +|---|---| +| `cargo fmt --check` | clean (exit 0) | +| `cargo clippy --all-targets -- -D warnings` | no issues | +| `cargo nextest run` | 5 passed (2 binaries), exit 0 | +| `cargo test --doc` | 0 doctests (none exist) | +| `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` | 176 passed, 0 failed (also under `dash`) | +| `sh scripts/test-cleanup.sh` | 79 passed, 0 failed, 0 skipped | +| `sh scripts/test-hooks.sh` | 24 passed, 0 failed | +| `sh scripts/check-public.sh --range tip HEAD` | exit 0 ("0 commits and the tree of fb41029 scanned") | +| `sh scripts/audit-status.sh --gate-push HEAD` | exit 0 (5 commits since audit 0005) | +| `sh scripts/audit-status.sh --gate-commit` | exit 1: "5 commits since the last coherence audit (limit 5)" | +| CI on fb41029 (PR #3) | all four jobs green | +| CI on `main` (8561ec5) | green, unchanged | + +The repository was not modified by the audit: `git status --porcelain` is empty before and after, no stash. `cleanup.sh` was run with `--plan` only. Nothing was posted or changed on GitHub. diff --git a/docs/audits/0007-2026-11-23.md b/docs/audits/0007-2026-11-23.md new file mode 100644 index 0000000..b977932 --- /dev/null +++ b/docs/audits/0007-2026-11-23.md @@ -0,0 +1,199 @@ +# Coherence audit 0007 (2026-11-23) +Range: 2891328..20a420d (five commits on `step/0.4-writing-guide`, PR #3, 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 0006). + +No code changed in the range, and no claim about code is false. The drift is in the documents. Three of the five commits change requirements (R16, R19, R20, R27, R28, R31, R33, R34, R40, R42, R45, R47) inside a step named "writing guide", and the new texts contradict each other in five places (F1 to F5). A sixth review comment, posted on PR #3 during this audit, lists most of them; they were checked here independently and are still open at the head. PR #3 has no comment that says its current state and next step (F7). + +## Unfinished work + +`sh scripts/audit-status.sh` (exit 0): + +``` +== Audit cadence +commits since last audit: 5 (audit every 5) +last audit: 2891328 2026-11-23 audit: 0006 +AUDIT DUE + +== Rust +pinned Rust 1.100.0 is the latest stable + +== Unfinished local work +working tree clean +branch step/0.4-writing-guide: 0 unpushed, 0 not pulled +local branches not merged into main: + step/0.4-writing-guide +remote branches not merged into main: + origin/step/0.4-writing-guide + +== Markers in code +none + +== Leftovers (scripts/cleanup.sh --plan; run scripts/cleanup.sh to remove the local ones) +keep local branch (not merged): step/0.4-writing-guide +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, draft PR (not closed here): #3 updated 2026-11-23: Roadmap 0.4: writing guide +nothing to remove + +== GitHub +open pull requests: +#3 DRAFT step/0.4-writing-guide updated 2026-11-23: Roadmap 0.4: writing guide +last CI runs on main: +2026-11-23 completed/success: Guard the Windows skips; test the report with no red checks +2026-11-23 completed/success: CI +2026-11-22 completed/success: Remove --apply everywhere, close review and audit 0002 findings +``` + +- **Local work**: nothing uncommitted, no stashes, nothing unpushed, one worktree. +- **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. Audit 0006 was committed alone (`git show --stat 2891328`: one file). +- **PR #3** (draft, opened 2026-11-23 05:36 UTC, less than a day old, head 20a420d, 15 commits, 16 comments): + - What it is for: roadmap 0.4 (`docs/roadmap.md:34-38`): the writing guide, the rewrite of README, design, roadmap, `CLAUDE.md` and the agent prompts to it, the `rust-toolchain.toml` comment, the session-report line for a newer Rust. + - Done: the guide, the pointers to it, the `rust-toolchain.toml` comment, the "Rust" section with its tests, the README rewritten to the guide (d323e74, 40e2d4c). + - Missing: + - an APPROVED verdict. PR #3 has nine verdicts, all CHANGES NEEDED. The latest, on 20a420d (comment of 12:38 UTC), has 21 items, four of them questions for the owner; none is closed yet; + - the rewrite of `docs/design.md`, `docs/roadmap.md`, `CLAUDE.md` and the agent prompts; + - a state comment with the next step (F7); + - the `[x]` mark at `docs/roadmap.md:34`, correctly absent. + - Still relevant: yes, it is the one open step. Its content has grown beyond the step (F6). +- **CI job lists** (`gh run list`, `gh run view`, `gh pr checks 3`): + + | Commit | Run | Result | + |---|---|---| + | 2891328 (audit 0006) | 45166698876 | cancelled | + | d323e74 | 45166789199 | success | + | 40e2d4c | 45168033014 | success | + | 5ba364e | 45172170142 | success | + | f0cc470 | 45173925936 | success | + | 20a420d (head) | 45175501435 | Repository rules, Linux musl, Windows gnu, macOS arm64: all four pass, read in the job list | + + The run on 2891328 was cancelled, not red: d323e74 was pushed 36 seconds later, and a new push to a pull request replaces the running check (`.github/workflows/ci.yml:22-26`). The run on the head was still in progress at the start of the audit and finished green during it. GitGuardian passes. `main` is unchanged at 8561ec5, green. +- **Branches**: local `main` and the step branch; on GitHub `main`, `step/0.2-ci` and `step/0.2.1-confirmation-rules` (both merged, kept) and the step branch. Nothing stale. +- **Pull requests**: #1 and #2 merged, #3 open as a draft. No other open PR. +- **Markers**: none. +- **Leftovers**: `sh scripts/cleanup.sh --plan` (exit 0) prints the four lines shown above and "nothing to remove". +- **Tracked files that belong to the work, not the product**: none. `git ls-files` shows 37 files; the only reports are the six under `docs/audits/`. + +## Findings + +F1 to F5 are about what the tool should do. Each needs the owner's choice; none should be settled by aligning one text to the other. + +### F1. `contradiction`: a foreign file in the cache is "never replaced" in one place and replaceable in another +- R47, `docs/design.md:309-311`: "The tool replaces only the files with the fixed names it creates there, never another file found in that folder." A file that the tool did not create, but that carries one of the fixed names, may be replaced under this rule. +- R34, `docs/design.md:250-251`: "a file in the cache folder that the tool did not create is never replaced". `.claude/agents/fable-reviewer.md:36` says the same ("replaces a file in the cache that the tool did not create"). +- The two rules give different answers for a foreign file with a fixed name. No R34 case names it. Also open: the names of cached CRL files, which must not come from the input if R47 is to hold. +- Change: the owner decides which rule holds; then R47, R34 and the reviewer prompt say the same, and R34 gets the case. Item 4 and 13 of the review of 20a420d on PR #3. + +### F2. `contradiction`: R47 sends the reader to R42 for the cache folder, and the test rule does not fit the candidate crate on Windows +- R47, `docs/design.md:307-309`: "The cache folder is the operating system's standard one (R42) ... Tests move it only through the system's own variables (`HOME`, `XDG_CACHE_HOME`, `LOCALAPPDATA`)." +- R42, `docs/design.md:410-415`: the Windows item names registry keys and the uninstall entry only. It names no cache folder and no folder for the manifest. macOS and Linux have both (`docs/design.md:416-419`). +- The architecture table names `directories` as the candidate crate for the cache (`docs/design.md:440`). On Windows that crate does not read `LOCALAPPDATA`: it asks the system (`SHGetKnownFolderPath`). Checked in the crate sources: `dirs-sys` `src/lib.rs:153,180` (`known_folder_local_app_data`), used by `directories` `src/win.rs:13`. A test that sets `LOCALAPPDATA` would still reach the user's real cache, which R34 forbids (`docs/design.md:249-250`). +- The manifest of R41 lives in the config folder. No rule says how tests of `install-menu` move that folder. +- Change: name the Windows cache and config folders in R42; decide before roadmap 3.5 how the folder is found on Windows so that the test rule of R47 can work. `directories` is not a dependency yet (`Cargo.toml:16`), so nothing is broken today. Item 5 of the review of 20a420d. + +### F3. `contradiction`: the "create new" rule has three different scopes +- R31, `docs/design.md:202-203`, and `CLAUDE.md:160-161`: "every file `check` and `extract` write outside the cache". +- `.claude/agents/fable-reviewer.md:35-36`: "opens any file for writing outside the tool's cache (the report too) without `create_new`", for every command. +- `README.md:69-71`: "Nothing is ever overwritten, not even an earlier report. Every file is created with an exclusive "create new" operation". +- The commit message of 20a420d says the rule was "scoped to check and extract, so the install manifest (R41) is not caught by it". The README and the reviewer prompt were not scoped. With the narrow scope, no rule says what `install-menu` does when it meets a foreign menu item with the same name, which `uninstall` could then remove (R41, `docs/design.md:404-408`). +- Change: the owner decides the rule for `install-menu`; then the three texts carry one scope. Items 1 to 3 of the review of 20a420d. + +### F4. `contradiction` (gap): `--no-report` and the second report +- `--no-report` appears three times: `docs/design.md:62` ("none with `--no-report`, R19"), the option list at `docs/design.md:120`, and the test case at `docs/design.md:246`. R19 only lists the name. No text says what it does with `extract`. +- R33 (`docs/design.md:228-229`) and R20 (`docs/design.md:125-127`) make the report of an extraction the only record `undo` can use. With `--no-report`, an extraction would leave no record. With `--report ` or `--json `, where the second report and a second JSON file go is not said. +- Change: the owner decides whether `--no-report` is allowed with an extraction and what the second report does for `--json`; define the option in R19. Items 7 and 18 of the review of 20a420d. + +### F5. `contradiction` (minor): what the dialog shows, and the R34 cases that follow +- The commit message of 20a420d says: "The summary and the dialog show the any-kind count and why a run is risky." The console summary does (`docs/design.md:94-96`). The dialog of R30 shows the files to process, the total, the reason and the operation (`docs/design.md:184-187`); it does not show the any-kind count. +- R34, dialogs (`docs/design.md:265-269`): "every selected folder with its count, the total and the operation are shown". The reason, which R30 now requires, has no case. The console cases (`docs/design.md:254-264`) have none for "the summary says why" or for the any-kind count in rows and totals. +- Change: decide whether the dialog shows the any-kind count; add the missing cases to R34. Items 6, 9 and 10 of the review of 20a420d. + +### F6. `drift`: three commits of requirement decisions inside the step "writing guide" +- Roadmap 0.4 (`docs/roadmap.md:34-38`) covers the guide, the rewrite of the documents, a comment and a report line. Commits 5ba364e, f0cc470 and 20a420d record owner's decisions that change what the tool does: what `check` writes, the 10,000-file rule on files of any kind, reports never replaced, `--plan` downloading nothing, the second report, the cache rules, no saved preference (`git diff 2891328..HEAD --stat`: `docs/design.md` 90 lines added, 50 removed). +- The decisions are dated and attributed in the commit messages and in the PR comments of 12:28 and 12:38 UTC. No roadmap step names them. The PR text does not either: its "Done so far" paragraph ends with the README and the "Rust" decision. +- Each decision opened new questions (F1 to F5), and the review rounds on this PR now discuss requirements, not the wording of documents. `CLAUDE.md:63` says "One step open at a time". +- Change: the owner decides whether these decisions stay in PR #3 (then roadmap 0.4 and the PR text name them) or go to a step of their own. + +### F7. `unfinished`: PR #3 has no comment with its current state and next step +- `GH_PROMPT_DISABLED=1 gh pr view 3 --comments `. + +### F10. `minor`: carried over +- From 0005-F3: `docs/roadmap.md:38` promises a "session report line when a newer stable Rust exists". The section prints one of six lines (`scripts/audit-status.sh:85-97`). The roadmap text can name the section when 0.4 is marked done. +- From 0001-F12 to 0006-F4: `Cargo.toml:19-21` declares `assert_cmd` 2.2.2 and `predicates` 3.1.4; `tests/` holds only `fixtures/`, no `tests/*.rs`. +- From 0003-F6 to 0006-F4: no test fixes the choice that a branch just created at `main` is removed (`grep -n 'just created\|no commits' scripts/test-cleanup.sh` finds nothing). + +### Follow-up of audit 0006 +- F1: closed by the comment of 11:37 UTC (how the review of 1363b18 was closed, state, next step). Open again as F7. +- F2: closed. `CLAUDE.md:27-28` states the exception and points to `docs/roadmap.md` 0.5; `docs/roadmap.md:60-72` records the decision, the missing time limit on `rustup check` and three listed breakages. +- F3: no change needed. +- F4: the text of merged PR #2 no longer ends with the emoji (`gh pr view 2 --json body`, last line: "Generated with [Claude Code](https://claude.com/claude-code)"). The other items are carried in F10. + +### Verified and found true +- **Commit messages in the range**: apart from F8, every change they name exists. + - d323e74: README headings are questions (`README.md:12,39,80,91,97,111,134,146`); it points to the guide (`README.md:158-159`); no bold label in its lists. + - 40e2d4c: every kind of risky folder of R28 (`README.md:52-57`); the script rule (`README.md:62-67`); two tests added (`scripts/test-scripts.sh:461-464`). + - 5ba364e: R16 (`docs/design.md:61-71`), `CLAUDE.md:141-143`, `.claude/agents/fable-reviewer.md:28-30`, `README.md:44-46` say what `check` writes in the same way. + - f0cc470 and 20a420d: R19 `--plan` (`docs/design.md:109-118`), R20 (`125-127`), R27 (`144-147`), R28 (`163-174`), R33 (`228-229`), R34 (`245-257`), R40 (`398-403`), R45 (`298-302`), R47 (`306-311`), roadmap 1.5 and 2.3 (`docs/roadmap.md:95-99,118-120`). "write log" is gone and the first free name is `(1)` everywhere (`grep -n 'write log\|(3)'` finds nothing). +- **Roadmap 0.5, "Rust" section** (`docs/roadmap.md:60-72`): the review history matches the comments of PR #3. The three listed breakages were made on a scratch copy; `sh scripts/test-scripts.sh` after each: + + | Breakage | Result | + |---|---| + | first dot of the x.y.z check unescaped | 178 passed, 0 failed | + | single digit only for major and patch | 178 passed, 0 failed | + | captured rustup version may start with a dot | 178 passed, 0 failed | + | x.y.z check accepts an empty middle part | 1 failed: `pin with an empty middle part said` | + | x.y.z check accepts an empty first part | 1 failed: `pin with an empty first part said` | + + The first three are green, as the roadmap says. The last two confirm the claim of 40e2d4c ("each fails when its rule is broken on a copy"). +- **PR #3 text**: the table of the "fifth review" names the two tests added in 40e2d4c, and the count is 178. +- **Roadmap marks**: 0.1, 0.2, 0.2.1 and 1.0 hold; nothing was marked in the range. `is_envelope` is at `src/lib.rs:10` with six test functions, none ignored (`windows_paths` is `#[cfg(windows)]`, `non_utf8_names` is `#[cfg(unix)]`). `src/` did not change in the range. There is no other module or public function. +- **References in the new texts**: `OpenOptions::create_new`, `std::io::IsTerminal`, `HOME`, `XDG_CACHE_HOME`, `LOCALAPPDATA` exist with the meaning used (but see F2 for the crate). Requirement numbers cited in the changed texts (R1a, R2, R9, R14 to R20, R27 to R31, R33 to R35, R40 to R42, R44, R45, R47, R49) exist in `docs/design.md` in that sense. `assert_cmd` 2.2.2 and `predicates` 3.1.4 match `Cargo.lock`. +- **Agent prompts**: `.claude/agents/coherence-auditor.md` is unchanged in the range and agrees with `CLAUDE.md:66-72`. The reviewer prompt agrees with `CLAUDE.md` and R16, R20, R29 except for F1 and F3. +- **Verdict comments** (`CLAUDE.md:32-37`): PR #3 carries a verdict for every review in the range, each by "a new fable-reviewer agent", each followed by how it was closed: on fb41029 and d323e74 (11:42), on 40e2d4c (11:53), on 5ba364e (12:17), on f0cc470 (12:28), on 20a420d (12:38, UTC). The comments hold no local path and no address; `sh scripts/check-public.sh --message ` exits 0 on each of the five comments of the range that existed when checked. PR #2: three verdict comments. PR #1: none (0003-F5, predates the rule). +- **Safety, accessibility, uninstall (R28–R43)**: still no code; nothing is claimed done; the placeholder in `src/main.rs` reads and writes nothing and is the recorded exception (`docs/design.md:478-479`). +- **Language rule**: all text added in the range is English. +- **Public-repository rule**: `sh scripts/check-public.sh --range tip HEAD` exits 0; the five commits have no-reply author and committer addresses. No `tests/corpus/` was read. +- **Not re-checked**: the GitHub settings (branch protection, actions allowlist, secret scanning); the LOTL numbers at `docs/design.md:287-288` (unchanged in the range); the laws and standards cited in the unchanged "Accessibility" section. + +## Health + +Run on macOS arm64 at 20a420d, working tree clean. Script tests and rule breaking ran on a scratch copy (`git archive HEAD`) with failing `gh` and `rustup` stubs first in `PATH`. + +| 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` | 178 passed, 0 failed (also under `dash`) | +| `sh scripts/test-cleanup.sh` | 79 passed, 0 failed, 0 skipped | +| `sh scripts/test-hooks.sh` | 24 passed, 0 failed | +| `sh scripts/check-public.sh --range tip HEAD` | exit 0 ("0 commits and the tree of 20a420d 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 20a420d (PR #3) | all four jobs green | +| CI on `main` (8561ec5) | green, unchanged | + +The repository was not modified by the audit: `git status --porcelain` is empty before and after, no stash, HEAD still 20a420d. `cleanup.sh` was run with `--plan` only. Nothing was posted or changed on GitHub. Two files of the `directories` and `dirs-sys` crates were read from their public repositories for F2; nothing about this project was sent. diff --git a/docs/audits/0008-2026-11-23.md b/docs/audits/0008-2026-11-23.md new file mode 100644 index 0000000..98bb31f --- /dev/null +++ b/docs/audits/0008-2026-11-23.md @@ -0,0 +1,180 @@ +# Coherence audit 0008 (2026-11-23) +Range: b0a9cd9..4a99ff1 (five commits on `step/0.4-writing-guide`, PR #3, 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 0007). + +The drift is small and only in documents. No code, script, hook or workflow changed in the range (`git diff --stat b0a9cd9..HEAD`: `docs/design.md`, `docs/roadmap.md`, `README.md`, `CLAUDE.md`, `.claude/agents/fable-reviewer.md`), and no claim about code is false. The rewrite of `docs/design.md` (8bdf261, 4a99ff1) kept all 50 requirement numbers and, as far as this audit compared it, dropped no restriction. It left one dead reference and three pointers that are one requirement off (F1, F2). The seven contradictions and gaps of audit 0007 (F1 to F7) are closed or recorded as open questions. PR #3 still has no APPROVED verdict, and its head commit is not reviewed yet (F3). + +## Unfinished work + +`sh scripts/audit-status.sh` (exit 0): + +``` +== Audit cadence +commits since last audit: 5 (audit every 5) +last audit: b0a9cd9 2026-11-23 audit: 0007 +AUDIT DUE + +== Rust +pinned Rust 1.100.0 is the latest stable + +== Unfinished local work +working tree clean +branch step/0.4-writing-guide: 0 unpushed, 0 not pulled +local branches not merged into main: + step/0.4-writing-guide +remote branches not merged into main: + origin/step/0.4-writing-guide + +== Markers in code +none + +== Leftovers (scripts/cleanup.sh --plan; run scripts/cleanup.sh to remove the local ones) +keep local branch (not merged): step/0.4-writing-guide +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, draft PR (not closed here): #3 updated 2026-11-23: Roadmap 0.4: writing guide +nothing to remove + +== GitHub +open pull requests: +#3 DRAFT step/0.4-writing-guide updated 2026-11-23: Roadmap 0.4: writing guide +last CI runs on main: +2026-11-23 completed/success: Guard the Windows skips; test the report with no red checks +2026-11-23 completed/success: CI +2026-11-22 completed/success: Remove --apply everywhere, close review and audit 0002 findings +``` + +- **Local work**: nothing uncommitted (`git status --porcelain` empty), no stashes, nothing unpushed, one worktree. +- **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. Audit 0007 was committed alone (`git show --stat b0a9cd9`: one file). +- **PR #3** (draft, opened 2026-11-23 05:36 UTC, less than a day old, head 4a99ff1, 21 commits, 25 comments): + - What it is for: roadmap 0.4 (`docs/roadmap.md:35-53`): the writing guide, the rewrite of README, design, roadmap, `CLAUDE.md` and the agent prompts to it, the `rust-toolchain.toml` comment, the session-report line for a newer Rust, and the owner's requirement decisions of 2026-11-23 now named in the step. + - Done in this range: the requirement decisions closed and listed (c3311f6, 0fc8394, cebaf40); `docs/design.md` rewritten to the guide with one section of open questions (8bdf261); the restrictions the rewrite had dropped restored (4a99ff1). + - Missing: + - an APPROVED verdict: no comment on PR #3 holds one (`grep -c APPROVED` on the 25 comments: 0). The four reviews of this range are all CHANGES NEEDED (F3); + - a review of the head 4a99ff1; + - the rewrite of `docs/roadmap.md`, `CLAUDE.md` and the agent prompts; + - the `[x]` mark at `docs/roadmap.md:35`, correctly absent. + - State comment: present. The latest comment (16:48 UTC) ends with "State: draft. Next: coherence audit 0008 (five commits since 0007), then a new reviewer on this commit, then the rewrite of docs/roadmap.md, CLAUDE.md and the agent prompts." This closes 0007-F7. + - Still relevant: yes, it is the one open step. +- **CI job lists** (`gh run list --branch step/0.4-writing-guide`, `gh run view 45220594282 --json jobs`, `gh pr checks 3`): + + | Commit | Run | Result | + |---|---|---| + | b0a9cd9 (audit 0007) | 45182718116 | cancelled | + | c3311f6 | 45183073784 | success | + | 0fc8394 | 45184216206 | success | + | cebaf40 | 45185340986 | success | + | 8bdf261 | 45219066210 | success | + | 4a99ff1 (head) | 45220594282 | Repository rules, Linux musl, Windows gnu, macOS arm64: all four `success`, read in the job list | + + The run on b0a9cd9 was cancelled, not red: c3311f6 was pushed two minutes later, and a new push to a pull request replaces the running check. The run on the head was in progress at the start of the audit and finished green during it. GitGuardian passes. `main` is unchanged at 8561ec5, green. +- **Branches**: local `main` and the step branch; on GitHub `main`, `step/0.2-ci` and `step/0.2.1-confirmation-rules` (both merged, kept) and the step branch. Nothing stale. +- **Pull requests** (`gh pr list --state all`): #1 and #2 merged, #3 open as a draft. No other open PR. +- **Markers**: none. +- **Leftovers**: `sh scripts/cleanup.sh --plan` (exit 0) prints the four lines shown above and "nothing to remove". +- **Tracked files that belong to the work, not the product**: none. `git ls-files` shows 38 files; the only reports are the seven under `docs/audits/`. + +## Findings + +### F1. `drift`: a reference to a design section that no longer exists +- `tests/fixtures/README.md:6`: `See "Test data" in docs/design.md for the list of cases to cover.` +- The rewrite renamed that section. `grep -n '^## ' docs/design.md` now gives "Which test data do we use?" (`docs/design.md:511`); `git show b0a9cd9:docs/design.md` had `## Test data`. +- No other file names an old heading: `grep -n -i -e 'open questions' -e 'recorded exceptions' -e 'Building on the Mac' -e '"Architecture'` over `CLAUDE.md`, `README.md`, `docs/roadmap.md`, `docs/writing.md`, the scripts, hooks, sources, `deny.toml`, `rust-toolchain.toml` and the workflow finds nothing. The README anchor `docs/design.md#how-do-i-build-it-on-the-mac` (`README.md:148`) matches the new heading (`docs/design.md:522`). +- Change: update the heading name in `tests/fixtures/README.md`. + +### F2. `drift` (minor): three pointers still name R19 for a rule that 4a99ff1 moved to R30 +- 4a99ff1 says: "R30 holds how each kind of run confirms (yes/no default, Enter, focus on Cancel, what runs from a script); R19, R28 and R42 point to it." R30 now holds it (`docs/design.md:195-197`: "Yes/no questions default to No, and Enter alone cancels. The answers and the default are written out in words"). R19 only says that these commands "ask a yes/no question (R30)" (`docs/design.md:98-99`). +- Still pointing to R19 for the default and the answers: + - `docs/design.md:306`, R34: "Yes/no questions (R19): Enter alone cancels, `y` on a pipe is refused, a number is not a yes." + - `docs/roadmap.md:121`: "yes/no default No (R19)". + - `CLAUDE.md:147-148`: "ask a yes/no question, default No, answers in words (R19, R35)". +- The reader reaches the rule in two hops instead of one; nothing contradicts. Change: name R30 in the three places (the last two when the roadmap and `CLAUDE.md` are rewritten). + +### F3. `unfinished`: PR #3 has no APPROVED verdict, and the head is not reviewed +- `GH_PROMPT_DISABLED=1 gh pr view 3 --json comments [A-Z]*<' eu-lotl.xml | sort | uniq -c` lists `EL` and `UK`, and no `GR` or `GB`. +- No text says how a `C=` value is matched to a territory code. R48 names the United Kingdom as accepted (`docs/design.md:367`), so the case is in scope. +- Change: the owner decides; a question "Before 3.5" would record it. Not introduced in this range. + +### F5. `minor`: texts that break `docs/writing.md` +Rewritten file, `docs/design.md`: +- `docs/design.md:6`: "in the requirement named in brackets". Requirements are named in round brackets after the text and in bold titles; the sentence does not say which. +- Sentences far over 20 words, all in R34 test lists: `docs/design.md:308-312` (one sentence, 73 words), `262-265` (53), `300-303` (51). Also `docs/design.md:513-516` (48) and `391-394` (45). +- Broken line layout: `docs/design.md:179` (a line cut after "the user's"). +- Headings that are not questions: the fourteen `### Before x.y (...)` headings (`docs/design.md:548-655`) and "(proposal)" after the question at `docs/design.md:487`. `docs/writing.md:82-84` does not list them among the fixed formats. +- Bold labels at the start of sub-items: `docs/design.md:100,112,117` ("Several folders.", "`--interactive`", "`--plan`"), `177`, `224`. +- "Each rule is written once" (`docs/design.md:6-7`) holds for R16, R31 and R47. A few rules are still stated twice: never overwrite and the `(1)` name in R17 (`docs/design.md:83-84`) and R31 (`221-222`); which runs are allowed from a script in R30 (`211-213`) and in the `--plan` items of R19 (`120-125`). + +Files changed in the range but not yet rewritten: +- `README.md:61`: a line cut after "and a". +- `docs/roadmap.md:120` and `124`: lines cut in the middle of step 1.6; `docs/roadmap.md:94-95`: no blank line before "## Phase 1". +- `docs/roadmap.md:129`: 'the question "Before 1.7"', where the section holds three questions (`docs/design.md:561-567`). +- `CLAUDE.md:141-152`: one bullet of seven long sentences, unchanged from 0007-F9; `CLAUDE.md:159-162`: lines cut after the edit of 8bdf261. +- Lines longer than 100 characters: `CLAUDE.md:4,40`, `.claude/agents/coherence-auditor.md:22`, `.claude/agents/fable-reviewer.md:10` (all carried over); `docs/design.md:495,502,504` are table rows. The front-matter lines of the two prompts are a fixed format. +- No em dash, curly quote, arrow character or emoji in `README.md`, `CLAUDE.md`, `docs/design.md`, `docs/roadmap.md` or the agent prompts (`grep -P` for U+2014, U+2018 to U+201D, U+2192: no line). "Settings -> Apps" (`docs/design.md:474`) now matches the README. + +### F6. `minor`: carried over +- From 0007-F9: `docs/roadmap.md:27`, step 0.2.1, marked done: "from a script nothing that changes anything runs (R30)". R19 names the exception (`docs/design.md:95-96`). +- From 0007-F8: `README.md:166` ("License") is a heading that is not a question and not a listed fixed format. +- From 0005-F3: `docs/roadmap.md:39` promises a "session report line when a newer stable Rust exists"; the script prints a "Rust" section. The text can name the section when 0.4 is marked done. +- From 0001-F12: `Cargo.toml:19-21` declares `assert_cmd` 2.2.2 and `predicates` 3.1.4; `tests/` holds only `fixtures/`, no `tests/*.rs`. +- From 0003-F6: no test fixes the choice that a branch just created at `main` is removed by `cleanup.sh`. + +### Follow-up of audit 0007 +- F1 (foreign file in the cache): closed. The rule is by name everywhere: R31 (`docs/design.md:224-229`), R47 (`359-363`), R34 (`283-287`); the reviewer prompt points to R31 (`.claude/agents/fable-reviewer.md:35-37`). What `uninstall` does with a foreign file is an open question (`docs/design.md:656-657`). +- F2 (Windows cache folder and tests): closed as an open question. R42 and R47 say the Windows folders are still open (`docs/design.md:357-358,477`); the question is under "Before 3.5" (`584-588`). +- F3 (three scopes of "create new"): closed. One rule in R31 (`docs/design.md:218-229`); `README.md:71-76` and `CLAUDE.md:159-160` point to it; `install-menu` and a foreign item are in R41 (`461-465`). +- F4 (`--no-report`): closed. R14 and R16 define it (`docs/design.md:66-67,75-77`); the remaining choice is under "Before 4.4" (`618-619`), and R34 states both outcomes (`280-282`). +- F5 (dialog): closed. R34 has the cases (`docs/design.md:293-294`); the any-kind count in the dialog is under "Before 5.2" (`640-641`). +- F6 (requirement decisions inside step 0.4): closed. `docs/roadmap.md:39-53` names the eight decisions, and the PR text names them. +- F7 (state comment): closed, see "Unfinished work". +- F8: no change needed. F9: partly closed (`--open` and `--threads` are a question at `docs/design.md:617`; the README count rule now names unreadable folders and overlaps, `README.md:59-62`; R28 tells links met during the walk from a selected link, `docs/design.md:183-186`); the rest is in F5 and F6. F10: carried in F6. + +### Verified and found true +- **The rewrite kept the requirements.** The last text before the rewrite (cebaf40) and the head were compared: + - the same 50 requirement labels, R1a to R49, in both (`grep '^- R'` on each); + - every number in the old text is in the new one; the only code-quoted item gone is `XDG_CONFIG_HOME`, removed on purpose (4a99ff1: "unverified statements ... removed"); + - per requirement, the counts of restriction words (never, only, not, no, except, always, must, refuse, without) were compared, and every difference was read: R16, R19, R28, R30, R31, R33, R34, R41, R42 and R47 side by side with the old text. Each difference is a rule moved to its one place (R14, R16, R28, R30, R31, R40, R47) or a restriction added. None was lost at the head. + - every "To decide" item of the old text is a question under "What is still open?" (`docs/design.md:543-657`); `grep -n -i 'to decide'` finds only the table cell at `docs/design.md:494` and `deny.toml:40`, both still right. +- **Open questions and the roadmap point to each other.** The fourteen headings of "What is still open?" (1.4, 1.5, 1.7, 3.1, 3.2, 3.5, 3.6, 3.7, 3.9, 4.2, 4.4, 5.1, 5.2, 5.3) match the list at `docs/roadmap.md:52-53`, and each of those roadmap steps names its section (`docs/roadmap.md:110,111,129,143,145,151,153,157,159,170,173,177,179,182`). +- **Commit messages in the range**: every change they name exists. + - c3311f6, 0fc8394, cebaf40: the decisions on menu items (R41), the extraction report (R16), the cache rule and CRL names (R47), the R34 cases, the roadmap 0.4 list. + - 8bdf261: headings as questions (`grep -n '^#' docs/design.md`), R31, R47 and R16 as single places, `CLAUDE.md`, README and reviewer prompt pointing to R31. + - 4a99ff1: "the only commands" and "an item of ours" in R41 (`docs/design.md:466-470`); the R29-only and `--json f` cases in R34 (`276-282`); "write nothing" in R30 (`208-210`); pointers to "Before 5.1" (`222-223,461-462`); the JSON file in the script exception (`95-96`); precedence of the cached list in R47 (`354-355`); Brainpool before 3.1 (`569-570`); no bold labels in R49. +- **PR #3 text**: "Done so far" names the decisions, the closing of requirement changes and the rewrite. It ends with "Draft. The current state and the next step are in the latest comment", which is true at the head. +- **Verdict comments** (`CLAUDE.md:32-37`): PR #3 carries a verdict for each of the four reviews of the range (F3), each followed by how it was closed. `sh scripts/check-public.sh --message ` exits 0 on the PR text and on each of the nine comments of the range; none holds a local path or an address. PR #2: verdict comments present. PR #1: none (0003-F5, predates the rule). +- **Roadmap marks**: 0.1, 0.2, 0.2.1 and 1.0 hold; nothing was marked in the range. `is_envelope` is at `src/lib.rs:10` with six test functions, none ignored. `src/` did not change. There is no other module or public function, so no scope drift in code. +- **Concrete references**: the LOTL address answers; the file is sequence number 398 with 43 pointers (`grep -o '...'`, `grep -o 'OtherTSLPointer>' | wc -l`), as `docs/design.md:330` says. `assert_cmd` 2.2.2 and `predicates` 3.1.4 match `Cargo.lock:21-22,95-96`. Requirement numbers cited in `README.md`, `CLAUDE.md`, the roadmap and the reviewer prompt exist in `docs/design.md` in the sense used, except the three pointers of F2. Laws and standards (Legge 4/2004, D.Lgs. 106/2018, Directive 2019/882, D.Lgs. 82/2022, EN 301 549, WCAG 2.2, ETSI EN 319 102-1, RFC 3161, RFC 5544) are cited in the same sense as before the rewrite. +- **Agent prompts**: `.claude/agents/coherence-auditor.md` is unchanged and agrees with `CLAUDE.md`. The reviewer prompt agrees with R16, R20, R29, R30 and R31 (`.claude/agents/fable-reviewer.md:28-45`). +- **Safety, accessibility, uninstall (R28–R43)**: still no code; nothing is claimed done; the placeholder in `src/main.rs` reads and writes nothing and is the recorded exception (`docs/design.md:540-541`). +- **Language rule**: all text added in the range is English. +- **Public-repository rule**: `sh scripts/check-public.sh --range tip HEAD` exits 0; the five commits and the audit commit have no-reply author addresses (`git log --format='%ae'`). `tests/corpus/` was not read. +- **Not re-checked**: the GitHub settings (branch protection, actions allowlist, secret scanning); the crates named as candidates in the architecture table (unchanged in the range). + +## Health + +Run on macOS arm64 at 4a99ff1, working tree clean. Script tests ran on a scratch copy (`git archive HEAD`) with failing `gh` and `rustup` stubs first in `PATH`. + +| 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); warnings for allowed licences not used yet (`Unicode-3.0`, `Zlib`, `deny.toml:21-22`) | +| `sh scripts/test-scripts.sh` | 178 passed, 0 failed | +| `sh scripts/test-cleanup.sh` | 79 passed, 0 failed, 0 skipped | +| `sh scripts/test-hooks.sh` | 24 passed, 0 failed | +| `sh scripts/check-public.sh --range tip HEAD` | exit 0 ("0 commits and the tree of 4a99ff1 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 4a99ff1 (PR #3) | all four jobs green | +| CI on `main` (8561ec5) | green, unchanged | + +The repository was not modified by the audit: `git status --porcelain` is empty before and after, no stash, HEAD still 4a99ff1. `cleanup.sh` was run with `--plan` only. Nothing was posted or changed on GitHub. The public LOTL file was downloaded once for F4 and for the numbers at `docs/design.md:330`; nothing about this project was sent. diff --git a/docs/audits/0009-2026-11-23.md b/docs/audits/0009-2026-11-23.md new file mode 100644 index 0000000..23eef5a --- /dev/null +++ b/docs/audits/0009-2026-11-23.md @@ -0,0 +1,201 @@ +# Coherence audit 0009 (2026-11-23) +Range: e025b10..a3ad768 (five commits on `step/0.4-writing-guide`, PR #3, 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 0008). + +The drift is small and only in documents. No code, script, hook or workflow changed in the range. `git diff --stat e025b10..HEAD` lists seven files: `docs/design.md`, `docs/roadmap.md`, `README.md`, `CLAUDE.md`, the two agent prompts and `tests/fixtures/README.md`. No claim about code is false. The findings of audit 0008 that asked for a change (F1, F2, F4, the 0.2.1 line of F6) are closed. Three new points concern the confirmation rules and the roadmap (F1 to F3). PR #3 still has no APPROVED verdict, and its head is not reviewed (F4). + +## Unfinished work + +`sh scripts/audit-status.sh` (exit 0): + +``` +== Audit cadence +commits since last audit: 5 (audit every 5) +last audit: e025b10 2026-11-23 audit: 0008 +AUDIT DUE + +== Rust +pinned Rust 1.100.0 is the latest stable + +== Unfinished local work +working tree clean +branch step/0.4-writing-guide: 0 unpushed, 0 not pulled +local branches not merged into main: + step/0.4-writing-guide +remote branches not merged into main: + origin/step/0.4-writing-guide + +== Markers in code +none + +== Leftovers (scripts/cleanup.sh --plan; run scripts/cleanup.sh to remove the local ones) +keep local branch (not merged): step/0.4-writing-guide +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, draft PR (not closed here): #3 updated 2026-11-23: Roadmap 0.4: writing guide +nothing to remove + +== GitHub +open pull requests: +#3 DRAFT step/0.4-writing-guide updated 2026-11-23: Roadmap 0.4: writing guide +last CI runs on main: +2026-11-23 completed/success: Guard the Windows skips; test the report with no red checks +2026-11-23 completed/success: CI +2026-11-22 completed/success: Remove --apply everywhere, close review and audit 0002 findings +``` + +- **Local work**: nothing uncommitted (`git status --porcelain` empty), no stashes, nothing unpushed (`git rev-parse HEAD origin/step/0.4-writing-guide` give the same commit), one worktree. +- **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. Audit 0008 was committed alone (e025b10). +- **PR #3** (draft, opened 2026-11-23 05:36 UTC, less than a day old, head a3ad768, 35 comments): + - What it is for: roadmap 0.4 (`docs/roadmap.md:36-54`): the writing guide, the rewrite of README, design, roadmap, `CLAUDE.md` and the agent prompts to it, the `rust-toolchain.toml` comment, the session-report line for a newer Rust, and the owner's requirement decisions of 2026-11-23. + - Done in this range: five commits, each closing the review of the one before (7179d7b closes the review of 4a99ff1 and audit 0008; then b3c6fb9, 0247ceb, bc18b75, a3ad768). They rename the terms (a "sensitive folder", a "risky run", an "ordinary run"), move pointers to R30, move the dialog helper rules into R38, and add open questions, with a new section "Before 1.6". + - Missing: + - an APPROVED verdict: none of the 35 comments holds one (F4); + - a review of the head a3ad768; + - the rewrite of `docs/roadmap.md`, `CLAUDE.md` and the agent prompts to `docs/writing.md`; + - the `[x]` mark at `docs/roadmap.md:36`, correctly absent. + - State comment: present and true. The latest comment (17:25 UTC) ends with "State: draft. This is the fifth commit since audit 0008, so the next step is coherence audit 0009, then a review by a new fable-reviewer agent." + - Still relevant: yes, it is the one open step. +- **CI job lists** (`gh run list --branch step/0.4-writing-guide`, `gh run view --json jobs`, `gh pr checks 3`): + + | Commit | Run | Result | + |---|---|---| + | e025b10 (audit 0008) | 45222341217 | success | + | 7179d7b | 45223765073 | success | + | b3c6fb9 | 45224955755 | success | + | 0247ceb | 45225808176 | success | + | bc18b75 | 45226835831 | cancelled | + | a3ad768 (head) | 45227514699 | Repository rules, Linux musl, macOS arm64, Windows gnu: all four `success`, read in the job list | + + The run on bc18b75 was cancelled, not red: a3ad768 was pushed four minutes later and replaced it; only its Windows job was cancelled, the other three had passed. The Windows job of the head was still running at the start of the audit and finished green at 17:31 UTC. GitGuardian passes. `main` is unchanged at 8561ec5, green. +- **Branches**: local `main` and the step branch; on GitHub `main`, `step/0.2-ci` and `step/0.2.1-confirmation-rules` (both merged, kept) and the step branch. Nothing stale. +- **Pull requests** (`gh pr list --state all`): #1 and #2 merged, #3 open as a draft. No other open PR. +- **Markers**: none (`grep` for `TODO`, `FIXME`, `todo!`, `unimplemented!`, `#[ignore` in `src`, `scripts`, `.githooks`, `.github`: only the pattern itself at `scripts/audit-status.sh:125`). +- **Leftovers**: `sh scripts/cleanup.sh --plan` (exit 0) prints the four lines shown above and "nothing to remove". +- **Tracked files that belong to the work, not the product**: none. `git ls-files` shows 39 files; the only reports are the eight under `docs/audits/`. + +## Findings + +### F1. `drift` (minor): "a wrong or empty number never confirms" is written as a rule only inside an open question +- `docs/design.md:566-567`, under "Before 1.6": "A wrong or empty number never confirms, for the files of a risky run (R28) or for the documents (R29)." The commit a3ad768 calls it "the fixed point" and says "R28, R19 and R30 do" cover it. +- `grep -n -i -e 'wrong' -e 'right number' docs/design.md` finds the rule in these places only: + - `207`, R30, dialog: "Confirm accepts only the right number"; + - `265`, `280`, `311-313`, R34: test cases (R29 at the terminal, the dialogs); + - `566`, `569`, `663-665`: open questions. +- For the terminal, R28 says "the user must type the number of files to process" (`docs/design.md:178`) and R29 "the user types the number of documents to write" (`192-193`). Neither says what a wrong or empty number does. R30's terminal item speaks only of yes/no questions (`197-199`). +- `docs/design.md:6-7` says each rule is written once, in a requirement. This one is implied by R28 to R30 and stated only in the section of open points. +- Change: state the sentence in R30 (or in R28 and R29) and let the question point to it. The meaning is not in doubt; no owner's decision is needed for the rule itself. What happens next (ask again or stop, exit code) stays an open question. + +### F2. `contradiction` (minor): roadmap 1.6 already plans a test that the question before 1.6 leaves open +- `docs/roadmap.md:122-123`: "Tests: the terminal and script cases of R34 ("Yes/no questions", "Scripts"), with a wrong or empty number at each typed count." The typed counts are R28 and R29 (`docs/roadmap.md:121-122`). +- `docs/design.md:569-570`: "Does R34 get the same test for the R28 number?" +- The roadmap answers yes while the design still asks. Also, the terminal cases "empty answer, `n`, wrong number" sit in the R34 item "Writing and undo" (`docs/design.md:265`), which the roadmap pointer does not name. +- Change: the owner answers the question; then R34 and roadmap 1.6 say the same. If the answer is yes, the question can go and R34 gets the case. + +### F3. `drift` (minor): no roadmap step names the two-step replace of cache files and the manifest +- PR #3, comment of 17:05 UTC (how the review of 4a99ff1 was closed): "The two-step replace is built in roadmap 1.7 (R31)." +- `docs/roadmap.md:127-130`, step 1.7: "`create_new`, next free name on race, removal of partial files, stays inside the folder (`..`, symbolic links), free-space check, re-check of originals." It does not name the temporary file and the rename of R31 (`docs/design.md:222-232`). +- `grep -n -i -e 'rename' -e 'two-step' -e 'two steps' -e 'replac' docs/roadmap.md` finds only lines 45 ("reports never replaced") and 190. Steps 3.5 (cache) and 5.1 (manifest) do not name it either. +- The questions "Before 1.7" do speak of the rename (`docs/design.md:575-578`), so 1.7 is the likely home. The roadmap text does not say so. +- Change: name the two-step replace in step 1.7 (or in the step the owner prefers) when the roadmap is rewritten. + +### F4. `unfinished`: PR #3 has no APPROVED verdict, and the head is not reviewed +- `GH_PROMPT_DISABLED=1 gh pr view 3 --json comments ` exits 0 on the PR text and on each of the ten comments of the range; none holds a local path or an address. PR #2: verdict comments present. PR #1: none (0003-F5, predates the rule). +- **Roadmap marks**: 0.1, 0.2, 0.2.1 and 1.0 hold; nothing was marked in the range. `is_envelope` is at `src/lib.rs:10` with six test functions (one for Windows only, one for Unix only), none ignored. `src/` did not change. There is no other module or public function, so no scope drift in code. +- **Concrete references added in the range**: R13's exit codes 0, 1 and 2 (`docs/design.md:64-65`), `--trust-lists` (R46, `351`), "audit 0008, F4" (this folder), `/usr/bin/osascript` and `/usr/bin/zenity` as examples of fixed paths. All exist in the sense used. Crates and versions did not change (`Cargo.toml`, `Cargo.lock` untouched). +- **Safety, accessibility, uninstall (R28–R43)**: still no code; nothing is claimed done; the placeholder in `src/main.rs` is the recorded exception (`docs/design.md:544-545`). +- **Language rule**: all text added in the range is English. +- **Public-repository rule**: `sh scripts/check-public.sh --range tip HEAD` exits 0; the five commits have no-reply author and committer addresses (`git log --format='%ae %ce'`). `tests/corpus/` was not read. +- **Not re-checked**: the GitHub settings (branch protection, actions allowlist, secret scanning); the LOTL numbers at `docs/design.md:333` (checked by audit 0008, text unchanged); the crates named as candidates in the architecture table (unchanged in the range). + +## Health + +Run on macOS arm64 at a3ad768, working tree clean. Script tests ran on a scratch copy (`git archive HEAD`) with failing `gh` and `rustup` stubs first in `PATH`. + +| Command | Result | +|---|---| +| `cargo fmt --check` | clean (exit 0) | +| `cargo clippy --all-targets -- -D warnings` | no issues (exit 0) | +| `cargo nextest run` | 5 passed, 0 skipped (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); warnings for allowed licences not used yet (`ISC`, `MIT`, `Unicode-3.0`, `Zlib`, `deny.toml:15,20-22`) | +| `sh scripts/test-scripts.sh` | 178 passed, 0 failed | +| `sh scripts/test-cleanup.sh` | 79 passed, 0 failed, 0 skipped | +| `sh scripts/test-hooks.sh` | 24 passed, 0 failed | +| `sh scripts/check-public.sh --range tip HEAD` | exit 0 ("0 commits and the tree of a3ad768 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 a3ad768 (PR #3) | all four jobs green (run 45227514699) | +| CI on `main` (8561ec5) | green, unchanged | + +The repository was not modified by the audit: `git status --porcelain` is empty before and after, no stash, HEAD still a3ad768. `cleanup.sh` was run with `--plan` only. Nothing was posted or changed on GitHub. diff --git a/docs/audits/0010-2026-11-24.md b/docs/audits/0010-2026-11-24.md new file mode 100644 index 0000000..e7d9c49 --- /dev/null +++ b/docs/audits/0010-2026-11-24.md @@ -0,0 +1,203 @@ +# Coherence audit 0010 (2026-11-24) +Range: 98bc03c..f8c0ac2 (five commits on `step/0.4-writing-guide`, PR #3, 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 0009). + +The drift is small and only in documents. No claim about code is false. The range rewrites `docs/roadmap.md` and `CLAUDE.md` to `docs/writing.md` and states the R30 rule on typed numbers. The two rewrites lost no step, requirement pointer, code span or negation (checked by comparison, see "Verified and found true"). Findings F1 to F3 of audit 0009 are closed. The head f8c0ac2 has no review yet, and the agent prompts are not rewritten yet (F1). One sentence about when the review happens does not match the practice on the PR (F2). + +## Unfinished work + +`sh scripts/audit-status.sh` (exit 0): + +``` +== Audit cadence +commits since last audit: 5 (audit every 5) +last audit: 98bc03c 2026-11-23 audit: 0009 +AUDIT DUE + +== Rust +pinned Rust 1.100.0 is the latest stable + +== Unfinished local work +working tree clean +branch step/0.4-writing-guide: 0 unpushed, 0 not pulled +local branches not merged into main: + step/0.4-writing-guide +remote branches not merged into main: + origin/step/0.4-writing-guide + +== Markers in code +none + +== Leftovers (scripts/cleanup.sh --plan; run scripts/cleanup.sh to remove the local ones) +keep local branch (not merged): step/0.4-writing-guide +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, draft PR (not closed here): #3 updated 2026-11-24: Roadmap 0.4: writing guide +nothing to remove + +== GitHub +open pull requests: +#3 DRAFT step/0.4-writing-guide updated 2026-11-24: Roadmap 0.4: writing guide +last CI runs on main: +2026-11-23 completed/success: Guard the Windows skips; test the report with no red checks +2026-11-23 completed/success: CI +2026-11-22 completed/success: Remove --apply everywhere, close review and audit 0002 findings +``` + +- **Local work**: nothing uncommitted (`git status --porcelain` empty), no stashes, one worktree, nothing unpushed (`git rev-parse HEAD origin/step/0.4-writing-guide` give f8c0ac2 twice). +- **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. Audit 0009 was committed alone (`git show --stat 98bc03c`: one file, `docs/audits/0009-2026-11-23.md`). +- **PR #3** (draft, opened 2026-11-23 05:36 UTC, one day old, head f8c0ac2, 45 comments): + - What it is for: roadmap 0.4 (`docs/roadmap.md:48-69`): the writing guide, the rewrite of README, design, roadmap, `CLAUDE.md` and the agent prompts, the `rust-toolchain.toml` comment, the "Rust" section of the session report, and the owner's requirement decisions. + - Done in this range: + - 770559d, 9779353, 818ba2d: R30 says that only the right number confirms; R34 and roadmap 1.5, 1.6, 1.7 and 2.3 follow; + - f14f725: `docs/roadmap.md` rewritten to the guide; + - f8c0ac2: `CLAUDE.md` rewritten to the guide; the comments and pointers that named its old headings follow the new ones. + - Missing: + - a review verdict on the head f8c0ac2 (F1); + - the rewrite of the two agent prompts (`docs/roadmap.md:50-51`, F1); + - the `[x]` mark at `docs/roadmap.md:48`, correctly absent. + - State comment: present and true. The latest comment (2026-11-24 11:04 UTC) ends with "State: draft. This is the fifth commit since audit 0009. Next steps: coherence audit 0010 and a review by a new fable-reviewer agent on this commit, then the rewrite of the agent prompts." + - Still relevant: yes, it is the one open step. +- **CI job lists** (`gh run list --branch step/0.4-writing-guide`, `gh run view --json jobs`, `gh pr checks 3`): + + | Commit | Run | Result | + |---|---|---| + | 98bc03c (audit 0009) | 45229043102 | success | + | 770559d | 45250339110 | cancelled | + | 9779353 | 45251015124 | cancelled | + | 818ba2d | 45251849479 | success | + | f14f725 | 45379762027 | success | + | f8c0ac2 (head) | 45380721870 | Repository rules, Linux musl, macOS arm64, Windows gnu: all four `success`, read in the job list | + + The two cancelled runs are not red: the next commit was pushed four and five minutes later and replaced each. The Windows job of the head was still running when the audit started and finished green at 11:09 UTC. GitGuardian passes. `main` is unchanged at 8561ec5, green. +- **Branches**: local `main` and the step branch; on GitHub `main`, `step/0.2-ci` and `step/0.2.1-confirmation-rules` (both merged, kept) and the step branch. Nothing stale. +- **Pull requests** (`gh pr list --state all`): #1 and #2 merged, #3 open as a draft. No other open PR. +- **Markers**: none. `grep -rnE 'TODO|FIXME|todo!|unimplemented!|#\[ignore' src scripts .githooks .github Cargo.toml` finds only the pattern itself at `scripts/audit-status.sh:126`. +- **Leftovers**: `sh scripts/cleanup.sh --plan` (exit 0) prints the four lines shown above and "nothing to remove". +- **Tracked files that belong to the work, not the product**: none. `git ls-files` shows 40 files; the only reports are the nine under `docs/audits/`. + +## Findings + +### F1. `unfinished`: the head is not reviewed, and the agent prompts are not rewritten +- `GH_PROMPT_DISABLED=1 gh pr view 3 --json comments green -> refactor) and before every commit". +- On PR #3 every review of the range names a commit that was already pushed. Committer times (`TZ=UTC git log --format='%h %cd'`) against the verdict comments: + + | Commit | Committed (UTC) | CI run created | Verdict posted | + |---|---|---|---| + | 770559d | 11-23 19:34:13 | 19:34:27 | 19:37:01 | + | 9779353 | 19:38:05 | 19:38:20 | 19:41:19 | + | 818ba2d | 19:43:00 | 19:43:15 | 19:46:15 | + | f14f725 | 11-24 10:32:37 | 10:58:13 | 11:00:36 | + +- `CLAUDE.md:30-38` (step 5) does not say whether the review comes before or after the commit. It asks for the approval before the PR is marked ready (`CLAUDE.md:63-65`), which the practice respects. +- The sentence is old: `git show 98bc03c:docs/roadmap.md` has "reviewed by the `fable-reviewer` agent, then committed". The rewrite kept it. No earlier audit reports it (`grep -i 'before every commit' docs/audits/*`: no line). +- Change: the owner chooses. Either the two texts say "each commit is reviewed after the push, before the PR is marked ready", or the practice changes. +- A note on what an audit can check: three of the four verdicts were posted about three minutes after the commit, and each lists nextest, clippy, fmt and the public check as run. The files and the PR show the verdicts, not how the reviewer was started. That each review was "a new fable-reviewer agent" rests on the comments alone. + +### F3. `minor`: the PR #3 description is behind the branch +- The section "Done so far" of the description (`gh pr view 3 --json body`) lists the guide, the README and the design rewrite. It does not name the rewrite of `docs/roadmap.md` (f14f725) or of `CLAUDE.md` (f8c0ac2), nor the R30 decision of 770559d. +- It still says "owner's decisions on requirements (what `check` writes, risky folders, ...)". R28 says "risky" never describes a folder (`docs/design.md:183-184`); `docs/roadmap.md:58` says "risky runs". Carried over from 0009-F6. +- The description ends with "Draft. The current state and the next step are in the latest comment", which is true. +- Change: update the description before the PR is marked ready. + +### F4. `minor`: texts that break `docs/writing.md` +New or changed in the range: +- `docs/design.md:268-273` (R34 "Writing and undo"): one sentence of about 77 words, edited in 9779353, 818ba2d and f14f725. +- `docs/roadmap.md:165-167` (1.6, tests from "Counting"): one sentence of about 43 words. `docs/roadmap.md:127-130` (1.1) and `218-221` (3.9): lists of 47 and 48 words in one sentence. `docs/roadmap.md:108-111` (0.5): 57 words. +- `CLAUDE.md:32`: "never give it my conclusions". `docs/writing.md:68` says "We use 'we' for the project". The sentence was "my" before the rewrite too. +- The commit message of f8c0ac2 says "Steps 1.0 and 1.1 put the requirement number at the end". `docs/roadmap.md:124-125` put it at the end of the title, in brackets, before the colon. The meaning is clear; the wording is loose. + +Carried over from 0009-F6, unchanged: +- `docs/design.md:6`: "in the requirement named in brackets". +- Bold labels at the start of sub-items (`docs/design.md:101,113,118`) and bold inside running text (`181-182`, `430`, `473`). +- Headings that are not questions: the fifteen `### Before x.y (...)` headings (`docs/design.md:559-689`) and "(proposal)" at `498`. `docs/writing.md:82-84` does not list them among the fixed formats. +- `docs/design.md:310-313` ("Several folders", 58 words) and `318-322` ("Dialogs", 75 words): single sentences. +- The agent prompts, not rewritten yet (F1): `.claude/agents/fable-reviewer.md:10` (134 characters), item 3 at `28-44` (a sentence of about 177 words), `.claude/agents/coherence-auditor.md:22` (142 characters). Line 3 of each prompt is front matter. + +Closed from 0009-F6: `CLAUDE.md` has no line over 100 characters, no bold and no long bullet; all its headings below the title are questions. `docs/roadmap.md` has no bold, question headings with an answer under each, and step 1.6 is split into items (`docs/roadmap.md:156-170`). The blank-line faults around "Phase 1" and between 0.3 and 0.4 are gone. No em dash or curly quote in `README.md`, `CLAUDE.md`, `docs/design.md`, `docs/roadmap.md`, `docs/writing.md` or the prompts (scan for U+2014, U+2018, U+2019, U+201C, U+201D: no line). + +### F5. `drift` (minor): some R34 items are named by no roadmap step +- `grep -n -o -E 'R34 "[^"]+"|R34 items [^.]*' docs/roadmap.md` finds pointers at lines 151, 153, 163, 164, 165, 168, 189 and 190 only. They cover "Counting", "Several folders", "Risky run at the terminal", "Yes/no questions", "Scripts" and, from "Writing and undo", the answers at the count and the `undo` cases. Step 5.2 names the dialogs' "R34 tests" (`docs/roadmap.md:244-245`); step 1.7 names the snapshot helper (`176`). +- No step names these items of R34 (`docs/design.md:268-315`): "`--plan`" (`281-282`), "What `check` writes" (`283-285`), "Extraction reports" (`286-292`), "Cache and manifest" (`293-299`), "Menu items" (`300-302`), "Time" (`314-315`), and from "Writing and undo" the cases "a file appearing between plan and write", "a symbolic link pointing outside" and "disk full" (`270-272`). +- The commit 818ba2d claims only that every case of "Counting" and "Several folders" has a step. That claim is true (checked case by case against `docs/roadmap.md:151-155,165-169,189` and 5.2). So this is not a false claim. After the range, the roadmap names R34 items for steps 1.5, 1.6 and 2.3 and not for the others, and a reader cannot tell whether the rest is planned. +- Also: `docs/roadmap.md:155` plans a "Test for R28: each kind of sensitive folder selected directly". R34 lists only the symbolic-link variant (`docs/design.md:312-313`), while `CLAUDE.md:176` says "Any change here needs the tests of R34". +- Change: when the steps 1.7, 2.3, 3.5, 3.7, 4.4 and 5.1 are next edited, name the R34 item each one tests. The owner decides whether the direct-selection test also goes into R34. + +### F6. `minor`: carried over +- From 0007-F8: `README.md:165` ("License") is a heading that is not a question and not a listed fixed format. +- From 0001-F12: `Cargo.toml:19-21` declares `assert_cmd` 2.2.2 and `predicates` 3.1.4; `tests/` holds only `fixtures/`, no `tests/*.rs`. +- From 0003-F6: no test fixes the choice that a branch just created at `main` is removed by `cleanup.sh`. + +### Follow-up of audit 0009 +- F1 (the rule on a wrong number stood only in an open question): closed. R30 states it at `docs/design.md:198-201`, with the owner's decision. The question "Before 1.6" keeps only what is open (`573-576`). +- F2 (roadmap 1.6 planned a test the design still asked about): closed. R34 has "Risky run at the terminal" (`docs/design.md:274-275`); roadmap 1.6 points to it (`docs/roadmap.md:163`); the question is gone. +- F3 (two-step replace named by no step): closed. `docs/roadmap.md:173`: "The two-step replace of cache files and the manifest: a temporary file, then a rename." +- F4 (no approval): partly closed, see F1. +- F5 (wrong statements in older commit messages): no change needed. +- F6 (writing): partly closed, see F4. +- F7: the "Rust" section line is closed (`docs/roadmap.md:53-54` names the section as the script prints it); the rest is in F6. + +### Verified and found true +- **The roadmap rewrite lost nothing** (f14f725, f8c0ac2 against 818ba2d). A script compared the two versions: + - the same 37 steps with the same marks; + - no requirement pointer lost (gained: R28 once, R34 five times); + - no code span lost except `design.md`, which became `docs/design.md`; + - "not" 10, "only" 9, "except" 1 before and after; "never" 5, then 6 at f8c0ac2. + The message of f14f725 says these counts are the same, which holds at f14f725. No line of `docs/roadmap.md` is longer than 96 columns, and no code span crosses a line. +- **The `CLAUDE.md` rewrite lost nothing** (f8c0ac2 against f14f725): the set of code spans is identical (`diff` of the sorted spans: no line); no requirement pointer lost; "not" 11 to 12, "never" 14 to 17, "only" 14 to 14. The one "except" became "The one exception is" (`CLAUDE.md:156`), as the message says. The GitHub settings, the cleanup rules, the review rules and the hook list read the same as before. +- **Old heading names are gone.** `git grep -n -e 'Coherence audits' -e 'Conventions' -e 'Way of working' -e '"Public repository'` outside `docs/audits/` finds nothing. The new pointers name headings that exist: + - "How do we keep long work from drifting?" (`CLAUDE.md:54`), named at `.githooks/pre-commit:10`, `scripts/audit-status.sh:9-10`, `scripts/cleanup.sh:2-3`; + - "What may never reach the public repository?" (`CLAUDE.md:98`), named at `.claude/agents/fable-reviewer.md:54-55`; + - "Which rules hold everywhere?" (`CLAUDE.md:140`), named at `docs/writing.md:6`. +- **Scripts and hook changed in comments only.** `git diff 98bc03c..HEAD -- scripts .githooks` shows three comment blocks and no other line. The script, cleanup and hook tests pass with the numbers the PR comment gives (178, 79, 24). +- **R30, R34 and the roadmap agree on answers.** R30: only the right number confirms; a wrong number, `y`, `n` and Enter alone never do (`docs/design.md:198-201`). R34: "Writing and undo" (`268-270`), "Risky run at the terminal" (`274-275`), "Extraction reports" (`287`), "Yes/no questions" (`316-317`), "Dialogs" (`318-320`). Roadmap 0.4 lists the decision (`docs/roadmap.md:61`); 1.6 tests it (`163-164`); 2.3 tests the `undo` answers (`190-191`). `CLAUDE.md:159-163,169-173` and `README.md:47-68,126-134` say the same. +- **Open questions and the roadmap point to each other.** The fifteen headings of "What is still open?" (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) match the list at `docs/roadmap.md:68-69`. Each of those steps names its section (`docs/roadmap.md:140,141,156,171,198,200,206,208,210,215,231,235,243,246,249`), with "question" or "questions" matching the number of items. +- **Commit messages in the range**: every change they name exists in the diff of that commit, apart from the loose wording noted in F4. The cross-references hold: "audit 0005-F3, 0009-F7" (this folder), "review of 818ba2d, m1" to "m5" (PR comment of 19:46 UTC), "findings F1 to F3 of audit 0009". +- **Verdict comments**: PR #3 carries a verdict for every reviewed commit of the range except the head (F1), each followed by how it was closed. `sh scripts/check-public.sh --message ` exits 0 on the PR description and on each of the ten comments of the range; none holds a local path or an address. PR #2: verdict comments present. PR #1: none (0003-F5, predates the rule). +- **Roadmap marks**: 0.1, 0.2, 0.2.1 and 1.0 hold; nothing was marked in the range. `is_envelope` is at `src/lib.rs:10` with six test functions (one for Windows only, one for Unix only), none ignored. `src/` did not change. There is no other module or public function, so no scope drift in code. +- **Requirement numbering**: the labels R1a to R49 are unchanged in the range; no requirement was added or removed. +- **Safety, accessibility, uninstall (R28–R43)**: still no code; nothing is claimed done; the placeholder in `src/main.rs` is the recorded exception (`docs/design.md:551-552`). +- **Language rule**: all text added in the range is English. +- **Public-repository rule**: `sh scripts/check-public.sh --range tip HEAD` exits 0; the five commits have no-reply author and committer addresses (`git log --format='%ae %ce'`). `tests/corpus/` was not read. +- **Not re-checked**: the GitHub settings (branch protection, actions allowlist, secret scanning, interaction limit); the workflow against roadmap 0.2 (`.github/workflows/ci.yml` unchanged in the range); the LOTL numbers at `docs/design.md:340`; the crates named as candidates in the architecture table; the laws and standards cited at `docs/design.md:410-417` (text unchanged in the range). + +## Health + +Run on macOS arm64 at f8c0ac2, working tree clean. Script tests ran on a scratch copy (`git archive HEAD`) with failing `gh` and `rustup` stubs first in `PATH`. + +| 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); warnings for allowed licences not used yet (for example `Zlib`, `deny.toml:22`) | +| `sh scripts/test-scripts.sh` | 178 passed, 0 failed | +| `sh scripts/test-cleanup.sh` | 79 passed, 0 failed, 0 skipped | +| `sh scripts/test-hooks.sh` | 24 passed, 0 failed | +| `sh scripts/check-public.sh --range tip HEAD` | exit 0 ("0 commits and the tree of f8c0ac2 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 f8c0ac2 (PR #3) | all four jobs green (run 45380721870) | +| CI on `main` (8561ec5) | green, unchanged | + +The repository was not modified by the audit: `git status --porcelain` is empty before and after, no stash, HEAD still f8c0ac2. `cleanup.sh` was run with `--plan` only. Nothing was posted or changed on GitHub. diff --git a/docs/design.md b/docs/design.md index 8b10a3c..3b1a76f 100644 --- a/docs/design.md +++ b/docs/design.md @@ -1,195 +1,248 @@ # SignSpector: requirements and design -Status: **draft**, to be completed with the author. Sections marked *To decide* are open. - -## The idea - -Offices receive and archive documents signed digitally (CAdES `.p7m`, detached `.p7s`) and -time-stamped (`.tsd`, `.m7m`), often nested (a `.p7m` inside a `.p7m`, a `.tsd` around a -`.p7m`). Opening them one by one is slow and tells little about the signatures. SignSpector -takes a folder, finds every such file, opens all the layers, checks signatures, certificates and -time stamps, and produces a report anyone can read. On request it saves the signed documents -beside the originals, ready to open. - -## Requirements - -### Finding files -- R1a. A name is an envelope when its extension is `.p7m`, `.p7s`, `.tsd` or `.m7m`, ignoring - case; purely lexical, any bytes allowed in the rest of the name (non-UTF-8 names on Linux). - *(done: `is_envelope`)* -- R1b. Walk a folder recursively; only regular files are checked with R1a (a folder named - `archivio.p7m` is not an envelope). -- *To decide*: a file named exactly `.p7m` (no stem) is not an envelope today: list it in the - report as skipped? Are stand-alone time-stamp responses `.tsr` an input format? -- R2. Unreadable folders are reported and skipped; the walk goes on. Symbolic links are not - followed and hidden folders (name starting with `.`) are skipped; both are listed in the - report, so nothing is left out silently. - -### Opening envelopes -- R3. Read CMS SignedData in BER, including indefinite lengths (common in real files), and in - base64 form. -- R4. Unwrap nested layers until the signed document is reached; report each layer. -- R5. RFC 5544 TimeStampedData (`.tsd`) and `.m7m` (MIME with signature and time stamp). -- R6. Detached `.p7s`: look for the signed file beside it. -- R7. A malformed file never stops the run: it becomes a "problem" line for that file (source wording in English, translated per R27). - -### Verifying -- R8. Each signature: digest of the content, signed attributes, signature (RSA PKCS#1 v1.5, - RSA-PSS, ECDSA P-256/P-384/P-521; SHA-1/256/384/512). -- R9. Signer certificate: validity at the reference time, key usage (non-repudiation), - qualified / QSCD flags. The **reference time** is a proved time only: the signature's time - stamp, or the time stamp of a `.tsd`/`.m7m` that contains the file (R5, R12). The - signing-time attribute is written by the signer and proves nothing: without a time stamp - the reference time is the time of the check, and the report shows the claimed time marked - "claimed, not proved". The same reference time is used by R48 and R49. -- R10. Chain to a CA of a **European trusted list** (R44–R48): the national list of the - certifier's country, reached through the EU List of Trusted Lists; optionally to the system - trust store, labelled "recognised by the system" (translated per R27). +Status: draft, completed with the owner step by step. Open points are listed at the end, under +"What is still open?", each with the roadmap step that needs the answer. + +Each rule is written once, in one requirement. Other places name that requirement in brackets +(R31) instead of repeating the rule. + +## What is SignSpector for? + +It saves opening signed files one by one. Offices receive and archive documents signed +digitally (CAdES `.p7m`, detached `.p7s`) and time-stamped (`.tsd`, `.m7m`). They are often +nested: a `.p7m` inside a `.p7m`, a `.tsd` around a `.p7m`. Opening them one by one is slow and +tells little about the signatures. + +SignSpector takes a folder and finds every such file. It opens all the layers and checks +signatures, certificates and time stamps. Then it writes a report anyone can read. On request it +saves the signed documents beside the originals, ready to open. + +## What must it do? + +### Which files does it look at? +- R1a. A name is an envelope when its extension is `.p7m`, `.p7s`, `.tsd` or `.m7m`, in any + letter case. The test is on the name only, and any bytes are allowed in the rest of the name + (non-UTF-8 names on Linux). *(done: `is_envelope`)* +- R1b. The folder is walked recursively. Only regular files are tested with R1a: a folder named + `archivio.p7m` is not an envelope. +- R2. Some entries are not walked or not checked, and each is listed in the report, so nothing + is left out silently: + - an unreadable folder is reported and skipped, and the walk goes on; + - a symbolic link met during the walk, to a file or to a folder, is not followed (a selected + folder is different: R19); + - a hidden folder (name starting with `.`) is skipped. + +### How does it open an envelope? +- R3. It reads CMS SignedData in BER, including indefinite lengths (common in real files), and + in base64 form. +- R4. It unwraps nested layers until the signed document is reached, and reports each layer. +- R5. It reads RFC 5544 TimeStampedData (`.tsd`) and `.m7m` (MIME with signature and time + stamp). +- R6. For a detached `.p7s`, it looks for the signed file beside it. +- R7. A malformed file never stops the run. It becomes a "problem" line for that file (source + text in English, translated per R27). + +### What does it verify? +- R8. Each signature: the digest of the content, the signed attributes, and the signature (RSA + PKCS#1 v1.5, RSA-PSS, ECDSA P-256/P-384/P-521; SHA-1/256/384/512). +- R9. The signer's certificate: validity at the reference time, key usage (non-repudiation), + qualified and QSCD flags. + - The reference time is a proved time only: the signature's time stamp, or the time stamp + of a `.tsd` or `.m7m` that contains the file (R5, R12). + - The signing-time attribute is written by the signer and proves nothing. Without a time + stamp, the reference time is the time of the check, and the report shows the claimed time + marked "claimed, not proved". + - R48 and R49 use the same reference time. +- R10. The chain must reach a CA of a European trusted list (R44–R48): the national list of + the certifier's country, reached through the EU List of Trusted Lists. Optionally it may reach + the system trust store, labelled "recognised by the system" (translated per R27). - R11. Countersignatures. -- R12. Time stamps (RFC 3161): imprint matches, TSA signature and chain valid. -- Revocation: R49. *To decide*: Brainpool curves? Download of missing intermediates (AIA)? - -### Output -- R13. Console summary per file, in the user's language (R27), with colours; exit codes 0 all fine / 1 problems / - 2 cannot run. -- R14. HTML report (one self-contained file) in each analysed folder, covering that folder - only, or at `--report ` (one file for the whole run). -- R15. `--json ` with the same information, for scripts. -- *To decide*: layout and content of the report (start from the old tool's report as a sketch?). - -### Extracting -- R16. `check` (the default) writes nothing but the report. `extract` writes the signed - documents beside the originals (`Relazione.pdf.p7m` -> `Relazione.pdf`) after the two - confirmations of R28 and R29: typing the number of documents is the safeguard. -- R17. Never overwrite: same content already there -> nothing to do; different content -> +- R12. Time stamps (RFC 3161): the imprint matches, and the TSA signature and chain are valid. +- Revocation is R49. + +### What does it show and write after an analysis? +- R13. A console summary per file, in the user's language (R27), with colours (R35). Exit codes: + 0 all fine, 1 problems found, 2 cannot run. +- R14. An HTML report (one self-contained file) in each analysed folder, covering that folder + 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.** + - `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` -> + `Relazione.pdf`) after the two confirmations of R28 and R29. Typing the number of documents + is the safeguard. + - An extraction always writes its own report, and its JSON file when `--json` is given, so + that `undo` has the list of documents (R33). `--no-report` does not apply to it (owner's + decision, 2026-11-23). + - A `check` run writes documents in one case only: an extraction chosen at the interactive + end of run (R20), which goes through R29. + - How every file is created, and which files may ever be replaced, is R31. + +### How does it name extracted documents? +- R17. Never overwrite. The same content already there: nothing to do. Different content: `Relazione (1).pdf`. Originals are never modified, moved or renamed. -- R18. Name without a usable extension: guess it from the content (PDF, ZIP-based office - formats, XML, images). - -### Using it -- 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 after a person confirms. Where the person is decides how (R30): - - **at a terminal**: before analysing, a yes/no question (R28); for files found in a folder - the user types the number (risky folder, R28; documents to write, R29); `undo`, - `install-menu`, `uninstall-menu`, `uninstall` change only what the tool itself made and - ask a yes/no question. Yes/no questions default to No, Enter alone cancels, and the - answers and the default are written out in words in the user's language (R35, R27); - - **from the context menu** (`--interactive`): the same confirmations (same number to type, - same default) in a native dialog (R38), with the summary of R30, focus on Cancel; - - **from a script** (no terminal, no `--interactive`): nobody can answer, so they refuse. - - `check` and `extract` take one or more folders (several can be selected in the file manager). - They are counted and confirmed together: one summary with a row per folder (path and number - of files to process) and the total, one question for all. The number typed is the total. A - single risky folder makes the whole run risky, and the 10,000-envelope limit applies to the - total (R28). A folder with no envelopes is shown with 0; if all are empty the run stops. - The same folder given twice (also spelt differently: letter case, a symbolic link, a - trailing slash), or a folder inside another selected one, is counted once, under the outer - folder; the summary says so, and its envelopes go in the outer folder's report. - - `--interactive` says that a person is there even without a terminal: questions come in - native dialogs (R30) and the run ends with the interactive end of run (R20). The - context-menu entries and the Windows uninstall entry (R42) pass it. With a terminal the - questions stay in the terminal and R20 still applies. If no dialog can be shown (no - desktop session), `--interactive` refuses with exit code 2, like a script. - - `--plan` shows what the command would do and stops before doing it. It never writes - anything, not even the report. - - `check --plan` only counts (R28; no envelope is opened) and prints the summary: no - question, allowed everywhere, also from a script on a risky folder. - - `extract --plan` builds the write plan of R29, which opens every envelope, so it asks the - R28 question first (console or dialog), and from a script runs on an ordinary folder and - refuses a risky one, like `check`. - - For the other commands it lists the items, with no question, also from a script. - - `check` changes nothing but the report. - Options: `--open`, `--report`, `--no-report`, `--report-lang `, `--json `, - `--threads`, `--offline`, `--trust-lists `, `--trust-list `, - `--lang `, `--interactive`, `--plain`, `--no-color`, `--plan`. Help translated (R27). -- R20. Interactive end of run (double-click on Windows, context menu, `--interactive`): after - the analysis, offer to view the report or to extract; extraction goes through the write - plan and its confirmation (R29) and reuses the analysis already done. -- R21. `install-menu` / `uninstall-menu` (plan and yes/no question, R19) for the file manager's - context menu: Windows per-user registry keys (no admin, no PowerShell); macOS Quick Actions; - Linux Nautilus script and Dolphin service menu. Full removal: `uninstall` (R40–R43). - -### Non-functional -- R22. One self-contained executable per platform, pure Rust dependencies. -- R23. Files processed in parallel, output printed in a stable order. +- R18. A name without a usable extension gets one guessed from the content (PDF, ZIP-based + office formats, XML, images). +- R32 has the rules for valid names. + +### How is it used? +- 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 + after a person confirms. How a person confirms, at a terminal, in a dialog or not at all + from a script, is R30. The one exception: `check` in an ordinary run from a script writes + its report (HTML and JSON) and the cache with no question (R16, R30). + - A number is typed only for files found in a folder: the files to process in a risky run + (R28) and the documents to write (R29). `undo`, `install-menu`, `uninstall-menu` and + `uninstall` change only what the tool itself made, and ask a yes/no question (R30). + - Several folders. `check` and `extract` take one or more folders (several can be + selected in the file manager). They are counted and confirmed together: + - one summary with a row per folder (path, number of files to process, number of files of + any kind) and the totals, and one question for all. The number typed is the total; + - when the run is risky (R28), the summary says why: the kind of sensitive folder, or the + 10,000-file limit; + - a folder with no envelopes is shown with 0; if all are empty, the run stops; + - the same folder given twice (also spelt differently: letter case, a symbolic link, a + trailing slash), or a folder inside another selected one, is counted once, under the + outer folder. The summary says so, and its envelopes go in the outer folder's report; + - a selected folder that is a symbolic link is resolved, then counted and judged like any + other folder (R28). + - `--interactive` says that a person is there even without a terminal: questions come in + native dialogs (R30) and the run ends with the interactive end of run (R20). The + context-menu entries and the Windows uninstall entry (R42) pass it. With a terminal, the + questions stay in the terminal and R20 still applies. If no dialog can be shown (no + desktop session), `--interactive` refuses with exit code 2, like a script. + - `--plan` shows what the command would do and stops before doing it. It writes nothing, + not even the report or the cache, and downloads nothing: it uses the embedded lists and + those already in the cache. + - `check --plan` only counts (R28; no envelope is opened) and prints the summary. It asks + no question and runs everywhere (R30). + - `extract --plan` builds the write plan of R29, which opens every envelope. So it asks the + R28 question first, and from a script it behaves like `check` (R30). It also says which + trusted lists a real run would download (R45). + - For the other commands it lists the items, with no question (R30). + - Options: `--open`, `--report`, `--no-report`, `--report-lang `, `--json `, + `--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`). + 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 + free name, R31) with the analysis and the documents written, and `undo` uses that one (R33). + - With `--json`, it also writes a second JSON file beside the first. + - After `check --no-report` there is no first report: the extraction report is the only one. +- R21. `install-menu` and `uninstall-menu` (plan, R19; yes/no question, R30) add and remove the + file manager's context menu: Windows per-user registry keys (no admin, no PowerShell), macOS + Quick Actions, a Linux Nautilus script and Dolphin service menu. Full removal: `uninstall` + (R40–R43). + +### How is it built and released? +- R22. One self-contained executable per platform, with pure Rust dependencies. +- R23. Files are processed in parallel, and the output is printed in a stable order. - R24. Targets: Windows x86_64, macOS arm64 + universal, Linux x86_64 static (musl). -- R25. Linux packages: `.deb`, `.rpm` and a generic `.tar.gz` (static musl binary, works on - any distribution). Built on the Mac from the musl binary with `cargo-deb` and - `cargo-generate-rpm` (pure Rust, no dpkg/rpmbuild needed). -- R26. Versioning: SemVer starting from `0.1.0`; `0.x` while behaviour and options may still - change, `1.0.0` when the tool is ready to replace the old one in production. The old tool's +- R25. Linux packages: `.deb`, `.rpm` and a generic `.tar.gz` (static musl binary, works on any + distribution). They are built on the Mac from the musl binary with `cargo-deb` and + `cargo-generate-rpm` (pure Rust, no dpkg or rpmbuild needed). +- R26. Versioning: SemVer starting from `0.1.0`. `0.x` while behaviour and options may still + change; `1.0.0` when the tool is ready to replace the old one in production. The old tool's numbering is not continued. Every release is a git tag `vX.Y.Z`. -### Languages -- R27. The interface (console messages, `--help`, HTML report, JSON field values meant for - people, user guide) is translated. Language = the one chosen by the user (`--lang it`, - or a saved preference), otherwise the operating system's language, otherwise English. - Source language English; first translation Italian; more can be added without code changes. -- *To decide*: translation mechanism (e.g. Fluent `.ftl` files embedded in the executable, or - `rust-i18n`), OS language detection (`sys-locale`), where the preference is saved, how - dates and numbers are formatted per language. -- The report is written in the interface language by default; `--report-lang ` writes it - in another one (for example to send it to an office abroad). - -### Confirmation and write safety -Nothing is ever processed right after a person chooses a folder, and nothing is written -without a second, separate confirmation. Writing never replaces an existing file. A folder -named in a script has no person to ask: an ordinary folder is analysed (`check` writes only the -report), a risky one is refused (only counted by `check --plan`), and nothing is written -(R30). - -- R28. **Confirm before analysing.** After the folders are chosen the tool only counts (no - envelope is opened) and asks, default No (Enter alone cancels): - folder, number of envelopes, total size, number of subfolders, unreadable folders that will - be skipped. Zero envelopes: say so and stop. **Risky folder**: root of a drive or volume, - the user's home, Desktop, Documents, system folders (`C:\Windows`, `Program Files`, - `/System`, `/usr`, `/etc`...), network share roots, or **more than 10,000 envelopes**: a - stronger warning and the user must type the number of envelopes. Every path-based kind of - risky folder is judged on the path after resolving symbolic links. -- R29. **Confirm before writing.** Extraction first builds the complete write plan and shows +### Which languages does it speak? +- R27. The interface is translated: console messages, `--help`, HTML report, JSON field values + meant for people, user guide. + - The language is the one chosen with `--lang it`, otherwise the operating system's language, + otherwise English. + - No preference is saved. A command to save one can be added later, with its plan and + question (R30). + - Source language English; first translation Italian; more can be added without code + changes. + - The report is written in the interface language by default. `--report-lang ` writes it + in another one, for example to send it to an office abroad. + +### How does it protect the user's files? +No folder is processed right after a person chooses it: the tool counts first and asks (R28). +No document is written without a second, separate confirmation on the full write plan (R29). +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 + 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 + skipped. The interface calls the envelopes "files to process". Zero envelopes: it says so and + stops. + - A risky run gets a stronger warning, and the user must type the number of files to process. A + run is risky when one chosen folder is a sensitive folder: the root of a drive or volume, the + user's home, Desktop, Documents, a system folder (`C:\Windows`, `Program Files`, `/System`, + `/usr`, `/etc`...) or a network share root. It is also risky when the folders hold more than + 10,000 files of any kind in all, subfolders included (owner's decision, 2026-11-23). A run + that is not risky is an ordinary run. "Risky" and "ordinary" always describe the whole run, + never one folder. + - The 10,000 count covers the regular files of the folders the walk visits (R2). Files in + 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 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 + (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.** - - Terminal (`std::io::IsTerminal` on input and output): questions in the console (R28, R29, - R19). - - Context menu: no terminal, started with `--interactive`: the same confirmations in a native - dialog (R38), with a shorter summary than the console. The dialog lists every selected - folder with its number of files to process (envelopes to analyse, R28; documents to write, - R29), the total and the operation proposed, then asks the question. When a number is - required (R28 risky folder, R29) it is typed in a text field and Confirm accepts only the - right number; otherwise the dialog is a yes/no question. In every dialog the focus starts on - Cancel; Enter alone and closing the window cancel; no time limit. + - 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 + Enter alone cancels. A typed number confirms only if it is the right one. Any other answer + (a wrong number, `y`, `n`, Enter alone) never confirms. This holds for the files to process + of a risky run (R28) and for the documents to write (R29). The owner decided on 2026-11-23 + that only the right number confirms and that any other answer never confirms. The answers + and the default are written out in words in the user's language (R35, R27). + - Context menu (no terminal, started with `--interactive`): the same confirmations, with the + same number to type and the same default, in a native dialog (R38), with a shorter summary + than the console. + - The dialog lists every selected folder with its number of files to process (envelopes to + analyse, R28; documents to write, R29), the total, the reason when the run is risky + (R19) and the operation proposed. Then it asks the question. + - When a number is required (risky run, R28; R29), it is typed in a text field, and Confirm + accepts only the right number. Otherwise the dialog is a yes/no question. + - In every dialog the focus starts on Cancel. Enter alone and closing the window cancel. + There is no time limit. - Script (no terminal, no `--interactive`): `extract`, `undo`, `install-menu`, - `uninstall-menu`, `uninstall` and `check` on a risky folder (R28) stop with exit code 2 - and say that a person must confirm. A `y` or a number arriving on a pipe is not a - confirmation. Only `check` on an ordinary folder, `check --plan`, `extract --plan` on an - ordinary folder and `--plan` of `undo`, the menus and `uninstall` (a list) run. - "Terminal" means both input and output are a terminal: with output redirected - (`| tee log`, `> file`) the run counts as a script. -- R31. **Never overwrite, never write outside.** - - In code, writing 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. - - Every file is created with `OpenOptions::create_new(true)`: the OS refuses if the name - exists, even if the file appeared after the plan; then the next free name `(2)`, `(3)`... - is used. A partly written file (error, disk full) is removed, only if we created it. - - Before writing, each original is re-checked against the analysis (size, mtime, SHA-256); - if the folder changed, the plan is rebuilt and confirmed again. - - Every target must stay inside the selected folder its envelope was found in, after + `uninstall-menu`, `uninstall`, and `check` in a risky run (R28) stop with exit code 2, + write nothing, and say that a person must confirm. A `y` or a number arriving on a pipe is + 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. + - 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. + - Every file the tool writes is created with `OpenOptions::create_new(true)`: documents, + reports, JSON files, menu items and temporary files. The OS refuses if the name exists, even + if the file appeared after the plan. A cache file and the manifest are created that way under + a temporary name, and reach their own name only by the rename described below, also the + first time. + - When the name is taken: a document, report or JSON file takes the next free name (`(1)`, + `(2)`...); a menu item is reported and left (R41). How this applies to registry keys and + `.workflow` folders is still open (question "Before 5.1"). + - Only two kinds of file are ever replaced: the tool's own cache files (R47) and its + install manifest (R41). They are replaced in two steps. The new content is written with + `create_new` under a temporary name in the same folder; then that file is renamed over the + old one. The tool never follows a symbolic link there, and it refuses a name that exists and + is not a regular file. Nothing is ever written in place. + - A partly written file (error, disk full) is removed, only if the tool created it. + - Before writing, each original is re-checked against the analysis (size, mtime, SHA-256). If + the folder changed, the plan is rebuilt and confirmed again. + - Every document must stay inside the selected folder its envelope was found in, after 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. + - 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 - valid on **Windows, macOS and Linux at the same time**, and on FAT32/exFAT file systems, - whatever system the tool runs on (archives move between systems): + 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 U+0000–U+001F and U+007F; trailing dots and spaces; leading spaces; - reserved Windows names, with or without extension and in any case: `CON`, `PRN`, `AUX`, @@ -199,192 +252,261 @@ report), a risky one is refused (only counted by `check --plan`), and nothing is - invalid UTF-8 or unpaired surrogates are replaced; names are stored in Unicode NFC; - length: at most 255 UTF-8 bytes and 255 UTF-16 units per component, cut without breaking a character or the extension; - - collisions are checked **case-insensitively and normalization-insensitively** (NTFS and - APFS default are case-insensitive; APFS treats NFC/NFD as the same name), so two - documents never compete for "names" that the file system sees as equal; + - collisions are checked case-insensitively and normalization-insensitively (NTFS and the + 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 records every file written with its SHA-256. - `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 (R19); never - from a script (R30). -- R34. **Proof by tests.** A shared test helper snapshots the whole folder (paths + SHA-256) +- 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) before and after every end-to-end test: originals identical, nothing changed but the - confirmed plan. Dedicated tests: empty answer, `n`, wrong number; file appearing between - plan and write; names with `..`, reserved names, forbidden characters, NFC/NFD and case - collisions, over-long names; symbolic link pointing outside; disk full (simulated); - `undo` with a modified file. Confirmation (R19, R28–R30): - - from a script: every changing command, `check` and `extract --plan` on a risky folder, - and `--interactive` without a desktop refused with exit 2; `check` on an ordinary folder, - `check --plan` anywhere, `extract --plan` on an ordinary folder and `--plan` of `undo`, - the menus and `uninstall` run without a question; output redirected counts as a script; - - `--interactive` with a terminal keeps the questions in the terminal; - - `--plan` writes nothing, not even the report; - - time: a back-dated signing-time attribute changes no verdict; without a time stamp the - report says "claimed, not proved" (R9); - - yes/no question: Enter alone cancels, `y` on a pipe is refused, a number is not a yes; - - several folders: the total is typed, one risky folder makes the run risky, the 10,000 - limit applies to the total, all folders empty stop the run, overlaps (also by letter - case, symbolic link, trailing slash) are counted once, one report per selected folder - that is not inside another, a symbolic link to a risky folder is risky; - - dialogs: when a number is required only the right one confirms, yes/no dialogs default - to Cancel, the focus starts on Cancel, Enter alone and closing the window cancel, a wrong - number does not confirm, every selected folder with its count, the total and the - operation are shown; a fake dialog helper placed first in `PATH` is not used, and a - folder name with quotes or script code is shown as text, never run. - - How confirmed runs are tested without a bypass: the public confirmation has two - constructors only, terminal and dialog, which take no input source: they open the terminal - or the dialog themselves and check `IsTerminal` inside. The core that turns answers into a - `ConfirmedPlan` is `pub(crate)`; the test answer source is a `#[cfg(test)]` item that calls - it, so it exists only in the library's own unit tests (`tests/*.rs` cannot see it) and the - compiler enforces R31. Cases that need confirmed writes (file appearing between plan and - write, disk full) are library unit tests or pseudo-terminal tests; the folder-snapshot - helper serves both. The executable is tested end to end under a pseudo-terminal (Unix pty, - Windows ConPTY) and for its refusals; the dialogs through the OS accessibility interface - where it can be driven, by hand otherwise (R39). There is no environment variable, hidden - option or build flag that confirms. - -### European trusted lists -Signatures may come from any EU/EEA country (Italy, Romania, France...). Trust is anchored in -the EU **List of Trusted Lists** (LOTL, `https://ec.europa.eu/tools/lotl/eu-lotl.xml`, -signed by the European Commission). It points to each national trusted list and names the -certificates that sign it (checked 2026-11-22: LOTL no. 398, 43 pointers: EU-27, Iceland, + confirmed plan. + - Writing and undo (R29, R31, R32, R33): at the count of documents (R29), an empty answer, + `y`, `n` or a wrong number writes nothing. At the `undo` question, an empty answer or `n` + removes nothing. Also tested: + - a file appearing between plan and write; + - names with `..`, reserved names, forbidden characters, NFC/NFD and case collisions, + over-long names; + - a symbolic link pointing outside; + - disk full (simulated); + - `undo` with a modified file, and `undo` on a report that records no document. + - Risky run at the terminal (R28, R30): an empty answer, `y`, `n` or a wrong number starts + no analysis. + - Scripts (R30): every changing command, `check` and `extract --plan` in a risky run, and + `--interactive` without a desktop are refused with exit 2. `check` in an ordinary run, + `check --plan` in any run, `extract --plan` in an ordinary run and `--plan` of `undo`, the + menus and `uninstall` run without a question. Output redirected counts as a script. + `--interactive` with a terminal keeps the questions in the terminal. + - `--plan` (R19): it writes nothing, not even the report or the cache, and downloads nothing; + `extract --plan` names the lists a real run would download. + - What `check` writes (R16): only its report is added to the folder, and nothing with + `--no-report`. An existing report or JSON file, also one named with `--report` or `--json`, + is not replaced: the new one gets the next free name. + - Extraction reports (R16, R20, R33): at the interactive end of run, documents are written + only through R29: any answer other than the right number writes none (R30), and declining + writes none. An extraction there writes a second report, and with `--json` a second JSON + file, without touching the first. `undo` on the second report removes the documents. + `extract --no-report`, with and without `--json f`, follows the open question on it + ("Before 4.4"): either it writes the extraction report (and `f`), or it is refused with + exit 2 and writes nothing. + - Cache and manifest (R31, R47): end-to-end tests point the cache to a temporary folder, + never the user's real one. A file in the cache folder under a name the tool does not derive + is never replaced. A symbolic link, a folder or another non-regular file at one of the + tool's own names (cache or manifest) is refused, never followed. A CA whose name holds + `../` or a separator gives a cache file named only by the hash, inside the folder. + Snapshots of the config and cache folders around `install-menu`, `uninstall-menu` and a list + refresh show that only the manifest and the cache files changed. + - Menu items (R41): `install-menu` run twice changes nothing. A foreign item with the same name + is reported, left, never enters the manifest, and `uninstall` does not remove it. After a + lost manifest, our marked items are recognised. + - Counting (R19, R28): the summary shows both counts in each row and in the totals, and the + reason for a risky run; the dialog shows the reason. More than 10,000 files of any kind + (subfolders included) is risky even with few envelopes, and the number typed is the files to + process: exactly 10,000 is not risky, 10,001 is, also as a total over several folders. Files + in hidden folders, behind symbolic links met during the walk or in unreadable folders are not + counted; a selected folder that is a symbolic link is resolved and counted; overlaps count + once. + - Several folders (R19, R28): the total is typed. One sensitive folder makes the whole run + risky. All folders empty stop the run. Overlaps (also by letter case, symbolic link, + trailing slash) are counted once. There is one report per selected folder that is not inside + another. Each kind of sensitive folder makes the run risky, selected directly or through a + symbolic link (owner's decision, 2026-11-24). + - Time (R9): a back-dated signing-time attribute changes no verdict; without a time stamp the + report says "claimed, not proved". + - Yes/no questions (R30): Enter alone and `n` cancel, `y` on a pipe is refused, a number is + not a yes. + - Dialogs (R30, R38): + - when a number is required, only the right one confirms; + - a wrong number does not confirm; + - yes/no dialogs default to Cancel; + - in every dialog the focus starts on Cancel; + - Enter alone and closing the window cancel; + - every selected folder with its count, the total and the operation are shown; + - a fake dialog helper placed first in `PATH` is not used; + - a folder name with quotes or script code is shown as text, never run. + + How are confirmed runs tested without a bypass? The public confirmation has two constructors + only, terminal and dialog, which take no input source: they open the terminal or the dialog + themselves and check `IsTerminal` inside. The core that turns answers into a `ConfirmedPlan` + is `pub(crate)`. The test answer source is a `#[cfg(test)]` item that calls it, so it exists + only in the library's own unit tests (`tests/*.rs` cannot see it), and the compiler enforces + R31. Cases that need confirmed writes (a file appearing between plan and write, disk full) + are library unit tests or pseudo-terminal tests; the folder-snapshot helper serves both. The + executable is tested end to end under a pseudo-terminal (Unix pty, Windows ConPTY) and for + its refusals. The dialogs are tested through the OS accessibility interface where it can be + driven, by hand otherwise (R39). There is no environment variable, hidden option or build + flag that confirms. + +### Which trusted lists does it use? +Signatures may come from any country on the EU List of Trusted Lists (LOTL, +`https://ec.europa.eu/tools/lotl/eu-lotl.xml`, signed by the European Commission): Italy, +Romania, France and the others. The LOTL points to each national trusted list and names the +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 - certificates (published in the Official Journal of the EU). A national list is used only if - its XAdES signature verifies against the certificates the LOTL names for that country; the - LOTL only if it verifies against the embedded Commission certificates. Italy is one country - among the others. The repository stores no trusted list: the release build downloads the - current LOTL and the Italian list and embeds them, so the tool works offline out of the box; - at the first run with network the tool refreshes them into its cache, which then takes - precedence (R47). + 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 + LOTL names for that country. Italy is one country among the others. + - The repository stores no trusted list. The release build downloads the current LOTL and the + Italian list and embeds them, so the tool works offline out of the box. At the first run with + 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 files (`C=` of the issuing CA) and loads only those lists: from the cache if still valid, - otherwise downloaded. The summary before confirmation names them, for example "signatures + 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` / `it,ro,fr`; `--trust-list ` - loads a list by hand; `--offline` uses only the embedded copies and the cache. A missing 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.** Lists (and the CRLs of R49) are cached in the SignSpector cache folder and - refreshed when their own `NextUpdate` date passes; `uninstall` removes the cache (R40). +- 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. + - The cache folder is the operating system's standard one (R42); no option moves it. Tests move + it only through the system's own variables (`HOME`, `XDG_CACHE_HOME`; Windows: question + "Before 3.5", open). + - The tool uses only names it derives itself: one fixed name per list, and for a CRL the + SHA-256 of its CA certificate (partitioned CRLs: question "Before 3.9"). A name is never text + 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 - history in the list (a service withdrawn later still validates an earlier signature). A + 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). -- Cost: verifying XAdES needs XML canonicalisation (exclusive C14N) and XML signature - verification; no mature pure-Rust library exists, so it is written here, test first, as - carefully as the BER reader. - R49. **Revocation without a query per signature.** Network traffic grows with the number of - certificates, never with the number of files: 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. - - **Reference time**: the proved time of R9 (a time stamp), otherwise the time of the check. - - **Revocation data inside the signature** (CAdES -LT/-LTA) is used only if its own - signature verifies against the issuing CA or an authorised OCSP responder and it was - issued after the reference time; otherwise it is ignored and the CA's CRL is used. - - **The CA's CRL**: fetched only once the chain reaches a CA of a trusted list, from its - distribution point, `http` or `https` only (redirects too), with limits on size and time; - its signature and issuer are verified before it is used or cached. It answers when it was - issued after the reference time; when the reference time is the time of the check, a CRL - inside its validity (`thisUpdate` <= now < `nextUpdate`) answers. Cached in the - SignSpector cache folder until its `nextUpdate` (R47; removed by `uninstall`, R40). OCSP - only when the CA publishes no CRL. - - **Verdicts**: + 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"). + - The reference time is the proved time of R9 (a time stamp), otherwise the time of the + check. + - Revocation data inside the signature (CAdES -LT/-LTA) is used only if its own signature + verifies against the issuing CA or an authorised OCSP responder, and it was issued after + the reference time. Otherwise it is ignored and the CA's CRL is used. + - The CA's CRL is fetched only once the chain reaches a CA of a trusted list. It comes + from its distribution point, `http` or `https` only (redirects too), with limits on size and + time. Its signature and issuer are verified before it is used or cached. It answers when it + was issued after the reference time. When the reference time is the time of the check, a + CRL inside its validity (`thisUpdate` <= now < `nextUpdate`) answers. It is cached until its + `nextUpdate` (R47). OCSP is used only when the CA publishes no CRL. + - The verdicts are: - "not revoked"; - "revoked on ", before a proved reference time (a time stamp): invalid; - "revoked on ", after the time stamp: valid when signed, and the report shows the revocation date; - revoked, but the signature has no time stamp: "cannot be determined: no proof the signature is older than the revocation" (as ETSI EN 319 102-1), never "invalid"; - - "cannot be determined" also when the certificate has expired and the CRL no longer - lists expired certificates (a CRL answers for an expired certificate only if issued - before its `notAfter` or marked ExpiredCertsOnCRL), and for a suspension - (`certificateHold`) that a later CRL no longer shows; + - "cannot be determined" also when the certificate has expired and the CRL no longer lists + expired certificates (a CRL answers for an expired certificate only if issued before its + `notAfter` or marked ExpiredCertsOnCRL), and for a suspension (`certificateHold`) that a + later CRL no longer shows; - "revocation not checked": no network, or no CRL fresh enough could be fetched. + None of the last three is "invalid signature". `--offline` uses a cached CRL that still answers, otherwise "revocation not checked". -### Accessibility -Legal frame (Italy/EU): Legge 4/2004 ("Legge Stanca", as amended by D.Lgs. 106/2018) and the -AgID guidelines on the accessibility of IT tools, which refer to the harmonised standard -**EN 301 549** (ch. 11 software, ch. 12 documentation and support, ch. 9 web content = WCAG). +### Who must be able to use it, and how? +Legal frame (Italy and EU): Legge 4/2004 ("Legge Stanca", as amended by D.Lgs. 106/2018) and +the AgID guidelines on the accessibility of IT tools. They refer to the harmonised standard +EN 301 549 (ch. 11 software, ch. 12 documentation and support, ch. 9 web content = WCAG). The European Accessibility Act (Directive 2019/882, D.Lgs. 82/2022) probably does not cover -this tool, but meeting EN 301 549 covers it too. Targets: **EN 301 549** for the program and -**WCAG 2.2 level AA** for the HTML report and the user guide. Whoever deploys the tool in a -public administration checks the applicable obligations (e.g. accessibility statement). +this tool, but meeting EN 301 549 covers it too. Targets: EN 301 549 for the program and +WCAG 2.2 level AA for the HTML report and the user guide. Whoever deploys the tool in a +public administration checks the applicable obligations (for example an accessibility +statement). - 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 off with `NO_COLOR`, `--no-color`, or when output is not a terminal. - - No box drawing, ASCII art or tables made of spaces for essential information: linear - text, one fact per line, read well by NVDA, JAWS, Narrator, VoiceOver and Orca. - - Progress does not flood screen readers: no spinners, no rewriting the same line many - times a second. `--plain` (also `SIGNSPECTOR_PLAIN=1`) gives line-by-line output with a - progress line at most every few seconds and a final summary. - - Prompts: the full question on one line, with the possible answers and the default - spelled 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. + - 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 + are off with `NO_COLOR`, `--no-color`, or when output is not a terminal. + - No box drawing, ASCII art or tables made of spaces for essential information: linear text, + one fact per line, read well by NVDA, JAWS, Narrator, VoiceOver and Orca. + - Progress does not flood screen readers: no spinners, no rewriting the same line many times + a second. `--plain` (also `SIGNSPECTOR_PLAIN=1`) gives line-by-line output with a progress + line at most every few seconds and a final summary. + - Prompts: the full question on one line, with the possible answers and the default spelled + 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).** - - `lang` set to the report language; meaningful ``; landmarks (`header`, `main`, + - `lang` set to the report language; a meaningful `<title>`; landmarks (`header`, `main`, `nav`) and a "skip to content" link; headings in order, no level skipped. - - Real tables with `<caption>` and `<th scope>`; status shown as text (with optional icon - that has a text alternative), never by colour alone. + - Real tables with `<caption>` and `<th scope>`. Status is shown as text (with an optional + icon that has a text alternative), never by colour alone. - Contrast at least 4.5:1 for text and 3:1 for UI parts and icons, in light and dark mode - (`prefers-color-scheme`); respects `prefers-reduced-motion`. - - Works at 200% zoom and reflows at 320 CSS px width without horizontal scrolling - (except data tables, which scroll on their own). - - Fully keyboard operable (`<details>`/`<summary>` for expandable parts), visible focus, + (`prefers-color-scheme`); `prefers-reduced-motion` is respected. + - Works at 200% zoom and reflows at 320 CSS px width without horizontal scrolling (except + 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 / HTML (no scanned or untagged PDF), translated, and include a section describing 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 OS accessibility (screen readers, keyboard); 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. +- 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 + 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 - headers, no colour-only status) and an accessibility checker on sample reports in CI (e.g. - `axe-core` or `pa11y`); 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 recorded in `docs/accessibility.md`. - -### Uninstalling -- R40. **`signspector uninstall`** removes everything SignSpector added to the system, and - only that: context menu entries, the Windows "Installed apps" entry (R42), trust-list and CRL cache, - saved preferences, logs. Same rule 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.** `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, reports changed or foreign items - and leaves them. If the manifest is lost, entries are recognised by an explicit SignSpector - marker, never by guessing. Running it twice is harmless. + 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 + 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.** + - `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. + - If the manifest is lost, our items are recognised by an explicit SignSpector marker, never + by guessing. + - Each item is created as R31 says (registry keys and `.workflow` folders: still open, + question "Before 5.1"). An item is foreign when it is not in the manifest and + has no SignSpector marker. When a foreign item has the same name, `install-menu` reports it + and leaves it, and it never enters the manifest, so `uninstall` never removes it (owner's + decision, 2026-11-23). + - An item of ours that already exists (in the manifest, or marked after a lost manifest) is + left as it is if unchanged, and reported if changed. + 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.** - - 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 `signspector.exe uninstall --interactive`, - which shows the list in a native dialog with the focus on Cancel (R30). - A running `.exe` cannot delete itself: the tool says where it is so the user can delete it - (no PowerShell, no scheduled tricks). - - macOS: Quick Actions in `~/Library/Services`, caches in `~/Library/Caches/SignSpector`, - preferences in `~/Library/Application Support/SignSpector`. - - Linux: Nautilus script, Dolphin service menu, `~/.cache/signspector`, - `~/.config/signspector`. `.deb`/`.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 end the tool lists what it left in place on purpose and where the executable is. - -## Architecture (proposal) - -Library crate with one module per concern, the executable only parses arguments and prints: + - 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 + `signspector.exe uninstall --interactive`, which shows the list in a native dialog (R30). A + running `.exe` cannot delete itself: the tool says where it is so the user can delete it + (no PowerShell, no scheduled tricks). The cache and manifest folders: question "Before 3.5". + - macOS: Quick Actions in `~/Library/Services`, the cache in `~/Library/Caches/SignSpector`, + the manifest in `~/Library/Application Support/SignSpector`. + - Linux: Nautilus script, Dolphin service menu, the cache in `~/.cache/signspector`, the + 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 + end the tool lists what it left in place on purpose and where the executable is. + +## How is the code organised? + +A library crate with one module per concern; the executable only parses arguments and prints. +This is a proposal. | Module | Role | Candidate crates | |---|---|---| @@ -399,25 +521,25 @@ Library crate with one module per concern, the executable only parses arguments | `xmldsig` | exclusive C14N, XML signature verification (R44) | `roxmltree`, own code | | `tsl` | LOTL and national lists: embedded copies, choice by country, refresh, cache (R44–R48) | `roxmltree`, `flate2`, `ureq` + rustls, `directories` | | `scan` | folder walk, per-file pipeline, parallelism | `std::thread::scope` | -| `extract` | safe writer, write log, `undo` (R31, R33), content type (R18) | `zip` | +| `extract` | safe writer, record of written documents in the report, `undo` (R31, R33), content type (R18) | `zip` | | `report` | console, HTML, JSON | `serde_json`, `anstream` | | `menu` | context-menu install, manifest, `uninstall` (R21, R40–R43) | `winreg` (Windows) | | `main.rs` | arguments, help | `clap` | -The order of work is in `roadmap.md` (safety-critical, pure parts first). +The order of work is in `roadmap.md`: safety-critical, pure parts first. -## Test data +## Which test data do we use? - Synthetic fixtures in `tests/fixtures/`, generated by a script (Homebrew `openssl@3`: `openssl cms -sign`, `openssl ts`) and by Rust test helpers for what OpenSSL cannot produce: BER indefinite lengths, nested envelopes, `.tsd`, base64, RSA-PSS, ECDSA, countersignatures, tampered content, expired and untrusted certificates, a fake TSL listing the test CA. -- Fuzzing of the `ber` and `cms` readers (`cargo fuzz`, needs nightly) once they exist: no input - may panic or hang. -- Real documents stay on the Windows PC (`tests/corpus/`, git-ignored, personal data): used to - check results by hand and, if useful, against the old tool's output. +- Fuzzing of the `ber` and `cms` readers (`cargo fuzz`, needs nightly) once they exist: no + input may panic or hang. +- Real documents stay on the Windows PC (`tests/corpus/`, git-ignored, personal data). They are + used to check results by hand and, if useful, against the old tool's output. -## Building on the Mac +## How do I build it on the Mac? ```sh cargo build --release # macOS, this machine @@ -431,34 +553,150 @@ x86_64-w64-mingw32-objdump -p target/x86_64-pc-windows-gnu/release/signspector.e The Windows executable must import only system DLLs (checked: `KERNEL32`, `ntdll`, `api-ms-win-*`). First milestone on the company PC: run the placeholder `.exe` from `cmd` to -confirm antivirus, SmartScreen and AppLocker accept a mingw-built executable. +confirm that antivirus, SmartScreen and AppLocker accept a mingw-built executable. -## Recorded exceptions +## Which exceptions are recorded? - Until the translation layer exists (roadmap 1.4), the placeholder message in `src/main.rs` is the only hard-coded user-facing text; it goes away with 1.4. -## Open questions - -- `ring` as the crypto provider of rustls (for the TSL refresh over HTTPS): it contains C and - assembly, cross-compiles fine, and is the only provider not banned in `deny.toml` - (`aws-lc-rs` is). Accept it as an exception to "pure Rust", or look for a pure-Rust provider - (e.g. `rustls-rustcrypto`)? To decide before roadmap 3.5 (download of the lists). -- Does the company proxy require integrated authentication (NTLM/Kerberos) to reach the - trusted lists (`ec.europa.eu` for the LOTL, `eidas.agid.gov.it` and the other national - addresses)? If yes, Windows needs WinHTTP for the refresh. -- Brainpool curves, AIA download of missing intermediates: needed by the real files? -- Native dialogs (R30, R38) before roadmap 5.2: a folder list, a text field for the number and - the focus on Cancel. Windows has no stock dialog with a text field (MessageBox and - TaskDialog have none): an own Win32 dialog in Rust, no PowerShell. macOS: AppleScript - `display dialog` (text field, default button Cancel). Linux: `zenity` or `kdialog`, which - may be missing; then a context-menu run refuses (R19). Which crate or code per OS? - Whatever is chosen: helper programs 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 AppleScript source or markup. Enter in the number field confirms only if - the number is right; otherwise it does nothing. Several folders selected in Windows - Explorer start one process each with plain registry verbs: one summary needs a - multi-selection entry (`IExecuteCommand`, a drop target, or one instance collecting the - others). +## What is still open? + +The owner closed requirement changes in roadmap step 0.4 on 2026-11-23. Decisions on +requirements taken after that date are listed in the same step, each with its date. Each +question below is answered before the roadmap step named in its heading; that step points back +here. + +### Before 1.4 (translations) +- Translation mechanism (for example Fluent `.ftl` files embedded in the executable, or + `rust-i18n`), OS language detection (`sys-locale`), how dates and numbers are formatted per + language. + +### Before 1.5 (walk and count) +- A file named exactly `.p7m` (no stem) is not an envelope today: should the report list it as + skipped? Are stand-alone time-stamp responses (`.tsr`) an input format? +- A selected folder whose name starts with `.`: is it analysed or skipped? Is the name judged + after resolving the path (`check .`, `check ..`)? What about a selected folder inside a hidden + one, and a selected symbolic link whose name is hidden but whose target is not, or the + reverse? + +### Before 1.6 (confirmation logic) +- R30 says any answer other than the right number never confirms. At the terminal, after such + an answer (`y`, `n`, Enter, a wrong number), is the question asked again or does the run stop? + Which exit code does a run declined at the terminal give? R13 has 0, 1 and 2, and R30 gives 2 + only for scripts. +- When is a typed number the right one? R29 calls it language-neutral. Does it accept the + separators of the user's language (`12.345`, `12,345`), leading zeros, spaces around it (R27, + questions "Before 1.4")? Is the answer the same for the dialog text field (R30, "Before 5.2")? + +### Before 1.7 (safe writer) and the first pseudo-terminal test - Pseudo-terminal tests (R34) need a pty crate as a dev-dependency, accepted by `deny.toml`: which one, for Unix and Windows ConPTY? +- R31 checks that a cache or manifest name is a regular file, then renames over it. What if the + name changes between the check and the rename, or a foreign file appears at a name that did + not exist yet (the first creation is also a rename) and would be replaced? How is that + prevented? +- R31 keeps documents inside the selected folder. Does a rule cover a report written into a + selected folder that is a symbolic link? + +### Before 3.1 (crypto) +- Brainpool curves: are they needed by the real files? + +### Before 3.2 (certificates) +- How does the report word a certificate expired at the time of the check, when no time stamp + proves an earlier time? + +### Before 3.5 (lists, download, cache) +- `ring` as the crypto provider of rustls (for the list refresh over HTTPS) contains C and + assembly. It cross-compiles fine and is the only provider not banned in `deny.toml` + (`aws-lc-rs` is). Do we accept it as an exception to "pure Rust", or look for a pure-Rust + provider (for example `rustls-rustcrypto`)? +- Does the company proxy require integrated authentication (NTLM or Kerberos) to reach the + trusted lists (`ec.europa.eu` for the LOTL, `eidas.agid.gov.it` and the other national + addresses)? If yes, Windows needs WinHTTP for the refresh. +- Which folders hold the cache and the manifest on Windows, and how do tests move them? The + candidate crate `directories` asks the system (`SHGetKnownFolderPath`) and ignores + `LOCALAPPDATA` (audit 0007, F2), so the test rule of R47 cannot work with it as is. Tests of + `install-menu` must also move the manifest folder; which variable does that on each OS is to + be checked. +- When the tool refuses a cache name (R31), does the run go on with the list held in memory, or + report "list not available"? +- What if the cache folder, or a folder above it, is a symbolic link (redirected profiles on + company PCs)? +- Which non-regular files count as "not a regular file" at a cache or manifest name: a FIFO, a + socket, a device, a Windows junction or reparse point? +- What is the fixed name of a national list? The territory code comes from the downloaded LOTL. + The earlier draft accepted it only as two letters; the alternative is a hash. Which one? Is a + list given with `--trust-list <file>` cached at all? +- How are temporary files named (R31), so that a leftover from an interrupted refresh does not + block every later refresh? Is a temporary name one the tool derives (R47)? +- Certificates carry ISO country codes (`GR`, `GB`); the LOTL uses `EL` for Greece and `UK` for + the United Kingdom (audit 0008, F4). How is a certificate's `C=` matched to a list, and which + codes does `--trust-lists` accept? +- After an upgrade, the embedded LOTL may be newer than a cached one whose `NextUpdate` has not + passed. Does the higher sequence number win over R47's precedence of the cache? +- Which event triggers the first refresh: the first run with network (R44) or a passed + `NextUpdate` (R47)? +- Which limits on size and time apply to list downloads? + +### Before 3.6 (chains) +- The download of missing intermediates (AIA): is it needed by the real files? +- R10 says the chain may optionally reach the system trust store. Which option turns it on? + +### Before 3.7 (countersignatures and time stamps) +- Which time stamp counts when there are several? + +### Before 3.9 (revocation) +- What is the verdict when the revocation time equals the time stamp? How are the revocation + reasons `removeFromCRL` and `keyCompromise` treated? Settled together with the tests. +- Which values do the CRL limits on size and time take (R49)? +- A CA that publishes partitioned CRLs has several CRLs. Is each file named by the hash of the CA + and of the distribution point, or is one kept? R47 and R49 change with the answer. + +### Before 4.2 (HTML report) +- Layout and content of the report: do we start from the old tool's report as a sketch? +- Which accessibility checker runs in CI (R39: `axe-core`, `pa11y`, or another)? + +### Before 4.4 (command line) +- What do `--open` and `--threads` do? (R23 asks for parallel work, not an option.) +- Is `extract --no-report` refused as a usage error (exit 2, nothing written), or accepted with a + message saying that the extraction report is written anyway (R16)? +- How is a double-click on Windows detected (R20), and which folder does it analyse? + +### Before 5.1 (install manifest) +- How does "created with `create_new`" (R31) apply to a registry key (for example + `RegCreateKeyEx`, accepted only when the key was created new, also for the + `Uninstall\SignSpector` key) and to a macOS Quick Action, which is a `.workflow` folder? +- An item of ours that matches the manifest but not what the current version would write (after + an update or a moved executable): is it updated or reported? If updated, R31, R34 and the + README change, since today a menu item is never replaced. +- After a lost manifest, what is a marked item compared with, and does it enter the new + manifest? +- A symbolic link or a folder at the manifest path: `install-menu` should refuse before it + creates any item; what do `uninstall-menu` and `uninstall` do there? +- How do tests move the Windows `HKCU` keys (the menu keys and the `Uninstall\SignSpector` + key), which no variable moves, and how do the R34 snapshots cover them? Which variable moves + the menu folders on macOS and Linux is to be checked. + +### Before 5.2 (context menu and dialogs) +- R30 says Enter alone cancels a dialog. In a dialog number field, what does Enter do after the + right number: confirm, or cancel because the focus is on Cancel? After a wrong number, does + Enter do nothing (the dialog stays open) or cancel? The same question for Confirm after a + wrong or empty number. +- What must the shorter dialog summary still show: unreadable folders, alternative names, + "existing files modified: 0", a way to see the full list, and the list for `undo`, the menus + and `uninstall`? +- Does the dialog of R30 also show the count of files of any kind, as the console summary does + (R19)? +- Native dialogs (R30, R38) need a folder list, a text field for the number and the focus on + Cancel. Windows has no stock dialog with a text field (MessageBox and TaskDialog have none): + an own Win32 dialog in Rust, no PowerShell. macOS: AppleScript `display dialog` (text field, + default button Cancel). Linux: `zenity` or `kdialog`, which may be missing; then a + context-menu run refuses (R30). Which crate or code per OS? Whatever is chosen follows R38. +- Several folders selected in Windows Explorer start one process each with plain registry + verbs. One summary needs a multi-selection entry (`IExecuteCommand`, a drop target, or one + instance collecting the others). + +### Before 5.3 (uninstall) +- Does `uninstall` remove a file in the cache folder that the tool did not write, or leave and + list it (R40, R43)? Does it remove leftover temporary files (R31)? diff --git a/docs/roadmap.md b/docs/roadmap.md index d0288af..eee2fe5 100644 --- a/docs/roadmap.md +++ b/docs/roadmap.md @@ -1,153 +1,275 @@ # SignSpector: roadmap -Order of work. Requirements (R…) are in `design.md`. Every step is TDD (red -> green -> -refactor), reviewed by the `fable-reviewer` agent, then committed. A step is done when its tests -are green on all three systems in CI and its PR is merged. Mark a step done here (`[x]`) in -the same PR that completes it; the coherence audit checks that the mark is true. - -The order follows two ideas: -1. **Safety first**: the parts that decide what gets written (names, collisions, confirmation) - come before the parts that read envelopes, and are pure functions, easy to test exhaustively. -2. **A thin end-to-end slice early**: as soon as envelopes can be opened, the whole path - count -> confirm -> plan -> confirm -> write -> report -> undo works on simple files, - before the long verification work. Problems in the flow show up early. - -## Phase 0: groundwork -- [x] 0.1 First commit and push to `main` (after review of the file list). From then on: one - branch and one draft PR per step, coherence audit every 5 commits, merge by local fast-forward (`CLAUDE.md`). -- [x] 0.2 GitHub Actions CI (`.github/workflows/ci.yml`) on Windows, macOS, Linux, on the - shipped targets (windows-gnu, linux-musl, macOS arm64 + x86_64 build): fmt, clippy, nextest, - doctests, release build, cargo deny (also weekly), tests of the rule scripts on all three - systems; public-repository scan of every new commit (`check-public.sh --range`); audit - cadence on the PR head. Branch protection on `main`: all jobs green, linear history, no - force-push. CI is an alarm; the local hooks are the barrier. -- [x] 0.2.1 Confirmation rules simplified: the typed number only for files found in a folder - (R28, R29); `undo`, menus and `uninstall` ask yes/no; from the context menu the same - confirmations come in a native dialog; from a script nothing that changes anything runs (R30); - `check`/`extract` take several folders (a row each, the total typed); revocation without a - query per signature (R49); no `--yes`/`--expect`; `scripts/cleanup.sh` removes its safe - leftovers without asking. +## How does a step get done? + +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`. + +## Why this order? + +Two ideas set it: + +1. Safety first. The parts that decide what gets written (names, collisions, confirmation) come + before the parts that read envelopes. They are pure functions, easy to test exhaustively. +2. A thin end-to-end slice early. As soon as envelopes can be opened, the whole path works on + simple files: count, confirm, plan, confirm, write, report, undo. This comes before the long + verification work, so problems in the flow show up early. + +## 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. + +- [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 + fast-forward (`CLAUDE.md`). +- [x] 0.2 GitHub Actions CI (`.github/workflows/ci.yml`) on Windows, macOS and Linux, on the + shipped targets (windows-gnu, linux-musl, macOS arm64 + x86_64 build). It runs fmt, clippy, + nextest, doctests, the release build, cargo deny (also weekly) and the tests of the rule + scripts on all three systems. It scans every new commit for the public repository + (`check-public.sh --range`) and checks the audit cadence on the PR head. Branch protection on + `main`: all jobs green, linear history, no force-push. CI is an alarm; the local hooks are the + barrier. +- [x] 0.2.1 Confirmation rules simplified: + - the number is typed only for files found in a folder (R28, R29); + - `undo`, menus and `uninstall` ask yes/no; + - from the context menu the same confirmations come in a native dialog; + - from a script nothing that changes anything runs, except `check` in an ordinary run, which + writes its report and the cache (R30); + - `check` and `extract` take several folders (a row each, the total typed); + - revocation without a query per signature (R49); + - no `--yes` or `--expect`; + - `scripts/cleanup.sh` removes its safe leftovers without asking. - [ ] 0.3 Fixture generator `scripts/make-fixtures.sh` (Homebrew `openssl@3`): test CA, signers, - simple `.p7m`/`.p7s`, `.tsd`. Synthetic identities only, private keys never committed - (generated at test time or kept in `target/`). - -- [ ] 0.4 Writing guide (`docs/writing.md`): texts as answers to the reader's questions, no - machine-made patterns (after Wikipedia's "Signs of AI writing"), answer first, short - sentences, code and commands verbatim. Rewrite README, design, roadmap, CLAUDE.md and the - agent prompts with it; comment in `rust-toolchain.toml` (targets and R25, how to update the - pinned version); session report line when a newer stable Rust exists. -- [ ] 0.5 Remaining gaps in the rule-script tests, found by the reviews of PR #1 and PR #2 and - accepted as known limits for now (each needs a test before the code changes): - - `check-public.sh`: failures of `git show`, `ls-tree`, `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`: on Windows 5 checks are skipped (names with `\` cannot exist there, and a - read-only folder does not stop `rm`), so 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); - - `audit-status.sh`: in the unfinished-work section, uncommitted changes, stashes and the - unpushed / not pulled counts have no test (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 and "no tags or other refs" do); 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; - - report-mode tests pass if the script prints nothing in that section. - - from the targeted review of the third-round fixes: - - 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; + simple `.p7m`/`.p7s`, `.tsd`. Synthetic identities only. Private keys are never committed: + they are generated at test time or kept in `target/`. +- [x] 0.4 Writing guide (`docs/writing.md`). Texts answer the reader's questions, with the + answer first and short sentences. Code and commands stay verbatim. Texts use no machine-made + patterns (after Wikipedia's "Signs of AI writing"). Rewrite README, design, roadmap, + `CLAUDE.md` and the agent prompts with it. Also in this step: + - a comment in `rust-toolchain.toml`: targets and R25, how to update the pinned version; + - a "Rust" section in the session report (`scripts/audit-status.sh`) that names a newer stable + Rust when one exists; + - owner's decisions on requirements, taken in the reviews of this step (2026-11-23 unless + dated) and recorded in `docs/design.md`: + - what `check` writes (R16); + - risky runs counted on files of any kind (R28); + - reports never replaced, and the second report (R16, R20, R31, R33); + - `--plan` writes and downloads nothing (R19); + - at the terminal, any answer other than the right number never confirms (R30); + - the cache (R47); + - no saved preference (R27); + - `--no-report` (R14, R16); + - foreign menu items (R41); + - R34 also tests each kind of sensitive folder selected directly (R28), decided on + 2026-11-24. + + 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. + - `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`: + - 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: + - 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. -## Phase 1: safe writing core (no cryptography) -- [x] 1.0 **R1a envelope names** (`is_envelope`): delivered with the project setup (0.1). -- [ ] 1.1 **R32 portable names** (`names` module). `portable_name(raw) -> PortableName { name, - changed }`. Tests, one per rule: forbidden characters, control characters, trailing dot and - space, reserved Windows names (any case, with extension, superscript digits), leading `-` - and `.`, `.`/`..`, invalid UTF-8, NFC, 255-byte/255-unit limit without breaking a character - or the extension, empty result -> fallback name. Property tests (`proptest`): output always - valid on all three systems, idempotent (`portable(portable(x)) == portable(x)`). -- [ ] 1.2 **Collision key and free name** (R17, R32): `collision_key` (case- and - normalization-insensitive); `next_free_name("x.pdf", taken)` -> `x (1).pdf`, `x (2).pdf`..., - still within the length limit. -- [ ] 1.3 **Output name from envelope name** (R16, R18 without content sniffing for now): + - 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? + +With pure functions for names and confirmation, and a writer that never overwrites. + +- [x] 1.0 Envelope names (`is_envelope`, R1a): delivered with the project setup (0.1). +- [ ] 1.1 Portable names (`names` module, R32): + `portable_name(raw) -> PortableName { name, changed }`. + - Tests, one per rule: + - forbidden characters; + - control characters; + - trailing dot and space; + - reserved Windows names (any case, with extension, superscript digits); + - leading `-` and `.`; + - `.` and `..`; + - invalid UTF-8; + - NFC; + - the 255-byte/255-unit limit, without breaking a character or the extension; + - an empty result, which gives the fallback name. + - Property tests (`proptest`): the output is always valid on all three systems, and idempotent + (`portable(portable(x)) == portable(x)`). +- [ ] 1.2 Collision key and free name (R17, R32): `collision_key` ignores case and + normalization. `next_free_name("x.pdf", taken)` gives `x (1).pdf`, `x (2).pdf`..., still + within the length limit. +- [ ] 1.3 Output name from the envelope name (R16; R18 without content sniffing for now): `Relazione.pdf.p7m` -> `Relazione.pdf`, nested `.pdf.p7m.tsd`, uppercase extensions. -- [ ] 1.4 **i18n skeleton** (R27): pick the mechanism (Fluent vs `rust-i18n`, decided with the - user), English + Italian, `--lang`, OS language detection. Needed before any message below. -- [ ] 1.5 **Walk and count** (R1b, R2, R19, R28): one or more folders, a row per folder and - the total; regular files only, symbolic links not followed and - hidden folders skipped (both listed in the report), - unreadable folders listed; count, total size, subfolders. Risky-folder detection (drive - roots, home, Desktop, Documents, system folders, network share roots, > 10,000 envelopes). -- [ ] 1.6 **Confirmation logic** (R28–R30): pure functions turning (counts, folder, terminal, - dialog via `--interactive`, or script; `--plan`) into the question to ask and parsing the - answer: typed count (R28 risky folder, - R29), yes/no default No (R19). Typestate `ConfirmedPlan`. Tests: Enter, `n`, wrong number, - changing command, and `check` or `extract --plan` on a risky folder, refused from a - script; `check --plan`, `extract --plan` on an ordinary folder and the item lists of - `--plan` run from a script; symbolic links - resolved before the risky-folder check (all path-based kinds of risky folder, not only shares); - several folders (total, overlaps counted once). The dialogs themselves come with the menus (5.2). -- [ ] 1.7 **Safe writer** (R31): `create_new`, next free name on race, removal of partial files, - stays inside the folder (`..`, symbolic links), free-space check, re-check of originals. - Folder snapshot test helper (R34) introduced here and used from now on. - -## Phase 2: opening envelopes (thin slice) +- [ ] 1.4 i18n skeleton (R27): pick the mechanism (Fluent or `rust-i18n`, decided with the + user), English and Italian, `--lang`, OS language detection. Needed before any message below. + First decide the questions "Before 1.4" in `docs/design.md`. +- [ ] 1.5 Walk and count (R1b, R2, R19, R28). First decide the questions "Before 1.5" in + `docs/design.md`. + - One or more folders, a row per folder and the total. + - Regular files only. Symbolic links met during the walk are not followed (a selected one is + 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. +- [ ] 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 + `--interactive`, or script) and `--plan` into the question to ask. They also parse the + answer. + - The question is a typed count (R28 risky run, R29) or a yes/no question with default No + (R30). Typestate `ConfirmedPlan`. + - The dialogs themselves come with the menus (5.2). +- [ ] 1.7 Safe writer (R31). First decide the questions "Before 1.7" in `docs/design.md`. + - `create_new`, the next free name on a race, removal of partial files. + - The two-step replace of cache files and the manifest: a temporary file, then a rename. + - Writing stays inside the folder (`..`, symbolic links); free-space check; re-check of + originals. + - The folder snapshot test helper (R34) is introduced here and used from now on. + +## Phase 2: how do we open envelopes end to end? + +With a BER reader, a CMS parser and one thin run of the whole flow. + - [ ] 2.1 `ber` reader: definite and indefinite lengths, limits on depth and size, checked arithmetic; fuzz target. - [ ] 2.2 `cms` SignedData parsing: encapsulated content, certificates, signer infos (no verification yet); base64 envelopes; nested layers (R3, R4, R7). -- [ ] 2.3 End-to-end slice: `check` and `extract` on simple fixtures through the real flow, - minimal console output with `--plain`, `--no-color` (R35), minimal JSON (R15), write log - with SHA-256 and `undo` (R33). - -## Phase 3: verification -- [ ] 3.1 `crypto`: digests, RSA PKCS#1 v1.5, RSA-PSS, ECDSA P-256/P-384/P-521 (R8). -- [ ] 3.2 `x509`: certificate fields, key usage, qualified/QSCD statements, validity (R9). - Report wording for a certificate expired at the time of the check when no time stamp - proves an earlier time. -- [ ] 3.3 `xmldsig`: exclusive C14N and XML signature verification (R44), test first, - fuzzed like `ber`. -- [ ] 3.4 `tsl`: LOTL and national lists, signatures verified, embedded LOTL + Italian list, +- [ ] 2.3 End-to-end slice: `check` and `extract` on simple fixtures through the real flow. + - Minimal console output with `--plain` and `--no-color` (R35); minimal JSON (R15). + - Written documents recorded in the report with SHA-256, and `undo` (R33). + - The first end-to-end tests in `tests/*.rs` use `assert_cmd` and `predicates`, declared in + `Cargo.toml` since 0.1 (audit 0001, F12). + +## Phase 3: how do we verify signatures and time stamps? + +One layer at a time: cryptography, certificates, trusted lists, chains, time stamps, revocation. + +- [ ] 3.1 `crypto`: digests, RSA PKCS#1 v1.5, RSA-PSS, ECDSA P-256/P-384/P-521 (R8). First + decide the question "Before 3.1" in `docs/design.md`. +- [ ] 3.2 `x509`: certificate fields, key usage, qualified/QSCD statements, validity (R9). First + decide the question "Before 3.2" in `docs/design.md`. +- [ ] 3.3 `xmldsig`: exclusive C14N and XML signature verification (R44), test first, fuzzed + like `ber`. +- [ ] 3.4 `tsl`: LOTL and national lists, signatures verified, embedded LOTL and Italian list, service history (R44, R48). - [ ] 3.5 Choice of lists from the certifiers' countries, download, cache, `--trust-lists`, - `--offline` (R45–R47). -- [ ] 3.6 Chain building against the TSL and the system store (R10). -- [ ] 3.7 Countersignatures (R11); `tsp`: RFC 3161, `.tsd`, `.m7m` (R5, R12); detached `.p7s` (R6). - A time stamp is a proved time (R9) only if it verifies per R12 (chain to a trusted-list - TSA); negative test: a forged or untrusted time stamp changes no verdict. Which time stamp - counts when there are several. + `--offline` (R45–R47). First decide the questions "Before 3.5" in `docs/design.md`. +- [ ] 3.6 Chain building against the TSL and the system store (R10). First decide the questions + "Before 3.6" in `docs/design.md`. +- [ ] 3.7 Countersignatures (R11); `tsp`: RFC 3161, `.tsd`, `.m7m` (R5, R12); detached `.p7s` + (R6). First decide the question "Before 3.7" in `docs/design.md`. + - A time stamp is a proved time (R9) only if it verifies per R12, with a chain to a + trusted-list TSA. + - Negative test: a forged or untrusted time stamp changes no verdict. - [ ] 3.8 Content sniffing for names without a usable extension (R18). -- [ ] 3.9 Revocation (R49): define the case of a revocation time equal to the time stamp; data - embedded in the signature, CRL per CA with cache, one check per certificate, "revocation not - checked" offline. Negative tests: revoked before and after the time stamp, revoked with no - time stamp (cannot be determined, never invalid), stale or forged embedded data, forged or - oversized CRL, CRL older than the reference time, expired certificate no longer listed, - distribution point outside `http`/`https`. Also to define with the tests: revocation reasons - (`removeFromCRL`, `keyCompromise`); an embedded CRL older than the reference time when the - CA's CRL cannot be fetched ("revocation not checked"). - -## Phase 4: output +- [ ] 3.9 Revocation (R49). First decide the questions "Before 3.9" in `docs/design.md`. + - Data embedded in the signature, a CRL per CA with cache, one check per certificate, + "revocation not checked" offline. + - Negative tests: + - revoked before and after the time stamp; + - revoked with no time stamp (cannot be determined, never invalid); + - stale or forged embedded data; + - a forged or oversized CRL; + - a CRL older than the reference time; + - an expired certificate no longer listed; + - a distribution point outside `http`/`https`. + - Also: an embedded CRL older than the reference time when the CA's CRL cannot be fetched + ("revocation not checked"). + +## Phase 4: what does the user see? + +A console summary, an accessible HTML report, JSON and a translated command line. + - [ ] 4.1 Console summary, colours with contrast, exit codes (R13, R35). -- [ ] 4.2 Accessible HTML report, WCAG 2.2 AA (R14, R36), checker in CI (R39). -- [ ] 4.3 Full `--json` (R15); parallel processing with stable output order (R23). -- [ ] 4.4 Command line and translated help, interactive end of run (R19, R20, R37). - -## Phase 5: system integration -- [ ] 5.1 Install manifest (R41). -- [ ] 5.2 Context menu per OS (R21, R38) with the confirmation dialogs (R30): decide what the - shorter dialog summary must still show (unreadable folders, alternative names, "existing files - modified: 0", a way to see the full list; the list for `undo`, menus and `uninstall`), with - R34 tests; Windows "Installed apps" entry (R42). -- [ ] 5.3 `uninstall` (R40–R43). - -## Phase 6: release +- [ ] 4.2 Accessible HTML report, WCAG 2.2 AA (R14, R36), checker in CI (R39). First decide the + questions "Before 4.2" in `docs/design.md`. +- [ ] 4.3 Full `--json` (R15); parallel processing with a stable output order (R23). +- [ ] 4.4 Command line and translated help, interactive end of run (R19, R20, R37). First decide + `--open`, `--threads`, `extract --no-report` and double-click detection (questions "Before + 4.4" in `docs/design.md`). + +## Phase 5: how does it fit into the system? + +Through a context menu with native dialogs, recorded in a manifest so that `uninstall` can +remove it. + +- [ ] 5.1 Install manifest (R41). First decide how `create_new` applies to registry keys and + `.workflow` folders, and the other questions "Before 5.1" in `docs/design.md`. +- [ ] 5.2 Context menu per OS (R21, R38) with the confirmation dialogs (R30); Windows "Installed + apps" entry (R42). First decide the questions "Before 5.2" in `docs/design.md`: Enter in a + number field, what the shorter dialog summary must show, and the other questions. +- [ ] 5.3 `uninstall` (R40–R43). First decide what happens to a file in the cache folder that + the tool did not write (questions "Before 5.3" in `docs/design.md`). + +## Phase 6: how do we release it? + +As one self-contained executable per platform, tested on the company PC before `1.0.0`. + - [ ] 6.1 Builds for all targets; `.deb`, `.rpm`, `.tar.gz` (R24, R25); one self-contained executable per platform, pure Rust (R22, enforced by `cargo deny`); version tag (R26). -- [ ] 6.2 Test on the company Windows PC (antivirus, SmartScreen, AppLocker) with the real corpus. +- [ ] 6.2 Test on the company Windows PC (antivirus, SmartScreen, AppLocker) with the real + corpus. - [ ] 6.3 Manual accessibility checks, `docs/accessibility.md` (R39); user guide (R37). -- [ ] 6.4 `1.0.0` when ready to replace the old tool. +- [ ] 6.4 `1.0.0` when ready to replace the old tool. Before it, every case of R34 has a test. diff --git a/docs/writing.md b/docs/writing.md new file mode 100644 index 0000000..46611d8 --- /dev/null +++ b/docs/writing.md @@ -0,0 +1,99 @@ +# How we write + +These rules apply to every text in this repository. That means docs, agent prompts, comments, +commit messages, PR texts, the user guide and the strings the tool shows. Everything is in +English; only the tool's interface (its strings and the user guide) is translated (see +"Which rules hold everywhere?" in `CLAUDE.md`). + +## Who reads our texts? + +A person looking for one answer. They arrive with a question ("does it work offline?", +"what happens if the file already exists?") and leave when they have the answer. We write so +that they find it fast and can trust it. + +## How is a document organised? + +As questions and answers. Each section heading is a question the reader would ask, in their +words: "Which files does SignSpector open?", not "File discovery". The first sentence under +the heading answers it. Reasons, details and exceptions come after. + +Requirement and step numbers stay (R16, 3.4): code and tests refer to them. They go at the +end of the answer, not in the heading. + +## How long is a sentence? + +At most about 20 words, one idea per sentence, active voice. Instructions use the imperative: +"Run `cargo nextest run`", not "The tests can be run with...". One term per thing: if it is +an "envelope" in one place, it is not a "container" two lines later. + +## What is never shortened or reworded? + +Code, commands, paths, file names, option names, error messages, numbers, versions and +dates. We copy them exactly, and put code, commands, paths, file names and options in +backticks. We never drop a negation or a restriction (not, never, only, except) to save words. + +## What do we cut? + +Anything that does not answer the question: + +- greetings, recaps, "in summary", "let me know", "I hope this helps"; +- hedging piled on hedging ("could potentially perhaps"): say what is known and what is not; +- filler: "in order to", "it is important to note that", "at its core"; +- generic endings ("the future looks bright"). + +## Which patterns make a text sound machine-made? + +These ones, from Wikipedia's page "Signs of AI writing" +(https://en.wikipedia.org/wiki/Wikipedia:Signs_of_AI_writing). We do not use them: + +- inflated significance: "plays a pivotal role", "is a testament to", "marks a shift"; +- the usual filler vocabulary: crucial, delve, enhance, foster, intricate, landscape, + leverage, seamless, showcase, tapestry, underscore, vibrant (a literal use is fine); +- "serves as", "stands as", "boasts" instead of "is" or "has"; +- "not just X, but Y" and "it's not about X, it's about Y"; +- lists of three by reflex, and synonyms rotated to avoid repeating a word; +- false ranges: "from small offices to large institutions"; +- em dashes (use a comma, a colon or a new sentence), emojis, curly quotes; +- trailing "-ing" commentary ("..., ensuring a smooth experience"), promotional adjectives, + flattering openers; +- bold words scattered in running text, and lists where every item starts with a bold + label and a colon; +- Title Case In Headings (we write headings in sentence case); +- vague sources: "experts say", "it is widely recognised". + +## Do our texts have a voice? + +Yes, a plain one. We state decisions and say why: "The release embeds the LOTL and the Italian +list. The tool then works offline from the start." We say what we do not know: "We do not +know yet whether the company proxy needs NTLM." We use "we" for the project. A text with no +opinion and no reason is not neutral, it is useless. + +## Are there exceptions? + +Yes, seven: + +- Safety warnings and irreversible actions: full sentences, even if longer. Clarity beats brevity. +- Steps that must happen in order: a numbered list, one action per step. +- Tables: only when the reader compares values across rows. +- Strings shown by the tool follow the same rules in every language (R27), and must work + with screen readers (R35): words, not symbols. +- Texts without headings (commit messages, comments, the tool's strings) keep the rest: answer + first, short sentences, nothing to cut. +- Numbered lists and fixed formats keep their labels and layout. The text inside them follows + the guide. Examples: + - requirements `R44.` and roadmap steps `3.4`; + - the reviewer's `VERDICT:` line and the audit report skeleton; + - the front matter of agent prompts; + - headings such as `### Before 1.5 (walk and count)` in "What is still open?" in + `docs/design.md`, which roadmap steps point to. +- Audit reports in `docs/audits/` are records: they are never rewritten. + +## Who checks? + +The author, before committing, reads the text once as the reader with the question. The +`fable-reviewer` and `coherence-auditor` agents report the patterns above in their reviews. + +## May a tool rewrite our texts? + +Only the Claude models of the project's own subscription, the same ones that write the code. +We send no text to other services or models to be rewritten. diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 52e3e46..9ec4de1 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,5 +1,22 @@ +# Which Rust builds SignSpector? Exactly this version, on every machine and in CI. +# +# Why pinned? A new Rust release can add lints, and clippy runs with -D warnings: the build +# must not break on its own. We move to a new version on purpose, in its own commit. +# +# How to update: +# 1. rustup check (shows the latest stable; needs a "stable" toolchain: +# rustup toolchain install stable) +# 2. change `channel` below, then: rustup toolchain install (as CI does) +# 3. cargo fmt --check && cargo clippy --all-targets -- -D warnings && cargo nextest run +# 4. commit alone ("Rust 1.x.y"); CI runs the four jobs on the new version. +# +# Which targets, and why? The release builds (R24 in docs/design.md): +# aarch64-apple-darwin, x86_64-apple-darwin macOS arm64 and Intel (universal binary) +# x86_64-pc-windows-gnu Windows, mingw-w64 (linker in .cargo/config.toml) +# x86_64-unknown-linux-musl Linux, one static binary (cargo zigbuild); +# the .deb, .rpm and .tar.gz are made from it (R25) [toolchain] -channel = "1.100.0" # pinned: update by hand, new lints can break -D warnings +channel = "1.100.0" components = ["clippy", "rustfmt", "llvm-tools-preview"] targets = [ "aarch64-apple-darwin", diff --git a/scripts/audit-status.sh b/scripts/audit-status.sh index 8ea302e..2a49ee2 100755 --- a/scripts/audit-status.sh +++ b/scripts/audit-status.sh @@ -6,8 +6,9 @@ # (pre-push with the pushed commit; CI with the PR head) # Every commit not reachable from the last audit counts, also those brought in by a merge. # Exit 2 when git cannot answer: never a silent pass. -# An audit is a non-merge commit that only adds files under docs/audits/ (see CLAUDE.md, "Coherence -# audits"); a commit mixing a report with other changes, or deleting one, does not count. +# An audit is a non-merge commit that only adds files under docs/audits/ (see CLAUDE.md, "How do +# we keep long work from drifting?"); a commit mixing a report with other changes, or deleting +# one, does not count. set -u AUDIT_EVERY=5 @@ -73,6 +74,29 @@ else fi [ "$since" -ge "$AUDIT_EVERY" ] && echo "AUDIT DUE" +section "Rust" +# The pinned version (rust-toolchain.toml) is moved by hand; say when a newer stable exists. +# rustup check needs a "stable" toolchain installed. It prints one line per toolchain: +# "up to date: X" or "update available: X -> Y" (rustup 1.29), "Up to date : X" (older releases). +# The first line of the stable channel is read. +pinned=$(sed -n "s/^[[:space:]]*channel[[:space:]]*=[[:space:]]*[\"']\([^\"']*\)[\"'].*/\1/p" rust-toolchain.toml 2>/dev/null | head -n 1) +latest=$(rustup check 2>/dev/null </dev/null | sed -n \ + -e 's/^stable-.* -> \([0-9][0-9.]*\).*/\1/p' \ + -e 's/^stable-.* [Uu]p to date *: *\([0-9][0-9.]*\).*/\1/p' | head -n 1) +if [ -z "$pinned" ]; then + echo "pinned Rust version not found in rust-toolchain.toml" +elif ! printf '%s\n' "$pinned" | grep -qx '[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*'; then + echo "pinned Rust $pinned is not x.y.z; see rust-toolchain.toml" +elif [ -z "$latest" ]; then + echo "Rust release not checked (rustup check failed, or no stable toolchain: rustup toolchain install stable)" +elif [ "$latest" = "$pinned" ]; then + echo "pinned Rust $pinned is the latest stable" +elif [ "$(printf '%s\n%s\n' "$pinned" "$latest" | sort -t. -k1,1n -k2,2n -k3,3n | tail -n 1)" = "$latest" ]; then + echo "NEWER RUST STABLE: $latest (pinned: $pinned); see rust-toolchain.toml" +else + echo "pinned Rust $pinned; latest stable reported by rustup: $latest" +fi + section "Unfinished local work" dirty=$(git status --porcelain) [ -n "$dirty" ] && { echo "uncommitted changes:"; printf '%s\n' "$dirty"; } || echo "working tree clean" diff --git a/scripts/cleanup.sh b/scripts/cleanup.sh index 572f245..76e7014 100755 --- a/scripts/cleanup.sh +++ b/scripts/cleanup.sh @@ -1,5 +1,6 @@ #!/bin/sh -# Removes local leftovers after a coherence audit (CLAUDE.md, "Coherence audits"). +# Removes local leftovers after a coherence audit (CLAUDE.md, "How do we keep long work from +# drifting?"). # scripts/cleanup.sh removes the local leftovers listed below and says what it removed # scripts/cleanup.sh --plan lists what it would remove and removes nothing (session report) # No question is asked: only unambiguous junk files and branches already merged into main diff --git a/scripts/test-scripts.sh b/scripts/test-scripts.sh index d5f6d77..52265f4 100755 --- a/scripts/test-scripts.sh +++ b/scripts/test-scripts.sh @@ -36,6 +36,8 @@ expect_reason() { # 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" +# The same for rustup: the report's "Rust" section must not reach the network in the tests. +printf '#!/bin/sh\necho "$*" >> "%s/rustup-stub.log"\nexit 1\n' "$work" > "$work/nogh/rustup"; chmod +x "$work/nogh/rustup" PATH="$work/nogh:$PATH" new_repo() { @@ -358,6 +360,128 @@ PATH="$work/ghshim:$PATH" sh scripts/audit-status.sh 2>/dev/null | grep -q "INTE PATH="$work/ghshim:$PATH" sh scripts/audit-status.sh 2>/dev/null | grep -q "== GitHub"; 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 $? +# 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 +mkdir -p "$work/rustupshim" +# The stub lines copy the format of rustup 1.29.3 (rustup check), apart from the older-format test. +rustup_says() { printf '#!/bin/sh\n[ "$1" = check ] || exit 1\n%s\n' "$1" > "$work/rustupshim/rustup"; chmod +x "$work/rustupshim/rustup"; } +rustup_says "echo 'stable-x86_64-unknown-linux-gnu - update available: 1.100.0 (a 2026-11-09) -> 1.101.0 (b 2026-12-21)'" +PATH="$work/rustupshim:$PATH" sh scripts/audit-status.sh 2>&1 | grep -qx "NEWER RUST STABLE: 1.101.0 (pinned: 1.100.0); see rust-toolchain.toml"; expect "report: newer Rust stable shown" 0 $? +rustup_says "echo 'stable-x86_64-unknown-linux-gnu - up to date: 1.100.0 (a 2026-11-09)'" +PATH="$work/rustupshim:$PATH" sh scripts/audit-status.sh 2>&1 | grep -qx "pinned Rust 1.100.0 is the latest stable"; expect "report: pinned Rust is the latest stable" 0 $? +rustup_says "echo 'stable-x86_64-unknown-linux-gnu - up to date: 1.99.0 (a 2026-10-01)'" +out=$(PATH="$work/rustupshim:$PATH" sh scripts/audit-status.sh 2>&1) +printf '%s\n' "$out" | grep -q "NEWER RUST"; expect "report: an older installed stable is not newer" 1 $? +printf '%s\n' "$out" | grep -qx "pinned Rust 1.100.0; latest stable reported by rustup: 1.99.0"; expect "report: pinned ahead of the stable said" 0 $? +rm -f rust-toolchain.toml +rustup_says "echo 'stable-x86_64-unknown-linux-gnu - up to date: 1.100.0 (a 2026-11-09)'" +PATH="$work/rustupshim:$PATH" sh scripts/audit-status.sh 2>&1 | grep -qx "pinned Rust version not found in rust-toolchain.toml"; expect "report: missing pin said" 0 $? +grep -q "^check" "$work/rustup-stub.log"; expect "the test stub stands in for the real rustup" 0 $? +printf '[toolchain]\nchannel = "1.100.0"\n' > rust-toolchain.toml +rustup_says "exit 1" +PATH="$work/rustupshim:$PATH" sh scripts/audit-status.sh 2>&1 | grep -qx "Rust release not checked (rustup check failed, or no stable toolchain: rustup toolchain install stable)"; expect "report: rustup check failing is said" 0 $? +# Versions are compared number by number: patch 10 is after patch 9, major 10 after major 9. +printf '[toolchain]\nchannel = "1.100.9"\n' > rust-toolchain.toml +rustup_says "echo 'stable-x86_64-unknown-linux-gnu - update available: 1.100.9 (a 2026-11-09) -> 1.100.10 (b 2026-11-20)'" +PATH="$work/rustupshim:$PATH" sh scripts/audit-status.sh 2>&1 | grep -qx "NEWER RUST STABLE: 1.100.10 (pinned: 1.100.9); see rust-toolchain.toml"; expect "report: newer patch release shown" 0 $? +printf '[toolchain]\nchannel = "1.100.10"\n' > rust-toolchain.toml +rustup_says "echo 'stable-x86_64-unknown-linux-gnu - up to date: 1.100.9 (a 2026-11-09)'" +PATH="$work/rustupshim:$PATH" sh scripts/audit-status.sh 2>&1 | grep -q "NEWER RUST"; expect "report: older patch release is not newer" 1 $? +printf '[toolchain]\nchannel = "9.0.0"\n' > rust-toolchain.toml +rustup_says "echo 'stable-x86_64-unknown-linux-gnu - up to date: 10.0.0 (a 2026-11-09)'" +PATH="$work/rustupshim:$PATH" sh scripts/audit-status.sh 2>&1 | grep -qx "NEWER RUST STABLE: 10.0.0 (pinned: 9.0.0); see rust-toolchain.toml"; expect "report: newer major release shown" 0 $? +printf '[toolchain]\nchannel = "1.100.0"\n' > rust-toolchain.toml +# Two hosts installed (e.g. arm64 and x86_64 on a Mac): rustup prints two stable lines, one is read. +rustup_says "printf '%s\\n' 'stable-aarch64-apple-darwin - update available: 1.100.0 (a 2026-11-09) -> 1.101.0 (b 2026-12-21)' 'stable-x86_64-apple-darwin - update available: 1.100.0 (a 2026-11-09) -> 1.101.0 (b 2026-12-21)'" +PATH="$work/rustupshim:$PATH" sh scripts/audit-status.sh 2>&1 | grep -qx "NEWER RUST STABLE: 1.101.0 (pinned: 1.100.0); see rust-toolchain.toml"; expect "report: two stable lines read as one" 0 $? +# The line format of older rustup releases: "Up to date : X". +rustup_says "echo 'stable-x86_64-unknown-linux-gnu - Up to date : 1.100.0 (a 2026-11-09)'" +PATH="$work/rustupshim:$PATH" sh scripts/audit-status.sh 2>&1 | grep -qx "pinned Rust 1.100.0 is the latest stable"; expect "report: older rustup format read" 0 $? +# rustup gets no standard input, and its error text stays out of the report. +rustup_says "echo \"stdin=\$(cat)\" >> '$work/rustup-ask.log'; echo rustup-noise >&2; echo 'stable-x86_64-unknown-linux-gnu - up to date: 1.100.0 (a 2026-11-09)'" +rm -f "$work/rustup-ask.log" +out=$(echo typed | PATH="$work/rustupshim:$PATH" sh scripts/audit-status.sh 2>&1) +[ "$(cat "$work/rustup-ask.log" 2>/dev/null)" = "stdin=" ]; expect "report: rustup reads no input" 0 $? +printf '%s\n' "$out" | grep -q "rustup-noise"; expect "report: rustup errors not shown" 1 $? +# Only the real channel line counts: not a commented one; tabs and single quotes are valid TOML. +rustup_says "echo 'stable-x86_64-unknown-linux-gnu - up to date: 1.100.0 (a 2026-11-09)'" +printf '[toolchain]\n# channel = "1.0.0"\nchannel = "1.100.0"\n' > rust-toolchain.toml +PATH="$work/rustupshim:$PATH" sh scripts/audit-status.sh 2>&1 | grep -qx "pinned Rust 1.100.0 is the latest stable"; expect "report: commented channel line ignored" 0 $? +printf "[toolchain]\nchannel\t= '1.100.0'\n" > rust-toolchain.toml +PATH="$work/rustupshim:$PATH" sh scripts/audit-status.sh 2>&1 | grep -qx "pinned Rust 1.100.0 is the latest stable"; expect "report: tab and single quotes read" 0 $? +# A pin that is not x.y.z (e.g. "1.100" or "stable") is said, never compared. +printf '[toolchain]\nchannel = "1.100"\n' > rust-toolchain.toml +out=$(PATH="$work/rustupshim:$PATH" sh scripts/audit-status.sh 2>&1) +printf '%s\n' "$out" | grep -qx "pinned Rust 1.100 is not x.y.z; see rust-toolchain.toml"; expect "report: pin without patch said" 0 $? +printf '%s\n' "$out" | grep -q "NEWER RUST"; expect "report: pin without patch not compared" 1 $? +printf '[toolchain]\nchannel = "1.100.0"\n' > rust-toolchain.toml +# Only stable lines count: a nightly line (cargo fuzz needs nightly) before the stable one is skipped. +rustup_says "printf '%s\\n' 'nightly-x86_64-unknown-linux-gnu - update available: 1.102.0-nightly (a 2026-11-20) -> 1.102.0-nightly (b 2026-11-22)' 'stable-x86_64-unknown-linux-gnu - up to date: 1.100.0 (a 2026-11-09)'" +PATH="$work/rustupshim:$PATH" sh scripts/audit-status.sh 2>&1 | grep -qx "pinned Rust 1.100.0 is the latest stable"; expect "report: nightly line skipped" 0 $? +rustup_says "printf '%s\\n' 'nightly-x86_64-unknown-linux-gnu - up to date: 1.102.0-nightly (a 2026-11-22)' 'stable-x86_64-unknown-linux-gnu - update available: 1.100.0 (a 2026-11-09) -> 1.101.0 (b 2026-12-21)'" +PATH="$work/rustupshim:$PATH" sh scripts/audit-status.sh 2>&1 | grep -qx "NEWER RUST STABLE: 1.101.0 (pinned: 1.100.0); see rust-toolchain.toml"; expect "report: nightly up-to-date line skipped" 0 $? +rustup_says "echo 'stable-x86_64-unknown-linux-gnu - up to date: 1.100.0 (a 2026-11-09)'" +# The whole pin must be x.y.z: a channel name or a pre-release is said, never compared. +printf '[toolchain]\nchannel = "stable"\n' > rust-toolchain.toml +PATH="$work/rustupshim:$PATH" sh scripts/audit-status.sh 2>&1 | grep -qx "pinned Rust stable is not x.y.z; see rust-toolchain.toml"; expect "report: channel name said" 0 $? +printf '[toolchain]\nchannel = "1.100.0-beta.1"\n' > rust-toolchain.toml +PATH="$work/rustupshim:$PATH" sh scripts/audit-status.sh 2>&1 | grep -qx "pinned Rust 1.100.0-beta.1 is not x.y.z; see rust-toolchain.toml"; expect "report: pre-release pin said" 0 $? +# Text after the closing quote is ignored: a trailing comment, CRLF line ends (Windows checkout). +printf '[toolchain]\nchannel = "1.100.0" # pinned\n' > rust-toolchain.toml +PATH="$work/rustupshim:$PATH" sh scripts/audit-status.sh 2>&1 | grep -qx "pinned Rust 1.100.0 is the latest stable"; expect "report: trailing comment ignored" 0 $? +printf '[toolchain]\r\nchannel = "1.100.0"\r\n' > rust-toolchain.toml +PATH="$work/rustupshim:$PATH" sh scripts/audit-status.sh 2>&1 | grep -qx "pinned Rust 1.100.0 is the latest stable"; expect "report: CRLF line ends read" 0 $? +# An indented key is valid TOML. +printf '[toolchain]\n channel = "1.100.0"\n' > rust-toolchain.toml +PATH="$work/rustupshim:$PATH" sh scripts/audit-status.sh 2>&1 | grep -qx "pinned Rust 1.100.0 is the latest stable"; expect "report: indented channel read" 0 $? +# A duplicate key (invalid TOML) still gives one line, from the first key. +printf '[toolchain]\nchannel = "1.99.0"\nchannel = "1.100.0"\n' > rust-toolchain.toml +PATH="$work/rustupshim:$PATH" sh scripts/audit-status.sh 2>&1 | grep -qx "NEWER RUST STABLE: 1.100.0 (pinned: 1.99.0); see rust-toolchain.toml"; expect "report: first of two channel keys read" 0 $? +# Without the file, the "Rust" section is its heading and one line: no sed error text. +rm -f rust-toolchain.toml +PATH="$work/rustupshim:$PATH" sh scripts/audit-status.sh 2>&1 | sed -n '/^== Rust$/,/^== /p' > "$work/rust-section.txt" +printf '== Rust\npinned Rust version not found in rust-toolchain.toml\n\n== Unfinished local work\n' | cmp -s - "$work/rust-section.txt"; expect "report: Rust section is one line without the file" 0 $? +# White space around "=" is free in TOML: none, or a tab after it. +rustup_says "echo 'stable-x86_64-unknown-linux-gnu - up to date: 1.100.0 (a 2026-11-09)'" +printf '[toolchain]\nchannel="1.100.0"\n' > rust-toolchain.toml +PATH="$work/rustupshim:$PATH" sh scripts/audit-status.sh 2>&1 | grep -qx "pinned Rust 1.100.0 is the latest stable"; expect "report: no spaces around = read" 0 $? +printf '[toolchain]\nchannel =\t"1.100.0"\n' > rust-toolchain.toml +PATH="$work/rustupshim:$PATH" sh scripts/audit-status.sh 2>&1 | grep -qx "pinned Rust 1.100.0 is the latest stable"; expect "report: tab after = read" 0 $? +# The value ends at its closing quote, even when a comment after it holds the other quote. +printf "[toolchain]\nchannel = '1.100.0' # don't move\n" > rust-toolchain.toml +PATH="$work/rustupshim:$PATH" sh scripts/audit-status.sh 2>&1 | grep -qx "pinned Rust 1.100.0 is the latest stable"; expect "report: apostrophe in a trailing comment" 0 $? +printf '[toolchain]\nchannel = "1.100.0" # was "1.99.0"\n' > rust-toolchain.toml +PATH="$work/rustupshim:$PATH" sh scripts/audit-status.sh 2>&1 | grep -qx "pinned Rust 1.100.0 is the latest stable"; expect "report: double quotes in a trailing comment" 0 $? +printf '[toolchain]\n\tchannel = "1.100.0"\n' > rust-toolchain.toml +PATH="$work/rustupshim:$PATH" sh scripts/audit-status.sh 2>&1 | grep -qx "pinned Rust 1.100.0 is the latest stable"; expect "report: tab-indented channel read" 0 $? +# A pin with an empty part is not x.y.z. +printf '[toolchain]\nchannel = "1.100."\n' > rust-toolchain.toml +PATH="$work/rustupshim:$PATH" sh scripts/audit-status.sh 2>&1 | grep -qx "pinned Rust 1.100. is not x.y.z; see rust-toolchain.toml"; expect "report: pin with an empty part said" 0 $? +printf '[toolchain]\nchannel = "1..0"\n' > rust-toolchain.toml +PATH="$work/rustupshim:$PATH" sh scripts/audit-status.sh 2>&1 | grep -qx "pinned Rust 1..0 is not x.y.z; see rust-toolchain.toml"; expect "report: pin with an empty middle part said" 0 $? +printf '[toolchain]\nchannel = ".100.0"\n' > rust-toolchain.toml +PATH="$work/rustupshim:$PATH" sh scripts/audit-status.sh 2>&1 | grep -qx "pinned Rust .100.0 is not x.y.z; see rust-toolchain.toml"; expect "report: pin with an empty first part said" 0 $? +# A pin with a fourth number is not x.y.z. +printf '[toolchain]\nchannel = "1.100.0.1"\n' > rust-toolchain.toml +PATH="$work/rustupshim:$PATH" sh scripts/audit-status.sh 2>&1 | grep -qx "pinned Rust 1.100.0.1 is not x.y.z; see rust-toolchain.toml"; expect "report: four-part pin said" 0 $? +printf '[toolchain]\nchannel = "1.100.0"\n' > rust-toolchain.toml +# With two stable hosts at different versions, the first line is read. +rustup_says "printf '%s\\n' 'stable-aarch64-apple-darwin - up to date: 1.100.0 (a 2026-11-09)' 'stable-x86_64-apple-darwin - update available: 1.100.0 (a 2026-11-09) -> 1.101.0 (b 2026-12-21)'" +PATH="$work/rustupshim:$PATH" sh scripts/audit-status.sh 2>&1 | grep -qx "pinned Rust 1.100.0 is the latest stable"; expect "report: first of two stable hosts read" 0 $? +rustup_says "printf '%s\\n' 'stable-aarch64-apple-darwin - update available: 1.100.0 (a 2026-11-09) -> 1.101.0 (b 2026-12-21)' 'stable-x86_64-apple-darwin - up to date: 1.100.0 (a 2026-11-09)'" +PATH="$work/rustupshim:$PATH" sh scripts/audit-status.sh 2>&1 | grep -qx "NEWER RUST STABLE: 1.101.0 (pinned: 1.100.0); see rust-toolchain.toml"; expect "report: first stable host read, not the lowest" 0 $? +# A pin problem is said before a rustup failure: the pin is the thing to fix first. +rustup_says "exit 1" +printf '[toolchain]\nchannel = "stable"\n' > rust-toolchain.toml +PATH="$work/rustupshim:$PATH" sh scripts/audit-status.sh 2>&1 | grep -qx "pinned Rust stable is not x.y.z; see rust-toolchain.toml"; expect "report: bad pin said before rustup failure" 0 $? +rm -f rust-toolchain.toml +PATH="$work/rustupshim:$PATH" sh scripts/audit-status.sh 2>&1 | grep -qx "pinned Rust version not found in rust-toolchain.toml"; expect "report: missing pin said before rustup failure" 0 $? +printf '[toolchain]\nchannel = "1.100.0"\n' > rust-toolchain.toml +# A toolchain whose name only contains "stable-" (a custom one) is not the stable channel. +rustup_says "printf '%s\\n' 'my-stable-x86_64-unknown-linux-gnu - up to date: 1.50.0 (a 2025-01-01)' 'my-stable-x86_64-unknown-linux-gnu - update available: 1.50.0 (a 2025-01-01) -> 1.51.0 (b 2025-02-01)' 'stable-x86_64-unknown-linux-gnu - up to date: 1.100.0 (a 2026-11-09)'" +PATH="$work/rustupshim:$PATH" sh scripts/audit-status.sh 2>&1 | grep -qx "pinned Rust 1.100.0 is the latest stable"; expect "report: custom toolchain named *stable- skipped" 0 $? +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 diff --git a/tests/fixtures/README.md b/tests/fixtures/README.md index 8ec3af5..3cad87f 100644 --- a/tests/fixtures/README.md +++ b/tests/fixtures/README.md @@ -3,4 +3,4 @@ Synthetic files only: test CA, test signers and test time stamps generated by a script (Homebrew `openssl@3`) or by Rust test helpers. No real signed documents here: they contain personal data and stay on the Windows PC in `tests/corpus/` (git-ignored). -See "Test data" in `docs/design.md` for the list of cases to cover. +See "Which test data do we use?" in `docs/design.md` for the list of cases to cover.