geneseed 4.30.1 → 4.32.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (97) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/SHIPPED.md +1 -1
  3. package/adapters/opencode/plugins/geneseed-context.js +136 -1
  4. package/adapters/opencode/plugins/geneseed-guard.js +145 -2
  5. package/docs/concepts/exclusions.md +1 -1
  6. package/docs/concepts/footprint.md +1 -1
  7. package/docs/concepts/hook-gates.md +1 -1
  8. package/docs/concepts/hooks.md +6 -4
  9. package/docs/concepts/host-matrix.md +1 -1
  10. package/docs/concepts/loop-bricks.md +1 -1
  11. package/docs/concepts/loop-notes.md +4 -2
  12. package/docs/concepts/loop-templates.md +7 -4
  13. package/docs/concepts/loops.md +3 -0
  14. package/docs/concepts/ownership.md +1 -1
  15. package/docs/guides/run-a-loop.md +1 -1
  16. package/docs/guides/set-up-ownership.md +1 -1
  17. package/docs/reference/loop-actions.md +1 -1
  18. package/docs/reference/plugin-activity.md +1 -1
  19. package/docs/reference/plugin-context.md +4 -0
  20. package/docs/reference/plugin-guard.md +1 -1
  21. package/docs/understand/enforced-vs-asked.md +3 -2
  22. package/docs/understand/machine-bob.md +1 -1
  23. package/docs/web-ui.md +85 -26
  24. package/harness.config.json +1 -1
  25. package/js/README.md +3 -3
  26. package/js/hosts/hooks-context.mjs +22 -1
  27. package/js/hosts/hooks-done.mjs +97 -31
  28. package/js/hosts/hooks-prims.mjs +65 -0
  29. package/js/hosts/hooks.mjs +188 -27
  30. package/js/loop/state.mjs +15 -5
  31. package/js/web/actions.mjs +17 -27
  32. package/js/web/activity.mjs +139 -23
  33. package/js/web/api.mjs +31 -13
  34. package/js/web/catalog.mjs +108 -23
  35. package/js/web/handler.mjs +4 -3
  36. package/js/web/routes.mjs +47 -14
  37. package/js/web/server.mjs +14 -13
  38. package/js/web/state.mjs +36 -15
  39. package/js/web/usage-api.mjs +7 -3
  40. package/package.json +1 -1
  41. package/src/agents/_template.md +3 -0
  42. package/src/agents/developer.md +5 -2
  43. package/src/agents/tester.md +4 -1
  44. package/src/bricks/apply.md +3 -0
  45. package/src/bricks/test.md +6 -4
  46. package/src/loops/bugfix.json +11 -5
  47. package/src/loops/feature.json +7 -4
  48. package/src/skills/loop.md +1 -0
  49. package/src/skills/ship.md +9 -1
  50. package/web/dist/assets/Activity-Bjy64wHC.js +1 -0
  51. package/web/dist/assets/ActivityDetail-B0AaipP8.js +1 -0
  52. package/web/dist/assets/{Bonsai-CN4rRAHc.js → Bonsai-CJniRqaH.js} +1 -1
  53. package/web/dist/assets/{CopyButton-CYljsnLo.js → CopyButton-C5Li6awl.js} +1 -1
  54. package/web/dist/assets/Dashboard-B-6DTmae.js +2 -0
  55. package/web/dist/assets/{DataTable-BWbUx4bY.js → DataTable-b9zTShqJ.js} +1 -1
  56. package/web/dist/assets/{Docs-DE04qOKj.js → Docs-LRc30XL9.js} +2 -2
  57. package/web/dist/assets/{EmptyState-1sPNleqv.js → EmptyState-CY5Pm2xy.js} +1 -1
  58. package/web/dist/assets/FilterInput-qGKNSlxv.js +1 -0
  59. package/web/dist/assets/{GreenhouseView-DPwhFO_j.js → GreenhouseView-CcoYlaWo.js} +1 -1
  60. package/web/dist/assets/Installs-dp1epTcE.js +3 -0
  61. package/web/dist/assets/JournalView-nFP4poCf.js +1 -0
  62. package/web/dist/assets/{KitApply-BN2Az7dc.js → KitApply-DwyZUj57.js} +1 -1
  63. package/web/dist/assets/{Kits-C9qVd466.js → Kits-C0IEdZXe.js} +1 -1
  64. package/web/dist/assets/Laws-CkykmQWu.js +3 -0
  65. package/web/dist/assets/Library-Guh9HBZU.js +2 -0
  66. package/web/dist/assets/Loops-CzitjxGV.js +2 -0
  67. package/web/dist/assets/Markdown-C4S4tTA7.js +69 -0
  68. package/web/dist/assets/{OperatorHudView-CLN6Qn25.js → OperatorHudView-DLGNulIY.js} +1 -1
  69. package/web/dist/assets/Personal-BMtberL8.js +2 -0
  70. package/web/dist/assets/RailCats-D5weYPCS.js +1 -0
  71. package/web/dist/assets/Tabs-uYJqfuQt.js +1 -0
  72. package/web/dist/assets/api-BxjLd7Qd.js +1 -0
  73. package/web/dist/assets/index-DA7BiaE5.js +3 -0
  74. package/web/dist/assets/index-dbbDGFDq.css +1 -0
  75. package/web/dist/assets/{motion-CXaUMNkg.js → motion-Bccx3zE8.js} +1 -1
  76. package/web/dist/assets/react-C1iE8mnY.js +9 -0
  77. package/web/dist/assets/rolldown-runtime-XKyaHtl9.js +1 -0
  78. package/web/dist/assets/{usePoll-bDFN-Hr6.js → usePoll-o8ul-Sog.js} +1 -1
  79. package/web/dist/index.html +6 -6
  80. package/web/dist/assets/Activity-C8pQvnos.js +0 -1
  81. package/web/dist/assets/ActivityDetail-D_8Bx-QO.js +0 -1
  82. package/web/dist/assets/Dashboard-DkUm4XMu.js +0 -2
  83. package/web/dist/assets/FilterInput-CZREvrjX.js +0 -1
  84. package/web/dist/assets/Installs-DmPzD4BW.js +0 -3
  85. package/web/dist/assets/JournalView-DQlDC-7i.js +0 -1
  86. package/web/dist/assets/Laws-T2wbwMmB.js +0 -3
  87. package/web/dist/assets/Library-t3KocV0-.js +0 -2
  88. package/web/dist/assets/Loops-6lNY-9uR.js +0 -2
  89. package/web/dist/assets/Markdown-DpmmtW2Y.js +0 -65
  90. package/web/dist/assets/Personal-xjoSqCzr.js +0 -2
  91. package/web/dist/assets/RailCats-BuJD4Jou.js +0 -1
  92. package/web/dist/assets/Tabs-DaExAgql.js +0 -1
  93. package/web/dist/assets/api-LvBC0CnK.js +0 -1
  94. package/web/dist/assets/index-DhNNxhfg.js +0 -3
  95. package/web/dist/assets/index-XTGBLKQr.css +0 -1
  96. package/web/dist/assets/react-DlYQp10C.js +0 -9
  97. package/web/dist/assets/rolldown-runtime-hePW80VL.js +0 -1
package/CHANGELOG.md CHANGED
@@ -8,6 +8,40 @@ label. For the capability ↔ spec map, see [SHIPPED.md](SHIPPED.md).
8
8
 
9
9
  ## [Unreleased]
10
10
 
