@techgoblin/gobstack 0.6.1 → 0.7.3

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 CHANGED
@@ -5,6 +5,18 @@ version recorded in a target's `.goblin/installed.json` and the source `VERSION`
5
5
 
6
6
  ## Unreleased (v3 core: a default row set + a library)
7
7
 
8
+ - **`AG-01`: an instruction file changes only with a recorded approval.** `AGENTS.md` — the file
9
+ the gates are read from, editable by the very worker the gate polices — is now hash-pinned to
10
+ `.gob/agents.approved` (append-only: date · sha256 · approver · one-line reason, latest row
11
+ wins). New command `gob approve-agents "<reason>"` (`--approver` defaults to the repo's git
12
+ `user.name`, then `$USER`), shipped in `.gob/bin/goblin-approve` and routed through the npm
13
+ shim. `goblin-verify --only AG-01` passes when the hash matches, FAILs naming the file, both
14
+ hashes and the fix command when it does not, and SKIPs (exit 3 under `--only AG-01` alone)
15
+ when no record exists — an existing install never turns red by upgrading. `gob init --write`
16
+ writes the first record, so a fresh install is green on day one; a re-run never re-approves.
17
+ Only the hash is coverage: a record row carries no file name, so a reason naming another file
18
+ clears nothing (the control pins it). What the row cannot see — a forged record, an unread
19
+ diff, a record rewritten alongside the file — is docs/LIMITS.md #60.
8
20
  - **The default verifier is the ~19-row core; the rest lives in a library.** `verify` now runs a
9
21
  row set that is right for every repo — `IN-01..04`, `HP-01/02/03/05`, `GT-01/02/03`,
10
22
  `FM-01/02`, `SC-01`, `SK-01..04`, `BN-00`, plus the 8 `applies_when`-gated bans. The other 32
@@ -42,6 +54,120 @@ version recorded in a target's `.goblin/installed.json` and the source `VERSION`
42
54
  promotes them into catalogue.tsv by PR or edit. `--write` honours only the proposal's TICKED
43
55
  rows, through `gob extras install` itself — one allowlist, one code path.
44
56
 
