bareloop 0.53.0 → 0.54.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +34 -0
- package/bareloop.context.md +17 -11
- package/package.json +2 -2
- package/src/authorflow.js +33 -3
- package/src/authoring.js +30 -2
- package/src/authorjob.js +4 -0
- package/src/bridges.js +4 -3
- package/src/carrystore.js +5 -2
- package/src/declaredclose.js +1 -1
- package/src/kinds.js +4 -2
- package/src/launcher.js +7 -4
- package/src/learn.js +6 -4
- package/src/panel/handed.js +92 -0
- package/src/panel/index.html +225 -120
- package/src/panel/jobplan.js +6 -1
- package/src/panel/server.js +43 -8
- package/src/panel/status.js +3 -1
- package/src/plan.js +38 -1
- package/src/planrun.js +192 -38
- package/src/ralph.js +2 -0
- package/src/replay.js +6 -0
- package/src/reuse.js +3 -3
- package/src/tools.js +65 -6
- package/src/u-readout.js +2 -2
- package/src/userrun.js +1 -1
- package/types/authorflow.d.ts +54 -1
- package/types/bridges.d.ts +4 -3
- package/types/launcher.d.ts +5 -0
- package/types/panel/handed.d.ts +38 -0
- package/types/panel/jobplan.d.ts +2 -1
- package/types/plan.d.ts +19 -1
- package/types/planrun.d.ts +44 -1
- package/types/replay.d.ts +3 -0
- package/types/reuse.d.ts +2 -2
- package/types/tools.d.ts +25 -3
package/src/tools.js
CHANGED
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
// axis goes blind (F3). The consumer (planrun) wires it at construction.
|
|
14
14
|
|
|
15
15
|
import { createRequire } from 'node:module';
|
|
16
|
-
import { join, resolve, sep } from 'node:path';
|
|
16
|
+
import { join, resolve, sep, dirname, basename } from 'node:path';
|
|
17
|
+
import { realpath } from 'node:fs/promises';
|
|
17
18
|
import { homedir } from 'node:os';
|
|
18
19
|
|
|
19
20
|
const require = createRequire(import.meta.url);
|
|
@@ -57,9 +58,9 @@ export const PERSONA_TOOLS = 'You are a senior engineer working in a repository
|
|
|
57
58
|
+ `The repository root also holds the arbiter's own books — ${GATE_AUDIT_FILE}, ${ARBITER_BOOK_STORES.join(', ')}, and this run's spine. `
|
|
58
59
|
+ 'They are ALWAYS denied and record how you are being judged, never anything about the task: never read them, and never try to route around the denial. '
|
|
59
60
|
+ 'You are ONE attempt inside an automated loop: when you finish, a test suite runs and, if it still fails, you are called again with its output. '
|
|
60
|
-
+ 'So do not try to be certain before acting. Read only what you need to form your best hypothesis, make the change with the
|
|
61
|
+
+ 'So do not try to be certain before acting. Read only what you need to form your best hypothesis, make the change with the file-changing tool you were given, and stop. '
|
|
61
62
|
+ 'A wrong cheap attempt is corrected by the next round; exhaustive reading is not — every file you read is re-sent on every later round and the run has a hard budget it can exhaust before you ever write. '
|
|
62
|
-
+ 'Make the required changes with
|
|
63
|
+
+ 'Make the required changes with your file-changing tool, then reply with a short summary of what you changed. Never put file contents in your reply.';
|
|
63
64
|
|
|
64
65
|
// The retrieval verbs only pay if the worker reaches for them INSTEAD of paging a file.
|
|
65
66
|
// F18 measured the failure they exist to fix: the worker read one 117 KB file NINE times
|
|
@@ -616,14 +617,27 @@ export function createCtxTools(lc, workdir, emit, { onStalePointer = null } = {}
|
|
|
616
617
|
// cwd and reds at the fence, and the deny reason teaches the retry.
|
|
617
618
|
/** @param {string} p */
|
|
618
619
|
const expandHome = (p) => (p === '~' || p.startsWith('~/')) ? join(homedir(), p.slice(1)) : p;
|
|
620
|
+
/**
|
|
621
|
+
* F267 — what the audit records for a write/edit payload: its JSON type and its UTF-8 BYTE length. The old
|
|
622
|
+
* `String(x).length` read an object as "[object Object]" (15) and counted UTF-16 units, so a refused object
|
|
623
|
+
* write looked like a real 15-byte write. A non-string is measured as the JSON it was sent as.
|
|
624
|
+
* @param {any} v
|
|
625
|
+
* @returns {{bytes: number, valueType: string}}
|
|
626
|
+
*/
|
|
627
|
+
function valueSize(v) {
|
|
628
|
+
const valueType = v === null ? 'null' : Array.isArray(v) ? 'array' : typeof v;
|
|
629
|
+
if (v === undefined) return { bytes: 0, valueType };
|
|
630
|
+
const text = typeof v === 'string' ? v : (JSON.stringify(v) ?? '');
|
|
631
|
+
return { bytes: Buffer.byteLength(text), valueType };
|
|
632
|
+
}
|
|
619
633
|
/** @param {string} name @param {any} args @param {string} [workdir] */
|
|
620
634
|
export const toolAction = (name, args, workdir) => {
|
|
621
|
-
if (name === 'shell_write') return { type: 'write', path: resolve(expandHome(String(args?.path ?? ''))), args:
|
|
635
|
+
if (name === 'shell_write') return { type: 'write', path: resolve(expandHome(String(args?.path ?? ''))), args: valueSize(args?.content) };
|
|
622
636
|
// shell_edit (BA-13) is judged as bareguard's own 'edit' action type — the SAME
|
|
623
637
|
// fs.writeScope fence as write, decided upstream (bareguard FS_TYPES). `bytes` is
|
|
624
638
|
// the replacement's size so the audit can read the edit economy (a 40-byte splice
|
|
625
639
|
// vs an 8KB rewrite is the variable BA-13 exists to move — F18 blindness rule).
|
|
626
|
-
if (name === 'shell_edit') return { type: 'edit', path: resolve(expandHome(String(args?.path ?? ''))), args:
|
|
640
|
+
if (name === 'shell_edit') return { type: 'edit', path: resolve(expandHome(String(args?.path ?? ''))), args: valueSize(args?.newText) };
|
|
627
641
|
// `tool` rides the action so the AUDIT can tell the read tools apart. Without it every
|
|
628
642
|
// read tool collapses to {type:'read', path} and a whole-file shell_read is
|
|
629
643
|
// indistinguishable from a bounded ctx_get chunk — the ledger cannot see the one
|
|
@@ -664,8 +678,53 @@ export const toolAction = (name, args, workdir) => {
|
|
|
664
678
|
* `noFollowSymlinks` closes the swap-after-vetting window bare-agent documents.
|
|
665
679
|
* @param {{allows: (action: any) => Promise<boolean>}} gate
|
|
666
680
|
* @param {string} workdir
|
|
681
|
+
* @param {(absPath: string) => boolean|Promise<boolean>} [guardPath] BA-30: true for a path tracked at the seed (`trackedAtSeedGuard`)
|
|
667
682
|
*/
|
|
668
|
-
export const gatedShellOptions = (gate, workdir) => ({
|
|
683
|
+
export const gatedShellOptions = (gate, workdir, guardPath) => ({
|
|
669
684
|
noFollowSymlinks: true,
|
|
670
685
|
canRead: (/** @type {string} */ p, /** @type {{tool: string}} */ { tool }) => gate.allows(toolAction(tool, { path: p }, workdir)),
|
|
686
|
+
// BA-30 (F272): a whole-file write that would gut a file tracked at the seed is refused,
|
|
687
|
+
// file unchanged. Opt-in per worker; the scout has no write tool and passes no guardPath.
|
|
688
|
+
...(guardPath ? { shrinkGuard: { guardPath } } : {}),
|
|
671
689
|
});
|
|
690
|
+
|
|
691
|
+
/**
|
|
692
|
+
* The REAL path of `p`, for a path that may not exist yet: realpath the deepest existing
|
|
693
|
+
* ancestor and append the rest. bare-agent's guard hands its predicate the LEXICAL absolute
|
|
694
|
+
* path (it stays lexical by its own ruling), so a symlinked parent directory would otherwise
|
|
695
|
+
* read as "not tracked" and fail the guard open (F276 gap a).
|
|
696
|
+
* @param {string} p an absolute path
|
|
697
|
+
* @returns {Promise<string>}
|
|
698
|
+
*/
|
|
699
|
+
export async function realPathOrAncestor(p) {
|
|
700
|
+
/** @type {string[]} */ const rest = [];
|
|
701
|
+
let cur = p;
|
|
702
|
+
for (;;) {
|
|
703
|
+
try {
|
|
704
|
+
return join(await realpath(cur), ...rest);
|
|
705
|
+
} catch (e) {
|
|
706
|
+
const code = /** @type {NodeJS.ErrnoException} */ (e).code;
|
|
707
|
+
if (code !== 'ENOENT' && code !== 'ENOTDIR') throw e; // a fault is not "untracked": the guard throws and the write is refused
|
|
708
|
+
const up = dirname(cur);
|
|
709
|
+
if (up === cur) return p;
|
|
710
|
+
rest.unshift(basename(cur));
|
|
711
|
+
cur = up;
|
|
712
|
+
}
|
|
713
|
+
}
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
/**
|
|
717
|
+
* BA-30's `guardPath`: true only for a path tracked at the seed. Both sides are compared in
|
|
718
|
+
* the REAL form: the set is `realpath(workdir)` + each seed-listed name (a tracked path cannot
|
|
719
|
+
* lie beyond a symlink, git refuses it, so the join is already real), the candidate goes through
|
|
720
|
+
* `realPathOrAncestor`. Files the worker creates later are not in the set, so the guard is off
|
|
721
|
+
* for them (a rubric step file's own rewrite is not a gutting).
|
|
722
|
+
* @param {string} workdir the WORKER tree (panel worktree or hidden-git copy), never the source repo
|
|
723
|
+
* @param {string[]} files the seed listing (`seedListing().files`, repo-relative)
|
|
724
|
+
* @returns {Promise<(absPath: string) => Promise<boolean>>}
|
|
725
|
+
*/
|
|
726
|
+
export async function trackedAtSeedGuard(workdir, files) {
|
|
727
|
+
const root = await realpath(workdir);
|
|
728
|
+
const tracked = new Set(files.map((f) => join(root, f)));
|
|
729
|
+
return async (absPath) => tracked.has(await realPathOrAncestor(absPath));
|
|
730
|
+
}
|
package/src/u-readout.js
CHANGED
|
@@ -202,7 +202,7 @@ export function reviewDoorPackage({ door, diff }) {
|
|
|
202
202
|
const out = [];
|
|
203
203
|
out.push(`REVIEW DOOR — this run's close minted ${String(d.outcome ?? 'a verdict')} and it STANDS. Nothing you do here changes it.`);
|
|
204
204
|
if (held) {
|
|
205
|
-
out.push(' held this is a rubric (soft-green) job, so its green earns NO reuse
|
|
205
|
+
out.push(' held this is a rubric (soft-green) job, so its green earns NO reuse credit until you accept it, whether or not a judge ran');
|
|
206
206
|
}
|
|
207
207
|
// the body: what the machine judged, what moved, and the lines themselves —
|
|
208
208
|
// rendered by the SAME code the pause screen uses, off the same record shape.
|
|
@@ -273,7 +273,7 @@ export function doorTimingRedLines({ names }) {
|
|
|
273
273
|
export function runDoorLines({ rerun, accept, pause, ttlDays, held }) {
|
|
274
274
|
return threeDoors({
|
|
275
275
|
rerun: '"I don\'t like it, go again" — your words become the requirement a FRESH engagement plans against (its own clock, what is left of the signed budget)',
|
|
276
|
-
accept: `${held ? 'releases this run\'s
|
|
276
|
+
accept: `${held ? 'releases this run\'s reuse credit' : 'confirms it'} — and the close\'s MECHANICAL stages re-run first, because the tree can move after a run ends`,
|
|
277
277
|
pause: `not now. Nothing runs and nothing is spent; the door keeps for ${ttlDays} days and then expires on its own, which is all that "cancel" ever meant`,
|
|
278
278
|
}, { rerun, accept, pause });
|
|
279
279
|
}
|
package/src/userrun.js
CHANGED
|
@@ -2311,7 +2311,7 @@ async function execute(ctx) {
|
|
|
2311
2311
|
// still names (soft-green today) — a green-class row is born RELEASED, because a
|
|
2312
2312
|
// machine proved it and there was never a credit to quarantine
|
|
2313
2313
|
out(quarantinesCredit(spec.verdictType)
|
|
2314
|
-
? ' HELD: this green\'s
|
|
2314
|
+
? ' HELD: this green\'s reuse credit is quarantined until you release it at the door below'
|
|
2315
2315
|
: ' RELEASED: a machine proved this green, so its row carries no credit to quarantine');
|
|
2316
2316
|
} else if (REGISTRY_ROW.write !== null) {
|
|
2317
2317
|
// a REFUSED write is said out loud rather than swallowed — the door below is about to
|
package/types/authorflow.d.ts
CHANGED
|
@@ -218,6 +218,32 @@ export function declarationSchema(catalogue?: Record<string, any>, { verdictType
|
|
|
218
218
|
};
|
|
219
219
|
description: string;
|
|
220
220
|
};
|
|
221
|
+
guardLines: {
|
|
222
|
+
type: string;
|
|
223
|
+
items: {
|
|
224
|
+
type: string;
|
|
225
|
+
properties: {
|
|
226
|
+
guard: {
|
|
227
|
+
type: string;
|
|
228
|
+
minLength: number;
|
|
229
|
+
description: string;
|
|
230
|
+
};
|
|
231
|
+
lines: {
|
|
232
|
+
type: string;
|
|
233
|
+
minItems: number;
|
|
234
|
+
uniqueItems: boolean;
|
|
235
|
+
items: {
|
|
236
|
+
type: string;
|
|
237
|
+
minimum: number;
|
|
238
|
+
};
|
|
239
|
+
description: string;
|
|
240
|
+
};
|
|
241
|
+
};
|
|
242
|
+
required: string[];
|
|
243
|
+
additionalProperties: boolean;
|
|
244
|
+
};
|
|
245
|
+
description: string;
|
|
246
|
+
};
|
|
221
247
|
};
|
|
222
248
|
required: string[];
|
|
223
249
|
additionalProperties: boolean;
|
|
@@ -333,6 +359,32 @@ export function declarationTool(box: {
|
|
|
333
359
|
};
|
|
334
360
|
description: string;
|
|
335
361
|
};
|
|
362
|
+
guardLines: {
|
|
363
|
+
type: string;
|
|
364
|
+
items: {
|
|
365
|
+
type: string;
|
|
366
|
+
properties: {
|
|
367
|
+
guard: {
|
|
368
|
+
type: string;
|
|
369
|
+
minLength: number;
|
|
370
|
+
description: string;
|
|
371
|
+
};
|
|
372
|
+
lines: {
|
|
373
|
+
type: string;
|
|
374
|
+
minItems: number;
|
|
375
|
+
uniqueItems: boolean;
|
|
376
|
+
items: {
|
|
377
|
+
type: string;
|
|
378
|
+
minimum: number;
|
|
379
|
+
};
|
|
380
|
+
description: string;
|
|
381
|
+
};
|
|
382
|
+
};
|
|
383
|
+
required: string[];
|
|
384
|
+
additionalProperties: boolean;
|
|
385
|
+
};
|
|
386
|
+
description: string;
|
|
387
|
+
};
|
|
336
388
|
};
|
|
337
389
|
required: string[];
|
|
338
390
|
additionalProperties: boolean;
|
|
@@ -441,8 +493,9 @@ export function confirmedBlock(confirmed: {
|
|
|
441
493
|
* names the ONE numbered job line it serves, or the line is refused with a reason; the mandatory guards serve no line.
|
|
442
494
|
* The $0 validator (validateDeclaration, `jobLines`) enforces it and the revise loop feeds a miss back.
|
|
443
495
|
* @param {number} count how many numbered job lines the person wrote
|
|
496
|
+
* @param {string[]} [guardNames] the mandatory guards' names; present = the block also tells how a line they already cover is covered
|
|
444
497
|
*/
|
|
445
|
-
export function jobLineTagBlock(count: number): string;
|
|
498
|
+
export function jobLineTagBlock(count: number, guardNames?: string[]): string;
|
|
446
499
|
/**
|
|
447
500
|
* The whole authoring prompt, as one string.
|
|
448
501
|
*
|
package/types/bridges.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** does a green under this verdict class earn its
|
|
1
|
+
/** does a green under this verdict class earn its reuse credit at the close, or
|
|
2
2
|
* does it wait for a person? Absent/unknown means green's behaviour, byte for byte
|
|
3
3
|
* — the pre-softgreen path is the default and stays untouched.
|
|
4
4
|
* @param {unknown} verdictType @returns {boolean} */
|
|
@@ -112,7 +112,7 @@ export function reuseEligibility(bridge: unknown): {
|
|
|
112
112
|
/**
|
|
113
113
|
* THE REVIEW DOOR, written down (PRD v1.71 §3). The person read the finished run
|
|
114
114
|
* and said one of three things; this records that on the run's own row, and — for
|
|
115
|
-
* `accept` on a HELD green — releases the
|
|
115
|
+
* `accept` on a HELD green — releases the reuse credit that green has been
|
|
116
116
|
* carrying unspent.
|
|
117
117
|
*
|
|
118
118
|
* Three properties, and each is a ruling rather than a convenience:
|
|
@@ -272,7 +272,8 @@ export const BRIDGE_SCHEMA: "bridge-v1";
|
|
|
272
272
|
* SOFTGREEN MODULE 6 — the verdict classes whose greens are minted QUARANTINED.
|
|
273
273
|
*
|
|
274
274
|
* The standing ruling (PRD v1.53, given a mechanism by v1.71 §3): *softgreen
|
|
275
|
-
* passes are quarantined from learning credit until the judged floor is proven
|
|
275
|
+
* passes are quarantined from learning credit until the judged floor is proven*
|
|
276
|
+
* (learning credit = reuse/bridge credit),
|
|
276
277
|
* and **the signer's `accept` at the review door is what releases it**.
|
|
277
278
|
*
|
|
278
279
|
* `soft-green` and NOT `hitl`: the hold is about the young JUDGE, not about every
|
package/types/launcher.d.ts
CHANGED
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
* @property {((target: string) => Promise<boolean>)} [open] default the shared OS opener
|
|
24
24
|
* @property {(port: number) => Promise<boolean>} [portFree] default: try to bind 127.0.0.1:port
|
|
25
25
|
* @property {(ms: number) => Promise<void>} [sleep]
|
|
26
|
+
* @property {() => number} [clock] monotonic ms clock for stop's wait-until-gone deadlines (default performance.now); tests pass a fake one so load cannot move a deadline
|
|
26
27
|
* @property {(question: string) => Promise<string>} [ask] the y/N and menu reader
|
|
27
28
|
* @property {string} [bareloopBin] default bin/bareloop.mjs of this package
|
|
28
29
|
* @property {import('./tty-colour.js').Paint} [paint] colour for stdout lines (default none); {@link makePaint} decides TTY / NO_COLOR / TERM
|
|
@@ -294,6 +295,10 @@ export type LauncherDeps = {
|
|
|
294
295
|
*/
|
|
295
296
|
portFree?: ((port: number) => Promise<boolean>) | undefined;
|
|
296
297
|
sleep?: ((ms: number) => Promise<void>) | undefined;
|
|
298
|
+
/**
|
|
299
|
+
* monotonic ms clock for stop's wait-until-gone deadlines (default performance.now); tests pass a fake one so load cannot move a deadline
|
|
300
|
+
*/
|
|
301
|
+
clock?: (() => number) | undefined;
|
|
297
302
|
/**
|
|
298
303
|
* the y/N and menu reader
|
|
299
304
|
*/
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Every step part's and fix part's tries (and a cut-off try) gain `memo`: the carry-note record handed to that try, or null; a try whose text-only ending was nudged (spine `worker-text-only`, `nudged: true`) also gains `nudged: true`.
|
|
3
|
+
* Parts and tries are copied, never mutated. An outer-close try (no model call) never has one.
|
|
4
|
+
* @param {any[]|null|undefined} parts @param {any[]} records the run's spine records
|
|
5
|
+
*/
|
|
6
|
+
export function attachMemos(parts: any[] | null | undefined, records: any[]): any[] | null | undefined;
|
|
7
|
+
/**
|
|
8
|
+
* The learnings the planner was handed, by injection: `draft` and `replan` (the first replan), each `{phase, text, chars, ids, hints}` or
|
|
9
|
+
* null, plus `error` (the plain line when the learnings file could not be read, else null).
|
|
10
|
+
* @param {any[]} records
|
|
11
|
+
*/
|
|
12
|
+
export function learningsHanded(records: any[]): {
|
|
13
|
+
draft: {
|
|
14
|
+
phase: string;
|
|
15
|
+
text: any;
|
|
16
|
+
chars: any;
|
|
17
|
+
ids: any;
|
|
18
|
+
hints: import("../learn.js").HintParts[];
|
|
19
|
+
} | null;
|
|
20
|
+
replan: {
|
|
21
|
+
phase: string;
|
|
22
|
+
text: any;
|
|
23
|
+
chars: any;
|
|
24
|
+
ids: any;
|
|
25
|
+
hints: import("../learn.js").HintParts[];
|
|
26
|
+
} | null;
|
|
27
|
+
error: string | null;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Put the learnings on the parts that received them: the draft block (and the error line) on the drafting part, else the `plan` part;
|
|
31
|
+
* the first-replan block on the first `replan` part. `drafting` is the drafting part or null. Copies, never mutates.
|
|
32
|
+
* @param {any[]|null|undefined} parts the spine's own parts @param {any|null} drafting @param {ReturnType<typeof learningsHanded>} l
|
|
33
|
+
* @returns {{parts: any[]|null|undefined, drafting: any|null}}
|
|
34
|
+
*/
|
|
35
|
+
export function attachLearnings(parts: any[] | null | undefined, drafting: any | null, l: ReturnType<typeof learningsHanded>): {
|
|
36
|
+
parts: any[] | null | undefined;
|
|
37
|
+
drafting: any | null;
|
|
38
|
+
};
|
package/types/panel/jobplan.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** @typedef {{name: string, cls: 'machine check'|'judge'|null}} PlanCheck */
|
|
2
|
-
/** @typedef {{n: number, text: string, rule: string, rules: string[], checks: PlanCheck[], refused: string[]}} PlanLine */
|
|
2
|
+
/** @typedef {{n: number, text: string, rule: string, rules: string[], checks: PlanCheck[], refused: string[], always?: string[]}} PlanLine */
|
|
3
3
|
/** @typedef {{lines: PlanLine[], loose: PlanCheck[], notChecked: string[], readNotes: string[], alwaysOn: string[], older: boolean, goal?: string}} JobPlan */
|
|
4
4
|
/**
|
|
5
5
|
* `machine check` for a kind a command decides, `judge` for one that needs judgement; `null` for a stage whose kind is
|
|
@@ -57,6 +57,7 @@ export type PlanLine = {
|
|
|
57
57
|
rules: string[];
|
|
58
58
|
checks: PlanCheck[];
|
|
59
59
|
refused: string[];
|
|
60
|
+
always?: string[];
|
|
60
61
|
};
|
|
61
62
|
export type JobPlan = {
|
|
62
63
|
lines: PlanLine[];
|
package/types/plan.d.ts
CHANGED
|
@@ -116,6 +116,24 @@ export function validatePlan(input: object | string, { job, maxStepRounds, scope
|
|
|
116
116
|
reds: Red[];
|
|
117
117
|
plan: object | null;
|
|
118
118
|
};
|
|
119
|
+
/**
|
|
120
|
+
* F271 (B2) — pair a `write` grant with `edit`. A look-around step the drafter gave `write` but not `edit`, whose exits force a
|
|
121
|
+
* change to an existing big file, can pass only by a whole-file `write` (u-mvy4cd0d: src/gate.js 2433 lines to 1). Code adds the
|
|
122
|
+
* verb; the agent never asks for it, and it is added only when the SIGNED ceiling (`job.tools`, absent = the full menu) already
|
|
123
|
+
* offers `edit`, so the agent still cannot widen its own menu. `edit` is judged by the same `writeScope` fence as `write`: no
|
|
124
|
+
* authority a whole-file write did not have. No signed hash covers a plan, so none moves.
|
|
125
|
+
*
|
|
126
|
+
* A rubric step-file step is exempt: every path it declares (`target` plus the `artifact-written`/`json-valid` paths) lies under
|
|
127
|
+
* `newFileDir` (`output/steps`, the engine-owned always-new-file directory), so there is nothing to edit.
|
|
128
|
+
*
|
|
129
|
+
* Pure: never mutates `plan`; returns the SAME reference when nothing changes. `validatePlan` is untouched — the runner applies this
|
|
130
|
+
* to the validated plan, so `plan-accepted` records the plan as executed.
|
|
131
|
+
* @param {any} plan a validated plan (`validatePlan(...).plan`)
|
|
132
|
+
* @param {any} job the validateJob-green plan shape spec (its `tools` is the signed ceiling)
|
|
133
|
+
* @param {string|null} [newFileDir] the always-new-file directory whose steps are exempt, or null for none
|
|
134
|
+
* @returns {any} the plan with `edit` appended to each write-without-edit step, or `plan` itself
|
|
135
|
+
*/
|
|
136
|
+
export function pairEditGrant(plan: any, job: any, newFileDir?: string | null): any;
|
|
119
137
|
/** the closed exit menu (PRD v1.12 §3 + decision 1's `check-passes`): the
|
|
120
138
|
* shell evaluates every form with its own fixed code, never a command — the
|
|
121
139
|
* same both-directions inexpressibility guard as the two-validator split */
|
|
@@ -126,7 +144,7 @@ export const MAX_EXITS_PER_STEP: 2;
|
|
|
126
144
|
/** a legal-example sentence for the exit menu — shown in the planner prompt and
|
|
127
145
|
* appended to the missing-required exit red, so a redraft sees a legal shape,
|
|
128
146
|
* not only the rule (F254: `exit` is required on EVERY step) */
|
|
129
|
-
export const EXIT_EXAMPLE: "Legal exit examples: a step
|
|
147
|
+
export const EXIT_EXAMPLE: "Legal exit examples: a read-only look-around step (tools read, grep) uses [{\"type\":\"artifact-written\",\"path\":\"<an existing file the step reads>\"}]; a step that changes files and has no check uses [{\"type\":\"artifact-written\",\"path\":\"<its target>\"},{\"type\":\"tree-changed\",\"scope\":\"<an offered scope>\"}]; a step with a check uses [{\"type\":\"tree-changed\",\"scope\":\"<an offered scope>\"},{\"type\":\"check-passes\",\"name\":\"<a check name>\"}].";
|
|
130
148
|
/** plan size bound — per-step rounds bound the spend, but an unbounded step
|
|
131
149
|
* COUNT is still an unbounded claim on the wallet; same 8 as loop.maxIterations */
|
|
132
150
|
export const MAX_PLAN_STEPS: 8;
|
package/types/planrun.d.ts
CHANGED
|
@@ -103,7 +103,7 @@ export function closeGapBlock(gap: string | null | undefined): string;
|
|
|
103
103
|
* and announces the trim with the repo's ONE marker rather than a second spelling
|
|
104
104
|
* of "this text was cut" (F90.2).
|
|
105
105
|
*
|
|
106
|
-
* @param {{iteration?: number|string|undefined, cause: string, reason: string|null}|null|undefined} bounded
|
|
106
|
+
* @param {{iteration?: number|string|undefined, cause: string, reason: string|null, bad?: BadCallFacts|null}|null|undefined} bounded
|
|
107
107
|
* the previous attempt's bound state, or nullish when it was not bounded
|
|
108
108
|
* @param {number} rounds the step's round bound, as quoted by the frozen sentence
|
|
109
109
|
* @returns {string|null} the note, or null when there is nothing to say
|
|
@@ -112,6 +112,7 @@ export function boundedNote(bounded: {
|
|
|
112
112
|
iteration?: number | string | undefined;
|
|
113
113
|
cause: string;
|
|
114
114
|
reason: string | null;
|
|
115
|
+
bad?: BadCallFacts | null;
|
|
115
116
|
} | null | undefined, rounds: number): string | null;
|
|
116
117
|
/**
|
|
117
118
|
* The plan-drafting prompt: a schema DESCRIPTION built from the live validator
|
|
@@ -532,12 +533,54 @@ export const FORBIDDEN_WRITE_SEGMENT_PATTERN: RegExp;
|
|
|
532
533
|
* shipped path routinely rides through.
|
|
533
534
|
*/
|
|
534
535
|
export const BOUND_REASON_MAX: 200;
|
|
536
|
+
/** the one message a text-only worker ending is continued with (once per ask, no toolChoice) */
|
|
537
|
+
export const TEXT_ONLY_NUDGE: "You ended without writing any file. Make the change now with your write or edit tool; do not reply in text.";
|
|
538
|
+
/** the stored text-only ending is capped here (report-only record, masked first) */
|
|
539
|
+
export const TEXT_ONLY_MAX: 2000;
|
|
535
540
|
/** the recorded reason for a step attempt whose round was cut at the output cap (F122 2A b) */
|
|
536
541
|
export const TRUNCATED_REASON: "output cut at the token limit (max_tokens)";
|
|
537
542
|
/** the plain sentence for a replan answer cut off at its length limit (hamr 2026-10-16, run mv9gm796) */
|
|
538
543
|
export const REPLAN_CUT_WORDS: "The replan answer was cut off at its length limit, so no new plan came back.";
|
|
544
|
+
/**
|
|
545
|
+
* @typedef {{ kind: string, tool: string|null, param?: string, expected?: string, got?: string, argBytes?: number, parsed?: boolean, hasAppend: boolean, round: number|null }} BadCallFact
|
|
546
|
+
* @typedef {{ calls: BadCallFact[], cutOff: {outputTokens: number|null, reasoningTokens: number|null, maxTokensRequested: number|null}|null }} BadCallFacts
|
|
547
|
+
* bare-agent's STRUCTURED `badCalls`/`cutOff` for one attempt (BA-29); the only input of the two note sentences below
|
|
548
|
+
*/
|
|
549
|
+
/** a cut call at least this many bytes long is the reason the round hit the cap: the note teaches `append` (a bareloop choice, not bare-agent's) */
|
|
550
|
+
export const CUT_LARGE_ARG_BYTES: 8000;
|
|
551
|
+
/** a cut round whose reasoning tokens are more than this share of its output tokens was spent thinking, not writing */
|
|
552
|
+
export const CUT_REASONING_SHARE: 0.5;
|
|
539
553
|
export type CategorizedError = Error & {
|
|
540
554
|
category?: string;
|
|
541
555
|
lib?: string;
|
|
556
|
+
badCall?: {
|
|
557
|
+
kind: string;
|
|
558
|
+
tool: string | null;
|
|
559
|
+
param?: string;
|
|
560
|
+
expected?: string;
|
|
561
|
+
got?: string;
|
|
562
|
+
};
|
|
563
|
+
};
|
|
564
|
+
export type BadCallFact = {
|
|
565
|
+
kind: string;
|
|
566
|
+
tool: string | null;
|
|
567
|
+
param?: string;
|
|
568
|
+
expected?: string;
|
|
569
|
+
got?: string;
|
|
570
|
+
argBytes?: number;
|
|
571
|
+
parsed?: boolean;
|
|
572
|
+
hasAppend: boolean;
|
|
573
|
+
round: number | null;
|
|
574
|
+
};
|
|
575
|
+
/**
|
|
576
|
+
* bare-agent's STRUCTURED `badCalls`/`cutOff` for one attempt (BA-29); the only input of the two note sentences below
|
|
577
|
+
*/
|
|
578
|
+
export type BadCallFacts = {
|
|
579
|
+
calls: BadCallFact[];
|
|
580
|
+
cutOff: {
|
|
581
|
+
outputTokens: number | null;
|
|
582
|
+
reasoningTokens: number | null;
|
|
583
|
+
maxTokensRequested: number | null;
|
|
584
|
+
} | null;
|
|
542
585
|
};
|
|
543
586
|
import { rateSourceFields } from './text.js';
|
package/types/replay.d.ts
CHANGED
|
@@ -149,6 +149,7 @@ export function replayRun(spineEvents: any[], auditEvents?: any[], { runId, audi
|
|
|
149
149
|
spentUsd: number | null;
|
|
150
150
|
unpricedRounds: number;
|
|
151
151
|
tripped: {
|
|
152
|
+
ladder?: boolean | undefined;
|
|
152
153
|
category: any;
|
|
153
154
|
detail: string | null;
|
|
154
155
|
} | null;
|
|
@@ -211,6 +212,7 @@ export function replayRun(spineEvents: any[], auditEvents?: any[], { runId, audi
|
|
|
211
212
|
spentUsd: number | null;
|
|
212
213
|
unpricedRounds: number;
|
|
213
214
|
tripped: {
|
|
215
|
+
ladder?: boolean | undefined;
|
|
214
216
|
category: any;
|
|
215
217
|
detail: string | null;
|
|
216
218
|
} | null;
|
|
@@ -237,6 +239,7 @@ export function replayRun(spineEvents: any[], auditEvents?: any[], { runId, audi
|
|
|
237
239
|
spentUsd: number | null;
|
|
238
240
|
unpricedRounds: number;
|
|
239
241
|
tripped: {
|
|
242
|
+
ladder?: boolean | undefined;
|
|
240
243
|
category: any;
|
|
241
244
|
detail: string | null;
|
|
242
245
|
} | null;
|
package/types/reuse.d.ts
CHANGED
|
@@ -484,7 +484,7 @@ export function writeGreenRow({ registryDir, bridge, meta, record }: {
|
|
|
484
484
|
* row, and if so, write it.
|
|
485
485
|
*
|
|
486
486
|
* `scripts/run-u.mjs` has always kept standalone bridge FILES and never a registry,
|
|
487
|
-
* so its review door could describe a held
|
|
487
|
+
* so its review door could describe a held reuse credit it had no row to release:
|
|
488
488
|
* `--decide accept` reached `recordDoor`, found no green row for the runid and died
|
|
489
489
|
* `no-row-for-run`. This is the row, and STORAGE IS ALL IT IS — selection, promotion
|
|
490
490
|
* and reuse execution stay parked (layer-3-reuse). Nothing here reads a row back.
|
|
@@ -525,7 +525,7 @@ export function writeRunGreenRow({ registryDir, job, name, outcome, plan, record
|
|
|
525
525
|
/**
|
|
526
526
|
* Apply a signer's door decision to the workflow a run wrote its row against:
|
|
527
527
|
* record the disposition, and — on `accept` over a HELD judged green — release the
|
|
528
|
-
*
|
|
528
|
+
* reuse credit that green has been carrying unspent (PRD v1.71 §3).
|
|
529
529
|
*
|
|
530
530
|
* This is the ONE seam between a person's answer and the box. It is deliberately
|
|
531
531
|
* separate from `runReuse`: the door opens AFTER the run has ended (a green run is
|
package/types/tools.d.ts
CHANGED
|
@@ -224,6 +224,26 @@ export function createCtxTools(lc: any, workdir: string, emit: (type: string, da
|
|
|
224
224
|
};
|
|
225
225
|
execute: (args: any) => Promise<string>;
|
|
226
226
|
})[];
|
|
227
|
+
/**
|
|
228
|
+
* The REAL path of `p`, for a path that may not exist yet: realpath the deepest existing
|
|
229
|
+
* ancestor and append the rest. bare-agent's guard hands its predicate the LEXICAL absolute
|
|
230
|
+
* path (it stays lexical by its own ruling), so a symlinked parent directory would otherwise
|
|
231
|
+
* read as "not tracked" and fail the guard open (F276 gap a).
|
|
232
|
+
* @param {string} p an absolute path
|
|
233
|
+
* @returns {Promise<string>}
|
|
234
|
+
*/
|
|
235
|
+
export function realPathOrAncestor(p: string): Promise<string>;
|
|
236
|
+
/**
|
|
237
|
+
* BA-30's `guardPath`: true only for a path tracked at the seed. Both sides are compared in
|
|
238
|
+
* the REAL form: the set is `realpath(workdir)` + each seed-listed name (a tracked path cannot
|
|
239
|
+
* lie beyond a symlink, git refuses it, so the join is already real), the candidate goes through
|
|
240
|
+
* `realPathOrAncestor`. Files the worker creates later are not in the set, so the guard is off
|
|
241
|
+
* for them (a rubric step file's own rewrite is not a gutting).
|
|
242
|
+
* @param {string} workdir the WORKER tree (panel worktree or hidden-git copy), never the source repo
|
|
243
|
+
* @param {string[]} files the seed listing (`seedListing().files`, repo-relative)
|
|
244
|
+
* @returns {Promise<(absPath: string) => Promise<boolean>>}
|
|
245
|
+
*/
|
|
246
|
+
export function trackedAtSeedGuard(workdir: string, files: string[]): Promise<(absPath: string) => Promise<boolean>>;
|
|
227
247
|
export const PERSONA_TOOLS: string;
|
|
228
248
|
export const RETRIEVAL_STRATEGY: string;
|
|
229
249
|
export const EDIT_STRATEGY: string;
|
|
@@ -255,14 +275,13 @@ export function toolAction(name: string, args: any, workdir?: string): {
|
|
|
255
275
|
path: string;
|
|
256
276
|
args: {
|
|
257
277
|
bytes: number;
|
|
258
|
-
|
|
278
|
+
valueType: string;
|
|
259
279
|
};
|
|
260
280
|
} | {
|
|
261
281
|
type: string;
|
|
262
282
|
path: string;
|
|
263
283
|
args: {
|
|
264
284
|
tool: string;
|
|
265
|
-
bytes?: undefined;
|
|
266
285
|
};
|
|
267
286
|
} | {
|
|
268
287
|
type: string;
|
|
@@ -271,7 +290,10 @@ export function toolAction(name: string, args: any, workdir?: string): {
|
|
|
271
290
|
};
|
|
272
291
|
export function gatedShellOptions(gate: {
|
|
273
292
|
allows: (action: any) => Promise<boolean>;
|
|
274
|
-
}, workdir: string): {
|
|
293
|
+
}, workdir: string, guardPath?: (absPath: string) => boolean | Promise<boolean>): {
|
|
294
|
+
shrinkGuard?: {
|
|
295
|
+
guardPath: (absPath: string) => boolean | Promise<boolean>;
|
|
296
|
+
} | undefined;
|
|
275
297
|
noFollowSymlinks: boolean;
|
|
276
298
|
canRead: (p: string, { tool }: {
|
|
277
299
|
tool: string;
|