11
+ ## [4.32.0] — 2026-11-05
12
+
13
+ Minor: shell writes reach the rule gate, a weakened test is reported at the end of the turn, a loop `pass` cannot hide a skipped check, and the `feature` and `bugfix` loops prove their tests. Run `geneseed rebuild-all` once after updating to get the new hooks, agents and loops.
14
+
15
+ ### Added
16
+ - **The rule gate reads shell writes.** The targets of `>`, `>>`, `tee`, `sed -i`, `cp`, `mv` and `rm` now get the protected-checks and gate-configuration checks, by path only: a prompt on Claude Code and OpenClaude, a refusal on OpenCode and Bob. Scripts, interpreter one-liners, `npm run`, variables, globs and subshell tricks stay unseen, so keep running the checks in CI. Run `geneseed rebuild-all` to pick up the OpenCode plugins.
17
+ - **A weakened test is reported, as an advisory.** An edit of a test file that adds a skip marker or removes an assertion leaves the agent a note and adds a `[done-gate] advisory` line when the turn ends, citing *Cure the Cause*. It never asks or blocks. Bob gets a log line, OpenCode a reminder on the next request.
18
+ - **A `Runtime floor:` line at session start.** A git root whose `package.json` has no `engines` field gets one context line that asks the agent to name the supported runtime before it adds a dependency or a language feature. Run `geneseed rebuild-all` to pick up the OpenCode plugin.
19
+ - **A `STATUS:` first line in agent reports.** The developer and tester output contracts, and the agent template, start with `STATUS: OK|BLOCKED|OUT_OF_SCOPE|ERROR`. In ownership mode, `blocked: decision needed` follows `STATUS: BLOCKED`.
20
+
21
+ ### Changed
22
+ - **Inferred done checks stay advisory, with no date.** The 4.29.0 note that called them "advisory in this release" promised a change that is not coming: only a list the project wrote in `.geneseed/done-checks.txt` can block.
23
+ - **The web console can switch the ownership gate.** The Constitution page has a switch inside the *Ownership* row of the Credo band: a click asks, then rebuilds the install with or without `--no-ownership-gate`. The row reads *Hook gate* or *Gate off*, and the Credo's pill counts it while it is off. The Gate asks card now names the gate, reads it off, and lands on its row; before, its link led nowhere.
24
+ - **The ship skill deletes a branch once it is merged, local and remote, including after a PR merge.** Before, it deleted a branch only after a local merge, so on a PR-based repo every merged branch stayed on the remote (this repo reached 156). It asks first, as for any deletion, and the first time it ships in a repo it checks whether the forge deletes merged branches by itself (GitHub: *Automatically delete head branches*), since a PR usually merges after the agent's turn has ended. Run `geneseed rebuild-all` to pick it up.
25
+ - **`geneseed loop record` refuses a `test` `pass` whose check list has a skipped check.** The `test` brick now writes its list to a temp file and reports the path with every outcome, so the list reaches the engine. The record fails with the entry named and `LOOP.md` does not change. `fail` and `error` with skipped checks are still accepted.
26
+ - **The `feature` loop writes a failing test first, and the `bugfix` loop proves its tests bite.** `feature` runs `red-test` before `apply`. `bugfix` runs `mutation-check` between `test` and `review`; with no mutation tool it reports `unavailable` and the loop carries on. Each `bugfix` card's write set must name the reproduction test, so a repair can strengthen it.
27
+ - **`review` and `mutation-check` notes leave `LOOP.md` when `apply` reports.** A later repair no longer reads findings about code that has changed.
28
+ - **The Library shows compact status icons, and the Overview graphs fill their cards.**
29
+
30
+ ### Fixed
31
+ - **Long install names no longer overflow** the voice menu, the Library rows and the sidebar.
32
+
33
+ ## [4.31.0] — 2026-10-31
34
+
35
+ Minor: the web console becomes one hub over every install. The top install switch is gone; Activity, Library, Rules, Profile, Memory and Notebook cover every install, and a page or control that acts on one install has its own picker next to it. Run `geneseed web restart` after updating, so the console serves the new UI.
36
+
37
+ ### Changed
38
+ - **The web console's Activity view covers every install.** It reads the `activity/` folder of every active install (OpenCode, Claude Code, Bob, OpenClaude; global and project) and shows one garden: each card carries a host chip, shelves stay grouped by repo, and collisions and loops are found across hosts. A session that two installs record in one checkout (a global and a project install of one host) is one card. The tracking switch is one row per install, and the daemon sweeps every install's old cards. An OpenCode project install has no row of its own: its sessions appear under, and follow the switch of, the OpenCode global install.
39
+ - **The web console's Library covers every install.** Skills and agents are listed once each across every active install, with a badge for each install that has it, so a skill one install leaves out stays visible. The reader shows the first install's copy (host order, global before project) and, when several installs have the entry, a "Viewing copy from" picker for that entry only. The rail counts match the combined list.
40
+ - **The web console has no install switch any more: it is one hub over every install.** The topbar selector and `POST /api/view` are gone, and the breadcrumb is the page name. A page or control that acts on one install carries its own labelled picker next to it, shown only when two or more installs are active: Doctor, Local edits and Server each remember theirs; the Constitution's gate switches and doctrine Apply, Loops and the Voice rebuild act on the install they name. Rules, Profile, Memory and Notebook list every install, each entry tagged; an edit, Forget or Promote writes back to the entry's own install, and a new rule goes where its form's "Write to:" picker says. Every per-install figure on a combined page names its install (the gate "off" badge reads "off · claude global"). The Overview is fleet-only, with each install's voice, footprint, posture, mode and memory count in its row. A request that names no install reads the default install: the first active one in host order, global before project.
41
+
42
+ ### Fixed
43
+ - **The web console sees an OpenCode project install.** That install keeps its manifest and the skills and agents OpenCode loads under `<repo>/.opencode/`, and the console looked for the manifest only at the repo root. So it called the install "not deployed", listed the full source catalogue instead of what the install has (skills it left out included), refused Build, could jump to another install on refresh, and built its "never used" list from the root bundle. It now reads the manifest at either place, reads skills and agents from `.opencode/`, and Build rebuilds such an install in place with the same command `rebuild-all` uses. Diff and Restore are unchanged: as for every project install, no drift check exists.
44
+
11
45
  ## [4.30.1] — 2026-10-31
12
46
 
13
47
  Patch: Bob can read a protected check again (a regression in 4.29.0 and 4.30.0). Run `geneseed rebuild-all` once after updating.
package/SHIPPED.md CHANGED
@@ -20,7 +20,7 @@ historical references, not files distributed with the repo.
20
20
  > **On version numbers.** [`harness.config.json`](harness.config.json)'s `version` is a
21
21
  > human-readable label only. The canonical identity of an installed harness is the
22
22
  > **source fingerprint** stamped in `.geneseed-version` (see `geneseed version`), not the
23
- > string. Current label: **4.30.1**.
23
+ > string. Current label: **4.32.0**.
24
24
 
25
25
  ## Capabilities
26
26
 
@@ -859,7 +859,8 @@ async function resolveBlock(root, judged = true) {
859
859
  const commands = await discoverCommands(root)
860
860
  const done = (await doneGateOff()) ? null : await doneLine(root, judged).catch(() => null)
861
861
  const owned = (await ownershipGateOff()) ? null : await ownershipLine(root).catch(() => null)
862
- const heads = [done, owned].filter(Boolean).join("\n") || null
862
+ const floor = await runtimeFloorLine(root).catch(() => null)
863
+ const heads = [done, owned, floor].filter(Boolean).join("\n") || null
863
864
  return { block: await buildBlock(sets, wikis, commands, await sessionFiles(harness), heads), src }
864
865
  }
865
866
 
@@ -894,6 +895,95 @@ async function alreadyInjected(client, sid) {
894
895
  return false
895
896
  }
896
897
 