57
+ ## 0.7.3 (categories: the anti-slop filter is inventoried)
58
+
59
+ - **`manifest/categories.tsv` gains a fourth external pack: `anti-slop`.** MIT, v3.2.33,
60
+ `github.com/miqdadbadjuber/anti-slop` — six `SKILL.md` packs (a 40-rule filter in three tiers
61
+ behind a delivery gate, plus ui / copywriting / human / layoutmobile / code-comment) that catch
62
+ the generic-output failure modes mechanical checks do not: fabricated proof, decorative status,
63
+ comments that restate the line, uniform rhythm in copy. Its `fits_when` requires a target that
64
+ ships a web surface or user-facing copy, so a repo with neither records `declined` with a
65
+ reason. Data only — no executable line reads the file; the agent adjudicates the row at init and
66
+ writes `compose-decisions.tsv`. Not vendored: a project installs the upstream skill files itself
67
+ under the SK-01..04 lane every external pack uses, and a skipped pack stays visible as a
68
+ decision rather than quietly missing.
69
+
70
+ ## 0.7.2 (installer: a re-install keeps every line the project declared)
71
+
72
+ The carry in 0.7.1 was a LIST of seven names (`CARRY_KEYS`). Every other key the render drew
73
+ from a hardcoded literal was overwritten with the template default on a plain re-install, and
74
+ every key the render did not emit at all was silently deleted — comment lines included.
75
+ Measured on a fixture (kit 0.7.1, declare, then re-install with no flags): `ratchet.ceiling:
76
+ 1105500` -> `0`; `gate_tsc_build_cmd: npx tsc --noEmit && npx vite build` -> line gone; three
77
+ `#` comment lines -> gone (same fixture against this build: all three kept, second consecutive
78
+ re-install byte-identical). Measured on `~/projects/tech-goblin/lab/diagram-studio`'s restored
79
+ AGENTS.md adopted into a fixture: `ratchet.ceiling: 1105500`, `gate_tsc_build_cmd`,
80
+ `perf.baseline_commit: 0bde816`, `perf.baseline_value: 831522`, `security.build_output:
81
+ dist/assets` and its 301-line ratchet comment block all kept through a re-install (`rc=0`);
82
+ the only change to the block is the three keys this template emits that the old block lacked,
83
+ appended at the end.
84
+
85
+ Two measured fixes round out the same carry: the `--opt-out` re-record stripped no brackets
86
+ (`${cur#[]}` is an empty glob class), so a fresh install with `--opt-out mcp` rendered the
87
+ malformed `disabled: [[mcp],mcp]` on 0.7.1 AND on this build — now the opt-out seeds from the
88
+ previous value with brackets stripped, appends its part once, dedupes and sorts: `[mcp]` stays
89
+ `[mcp]` across re-installs, `--opt-out skills` on top gives `[mcp,skills]`, and an empty set
90
+ renders `disabled: []`.
91
+
92
+ The carry is no longer a list: the previous block is read as LINES and
93
+ every line the new render did not reproduce under the same key is kept — a pair's previous
94
+ value replaces the rendered one, a pair the render does not emit is re-inserted, a comment
95
+ survives verbatim in its old relative position. Two rules sit above the merge: a flag is a
96
+ decision (`--gate`, `--archive`, `--opt-out` keep the rendered value), and a value the project
97
+ deliberately blanked stays blank. The practice pin's own contract is unchanged and sits above
98
+ the merge — an `--upgrade` never re-pins the standard by itself, even when `--practice` names a
99
+ file; `--re-pin` remains the deliberate path. Fresh installs render exactly as before. No row
100
+ changes: 26 enforcement + 32 library stays.
101
+
102
+ ## 0.7.1 (installer: a re-install keeps the block's declared values)
103
+
104
+ Two fixes that landed after 0.7.0 was tagged, both about `goblin-install` erasing a value the
105
+ repo had declared. No row changes: 58 target rows, the same measured baseline.
106
+
107
+ ### Fixed
108
+
109
+ - **A re-install no longer blanks a declared key.** The block is rendered from the template on every
110
+ install and written wholesale, and the render call draws a set of keys from hardcoded literals
111
+ (`feature_map`, `verify_doctor`, `reference_manifest`, `quarantine_root`, `source_root`, `max_dirty`,
112
+ `bans_exempt` — `CARRY_KEYS`, the whole enumeration) — so a plain `goblin-install` (no `--upgrade`)
113
+ erased every declared value and the gate reading it fell back to SKIP: `FM-01`/`FM-02`, `VA-01`,
114
+ `RC-01`, `CM-03` and the `bans_exempt:` route were all rows a re-install could switch off by
115
+ deleting their subject. The installer now carries each previous value forward through the
116
+ round-trip reader (`g_agents_pairs`, so a value containing ": " or a raw tab survives), and the
117
+ carry replaces the rendered line rather than appending a duplicate. A value the project blanked
118
+ stays blank — the carry never resurrects one — and a key whose literal default is real
119
+ (`source_root: .`, `max_dirty: 0`) re-renders that default, exactly as a fresh install does.
120
+ `tests/t-install-feature-map-carry.sh` plants every key, re-installs twice, asserts the block is
121
+ byte-identical, diffs a fresh install against the pre-change renderer, and carries the negative
122
+ control (4 in -> 0 out with the carry switched off; on the previous engine the same plants measure
123
+ 0/6 and 4 in -> 1 out).
124
+
125
+ ## 0.7.0 (curation: framework-agnostic)
126
+
127
+ Rows removed is a breaking change: a repo upgrading from 0.6.x loses six rows (see Removed) and
128
+ four rows stop passing vacuously (see Fixed). Measured default green after this change:
129
+ `19 passed, 0 failed, 0 advisory, 7 skipped` on a fresh install of every shape (Godot, Python,
130
+ docs-only) — was `20 passed, 0 failed, 0 advisory, 11 skipped`.
131
+
132
+ ### Removed
133
+
134
+ - **`BN-06`..`BN-09` (Electron renderer isolation).** The four bans state Electron mechanics
135
+ (`nodeIntegration`, `contextIsolation`+`sandbox`, `webPreferences`, `sendSync`+`@electron/remote`)
136
+ that no repo in the fleet has. They were gated on a `dep:electron` predicate so other shapes
137
+ skipped them, but the statement itself is framework-bound; the rule text moves to the audit doc
138
+ for the project that needs it. Their `bans.tsv` rows went with them (`BN-00` recount: 4 bans).
139
+ - **`HV-02` (browser bounding box guard).** A `getBoundingClientRect` probe run through a Node
140
+ child process — the web-automation surface of one project. On every other shape it graded the
141
+ kit's own `checks/*.mjs` scaffold and passed by measuring nothing.
142
+ - **`SC-09` (auth consistency across sibling routes).** "Sibling routes" is web routing; the row
143
+ was advisory prose with no check at all.
144
+
145
+ ### Fixed
146
+
147
+ - **`SC-03` no longer passes without inspecting.** Zero JS-family source files and no declared
148
+ build output used to print `PASS 0 client-visible secret-shaped name(s); no build output to
149
+ scan for clause 2`; it now SKIPs with that reason. PASS requires at least one examined artifact.
150
+ - **`SC-04` no longer passes without inspecting.** Zero cookie writes examined now SKIPs
151
+ (`no cookie write found in N examined file(s)`) instead of `PASS 0 cookie write(s) checked`;
152
+ a non-JS repo's `set_cookie` is a named skip, not a green.
153
+ - **`SC-05` no longer passes on an undeclared or unmatched route surface.** Undeclared
154
+ `security.write_routes` now SKIPs (`there is no route surface to check`); a declared surface
155
+ matching zero handlers now SKIPs naming the declaration and the 0 matches, instead of
156
+ `PASS 0 write handler(s), 0 waived`.
157
+ - **`HS-02` counts what it actually replayed.** Zero replayed harnesses now SKIPs
158
+ (`no harness in <dir> matched the replay set`) instead of `PASS every harness was RED at <sha>`;
159
+ the PASS names the count, the commit and the extension set, and files outside the replay set
160
+ are listed as `not replayed:` rather than silently ungraded.
161
+ - **`HV-01` no longer false-REDs a non-JS harness file.** A harness directory whose only files are
162
+ not JS-family now SKIPs (`the text probe reads import/require syntax it cannot see in other
163
+ languages`) instead of accusing the file.
164
+ - **Nine rows now name their ecosystem and prove their skip.** `BN-01`/`BN-02`/`BN-03`/`BN-05`,
165
+ `HV-01`, `SC-02`, `SC-06`, `RC-02`, `RC-04` carry an `ecosystem:` token in the artifact cell,
166
+ and a fixture of another shape must get SKIP(3) with a reason — never a PASS graded on nothing
167
+ (controls in tests/t-verify-red.sh).
168
+
169
+ Method, class counts and the empirical baseline: docs/AUDIT-2026-11-25-framework-agnostic.md.
170
+
45
171
  ## 0.6.1
