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
package/js/hosts/hooks.mjs
CHANGED
|
@@ -64,7 +64,9 @@ import {
|
|
|
64
64
|
} from './hosts.mjs';
|
|
65
65
|
import { currentBranch, gitRootOf, loopLaunched } from './gitref.mjs';
|
|
66
66
|
import { LOSS_CANDIDATE_RE, catastrophic, lossReason, stripStructure } from './loss.mjs';
|
|
67
|
-
import {
|
|
67
|
+
import {
|
|
68
|
+
selfAndParents, readStdin, SECRET_RE, DONE_LIST, DIFF_BLOCK_RE, isTestPath, weakenedBy, editPairs,
|
|
69
|
+
} from './hooks-prims.mjs';
|
|
68
70
|
import { recordUse } from './usage.mjs';
|
|
69
71
|
import { WRITE_NAME_RE, ownershipBlock } from './ownership-gate.mjs';
|
|
70
72
|
|
|
@@ -190,10 +192,20 @@ export function askDecision(reason) { return decisionDoc('ask', reason); }
|
|
|
190
192
|
export function denyDecision(reason) { return decisionDoc('deny', reason); }
|
|
191
193
|
|
|
192
194
|
function decisionDoc(decision, reason) {
|
|
193
|
-
const value = JSON.stringify(reason)
|
|
194
|
-
.replace(/[\u007f-]/g, (c) => `\\u${c.charCodeAt(0).toString(16).padStart(4, '0')}`);
|
|
195
195
|
return `{"hookSpecificOutput": {"hookEventName": "PreToolUse", "permissionDecision": "${decision}", `
|
|
196
|
-
+ `"permissionDecisionReason": ${
|
|
196
|
+
+ `"permissionDecisionReason": ${asciiJson(reason)}}}\n`;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
const asciiJson = (s) => JSON.stringify(s)
|
|
200
|
+
.replace(/[\u007f-]/g, (c) => `\\u${c.charCodeAt(0).toString(16).padStart(4, '0')}`);
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* A note to the MODEL that decides nothing: PreToolUse `additionalContext` with no
|
|
204
|
+
* `permissionDecision` defers, and the host puts the text next to the tool result (hooks.md,
|
|
205
|
+
* `additionalContext`; not seen live, no gate here runs a model turn).
|
|
206
|
+
*/
|
|
207
|
+
export function contextNote(text) {
|
|
208
|
+
return `{"hookSpecificOutput": {"hookEventName": "PreToolUse", "additionalContext": ${asciiJson(text)}}}\n`;
|
|
197
209
|
}
|
|
198
210
|
|
|
199
211
|
/**
|
|
@@ -488,6 +500,119 @@ const lossSegments = (s) => scanSegments(s).map((seg) => seg.match(SCAN_TOKEN_RE
|
|
|
488
500
|
// (`rg "/mnt/c" README.md`) — never a root target; only an unquoted root is one.
|
|
489
501
|
const rootArg = (t) => !/^["']/.test(t) && FS_ROOT_RE.test(t);
|
|
490
502
|
|
|
503
|
+
// ---- shell-write twin: BEGIN — adapters/opencode/plugins/geneseed-guard.js carries everything down
|
|
504
|
+
// to the END marker verbatim, with `export ` dropped (tests/plugins/guard.test.mjs diffs the two).
|
|
505
|
+
|
|
506
|
+
// The cheap prefilter, a superset of what the parse acts on: a `>`, or one of the programs as a word.
|
|
507
|
+
const SHELL_WRITE_RE = />|(?:^|[\s;&|("'`\\/])(?:tee|sed|cp|mv|rm)(?:\.exe)?(?=[\s;&|)"'`]|$)/im;
|
|
508
|
+
// One pass over a segment: a quoted run (kept: its `>` is data), or a redirection with its optional
|
|
509
|
+
// fd, operator, `&` (a dup such as `2>&1`, which writes no file) and target word. `<` forms match
|
|
510
|
+
// too, so that their words never read as operands. A backslash is no escape here, as in
|
|
511
|
+
// `SCAN_SPLIT_RE`: `echo "say \"hi > f\""` closes its quote early, reads a target, and asks (on Bob, blocks).
|
|
512
|
+
const REDIRECT_RE = /"[^"]*"?|'[^']*'?|(?:(?<!\S)\d+|&)?(<<?<?-?|>>?)[ \t]*(&?)((?:[^\s"';|&<>()]|"[^"]*"?|'[^']*'?)*)/g;
|
|
513
|
+
const SHELL_CD = new Set(['cd', 'pushd', 'chdir', 'set-location', 'sl']);
|
|
514
|
+
|
|
515
|
+
/** `t` as an absolute path from `dir`, `~/…` as it stands, or null for what the shell rewrites. */
|
|
516
|
+
function writePath(dir, t) {
|
|
517
|
+
if (/[$`*?{}\0]/.test(t) || /^~[^\\/]/.test(t) || /^(?:\/dev\/|nul$)/i.test(t)) return null;
|
|
518
|
+
if (t[0] === '~') return t;
|
|
519
|
+
// A Git Bash `/c/…` path, as `resolveIn` reads it.
|
|
520
|
+
const q = process.platform === 'win32' ? t.replace(/^\/([a-zA-Z])(?=\/|$)/, '$1:') : t;
|
|
521
|
+
if (path.isAbsolute(q)) return path.resolve(q);
|
|
522
|
+
return dir ? path.resolve(dir, q) : null;
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
/** The files `sed` edits in place: none without `-i`; else its operands, past the script if inline. */
|
|
526
|
+
function sedFiles(args) {
|
|
527
|
+
const ops = [];
|
|
528
|
+
let inPlace = false; let script = false; let flags = true;
|
|
529
|
+
for (let i = 0; i < args.length; i += 1) {
|
|
530
|
+
const a = args[i];
|
|
531
|
+
if (flags && a === '--') flags = false;
|
|
532
|
+
else if (flags && /^--in-place(?:=|$)/.test(a)) inPlace = true;
|
|
533
|
+
else if (flags && (a === '--expression' || a === '--file')) { script = true; i += 1; }
|
|
534
|
+
else if (flags && /^--(?:expression|file)=/.test(a)) script = true;
|
|
535
|
+
else if (flags && /^-[a-zA-Z]*i/.test(a)) inPlace = true;
|
|
536
|
+
else if (flags && /^-[a-zA-Z]*[ef]$/.test(a)) { script = true; i += 1; }
|
|
537
|
+
else if (!flags || !a.startsWith('-') || a === '-') { if (a) ops.push(a); }
|
|
538
|
+
}
|
|
539
|
+
return inPlace ? ops.slice(script ? 0 : 1) : [];
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
/**
|
|
543
|
+
* The files `command` would write, as absolute paths: redirect targets (`>`, `>>`, `&>`), `tee`
|
|
544
|
+
* and `rm` operands, `sed -i` files, the destination of `cp` and `mv`, and the sources of `mv`, which
|
|
545
|
+
* it removes. A destination may be a folder, so `cp a tests/` also names `tests/a`. Read like
|
|
546
|
+
* `rootScan`: quotes, comments and heredoc bodies are data. A `cd` is followed; one it cannot read
|
|
547
|
+
* leaves later relative paths unseen. What it cannot read, it leaves out: this reader fails OPEN.
|
|
548
|
+
*
|
|
549
|
+
* shortcut: KNOWN UNSEEN FORMS, all of them still a write. An interpreter (inline code,
|
|
550
|
+
* `bash -c`, `eval`, `xargs`), a script or `npm run`, a `$(…)` or subshell trick, `>|`, a path with a
|
|
551
|
+
* variable, glob or brace in it, a wrapper with flags (`sudo -u x`) or outside `SCAN_WRAPPERS` (`env rm`,
|
|
552
|
+
* `nohup rm`, `timeout 5 rm`, `exec rm`), `echo x >& file` (read as a dup), a `popd` (not followed, so
|
|
553
|
+
* relative paths after a `pushd`/`popd` pair resolve from the wrong folder), `cp -t`, any other writer
|
|
554
|
+
* (`dd`, `ln`, `install`, `git mv`, `git checkout`, `Set-Content`), and a folder removed above a
|
|
555
|
+
* listed file (`rm -r tests` when only `tests/a.test.js` is listed). CI running the checks is the
|
|
556
|
+
* boundary that holds against those.
|
|
557
|
+
*/
|
|
558
|
+
export function shellWriteTargets(command, cwd) {
|
|
559
|
+
if (!SHELL_WRITE_RE.test(command)) return [];
|
|
560
|
+
const found = new Set();
|
|
561
|
+
let dir = cwd;
|
|
562
|
+
const add = (t) => { const p = writePath(dir, t); if (p) found.add(p); };
|
|
563
|
+
const bare = (t) => t.replace(/["']/g, '');
|
|
564
|
+
for (const seg of scanSegments(command)) {
|
|
565
|
+
const outs = [];
|
|
566
|
+
const body = seg.replace(REDIRECT_RE, (m, op, dup, target) => {
|
|
567
|
+
if (op === undefined) return m;
|
|
568
|
+
if (op[0] === '>' && !dup && target) outs.push(bare(target));
|
|
569
|
+
return ' ';
|
|
570
|
+
});
|
|
571
|
+
let toks = stripStructure(body.match(SCAN_TOKEN_RE) || []);
|
|
572
|
+
while (toks.length && (/^\w+=/.test(toks[0]) || SCAN_WRAPPERS.has(bare(toks[0])))) toks = toks.slice(1);
|
|
573
|
+
const prog = toks.length ? bare(toks[0]).split(/[\\/]/).pop().toLowerCase().replace(/\.exe$/, '') : '';
|
|
574
|
+
const args = toks.slice(1).map(bare);
|
|
575
|
+
const dashes = args.indexOf('--');
|
|
576
|
+
const ops = args.filter((a, i) => a && (a === '-' || !a.startsWith('-') || (dashes >= 0 && i > dashes)));
|
|
577
|
+
if (SHELL_CD.has(prog)) {
|
|
578
|
+
const to = ops.find((a) => !/^\/d$/i.test(a));
|
|
579
|
+
dir = to && to !== '-' ? writePath(dir, to) : null;
|
|
580
|
+
} else if (prog === 'rm' || prog === 'tee') ops.forEach(add);
|
|
581
|
+
else if (prog === 'sed') sedFiles(args).forEach(add);
|
|
582
|
+
else if ((prog === 'cp' || prog === 'mv') && ops.length > 1) {
|
|
583
|
+
const dest = ops[ops.length - 1];
|
|
584
|
+
const sources = ops.slice(0, -1);
|
|
585
|
+
add(dest);
|
|
586
|
+
for (const s of sources) {
|
|
587
|
+
add(`${dest.replace(/[\\/]+$/, '')}/${s.split(/[\\/]/).pop()}`);
|
|
588
|
+
if (prog === 'mv') add(s);
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
outs.forEach(add);
|
|
592
|
+
}
|
|
593
|
+
return [...found];
|
|
594
|
+
}
|
|
595
|
+
// ---- shell-write twin: END
|
|
596
|
+
|
|
597
|
+
/**
|
|
598
|
+
* External Gate over a shell command: the first write target that `externalGate` refuses, as the
|
|
599
|
+
* reason to ask, or null. Path check only, no secret scan of the command. Any throw is a pass, not
|
|
600
|
+
* `guardGate`'s `gate-error` ask: this reader fails open, and a hand-mangled path is not a gate failure.
|
|
601
|
+
*/
|
|
602
|
+
function shellWriteReason(args, command, payload) {
|
|
603
|
+
try {
|
|
604
|
+
const base = (payload && typeof payload.cwd === 'string' && payload.cwd) || process.cwd();
|
|
605
|
+
// A Roo-lineage shell tool may name its own directory, as OpenCode's `workdir` does.
|
|
606
|
+
const own = payload && payload.tool_input && payload.tool_input.cwd;
|
|
607
|
+
const cwd = typeof own === 'string' && own ? path.resolve(base, own) : base;
|
|
608
|
+
for (const t of shellWriteTargets(command, cwd)) {
|
|
609
|
+
const why = externalGate(args, t, payload);
|
|
610
|
+
if (why) return why;
|
|
611
|
+
}
|
|
612
|
+
} catch { /* see above */ }
|
|
613
|
+
return null;
|
|
614
|
+
}
|
|
615
|
+
|
|
491
616
|
function gitDecide(args, payload) {
|
|
492
617
|
const command = ((payload && payload.tool_input) || {}).command;
|
|
493
618
|
if (typeof command !== 'string') return 0;
|
|
@@ -521,6 +646,10 @@ function gitDecide(args, payload) {
|
|
|
521
646
|
+ 'share, for hours; | head stops nothing). Search a specific directory instead: the '
|
|
522
647
|
+ 'project, node_modules, ~/.npm, %APPDATA%.');
|
|
523
648
|
}
|
|
649
|
+
// Also before `--no-consent`: rigor-5 is no part of the process pack. On Bob a hook-settings
|
|
650
|
+
// target cannot be replayed from a command (`bobSettingsChange`), so it blocks.
|
|
651
|
+
const shellWrite = shellWriteReason(args, command, payload);
|
|
652
|
+
if (shellWrite) return ask(args, 'git-gate', 'rigor-5', shellWrite);
|
|
524
653
|
// `--no-consent`: the process pack (or process 5 alone) is off, so the commit/push ask has
|
|
525
654
|
// no rule behind it — but Law IV above is universal and has already run. Checked before
|
|
526
655
|
// `loopExempt` so a non-git command, or one with consent off, never pays for the whitelist.
|
|
@@ -585,8 +714,8 @@ export const SENSOR_LIST = '.geneseed/protected-checks.txt';
|
|
|
585
714
|
* them, one repo-relative path per line (`#` comments), in `.geneseed/protected-checks.txt` at
|
|
586
715
|
* its git root — found by walking up from the WRITE TARGET, not the cwd, so a session in one repo
|
|
587
716
|
* writing into another reads that other repo's list. The list protects itself. Returns the entry
|
|
588
|
-
* the path falls under, or null.
|
|
589
|
-
*
|
|
717
|
+
* the path falls under, or null. A write tool's path reaches this through `ruleDecide`, a shell
|
|
718
|
+
* command's write targets through `shellWriteTargets`, whose docblock names what stays unseen.
|
|
590
719
|
*/
|
|
591
720
|
function protectedCheck(p) {
|
|
592
721
|
return protectedIn(path.resolve(p)) ?? protectedIn(resolvePath(p));
|
|
@@ -633,7 +762,7 @@ function protectedIn(target) {
|
|
|
633
762
|
* guard holds these lists minus the hook settings and OpenCode's own files, which OpenCode asks about natively
|
|
634
763
|
* (`opencodeEditAsks` in ./settings.mjs; tests/plugins/guard.test.mjs pins the difference). The CLI
|
|
635
764
|
* (`geneseed exclude`, an emit) writes these with `fs`, never through a write tool, so it is
|
|
636
|
-
* not gated.
|
|
765
|
+
* not gated. Reached from a shell command too, with the same limit as `protectedCheck`.
|
|
637
766
|
*/
|
|
638
767
|
const GATE_CONFIG_FILES = ['settings.json', 'settings.local.json', 'settings/settings.json', 'excludes.json', 'AGENT.md', '.geneseed-manifest.json', '.geneseed-emit', 'opencode.json', 'opencode.jsonc'];
|
|
639
768
|
const GATE_CONFIG_MARKERS = ['.claude', '.openclaude', '.bob', '.opencode'];
|
|
@@ -690,7 +819,7 @@ function settingsAfter(before, payload) {
|
|
|
690
819
|
return ranged ? null : once(before, ti.search, ti.replace);
|
|
691
820
|
}
|
|
692
821
|
if (tool === 'apply_diff' && typeof ti.diff === 'string') {
|
|
693
|
-
const blocks = [...ti.diff.matchAll(
|
|
822
|
+
const blocks = [...ti.diff.matchAll(DIFF_BLOCK_RE)];
|
|
694
823
|
let text = before;
|
|
695
824
|
for (const [, search, replace] of blocks) if ((text = once(text, search, replace)) === null) return null;
|
|
696
825
|
// One block only: with several, Bob may apply some and refuse others (its start-line window).
|
|
@@ -731,6 +860,51 @@ function bobSettingsChange(p, payload) {
|
|
|
731
860
|
return geneseedWiring(a) === geneseedWiring(b) ? null : 'it changes Geneseed\'s own hook entries';
|
|
732
861
|
}
|
|
733
862
|
|
|
863
|
+
/**
|
|
864
|
+
* External Gate on one write target, by tool or by shell: why it must be asked about, or null.
|
|
865
|
+
* On Bob a hook-settings file is the user's shared host config, refused only when the write
|
|
866
|
+
* touches Geneseed's wiring (`bobSettingsChange`), and it never reads `opencode.json(c)`.
|
|
867
|
+
*/
|
|
868
|
+
function externalGate(args, p, payload) {
|
|
869
|
+
const sensor = protectedCheck(p);
|
|
870
|
+
if (sensor) {
|
|
871
|
+
return `Geneseed (External Gate) — ${p} is a protected check (${sensor === DONE_LIST
|
|
872
|
+
? 'the done gate list itself' : `${sensor}, listed in ${SENSOR_LIST}`}). A check the agent can `
|
|
873
|
+
+ 'edit is not a check: fix the code, not the check, unless the user asks for this edit.';
|
|
874
|
+
}
|
|
875
|
+
if (HOST === 'bob' && /^opencode\.jsonc?$/i.test(path.basename(p))) return null;
|
|
876
|
+
if (!gateConfig(p, args.root)) return null;
|
|
877
|
+
const why = HOST === 'bob' && SETTINGS_RE.test(p) ? bobSettingsChange(p, payload) : '';
|
|
878
|
+
if (why === null) return null;
|
|
879
|
+
return `Geneseed (External Gate) — ${p} ${GATE_CONFIG_ASK}`
|
|
880
|
+
+ (why ? ` On Bob this write is refused because ${why}.` : '');
|
|
881
|
+
}
|
|
882
|
+
|
|
883
|
+
/**
|
|
884
|
+
* Cure the Cause's edit-time half, ADVISORY: tells the agent that this write weakens a test (a skip
|
|
885
|
+
* marker added, an assertion dropped). The turn-end line is `doneGate`'s, read from the transcript.
|
|
886
|
+
* It only speaks, and it must not fail a write, so every error is silence. On Bob stdout is not
|
|
887
|
+
* read on PreToolUse, so the note is a stderr line, which also serves as its log line.
|
|
888
|
+
*/
|
|
889
|
+
function testWeakenedNote(p, payload) {
|
|
890
|
+
try {
|
|
891
|
+
if (!isTestPath(p)) return;
|
|
892
|
+
const abs = path.resolve(typeof payload.cwd === 'string' ? payload.cwd : '.', p);
|
|
893
|
+
const root = gitRootOf(path.dirname(abs));
|
|
894
|
+
if (root && !isTestPath(path.relative(root, abs))) return;
|
|
895
|
+
let whole = '';
|
|
896
|
+
if (/write/i.test(String(payload.tool_name))) {
|
|
897
|
+
try { whole = readFileSync(abs, 'utf8'); } catch { /* a new file: nothing to weaken */ }
|
|
898
|
+
}
|
|
899
|
+
const hits = weakenedBy(editPairs(payload.tool_input, whole));
|
|
900
|
+
if (!hits.length) return;
|
|
901
|
+
const note = `Geneseed (Cure the Cause) — this edit weakens a test: ${p} (${hits.join(', ')}). `
|
|
902
|
+
+ 'Fix the code, not the test. State this in your closing summary, with the reason.';
|
|
903
|
+
if (HOST === 'bob') err(`[geneseed] ${note}\n`);
|
|
904
|
+
else out(contextNote(note));
|
|
905
|
+
} catch { /* see above */ }
|
|
906
|
+
}
|
|
907
|
+
|
|
734
908
|
function ruleGate(args) {
|
|
735
909
|
if (sovereignBypass(args.root)) return 0;
|
|
736
910
|
return ruleDecide(args, readPayload());
|
|
@@ -773,30 +947,17 @@ function ruleDecide(args, payload) {
|
|
|
773
947
|
// shortcut: a write is told by its tool name, so a Bob write tool named outside WRITE_NAME_RE
|
|
774
948
|
// passes both gates; switch to an allowlist of Bob's read tools if Bob adds or renames one.
|
|
775
949
|
const bobRead = HOST === 'bob' && !WRITE_NAME_RE.test(String((payload && payload.tool_name) || ''));
|
|
776
|
-
const
|
|
777
|
-
if (
|
|
778
|
-
return ask(args, 'rule-gate', 'rigor-5', `Geneseed (External Gate) — ${p} is a protected `
|
|
779
|
-
+ `check (${sensor === DONE_LIST ? 'the done gate list itself'
|
|
780
|
-
: `${sensor}, listed in ${SENSOR_LIST}`}). A check the agent can edit is not a `
|
|
781
|
-
+ 'check: fix the code, not the check, unless the user asks for this edit.');
|
|
782
|
-
}
|
|
783
|
-
// Bob never reads `opencode.json(c)`, OpenCode's whole host config: it is not gated from Bob.
|
|
784
|
-
const bobWrite = !bobRead && !(HOST === 'bob' && /^opencode\.jsonc?$/i.test(path.basename(p)));
|
|
785
|
-
if (bobWrite && gateConfig(p, args.root)) {
|
|
786
|
-
// Bob: a hook-settings file is the user's shared host config — refused only when the write
|
|
787
|
-
// touches Geneseed's wiring (`bobSettingsChange`); a pass falls through to the checks below.
|
|
788
|
-
const why = HOST === 'bob' && SETTINGS_RE.test(p) ? bobSettingsChange(p, payload) : '';
|
|
789
|
-
if (why !== null) {
|
|
790
|
-
return ask(args, 'rule-gate', 'rigor-5', `Geneseed (External Gate) — ${p} ${GATE_CONFIG_ASK}`
|
|
791
|
-
+ (why ? ` On Bob this write is refused because ${why}.` : ''));
|
|
792
|
-
}
|
|
793
|
-
}
|
|
950
|
+
const external = !bobRead && externalGate(args, p, payload);
|
|
951
|
+
if (external) return ask(args, 'rule-gate', 'rigor-5', external);
|
|
794
952
|
const target = ruleGateTarget(p, args.root);
|
|
795
953
|
if (!target) {
|
|
796
954
|
// The ownership first-write gate (./ownership-gate.mjs), last: every rule above outranks it.
|
|
797
955
|
// `--no-ownership-gate`: the install switched it off (D25).
|
|
798
956
|
const why = args.noOwnershipGate ? null : ownershipBlock(p, payload, body, args.root);
|
|
799
|
-
|
|
957
|
+
if (why) return deny(args, 'rule-gate', 'ownership', why);
|
|
958
|
+
// Only here: stdout carries one document, and an ask or a deny above already holds it.
|
|
959
|
+
if (!bobRead) testWeakenedNote(p, payload);
|
|
960
|
+
return 0;
|
|
800
961
|
}
|
|
801
962
|
return ask(args, 'rule-gate', 'process-1', `Geneseed (Persist Insight) \u2014 writing to `
|
|
802
963
|
+ `${target}: a standing rule, or a fact to remember? That choice is the user's. ${PERSIST_ASK}`);
|
package/js/loop/state.mjs
CHANGED
|
@@ -352,6 +352,12 @@ export function recordOutcome(state, bricks, outcome, { card = null, porcelain =
|
|
|
352
352
|
if (brick.effect === 'mutate' && !state.validated) {
|
|
353
353
|
throw new Error(`${from} modifies code: run \`geneseed loop score --declared\` before it, then record`);
|
|
354
354
|
}
|
|
355
|
+
// `pass` is mechanical: a check that did not run is not a check that passed, whatever the model
|
|
356
|
+
// concluded. Only `test` writes this list, as `<check>: <status>`, so the word counts only where
|
|
357
|
+
// the status sits: right after a colon, markdown marks allowed, and not as a runner's count
|
|
358
|
+
// (`skipped: 0`, `: skipped 0`).
|
|
359
|
+
const skipped = from === 'test' && outcome === 'pass' ? note.split('\n').find((l) => /:[\s*`_]*skipped\b(?!\s*\d)/i.test(l)) : null;
|
|
360
|
+
if (skipped) throw new Error(`test cannot report pass with a skipped check (${skipped.trim()}): run it, or report fail or error`);
|
|
355
361
|
const filteredPorcelain = porcelain === null ? null : filterPorcelain(porcelain);
|
|
356
362
|
if (brick.effect === 'read' && filteredPorcelain !== null && filteredPorcelain !== state.snapshot) {
|
|
357
363
|
return stop(state, `read-brick-wrote: ${from} changed the working tree`);
|
|
@@ -359,15 +365,19 @@ export function recordOutcome(state, bricks, outcome, { card = null, porcelain =
|
|
|
359
365
|
if (filteredPorcelain !== null) state.snapshot = filteredPorcelain;
|
|
360
366
|
if (card) state.card = card;
|
|
361
367
|
if (from === 'test') state.tests = outcome;
|
|
362
|
-
// A finding a brick needs to survive the unit (the ordered plan `plan` produced
|
|
363
|
-
//
|
|
364
|
-
//
|
|
365
|
-
//
|
|
368
|
+
// A finding a brick needs to survive the unit (the ordered plan `plan` produced) — pushed before
|
|
369
|
+
// the transition below, so it lands in `notes` even when this call closes the unit, re-splits,
|
|
370
|
+
// or stops the loop. `notes` is never reset with the unit (only the two filters below trim it,
|
|
371
|
+
// and only `exhaust`'s own push and `decideAwaiting` add to it otherwise), so it survives
|
|
366
372
|
// `resetUnit`/`finishUnit` — which a card does not: `resetUnit` clears it.
|
|
367
373
|
// A fresh verdict: `test`'s latest report supersedes its earlier ones, so a repair never reads
|
|
368
374
|
// findings about code that has since changed (stale traces broke 34 of 135 correct attempts
|
|
369
|
-
// in arXiv 2607.24604, fresh ones 4).
|
|
375
|
+
// in arXiv 2607.24604, fresh ones 4). `review`'s and `mutation-check`'s findings go once `apply`
|
|
376
|
+
// has acted on them: it reads them through `next`, so they leave when it records, never when it
|
|
377
|
+
// is entered.
|
|
378
|
+
// Every other brick's notes are a record and are kept.
|
|
370
379
|
if (from === 'test') state.notes = state.notes.filter((n) => !/^iteration \d+ \(test\): /.test(n));
|
|
380
|
+
if (from === 'apply') state.notes = state.notes.filter((n) => !/^iteration \d+ \((review|mutation-check)\): /.test(n));
|
|
371
381
|
if (note) state.notes.push(`iteration ${state.iteration} (${from}): ${note}`);
|
|
372
382
|
state.visited.push(from);
|
|
373
383
|
|
package/js/web/actions.mjs
CHANGED
|
@@ -145,10 +145,10 @@ function bodyKits(body) {
|
|
|
145
145
|
}
|
|
146
146
|
|
|
147
147
|
/**
|
|
148
|
-
* The gate switches across the trust boundary (`deletionGate`, `secretsGate`, `doneGate
|
|
149
|
-
* on its own: only a real JSON boolean counts. Anything else — a string
|
|
150
|
-
* absence — falls back to the install's own answer for THAT gate, so a
|
|
151
|
-
* can never disarm (or re-arm) a gate it did not name.
|
|
148
|
+
* The gate switches across the trust boundary (`deletionGate`, `secretsGate`, `doneGate`,
|
|
149
|
+
* `ownershipGate`), each on its own: only a real JSON boolean counts. Anything else — a string
|
|
150
|
+
* `"false"`, a number, absence — falls back to the install's own answer for THAT gate, so a
|
|
151
|
+
* malformed or partial body can never disarm (or re-arm) a gate it did not name.
|
|
152
152
|
*/
|
|
153
153
|
function bodyGates(body, root, host) {
|
|
154
154
|
const own = gatesOfDir(root, host);
|
package/js/web/api.mjs
CHANGED
|
@@ -373,8 +373,8 @@ export function apiOverview(state) {
|
|
|
373
373
|
for (const [host, scope, root] of installTargets()) {
|
|
374
374
|
try {
|
|
375
375
|
if (samePath(viewCfg(host, scope, root), state.target)) {
|
|
376
|
-
// `deletionGate`/`secretsGate`/`doneGate`: the gate switches, for the
|
|
377
|
-
// page's toggles on rows IV, I and
|
|
376
|
+
// `deletionGate`/`secretsGate`/`doneGate`/`ownershipGate`: the gate switches, for the
|
|
377
|
+
// Constitution page's toggles on rows IV, I, III and inside the Credo's Ownership row.
|
|
378
378
|
install = { host, scope, path: root, footprint: footprintOfDir(root),
|
|
379
379
|
...gatesOfDir(root, host) };
|
|
380
380
|
break;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"//": "Every field here is argued and gated in tests/unit/package_manifest.test.mjs. `files`, `bin` and `engines` each have a test that fails when reality drifts from this file; `version` mirrors harness.config.json and is gated too. Read that docblock before editing this one.",
|
|
3
3
|
"name": "geneseed",
|
|
4
|
-
"version": "4.
|
|
4
|
+
"version": "4.32.0",
|
|
5
5
|
"description": "A portable, theme-able harness you implant once and use everywhere to grow a disciplined AI coding agent.",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"ai",
|
package/src/agents/_template.md
CHANGED
|
@@ -47,6 +47,9 @@
|
|
|
47
47
|
1. Step-by-step method this {{AGENT}} follows.
|
|
48
48
|
|
|
49
49
|
## Output contract
|
|
50
|
+
- The report starts with one line, `STATUS: OK|BLOCKED|OUT_OF_SCOPE|ERROR`:
|
|
51
|
+
`OK` the contract is met; `BLOCKED` an input or a decision is missing;
|
|
52
|
+
`OUT_OF_SCOPE` this {{AGENT}} does not own the task; `ERROR` a step failed.
|
|
50
53
|
- The exact shape of what this {{AGENT}} returns to the caller (e.g. a list of
|
|
51
54
|
findings with file:line, a verdict, a summary of changes made).
|
|
52
55
|
- Include an honest-failure line: what this {{AGENT}} returns when the contract
|
package/src/agents/developer.md
CHANGED
|
@@ -42,12 +42,15 @@
|
|
|
42
42
|
actually close — report the blocker instead ({{ONTOLOGY}}: {{ONT_EVIDENCE}}).
|
|
43
43
|
|
|
44
44
|
## Output contract
|
|
45
|
+
- The report starts with one line, `STATUS: OK|BLOCKED|OUT_OF_SCOPE|ERROR`: `OK` the contract is met;
|
|
46
|
+
`BLOCKED` an input or a decision is missing; `OUT_OF_SCOPE` not this task; `ERROR` a step failed,
|
|
47
|
+
red tests included.
|
|
45
48
|
- The files changed in the worktree and a one-line summary of what changed and
|
|
46
49
|
why, ready for the tester's pass.
|
|
47
50
|
- If the scoped task cannot be implemented as given (missing input, contradictory
|
|
48
|
-
acceptance criteria), report that blocker instead of guessing.
|
|
51
|
+
acceptance criteria), report that blocker instead of guessing (`STATUS: BLOCKED`).
|
|
49
52
|
- In ownership mode: the diff, for the developer's final review — or
|
|
50
|
-
`blocked: decision needed` with the options
|
|
53
|
+
`blocked: decision needed` with the options, on the line after `STATUS: BLOCKED`.
|
|
51
54
|
|
|
52
55
|
## Pipeline role
|
|
53
56
|
|
package/src/agents/tester.md
CHANGED
|
@@ -30,10 +30,13 @@
|
|
|
30
30
|
is not proof.
|
|
31
31
|
|
|
32
32
|
## Output contract
|
|
33
|
+
- The report starts with one line, `STATUS: OK|BLOCKED|OUT_OF_SCOPE|ERROR`: `OK` the contract is met;
|
|
34
|
+
`BLOCKED` an input or a decision is missing; `OUT_OF_SCOPE` not this task; `ERROR` a step failed,
|
|
35
|
+
red tests included.
|
|
33
36
|
- The test files written/changed, the command to run them, and the actual run
|
|
34
37
|
output (pass/fail counts). For diagnosis: root cause + recommended fix location.
|
|
35
38
|
- If the suite cannot be run or the expected behaviour is unspecified, report
|
|
36
|
-
that blocker instead of delivering tests that were never seen to fail.
|
|
39
|
+
that blocker (`STATUS: BLOCKED`) instead of delivering tests that were never seen to fail.
|
|
37
40
|
|
|
38
41
|
## Pipeline role
|
|
39
42
|
|
package/src/bricks/apply.md
CHANGED
|
@@ -12,6 +12,9 @@ replaced.
|
|
|
12
12
|
When this is a repair after `test`, act on the latest `test` note only — it is the verdict on
|
|
13
13
|
the code as it stands. Fix every finding it lists in this one pass: repairs are capped at two.
|
|
14
14
|
|
|
15
|
+
When this is a repair after `mutation-check`, act on its latest note: add each assertion that
|
|
16
|
+
kills a survivor to a test in the `writeSet`. Production code stays as it is.
|
|
17
|
+
|
|
15
18
|
Make no unrelated edits: no drive-by rename, no incidental cleanup, no touching a file the card
|
|
16
19
|
did not declare. If the change genuinely needs a file outside the write set, stop and report that
|
|
17
20
|
rather than widening scope unasked — the diff is scored against the declared set, not your
|
package/src/bricks/test.md
CHANGED
|
@@ -14,10 +14,12 @@ brick only observes; a fix belongs in `apply`, not here.
|
|
|
14
14
|
failure: they check independent properties, and each repair must see every finding at once.
|
|
15
15
|
3. **Full suite** — only when everything above passed; otherwise `SKIPPED (an earlier check failed)`.
|
|
16
16
|
|
|
17
|
-
List every check
|
|
18
|
-
never left out, and silence is never a pass.
|
|
19
|
-
purpose, the property it guards, a one-line
|
|
20
|
-
reruns it alone. Keep full logs in a file
|
|
17
|
+
List every check on its own line as `<check>: <status>`, the status one of `PASS`, `FAIL`, `ERROR`
|
|
18
|
+
or `SKIPPED (reason)` — one that did not run is never left out, and silence is never a pass.
|
|
19
|
+
Write each failure as four lines: the check's purpose, the property it guards, a one-line
|
|
20
|
+
diagnostic (not the raw log), and the command that reruns it alone. Keep full logs in a file.
|
|
21
|
+
Write the list to a file in the OS temp directory (never inside the worktree) and report that
|
|
22
|
+
file's path with every outcome, `pass` included: the engine reads the list from it.
|
|
21
23
|
|
|
22
24
|
Report `pass` only if every check passed. Report `error` if a check crashed or could not be run —
|
|
23
25
|
no test runner, a missing tool, evidence never wired: that is a stop for a human, not a repair.
|
package/src/loops/bugfix.json
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bugfix",
|
|
3
|
-
"description": "Reproduce the bug with a failing test, then iterate: apply the fix, test, and review, until the requirement is met and the reproduction passes.",
|
|
3
|
+
"description": "Reproduce the bug with a failing test, then iterate: apply the fix, test, prove the tests bite by mutation, and review, until the requirement is met and the reproduction passes.",
|
|
4
4
|
"category": "development",
|
|
5
|
-
"
|
|
5
|
+
"rules": [
|
|
6
|
+
"Each card's writeSet names the reproduction test, so a mutation-check repair can strengthen it."
|
|
7
|
+
],
|
|
8
|
+
"nodes": ["reproduce", "identify", "apply", "test", "mutation-check", "review"],
|
|
6
9
|
"start": "reproduce",
|
|
7
10
|
"edges": [
|
|
8
11
|
{ "from": "reproduce", "on": "pass", "to": "identify" },
|
|
@@ -11,13 +14,16 @@
|
|
|
11
14
|
{ "from": "identify", "on": "done", "to": "$close" },
|
|
12
15
|
{ "from": "apply", "on": "pass", "to": "test" },
|
|
13
16
|
{ "from": "test", "on": "fail", "to": "apply" },
|
|
14
|
-
{ "from": "test", "on": "pass", "to": "
|
|
17
|
+
{ "from": "test", "on": "pass", "to": "mutation-check" },
|
|
18
|
+
{ "from": "mutation-check", "on": "pass", "to": "review" },
|
|
19
|
+
{ "from": "mutation-check", "on": "fail", "to": "apply" },
|
|
20
|
+
{ "from": "mutation-check", "on": "unavailable", "to": "review" },
|
|
15
21
|
{ "from": "review", "on": "pass", "to": "identify" },
|
|
16
22
|
{ "from": "review", "on": "fail", "to": "apply" }
|
|
17
23
|
],
|
|
18
24
|
"loops": [
|
|
19
|
-
{ "name": "iterations", "nodes": ["identify", "apply", "test", "review"], "max": 20, "iteration": true },
|
|
25
|
+
{ "name": "iterations", "nodes": ["identify", "apply", "test", "mutation-check", "review"], "max": 20, "iteration": true },
|
|
20
26
|
{ "name": "apply-test", "nodes": ["apply", "test"], "max": 2 },
|
|
21
|
-
{ "name": "review-fix", "nodes": ["apply", "test", "review"], "max": 3 }
|
|
27
|
+
{ "name": "review-fix", "nodes": ["apply", "test", "mutation-check", "review"], "max": 3 }
|
|
22
28
|
]
|
|
23
29
|
}
|
package/src/loops/feature.json
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "feature",
|
|
3
|
-
"description": "Plan the feature into ordered iterations, then build each one: apply, test, and review, until the plan is complete — and an independent done-check maps every requirement to a passing test before the loop closes.",
|
|
3
|
+
"description": "Plan the feature into ordered iterations, then build each one test-first: a failing test, apply, test, and review, until the plan is complete — and an independent done-check maps every requirement to a passing test before the loop closes.",
|
|
4
4
|
"category": "development",
|
|
5
|
-
"nodes": ["plan", "identify", "apply", "test", "review", "done-check"],
|
|
5
|
+
"nodes": ["plan", "identify", "red-test", "apply", "test", "review", "done-check"],
|
|
6
6
|
"start": "plan",
|
|
7
7
|
"edges": [
|
|
8
8
|
{ "from": "plan", "on": "pass", "to": "identify" },
|
|
9
|
-
{ "from": "identify", "on": "more", "to": "
|
|
9
|
+
{ "from": "identify", "on": "more", "to": "red-test" },
|
|
10
10
|
{ "from": "identify", "on": "done", "to": "done-check" },
|
|
11
|
+
{ "from": "red-test", "on": "red", "to": "apply" },
|
|
12
|
+
{ "from": "red-test", "on": "green", "to": "test" },
|
|
13
|
+
{ "from": "red-test", "on": "untestable", "to": "$stop" },
|
|
11
14
|
{ "from": "apply", "on": "pass", "to": "test" },
|
|
12
15
|
{ "from": "test", "on": "pass", "to": "review" },
|
|
13
16
|
{ "from": "test", "on": "fail", "to": "apply" },
|
|
@@ -17,7 +20,7 @@
|
|
|
17
20
|
{ "from": "done-check", "on": "fail", "to": "identify" }
|
|
18
21
|
],
|
|
19
22
|
"loops": [
|
|
20
|
-
{ "name": "iterations", "nodes": ["identify", "apply", "test", "review", "done-check"], "max": 20, "iteration": true },
|
|
23
|
+
{ "name": "iterations", "nodes": ["identify", "red-test", "apply", "test", "review", "done-check"], "max": 20, "iteration": true },
|
|
21
24
|
{ "name": "apply-test", "nodes": ["apply", "test"], "max": 2 },
|
|
22
25
|
{ "name": "review-fix", "nodes": ["apply", "test", "review"], "max": 3 }
|
|
23
26
|
]
|
package/src/skills/loop.md
CHANGED
|
@@ -87,6 +87,7 @@ What `score --diff`, `decide` and `record` print back:
|
|
|
87
87
|
brick, `score --diff` before `record`). Do the step, never edit the state block to get past it.
|
|
88
88
|
An `{error}` from `record` that mentions JSON means the shell mangled the card's quotes: retry
|
|
89
89
|
with the card on a single line and no single quotes inside it.
|
|
90
|
+
A `test` `pass` with a `SKIPPED` entry is refused: run the check, or report `fail` or `error`.
|
|
90
91
|
|
|
91
92
|
## The end
|
|
92
93
|
|
package/src/skills/ship.md
CHANGED
|
@@ -36,7 +36,13 @@ request or merge the branch.
|
|
|
36
36
|
it is wrong — consumers, layout, data), and any follow-up. Link the
|
|
37
37
|
issue it closes; keep the title an imperative one-line summary.
|
|
38
38
|
6. If the project merges locally instead, merge into the base branch only after
|
|
39
|
-
review/approval
|
|
39
|
+
review/approval.
|
|
40
|
+
7. Once the branch is merged — locally or through the PR — delete it, local and remote
|
|
41
|
+
(`git branch -d <branch>`, `git push origin --delete <branch>`), with consent: it is a
|
|
42
|
+
deletion ({{LAW:deletion-is-deliberate}}). A PR usually merges after your turn ends,
|
|
43
|
+
with nobody left to delete its branch, so the first time you ship in a repo, check
|
|
44
|
+
whether the forge deletes merged branches by itself (GitHub: *Automatically delete
|
|
45
|
+
head branches*) and recommend turning it on if not.
|
|
40
46
|
If shipping triggers a production deploy, confirm a tested rollback or
|
|
41
47
|
fix-forward path and a retained previous artifact *before* deploying — there must
|
|
42
48
|
be a way back ({{LAW:deletion-is-deliberate}}); dispatch the
|
|
@@ -46,5 +52,7 @@ request or merge the branch.
|
|
|
46
52
|
## Done when
|
|
47
53
|
- The diff passed review with no `blocking` finding, and the PR is open (or the branch is merged) with a Summary / Evidence / Merge danger
|
|
48
54
|
body, and nothing unrelated rides along.
|
|
55
|
+
- A branch merged while you are still working is deleted, local and remote, or the user
|
|
56
|
+
declined.
|
|
49
57
|
|
|
50
58
|
<!-- INCLUDE: skills/_self-improvement.md -->
|