geneseed 4.31.0 → 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.
- package/CHANGELOG.md +22 -0
- package/SHIPPED.md +1 -1
- package/adapters/opencode/plugins/geneseed-context.js +136 -1
- package/adapters/opencode/plugins/geneseed-guard.js +145 -2
- package/docs/concepts/exclusions.md +1 -1
- package/docs/concepts/hook-gates.md +1 -1
- package/docs/concepts/hooks.md +6 -4
- package/docs/concepts/host-matrix.md +1 -1
- package/docs/concepts/loop-bricks.md +1 -1
- package/docs/concepts/loop-notes.md +4 -2
- package/docs/concepts/loop-templates.md +7 -4
- package/docs/concepts/loops.md +3 -0
- package/docs/concepts/ownership.md +1 -1
- package/docs/guides/run-a-loop.md +1 -1
- package/docs/guides/set-up-ownership.md +1 -1
- package/docs/reference/loop-actions.md +1 -1
- package/docs/reference/plugin-context.md +4 -0
- package/docs/reference/plugin-guard.md +1 -1
- package/docs/understand/enforced-vs-asked.md +3 -2
- package/docs/understand/machine-bob.md +1 -1
- package/docs/web-ui.md +15 -5
- package/harness.config.json +1 -1
- package/js/hosts/hooks-context.mjs +22 -1
- package/js/hosts/hooks-done.mjs +97 -31
- package/js/hosts/hooks-prims.mjs +65 -0
- package/js/hosts/hooks.mjs +188 -27
- package/js/loop/state.mjs +15 -5
- package/js/web/actions.mjs +4 -4
- package/js/web/api.mjs +2 -2
- package/package.json +1 -1
- package/src/agents/_template.md +3 -0
- package/src/agents/developer.md +5 -2
- package/src/agents/tester.md +4 -1
- package/src/bricks/apply.md +3 -0
- package/src/bricks/test.md +6 -4
- package/src/loops/bugfix.json +11 -5
- package/src/loops/feature.json +7 -4
- package/src/skills/loop.md +1 -0
- package/src/skills/ship.md +9 -1
- package/web/dist/assets/{Activity-B7cFtS00.js → Activity-Bjy64wHC.js} +1 -1
- package/web/dist/assets/{ActivityDetail-C-GbMmuW.js → ActivityDetail-B0AaipP8.js} +1 -1
- package/web/dist/assets/{Bonsai-_YyexVC5.js → Bonsai-CJniRqaH.js} +1 -1
- package/web/dist/assets/{CopyButton-IXnXzH4Y.js → CopyButton-C5Li6awl.js} +1 -1
- package/web/dist/assets/Dashboard-B-6DTmae.js +2 -0
- package/web/dist/assets/{DataTable-BWbUx4bY.js → DataTable-b9zTShqJ.js} +1 -1
- package/web/dist/assets/{Docs-w3Y7M5Ts.js → Docs-LRc30XL9.js} +1 -1
- package/web/dist/assets/{EmptyState-1sPNleqv.js → EmptyState-CY5Pm2xy.js} +1 -1
- package/web/dist/assets/FilterInput-qGKNSlxv.js +1 -0
- package/web/dist/assets/{GreenhouseView-BWWbMKmg.js → GreenhouseView-CcoYlaWo.js} +1 -1
- package/web/dist/assets/Installs-dp1epTcE.js +3 -0
- package/web/dist/assets/JournalView-nFP4poCf.js +1 -0
- package/web/dist/assets/{KitApply-CQQbnThf.js → KitApply-DwyZUj57.js} +1 -1
- package/web/dist/assets/{Kits-aj07N7mT.js → Kits-C0IEdZXe.js} +1 -1
- package/web/dist/assets/Laws-CkykmQWu.js +3 -0
- package/web/dist/assets/Library-Guh9HBZU.js +2 -0
- package/web/dist/assets/{Loops-C5u7fQOR.js → Loops-CzitjxGV.js} +1 -1
- package/web/dist/assets/Markdown-C4S4tTA7.js +69 -0
- package/web/dist/assets/{OperatorHudView-Blu1lqiZ.js → OperatorHudView-DLGNulIY.js} +1 -1
- package/web/dist/assets/{Personal-ox_MktWO.js → Personal-BMtberL8.js} +1 -1
- package/web/dist/assets/RailCats-D5weYPCS.js +1 -0
- package/web/dist/assets/{Tabs-CIPyMAX-.js → Tabs-uYJqfuQt.js} +1 -1
- package/web/dist/assets/index-DA7BiaE5.js +3 -0
- package/web/dist/assets/index-dbbDGFDq.css +1 -0
- package/web/dist/assets/{motion-CXaUMNkg.js → motion-Bccx3zE8.js} +1 -1
- package/web/dist/assets/react-C1iE8mnY.js +9 -0
- package/web/dist/assets/rolldown-runtime-XKyaHtl9.js +1 -0
- package/web/dist/assets/{usePoll-bDFN-Hr6.js → usePoll-o8ul-Sog.js} +1 -1
- package/web/dist/index.html +5 -5
- package/web/dist/assets/Dashboard-sCfEjowQ.js +0 -2
- package/web/dist/assets/FilterInput-CZREvrjX.js +0 -1
- package/web/dist/assets/Installs-CnkdJ-VA.js +0 -3
- package/web/dist/assets/JournalView-C7bPD3fZ.js +0 -1
- package/web/dist/assets/Laws-DZ38nl_H.js +0 -3
- package/web/dist/assets/Library-QCGXPV5h.js +0 -2
- package/web/dist/assets/Markdown-DpmmtW2Y.js +0 -65
- package/web/dist/assets/RailCats-BuJD4Jou.js +0 -1
- package/web/dist/assets/index-0GCxkY7m.css +0 -1
- package/web/dist/assets/index-CzDi9JpF.js +0 -3
- package/web/dist/assets/react-DlYQp10C.js +0 -9
- package/web/dist/assets/rolldown-runtime-hePW80VL.js +0 -1
|
@@ -17,10 +17,14 @@ One of the [OpenCode plugins](opencode-plugins.md). Its switches are also listed
|
|
|
17
17
|
|
|
18
18
|
**When it runs.** On every request: the context rides invisibly in the request's message list, so it also survives compaction. If your OpenCode build lacks that (experimental) hook, the plugin notices and falls back to one visible message at session start, re-pushed when the session compacts.
|
|
19
19
|
|
|
20
|
+
**The weakened-test reminder.** A write tool call that adds a skip marker to a test file or removes an assertion (the rule in [Hooks](../concepts/hooks.md)) makes the next request carry one invisible message citing *Cure the Cause*, on OpenCode 1 and 2. It is advisory, needs no checks, and an install built `--no-done-gate` does not say it. The call is read before it runs, so one the guard then refuses is still named.
|
|
21
|
+
|
|
20
22
|
**The done gate's reminder.** The project's checks come from `.geneseed/done-checks.txt`, or, without that file, are inferred from the manifests at the project's git root (see [Hooks](../concepts/hooks.md)). A request that follows a turn which edited files without every check passing since gets one more invisible message naming the checks owed (inferred ones marked advisory). OpenCode has no turn-end event a plugin can block on, so this is a reminder, not a block. OpenCode 1 only: on OpenCode 2 the turn is not judged, and with a listed file the plugin logs that once. The context block also opens with one line naming the checks and their source (`Done gate: …`), ending `(reminder)` for a listed file or `(advisory)` for inferred checks on OpenCode 1, and `(not judged on this host)` on OpenCode 2. `GENESEED_CONTEXT_INJECT=off` does not turn the reminder off; a done list that lists nothing does, and so does an install built `--no-done-gate` (`Done gate: off` in its `AGENT.md`, read once when OpenCode starts), which also silences the OpenCode 2 log line and the context line.
|
|
21
23
|
|
|
22
24
|
**The ownership decline line.** In an application repo whose root `AGENTS.md` has no `## Ownership` section, a `Setup: declined <YYYY-MM-DD>` line in the personal `.geneseed/ownership.md` of the main worktree (the main checkout's, from a linked git worktree) adds one line beside the done line: `Ownership: setup declined since <date> — not set up; say "set up ownership" to run it`. An install built `--no-ownership-gate` (`Ownership gate: off` in its `AGENT.md`, read once when OpenCode starts) prints no such line.
|
|
23
25
|
|
|
26
|
+
**The runtime floor line.** A git root whose `package.json` has no `engines` field adds one line after those: `Runtime floor: package.json declares no engines — name the supported runtime before you add a dependency or a language feature.` There is no line when `engines` exists, when there is no `package.json`, or when the file is not a JSON object.
|
|
27
|
+
|
|
24
28
|
**What you see.** Normally nothing — the context is there, but not shown. With the visible fallback, a `PROJECT CONTEXT` block at the top of the session.
|
|
25
29
|
|
|
26
30
|
**Switches.**
|
|
@@ -10,7 +10,7 @@ One of the [OpenCode plugins](opencode-plugins.md). [Environment variables](envi
|
|
|
10
10
|
|
|
11
11
|
**What it does.** Enforces the safety rules at the tool boundary — before a tool call runs, not after. High-confidence patterns only, so legitimate work is not caught.
|
|
12
12
|
|
|
13
|
-
- **Blocks** writes to private-key and credential files and writes whose content carries a credential (*Sealed Secrets*; an install built `--no-secrets-gate` carries `Secrets gate: off` in its `AGENT.md`, read once at load, and both stop blocking), catastrophic shell commands such as deleting the filesystem root and every command that would really lose data — a protected branch deleted or force-pushed, an unpushed unmerged branch deleted, a protected branch force-moved off commits nothing else holds, unpushed commits abandoned by `reset --hard`, uncommitted work discarded other than by `reset --hard`, a stash dropped, files git cannot restore removed — judged against the repository's state, the same decisions the Claude/Bob hook makes (*Deletion Is Deliberate*; `reflog expire` and `gc --prune` are left to the `permission.bash` ask; an install built `--no-deletion-gate` carries `Deletion gate: off` in its `AGENT.md`, which the plugin reads once at load and then stops blocking real loss — catastrophic commands still block), a recursive scan rooted at a whole filesystem such as `find /` (*Commands Must Return* — search a specific directory instead), and any change — write, move, rename, delete — under a wiki folder declared `protected` in `geneseed-wiki.jsonc`, and writes to a check listed in the project's `.geneseed/protected-checks.txt` (*External Gate* — see [Hooks](../concepts/hooks.md)).
|
|
13
|
+
- **Blocks** writes to private-key and credential files and writes whose content carries a credential (*Sealed Secrets*; an install built `--no-secrets-gate` carries `Secrets gate: off` in its `AGENT.md`, read once at load, and both stop blocking), catastrophic shell commands such as deleting the filesystem root and every command that would really lose data — a protected branch deleted or force-pushed, an unpushed unmerged branch deleted, a protected branch force-moved off commits nothing else holds, unpushed commits abandoned by `reset --hard`, uncommitted work discarded other than by `reset --hard`, a stash dropped, files git cannot restore removed — judged against the repository's state, the same decisions the Claude/Bob hook makes (*Deletion Is Deliberate*; `reflog expire` and `gc --prune` are left to the `permission.bash` ask; an install built `--no-deletion-gate` carries `Deletion gate: off` in its `AGENT.md`, which the plugin reads once at load and then stops blocking real loss — catastrophic commands still block), a recursive scan rooted at a whole filesystem such as `find /` (*Commands Must Return* — search a specific directory instead), and any change — write, move, rename, delete — under a wiki folder declared `protected` in `geneseed-wiki.jsonc`, and writes to a check listed in the project's `.geneseed/protected-checks.txt` (*External Gate* — see [Hooks](../concepts/hooks.md)). The guard also refuses a write to the other hosts' Geneseed-only files (their `excludes.json`, `AGENT.md` and manifests); OpenCode's own config and the shared hook settings get `permission.edit` "ask" keys in `opencode.json` instead, so you see OpenCode's prompt. A shell write is read as well: the targets of `>`, `>>`, `tee`, `sed -i`, `cp`, `mv` and `rm` get the same path checks, by path only. `permission.edit` never sees a shell command and this hook has no ask tier, so a shell write to those "ask" files is refused too.
|
|
14
14
|
- **Refuses once** 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, so the agent proposes the [ownership](../concepts/ownership.md) setup first; the next write passes, and a sub-agent's session never triggers it. Off per repo with `mode: off` in that section, or for one developer with a personal `Setup: declined <YYYY-MM-DD>` line in `.geneseed/ownership.md`; an install built `--no-ownership-gate` carries `Ownership gate: off` in its `AGENT.md`, read once at load.
|
|
15
15
|
- **Warns** (logged, allowed) on `.env` writes.
|
|
16
16
|
- **Speed-bumps** the *first* write to `user-rules.md` or a memory file: it is refused once, naming *Persist Insight* — whether something is a standing rule or a fact to remember is your call, settled through the `rule` skill. The re-issued write goes through.
|
|
@@ -28,11 +28,12 @@ On Claude Code and OpenClaude the hooks never block silently. They make the host
|
|
|
28
28
|
- **Credentials**: a write or edit whose content looks like a real key (AWS, GitHub, Anthropic, Slack, or a private-key block), anywhere except a `.env` file.
|
|
29
29
|
- **Your rules and memory**: any write by the agent to `user-rules.md` or to the memory store. Whether something is a standing rule or a fact to remember is your call.
|
|
30
30
|
- **The first write in an application with no ownership setup**: in a repo with a build manifest whose root `AGENTS.md` has no `## Ownership` section, the session's first write is refused once, with the reason sent to the agent rather than to you: it then asks you to set [ownership](../concepts/ownership.md) up now, skip this session, or skip in this repo until you ask. Off per repo with `mode: off`, for you alone in one repo with `Setup: declined <YYYY-MM-DD>` in `.geneseed/ownership.md`, per install with `--no-ownership-gate`.
|
|
31
|
-
- **
|
|
31
|
+
- **The checks you are judged by, and the gates' own switches**: a write to a file listed in `.geneseed/protected-checks.txt`, to the done gate's list, or to a file that can switch a gate off (the hook settings, `excludes.json`, a gate marker in `AGENT.md`, the hook shim). You get a prompt. A shell write counts too, for the common forms: `>`, `>>`, `tee`, `sed -i`, `cp`, `mv`, `rm`. A script or an interpreter's inline code is not seen, so run the checks in CI as well.
|
|
32
|
+
- **Ending a turn without the proof**: only in a project whose `.geneseed/done-checks.txt` lists at least one check; a file that lists none turns the gate off for that project. A turn that edited files cannot end until every listed check has passed since the last edit. The agent is stopped once, then the turn may end. Without that file, Geneseed infers the checks from the project's manifest (`package.json` scripts, Maven, Gradle, `pyproject.toml`, `Cargo.toml`, `go.mod`): you get a warning when a turn ends without them, but the turn is not stopped.
|
|
32
33
|
|
|
33
34
|
If a gate crashes, it asks instead of letting the call through. If it cannot start at all (a deleted or broken shim) or times out, Claude Code blocks the call instead: see [Troubleshoot hooks](../reference/troubleshoot-hooks.md) to recover. Other shell commands go through Claude Code's normal permission flow; an `rm` of files git cannot restore is the real-loss case above.
|
|
34
35
|
|
|
35
|
-
**Bob** runs one combined gate and has no "ask": it refuses with exit code 2, and only for the rules that admit no judgement call: credentials, destructive git, a scan of a whole filesystem,
|
|
36
|
+
**Bob** runs one combined gate and has no "ask": it refuses with exit code 2, and only for the rules that admit no judgement call: credentials, destructive git, a 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 memory checks become a log line, and the call goes through. The ownership gate also refuses with exit 2, but once: the same write passes after you answer. Bob's hook wiring follows its documentation but has not been tested on a live Bob install.
|
|
36
37
|
|
|
37
38
|
<!--/harness-->
|
|
38
39
|
<!--harness:opencode-->
|
|
@@ -8,7 +8,7 @@ description: "Where an install lands on IBM Bob or as a plain AGENT.md bundle, a
|
|
|
8
8
|
---
|
|
9
9
|
Bob and the plain bundle carry the same rules, agents and skills as the other hosts. What differs is where they land and how much of it is enforced. The **Kind** words are explained in [What lands on your machine](on-your-machine.md).
|
|
10
10
|
|
|
11
|
-
**Bob.** A global install writes to `~/.bob/`, or `BOB_CONFIG_DIR`. Bob does not load a global `AGENTS.md`, so the rules go into `~/.bob/rules/geneseed.md`. A per-repo install writes `AGENTS.md` instead. Hooks live in `~/.bob/settings/settings.json`. Bob runs three of them: context at session start, one combined gate before each tool call, and learn at session end. Bob has no "ask" prompt, so the gate refuses outright, and only for the checks that admit no judgement call: credentials, destructive git,
|
|
11
|
+
**Bob.** A global install writes to `~/.bob/`, or `BOB_CONFIG_DIR`. Bob does not load a global `AGENTS.md`, so the rules go into `~/.bob/rules/geneseed.md`. A per-repo install writes `AGENTS.md` instead. Hooks live in `~/.bob/settings/settings.json`. Bob runs three of them: context at session start, one combined gate before each tool call, and learn at session end. Bob has no "ask" prompt, so the gate refuses outright, and only for the checks that admit no judgement call: credentials, destructive git, a write under a project's own protected-checks list, and writes that would switch a gate off. The commit/push and memory questions become log lines. One more refusal happens only once: in an application repo whose root `AGENTS.md` has no `## Ownership` section, the session's first write is refused so the agent proposes the [ownership](../concepts/ownership.md) setup, and the same write passes after you answer. Turn it off per repo with `mode: off` in that section, for yourself in one repo with `Setup: declined <YYYY-MM-DD>` in `.geneseed/ownership.md`, or per install with `--no-ownership-gate`.
|
|
12
12
|
|
|
13
13
|
**Plain bundle.** The `files` target writes `AGENT.md` and the same folders into `./Harness/` for any tool that reads `AGENT.md`. It installs no hooks and no plugins, so nothing in it is enforced.
|
|
14
14
|
|
package/docs/web-ui.md
CHANGED
|
@@ -174,11 +174,21 @@ streams the output of background jobs and keeps their history across reloads.
|
|
|
174
174
|
secrets gate, the done gate and the deletion gate (`--no-secrets-gate`, `--no-done-gate`,
|
|
175
175
|
`--no-deletion-gate`; *Enforced by* reads *Gate off* while one is off) — flipping one asks,
|
|
176
176
|
then rebuilds the install once; the other Rules read *no gate*. The ownership gate belongs
|
|
177
|
-
to no Rule, so
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
177
|
+
to no Rule, so its switch (`--no-ownership-gate`) sits inside the Ethos band's *Ownership*
|
|
178
|
+
row and works the same way. Closed, the row reads *Always* (the section's text binds whatever
|
|
179
|
+
the gate does) and *Hook gate* or *Gate off*. Open, it shows the text, then a gate line with
|
|
180
|
+
the gate's asks and the switch. That line exists only in the console and only where an install
|
|
181
|
+
can be rebuilt: with no install the row reads *Instruction*. The gate counts in *Gated* but
|
|
182
|
+
not as a Rule or a section, and the Ethos rank's pill counts it while it is off. Every tab,
|
|
183
|
+
view and filter shows the row, like the sections around it.
|
|
184
|
+
A precedence ladder heads the page (a state pill per rank; ranks 5–6 below). *Gated* and *Changed* narrow the rows; packs fold; staged doctrine changes
|
|
185
|
+
collect in a sticky *Unapplied changes* bar that holds Revert and the page's one Apply.
|
|
186
|
+
Every row expands to its full body, lazily fetched. The rail
|
|
187
|
+
entry is labelled *Constitution* while the route, the id and the badge key stay `laws`; deep links
|
|
188
|
+
are `#/item/law/ont:telos`, `#/item/law/IV`, `#/item/law/process.5` and `#/item/law/ownership` — address
|
|
189
|
+
shapes that cannot collide, because a slug carries a colon no numeral has, a doctrine
|
|
190
|
+
address carries a dot, and `ownership`, which opens the Ownership row at its gate, is a word
|
|
191
|
+
no rule uses.
|
|
182
192
|
- **Library** (`#/library`) — browse the content that has no tab of its own: **Memory ·
|
|
183
193
|
Notebook · Knowledge** (the wiki chip, which also carries the two setup manifests).
|
|
184
194
|
Constitution, Skills and Agents each have their own rail entry instead. Drill into a section, then an item, to read its
|
package/harness.config.json
CHANGED
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
"_comment": "version is a human-readable release label only; the canonical identity of an installed harness is the source fingerprint stamped in .geneseed-version (see `harness version`), not this string.",
|
|
3
3
|
"theme": "neutral",
|
|
4
4
|
"product": "Geneseed",
|
|
5
|
-
"version": "4.
|
|
5
|
+
"version": "4.32.0"
|
|
6
6
|
}
|
|
@@ -171,6 +171,27 @@ export function memoryNudge(map) {
|
|
|
171
171
|
return '';
|
|
172
172
|
}
|
|
173
173
|
|
|
174
|
+
// The one context line for a project that names no runtime; the OpenCode context plugin carries
|
|
175
|
+
// the same text (tests/plugins/context_done.test.mjs holds the two equal).
|
|
176
|
+
const FLOOR_LINE = 'Runtime floor: package.json declares no engines — name the supported runtime before you '
|
|
177
|
+
+ 'add a dependency or a language feature.';
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* `FLOOR_LINE` when the git root's package.json is a JSON object with no `engines` field, else
|
|
181
|
+
* null: no file, invalid JSON, or `engines` present (even empty). It reads the file itself:
|
|
182
|
+
* `inferDoneChecks` skips that read for a project with a done list, and an install with the done
|
|
183
|
+
* gate off never reaches it, so sharing it would tie this line to the done gate.
|
|
184
|
+
*
|
|
185
|
+
* shortcut: package.json only — pom.xml (`maven.compiler.release`), pyproject.toml
|
|
186
|
+
* (`requires-python`) and go.mod (`go`) are not read. Add one when a session in such a repo adds
|
|
187
|
+
* something its runtime cannot run.
|
|
188
|
+
*/
|
|
189
|
+
function runtimeFloorLine(root) {
|
|
190
|
+
let pkg;
|
|
191
|
+
try { pkg = JSON.parse(readText(path.join(root, 'package.json'))); } catch { return null; }
|
|
192
|
+
return pkg && typeof pkg === 'object' && !Array.isArray(pkg) && pkg.engines === undefined ? FLOOR_LINE : null;
|
|
193
|
+
}
|
|
194
|
+
|
|
174
195
|
/**
|
|
175
196
|
* The session files present under `hookRoot` and changed from their seed, as `{ rel, abs, text }`
|
|
176
197
|
* (text CRLF-folded, trailing newlines trimmed). `$GENESEED_WIKI` overrides the wiki declaration,
|
|
@@ -459,7 +480,7 @@ export function cmdContext(args) {
|
|
|
459
480
|
// The ownership decline reminder (`./ownership-gate.mjs`), under the same contract: an install
|
|
460
481
|
// built `--no-ownership-gate` carries `Ownership gate: off` and gets no line.
|
|
461
482
|
const owned = gitRoot && !gateOff('Ownership gate') ? ownershipLine(gitRoot) : null;
|
|
462
|
-
const heads = [done, owned].filter(Boolean);
|
|
483
|
+
const heads = [done, owned, gitRoot && runtimeFloorLine(gitRoot)].filter(Boolean);
|
|
463
484
|
if (!session.length && !eager.length && !lazy.length) {
|
|
464
485
|
err(`[context] nothing to load for ${root} `
|
|
465
486
|
+ '(no docs discovered, no manifest entries).\n');
|
package/js/hosts/hooks-done.mjs
CHANGED
|
@@ -11,8 +11,17 @@
|
|
|
11
11
|
* one command per line, and it BLOCKS (a present file that lists nothing switches the gate off for
|
|
12
12
|
* that project). Absent, the checks are INFERRED from the root manifests (`inferDoneChecks`), and
|
|
13
13
|
* an inferred check is ADVISORY: an unproven turn still ends, with a `systemMessage` to the user,
|
|
14
|
-
* a ledger line and a stderr line — never `decision: block`.
|
|
15
|
-
*
|
|
14
|
+
* a ledger line and a stderr line — never `decision: block`. It stays advisory, with no date: an
|
|
15
|
+
* inferred check is a guess at a project's proof, and only a list the project wrote may block
|
|
16
|
+
* (user decision 2026-11). An inferred check is a GROUP of accepted command forms (`npm test` |
|
|
17
|
+
* `npm run test` | `npm t`), satisfied by any one.
|
|
18
|
+
*
|
|
19
|
+
* THE OTHER ADVISORY: A WEAKENED TEST (Cure the Cause). A turn whose write tools added a skip marker
|
|
20
|
+
* to a test file, or dropped an assertion (`weakenedBy`), gets a `[done-gate] advisory` line in the
|
|
21
|
+
* same `systemMessage`. It needs no checks and never blocks, and `--no-done-gate` silences it as
|
|
22
|
+
* it silences the inferred advisory: `cmdLearn` does not call this module at all then. On a Write
|
|
23
|
+
* the old text comes from the transcript line's `toolUseResult.originalFile` (a string on an
|
|
24
|
+
* update, null on a create, seen in real transcripts 2026-11); without it the text reads as new.
|
|
16
25
|
*
|
|
17
26
|
* WHY IT RIDES `learn` AND NOT A VERB OR A FLAG OF ITS OWN (ADR 0010). The machine-wide shim is
|
|
18
27
|
* last-writer-wins: an older `geneseed-hook` would refuse a new verb or flag, and the Stop
|
|
@@ -33,7 +42,8 @@
|
|
|
33
42
|
* inferred checks from `doneLine`, in the SessionStart context, instead.
|
|
34
43
|
*
|
|
35
44
|
* WHAT COUNTS (shortcut: write tools only; a shell `sed -i` or redirect is not an edit here —
|
|
36
|
-
* seeing
|
|
45
|
+
* seeing every one would need `git status`, a spawn; the rule gate reads the common forms for
|
|
46
|
+
* `protected-checks.txt`, but a turn is judged on what it wrote, which a command line cannot prove):
|
|
37
47
|
* - an edit is a Write/Edit/NotebookEdit/MultiEdit whose target is under the project root and
|
|
38
48
|
* whose result is not an error (a denied write changed nothing);
|
|
39
49
|
* - a pass is a Bash/PowerShell call whose command contains one of the check's forms UNPIPED (a pipe
|
|
@@ -56,7 +66,7 @@ import { within } from '../lib/paths.mjs';
|
|
|
56
66
|
import { gitRootOf } from './gitref.mjs';
|
|
57
67
|
import { recordGate } from './hooks.mjs';
|
|
58
68
|
import { ADVISORY_VERB } from './hosts.mjs';
|
|
59
|
-
import { DONE_LIST, splitLines, tailReader } from './hooks-prims.mjs';
|
|
69
|
+
import { DONE_LIST, editPairs, isTestPath, splitLines, tailReader, weakenedBy } from './hooks-prims.mjs';
|
|
60
70
|
import { doneChecksOf } from './done-checks.mjs';
|
|
61
71
|
|
|
62
72
|
const EDIT_TOOLS = new Set(['Write', 'Edit', 'NotebookEdit', 'MultiEdit']);
|
|
@@ -133,15 +143,12 @@ function isPrompt(obj) {
|
|
|
133
143
|
}
|
|
134
144
|
|
|
135
145
|
/**
|
|
136
|
-
* The
|
|
137
|
-
*
|
|
138
|
-
*
|
|
139
|
-
*
|
|
140
|
-
* null ("read more") — a turn judged from its middle could miss its edit and wrongly pass.
|
|
141
|
-
* A check is a line (one form) or a `{ label, forms }` group; the answer lists labels.
|
|
146
|
+
* The current turn in transcript TEXT: its tool calls in order, each result's `is_error`, and the
|
|
147
|
+
* old text the host recorded for a write. `whole` false means the text is only the file's tail:
|
|
148
|
+
* with no prompt in it the turn may start earlier, so the answer is null ("read more") — a turn
|
|
149
|
+
* judged from its middle could miss its edit and wrongly pass.
|
|
142
150
|
*/
|
|
143
|
-
|
|
144
|
-
const groups = checks.map((c) => (typeof c === 'string' ? { label: c, forms: [c] } : c));
|
|
151
|
+
function turnOf(transcript, whole) {
|
|
145
152
|
const entries = [];
|
|
146
153
|
for (const line of splitLines(transcript)) {
|
|
147
154
|
if (!line.trim()) continue;
|
|
@@ -157,6 +164,7 @@ export function doneDecide(transcript, checks, root, cwd = root, whole = true) {
|
|
|
157
164
|
}
|
|
158
165
|
const calls = []; // tool_use blocks, in order
|
|
159
166
|
const results = new Map(); // tool_use_id -> is_error
|
|
167
|
+
const originals = new Map(); // tool_use_id -> the file before a Write
|
|
160
168
|
for (const obj of entries.slice(start)) {
|
|
161
169
|
if (obj.isSidechain) continue;
|
|
162
170
|
const content = obj.message && obj.message.content;
|
|
@@ -164,15 +172,58 @@ export function doneDecide(transcript, checks, root, cwd = root, whole = true) {
|
|
|
164
172
|
for (const b of content) {
|
|
165
173
|
if (!b || typeof b !== 'object') continue;
|
|
166
174
|
if (b.type === 'tool_use') calls.push(b);
|
|
167
|
-
else if (b.type === 'tool_result')
|
|
175
|
+
else if (b.type === 'tool_result') {
|
|
176
|
+
results.set(b.tool_use_id, b.is_error === true);
|
|
177
|
+
const before = obj.toolUseResult && obj.toolUseResult.originalFile;
|
|
178
|
+
if (typeof before === 'string') originals.set(b.tool_use_id, before);
|
|
179
|
+
}
|
|
168
180
|
}
|
|
169
181
|
}
|
|
182
|
+
return { calls, results, originals };
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/** The target of a landed write under `root`, absolute, or null. A denied write changed nothing. */
|
|
186
|
+
function editTarget(c, results, root, cwd) {
|
|
187
|
+
if (!EDIT_TOOLS.has(c.name) || results.get(c.id) === true) return null;
|
|
188
|
+
const p = c.input && (c.input.file_path || c.input.notebook_path || c.input.path);
|
|
189
|
+
if (typeof p !== 'string' || !p) return null;
|
|
190
|
+
const abs = path.resolve(cwd, p);
|
|
191
|
+
return within(abs, root) ? abs : null;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/** The turn's weakened tests, one `path (labels)` entry per file, the path relative to `root`. */
|
|
195
|
+
function weakenedTests({ calls, results, originals }, root, cwd) {
|
|
196
|
+
const byFile = new Map();
|
|
197
|
+
for (const c of calls) {
|
|
198
|
+
const abs = editTarget(c, results, root, cwd);
|
|
199
|
+
if (!abs) continue;
|
|
200
|
+
const rel = path.relative(root, abs).split(path.sep).join('/');
|
|
201
|
+
if (!isTestPath(rel)) continue;
|
|
202
|
+
const hits = weakenedBy(editPairs(c.input, originals.get(c.id)));
|
|
203
|
+
if (hits.length) byFile.set(rel, new Set([...(byFile.get(rel) || []), ...hits]));
|
|
204
|
+
}
|
|
205
|
+
return [...byFile].map(([rel, hits]) => `${rel} (${[...hits].join(', ')})`);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* The decision, over transcript TEXT: the checks that have not passed since the turn's last
|
|
210
|
+
* edit, or [] when the turn may end (no edit, or every check passed after it); null when `whole`
|
|
211
|
+
* is false and the tail holds no prompt (`turnOf`). Exported for the unit tier — a transcript is
|
|
212
|
+
* text no CLI cell can vary cheaply. A check is a line (one form) or a `{ label, forms }` group;
|
|
213
|
+
* the answer lists labels.
|
|
214
|
+
*/
|
|
215
|
+
export function doneDecide(transcript, checks, root, cwd = root, whole = true) {
|
|
216
|
+
const turn = turnOf(transcript, whole);
|
|
217
|
+
return turn && missingChecks(turn, checks, root, cwd);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/** `weakenedTests` over transcript TEXT, for the unit tier: `doneDecide`'s other question. */
|
|
221
|
+
export const weakenedIn = (transcript, root, cwd = root) => weakenedTests(turnOf(transcript, true), root, cwd);
|
|
222
|
+
|
|
223
|
+
function missingChecks({ calls, results }, checks, root, cwd) {
|
|
224
|
+
const groups = checks.map((c) => (typeof c === 'string' ? { label: c, forms: [c] } : c));
|
|
170
225
|
let lastEdit = -1;
|
|
171
|
-
calls.forEach((c, i) => {
|
|
172
|
-
if (!EDIT_TOOLS.has(c.name) || results.get(c.id) === true) return;
|
|
173
|
-
const p = c.input && (c.input.file_path || c.input.notebook_path || c.input.path);
|
|
174
|
-
if (typeof p === 'string' && p && within(path.resolve(cwd, p), root)) lastEdit = i;
|
|
175
|
-
});
|
|
226
|
+
calls.forEach((c, i) => { if (editTarget(c, results, root, cwd)) lastEdit = i; });
|
|
176
227
|
if (lastEdit === -1) return [];
|
|
177
228
|
const passed = new Set();
|
|
178
229
|
calls.slice(lastEdit + 1).forEach((c) => {
|
|
@@ -199,38 +250,53 @@ export function doneGate(meta, args, install, read = tailReader()) {
|
|
|
199
250
|
const root = gitRootOf(cwd);
|
|
200
251
|
if (!root) return null;
|
|
201
252
|
const { source, blocking, checks } = doneChecksOf(root);
|
|
202
|
-
if (!checks.length) return null;
|
|
203
253
|
// Bob's Stop payload carries no transcript (learn's I2): nothing to judge, and a listed gate
|
|
204
254
|
// says so. Inferred checks stay quiet there: every repo with a manifest would log it.
|
|
205
255
|
if (args.host === 'bob' || typeof meta.transcript_path !== 'string') {
|
|
206
|
-
if (blocking) err(`[done-gate] no transcript${args.host === 'bob' ? ' (bob)' : ''} — turn not judged.\n`);
|
|
256
|
+
if (blocking && checks.length) err(`[done-gate] no transcript${args.host === 'bob' ? ' (bob)' : ''} — turn not judged.\n`);
|
|
207
257
|
return null;
|
|
208
258
|
}
|
|
209
|
-
let
|
|
259
|
+
let verdict;
|
|
210
260
|
try {
|
|
211
|
-
|
|
212
|
-
|
|
261
|
+
verdict = read(meta.transcript_path, (text, whole) => {
|
|
262
|
+
const turn = turnOf(text, whole);
|
|
263
|
+
return turn && {
|
|
264
|
+
missing: missingChecks(turn, checks, root, cwd), weakened: weakenedTests(turn, root, cwd),
|
|
265
|
+
};
|
|
266
|
+
});
|
|
213
267
|
} catch {
|
|
214
268
|
// No ask tier on Stop: blocking on an unreadable transcript would trap the user.
|
|
215
|
-
err('[done-gate] transcript unreadable — turn not judged.\n');
|
|
269
|
+
if (checks.length) err('[done-gate] transcript unreadable — turn not judged.\n');
|
|
216
270
|
return null;
|
|
217
271
|
}
|
|
272
|
+
const { missing, weakened } = verdict;
|
|
273
|
+
// One JSON document on stdout, whatever the advisories: Stop reads no second one.
|
|
274
|
+
const advise = (...said) => {
|
|
275
|
+
if (weakened.length) {
|
|
276
|
+
// A stable id, not a law number: an advisory is no hook-pinned rule (`HOOK_PINNED`).
|
|
277
|
+
recordGate(install, ADVISORY_VERB, 'cure-the-cause');
|
|
278
|
+
const line = `[done-gate] advisory — test weakened this turn: ${weakened.join('; ')}`;
|
|
279
|
+
err(`${line}\n`);
|
|
280
|
+
said.push(`${line}. Cure the Cause: fix the code, not the test.`);
|
|
281
|
+
}
|
|
282
|
+
out(`${JSON.stringify({ systemMessage: said.join(' ') })}\n`);
|
|
283
|
+
return 'advisory';
|
|
284
|
+
};
|
|
285
|
+
if (!missing.length && weakened.length) return advise();
|
|
218
286
|
if (!missing.length) return null;
|
|
219
287
|
if (!blocking) {
|
|
220
288
|
recordGate(install, ADVISORY_VERB, 'law-3');
|
|
221
289
|
err(`[done-gate] advisory — unproven since the last edit: ${missing.join('; ')}\n`);
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
+ `List your own in ${DONE_LIST} to make the gate block.`,
|
|
226
|
-
})}\n`);
|
|
227
|
-
return 'advisory';
|
|
290
|
+
return advise('Geneseed done gate (advisory) — this turn edited files, and these checks '
|
|
291
|
+
+ `inferred from ${source} have not passed since the last edit: ${missing.join('; ')}. `
|
|
292
|
+
+ `List your own in ${DONE_LIST} to make the gate block.`);
|
|
228
293
|
}
|
|
229
294
|
if (meta.stop_hook_active === true) {
|
|
230
295
|
recordGate(install, 'done-gate-cap', 'law-3');
|
|
231
296
|
err(`[done-gate] cap reached — turn ends with unproven checks: ${missing.join('; ')}\n`);
|
|
232
|
-
return null;
|
|
297
|
+
return weakened.length ? advise() : null;
|
|
233
298
|
}
|
|
299
|
+
// The turn goes on, so a weakened test is said at the Stop that really ends it.
|
|
234
300
|
recordGate(install, 'done-gate', 'law-3');
|
|
235
301
|
out(`${JSON.stringify({
|
|
236
302
|
decision: 'block',
|
package/js/hosts/hooks-prims.mjs
CHANGED
|
@@ -137,6 +137,71 @@ export const DONE_LIST = '.geneseed/done-checks.txt';
|
|
|
137
137
|
export const SECRET_RE =
|
|
138
138
|
/\b(?:AKIA[0-9A-Z]{16}|ghp_[A-Za-z0-9]{30,}|github_pat_[A-Za-z0-9_]{30,}|sk-ant-[A-Za-z0-9_-]{20,}|xox[abprs]-[0-9A-Za-z-]{10,})\b|-----BEGIN [A-Z ]*PRIVATE KEY-----/;
|
|
139
139
|
|
|
140
|
+
// ---- test-weakening twin: BEGIN — adapters/opencode/plugins/geneseed-context.js carries everything
|
|
141
|
+
// down to the END marker verbatim, with `export ` dropped (tests/plugins/context_done.test.mjs diffs the two).
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* A test file: a path segment `test`, `tests`, `__tests__` or `spec`, or a name `*.test.*`,
|
|
145
|
+
* `*.spec.*`, `*_test.*` or `test_*`. Give it a path relative to the repo, or an ancestor
|
|
146
|
+
* folder named `test` makes every file a test.
|
|
147
|
+
*/
|
|
148
|
+
const TEST_PATH_RE = /(?:^|[\\/])(?:tests?|__tests__|spec)[\\/]|(?:^|[\\/])test_[^\\/]*$|\.(?:test|spec)\.[^\\/]*$|_test\.[^\\/]*$/;
|
|
149
|
+
export const isTestPath = (p) => TEST_PATH_RE.test(p);
|
|
150
|
+
// `\bxit`, or `process.exit(` reads as one; `(?<!mark)`, or `pytest.mark.skip(` counts twice.
|
|
151
|
+
const SKIP_MARKERS = [['.skip', /(?<!mark)\.skip\(/g], ['xit', /\bxit\(/g], ['xfail', /\bxfail\b/g],
|
|
152
|
+
['@Disabled', /@Disabled\b/g], ['@Ignore', /@Ignore\b/g], ['pytest.mark.skip', /\bpytest\.mark\.skip/g],
|
|
153
|
+
['t.Skip', /\bt\.Skip\(/g]];
|
|
154
|
+
const ASSERT_LINE_RE = /\bassert\w*!?\s*[.(]|\bexpect\s*\(|^assert\s/;
|
|
155
|
+
const COMMENT_LINE_RE = /^(?:\/\/|\/\*|\*|#)/;
|
|
156
|
+
// shortcut: only whole comment lines are dropped, so a marker in a string or a trailing comment, and
|
|
157
|
+
// any other `.skip(` (`stream().skip(1)`), still count. Upgrade by parsing the language; it is an advisory.
|
|
158
|
+
const code = (text) => text.split(/\r?\n/).filter((l) => !COMMENT_LINE_RE.test(l.trim())).join('\n');
|
|
159
|
+
// shortcut: a Set hides the loss of one of two identical lines, and `require.Equal`, `t.Errorf` and
|
|
160
|
+
// `.should` are not read as assertions. Upgrade by counting lines and widening `ASSERT_LINE_RE`.
|
|
161
|
+
const assertLines = (text) => new Set(text.split(/\r?\n/).map((l) => l.trim())
|
|
162
|
+
.filter((l) => ASSERT_LINE_RE.test(l) && !COMMENT_LINE_RE.test(l)));
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* What `pairs` of `[old, new]` text do to a test, as labels: a skip marker the new text has more
|
|
166
|
+
* of (`.skip added`), or an assertion line gone with none new in its place (`assertion removed`).
|
|
167
|
+
* A comment is no assertion, so commenting one out removes it. Cure the Cause's advisory half.
|
|
168
|
+
*/
|
|
169
|
+
export function weakenedBy(pairs) {
|
|
170
|
+
const found = new Set();
|
|
171
|
+
for (const [before, after] of pairs) {
|
|
172
|
+
for (const [label, re] of SKIP_MARKERS) {
|
|
173
|
+
if ((code(after).match(re) || []).length > (code(before).match(re) || []).length) found.add(`${label} added`);
|
|
174
|
+
}
|
|
175
|
+
const was = assertLines(before);
|
|
176
|
+
const now = assertLines(after);
|
|
177
|
+
if ([...was].some((l) => !now.has(l)) && [...now].every((l) => was.has(l))) found.add('assertion removed');
|
|
178
|
+
}
|
|
179
|
+
return [...found];
|
|
180
|
+
}
|
|
181
|
+
// ---- test-weakening twin: END
|
|
182
|
+
|
|
183
|
+
// One Roo-style `apply_diff` block: its SEARCH half, then its REPLACE half.
|
|
184
|
+
export const DIFF_BLOCK_RE = /<<<<<<< SEARCH\r?\n(?::start_line:\s*\d+\r?\n)?(?:-------\r?\n)?([\s\S]*?)\r?\n?=======\r?\n([\s\S]*?)\r?\n?>>>>>>> REPLACE/g;
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* A write tool's input as `[old, new]` pairs for `weakenedBy`. `whole` is the file before a
|
|
188
|
+
* whole-file write, which the input does not carry. NotebookEdit's input names no old text either,
|
|
189
|
+
* so a cell that already held a marker reads as adding it.
|
|
190
|
+
*/
|
|
191
|
+
export function editPairs(ti, whole = '') {
|
|
192
|
+
const text = (v) => (typeof v === 'string' ? v : '');
|
|
193
|
+
const pairs = [];
|
|
194
|
+
if (typeof ti.content === 'string') pairs.push([whole, ti.content]);
|
|
195
|
+
if (typeof ti.new_string === 'string') pairs.push([text(ti.old_string), ti.new_string]);
|
|
196
|
+
if (typeof ti.new_source === 'string') pairs.push(['', ti.new_source]);
|
|
197
|
+
if (typeof ti.replace === 'string') pairs.push([text(ti.search), ti.replace]);
|
|
198
|
+
for (const e of Array.isArray(ti.edits) ? ti.edits : []) {
|
|
199
|
+
if (e && typeof e.new_string === 'string') pairs.push([text(e.old_string), e.new_string]);
|
|
200
|
+
}
|
|
201
|
+
if (typeof ti.diff === 'string') for (const m of ti.diff.matchAll(DIFF_BLOCK_RE)) pairs.push([m[1], m[2]]);
|
|
202
|
+
return pairs;
|
|
203
|
+
}
|
|
204
|
+
|
|
140
205
|
const OFF = ['off', '0', 'false', 'no'];
|
|
141
206
|
|
|
142
207
|
/**
|