46
172
 
47
173
  A crash fix in the front door. `gob init --write` with a flag and no value hung forever, printing nothing: the
package/README.md CHANGED
@@ -82,20 +82,20 @@ After installing, in this order:
82
82
  cd <target> && git add -A && git commit # the install is a change like any other
83
83
  .gob/bin/goblin-verify # or gob verify, anywhere in the target
84
84
 
85
- **A default install verifies green — `20 passed, 0 failed, 0 advisory,
86
- 10 skipped`, exit 0 — once `HANDOFF.md` names a commit that exists. Before that edit the
87
- scaffold's `0000000` placeholder is the one expected red.** Ten rows skip: `SK-01`, `SK-02` and
85
+ **A default install verifies green — `19 passed, 0 failed, 0 advisory,
86
+ 7 skipped`, exit 0 — once `HANDOFF.md` names a commit that exists. Before that edit the
87
+ scaffold's `0000000` placeholder is the one expected red.** Seven rows skip: `AG-01` has no
88
+ approval record yet (a plain install writes none; `gob approve-agents "<reason>"` records the
89
+ first, and `gob init --write` writes it for you); `SK-01`, `SK-02` and
88
90
  `SK-04` **run** (the core procedure tier is vendored under `.gob/skills/` on every install);
89
91
  `BN-01`/`BN-02`/`BN-03`/`BN-05` match only `.ts`/`.tsx`/`.js`/`.jsx` and have no such source, so
90
- each reports itself *not applicable*; the four electron bans `BN-06`–`BN-09` are selected by the
91
- `dep:electron` predicate, so with no `package.json` they too report *not applicable* — never
92
- running vacuously off the harness's own `.mjs`/`.json`;
93
- and `FM-01`/`FM-02` have no feature map yet. **Thirty-two further rows are OFF by default** —
92
+ each reports itself *not applicable*;
93
+ and `FM-01`/`FM-02` have no feature map yet. **Thirty-four further rows are OFF by default** —
94
94
  they are not skipped, they are held in the **library** (`gob verify --library`), the discovery
95
95
  surface for the extend mechanism: the spec/round rows (`SP-01`..`SP-03`), the ratchet rows
96
96
  (`GT-04`/`GT-05`), the replay rows (`HS-01`..`HS-03`), commit hygiene (`CM-02`/`CM-03`),
97
97
  the PR-gate rows (`PG-01`..`PG-03`), the runtime-data rows (`DS-01`/`DS-02`), the doc rows
98
- (`DOC-01`/`DOC-02`), the security rows (`SC-02`..`SC-06`, `SC-09`), the perf baseline (`PF-01`),
98
+ (`DOC-01`/`DOC-02`), the security rows (`SC-02`..`SC-06`), the perf baseline (`PF-01`),
99
99
  the reference corpus (`RC-01`..`RC-04`), the archive switch (`CL-02`), the portability row
100
100
  (`PT-01`) and the doctor row (`VA-01`). A default run states the library count in its summary, so
101
101
  a green run is never the whole story. Full inventory: `gob verify --library`. Turn one on by
@@ -116,8 +116,9 @@ and prints the usage.
116
116
  | command | what it does |
117
117
  |---|---|
118
118
  | `gob init` | the first step: print the AGENT BRIEF + proposal schema; `--heuristic` appends scanned hints as a fallback; `--write <proposal> [--yes]` validates the proposal and installs; `--target <dir>` aims elsewhere; `--dry-run` validates without writing |
119
- | `gob verify` | run the rule matrix against the current repo — `PASS`/`FAIL`/`SKIP` per row, exit 0 pass · 1 a check failed · 2 could not run · 3 the manifest is broken |
119
+ | `gob verify` | run the rule matrix against the current repo — `PASS`/`FAIL`/`SKIP` per row, exit 0 pass · 1 a check failed · 2 could not run · 3 the manifest is broken (or `--only AG-01` with no approval record: not policed yet, not red) |
120
120
  | `gob bans` | run the ban list (per-pattern red lines over the source tree) |
121
+ | `gob approve-agents "<reason>"` | record who approved the current `AGENTS.md` (row `AG-01`): appends date · sha256 · approver · reason to `.gob/agents.approved`; the row goes red when the file changes with no approval |
121
122
  | `gob mcp` | serve the harness to your coding agent over MCP stdio — three tools (`gob_verify`, `gob_map_status`, `gob_init_status`), local only, no SDK, no network |
122
123
  | `gob uninstall` | remove everything an install wrote, byte-exactly (the same job as `goblin-install --target <dir> --uninstall` from the checkout/install tree) |
123
124
 
@@ -195,14 +196,15 @@ flows; `manifest/glossary.tsv` for the vocabulary.
195
196
  gob verify [--only <id[,id...]>] [--json] [--list] [--source <path>]
196
197
 
197
198
  Exit codes: `0` pass · `1` a check failed · `2` could not
