bareloop 0.50.0 → 0.52.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.
@@ -0,0 +1,69 @@
1
+ /**
2
+ * The ONE setting: `carryNote` in config.json, read exactly like `learningHints` (src/learnstore.js `learningHintsOn`).
3
+ * Absent = on; only an explicit `false` turns it off. An unreadable config reads as OFF (the safe side).
4
+ * @param {string} [home]
5
+ * @returns {boolean}
6
+ */
7
+ export function carryNoteOn(home?: string): boolean;
8
+ /**
9
+ * The run's edits from the working tree against the start commit: tracked (git diff) plus untracked (no diff exists).
10
+ * Arbiter books / .git / .bareloop are excluded. Never throws; [] on any git failure.
11
+ * @param {string} workdir @param {string|null} base
12
+ * @returns {Promise<{path: string, lines: number, hunks: string[]}[]>}
13
+ */
14
+ export function workingEdits(workdir: string, base: string | null): Promise<{
15
+ path: string;
16
+ lines: number;
17
+ hunks: string[];
18
+ }[]>;
19
+ /**
20
+ * Order edits oldest to newest by when they last changed: a file's recency is the latest settled ask whose `changed`
21
+ * list names it; a file in no `changed` list is oldest. Ties keep their incoming (alphabetical) order. PURE.
22
+ * @param {{path: string}[]} edits @param {{changed?: string[]}[]} settled asks settled so far, oldest first
23
+ */
24
+ export function orderEditsByRecency(edits: {
25
+ path: string;
26
+ }[], settled: {
27
+ changed?: string[];
28
+ }[]): {
29
+ path: string;
30
+ }[];
31
+ /**
32
+ * Run-level store. Asks are sequential, so "the current ask" is one counter.
33
+ * @param {{workdir: string, emit: (type: string, rec: any) => void, strikeLimit?: number, resume?: boolean}} o
34
+ */
35
+ export function createCarryStore({ workdir, emit, strikeLimit, resume }: {
36
+ workdir: string;
37
+ emit: (type: string, rec: any) => void;
38
+ strikeLimit?: number;
39
+ resume?: boolean;
40
+ }): {
41
+ wrapTools: (tools: {
42
+ name: string;
43
+ execute: Function;
44
+ }[]) => void;
45
+ beginAsk: ({ phase, iteration, prompt }: {
46
+ phase: string;
47
+ iteration: number | string | undefined;
48
+ prompt: string;
49
+ }) => Promise<string>;
50
+ endAsk: ({ bounded, iteration, rounds }: {
51
+ bounded?: {
52
+ iteration: any;
53
+ cause: string;
54
+ } | undefined;
55
+ iteration: any;
56
+ rounds: number;
57
+ }) => void;
58
+ setBase: (b: string | null | undefined) => void;
59
+ loaded: () => boolean;
60
+ _state: () => {
61
+ n: number;
62
+ events: any[];
63
+ asks: any[];
64
+ base: string | null;
65
+ };
66
+ };
67
+ export const CARRY_DIR: "carry";
68
+ /** the next prompt of a retried step / fix try carries this when the previous ask's check failed */
69
+ export const RED_MARKER: RegExp;
package/types/config.d.ts CHANGED
@@ -36,7 +36,7 @@ export function modelsProblem(list: unknown): string | null;
36
36
  * `keys` merges per key variable name, then per field; `models.<ENV>` is REPLACED WHOLE (`null`
37
37
  * clears it). Validated before anything is written; nothing is written on a refusal.
38
38
  *
39
- * Patch fields understood: `monthlyLimitUsd` (finite > 0), `learningHints` (true | false), `keys.<ENV>.{shape,baseUrl,legacyMaxTokens}`,
39
+ * Patch fields understood: `monthlyLimitUsd` (finite > 0), `learningHints` (true | false), `carryNote` (true | false), `keys.<ENV>.{shape,baseUrl,legacyMaxTokens}`,
40
40
  * `models.<ENV>` (a list judged by {@link modelsProblem}). The first write of a row's `models` list
