@sabaiway/agent-workflow-kit 14.11.0 → 14.12.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 +37 -0
- package/README.md +1 -1
- package/SKILL.md +1 -1
- package/capability.json +1 -1
- package/package.json +1 -1
- package/references/modes/control-bytes.md +9 -6
- package/references/modes/doc-parity.md +1 -1
- package/references/modes/gates.md +3 -1
- package/references/modes/upgrade.md +4 -2
- package/references/scripts/migrate-gates.mjs +11 -9
- package/tools/checker-claim.mjs +12 -10
- package/tools/checker-gates-read.mjs +156 -0
- package/tools/checker-gates.mjs +134 -0
- package/tools/direct-run.mjs +2 -0
- package/tools/doc-parity.mjs +2 -2
- package/tools/gates-declaration.mjs +15 -1
- package/tools/gates-init.mjs +3 -3
- package/tools/profile-gaps.mjs +13 -13
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,43 @@ 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
|
+
## 14.12.0 — the upgrade offers the kit's own checkers as gates of your project, each only where it can run (AD-158)
|
|
8
|
+
|
|
9
|
+
**The kit's own checkers can now be declared as gates of your project without a hand edit.** Until 14.12.0 no
|
|
10
|
+
preview offered `control-bytes`, `plan-shape`, `spec-check` or `spec-coverage`, and the `control-bytes` document
|
|
11
|
+
told a user to paste its entry into `docs/ai/gates.json` by hand. 14.12.0 adds a declare verb that previews them, and the
|
|
12
|
+
upgrade's `tier` step now shows them as a fourth entry, `checker-gates-declared`, and writes them on the same one yes.
|
|
13
|
+
No new upgrade item, no migration note and no lineage change: a project already at lineage `4.0.0` is offered them on
|
|
14
|
+
its next upgrade. Story S4 of the epic `CONSUMERS-MOVE-ONTO-THE-FULL-FLOW`; contract
|
|
15
|
+
`docs/ai/specs/kit/tier/checker-gates/` (new).
|
|
16
|
+
|
|
17
|
+
- **`tools/checker-gates.mjs --cwd <project> [--apply] [--only <id>]…`.** Without a flag it writes nothing and
|
|
18
|
+
prints one line per checker: `declared`, `id-taken` (a gate with that id runs something else), `probe-unreadable`,
|
|
19
|
+
`not-applicable`, `offered` or `withheld`, with a detail where one applies; under an offered checker, its paste-ready
|
|
20
|
+
`entry:` line. The gates-file disclosure is printed once whenever a checker is offered or written. `--apply`
|
|
21
|
+
writes the offered entries; `--only <id>` (repeatable) narrows the write, and an id that is not offered is a usage
|
|
22
|
+
error. Exit 0 done, 1 one named refusal on stderr, 2 usage. A second `--apply` writes nothing.
|
|
23
|
+
- **Each checker is offered only where it runs by design.** `control-bytes --check` needs a `.git` directory or
|
|
24
|
+
gitfile at the project root; `plan-shape --check --in-flight` is offered on any deployment; `spec-check --all`
|
|
25
|
+
needs a regular `docs/ai/specs/index.md`; `spec-coverage --check` needs a regular `docs/ai/spec-coverage.json`
|
|
26
|
+
and that store root. The command names the installed tool by its absolute, double-quoted path; a kit path that
|
|
27
|
+
cannot be written into a command withholds every checker that would be offered, by name, and writes nothing.
|
|
28
|
+
- **Your declaration is only added to.** The write keeps every existing entry's value and order and the `_README`,
|
|
29
|
+
places each new entry as `gates-init` does (before a trailing coverage checker), must pass the declaration's
|
|
30
|
+
validation, and is atomic. A checker already declared in the form the verb writes, under any id, reads
|
|
31
|
+
`declared`. A missing, symlinked, non-regular, unreadable, unparseable or
|
|
32
|
+
invalid `docs/ai/gates.json`, or one whose coverage checker is already inert, misplaced or declared twice, is
|
|
33
|
+
reported by one name and nothing is written. The verb never removes an entry: an entry it wrote is removed by hand.
|
|
34
|
+
- **The upgrade relays the preview before the ask.** While `checker-gates-declared` is offered, the `tier` step shows
|
|
35
|
+
the verb's lines, the disclosure and each `entry:` line included, before its one question.
|
|
36
|
+
- **A matrix of only the kit's checkers is not project verification.** These four now count as kit-owned checkers,
|
|
37
|
+
so the kit's recommendations report a `docs/ai/gates.json` holding nothing else as carrying no
|
|
38
|
+
project-verification gate, as they already did for a lone `source-size` gate.
|
|
39
|
+
- **The documents stop saying "declare it by hand".** `references/modes/gates.md` gains the checkers' paragraph,
|
|
40
|
+
`references/modes/control-bytes.md` step 3 names `--only control-bytes` beside its paste-ready line, and
|
|
41
|
+
`doc-parity` is no longer described as a project gate: it checks only the kit's own package. `epic-shape` and
|
|
42
|
+
`queue-audit` take a project operand, so they are not offered.
|
|
43
|
+
|
|
7
44
|
## 14.11.0 — the upgrade offers the epic and task settings and the epic store in one preview, and remembers a no (AD-157)
|
|
8
45
|
|
|
9
46
|
**An upgraded project is now offered the epic tier's settings and store instead of being left to find them.** Up to
|
package/README.md
CHANGED
|
@@ -246,7 +246,7 @@ file), or run the guarded `/agent-workflow-kit uninstall`.
|
|
|
246
246
|
| `/agent-workflow-kit coverage-check` | any time | **the final-run checker** (D3(c)+(d)) — **certifies coverage ONLY inside the `--final` run that owns the lcov** (ownership is exclusive by CONVENTION over the fixed path, not enforced — a concurrent writer to it is a stated residual, queued as LCOV-EXCLUSIVE-OWNERSHIP): an artifact on disk proves nothing about the tree it came from, so a standalone run prints its findings and states `attested=no` / `NO VERDICT` rather than a PASS (an lcov that predates an edit would otherwise certify a line the suite never executed). `attested=` claims a verdict was ISSUED, pass or fail — a run over uncovered lines still reads `attested=yes` and still exits 1, and a run whose coverage arm never executed (no lcov) reads `attested=no` even inside `--final`, because nothing was read and nothing is certified. The runner passes a nonce whose one-way commitment over `{nonce, fingerprint, base}` is the `final-start.attempt` it recorded; a context describing another tree, or matching no recorded attempt, is a REFUSAL, never a verdict. Findings are unchanged — reads the lcov the declared `unit-tests` gate produced at the FIXED git-dir path and fails on any uncovered CHANGED executable Node line (listed `file:line`; a changed file absent from the map is a file-level red; out-of-domain/unsupported files are LISTED — the claim narrowed honestly); VERIFIES every current-base red-proof declaration (bound test exists · custody hash unchanged · green N/N now · pre-fix fingerprint differs); prints `lcov-sha256=<hex|none>` of the exact bytes it consumed — the sha the `--final` receipt binds and re-hashes. An absent lcov is a LOUD `skipped-no-lcov`; a symlinked path is a refusal. `--check` is the gate exit code — declare it as the LAST gate (`run-gates --final` refuses otherwise). Read-only. |
|
|
247
247
|
| `/agent-workflow-kit commit-guard` | any time | **the read-only pre-commit guard** (D10) — makes the commit capture the whole current working tree, so «verified» and «about to be committed» are the same bytes (the receipt itself has a stated residual — see the mode doc). FIRST it refuses an **INDEX that lags the verified working tree** (the gates and the fingerprint describe the WORKING tree while `git commit` takes the INDEX alone, and the fingerprint cannot tell them apart — so a lagging index used to ship a strict subset of what was verified): unstaged tracked paths or reviewable untracked-not-ignored paths, named up to a bounded cap with the remainder stated, a dirty tracked **submodule** named separately with its own recovery, and fail-closed on an undecidable probe. This deliberately blocks a partial commit. Then it binds the LATEST completed `run-gates --final` receipt to the EXACT current tree: refuses on a missing/red/stale receipt, fingerprint drift under the run, a dangling later attempt, declaration content drift, evidence-hash or lcov drift, or unsatisfied review obligations (the same review-state decision, recomputed over a sanitized env — forged out-of-repo stores never satisfy). Re-runs NO gate or test. Wire it into `.git/hooks/pre-commit` (the installer writes the RESOLVED invocation). `git commit --no-verify` stays the stated residual. |
|
|
248
248
|
| `/agent-workflow-kit recommendations` | any time (every `upgrade` ends with it) | **read-only deployment advisor** (AD-044) — computes what in THIS deployment is configured sub-optimally (allowlist not seeded, autonomy render drifted, OS sandbox unavailable, gates undeclared, bridge friction, sandbox-mask clutter, an unacknowledged sandbox recipe, a feature-spec layer never adopted) and renders **verdict-first**: one composed verdict line (does anything need attention?), then each item as **{severity · what · one-line benefit · an optional `recipe:` line (the sandbox-lane live recipe, the worktrees-dir hand-apply-first grant advice, the agents hidden-mode reconcile follow-up, or the spec-adoption decline preview) · the exact consent-gated apply one-liner}**. The agent PRESENTS the section in the user's conversational language — every fact and count, nothing added or dropped; commands, paths, hosts and rule strings byte-exact; raw tool block on request — and runs EXACTLY the rendered one-liners only on your yes, surfacing each item's posture note first. Renders **present-even-when-empty** (`no recommendations — flow optimal.`); a failed probe degrades to a stated skip line. Registry strings are fact-true frozen one-line data (posture/risk notes live in the mode doc at the consent moment); the kit never seeds `sandbox.network.allowedDomains` / `filesystem.allowWrite` (**HAND-APPLY** territory), and the sandbox-lane item's convergence is a neutral fingerprint acknowledgement recorded by a consent-gated ack writer into `docs/ai/acks.json` — never a security key (the recipe is documented per bridge in `capability.json` `networkHosts` + `writableDirs`). `--cwd` is required (the target project is explicit); never writes, never commits, never runs a subscription CLI. |
|
|
249
|
-
| `/agent-workflow-kit doc-parity` | any time | **read-only doc-parity lint** (AD-049) — kills the doc-drift class where a mode-contract doc silently lags a code constant (a `--check` doc still reading `300` after the diff cap moved to `400`): a **closed, exported registry** binds each live constant (review caps, schema versions, the ledger's own class/scope vocabulary, and the autonomy-doctor EXIT/status/trusted-dir contract) to the exact token its `references/modes/*.md` contract must carry, and asserts the CURRENT value renders into every bound file — a drifted doc, an unreadable file, or an absent token **fails closed**. The values are sourced from the live imports (never re-typed), so the lint can't itself go stale; adding a binding is adding a checked entry (closed-world, edit-safe). `--check` is
|
|
249
|
+
| `/agent-workflow-kit doc-parity` | any time | **read-only doc-parity lint** (AD-049) — kills the doc-drift class where a mode-contract doc silently lags a code constant (a `--check` doc still reading `300` after the diff cap moved to `400`): a **closed, exported registry** binds each live constant (review caps, schema versions, the ledger's own class/scope vocabulary, and the autonomy-doctor EXIT/status/trusted-dir contract) to the exact token its `references/modes/*.md` contract must carry, and asserts the CURRENT value renders into every bound file — a drifted doc, an unreadable file, or an absent token **fails closed**. The values are sourced from the live imports (never re-typed), so the lint can't itself go stale; adding a binding is adding a checked entry (closed-world, edit-safe). `--check` is the gate exit code a kit maintainer runs: the lint checks the kit's own package. Never writes, never commits, never runs a subscription CLI. |
|
|
250
250
|
| `/agent-workflow-kit dispatch` | any time | **the delegation engine** — makes "how much does delegating a sub-task actually buy?" a measured number instead of a feeling. `check <file>` validates a sub-task brief's contract block and exits 0/1 naming the first violated field — **form only**: whether the task is genuinely bounded, its design decided and its acceptance adequate stays your judgment, and a well-formed absurdity passes here by construction. `advise --step-class <c>` answers the question that comes BEFORE that one — which vehicle should carry this kind of sub-task, whether it is even present on this machine, and what the ledger has already recorded for threads of that class (finished, failed, closed without a fold, and still open — counted separately) — and it decides nothing: it refuses no dispatch, gates no verb, and a choice that diverges from the advice is noted rather than blocked. It reads the filesystem only: nothing is launched to find out what is installed, an absent ledger prints "no recorded history", an unreadable one prints the store's own words, and either way the advice still prints. The same block appears as a footer under a form-valid `check` — never under a refusal, so it can never hide one. `register` pre-registers an acceptance wave (step classes, pairing key, minimum observations per class, the mean and first-pass thresholds) so the bar can never be chosen after the results it judges — immutable per wave. `observe` records ONE hand-written observation (`solo-construction`, the baseline whose ratio is 1 by construction — except over a scope measuring zero bytes, which has no ratio at all and is recorded ineligible by name — or `self-reported`) — delegated numbers are never hand-written, they are derived. The writer verbs are where that derivation happens: `open` puts a delegated thread on the record with every mint-time field copied from the brief's own header, refusing a deadline the wrapper's cap plus its kill grace would not fit inside, and recording whether the tree it started from was clean against the thread's base — HEAD by default, or the tree `--checkpoint <oid>` names, so the second task of a story is measured over the first one's uncommitted work instead of opening dirty (a dirty one makes the result honestly unmeasurable rather than quietly counted), while `--task <brief>` also records which task brief the thread carries out and the files that brief lists, refusing, since the last commit, a task thread whose files overlap by path prefix those of an open task thread or of a folded thread of another brief (`files-overlap`), and a mix of the two kinds — an untasked open beside an open task thread or, for a `code` open of backend `codex`, after a task fold, and a task open beside an open untasked thread (`mixed-open`), refusing at open a Files path the snapshot scope can never hold (`task-files-scope`), and measuring a task thread over its files alone, so `return` and `fold` refuse a changed path that no open or folded task thread on the same base claims (`out-of-files`); `await` waits for that one dispatch to answer and writes nothing — only the finished receipt satisfies it, a run still holding the nonce means keep waiting, and a wait that runs out says so with its own exit code, names whether the deadline or your own timeout ended it, and authorizes nothing: a wait that ended without an answer is a question for you, never permission to dispatch again; `return` absorbs the receipt the wrapper minted — only a finished one, checked against the contract it actually ran, its deadline and its own report, and refused outright when the tree hides changes from git or moves while the return is being computed — and derives the bytes from git rather than from anyone's claim; `fold` is the acceptance, and it refuses if the tree moved since the return — precisely, it re-confirms **equality of the visible canonical payload**, which is a change detector rather than a cryptographic identity of the tree: under the default head base that payload's untracked section is unframed and carries no file mode, so a content or symlink target that imitates the marker opening the next entry can alias two trees, and making an untracked file executable moves nothing (both named as residuals in the mode doc, with the fix queued); under a checkpoint base it is one indexed diff that carries modes. A change set carrying a binary, a non-regular path, a submodule, or a symlink whose target is not valid UTF-8 is **refused** at `return` and `fold` — CONSERVATIVELY, rather than promise what the default head payload may not be able to follow — and the same refusals hold for a checkpoint thread. `degrade` closes a thread that never earned a fold, on the record and with its reason. `aggregate` prints one wave: the registered thresholds, every observation as context, and per step class the finished threads — a folded success with git-provable bytes contributes its ratio, one whose bytes are unprovable is excluded from the mean but still counts in the first-pass rate, and a failed thread, a degrade-closed one, or one folded after failing acceptance each count as a real zero. Below the registered minimum nothing is computed (insufficient); at or above it is computed and labeled PILOT evidence. It REFUSES rather than guessing: no pre-registration, an unfinished thread in scope, a recorded refusal-to-delegate that never opened a thread, or an ambiguous wave each stop the computation by name. `handoff-return --slug <s>` closes the worktree loop after `land --prepare`: it re-attests that main still holds exactly the prepared tree under the same HEAD (both recorded in the handoff at prepare time), prints the satellite handoff's user-owned content byte for byte with its boundaries, byte lengths and the main-owned destinations each part folds into, prints the handoff digest and both OIDs as its proof, states the after-the-fold order (a fold landed after the gates leaves them stale), and records ONE self-reported worktree-stream observation only when the whole prepared change set is measurable — a deletion, a rename, a symlink, a submodule or a mode-only change ends with a named NOT RECORDED instead, never a partial number. Appends only to its own ledger inside the git dir (never committable); it also writes `handoff-return`'s `write-tree` tree object and, for a checkpoint measurement, the leaf's OWN temporary index file and the blobs its forced adds store — never a ref, never the real index; never commits, never runs a subscription CLI. |
|
|
251
251
|
| `/agent-workflow-kit worktrees` | any time | **parallel feature worktrees** — run several features in DIFFERENT agent sessions on one repo, zero interference on working-tree files (the ONE exception is the dependency cache, below): `provision <slug> --plan <file>` creates a sibling git worktree on branch `aw/<slug>` and populates it (registry-derived footprint copy-if-missing — a tracked file is never overwritten; EXACTLY ONE seeded feature plan; the `handoff-<slug>.md` record from minute zero; `node_modules` symlinked where the link stays ignored — a shared MUTABLE dependency cache: writes through it hit MAIN's node_modules; for isolation run the printed isolated-install command (`--install` only PRINTS it; on `--resume` run the printed unlink-first recovery first — printed only for a link whose RAW TARGET is MAIN's `node_modules`, since a foreign or unreadable link is reported as such with no removal advised); absolute root-pinned gate commands rebased on untracked copies only, and only while their bytes equal the MAIN source or its rebased form — user-modified copies stay untouched); `list` is read-only (slug, branch, base, dirty, handoff); `prompt <slug>` is read-only too and re-prints the satellite's cold-start prompt — the same text `provision` ends its report with: where the worktree is, its ONE seeded plan, the handoff as the one channel back, MAIN's orientation (shared series index, landing) and, under its own heading because it is probed on the satellite, that checkout's install posture — every value derived LIVE rather than replayed from the frozen provision record, a recorded value that no longer matches NAMED as a divergence (with the cause its source makes likely) instead of printed as the runnable one, every offered command marked with WHO runs it (`MAIN $ …` for the landing, `HERE $ …` for this checkout's own install, a posture with nothing to run staying prose), and a control character in any rendered value a typed STOP rather than a forged prompt line; `land <slug> --prepare` locks the common git dir, fail-closes on divergence or incomplete satellite state, transfers the complete accepted satellite diff onto a CLEAN main, runs sync plus the declared gates, and reports HEAD/TRANSFER/PREPARED OIDs — the commit ALWAYS stays a dialogue ask; `cleanup <slug>` takes the same lock and removes a LANDED worktree only after live landed-verification against main HEAD, while `--abandon` is the ONE destructive arm (destroys unlanded work; **no preview step** on any writer). The parent dir is the `docs/ai/worktrees.json` `parentDir` setting (default: the repo's sibling parent); an unwritable parent degrades to printed maintainer-pasted commands, and the one-time host consent that makes it promptless surfaces via `recommendations`. Never commits, never pushes, never runs a subscription CLI. |
|
|
252
252
|
| `/agent-workflow-kit uninstall` | opt-in, any time | **guarded teardown** — the inverse of `init` / `setup`. Removes only what's **provably ours** (managed skill dirs + bridge wrappers; in a project, the hidden-mode git-ignore block it added + the pre-commit hook it installed); **never deletes** your `docs/ai` / `AGENTS.md` (prints the exact `rm` to run by hand) or your `.claude/settings.json` (prints an **edit** — remove the attribution key, review any velocity `permissions.*` — never an `rm`). Always `--dry-run` first; preflight-then-mutate; never commits. |
|
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`.
|
|
4
4
|
disable-model-invocation: true
|
|
5
5
|
metadata:
|
|
6
|
-
version: '14.
|
|
6
|
+
version: '14.12.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": "14.
|
|
3
|
+
"version": "14.12.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",
|
|
@@ -65,12 +65,15 @@ that directory's work-tree root):
|
|
|
65
65
|
usage — every operand is validated at parse; an unknown argument is usage. Every content read is
|
|
66
66
|
descriptor-bound (open, fstat, read on the descriptor), never a path read that a symlink swap
|
|
67
67
|
could redirect.
|
|
68
|
-
3. **
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
68
|
+
3. **Declare it as a gate — never without consent (AD-021/D9).** `node
|
|
69
|
+
${CLAUDE_SKILL_DIR}/tools/checker-gates.mjs --cwd <project> --only control-bytes --apply` writes
|
|
70
|
+
this one entry while the kit offers it; without `--only control-bytes --apply` the same command
|
|
71
|
+
previews and writes nothing. The upgrade's `tier` ask writes it on your explicit yes. The candidate
|
|
72
|
+
line to paste into your own `docs/ai/gates.json` instead: `{ "id": "control-bytes", "title": "No raw
|
|
73
|
+
control byte in the work tree", "cmd": "node \"<path-to-this-skill>/tools/control-bytes.mjs\"
|
|
74
|
+
--check" }` — with the path your project actually reaches the kit by, double-quoted inside the JSON
|
|
75
|
+
string so a path with spaces survives, executable from the project root. The full consent-fill
|
|
76
|
+
contract for the matrix is in `${CLAUDE_SKILL_DIR}/references/modes/gates.md`. Once declared, the opt-in
|
|
74
77
|
`${CLAUDE_SKILL_DIR}/references/modes/hook.md` auto-approves it like any other declared gate.
|
|
75
78
|
|
|
76
79
|
**Honest bounds (stated, accepted):** the work tree is judged at the moment of the read — a byte
|
|
@@ -6,7 +6,7 @@ The DOC-PARITY lint (BUGFREE-3 / AD-049, session-economics item (b)) — the det
|
|
|
6
6
|
|
|
7
7
|
**Run** — `node ${CLAUDE_SKILL_DIR}/tools/doc-parity.mjs [--check | --json]`:
|
|
8
8
|
- default → the per-binding report (each `constant → file` marked ✓/✗).
|
|
9
|
-
- **`--check`** → the gate exit code (0 consistent, 1 drift)
|
|
9
|
+
- **`--check`** → the gate exit code (0 consistent, 1 drift): the lint checks the kit's own package, the gate a kit maintainer runs.
|
|
10
10
|
- `--json` → the structured result.
|
|
11
11
|
|
|
12
12
|
**What it checks (the closed registry).** The tokens are IMPORTED live from the tools — never re-typed in the lint — so the registry itself can never go stale:
|
|
@@ -23,7 +23,9 @@ Declared gates can also be **auto-approved** (no permission prompt on a byte-exa
|
|
|
23
23
|
|
|
24
24
|
**Candidate line — the source-size gate (opt-in, never auto-seeded).** A project declaring the source-size practice (`docs/ai/source-size.json`) can declare its checker as one more gate, offered **only over a MINTED practice** — an absent config has nothing to offer, an authored-but-unminted one is withheld by name rather than declaring a gate that would refuse. Adoption is ONE consented verb, `node ${CLAUDE_SKILL_DIR}/tools/source-size-check.mjs --adopt --reason "<text>" [--cwd <project>]`: it mints the record and declares this gate and NOTHING else, is idempotent once adopted, and with no config refuses with the exact file to author (the practice's one manual step). The advisor surfaces it as the `source-size` item, reading a declared cmd as one of THREE claims rather than a yes/no — **canonical** (this copy — answered), **tool-elsewhere** (the same shape resolving to a DIFFERENT real copy — a vendored deployment, converging on a `source-size-copy` acknowledgement, never on `--adopt`, which would collide on the declared id), **not-the-tool** (a gate merely CARRYING the id is a squatter: rename it, or repoint its cmd at this `--check` form) — in that precedence. An unminted record stays the same attention outcome for either copy, and no acknowledgement silences it.
|
|
25
25
|
|
|
26
|
-
**
|
|
26
|
+
**Candidate lines — the kit's own checkers (opt-in, one consented verb).** `control-bytes`, `plan-shape`, `spec-check` and `spec-coverage` can each be declared as a gate of your project: `node ${CLAUDE_SKILL_DIR}/tools/checker-gates.mjs --cwd <project>` previews them and writes nothing. Each is offered only over a state where its checker runs by design: `control-bytes` over a `.git` directory or gitfile at the project root, `plan-shape` on any deployment, `spec-check` over a regular `docs/ai/specs/index.md`, `spec-coverage` over a regular `docs/ai/spec-coverage.json` beside that store root. An offered checker prints its paste-ready entry line; the upgrade's `tier` ask writes the offered entries on your explicit yes — add-only, placed by the rule below, not stamp-gated, after the preview printed the disclosure below. An entry it wrote is removed by hand from `docs/ai/gates.json`: the verb never un-declares. `epic-shape` and `queue-audit` take a project operand and `doc-parity` checks only the kit's own package, so none of them is offered.
|
|
27
|
+
|
|
28
|
+
**Consent-gated filling — the init preview, not part of the runner (D9).** The template `gates.json` is seeded EMPTY; FILLING it is a consented preview at init (`node ${CLAUDE_SKILL_DIR}/tools/gates-init.mjs --cwd <project>`, dry-run by default — prints the derived entries and **writes NOTHING**; `--apply [--only <id>]…` writes exactly the consented entries on your explicit yes; add-only, id collisions refused). **Placement, not blind appending:** a consented entry lands at the END, except that a non-checker entry goes **BEFORE** a trailing canonical coverage checker — that checker must stay last, so appending after it would write a declaration the validator refuses, leaving a hand edit as the only lane on any final-capable declaration. Existing entries are never modified, removed or reordered. The offer derivation is **closed-world** (AD-052): only a terminating-class script NAME (test / lint / type-check / build — never dev/watch/serve, never a write-mode or release/publish/deploy variant) whose BODY is a member of the literal runner allowlist is offered — membership, never blocklist screening: the worst case is a legit command not offered, never a dangerous one offered. The offered cmd is the uniform hook-free **`COREPACK_ENABLE_NETWORK=0 <pm> exec -- <allowlisted-body>`** — `exec` runs a command, not a named script, so no pre/post hook can fire (npm/pnpm/yarn alike; never `<pm> run <name>`, which re-exposes hooks), and the Corepack env prefix blocks a hostile `packageManager` pin from fetching the PM binary before exec. npm is pinned `--offline --script-shell /bin/sh`; pnpm/yarn refuse an absent runner without network (a user-installed cache/global/PATH runner executing is user machine state — part of the disclosed residual); a family without a verified fail-closed exec contract is WITHHELD loudly. A screened-out body is always named — and when nothing but kit checkers remains, the preview says so in plain words: the offer carries **no project-verification gate at all**. **Disclose before the yes** (the preview prints it): gates.json is a PRIVILEGED file — the wired hook auto-approves byte-exact declared commands — and a script gate runs project-controlled tooling the preview does not sandbox (safe-by-construction = the OFFER DERIVATION). At upgrade, step 3's run-list changes an existing gates.json only through the consented legacy migration and, under the `tier` ask, `tools/checker-gates.mjs` (`${CLAUDE_SKILL_DIR}/references/modes/upgrade.md`).
|
|
27
29
|
|
|
28
30
|
**The coverage PRODUCER and the canonical checker are declared together or not at all.** `coverage-check` READS an lcov; something must WRITE it, and a checker with no producer PASSES (`skipped-no-lcov`) certifying nothing. A **producer** is a CLOSED set of full command forms, never a substring probe: the suite body `node --test --experimental-test-coverage --test-reporter=lcov --test-reporter-destination="${AW_GIT_DIR:?exported by run-gates}/agent-workflow-lcov.info" --test-reporter=spec --test-reporter-destination=stdout` (optionally + the project's own test paths), bare or behind ONE verified per-PM `exec` wrapper. A cmd that merely MENTIONS the destination (in an `echo`, as a bare substring) or carries a PARTIAL flag set is **not** one. The tail must be path-shaped — path/glob/quoting bytes only, nothing that could sequence, redirect or substitute a command, no plain leading `-`. **Residual:** the screen judges SOURCE bytes — brace *sequence* expansion can produce others (`{Y..a}`), though bash never re-scans an expansion result as syntax, so such a byte is literal argument data, not an operator; the leading-`-` rule is first-order only (`'--flag'`, `{path,--flag}` pass); neither proves the lcov SURVIVES — "producer" means *configured with the reporters*, and a run producing none is caught at runtime as `skipped-no-lcov`. The destination rides `AW_GIT_DIR`, exported to every gate child on plain and `--final` runs alike (`AW_LCOV_FILE` is `--final`-only), so one cmd survives the unmet-producer preflight in both modes; the `:?` is the required-parameter form, so a hand-run with `AW_GIT_DIR` unset or empty fails naming it instead of writing the lcov to the filesystem ROOT (a STALE exported value is not caught), and the preflight counts it as a reference (a `${VAR:-…}` fallback stays unmatched). Recognition is APPEND-ONLY — every destination form the kit has emitted stays a producer, so an earlier kit's declaration never re-reads as customized; emission uses the newest alone. Recognition never WIDENS: a suite the closed set cannot express declares itself with **`"lcovProducer": true`** — the ONE other way to be a producer. Only the literal `true` claims (a string is a loud refusal); the claim binds the DECLARATION, never the run (a marked gate producing no lcov still ends `skipped-no-lcov` / `attested=no`); and it is FORWARD-ONLY — an older kit rejects a marker-carrying declaration by name (exit 5) instead of reading a claim it cannot honor. On BOTH declaration paths: the fill preview WIRES those reporters onto a `node --test` body — the one allowlist member producing lcov unaided, every other body is emitted unchanged — WITHHOLDS the `coverage-check` candidate, with a named note, when neither the offer nor the declaration carries a producer; and `--apply` REFUSES a checker with no producer, a checker that is not LAST (an ORDERING refusal about entries that are ALREADY declared — reorder by hand; the fill places new entries before a trailing checker but never reorders what it did not write), or a SECOND canonical checker. The legacy migration likewise never ADDS the checker into a producer-less declaration, and reports an already-declared one as INERT. A producer declared AFTER the checker leaves it just as inert (it reads nothing, or stale bytes) — ORDER is the rule. An already-declared inert pair, and a matrix of nothing but kit checkers, are surfaced by the advisor's `gates-inert` item (`${CLAUDE_SKILL_DIR}/references/modes/recommendations.md`); its cause-A remedy is the fill preview when the checker is LAST and the project's own scripts yield an offerable producer (the placement rule lands it before the checker), and HAND-APPLY otherwise.
|
|
29
31
|
|
|
@@ -48,7 +48,7 @@ Requires: ${CLAUDE_SKILL_DIR}/references/shared/report-footer.md · ${CLAUDE_SKI
|
|
|
48
48
|
|
|
49
49
|
**What the spec-layer ensure does.** A deployment older than the feature-spec layer lacks `scripts/spec-schema.mjs` and `docs/ai/specs/index.md`, and its deployed `check-docs-size.mjs` predates the store collapse. In ONE order: the reader pair, then the checker pair — each seeded when absent and REFRESHED only while a file's bytes are a body a release shipped (an append-only digest catalog → `refreshed`; an edited body is preserved verbatim and withholds the writes that depend on it, the checker lane waiting on a byte-current reader pair); the store root is seeded from the bundled template, date rendered, ONLY behind a checker pair current after the run — an older or edited checker renders the store row by row and reds the hook's `--check-index`, so behind a custom checker the store root is NOT seeded and the line names the remedy (copy the pair from `${CLAUDE_SKILL_DIR}/references/scripts/` by hand, re-run). One token by precedence: `seeded` > `refreshed` > `customized-preserved` (an edited pair, and this run wrote nothing) > `already-present`; `skipped-no-node-evidence` only when neither a root `package.json` nor any kit-seeded `scripts/*.mjs` is present (the same Node-evidence probe the enforcement-script ensure uses; an unreadable probe is `failed` / `node-evidence-unverifiable`); every line states what this run did, and a write that stops partway names what landed. The legacy-ADR instruct never withholds it. **The adoption state this seed leaves behind is reported, never assumed:** the Recommendations section (step 4 / 8) carries the `spec-adoption` item — `not adopted` (the store is absent: the seed offered, the decline a named hand-apply alternative), `adopting` (a store with no live contract: the decline offered), silenced by a recorded decline (`ack-write --lane spec-adoption`), and a store the probe cannot read is a stated skip — and `status` prints the same state on its own line.
|
|
50
50
|
|
|
51
|
-
**`gates-migration` — legacy gates.json migration (consented preview — D8).** An EXISTING declaration may still carry the retired review-ledger / fold-completeness checks. Run the preview (dry-run — writes NOTHING), show the user the exact plan, and only on an explicit yes re-run it with `--apply`: canonical legacy entries (matched by their documented single-invocation cmd forms) are REMOVED, the canonical `unit-tests` cmd gains the built-in lcov reporters, and the coverage-check gate is ADDED last — atomic and COMPLETE, so the migrated declaration satisfies `run-gates --final`. **The checker rides a PRODUCER or is not declared at all** (`${CLAUDE_SKILL_DIR}/references/modes/gates.md`): with no gate producing the lcov it reads, the migration does NOT add it, an already-declared one is reported INERT, the result is not called final-run-capable, and the preview prints the paste-ready suite cmd to declare by hand — nothing is ever removed for you. CUSTOMIZED entries are NEVER auto-touched: the preview names each with a paste-ready recovery, and the commit guard must NOT be installed until they are resolved.
|
|
51
|
+
**`gates-migration` — legacy gates.json migration (consented preview — D8).** An EXISTING declaration may still carry the retired review-ledger / fold-completeness checks. Run the preview (dry-run — writes NOTHING), show the user the exact plan, and only on an explicit yes re-run it with `--apply`: canonical legacy entries (matched by their documented single-invocation cmd forms) are REMOVED, the canonical `unit-tests` cmd gains the built-in lcov reporters, and the coverage-check gate is ADDED last — atomic and COMPLETE, so the migrated declaration satisfies `run-gates --final`. **The checker rides a PRODUCER or is not declared at all** (`${CLAUDE_SKILL_DIR}/references/modes/gates.md`): with no gate producing the lcov it reads, the migration does NOT add it, an already-declared one is reported INERT, the result is not called final-run-capable, and the preview prints the paste-ready suite cmd to declare by hand — nothing is ever removed for you. CUSTOMIZED entries are NEVER auto-touched: the preview names each with a paste-ready recovery, and the commit guard must NOT be installed until they are resolved. Of step 3's run-list, only this migration and `tools/checker-gates.mjs` under the `tier` ask change an existing gates.json (the FILL preview runs at init).
|
|
52
52
|
|
|
53
53
|
**`bridges` — placed-bridge refresh — stamp-independent, same gate, BEFORE the equal-head short-circuit.** Run
|
|
54
54
|
`node ${CLAUDE_SKILL_DIR}/tools/setup-backends.mjs --refresh-placed` and **paste its per-bridge
|
|
@@ -95,7 +95,9 @@ Requires: ${CLAUDE_SKILL_DIR}/references/shared/report-footer.md · ${CLAUDE_SKI
|
|
|
95
95
|
`offered`: yes re-runs it and every other offered `apply:` line with `--apply`; no re-runs it
|
|
96
96
|
with `--decline`. `story-sessions-section` `offered`: run its preview line and relay its lines
|
|
97
97
|
(Communication `planned` too) before the ask; `declined`: relay the lens story-sessions absent note
|
|
98
|
-
as the recorded decline, without its preview command, and put no ask for it.
|
|
98
|
+
as the recorded decline, without its preview command, and put no ask for it. `checker-gates-declared`
|
|
99
|
+
`offered`: run its preview line and relay its lines, the disclosure and each `entry:` line included,
|
|
100
|
+
before the ask. A Communication absent
|
|
99
101
|
note beside a `present` or `declined` one keeps its own ask, after the insert's full preview
|
|
100
102
|
(the insert is indivisible). In an upgrade this governs the composition handoff's lens ask. A
|
|
101
103
|
`refused` item, or a non-zero exit of any command the ask runs, STOPs the upgrade before the
|
|
@@ -157,7 +157,7 @@ export const isCoverageProducerGate = (gate) => {
|
|
|
157
157
|
// A cmd makes exactly ONE of three claims about a given tool, and collapsing them into a boolean is
|
|
158
158
|
// what makes a VENDORED copy of the tool read as "the tool is not declared at all" — a false
|
|
159
159
|
// absence, with a remedy (adopt it) that then collides with the entry already there:
|
|
160
|
-
// • canonical — this tool's `--check`
|
|
160
|
+
// • canonical — this tool's invocation with its tail (`--check` by default), resolving to THIS copy
|
|
161
161
|
// • tool-elsewhere — the same invocation shape, resolving to a DIFFERENT real copy
|
|
162
162
|
// • not-the-tool — anything else: another command, a masked form, an inadmissible token, or a
|
|
163
163
|
// path nothing can resolve
|
|
@@ -195,16 +195,18 @@ const bareTokenSafe = (text) => text.length > 0 && ![...text].some((ch) => {
|
|
|
195
195
|
|
|
196
196
|
const RE_META = /[.*+?^${}()|[\]\\]/g;
|
|
197
197
|
|
|
198
|
-
// checkerClaimTool(basename, canonicalPath) → the screen for ONE tool. The shape is the STRICT
|
|
199
|
-
// command — `node` + ONE (quoted or bare) path token + the exact basename +
|
|
200
|
-
// masked form (`--check --help`, `--check || true`, a prefix
|
|
201
|
-
//
|
|
202
|
-
//
|
|
203
|
-
//
|
|
204
|
-
|
|
198
|
+
// checkerClaimTool(basename, canonicalPath, tail) → the screen for ONE tool. The shape is the STRICT
|
|
199
|
+
// full command — `node` + ONE (quoted or bare) path token + the exact basename + the exact argument
|
|
200
|
+
// tail (`--check` by default) + END — so a masked form (`--check --help`, `--check || true`, a prefix
|
|
201
|
+
// command) or a reordered tail is never any claim at all. Separators are PLAIN SPACES, not \s: a
|
|
202
|
+
// newline between the tokens is not a command a runner would execute as written. The basename and
|
|
203
|
+
// every tail token are regex-escaped here, never by the caller — a caller-escaped literal is one
|
|
204
|
+
// forgotten backslash away from a dot matching any byte.
|
|
205
|
+
export const checkerClaimTool = (basename, canonicalPath, tail = '--check') => {
|
|
205
206
|
const safe = basename.replace(RE_META, '\\$&');
|
|
207
|
+
const args = tail.split(' ').map((token) => token.replace(RE_META, '\\$&')).join(' +');
|
|
206
208
|
return Object.freeze({
|
|
207
|
-
re: new RegExp(`^node +(?:"((?:[^"]*[/\\\\])?${safe})"|((?:[^\\s"]*[/\\\\])?${safe}))
|
|
209
|
+
re: new RegExp(`^node +(?:"((?:[^"]*[/\\\\])?${safe})"|((?:[^\\s"]*[/\\\\])?${safe})) +${args}$`),
|
|
208
210
|
canonical: canonicalPath,
|
|
209
211
|
});
|
|
210
212
|
};
|
package/tools/checker-claim.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// checker-claim.mjs — what a declared gate cmd CLAIMS about one of the kit's own
|
|
1
|
+
// checker-claim.mjs — what a declared gate cmd CLAIMS about one of the kit's own checker tools,
|
|
2
2
|
// as three named outcomes instead of a boolean. A LEAF: node built-ins only, so every surface that
|
|
3
3
|
// must recognize a tool invocation (the source-size matcher, the advisor's probes, the standalone
|
|
4
4
|
// migration's twin) decides through ONE screen.
|
|
@@ -17,7 +17,7 @@ import { isAbsolute, join } from 'node:path';
|
|
|
17
17
|
// A cmd makes exactly ONE of three claims about a given tool, and collapsing them into a boolean is
|
|
18
18
|
// what makes a VENDORED copy of the tool read as "the tool is not declared at all" — a false
|
|
19
19
|
// absence, with a remedy (adopt it) that then collides with the entry already there:
|
|
20
|
-
// • canonical — this tool's `--check`
|
|
20
|
+
// • canonical — this tool's invocation with its tail (`--check` by default), resolving to THIS copy
|
|
21
21
|
// • tool-elsewhere — the same invocation shape, resolving to a DIFFERENT real copy
|
|
22
22
|
// • not-the-tool — anything else: another command, a masked form, an inadmissible token, or a
|
|
23
23
|
// path nothing can resolve
|
|
@@ -55,16 +55,18 @@ const bareTokenSafe = (text) => text.length > 0 && ![...text].some((ch) => {
|
|
|
55
55
|
|
|
56
56
|
const RE_META = /[.*+?^${}()|[\]\\]/g;
|
|
57
57
|
|
|
58
|
-
// checkerClaimTool(basename, canonicalPath) → the screen for ONE tool. The shape is the STRICT
|
|
59
|
-
// command — `node` + ONE (quoted or bare) path token + the exact basename +
|
|
60
|
-
// masked form (`--check --help`, `--check || true`, a prefix
|
|
61
|
-
//
|
|
62
|
-
//
|
|
63
|
-
//
|
|
64
|
-
|
|
58
|
+
// checkerClaimTool(basename, canonicalPath, tail) → the screen for ONE tool. The shape is the STRICT
|
|
59
|
+
// full command — `node` + ONE (quoted or bare) path token + the exact basename + the exact argument
|
|
60
|
+
// tail (`--check` by default) + END — so a masked form (`--check --help`, `--check || true`, a prefix
|
|
61
|
+
// command) or a reordered tail is never any claim at all. Separators are PLAIN SPACES, not \s: a
|
|
62
|
+
// newline between the tokens is not a command a runner would execute as written. The basename and
|
|
63
|
+
// every tail token are regex-escaped here, never by the caller — a caller-escaped literal is one
|
|
64
|
+
// forgotten backslash away from a dot matching any byte.
|
|
65
|
+
export const checkerClaimTool = (basename, canonicalPath, tail = '--check') => {
|
|
65
66
|
const safe = basename.replace(RE_META, '\\$&');
|
|
67
|
+
const args = tail.split(' ').map((token) => token.replace(RE_META, '\\$&')).join(' +');
|
|
66
68
|
return Object.freeze({
|
|
67
|
-
re: new RegExp(`^node +(?:"((?:[^"]*[/\\\\])?${safe})"|((?:[^\\s"]*[/\\\\])?${safe}))
|
|
69
|
+
re: new RegExp(`^node +(?:"((?:[^"]*[/\\\\])?${safe})"|((?:[^\\s"]*[/\\\\])?${safe})) +${args}$`),
|
|
68
70
|
canonical: canonicalPath,
|
|
69
71
|
});
|
|
70
72
|
};
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
// checker-gates-read.mjs — the READ-ONLY leaf of the kit-owned checker gates: the frozen candidate
|
|
2
|
+
// table, the precondition probes, the declaration read and the one derivation the declare verb and
|
|
3
|
+
// the profile-gap detector both call. Governing contract: docs/ai/specs/kit/tier/checker-gates/
|
|
4
|
+
// (part checker-gates-read). No CLI (refuseDirectRun); nothing here writes.
|
|
5
|
+
import { lstatSync } from 'node:fs';
|
|
6
|
+
import { dirname, join, resolve } from 'node:path';
|
|
7
|
+
import { CHECKER_CLAIM, classifyCheckerClaim, dqUnsafePath } from './checker-claim.mjs';
|
|
8
|
+
import { refuseDirectRun } from './direct-run.mjs';
|
|
9
|
+
import { readRegularFileNoFollow } from './fs-read-nofollow.mjs';
|
|
10
|
+
import { GATES_REL, KIT_CHECKER_CLAIMS, coverageDeclarationDefects, validateDeclaration } from './gates-declaration.mjs';
|
|
11
|
+
import { escapeForLine, isLineUnsafe } from './source-size-core.mjs';
|
|
12
|
+
|
|
13
|
+
const DEPLOYMENT_CHAIN = ['.', 'docs', 'docs/ai'];
|
|
14
|
+
const NOT_APPLICABLE_CODES = new Set(['ENOENT', 'ENOTDIR']);
|
|
15
|
+
const OK = 'ok';
|
|
16
|
+
const ABSENT = 'absent';
|
|
17
|
+
const FOREIGN = 'foreign';
|
|
18
|
+
const SYMLINK_CLASS = 'symlink';
|
|
19
|
+
const GIT_DIR = Object.freeze({ rel: '.git', kinds: ['directory', 'file'], what: 'a directory or a regular gitfile' });
|
|
20
|
+
const STORE_ROOT = Object.freeze({ rel: 'docs/ai/specs/index.md', kinds: ['file'], what: 'a regular file' });
|
|
21
|
+
const COVERAGE_SCOPE = Object.freeze({ rel: 'docs/ai/spec-coverage.json', kinds: ['file'], what: 'a regular file' });
|
|
22
|
+
|
|
23
|
+
export const CANDIDATE_STATES = Object.freeze({
|
|
24
|
+
declared: 'declared',
|
|
25
|
+
idTaken: 'id-taken',
|
|
26
|
+
probeUnreadable: 'probe-unreadable',
|
|
27
|
+
notApplicable: 'not-applicable',
|
|
28
|
+
offered: 'offered',
|
|
29
|
+
withheld: 'withheld',
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
const lstatOf = (deps) => deps.lstatSync ?? lstatSync;
|
|
33
|
+
|
|
34
|
+
export const isDeployed = (root, deps) => {
|
|
35
|
+
try {
|
|
36
|
+
return DEPLOYMENT_CHAIN.every((path, index) => {
|
|
37
|
+
const stat = lstatOf(deps)(resolve(root, path));
|
|
38
|
+
if (stat.isSymbolicLink()) return false;
|
|
39
|
+
return index < DEPLOYMENT_CHAIN.length - 1 || stat.isDirectory();
|
|
40
|
+
});
|
|
41
|
+
} catch {
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const kindAt = (path, lstat) => {
|
|
47
|
+
try {
|
|
48
|
+
const stat = lstat(path);
|
|
49
|
+
if (stat.isSymbolicLink()) return { kind: SYMLINK_CLASS };
|
|
50
|
+
if (stat.isDirectory()) return { kind: 'directory' };
|
|
51
|
+
return { kind: stat.isFile() ? 'file' : 'other' };
|
|
52
|
+
} catch (error) {
|
|
53
|
+
if (NOT_APPLICABLE_CODES.has(error?.code)) return { kind: ABSENT };
|
|
54
|
+
return { unreadable: String(error?.code ?? error?.message ?? error) };
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
// A probe answers {} when its checker runs by design over the tree, else the state and its detail.
|
|
59
|
+
const requiring = (...requirements) => (root, deps) => {
|
|
60
|
+
const judged = requirements.map((requirement) => ({ requirement, ...kindAt(resolve(root, requirement.rel), lstatOf(deps)) }));
|
|
61
|
+
const unreadable = judged.find((item) => item.unreadable !== undefined);
|
|
62
|
+
if (unreadable) {
|
|
63
|
+
return { state: CANDIDATE_STATES.probeUnreadable, detail: `${unreadable.requirement.rel}: ${unreadable.unreadable}` };
|
|
64
|
+
}
|
|
65
|
+
const missing = judged.find(({ requirement, kind }) => !requirement.kinds.includes(kind));
|
|
66
|
+
if (missing) return { state: CANDIDATE_STATES.notApplicable, detail: `${missing.requirement.rel} is not ${missing.requirement.what}` };
|
|
67
|
+
return {};
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const candidate = (id, title, probe) => Object.freeze({ id, title, probe });
|
|
71
|
+
|
|
72
|
+
export const CHECKER_GATE_CANDIDATES = Object.freeze([
|
|
73
|
+
candidate('control-bytes', 'No raw control byte in the work tree', requiring(GIT_DIR)),
|
|
74
|
+
candidate('plan-shape', 'Plans in flight keep the structural planning shape', requiring()),
|
|
75
|
+
candidate('spec-check', 'Feature-spec store structure — the whole store', requiring(STORE_ROOT)),
|
|
76
|
+
candidate(
|
|
77
|
+
'spec-coverage',
|
|
78
|
+
'No work without a specification — every in-scope tool is governed by a contract, or named in the shrink-only debt',
|
|
79
|
+
requiring(COVERAGE_SCOPE, STORE_ROOT),
|
|
80
|
+
),
|
|
81
|
+
]);
|
|
82
|
+
|
|
83
|
+
const claimOf = (id) => KIT_CHECKER_CLAIMS.find((claim) => claim.id === id);
|
|
84
|
+
|
|
85
|
+
const refusal = (name, detail) => (detail === undefined ? { refusal: name } : { refusal: name, detail: String(detail) });
|
|
86
|
+
|
|
87
|
+
const attempt = (read) => {
|
|
88
|
+
try {
|
|
89
|
+
return { value: read() };
|
|
90
|
+
} catch (error) {
|
|
91
|
+
return { error };
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
const readDeclaration = (root, deps) => {
|
|
96
|
+
const read = readRegularFileNoFollow(resolve(root, GATES_REL), deps);
|
|
97
|
+
if (read.outcome === ABSENT) return refusal('declaration-absent');
|
|
98
|
+
if (read.outcome === FOREIGN) {
|
|
99
|
+
return read.className === SYMLINK_CLASS ? refusal('declaration-symlink') : refusal('declaration-not-regular', read.className);
|
|
100
|
+
}
|
|
101
|
+
if (read.outcome !== OK) return refusal('declaration-unreadable', read.code);
|
|
102
|
+
const parsed = attempt(() => JSON.parse(read.content));
|
|
103
|
+
if (parsed.error) return refusal('declaration-malformed', parsed.error.message);
|
|
104
|
+
const validated = attempt(() => validateDeclaration(parsed.value));
|
|
105
|
+
if (validated.error) return refusal('declaration-invalid', validated.error.message);
|
|
106
|
+
const gates = validated.value;
|
|
107
|
+
const defects = coverageDeclarationDefects(gates, root);
|
|
108
|
+
if (defects.length > 0) return refusal('declaration-coverage-defect', defects[0].message);
|
|
109
|
+
return { declaration: Object.hasOwn(parsed.value, '_README') ? { readme: parsed.value._README, gates } : { gates } };
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
const claimState = ({ id, screen }, gates, root) => {
|
|
113
|
+
const claimed = gates.some((gate) => {
|
|
114
|
+
const claim = classifyCheckerClaim(screen, gate.cmd, root);
|
|
115
|
+
return claim === CHECKER_CLAIM.CANONICAL || claim === CHECKER_CLAIM.ELSEWHERE;
|
|
116
|
+
});
|
|
117
|
+
if (claimed) return { state: CANDIDATE_STATES.declared };
|
|
118
|
+
const taken = gates.find((gate) => gate.id === id);
|
|
119
|
+
return taken ? { state: CANDIDATE_STATES.idTaken, detail: taken.cmd } : {};
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
const toolPathOf = ({ basename, screen }, deps) => join(deps.kitToolsDir ?? dirname(screen.canonical), basename);
|
|
123
|
+
const isUnrenderable = (path) => dqUnsafePath(path) || isLineUnsafe(path);
|
|
124
|
+
|
|
125
|
+
const judgeCandidate = ({ id, title, probe }, rendered, gates, root, deps) => {
|
|
126
|
+
const claimed = claimState(claimOf(id), gates, root);
|
|
127
|
+
if (claimed.state) return claimed;
|
|
128
|
+
const probed = probe(root, deps);
|
|
129
|
+
if (probed.state) return probed;
|
|
130
|
+
if (rendered.unrenderable) return { state: CANDIDATE_STATES.withheld };
|
|
131
|
+
return { state: CANDIDATE_STATES.offered, entry: JSON.stringify({ id, title, cmd: rendered.cmd }) };
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
const shapeOf = (id, { state, entry = null, detail }) => (detail === undefined ? { id, state, entry } : { id, state, entry, detail });
|
|
135
|
+
|
|
136
|
+
export const judgeCheckerGates = (root, deps = {}) => {
|
|
137
|
+
if (!isDeployed(root, deps)) return refusal('no-deployment');
|
|
138
|
+
const loaded = readDeclaration(root, deps);
|
|
139
|
+
if (loaded.refusal) return loaded;
|
|
140
|
+
const rendered = CHECKER_GATE_CANDIDATES.map(({ id }) => {
|
|
141
|
+
const claim = claimOf(id);
|
|
142
|
+
const path = toolPathOf(claim, deps);
|
|
143
|
+
return isUnrenderable(path) ? { unrenderable: path } : { cmd: `node "${path}" ${claim.tail}` };
|
|
144
|
+
});
|
|
145
|
+
const judged = CHECKER_GATE_CANDIDATES.map((entry, index) => judgeCandidate(entry, rendered[index], loaded.declaration.gates, root, deps));
|
|
146
|
+
const firstWithheld = judged.findIndex(({ state }) => state === CANDIDATE_STATES.withheld);
|
|
147
|
+
const named = (item, index) => (index === firstWithheld
|
|
148
|
+
? { ...item, detail: `the kit path cannot be rendered into a command: ${escapeForLine(rendered[index].unrenderable)}` }
|
|
149
|
+
: item);
|
|
150
|
+
return {
|
|
151
|
+
declaration: loaded.declaration,
|
|
152
|
+
candidates: CHECKER_GATE_CANDIDATES.map(({ id }, index) => shapeOf(id, named(judged[index], index))),
|
|
153
|
+
};
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
refuseDirectRun(import.meta.url);
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// checker-gates.mjs — the declare verb of the kit-owned checker gates: previews the candidates the
|
|
3
|
+
// read leaf judges and, on --apply, writes the offered ones add-only into docs/ai/gates.json.
|
|
4
|
+
// Governing contract: docs/ai/specs/kit/tier/checker-gates/ (part checker-gates-verb).
|
|
5
|
+
// main(argv, deps) returns, never exits, never asks.
|
|
6
|
+
import { resolve } from 'node:path';
|
|
7
|
+
import { assertDocsAiDeployment, writeDocsAiFileAtomic } from './atomic-write.mjs';
|
|
8
|
+
import { safeLine } from './carriers.mjs';
|
|
9
|
+
import { CANDIDATE_STATES, judgeCheckerGates } from './checker-gates-read.mjs';
|
|
10
|
+
import { isDirectRun } from './direct-run.mjs';
|
|
11
|
+
import { GATES_REL, coverageDeclarationDefects, validateDeclaration } from './gates-declaration.mjs';
|
|
12
|
+
import { TRUST_CHAIN_DISCLOSURE, placeEntries } from './gates-init.mjs';
|
|
13
|
+
|
|
14
|
+
const LF = String.fromCharCode(10);
|
|
15
|
+
const ARGV_OFFSET = 2;
|
|
16
|
+
const EXIT_SUCCESS = 0;
|
|
17
|
+
const EXIT_REFUSAL = 1;
|
|
18
|
+
const EXIT_USAGE = 2;
|
|
19
|
+
const CWD_FLAG = '--cwd';
|
|
20
|
+
const APPLY_FLAG = '--apply';
|
|
21
|
+
const ONLY_FLAG = '--only';
|
|
22
|
+
const HELP_FLAGS = new Set(['--help', '-h']);
|
|
23
|
+
const APPLIED = 'applied';
|
|
24
|
+
const INDENT = ' ';
|
|
25
|
+
const JSON_INDENT = 2;
|
|
26
|
+
const NOUN = 'a gate declaration';
|
|
27
|
+
|
|
28
|
+
export const OUTCOME_LINES = Object.freeze({
|
|
29
|
+
candidate: (id, word, detail) => `${id}: ${word}${detail ? ` — ${safeLine(detail)}` : ''}`,
|
|
30
|
+
entry: (json) => `${INDENT}entry: ${json}`,
|
|
31
|
+
disclosure: () => TRUST_CHAIN_DISCLOSURE,
|
|
32
|
+
refusal: (name, detail) => `checker-gates: refused — ${name}${detail ? `: ${safeLine(detail)}` : ''}`,
|
|
33
|
+
usage: (problem) => `usage: checker-gates.mjs --cwd DIR [--apply] [--only ID]... — ${safeLine(problem)}`,
|
|
34
|
+
onlyNotOffered: (ids, offered) => `${ONLY_FLAG} names ids not offered: ${ids.join(', ')} (offered: ${offered.join(', ') || 'none'})`,
|
|
35
|
+
help: () => [
|
|
36
|
+
'checker-gates.mjs --cwd DIR [--apply] [--only ID]...',
|
|
37
|
+
'Previews the kit-owned checker gates the project in DIR can declare; writes nothing by default.',
|
|
38
|
+
'--apply writes the offered entries into docs/ai/gates.json, add-only; --only ID narrows the write.',
|
|
39
|
+
'Exit codes: 0 done, 1 one named refusal, 2 usage.',
|
|
40
|
+
].join(LF),
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
const result = (code, stdout = '', stderr = '') => ({ code, stdout, stderr });
|
|
44
|
+
const refuse = (name, detail) => result(EXIT_REFUSAL, '', OUTCOME_LINES.refusal(name, detail));
|
|
45
|
+
const causeOf = (error) => String(error?.message ?? error);
|
|
46
|
+
|
|
47
|
+
const parseArgs = (argv) => {
|
|
48
|
+
if (argv.length === 1 && HELP_FLAGS.has(argv[0])) return { help: true };
|
|
49
|
+
const options = { only: [] };
|
|
50
|
+
for (let index = 0; index < argv.length; index += 1) {
|
|
51
|
+
const flag = argv[index];
|
|
52
|
+
const value = argv[index + 1];
|
|
53
|
+
if (flag === CWD_FLAG) {
|
|
54
|
+
if (options.cwd !== undefined) return { problem: `${CWD_FLAG} given twice` };
|
|
55
|
+
if (value === undefined || value.startsWith('-')) return { problem: `${CWD_FLAG} needs a directory` };
|
|
56
|
+
options.cwd = value;
|
|
57
|
+
index += 1;
|
|
58
|
+
} else if (flag === APPLY_FLAG) {
|
|
59
|
+
if (options.apply) return { problem: `${APPLY_FLAG} given twice` };
|
|
60
|
+
options.apply = true;
|
|
61
|
+
} else if (flag === ONLY_FLAG) {
|
|
62
|
+
if (value === undefined || value.startsWith('-')) return { problem: `${ONLY_FLAG} needs a gate id` };
|
|
63
|
+
if (!options.only.includes(value)) options.only.push(value);
|
|
64
|
+
index += 1;
|
|
65
|
+
} else {
|
|
66
|
+
return { problem: `unknown argument ${flag}` };
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
if (options.cwd === undefined) return { problem: `${CWD_FLAG} is required` };
|
|
70
|
+
return { cwd: options.cwd, apply: Boolean(options.apply), only: options.only };
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
export const mergeCheckerGates = (loaded, selected, root) => {
|
|
74
|
+
const readme = Object.hasOwn(loaded, 'readme') ? { _README: loaded.readme } : {};
|
|
75
|
+
const merged = { ...readme, gates: placeEntries(loaded.gates, selected, root) };
|
|
76
|
+
validateDeclaration(merged);
|
|
77
|
+
const defects = coverageDeclarationDefects(merged.gates, root);
|
|
78
|
+
if (defects.length > 0) return { refusal: 'coverage-defect', detail: defects[0].message };
|
|
79
|
+
return { merged, body: `${JSON.stringify(merged, null, JSON_INDENT)}${LF}` };
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
const renderLines = (candidates) => {
|
|
83
|
+
const disclose = candidates.some(({ state }) => state === CANDIDATE_STATES.offered || state === APPLIED);
|
|
84
|
+
const lines = candidates.flatMap(({ id, state, entry, detail }) => (state === CANDIDATE_STATES.offered
|
|
85
|
+
? [OUTCOME_LINES.candidate(id, state, detail), OUTCOME_LINES.entry(entry)]
|
|
86
|
+
: [OUTCOME_LINES.candidate(id, state, detail)]));
|
|
87
|
+
return disclose ? [OUTCOME_LINES.disclosure(), ...lines] : lines;
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
const writeSelected = (root, judged, selected, deps) => {
|
|
91
|
+
const merge = mergeCheckerGates(judged.declaration, selected.map(({ entry }) => JSON.parse(entry)), root);
|
|
92
|
+
if (merge.refusal) return { refusal: refuse(merge.refusal, merge.detail) };
|
|
93
|
+
try {
|
|
94
|
+
writeDocsAiFileAtomic(root, GATES_REL, merge.body, deps, { noun: NOUN, rel: GATES_REL });
|
|
95
|
+
} catch (error) {
|
|
96
|
+
return { refusal: refuse('write-failed', causeOf(error)) };
|
|
97
|
+
}
|
|
98
|
+
const written = new Set(selected.map(({ id }) => id));
|
|
99
|
+
return { candidates: judged.candidates.map((item) => (written.has(item.id) ? { ...item, state: APPLIED, entry: null } : item)) };
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
const runVerb = (options, deps) => {
|
|
103
|
+
const root = resolve(options.cwd);
|
|
104
|
+
try {
|
|
105
|
+
assertDocsAiDeployment(root, deps, { noun: NOUN, rel: GATES_REL });
|
|
106
|
+
} catch (error) {
|
|
107
|
+
return refuse('no-deployment', causeOf(error));
|
|
108
|
+
}
|
|
109
|
+
const judged = judgeCheckerGates(root, deps);
|
|
110
|
+
if (judged.refusal) return refuse(judged.refusal, judged.detail);
|
|
111
|
+
const offered = judged.candidates.filter(({ state }) => state === CANDIDATE_STATES.offered);
|
|
112
|
+
const offeredIds = offered.map(({ id }) => id);
|
|
113
|
+
const unknown = options.only.filter((id) => !offeredIds.includes(id));
|
|
114
|
+
if (unknown.length > 0) return result(EXIT_USAGE, '', OUTCOME_LINES.usage(OUTCOME_LINES.onlyNotOffered(unknown, offeredIds)));
|
|
115
|
+
const selected = options.only.length > 0 ? offered.filter(({ id }) => options.only.includes(id)) : offered;
|
|
116
|
+
if (!options.apply || selected.length === 0) return result(EXIT_SUCCESS, renderLines(judged.candidates).join(LF));
|
|
117
|
+
const written = writeSelected(root, judged, selected, deps);
|
|
118
|
+
if (written.refusal) return written.refusal;
|
|
119
|
+
return result(EXIT_SUCCESS, renderLines(written.candidates).join(LF));
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
export const main = (argv, deps = {}) => {
|
|
123
|
+
const parsed = parseArgs(argv);
|
|
124
|
+
if (parsed.help) return result(EXIT_SUCCESS, OUTCOME_LINES.help());
|
|
125
|
+
if (parsed.problem) return result(EXIT_USAGE, '', OUTCOME_LINES.usage(parsed.problem));
|
|
126
|
+
return runVerb(parsed, deps);
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
if (isDirectRun(import.meta.url)) {
|
|
130
|
+
const outcome = main(process.argv.slice(ARGV_OFFSET));
|
|
131
|
+
if (outcome.stdout) console.log(outcome.stdout);
|
|
132
|
+
if (outcome.stderr) console.error(outcome.stderr);
|
|
133
|
+
process.exitCode = outcome.code;
|
|
134
|
+
}
|
package/tools/direct-run.mjs
CHANGED
|
@@ -67,6 +67,8 @@ export const LIBRARY_ONLY_MODULES = Object.freeze({
|
|
|
67
67
|
'set-recipe-roster.mjs': '/agent-workflow-kit set-recipe',
|
|
68
68
|
// The read half of the tier offer: the upgrade's step-3 `tier` item runs the offer that uses it.
|
|
69
69
|
'reference-profile.mjs': '/agent-workflow-kit upgrade',
|
|
70
|
+
// The read half of the checker-gates verb: the same step-3 `tier` item runs the verb that uses it.
|
|
71
|
+
'checker-gates-read.mjs': '/agent-workflow-kit upgrade',
|
|
70
72
|
});
|
|
71
73
|
|
|
72
74
|
// The frozen refusal line. One line, names the module, names the command.
|
package/tools/doc-parity.mjs
CHANGED
|
@@ -330,8 +330,8 @@ read only from the surface anchored between the doc's advisor-matrix begin/end m
|
|
|
330
330
|
elsewhere in the doc can neither stand in for it nor mask its drift, and a drifted header inside the
|
|
331
331
|
anchor fails closed rather than falling through to another table.
|
|
332
332
|
|
|
333
|
-
--check exits 0/1 as a gate
|
|
334
|
-
result. Default prints the per-binding report.
|
|
333
|
+
--check exits 0/1 as a gate over the kit's own package, the gate a kit maintainer runs. --json prints
|
|
334
|
+
the structured result. Default prints the per-binding report.
|
|
335
335
|
|
|
336
336
|
Read-only: never writes, never commits, spawns nothing. Exit codes: 0 pass (or plain report); 1 drift
|
|
337
337
|
(under --check) or error; 2 usage.`;
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
import { readFileSync, lstatSync, realpathSync } from 'node:fs';
|
|
10
10
|
import { join, isAbsolute } from 'node:path';
|
|
11
11
|
import { fileURLToPath } from 'node:url';
|
|
12
|
+
import { CHECKER_CLAIM, checkerClaimTool, classifyCheckerClaim } from './checker-claim.mjs';
|
|
12
13
|
import { fail, loadConfig, CONFIG_REL } from './orchestration-config.mjs';
|
|
13
14
|
import { isCoverageProducerGate } from './coverage-producer.mjs';
|
|
14
15
|
import { matchesSourceSizeGate } from './source-size-core.mjs';
|
|
@@ -224,8 +225,21 @@ export const isReviewDependentGate = (gate, projectDir) =>
|
|
|
224
225
|
// "does this declaration verify the PROJECT?" through the review-dependent predicate alone read a
|
|
225
226
|
// matrix of nothing but that gate as project verification. Three surfaces asked it, each knowing a
|
|
226
227
|
// different half; this is the one home, so a future kit checker is added once.
|
|
228
|
+
// KIT_CHECKER_CLAIMS is the one statement of the four declarable kit checkers' basenames, tails and
|
|
229
|
+
// canonical paths (docs/ai/specs/kit/tier/checker-gates/, part checker-claim-tail).
|
|
230
|
+
const kitCheckerClaim = (id, basename, tail) => Object.freeze({
|
|
231
|
+
id, basename, tail, screen: checkerClaimTool(basename, fileURLToPath(new URL(`./${basename}`, import.meta.url)), tail),
|
|
232
|
+
});
|
|
233
|
+
export const KIT_CHECKER_CLAIMS = Object.freeze([
|
|
234
|
+
kitCheckerClaim('control-bytes', 'control-bytes.mjs', '--check'),
|
|
235
|
+
kitCheckerClaim('plan-shape', 'plan-shape-cli.mjs', '--check --in-flight'),
|
|
236
|
+
kitCheckerClaim('spec-check', 'spec-check-cli.mjs', '--all'),
|
|
237
|
+
kitCheckerClaim('spec-coverage', 'spec-coverage-cli.mjs', '--check'),
|
|
238
|
+
]);
|
|
239
|
+
|
|
227
240
|
export const isKitOwnedCheckerGate = (gate, projectDir) =>
|
|
228
|
-
isReviewDependentGate(gate, projectDir) || matchesSourceSizeGate(gate.cmd, projectDir)
|
|
241
|
+
isReviewDependentGate(gate, projectDir) || matchesSourceSizeGate(gate.cmd, projectDir)
|
|
242
|
+
|| KIT_CHECKER_CLAIMS.some(({ screen }) => classifyCheckerClaim(screen, gate.cmd, projectDir) === CHECKER_CLAIM.CANONICAL);
|
|
229
243
|
|
|
230
244
|
// ── the pregate subset derivation (#66 / Decision 7 — ONE home for producer and factory) ─────
|
|
231
245
|
|
package/tools/gates-init.mjs
CHANGED
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
// explicitly-consenting prose (the init/bootstrap flows and the gates.md consent-fill section) —
|
|
5
5
|
// it is NOT a routable mode token, it sits OUTSIDE every velocity allowlist tier (a
|
|
6
6
|
// consent-per-run writer is never pre-approved), and the shipped gates.json TEMPLATE stays EMPTY
|
|
7
|
-
// (AD-021/AD-038): a populated declaration is per-entry maintainer consent recorded through
|
|
8
|
-
// preview, never auto-seeding.
|
|
9
|
-
//
|
|
7
|
+
// (AD-021/AD-038): a populated declaration is per-entry maintainer consent recorded through a
|
|
8
|
+
// consented writer (this preview among them), never auto-seeding. This preview runs at INIT; at UPGRADE step 3's
|
|
9
|
+
// run-list changes entries only through the consented legacy migration and, under `tier`, checker-gates.mjs.
|
|
10
10
|
//
|
|
11
11
|
// What it offers (the derivation invariants, test-pinned) — CLOSED-WORLD since AD-052: an entry
|
|
12
12
|
// is offered only when every axis is proven safe by MEMBERSHIP in a finite, test-guarded set,
|
package/tools/profile-gaps.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { resolve } from 'node:path';
|
|
2
2
|
import { fileURLToPath } from 'node:url';
|
|
3
|
+
import { CANDIDATE_STATES, isDeployed, judgeCheckerGates } from './checker-gates-read.mjs';
|
|
3
4
|
import { CONFIG_REL, validateConfig } from './orchestration-config.mjs';
|
|
4
5
|
import { TIER_TARGETS } from './reference-profile.mjs';
|
|
5
6
|
import {
|
|
@@ -16,8 +17,10 @@ const GAP_ID = 'story-sessions-section';
|
|
|
16
17
|
const SLOTS_ID = 'epic-task-slots';
|
|
17
18
|
const STORE_ID = 'epic-store-seeded';
|
|
18
19
|
const STORE_PATH = 'docs/ai/epics';
|
|
19
|
-
const
|
|
20
|
+
const CHECKER_GATES_ID = 'checker-gates-declared';
|
|
20
21
|
const TIER_PREVIEW_PATH = fileURLToPath(new URL('./tier-preview.mjs', import.meta.url));
|
|
22
|
+
const CHECKER_GATES_PATH = fileURLToPath(new URL('./checker-gates.mjs', import.meta.url));
|
|
23
|
+
const UNDECIDED_STATES = [CANDIDATE_STATES.idTaken, CANDIDATE_STATES.probeUnreadable, CANDIDATE_STATES.withheld];
|
|
21
24
|
const STORY_ID = 'story-sessions';
|
|
22
25
|
const TEMPLATE_CANON = 'template';
|
|
23
26
|
const ENCODING = 'utf8';
|
|
@@ -97,18 +100,6 @@ const detectStorySessions = ({ root, deps }) => {
|
|
|
97
100
|
return { verdict: VERDICTS.absent };
|
|
98
101
|
};
|
|
99
102
|
|
|
100
|
-
const isDeployed = (root, deps) => {
|
|
101
|
-
try {
|
|
102
|
-
return DEPLOYMENT_CHAIN.every((path, index) => {
|
|
103
|
-
const stat = deps.lstatSync(resolve(root, path));
|
|
104
|
-
if (stat.isSymbolicLink()) return false;
|
|
105
|
-
return index < DEPLOYMENT_CHAIN.length - 1 || stat.isDirectory();
|
|
106
|
-
});
|
|
107
|
-
} catch {
|
|
108
|
-
return false;
|
|
109
|
-
}
|
|
110
|
-
};
|
|
111
|
-
|
|
112
103
|
const parseConfig = (bytes) => {
|
|
113
104
|
let parsed;
|
|
114
105
|
try {
|
|
@@ -163,10 +154,19 @@ const detectStore = ({ root, deps }) => {
|
|
|
163
154
|
return { verdict: VERDICTS.present };
|
|
164
155
|
};
|
|
165
156
|
|
|
157
|
+
const detectCheckerGates = ({ root, deps }) => {
|
|
158
|
+
const judged = judgeCheckerGates(root, deps);
|
|
159
|
+
if (judged.refusal) return reportUndecidable(judged.refusal);
|
|
160
|
+
if (judged.candidates.some(({ state }) => state === CANDIDATE_STATES.offered)) return { verdict: VERDICTS.absent };
|
|
161
|
+
const undecided = judged.candidates.find(({ state }) => UNDECIDED_STATES.includes(state));
|
|
162
|
+
return undecided ? reportUndecidable(undecided.state) : { verdict: VERDICTS.present };
|
|
163
|
+
};
|
|
164
|
+
|
|
166
165
|
const tierPreview = (root) => buildInsertPreview(root, TIER_PREVIEW_PATH);
|
|
167
166
|
|
|
168
167
|
export const PROFILE_GAPS = Object.freeze([
|
|
169
168
|
Object.freeze({ id: GAP_ID, detect: detectStorySessions, apply: (root) => buildInsertPreview(root) }),
|
|
170
169
|
Object.freeze({ id: SLOTS_ID, detect: detectSlots, apply: tierPreview }),
|
|
171
170
|
Object.freeze({ id: STORE_ID, detect: detectStore, apply: tierPreview }),
|
|
171
|
+
Object.freeze({ id: CHECKER_GATES_ID, detect: detectCheckerGates, apply: (root) => buildInsertPreview(root, CHECKER_GATES_PATH) }),
|
|
172
172
|
]);
|