@sabaiway/agent-workflow-kit 23.9.0 → 23.10.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 +28 -0
- package/SKILL.md +1 -1
- package/capability.json +1 -1
- package/package.json +1 -1
- package/references/modes/gates.md +1 -1
- package/references/modes/now.md +1 -1
- package/references/modes/procedures.md +1 -1
- package/references/modes/recommendations.md +2 -2
- package/tools/gates-init.mjs +3 -3
- package/tools/now-render.mjs +1 -1
- package/tools/procedures.mjs +5 -11
- package/tools/recommendations.mjs +4 -4
- package/tools/source-size/help.mjs +8 -7
- package/tools/source-size/index.mjs +1 -0
- package/tools/source-size/limits.mjs +8 -2
- package/tools/source-size/piles.mjs +2 -2
- package/tools/source-size/reason.mjs +0 -1
- package/tools/source-size/record.mjs +6 -13
- package/tools/source-size/setup.mjs +2 -2
- package/tools/source-size-config.mjs +29 -41
- package/tools/source-size-core.mjs +3 -2
- package/tools/source-size-judge.mjs +11 -28
- package/tools/source-size-refusal.mjs +1 -1
- package/tools/source-size-report.mjs +24 -27
- package/tools/source-size-runs.mjs +31 -24
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,34 @@ Semantically versioned ([semver](https://semver.org)), newest first. The `versio
|
|
|
4
4
|
is the current release. `upgrade` mode reads a project's `docs/ai/.workflow-version` and applies
|
|
5
5
|
every `migrations/<version>-<slug>.md` newer than it, in semver order.
|
|
6
6
|
|
|
7
|
+
## 23.10.0 — a line added inside a file's limits no longer stops the size check (AD-238)
|
|
8
|
+
|
|
9
|
+
**After `/agent-workflow-kit upgrade`, the size check no longer sums the lines of each declared root.** Before, a
|
|
10
|
+
regeneration recorded each root's line sum under `aggregate`, and one line added to any file, however far within its
|
|
11
|
+
limits, stopped the check and asked a reason for growth no single file shows.
|
|
12
|
+
|
|
13
|
+
- **No per-root line sum is judged or recorded.** A file within its limits is no finding, however the root grows;
|
|
14
|
+
every per-file and layout record keeps its ratchet, and files per root still stops a growing root where layout is
|
|
15
|
+
recorded.
|
|
16
|
+
- **An existing record keeps working.** A minted config that still holds `aggregate` gets one warning about it on
|
|
17
|
+
every check that judges it, with the paste-ready `--write-baseline` line, which needs no reason where nothing else
|
|
18
|
+
rises. That regeneration drops the sum, printing one `<root>: aggregate lines <n> → none` line per root.
|
|
19
|
+
- **Every regeneration writes config schema 3**, which is schema 2 with no `aggregate`. The reader takes schemas 1,
|
|
20
|
+
2 and 3. A write that changes the file's schema prints `moved from schema <from> to schema <to> in this write`, and
|
|
21
|
+
the first write of an absent config prints `written at schema 3 in this write`; each adds that a kit that predates
|
|
22
|
+
that schema stops by name until that copy is upgraded.
|
|
23
|
+
- **A clone or a vendored copy on kit 23.9.0 or earlier stops by name** on a config written at schema 3
|
|
24
|
+
(`"schema" must be 1 or 2, got 3`, exit 2) until that copy is upgraded. Before the write, the kit says so only in
|
|
25
|
+
the deployed sum's warning; after it, in the line above.
|
|
26
|
+
- **A config with a file record and no sum is judged**, where it stopped before as half-written: a config is absent,
|
|
27
|
+
authored (no `baseline`) or minted (`baseline` present).
|
|
28
|
+
- **The verbatim move of a minted schema-1 config** (by `--adopt`, or by a `--write-baseline` that refuses a raise)
|
|
29
|
+
writes schema 2 where the file holds `aggregate`, which it carries as it is, and schema 3 where it holds none; an
|
|
30
|
+
admitted regeneration of a schema-1 config lands on schema 3.
|
|
31
|
+
- **Fixed:** a directory named `constructor` no longer stops the size check where layout is judged.
|
|
32
|
+
- The green practice line, the procedures block, the `now` CAMPAIGN line, `--help` and the advisor's texts no longer
|
|
33
|
+
state a sum or a half-written record.
|
|
34
|
+
|
|
7
35
|
## 23.9.0 — a failed coverage check shows what failed and the fix first (AD-237)
|
|
8
36
|
|
|
9
37
|
**After `/agent-workflow-kit upgrade`, a red `coverage-check.mjs --check` run opens with its failure, and so do a
|
package/SKILL.md
CHANGED
|
@@ -3,7 +3,7 @@ name: agent-workflow-kit
|
|
|
3
3
|
description: Deploy or upgrade a portable AI-agent memory-and-workflow system in any project. Use when the user wants to bootstrap `docs/ai/` + an entry-point `AGENTS.md` (+ `CLAUDE.md` alias) + cap/archive/index enforcement in a new or existing repo, set up the Memory Map and session protocols, install the docs-rotation pre-commit hook, or run `/agent-workflow-kit` / `/agent-workflow-kit upgrade`. Triggers on phrases like "set up the memory system", "deploy the AI workflow here", "bootstrap docs/ai", "upgrade the workflow". New to the epic, story and task tier? Run `/agent-workflow-kit tier`. A typed decision with a confidence from Jev? Run `/agent-workflow-kit jev`.
|
|
4
4
|
disable-model-invocation: true
|
|
5
5
|
metadata:
|
|
6
|
-
version: '23.
|
|
6
|
+
version: '23.10.0'
|
|
7
7
|
---
|
|
8
8
|
|
|
9
9
|
# agent-workflow-kit
|
package/capability.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sabaiway/agent-workflow-kit",
|
|
3
|
-
"version": "23.
|
|
3
|
+
"version": "23.10.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",
|
|
@@ -21,7 +21,7 @@ Declared gates can also be **auto-approved** (no permission prompt on a byte-exa
|
|
|
21
21
|
|
|
22
22
|
**Candidate line — the review-receipt gate (opt-in, never auto-seeded; AD-021).** Projects that configure a reviewed/council `plan-execution.review` recipe can declare the review-state check as one more gate — the exact candidate `{ id, title, cmd }` line and its contract live under `${CLAUDE_SKILL_DIR}/references/modes/review-state.md` (step 3).
|
|
23
23
|
|
|
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 schema
|
|
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 past schema 1** — an absent config has nothing to offer, an authored-but-unminted one is withheld by name rather than declaring a gate that would refuse, and a minted schema-1 one is withheld naming its `--write-baseline` move. 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 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`, `spec-coverage` and `project-rules` 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` and `project-rules` 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
27
|
|
package/references/modes/now.md
CHANGED
|
@@ -13,7 +13,7 @@ The four blocks keep this order:
|
|
|
13
13
|
1. **NOW** — every plan in flight, its derived phase, current and next step, then the tree fingerprint, clean state, review verdict lines, final run and red-proof currency. No plan and several plans are rendered states; never pick one silently.
|
|
14
14
|
2. **STEPS** — every ledger row with one of `landed`, `in progress`, `pending` or `unjudged`. The rows are the steps; invent no numbering.
|
|
15
15
|
3. **QUEUE** — every work-carrying row (live, parked, ambiguous) under the full line-numbered heading path it carries, with per-class counts covering every row of the bucket, terminal and record included, and names rather than ids. Only a path through `## Pending / backlog` calls its position priority; every other bucket is archive and calls it position.
|
|
16
|
-
4. **CAMPAIGN** — source-size config state (`absent`, `authored`, `
|
|
16
|
+
4. **CAMPAIGN** — source-size config state (`absent`, `authored`, `minted`), caps, roots and recorded over-cap files. An absent opt-in config is a rendered state.
|
|
17
17
|
|
|
18
18
|
Evidence alone sets a ledger status: the row's path and verb, then the path fact, changed set and exclusion fact. The plan's prose never sets a status. A checked box or terminal marker is only a claim; when evidence contradicts it, print the claim beside the evidence-derived status. Keep anomaly and current red-proof annotations beside the same status too. Every status line names its evidence source.
|
|
19
19
|
|
|
@@ -31,7 +31,7 @@ Run **`node ${CLAUDE_SKILL_DIR}/tools/procedures.mjs <activity> [--override <slo
|
|
|
31
31
|
|
|
32
32
|
**Flow armed-halves block (session-start read side).** When the config carries a `flow` block, the advisor also renders `Flow (schema 1) — armed halves (config · chain · bookkeeping):` — the **config half** (preset · councilRounds · kitMinVersion), the **chain half** (a light read-only probe of the flow store on the checker's fixed path: ARMED at an adoption record, UNARMED for an absent or unadopted store, fail-closed BROKEN wording for a malformed one), and the **bookkeeping half** (each declared path: declared non-excluded — the tracked-file floor verifies on the `set-flow` arming path — vs loudly DECLARED-EXCLUDED). A config with no `flow` block renders byte-identically to before and pays no store probe.
|
|
33
33
|
|
|
34
|
-
**Declared source-size practice block (upfront knowledge, D-17 U1).** When the project declares a source-size practice in `docs/ai/source-size.json`, the advisor also renders `Declared source-size practice (docs/ai/source-size.json) — known BEFORE the code is written:` — the caps, the five limits with their tolerances, whether layout is recorded, on schema 1 the `--write-baseline` move, what is recorded and the canonical WHY sentence (the plan-time layout itself is the planning canon's Module ledger). `--json` carries the SAME lines under **`declaredPractice`** (an empty array when nothing is declared), so the human and structured renders never diverge. The
|
|
34
|
+
**Declared source-size practice block (upfront knowledge, D-17 U1).** When the project declares a source-size practice in `docs/ai/source-size.json`, the advisor also renders `Declared source-size practice (docs/ai/source-size.json) — known BEFORE the code is written:` — the caps, the five limits with their tolerances, whether layout is recorded, on schema 1 the `--write-baseline` move, what is recorded and the canonical WHY sentence (the plan-time layout itself is the planning canon's Module ledger). `--json` carries the SAME lines under **`declaredPractice`** (an empty array when nothing is declared), so the human and structured renders never diverge. The three config states each read as themselves: **ABSENT** renders nothing at all (a project declaring no practice is handed no invented limits), **AUTHORED** is pre-mint (no file size is recorded yet), **MINTED** carries the recorded count. A declaration that cannot be read (malformed, unknown-keyed, a dangling symlink) renders ONE loud `UNREADABLE` line and the advisor **still exits 0** — the practice's own checker owns the exit code for its config (exit 2 there) and its declared gate reds the gate matrix. Read through the practice's pure read core, so this advisor never reaches its writer half.
|
|
35
35
|
|
|
36
36
|
**Readers-sweep block (`plan-authoring` only, unconditional).** Before the review-loop block the advisor renders `Readers sweep (before the first review) — …`: the search form for every config key, registry entry, exported constant, receipt field or canon sentence the plan changes, and the classification rule (a ledger row, a stated non-goal, or unchanged with its proof). The command line `run: node <kit>/tools/repo-search.mjs --pattern <the literal>` ALWAYS renders — bare wherever the `--kit-tools` tier could seed that path (the tier's own byte-form, the same predicate), and single-quoted otherwise (an unseedable path has no rule to match); `--pattern-file <f>` only for a pattern carrying a shell-significant byte; when the project's MCP registration is complete (`/agent-workflow-kit mcp`) a `use: repo_search {"pattern": "<the literal>"}` line renders ABOVE it — registration on disk, never a claim the tool is loaded in this session. `--json` carries the SAME lines under **`readersSweep`** (an empty array for the other activities).
|
|
37
37
|
|
|
@@ -37,10 +37,10 @@ A variant's posture note, where its key has one, is printed by `init` from this
|
|
|
37
37
|
|
|
38
38
|
- `gates-inert` — the gate matrix is DECLARED but verifies nothing, and the two causes have different remedies, so the item renders a different apply for each. **Cause A** — a canonical `coverage-check` gate with no producer gate declared BEFORE it (none at all, or one declared after it, which writes the lcov too late): the run certifies no coverage of its own — `coverage=not-run` when nothing wrote an lcov, or a verdict over STALE bytes an earlier run left in the git dir, which is worse because it reads as `coverage=certified`. The remedy needs the producer to run BEFORE the checker — declared or MOVED there. When the checker is the LAST declared gate and the project's own scripts yield an offerable producer, the fill PLACES that producer before it, so the apply is the ordinary `gates-init` dry-run preview. Otherwise — no offerable producer, or a checker that is not last — it is the user item `gates-inert.unfillable`: the user's own step is to edit `docs/ai/gates.json` (the exact producer form lives in `${CLAUDE_SKILL_DIR}/references/modes/gates.md`), because the fill never reorders entries it did not write. When the declaration carries, anywhere, a gate in a form an earlier kit wrote that the upgrade moves (one whose tail holds only test paths), or the fill withheld its `node --test` script because the kit folder does not hold this kit's command and reporter, the apply is `/agent-workflow-kit upgrade` in place of both: it moves an earlier kit's gate with no question, or a line of its report names what stops it. **Cause B** — every declared gate is one of the kit's own canonical checkers, so the matrix runs no project-verification command at all: the apply is the `gates-init` dry-run preview, the same consent-gated seeder the `gates-declaration` item renders, and after the SAME confirmation you run the `--apply` line it prints. Neither cause changes any gate result, exit code or receipt — the item adds no enforcement, only the offer. Risk profile: `docs/ai/gates.json` is a PRIVILEGED file (a declared gate is auto-approvable by the wired hook), so both causes land in the same place — where the fill can help, it declares a project-controlled command on your explicit yes; where it cannot, the edit is the user's own step.
|
|
39
39
|
|
|
40
|
-
- `source-size` — the arms differ by what the declared gate IS. **`adopted-elsewhere`** — the gate runs a DIFFERENT real copy of this checker (a vendored deployment): the practice runs, the advisor cannot resolve it as its own sibling, and the realpath anchor does not widen (that stops a lookalike). So the convergence is the ack writer's preview (`--lane source-size-copy` → `sourceSizeCopyAck`), never `--adopt`, which would mint and then be refused by the fill on the declared id. The fingerprint binds the declared claims AS AUTHORED, sorted, not resolved paths, so a second external copy re-fires it. **`id-squatter`** — a gate carries the `source-size` id and is not this checker under any reading: the gate matrix reads as running the size check while it runs none, so it is the user's own step (rename the id, or repoint the cmd at this `--check`). **`unminted`**, for both copies: a gate refusing every run over an authored
|
|
40
|
+
- `source-size` — the arms differ by what the declared gate IS. **`adopted-elsewhere`** — the gate runs a DIFFERENT real copy of this checker (a vendored deployment): the practice runs, the advisor cannot resolve it as its own sibling, and the realpath anchor does not widen (that stops a lookalike). So the convergence is the ack writer's preview (`--lane source-size-copy` → `sourceSizeCopyAck`), never `--adopt`, which would mint and then be refused by the fill on the declared id. The fingerprint binds the declared claims AS AUTHORED, sorted, not resolved paths, so a second external copy re-fires it. **`id-squatter`** — a gate carries the `source-size` id and is not this checker under any reading: the gate matrix reads as running the size check while it runs none, so it is the user's own step (rename the id, or repoint the cmd at this `--check`). **`unminted`**, for both copies: a gate refusing every run over an authored record (over an absent one the check judges layout alone), attention, and NO acknowledgement silences it; only the verb differs (with the gate declared elsewhere, `--write-baseline`); a line carrying the placeholder takes your own sentence, by the `recipe:` line. **`schema-1`** — the check stops on a minted schema-1 config, so this arm comes first: its `--write-baseline` line carries NO reason (a pinned one would launder a raise; a raise riding the move refuses, and the agent writes that raise's reason from what the run shows, with no question to the user), every run until the move. **`layout`** — on a config with no layout record, the record of the piles already there comes first, as its own item: a no writes nothing and the item returns every run; its `recipe:` line names the branch states, and `source-size.layout` is applied before the `hook-checks` check line runs, whose layout line follows that record. **`piles`** — each recorded pile with no queue row gets one, at the end of the queue's Later bucket; a write the queue's own declared check would refuse is not made and the stated skip says why. Risk profile: `docs/ai/gates.json` is a PRIVILEGED file, so every arm here either records an acknowledgement or hands you an edit — the kit declares nothing on its own.
|
|
41
41
|
- `gate-hook` — the offer wires the hook on the harness lane: the agent applies it on the chat yes after the check; `init` previews and applies it on the terminal yes as the route the user may take instead. Over a wired hook the key renders the kit item `gate-hook.not-current` instead: the placed hook file is absent or differs from the body the kit writes for it. An older body validates your declaration through its OWN baked copy and goes dark on a key it does not know, such as `lcovProducer` (present, whatever its value), so every gate prompts again with no error anywhere. The agent applies the kit item with no question after the check, whose result names the file with its new digest, and the old one too over a differing file; it writes only the hook file. Risk profile: the offer places a hook file and wires one settings entry; the kit item writes one hook file with the kit's body; the declaration is never touched.
|
|
42
42
|
- `enforcement` — copies the bundled runtime files of `references/scripts/` into the kit folder `scripts/agent-workflow/`, then runs the project's own hook installer, which installs the pre-commit hook. The lane is harness: the agent applies the item on the chat yes after the check, whose result shows each script the kit places with its bytes and the installer it runs with its bytes; `init` applies it on the batch terminal yes as the route the user may take instead. The copy is create-only: an existing file stands and nothing is written through a link, and the offer renders only on no Node evidence. The hook invokes `node` directly, so a committer without it on PATH gets a loud failure. The installer refuses to overwrite a pre-commit hook it did not write: an install it refuses removes the scripts this apply copied, and the item is offered again with the installer's output shown; over a pre-commit hook the installer did not write the item is not offered — its skip names the user's own step. Risk profile: local tooling and a Git hook are added on the chat yes after the check, or on init's y.
|
|
43
|
-
- `hook-checks` — the agent applies the item on the chat yes after the check; `init` applies it on the terminal y as the route the user may take instead. Risk profile: future commits stop on the rules check and, where judged, on the size check's findings — lines
|
|
43
|
+
- `hook-checks` — the agent applies the item on the chat yes after the check; `init` applies it on the terminal y as the route the user may take instead. Risk profile: future commits stop on the rules check and, where judged, on the size check's findings — lines and layout; over a clone with no pre-commit hook the installer writes its whole hook, so commits also stop on its docs and archive lines.
|
|
44
44
|
- `attribution` — the agent applies the item on the chat yes after the check, setting one key in the project `.claude/settings.json`; `init` applies it on the terminal y as the route the user may take instead. An existing "includeCoAuthoredBy": false already converges the item unless an "attribution" key sets a commit or PR text; a local-scope override is the user's own edit. Risk profile: one settings key, nothing widened.
|
|
45
45
|
- `footprint-global` — the agent applies the item on the chat yes after the check, which prints each line it removes; `init` applies it on the terminal y as the route the user may take instead. Another of the user's repositories may rely on the same lines: a no keeps the block, and the item returns at the next run. The apply prints the removed lines as a backup. Risk profile: lines removed from the machine-global excludes file.
|
|
46
46
|
- `mcp-channel` — the offer is to REGISTER the kit's read-only stdio MCP server in this project on the harness lane: a registration is a command your MCP client will RUN. The agent applies it on the chat yes after the check; `init` previews the exact entry and applies it on the terminal y as the route the user may take instead. What the registration buys: path questions and literal searches become typed tool calls whose arguments are named JSON fields instead of a string handed to a shell, so a pipe, a redirect or a quote inside a pattern or a path stays DATA and is never interpreted. Posture: the server is a **read-only child of your client** (path/type/size/line facts and literal search over this project root; no write and no exec API), and like the client itself it runs **outside the Bash sandbox** — the sandbox is not what bounds it, the server's own root containment is. The two allow rules it adds make those two tools promptless and nothing else. The **`.differing`** arm is also a harness item: an `agent-workflow` entry already stands in `.mcp.json` and **structurally differs** from what this kit copy would write (another kit copy, a hand-edited path, an added `env`; the comparison ignores key order, so re-serialized identical bytes are the same registration). The check shows the entry standing in `.mcp.json` and the entry it would write; the chat yes confirms the replacement. `init` previews `mcp --replace` and replaces only on the terminal y. Stated limit: this item does **not** detect a `disabledMcpjsonServers` veto, so a converged `mcp-channel` means *what the mode writes is in place*, not *the client will load it* — see `${CLAUDE_SKILL_DIR}/references/modes/mcp.md`. Risk profile: a new read-only channel your client will launch; no write or exec exposure; a differing registration is replaced only on the checked chat yes or the terminal y and every other declaration is kept.
|
package/tools/gates-init.mjs
CHANGED
|
@@ -441,8 +441,8 @@ export const flowCheckCandidate = (cwd, deps = {}) => {
|
|
|
441
441
|
};
|
|
442
442
|
|
|
443
443
|
// The conditional SOURCE-SIZE candidate — keyed on the practice's own declaration rather than on a
|
|
444
|
-
// recipe: the gate is offered ONLY over a MINTED
|
|
445
|
-
//
|
|
444
|
+
// recipe: the gate is offered ONLY over a MINTED docs/ai/source-size.json past schema 1. Over an authored
|
|
445
|
+
// one the checker REFUSES by design, and a declared gate that refuses is a matrix
|
|
446
446
|
// this preview would have reddened on the user's behalf; a minted schema-1 one is withheld naming its
|
|
447
447
|
// --write-baseline move. A project that never declared the practice hears nothing here, while one
|
|
448
448
|
// that authored it and stopped short hears WHY the gate is not offered yet — the mint is the step it
|
|
@@ -468,7 +468,7 @@ export const sourceSizeCandidate = (cwd, deps = {}) => {
|
|
|
468
468
|
// The advice still follows the STATE: over an unminted record a hand-declared gate is red on
|
|
469
469
|
// every run, so pointing there would hand the reader their next failure as the way out.
|
|
470
470
|
const lane = state === 'minted'
|
|
471
|
-
? `${schema1 ? 'move the record
|
|
471
|
+
? `${schema1 ? 'move the record off schema 1 first — run source-size-check.mjs --write-baseline with the working directory set to this project, then ' : ''}declare the gate by hand`
|
|
472
472
|
: `mint the record first — run source-size-check.mjs --adopt --reason "${mintReasonOf(config)}" with the working directory set to this project, then declare the gate by hand`;
|
|
473
473
|
return {
|
|
474
474
|
candidate: null,
|
package/tools/now-render.mjs
CHANGED
|
@@ -133,7 +133,7 @@ const renderCampaignBlock = (block, color) => {
|
|
|
133
133
|
const lines = [getHeading(BLOCK_TITLE.campaign, color), ` state: ${block.state}`];
|
|
134
134
|
if (block.state !== 'absent') {
|
|
135
135
|
lines.push(` caps: ${block.maxLines} lines · ${block.maxLineBytes} bytes per line`);
|
|
136
|
-
lines.push(` roots: ${block.roots} · recorded files: ${getFigure(block.recordedFiles)}
|
|
136
|
+
lines.push(` roots: ${block.roots} · recorded files: ${getFigure(block.recordedFiles)}`);
|
|
137
137
|
}
|
|
138
138
|
return lines;
|
|
139
139
|
};
|
package/tools/procedures.mjs
CHANGED
|
@@ -536,9 +536,8 @@ const flowHalvesAdvice = (flow, probe) => {
|
|
|
536
536
|
// their reason ride EVERY named-activity render, so the plan's Module ledger is cut to them while the
|
|
537
537
|
// plan is being written. Composed from the project's live declaration, never from constants here.
|
|
538
538
|
// Each config state speaks as itself: ABSENT renders NOTHING (a project that declares no practice must
|
|
539
|
-
// not be handed invented limits); AUTHORED
|
|
540
|
-
//
|
|
541
|
-
// whole tree's debt); MINTED renders the recorded counts too.
|
|
539
|
+
// not be handed invented limits); AUTHORED renders the declared caps plus the honest "no file size is
|
|
540
|
+
// recorded yet" line; MINTED renders the recorded count too.
|
|
542
541
|
// A config that cannot be read renders ONE loud line carrying the reader's own message and the render
|
|
543
542
|
// still completes: the exit code for a broken source-size config belongs to the practice's own checker,
|
|
544
543
|
// while THIS tool's exit contract is about its own config and the engine.
|
|
@@ -554,14 +553,9 @@ const declaredPracticeAdvice = (cwd, readFile, lstat) => {
|
|
|
554
553
|
}
|
|
555
554
|
if (declaration.state === 'absent') return [];
|
|
556
555
|
const facts = practiceFacts(declaration.config);
|
|
557
|
-
// The two pre-mint states share a LANE (the ratchet holds nothing, the mint step is next) but not a
|
|
558
|
-
// FACT: an incomplete file carries half the machine record, so "no size is recorded" would be a
|
|
559
|
-
// plain untruth about it — it names the missing half instead. Neither ever prints minted counts.
|
|
560
556
|
// The mint step is named, not rendered: on a project path that does not survive double-quoting the
|
|
561
557
|
// checker deliberately withholds a paste-ready command, and this advisor never re-decides that.
|
|
562
|
-
const unmintedRecord =
|
|
563
|
-
? ` recorded: PARTIAL — the machine record is half-written (missing ${declaration.missingMachineKeys.map((key) => `"${key}"`).join(', ')}), so the ratchet holds nothing yet; run \`source-size-check.mjs --check\` for the mint step.`
|
|
564
|
-
: ' recorded: NOTHING YET — the caps are declared but no size is recorded, so the ratchet holds nothing; run `source-size-check.mjs --check` for the mint step.';
|
|
558
|
+
const unmintedRecord = ' recorded: NO FILE YET — the caps are declared but no file size is recorded, so the ratchet holds no file; run `source-size-check.mjs --check` for the mint step.';
|
|
565
559
|
// The five limits are the check's own lines, from the one function both renders read.
|
|
566
560
|
const { config } = declaration;
|
|
567
561
|
return [
|
|
@@ -571,9 +565,9 @@ const declaredPracticeAdvice = (cwd, readFile, lstat) => {
|
|
|
571
565
|
config.layout !== null
|
|
572
566
|
? ' layout: recorded — entries per directory, depth and files per root are judged by the size check.'
|
|
573
567
|
: ' layout: not recorded — `source-size-check.mjs --write-baseline --layout --reason "<text>"` starts it.',
|
|
574
|
-
...(config.schema === 1 ? [' schema 1: the check stops on it — `source-size-check.mjs --write-baseline` moves it
|
|
568
|
+
...(config.schema === 1 ? [' schema 1: the check stops on it — `source-size-check.mjs --write-baseline` moves it off schema 1.'] : []),
|
|
575
569
|
declaration.state === 'minted'
|
|
576
|
-
? ` recorded: ${facts.recordedFiles} file(s) carry a recorded size (debt, not permission)
|
|
570
|
+
? ` recorded: ${facts.recordedFiles} file(s) carry a recorded size (debt, not permission) — growth past a record takes a reasoned bump, and a record above the tree warns until the regeneration lowers it.`
|
|
577
571
|
: unmintedRecord,
|
|
578
572
|
` why: ${SOURCE_SIZE_WHY}`,
|
|
579
573
|
];
|
|
@@ -133,7 +133,7 @@ const HOOK_CHECKS_UNMANAGED_HOOK = 'an UNMANAGED pre-commit hook exists \u2014 t
|
|
|
133
133
|
const HOOK_CHECKS_WAIT = 'the layout line follows the source-size.layout record \u2014 apply that item first; this item\'s check line then arms the layout line too';
|
|
134
134
|
const HOOK_CHECKS_COMMAND = "the hook runs the kit's checks by flat paths this upgrade removes — once they are gone every commit stops until this item is applied";
|
|
135
135
|
const LAYOUT_RECORD_RECIPE = 'the hook is per clone and the config per branch: a branch or linked worktree with no size config is judged under the kit\'s values and stops on its piles until it takes the record (a hidden deployment\'s linked worktree carries none); one with an older config without layout is not judged on layout; one whose config is schema 1 or unminted stops every commit on that config\'s own stop until it takes the current config';
|
|
136
|
-
const REASON_AUTHOR_RECIPE = 'the reason is yours to write, with no question to the user: where you made the growth, say why this size is accepted; where an entry grew before this write (a
|
|
136
|
+
const REASON_AUTHOR_RECIPE = 'the reason is yours to write, with no question to the user: where you made the growth, say why this size is accepted; where an entry grew before this write (a raise after the schema move, a teammate\'s growth), write that it grew before this write and its cause was not recorded';
|
|
137
137
|
const SOURCE_SIZE_KEPT_WHAT = 'no source-size gate is declared — the size record is kept as it is; declaring the gate adds the size check to the gate matrix';
|
|
138
138
|
const LAYOUT_HELD = {
|
|
139
139
|
stops: () => 'the source-size check stops on this tree, so a layout record or layout line not yet in place waits \u2014 record that growth first with the reasoned --write-baseline its stop names, then re-run',
|
|
@@ -288,7 +288,7 @@ export const WHATS = Object.freeze({
|
|
|
288
288
|
'gates-inert.coverage-domain-narrow': 'certification covers the assessable minority only — {ext} dominate(s) the tracked tree, and the changed-line domain excludes them',
|
|
289
289
|
'source-size': 'no source-size gate is declared — the gate matrix runs no size check, so no gate run stops a file beyond its limits',
|
|
290
290
|
'source-size.unminted': 'the source-size gate is declared over an unminted record ({state}) — the check refuses it, or if absent judges layout alone, no line',
|
|
291
|
-
'source-size.schema-1': 'the source-size config is schema 1, which the check stops on — the writer moves it
|
|
291
|
+
'source-size.schema-1': 'the source-size config is schema 1, which the check stops on — the writer moves it off schema 1 in one write',
|
|
292
292
|
'source-size.layout': 'the layout record is not started — starting it records any directory already beyond the layout limits, so the commit hook can judge layout',
|
|
293
293
|
'source-size.piles': '{n} recorded pile(s) have no queue row planning their cleanup — one row each goes to the end of the queue\'s Later bucket',
|
|
294
294
|
'source-size.adopted-elsewhere': "the source-size gate runs a DIFFERENT copy of this checker ({n} declared) — adopted here, just not through this kit's own tool",
|
|
@@ -920,8 +920,8 @@ const probeSourceSize = ({ root, deps, add, skip, shared }) => {
|
|
|
920
920
|
const canonical = claims.filter((c) => c.claim === CHECKER_CLAIM.CANONICAL);
|
|
921
921
|
const elsewhere = claims.filter((c) => c.claim === CHECKER_CLAIM.ELSEWHERE);
|
|
922
922
|
if (canonical.length > 0 || elsewhere.length > 0) {
|
|
923
|
-
// A DECLARED gate is not the same fact as a working one: the checker refuses an authored
|
|
924
|
-
//
|
|
923
|
+
// A DECLARED gate is not the same fact as a working one: the checker refuses an authored
|
|
924
|
+
// record, so a gate declared over one reds the matrix on every run, and over an
|
|
925
925
|
// absent one it judges layout alone and no line. The declaration alone would report that deployment
|
|
926
926
|
// as adopted and say nothing about the one thing wrong with it. The split changes NOTHING here —
|
|
927
927
|
// the outcome, its attention class and its immunity to every ack are the same whichever copy runs.
|
|
@@ -31,16 +31,17 @@ root outside the kit's own folder ${KIT_FOLDER_ROOT} plus the spec store docs/ai
|
|
|
31
31
|
disk, and the files of each declared root.
|
|
32
32
|
|
|
33
33
|
A recorded entry is DEBT: a finding stops exactly when the regeneration would raise it, and a record
|
|
34
|
-
above the tree or gone warns until the regeneration lowers or removes it.
|
|
35
|
-
|
|
34
|
+
above the tree or gone warns until the regeneration lowers or removes it. No line sum over a root is
|
|
35
|
+
judged or recorded: an "aggregate" an earlier schema recorded warns on every check of a minted config and is dropped,
|
|
36
|
+
with no reason, by the next regeneration.
|
|
36
37
|
|
|
37
|
-
--write-baseline regenerates the machine keys (baseline,
|
|
38
|
-
|
|
38
|
+
--write-baseline regenerates the machine keys (baseline, and layout where it is judged) from the
|
|
39
|
+
tree and writes schema ${SOURCE_SIZE_SCHEMA}, on an absent config too. --layout starts the layout record on a
|
|
39
40
|
present config that has none. The authored keys keep their values and their order; the file is
|
|
40
41
|
canonically serialized. A regeneration that RAISES any recorded value needs --reason; the string is
|
|
41
|
-
recorded in the entry it raised. A pure tighten needs none. A
|
|
42
|
-
the same write
|
|
43
|
-
stops on
|
|
42
|
+
recorded in the entry it raised. A pure tighten needs none. A config of an earlier schema is moved in
|
|
43
|
+
the same write; a minted schema-1 one whose regeneration is refused is moved off schema 1 in a write
|
|
44
|
+
of its own, its records carried as they are; --check stops on schema 1 until it is moved.
|
|
44
45
|
|
|
45
46
|
--adopt is the ONE-line adoption: it mints the record and declares the source-size gate (and NOTHING
|
|
46
47
|
else) in docs/ai/gates.json. It is idempotent on an already-adopted project. With the config absent
|
|
@@ -80,8 +80,9 @@ export const limitLines = (limits, { escape = String, recorded = false } = {}) =
|
|
|
80
80
|
return `limit ${id} ${amount}, tolerance ${tolerance}% — ${source === 'kit' ? 'from kit' : `from override: ${escape(reason)}`}`;
|
|
81
81
|
});
|
|
82
82
|
|
|
83
|
-
// migrateSchema1(parsed, readmes) → the schema-2 config
|
|
84
|
-
// `_README` byte-equal to `readmes.schema1`
|
|
83
|
+
// migrateSchema1(parsed, readmes) → the schema-2 config, every key in its place; the writer writes it as
|
|
84
|
+
// it is only where the moved file holds the line sum. A `_README` byte-equal to `readmes.schema1`
|
|
85
|
+
// becomes `readmes.schema2`; any other is carried verbatim.
|
|
85
86
|
export const migrateSchema1 = (parsed, readmes = {}) => {
|
|
86
87
|
const overrides = Object.fromEntries(Object.entries(SCHEMA1_KEY)
|
|
87
88
|
.filter(([id, key]) => parsed.defaults[key] !== KIT_LIMITS[id].value)
|
|
@@ -94,6 +95,11 @@ export const migrateSchema1 = (parsed, readmes = {}) => {
|
|
|
94
95
|
}));
|
|
95
96
|
};
|
|
96
97
|
|
|
98
|
+
// atSchema(parsed, schema, { earlier, current }) → the config at `schema`, every key in its place: a
|
|
99
|
+
// `_README` byte-equal to one of the `earlier` template texts becomes `current`, any other is carried.
|
|
100
|
+
export const atSchema = (parsed, schema, { earlier = [], current } = {}) => Object.fromEntries(Object.entries(parsed)
|
|
101
|
+
.map(([key, value]) => [key, key === 'schema' ? schema : key === '_README' && earlier.includes(value) ? current : value]));
|
|
102
|
+
|
|
97
103
|
// applyOverride(parsed, id, override) → the config with one id's override set from { value,
|
|
98
104
|
// tolerance, reason } or, given null, removed; a `limits` left empty is dropped and a new one is
|
|
99
105
|
// appended. It judges nothing about the tree: the writer regenerates the record from the result.
|
|
@@ -29,11 +29,11 @@ const HELD_TEXT = {
|
|
|
29
29
|
};
|
|
30
30
|
const held = (reason, ...args) => ({ answer: 'held', reason, text: HELD_TEXT[reason](...args) });
|
|
31
31
|
|
|
32
|
-
// pilesOf(loaded) → [{ key, entries, value }]: each directory of a minted
|
|
32
|
+
// pilesOf(loaded) → [{ key, entries, value }]: each directory of a minted config's layout record whose
|
|
33
33
|
// recorded entries exceed the resolved entries-per-directory value plus its band, in the record's order.
|
|
34
34
|
export const pilesOf = (loaded) => {
|
|
35
35
|
const config = loaded?.state === 'minted' ? loaded.config : null;
|
|
36
|
-
if (config === null || config.schema
|
|
36
|
+
if (config === null || config.schema === 1 || config.layout === null) return [];
|
|
37
37
|
const { value, tolerance } = config.limits['entries-per-directory'];
|
|
38
38
|
return Object.entries(config.layout.directories)
|
|
39
39
|
.filter(([, record]) => Object.hasOwn(record, 'entries') && record.entries > value + bandOf(value, tolerance))
|
|
@@ -86,13 +86,11 @@ const layoutPlan = (recorded, projected) => {
|
|
|
86
86
|
// then two renderings of one computation.
|
|
87
87
|
export const planRecord = ({ config, verdict }) => {
|
|
88
88
|
const oldBaseline = config.baseline ?? {};
|
|
89
|
-
const oldAggregate = config.aggregate ?? {};
|
|
90
89
|
const files = verdict.scope.files.map((rel) => {
|
|
91
90
|
const next = verdict.projected.get(rel);
|
|
92
91
|
const recorded = ownEntry(oldBaseline, rel);
|
|
93
92
|
return { rel, next, recorded, changes: changesFor(rel, next, recorded) };
|
|
94
93
|
});
|
|
95
|
-
const roots = config.roots.map((root) => ({ root, lines: verdict.rootLines.get(root) ?? 0, recorded: ownEntry(oldAggregate, root) }));
|
|
96
94
|
const layout = verdict.layout ? layoutPlan(config.layout, verdict.layout.projected) : null;
|
|
97
95
|
const deltas = [
|
|
98
96
|
...files.flatMap(({ changes }) => changes),
|
|
@@ -101,30 +99,24 @@ export const planRecord = ({ config, verdict }) => {
|
|
|
101
99
|
...Object.entries(oldBaseline)
|
|
102
100
|
.filter(([rel]) => !verdict.measured.has(rel))
|
|
103
101
|
.flatMap(([rel, recorded]) => changesFor(rel, {}, recorded)),
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
.map(({ root, lines, recorded }) => ({ target: root, dimension: 'aggregate lines', from: recorded ? recorded.lines : null, to: lines })),
|
|
107
|
-
...Object.entries(oldAggregate)
|
|
108
|
-
.filter(([root]) => !config.roots.includes(root))
|
|
102
|
+
// A per-root line sum an earlier schema recorded is dropped whole, and the delta says so.
|
|
103
|
+
...Object.entries(config.aggregate ?? {})
|
|
109
104
|
.map(([root, recorded]) => ({ target: root, dimension: 'aggregate lines', from: recorded.lines, to: null })),
|
|
110
105
|
...(layout ? layout.deltas : []),
|
|
111
106
|
];
|
|
112
|
-
return { files,
|
|
107
|
+
return { files, layout, deltas, raises: deltas.filter(isRaise) };
|
|
113
108
|
};
|
|
114
109
|
|
|
115
110
|
const byKey = (entries) => Object.fromEntries(entries.sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0)));
|
|
116
111
|
|
|
117
112
|
// The reason of an entry the regeneration did NOT raise is the one already recorded — a tighten
|
|
118
113
|
// rewrites a number, never the human sentence that justified it.
|
|
119
|
-
export const materialize = ({ files,
|
|
114
|
+
export const materialize = ({ files, layout }, reason) => ({
|
|
120
115
|
baseline: Object.fromEntries(
|
|
121
116
|
files
|
|
122
117
|
.filter(({ next }) => Object.keys(next).length > 0)
|
|
123
118
|
.map(({ rel, next, recorded, changes }) => [rel, { ...next, reason: changes.some(isRaise) ? reason : recorded.reason }]),
|
|
124
119
|
),
|
|
125
|
-
aggregate: Object.fromEntries(
|
|
126
|
-
roots.map(({ root, lines, recorded }) => [root, { lines, reason: !recorded || lines > recorded.lines ? reason : recorded.reason }]),
|
|
127
|
-
),
|
|
128
120
|
...(layout === null ? {} : {
|
|
129
121
|
layout: {
|
|
130
122
|
roots: byKey(layout.roots.map(({ root, next, recorded }) => [root, { files: next, reason: !recorded || next > recorded.files ? reason : recorded.reason }])),
|
|
@@ -136,7 +128,8 @@ export const materialize = ({ files, roots, layout }, reason) => ({
|
|
|
136
128
|
// The file is CANONICALLY serialized: the authored VALUES and the ORDER the human wrote them in are
|
|
137
129
|
// preserved exactly, their formatting is not — this file is machine-maintained and the writer owns
|
|
138
130
|
// half of it, so one deterministic rendering is what makes "regenerate an unchanged tree and get the
|
|
139
|
-
// same bytes" true at all. The machine keys follow in their fixed order
|
|
131
|
+
// same bytes" true at all. The machine keys follow in their fixed order; `aggregate` is dropped
|
|
132
|
+
// with them and written back only by the schema-1 move, which carries it.
|
|
140
133
|
export const serialize = (parsed, machine) => {
|
|
141
134
|
const authored = Object.fromEntries(Object.entries(parsed).filter(([key]) => !MACHINE_KEYS.includes(key)));
|
|
142
135
|
return `${JSON.stringify({ ...authored, ...machine }, null, 2)}\n`;
|
|
@@ -10,12 +10,12 @@ import { SPEC_STORE_ROOT } from './layout.mjs';
|
|
|
10
10
|
export const SETUP_ANSWERS = Object.freeze(['armable', 'record', 'held']);
|
|
11
11
|
|
|
12
12
|
// checkTargetOf({ loaded, absentConfig }) → exactly one of: the schema-1 stop, the unminted stop (a
|
|
13
|
-
// present config
|
|
13
|
+
// present config with no file record), or the config to judge with the dimensions judged.
|
|
14
14
|
export const checkTargetOf = ({ loaded, absentConfig }) => {
|
|
15
15
|
const absent = loaded.state === 'absent';
|
|
16
16
|
const config = absent ? absentConfig : loaded.config;
|
|
17
17
|
if (config.schema === 1) return { stop: 'schema-1', config };
|
|
18
|
-
if (!absent && loaded.state !== 'minted') return { stop: 'unminted', config, state: loaded.state
|
|
18
|
+
if (!absent && loaded.state !== 'minted') return { stop: 'unminted', config, state: loaded.state };
|
|
19
19
|
return { stop: null, config, judged: { absent, layout: absent || config.layout !== null } };
|
|
20
20
|
};
|
|
21
21
|
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
// source-size-config.mjs — the practice's declaration: what docs/ai/source-size.json may say, which
|
|
2
|
-
// of its
|
|
2
|
+
// of its three states it is in, and how it is read back. Nothing here touches the tree.
|
|
3
3
|
//
|
|
4
|
-
// • CONFIG STATES — ABSENT (no entry at the path) / AUTHORED (
|
|
5
|
-
//
|
|
6
|
-
// lane) / MINTED (both machine keys). A malformed or unknown-keyed config is a loud STOP
|
|
4
|
+
// • CONFIG STATES — ABSENT (no entry at the path) / AUTHORED (no `baseline`) / MINTED (`baseline`
|
|
5
|
+
// present). A malformed or unknown-keyed config is a loud STOP
|
|
7
6
|
// (exit 2), never a guess, and the template placeholders are REFUSED until replaced, so a
|
|
8
7
|
// printed authoring template can never be pasted into an empty-green scope.
|
|
9
8
|
// • A RECORDED size is debt, not permission: every entry carries a reason, and the reason lands
|
|
10
9
|
// verbatim in the JSON, the commit message and the release CHANGELOG — so it is validated as the
|
|
11
10
|
// single line those three surfaces can carry.
|
|
12
|
-
// • SCHEMAS —
|
|
13
|
-
// holds the scope, the record and a project's reasoned overrides.
|
|
14
|
-
//
|
|
11
|
+
// • SCHEMAS — 3 is the shape: the kit's limits live in its code (tools/source-size/), the config
|
|
12
|
+
// holds the scope, the record and a project's reasoned overrides. 2 is read as 3, the per-root
|
|
13
|
+
// line sum it recorded (`aggregate`) judged by nothing and dropped by the next regeneration. 1 is
|
|
14
|
+
// still read strictly and resolved in memory by the very transform the writer moves it with; a
|
|
15
|
+
// read writes nothing.
|
|
15
16
|
//
|
|
16
17
|
// Dependency-free, Node >= 22. No side effects on import.
|
|
17
18
|
|
|
@@ -20,7 +21,8 @@ import { isAbsolute } from 'node:path';
|
|
|
20
21
|
import { SOURCE_SIZE_CONFIG_REL, configFail, configPathFor, isLineUnsafe } from './source-size-refusal.mjs';
|
|
21
22
|
import { KIT_LIMITS, SPEC_STORE_ROOT, layoutDefect, limitsDefect, migrateSchema1, resolveLimits } from './source-size/index.mjs';
|
|
22
23
|
|
|
23
|
-
export const SOURCE_SIZE_SCHEMA =
|
|
24
|
+
export const SOURCE_SIZE_SCHEMA = 3;
|
|
25
|
+
const READ_SCHEMAS = Object.freeze([1, 2, SOURCE_SIZE_SCHEMA]);
|
|
24
26
|
export const SOURCE_SIZE_DEFAULTS = Object.freeze({
|
|
25
27
|
maxLines: KIT_LIMITS['lines-per-file'].value,
|
|
26
28
|
maxLineBytes: KIT_LIMITS['bytes-per-line'].value,
|
|
@@ -34,8 +36,11 @@ export const KIT_FOLDER_ROOT = 'scripts/agent-workflow';
|
|
|
34
36
|
|
|
35
37
|
export const AUTHORED_KEYS = Object.freeze(['_README', 'schema', 'roots', 'exclude', 'extensions', 'limits']);
|
|
36
38
|
const SCHEMA1_AUTHORED_KEYS = Object.freeze(['_README', 'schema', 'defaults', 'roots', 'exclude', 'extensions']);
|
|
37
|
-
|
|
38
|
-
|
|
39
|
+
// The machine key that decides the state: MINTED means it is present.
|
|
40
|
+
export const MACHINE_KEYS = Object.freeze(['baseline']);
|
|
41
|
+
// The per-root line sum schemas 1 and 2 recorded: a known key, read and judged by nothing.
|
|
42
|
+
export const RETIRED_SUM_KEY = 'aggregate';
|
|
43
|
+
// The layout record is a machine key of its own, and no part of the state.
|
|
39
44
|
export const LAYOUT_KEY = 'layout';
|
|
40
45
|
const ENTRY_KEYS = Object.freeze(['lines', 'maxLineBytes', 'reason']);
|
|
41
46
|
|
|
@@ -93,16 +98,13 @@ export const segmentPrefixOf = (prefix, path) => prefix === WHOLE_TREE_ROOT || p
|
|
|
93
98
|
// practiceFacts(config) → the numbers every surface that SPEAKS for the practice states: the caps,
|
|
94
99
|
// how much is declared, and how much is recorded. Derived in ONE place so the plan-time render and
|
|
95
100
|
// the checker's own green line can never state two different counts of the same tree.
|
|
96
|
-
// `recordedFiles`
|
|
97
|
-
//
|
|
101
|
+
// `recordedFiles` is null while `baseline` is absent — "not recorded at all" is a different fact
|
|
102
|
+
// from "recorded as zero", and the two states read differently to a human.
|
|
98
103
|
export const practiceFacts = (config) => ({
|
|
99
104
|
maxLines: config.defaults.maxLines,
|
|
100
105
|
maxLineBytes: config.defaults.maxLineBytes,
|
|
101
106
|
roots: config.roots.length,
|
|
102
107
|
recordedFiles: config.baseline === null ? null : Object.keys(config.baseline).length,
|
|
103
|
-
aggregateLines: config.aggregate === null
|
|
104
|
-
? null
|
|
105
|
-
: Object.values(config.aggregate).reduce((sum, entry) => sum + entry.lines, 0),
|
|
106
108
|
});
|
|
107
109
|
|
|
108
110
|
// `requiredDimensions: 'any'` — a per-file record may pin EITHER dimension or both, because only the
|
|
@@ -161,16 +163,16 @@ const validateSchema1 = (parsed) => {
|
|
|
161
163
|
// The keys each schema may carry. A key of the other schema is a stop named as such: a `defaults` on
|
|
162
164
|
// schema 2 would be a second home for a kit value, and a `limits` on schema 1 a shape no writer made.
|
|
163
165
|
const keysDefect = (parsed) => {
|
|
164
|
-
if (parsed.schema
|
|
166
|
+
if (parsed.schema !== 1 && Object.hasOwn(parsed, 'defaults')) {
|
|
165
167
|
return '"defaults" is a schema-1 key — the kit\'s limits live in the kit\'s code, and a project states its own number as a reasoned override under "limits"';
|
|
166
168
|
}
|
|
167
169
|
if (parsed.schema === 1 && Object.hasOwn(parsed, 'limits')) {
|
|
168
|
-
return '"limits" is
|
|
170
|
+
return '"limits" is no schema-1 key — a schema-1 config states its numbers under "defaults"; --write-baseline moves it off schema 1';
|
|
169
171
|
}
|
|
170
172
|
if (parsed.schema === 1 && Object.hasOwn(parsed, LAYOUT_KEY)) {
|
|
171
|
-
return '"layout" is
|
|
173
|
+
return '"layout" is no schema-1 key — a schema-1 config records no layout; --write-baseline moves it off schema 1';
|
|
172
174
|
}
|
|
173
|
-
const known = new Set([...(parsed.schema === 1 ? SCHEMA1_AUTHORED_KEYS : [...AUTHORED_KEYS, LAYOUT_KEY]), ...MACHINE_KEYS]);
|
|
175
|
+
const known = new Set([...(parsed.schema === 1 ? SCHEMA1_AUTHORED_KEYS : [...AUTHORED_KEYS, LAYOUT_KEY]), ...MACHINE_KEYS, RETIRED_SUM_KEY]);
|
|
174
176
|
const unknown = Object.keys(parsed).filter((k) => !known.has(k));
|
|
175
177
|
return unknown.length === 0 ? null : `${SOURCE_SIZE_CONFIG_REL} carries unknown key(s): ${unknown.join(', ')} — known keys are ${[...known].join(', ')}`;
|
|
176
178
|
};
|
|
@@ -179,8 +181,8 @@ const keysDefect = (parsed) => {
|
|
|
179
181
|
// cannot judge — an unknown key included, because a typo'd key would otherwise disarm a rule.
|
|
180
182
|
export const validateSourceSizeConfig = (parsed) => {
|
|
181
183
|
if (!isPlainObject(parsed)) throw configFail(`${SOURCE_SIZE_CONFIG_REL} must contain a JSON object`);
|
|
182
|
-
if (
|
|
183
|
-
throw configFail(`"schema" must be
|
|
184
|
+
if (!READ_SCHEMAS.includes(parsed.schema)) {
|
|
185
|
+
throw configFail(`"schema" must be one of ${READ_SCHEMAS.join(', ')}, got ${JSON.stringify(parsed.schema)}`);
|
|
184
186
|
}
|
|
185
187
|
const keys = keysDefect(parsed);
|
|
186
188
|
if (keys) throw configFail(keys);
|
|
@@ -210,7 +212,7 @@ export const validateSourceSizeConfig = (parsed) => {
|
|
|
210
212
|
for (const outer of roots) {
|
|
211
213
|
for (const inner of roots) {
|
|
212
214
|
if (outer !== inner && segmentPrefixOf(outer, inner)) {
|
|
213
|
-
throw configFail(`"roots" entries overlap: "${inner}" sits inside "${outer}" — an overlapping root
|
|
215
|
+
throw configFail(`"roots" entries overlap: "${inner}" sits inside "${outer}" — an overlapping root counts its files twice in the layout record`);
|
|
214
216
|
}
|
|
215
217
|
}
|
|
216
218
|
}
|
|
@@ -262,11 +264,9 @@ export const validateSourceSizeConfig = (parsed) => {
|
|
|
262
264
|
};
|
|
263
265
|
};
|
|
264
266
|
|
|
265
|
-
// loadSourceSizeConfig(cwd) → { state, path, config, parsed, text
|
|
266
|
-
//
|
|
267
|
-
//
|
|
268
|
-
// carries a fully validated config, INCOMPLETE included: the key that IS there is judged by the same
|
|
269
|
-
// rules as ever. `parsed` and `text` are the file as written — the writer copies the authored VALUES
|
|
267
|
+
// loadSourceSizeConfig(cwd) → { state, path, config, parsed, text }. The states: ABSENT (no file) /
|
|
268
|
+
// AUTHORED (no `baseline`) / MINTED (`baseline` present). `config` is null only in the ABSENT state;
|
|
269
|
+
// every other state carries a fully validated config. `parsed` and `text` are the file as written — the writer copies the authored VALUES
|
|
270
270
|
// (and their order) from `parsed`, and compares its own bytes against `text` to know whether it
|
|
271
271
|
// actually changed anything.
|
|
272
272
|
export const loadSourceSizeConfig = (cwd, deps = {}) => {
|
|
@@ -296,18 +296,6 @@ export const loadSourceSizeConfig = (cwd, deps = {}) => {
|
|
|
296
296
|
throw configFail(`${path} is not valid JSON (${err.message}) — fix it by hand; a malformed config is a STOP, never a guess`);
|
|
297
297
|
}
|
|
298
298
|
const config = validateSourceSizeConfig(parsed);
|
|
299
|
-
const
|
|
300
|
-
|
|
301
|
-
// state no regenerator produces — it was hand-edited into it — so it is INCOMPLETE and routes to
|
|
302
|
-
// the mint lane, which writes both. Refusing it as a config error would deadlock the only
|
|
303
|
-
// self-service lane, because the regenerator reads its config through this very function.
|
|
304
|
-
const state = present.length === MACHINE_KEYS.length ? 'minted' : present.length === 0 ? 'authored' : 'incomplete';
|
|
305
|
-
return {
|
|
306
|
-
state,
|
|
307
|
-
path,
|
|
308
|
-
config,
|
|
309
|
-
parsed,
|
|
310
|
-
text: raw,
|
|
311
|
-
missingMachineKeys: MACHINE_KEYS.filter((key) => !present.includes(key)),
|
|
312
|
-
};
|
|
299
|
+
const state = MACHINE_KEYS.every((key) => Object.hasOwn(parsed, key)) ? 'minted' : 'authored';
|
|
300
|
+
return { state, path, config, parsed, text: raw };
|
|
313
301
|
};
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
//
|
|
6
6
|
// The halves, each holding ONE rule set and each within the cap this practice declares:
|
|
7
7
|
// • source-size-refusal.mjs — the two exit classes, and the absolute config path every refusal names
|
|
8
|
-
// • source-size-config.mjs — the config file: its grammar, its
|
|
8
|
+
// • source-size-config.mjs — the config file: its grammar, its three states, its reader
|
|
9
9
|
// • source-size-scope.mjs — which files are judged (D-6) and how big each one is (D-7)
|
|
10
10
|
// • source-size-gate-cmd.mjs — whether a declared gate cmd IS this checker (the canonical matcher),
|
|
11
11
|
// and which of the three tool claims it makes when it is not
|
|
@@ -64,6 +64,7 @@ export {
|
|
|
64
64
|
SCHEMA1_REASON,
|
|
65
65
|
SPEC_STORE_ROOT,
|
|
66
66
|
applyOverride,
|
|
67
|
+
atSchema,
|
|
67
68
|
bandOf,
|
|
68
69
|
changesFor,
|
|
69
70
|
isRaise,
|
|
@@ -115,7 +116,7 @@ export { CHECKER_CLAIM } from './checker-claim.mjs';
|
|
|
115
116
|
|
|
116
117
|
// readLayoutSetup(root, deps) → the layout setup's answer for a project, the one bound form the advisor
|
|
117
118
|
// and the git-hooks leaf ask: the loader, the tree judge and its stop filter, the absent config the
|
|
118
|
-
// check judges (schema
|
|
119
|
+
// check judges (the current schema under the kit's values) and the reason the record's first entries take.
|
|
119
120
|
export const readLayoutSetup = (root, deps = {}) => layoutSetupOf(root, {
|
|
120
121
|
loadSourceSizeConfig,
|
|
121
122
|
judgeTree,
|
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
// The ratchet (D-3, D-4): a recorded size is DEBT, not permission. Each limit is judged with its
|
|
7
7
|
// band; a finding STOPS exactly when the regeneration would RAISE (beyond the band with no record, a
|
|
8
8
|
// record that grew, an unrecorded root) and WARNS otherwise (within the band, a record above the
|
|
9
|
-
// tree, no longer needed or gone).
|
|
9
|
+
// tree, no longer needed or gone). No per-root line sum is judged: one an earlier schema recorded
|
|
10
|
+
// warns until the regeneration drops it.
|
|
10
11
|
//
|
|
11
12
|
// Dependency-free, Node >= 22. No writes, no side effects on import.
|
|
12
13
|
|
|
@@ -49,8 +50,9 @@ export const standingWarningsOf = (findings) => findings.flatMap((f) => {
|
|
|
49
50
|
return kind && f.dimension !== 'depth' && f.actual > f.allowed && f.actual <= f.ceiling ? [{ ...f, kind }] : [];
|
|
50
51
|
});
|
|
51
52
|
export const hasLoweredRecord = (findings) => findings.some((f) => LOWERED_KINDS.has(f.kind));
|
|
52
|
-
//
|
|
53
|
-
|
|
53
|
+
// Records nothing judges any more, the spec store's files count and an earlier schema's per-root line sum: no decomposition, so no focus line.
|
|
54
|
+
const DROPPED_KINDS = new Set(['store-record', 'sum-record']);
|
|
55
|
+
export const hasDroppedRecord = (findings) => findings.some((f) => DROPPED_KINDS.has(f.kind));
|
|
54
56
|
|
|
55
57
|
// One rule for every recorded number: a raise stops, any other change warns. `kinds` names no record
|
|
56
58
|
// yet, grew, lowered and no longer needed in the target's own vocabulary.
|
|
@@ -72,22 +74,6 @@ const fileFindings = (rel, measured, projected, recorded, limits) => {
|
|
|
72
74
|
];
|
|
73
75
|
};
|
|
74
76
|
|
|
75
|
-
const judgeAggregate = (rootLines, aggregate) => {
|
|
76
|
-
const findings = [];
|
|
77
|
-
for (const [root, actual] of rootLines) {
|
|
78
|
-
const recorded = ownEntry(aggregate, root)?.lines;
|
|
79
|
-
if (recorded === undefined) findings.push({ kind: 'aggregate-unrecorded', severity: STOP, root, actual });
|
|
80
|
-
else if (actual > recorded) findings.push({ kind: 'aggregate-grew', severity: STOP, root, actual, recorded });
|
|
81
|
-
else if (actual < recorded) findings.push({ kind: 'aggregate-stale', severity: WARNING, root, actual, recorded });
|
|
82
|
-
}
|
|
83
|
-
// The recorded set must MIRROR the declared roots: a budget nobody declares any more warns until
|
|
84
|
-
// the writer drops it, and deleting an entry must never be a way to disarm it.
|
|
85
|
-
for (const root of Object.keys(aggregate)) {
|
|
86
|
-
if (!rootLines.has(root)) findings.push({ kind: 'aggregate-root-gone', severity: WARNING, root, recorded: aggregate[root].lines });
|
|
87
|
-
}
|
|
88
|
-
return findings;
|
|
89
|
-
};
|
|
90
|
-
|
|
91
77
|
// A directory is keyed by its repo-relative path, a root's own by its declared name. A name that is
|
|
92
78
|
// not lossless UTF-8 is counted, and refused only once a record would have to carry it.
|
|
93
79
|
const measureLayout = (cwd, config, scope, deps) => {
|
|
@@ -136,7 +122,7 @@ const directoryFindings = (directories, projected, recorded, limits) => {
|
|
|
136
122
|
}
|
|
137
123
|
for (const [dir, facts] of directories) {
|
|
138
124
|
const was = ownEntry(recorded, dir);
|
|
139
|
-
const changes = changesFor(dir, projected
|
|
125
|
+
const changes = changesFor(dir, ownEntry(projected, dir) ?? {}, was, LAYOUT_DIMENSIONS);
|
|
140
126
|
const actual = { entries: facts.entries, depth: facts.reach };
|
|
141
127
|
findings.push(...changes.map((change) => changeFinding({ dir }, change, actual[change.dimension], limits, DIR_KINDS)));
|
|
142
128
|
const entries = limits['entries-per-directory'];
|
|
@@ -162,9 +148,9 @@ const judgeLayout = (cwd, config, scope, deps, { absent }) => {
|
|
|
162
148
|
return { measured, projected, findings };
|
|
163
149
|
};
|
|
164
150
|
|
|
165
|
-
// judgeTree(cwd, config, deps, { layout, absent }) → { scope, measured, projected,
|
|
166
|
-
//
|
|
167
|
-
//
|
|
151
|
+
// judgeTree(cwd, config, deps, { layout, absent }) → { scope, measured, projected, layout, findings }.
|
|
152
|
+
// EVERY in-scope file is measured, recorded or not: an unreadable or non-UTF-8 file refuses even
|
|
153
|
+
// when its size is recorded debt.
|
|
168
154
|
export const judgeTree = (cwd, config, deps = {}, { layout = false, absent = false } = {}) => {
|
|
169
155
|
const scope = resolveScope(cwd, config, deps);
|
|
170
156
|
const bytes = new Map();
|
|
@@ -175,14 +161,11 @@ export const judgeTree = (cwd, config, deps = {}, { layout = false, absent = fal
|
|
|
175
161
|
for (const rel of Object.keys(baseline)) {
|
|
176
162
|
if (!measured.has(rel)) findings.push({ kind: 'entry-gone', severity: WARNING, rel, recorded: baseline[rel] });
|
|
177
163
|
}
|
|
178
|
-
|
|
179
|
-
[...scope.perRoot].map(([root, files]) => [root, files.reduce((sum, rel) => sum + measured.get(rel).lines, 0)]),
|
|
180
|
-
);
|
|
181
|
-
if (!absent) findings.push(...judgeAggregate(rootLines, config.aggregate ?? {}));
|
|
164
|
+
if (config.aggregate !== null) findings.push({ kind: 'sum-record', severity: WARNING, roots: Object.keys(config.aggregate).length, schema: config.schema });
|
|
182
165
|
const judged = layout ? judgeLayout(cwd, config, scope, deps, { absent }) : null;
|
|
183
166
|
if (judged) findings.push(...judged.findings);
|
|
184
167
|
const tree = workTreeOf(cwd, config, { scope, bytes, layout }, deps);
|
|
185
168
|
findings.push(...Object.entries(WORK_TREE_KINDS).filter(([part]) => tree[part].length > 0)
|
|
186
169
|
.map(([part, kind]) => ({ kind, severity: WARNING, paths: tree[part] })));
|
|
187
|
-
return { scope, measured, projected,
|
|
170
|
+
return { scope, measured, projected, layout: judged, findings };
|
|
188
171
|
};
|
|
@@ -25,7 +25,7 @@ export const SOURCE_SIZE_CONFIG_REL = 'docs/ai/source-size.json';
|
|
|
25
25
|
|
|
26
26
|
// Quoted VERBATIM by every surface that explains the practice: the plan-time render, the checker's
|
|
27
27
|
// rendered refusals, the constraints row a grounded review payload carries. The checker's GREEN line
|
|
28
|
-
// states the practice's FACTS instead — caps, recorded count
|
|
28
|
+
// states the practice's FACTS instead — caps, recorded count — and never this sentence.
|
|
29
29
|
export const SOURCE_SIZE_WHY = 'A module you can hold whole is the unit of review, test pairing and safe edit; the caps turn size drift into recorded, reasoned debt instead of invisible growth.';
|
|
30
30
|
|
|
31
31
|
// Every warning the check prints is one line under this anchored prefix, so the gate runner can echo
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
import { SOURCE_SIZE_CONFIG_REL, SOURCE_SIZE_WARNING_PREFIX, SOURCE_SIZE_WHY, configPathFor, escapeForLine, isLineUnsafe, jsonForLine } from './source-size-refusal.mjs';
|
|
19
19
|
import { KIT_FOLDER_ROOT, SOURCE_SIZE_SCHEMA, practiceFacts } from './source-size-config.mjs';
|
|
20
20
|
import { SOURCE_SIZE_TOOL_PATH, dqUnsafePath } from './source-size-gate-cmd.mjs';
|
|
21
|
-
import {
|
|
21
|
+
import { hasDroppedRecord, hasLoweredRecord, stopsOf, warningsOf } from './source-size-judge.mjs';
|
|
22
22
|
import { GROWTH_REASON_PLACEHOLDER, INITIAL_ADOPTION_REASON, helpText, isRaise, limitLines, mintReasonOf } from './source-size/index.mjs';
|
|
23
23
|
|
|
24
24
|
export { GROWTH_REASON_PLACEHOLDER };
|
|
@@ -28,11 +28,13 @@ export { GROWTH_REASON_PLACEHOLDER };
|
|
|
28
28
|
// filesystem path the writer opens.
|
|
29
29
|
const namedConfig = (cwd) => escapeForLine(configPathFor(cwd));
|
|
30
30
|
|
|
31
|
-
// The `_README` the kit's schema-1
|
|
32
|
-
// to
|
|
31
|
+
// The `_README` texts the kit's schema-1 and schema-2 templates carried, frozen: a write replaces a
|
|
32
|
+
// `_README` byte-equal to one of them with the text of the schema it writes and carries any other verbatim.
|
|
33
33
|
export const SCHEMA1_TEMPLATE_README = 'Source-size practice: declared scope + thresholds + the recorded ratchet. Authored keys: schema, defaults, roots, exclude, extensions. Machine keys: baseline, aggregate — each recorded entry carries a reason, and a recorded size is debt, not permission. Strict JSON — unknown keys refused.';
|
|
34
|
-
export const
|
|
35
|
-
export const
|
|
34
|
+
export const SCHEMA2_TEMPLATE_README = 'Source-size practice: declared scope + the recorded ratchet; the limits are the kit\'s, kept in its code. Authored keys: schema, roots, exclude, extensions, limits (a project\'s reasoned overrides of a kit limit). Machine keys: baseline, aggregate, layout — each recorded entry carries a reason, and a recorded size is debt, not permission. Strict JSON — unknown keys refused.';
|
|
35
|
+
export const TEMPLATE_README = 'Source-size practice: declared scope + the recorded ratchet; the limits are the kit\'s, kept in its code. Authored keys: schema, roots, exclude, extensions, limits (a project\'s reasoned overrides of a kit limit). Machine keys: baseline, layout — each recorded entry carries a reason, and a recorded size is debt, not permission. Strict JSON — unknown keys refused.';
|
|
36
|
+
export const TEMPLATE_READMES = Object.freeze({ schema1: SCHEMA1_TEMPLATE_README, schema2: SCHEMA2_TEMPLATE_README });
|
|
37
|
+
export const EARLIER_TEMPLATE_READMES = Object.freeze([SCHEMA1_TEMPLATE_README, SCHEMA2_TEMPLATE_README]);
|
|
36
38
|
|
|
37
39
|
// The authoring template (D-5): GENERIC, and INERT by construction — its roots/extensions carry
|
|
38
40
|
// placeholders the validator refuses, so it can never be pasted into an empty-green scope.
|
|
@@ -104,7 +106,7 @@ const refusal = (lines) => [...lines, WHY_LINE];
|
|
|
104
106
|
// absent one records nothing to summarize.
|
|
105
107
|
const practiceLine = (config) => {
|
|
106
108
|
const facts = practiceFacts(config);
|
|
107
|
-
return `source-size: practice — caps ${facts.maxLines} lines · ${facts.maxLineBytes} bytes per line over ${facts.roots} declared root(s) · ${facts.recordedFiles} file(s) carry a recorded size (debt, not permission)
|
|
109
|
+
return `source-size: practice — caps ${facts.maxLines} lines · ${facts.maxLineBytes} bytes per line over ${facts.roots} declared root(s) · ${facts.recordedFiles} file(s) carry a recorded size (debt, not permission): growth past a record takes a reasoned bump, and a record above the tree or gone warns until the regeneration lowers or removes it.`;
|
|
108
110
|
};
|
|
109
111
|
|
|
110
112
|
export const absentRefusalLines = (cwd) => refusal([
|
|
@@ -114,30 +116,26 @@ export const absentRefusalLines = (cwd) => refusal([
|
|
|
114
116
|
authoringTemplate(),
|
|
115
117
|
]);
|
|
116
118
|
|
|
117
|
-
//
|
|
118
|
-
|
|
119
|
-
// machine half no regenerator produces, which means the file was hand-edited into it.
|
|
120
|
-
const unmintedSentence = (cwd, { state, missing }) => state === 'incomplete'
|
|
121
|
-
? `${namedConfig(cwd)} is INCOMPLETE: it carries a machine half no regenerator produces (missing ${missing.map((key) => `"${key}"`).join(', ')}), so the ratchet holds only part of this tree.`
|
|
122
|
-
: `${namedConfig(cwd)} is AUTHORED but not yet MINTED (it records no size yet), so there is nothing for the ratchet to hold.`;
|
|
119
|
+
// The one not-yet-MINTED state: no `baseline`, whatever else the file holds.
|
|
120
|
+
const unmintedSentence = (cwd) => `${namedConfig(cwd)} is AUTHORED but not yet MINTED (it holds no "baseline", the per-file record), so the ratchet holds no file of this tree.`;
|
|
123
121
|
const MINT_LINE = 'Mint it — the regenerator records what this tree already carries; recording a value for the first time is a raise, so it takes a reason';
|
|
124
122
|
const unmintedLane = (reason) => `Run source-size-check.mjs --write-baseline --reason "${reason}" with the working directory set to this project.`;
|
|
125
123
|
|
|
126
|
-
export const unmintedRefusalLines = (cwd, {
|
|
124
|
+
export const unmintedRefusalLines = (cwd, { config }) => {
|
|
127
125
|
const reason = mintReasonOf(config);
|
|
128
126
|
const { command, withheld } = regenerator(cwd, reason);
|
|
129
127
|
return refusal([
|
|
130
|
-
`source-size: REFUSED — ${unmintedSentence(cwd
|
|
128
|
+
`source-size: REFUSED — ${unmintedSentence(cwd)}`,
|
|
131
129
|
`${MINT_LINE}:`,
|
|
132
130
|
command === null ? `${withheld} ${unmintedLane(reason)}` : ` ${command}`,
|
|
133
131
|
]);
|
|
134
132
|
};
|
|
135
133
|
|
|
136
|
-
export const unmintedStopBlock = (cwd, {
|
|
134
|
+
export const unmintedStopBlock = (cwd, { config }) => {
|
|
137
135
|
const reason = mintReasonOf(config);
|
|
138
136
|
const { command, withheld } = regenerator(cwd, reason);
|
|
139
137
|
return {
|
|
140
|
-
failed: escapeLeadingSpace(unmintedSentence(cwd
|
|
138
|
+
failed: escapeLeadingSpace(unmintedSentence(cwd).slice(0, -1)),
|
|
141
139
|
findings: [{ place: SOURCE_SIZE_CONFIG_REL, text: MINT_LINE }],
|
|
142
140
|
remedies: [command ?? unmintedLane(reason)],
|
|
143
141
|
after: refusal(command === null ? [withheld] : []),
|
|
@@ -157,6 +155,8 @@ const lineSafeFinding = (finding) => ({
|
|
|
157
155
|
...(finding.dir === undefined ? {} : { dir: escapeForLine(finding.dir) }),
|
|
158
156
|
});
|
|
159
157
|
|
|
158
|
+
// Said before a write that moves the schema, in the deployed sum's warning, and after it, in the move line.
|
|
159
|
+
const PREDATING_KIT_STOPS = (schema) => `a kit that predates schema ${schema} stops by name until that copy is upgraded`;
|
|
160
160
|
const BAND = (f) => `over the limit ${f.allowed} but within its band (up to ${f.ceiling})`;
|
|
161
161
|
const NAMED_PATHS = 3;
|
|
162
162
|
const namedPaths = (paths) => `${paths.slice(0, NAMED_PATHS).map(escapeForLine).join(', ')}${paths.length > NAMED_PATHS ? ` and ${paths.length - NAMED_PATHS} more` : ''}`;
|
|
@@ -165,8 +165,6 @@ const namedPaths = (paths) => `${paths.slice(0, NAMED_PATHS).map(escapeForLine).
|
|
|
165
165
|
const FINDING_LINE = Object.freeze({
|
|
166
166
|
'over-default': (f) => `${f.rel}: ${f.dimension} ${f.actual} exceeds the declared default ${f.allowed} beyond its band (up to ${f.ceiling})`,
|
|
167
167
|
grew: (f) => `${f.rel}: ${f.dimension} ${f.actual} exceeds its recorded baseline ${f.recorded} — recorded debt is not permission to grow`,
|
|
168
|
-
'aggregate-grew': (f) => `${f.root}: aggregate lines ${f.actual} exceeds the recorded budget ${f.recorded} — splitting a file buys no aggregate headroom`,
|
|
169
|
-
'aggregate-unrecorded': (f) => `${f.root}: declared root carries NO recorded aggregate budget (${f.actual} lines measured) — the record must mirror the declared roots exactly`,
|
|
170
168
|
'root-unrecorded': (f) => `${f.root}: declared root carries NO recorded files count (${f.actual} files measured) — the layout record must mirror the declared roots exactly`,
|
|
171
169
|
'root-grew': (f) => `${f.root}: files ${f.actual} exceeds its recorded ${f.recorded} beyond its band (up to ${f.ceiling})`,
|
|
172
170
|
'dir-over': (f) => `${f.dir}: ${f.dimension} ${f.actual} exceeds the limit ${f.allowed} beyond its band (up to ${f.ceiling})`,
|
|
@@ -179,8 +177,7 @@ const WARNING_LINE = Object.freeze({
|
|
|
179
177
|
stale: (f) => `${f.rel}: ${f.dimension} ${f.actual} is under the recorded ${f.recorded} — the regeneration lowers it`,
|
|
180
178
|
'record-obsolete': (f) => `${f.rel}: ${f.dimension} ${f.actual} is within its band (up to ${f.ceiling}), so its record is obsolete — the regeneration removes it`,
|
|
181
179
|
'entry-gone': (f) => `${f.rel}: recorded in "baseline" but no longer in scope — split, renamed or deleted; the regeneration removes it`,
|
|
182
|
-
'
|
|
183
|
-
'aggregate-root-gone': (f) => `${f.root}: recorded in "aggregate" but no longer a declared root — the regeneration removes it`,
|
|
180
|
+
'sum-record': (f) => `"aggregate" records a line sum for ${f.roots} root(s), which the check no longer judges or records — the regeneration removes it${f.schema === SOURCE_SIZE_SCHEMA ? '' : ` and writes schema ${SOURCE_SIZE_SCHEMA}, on which ${PREDATING_KIT_STOPS(SOURCE_SIZE_SCHEMA)}`}`,
|
|
184
181
|
'root-band': (f) => `${f.root}: files ${f.actual} is over its recorded ${f.recorded} but within its band (up to ${f.ceiling}) — past ${f.ceiling} it stops`,
|
|
185
182
|
'root-stale': (f) => `${f.root}: files ${f.actual} is under the recorded ${f.recorded} — the regeneration lowers it`,
|
|
186
183
|
'root-gone': (f) => `${f.root}: recorded in "layout"."roots" but no longer a declared root — the regeneration removes it`,
|
|
@@ -243,7 +240,7 @@ export const checkStopBlock = ({ cwd, verdict, absent = false }) => {
|
|
|
243
240
|
// A lowered or removed record warns with the paste-ready regeneration, which needs no reason.
|
|
244
241
|
const tightenLine = (cwd) => {
|
|
245
242
|
const { command, withheld } = regenerator(cwd);
|
|
246
|
-
return `${SOURCE_SIZE_WARNING_PREFIX}a record above is lower or
|
|
243
|
+
return `${SOURCE_SIZE_WARNING_PREFIX}a record above is lower, gone or no longer judged, so regenerating lowers or removes it with no reason: ${command ?? `${withheld} ${WITHHELD_LANE}`}`;
|
|
247
244
|
};
|
|
248
245
|
|
|
249
246
|
// A passing check keeps its notes, warnings and green line in that order.
|
|
@@ -252,7 +249,7 @@ export const checkReportLines = ({ cwd, config, verdict, absent = false }) => {
|
|
|
252
249
|
const warnings = warningsOf(verdict.findings);
|
|
253
250
|
lines.push(...warningLines(warnings));
|
|
254
251
|
const lowered = hasLoweredRecord(warnings);
|
|
255
|
-
if (lowered ||
|
|
252
|
+
if (lowered || hasDroppedRecord(warnings)) lines.push(tightenLine(cwd));
|
|
256
253
|
if (lowered) lines.push(SPLIT_QUALITY_FOCUS);
|
|
257
254
|
lines.push(warnings.length === 0
|
|
258
255
|
? `source-size: PASS — ${verdict.scope.files.length} in-scope file(s) within the declared caps`
|
|
@@ -289,15 +286,15 @@ export const schema1StopBlock = (cwd) => {
|
|
|
289
286
|
const { command, withheld } = regenerator(cwd);
|
|
290
287
|
return {
|
|
291
288
|
failed: escapeLeadingSpace(`${namedConfig(cwd)} is schema 1, which the check no longer judges`),
|
|
292
|
-
findings: [{ place: SOURCE_SIZE_CONFIG_REL, text: '--write-baseline moves it
|
|
289
|
+
findings: [{ place: SOURCE_SIZE_CONFIG_REL, text: '--write-baseline moves it off schema 1 (a raise riding it still takes --reason)' }],
|
|
293
290
|
remedies: [command ?? 'Run source-size-check.mjs --write-baseline with the working directory set to this project.'],
|
|
294
291
|
after: refusal(command === null ? [withheld] : []),
|
|
295
292
|
};
|
|
296
293
|
};
|
|
297
294
|
|
|
298
295
|
// Claims only what holds of every written file.
|
|
299
|
-
export const
|
|
300
|
-
`source-size: ${namedConfig(cwd)} moved from schema
|
|
296
|
+
export const schemaMovedLines = (cwd, from, to) => [
|
|
297
|
+
`source-size: ${namedConfig(cwd)} ${from === null ? 'written at' : `moved from schema ${from} to`} schema ${to} in this write; ${PREDATING_KIT_STOPS(to)}.`,
|
|
301
298
|
];
|
|
302
299
|
|
|
303
300
|
// The record must hold before an override is written, so its reason never lands on drift it did not
|
|
@@ -370,11 +367,11 @@ export const gateRefusedLines = (rel, message) => refusal([
|
|
|
370
367
|
]);
|
|
371
368
|
|
|
372
369
|
// `changed` is decided by comparing the serialized bytes with the file's own — never by the delta
|
|
373
|
-
// count alone:
|
|
370
|
+
// count alone: a schema move or a re-serialization changes the file while raising nothing, and
|
|
374
371
|
// reporting that as "unchanged" would hide a write that happened.
|
|
375
372
|
export const writtenLines = ({ cwd, deltas, reason, changed }) => {
|
|
376
373
|
if (!changed) return [`source-size: baseline unchanged — ${namedConfig(cwd)} already records this tree`];
|
|
377
|
-
if (deltas.length === 0) return [`source-size: baseline rewritten — no recorded value changed; ${namedConfig(cwd)} was
|
|
374
|
+
if (deltas.length === 0) return [`source-size: baseline rewritten — no recorded value changed; ${namedConfig(cwd)} was re-serialized`];
|
|
378
375
|
return [
|
|
379
376
|
`source-size: baseline regenerated — ${deltas.length} change(s) in ${namedConfig(cwd)}:`,
|
|
380
377
|
...deltaLines(deltas),
|
|
@@ -6,8 +6,7 @@
|
|
|
6
6
|
// What --check judges: every in-scope file against the resolved limits with their bands, layout
|
|
7
7
|
// where it is recorded or the config is absent, and every RECORDED size against the ratchet — a
|
|
8
8
|
// record may not grow, and one above the tree or gone warns until the regeneration lowers or removes
|
|
9
|
-
// it.
|
|
10
|
-
// file into six buys no headroom. An absent config is judged under the kit's values.
|
|
9
|
+
// it. No per-root line sum is judged or recorded. An absent config is judged under the kit's values.
|
|
11
10
|
//
|
|
12
11
|
// What --write-baseline does: regenerates the machine keys from the tree, and ONLY the machine keys.
|
|
13
12
|
// The authored half is copied through with its VALUES and their ORDER preserved exactly; the file
|
|
@@ -20,12 +19,12 @@
|
|
|
20
19
|
// What --adopt does: mints the record and declares the gate — the whole adoption as ONE consented
|
|
21
20
|
// line, because the alternative is a two-step ceremony whose halves can be left half-done. It
|
|
22
21
|
// composes the two writers it already has (this module's mint, the fill's consented apply restricted
|
|
23
|
-
// to this one id) and owns no write of its own, but for the
|
|
24
|
-
// carries
|
|
22
|
+
// to this one id) and owns no write of its own, but for the verbatim move of a minted schema-1 config,
|
|
23
|
+
// which carries the file record, and the line sum where the file holds one.
|
|
25
24
|
//
|
|
26
25
|
// What --override does: once a regeneration under the current limits would raise nothing, writes or
|
|
27
26
|
// removes one reasoned override of a kit limit and regenerates the machine keys under the new limits
|
|
28
|
-
// in the same write. Every write here moves a schema-1 config
|
|
27
|
+
// in the same write. Every write here moves a schema-1 config off schema 1; --check stops on one.
|
|
29
28
|
//
|
|
30
29
|
//
|
|
31
30
|
// Dependency-free, Node >= 22. No side effects on import.
|
|
@@ -39,6 +38,7 @@ import {
|
|
|
39
38
|
SOURCE_SIZE_SCHEMA,
|
|
40
39
|
applyOverride,
|
|
41
40
|
assertNoStoreRoot,
|
|
41
|
+
atSchema,
|
|
42
42
|
checkTargetOf,
|
|
43
43
|
isRaise,
|
|
44
44
|
loadSourceSizeConfig,
|
|
@@ -55,6 +55,7 @@ import { bandWarningsOf, judgeTree, standingWarningsOf, stopsOf } from './source
|
|
|
55
55
|
import { GATES_REL, loadDeclaration } from './gates-declaration.mjs';
|
|
56
56
|
import { applyFill } from './gates-init.mjs';
|
|
57
57
|
import {
|
|
58
|
+
EARLIER_TEMPLATE_READMES,
|
|
58
59
|
TEMPLATE_README,
|
|
59
60
|
TEMPLATE_READMES,
|
|
60
61
|
absentRefusalLines,
|
|
@@ -70,7 +71,7 @@ import {
|
|
|
70
71
|
reasonRequiredLines,
|
|
71
72
|
recordNoLongerHoldsLines,
|
|
72
73
|
recordRecognizedLines,
|
|
73
|
-
|
|
74
|
+
schema1StopBlock, schemaMovedLines,
|
|
74
75
|
unmintedRefusalLines, unmintedStopBlock,
|
|
75
76
|
warningLines,
|
|
76
77
|
writtenLines,
|
|
@@ -83,7 +84,7 @@ export const usageFail = (message) => Object.assign(new Error(`${ERROR_PREFIX}${
|
|
|
83
84
|
const RECORD_NOUN = 'the source-size record';
|
|
84
85
|
const LAYOUT_GROWTH_LEAD = 'source-size: --layout REFUSED — it starts the layout record and raises nothing else, but the record no longer holds for this tree, so that growth takes --write-baseline --reason first; no record was regenerated.';
|
|
85
86
|
|
|
86
|
-
// What an absent config is judged as: schema
|
|
87
|
+
// What an absent config is judged as: the current schema under the kit's values, layout over "." and the store.
|
|
87
88
|
const ABSENT = Object.freeze({ _README: TEMPLATE_README, schema: SOURCE_SIZE_SCHEMA });
|
|
88
89
|
|
|
89
90
|
// Every run returns the config it resolved, so the CLI states the limits that run judged, and the
|
|
@@ -92,7 +93,7 @@ export const runCheck = ({ cwd, deps = {} }) => {
|
|
|
92
93
|
const target = checkTargetOf({ loaded: loadSourceSizeConfig(cwd, deps), absentConfig: validateSourceSizeConfig(ABSENT) });
|
|
93
94
|
const { config, judged } = target;
|
|
94
95
|
if (target.stop === 'schema-1') return { code: 1, block: schema1StopBlock(cwd), config };
|
|
95
|
-
if (target.stop === 'unminted') return { code: 1, block: unmintedStopBlock(cwd, {
|
|
96
|
+
if (target.stop === 'unminted') return { code: 1, block: unmintedStopBlock(cwd, { config }), config };
|
|
96
97
|
const verdict = judgeTree(cwd, config, deps, judged);
|
|
97
98
|
const report = { cwd, config, verdict, absent: judged.absent };
|
|
98
99
|
return stopsOf(verdict.findings).length > 0 ? { code: 1, block: checkStopBlock(report), config, judged, scope: verdict.scope }
|
|
@@ -102,11 +103,14 @@ export const runCheck = ({ cwd, deps = {} }) => {
|
|
|
102
103
|
// ── the writer ────────────────────────────────────────────────────────────────────────────────────
|
|
103
104
|
|
|
104
105
|
// A schema-1 config is moved by the one transform, the kit's old template `_README` replaced by the
|
|
105
|
-
//
|
|
106
|
+
// schema-2 one; every write of this module goes through it, so no writer ever writes schema 1 back.
|
|
106
107
|
const schema2Of = (parsed) => (parsed.schema === 1 ? migrateSchema1(parsed, TEMPLATE_READMES) : parsed);
|
|
107
108
|
|
|
108
|
-
// What a
|
|
109
|
-
const
|
|
109
|
+
// What a regeneration writes: the current schema, an earlier template `_README` replaced by today's.
|
|
110
|
+
const currentOf = (parsed) => atSchema(schema2Of(parsed), SOURCE_SIZE_SCHEMA, { earlier: EARLIER_TEMPLATE_READMES, current: TEMPLATE_README });
|
|
111
|
+
|
|
112
|
+
// What a write says of the schema it left, read off the file as loaded (null where none was) and the schema written.
|
|
113
|
+
const movedLines = (cwd, from, to = SOURCE_SIZE_SCHEMA) => (from === to ? [] : schemaMovedLines(cwd, from, to));
|
|
110
114
|
|
|
111
115
|
const writeRecord = (cwd, body, deps) =>
|
|
112
116
|
writeDocsAiFileAtomic(cwd, SOURCE_SIZE_CONFIG_REL, body, deps, { stop: scopeFail, noun: RECORD_NOUN });
|
|
@@ -147,13 +151,13 @@ export const runWriteBaseline = ({ cwd, reason, layout = false, deps = {} }) =>
|
|
|
147
151
|
const moved = minted && config.schema === 1 ? moveMinted(cwd, parsed, deps) : [];
|
|
148
152
|
return { code: 1, lines: [...bandWarnings, ...moved, ...refused], config, judged, scope };
|
|
149
153
|
}
|
|
150
|
-
const body = serialize(
|
|
151
|
-
// Whether anything was written is decided by the BYTES, not by the delta count:
|
|
152
|
-
//
|
|
154
|
+
const body = serialize(currentOf(parsed), materialize(plan, reason));
|
|
155
|
+
// Whether anything was written is decided by the BYTES, not by the delta count: a schema move
|
|
156
|
+
// changes the file while raising nothing at all.
|
|
153
157
|
const changed = body !== loaded.text;
|
|
154
158
|
if (changed) writeRecord(cwd, body, deps);
|
|
155
159
|
const written = writtenLines({ cwd, deltas: plan.deltas, reason: plan.raises.length > 0 ? reason : undefined, changed });
|
|
156
|
-
return { code: 0, lines: [...warnings, ...movedLines(cwd, parsed), ...written], config, judged, scope };
|
|
160
|
+
return { code: 0, lines: [...warnings, ...movedLines(cwd, absent ? null : parsed.schema), ...written], config, judged, scope };
|
|
157
161
|
};
|
|
158
162
|
|
|
159
163
|
// --override: the projection under the CURRENT limits comes first, so an override's reason never
|
|
@@ -161,9 +165,9 @@ export const runWriteBaseline = ({ cwd, reason, layout = false, deps = {} }) =>
|
|
|
161
165
|
// under the new limits, in the same atomic write.
|
|
162
166
|
export const runOverride = ({ cwd, id, value, tolerance, kitDefault, reason, deps = {} }) => {
|
|
163
167
|
assertDocsAiDeployment(cwd, deps, { stop: scopeFail, rel: SOURCE_SIZE_CONFIG_REL, noun: RECORD_NOUN });
|
|
164
|
-
const { state, config, parsed, text
|
|
168
|
+
const { state, config, parsed, text } = loadSourceSizeConfig(cwd, deps);
|
|
165
169
|
if (state === 'absent') return { code: 1, lines: absentRefusalLines(cwd) };
|
|
166
|
-
if (state !== 'minted') return { code: 1, lines: unmintedRefusalLines(cwd, {
|
|
170
|
+
if (state !== 'minted') return { code: 1, lines: unmintedRefusalLines(cwd, { config }), config };
|
|
167
171
|
const judged = { absent: false, layout: config.layout !== null };
|
|
168
172
|
const current = judgeForWrite(cwd, config, deps, judged);
|
|
169
173
|
const scope = current.verdict.scope;
|
|
@@ -174,7 +178,7 @@ export const runOverride = ({ cwd, id, value, tolerance, kitDefault, reason, dep
|
|
|
174
178
|
if (filled !== null && filled.tolerance === kit.tolerance && (kit.value === null || filled.value === kit.value)) {
|
|
175
179
|
throw usageFail(`--override ${id} equals the kit's own numbers — pass --kit-default to return to them; the writer never writes an override equal to the kit's`);
|
|
176
180
|
}
|
|
177
|
-
const next = applyOverride(
|
|
181
|
+
const next = applyOverride(currentOf(parsed), id, filled);
|
|
178
182
|
const nextConfig = validateSourceSizeConfig(next);
|
|
179
183
|
const { plan, warnings } = judgeForWrite(cwd, nextConfig, deps, judged);
|
|
180
184
|
const body = serialize(next, materialize(plan, reason));
|
|
@@ -187,7 +191,7 @@ export const runOverride = ({ cwd, id, value, tolerance, kitDefault, reason, dep
|
|
|
187
191
|
lines: [
|
|
188
192
|
...warnings,
|
|
189
193
|
...overrideWrittenLines({ cwd, id, removed: kitDefault, reason }),
|
|
190
|
-
...movedLines(cwd, parsed),
|
|
194
|
+
...movedLines(cwd, parsed.schema),
|
|
191
195
|
...(plan.deltas.length === 0 ? [] : writtenLines({ cwd, deltas: plan.deltas, reason: plan.raises.length > 0 ? reason : undefined, changed: true })),
|
|
192
196
|
],
|
|
193
197
|
config: nextConfig,
|
|
@@ -248,12 +252,15 @@ const recognizeRecord = ({ cwd, deps }) => {
|
|
|
248
252
|
return { code: 0, lines: recordRecognizedLines(cwd) };
|
|
249
253
|
};
|
|
250
254
|
|
|
251
|
-
// A MINTED schema-1 config is moved in its own write before adoption reads it
|
|
252
|
-
// authored half transformed,
|
|
253
|
-
// adoption reason can never ride a raise.
|
|
255
|
+
// A MINTED schema-1 config is moved in its own write before adoption reads it: the
|
|
256
|
+
// authored half transformed, the file record and the line sum carried verbatim, nothing regenerated —
|
|
257
|
+
// so the adoption reason can never ride a raise. It writes schema 2, the last schema that holds the
|
|
258
|
+
// sum, exactly where the file holds one, and the current schema where it holds none; an authored one is
|
|
259
|
+
// moved by the mint itself.
|
|
254
260
|
const moveMinted = (cwd, parsed, deps) => {
|
|
255
|
-
|
|
256
|
-
|
|
261
|
+
const carriesSum = Object.hasOwn(parsed, 'aggregate');
|
|
262
|
+
writeRecord(cwd, serialize(carriesSum ? schema2Of(parsed) : currentOf(parsed), { baseline: parsed.baseline, ...(carriesSum ? { aggregate: parsed.aggregate } : {}) }), deps);
|
|
263
|
+
return movedLines(cwd, parsed.schema, carriesSum ? 2 : SOURCE_SIZE_SCHEMA);
|
|
257
264
|
};
|
|
258
265
|
|
|
259
266
|
// A stop after the move still prints the move: the write happened, and no stop may hide it.
|