198
- run · `3` the manifest is broken. Every run prints what it cannot see.
199
+ run · `3` the manifest is broken (`--only AG-01` with no approval record is also 3: not policed
200
+ yet, not red). Every run prints what it cannot see.
199
201
 
200
202
  ## Develop
201
203
 
202
204
  bash tests/run-tests.sh
203
205
 
204
206
  Runs the source-scope rules (PR-01..PR-04) and the test scripts, including `t-verify-red.sh` —
205
- one control per target-scope row (125 over 62 target rows), each required to go RED and then
207
+ one control per target-scope row (149 over 60 target rows), each required to go RED and then
206
208
  restored. **A verifier that only ever prints GREEN is a failure**, so that file is the one that
207
209
  matters most.
208
210
 
@@ -297,7 +299,9 @@ bounded panel, a pinned-SHA verdict. What does not transfer is cut, with the rea
297
299
  #### D1 — the enforcement matrix is an executable artifact, not a document
298
300
 
299
301
  `manifest/enforcement.tsv` has one row per rule. The `check` column holds a real command, the
300
- literal `advisory`, or the marker `goblin-verify --only <ID>` for a check that needs more than
302
+ literal `advisory`, prose that names its reader (the library's `GT-06`/`EX-01` rows end in
303
+ ", read by a human" and the engine advisories them), or the marker `goblin-verify --only <ID>` for
304
+ a check that needs more than
301
305
  one shell line. A self-check row (IN-03) fails the manifest when a row has neither, and SK-03
302
306
  caps the advisory count. **The number of unenforceable rules is itself a gate.**
303
307
 
@@ -393,14 +397,13 @@ state), and CI and `goblin-verify` were free to report different truths about on
393
397
 
394
398
  No row of the shipped matrix is labelled `advisory` — the **six advisory rows moved to the
395
399
  library**, so a default run sits at **0 of 10** on the `SK-03` cap (`gob verify --library` lists
396
- them). Those six carry **no executable check at all**:
400
+ them). Those five carry **no executable check at all**:
397
401
 
398
402
  - **HP-04** — a stale sentence is corrected in place with a dated parenthetical, never deleted.
399
403
  - **HS-03** — source probes read text with comments blanked first.
400
404
  - **CM-02** — the commit message was written to a file, not passed inline.
401
405
  - **DOC-01** — a significant change updates the docs that teach it.
402
406
  - **DOC-02** — system-level changes are recorded wherever the project's standard says they live.
403
- - **SC-09** — auth is applied consistently across sibling routes.
404
407
 
405
408
  `HP-04` and `CM-02` additionally print a heuristic when run with `--only`. A heuristic is not a
406
409
  check: it never fails a run. A counted rule is still not an enforced one, and the cap is a policy,
