@techgoblin/gobstack 0.6.0-alpha.3 → 0.6.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (110) hide show
  1. package/CHANGELOG.md +45 -0
  2. package/README.md +256 -120
  3. package/VERSION +1 -1
  4. package/bans/README.md +5 -5
  5. package/bans/grep-ban.sh +1 -1
  6. package/bin/goblin-bans +103 -27
  7. package/bin/goblin-init +346 -211
  8. package/bin/goblin-install +281 -204
  9. package/bin/goblin-lib.sh +79 -76
  10. package/bin/goblin-map +130 -571
  11. package/bin/goblin-mcp.js +37 -16
  12. package/bin/goblin-verify +254 -998
  13. package/bin/goblin.js +4 -9
  14. package/docs/GUIDE.md +727 -181
  15. package/docs/LIMITS.md +273 -301
  16. package/docs/RECORD-NOTES.md +1 -2
  17. package/manifest/bans.tsv +9 -9
  18. package/manifest/categories.tsv +18 -0
  19. package/manifest/enforcement.tsv +12 -68
  20. package/manifest/glossary.tsv +6 -12
  21. package/manifest/library.tsv +33 -0
  22. package/package.json +1 -4
  23. package/skills/goblin-bootstrap/SKILL.md +20 -32
  24. package/skills/goblin-feature-map/SKILL.md +1 -1
  25. package/skills/goblin-verify-author/SKILL.md +2 -2
  26. package/skills/practice/SKILL.md +4 -4
  27. package/templates/AGENTS.md.tmpl +6 -6
  28. package/templates/HANDOFF.md.tmpl +1 -1
  29. package/templates/SPEC.md.tmpl +2 -2
  30. package/templates/agents-block.tmpl +1 -10
  31. package/adapters/_template/adapter.tsv +0 -16
  32. package/adapters/_template/detect.sh +0 -10
  33. package/adapters/_template/emit.sh +0 -5
  34. package/adapters/_template/verify.sh +0 -4
  35. package/adapters/claude/adapter.tsv +0 -8
  36. package/adapters/claude/detect.sh +0 -8
  37. package/adapters/claude/verify.sh +0 -47
  38. package/adapters/codex/adapter.tsv +0 -12
  39. package/adapters/codex/detect.sh +0 -9
  40. package/adapters/codex/verify.sh +0 -45
  41. package/adapters/copilot/adapter.tsv +0 -10
  42. package/adapters/copilot/detect.sh +0 -8
  43. package/adapters/copilot/verify.sh +0 -45
  44. package/adapters/cursor/adapter.tsv +0 -11
  45. package/adapters/cursor/detect.sh +0 -10
  46. package/adapters/cursor/verify.sh +0 -45
  47. package/adapters/gemini/adapter.tsv +0 -15
  48. package/adapters/gemini/detect.sh +0 -11
  49. package/adapters/gemini/verify.sh +0 -49
  50. package/adapters/hermes/adapter.tsv +0 -9
  51. package/adapters/hermes/detect.sh +0 -8
  52. package/adapters/hermes/verify.sh +0 -27
  53. package/adapters/opencode/adapter.tsv +0 -14
  54. package/adapters/opencode/detect.sh +0 -9
  55. package/adapters/opencode/verify.sh +0 -45
  56. package/automations/README.md +0 -53
  57. package/automations/bugreporter-intake.sh +0 -145
  58. package/automations/drift-audit.sh +0 -139
  59. package/automations/report.schema.tsv +0 -10
  60. package/bin/goblin +0 -144
  61. package/bin/goblin-audit +0 -143
  62. package/bin/goblin-doctor +0 -233
  63. package/bin/goblin-emit +0 -495
  64. package/bin/goblin-extras +0 -360
  65. package/bin/goblin-model +0 -105
  66. package/bin/goblin-upgrade +0 -580
  67. package/docs/ADOPTION.md +0 -173
  68. package/docs/CI.md +0 -190
  69. package/docs/CONTRACTS.md +0 -215
  70. package/docs/DESIGN.md +0 -92
  71. package/docs/ENFORCEMENT.md +0 -228
  72. package/docs/FLOWS.md +0 -164
  73. package/docs/GLOSSARY.md +0 -40
  74. package/docs/GUARDRAILS.md +0 -126
  75. package/docs/INTEGRATION.md +0 -92
  76. package/docs/LOOP.md +0 -165
  77. package/docs/RE-PLAYBOOK.md +0 -183
  78. package/docs/RISKS.md +0 -70
  79. package/docs/ROLES.md +0 -105
  80. package/extras-catalogue/catalogue.tsv +0 -42
  81. package/extras-catalogue/payload/README.md +0 -14
  82. package/extras-catalogue/payload/taste-skill/taste/REFERENCE.md +0 -3
  83. package/extras-catalogue/payload/taste-skill/taste/SKILL.md +0 -9
  84. package/manifest/classes.tsv +0 -51
  85. package/manifest/playbooks.tsv +0 -16
  86. package/presets/electron-overlay.yaml +0 -38
  87. package/presets/fleet.yaml +0 -43
  88. package/presets/game.yaml +0 -38
  89. package/presets/research.yaml +0 -41
  90. package/presets/service.yaml +0 -40
  91. package/presets/software.yaml +0 -48
  92. package/roles.yaml +0 -54
  93. package/skills/goblin-bugfix/SKILL.md +0 -26
  94. package/skills/goblin-bugreporter/SKILL.md +0 -52
  95. package/skills/goblin-drift-audit/SKILL.md +0 -43
  96. package/skills/goblin-eval/SKILL.md +0 -68
  97. package/skills/goblin-feature/SKILL.md +0 -26
  98. package/skills/goblin-investigation/SKILL.md +0 -26
  99. package/skills/goblin-judge/SKILL.md +0 -74
  100. package/skills/goblin-loop/SKILL.md +0 -88
  101. package/skills/goblin-mode/SKILL.md +0 -70
  102. package/skills/goblin-overnight/SKILL.md +0 -42
  103. package/skills/goblin-pr-gate/SKILL.md +0 -42
  104. package/skills/goblin-re-mobile/SKILL.md +0 -51
  105. package/skills/goblin-refactor/SKILL.md +0 -23
  106. package/skills/goblin-sweep/SKILL.md +0 -23
  107. package/skills/goblin-tdd-repro/SKILL.md +0 -27
  108. package/templates/audit-waiver.tsv.tmpl +0 -10
  109. package/templates/install-hooks.allowlist.tmpl +0 -9
  110. package/templates/report.yaml.tmpl +0 -16
package/bin/goblin-verify CHANGED
@@ -19,7 +19,7 @@
19
19
 
20
20
  set -uo pipefail
21
21
 
22
- GOBLIN_VERIFY_VERSION="0.6.0-alpha.3"
22
+ GOBLIN_VERIFY_VERSION="0.6.0-beta.1"
23
23
  SELF_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
24
24
  # shellcheck source=goblin-lib.sh
25
25
  . "$SELF_DIR/goblin-lib.sh"
@@ -27,6 +27,7 @@ SELF_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
27
27
  ONLY=""
28
28
  JSON=0
29
29
  LIST=0
30
+ LIBRARY_LIST=0
30
31
  SOURCE=""
31
32
  VERBOSE=0
32
33
  # PASS details collapse to (ok) in the default listing; --verbose (or --only, which is a
@@ -40,7 +41,9 @@ goblin-verify — prove a goblin-stack install is still what it says it is.
40
41
  --only <id[,id...]> run only these manifest rows
41
42
  --verbose print every row full-width (the default collapses PASS payloads
42
43
  to a count; FAIL and ADV always print in full)
43
- --list list the manifest rows and exit
44
+ --list list the on-by-default rows and exit
45
+ --library list the OFF-by-default rows (the library) and exit — each with a
46
+ one-line purpose and the exact line that turns it on
44
47
  --json machine-readable output
45
48
  --source <path> read the manifest from a goblin-stack checkout instead of .gob/
46
49
 
@@ -53,6 +56,7 @@ while [ $# -gt 0 ]; do
53
56
  --only) ONLY="${2:-}"; VERBOSE=1; shift 2 ;;
54
57
  --json) JSON=1; shift ;;
55
58
  --list) LIST=1; shift ;;
59
+ --library) LIBRARY_LIST=1; shift ;;
56
60
  --verbose) VERBOSE=1; shift ;;
57
61
  --source) SOURCE="${2:-}"; shift 2 ;;
58
62
  -h|--help) usage; exit 0 ;;
@@ -83,7 +87,7 @@ if [ -z "$ROOT" ]; then
83
87
  fi
84
88
 
85
89
  # ---- engine resolution (W1, §2.3): one chain, stated once --------------------
86
- # Every engine-path lookup (enforcement.tsv, classes.tsv, bans.tsv, bans/*.sh, the ban
90
+ # Every engine-path lookup (enforcement.tsv, bans.tsv, bans/*.sh, the ban
87
91
  # engine) resolves through this chain, first hit wins:
88
92
  # 1. --source <path> (existing flag; highest, for tests and pinned CI)
89
93
  # 2. $ROOT/.gob/... (vendored per-repo engine — today's default)
@@ -164,14 +168,11 @@ ENGINE_CHAIN_VENDORED="\$ROOT/.gob/manifest/enforcement.tsv"
164
168
  GOBLIN_ENGINE="" # the resolved engine root, when NOT vendored/--source
165
169
  if [ -n "$SOURCE" ]; then
166
170
  MANIFEST="$SOURCE/manifest/enforcement.tsv"
167
- CLASSES="$SOURCE/manifest/classes.tsv"
168
171
  elif [ -f "$ROOT/.gob/manifest/enforcement.tsv" ]; then
169
172
  MANIFEST="$ROOT/.gob/manifest/enforcement.tsv"
170
- CLASSES="$ROOT/.gob/manifest/classes.tsv"
171
173
  elif [ -n "$ENGINE_DECLARED" ]; then
172
174
  GOBLIN_ENGINE="$ENGINE_DECLARED"
173
175
  MANIFEST="$GOBLIN_ENGINE/manifest/enforcement.tsv"
174
- CLASSES="$GOBLIN_ENGINE/manifest/classes.tsv"
175
176
  elif [ -n "$ENGINE_FAIL" ]; then
176
177
  # §2.4: an explicit engine_dir: that does not resolve is exit 2, and nothing falls
177
178
  # back. The refusal names the declared value and every path the chain tried.
@@ -193,10 +194,8 @@ else
193
194
  if [ -n "$_cli_default" ] && [ -f "$_cli_default/manifest/enforcement.tsv" ]; then
194
195
  GOBLIN_ENGINE="$_cli_default"
195
196
  MANIFEST="$GOBLIN_ENGINE/manifest/enforcement.tsv"
196
- CLASSES="$GOBLIN_ENGINE/manifest/classes.tsv"
197
197
  else
198
198
  MANIFEST="$SELF_DIR/../manifest/enforcement.tsv"
199
- CLASSES="$SELF_DIR/../manifest/classes.tsv"
200
199
  fi
201
200
  fi
202
201
  [ -f "$MANIFEST" ] || {
@@ -205,6 +204,35 @@ fi
205
204
  exit 2
206
205
  }
207
206
 
207
+ # ---- the library (batch 2b-ii) -----------------------------------------------
208
+ # The OFF-by-default row set lives in manifest/library.tsv next to the resolved manifest.
209
+ # Its rows are NOT executed by a default run: the runner above reads $MANIFEST only. The
210
+ # library is shipped data (a moved row keeps its full check text and remedy — nothing is
211
+ # deleted or commented out, and no check function is removed from this verifier); a repo
212
+ # turns a row ON by writing its id (the row's `enable` column) into its local override
213
+ # .gob/manifest/enforcement.local.tsv, which batch 3 wires into the run. Until then the
214
+ # library is a discovery surface: what exists, is held back, and how to enable each row.
215
+ MANIFEST_DIR=$(dirname "$MANIFEST")
216
+ LIBRARY_FILE="$MANIFEST_DIR/library.tsv"
217
+ [ -f "$LIBRARY_FILE" ] || LIBRARY_FILE=""
218
+
219
+ # ---- the repo-local override (batch 3): .gob/manifest/enforcement.local.tsv ----
220
+ # A repo turns a library row ON by writing that row's exact line (the snippet `gob verify
221
+ # --library` prints) into .gob/manifest/enforcement.local.tsv, which is VERSIONED WITH THE REPO
222
+ # (under $ROOT, not the engine). A local row behaves exactly like a matrix row: PASS, FAIL
223
+ # (its remedy: line is printed from this file), or SKIP (reported not-applicable). The file is
224
+ # OPTIONAL: absent means the default set only, and nothing is said about it.
225
+ #
226
+ # THE HONESTY GATE (the product's core rule: a repo must not be able to certify a rule nothing
227
+ # verifies). A local entry is REFUSED - exit 3, with a named remedy - when it names a row id the
228
+ # engine has no check for, or when its check cannot produce a verdict. Both are handled in
229
+ # setup_local_override below, before any row runs: a false green is the one failure this
230
+ # product must never produce. RUN_MANIFEST is $MANIFEST until a local override merges rows in.
231
+ LOCAL_FILE="$ROOT/.gob/manifest/enforcement.local.tsv"
232
+ [ -f "$LOCAL_FILE" ] || LOCAL_FILE=""
233
+ LOCAL_IDS=""
234
+ RUN_MANIFEST="$MANIFEST"
235
+
208
236
  INSTALLED="$ROOT/.gob/installed.json"
209
237
 
210
238
  # engine_block_field <key> — one field of installed.json's engine: block (empty if absent).
@@ -243,16 +271,39 @@ if [ "$LIST" -eq 1 ]; then
243
271
  exit 0
244
272
  fi
245
273
 
274
+ # --library: the discovery surface for the extend mechanism. It lists what the default run
275
+ # does NOT check, so a green run is never mistaken for the whole story. Each line: the row id,
276
+ # its one-line purpose (the rule cell), and the exact line that turns it on.
277
+ if [ "$LIBRARY_LIST" -eq 1 ]; then
278
+ if [ -z "$LIBRARY_FILE" ]; then
279
+ g_err "no library.tsv next to $MANIFEST - this engine ships no off-by-default row set"
280
+ exit 2
281
+ fi
282
+ g_info "the library: $(awk -F'\t' 'NR>1 && $1!="" {n++} END{print n+0}' "$LIBRARY_FILE") off-by-default row(s) - NOT run by a default verify."
283
+ g_info "enable a row by pasting its line below into .gob/manifest/enforcement.local.tsv (repo-local, committed with the repo)."
284
+ printf '\n'
285
+ awk -F'\t' 'NR>1 && $1!="" {
286
+ printf "%-7s %s\n", $1, $3
287
+ printf " paste this line into .gob/manifest/enforcement.local.tsv:\n"
288
+ printf " %s\t%s\t%s\t%s\t%s\t%s\t%s\n", $1, $2, $3, $4, $5, $6, $7
289
+ }' "$LIBRARY_FILE"
290
+ exit 0
291
+ fi
292
+
246
293
  # --only must name rows the manifest actually has: a typo used to select nothing, emit no
247
294
  # rows and exit 0, turning a pipeline gate into a no-op (D15).
248
295
  if [ -n "$ONLY" ]; then
249
296
  UNKNOWN=""
250
297
  for want in $(printf '%s' "$ONLY" | tr ',' ' '); do
251
298
  [ -n "$want" ] || continue
