@sabaiway/agent-workflow-kit 2.0.0 → 3.0.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.
Files changed (102) hide show
  1. package/CHANGELOG.md +74 -0
  2. package/README.md +6 -5
  3. package/SKILL.md +12 -8
  4. package/bin/install.mjs +1 -1
  5. package/bridges/antigravity-cli-bridge/SKILL.md +16 -4
  6. package/bridges/antigravity-cli-bridge/bin/agy-review-honesty.test.mjs +150 -0
  7. package/bridges/antigravity-cli-bridge/bin/agy-review-model-screen.test.mjs +76 -0
  8. package/bridges/antigravity-cli-bridge/bin/agy-review.sh +131 -23
  9. package/bridges/antigravity-cli-bridge/bin/agy-review.test.mjs +193 -15
  10. package/bridges/antigravity-cli-bridge/capability.json +12 -8
  11. package/bridges/antigravity-cli-bridge/references/driving-agy.md +6 -2
  12. package/bridges/antigravity-cli-bridge/references/models-and-flags.md +3 -2
  13. package/bridges/antigravity-cli-bridge/references/review-prompt.md +1 -1
  14. package/bridges/codex-cli-bridge/SKILL.md +8 -1
  15. package/bridges/codex-cli-bridge/bin/codex-review-honesty.test.mjs +143 -0
  16. package/bridges/codex-cli-bridge/bin/codex-review.sh +71 -10
  17. package/bridges/codex-cli-bridge/bin/codex-review.test.mjs +93 -10
  18. package/bridges/codex-cli-bridge/capability.json +3 -2
  19. package/capability.json +1 -1
  20. package/migrations/3.0.0-hardened-core-loop.md +44 -0
  21. package/migrations/README.md +1 -1
  22. package/package.json +2 -2
  23. package/references/hooks/gate-approve.mjs +1 -1
  24. package/references/modes/bootstrap.md +3 -3
  25. package/references/modes/commit-guard.md +19 -0
  26. package/references/modes/core-evidence.md +15 -0
  27. package/references/modes/coverage-check.md +12 -0
  28. package/references/modes/doc-parity.md +7 -6
  29. package/references/modes/gates.md +7 -6
  30. package/references/modes/grounding.md +1 -2
  31. package/references/modes/hook.md +1 -1
  32. package/references/modes/review-state.md +3 -3
  33. package/references/modes/upgrade.md +6 -6
  34. package/references/modes/velocity.md +2 -2
  35. package/references/scripts/archive-decisions.mjs +1 -1
  36. package/references/scripts/install-git-hooks-repo-exec.test.mjs +82 -0
  37. package/references/scripts/install-git-hooks.mjs +90 -18
  38. package/references/scripts/install-git-hooks.test.mjs +102 -0
  39. package/references/scripts/migrate-gates-branches.test.mjs +157 -0
  40. package/references/scripts/migrate-gates.mjs +395 -0
  41. package/references/scripts/migrate-gates.test.mjs +284 -0
  42. package/references/templates/agent_rules.md +2 -2
  43. package/tools/ack-write.mjs +1 -1
  44. package/tools/atomic-write.mjs +2 -2
  45. package/tools/autonomy-config.mjs +1 -1
  46. package/tools/autonomy-doctor.mjs +1 -1
  47. package/tools/autonomy-write.mjs +1 -1
  48. package/tools/bridge-settings-read.mjs +1 -1
  49. package/tools/bridge-settings.mjs +1 -1
  50. package/tools/changed-surface.mjs +8 -69
  51. package/tools/cheap-agents.mjs +2 -2
  52. package/tools/commands.mjs +17 -10
  53. package/tools/commit-guard.mjs +167 -0
  54. package/tools/core-evidence.mjs +914 -0
  55. package/tools/coverage-check.mjs +260 -0
  56. package/tools/delegation.mjs +1 -1
  57. package/tools/detect-backends.mjs +7 -6
  58. package/tools/doc-parity.mjs +11 -27
  59. package/tools/engine-source.mjs +1 -1
  60. package/tools/family-members.mjs +1 -1
  61. package/tools/family-registry.mjs +1 -1
  62. package/tools/fs-safe.mjs +1 -1
  63. package/tools/gate-hook.mjs +1 -1
  64. package/tools/{seed-gates.mjs → gates-init.mjs} +58 -52
  65. package/tools/grounding.mjs +6 -83
  66. package/tools/hide-footprint.mjs +1 -1
  67. package/tools/inject-methodology.mjs +1 -1
  68. package/tools/known-footprint.mjs +1 -1
  69. package/tools/labels.mjs +1 -1
  70. package/tools/lcov.mjs +6 -10
  71. package/tools/lens-region.mjs +1 -1
  72. package/tools/manifest/validate.mjs +19 -0
  73. package/tools/migrate-adr-store.mjs +2 -2
  74. package/tools/orchestration-config.mjs +1 -1
  75. package/tools/orchestration-write.mjs +1 -1
  76. package/tools/presentation.mjs +1 -1
  77. package/tools/procedures.mjs +2 -2
  78. package/tools/recipes.mjs +60 -9
  79. package/tools/recommendations.mjs +63 -7
  80. package/tools/release-scan.mjs +1 -1
  81. package/tools/renderers.mjs +1 -1
  82. package/tools/review-state.mjs +288 -340
  83. package/tools/run-gates.mjs +216 -92
  84. package/tools/sandbox-masks.mjs +1 -1
  85. package/tools/semver-lite.mjs +1 -1
  86. package/tools/set-autonomy.mjs +1 -1
  87. package/tools/set-recipe.mjs +1 -1
  88. package/tools/setup-backends.mjs +1 -1
  89. package/tools/surface.mjs +1 -1
  90. package/tools/uninstall.mjs +1 -1
  91. package/tools/velocity-profile.mjs +2 -2
  92. package/tools/view-model.mjs +1 -1
  93. package/references/modes/fold-completeness.md +0 -30
  94. package/references/modes/review-ledger.md +0 -34
  95. package/references/templates/verification-profile.json +0 -10
  96. package/tools/fold-completeness-run.mjs +0 -1120
  97. package/tools/fold-completeness.mjs +0 -672
  98. package/tools/review-ledger-core.mjs +0 -428
  99. package/tools/review-ledger-write.mjs +0 -647
  100. package/tools/review-ledger.mjs +0 -630
  101. package/tools/sarif.mjs +0 -52
  102. package/tools/verification-profile.mjs +0 -219