41
41
  * removes that row's older `name` / `priceInPerM` / `priceOutPerM` in the SAME write (never two
42
42
  * sources); a retired top-level `anthropicBalanceNote` is dropped on any write. Any other field is
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Is this repo-relative path off limits to a note: outside the job root, an arbiter book (the one list,
3
+ * `isArbiterBook`: .smoke — spine, attempt-diff, bridges — .litectx, the gate audit), or inside `.git` / `.bareloop`.
4
+ * @param {string} rel
5
+ */
6
+ export function isHandoffExcluded(rel: string): boolean;
7
+ /**
8
+ * Wrap the worker's read-class tools (the real names come from the caller: shell_read, ctx_get) so a call that
9
+ * reached `execute` (the gate already allowed it) and returned a file's text is reported to `onRead`.
10
+ * Wraps in place: tool objects are fresh per worker.
11
+ * @param {{name: string, execute: Function}[]} tools
12
+ * @param {string[]} names
13
+ * @param {(absPath: string) => void} onRead
14
+ * @param {string} workdir
15
+ */
16
+ export function trackReads(tools: {
17
+ name: string;
18
+ execute: Function;
19
+ }[], names: string[], onRead: (absPath: string) => void, workdir: string): void;
20
+ /**
21
+ * Run-level store of the paths earlier workers read. Newest read last; a re-read moves a path to newest.
22
+ * In memory only: a resumed leg starts empty (the first ask of a resumed leg gets no note, later asks do).
23
+ * @param {{workdir: string}} o
24
+ */
25
+ export function createHandoffStore({ workdir }: {
26
+ workdir: string;
27
+ }): {
28
+ absorb: (absPaths: Iterable<string>) => void;
29
+ render: ({ getNode }?: {
30
+ getNode?: (rel: string) => any;
31
+ }) => {
32
+ text: string;
33
+ paths: number;
34
+ };
35
+ size: () => number;
36
+ };
37
+ /** The one cap on a note, in characters. */
38
+ export const HANDOFF_CAP: 8000;
39
+ export const HANDOFF_HEADING: "== Files earlier workers in this run read (a map only; contents are not included; line ranges as ctx_recall prints them) ==";
package/types/plan.d.ts CHANGED
@@ -123,6 +123,10 @@ export const EXIT_TYPES: readonly string[];
123
123
  /** decision 8: AND-only conjunction, bounded — no OR (a weak arm would
124
124
  * launder the exit), no NOT */
125
125
  export const MAX_EXITS_PER_STEP: 2;
126
+ /** a legal-example sentence for the exit menu — shown in the planner prompt and
127
+ * appended to the missing-required exit red, so a redraft sees a legal shape,
128
+ * not only the rule (F254: `exit` is required on EVERY step) */
129
+ export const EXIT_EXAMPLE: "Legal exit examples: a step with 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>\"}].";
126
130
  /** plan size bound — per-step rounds bound the spend, but an unbounded step
127
131
  * COUNT is still an unbounded claim on the wallet; same 8 as loop.maxIterations */
128
132
  export const MAX_PLAN_STEPS: 8;
@@ -408,12 +408,15 @@ export function planPrompt(job: any, scoutBlob: string, reds: any[] | null, maxS
408
408
  * run start from the ledger as it stood). Handed to the PLANNER only: the first draft and the FIRST replan. No worker ever
409
409
  * receives it, and a later replan gets nothing. Each injection is recorded on the spine as a `learnings` record (the exact
410
410
  * text) so the Audit can show it and the byte check can compare it with a fresh render. `null` = no hints (the default).
411
+ * @param {boolean} [opts.carryNote=false] THE CARRY NOTE (src/carrynote.js): the step/fix worker is handed a facts-only note of what earlier
412
+ * workers of this run looked at, searched and changed, after the handoff note. The caller reads the switch once; `false` builds no store
413
+ * and leaves the worker prompt byte-identical. One `carry-note` spine record (counts only) per note handed.
411
414
  * @returns {Promise<string>} 'green' | 'already-green' | 'escalated' | 'plan-red' |