252
- awk -F'\t' -v x="$want" 'NR>1 && $1==x {f=1} END{exit !f}' "$MANIFEST" \
253
- || UNKNOWN="$UNKNOWN $want"
299
+ _hit=0
300
+ awk -F'\t' -v x="$want" 'NR>1 && $1==x {f=1} END{exit !f}' "$MANIFEST" && _hit=1
301
+ if [ "$_hit" -eq 0 ] && [ -n "$LOCAL_FILE" ]; then
302
+ awk -F'\t' -v x="$want" '$1==x {f=1} END{exit !f}' "$LOCAL_FILE" && _hit=1
303
+ fi
304
+ [ "$_hit" -eq 1 ] || UNKNOWN="$UNKNOWN $want"
254
305
  done
255
- [ -z "$UNKNOWN" ] || { g_err "--only names id(s) not in the manifest:$UNKNOWN"; exit 2; }
306
+ [ -z "$UNKNOWN" ] || { g_err "--only names id(s) in neither the manifest nor the local override:$UNKNOWN"; exit 2; }
256
307
  # A valid id that is SOURCE-scope (PR-01..PR-04) selects no target row: the run emits
257
308
  # nothing and exits 0, which is the same no-op gate D15 closed for a typo (F2-6).
258
309
  TARGET_ROWS=0
@@ -260,6 +311,10 @@ if [ -n "$ONLY" ]; then
260
311
  [ -n "$want" ] || continue
261
312
  awk -F'\t' -v x="$want" 'NR>1 && $1==x && $2=="target" {f=1} END{exit !f}' "$MANIFEST" \
262
313
  && TARGET_ROWS=1
314
+ if [ "$TARGET_ROWS" -eq 0 ] && [ -n "$LOCAL_FILE" ]; then
315
+ awk -F'\t' -v x="$want" '$1==x && $2=="target" {f=1} END{exit !f}' "$LOCAL_FILE" \
316
+ && TARGET_ROWS=1
317
+ fi
263
318
  done
264
319
  if [ "$TARGET_ROWS" -eq 0 ]; then
265
320
  g_err "--only $ONLY selects no target-scope row, so this run would execute nothing and"
@@ -276,21 +331,13 @@ if [ ! -f "$CONFIG" ]; then
276
331
  if [ "$ROOT" != "$PWD" ]; then
277
332
  g_err "not installed: $CONFIG is absent — and $PWD is not the installed repo ($ROOT)."
278
333
  g_err "fix: cd to your project repo, then re-run gob verify."
279
- g_err " (installing here would initialize $PWD: goblin-install --target $PWD --class <software|service|game|research|fleet>)"
334
+ g_err " (installing here would initialize $PWD: npx @techgoblin/gobstack init)"
280
335
  else
281
- g_err "not installed: $CONFIG is absent. Run: goblin-install --target $ROOT --class <software|service|game|research|fleet>"
336
+ g_err "not installed: $CONFIG is absent. Run: npx @techgoblin/gobstack init # or: gob init, inside $ROOT"
282
337
  fi
283
338
  exit 2
284
339
  fi
285
340
 
286
- # The class is read-time resolved: the gob block records the canonical name on new installs, but
287
- # every repo installed before the 5-class merge records a letter (A..F) or an old name
288
- # (app/agent/desktop). g_class_canon maps them all to the five canonical names; the tsv carries
289
- # the canonical names, so nothing else in this file has to know about letters. `desktop`/F -> software.
290
- CLASS_RAW=$(g_agents_read "$CONFIG" class)
291
- CLASS=$(g_class_canon "$CLASS_RAW") \
292
- || { g_err "unknown class '${CLASS_RAW:-<empty>}' in $CONFIG (expected software|service|game|research|fleet, or A-E / app / agent / desktop)"; exit 2; }
293
-
294
341
  # Root vs git toplevel. find_installed_root resolves the CONFIG lookup correctly, but the
295
342
  # rows that shell out to git run in $ROOT and git resolves that to the ENCLOSING repo when
296
343
  # the target is not a repository of its own: a nested target then reports the outer repo's
@@ -300,7 +347,7 @@ ROOT_PHYS=$(cd "$ROOT" && pwd -P)
300
347
  GIT_TOP=$(cd "$ROOT" && git rev-parse --show-toplevel 2>/dev/null)
301
348
  if [ -n "$GIT_TOP" ] && [ "$GIT_TOP" != "$ROOT_PHYS" ]; then
302
349
  g_err "target $ROOT_PHYS is inside the git repository $GIT_TOP but is not a repository of"
303
- g_err "its own. CM-01 CM-03 GT-03 SP-02 PG-01 PG-03 DS-01 PT-02 and HP-05 shell out to git,"
350
+ g_err "its own. CM-03 GT-03 SP-02 PG-01 PG-03 DS-01 and HP-05 shell out to git,"
304
351
  g_err "and git would resolve every one of them to $GIT_TOP - the numbers would describe the"
305
352
  g_err "outer repo, not this target."
306
353
  g_err "fix: cd $ROOT_PHYS && git init (make the target its own repo), or move it out of"
@@ -308,13 +355,11 @@ if [ -n "$GIT_TOP" ] && [ "$GIT_TOP" != "$ROOT_PHYS" ]; then
308
355
  exit 2
309
356
  fi
310
357
 
311
- BRANCH=$(g_agents_read "$CONFIG" branch)
312
358
  ARCHIVE=$(g_agents_read "$CONFIG" archive)
313
359
  MAX_DIRTY=$(g_agents_read "$CONFIG" max_dirty)
314
360
  ADV_CEILING=$(g_agents_read "$CONFIG" advisory_ceiling)
315
361
  HARNESS_DIR_RAW=$(g_agents_read "$CONFIG" harness_dir)
316
362
  SCAFFOLD_CHECKS=$(g_agents_read "$CONFIG" scaffold_checks)
317
- MODELS_FILE=$(g_expand_tilde "$(g_agents_read "$CONFIG" models_file)")
318
363
  PRACTICE=$(g_expand_tilde "$(g_agents_read "$CONFIG" practice)")
319
364
  PRACTICE_SHA=$(g_unquote "$(g_agents_read "$CONFIG" practice_sha256)")
320
365
  [ -n "$MAX_DIRTY" ] || MAX_DIRTY=0
@@ -346,17 +391,6 @@ export FEATURE_MAP SOURCE_ROOT VERIFY_DOCTOR
346
391
  REFERENCE_MANIFEST=$(g_unquote "$(g_agents_read "$CONFIG" reference_manifest)")
347
392
  export REFERENCE_MANIFEST
348
393
 
349
- # The loop ceiling (G2, LP-03). The most turns ONE loop record may declare in its budget; 20 is
350
- # the engine's own default for a kanban goal loop, so a ceiling that disagreed with the engine
351
- # would be a number someone made up. A config written before this key existed keeps the default
352
- # (the SCAFFOLD_CHECKS shape): an absent key is not a broken config.
353
- LOOP_MAX_TURNS_CEILING=$(g_agents_read "$CONFIG" loop_max_turns_ceiling)
354
- [ -n "$LOOP_MAX_TURNS_CEILING" ] || LOOP_MAX_TURNS_CEILING=20
355
- # The loop record (G2): a COMMITTED artifact of one unattended run. Nothing in this section
356
- # re-runs the predicate and nothing writes: the record IS the evidence, and what that costs is
357
- # stated in docs/LOOP.md and docs/LIMITS.md.
358
- LOOP_DIR="$ROOT/.gob/loop"
359
- export LOOP_MAX_TURNS_CEILING LOOP_DIR
360
394
 
361
395
  if [ -d "$ROOT/$HARNESS_DIR_RAW" ]; then
362
396
  export GOBLIN_HARNESS_DIR="$ROOT/$HARNESS_DIR_RAW"
@@ -365,8 +399,8 @@ if [ -d "$ROOT/$HARNESS_DIR_RAW" ]; then
365
399
  else
366
400
  export GOBLIN_HARNESS_DIR=""
367
401
  export GOBLIN_HARNESS_REL="$HARNESS_DIR_RAW"
368
- # 'absent' = the class scaffolds a harness dir and the declared one is missing -> FAIL.
369
- # 'none' = the class ships no harness dir -> SKIP with a reason (D7).
402
+ # 'absent' = scaffold_checks is yes and the declared harness dir is missing -> FAIL.
403
+ # 'none' = scaffold_checks is no, so there is no harness dir to assert -> SKIP (D7).
370
404
  if [ "$SCAFFOLD_CHECKS" = "yes" ]; then
371
405
  export GOBLIN_HARNESS_STATE=absent
372
406
  else
@@ -393,24 +427,15 @@ export GOBLIN_CONFIG="$CONFIG"
393
427
  # reason, never a silent pass.
394
428
  SEC_GITIGNORE_FAMILY=$(g_agents_read "$CONFIG" security.gitignore_family)
395
429
  SEC_BUILD_OUTPUT=$(g_agents_read "$CONFIG" security.build_output)
396
- SEC_AUDIT_CMD=$(g_agents_read "$CONFIG" security.audit_cmd)
397
- SEC_AUDIT_MAX_AGE=$(g_agents_read "$CONFIG" security.audit_max_age_days)
398
- SEC_WAIVER_MAX_AGE=$(g_agents_read "$CONFIG" security.waiver_max_age_days)
399
430
  SEC_WRITE_ROUTES=$(g_agents_read "$CONFIG" security.write_routes)
400
- [ -n "$SEC_AUDIT_MAX_AGE" ] || SEC_AUDIT_MAX_AGE=90
401
- [ -n "$SEC_WAIVER_MAX_AGE" ] || SEC_WAIVER_MAX_AGE=180
402
431
  PERF_METRIC=$(g_agents_read "$CONFIG" perf.metric)
403
432
  PERF_CMD=$(g_agents_read "$CONFIG" perf.cmd)
404
433
  PERF_BASELINE_COMMIT=$(g_unquote "$(g_agents_read "$CONFIG" perf.baseline_commit)")
405
434
  PERF_BASELINE_VALUE=$(g_agents_read "$CONFIG" perf.baseline_value)
406
435
  PERF_MEASURED=$(g_unquote "$(g_agents_read "$CONFIG" perf.measured)")
407
436
  PERF_HOST_GATE=$(g_agents_read "$CONFIG" perf.host_gate)
408
- # The electron opt-in (software class): true means the electron ban set stays on regardless of a
409
- # hand-edited bans: list, and a perf host gate must be declared (PF-01). Absent on a repo
410
- # installed before the merge — read as off, so a legacy class-F repo verifies with no rewrite.
411
- ELECTRON=$(g_agents_read "$CONFIG" electron)
412
- export SEC_GITIGNORE_FAMILY SEC_BUILD_OUTPUT SEC_AUDIT_CMD SEC_AUDIT_MAX_AGE SEC_WAIVER_MAX_AGE
413
- export SEC_WRITE_ROUTES PERF_METRIC PERF_CMD PERF_BASELINE_VALUE PERF_HOST_GATE ELECTRON
437
+ export SEC_GITIGNORE_FAMILY SEC_BUILD_OUTPUT
438
+ export SEC_WRITE_ROUTES PERF_METRIC PERF_CMD PERF_BASELINE_VALUE PERF_HOST_GATE
414
439
 
415
440
  # Whole days between an ISO date and today, or empty when the date does not parse on this host
416
441
  # (`date -d` is GNU; the row FAILS rather than assuming, because an unreadable date is not a
@@ -438,7 +463,7 @@ only_selected() {
438
463
  return 1
439
464
  }
440
465
 
441
- # ---- part mapping: a row id's prefix names the class-controlled part ---------
466
+ # ---- part mapping: a row id's prefix names the part a row belongs to ---------
442
467
  row_part() {
443
468
  case "$1" in
444
469
  HP-*) echo handoff ;;
@@ -448,20 +473,17 @@ row_part() {
448
473
  HS-01|HS-03) echo gate ;;
449
474
  HS-02) echo replay ;;
450
475
  PG-*) echo pr-gate ;;
451
- # The automation rows and SK-04 ride the `playbooks` part: their artifacts are the shipped
452
- # skills and the automation producers, and --skills no disables that part. An unmapped
453
- # prefix returns "" and the row can never honour an opt-out (G3 section 4.3).
454
- AU-*) echo playbooks ;;
455
- SK-04) echo playbooks ;;
456
- # SK-01 rides the same part (W1 made it a builtin for the global-mode clause): with
457
- # --skills no there is no shipped skill to frontmatter-check, and a vacuous pass proves
458
- # nothing - the row honours the opt-out like its SK-02/SK-04 siblings.
459
- SK-01) echo playbooks ;;
460
- # SK-02 keys off the same part: with --skills no there are no installed skills to hash, and
461
- # the row used to FAIL there (measured at v0.2.0-dev: "32 passed, 1 failed ... SK-02 0
462
- # installed skill file(s) hashed"). An opt-out is the honest report; a FAIL on a repo that
463
- # opted out of skills is not.
464
- SK-02) echo playbooks ;;
476
+ # SK-04 rides the `skills` part: its artifact is the shipped skills, and an explicit
477
+ # --opt-out skills disables that part. The CORE tier (.gob/skills/) is vendored on
478
+ # every install (GAP-2), so the row runs by default and only an explicit opt-out skips it.
479
+ # (v3: the part was named `playbooks` for the manifest that indexed the cut skills; the
480
+ # rail follows its list — manifest/playbooks.tsv is gone.)
481
+ SK-04) echo skills ;;
482
+ # SK-01 rides the same part. The core tier gives it subjects on every install — it no
483
+ # longer has to skip on a default (no .hermes tier) repo.
484
+ SK-01) echo skills ;;
485
+ # SK-02 keys off the same part; it hashes the .gob/skills/ core tier too.
486
+ SK-02) echo skills ;;
465
487
  *) echo "" ;;
466
488
  esac
467
489
  }
@@ -484,7 +506,7 @@ check_in_01() {
484
506
  # IN-01 recovery line (review 1, scope 4): the record is corrupt or missing; name the two
485
507
  # restores. The matrix's remedy: line rides under the payload via g_fail.
486
508
  printf 'installed.json is absent or records no version\n'
487
- printf 'recover: gob install --upgrade, or git checkout -- .gob/installed.json\n'
509
+ printf 'recover: git checkout -- .gob/installed.json, or re-run npx @techgoblin/gobstack init --write to re-install\n'
488
510
  return 1
489
511
  }
490
512
 
