bareloop 0.51.0 → 0.53.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 +34 -0
- package/README.md +12 -0
- package/bareloop.context.md +29 -12
- package/package.json +2 -2
- package/src/authorscout.js +2 -2
- package/src/carrynote.js +288 -0
- package/src/carrystore.js +264 -0
- package/src/config.js +2 -1
- package/src/job.js +16 -4
- package/src/pagedropwords.js +5 -2
- package/src/panel/index.html +289 -181
- package/src/panel/schedules.js +2 -2
- package/src/panel/server.js +47 -3
- package/src/planrun.js +59 -32
- package/src/readshim.js +98 -3
- package/src/replay.js +28 -3
- package/src/seednote.js +28 -0
- package/src/tools.js +17 -0
- package/types/carrynote.d.ts +151 -0
- package/types/carrystore.d.ts +65 -0
- package/types/config.d.ts +1 -1
- package/types/planrun.d.ts +2 -1
- package/types/readshim.d.ts +54 -18
- package/types/replay.d.ts +1 -0
- package/types/seednote.d.ts +18 -0
- package/types/tools.d.ts +8 -0
- package/src/handoff.js +0 -100
- package/types/handoff.d.ts +0 -39
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
// The carry note's store (M1, F258): the run-level record behind src/carrynote.js. It captures the worker's read-class tool
|
|
2
|
+
// calls AT THE SOURCE (the worker's tool objects, result SUMMARIES only, never file
|
|
3
|
+
// content), reads the run's edits from the WORKING TREE (git diff against the run's start commit, never the spine), renders
|
|
4
|
+
// the note and persists its state under `<workdir>/.smoke/carry/state.json` (an arbiter book: the worker's fs.deny covers
|
|
5
|
+
// `.smoke`, so it cannot read it; the gate audit, spine and bridges live there too). There is no switch: the memo is
|
|
6
|
+
// always on (hamr 2026-11-01).
|
|
7
|
+
import { execFile } from 'node:child_process';
|
|
8
|
+
import { promisify } from 'node:util';
|
|
9
|
+
import { existsSync, mkdirSync, readFileSync, statSync, writeFileSync } from 'node:fs';
|
|
10
|
+
import { isAbsolute, join, relative, resolve } from 'node:path';
|
|
11
|
+
import { SMOKE_STORE } from './kinds.js';
|
|
12
|
+
import { redactSecrets } from './validate.js';
|
|
13
|
+
import { render, isCarryExcluded, HUNK_LINES } from './carrynote.js';
|
|
14
|
+
|
|
15
|
+
const exec = promisify(execFile);
|
|
16
|
+
export const CARRY_DIR = 'carry';
|
|
17
|
+
/** the retry marker the next prompt of a retried step / fix try carries; kept as a pinned fact about the prompts, no longer read to decide an outcome */
|
|
18
|
+
export const RED_MARKER = /Previous attempt failed (this step's checks|the verification):/;
|
|
19
|
+
|
|
20
|
+
const lineCount = (/** @type {string} */ s) => (s === '' ? 0 : s.split('\n').length - (s.endsWith('\n') ? 1 : 0));
|
|
21
|
+
const clip = (/** @type {unknown} */ s, n = 200) => redactSecrets(String(s ?? '')).slice(0, n);
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* The run's edits from the working tree against the start commit: tracked (git diff) plus untracked (no diff exists).
|
|
25
|
+
* Arbiter books / .git / .bareloop are excluded. Never throws; [] on any git failure.
|
|
26
|
+
* @param {string} workdir @param {string|null} base
|
|
27
|
+
* @returns {Promise<{path: string, lines: number, hunks: string[]}[]>}
|
|
28
|
+
*/
|
|
29
|
+
export async function workingEdits(workdir, base) {
|
|
30
|
+
if (!base) return [];
|
|
31
|
+
const g = (/** @type {string[]} */ a) => exec('git', ['-c', 'core.quotepath=false', ...a], { cwd: workdir, maxBuffer: 1 << 26 });
|
|
32
|
+
const out = [];
|
|
33
|
+
try {
|
|
34
|
+
const { stdout: names } = await g(['diff', '--name-only', '-z', base]);
|
|
35
|
+
for (const p of names.split('\0').filter(Boolean)) {
|
|
36
|
+
if (isCarryExcluded(p)) continue;
|
|
37
|
+
const { stdout } = await g(['diff', '-U1', '--no-color', '--no-ext-diff', base, '--', `:(literal)${p}`]);
|
|
38
|
+
if (/^(Binary files .* differ|GIT binary patch)$/m.test(stdout)) { out.push({ path: p, lines: 0, hunks: ['(binary file changed)'] }); continue; }
|
|
39
|
+
const body = stdout.split('\n').filter((l) => !/^(diff --git|index |--- |\+\+\+ |new file mode|deleted file mode)/.test(l));
|
|
40
|
+
out.push({ path: p, lines: body.filter((l) => /^[+-]/.test(l)).length, hunks: body.slice(0, HUNK_LINES * 2) });
|
|
41
|
+
}
|
|
42
|
+
const { stdout: un } = await g(['ls-files', '--others', '--exclude-standard', '-z']);
|
|
43
|
+
for (const p of un.split('\0').filter(Boolean)) {
|
|
44
|
+
if (isCarryExcluded(p)) continue;
|
|
45
|
+
try {
|
|
46
|
+
const abs = resolve(workdir, p);
|
|
47
|
+
if (!statSync(abs).isFile() || statSync(abs).size > 262144) continue;
|
|
48
|
+
const text = readFileSync(abs, 'utf8');
|
|
49
|
+
if (text.includes('\0')) continue;
|
|
50
|
+
const ls = text.split('\n'); if (ls.at(-1) === '') ls.pop();
|
|
51
|
+
out.push({ path: p, lines: ls.length, hunks: ls.slice(0, HUNK_LINES * 2).map((l) => '+' + l) });
|
|
52
|
+
} catch { /* unreadable: not shown */ }
|
|
53
|
+
}
|
|
54
|
+
} catch { return out; }
|
|
55
|
+
return out;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Order edits oldest to newest by when they last changed: a file's recency is the latest settled ask whose `changed`
|
|
60
|
+
* list names it; a file in no `changed` list is oldest. Ties keep their incoming (alphabetical) order. PURE.
|
|
61
|
+
* @param {{path: string}[]} edits @param {{changed?: string[]}[]} settled asks settled so far, oldest first
|
|
62
|
+
*/
|
|
63
|
+
export function orderEditsByRecency(edits, settled) {
|
|
64
|
+
const last = (/** @type {string} */ p) => { for (let i = settled.length - 1; i >= 0; i--) if ((settled[i].changed ?? []).includes(p)) return i; return -1; };
|
|
65
|
+
return edits.map((e, k) => ({ e, k, r: last(e.path) })).sort((a, b) => a.r - b.r || a.k - b.k).map((x) => x.e);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Run-level store. Asks are sequential, so "the current ask" is one counter.
|
|
70
|
+
* @param {{workdir: string, emit: (type: string, rec: any) => void, strikeLimit?: number, resume?: boolean}} o
|
|
71
|
+
*/
|
|
72
|
+
export function createCarryStore({ workdir, emit, strikeLimit, resume = false }) {
|
|
73
|
+
workdir = resolve(workdir);
|
|
74
|
+
const dir = join(workdir, SMOKE_STORE, CARRY_DIR);
|
|
75
|
+
const stateFile = join(dir, 'state.json');
|
|
76
|
+
/** @type {string|null} */
|
|
77
|
+
let base = null;
|
|
78
|
+
let n = 0;
|
|
79
|
+
/** @type {any[]} */ let events = [];
|
|
80
|
+
/** @type {any[]} one per WORK ask (step/fix): {n, kind, step, iteration, bounded, red, changed, startSnap} */
|
|
81
|
+
let asks = [];
|
|
82
|
+
let loaded = false;
|
|
83
|
+
/** @type {string|null} the job's own count-check text at start (the seed note's body), the oldest entry of the memo's earlier failures */
|
|
84
|
+
let startFailure = null;
|
|
85
|
+
if (resume && existsSync(stateFile)) {
|
|
86
|
+
try { const s = JSON.parse(readFileSync(stateFile, 'utf8')); n = s.n ?? 0; events = s.events ?? []; asks = s.asks ?? []; base = s.base ?? null; startFailure = s.startFailure ?? null; loaded = true; } catch { /* a bad file starts empty */ }
|
|
87
|
+
}
|
|
88
|
+
const save = () => {
|
|
89
|
+
try { mkdirSync(dir, { recursive: true }); writeFileSync(stateFile, JSON.stringify({ n, base, events, asks, startFailure })); } catch { /* a record, never a verdict: a failed save never breaks a run */ }
|
|
90
|
+
};
|
|
91
|
+
const rel = (/** @type {string} */ p) => (isAbsolute(p) ? relative(workdir, p) : p).split('\\').join('/') || '.';
|
|
92
|
+
const diskLines = (/** @type {string} */ r, /** @type {string|undefined} */ fallback) => { try { return lineCount(readFileSync(resolve(workdir, r), 'utf8')); } catch { return fallback === undefined ? null : lineCount(fallback); } };
|
|
93
|
+
|
|
94
|
+
/** Wrap the worker's read-class tools in place; records tool, args and a result SUMMARY - never file content. @param {{name: string, execute: Function}[]} tools */
|
|
95
|
+
const wrapTools = (tools) => {
|
|
96
|
+
for (const t of tools) {
|
|
97
|
+
const inner = t.execute;
|
|
98
|
+
if (t.name === 'shell_read') {
|
|
99
|
+
t.execute = async (/** @type {any} */ args) => {
|
|
100
|
+
const r = await inner(args);
|
|
101
|
+
try {
|
|
102
|
+
if (typeof r === 'string' && typeof args?.path === 'string') {
|
|
103
|
+
const p = rel(args.path);
|
|
104
|
+
const dirRead = /^dir /.test(r);
|
|
105
|
+
events.push({ ask: n, tool: 'read', path: p, ...(dirRead ? { dir: true } : { lines: diskLines(p, r) }) });
|
|
106
|
+
}
|
|
107
|
+
} catch { /* never break the worker */ }
|
|
108
|
+
return r;
|
|
109
|
+
};
|
|
110
|
+
} else if (t.name === 'ctx_get') {
|
|
111
|
+
t.execute = async (/** @type {any} */ args) => {
|
|
112
|
+
const r = await inner(args);
|
|
113
|
+
try {
|
|
114
|
+
if (typeof r === 'string' && typeof args?.path === 'string' && !/^(ctx_get failed|no chunk|stale)/.test(r)) {
|
|
115
|
+
const p = rel(args.path);
|
|
116
|
+
const a = Number(args.startLine); const b = Number(args.endLine);
|
|
117
|
+
events.push({ ask: n, tool: 'get', path: p, lines: diskLines(p, undefined), range: Number.isFinite(a) && Number.isFinite(b) ? [a, b] : null });
|
|
118
|
+
}
|
|
119
|
+
} catch { /* never break the worker */ }
|
|
120
|
+
return r;
|
|
121
|
+
};
|
|
122
|
+
} else if (t.name === 'shell_grep') {
|
|
123
|
+
t.execute = async (/** @type {any} */ args) => {
|
|
124
|
+
const r = await inner(args);
|
|
125
|
+
try {
|
|
126
|
+
const hits = Array.isArray(r?.hits) ? r.hits : null;
|
|
127
|
+
events.push({
|
|
128
|
+
ask: n, tool: 'grep', pattern: clip(args?.pattern), scope: rel(String(args?.path ?? '.')),
|
|
129
|
+
...(hits ? { matches: hits.length, firstMatches: hits.slice(0, 3).map((/** @type {any} */ h) => `${rel(String(h.file))}:${h.line}`) } : {}),
|
|
130
|
+
});
|
|
131
|
+
} catch { /* never break the worker */ }
|
|
132
|
+
return r;
|
|
133
|
+
};
|
|
134
|
+
} else if (t.name === 'ctx_recall') {
|
|
135
|
+
t.execute = async (/** @type {any} */ args) => {
|
|
136
|
+
const r = await inner(args);
|
|
137
|
+
try {
|
|
138
|
+
if (typeof r === 'string') {
|
|
139
|
+
/** @type {string[]} */ const hitPaths = []; /** @type {string[]} */ const hitRanges = [];
|
|
140
|
+
for (const line of r.split('\n')) {
|
|
141
|
+
const m = /^([^\t]+)\t[^\t]*\t[^\t]*\tlines (\d+-\d+)$/.exec(line);
|
|
142
|
+
if (m) { hitPaths.push(m[1]); hitRanges.push(`${m[1]} ${m[2]}`); }
|
|
143
|
+
}
|
|
144
|
+
events.push({ ask: n, tool: 'recall', query: clip(args?.query), hitPaths: [...new Set(hitPaths)], hitRanges });
|
|
145
|
+
}
|
|
146
|
+
} catch { /* never break the worker */ }
|
|
147
|
+
return r;
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
/** the per-entry cap on one file's function ranges, so one huge file cannot eat the memo */
|
|
154
|
+
const FN_CAP = 500;
|
|
155
|
+
/**
|
|
156
|
+
* Function line ranges per read file, from the LiteCtx index's named chunks (`name a-b, ...`). Fresh index only: a node whose
|
|
157
|
+
* last chunk ends past the file's current end is stale, and that file gets no ranges. Never throws.
|
|
158
|
+
* @param {any[]} evs @param {(rel: string) => any} getNode @returns {Record<string, string>}
|
|
159
|
+
*/
|
|
160
|
+
const fnRangesOf = (evs, getNode) => {
|
|
161
|
+
/** @type {Record<string, string>} */ const out = {};
|
|
162
|
+
for (const p of new Set(evs.filter((e) => (e.tool === 'read' || e.tool === 'get') && !e.dir && e.path && !isCarryExcluded(e.path)).map((e) => e.path))) {
|
|
163
|
+
let node = null;
|
|
164
|
+
try { node = getNode(p); } catch { node = null; }
|
|
165
|
+
const n = diskLines(p, undefined);
|
|
166
|
+
const named = (node?.chunks ?? []).filter((/** @type {any} */ c) => c.symbol);
|
|
167
|
+
if (n === null || !named.length || !named.every((/** @type {any} */ c) => c.endLine <= n)) continue;
|
|
168
|
+
let map = ''; let more = 0;
|
|
169
|
+
for (let i = 0; i < named.length; i++) {
|
|
170
|
+
const piece = `${named[i].symbol} ${named[i].startLine}-${named[i].endLine}`;
|
|
171
|
+
if ((map ? map.length + 2 : 0) + piece.length > FN_CAP) { more = named.length - i; break; }
|
|
172
|
+
map += (map ? ', ' : '') + piece;
|
|
173
|
+
}
|
|
174
|
+
out[p] = map + (more ? `, +${more} more` : '');
|
|
175
|
+
}
|
|
176
|
+
return out;
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
const snapOf = (/** @type {{path: string, lines: number}[]} */ edits) => Object.fromEntries(edits.map((e) => [e.path, e.lines]));
|
|
180
|
+
const tryLabel = (/** @type {any} */ a) => (a.kind === 'fix' ? `fix loop try ${a.iteration}` : `step "${a.step}" try ${a.iteration}`);
|
|
181
|
+
// how the try ended AND what its check said: a bounded try says both (the bound hides nothing)
|
|
182
|
+
const endedOf = (/** @type {any} */ a) => {
|
|
183
|
+
const res = a.result === 'red' ? 'Its check failed.' : a.result === 'green' ? 'Its check passed.' : null;
|
|
184
|
+
if (a.boundedText) return `${a.boundedText} ${res ?? 'Check not run.'}`;
|
|
185
|
+
return res ?? 'No check result was recorded for it.';
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Called at the start of EVERY ask (scout and drafter included, so their finds feed the store).
|
|
190
|
+
* Returns the note text for step/fix asks, '' otherwise.
|
|
191
|
+
* `getNode`: the LiteCtx index's node for a path (its `chunks`), for the function ranges; absent = no ranges.
|
|
192
|
+
* @param {{phase: string, iteration: number|string|undefined, prompt: string, getNode?: (rel: string) => any}} o
|
|
193
|
+
*/
|
|
194
|
+
const beginAsk = async ({ phase, iteration, prompt, getNode }) => {
|
|
195
|
+
n++;
|
|
196
|
+
const work = phase === 'fix' || phase.startsWith('step:');
|
|
197
|
+
if (!work) { save(); return ''; }
|
|
198
|
+
const edits = await workingEdits(workdir, base);
|
|
199
|
+
const prev = asks[asks.length - 1];
|
|
200
|
+
if (prev && prev.red === undefined) {
|
|
201
|
+
// settle the previous work ask: red = the check result the engine handed to settleAsk (never this prompt's wording);
|
|
202
|
+
// changed = files whose changed-line count moved
|
|
203
|
+
prev.red = prev.result === 'red';
|
|
204
|
+
const now = snapOf(edits);
|
|
205
|
+
prev.changed = [...new Set([...Object.keys(now), ...Object.keys(prev.startSnap)])].filter((p) => now[p] !== prev.startSnap[p]).sort();
|
|
206
|
+
for (const e of events) if (e.ask === prev.n) e.noFix = prev.changed.length === 0 && prev.red;
|
|
207
|
+
}
|
|
208
|
+
const kind = phase === 'fix' ? 'fix' : 'step';
|
|
209
|
+
const step = kind === 'step' ? phase.slice('step:'.length) : null;
|
|
210
|
+
const settled = asks.filter((a) => a.red !== undefined);
|
|
211
|
+
const lt = settled[settled.length - 1];
|
|
212
|
+
const notes = {
|
|
213
|
+
lastTry: lt ? { step: lt.step, kind: lt.kind, n: lt.iteration, of: lt.kind === 'step' ? strikeLimit : undefined, ended: endedOf(lt), changed: lt.changed } : null,
|
|
214
|
+
lastCheck: null, // the failed check's text is already in the prompt today; one copy
|
|
215
|
+
events: events.map((e) => ({ ...e })),
|
|
216
|
+
edits: orderEditsByRecency(edits, settled),
|
|
217
|
+
// every failed check's whole text, oldest first; the newest is left out only when it belongs to the last settled try
|
|
218
|
+
// (a red try being retried: the prompt carries it, one copy). A failure from a try that was later passed is in no prompt.
|
|
219
|
+
// plus the start failure, oldest of all: it is never in a prompt gap, so it is never the one left out
|
|
220
|
+
failures: [...(startFailure ? [{ label: 'at start', text: startFailure }] : []), ...settled.filter((a) => a.failure && a !== lt).map((a) => ({ label: tryLabel(a), text: a.failure }))],
|
|
221
|
+
earlier: settled.slice(0, -1).map((a) => `${tryLabel(a)}: ${endedOf(a)} ${a.changed.length ? `Changed ${a.changed.join(', ')}.` : 'Changed nothing.'}`),
|
|
222
|
+
lastAsk: lt ? lt.n : undefined,
|
|
223
|
+
fnRanges: getNode ? fnRangesOf(events, getNode) : {},
|
|
224
|
+
};
|
|
225
|
+
asks.push({ n, kind, step, iteration, startSnap: snapOf(edits) });
|
|
226
|
+
const hasAny = notes.events.length || edits.length || notes.earlier.length || notes.failures.length || notes.lastTry;
|
|
227
|
+
if (!hasAny) { save(); return ''; }
|
|
228
|
+
const r = render(/** @type {any} */ (notes));
|
|
229
|
+
emit('carry-note', { phase, iteration, chars: r.text.length, capped: r.capped, sections: r.sections }); // counts only
|
|
230
|
+
save();
|
|
231
|
+
return r.text;
|
|
232
|
+
};
|
|
233
|
+
|
|
234
|
+
/** Called when the ask returns (finally). @param {{bounded?: {iteration: any, cause: string}|undefined, iteration: any, rounds: number}} o */
|
|
235
|
+
const endAsk = ({ bounded, iteration, rounds }) => {
|
|
236
|
+
const a = asks[asks.length - 1];
|
|
237
|
+
if (!a || a.n !== n) return;
|
|
238
|
+
if (bounded && bounded.iteration === iteration) {
|
|
239
|
+
a.boundedText = bounded.cause === 'rounds' ? `Ran out of calls (${rounds} of ${rounds}).`
|
|
240
|
+
: bounded.cause === 'wall' ? 'Stopped by the wall clock.'
|
|
241
|
+
: bounded.cause === 'denied' ? 'Stopped after repeated denied calls.' : 'Output cut at the token limit.';
|
|
242
|
+
}
|
|
243
|
+
save();
|
|
244
|
+
};
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* The engine's own check result for the ask that just returned: 'green' (every check passed), 'red' (one failed) or
|
|
248
|
+
* 'unknown' (the check hit an instrument fault, so no honest answer). Only the first result per ask counts.
|
|
249
|
+
* A red also hands over the check's WHOLE failing text (the gap the next prompt carries); it is stored masked, never clipped.
|
|
250
|
+
* @param {'green'|'red'|'unknown'} result @param {string} [text]
|
|
251
|
+
*/
|
|
252
|
+
const settleAsk = (result, text) => {
|
|
253
|
+
const a = asks[asks.length - 1];
|
|
254
|
+
if (!a || a.n !== n || a.result !== undefined) return;
|
|
255
|
+
a.result = result;
|
|
256
|
+
if (result === 'red' && typeof text === 'string' && text !== '') a.failure = redactSecrets(text);
|
|
257
|
+
save();
|
|
258
|
+
};
|
|
259
|
+
|
|
260
|
+
/** The seed note's body (already secret-masked), set once per run; a resume keeps the one it persisted. @param {string} text */
|
|
261
|
+
const setStartFailure = (text) => { if (!startFailure && text) { startFailure = text; save(); } };
|
|
262
|
+
|
|
263
|
+
return { wrapTools, beginAsk, setStartFailure, endAsk, settleAsk, setBase: (/** @type {string|null|undefined} */ b) => { if (!base && b) base = b; }, loaded: () => loaded, _state: () => ({ n, events, asks, base }) };
|
|
264
|
+
}
|
package/src/config.js
CHANGED
|
@@ -161,7 +161,7 @@ function docProblem(doc) {
|
|
|
161
161
|
* Patch fields understood: `monthlyLimitUsd` (finite > 0), `learningHints` (true | false), `keys.<ENV>.{shape,baseUrl,legacyMaxTokens}`,
|
|
162
162
|
* `models.<ENV>` (a list judged by {@link modelsProblem}). The first write of a row's `models` list
|
|
163
163
|
* removes that row's older `name` / `priceInPerM` / `priceOutPerM` in the SAME write (never two
|
|
164
|
-
* sources);
|
|
164
|
+
* sources); the retired top-level `anthropicBalanceNote` and `carryNote` (the carry memo is always on, 2026-11-01) are dropped on any write. Any other field is
|
|
165
165
|
* kept, but the whole document is swept for secret-shaped strings first.
|
|
166
166
|
* @param {Record<string, any>} patch
|
|
167
167
|
* @param {{ home?: string }} [opts]
|
|
@@ -182,6 +182,7 @@ export function updateConfig(patch, opts = {}) {
|
|
|
182
182
|
next[k] = v;
|
|
183
183
|
}
|
|
184
184
|
delete next.anthropicBalanceNote;
|
|
185
|
+
delete next.carryNote;
|
|
185
186
|
if (patch.keys !== undefined) {
|
|
186
187
|
if (patch.keys === null || typeof patch.keys !== 'object' || Array.isArray(patch.keys)) {
|
|
187
188
|
throw new ConfigError('keys must be an object of key variable names');
|
package/src/job.js
CHANGED
|
@@ -170,7 +170,7 @@ export const CONDITION_KEYS = Object.freeze(['providerPath', 'closeVerbosity', '
|
|
|
170
170
|
// `steps` stays in the field list ONLY so a retired spec reds by name
|
|
171
171
|
// (`shape-retired`) instead of falling through to a generic unknown-field —
|
|
172
172
|
// the operator gets told what happened, not just that something is wrong.
|
|
173
|
-
const JOB_FIELDS = ['schema', 'job', 'description', 'provider', 'baseUrl', 'conditions', 'cadence', 'trigger', 'budgetUsd', 'maxWallMs', 'closeTimeoutMs', 'model', 'thinking', 'handoffNote', 'judge', 'writeScope', 'steps', 'escalation', 'goal', 'verdictType', 'close', 'closeDecl', 'checks', 'tools', 'jobLines', 'inputs'];
|
|
173
|
+
const JOB_FIELDS = ['schema', 'job', 'description', 'provider', 'baseUrl', 'conditions', 'cadence', 'trigger', 'budgetUsd', 'maxWallMs', 'closeTimeoutMs', 'model', 'thinking', 'handoffNote', 'seedNote', 'readMap', 'judge', 'writeScope', 'steps', 'escalation', 'goal', 'verdictType', 'close', 'closeDecl', 'checks', 'tools', 'jobLines', 'inputs'];
|
|
174
174
|
/** the exact fields of a signed `judge` override — nested objects red unknown
|
|
175
175
|
* keys too, because no smuggling level exists in a signed spec */
|
|
176
176
|
const JUDGE_FIELDS = ['provider', 'model'];
|
|
@@ -349,10 +349,22 @@ export function validateJob(input, { shellCapUsd = 2 } = {}) {
|
|
|
349
349
|
if (spec.thinking !== undefined && typeof spec.thinking !== 'boolean') {
|
|
350
350
|
red('invalid-value', 'thinking', 'true or false — the job\'s "Thinking on" tick (absent = off)');
|
|
351
351
|
}
|
|
352
|
-
//
|
|
353
|
-
//
|
|
352
|
+
// LEGACY `handoffNote` (the handoff note was folded into the carry memo, 2026-10-31): still accepted and hashed so an old signed spec
|
|
353
|
+
// verifies; it has NO effect since 2026-11-01 (the carry memo is always on). A boolean if present. New specs and drafts never write it.
|
|
354
354
|
if (spec.handoffNote !== undefined && typeof spec.handoffNote !== 'boolean') {
|
|
355
|
-
red('invalid-value', 'handoffNote', 'true or false (
|
|
355
|
+
red('invalid-value', 'handoffNote', 'true or false (legacy, ignored: the carry memo is always on)');
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
// THE SEED NOTE (src/seednote.js): a declared job condition, signed like `thinking`. A boolean; ABSENT = on (an old spec keeps its
|
|
359
|
+
// bytes, so its hash), only an explicit `false` turns off handing the planner and the first worker what the job's own check said at start. The switch is hashed; the text never is.
|
|
360
|
+
if (spec.seedNote !== undefined && typeof spec.seedNote !== 'boolean') {
|
|
361
|
+
red('invalid-value', 'seedNote', 'true or false (absent = on): whether the planner and the first worker are told what the job\'s own count check said on the untouched tree');
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
// THE FIRST-READ MAP (src/readshim.js, EXPERIMENTAL): a declared job condition, signed like `thinking`. A boolean; ABSENT = off (an old spec keeps
|
|
365
|
+
// its bytes, so its hash), `true` makes the first shell_read of a big non-test file in an ask return a map of its parts. The switch is hashed.
|
|
366
|
+
if (spec.readMap !== undefined && typeof spec.readMap !== 'boolean') {
|
|
367
|
+
red('invalid-value', 'readMap', 'true or false (absent = off, experimental): whether the first read of a big file in an ask returns a map of its parts instead of the file');
|
|
356
368
|
}
|
|
357
369
|
|
|
358
370
|
// JUDGE — PRD item 32.1 (hamr, 2026-09-10: the judge "defaults to whatever
|
package/src/pagedropwords.js
CHANGED
|
@@ -7,6 +7,9 @@ import { FACT_LANGS } from './facts.js';
|
|
|
7
7
|
|
|
8
8
|
/** @typedef {import('./pagerules.js').Dropped} Dropped */
|
|
9
9
|
|
|
10
|
+
/** the two ways a sign listed twice can be used once; the sentence below and the read-note probes (SENTENCE_RE) both read this one list */
|
|
11
|
+
const SIGN_TWICE_AS = ['currency', 'unit'];
|
|
12
|
+
|
|
10
13
|
/** reason code -> the plain sentence (`d.word` = the page's word, `d.fact` = the fact's name, `d.other` = what it was compared to) */
|
|
11
14
|
const WORDS = /** @type {Record<string, (d: Dropped) => string>} */ ({
|
|
12
15
|
'not-on-page': (d) => `"${d.word}" is not written on the page.`,
|
|
@@ -14,7 +17,7 @@ const WORDS = /** @type {Record<string, (d: Dropped) => string>} */ ({
|
|
|
14
17
|
'reads-no-amount': (d) => `The page never shows an amount next to "${d.word}", so it was not used to write the price.`,
|
|
15
18
|
'n2': (d) => `"${d.word}" is written more than once inside one line of the page, so one result cannot show it once.`,
|
|
16
19
|
'r1': (d) => `"${d.word}" does not show the same values as "${d.other}", so it was not used as a second way to read it.`,
|
|
17
|
-
'sign-twice': (d) => `"${d.word}" was listed twice, as a unit and as a currency; it is used once, as the ${
|
|
20
|
+
'sign-twice': (d) => `"${d.word}" was listed twice, as a unit and as a currency; it is used once, as the ${SIGN_TWICE_AS.find((kind) => kind === d.other) ?? 'currency'}.`,
|
|
18
21
|
'r1l': (d) => d.word === d.other
|
|
19
22
|
? `"${d.word}" was listed twice, as a unit and as a currency; it is used once, as the first way to write the price.`
|
|
20
23
|
: `"${d.word}" does not show the same amounts as "${d.other}", so it was not used as a second way to write the price.`,
|
|
@@ -81,7 +84,7 @@ const SENTENCE_RE = (() => {
|
|
|
81
84
|
/** @type {string[]} */
|
|
82
85
|
const alts = [];
|
|
83
86
|
for (const reason of WORD_REASONS) {
|
|
84
|
-
const probes = reason === 'r1l' ? [{ word: W, other: W }, { word: W, other: O }] : reason === 'sign-twice' ?
|
|
87
|
+
const probes = reason === 'r1l' ? [{ word: W, other: W }, { word: W, other: O }] : reason === 'sign-twice' ? SIGN_TWICE_AS.map((other) => ({ word: W, other })) : [{ word: W, other: O }];
|
|
85
88
|
for (const p of probes) alts.push(esc(WORDS[reason](/** @type {any} */ ({ ...p, reason, line: 0, fact: 'f' }))).split(esc(W)).join('[^"]+').split(esc(O)).join('[^"]+'));
|
|
86
89
|
}
|
|
87
90
|
return new RegExp(`^(?:(?:${alts.join('|')})(?: |$))+$`);
|