package/VERSION CHANGED
@@ -1 +1 @@
1
- 0.6.1
1
+ 0.7.3
@@ -0,0 +1,93 @@
1
+ #!/usr/bin/env bash
2
+ # goblin-approve — `gob approve-agents "<reason>"` (AG-01): record an approval of AGENTS.md
3
+ # as it stands right now.
4
+ #
5
+ # The row AG-01 exists because the file that decides what "green" means (AGENTS.md's gates)
6
+ # is editable by the worker the gate polices. This command is the human half of the loop:
7
+ # after a person reads the diff, it appends ONE row to .gob/agents.approved —
8
+ #
9
+ # date <TAB> sha256-of-AGENTS.md <TAB> approver <TAB> one-line reason
10
+ #
11
+ # append-only history, latest row wins. `goblin-verify --only AG-01` recomputes the hash and
12
+ # compares it with the last row: match = PASS (printing date + approver), mismatch = FAIL,
13
+ # no record at all = SKIP (an existing install never turns red by upgrading).
14
+ #
15
+ # gob approve-agents "<reason>" [--approver <name>] [--target <dir>]
16
+ #
17
+ # --approver defaults to the target repo's git user.name, then $USER. The reason is one
18
+ # line: tabs and newlines are flattened to spaces so the row stays 4 tab-separated fields.
19
+ #
20
+ # Exit codes: 0 recorded | 1 refusal (named path + fix) | 2 bad input.
21
+ # No npm, no jq, no network. bash/awk/git only.
22
+ set -uo pipefail
23
+
24
+ SELF_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
25
+ # shellcheck source=goblin-lib.sh
26
+ . "$SELF_DIR/goblin-lib.sh"
27
+
28
+ usage() { sed -n '2,/^$/p' "${BASH_SOURCE[0]}" | sed 's/^# \{0,1\}//'; }
29
+
30
+ # need_val <flag> <usage> <value> — refuse exit 2 unless the value is set. The same guard
31
+ # goblin-init learned from INIT-WRITE-HANG: `shift 2` with $#=1 fails silently under
32
+ # `set -uo pipefail`, so a value flag at the end of the line must demand its argument.
33
+ need_val() {
34
+ [ -n "${3:-}" ] && return 0
35
+ g_err "$1: missing value — usage: gob approve-agents $2"
36
+ exit 2
37
+ }
38
+
39
+ REASON="" APPROVER="" TARGET=""
40
+ while [ $# -gt 0 ]; do
41
+ case "$1" in
42
+ --target) need_val --target '[--target <dir>] "<reason>"' "${2:-}"; TARGET=$2; shift 2 ;;
43
+ --approver) need_val --approver '"<reason>" --approver <name>' "${2:-}"; APPROVER=$2; shift 2 ;;
44
+ -h|--help) usage; exit 0 ;;
45
+ -*) g_err "unknown option: $1"; usage >&2; exit 2 ;;
46
+ *) [ -z "$REASON" ] || { g_err "one reason only — usage: gob approve-agents \"<reason>\""; exit 2; }
47
+ REASON=$1; shift ;;
48
+ esac
49
+ done
50
+ [ -n "$REASON" ] || { g_err "no reason given — usage: gob approve-agents \"<one-line reason>\""; usage >&2; exit 2; }
51
+
52
+ command -v git >/dev/null 2>&1 || { g_err "missing dependency: git"; exit 2; }
53
+
54
+ # Root resolution, the verifier's own rule (D20): the installed AGENTS.md is the marker, so
55
+ # a nested target is not verified/approved as the outer repo that encloses it.
56
+ if [ -n "$TARGET" ]; then
57
+ TARGET=$(g_expand_tilde "$TARGET")
58
+ [ -d "$TARGET" ] || { g_err "--target is not a directory: $TARGET"; exit 2; }
59
+ ROOT=$(cd "$TARGET" && pwd)
60
+ else
61
+ ROOT=""
62
+ local_d="$PWD"
63
+ while :; do
64
+ if [ -f "$local_d/AGENTS.md" ] && grep -q "^$GOB_AGENTS_BEGIN" "$local_d/AGENTS.md" 2>/dev/null; then ROOT="$local_d"; break; fi
65
+ [ "$local_d" = "/" ] && break
66
+ local_d=$(dirname "$local_d")
67
+ done
68
+ [ -n "$ROOT" ] || ROOT="$PWD"
69
+ fi
70
+ AGENTS="$ROOT/AGENTS.md"
71
+ [ -f "$AGENTS" ] || { g_err "no AGENTS.md at $ROOT — approve-agents records the file AG-01 polices; run it inside an installed repo"; exit 1; }
72
+
73
+ # The approver: explicit, then the repo's own git identity, then $USER.
74
+ if [ -z "$APPROVER" ]; then
75
+ APPROVER=$(git -C "$ROOT" config user.name 2>/dev/null | head -n 1)
76
+ fi
77
+ [ -n "$APPROVER" ] || APPROVER=${USER:-unknown}
78
+
79
+ # The reason is one line: flatten tabs/newlines so the row stays exactly 4 fields.
80
+ REASON=$(printf '%s' "$REASON" | tr '\t\r\n' ' ' | sed 's/ */ /g; s/^ //; s/ $//')
81
+
82
+ RECORD="$ROOT/.gob/agents.approved"
83
+ SHA=$(g_sha256_file "$AGENTS")
84
+ DATE=$(date +%F)
85
+ mkdir -p "$ROOT/.gob" || { g_err "could not create $ROOT/.gob"; exit 1; }
86
+ printf '%s\t%s\t%s\t%s\n' "$DATE" "$SHA" "$APPROVER" "$REASON" >> "$RECORD" || { g_err "could not append to $RECORD"; exit 1; }
87
+
88
+ N=$(grep -c . "$RECORD" || true)
89
+ printf 'approved %s\n' "AGENTS.md"
90
+ printf ' record %s (row %s, latest wins)\n' "${RECORD#"$ROOT"/}" "$N"
91
+ printf ' sha256 %s\n' "$SHA"
92
+ printf ' date %s by %s — %s\n' "$DATE" "$APPROVER" "$REASON"
93
+ exit 0
package/bin/goblin-bans CHANGED
@@ -41,7 +41,7 @@
41
41
 
42
42
  set -uo pipefail
43
43
 
44
- GOBLIN_BANS_VERSION="0.6.1"
44
+ GOBLIN_BANS_VERSION="0.7.3"
45
45
  SELF_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
46
46
  # shellcheck source=goblin-lib.sh
47
47
  . "$SELF_DIR/goblin-lib.sh"
package/bin/goblin-init CHANGED
@@ -581,6 +581,19 @@ if [ "$WITH_MCP" -eq 1 ]; then
581
581
  fi
582
582
  do_hooks || exit 1
583
583
 
584
+ # ------------------------------------------------- AG-01's first record --------
585
+ # A fresh install is green on day one: `gob init --write` records an approval of the
586
+ # AGENTS.md it just wrote. FIRST RECORD ONLY — a re-run over a repo that already has one
587
+ # leaves it alone, so an init block-rewrite over unapproved edits stays AG-01 red with the
588
+ # fix command, rather than this command silently rubber-stamping them.
589
+ if [ ! -f "$TARGET/.gob/agents.approved" ]; then
590
+ bash "$SRC/bin/goblin-approve" --target "$TARGET" "gob init --write day one" >/dev/null 2>&1 \
591
+ || { g_err "could not write the first AG-01 approval record at $TARGET/.gob/agents.approved"; exit 1; }
592
+ g_info "recorded .gob/agents.approved (AG-01: re-approve after you edit AGENTS.md — gob approve-agents \"<reason>\")"
593
+ else
594
+ g_info "kept .gob/agents.approved (an approval record already exists; AG-01 judges AGENTS.md against it)"
595
+ fi
596
+
584
597
  # --------------------------------------------------------------------- done ----
585
598
  printf '\n'
586
599
  printf 'gob init: installed — feature map %s\n' "$FEATURE_MAP"