898
+ // ---- test-weakening twin: BEGIN — adapters/opencode/plugins/geneseed-context.js carries everything
899
+ // down to the END marker verbatim, with `export ` dropped (tests/plugins/context_done.test.mjs diffs the two).
900
+
901
+ /**
902
+ * A test file: a path segment `test`, `tests`, `__tests__` or `spec`, or a name `*.test.*`,
903
+ * `*.spec.*`, `*_test.*` or `test_*`. Give it a path relative to the repo, or an ancestor
904
+ * folder named `test` makes every file a test.
905
+ */
906
+ const TEST_PATH_RE = /(?:^|[\\/])(?:tests?|__tests__|spec)[\\/]|(?:^|[\\/])test_[^\\/]*$|\.(?:test|spec)\.[^\\/]*$|_test\.[^\\/]*$/;
907
+ const isTestPath = (p) => TEST_PATH_RE.test(p);
908
+ // `\bxit`, or `process.exit(` reads as one; `(?<!mark)`, or `pytest.mark.skip(` counts twice.
909
+ const SKIP_MARKERS = [['.skip', /(?<!mark)\.skip\(/g], ['xit', /\bxit\(/g], ['xfail', /\bxfail\b/g],
910
+ ['@Disabled', /@Disabled\b/g], ['@Ignore', /@Ignore\b/g], ['pytest.mark.skip', /\bpytest\.mark\.skip/g],
911
+ ['t.Skip', /\bt\.Skip\(/g]];
912
+ const ASSERT_LINE_RE = /\bassert\w*!?\s*[.(]|\bexpect\s*\(|^assert\s/;
913
+ const COMMENT_LINE_RE = /^(?:\/\/|\/\*|\*|#)/;
914
+ // shortcut: only whole comment lines are dropped, so a marker in a string or a trailing comment, and
915
+ // any other `.skip(` (`stream().skip(1)`), still count. Upgrade by parsing the language; it is an advisory.
916
+ const code = (text) => text.split(/\r?\n/).filter((l) => !COMMENT_LINE_RE.test(l.trim())).join('\n');
917
+ // shortcut: a Set hides the loss of one of two identical lines, and `require.Equal`, `t.Errorf` and
918
+ // `.should` are not read as assertions. Upgrade by counting lines and widening `ASSERT_LINE_RE`.
919
+ const assertLines = (text) => new Set(text.split(/\r?\n/).map((l) => l.trim())
920
+ .filter((l) => ASSERT_LINE_RE.test(l) && !COMMENT_LINE_RE.test(l)));
921
+
922
+ /**
923
+ * What `pairs` of `[old, new]` text do to a test, as labels: a skip marker the new text has more
924
+ * of (`.skip added`), or an assertion line gone with none new in its place (`assertion removed`).
925
+ * A comment is no assertion, so commenting one out removes it. Cure the Cause's advisory half.
926
+ */
927
+ function weakenedBy(pairs) {
928
+ const found = new Set();
929
+ for (const [before, after] of pairs) {
930
+ for (const [label, re] of SKIP_MARKERS) {
931
+ if ((code(after).match(re) || []).length > (code(before).match(re) || []).length) found.add(`${label} added`);
932
+ }
933
+ const was = assertLines(before);
934
+ const now = assertLines(after);
935
+ if ([...was].some((l) => !now.has(l)) && [...now].every((l) => was.has(l))) found.add('assertion removed');
936
+ }
937
+ return [...found];
938
+ }
939
+ // ---- test-weakening twin: END
940
+
941
+ // A weakened test (Cure the Cause), ADVISORY. OpenCode has no turn end to report at, so a write is
942
+ // read before it runs and the next request carries one reminder, on OpenCode 1 and 2 alike: both
943
+ // expose the tool's input before it runs, unlike the tool parts the done gate reads on V1 alone.
944
+ // shortcut: a call the guard then refuses still counts; move to an after-hook if that ever misleads.
945
+ const WEAKENED = new Map() // sessionID -> Map(path -> labels)
946
+ function testEditPairs(tool, args, before) {
947
+ const t = String(tool).toLowerCase()
948
+ if (t === "write" && typeof args.content === "string") return [[null, before, args.content]]
949
+ if (t === "edit" && typeof args.newString === "string") return [[null, String(args.oldString ?? ""), args.newString]]
950
+ if ((t !== "patch" && t !== "apply_patch") || typeof args.patchText !== "string") return []
951
+ // `*** Add|Update File: <path>` sections: `-` lines leave the file, `+` lines land in it.
952
+ const out = []
953
+ for (const line of args.patchText.split(/\r?\n/)) {
954
+ const m = /^\*\*\* (?:Add|Update) File:\s*(.+)$/.exec(line)
955
+ if (m) out.push([m[1].trim(), "", ""])
956
+ else if (out.length && /^[-+]/.test(line)) out[out.length - 1][line[0] === "-" ? 1 : 2] += `${line.slice(1)}\n`
957
+ }
958
+ return out
959
+ }
960
+ async function noteWeakened(root, sid, tool, args) {
961
+ try {
962
+ if (!sid || !args) return
963
+ const file = typeof args.filePath === "string" ? path.resolve(root, args.filePath) : null
964
+ let before = ""
965
+ if (file && String(tool).toLowerCase() === "write" && isTestPath(path.relative(root, file))) {
966
+ before = await fs.readFile(file, "utf8").catch(() => "")
967
+ }
968
+ for (const [p, was, now] of testEditPairs(tool, args, before)) {
969
+ const rel = path.relative(root, p === null ? file ?? "" : path.resolve(root, p)).replace(/\\/g, "/")
970
+ const hits = isTestPath(rel) ? weakenedBy([[was, now]]) : []
971
+ if (!hits.length) continue
972
+ if (!WEAKENED.has(sid)) WEAKENED.set(sid, new Map())
973
+ WEAKENED.get(sid).set(rel, [...new Set([...(WEAKENED.get(sid).get(rel) ?? []), ...hits])])
974
+ }
975
+ } catch (err) { log(`test-weakening error: ${err?.message ?? err}`) }
976
+ }
977
+ // The reminder owed to this session, once; null when there is none.
978
+ function takeWeakened(sid) {
979
+ const files = WEAKENED.get(sid)
980
+ if (!files) return null
981
+ WEAKENED.delete(sid)
982
+ const list = [...files].map(([rel, hits]) => `${rel} (${hits.join(", ")})`).join("; ")
983
+ return `Geneseed (Cure the Cause) — advisory: test weakened this turn: ${list}. Fix the code, not the `
984
+ + "test. State this in your closing summary, with the reason."
985
+ }
986
+
897
987
  // ---- The done gate (#289): the OpenCode twin of js/hosts/hooks-done.mjs ----------------
898
988
  // OpenCode has no turn-end event a plugin can block on, so its ceiling is a reminder: on the
899
989
  // request AFTER a turn that edited files without the project's declared checks passing
@@ -1049,6 +1139,18 @@ async function ownershipLine(dir) {
1049
1139
  return since ? `Ownership: setup declined since ${since} — not set up; say "set up ownership" to run it` : null
1050
1140
  }
1051
1141
 
1142
+ // ---- The runtime floor: the twin of js/hosts/hooks-context.mjs `runtimeFloorLine` ----
1143
+ // One line when the git root's package.json is a JSON object with no `engines` field; the hook's
1144
+ // shortcut comment names the manifests not read. No done-gate or ownership switch silences it.
1145
+ const FLOOR_LINE = "Runtime floor: package.json declares no engines — name the supported runtime before you "
1146
+ + "add a dependency or a language feature."
1147
+ async function runtimeFloorLine(dir) {
1148
+ const root = await gitRootOf(dir)
1149
+ if (!root) return null
1150
+ const pkg = await readJson(path.join(root, "package.json"))
1151
+ return pkg && typeof pkg === "object" && !Array.isArray(pkg) && pkg.engines === undefined ? FLOOR_LINE : null
1152
+ }
1153
+
1052
1154
  function runsUnpiped(command, line) {
1053
1155
  const cmd = String(command).replace(/[ \t]+/g, " ")
1054
1156
  for (let i = cmd.indexOf(line); i !== -1; i = cmd.indexOf(line, i + 1)) {
@@ -1237,6 +1339,10 @@ export const GeneseedContext = async (ctx) => {
1237
1339
  })
1238
1340
 
1239
1341
  return {
1342
+ "tool.execute.before": async (input, output) => {
1343
+ await noteWeakened(root, input?.sessionID, input?.tool, output?.args)
1344
+ },
1345
+
1240
1346
  event: async ({ event }) => {
1241
1347
  if (!event || INJECT_OFF) return
1242
1348
  if (await sovereignBypass(root)) return
@@ -1311,6 +1417,16 @@ export const GeneseedContext = async (ctx) => {
1311
1417
  })
1312
1418
  log("transform: done-gate reminder injected")
1313
1419
  })().catch((err) => log(`done-gate error: ${err?.message ?? err}`))
1420
+ // The weakened-test reminder, on the same switch: it needs no checks, so not inside the above.
1421
+ const weakened = !(await doneGateOff()) && takeWeakened(sid)
1422
+ if (weakened) {
1423
+ const stamp = Date.now()
1424
+ output.messages.unshift({
1425
+ info: { id: `geneseed-weakened-${stamp}`, role: "user", sessionID: sid, time: { created: stamp } },
1426
+ parts: [{ id: `geneseed-weakened-part-${stamp}`, type: "text", text: weakened }],
1427
+ })
1428
+ log("transform: test-weakening reminder injected")
1429
+ }
1314
1430
  if (INJECT_OFF || !TRANSFORM || fallbackVisible) return
1315
1431
  try {
1316
1432
  // Already present this request? (idempotent across plugin copies / retries.)
@@ -1374,8 +1490,27 @@ async function setupV2(ctx) {
1374
1490
  console.error(`[geneseed-context] done gate: ${DONE_LIST} found, but OpenCode 2 turns are not judged.`)
1375
1491
  }
1376
1492
 
1493
+ // The weakened-test reminder, which INJECT_OFF and visible delivery leave on, as on V1. A V2
1494
+ // callback that throws fails the agent step, so both swallow their errors.
1495
+ await ctx.tool?.hook?.("execute.before", async (event) => {
1496
+ await noteWeakened(root, event?.sessionID, event?.tool, event?.input)
1497
+ })
1498
+ const remindWeakened = async (event) => {
1499
+ try {
1500
+ if (!Array.isArray(event?.messages) || await sovereignBypass(root) || await doneGateOff()) return
1501
+ if (await skipSession(event.sessionID)) return
1502
+ const weakened = takeWeakened(event.sessionID)
1503
+ if (weakened) event.messages.unshift(v2UserMessage(event.messages, weakened))
1504
+ } catch (err) {
1505
+ log(`test-weakening error: ${err?.message ?? err}`)
1506
+ }
1507
+ }
1508
+
1509
+ // One `context` hook either way: only `remindWeakened` in visible delivery.
1510
+ if (VISIBLE) await ctx.session.hook("context", remindWeakened)
1377
1511
  if (!VISIBLE) {
1378
1512
  await ctx.session.hook("context", async (event) => {
1513
+ await remindWeakened(event)
1379
1514
  if (INJECT_OFF) return
1380
1515
  try {
1381
1516
  if (await sovereignBypass(root)) return
@@ -1388,6 +1388,142 @@ function gateConfig(p) {
1388
1388
  return false
1389
1389
  }
1390
1390
 
1391
+ // The files `gateConfig` leaves to OpenCode's native `permission.edit` ask (`opencodeEditAsks` in
1392
+ // js/hosts/settings.mjs). That ask covers edit tools only: a shell command never reaches it, and
1393
+ // this tool hook has no ask tier, so for a SHELL write these are refused. The agent can still
1394
+ // make the edit through an edit tool, where the user gets the prompt. The key shapes are the emit's,
1395
+ // matched as a path tail; tests/plugins/guard.test.mjs walks `opencodeEditAsks`'s own output.
1396
+ // A project `AGENT.md` in a subfolder has no fixed name, so its keys are read back from the
1397
+ // opencode.json the emit wrote beside the install, only when a shell write names a target at all.
1398
+ function agentAskTails(cfg) {
1399
+ const tails = []
1400
+ for (const f of ["opencode.json", "opencode.jsonc"]) {
1401
+ try {
1402
+ const edit = JSON.parse(stripJsonc(readFileSync(path.join(path.dirname(cfg), f), "utf8")))?.permission?.edit
1403
+ for (const k of Object.keys(edit ?? {})) {
1404
+ const tail = k.replace(/^\*(?:\.\.)?\/?/, "")
1405
+ if (/\/AGENT\.md$/i.test(tail)) tails.push(tail)
1406
+ }
1407
+ } catch { /* none, or unreadable: the fixed names below still hold */ }
1408
+ }
1409
+ return tails
1410
+ }
1411
+ function nativeAskFile(p) {
1412
+ try {
1413
+ const cfg = path.dirname(PLUGIN_DIR)
1414
+ const name = path.basename(cfg)
1415
+ const tails = ["opencode.json", "opencode.jsonc", ...[".claude", ".openclaude", ".bob"].flatMap((m) =>
1416
+ [`${m}/settings.json`, `${m}/settings.local.json`]), ".bob/settings/settings.json", ".geneseed/bin/*",
1417
+ ...["excludes.json", ".geneseed-manifest.json", ".geneseed-emit", "plugins/geneseed-*.js", "AGENT.md", "config.json"]
1418
+ .map((f) => `${name}/${f}`), ...agentAskTails(cfg)]
1419
+ const fold = (s) => nocase(s.replace(/\\/g, "/"))
1420
+ const asked = tails.map((t) => new RegExp(`(?:^|/)${fold(t).replace(/[.+?^${}()|[\]\\]/g, "\\$&").replace(/\*/g, "[^/]*")}$`))
1421
+ // Its own try: a home that cannot be read costs the shim dir, never the entries above.
1422
+ let bin = null
1423
+ try { bin = fold(path.join(resolvePath(process.env.GENESEED_HOME || "~/.geneseed"), "bin")) } catch { /* no shim dir */ }
1424
+ const agents = [cfg, path.dirname(cfg)].map((d) => fold(path.join(d, "AGENT.md")))
1425
+ for (const target of [path.resolve(p), resolvePath(p)]) {
1426
+ const t = fold(target)
1427
+ if (asked.some((re) => re.test(t)) || agents.includes(t) || (bin && t.startsWith(`${bin}/`))) return true
1428
+ }
1429
+ } catch { /* an unresolvable path is no hit, like `protectedIn` */ }
1430
+ return false
1431
+ }
1432
+
1433
+ // ---- shell-write twin: BEGIN — adapters/opencode/plugins/geneseed-guard.js carries everything down
1434
+ // to the END marker verbatim, with `export ` dropped (tests/plugins/guard.test.mjs diffs the two).
1435
+
1436
+ // The cheap prefilter, a superset of what the parse acts on: a `>`, or one of the programs as a word.
1437
+ const SHELL_WRITE_RE = />|(?:^|[\s;&|("'`\\/])(?:tee|sed|cp|mv|rm)(?:\.exe)?(?=[\s;&|)"'`]|$)/im;
1438
+ // One pass over a segment: a quoted run (kept: its `>` is data), or a redirection with its optional
1439
+ // fd, operator, `&` (a dup such as `2>&1`, which writes no file) and target word. `<` forms match
1440
+ // too, so that their words never read as operands. A backslash is no escape here, as in
1441
+ // `SCAN_SPLIT_RE`: `echo "say \"hi > f\""` closes its quote early, reads a target, and asks (on Bob, blocks).
1442
+ const REDIRECT_RE = /"[^"]*"?|'[^']*'?|(?:(?<!\S)\d+|&)?(<<?<?-?|>>?)[ \t]*(&?)((?:[^\s"';|&<>()]|"[^"]*"?|'[^']*'?)*)/g;
1443
+ const SHELL_CD = new Set(['cd', 'pushd', 'chdir', 'set-location', 'sl']);
1444
+
1445
+ /** `t` as an absolute path from `dir`, `~/…` as it stands, or null for what the shell rewrites. */
1446
+ function writePath(dir, t) {
1447
+ if (/[$`*?{}\0]/.test(t) || /^~[^\\/]/.test(t) || /^(?:\/dev\/|nul$)/i.test(t)) return null;
1448
+ if (t[0] === '~') return t;
1449
+ // A Git Bash `/c/…` path, as `resolveIn` reads it.
1450
+ const q = process.platform === 'win32' ? t.replace(/^\/([a-zA-Z])(?=\/|$)/, '$1:') : t;
1451
+ if (path.isAbsolute(q)) return path.resolve(q);
1452
+ return dir ? path.resolve(dir, q) : null;
1453
+ }
1454
+
1455
+ /** The files `sed` edits in place: none without `-i`; else its operands, past the script if inline. */
1456
+ function sedFiles(args) {
1457
+ const ops = [];
1458
+ let inPlace = false; let script = false; let flags = true;
1459
+ for (let i = 0; i < args.length; i += 1) {
1460
+ const a = args[i];
1461
+ if (flags && a === '--') flags = false;
1462
+ else if (flags && /^--in-place(?:=|$)/.test(a)) inPlace = true;
1463
+ else if (flags && (a === '--expression' || a === '--file')) { script = true; i += 1; }
1464
+ else if (flags && /^--(?:expression|file)=/.test(a)) script = true;
1465
+ else if (flags && /^-[a-zA-Z]*i/.test(a)) inPlace = true;
1466
+ else if (flags && /^-[a-zA-Z]*[ef]$/.test(a)) { script = true; i += 1; }
1467
+ else if (!flags || !a.startsWith('-') || a === '-') { if (a) ops.push(a); }
1468
+ }
1469
+ return inPlace ? ops.slice(script ? 0 : 1) : [];
1470
+ }
1471
+
1472
+ /**
1473
+ * The files `command` would write, as absolute paths: redirect targets (`>`, `>>`, `&>`), `tee`
1474
+ * and `rm` operands, `sed -i` files, the destination of `cp` and `mv`, and the sources of `mv`, which
1475
+ * it removes. A destination may be a folder, so `cp a tests/` also names `tests/a`. Read like
1476
+ * `rootScan`: quotes, comments and heredoc bodies are data. A `cd` is followed; one it cannot read
1477
+ * leaves later relative paths unseen. What it cannot read, it leaves out: this reader fails OPEN.
1478
+ *
1479
+ * shortcut: KNOWN UNSEEN FORMS, all of them still a write. An interpreter (inline code,
1480
+ * `bash -c`, `eval`, `xargs`), a script or `npm run`, a `$(…)` or subshell trick, `>|`, a path with a
1481
+ * variable, glob or brace in it, a wrapper with flags (`sudo -u x`) or outside `SCAN_WRAPPERS` (`env rm`,
1482
+ * `nohup rm`, `timeout 5 rm`, `exec rm`), `echo x >& file` (read as a dup), a `popd` (not followed, so
1483
+ * relative paths after a `pushd`/`popd` pair resolve from the wrong folder), `cp -t`, any other writer
1484
+ * (`dd`, `ln`, `install`, `git mv`, `git checkout`, `Set-Content`), and a folder removed above a
1485
+ * listed file (`rm -r tests` when only `tests/a.test.js` is listed). CI running the checks is the
1486
+ * boundary that holds against those.
1487
+ */
1488
+ function shellWriteTargets(command, cwd) {
1489
+ if (!SHELL_WRITE_RE.test(command)) return [];
1490
+ const found = new Set();
1491
+ let dir = cwd;
1492
+ const add = (t) => { const p = writePath(dir, t); if (p) found.add(p); };
1493
+ const bare = (t) => t.replace(/["']/g, '');
1494
+ for (const seg of scanSegments(command)) {
1495
+ const outs = [];
1496
+ const body = seg.replace(REDIRECT_RE, (m, op, dup, target) => {
1497
+ if (op === undefined) return m;
1498
+ if (op[0] === '>' && !dup && target) outs.push(bare(target));
1499
+ return ' ';
1500
+ });
1501
+ let toks = stripStructure(body.match(SCAN_TOKEN_RE) || []);
1502
+ while (toks.length && (/^\w+=/.test(toks[0]) || SCAN_WRAPPERS.has(bare(toks[0])))) toks = toks.slice(1);
1503
+ const prog = toks.length ? bare(toks[0]).split(/[\\/]/).pop().toLowerCase().replace(/\.exe$/, '') : '';
1504
+ const args = toks.slice(1).map(bare);
1505
+ const dashes = args.indexOf('--');
1506
+ const ops = args.filter((a, i) => a && (a === '-' || !a.startsWith('-') || (dashes >= 0 && i > dashes)));
1507
+ if (SHELL_CD.has(prog)) {
1508
+ const to = ops.find((a) => !/^\/d$/i.test(a));
1509
+ dir = to && to !== '-' ? writePath(dir, to) : null;
1510
+ } else if (prog === 'rm' || prog === 'tee') ops.forEach(add);
1511
+ else if (prog === 'sed') sedFiles(args).forEach(add);
1512
+ else if ((prog === 'cp' || prog === 'mv') && ops.length > 1) {
1513
+ const dest = ops[ops.length - 1];
1514
+ const sources = ops.slice(0, -1);
1515
+ add(dest);
1516
+ for (const s of sources) {
1517
+ add(`${dest.replace(/[\\/]+$/, '')}/${s.split(/[\\/]/).pop()}`);
1518
+ if (prog === 'mv') add(s);
1519
+ }
1520
+ }
1521
+ outs.forEach(add);
1522
+ }
1523
+ return [...found];
1524
+ }
1525
+ // ---- shell-write twin: END
1526
+
1391
1527
  // ---- the ownership first-write gate --------------------------------------------
1392
1528
  // Twin of js/hosts/ownership-gate.mjs's `ownershipBlock` — keep in step (same manifests, same
1393
1529
  // managed-block strip, same section match, same reason). In an application repo (a git root
@@ -1592,12 +1728,19 @@ export const GeneseedGuard = async (ctx) => {
1592
1728
  "search a specific directory instead: the project, node_modules, ~/.npm, %APPDATA%", "ops-2")
1593
1729
  return
1594
1730
  }
1731
+ // OpenCode's bash tool may run in `workdir`, resolved against the session directory.
1732
+ const wd = typeof args.workdir === "string" && args.workdir ? path.resolve(cwd, args.workdir) : cwd
1595
1733
  if (c && !DELETION_GATE_OFF && LOSS_CANDIDATE_RE.test(c)) {
1596
- // OpenCode's bash tool may run in `workdir`, resolved against the session directory.
1597
- const wd = typeof args.workdir === "string" && args.workdir ? path.resolve(cwd, args.workdir) : cwd
1598
1734
  const loss = lossReason(cut(c), wd, { always: false, split: cut })
1599
1735
  if (loss) { await deny(`${loss} (Deletion Is Deliberate) — confirm with the user first`, "law-4"); return }
1600
1736
  }
1737
+ // External Gate over a shell write: the same paths as a write tool, no content scan. A
1738
+ // throw fails open through the catch below, as the twin's `shellWriteReason` does.
1739
+ for (const p of c ? shellWriteTargets(c, wd) : []) {
1740
+ const sensor = protectedCheck(p)
1741
+ if (sensor) { await deny(`${p} is a protected check (${sensor === DONE_LIST ? "the done gate list itself" : `${sensor}, listed in ${SENSOR_LIST}`}) — a check the agent can edit is not a check (External Gate)`, "rigor-5"); return }
1742
+ if (gateConfig(p) || nativeAskFile(p)) { await deny(`${p} ${GATE_CONFIG_ASK} (External Gate)`, "rigor-5"); return }
1743
+ }
1601
1744
  }
1602
1745
  } catch (err) {
1603
1746
  // Our own deny must propagate; any inspection error must never break a tool call.
@@ -113,7 +113,7 @@ The [ownership](ownership.md) first-write gate is not a Rule's gate: it stops th
113
113
  geneseed build --emit claude-global --no-ownership-gate
114
114
  ```
115
115
 
116
- The install records `Ownership gate: off` beside the other gate markers, written only when off; rebuilds, upgrades and `geneseed status` carry it. The console has no switch for it, because it has no Rule row. What stops: the ownership check of `rule-gate` (Claude Code, OpenClaude) and of `tool-gate` (Bob), on OpenCode the guard plugin's ownership refusal, the setup proposal in the install's `AGENT.md` (the build drops that sentence), and the session-start decline reminder. A repo with `mode: on` still runs the ownership checkpoints, and every other check of those gates stays.
116
+ The install records `Ownership gate: off` beside the other gate markers, written only when off; rebuilds, upgrades and `geneseed status` carry it. The console's Constitution page has a switch for it inside the *Ownership* row of the Credo band: open the row, and a gate line follows the section's text. The gate belongs to no Rule, and that line exists only in the console. The section's text always binds, so the row's status stays *Always*. *Enforced by* reads **Gate off** while the gate is off, and the Credo's pill on the Precedence ladder counts it. What stops: the ownership check of `rule-gate` (Claude Code, OpenClaude) and of `tool-gate` (Bob), on OpenCode the guard plugin's ownership refusal, the setup proposal in the install's `AGENT.md` (the build drops that passage, and the `/document-project` suggestion in it goes too), and the session-start decline reminder. A repo with `mode: on` still runs the ownership checkpoints, and every other check of those gates stays.
117
117
 
118
118
  Two narrower ways out need no rebuild: `## Ownership` with `mode: off` in a repo's root `AGENTS.md` silences it for that repo and its team; answering "skip in this repo until I ask" writes `Setup: declined <YYYY-MM-DD>` into your personal `.geneseed/ownership.md`, which silences it for you alone in that repo until you delete the line or ask for the setup; and answering "skip this session" lets the session write on.
119
119
 
@@ -42,7 +42,7 @@ Footprint is stored in a `.geneseed-footprint` marker in the install and kept ac
42
42
  geneseed setup
43
43
  ```
44
44
 
45
- - **Web console** — each install's own panel on the Hosts page changes its footprint and rebuilds it; Settings shows the viewed install's footprint and links there. A new install or deploy from the console starts lean, as from the command line.
45
+ - **Web console** — each install's own panel on the Hosts page changes its footprint and rebuilds it; Settings shows the footprint of the install its own picker names and links there. A new install or deploy from the console starts lean, as from the command line.
46
46
  - **Command line** — with the emit target of the install you are changing:
47
47
 
48
48
  ```bash
@@ -37,7 +37,7 @@ The merge is surgical. Every other key and every hook of your own survive, and t
37
37
  **Bob** has its own contract. It uses Claude's event names but ignores a hook's output before a tool call — the only way to refuse is exit code 2 — and it has no tool matcher or `SubagentStop`. Bob 2.2.3 does have `PreCompact` and `PostCompact`, but Geneseed does not wire them yet. So Bob gets four hooks:
38
38
 
39
39
  - `SessionStart` → `geneseed-hook context`.
40
- - `PreToolUse` → `geneseed-hook tool-gate`, the git gate and the rule gate fused into one command that decides from the shape of the call. It **blocks** (exit 2) only for the checks that admit no judgement call: secrets, destructive git, a recursive scan of a whole filesystem, and a write under a project's own protected-checks list. The commit/push and rule-or-memory checks become a warning line, because a hard block would leave Bob unable to commit at all. The [ownership](ownership.md) gate also exits 2, but only once per session and repo: the same write passes after the developer answers.
40
+ - `PreToolUse` → `geneseed-hook tool-gate`, the git gate and the rule gate fused into one command that decides from the shape of the call. It **blocks** (exit 2) only for the checks that admit no judgement call: secrets, destructive git, a recursive scan of a whole filesystem, a write under a project's own protected-checks list, and writes that would switch a gate off. The commit/push and rule-or-memory checks become a warning line, because a hard block would leave Bob unable to commit at all. The [ownership](ownership.md) gate also exits 2, but only once per session and repo: the same write passes after the developer answers.
41
41
  - `Stop` → `geneseed-hook learn`.
42
42
  - `UserPromptSubmit` → `geneseed-hook activity`, which records the turn for the Activity view.
43
43
 
@@ -39,7 +39,7 @@ On Bob, a subagent's files cannot be told apart from its session's files (its ho
39
39
 
40
40
  ## What each one does, and what you see
41
41
 
42
- **context.** Before your first message, the agent receives your own harness files — `user-rules.md`, `PROFILE.md`, the memory index, the notebook index, your wiki declaration — skipping any still untouched since install, then the repo's docs, discovered by convention or listed in a `context.json`. Each file is capped at 16 KB and the whole injection at 48 KB; what does not fit is listed for the agent to read on demand. You see nothing, except that the agent already knows your project. See [Project context](../guides/project-context.md).
42
+ **context.** Before your first message, the agent receives your own harness files — `user-rules.md`, `PROFILE.md`, the memory index, the notebook index, your wiki declaration — skipping any still untouched since install, then the repo's docs, discovered by convention or listed in a `context.json`. Each file is capped at 16 KB and the whole injection at 48 KB; what does not fit is listed for the agent to read on demand. A git root whose `package.json` has no `engines` field adds one `Runtime floor:` line, which asks the agent to name the supported runtime before it adds a dependency or a language feature. You see nothing, except that the agent already knows your project. See [Project context](../guides/project-context.md).
43
43
 
44
44
  **git-gate.** Runs before every shell command and looks for `git` in it, including chained one-liners and `git -C <path>` forms, and for a recursive scan of a whole filesystem.
45
45
  - **A catastrophic command** gets a confirmation prompt citing *Deletion Is Deliberate* (on Bob, it is refused with exit 2) whatever the repository holds, even with the deletion gate switched off: a recursive removal of `/`, a drive root (`C:\`, `/c`) or the home directory (`~`, `$HOME`), `mkfs` on a device, `dd` over a raw disk, `format C:`, a fork bomb. It judges the program, not the text: a `sudo`, a background `&`, a subshell, `bash -c '…'` or a heredoc fed to a shell (`bash <<'EOF'`) hides nothing, and a heredoc fed to anything else (`cat`, `git commit -F -`) or a commit message that only names `rm -rf /` passes. The OpenCode guard runs the same code, plus its own stricter text match.
@@ -55,12 +55,13 @@ On Bob, a subagent's files cannot be told apart from its session's files (its ho
55
55
  A force push to a feature branch, the protected-branch-only forms above on a feature branch, a new branch (`checkout -b`, `switch -c`), `reset --hard` over uncommitted work or to a commit that keeps every unpushed one, `branch -D` of a pushed branch, or `rm` of a tracked, unmodified file passes. When the gate cannot tell — a glob or `$variable` it would have to expand, a `cd` it cannot follow, `sh -c`/`xargs`, git failing or missing — it asks, and says it could not verify. To read the state it runs `git` itself, only once a command already looked destructive; every other command pays nothing. That is a Rule, so it holds in every build — unless you switch its gate off for one install with `--no-deletion-gate` (or the switch on Rule IV in the console's Constitution page). The hook is then wired with `--no-deletion-gate` and this check stands down; the Rule's text still binds the agent, and the catastrophic-command check above and the root-scan and consent checks below still run ([Exclusions](exclusions.md)).
56
56
  - **Every `git commit` and `git push`** gets a prompt citing *Consent Before Push*. This part belongs to the **process** doctrine pack: build without it, or exclude that rule, and the hook stays wired with `--no-consent` — commits and pushes go through without asking, real data loss is still stopped ([Rules](rules.md)).
57
57
  - **A recursive scan of a whole filesystem** — `find /`, `du -sh /`, `grep -r foo /`, `rg x C:\`, `Get-ChildItem C:\ -Recurse` — gets a prompt citing *Commands Must Return* (on Bob, it is blocked). In Git Bash `/` mounts every drive and mounted share, so such a scan runs for hours, and `| head` does not stop it. The prompt tells the agent to search a specific directory instead. A deeper path (`find /c/Users/me/project`), `ls /` without `-R` (`ls -r` is reverse order, not recursion), a quoted argument (a search pattern such as `grep -rn "/" src`), a `#` comment, and the remote half of an `ssh` command pass. This check is wired in every build, whatever packs or rules you excluded: it rides inside `git-gate` with no flag of its own, because a new flag or verb would reach machines still running an older hook shim, which would refuse it — and Claude Code blocks a tool call whose gate fails.
58
+ - **A shell write to a protected check or a gate's own configuration** gets the same *External Gate* prompt as a write tool (see rule-gate below; on Bob, it is blocked). `--no-consent` does not touch it.
58
59
  - Any other command passes untouched.
59
60
 
60
61
  **rule-gate.** Runs before every file write.
61
62
  - Content that looks like a credential (a cloud access key, a GitHub or Anthropic token, a Slack token, a private-key block) going into any file other than `.env*` gets a prompt citing *Sealed Secrets*. An install built `--no-secrets-gate` wires the hook with that flag and this check alone stands down ([Exclusions](exclusions.md)).
62
63
  - A write to `user-rules.md`, `MEMORY.md` or a file in the install's `memory/` gets a prompt citing *Persist Insight*: whether something is a standing rule or a fact to remember is your call, settled through the `rule` [skill](skills.md).
63
- - A write to a check the project protects gets a prompt citing *External Gate* (on Bob, it is blocked). The list is `.geneseed/protected-checks.txt` at the project's git root: one repo-relative file or folder per line, `#` for comments — the checks and tests the agent is judged by. A project install (any host) seeds it when it is absent, with only the paths that exist there: CI (`.github/workflows/`, `.gitlab-ci.yml`, `Jenkinsfile`, `azure-pipelines.yml`, `.circleci/`), lint, type and test config (`eslint.config.*`, `.eslintrc*`, `biome.json(c)`, `tsconfig.json`, `jest.config.*`, `vitest.config.*`, `pytest.ini`, `ruff.toml`, `.golangci.yml`, `checkstyle.xml`), and the manifests the done gate infers its checks from (`package.json`, `pom.xml`, `build.gradle(.kts)`, `pyproject.toml`, `Cargo.toml`, `go.mod`). It is seeded once and is yours from then on: Geneseed never rewrites it, never deletes it on uninstall, and never touches a list that already exists. To opt out, delete the listed paths (the comments may stay) but keep the file. An existing list, even one holding only comments, is never seeded again; a deleted file is. A global install seeds nothing. Whenever `.geneseed/` exists, the emit also makes sure it holds the personal-by-default `.gitignore`. A check the agent can edit is not a check. The list protects itself. Only file-write tools are seen: a shell `sed -i` or redirect is not, so run the same checks in CI as the boundary that holds.
64
+ - A write to a check the project protects gets a prompt citing *External Gate* (on Bob, it is blocked). The list is `.geneseed/protected-checks.txt` at the project's git root: one repo-relative file or folder per line, `#` for comments — the checks and tests the agent is judged by. A project install (any host) seeds it when it is absent, with only the paths that exist there: CI (`.github/workflows/`, `.gitlab-ci.yml`, `Jenkinsfile`, `azure-pipelines.yml`, `.circleci/`), lint, type and test config (`eslint.config.*`, `.eslintrc*`, `biome.json(c)`, `tsconfig.json`, `jest.config.*`, `vitest.config.*`, `pytest.ini`, `ruff.toml`, `.golangci.yml`, `checkstyle.xml`), and the manifests the done gate infers its checks from (`package.json`, `pom.xml`, `build.gradle(.kts)`, `pyproject.toml`, `Cargo.toml`, `go.mod`). It is seeded once and is yours from then on: Geneseed never rewrites it, never deletes it on uninstall, and never touches a list that already exists. To opt out, delete the listed paths (the comments may stay) but keep the file. An existing list, even one holding only comments, is never seeded again; a deleted file is. A global install seeds nothing. Whenever `.geneseed/` exists, the emit also makes sure it holds the personal-by-default `.gitignore`. A check the agent can edit is not a check. The list protects itself. A shell command is read too: the targets of `>`, `>>`, `tee`, `sed -i`, `cp`, `mv` and `rm` get the same check, by path only (no secret scan of the command), through the git gate. `mv` counts its source as well, and a read (`cat x > /tmp/y`) counts only `/tmp/y`. What the reader cannot follow stays unseen: interpreters with inline code, scripts, `npm run`, variables, globs, subshell tricks, a folder removed above a listed file. So run the same checks in CI as the boundary that holds.
64
65
  - A write to `.geneseed/done-checks.txt`, the done gate's own list (below), gets the same *External Gate* prompt: emptying it would disarm the gate.
65
66
  - A write to a gate's own configuration gets the same *External Gate* prompt on Claude Code and OpenClaude. These files can switch a gate off:
66
67
  - In the install's own dir: `settings.json`, `settings.local.json` and Bob global's `settings/settings.json` (the hook wiring), `excludes.json`, `AGENT.md` (its `… gate: off` markers), `.geneseed-manifest.json` and `.geneseed-emit`.
@@ -69,11 +70,12 @@ On Bob, a subagent's files cannot be told apart from its session's files (its ho
69
70
  - On OpenCode, also the install's `opencode.json(c)` and its own `plugins/geneseed-*.js`.
70
71
  - **OpenCode** asks with its own prompt. The emit writes `permission.edit` "ask" keys into `opencode.json`: every `opencode.json(c)`, the global `config.json`, the install's `AGENT.md` (where the emit put it), the install dir's `excludes.json`, manifest, `.geneseed-emit` and `plugins/geneseed-*.js`, the `.claude/`, `.openclaude/` and `.bob/` hook settings, and the shim dir. A blanket `"edit": "allow"` becomes `{"*": "allow", …}` with the asks after it. A blanket `"ask"` or `"deny"` already covers them and is left alone; a key you set yourself is kept and named in a warning. The manifest records the keys Geneseed added (`edit_asks`, `edit_shorthand`); a rebuild drops a recorded key it no longer wants, and uninstall takes back the ones still set to `"ask"` and restores your `"allow"`. The guard plugin refuses only the other hosts' Geneseed-only files (`excludes.json`, `AGENT.md`, manifest) and an `AGENT.md` under `$GENESEED_HARNESS`. These rules match by name, not through a link, a project `opencode.json` with its own `"edit": "allow"` replaces a global install's object, and a custom `$GENESEED_HOME` is named by its absolute path, which only OpenCode 2 matches. In OpenCode's built-in plan agent, these files are asked about rather than refused.
71
72
  - **Bob** has no prompt, so it blocks, and only writes: a read passes, and so does a write to `opencode.json(c)`, which Bob never reads. A hook `settings.json` (or `settings.local.json`, or global `settings/settings.json`) is blocked only when the write changes Geneseed's own entries (a hook whose command names `geneseed-hook`, with its event and matcher), turns on `disableAllHooks`, or changes a `GENESEED_*`, `*_CONFIG_DIR` or `NODE_OPTIONS` env value. An MCP server or your own hook passes. An edit the hook cannot replay exactly is blocked: a regex, case-folded or line-ranged replace, a search not found exactly once, a diff of more than one block, an unknown write-shaped tool (its name says write, edit, diff, replace or insert; a tool named otherwise is not judged), or a file left unparseable or turned from strict JSON into JSONC. The other files stay blocked.
72
- Names match exactly, and on Windows without regard to case or slash direction; a link into one of these paths is caught too. To change one of these files, edit it yourself, or approve the prompt. `geneseed` commands (`exclude`, a rebuild) write these files directly and are never asked. Claude Code itself also prompts for writes under `.claude/` in its default and `acceptEdits` modes, but not in `bypassPermissions`, so you can see two prompts there. Only file-write tools are seen, as above.
73
+ Names match exactly, and on Windows without regard to case or slash direction; a link into one of these paths is caught too. To change one of these files, edit it yourself, or approve the prompt. `geneseed` commands (`exclude`, a rebuild) write these files directly and are never asked. Claude Code itself also prompts for writes under `.claude/` in its default and `acceptEdits` modes, but not in `bypassPermissions`, so you can see two prompts there. A shell write is read as above. On OpenCode `permission.edit` covers edit tools only, so the guard refuses a shell write to every file in this list; the same edit through an edit tool gets the prompt. On Bob a shell write to a hook `settings.json` is blocked: a command line cannot be replayed.
73
74
  - The first write of a session in an application repo (a git root holding a build manifest) whose root `AGENTS.md` has no `## Ownership` section is refused once, the **ownership gate**. It is not a prompt for you: the reason goes to the agent, which asks you to set ownership up now, skip this session, or skip in this repo until you ask (on Bob, exit 2, once). The next write passes, a sub-agent never triggers it on Claude Code and OpenClaude, and writes to `AGENTS.md` or `.geneseed/` pass. Off per repo with `mode: off` in that section; for you alone in one repo with `Setup: declined <YYYY-MM-DD>` in your personal `.geneseed/ownership.md`, which also makes every session start with the line `Ownership: setup declined since <date> — not set up; say "set up ownership" to run it`; per install with `--no-ownership-gate`, which prints no such line ([Ownership](ownership.md), [Exclusions](exclusions.md)).
75
+ - An edit that weakens a test gets a note to the agent, citing *Cure the Cause*. It is **advisory**: it asks nothing and blocks nothing. A test file has a path segment `test`, `tests`, `__tests__` or `spec`, or a name `*.test.*`, `*.spec.*`, `*_test.*` or `test_*`. The edit weakens it when it adds `.skip(`, `xit(`, `xfail`, `@Disabled`, `@Ignore`, `pytest.mark.skip` or `t.Skip(`, or when it removes an assertion line and adds no other. The done gate repeats it to you when the turn ends. On Bob the note is a line in the hook log. On OpenCode it is one reminder on the next request.
74
76
  - Ordinary edits pass untouched.
75
77
 
76
- **The done gate.** Runs when a turn ends, inside `learn` and before it calls any model. You do not have to set it up: with no list, the gate infers the checks from the manifests at the project's git root — the `test`, `lint` and `typecheck` scripts of `package.json` (run with the package manager its lockfile names; npm's default "no test specified" script is skipped), `mvn test` for `pom.xml`, `gradle test` for `build.gradle(.kts)`, `pytest` for `pyproject.toml` when the project shows pytest (a `[tool.pytest` section, `pytest.ini`, `conftest.py` or a `tests/` folder), `cargo test` for `Cargo.toml`, `go test` for `go.mod`. Subprojects of a monorepo are not inferred. Each inferred check accepts its usual spellings: `npm test`, `npm run test` and `npm t` all count, and so do `./mvnw clean verify` or `.\gradlew build` — but not with a flag that skips the tests (`-DskipTests`, `-Dmaven.test.skip`, `-x test`, `cargo test --no-run`). Spellings it does not know (`npm run test:unit`, `npx vitest`, `CI=1 npm test`, `./gradlew :app:test`) read as not run. Inferred checks are **advisory**: a turn that ends without them still ends, and you see a warning naming them (a `systemMessage`), plus a `done-gate-advisory` line in the gate ledger. To make the gate block, or to choose the checks yourself, list them in `.geneseed/done-checks.txt` at the git root: one command per line, `#` for comments, for example `npm run lint` and `node --test`. That file replaces the inference; a file that lists nothing turns the gate off for the project. With a listed file, if the turn edited a file under that root and a listed check has not passed since the last edit, the turn does not end: the agent is told which checks are owed, citing *Verify Before Asserting*. Every session starts with one line naming the checks and their source, for example `Done gate: inferred from package.json — npm test, npm run lint (advisory)`. On Bob, which never judges a turn, the line ends `(not judged on this host)` instead. A check counts when it ran as a shell command, unpiped (`npm test | tail` exits with `tail`'s code, so it proves nothing), with nothing after it that masks its exit code (`|| true`, `; true`, `; exit 0` all exit 0 on a red suite, so any `||` after the check, or a `;` or newline followed by `true`, `:`, `exit 0` or a bare `exit`, reads as "not run"), and its result was not an error. The gate never runs a check itself. It reads the transcript from its end, back only to the prompt that opened the turn, so its cost does not grow with the session. It blocks at most once per turn; the second stop ends the turn and leaves a line in the gate ledger. Only file-write tools count as edits: a shell `sed -i` or redirect is not seen. On OpenCode the gate is a reminder on the next request (OpenCode 1 only), listed or inferred; on Bob, whose Stop carries no transcript, the turn is not judged, and with a listed file a log line says so. An install built `--no-done-gate` wires `learn` with that flag: the check is skipped, learning still runs ([Exclusions](exclusions.md)).
78
+ **The done gate.** Runs when a turn ends, inside `learn` and before it calls any model. You do not have to set it up: with no list, the gate infers the checks from the manifests at the project's git root — the `test`, `lint` and `typecheck` scripts of `package.json` (run with the package manager its lockfile names; npm's default "no test specified" script is skipped), `mvn test` for `pom.xml`, `gradle test` for `build.gradle(.kts)`, `pytest` for `pyproject.toml` when the project shows pytest (a `[tool.pytest` section, `pytest.ini`, `conftest.py` or a `tests/` folder), `cargo test` for `Cargo.toml`, `go test` for `go.mod`. Subprojects of a monorepo are not inferred. Each inferred check accepts its usual spellings: `npm test`, `npm run test` and `npm t` all count, and so do `./mvnw clean verify` or `.\gradlew build` — but not with a flag that skips the tests (`-DskipTests`, `-Dmaven.test.skip`, `-x test`, `cargo test --no-run`). Spellings it does not know (`npm run test:unit`, `npx vitest`, `CI=1 npm test`, `./gradlew :app:test`) read as not run. Inferred checks are **advisory**, and they stay advisory, with no date: only a list the project wrote can block. A turn that ends without them still ends, and you see a warning naming them (a `systemMessage`), plus a `done-gate-advisory` line in the gate ledger. To make the gate block, or to choose the checks yourself, list them in `.geneseed/done-checks.txt` at the git root: one command per line, `#` for comments, for example `npm run lint` and `node --test`. That file replaces the inference; a file that lists nothing turns the gate off for the project. With a listed file, if the turn edited a file under that root and a listed check has not passed since the last edit, the turn does not end: the agent is told which checks are owed, citing *Verify Before Asserting*. Every session starts with one line naming the checks and their source, for example `Done gate: inferred from package.json — npm test, npm run lint (advisory)`. On Bob, which never judges a turn, the line ends `(not judged on this host)` instead. A check counts when it ran as a shell command, unpiped (`npm test | tail` exits with `tail`'s code, so it proves nothing), with nothing after it that masks its exit code (`|| true`, `; true`, `; exit 0` all exit 0 on a red suite, so any `||` after the check, or a `;` or newline followed by `true`, `:`, `exit 0` or a bare `exit`, reads as "not run"), and its result was not an error. The gate never runs a check itself. It reads the transcript from its end, back only to the prompt that opened the turn, so its cost does not grow with the session. It blocks at most once per turn; the second stop ends the turn and leaves a line in the gate ledger. Only file-write tools count as edits: a shell `sed -i` or redirect is not one here. When a turn weakened a test (see the rule gate), the gate adds a line that the agent cannot suppress, `[done-gate] advisory — test weakened this turn: tests/a.test.js (.skip added)`. The line needs no checks and stays out of the ask counts. `--no-done-gate` silences this line and OpenCode's reminder, but not the note the agent gets at edit time on Claude Code, OpenClaude and Bob: the rule gate never receives that flag. A block prints only the block; the line comes at the stop that ends the turn. On OpenCode the gate is a reminder on the next request (OpenCode 1 only), listed or inferred; on Bob, whose Stop carries no transcript, the turn is not judged, and with a listed file a log line says so. An install built `--no-done-gate` wires `learn` with that flag: the check is skipped, learning still runs ([Exclusions](exclusions.md)).
77
79
 
78
80
  **learn.** Takes the tail of the transcript and asks a model to distil what is worth keeping into one-fact-per-file entries under `memory/`. It is shown the facts already stored, so it updates one with the merged text rather than writing a twin (the old version is kept in `memory/archive/`), and moves one the session proved obsolete into `memory/archive/`. It needs `GENESEED_LLM` set to a model command, for example:
79
81
 
@@ -26,7 +26,7 @@ Every [host](hosts.md) gets the same content. This table is what each one lets G
26
26
 
27
27
  ✅ native · ⚙️ OpenCode plugin · 🔒 `permission` entry in `opencode.json` · 🪝 `settings.json` hook · ➖ no host mechanism (the rule still applies as prose).
28
28
 
29
- ¹ **Bob** has its own hook contract: Claude's event names, but it ignores a hook's output on `PreToolUse`, so the only way to refuse is exit code 2. Geneseed therefore blocks only the rules that admit no judgement call — secrets, real data loss, a recursive scan of a whole filesystem, and a write under a project's own protected-checks list — and turns the two consent checks into a logged warning. It has no `SubagentStop` event. Bob 2.2.3 does have `PreCompact` and `PostCompact`, but Geneseed does not wire them yet, so learn runs on `Stop` only. **What is verified:** the payload shape (Claude's keys plus `cwd`), the event list and the strict settings schema were read in Bob 2.2.3's shipped bundle on the authoring machine, and a live prompt on 2026-10-25 wrote an Activity snapshot from `UserPromptSubmit`. The gates' block-by-exit-code behaviour is Bob's documented contract, not yet observed live; the rules preamble still holds if a hook does not fire.
29
+ ¹ **Bob** has its own hook contract: Claude's event names, but it ignores a hook's output on `PreToolUse`, so the only way to refuse is exit code 2. Geneseed therefore blocks only the rules that admit no judgement call — secrets, real data loss, a recursive scan of a whole filesystem, a write under a project's own protected-checks list, and writes that would switch a gate off — and turns the two consent checks into a logged warning. It has no `SubagentStop` event. Bob 2.2.3 does have `PreCompact` and `PostCompact`, but Geneseed does not wire them yet, so learn runs on `Stop` only. **What is verified:** the payload shape (Claude's keys plus `cwd`), the event list and the strict settings schema were read in Bob 2.2.3's shipped bundle on the authoring machine, and a live prompt on 2026-10-25 wrote an Activity snapshot from `UserPromptSubmit`. The gates' block-by-exit-code behaviour is Bob's documented contract, not yet observed live; the rules preamble still holds if a hook does not fire.
30
30
  ² **OpenClaude** is a Claude Code fork and gets Claude's hooks and verdicts verbatim, in `~/.openclaude/settings.json` (global) or `.openclaude/settings.local.json` (per repo). **Unverified live** for the same reason.
31
31
  ³ OpenCode's plugin hook can only allow or throw — there is no "ask the user" — so the rule-or-memory check stops the first such write once rather than prompting, and a real data loss is blocked outright (as on Bob) rather than asked; `GENESEED_GUARD=warn` turns the block into a logged warning.
32
32
  ⁴ The checks differ in shape: OpenCode's guard plugin blocks writes *to* private-key and credential files by path; the Claude-shaped hook looks at the *content* being written for credential-shaped strings (cloud keys, tokens, private-key blocks) and asks. A `.env` file is exempt on the hook side — that is where a secret is allowed to live.
@@ -34,7 +34,7 @@ the repository.
34
34
 
35
35
  ## Java notes for the newer bricks
36
36
 
37
- - **`mutation-check`** (`legacy-tests`) prefers PIT on a Maven build: `mvn test-compile
37
+ - **`mutation-check`** (`legacy-tests`, `bugfix`) prefers PIT on a Maven build: `mvn test-compile
38
38
  org.pitest:pitest-maven:mutationCoverage -DtargetClasses=<fq.Class*>
39
39
  -DreportsDirectory=<OS temp dir> -DtimestampedReports=false`, and needs `pitest-junit5-plugin`
40
40
  on the classpath under JUnit 5; on Gradle, the `info.solidsoft.pitest` plugin's `pitest` task.
@@ -21,8 +21,10 @@ brick's behalf. This applies to `plan` and `review` as much as to the newer bric
21
21
  brick whose finding the next brick needs writes it to a file in the OS temp directory and reports
22
22
  that file's path with the outcome.
23
23
 
24
- One exception keeps the verdict fresh: each `test` report replaces every earlier `test` note, so a
25
- repair reads only the findings for the code as it stands, never a trace from an older version.
24
+ Two exceptions keep the verdict fresh: each `test` report replaces every earlier `test` note, so a
25
+ repair reads only the findings for the code as it stands, never a trace from an older version; and
26
+ when `apply` reports, every `review` and `mutation-check` note goes, since `apply` has just acted
27
+ on those findings.
26
28
 
27
29
  ## `description` and `rules`: what a template is for, and what every brick must do
28
30
 
@@ -10,8 +10,8 @@ The loop templates Geneseed ships. Each is a graph of [bricks](loop-bricks.md) w
10
10
 
11
11
  | template | purpose | when to use |
12
12
  |---|---|---|
13
- | `bugfix` | reproduce, fix, test, review a defect | a reported bug with a reproduction step |
14
- | `feature` | plan, then build and review in small iterations | new behaviour with no existing test pinning it |
13
+ | `bugfix` | reproduce, fix, test, mutation-check, review a defect | a reported bug with a reproduction step |
14
+ | `feature` | plan, then build test-first and review in small iterations | new behaviour with no existing test pinning it |
15
15
  | `refactor` | restructure behind the existing tests, no behaviour change | the tests already cover the code you're moving |
16
16
  | `tdd` | plan, then write each failing test before the code that passes it | you want the test written first, every iteration |
17
17
  | `legacy-tests` | pin undocumented behaviour with characterization tests, mutation-checked, production code untouched | code with no tests and no spec, before anyone risks changing it |
@@ -30,12 +30,15 @@ The loop templates Geneseed ships. Each is a graph of [bricks](loop-bricks.md) w
30
30
  maps every acceptance criterion to a passing test (or a stated manual check) and reports `fail`
31
31
  with what's missing rather than trusting the iterations that already ran.
32
32
 
33
+ `feature` writes each card's failing test first, through `red-test`, as `tdd` does: the card's write
34
+ set must name a test file, and `untestable` stops the loop.
35
+
33
36
  `legacy-tests` and `legacy-refactor` both open on `baseline-green` — the suite must already be
34
37
  green before either template pins anything, and `baseline-green` reporting `fail` stops the loop
35
38
  rather than characterizing a change no one can tell from existing breakage.
36
39
 
37
- `mutation-check`, inside `legacy-tests`, needs a mutation tool on the stack (Stryker, PIT, mutmut,
38
- cargo-mutants) to prove the new characterization tests actually bite. With none configured it
40
+ `mutation-check`, inside `legacy-tests` and `bugfix`, needs a mutation tool on the stack (Stryker, PIT,
41
+ mutmut, cargo-mutants) to prove the new tests actually bite. With none configured it
39
42
  reports `unavailable` rather than a silent `pass` — and still writes a note saying what it checked,
40
43
  so the gap is visible in `LOOP.md` rather than just absent from it.
41
44
 
@@ -54,6 +54,9 @@ rings (`apply-test`, `fix-test`, `write-run`, `stabilise`) are `max: 2`: two rep
54
54
  attempt is discarded for one fresh try, then the loop stops for you. Most of the gain is in the
55
55
  first revision — 0.82 correct after one, 0.673 after two (arXiv 2607.24604) — but a second still
56
56
  lands fixes the first missed, so it is kept as the last chance, and nothing past it.
57
+ `review-fix` stays at `max: 3`, a deliberate exception to the two-repair rule of Bound the Loop: a
58
+ review round is a verdict from a separate reviewer, not a blind repair of one's own red test. In
59
+ `bugfix` the same budget also pays for `mutation-check` repairs, each one a mutation tool's verdict.
57
60
 
58
61
  **`error` always stops.** A brick may declare the outcome `error` without an edge for it; the
59
62
  engine sends it to `$stop`. The shipped `test` brick reports it when a check crashed or its
@@ -60,7 +60,7 @@ Per host: Claude Code and OpenClaude deny the call with the reason; Bob refuses
60
60
  | One session | Answer "skip this session" when the agent asks | This session; it asks again in the next one |
61
61
  | One repo, for you | Answer "skip in this repo until I ask": the agent writes `Setup: declined <YYYY-MM-DD>` into your personal `.geneseed/ownership.md` in the main worktree — from a linked git worktree, the main checkout's, so the decline survives each new worktree (Claude Desktop opens one per session) | No expiry: until you delete the line or ask for the setup; never committed, so it never reaches the team. Each session opens with the reminder `Ownership: setup declined since <date> — not set up; say "set up ownership" to run it` |
62
62
  | One repo, for the team | `## Ownership` with `mode: off` in the root `AGENTS.md` | Until the line changes; travels with the repo |
63
- | One install | Rebuild with `--no-ownership-gate` ([Exclusions](exclusions.md)) | Every rebuild replays it |
63
+ | One install | Open the *Ownership* row and flip its gate switch, in the Credo band of the web console's Constitution page, or rebuild with `--no-ownership-gate` ([Exclusions](exclusions.md)) | Every rebuild replays it |
64
64
 
65
65
  The decline is looked up only in the main worktree; the `## Ownership` section and the manifest are read from the git root you work in. A decline left inside a linked worktree is ignored, and a `.git` file that names no gitdir falls back to the current root. If the host refuses the write to the main checkout (outside the session's working directory, a sandbox, a declined permission prompt), the agent tells you the decline was not saved and why; it never writes it inside the linked worktree instead. A `## Ownership` section, on or off, outranks a personal decline: the line is then ignored and no reminder prints. The per-install switch stops the gate, drops the setup proposal from the install's `AGENT.md`, and prints no decline reminder. A repo with `mode: on` still runs the ownership checkpoints, and the Credo section still binds.
66
66