412
415
  * 'check-red' | 'close-red' | 'close-unsupported' | 'recipe-stale' | 'pricing-red' |
413
416
  * 'branch-red' | 'cap-halt' | 'wall-halt' | 'stopped' | 'provider-red' | 'interpreter-red' |
414
417
  * 'step-stalled' | 'hitl-pause' | 'hitl-decision-red' | `step-red:<id>`
415
418
  */
416
- export function runPlan(job: any, { workdir, provider, nativeProvider, providerFor, judgeProvider, judgeModel, rates, judgeRates, emit, remainingUsd, isUnpriced, spendComplete, capRuns, strikeLimit, closeTimeoutMs, closeDir, maxStepRounds, layerRoot, readShim, scout, scoutRounds, bridge, now, priorWallMs, resumeSeed, resumeGrades, resumeReplans, resumeBranch, humanRuling, heldRuling, priorSpentUsd, reviewDoor, doorRerun, resumable, stopFile, learnHints }: {
419
+ export function runPlan(job: any, { workdir, provider, nativeProvider, providerFor, judgeProvider, judgeModel, rates, judgeRates, emit, remainingUsd, isUnpriced, spendComplete, capRuns, strikeLimit, closeTimeoutMs, closeDir, maxStepRounds, layerRoot, readShim, scout, scoutRounds, bridge, now, priorWallMs, resumeSeed, resumeGrades, resumeReplans, resumeBranch, humanRuling, heldRuling, priorSpentUsd, reviewDoor, doorRerun, resumable, stopFile, learnHints, carryNote }: {
417
420
  workdir: string;
418
421
  provider: any;
419
422
  nativeProvider?: ((o: {
@@ -481,6 +484,7 @@ export function runPlan(job: any, { workdir, provider, nativeProvider, providerF
481
484
  text: string;
482
485
  ids: string[];
483
486
  } | null | undefined;
487
+ carryNote?: boolean | undefined;
484
488
  }): Promise<string>;
485
489
  export { rateSourceFields };
486
490
  /**
@@ -67,6 +67,7 @@ export function createReadShim({ cap, arm, onCount }?: {
67
67
  capped: number;
68
68
  bytesWithheld: number;
69
69
  };
70
+ reset: () => void;
70
71
  };
71
72
  /**
72
73
  * The one-tool spelling, kept for every caller written before the shim became an
package/types/replay.d.ts CHANGED
@@ -197,6 +197,7 @@ export function replayRun(spineEvents: any[], auditEvents?: any[], { runId, audi
197
197
  iteration: any;
198
198
  startSeq: any;
199
199
  endSeq: any;
200
+ rounds: number;
200
201
  startTs: number | null;
201
202
  endTs: number | null;
202
203
  } | null;
package/types/run.d.ts CHANGED
@@ -200,6 +200,9 @@
200
200
  * round-boundary seam (where the money cap binds) and ends the leg `stopped`. `null` = no stop surface.
201
201
  * @param {{text: string, ids: string[]}|null} [opts.learnHints=null] cross-run learnings for the PLANNER only (the draft and the
202
202
  * first replan); forwarded verbatim to the plan flow, which records what it handed over as a `learnings` spine record.
203
+ * @param {boolean} [opts.carryNote=false] THE CARRY NOTE (src/carrynote.js): hand each step/fix worker a facts-only note of what earlier
204
+ * workers of this run looked at, searched and changed. The caller reads the one switch (`carryNote` in config.json, src/carrystore.js
205
+ * `carryNoteOn`) once; the library default is off, exactly like `learnHints`. Forwarded verbatim to the plan flow.
203
206
  * @returns {Promise<string>} outcome: 'green' | 'already-green' | 'escalated' |
204
207
  * 'unapproved-spec' | 'job-red' | 'smoke-red' | 'plan-red' | 'check-red' |
205
208
  * 'close-red' | 'close-unsupported' | 'recipe-stale' | 'branch-red' | 'pricing-red' | 'provider-red' |
@@ -214,7 +217,7 @@
214
217
  * deliberately NOT in the resumable/checkpoint set (`src/reuse.js`) — an
215
218
  * unknown in-flight state is not a known-safe resume point.
216
219
  */
217
- export function runJob(rawSpec: object | string, { approvals, workdir, provider, nativeProvider, providerFor, judgeProvider, judgeModel, rates, judgeRates, emit, capRuns, strikeLimit, shellCapUsd, closeTimeoutMs, closeDir, layerRoot, readShim, scout, bridge, draftSpentUsd, draftSpendComplete, priorSpentUsd, priorSpendComplete, priorWallMs, resumeSeed, resumeGrades, resumeReplans, resumeBranch, humanRuling, heldRuling, reviewDoor, doorRerun, resumable, stopFile, learnHints }: {
220
+ export function runJob(rawSpec: object | string, { approvals, workdir, provider, nativeProvider, providerFor, judgeProvider, judgeModel, rates, judgeRates, emit, capRuns, strikeLimit, shellCapUsd, closeTimeoutMs, closeDir, layerRoot, readShim, scout, bridge, draftSpentUsd, draftSpendComplete, priorSpentUsd, priorSpendComplete, priorWallMs, resumeSeed, resumeGrades, resumeReplans, resumeBranch, humanRuling, heldRuling, reviewDoor, doorRerun, resumable, stopFile, learnHints, carryNote }: {
218
221
  approvals: unknown;
219
222
  workdir: string;
220
223
  provider: any;
@@ -281,6 +284,7 @@ export function runJob(rawSpec: object | string, { approvals, workdir, provider,
281
284
  text: string;
282
285
  ids: string[];
283
286
  } | null | undefined;
287
+ carryNote?: boolean | undefined;
284
288
  }): Promise<string>;
285
289
  /** @typedef {{code: string, path: string, detail?: string}} Red */
286
290
  /**
@@ -26,8 +26,13 @@ export function cmdKey(params: any): string | null;
26
26
  * - `pattern-absent-in-diff` is always the `no-suppressions` guard: "no
27
27
  * casts or silencers added?"
28
28
  * - `rubric-step` (Part 1a) is one job line's output file: "line N — does its output pass the line's checks?"
29
- * - `command-exit` is the genre's `suite-green` stage (the only shipped use
30
- * of this kind): "does the test suite pass?"
29
+ * - `command-exit` quotes its OWN signed command verbatim:
30
+ * `does "<cmd> <args joined by space>" exit clean?` (e.g. `does "npm test"
31
+ * exit clean?`, `does "npx tsc --noEmit --strict" exit clean?`). It used
32
+ * to read "does the test suite pass?" for every command, so F256's run
33
+ * mvtatlxw showed two different commands (the real suite and a whole-repo
34
+ * `tsc --strict`) reading the same question. A missing or non-string
35
+ * `cmd` returns `null` (the caller falls back to the stage name).
31
36
  * - `count-not-worse` splits three ways on its own declared
32
37
  * `direction`/`baseline` (never the runtime number — see
33
38
  * {@link stageKindMetaFromSpec}'s own doc for why the baseline KIND must
package/types/tools.d.ts CHANGED
@@ -269,6 +269,14 @@ export function toolAction(name: string, args: any, workdir?: string): {
269
269
  args: any;
270
270
  path?: undefined;
271
271
  };
272
+ export function gatedShellOptions(gate: {
273
+ allows: (action: any) => Promise<boolean>;
274
+ }, workdir: string): {
275
+ noFollowSymlinks: boolean;
276
+ canRead: (p: string, { tool }: {
277
+ tool: string;
278
+ }) => Promise<boolean>;
279
+ };
272
280
  /**
273
281
  * litectx recall hit — body present only with `{body: true}`
274
282
  */