@@ -28,7 +28,7 @@
28
28
 
29
29
  set -uo pipefail
30
30
 
31
- GOBLIN_INSTALL_VERSION="0.6.1"
31
+ GOBLIN_INSTALL_VERSION="0.7.3"
32
32
  SELF_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
33
33
  SRC=$(cd "$SELF_DIR/.." && pwd)
34
34
  # shellcheck source=goblin-lib.sh
@@ -447,7 +447,7 @@ ADV_CEILING=$(default_ advisory_ceiling); [ -n "$ADV_CEILING" ] || ADV_CEILING=1
447
447
  # The optional second gate (the TODO ceiling); blank it to render one gate only.
448
448
  GATE2_NAME=$(default_ gate2_name)
449
449
  GATE2_CMD=$(default_ gate2_cmd)
450
- # The security surface (SC-01..SC-09) and the perf baseline (PF-01).
450
+ # The security surface (SC-01..SC-08 enforcement; SC-09 is a library advisory) and the perf baseline (PF-01).
451
451
  SEC_GITIGNORE_FAMILY=$(default_ sec_gitignore_family); [ -n "$SEC_GITIGNORE_FAMILY" ] || SEC_GITIGNORE_FAMILY=no
452
452
  SEC_BUILD_OUTPUT=$(default_ sec_build_output)
453
453
  SEC_WRITE_ROUTES=$(default_ sec_write_routes)
@@ -470,7 +470,14 @@ LAYERS_BLOCK=""
470
470
  # skill rows (SK-01/02/04) — a fresh repo's harness runs them instead of skipping. An
471
471
  # explicit --opt-out is the only thing that records a part in disabled:.
472
472
  DISABLED=""
473
- if [ -n "$OPT_OUT" ]; then DISABLED="$DISABLED$OPT_OUT,"; fi
473
+ if [ -n "$OPT_OUT" ]; then
474
+ # An opt-out ADDS to the parts already recorded: seed from the PREVIOUS value — brackets
475
+ # stripped — or the flag merge lets this run's render ([skills]) replace the carried
476
+ # [mcp] and the older opt-outs are lost (measured on this tree). A fresh install has no
477
+ # previous value, so the list is exactly this run's part.
478
+ PREV_DISABLED=$(g_agents_read "$CONFIG" disabled 2>/dev/null || true)
479
+ DISABLED="${PREV_DISABLED//[][]/},$OPT_OUT,"
480
+ fi
474
481
  DISABLED=$(printf '%s' "$DISABLED" | tr ',' '\n' | grep -v '^$' | sort -u | paste -sd, -)
475
482
 
476
483
  # FIX 3: a *-SPEC.md and reviews/ are policed by LIBRARY rows (SP-01..03, PG-01..03, off by
@@ -678,6 +685,97 @@ render_config() {
678
685
  grep -v '^gate__cmd: $' "$TMP/agents-block.raw" > "$TMP/agents-block"
679
686
  }
680
687
 