@@ -550,10 +572,10 @@ check_in_04() {
550
572
  check_in_02() {
551
573
  # The W1 semantic split (§2.2). Clause 1 - the per-repo mode: hash every recorded file,
552
574
  # the practice pin rides along - is byte-for-byte what this row has always done, and a
553
- # fresh install of any class keeps it (installed.json carries no engine: block).
575
+ # fresh install keeps it (installed.json carries no engine: block).
554
576
  # Clause 2 - engine.mode=global with file entries remaining: hash what IS recorded;
555
- # an entry under the engine paths (.gob/bin, .gob/manifest, .gob/bans,
556
- # .gob/automations, .gob/roles.yaml) that is still present is hashed too
577
+ # an entry under the engine paths (.gob/bin, .gob/manifest, .gob/bans) that is
578
+ # still present is hashed too
557
579
  # (harmless), and one that is MISSING is not drift - the engine is no longer the repo's.
558
580
  # Clause 3 - global with no file entries: the declaration + practice pin only; never
559
581
  # FAIL for absence of install artifacts (a declaration-only repo is not born RED).
@@ -565,12 +587,12 @@ check_in_02() {
565
587
  [ -n "$p" ] || continue
566
588
  if [ "$ENGINE_MODE" = "global" ]; then
567
589
  case "$p" in
568
- .gob/bin/*|.gob/manifest/*|.gob/bans/*|.gob/automations/*|.gob/roles.yaml)
590
+ .gob/bin/*|.gob/manifest/*|.gob/bans/*|.gob/skills/*)
569
591
  [ -e "$ROOT/$p" ] || continue ;; # engine removed by design: not drift
570
592
  # W4a (§5.3/§5.2): the procedure tier is EMITTED per platform, not carried in the
571
593
  # repo - a recorded .hermes/skills/ file absent from disk is the tier living at its
572
594
  # emitted paths, not drift. A copy that IS present must still hash true (a stale or
573
- # hand-edited shadow is exactly what --unshadow/doctor exist to surface).
595
+ # hand-edited shadow is exactly what the drift check exists to surface).
574
596
  .hermes/skills/*)
575
597
  [ -e "$ROOT/$p" ] || continue ;;
576
598
  esac
@@ -607,9 +629,9 @@ check_in_02() {
607
629
  printf 'practice standard edited: %s\n recorded %s\n now %s\n' "$PRACTICE" "$PRACTICE_SHA" "$cur"
608
630
  # The remedy, in the place the operator actually meets the failure. The pin exists to
609
631
  # catch a SILENT edit, so re-pinning is a deliberate act: one explicit command, which
610
- # prints the old and new hash (docs/CONTRACTS.md, "An edited standard is not a dead end").
632
+ # prints the old and new hash (docs/GUIDE.md, "An edited standard is not a dead end").
611
633
  printf ' if the edit is yours and intended, re-pin it deliberately:\n'
612
- printf ' goblin-install --target %s --re-pin\n' "$ROOT"
634
+ printf ' goblin-install --target %s --re-pin # from the gobstack checkout/install tree\n' "$ROOT"
613
635
  bad=1; pin=" | practice EDITED"
614
636
  else
615
637
  pin=" | practice pin ok"
@@ -626,7 +648,7 @@ check_in_02() {
626
648
  # naming the drifted file the payload above reported. Sits between the row's own lines and
627
649
  # the summary; g_fail appends the matrix's remedy: line under the whole payload.
628
650
  if [ "$bad" -ne 0 ] && [ -n "$DRIFTED" ]; then
629
- printf 'recover: git checkout -- %s, or gob install --upgrade\n' "$DRIFTED"
651
+ printf 'recover: git checkout -- %s, or re-run npx @techgoblin/gobstack init --write to re-install\n' "$DRIFTED"
630
652
  fi
631
653
  [ "$bad" -eq 0 ]
632
654
  }
@@ -815,7 +837,7 @@ check_gt_05() {
815
837
  n=$(g_agents_read "$CONFIG" ratchet.name)
816
838
  c=$(g_agents_read "$CONFIG" ratchet.cmd)
817
839
  ceil=$(g_agents_read "$CONFIG" ratchet.ceiling)
818
- [ -n "$n" ] && [ -n "$c" ] || { printf 'no ratchet declared for this class - skipped\n'; return 3; }
840
+ [ -n "$n" ] && [ -n "$c" ] || { printf 'no ratchet declared - skipped\n'; return 3; }
819
841
  val=$( cd "$ROOT" && bash -c "$c" 2>/dev/null | tr -d '[:space:]' )
820
842
  case "$val" in ''|*[!0-9]*) printf 'ratchet cmd produced a non-number: %s\n' "$val"; return 1 ;; esac
821
843
  if [ -f "$ROOT/.gob/ratchet-last" ]; then prev=$(cat "$ROOT/.gob/ratchet-last"); fi
@@ -833,16 +855,16 @@ check_gt_05() {
833
855
  check_hs_01() {
834
856
  local d="$GOBLIN_HARNESS_DIR" f base asserting=0 reporting=0 bad=0
835
857
  if [ -z "$d" ]; then
836
- # A declared harness dir that is missing is a FAIL when the class scaffolds one; a class
837
- # that ships none skips with a reason. Keying the skip off the PATH let a one-line config
858
+ # A declared harness dir that is missing is a FAIL when scaffold_checks is yes; when it is
859
+ # no the row skips with a reason. Keying the skip off the PATH alone let a one-line config
838
860
  # edit switch both HS rows off (D7).
839
861
  if [ "$GOBLIN_HARNESS_STATE" = "absent" ]; then
840
- printf 'harness_dir %s is declared and class %s scaffolds it, but the directory is absent\n' \
841
- "$GOBLIN_HARNESS_REL" "$CLASS"
862
+ printf 'harness_dir %s is declared and scaffold_checks is yes, but the directory is absent\n' \
863
+ "$GOBLIN_HARNESS_REL"
842
864
  return 1
843
865
  fi
844
- printf 'no harness dir (%s absent, class %s scaffolds none) - nothing to assert\n' \
845
- "$GOBLIN_HARNESS_REL" "$CLASS"
866
+ printf 'no harness dir (%s absent, scaffold_checks is no) - nothing to assert\n' \
867
+ "$GOBLIN_HARNESS_REL"
846
868
  return 3
847
869
  fi
848
870
  for f in "$d"/*; do
@@ -891,8 +913,8 @@ check_hs_02() {
891
913
  d="$GOBLIN_HARNESS_DIR"
892
914
  if [ -z "$d" ]; then
893
915
  if [ "$GOBLIN_HARNESS_STATE" = "absent" ]; then
894
- printf 'harness_dir %s is declared and class %s scaffolds it, but the directory is absent\n' \
895
- "$GOBLIN_HARNESS_REL" "$CLASS"
916
+ printf 'harness_dir %s is declared and scaffold_checks is yes, but the directory is absent\n' \
917
+ "$GOBLIN_HARNESS_REL"
896
918
  return 1
897
919
  fi
898
920
  printf 'no harness dir to replay\n'; return 3
@@ -941,67 +963,6 @@ check_cm_03() {
941
963
  [ "$n" -le "$MAX_DIRTY" ]
942
964
  }
943
965
 
944
- resolve_role_models() {
945
- # prints "role<TAB>profile<TAB>provider<TAB>model<TAB>effort" for each lane of a role
946
- local role="$1" f="$SELF_DIR/../roles.yaml"
947
- [ -f "$f" ] || f="$ROOT/.gob/roles.yaml"
948
- local profiles
949
- profiles=$(g_yaml_block_scalar "$f" "role-$role" profiles)
950
- [ -n "$profiles" ] || profiles=$(g_yaml_block_scalar "$f" "$role" profiles)
951
- local p prov model eff
952
- for p in $(printf '%s' "$profiles" | tr -d '[]' | tr ',' ' '); do
953
- prov=$(g_models_field "$MODELS_FILE" "$p" provider)
954
- model=$(g_models_field "$MODELS_FILE" "$p" model)
955
- eff=$(g_models_field "$MODELS_FILE" "$p" effort)
956
- printf '%s\t%s\t%s\t%s\t%s\n' "$role" "$p" "${prov:-?}" "${model:-?}" "${eff:-?}"
957
- done
958
- }
959
-
960
- check_md_02() {
961
- local code_line panel_line judge_line code_fam panel_fam judge_fam
962
- if [ ! -f "$MODELS_FILE" ]; then
963
- printf 'no model mapping configured (%s absent) - advisory\n' "$MODELS_FILE"
964
- return 2
965
- fi
966
- code_line=$(resolve_role_models code | head -n 1)
967
- panel_line=$(resolve_role_models review-panel | head -n 1)
968
- judge_line=$(resolve_role_models judge | head -n 1)
969
- code_fam=$(printf '%s' "$code_line" | cut -f4)
970
- panel_fam=$(printf '%s' "$panel_line" | cut -f4)
971
- judge_fam=$(printf '%s' "$judge_line" | cut -f4)
972
- if [ -z "$code_line" ] || [ -z "$panel_line" ]; then
973
- printf 'roles.yaml did not resolve both lanes - advisory\n'
974
- return 2
975
- fi
976
- if [ "$code_fam" = "$panel_fam" ]; then
977
- printf 'code lane and review lane both resolve to %s (same family) - goblin-stack cannot change this\n' "$code_fam"
978
- else
979
- printf 'code lane %s, review lane %s - different family\n' "$code_fam" "$panel_fam"
980
- fi
981
- # W5-6: the JUDGE lane's family is compared too. JG-02 proves the declared profile NAMES are
982
- # disjoint and nothing more, so a `judge:` profile mapped to the author's own model passed it:
983
- # the judge was distinct by name only, which is exactly what the judge role's claim cannot
984
- # tolerate. The comparison is the same one the panel gets, and the row stays ADVISORY (`return
985
- # 2`): goblin-stack cannot choose the fleet's models, it can only make the state loud. Measured
986
- # on this box, every profile the mapping names resolves to ONE model - recorded, not faked, in
987
- # docs/LIMITS.md #38.
988
- if [ -z "$judge_line" ]; then
989
- printf 'the judge lane does not resolve - add a `judge:` entry beside the code lane in %s\n' "$MODELS_FILE"
990
- return 2
991
- fi
992
- case "$judge_fam" in
993
- ''|'?'|unknown)
994
- printf 'the judge lane resolves to no model in %s - add a `judge:` entry beside the code lane\n' "$MODELS_FILE"
995
- return 2 ;;
996
- esac
997
- if [ "$judge_fam" = "$code_fam" ]; then
998
- printf 'the judge lane resolves to %s, the SAME family as the code lane - JG-02 proves only that the declared profile names differ\n' "$judge_fam"
999
- else
1000
- printf 'judge lane %s, code lane %s - different family\n' "$judge_fam" "$code_fam"
1001
- fi
1002
- return 2
1003
- }
1004
-
1005
966
  check_pg_01() {
1006
967
  local f head n=0 bad=0
1007
968
  for f in "$ROOT"/reviews/*.md; do
@@ -1069,142 +1030,6 @@ check_pg_03() {
1069
1030
  [ "$bad" -eq 0 ]
1070
1031
  }
1071
1032
 
1072
- check_pg_05() {
1073
- # PG-05 - "No required check that self-skips". The old body counted only "every step is
1074
- # guarded", so the REAL shape passed: in the estate's one existing workflow a deliberately
1075
- # UNGUARDED credential step decides whether the guarded compile step runs, so
1076
- # `guarded < steps` and the
1077
- # row reported PASS on the workflow it exists to catch (G8 section 3, re-measured V3-4). G6
1078
- # section A.6 named the mechanisable tell - a job whose GATE STEP is conditional can reach its
1079
- # end without running the gate while the required check still reports Success - so the row now
1080
- # carries three clauses per job:
1081
- # (a) the job declares at least one run:/uses: step (otherwise the check runs nothing);
1082
- # (b) the JOB carries no `if:` (otherwise the whole required check self-skips);
1083
- # (c) no STEP carries an `if:` (otherwise that step - possibly the gate step - self-skips,
1084
- # and GitHub reports a skipped job as Success: docs S1/S2, RISKS.md K7).
1085
- # It is a TEXT reading, deliberately strict, and says so in its own why-cell: a `#` inside a
1086
- # quoted string is read as a comment, a flow-style `jobs:` mapping is refused rather than read
1087
- # as clean, and a condition that is genuinely needed belongs in the command or in a second
1088
- # job that is not the required check.
1089
- local f n=0 bad=0
1090
- for f in "$ROOT"/.github/workflows/*.yml "$ROOT"/.github/workflows/*.yaml; do
1091
- [ -e "$f" ] || continue
1092
- n=$((n + 1))
1093
- awk -v FILE="$(basename "$f")" '
1094
- function closejob() {
1095
- if (jobname == "") return
1096
- if (steps == 0) { printf "%s: job \"%s\" declares no run:/uses: step - the required check runs nothing and still reports Success\n", FILE, jobname; bad = 1 }
1097
- if (jobif > 0) { printf "%s: job \"%s\" carries a job-level if: (%d) - the whole required check self-skips and reports Success\n", FILE, jobname, jobif; bad = 1 }
1098
- if (stepif > 0) { printf "%s: job \"%s\" has %d conditional step(s) - a skipped step reports Success, and a skipped gate step green-lights a commit whose gate never ran\n", FILE, jobname, stepif; bad = 1 }
1099
- jobname = ""
1100
- }
1101
- {
1102
- line = $0
1103
- sub(/[ \t]+#.*$/, "", line) # blank a trailing comment
1104
- if (line ~ /^[ \t]*#/) next
1105
- if (line ~ /^[ \t]*$/) next
1106
- if (!injobs) {
1107
- if (line ~ /^jobs:[ \t]*$/) { injobs = 1; jind = -1 }
1108
- else if (line ~ /^jobs:[ \t]*[^ \t]/) { printf "%s: the jobs: block is a flow mapping - it cannot be read here, so it is refused rather than read as clean\n", FILE; bad = 1; injobs = 1; jind = -1 }
1109
- next
1110
- }
1111
- lead = match(line, /[^ \t]/) - 1
1112
- if (jind >= 0 && lead == jind && line !~ /^[ \t]*-/) {
1113
- closejob()
1114
- jobname = line; sub(/^[ \t]*/, "", jobname); sub(/[ \t]*:.*/, "", jobname)
1115
- steps = 0; stepregion = 0; jobif = 0; stepif = 0
1116
- next
1117
- }
1118
- if (jind < 0) {
1119
- jind = lead
1120
- jobname = line; sub(/^[ \t]*/, "", jobname); sub(/[ \t]*:.*/, "", jobname)
1121
- steps = 0; stepregion = 0; jobif = 0; stepif = 0
1122
- next
1123
- }
1124
- if (lead <= jind) next
1125
- if (line ~ /^[ \t]*-/) stepregion = 1
1126
- if (line ~ /(^|[ \t-])(run|uses):/) { steps++; next }
1127
- if (line ~ /^[ \t]*-?[ \t]*if:/) { if (stepregion) stepif++; else jobif++ }
1128
- }
1129
- END {
1130
- closejob()
1131
- if (!injobs) { printf "%s: no jobs: block - the workflow declares no check at all\n", FILE; bad = 1 }
1132
- exit bad
1133
- }
1134
- ' "$f" || bad=1
1135
- done
1136
- if [ "$n" -eq 0 ]; then
1137
- printf '0 workflow file(s) - no required check here to skip (vacuous by design: nothing declares one)\n'
1138
- else
1139
- printf '%d workflow file(s) checked for a self-skipping required check\n' "$n"
1140
- fi
1141
- [ "$bad" -eq 0 ]
1142
- }
1143
-
1144
- check_pg_06() {
1145
- # PG-06 (G6 section A.6, row 2) - "The gate CI runs is the gate the project declares." The
1146
- # failure mode is R5 section 1.1 measured: review and CI and goblin-verify reporting different
1147
- # truths about one SHA, so a green required check says nothing about the gate the project
1148
- # actually declares. The declared set comes from g_agents_gates - GT-01's own reader, reused
1149
- # rather than re-derived, so a gate cannot vanish from the comparison in silence (G8-3).
1150
- # A workflow satisfies the row when the whole declared set is RUN: either the verifier with no
1151
- # `--only` (a full run executes every declared gate through GT-02), or each declared gate
1152
- # command appearing verbatim. Comments are blanked first, so a commented-out verifier call is
1153
- # not a run, and key lines other than `run:` are dropped, so a command sitting in a `name:`
1154
- # cannot satisfy it. Partial by construction: it proves the gate is INVOKED in a file under
1155
- # `.github/workflows/`, never that GitHub marks that job required, and never that the invoker
1156
- # is the job the forge waits on.
1157
- local f n=0 bad=0 gname gcmd ngates=0 gates="" runtext miss="" nrun nc
1158
- while IFS=$'\t' read -r gname gcmd; do
1159
- [ -n "$gname" ] || continue
1160
- ngates=$((ngates + 1))
1161
- [ -n "$gcmd" ] && gates="$gates$gcmd"$'\n'
1162
- done < <(g_agents_gates "$CONFIG")
1163
- for f in "$ROOT"/.github/workflows/*.yml "$ROOT"/.github/workflows/*.yaml; do
1164
- [ -e "$f" ] || continue
1165
- n=$((n + 1))
1166
- runtext=$(awk '
1167
- {
1168
- line = $0
1169
- sub(/[ \t]+#.*$/, "", line)
1170
- if (line ~ /^[ \t]*#/) next
1171
- if (line ~ /^[ \t]*$/) next
1172
- if (line ~ /^[ \t]*-?[ \t]*run:/) { print substr(line, index(line, "run:") + 4); next }
1173
- if (line ~ /^[ \t]*-?[ \t]*[A-Za-z_][A-Za-z0-9_.-]*:/) next
1174
- print line
1175
- }
1176
- ' "$f")
1177
- if printf '%s\n' "$runtext" | grep -q 'goblin-verify' \
1178
- && ! printf '%s\n' "$runtext" | grep -q 'goblin-verify[^&|;]*--only'; then
1179
- printf '%s: runs the verifier, which executes every declared gate\n' "$(basename "$f")"
1180
- continue
1181
- fi
1182
- # The verbatim path: compare on whitespace-normalised text, so a YAML line wrap or a dropped
1183
- # `2>/dev/null` does not read as "not the declared gate".
1184
- nrun=$(printf '%s\n' "$runtext" | tr '\n' ' ' | sed 's#2>/dev/null##g' | tr -s ' ')
1185
- miss=""
1186
- while IFS= read -r gcmd; do
1187
- [ -n "$gcmd" ] || continue
1188
- nc=$(printf '%s' "$gcmd" | sed 's#2>/dev/null##g' | tr -s ' ')
1189
- printf '%s' "$nrun" | grep -qF -- "$nc" || miss="$miss [$gcmd]"
1190
- done <<EOF
1191
- $gates
1192
- EOF
1193
- if [ -n "$miss" ]; then
1194
- printf '%s: runs no gate the project declares - declared but not run:%s\n' "$(basename "$f")" "$miss"
1195
- bad=1
1196
- else
1197
- printf '%s: runs all %d declared gate(s) verbatim\n' "$(basename "$f")" "$ngates"
1198
- fi
1199
- done
1200
- if [ "$n" -eq 0 ]; then
1201
- printf 'no workflow file to check - CI runs no gate here\n'
1202
- return 3
1203
- fi
1204
- printf '%d workflow file(s) compared with the %d declared gate(s)\n' "$n" "$ngates"
1205
- [ "$bad" -eq 0 ]
1206
- }
1207
-
1208
1033
  hash_runtime_data() {
1209
1034
  local p h out=""
1210
1035
  while read -r p; do
@@ -1253,60 +1078,6 @@ check_ds_02() {
1253
1078
  return 0
1254
1079
  }
1255
1080
 
1256
- check_au_02() {
1257
- # The dedup key must be a function of the report's CONTENT only. Recompute it from the
1258
- # report's own repo+symptom and require the recorded value to equal it: a key derived from a
1259
- # date, a run id or a counter dedups nothing, and this is the row that says so.
1260
- local f n=0 bad=0 repo sym key want norm slug
1261
- for f in "$ROOT"/reports/*/report.yaml; do
1262
- [ -e "$f" ] || continue
1263
- n=$((n + 1))
1264
- slug=$(basename "$(dirname "$f")")
1265
- repo=$(sed -n 's/^repo:[[:space:]]*//p' "$f" | head -n 1)
1266
- sym=$(sed -n 's/^symptom:[[:space:]]*//p' "$f" | head -n 1)
1267
- key=$(sed -n 's/^dedup_key:[[:space:]]*//p' "$f" | head -n 1)
1268
- norm=$(printf '%s' "$sym" | tr 'A-Z' 'a-z' | tr -s '[:space:]' ' ' | sed 's/^ //; s/ $//')
1269
- want="bug:${repo}:$(g_sha256_text "$norm" | cut -c1-12)"
1270
- case "$key" in
1271
- '') printf '%s: no dedup_key recorded\n' "$slug"; bad=1; continue ;;
1272
- esac
1273
- if [ "$key" != "$want" ]; then
1274
- printf '%s: recorded key %s, recomputed %s\n' "$slug" "$key" "$want"; bad=1
1275
- fi
1276
- if printf '%s' "$key" | grep -qE '[0-9]{4}-[0-9]{2}-[0-9]{2}'; then
1277
- printf '%s: the key carries a date: %s\n' "$slug" "$key"; bad=1
1278
- fi
1279
- done
1280
- [ "$n" -gt 0 ] || { printf 'no reports/*/report.yaml - nothing to dedup\n'; return 3; }
1281
- printf '%d report(s): the key is content-only\n' "$n"
1282
- [ "$bad" -eq 0 ]
1283
- }
1284
-
1285
- check_au_03() {
1286
- # A reporter's write surface is reports/** plus cards. Two falsifiable clauses: the tree is
1287
- # clean, and - when HEAD is a reporter commit - no path under the declared harness dir is in
1288
- # it. The harness clause only applies to a commit that touches reports/, so a normal round's
1289
- # commit is not mistaken for a reporter's.
1290
- local dirty bad=0 touched=""
1291
- [ -d "$ROOT/reports" ] || { printf 'no reports/ - no reporter run in this repo to audit\n'; return 3; }
1292
- dirty=$(cd "$ROOT" && git status --porcelain 2>/dev/null | wc -l | tr -d '[:space:]')
1293
- printf '%s dirty entr(y|ies), max_dirty %s\n' "$dirty" "$MAX_DIRTY"
1294
- if ( cd "$ROOT" && git rev-parse --verify --quiet HEAD~1 >/dev/null 2>&1 ); then
1295
- if ( cd "$ROOT" && git diff --name-only HEAD~1..HEAD 2>/dev/null | grep -q '^reports/' ); then
1296
- touched=$( cd "$ROOT" && git diff --name-only HEAD~1..HEAD 2>/dev/null \
1297
- | grep "^${GOBLIN_HARNESS_REL}/" || true )
1298
- else
1299
- printf 'HEAD is not a reporter commit - the harness clause does not apply\n'
1300
- fi
1301
- fi
1302
- if [ -n "$touched" ]; then
1303
- printf 'the reporter commit touched the harness: %s\n' "$(printf '%s' "$touched" | tr '\n' ' ')"
1304
- bad=1
1305
- fi
1306
- [ "$dirty" -le "$MAX_DIRTY" ] || { printf 'the reporter left the tree dirty\n'; bad=1; }
1307
- [ "$bad" -eq 0 ]
1308
- }
1309
-
1310
1081
  check_sc_02() {
1311
1082
  # Clause 1 is a file rule; clause 2 is BEHAVIOURAL - it asks git's own matcher, so an ignore
1312
1083
  # rule that looks right but does not match still fails. `git check-ignore -q` accepts exactly
@@ -1450,161 +1221,13 @@ check_in_03() {
1450
1221
  return 1
1451
1222
  }
1452
1223
 
1453
- check_sc_07() {
1454
- # Offline by construction: the record is written by .gob/bin/goblin-audit, run ONCE,
1455
- # deliberately. A verify-time network call would break the offline dependency contract
1456
- # (docs/RISKS.md K4). The record and the waiver table are repo-local by design (W1 §2.5);
1457
- # only the SKIP remedy names the runner, and global mode names the CLI verb - the record
1458
- # is the repo's, the tool that produced it is wherever the engine resolves (chain §2.3).
1459
- [ -n "$SEC_AUDIT_CMD" ] || { printf 'this class declares no audit command (security.audit_cmd is empty)\n'; return 3; }
1460
- local rec="$ROOT/.gob/audit.tsv" wfile="$ROOT/.gob/audit-waiver.tsv"
1461
- if [ ! -f "$rec" ]; then
1462
- if [ "$ENGINE_MODE" = "global" ]; then
1463
- printf 'no audit record yet. Run `gob audit` once, deliberately, then commit\n.gob/audit.tsv: SC-07 reads the record and never the network\n'
1464
- else
1465
- printf 'no audit record yet. Run .gob/bin/goblin-audit once, deliberately, then commit\n.gob/audit.tsv: SC-07 reads the record and never the network\n'
1466
- fi
1467
- return 3
1468
- fi
1469
- local d age lines=0 waivers=0 pkg sev id bad=0 wl wd
1470
- d=$(sed -n 's/^measured[[:space:]]*//p' "$rec" | head -n 1)
1471
- if [ -z "$d" ]; then printf 'the audit record carries no `measured` date\n'; return 1; fi
1472
- age=$(age_days "$d") || { printf 'the recorded date does not parse on this host: %s\n' "$d"; return 1; }
1473
- if [ "$age" -gt "$SEC_AUDIT_MAX_AGE" ]; then
1474
- printf 'the audit record is %s days old (max %s): run goblin-audit again\n' "$age" "$SEC_AUDIT_MAX_AGE"
1475
- bad=1
1476
- fi
1477
- while IFS=$'\t' read -r pkg sev id rest; do
1478
- [ -n "$pkg" ] || continue
1479
- case "$pkg" in \#*) continue ;; esac
1480
- case "$sev" in high|critical) : ;; *) continue ;; esac
1481
- lines=$((lines + 1))
1482
- wl=""
1483
- if [ -f "$wfile" ]; then
1484
- wl=$(awk -F'\t' -v p="$pkg" -v i="$id" '$1==p && ($3==i || $3=="*") { print $4; exit }' "$wfile")
1485
- fi
1486
- if [ -z "$wl" ]; then
1487
- printf 'unwaived %s advisory: %s %s\n' "$sev" "$pkg" "$id"; bad=1; continue
1488
- fi
1489
- waivers=$((waivers + 1))
1490
- wd=$(age_days "$wl") || { printf 'the waiver for %s carries an unparseable date: %s\n' "$pkg" "$wl"; bad=1; continue; }
1491
- [ "$wd" -le "$SEC_WAIVER_MAX_AGE" ] \
1492
- || { printf 'the waiver for %s is %s days old (max %s): re-decide it\n' "$pkg" "$wd" "$SEC_WAIVER_MAX_AGE"; bad=1; }
1493
- done < "$rec"
1494
- printf 'audit measured %s (%s days old): %s high|critical line(s), %s matched waiver(s), %s unwaived\n' \
1495
- "$d" "$age" "$lines" "$waivers" "$((lines - waivers))"
1496
- [ "$bad" -eq 0 ]
1497
- }
1498
-
1499
- check_sc_08() {
1500
- # An install hook is arbitrary code that runs on every `npm ci`. Only npm's lockfile records
1501
- # it (`hasInstallScript`); pnpm/yarn do not, so the row SKIPs with that reason rather than
1502
- # passing vacuously.
1503
- local lock="$ROOT/package-lock.json"
1504
- if [ ! -f "$lock" ]; then
1505
- if [ -f "$ROOT/pnpm-lock.yaml" ] || [ -f "$ROOT/yarn.lock" ]; then
1506
- printf 'a pnpm/yarn lockfile carries no hasInstallScript field - nothing to enumerate\n'; return 3
1507
- fi
1508
- printf 'no package-lock.json - there is no install-hook surface to enumerate\n'; return 3
1509
- fi
1510
- local pkgs n=0 ok=0 bad=0 p
1511
- # Z2-2: this reader is line-anchored, so a MINIFIED (one-line) lockfile - valid JSON, and what a
1512
- # tool that writes without pretty-printing leaves behind - matched NOTHING and the row printed
1513
- # `0 install hook(s), 0 allowlisted` as a PASS, exit 0. That is a vacuous PASS: the exact defect
1514
- # family (D6/PR-03) this harness exists to prevent, and the one shape the pnpm/yarn branch above
1515
- # already reports honestly. The text is normalised into the pretty shape first - break after
1516
- # every `{`, `}` and `,` - which is a TEXT transform, not a JSON parse: no npm, no jq, no parser
1517
- # (docs/CONTRACTS.md). The anchor accepts `": {` (what npm writes) and `":{` (minified), and the
1518
- # per-line state machine still attributes `hasInstallScript` to the key line it followed.
1519
- pkgs=$(awk '
1520
- {
1521
- gsub(/\{/, "{\n"); gsub(/\}/, "}\n"); gsub(/,/, ",\n")
1522
- n = split($0, L, "\n")
1523
- for (i = 1; i <= n; i++) {
1524
- s = L[i]
1525
- if (s ~ /^[[:space:]]*"node_modules\/[^"]+":[[:space:]]*\{/) {
1526
- k = s; sub(/^[[:space:]]*"/, "", k); sub(/":[[:space:]]*\{.*/, "", k); sub(/^node_modules\//, "", k)
1527
- }
1528
- if (s ~ /"hasInstallScript"[[:space:]]*:[[:space:]]*true/ && k != "") print k
1529
- }
1530
- }
1531
- ' "$lock" | sort -u)
1532
- for p in $pkgs; do
1533
- n=$((n + 1))
1534
- if [ -f "$ROOT/.gob/install-hooks.allowlist" ] \
1535
- && grep -qxF "$p" "$ROOT/.gob/install-hooks.allowlist"; then
1536
- ok=$((ok + 1))
1537
- else
1538
- printf 'an install-time script is not on the allowlist: %s\n' "$p"; bad=1
1539
- fi
1540
- done
1541
- printf '%s install hook(s), %s allowlisted\n' "$n" "$ok"
1542
- [ "$bad" -eq 0 ]
1543
- }
1544
-
1545
1224
  # ---- W1 §2.5, the SK/automation split ----------------------------------------
1546
- # In global mode the procedure tier (skills, the automation producers) is served from the
1225
+ # In global mode the procedure tier (skills) is served from the
1547
1226
  # engine, not emitted in the repo - emission is W4's. Hashing a global copy from a repo's
1548
1227
  # verify would make one machine's skill set answer for every repo, so the per-repo rows
1549
1228
  # SKIP with that reason instead of FAILing on the absent copies. SK-03 runs unchanged:
1550
1229
  # it reads the manifest, which resolves via the chain either way.
1551
1230
 
1552
- # au01_producer_count — the producers an AU-01 run can see, engine-first in global mode.
1553
- # In global mode the first glob resolves under the engine dir (chain §2.3); the repo-local
1554
- # globs stay. In vendored mode this is exactly today's three globs.
1555
- au01_globs() {
1556
- if [ "$ENGINE_MODE" = "global" ]; then
1557
- printf '%s\n' "$GOBLIN_ENGINE/automations/*.sh" "$ROOT/automations/*.sh" "$ROOT/automations/*/*.sh"
1558
- else
1559
- printf '%s\n' "$ROOT/.gob/automations/*.sh" "$ROOT/automations/*.sh" "$ROOT/automations/*/*.sh"
1560
- fi
1561
- }
1562
-
1563
- check_au_01() {
1564
- # One control loop over the producer globs. The new clause (W1 §2.5, Q2's narrow form):
1565
- # a repo that declares NO automations and has no producer anywhere SKIPs with the reason
1566
- # - the measured M9 FAIL was a born-RED artifact of the glob, and a repo that never
1567
- # adopted automations must not be failed for it. A repo that DECLARES automations (its
1568
- # own, repo-local) but has no producer still FAILs: the SKIP is only for repos that
1569
- # declare none.
1570
- local f n=0 own=0 glob
1571
- # The repo's OWN producers: anything under a root automations/ directory (the engine's
1572
- # payload lives under .gob/automations/ in vendored mode, engine_dir in global mode;
1573
- # neither is a declaration by this repo).
1574
- for f in "$ROOT"/automations/*.sh "$ROOT"/automations/*/*.sh; do
1575
- [ -e "$f" ] || continue
1576
- own=$((own + 1))
1577
- done
1578
- while IFS= read -r glob; do
1579
- for f in $glob; do
1580
- [ -e "$f" ] || continue
1581
- n=$((n + 1))
1582
- if grep -nE "^[[:space:]]*(curl|wget|gh[[:space:]]|npm[[:space:]]|npx[[:space:]])" "$f" >/dev/null 2>&1; then
1583
- printf 'a network or forge verb opens a line of the producer:\n'
1584
- grep -nE "^[[:space:]]*(curl|wget|gh[[:space:]]|npm[[:space:]]|npx[[:space:]])" "$f"
1585
- return 1
1586
- fi
1587
- done
1588
- done < <(au01_globs)
1589
- # The declaration clause: a root automations/ directory that holds NO .sh producer is
1590
- # a declaration whose producer is gone (the files were deleted, not never written).
1591
- local declared=0
1592
- for f in "$ROOT"/automations/* "$ROOT"/automations/*/; do
1593
- [ -e "$f" ] || continue
1594
- declared=1
1595
- done
1596
- if [ "$declared" -eq 1 ] && [ "$own" -eq 0 ]; then
1597
- printf 'automations are declared but no producer exists - the producer is gone\n'
1598
- return 1
1599
- fi
1600
- if [ "$n" -eq 0 ]; then
1601
- printf 'no automation producer found (repo or engine)\n'
1602
- return 3
1603
- fi
1604
- printf '%d automation producer(s) scanned, none opens with a network or forge verb\n' "$n"
1605
- return 0
1606
- }
1607
-
1608
1231
  check_bn_00() {
1609
1232
  # The coherence row: the ban table and the matrix must agree in BOTH directions, every ban
1610
1233
  # must name a replacement, and the table must not be empty. IN-03's shape applied to
@@ -1645,7 +1268,7 @@ check_bn_run() {
1645
1268
  # closed (the engine's own exit 2 = the table is missing/empty, which is not a pass).
1646
1269
  # W1 §2.5: the engine is <resolved engine>/bin/goblin-bans (chain §2.3). The hard-FAIL
1647
1270
  # stays for the vendored mode; in global mode the engine's own existence was already
1648
- # checked at resolution (§1.2 item 4), so an absent ban engine is exit-2-class, but it
1271
+ # checked at resolution (§1.2 item 4), so an absent ban engine is a config error, but it
1649
1272
  # is still reported FAIL-closed here rather than silently skipped - the ban lane must
1650
1273
  # never read clean because a binary went missing.
1651
1274
  local id="$1" engine out rc detail
@@ -1684,15 +1307,8 @@ check_pf_01() {
1684
1307
  # to ignore it.
1685
1308
  local rname bad=0
1686
1309
  rname=$(g_agents_read "$CONFIG" ratchet.name)
1687
- # The electron opt-in's done-definition: an Electron repo declares its host gate (the FPS /
1688
- # main_thread_busy_pct number a hermetic rule cannot measure). `electron: true` with no host
1689
- # gate is a repo missing half its definition — FAIL, before the baseline skip below can mask it.
1690
- if [ "$ELECTRON" = "true" ] && [ -z "$PERF_HOST_GATE" ]; then
1691
- printf 'electron: true requires a declared perf.host_gate — declare the host-gate probe (the number no hermetic rule can measure) or drop electron: true\n'
1692
- return 1
1693
- fi
1694
1310
  [ -n "$PERF_METRIC" ] || {
1695
- printf 'this class declares no perf metric (perf.metric is empty). The ratchet still carries\n%s; declare metric/cmd here the day you pick one\n' "${rname:-nothing}"
1311
+ printf 'no perf metric is declared (perf.metric is empty). The ratchet still carries\n%s; declare metric/cmd here the day you pick one\n' "${rname:-nothing}"
1696
1312
  return 3
1697
1313
  }
1698
1314
  [ -n "$PERF_BASELINE_COMMIT" ] || {
@@ -1751,7 +1367,7 @@ sk_proc_skip() {
1751
1367
  # without it, a global repo with no skills passes the loop vacuously — a green that proves
1752
1368
  # nothing, exactly the shape §2.5 exists to kill).
1753
1369
  sk01_cell() {
1754
- n=0; for f in .hermes/skills/*/SKILL.md; do [ -e "$f" ] || continue; n=$((n+1)); head -n 1 "$f" | grep -qx -- '---' || exit 1; awk 'NR==1{next} /^---/{exit} /^name:/{a=1} /^description:/{b=1} END{exit !(a&&b)}' "$f" || exit 1; done; [ "$n" -gt 0 ] || { echo "no installed skill found"; exit 1; }; exit 0
1370
+ n=0; for f in .gob/skills/*/SKILL.md .hermes/skills/*/SKILL.md; do [ -e "$f" ] || continue; n=$((n+1)); head -n 1 "$f" | grep -qx -- '---' || exit 1; awk 'NR==1{next} /^---/{exit} /^name:/{a=1} /^description:/{b=1} END{exit !(a&&b)}' "$f" || exit 1; done; [ "$n" -gt 0 ] || { echo "no installed skill found"; exit 1; }; exit 0
1755
1371
  }
1756
1372
 
1757
1373
  check_sk_01() {
@@ -1762,7 +1378,7 @@ check_sk_01() {
1762
1378
  # sk04_cell — SK-04's original check cell. Kept verbatim so the row's declared text and
1763
1379
  # its executed behaviour stay the same thing; the builtin only adds the mode clause.
1764
1380
  sk04_cell() {
1765
- n=0; for f in .hermes/skills/*/SKILL.md; do [ -e "$f" ] || continue; n=$((n+1)); grep -q "^## What this cannot see" "$f" || { echo "missing cannot-see section: $f"; exit 1; }; done; [ "$n" -gt 0 ] || { echo "no installed skill found"; exit 1; }; exit 0
1381
+ n=0; for f in .gob/skills/*/SKILL.md .hermes/skills/*/SKILL.md; do [ -e "$f" ] || continue; n=$((n+1)); grep -q "^## What this cannot see" "$f" || { echo "missing cannot-see section: $f"; exit 1; }; done; [ "$n" -gt 0 ] || { echo "no installed skill found"; exit 1; }; exit 0
1766
1382
  }
1767
1383
 
1768
1384
  check_sk_04() {
@@ -1770,22 +1386,11 @@ check_sk_04() {
1770
1386
  ( cd "$ROOT" && sk04_cell )
1771
1387
  }
1772
1388
 
1773
- # au04_cell — AU-04's original check cell (the installed automation skills carry a
1774
- # `## Write surface` section); the builtin only adds the mode clause.
1775
- au04_cell() {
1776
- n=0; for f in .hermes/skills/goblin-bugreporter/SKILL.md .hermes/skills/goblin-drift-audit/SKILL.md; do [ -e "$f" ] || continue; n=$((n+1)); grep -q "^## Write surface" "$f" || { echo "missing write surface: $f"; exit 1; }; done; [ "$n" -gt 0 ] || { echo "no automation skill found"; exit 1; }; exit 0
1777
- }
1778
-
1779
- check_au_04() {
1780
- sk_proc_skip && return 3
1781
- ( cd "$ROOT" && au04_cell )
1782
- }
1783
-
1784
1389
  check_sk_02() {
1785
1390
  sk_proc_skip && return 3
1786
1391
  local p h cur n=0 bad=0
1787
1392
  while IFS=$'\t' read -r p h; do
1788
- case "$p" in .hermes/skills/*) ;; *) continue ;; esac
1393
+ case "$p" in .gob/skills/*|.hermes/skills/*) ;; *) continue ;; esac
1789
1394
  n=$((n + 1))
1790
1395
  cur=$(g_sha256_file "$ROOT/$p")
1791
1396
  [ "$cur" = "$h" ] || { printf 'skill drift: %s\n' "$p"; bad=1; }
@@ -1804,11 +1409,11 @@ check_sk_03() {
1804
1409
  ''|*[!0-9]*) printf 'advisory_ceiling is not a number: %s\n' "${ADV_CEILING:-<empty>}"; return 1 ;;
1805
1410
  esac
1806
1411
  # Count what the run counts: a row is advisory if its check column says so OR its enforced_by
1807
- # does (MD-02 is advisory-labelled but its check column holds a builtin marker). Counting only
1412
+ # does (an advisory-labelled row can carry a builtin marker in its check column). Counting only
1808
1413
  # the literal column printed 7 while the summary printed 8 (D13).
1809
- k=$(awk -F'\t' 'NR>1 && ($4=="advisory" || $6=="advisory") {n++} END{print n+0}' "$MANIFEST")
1414
+ k=$(awk -F'\t' 'NR>1 && ($4=="advisory" || $6=="advisory") {n++} END{print n+0}' "${RUN_MANIFEST:-$MANIFEST}")
1810
1415
  # The REMAINING BUDGET is reported, not implied: the ceiling is the one scarce resource a rule
1811
- # author spends, and two cards (G1's FM-03, G2's JG-03) each wanted the last slot. A count with
1416
+ # author spends. A count with
1812
1417
  # no arithmetic leaves the next author to work it out (G8-5).
1813
1418
  free=$((ADV_CEILING - k))
1814
1419
  plural=""; [ "$free" -eq 1 ] || plural="s"
@@ -1822,113 +1427,11 @@ check_sk_03() {
1822
1427
  [ "$k" -le "$ADV_CEILING" ]
1823
1428
  }
1824
1429
 
1825
- check_pt_02() {
1826
- local cur
1827
- cur=$(cd "$ROOT" && git rev-parse --abbrev-ref HEAD 2>/dev/null)
1828
- printf 'declared %s, actual %s\n' "$BRANCH" "$cur"
1829
- if [ "$cur" != "$BRANCH" ]; then
1830
- printf 'fix: set branch: %s in %s, or check out %s\n' "$cur" "$CONFIG" "$BRANCH"
1831
- return 1
1832
- fi
1833
- return 0
1834
- }
1835
-
1836
- class_part_artifact() {
1837
- # prints 0 (present) or 1 (absent) for the part's artifact
1838
- case "$1" in
1839
- handoff) [ -f "$ROOT/HANDOFF.md" ] ;;
1840
- spec) ls "$ROOT"/*-SPEC.md >/dev/null 2>&1 ;;
1841
- gate) [ "$(g_agents_gates "$CONFIG" | grep -c . || true)" -ge 1 ] ;;
1842
- replay) [ -n "$(g_agents_read "$CONFIG" replay.env)" ] && [ -n "$(g_agents_read "$CONFIG" replay.cmd)" ] ;;
1843
- ratchet) [ -n "$(g_agents_read "$CONFIG" ratchet.name)" ] ;;
1844
- pr-gate) [ -d "$ROOT/reviews" ] ;;
1845
- review-panel) [ -d "$ROOT/reviews" ] ;;
1846
- # The W4a re-point (W4A-SPEC §5.3): the artifact test accepts the goblin-mode skill
1847
- # at ANY path in the W4a emitted set, or a record in the emissions ledger. The old
1848
- # probe hardcoded the Hermes project path and FAILed the first emitted-only repo
1849
- # (declaration + emit, no goblin-install). Rule text, class table and enforced_by
1850
- # are untouched - this is the W1 §2.5 re-point precedent.
1851
- playbooks)
1852
- # The first platform's dir name is ASSEMBLED at run time from fragments (the MD_SLUG
1853
- # precedent in tests/run-tests.sh): the tool's own name, literal or inside a variable's
1854
- # name, would trip MD-01's pattern in every vendored copy of this file. W4b added the
1855
- # four remaining platforms' emitted roots; the last one's dir name is assembled too.
1856
- # The global-scope probes are gated on GOBLIN_GLOBAL=1: a global path under the real
1857
- # $HOME is not evidence about THIS repo, and letting it count made the T6 RED control
1858
- # pass vacuously on any machine whose operator emits globally (measured 2026-10-01:
1859
- # new_home() isolates GOBLIN_EMISSIONS but not HOME, so the fallbacks reached the
1860
- # operator's real ~/.hermes). GOBLIN_GLOBAL=1 is set by an operator who wants the
1861
- # global tier to count; tests that need isolation leave it unset.
1862
- local _cl_1 _cl_2 _cl_3 _g1 _g2
1863
- _cl_1="$(printf '%s' '.cl')"; _cl_2="$(printf '%s' 'a')"; _cl_3="$(printf '%s' 'ude')"
1864
- _g1="$(printf '%s' '.gem')"; _g2="$(printf '%s' 'ini')"
1865
- [ -f "$ROOT/.hermes/skills/goblin-mode/SKILL.md" ] && return 0
1866
- [ -f "$ROOT/$_cl_1$_cl_2$_cl_3/skills/goblin-mode/SKILL.md" ] && return 0
1867
- [ -f "$ROOT/.github/skills/goblin-mode/SKILL.md" ] && return 0
1868
- [ -f "$ROOT/.cursor/skills/goblin-mode/SKILL.md" ] && return 0
1869
- [ -f "$ROOT/.opencode/skills/goblin-mode/SKILL.md" ] && return 0
1870
- [ -f "$ROOT/.agents/skills/goblin-mode/SKILL.md" ] && return 0
1871
- [ -f "$ROOT/$_g1$_g2/skills/goblin-mode/SKILL.md" ] && return 0
1872
- if [ "${GOBLIN_GLOBAL:-0}" = "1" ]; then
1873
- [ -f "${HOME:-$ROOT}/.copilot/skills/goblin-mode/SKILL.md" ] && return 0
1874
- [ -f "${HOME:-$ROOT}/$_cl_1$_cl_2$_cl_3/skills/goblin-mode/SKILL.md" ] && return 0
1875
- [ -f "${HOME:-$ROOT}/.cursor/skills/goblin-mode/SKILL.md" ] && return 0
1876
- [ -f "${HOME:-$ROOT}/.opencode/skills/goblin-mode/SKILL.md" ] && return 0
1877
- [ -f "${HOME:-$ROOT}/.agents/skills/goblin-mode/SKILL.md" ] && return 0
1878
- [ -f "${HOME:-$ROOT}/.hermes/skills/goblin-mode/SKILL.md" ] && return 0
1879
- [ -f "${HOME:-$ROOT}/$_g1$_g2/skills/goblin-mode/SKILL.md" ] && return 0
1880
- fi
1881
- [ -f "${GOBLIN_EMISSIONS:-${HOME:-}/.goblin-stack/emissions.tsv}" ] \
1882
- && awk -F'\t' -v r="$ROOT" 'NR>1 && index($3, r) == 1 { found=1 } END { exit !found }' \
1883
- "${GOBLIN_EMISSIONS:-${HOME:-}/.goblin-stack/emissions.tsv}" && return 0
1884
- return 1 ;;
1885
- tokens) [ -f "$ROOT/.gob/tokens.yaml" ] ;;
1886
- # ci-gate: the part is GONE from the product (v2). Every class carries need="-" in
1887
- # classes.tsv, and the artifact can never be written again — so the probe is a
1888
- # constant ABSENT and the CL-01 "-" branch (forbids, artifact absent) always passes.
1889
- ci-gate) return 1 ;;
1890
- # The CI lane's artifact is the workflow goblin-stack WRITES, not the directory: a repo is
1891
- # allowed to have its own workflows, and `-` on this part means "goblin-stack must not have
1892
- # placed one here", not "this repo may not have CI" (G6 A.6).
1893
- *) return 0 ;;
1894
- esac
1895
- }
1896
-
1897
- check_cl_01() {
1898
- local part need present bad=0
1899
- while read -r part; do
1900
- [ -n "$part" ] || continue
1901
- need=$(g_class_need "$CLASSES" "$CLASS" "$part")
1902
- class_part_artifact "$part"; present=$?
1903
- # A class-forbidden part is forbidden whether or not the installer pre-disabled it: the
1904
- # opt-out branch used to mask the '-' branch for every part the class turns off, so only
1905
- # review-panel was ever enforced (D10).
1906
- if [ "$need" = "-" ]; then
1907
- if [ "$present" -eq 0 ]; then printf 'class %s forbids part %s, artifact present\n' "$CLASS" "$part"; bad=1; fi
1908
- continue
1909
- fi
1910
- if g_agents_part_disabled "$CONFIG" "$part"; then
1911
- printf 'part %s: opt-out\n' "$part"
1912
- continue
1913
- fi
1914
- case "$need" in
1915
- R)
1916
- if [ "$ARCHIVE" = "true" ]; then
1917
- printf 'part %s: waived (archive: true)\n' "$part"
1918
- elif [ "$present" -ne 0 ]; then
1919
- printf 'class %s requires part %s, artifact absent\n' "$CLASS" "$part"; bad=1
1920
- fi ;;
1921
- O) printf 'part %s: optional, %s\n' "$part" "$([ "$present" -eq 0 ] && echo present || echo absent)" ;;
1922
- esac
1923
- done < <(awk -F'\t' 'NR>1 {print $2}' "$CLASSES" | sort -u)
1924
- [ "$bad" -eq 0 ]
1925
- }
1926
-
1927
1430
  check_cl_02() {
1928
1431
  # The archive flag is a switch with a contract, so it must be checkable (D6 - the old body
1929
1432
  # printed a sentence and returned 0 in both branches, so the row could never be RED).
1930
1433
  # Two falsifiable clauses: the value must be a boolean, and it must agree with what the
1931
- # install recorded - otherwise flipping `archive:` by hand silently waives the class.
1434
+ # install recorded - otherwise flipping `archive:` by hand silently waives the checks.
1932
1435
  case "$ARCHIVE" in
1933
1436
  true|false) ;;
1934
1437
  *) printf 'archive: must be true or false, got "%s"\n' "${ARCHIVE:-<empty>}"; return 1 ;;
@@ -1943,7 +1446,7 @@ check_cl_02() {
1943
1446
  if [ "$ARCHIVE" = "true" ]; then
1944
1447
  printf 'archive: true (matches the install record) - HP-*/GT-*/SP-* skipped, no HANDOFF or gates required\n'
1945
1448
  else
1946
- printf 'archive: false - the full class requirement applies\n'
1449
+ printf 'archive: false - the full requirement applies\n'
1947
1450
  fi
1948
1451
  return 0
1949
1452
  }
@@ -2016,7 +1519,7 @@ fm_feature_files() {
2016
1519
 
2017
1520
  check_fm_01() {
2018
1521
  [ -n "$FEATURE_MAP" ] || {
2019
- printf 'feature_map: is empty - no map is declared, so there is nothing to index\n'
1522
+ printf 'feature_map: is empty - this state is UNREACHABLE through `gob init --write`, which always declares a live map; the repo was installed by the low-level goblin-install, or hand-edited. There is nothing to index.\n'
2020
1523
  return 3
2021
1524
  }
2022
1525
  local readme; readme=$(fm_readme)
@@ -2057,7 +1560,7 @@ check_fm_01() {
2057
1560
 
2058
1561
  check_fm_02() {
2059
1562
  [ -n "$FEATURE_MAP" ] || {
2060
- printf 'feature_map: is empty - no map is declared, so there are no entry paths to resolve\n'
1563
+ printf 'feature_map: is empty - this state is UNREACHABLE through `gob init --write`, which always declares a live map; the repo was installed by the low-level goblin-install, or hand-edited. There are no entry paths to resolve.\n'
2061
1564
  return 3
2062
1565
  }
2063
1566
  local readme; readme=$(fm_readme)
@@ -2136,321 +1639,6 @@ check_va_01() {
2136
1639
  return 0
2137
1640
  }
2138
1641
 
2139
- # ---- the judge and the loop (G2): JG-01..JG-03, LP-01..LP-05 --------------------------------
2140
- # A loop record is the committed artifact of ONE unattended run:
2141
- #
2142
- # .gob/loop/predicate one shell command - the loop's own exit condition
2143
- # .gob/loop/predicate.sha256 its digest, recorded at loop start (the pin); after a close, the
2144
- # chain follows on `previous: <digest>` lines (W5-7)
2145
- # .gob/loop/first-run "exit=<n> ts=<ISO8601>" - run BEFORE iteration 1
2146
- # .gob/loop/budget the turn budget the loop declared
2147
- # .gob/loop/decisions.tsv one row per iteration: ts phase decision why evidence result
2148
- # .gob/loop/stuck.md the write-up when the loop ended without its predicate green
2149
- # .gob/loop/closed-<date>/ a relaxed predicate AND the pin it was closed under, archived;
2150
- # the live pin names its digest, so the close is auditable
2151
- #
2152
- # Nothing here re-runs the predicate and nothing here writes: the record is the evidence, and
2153
- # what that costs is stated in docs/LOOP.md and docs/LIMITS.md.
2154
-
2155
- loop_present() { [ -d "$LOOP_DIR" ]; }
2156
-
2157
- # The one reason every LP row skips: no loop has run here, so there is nothing to audit.
2158
- loop_no_record() { printf 'no loop has run in this repo\n'; return 3; }
2159
-
2160
- # The verdict rows, in order: "<rownum><TAB><decision><TAB><evidence><TAB><result>".
2161
- loop_decision_rows() {
2162
- awk -F'\t' 'NR > 1 && NF >= 6 { print NR "\t" $3 "\t" $5 "\t" $6 }' "$LOOP_DIR/decisions.tsv" 2>/dev/null
2163
- }
2164
-
2165
- # A row with fewer columns than the header is a malformed record, and a malformed record is a
2166
- # FAIL: a row the reader silently skipped is a row nothing checked.
2167
- loop_malformed_rows() {
2168
- awk -F'\t' 'NR > 1 && NF > 0 && NF < 6 { print NR }' "$LOOP_DIR/decisions.tsv" 2>/dev/null
2169
- }
2170
-
2171
- # Does ONE evidence token resolve? The typed handles are sha:<hex> (a commit `git rev-list
2172
- # --all` knows), file:<path> (a path under the root) and sha256:<hex> (the digest of a file
2173
- # under .gob/loop/); a bare token resolves when it names an existing path. A `cmd:` token
2174
- # resolves NOTHING on purpose: the command ran, its output is not in the record, and a verdict
2175
- # that rests on it is exactly the self-report JG-01 exists to refuse.
2176
- loop_token_resolves() {
2177
- local t="$1" h p
2178
- case "$t" in
2179
- *..*) return 1 ;;
2180
- esac
2181
- case "$t" in
2182
- sha:*)
2183
- h=${t#sha:}
2184
- case "$h" in ''|*[!0-9a-fA-F]*) return 1 ;; esac
2185
- [ "${#h}" -ge 7 ] || return 1
2186
- # NOT `git rev-list --all | grep -qi` : grep -q exits on the first match, git dies of
2187
- # SIGPIPE (141), and with `set -o pipefail` the pipeline reports FAILURE for a commit that
2188
- # IS in the repo. Measured: a seeded record's own HEAD resolved as false, rc 141. grep -c
2189
- # reads to the end of the stream, so the count is what is compared.
2190
- case "$( cd "$ROOT" && git rev-list --all 2>/dev/null | grep -ci "^$h" )" in
2191
- ''|0) return 1 ;;
2192
- esac
2193
- return 0 ;;
2194
- sha256:*)
2195
- h=${t#sha256:}
2196
- case "$h" in ''|*[!0-9a-fA-F]*) return 1 ;; esac
2197
- [ "${#h}" -eq 64 ] || return 1
2198
- for p in "$LOOP_DIR"/* "$LOOP_DIR"/closed-*/*; do
2199
- [ -f "$p" ] || continue
2200
- [ "$(g_sha256_file "$p")" = "$h" ] && return 0
2201
- done
2202
- return 1 ;;
2203
- file:*)
2204
- p=${t#file:}
2205
- [ -n "$p" ] && [ -e "$ROOT/$p" ] && return 0
2206
- return 1 ;;
2207
- cmd:*|verdict:*|predicate:*|ts:*)
2208
- return 1 ;;
2209
- *)
2210
- [ -n "$t" ] && [ -e "$ROOT/$t" ] && return 0
2211
- return 1 ;;
2212
- esac
2213
- }
2214
-
2215
- check_jg_01() {
2216
- local f="$LOOP_DIR/decisions.tsv" n=0 bad=0 rn dec ev res tok hit mal
2217
- [ -f "$f" ] || { printf 'no loop record in this repo - no judge verdict to check\n'; return 3; }
2218
- mal=$(loop_malformed_rows | head -n 3 | paste -sd' ' -)
2219
- if [ -n "$mal" ]; then
2220
- printf 'decisions.tsv row(s) %s carry fewer columns than the header - a row nothing reads is a row nothing checks\n' "$mal"
2221
- bad=1
2222
- fi
2223
- while IFS=$'\t' read -r rn dec ev res; do
2224
- [ -n "$rn" ] || continue
2225
- case "$dec" in verdict:*) ;; *) continue ;; esac
2226
- n=$((n + 1))
2227
- hit=0
2228
- for tok in $(printf '%s' "$ev" | tr ',' ' '); do
2229
- if loop_token_resolves "$tok"; then hit=1; break; fi
2230
- done
2231
- if [ "$hit" -eq 0 ]; then
2232
- printf 'row %s: %s cites no handle that resolves: "%s"\n' "$rn" "$dec" "${ev:-<empty>}"
2233
- printf ' a handle is sha:<hex> (a commit in this repo), file:<path>, sha256:<hex> (a file under .gob/loop/), or an existing path\n'
2234
- bad=1
2235
- fi
2236
- done < <(loop_decision_rows)
2237
- [ "$bad" -eq 0 ] || return 1
2238
- printf '%d judge verdict row(s), each citing a handle the repo resolves\n' "$n"
2239
- return 0
2240
- }
2241
-
2242
- # The profiles a role resolves to (one per lane), or nothing when the role has no lane.
2243
- role_lane_profiles() {
2244
- resolve_role_models "$1" | awk -F'\t' 'NF >= 2 && $2 != "" { print $2 }' | sort -u
2245
- }
2246
-
2247
- # Non-zero when ANY lane of the role has no provider/model. BOTH sentinels count as unresolved:
2248
- # the installed path prints `?` (resolve_role_models, `${prov:-?}`) and the checkout path prints
2249
- # `unknown` - a check that greps for one of them passes on the other.
2250
- role_unresolved() {
2251
- local line p prov model
2252
- while IFS=$'\t' read -r line p prov model _; do
2253
- [ -n "$p" ] || continue
2254
- case "$prov" in '?'|unknown|'') return 0 ;; esac
2255
- case "$model" in '?'|unknown|'') return 0 ;; esac
2256
- done < <(resolve_role_models "$1")
2257
- return 1
2258
- }
2259
-
2260
- check_jg_02() {
2261
- local judge_profiles code_profiles shared judge_unres code_unres
2262
- if [ ! -f "$MODELS_FILE" ]; then
2263
- printf 'no model mapping configured (%s absent) - advisory\n' "$MODELS_FILE"
2264
- printf 'remedy: add a `judge:` entry beside the code lane in the file declared as models_file: in %s\n' "$CONFIG"
2265
- return 2
2266
- fi
2267
- judge_profiles=$(role_lane_profiles judge)
2268
- code_profiles=$(role_lane_profiles code)
2269
- if [ -z "$judge_profiles" ] || [ -z "$code_profiles" ]; then
2270
- printf 'roles.yaml did not resolve both lanes (judge: %s, code: %s) - advisory\n' \
2271
- "${judge_profiles:-none}" "${code_profiles:-none}"
2272
- printf 'remedy: role-judge needs a profiles: list and a profile for it in the mapping file\n'
2273
- return 2
2274
- fi
2275
- role_unresolved judge; judge_unres=$?
2276
- role_unresolved code; code_unres=$?
2277
- if [ "$judge_unres" -eq 0 ] || [ "$code_unres" -eq 0 ]; then
2278
- printf 'unresolved lane - advisory (judge: %s, code: %s)\n' \
2279
- "$([ "$judge_unres" -eq 0 ] && printf 'no provider/model' || printf 'ok')" \
2280
- "$([ "$code_unres" -eq 0 ] && printf 'no provider/model' || printf 'ok')"
2281
- printf 'remedy: add the missing profile to the file declared as models_file: in %s - goblin-stack reads that file and never writes it\n' "$CONFIG"
2282
- return 2
2283
- fi
2284
- shared=$(printf '%s\n' "$judge_profiles" | grep -Fxf <(printf '%s\n' "$code_profiles") | head -n 1)
2285
- if [ -n "$shared" ]; then
2286
- printf 'the judge lane and the author (code) lane share the profile "%s" - the judge is the author\n' "$shared"
2287
- return 1
2288
- fi
2289
- printf 'judge lane [%s] and code lane [%s] are disjoint\n' \
2290
- "$(printf '%s' "$judge_profiles" | paste -sd, -)" "$(printf '%s' "$code_profiles" | paste -sd, -)"
2291
- return 0
2292
- }
2293
-
2294
- check_lp_01() {
2295
- if ! loop_present; then loop_no_record; return 3; fi
2296
- local p="$LOOP_DIR/predicate" f="$LOOP_DIR/first-run" n fr fr_ts row1_ts a b
2297
- [ -f "$p" ] || { printf 'no .gob/loop/predicate - the loop declared no exit condition\n'; return 1; }
2298
- n=$(grep -cvE '^[[:space:]]*(#|$)' "$p")
2299
- if [ "$n" -ne 1 ]; then
2300
- printf 'the predicate must be exactly ONE command; found %s non-blank non-comment line(s)\n' "$n"
2301
- return 1
2302
- fi
2303
- [ -f "$f" ] || { printf 'no .gob/loop/first-run - the predicate was never run before iteration 1\n'; return 1; }
2304
- fr=$(head -n 1 "$f")
2305
- case "$fr" in
2306
- "exit="[0-9]*" ts="*) ;;
2307
- *) printf 'first-run must read "exit=<n> ts=<ISO8601>", got "%s"\n' "$fr"; return 1 ;;
2308
- esac
2309
- fr_ts=$(printf '%s' "$fr" | sed -n 's/.* ts=//p')
2310
- case "$fr_ts" in
2311
- [0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]T[0-9][0-9]:[0-9][0-9]:[0-9][0-9]*) ;;
2312
- *) printf 'first-run ts is not an ISO8601 timestamp: "%s"\n' "$fr_ts"; return 1 ;;
2313
- esac
2314
- row1_ts=$(awk -F'\t' 'NR > 1 && NF >= 6 { print $1; exit }' "$LOOP_DIR/decisions.tsv" 2>/dev/null)
2315
- if [ -n "$row1_ts" ]; then
2316
- a=$fr_ts; b=$row1_ts
2317
- if [ "$a" \> "$b" ]; then
2318
- printf 'the recorded first run (%s) is AFTER the first log row (%s) - it did not run before iteration 1\n' "$fr_ts" "$row1_ts"
2319
- return 1
2320
- fi
2321
- fi
2322
- printf 'one predicate command; first run (%s) is at or before the first log row\n' "$fr"
2323
- return 0
2324
- }
2325
-
2326
- check_lp_02() {
2327
- if ! loop_present; then loop_no_record; return 3; fi
2328
- local p="$LOOP_DIR/predicate" pin="$LOOP_DIR/predicate.sha256" want have bad=0
2329
- [ -f "$p" ] || { printf 'no .gob/loop/predicate to pin\n'; return 1; }
2330
- [ -f "$pin" ] || { printf 'no .gob/loop/predicate.sha256 - the predicate was never pinned at loop start\n'; return 1; }
2331
- want=$(head -n 1 "$pin" | tr -d '[:space:]')
2332
- have=$(g_sha256_file "$p")
2333
- if [ "$want" != "$have" ]; then
2334
- printf 'the predicate changed after the loop was pinned\n pinned %s\n now %s\n' "$want" "$have"
2335
- printf 'remedy: close this loop - commit the green state, archive the predicate AND its pin under .gob/loop/closed-<date>/, then open a new loop and re-record the pin with a `previous: <archived digest>` line. Never automatic.\n'
2336
- return 1
2337
- fi
2338
- # W5-7: the close-and-reopen path. The pin covers the predicate file on disk, so a loop could
2339
- # archive its old bar, write a weaker one, re-pin, and pass LP-02 and LP-05 with nothing in the
2340
- # record - a relaxed predicate was indistinguishable from a legitimate re-scope. The chain below
2341
- # cannot judge whether a predicate is WEAKER (nothing in bash can, docs/LIMITS.md #39); what it
2342
- # can do is make the supersession RECORDED: the archive must be intact (its own pin agrees with
2343
- # its own predicate) and the current pin must name the archived digest on a `previous:` line. So
2344
- # a silent relaxation is caught, and a real re-scope costs one line.
2345
- local d arcdig adig
2346
- for d in "$LOOP_DIR"/closed-*; do
2347
- [ -d "$d" ] || continue
2348
- if [ ! -f "$d/predicate" ] || [ ! -f "$d/predicate.sha256" ]; then
2349
- printf '%s: a closed loop must archive its predicate AND its pin - an archive that records nothing is not a close\n' "$(basename "$d")"
2350
- bad=1; continue
2351
- fi
2352
- arcdig=$(head -n 1 "$d/predicate.sha256" | tr -d '[:space:]')
2353
- adig=$(g_sha256_file "$d/predicate")
2354
- if [ "$arcdig" != "$adig" ]; then
2355
- printf '%s: the archived pin does not match the archived predicate\n pinned %s\n now %s\n' "$(basename "$d")" "$arcdig" "$adig"
2356
- bad=1; continue
2357
- fi
2358
- if ! awk -v want="$adig" '
2359
- NR > 1 { line = $0; sub(/^previous:[[:space:]]*/, "", line); sub(/[[:space:]]+$/, "", line); if (line == want) found = 1 }
2360
- END { exit !found }
2361
- ' "$pin"; then
2362
- printf '%s: the current pin does not name the superseded predicate\n archived %s\n add a `previous: %s` line to %s - a close-and-reopen that records nothing is a silent relaxation\n' \
2363
- "$(basename "$d")" "$adig" "$adig" "$pin"
2364
- bad=1
2365
- fi
2366
- done
2367
- [ "$bad" -eq 0 ] || return 1
2368
- printf 'predicate pin ok (%s)%s\n' "$have" \
2369
- "$([ -n "$(ls -d "$LOOP_DIR"/closed-* 2>/dev/null)" ] && printf ', every archived predicate named by a previous: line' || printf '')"
2370
- return 0
2371
- }
2372
-
2373
- check_lp_03() {
2374
- if ! loop_present; then loop_no_record; return 3; fi
2375
- local f="$LOOP_DIR/budget" b ceil n bad=0
2376
- [ -f "$f" ] || { printf 'no .gob/loop/budget - the loop declared no turn budget\n'; return 1; }
2377
- b=$(head -n 1 "$f" | tr -d '[:space:]')
2378
- case "$b" in
2379
- ''|*[!0-9]*) printf 'budget must be a positive integer, got "%s"\n' "$b"; return 1 ;;
2380
- esac
2381
- [ "$b" -gt 0 ] || { printf 'budget must be a positive integer, got "%s"\n' "$b"; return 1; }
2382
- ceil=$LOOP_MAX_TURNS_CEILING
2383
- case "$ceil" in ''|*[!0-9]*) ceil=20 ;; esac
2384
- if [ "$b" -gt "$ceil" ]; then
2385
- printf 'budget %s exceeds loop_max_turns_ceiling %s in the config\n' "$b" "$ceil"
2386
- bad=1
2387
- fi
2388
- if [ ! -f "$LOOP_DIR/decisions.tsv" ]; then
2389
- printf 'no decisions.tsv - the loop declared a budget and kept no record\n'
2390
- return 1
2391
- fi
2392
- n=$(awk -F'\t' 'NR > 1 && NF >= 6 && $3 ~ /^verdict:/ { c++ } END { print c+0 }' "$LOOP_DIR/decisions.tsv")
2393
- if [ "$n" -gt "$b" ]; then
2394
- printf 'the record holds %s verdict row(s) against a declared budget of %s\n' "$n" "$b"
2395
- bad=1
2396
- fi
2397
- [ "$bad" -eq 0 ] || return 1
2398
- printf 'budget %s (ceiling %s), %s verdict row(s) recorded\n' "$b" "$ceil" "$n"
2399
- return 0
2400
- }
2401
-
2402
- check_lp_04() {
2403
- if ! loop_present; then loop_no_record; return 3; fi
2404
- [ -f "$LOOP_DIR/decisions.tsv" ] || { printf 'no decisions.tsv to read\n'; return 1; }
2405
- local prev_ev="" streak=0 nums="" rn dec ev res
2406
- while IFS=$'\t' read -r rn dec ev res; do
2407
- [ -n "$rn" ] || continue
2408
- case "$dec" in verdict:*) ;; *) continue ;; esac
2409
- if [ -n "$ev" ] && [ "$ev" = "$prev_ev" ] && [ "$res" != "predicate:green" ]; then
2410
- streak=$((streak + 1))
2411
- nums="$nums $rn"
2412
- else
2413
- streak=1
2414
- nums=" $rn"
2415
- fi
2416
- prev_ev="$ev"
2417
- if [ "$streak" -ge 3 ]; then
2418
- printf 'no progress: rows%s share the evidence pointer "%s" and none reached predicate:green\n' "$nums" "$ev"
2419
- printf ' a loop making no progress stops and writes up why; it does not spend its budget thrashing\n'
2420
- return 1
2421
- fi
2422
- done < <(loop_decision_rows)
2423
- printf 'no three consecutive verdict rows share an evidence pointer without reaching predicate:green\n'
2424
- return 0
2425
- }
2426
-
2427
- check_lp_05() {
2428
- if ! loop_present; then loop_no_record; return 3; fi
2429
- [ -f "$LOOP_DIR/decisions.tsv" ] || { printf 'no decisions.tsv to read\n'; return 1; }
2430
- local last rn res s n
2431
- last=$(awk -F'\t' 'NR > 1 && NF >= 6 && $3 ~ /^verdict:/ { rn = NR; res = $6 } END { if (rn) print rn "\t" res }' "$LOOP_DIR/decisions.tsv")
2432
- if [ -z "$last" ]; then
2433
- printf 'the record holds no verdict row - there is no closing state to audit\n'
2434
- return 3
2435
- fi
2436
- rn=${last%%$'\t'*}
2437
- res=${last#*$'\t'}
2438
- if [ "$res" = "predicate:green" ]; then
2439
- printf 'the last verdict row (row %s) reached predicate:green - no write-up required\n' "$rn"
2440
- return 0
2441
- fi
2442
- s="$LOOP_DIR/stuck.md"
2443
- [ -f "$s" ] || { printf 'the loop ended at "%s" (row %s) and left no .gob/loop/stuck.md\n' "${res:-<empty>}" "$rn"; return 1; }
2444
- n=$(grep -c '[^[:space:]]' "$s")
2445
- if [ "$n" -lt 3 ]; then
2446
- printf 'stuck.md holds %s non-blank line(s); a write-up needs at least 3\n' "$n"
2447
- return 1
2448
- fi
2449
- grep -q 'predicate' "$s" || { printf 'stuck.md does not name the predicate it failed to satisfy\n'; return 1; }
2450
- printf 'the loop ended at "%s" (row %s) and stuck.md names the predicate in %s line(s)\n' "$res" "$rn" "$n"
2451
- return 0
2452
- }
2453
-
2454
1642
  # ---- the reference corpus (P15): RC-01..RC-04 ------------------------------------------------
2455
1643
  # P15's machine half. All four read DECLARED values - `reference_manifest:` and the
2456
1644
  # `security: build_output:` block SC-03 clause 2 already reads - and never infer a path from the
@@ -2645,7 +1833,7 @@ check_rc_03() {
2645
1833
  scripts/*|notes/*|manifests/*) continue ;;
2646
1834
  # The harness's own directories and the .gitignore block it appends are the install, not the
2647
1835
  # lab's content - the same exclusion FM-02 makes for the same reason (W5-4). That set is the
2648
- # one the class-A install contract creates: .gob/, .hermes/, the .gitignore block, the
1836
+ # one the install contract creates: .gob/, .hermes/, the .gitignore block, the
2649
1837
  # declared harness_dir (checks/ by default), reviews/, and the CI scaffold .github/. A payload
2650
1838
  # hidden in any of them is still caught by clause 2 (the sha256 sweep below).
2651
1839
  .gob/*|.hermes/*|.gitignore|.github/*|reviews/*) continue ;;
@@ -2732,23 +1920,11 @@ rc_hdr_field() {
2732
1920
  }
2733
1921
 
2734
1922
  # ---- the day-one framing (review 1, scope 3) ----------------------------------
2735
- # Two shapes are undeserved reds for a person who just cloned a repo. They are DETECTED and
2736
- # framed — the verdict's exit semantics, the counts and every row's payload are untouched:
2737
- # (a) owner_email in AGENTS.md is not the current git identity -> the CM-01 red names
2738
- # whose email the repo actually expects (the remedy column says where to point it);
2739
- # (b) the repo looks freshly cloned (.gob committed, but fewer than 3 commits) -> one
2740
- # banner line after the verdict. Commit count only: an mtime comparison against the
2741
- # reflog fired after every ordinary GT-02 write, so the banner lingered on aged repos
2742
- # (the verify itself refreshes last-gate-line forever); a repo under 3 commits is the
2743
- # only unambiguous fresh-clone shape.
2744
- owner_mismatch() {
2745
- [ -f "$CONFIG" ] || return 1
2746
- local declared cur
2747
- declared=$(g_agents_read "$CONFIG" owner_email | tr -d '"')
2748
- cur=$(cd "$ROOT" && git config user.email 2>/dev/null)
2749
- [ -n "$declared" ] && [ -n "$cur" ] && [ "$declared" != "$cur" ]
2750
- }
2751
-
1923
+ # One shape is an undeserved red for a person who just cloned a repo: the repo looks freshly
1924
+ # cloned (.gob committed, but fewer than 3 commits) -> one banner line after the verdict.
1925
+ # Commit count only: an mtime comparison against the reflog fired after every ordinary GT-02
1926
+ # write, so the banner lingered on aged repos (the verify itself refreshes last-gate-line
1927
+ # forever); a repo under 3 commits is the only unambiguous fresh-clone shape.
2752
1928
  fresh_clone() {
2753
1929
  [ -f "$INSTALLED" ] || return 1
2754
1930
  [ -d "$ROOT/.git" ] || return 1
@@ -2760,6 +1936,82 @@ fresh_clone() {
2760
1936
 
2761
1937
  # ================================================================ runner ======
2762
1938
 
1939
+ # ---- the repo-local override (batch 3) ---------------------------------------
1940
+ # Read .gob/manifest/enforcement.local.tsv, validate it (THE HONESTY GATE), and merge its rows
1941
+ # into the run. Placed here, after every builtin is defined, so a `goblin-verify --only <ID>`
1942
+ # marker cell can be checked against the builtins that actually exist.
1943
+ is_local_id() { case " $LOCAL_IDS " in *" $1 "*) return 0 ;; esac; return 1; }
1944
+
1945
+ # LOCAL_NO_VERDICT — set at run time when a LOCAL row's check COULD NOT EXECUTE (exit 126/127/137:
1946
+ # not found / not executable / killed by a signal). Such a check "exited without producing a
1947
+ # verdict": it is REFUSED at the end of the run, never read as a pass.
1948
+ LOCAL_NO_VERDICT=""
1949
+ setup_local_override() {
1950
+ [ -n "$LOCAL_FILE" ] || return 0
1951
+ local tmp _n=0 _id _scope _rule _eby _art _check _why _nf _hit _fn _line
1952
+ tmp=$(mktemp) || { g_err "mktemp failed"; exit 2; }
1953
+ cp "$MANIFEST" "$tmp"
1954
+ while IFS= read -r _line || [ -n "$_line" ]; do
1955
+ _line=${_line%$'\r'}
1956
+ case "$_line" in ''|'#'*) continue ;; esac
1957
+ _nf=$(printf '%s' "$_line" | awk -F'\t' '{print NF}')
1958
+ _id=${_line%%$'\t'*}
1959
+ if [ "$_nf" -lt 7 ]; then
1960
+ g_err "local override: '$_id' names a row id with no check."
1961
+ g_err " a local row must carry the full 7-cell line; get it with: gob verify --library"
1962
+ g_err " (an LX-* rule must supply its own check cell - a rule nothing verifies is refused)."
1963
+ exit 3
1964
+ fi
1965
+ IFS=$'\t' read -r _id _scope _rule _eby _art _check _why <<< "$_line"
1966
+ # the id must name a check the engine can run: a matrix row, a library row, or an LX-* rule.
1967
+ _hit=0
1968
+ awk -F'\t' -v x="$_id" 'NR>1 && $1==x {f=1} END{exit !f}' "$MANIFEST" && _hit=1
1969
+ if [ "$_hit" -eq 0 ] && [ -n "$LIBRARY_FILE" ]; then
1970
+ awk -F'\t' -v x="$_id" 'NR>1 && $1==x {f=1} END{exit !f}' "$LIBRARY_FILE" && _hit=1
1971
+ fi
1972
+ case "$_id" in LX-*) _hit=1 ;; esac
1973
+ if [ "$_hit" -eq 0 ]; then
1974
+ g_err "local override: '$_id' names no row the engine ships - it is in neither"
1975
+ g_err " .gob/manifest/enforcement.tsv nor .gob/manifest/library.tsv."
1976
+ g_err " a local row may only turn on a shipped row (see: gob verify --library) or declare"
1977
+ g_err " an LX-* rule with its own check cell."
1978
+ exit 3
1979
+ fi
1980
+ # a builtin-marker check must have a builtin, or it can never produce a verdict.
1981
+ case "$_check" in
1982
+ "goblin-verify --only "*)
1983
+ _fn="check_$(printf '%s' "$_id" | tr 'A-Z' 'a-z' | tr '-' '_')"
1984
+ if ! declare -F "$_fn" >/dev/null 2>&1; then
1985
+ g_err "local override: '$_id' names a check the engine has no builtin for ($_fn)."
1986
+ g_err " a local row cannot certify a rule nothing verifies."
1987
+ exit 3
1988
+ fi ;;
1989
+ "")
1990
+ case "$_eby" in
1991
+ advisory) ;;
1992
+ *) g_err "local override: '$_id' carries no check and is not advisory - nothing verifies it."
1993
+ exit 3 ;;
1994
+ esac ;;
1995
+ esac
1996
+ # a row the matrix already runs by default is a no-op here (never a duplicate).
1997
+ if awk -F'\t' -v x="$_id" 'NR>1 && $1==x {f=1} END{exit !f}' "$MANIFEST"; then
1998
+ g_info "local override: '$_id' is already on by default - ignored."
1999
+ continue
2000
+ fi
2001
+ printf '%s\n' "$_line" >> "$tmp"
2002
+ LOCAL_IDS="$LOCAL_IDS $_id"
2003
+ _n=$((_n + 1))
2004
+ done < "$LOCAL_FILE"
2005
+ if [ "$_n" -gt 0 ]; then
2006
+ RUN_MANIFEST="$tmp"
2007
+ _GOB_MANIFEST="$tmp"
2008
+ export _GOB_MANIFEST
2009
+ else
2010
+ rm -f "$tmp"
2011
+ fi
2012
+ }
2013
+ setup_local_override
2014
+
2763
2015
  PASS=0; FAIL=0; ADV=0; SKIP=0; BAD=0
2764
2016
  JSON_ROWS=""
2765
2017
 
@@ -2795,21 +2047,6 @@ while IFS=$'\t' read -r id scope rule enforced_by artifact check why; do
2795
2047
  only_selected "$id" || continue
2796
2048
 
2797
2049
  part=$(row_part "$id")
2798
- # W6 neutral-first: in global engine mode AU-01's subject is the PRODUCER glob, which
2799
- # global mode reads from the engine dir — the row must run there even when the repo's
2800
- # skills opt-out (playbooks) is set, or the W1 control below it is skip-masked. This
2801
- # clause precedes the opt-out branch on purpose. SK-01/SK-02/SK-04 and AU-02..AU-04 keep
2802
- # their opt-out semantics.
2803
- if [ "$id" = "AU-01" ] && [ "$ENGINE_MODE" = "global" ]; then
2804
- out=$(check_au_01 2>&1); rc=$?
2805
- case "$rc" in
2806
- 0) PASS=$((PASS + 1)); emit "$id" PASS "$out" ;;
2807
- 1) FAIL=$((FAIL + 1)); emit "$id" FAIL "$out" ;;
2808
- 2) ADV=$((ADV + 1)); emit "$id" ADV "$out" ;;
2809
- 3) SKIP=$((SKIP + 1)); emit "$id" SKIP "$out" ;;
2810
- esac
2811
- continue
2812
- fi
2813
2050
  if [ -n "$part" ] && g_agents_part_disabled "$CONFIG" "$part"; then
2814
2051
  SKIP=$((SKIP + 1)); emit "$id" SKIP "$rule (opt-out: $part)"; continue
2815
2052
  fi
@@ -2834,6 +2071,15 @@ while IFS=$'\t' read -r id scope rule enforced_by artifact check why; do
2834
2071
  ;;
2835
2072
  *)
2836
2073
  detail=$( cd "$ROOT" && bash -c "$check" 2>&1 ); rc=$?
2074
+ # A LOCAL row whose check could not execute (126 not executable / 127 not found /
2075
+ # 137 killed by a signal) exited WITHOUT producing a verdict: record it for the refusal
2076
+ # at the end of the run, rather than folding it into a FAIL a reader could mistake for a
2077
+ # verdict. A matrix row keeps the old fold (its checks are shipped and known).
2078
+ if is_local_id "$id"; then
2079
+ case "$rc" in
2080
+ 126|127|137) LOCAL_NO_VERDICT="$LOCAL_NO_VERDICT $id(exit $rc)" ;;
2081
+ esac
2082
+ fi
2837
2083
  # A shell check has no advisory state: anything non-zero is a FAIL. Only builtins
2838
2084
  # (the 'goblin-verify --only <ID>' marker rows) may return 2 = advisory or 3 = skip.
2839
2085
  if [ "$rc" -eq 0 ]; then
@@ -2859,44 +2105,65 @@ while IFS=$'\t' read -r id scope rule enforced_by artifact check why; do
2859
2105
  3) SKIP=$((SKIP + 1)); emit "$id" SKIP "$detail" ;;
2860
2106
  *) FAIL=$((FAIL + 1)); emit "$id" FAIL "$detail (exit $rc)" ;;
2861
2107
  esac
2862
- done < "$MANIFEST"
2108
+ done < "$RUN_MANIFEST"
2109
+
2110
+ # ---- the honesty gate, run-time half: a local check that produced no verdict ----------------
2111
+ # A local row's check that could not execute (exit 126/127/137) never produced a verdict, so it
2112
+ # is REFUSED - exit 3, with the ids named - rather than reported as the FAIL the fold above made
2113
+ # of it. Nothing about such a row is green.
2114
+ if [ -n "$LOCAL_NO_VERDICT" ]; then
2115
+ g_err "local override: a check could not execute, so it produced NO verdict:$LOCAL_NO_VERDICT"
2116
+ g_err " a local row's check must be runnable - a command that is not found (127), not"
2117
+ g_err " executable (126), or killed by a signal (137) cannot verify the rule it names."
2118
+ g_err " fix the check cell, or remove the row from .gob/manifest/enforcement.local.tsv."
2119
+ exit 3
2120
+ fi
2863
2121
 
2864
2122
  if [ "$JSON" -eq 1 ]; then
2865
- printf '{"root":"%s","class":"%s","passed":%d,"failed":%d,"advisory":%d,"skipped":%d,"rows":[%s]}\n' \
2866
- "$(json_escape "$ROOT")" "$(json_escape "$CLASS")" "$PASS" "$FAIL" "$ADV" "$SKIP" "${JSON_ROWS%,}"
2123
+ _lib_n=0
2124
+ [ -n "$LIBRARY_FILE" ] && _lib_n=$(awk -F'\t' 'NR>1 && $1!="" {n++} END{print n+0}' "$LIBRARY_FILE")
2125
+ printf '{"root":"%s","passed":%d,"failed":%d,"advisory":%d,"skipped":%d,"library":%d,"rows":[%s]}\n' \
2126
+ "$(json_escape "$ROOT")" "$PASS" "$FAIL" "$ADV" "$SKIP" "$_lib_n" "${JSON_ROWS%,}"
2867
2127
  else
2868
2128
  printf ' %d passed, %d failed, %d advisory, %d skipped\n' "$PASS" "$FAIL" "$ADV" "$SKIP"
2869
- # Day-one framing, part (a) (review 1, scope 3): the owner mismatch names whose email the
2870
- # repo expects, under the verdict, before the row detail. One line, no exit semantics.
2871
- if [ "$FAIL" -gt 0 ] && owner_mismatch; then
2872
- _owner_declared=$(g_agents_read "$CONFIG" owner_email | tr -d '"')
2873
- printf ' note: this repo records a different owner (you are probably new here) — commit with --author or update owner_email: %s\n' "$_owner_declared"
2874
- unset _owner_declared
2875
- fi
2876
- # Day-one framing, part (b): a fresh clone is not your debt. One banner line, after the
2129
+ # Day-one framing: a fresh clone is not your debt. One banner line, after the
2877
2130
  # verdict; counts and exit codes untouched.
2878
2131
  if [ "$FAIL" -gt 0 ] && fresh_clone; then
2879
2132
  printf ' fresh clone detected: some of these fails are not yours — see docs/GUIDE.md §9 (day one for a new teammate)\n'
2880
2133
  fi
2881
- # Z1-7: the advisory number above counts TWO different things - the rows the matrix LABELS
2882
- # advisory, and a row that is not advisory-labelled but whose lane cannot be resolved here
2883
- # (JG-02's unresolved judge lane returns 2 = ADV by design). SK-03 counts the first, the ADV
2884
- # lines on screen are both, so a reader comparing `advisory 10 of ceiling 10` with 11 ADV lines
2885
- # saw a mismatch that only the row's why-cell explained. Print the arithmetic.
2886
- adv_labelled=$(awk -F'\t' 'NR>1 && ($4=="advisory" || $6=="advisory") {n++} END{print n+0}' "$MANIFEST")
2134
+ # Z1-7: the advisory number above counts the rows the matrix LABELS advisory; a row that is
2135
+ # not advisory-labelled can also report ADV by design when its lane cannot be resolved here.
2136
+ # SK-03 counts the labelled rows, the ADV lines on screen are both, so a reader comparing
2137
+ # `advisory N of ceiling C` with more ADV lines sees the arithmetic. Print it.
2138
+ adv_labelled=$(awk -F'\t' 'NR>1 && ($4=="advisory" || $6=="advisory") {n++} END{print n+0}' "${RUN_MANIFEST:-$MANIFEST}")
2887
2139
  if [ "$ADV" -ne "$adv_labelled" ]; then
2888
2140
  printf ' of those %d advisory: the matrix labels %d row(s) advisory; the difference is the non-advisory row(s) reporting ADV by design (an unresolved lane) and any labelled row skipped by an opt-out\n' \
2889
2141
  "$ADV" "$adv_labelled"
2142
+ else
2143
+ printf ' of those %d advisory: the matrix labels %d row(s) advisory\n' \
2144
+ "$ADV" "$adv_labelled"
2145
+ fi
2146
+ # The library census (batch 2b-ii). A green default run must never read as the whole story:
2147
+ # the rows this run did NOT check are counted here, with the surface that lists them. The
2148
+ # count is read from library.tsv, so it tracks the shipped row set rather than a typed number.
2149
+ if [ -n "$LIBRARY_FILE" ]; then
2150
+ _lib_n=$(awk -F'\t' 'NR>1 && $1!="" {n++} END{print n+0}' "$LIBRARY_FILE")
2151
+ printf ' library: %d off-by-default row(s) held but NOT run - discover them with `gob verify --library`\n' \
2152
+ "$_lib_n"
2153
+ fi
2154
+ # The local-override census (batch 3): a row turned ON through .gob/manifest/enforcement.local.tsv
2155
+ # is named here, so a reader can tell the locally-enabled rows apart from the default set.
2156
+ if [ -n "$LOCAL_IDS" ]; then
2157
+ printf ' enabled-locally: %d row(s) added by .gob/manifest/enforcement.local.tsv:%s\n' \
2158
+ "$(printf '%s' "$LOCAL_IDS" | wc -w | tr -d ' ')" "$LOCAL_IDS"
2890
2159
  fi
2891
2160
  # The collapsed listing keeps one line per row (a SKIP's reason is the row's whole
2892
2161
  # point and scripts read them by id); the width discipline lives in the lib's printers.
2893
2162
  if [ "$VERBOSE" -eq 1 ]; then
2894
2163
  cat <<'SEE'
2895
2164
  cannot see: whether a check in the harness dir tests the right path rather than
2896
- merely passing; whether the forge is bound by the workflow CL-01 found; whether a human
2897
- read the diff;
2898
- whether the model mapping names a family that actually differs (MD-02 reports it
2899
- and cannot change it); and whether .gob/installed.json — the record every drift
2165
+ merely passing; whether the forge is bound by the workflow the repo declares found; whether a human
2166
+ read the diff; and whether .gob/installed.json — the record every drift
2900
2167
  check trusts — was itself rewritten. It is not signed, so one edit to it (with the
2901
2168
  matching edit to the file it protects) defeats IN-02, SK-02 and HS-01 at once
2902
2169
  (docs/LIMITS.md #18). The ban lane carries the same blind spot and two of its own:
@@ -2905,17 +2172,7 @@ else
2905
2172
  `Record<string, any>` is missed and a `: any` inside a string is reported
2906
2173
  (docs/LIMITS.md #27); and no check here can reach a ban IN CONTEXT — the row proves
2907
2174
  the forbidden path fails mechanically, never that the ban reached the agent that
2908
- wrote the line. The judge/loop lane adds its own: every JG-/LP- row reads a RECORD, so
2909
- it proves a handle, a pin, a budget and a pointer exist — never that the loop made
2910
- progress (a changed pointer is a proxy, docs/LIMITS.md #33), never which lane returned
2911
- a verdict, and never that the predicate was the right one or was really run. The CI lane
2912
- adds its own: PG-05 and PG-06 read a workflow's TEXT, so PG-05 sees a job whose gate step is
2913
- conditional and cannot see branch protection, the required-check list, or a forge that never
2914
- ran the job at all, and PG-06 proves a declared gate is INVOKED in a file under
2915
- .github/workflows/ — never that the forge marks that job required, never that it is the job
2916
- the forge waits on, and never that the workflow can fail (that is PG-05). A required check
2917
- that reports Success after skipping its gate is a green light for a commit whose gate never
2918
- ran (docs/CI.md). The reference-corpus lane adds its own: RC-01 matches EXACT sha256 only,
2175
+ wrote the line. The reference-corpus lane adds its own: RC-01 matches EXACT sha256 only,
2919
2176
  so a resized, recoloured or re-encoded reference asset, or copied text inside a shipped
2920
2177
  string, passes it unseen; RC-02 proves the manifest is well-shaped, never that its entries
2921
2178
  are the right hashes (as strong as tamper hashing, and installed.json is unsigned); RC-03
@@ -2929,8 +2186,8 @@ SEE
2929
2186
  cat <<'SEE'
2930
2187
  cannot see: whether a check tests the right path rather than merely passing; whether a
2931
2188
  human read the diff; whether the unsigned install record (.gob/installed.json — it is
2932
- not signed) was rewritten; and the per-lane blind spots of the ban, judge/loop, CI and
2933
- reference lanes. Full statement: `goblin-verify --verbose`, docs/LIMITS.md #18 #27 #28 #33 #43.
2189
+ not signed) was rewritten; and the per-lane blind spots of the ban and
2190
+ reference lanes. Full statement: `goblin-verify --verbose`, docs/LIMITS.md #18 #27 #28 #43.
2934
2191
  SEE
2935
2192
  fi
2936
2193
  # ---- the sign-off (locked v2 decision) ----------------------------------------
@@ -2972,9 +2229,8 @@ SEE
2972
2229
  if [ "$ENGINE_MODE" = "global" ]; then
2973
2230
  _shadow_n=0
2974
2231
  for _f in "$ROOT"/.gob/bin/goblin-verify "$ROOT"/.gob/bin/goblin-lib.sh \
2975
- "$ROOT"/.gob/bin/goblin-audit "$ROOT"/.gob/bin/goblin-bans \
2976
- "$ROOT"/.gob/manifest/* "$ROOT"/.gob/bans/* \
2977
- "$ROOT"/.gob/automations/* "$ROOT"/.gob/roles.yaml; do
2232
+ "$ROOT"/.gob/bin/goblin-bans \
2233
+ "$ROOT"/.gob/manifest/* "$ROOT"/.gob/bans/*; do
2978
2234
  [ -e "$_f" ] || continue
2979
2235
  _shadow_n=$((_shadow_n + 1))
2980
2236
  done