@@ -1,34 +0,0 @@
1
- ### Mode: review-ledger
2
-
3
- The review-round **LEDGER** (DEBT-REVIEW-CAP / AD-045) — it turns the prose review-loop crossover-stop (`planning.md` §9 "cap ≤2 / crossover-stop / fold-at-altitude"; `procedures.md` "{round N · finding-origin tally · per-backend verdict} … computed signal, not a remembered rule") into a **COMPUTED** signal. The orchestrator records **one round per review round** to a JSONL ledger **inside the git dir** (`<git dir>/agent-workflow-review-ledger.jsonl` — never committable by construction; `AW_REVIEW_LEDGER` overrides), and a read-only checker computes the stop decision from the recorded rounds + triage classifications, never from a remembered rule. It is the read-only sibling of `review-state` (presence vs convergence are distinct axes) — the read module **never imports the writer** (an import-split test pins it).
4
-
5
- **The SEGMENT (schema v4, BUGFREE-2 / AD-048).** Every v4 record carries `base` = the commit the dirty tree sits on (`git rev-parse HEAD`; `null` on an unborn branch). A **segment** = (activity, loop, base) — the review loop's real domain, the uncommitted change set over one base commit. **Round numbering (1..n), the review cap, the hard-max ceiling, every writer tooth, and `--check` all operate per segment**; the loop id (the plan stem) is unchanged — a plan is a sequence of segments. A segment closes ONLY through a gated commit (the gate matrix admits a commit only from a converged/resolved segment), so a round-counter reset is **earned, never declared**; an amend/rebase mid-loop orphans the segment's rounds — correct, the reviewed tree no longer exists. Pre-v4 records never enter a segment (readable history; the checker's failure reason names the schema upgrade when only old records exist).
6
-
7
- **Two tools — the read/write split (Decision 3):**
8
-
9
- 1. **Read-only checker** — `node ${CLAUDE_SKILL_DIR}/tools/review-ledger.mjs [--check | --status | --json]`:
10
- - `--status` (default) → the human report: resolved `plan-execution.review` recipe, plan-in-flight, per-round tally with `findings[]` **grouped by segment** (the current segment marked), per-backend counts + verdict, gate-run postures, the `decideStop` verdict. **This printed render REPLACES the remembered per-round `{round N · finding-origin tally · per-backend verdict}` emission** — run it each round instead of composing the tally by hand.
11
- - **`--check`** → the gate exit code. The **normative exit contract lives in the tool header** (the single home — do not re-enumerate it). It enforces the **plan-execution (code) loop** (the loop that produces the committable artifact), filtered to the current SEGMENT — `activity==="plan-execution"` AND the in-flight plan's filename stem AND `base===git rev-parse HEAD`: exit 0 for solo / no plan in flight / a clean tree / a non-git cwd / a `converged` or `resolved-residual` loop; exit 1 for a dirty non-converged loop (`triage-required`, `continue`, or **no round/receipt recorded at all** — a dirty active plan with an empty/stale ledger is a FAILURE, not a fail-open pass), more than one plan in flight (ambiguous loop id), a recorded 0/0 coexisting with a non-ship receipt verdict, or a non-degraded recorded backend missing its receipt. **Fail-CLOSED** on a detector failure — the only detector-independent green is an EXPLICIT configured solo.
12
- - `--json` → the structured state + decision.
13
- - **`--telemetry`** → read-only COUNTS across ALL loops and BOTH ledgers (never combined with the other flags — a mixed-mode gate cmd would silently pass): rounds/segments per loop, finding-origin totals, classification distribution (incl. `refuted`), per-backend verdict + divergence-round counts, override usage by scope, gate-run counts (quality-green / red results by gate id), fold runs, observed-red receipts, quarantined probes. Counts only — which gates earn their keep stays the maintainer's judgment.
14
-
15
- 2. **Writer** — `node ${CLAUDE_SKILL_DIR}/tools/review-ledger-write.mjs record|classify|override|batch --json '<payload>'` (the SOLE writer, over the shared `atomic-write` core):
16
- - `record` appends one round — `{ loop, round, origins, backends, findings }` (activity defaults to `plan-execution`). **The teeth (Decision 5 + AD-048, all per SEGMENT):** it REFUSES (typed STOP) to append a round WHILE `decideStop` on the segment's records is `triage-required` (an UNCLASSIFIED surviving blocking finding at/after the cap); refuses ANY round beyond the **hard-max ceiling of 3 within one segment** unconditionally (the counter reopens only at the next gated commit); refuses while a blocking finding of the segment's previous round **VANISHED unclassified** (present means present-as-blocking — a downgrade to minor does not survive; a pending `escalate` never clears; `refuted` is the honest phantom lane); refuses while the changed source surface exceeds the **diff-size cap** (`AW_REVIEW_DIFF_CAP`, default 400 new-side lines of assessable + unsupported SOURCE — tests and out-of-domain never count, pure deletions are free) without a recorded segment `size-cap` override; and refuses without a **quality-green gate-run** at the current fingerprint (`run-gates --record` — gates-before-review is computed, not remembered; a `--only` subset or a tree-changed run never satisfies; red PROCESS gates — the kit's own `--check` loop gates — never block). **Integrity binding (Decision 7):** each NON-degraded backend needs an **attesting** code receipt for the current tree — a round cannot be recorded for a tree no bridge really reviewed. *Attesting* is the SHARED predicate (`review-ledger-core`) that `review-state` and the round cross-check read too, so the gates can never disagree about what counts: a fresh `code` receipt at the current fingerprint that is **grounded** AND carries an explicit **`probe:false`**. A `probe:true` receipt never attests (a probe review runs with the quality guards off), and a **malformed or ABSENT** marker is rejected fail-closed — silence is not a declaration, so a receipt from a pre-marker bridge no longer counts (refresh it: `npx @sabaiway/agent-workflow-kit@latest init`). Each exclusion states its own reason, because the recoveries differ. **`--from-receipts`** (BUGFREE-3 / AD-049) DRAFTS the `backends[]` from those receipts instead of hand-composing them: each recipe-named backend's verdict comes from its fresh grounded code receipt and its counts are computed from the supplied `findings` (`origins` / `findings` stay explicit input); a recipe-named backend with no receipt is a LOUD stop — the draft never invents one (supply it explicitly as a degraded backend if the bridge really is down).
17
- - `classify` appends one triage — each surviving blocking finding of a SEGMENT round classified `fixable-bug` / `inherent-layer-residual` / `escalate` / **`refuted`** (v4 — the honest lane for a phantom finding, refuted against code: a MANDATORY non-empty `note` cites the grounds; never silently dropped, never folded). **A `fixable-bug` REQUIRES a `testId`** (M2/AD-046, schema v2) — the red→green test that pins the fold, formatted `<test-file>#<test-name-pattern>` (a `#` separator, both halves non-empty; no file-suffix rule); `inherent-layer-residual` / `escalate` may omit it. The writer validates the FORMAT only. **This is what BREAKS the deadlock:** once every surviving blocking finding is classified, `record` permits the next round (a `fixable-bug` classification lets the fix round run — no deadlock).
18
- - `override` appends one override record (schema v3, BUGFREE-1/AD-047) — the LOUD, durable waiver the **fold-completeness** gate consumes, `{ loop, round, scope, reason }` plus the per-scope payload (EXACT — a stray key is refused): scope **`oracle-change`** → `files[]`, the repo-relative pre-existing test files whose tamper flag it lifts (a fix diff that deliberately rewrote test expectations); scope **`red-proof`** → `testId`, the ONE bound test whose observed-red receipt + custody it waives (a red genuinely unestablishable pre-fold, or a custody file legitimately edited post-fix); scope **`size-cap`** (v4) → `sanctionedLines`, the EXACT changed-surface magnitude the waiver sanctions — **segment-scoped** (it dies at the next commit; a grown surface needs a fresh recorded sanction). Teeth: schema validation, fail-closed ledger read, round-sequence integrity, and the loop must be the SINGLE in-flight plan. QUARANTINE (a flaky/timed-out probe) has NO override lane. Overrides never enter `decideStop` — the two v3 scopes are fold-completeness inputs; `size-cap` is a writer-tooth input.
19
- - **`gate-run` records (v4, kind `gate-run`)** are minted by `run-gates --record` through the writer's `recordGateRun` API (the runner never opens the ledger itself) — the D5 green-baseline receipt: the FULL declaration + exactly what ran + the tree fingerprint BEFORE and AFTER the run, segment-framed with NO round number, minted only inside the single in-flight loop. A red run records honestly (telemetry fuel); **quality-green** (every declared NON-process gate green, tree unchanged under the run) is judged at read time. Revert-first beyond this is not mechanically observable at this layer — it ships as protocol + telemetry visibility (consecutive red gate-runs), stated plainly.
20
- - **`batch`** applies an ordered list of `record` / `classify` / `override` operations in ONE invocation — the prompt-economy lane for a records stage (WRITER-BURST-BATCH: one writer call, not one per op). The payload is `{ operations: [ { verb, …that verb's payload } ] }` (a `record` op may carry `fromReceipts: true`); every op rides the SAME per-verb teeth (no forked validator), so N batched ops are record-equivalent to the same N single invocations. **Two passes:** the whole envelope is validated STRUCTURALLY first with ZERO writes (a malformed envelope stops before any op runs), then ops apply sequentially and **fail-fast** on the first typed STOP — the ops already applied stay recorded (append-only, no rollback) and the STOP names the failing op index + the applied count; **resume by re-running the REMAINING ops**.
21
-
22
- **The computed stop (`decideStop`, precedence `converged > resolved-residual > triage-required > continue`).** Machine fields only (counts, `class`, `accepted`, `fingerprint`), never free-text:
23
- - **converged** — every recipe-named backend present, **non-degraded, at 0 blockers + 0 majors** in the latest round, at the current tree fingerprint. **"Surviving blocking finding" = a blocker OR a major** (a minor never forces triage).
24
- - **resolved-residual** — at/after the cap (or a recurrence auto-trip), every surviving blocking finding classified `inherent-layer-residual` (document + raise to an acceptance criterion → NEVER folded again), **`refuted`** (grounds recorded — without this arm an honestly refuted phantom minted at the hard-max round would wedge the segment), OR `escalate` with `accepted:true`, and the triage's own fingerprint equals the current tree (a doc edit after the triage → a fresh round).
25
- - **triage-required** (the writer HARD STOP) — a surviving blocking finding is UNCLASSIFIED at/after the cap, or a blocking finding recurred in ≥2 rounds still unclassified (even under the cap). `fixable-bug` → fold ONCE, re-review; `escalate` needs an accepted maintainer outcome.
26
- - **continue** — the catch-all: under the cap, or a classified-but-not-resolved loop (fold the `fixable-bug` / obtain the `escalate` outcome, then a fresh round).
27
-
28
- **"Every named backend" = "every NON-degraded named backend" (Decision 4).** A backend recorded `degraded:true` (agy is Issue-001-degraded on large diffs) is EXCLUDED from the 0/0 convergence requirement AND from the receipt cross-check (it ran no real review, mints no receipt), but is RECORDED (verdict `degraded`, a required `reason`) — it can never FAKE convergence. A recipe-named backend with NO entry is `missing` (≠ degraded) and BLOCKS convergence. Because the `degraded` mark is self-reported, `--check` surfaces every degraded backend loudly.
29
-
30
- **Wire `--check` as a gate by hand OR via the explicit-consent seeder — never without consent.** The candidate line for your own `docs/ai/gates.json`: `{ "id": "review-ledger", "title": "Review-round ledger: the in-flight loop is converged or resolved-residual", "cmd": "node <path-to-this-skill>/tools/review-ledger.mjs --check" }` — the path your project reaches the kit by, QUOTED. The consent-gated seeder offers exactly this entry ONLY when `docs/ai/orchestration.json` declares `reviewed`/`council` on `plan-execution.review`.
31
-
32
- **Human residual (stated, accepted — like `review-state`'s):** the ledger attests a review occurred and its ship-class is consistent; it does NOT prove the recorded COUNTS are truthful, nor that a self-reported `degraded:true` is real (`git commit --no-verify`, ledger-file editing, and forged counts remain possible). The ledger lives in the git dir (never committable) — a self-discipline mechanism against silent process drift, not a security boundary.
33
-
34
- **Invariants:** the read module is read-only · never commits · never runs a subscription CLI · spawns read-only `git` queries only · the SOLE writer is `review-ledger-write.mjs`, which the read module NEVER imports (structural read/write split, import-split test) · `hardMax` is a writer-only ceiling, never a `decideStop` input.
@@ -1,10 +0,0 @@
1
- {
2
- "_README": "Optional per-project VERIFICATION PROFILE for the fold-completeness gate (the language-independence contract). DELETE this file to reproduce the exact default behaviour (V8 line coverage + node:test TAP on stdout) — an absent profile is fully supported. Present, it GENERALIZES three inputs so a consumer on another language/runner can drive the same gate: (1) coverage.kind is \"v8\" (default) or \"lcov\" — with lcov, set coverage.lcovPath to where your suite leaves an LCOV file; (2) singleTest.argv is the shell-free command template for probing ONE test (placeholders {file} and {pattern} are required; a file-based resultFormat also requires {resultPath}), and singleTest.resultFormat is \"tap-stdout\" (default), \"tap-file\", or \"junit-xml\"; (3) findings.sarifPath (optional) points at a SARIF file for advisory-only findings (never gate-blocking). The suite COMMAND is NOT declared here — it stays your docs/ai/gates.json unit-tests gate (so the fold run and the gate share command-identity). Every DECLARED path (coverage.lcovPath, findings.sarifPath) MUST be gitignored or outside the repo (a symlink is refused): an in-tree, non-ignored file the suite writes would move the review fingerprint. Env knobs still override (AW_FOLD_SUITE_CMD / AW_FOLD_BOUND_CMD / AW_FOLD_RESULTS). Strict JSON — no comments.",
3
- "schema": 1,
4
- "coverage": { "kind": "v8" },
5
- "singleTest": {
6
- "argv": ["node", "--test", "--test-reporter", "tap", "--test-name-pattern={pattern}", "{file}"],
7
- "resultFormat": "tap-stdout"
8
- },
9
- "findings": {}
10
- }