@sabaiway/agent-workflow-kit 23.7.0 → 23.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +52 -0
- package/SKILL.md +1 -1
- package/capability.json +1 -1
- package/package.json +1 -1
- package/references/modes/coverage-check.md +4 -2
- package/references/modes/recommendations.md +1 -1
- package/tools/checker-block/index.mjs +2 -0
- package/tools/checker-block/place.mjs +71 -0
- package/tools/checker-block/tail.mjs +16 -0
- package/tools/coverage-check/block.mjs +75 -0
- package/tools/coverage-check/help.mjs +47 -0
- package/tools/coverage-check/index.mjs +5 -0
- package/tools/coverage-check.mjs +62 -112
- package/tools/coverage-declared/judge.mjs +2 -3
- package/tools/gates-init.mjs +5 -5
- package/tools/recommendations.mjs +25 -26
- package/tools/source-size/help.mjs +2 -1
- package/tools/source-size/index.mjs +10 -0
- package/tools/source-size/reason.mjs +32 -0
- package/tools/source-size-check.mjs +9 -279
- package/tools/source-size-config.mjs +1 -3
- package/tools/source-size-core.mjs +6 -0
- package/tools/source-size-judge.mjs +10 -4
- package/tools/source-size-report.mjs +39 -22
- package/tools/source-size-runs.mjs +290 -0
- package/tools/source-size-scope.mjs +70 -24
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,58 @@ Semantically versioned ([semver](https://semver.org)), newest first. The `versio
|
|
|
4
4
|
is the current release. `upgrade` mode reads a project's `docs/ai/.workflow-version` and applies
|
|
5
5
|
every `migrations/<version>-<slug>.md` newer than it, in semver order.
|
|
6
6
|
|
|
7
|
+
## 23.9.0 — a failed coverage check shows what failed and the fix first (AD-237)
|
|
8
|
+
|
|
9
|
+
**After `/agent-workflow-kit upgrade`, a red `coverage-check.mjs --check` run opens with its failure, and so do a
|
|
10
|
+
usage mistake and an unexpected error.** Before, a red run printed its machine lines and notes first and its failures
|
|
11
|
+
after them in indented groups, a refused attestation context as a `REFUSED` line; a usage mistake and an unexpected
|
|
12
|
+
error went to standard error.
|
|
13
|
+
|
|
14
|
+
- **A red run prints one block on standard output:** `coverage-check: FAIL — <what failed>`, naming each class it
|
|
15
|
+
meets in a fixed order (the declared list, the lcov file, changed Node lines or files uncovered with their count,
|
|
16
|
+
red-proof obligations unmet with their count, the evidence store, the attestation context refused); then each
|
|
17
|
+
finding at column one starting with its place (`file:line`, a file, or `.` with the path leading its text when the
|
|
18
|
+
path cannot stand as a place); then one `coverage-check: REMEDY — …` line per class; then the lines a green run
|
|
19
|
+
prints, in their old order.
|
|
20
|
+
- **A usage mistake** prints the verdict line and the `Usage:` lines (exit 2); **an unexpected error** prints the
|
|
21
|
+
verdict line naming it, a REMEDY line and the stack, with no machine line (exit 1). Standard error stays empty.
|
|
22
|
+
- **What stays:** every exit code, everything the check judges, both machine lines (`lcov-sha256=` and `attested=`)
|
|
23
|
+
in count and content, and every run that exits 0, byte for byte. Two stated exceptions: `--help` says
|
|
24
|
+
"attestation context refused" where it said `REFUSED`; and in a red run with no attestation context
|
|
25
|
+
the `NO VERDICT` line says the findings stand above it.
|
|
26
|
+
- **A new kit module, `tools/checker-block/`,** places each finding and makes the verdict text, each finding's
|
|
27
|
+
text, the remedies and the after lines safe before the shared composer; the later checkers of the kit's tools will
|
|
28
|
+
use it too.
|
|
29
|
+
|
|
30
|
+
## 23.8.0 — the size record's reasons stay honest, and every run says what its scope left out (AD-236)
|
|
31
|
+
|
|
32
|
+
**After `/agent-workflow-kit upgrade`, the kit writes its own reason `initial adoption` only into record entries the
|
|
33
|
+
write itself creates, and every size check, regeneration and override says what its declared scope did not judge.**
|
|
34
|
+
Before, the recovery line of a half-written size record printed `--reason "initial adoption"`, and run as printed it
|
|
35
|
+
replaced a reason a person had written on a grown entry; an `exclude` entry that matched nothing, and a new file git
|
|
36
|
+
did not know yet, were said by no line.
|
|
37
|
+
|
|
38
|
+
- **`initial adoption` is accepted only for a part of the record the config does not hold yet.** A regeneration that
|
|
39
|
+
raises an entry in a part that already exists refuses it by name and prints the whole change it would write;
|
|
40
|
+
`--override` never takes it.
|
|
41
|
+
- **Every line the kit prints to mint or recover a record carries the placeholder `<why this size is accepted>`**
|
|
42
|
+
wherever the kit's sentence would be refused, and the command line refuses a placeholder as a reason (exit 2,
|
|
43
|
+
`--reason still carries the placeholder …`). The reason is the agent's to write, with no question to the user.
|
|
44
|
+
- **A minted schema-1 config whose tree grew moves to schema 2 even when the regeneration is refused:** the move is written
|
|
45
|
+
and said first, then the raise is refused.
|
|
46
|
+
- **One note per `exclude` entry** on every check, regeneration and override: how many tracked paths under the
|
|
47
|
+
declared roots it left out, or that it left out nothing and why (no tracked path carries it, or the paths that do
|
|
48
|
+
lie outside every declared root). An entry is a literal path prefix, never a pattern.
|
|
49
|
+
- **Two warnings, echoed by `run-gates`:** paths the run would judge that are untracked and not ignored, so the
|
|
50
|
+
index-based scope did not include them, and judged files whose work-tree bytes differ from the index, which the check measures as they stand on
|
|
51
|
+
disk. Each names the first few paths. A refused regeneration or override prints them ahead of its refusal.
|
|
52
|
+
- **The advisor's size item says what holds:** with no gate declared it says so, and never that sizes go unmeasured;
|
|
53
|
+
over a minted record it says the record is kept, and its `--adopt` line carries no reason.
|
|
54
|
+
- **Stated limits:** `--adopt` prints no note and no warning when its check is green; a placeholder already in a
|
|
55
|
+
config, or pasted by hand from the check's hand-record entries, keeps reading; the spec store's layout is counted
|
|
56
|
+
from disk; a judged file differs only where git reports a work-tree change and its bytes differ from the index, so
|
|
57
|
+
a change of file mode alone or a line-ending conversion is no differing file.
|
|
58
|
+
|
|
7
59
|
## 23.7.0 — a failed size check shows what failed and the fix first (AD-235)
|
|
8
60
|
|
|
9
61
|
**After `/agent-workflow-kit upgrade`, a red `source-size-check.mjs --check` run opens with its failure, and so do, in
|
package/SKILL.md
CHANGED
|
@@ -3,7 +3,7 @@ name: agent-workflow-kit
|
|
|
3
3
|
description: Deploy or upgrade a portable AI-agent memory-and-workflow system in any project. Use when the user wants to bootstrap `docs/ai/` + an entry-point `AGENTS.md` (+ `CLAUDE.md` alias) + cap/archive/index enforcement in a new or existing repo, set up the Memory Map and session protocols, install the docs-rotation pre-commit hook, or run `/agent-workflow-kit` / `/agent-workflow-kit upgrade`. Triggers on phrases like "set up the memory system", "deploy the AI workflow here", "bootstrap docs/ai", "upgrade the workflow". New to the epic, story and task tier? Run `/agent-workflow-kit tier`. A typed decision with a confidence from Jev? Run `/agent-workflow-kit jev`.
|
|
4
4
|
disable-model-invocation: true
|
|
5
5
|
metadata:
|
|
6
|
-
version: '23.
|
|
6
|
+
version: '23.9.0'
|
|
7
7
|
---
|
|
8
8
|
|
|
9
9
|
# agent-workflow-kit
|
package/capability.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sabaiway/agent-workflow-kit",
|
|
3
|
-
"version": "23.
|
|
3
|
+
"version": "23.9.0",
|
|
4
4
|
"description": "Portable, cross-agent memory & workflow for AI coding agents — Claude Code, Codex, Cursor, Devin Desktop. One command deploys an AGENTS.md entry point + docs/ai context with cap/archive/index enforcement into any repo.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ai-agents",
|
|
@@ -6,10 +6,12 @@ The **final-run checker** (strip-the-kit D3(c)+(d)) — two deterministic arms o
|
|
|
6
6
|
|
|
7
7
|
Run `node ${CLAUDE_SKILL_DIR}/tools/coverage-check.mjs --check [--cwd <dir>]`:
|
|
8
8
|
|
|
9
|
-
0. **Attestation precondition (the provenance arm).** An lcov on disk carries no evidence of the tree it came from, so reading one and issuing a verdict certifies whatever happens to be there — the false GREEN direction is the dangerous one, because a line appended AFTER the suite ran has no `DA` entry and therefore reads non-executable ("nothing to cover"). Provenance is a CONSEQUENCE in exactly one context: a `run-gates --final` run deletes the artifact before any gate spawns. That runner mints a random nonce and writes `final-start.attempt` as a ONE-WAY COMMITMENT over `{nonce, tree fingerprint, base}`; the raw nonce rides the environment to this child, which recomputes the commitment and requires the record to carry it. Neither half suffices alone — a bare nonce is unverifiable, a persisted attempt id is reconstructible from public repo state — and the commitment is also the only place the BASE is bound, since no record stores it. The raw nonce is stripped from the red-proof probe environment so no descendant retains a live capability. `attested=` states whether a coverage VERDICT was ISSUED — pass **or** fail — never whether coverage passed: a valid handshake over an lcov that lists uncovered lines still reads `attested=yes` and still exits 1. Outcomes: **attested** → the coverage verdict is issued; **no handshake** → `attested=no` + `NO VERDICT` (exit 0, findings still printed, uncovered lines still exit 1 — the findings contract is unchanged); **a valid handshake over a run that read NO lcov BYTES** (the file is absent, or the path was refused as a non-regular file) → `attested=no` + `NO VERDICT`: the run owned the artifact's lifetime and read nothing, so it certifies NOTHING — reading `yes` there would be the false green this arm exists to close, one layer up. The predicate is the consumed bytes (`lcov-sha256` is a digest, not `none`), never the skip flag, so a refused path can never attest either. The two halves are independent: WITHHOLDING the verdict never changes an exit code — an absent file stays exit 0 (the loud `skipped-no-lcov`), and the refused non-regular path keeps its OWN fail-closed exit 1; **a handshake describing another tree or matching no recorded attempt** →
|
|
10
|
-
1. **Coverage arm (D3(d)):** every CHANGED executable Node line (`.mjs`/`.cjs`/`.js`, tracked working-vs-HEAD changes + untracked-not-ignored files) must be covered — uncovered lines are LISTED `file:line` and fail; a changed file ABSENT from the lcov map is a file-level red (never "non-executable" by silence); changed out-of-domain files (e.g. `.sh`) and unsupported-source files (e.g. `.ts`) are LISTED — the claim is narrowed honestly, not widened. NO lcov file at the path (ENOENT) = a LOUD `skipped-no-lcov` (exit 0, stated — produce the file via the unit-tests gate's lcov reporters); any other status failure exits 1 naming the path and the code where it has one; a symlink at the path is a refusal (lstat, no-follow). **The declared list:** a project may name in `docs/ai/coverage-declared.json` — a strict config written by hand, `{ "schema": 1, "entries": [{ "path": "<exact repo path>", "reason": "<one line>" }] }` — changed files nothing runs at their repository path (a fixture a test copies out and runs elsewhere). A listed changed file with no executed line in the lcov this run read is not judged and is printed with its reason; one with an executed line is judged as any other file; every line about the list prints on every run. An unreadable or malformed list fails (exit 1) and applies nothing. Under a final run the list must be the one the run started with, or the
|
|
9
|
+
0. **Attestation precondition (the provenance arm).** An lcov on disk carries no evidence of the tree it came from, so reading one and issuing a verdict certifies whatever happens to be there — the false GREEN direction is the dangerous one, because a line appended AFTER the suite ran has no `DA` entry and therefore reads non-executable ("nothing to cover"). Provenance is a CONSEQUENCE in exactly one context: a `run-gates --final` run deletes the artifact before any gate spawns. That runner mints a random nonce and writes `final-start.attempt` as a ONE-WAY COMMITMENT over `{nonce, tree fingerprint, base}`; the raw nonce rides the environment to this child, which recomputes the commitment and requires the record to carry it. Neither half suffices alone — a bare nonce is unverifiable, a persisted attempt id is reconstructible from public repo state — and the commitment is also the only place the BASE is bound, since no record stores it. The raw nonce is stripped from the red-proof probe environment so no descendant retains a live capability. `attested=` states whether a coverage VERDICT was ISSUED — pass **or** fail — never whether coverage passed: a valid handshake over an lcov that lists uncovered lines still reads `attested=yes` and still exits 1. Outcomes: **attested** → the coverage verdict is issued; **no handshake** → `attested=no` + `NO VERDICT` (exit 0, findings still printed, uncovered lines still exit 1 — the findings contract is unchanged); **a valid handshake over a run that read NO lcov BYTES** (the file is absent, or the path was refused as a non-regular file) → `attested=no` + `NO VERDICT`: the run owned the artifact's lifetime and read nothing, so it certifies NOTHING — reading `yes` there would be the false green this arm exists to close, one layer up. The predicate is the consumed bytes (`lcov-sha256` is a digest, not `none`), never the skip flag, so a refused path can never attest either. The two halves are independent: WITHHOLDING the verdict never changes an exit code — an absent file stays exit 0 (the loud `skipped-no-lcov`), and the refused non-regular path keeps its OWN fail-closed exit 1; **a handshake describing another tree or matching no recorded attempt** → the class attestation context refused (exit 1), never a verdict in either direction. One fully anchored `coverage-check: attested=<yes|no>` machine line rides every run, on the same exactly-once contract as the sha line — and a withheld verdict TRAVELS: `run-gates` carries it as `coverage=not-run` on the summary line and names it on the checker's table row, and `core-evidence summary` never renders an unqualified GREEN over a final record that consumed no lcov. Stated residuals, both named rather than implied: (a) an operator who runs both processes can forge the store or the code — the kit's standing self-discipline posture, not a security boundary; (b) **"the run owns the artifact" is exclusive by CONVENTION over the fixed path, not enforced** — a writer outside the run (a second `run-gates`, a hand-run `--only unit-tests`, an orphaned test process) can place foreign evidence between the deletion and the checker's read, and every check then agrees. Closing (b) needs an attempt-unique artifact path, which the runner can name but the declared producer cmd must reference — queued as LCOV-EXCLUSIVE-OWNERSHIP. What this arm removes is the false green that needs no second process and nobody trying: evidence that predates the edit.
|
|
10
|
+
1. **Coverage arm (D3(d)):** every CHANGED executable Node line (`.mjs`/`.cjs`/`.js`, tracked working-vs-HEAD changes + untracked-not-ignored files) must be covered — uncovered lines are LISTED `file:line` and fail; a changed file ABSENT from the lcov map is a file-level red (never "non-executable" by silence); changed out-of-domain files (e.g. `.sh`) and unsupported-source files (e.g. `.ts`) are LISTED — the claim is narrowed honestly, not widened. NO lcov file at the path (ENOENT) = a LOUD `skipped-no-lcov` (exit 0, stated — produce the file via the unit-tests gate's lcov reporters); any other status failure exits 1 naming the path and the code where it has one; a symlink at the path is a refusal (lstat, no-follow). **The declared list:** a project may name in `docs/ai/coverage-declared.json` — a strict config written by hand, `{ "schema": 1, "entries": [{ "path": "<exact repo path>", "reason": "<one line>" }] }` — changed files nothing runs at their repository path (a fixture a test copies out and runs elsewhere). A listed changed file with no executed line in the lcov this run read is not judged and is printed with its reason; one with an executed line is judged as any other file; every line about the list prints on every run. An unreadable or malformed list fails (exit 1) and applies nothing. Under a final run the list must be the one the run started with, or the attestation context is refused (exit 1).
|
|
11
11
|
2. **Red-proof arm (D3(c)):** every authoritative current-base `red-proof` declaration must verify — the bound test file exists (deleted fails), its content sha256 matches the declaration (custody), the test resolves (zero-match fails) and runs green N/N NOW, and the declaration's pre-fix fingerprint differs from the current tree (equal = reuse/forgery, refused). A malformed evidence store fails CLOSED.
|
|
12
12
|
|
|
13
|
+
**The red output.** A red run prints ONE block on standard output and nothing on standard error. Its first line, `coverage-check: FAIL — …`, names each class the run meets, in this order: the declared list, the lcov file, changed Node lines or files uncovered (with their count), red-proof obligations unmet (with their count), the evidence store, the attestation context refused. Then each finding at its place — `file:line`, a file, or `.` with the path leading its text when the path cannot stand as a place — then one `coverage-check: REMEDY — …` line per class met, then the lines a green run also prints: `lcov-sha256=`, the notes, the declared list's lines, the verified red-proof line, `attested=` and, where no verdict was issued and the context was not refused, the `NO VERDICT` line. A usage mistake prints the verdict line and the `Usage:` lines (exit 2); an unexpected error prints the verdict line naming it, a remedy line and the stack, with no machine line (exit 1). Every green run but `--help` prints what it printed before; `--help` says "attestation context refused" where it said `REFUSED`.
|
|
14
|
+
|
|
13
15
|
Wire it as the LAST declared gate in `docs/ai/gates.json` — `run-gates --final` REFUSES a declaration where the canonical coverage-check gate is not last (nothing may run after the checker consumed the lcov) or where its cmd is not ONE plain invocation of the kit's OWN tool (a masked form or a lookalike path never counts).
|
|
14
16
|
|
|
15
17
|
**Invariants:** writes nothing · spawns read-only `git` queries + the bound-test probes (`node --test`, shell-free) · no network · exit 0 pass / 1 fail (locations listed) / 2 usage.
|
|
@@ -37,7 +37,7 @@ A variant's posture note, where its key has one, is printed by `init` from this
|
|
|
37
37
|
|
|
38
38
|
- `gates-inert` — the gate matrix is DECLARED but verifies nothing, and the two causes have different remedies, so the item renders a different apply for each. **Cause A** — a canonical `coverage-check` gate with no producer gate declared BEFORE it (none at all, or one declared after it, which writes the lcov too late): the run certifies no coverage of its own — `coverage=not-run` when nothing wrote an lcov, or a verdict over STALE bytes an earlier run left in the git dir, which is worse because it reads as `coverage=certified`. The remedy needs the producer to run BEFORE the checker — declared or MOVED there. When the checker is the LAST declared gate and the project's own scripts yield an offerable producer, the fill PLACES that producer before it, so the apply is the ordinary `gates-init` dry-run preview. Otherwise — no offerable producer, or a checker that is not last — it is the user item `gates-inert.unfillable`: the user's own step is to edit `docs/ai/gates.json` (the exact producer form lives in `${CLAUDE_SKILL_DIR}/references/modes/gates.md`), because the fill never reorders entries it did not write. When the declaration carries, anywhere, a gate in a form an earlier kit wrote that the upgrade moves (one whose tail holds only test paths), or the fill withheld its `node --test` script because the kit folder does not hold this kit's command and reporter, the apply is `/agent-workflow-kit upgrade` in place of both: it moves an earlier kit's gate with no question, or a line of its report names what stops it. **Cause B** — every declared gate is one of the kit's own canonical checkers, so the matrix runs no project-verification command at all: the apply is the `gates-init` dry-run preview, the same consent-gated seeder the `gates-declaration` item renders, and after the SAME confirmation you run the `--apply` line it prints. Neither cause changes any gate result, exit code or receipt — the item adds no enforcement, only the offer. Risk profile: `docs/ai/gates.json` is a PRIVILEGED file (a declared gate is auto-approvable by the wired hook), so both causes land in the same place — where the fill can help, it declares a project-controlled command on your explicit yes; where it cannot, the edit is the user's own step.
|
|
39
39
|
|
|
40
|
-
- `source-size` — the arms differ by what the declared gate IS. **`adopted-elsewhere`** — the gate runs a DIFFERENT real copy of this checker (a vendored deployment): the practice runs, the advisor cannot resolve it as its own sibling, and the realpath anchor does not widen (that stops a lookalike). So the convergence is the ack writer's preview (`--lane source-size-copy` → `sourceSizeCopyAck`), never `--adopt`, which would mint and then be refused by the fill on the declared id. The fingerprint binds the declared claims AS AUTHORED, sorted, not resolved paths, so a second external copy re-fires it. **`id-squatter`** — a gate carries the `source-size` id and is not this checker under any reading:
|
|
40
|
+
- `source-size` — the arms differ by what the declared gate IS. **`adopted-elsewhere`** — the gate runs a DIFFERENT real copy of this checker (a vendored deployment): the practice runs, the advisor cannot resolve it as its own sibling, and the realpath anchor does not widen (that stops a lookalike). So the convergence is the ack writer's preview (`--lane source-size-copy` → `sourceSizeCopyAck`), never `--adopt`, which would mint and then be refused by the fill on the declared id. The fingerprint binds the declared claims AS AUTHORED, sorted, not resolved paths, so a second external copy re-fires it. **`id-squatter`** — a gate carries the `source-size` id and is not this checker under any reading: the gate matrix reads as running the size check while it runs none, so it is the user's own step (rename the id, or repoint the cmd at this `--check`). **`unminted`**, for both copies: a gate refusing every run over an authored or incomplete record (over an absent one the check judges layout alone), attention, and NO acknowledgement silences it; only the verb differs (with the gate declared elsewhere, `--write-baseline`); a line carrying the placeholder takes your own sentence, by the `recipe:` line. **`schema-1`** — the check stops on a minted schema-1 config, so this arm comes first: its `--write-baseline` line carries NO reason (a pinned one would launder a raise; a raise riding the move refuses, and the agent writes that raise's reason from what the run shows, with no question to the user), every run until the move. **`layout`** — on a config with no layout record, the record of the piles already there comes first, as its own item: a no writes nothing and the item returns every run; its `recipe:` line names the branch states, and `source-size.layout` is applied before the `hook-checks` check line runs, whose layout line follows that record. **`piles`** — each recorded pile with no queue row gets one, at the end of the queue's Later bucket; a write the queue's own declared check would refuse is not made and the stated skip says why. Risk profile: `docs/ai/gates.json` is a PRIVILEGED file, so every arm here either records an acknowledgement or hands you an edit — the kit declares nothing on its own.
|
|
41
41
|
- `gate-hook` — the offer wires the hook on the harness lane: the agent applies it on the chat yes after the check; `init` previews and applies it on the terminal yes as the route the user may take instead. Over a wired hook the key renders the kit item `gate-hook.not-current` instead: the placed hook file is absent or differs from the body the kit writes for it. An older body validates your declaration through its OWN baked copy and goes dark on a key it does not know, such as `lcovProducer` (present, whatever its value), so every gate prompts again with no error anywhere. The agent applies the kit item with no question after the check, whose result names the file with its new digest, and the old one too over a differing file; it writes only the hook file. Risk profile: the offer places a hook file and wires one settings entry; the kit item writes one hook file with the kit's body; the declaration is never touched.
|
|
42
42
|
- `enforcement` — copies the bundled runtime files of `references/scripts/` into the kit folder `scripts/agent-workflow/`, then runs the project's own hook installer, which installs the pre-commit hook. The lane is harness: the agent applies the item on the chat yes after the check, whose result shows each script the kit places with its bytes and the installer it runs with its bytes; `init` applies it on the batch terminal yes as the route the user may take instead. The copy is create-only: an existing file stands and nothing is written through a link, and the offer renders only on no Node evidence. The hook invokes `node` directly, so a committer without it on PATH gets a loud failure. The installer refuses to overwrite a pre-commit hook it did not write: an install it refuses removes the scripts this apply copied, and the item is offered again with the installer's output shown; over a pre-commit hook the installer did not write the item is not offered — its skip names the user's own step. Risk profile: local tooling and a Git hook are added on the chat yes after the check, or on init's y.
|
|
43
43
|
- `hook-checks` — the agent applies the item on the chat yes after the check; `init` applies it on the terminal y as the route the user may take instead. Risk profile: future commits stop on the rules check and, where judged, on the size check's findings — lines, aggregate and layout; over a clone with no pre-commit hook the installer writes its whole hook, so commits also stop on its docs and archive lines.
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { composeRedBlock } from '../../references/scripts/shared/index.mjs';
|
|
2
|
+
|
|
3
|
+
const ROOT_PLACE = '.';
|
|
4
|
+
const PARENT_SEGMENT = '..';
|
|
5
|
+
const PATH_SEPARATOR = '/';
|
|
6
|
+
const LINE_MARKER = ':';
|
|
7
|
+
const FINDING_SEPARATOR = ': ';
|
|
8
|
+
const EMPTY_TEXT = '';
|
|
9
|
+
const SPACE = ' ';
|
|
10
|
+
const MIN_LINE = 1;
|
|
11
|
+
const TRAILING_SLASH = /\/$/;
|
|
12
|
+
const UNSAFE_PLACE = /[\\:\r\n]/;
|
|
13
|
+
const CARRIAGE_RETURN = /\r/g;
|
|
14
|
+
const LINE_FEED = /\n/g;
|
|
15
|
+
const LEADING_SPACE = /^ /;
|
|
16
|
+
const SHOWN_CARRIAGE_RETURN = '\\r';
|
|
17
|
+
const SHOWN_LINE_FEED = '\\n';
|
|
18
|
+
const SHOWN_LEADING_SPACE = '\\u0020';
|
|
19
|
+
|
|
20
|
+
const escapeLineBreaks = (text) => typeof text === 'string'
|
|
21
|
+
? text.replace(CARRIAGE_RETURN, SHOWN_CARRIAGE_RETURN).replace(LINE_FEED, SHOWN_LINE_FEED)
|
|
22
|
+
: text;
|
|
23
|
+
|
|
24
|
+
export const escapeLineText = (text) => typeof text === 'string'
|
|
25
|
+
? escapeLineBreaks(text).replace(LEADING_SPACE, SHOWN_LEADING_SPACE) : text;
|
|
26
|
+
|
|
27
|
+
export const placeFinding = ({ root, name, path, line, laterLines = [] }) => {
|
|
28
|
+
const rootPrefix = root.replace(TRAILING_SLASH, EMPTY_TEXT);
|
|
29
|
+
const relative = path === (rootPrefix || PATH_SEPARATOR) ? ROOT_PLACE
|
|
30
|
+
: typeof path === 'string' && path.startsWith(`${rootPrefix}${PATH_SEPARATOR}`)
|
|
31
|
+
? path.slice(rootPrefix.length + PATH_SEPARATOR.length) : path;
|
|
32
|
+
if (relative === ROOT_PLACE && line === undefined) return { place: ROOT_PLACE, lead: EMPTY_TEXT };
|
|
33
|
+
const lineSuffix = line === undefined ? EMPTY_TEXT : `${LINE_MARKER}${String(line)}`;
|
|
34
|
+
const place = String(relative) + lineSuffix;
|
|
35
|
+
const segments = typeof path === 'string'
|
|
36
|
+
? (path.startsWith(PATH_SEPARATOR) ? path.slice(PATH_SEPARATOR.length) : path).split(PATH_SEPARATOR)
|
|
37
|
+
: [];
|
|
38
|
+
const ownPlace = typeof path === 'string'
|
|
39
|
+
&& segments.every((segment) => segment !== EMPTY_TEXT && segment !== ROOT_PLACE && segment !== PARENT_SEGMENT)
|
|
40
|
+
&& relative !== EMPTY_TEXT && relative !== ROOT_PLACE && !UNSAFE_PLACE.test(relative)
|
|
41
|
+
&& !relative.startsWith(SPACE) && relative !== name
|
|
42
|
+
&& (line === undefined || (Number.isSafeInteger(line) && line >= MIN_LINE))
|
|
43
|
+
&& !laterLines.some((text) => typeof text === 'string' && text.startsWith(`${place}${FINDING_SEPARATOR}`));
|
|
44
|
+
return ownPlace ? { place, lead: EMPTY_TEXT }
|
|
45
|
+
: { place: ROOT_PLACE, lead: `${escapeLineText(String(path) + lineSuffix)}${FINDING_SEPARATOR}` };
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const mapList = (list, transform) => Array.isArray(list) ? Array.from(list, transform) : list;
|
|
49
|
+
|
|
50
|
+
export const composeCheckerBlock = ({ name, root, failed, findings = [], remedies, after = [] }) => {
|
|
51
|
+
const afterLines = mapList(after, escapeLineBreaks);
|
|
52
|
+
const findingList = mapList(findings, (finding) => {
|
|
53
|
+
if (finding === null || typeof finding !== 'object') return finding;
|
|
54
|
+
const { path, line, text, detail } = finding;
|
|
55
|
+
const { place, lead } = placeFinding({
|
|
56
|
+
root, name, path, line, laterLines: Array.isArray(afterLines) ? afterLines : [],
|
|
57
|
+
});
|
|
58
|
+
return {
|
|
59
|
+
place,
|
|
60
|
+
text: typeof text === 'string' && text.length ? lead + escapeLineText(text) : text,
|
|
61
|
+
...(detail === undefined ? {} : { detail }),
|
|
62
|
+
};
|
|
63
|
+
});
|
|
64
|
+
return composeRedBlock({
|
|
65
|
+
name,
|
|
66
|
+
failed: escapeLineText(failed),
|
|
67
|
+
findings: findingList,
|
|
68
|
+
remedies: mapList(remedies, escapeLineText),
|
|
69
|
+
after: afterLines,
|
|
70
|
+
});
|
|
71
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { guardChecker } from '../../references/scripts/shared/index.mjs';
|
|
2
|
+
|
|
3
|
+
const LINE_FEED = '\n';
|
|
4
|
+
|
|
5
|
+
export const runCheckerTail = ({ name, exitCode, remedy }, run, host) => {
|
|
6
|
+
const answer = guardChecker({ name, exitCode, remedy }, run);
|
|
7
|
+
const writeAnswer = (result) => {
|
|
8
|
+
const lines = result.lines ?? result.stdout.split(LINE_FEED);
|
|
9
|
+
const text = lines.join(LINE_FEED);
|
|
10
|
+
if (text.length) host.stdout.write(text.endsWith(LINE_FEED) ? text : `${text}${LINE_FEED}`);
|
|
11
|
+
const code = result.code ?? result.exitCode;
|
|
12
|
+
host.exitCode = code;
|
|
13
|
+
return code;
|
|
14
|
+
};
|
|
15
|
+
return answer instanceof Promise ? answer.then(writeAnswer) : writeAnswer(answer);
|
|
16
|
+
};
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { composeCheckerBlock } from '../checker-block/index.mjs';
|
|
2
|
+
import { COVERAGE_DECLARED_REL } from '../coverage-declared/index.mjs';
|
|
3
|
+
|
|
4
|
+
export const CHECKER_NAME = 'coverage-check';
|
|
5
|
+
const ZERO = 0;
|
|
6
|
+
const CLASS_SEPARATOR = '; ';
|
|
7
|
+
const WITHHELD_PREFIX = `${CHECKER_NAME}: NO VERDICT — `;
|
|
8
|
+
const RED_NO_CONTEXT = `${WITHHELD_PREFIX}no final-run attestation context — a verdict is issued only inside the run that owns the lcov (run-gates.mjs --final); findings above are informational`;
|
|
9
|
+
const CLASS_TEXTS = [
|
|
10
|
+
{
|
|
11
|
+
verdict: () => 'the declared list is unusable',
|
|
12
|
+
remedy: `fix what each finding above names in ${COVERAGE_DECLARED_REL}, then re-run`,
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
verdict: () => 'the lcov file is unusable',
|
|
16
|
+
remedy: 'let the declared unit-tests gate write the lcov file as a regular file this run can read, then re-run',
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
verdict: (count) => `${count} changed Node line(s) or file(s) uncovered`,
|
|
20
|
+
remedy: 'cover each changed line and file above with a test that executes it, then re-run',
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
verdict: (count) => `${count} red-proof obligation(s) unmet`,
|
|
24
|
+
remedy: 're-observe each red proof above on its pre-fix tree, or restore its bound test until it runs green N/N',
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
verdict: () => 'the evidence store is unusable',
|
|
28
|
+
remedy: 'repair or move aside the evidence store above, then re-run',
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
verdict: () => 'the attestation context was refused',
|
|
32
|
+
remedy: 're-run run-gates.mjs --final on a tree no gate changes',
|
|
33
|
+
},
|
|
34
|
+
];
|
|
35
|
+
|
|
36
|
+
export const buildDeclaredFindings = ({ configFailure, failures }) => configFailure
|
|
37
|
+
? [{ path: COVERAGE_DECLARED_REL, text: configFailure }] : failures;
|
|
38
|
+
|
|
39
|
+
export const buildLcovFindings = (failure) => failure ? [{
|
|
40
|
+
path: failure.path,
|
|
41
|
+
text: failure.error
|
|
42
|
+
? `status could not be read (${failure.error.code ?? failure.error.message})`
|
|
43
|
+
: 'not a regular file (a symlink/device is never read — fail closed)',
|
|
44
|
+
}] : [];
|
|
45
|
+
|
|
46
|
+
export const buildUncoveredFindings = (failures) => failures.map(({ path, line }) => ({
|
|
47
|
+
path,
|
|
48
|
+
...(line === undefined ? {} : { line }),
|
|
49
|
+
text: line === undefined ? 'absent from coverage — the suite never executed this changed file'
|
|
50
|
+
: 'changed line not executed by the suite',
|
|
51
|
+
}));
|
|
52
|
+
|
|
53
|
+
export const buildRedProofFindings = (failures) => failures.map(({ file, testId, reason }) => ({
|
|
54
|
+
path: file, text: `${testId}: ${reason}`,
|
|
55
|
+
}));
|
|
56
|
+
|
|
57
|
+
export const buildEvidenceFindings = (path, failure) => failure ? [{ path, text: failure }] : [];
|
|
58
|
+
|
|
59
|
+
export const buildAttestationFindings = (root, refusal) => refusal ? [{ path: root, text: refusal }] : [];
|
|
60
|
+
|
|
61
|
+
export const isRed = (classes) => classes.some((findings) => findings.length > ZERO);
|
|
62
|
+
|
|
63
|
+
export const composeCoverageBlock = ({ root, classes, after, withoutContext = false }) => {
|
|
64
|
+
if (!isRed(classes)) return after;
|
|
65
|
+
const met = classes.map((findings, index) => ({ findings, ...CLASS_TEXTS[index] }))
|
|
66
|
+
.filter(({ findings }) => findings.length > ZERO);
|
|
67
|
+
return composeCheckerBlock({
|
|
68
|
+
name: CHECKER_NAME,
|
|
69
|
+
root,
|
|
70
|
+
failed: met.map(({ findings, verdict }) => verdict(findings.length)).join(CLASS_SEPARATOR),
|
|
71
|
+
findings: met.flatMap(({ findings }) => findings),
|
|
72
|
+
remedies: met.map(({ remedy }) => remedy),
|
|
73
|
+
after: after.map((line) => withoutContext && line.startsWith(WITHHELD_PREFIX) ? RED_NO_CONTEXT : line),
|
|
74
|
+
});
|
|
75
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { COVERAGE_DECLARED_REL } from '../coverage-declared/index.mjs';
|
|
2
|
+
|
|
3
|
+
export const LCOV_BASENAME = 'agent-workflow-lcov.info';
|
|
4
|
+
const USAGE = 'Usage:\n node coverage-check.mjs --check [--cwd <dir>]';
|
|
5
|
+
const HELP = `coverage-check — the D3(c)+(d) final-run checker (agent-workflow family).
|
|
6
|
+
|
|
7
|
+
${USAGE}
|
|
8
|
+
|
|
9
|
+
Reads the FIXED kit-owned lcov file (<git dir>/${LCOV_BASENAME}; AW_LCOV_FILE overrides —
|
|
10
|
+
produced by the declared unit-tests gate cmd's --experimental-test-coverage lcov reporters and
|
|
11
|
+
deleted fresh by run-gates --final), lists uncovered CHANGED executable Node lines file:line,
|
|
12
|
+
lists changed out-of-domain files (the coverage claim is narrowed to Node lines), and VERIFIES
|
|
13
|
+
every current-base red-proof record: bound test present, content hash unchanged, green N/N
|
|
14
|
+
(AW_CORE_EVIDENCE_RERUNS, default 3), pre-fix fingerprint differing from the current tree.
|
|
15
|
+
An absent lcov file (ENOENT) is a LOUD skipped-no-lcov (exit 0 — NO coverage check ran, stated).
|
|
16
|
+
Any other lcov status failure, a symlinked lcov path, an uncovered line, a broken red-proof
|
|
17
|
+
obligation, or a malformed evidence store fails (exit 1).
|
|
18
|
+
A changed file listed in ${COVERAGE_DECLARED_REL} (one { path, reason } entry per file nothing
|
|
19
|
+
runs at its repository path) with no executed line in the lcov read is not judged; it and every
|
|
20
|
+
other list line print on every run. An unreadable or malformed list fails (exit 1); with a context
|
|
21
|
+
the list must be the one the final run started with (AW_FINAL_ATTEST_DECLARED), else the run
|
|
22
|
+
fails as attestation context refused (exit 1).
|
|
23
|
+
|
|
24
|
+
A coverage VERDICT is issued ONLY inside the run that owns the artifact's lifetime: run-gates
|
|
25
|
+
--final deletes the lcov before any gate spawns and hands this checker an attestation context
|
|
26
|
+
(a nonce whose one-way commitment over {nonce, fingerprint, base} is the final-start attempt id).
|
|
27
|
+
One anchored machine line rides every run: coverage-check: attested=<yes|no>. It states whether a
|
|
28
|
+
coverage VERDICT was ISSUED — pass OR fail — never that coverage passed.
|
|
29
|
+
attested=yes → a verdict was issued over the lcov BYTES this run read (a failing one still
|
|
30
|
+
exits 1); the predicate is the consumed digest, never the skip flag.
|
|
31
|
+
attested=no → NO VERDICT: no handshake, or no lcov bytes were read at all (an absent file or a
|
|
32
|
+
refused path — nothing read, nothing certified). Withholding a verdict never
|
|
33
|
+
changes an exit code: an absent lcov stays exit 0, a refused non-regular path
|
|
34
|
+
keeps its own fail-closed exit 1, and uncovered lines still exit 1. Findings are
|
|
35
|
+
still printed; run-gates carries the withheld verdict as coverage=not-run.
|
|
36
|
+
attestation context refused (exit 1) → the context describes another tree or another declared
|
|
37
|
+
list, or matches no recorded attempt.
|
|
38
|
+
Residual, stated: ownership of the fixed path is CONVENTION, not enforcement — a concurrent writer
|
|
39
|
+
to it can still place foreign evidence (queued as LCOV-EXCLUSIVE-OWNERSHIP).
|
|
40
|
+
|
|
41
|
+
Sandbox-safe: no network; writes nothing; spawns read-only git queries and the bound-test
|
|
42
|
+
probes (node --test, shell-free) — the D4 sandbox lane. The attestation variables are consumed and
|
|
43
|
+
removed from this process's environment before anything spawns, so no child inherits the capability.
|
|
44
|
+
Read-only. Exit codes: 0 pass / no-verdict / skipped-loud; 1 fail or attestation context refused; 2 usage.`;
|
|
45
|
+
|
|
46
|
+
export const composeHelp = () => HELP;
|
|
47
|
+
export const composeUsage = () => USAGE;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export {
|
|
2
|
+
CHECKER_NAME, composeCoverageBlock, isRed, buildDeclaredFindings, buildLcovFindings,
|
|
3
|
+
buildUncoveredFindings, buildRedProofFindings, buildEvidenceFindings, buildAttestationFindings,
|
|
4
|
+
} from './block.mjs';
|
|
5
|
+
export { LCOV_BASENAME, composeHelp, composeUsage } from './help.mjs';
|