688
+ # The carry is NOT a list of names. It used to be: CARRY_KEYS enumerated seven keys the
689
+ # render-call drew from hardcoded literals, and everything else in the previous block was
690
+ # overwritten with the render's literal — or, for keys the render does not emit at all
691
+ # (a gate_<name>_cmd a newer template never draws, or a hand-added key), silently DELETED,
692
+ # comment lines included. That manufactured absence is this card's bug: a re-install raised
693
+ # a ratchet ceiling back to the template's measured number, deleted the gate that enforced
694
+ # it, and deleted the comment block that recorded why the ceiling is what it is — in
695
+ # silence, on every upgrade. The kit's own doctrine — a declared key that is absent is a
696
+ # skip with a reason, never a silent pass — makes the installer the one writer that must
697
+ # not manufacture it. So carry_forward now reads the previous block as LINES (g_agents_pairs
698
+ # loses comments) and keeps every line the new render did not reproduce under the same key:
699
+ # - a pair whose key the render emitted -> the previous value replaces the rendered one;
700
+ # - a pair whose key the render did NOT emit -> re-inserted, so a declared gate or any
701
+ # key a newer template stopped drawing cannot vanish;
702
+ # - a `#` comment line or any other non-pair line -> preserved verbatim, in its old
703
+ # relative position.
704
+ # Two rules sit above the merge:
705
+ # - A flag is a decision; the absence of a flag is not. A key this run was TOLD a value
706
+ # for (MERGE_FLAG_KEYS below: --gate, --archive, --opt-out) keeps the rendered value —
707
+ # the flag's — not the carried one. MERGE_FLAG_KEYS is rebuilt on every run from the
708
+ # parsed options; it is never read from a record. The practice pin is the DELIBERATE
709
+ # exception to this rule: IN-02's own contract — an --upgrade must never re-pin the
710
+ # standard by itself, even when --practice names a file; --re-pin is the decision — is
711
+ # stronger and sits above the merge (the keep-old-practice sed and the carry agree on
712
+ # the same answer: the previous pin, until --re-pin).
713
+ # - A value the project deliberately blanked stays blank (an empty previous value
714
+ # carries nothing), and a fresh install has no previous block and is untouched: the
715
+ # render is the answer on day one.
716
+ # The practice pin keeps its own contract above this mechanism: an OMITTED --practice never
717
+ # re-pins the standard (IN-02 — the block below and the sed over the rendered lines), and
718
+ # --re-pin remains the deliberate path for an edited standard.
719
+ MERGE_FLAG_KEYS=""
720
+ [ -n "${GOB_GATE:-}" ] && MERGE_FLAG_KEYS="$MERGE_FLAG_KEYS gate_${GATE_NAME}_cmd"
721
+ [ "$ARCHIVE" = "true" ] && MERGE_FLAG_KEYS="$MERGE_FLAG_KEYS archive"
722
+ [ -n "$OPT_OUT" ] && MERGE_FLAG_KEYS="$MERGE_FLAG_KEYS disabled"
723
+
724
+ # carry_forward — merge the PREVIOUS block into the rendered one, line by line. The rendered
725
+ # file is read first (its key -> line map drives the merge), then the previous block's lines
726
+ # are walked in order: a pair whose key the render emitted prints the rendered line (with the
727
+ # previous value spliced in, unless the key is in MERGE_FLAG_KEYS — the flag wins), a pair
728
+ # the render does not emit prints verbatim, and every other line (comments) prints verbatim.
729
+ # Rendered lines no previous key consumed (the markers, and keys newer than the previous
730
+ # block) are appended in render order afterwards. The value is cut at the FIRST ": " and
731
+ # rebuilt as `key: value`, so a value carrying ": " or a raw tab round-trips byte for byte
732
+ # (the same contract g_agents_pairs gives the write). A duplicated previous key: the first
733
+ # occurrence wins and the rest are dropped — g_agents_read stops at the first match, so a
734
+ # kept duplicate would shadow the carried value. An EMPTY previous value carries nothing —
735
+ # a value the project blanked stays blank. A failure here EXITS: a re-install that cannot
736
+ # read the previous block must not go on and write the render over it.
737
+ carry_forward() {
738
+ [ -f "$CONFIG" ] || return 0
739
+ g_agents_block "$CONFIG" > "$TMP/prev-block" 2>/dev/null \
740
+ || { g_err "could not read the previous gob block in $CONFIG"; exit 1; }
741
+ [ -s "$TMP/prev-block" ] || return 0
742
+ MERGE_FLAG_KEYS="$MERGE_FLAG_KEYS" awk '
743
+ FNR == NR { # pass 1: the rendered block — key -> line index
744
+ rn++; rline[rn] = $0
745
+ if (match($0, /^[A-Za-z_][A-Za-z0-9_.-]*:/)) {
746
+ k = substr($0, 1, RLENGTH - 1)
747
+ if (!(k in remit)) remit[k] = rn
748
+ }
749
+ next
750
+ }
751
+ { # pass 2: the previous block, in file order
752
+ if (match($0, /^[A-Za-z_][A-Za-z0-9_.-]*:/)) {
753
+ k = substr($0, 1, RLENGTH - 1)
754
+ if (k in remit) {
755
+ if (k in pdone) next # a duplicated previous key: first wins, rest dropped
756
+ pdone[k] = 1
757
+ v = ""
758
+ if (index($0, ": ") > 0) v = substr($0, index($0, ": ") + 2)
759
+ if (v != "" && index(" " ENVIRON["MERGE_FLAG_KEYS"] " ", " " k " ") == 0) {
760
+ rline[remit[k]] = k ": " v
761
+ }
762
+ print rline[remit[k]]
763
+ used[remit[k]] = 1
764
+ } else {
765
+ print $0 # the render has no line for this key: re-inserted
766
+ }
767
+ next
768
+ }
769
+ print $0 # a comment (or any non-pair line): kept verbatim
770
+ }
771
+ END {
772
+ for (i = 1; i <= rn; i++) if (!(i in used)) print rline[i]
773
+ }
774
+ ' "$TMP/agents-block" "$TMP/prev-block" > "$TMP/agents-block.merged" \
775
+ && mv "$TMP/agents-block.merged" "$TMP/agents-block" \
776
+ || { g_err "could not carry the previous block forward into $CONFIG"; exit 1; }
777
+ }
778
+
681
779
  render_config
682
780
  # The re-shadow refusal (W3 §5.3): a record with engine.mode=global is a MIGRATED repo.
683
781
  # Re-installing would recreate the 18-file payload (the vendored step of the resolution
@@ -729,6 +827,11 @@ put ".gob/engine/categories.tsv" "$SRC/manifest/categories.tsv"
729
827
  # wish, so the table and the engine install together or not at all.
730
828
  put ".gob/manifest/bans.tsv" "$SRC/manifest/bans.tsv"
731
829
  put ".gob/bin/goblin-bans" "$SRC/bin/goblin-bans"
830
+ # AG-01's approve command: shipped like the bans engine, hash-pinned by installed.json. The
831
+ # record it appends to (.gob/agents.approved) is deliberately NOT in this list — it is the
832
+ # project's own history, rewritten by every approval, so pinning it would turn IN-02 red on
833
+ # every legitimate approve.
834
+ put ".gob/bin/goblin-approve" "$SRC/bin/goblin-approve"
732
835
  put ".gob/bans/README.md" "$SRC/bans/README.md"
733
836
  put ".gob/bans/grep-ban.sh" "$SRC/bans/grep-ban.sh"
734
837
  put ".gob/bans/layer-check.sh" "$SRC/bans/layer-check.sh"
@@ -746,7 +849,9 @@ if [ "$DRY_RUN" -eq 0 ] && [ -f "$CONFIG" ]; then
746
849
  # The block file here is the RENDERED template ("key: value" lines, no tabs), so the match
747
850
  # anchors on the key prefix, not on a tab field ($1 == "practice" never fired under the
748
851
  # rendered shape and the freshly rendered NEW hash flowed straight through — an --upgrade
749
- # re-pinned the standard silently, exactly what IN-02 exists to catch).
852
+ # re-pinned the standard silently, exactly what IN-02 exists to catch). This sits ABOVE the
853
+ # line merge: even an explicit --practice does not re-pin on a re-install (the merge would
854
+ # otherwise keep the freshly hashed pin); --re-pin is the decision path for a new pin.
750
855
  if [ -n "$PREV_FILES" ]; then
751
856
  KEEP_PRACTICE=$(g_agents_read "$CONFIG" practice)
752
857
  KEEP_PRACTICE_SHA=$(g_agents_read "$CONFIG" practice_sha256)
@@ -754,6 +859,14 @@ if [ "$DRY_RUN" -eq 0 ] && [ -f "$CONFIG" ]; then
754
859
  sed -i "s#^practice: .*\$#practice: $KEEP_PRACTICE#; s#^practice_sha256: .*\$#practice_sha256: $KEEP_PRACTICE_SHA#" "$TMP/agents-block"
755
860
  fi
756
861
  fi
862
+ # The install-once contract for the block itself: a re-install must not ERASE a project's
863
+ # declaration and turn the gate that reads it into a SKIP. The merge above keeps every line
864
+ # the render did not reproduce under the same key — values, keys the render no longer emits,
865
+ # and comments. Gated on the BLOCK's presence, not
866
+ # on the previous install record: an AGENTS.md that carries a gob block is the project's
867
+ # answers whether or not installed.json survived, and the carry is a no-op when no block
868
+ # exists (so a fresh install still renders today's defaults).
869
+ carry_forward
757
870
  g_agents_write "$CONFIG" < "$TMP/agents-block" >/dev/null \
758
871
  || { g_err "could not write the gob block into $CONFIG"; exit 1; }
759
872
  fi
@@ -920,7 +1033,12 @@ if [ "$DRY_RUN" -eq 0 ]; then
920
1033
  fi
921
1034
  if [ -n "$OPT_OUT" ] && grep -q "^$GOB_AGENTS_BEGIN" "$CONFIG" 2>/dev/null; then
922
1035
  cur=$(g_agents_read "$CONFIG" disabled)
923
- new=$(printf '%s,%s' "${cur#[]}" "${OPT_OUT}" | tr ',' '\n' | grep -v '^$' | sort -u | paste -sd, -)
1036
+ # The strip must remove BOTH brackets: ${cur#[]} is an empty glob class and matches
1037
+ # nothing, so the previous value's own brackets flowed into the re-wrap — a fresh
1038
+ # --opt-out mcp measured `disabled: [[mcp],mcp]` (nested, part twice) on 0.7.1. Strip,
1039
+ # append this run's part, dedupe, sort, wrap once.
1040
+ cur=${cur//[][]/}
1041
+ new=$(printf '%s,%s' "$cur" "${OPT_OUT}" | tr ',' '\n' | grep -v '^$' | sort -u | paste -sd, -)
924
1042
  {
925
1043
  while IFS=$'\t' read -r k v; do
926
1044
  [ "$k" = "disabled" ] && continue
package/bin/goblin-lib.sh CHANGED
@@ -16,7 +16,7 @@
16
16
  # - name: typecheck four-space-indented second member of a list entry
17
17
  # cmd: npx tsc --noEmit
18
18
 
19
- GOBLIN_LIB_VERSION="0.6.1"
19
+ GOBLIN_LIB_VERSION="0.7.3"
20
20
 
21
21
  # ---------------------------------------------------------------- output -----
22
22
  # g_trunc <width> <text> — fold a long detail to one line at <width> columns, keeping the
@@ -50,12 +50,15 @@ g_fold() {
50
50
  }'
51
51
  }
52
52
  g_pass() {
53
- if [ "${GOB_VERIFY_VERBOSE:-0}" -eq 1 ]; then
54
- printf 'PASS %-6s %s\n' "$1" "$(g_trunc "${GOB_REPORT_COLS:-100}" "$2")"
55
- elif printf '%s' "$2" | grep -q "$(printf '\n')"; then
56
- # Multi-line PASS payloads print whole: the payload often IS the pin a test reads
57
- # (SK-03's advisory-ceiling line), and the collapse must not swallow it.
53
+ if printf '%s' "$2" | grep -q "$(printf '\n')"; then
54
+ # Multi-line PASS payloads print whole in every mode: the payload often IS the pin a
55
+ # test reads (SK-03's advisory-ceiling line), and under --only this used to run the
56
+ # whole payload through g_trunc below — whose length counts the newlines too, so the
57
+ # second line was cut mid-token (the ~100-col fold is for single-line payloads,
58
+ # exactly as g_adv has always done it).
58
59
  printf 'PASS %-6s %s\n' "$1" "$2"
60
+ elif [ "${GOB_VERIFY_VERBOSE:-0}" -eq 1 ]; then
61
+ printf 'PASS %-6s %s\n' "$1" "$(g_trunc "${GOB_REPORT_COLS:-100}" "$2")"
59
62
  else
60
63
  printf 'PASS %-6s (ok)\n' "$1"
61
64
  fi