bareloop 0.52.0 → 0.54.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 +45 -0
- package/bareloop.context.md +29 -16
- 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/carrynote.js +38 -12
- package/src/carrystore.js +78 -31
- package/src/config.js +3 -5
- package/src/declaredclose.js +1 -1
- package/src/job.js +16 -4
- package/src/kinds.js +4 -2
- package/src/pagedropwords.js +5 -2
- package/src/panel/handed.js +92 -0
- package/src/panel/index.html +225 -120
- package/src/panel/jobplan.js +6 -1
- package/src/panel/schedules.js +2 -2
- package/src/panel/server.js +25 -8
- package/src/plan.js +38 -1
- package/src/planrun.js +245 -80
- package/src/ralph.js +2 -0
- package/src/readshim.js +98 -3
- package/src/run.js +2 -5
- package/src/seednote.js +28 -0
- package/src/tools.js +65 -6
- package/src/userrun.js +0 -3
- package/types/authorflow.d.ts +54 -1
- package/types/carrynote.d.ts +19 -2
- package/types/carrystore.d.ts +5 -9
- package/types/config.d.ts +2 -2
- 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 +47 -7
- package/types/readshim.d.ts +54 -18
- package/types/run.d.ts +1 -5
- package/types/seednote.d.ts +18 -0
- package/types/tools.d.ts +25 -3
- package/src/handoff.js +0 -100
- package/types/handoff.d.ts +0 -39
package/src/panel/jobplan.js
CHANGED
|
@@ -15,7 +15,7 @@ import { splitReadNotes } from '../pagedropwords.js';
|
|
|
15
15
|
import { checksOfClose, signedFactNames, proseNotChecked, lineRules, confirmedGoalOf } from '../rubricstep.js';
|
|
16
16
|
|
|
17
17
|
/** @typedef {{name: string, cls: 'machine check'|'judge'|null}} PlanCheck */
|
|
18
|
-
/** @typedef {{n: number, text: string, rule: string, rules: string[], checks: PlanCheck[], refused: string[]}} PlanLine */
|
|
18
|
+
/** @typedef {{n: number, text: string, rule: string, rules: string[], checks: PlanCheck[], refused: string[], always?: string[]}} PlanLine */
|
|
19
19
|
/** @typedef {{lines: PlanLine[], loose: PlanCheck[], notChecked: string[], readNotes: string[], alwaysOn: string[], older: boolean, goal?: string}} JobPlan */
|
|
20
20
|
|
|
21
21
|
/**
|
|
@@ -95,6 +95,11 @@ export function planFromSpec(spec) {
|
|
|
95
95
|
for (const line of served) line.checks.push({ name: s.name, cls: s.cls });
|
|
96
96
|
if (served.length === 0) loose.push({ name: s.name, cls: s.cls });
|
|
97
97
|
}
|
|
98
|
+
// an always-on guard that the drafter said covers a job line is shown under that line too ("› check · always-on: <guard>")
|
|
99
|
+
for (const g of Array.isArray(spec?.closeDecl?.guardLines) ? spec.closeDecl.guardLines : []) {
|
|
100
|
+
if (!g || typeof g.guard !== 'string' || !Array.isArray(g.lines)) continue;
|
|
101
|
+
for (const line of lines.filter((l) => g.lines.includes(l.n))) (line.always ??= []).push(g.guard);
|
|
102
|
+
}
|
|
98
103
|
const refused = Array.isArray(spec?.closeDecl?.refused) ? spec.closeDecl.refused : [];
|
|
99
104
|
for (const r of refused) {
|
|
100
105
|
const line = lines.find((l) => l.n === r?.line);
|
package/src/panel/schedules.js
CHANGED
|
@@ -260,7 +260,7 @@ export function createScheduleDoor(deps) {
|
|
|
260
260
|
if (workflowKey(spec) !== green.key) return reply(400, { refused: 'bad-spec', say: 'The job this would sign is not the one that had the good run. Nothing was changed.' });
|
|
261
261
|
let monthlyNote = null;
|
|
262
262
|
try {
|
|
263
|
-
const room = checkMonthlyRoom({ capUsd: spec.budgetUsd, home: deps.home, sessionsRoot: deps.sessionsRoot });
|
|
263
|
+
const room = checkMonthlyRoom({ capUsd: spec.budgetUsd, home: deps.home, sessionsRoot: deps.sessionsRoot, now });
|
|
264
264
|
const refusal = monthlyRefusalText(room);
|
|
265
265
|
if (refusal) monthlyNote = `${refusal}. Each run is checked against the monthly limit when it starts.`;
|
|
266
266
|
} catch (e) {
|
|
@@ -421,7 +421,7 @@ export function createScheduleDoor(deps) {
|
|
|
421
421
|
if (paused(job)) return { outcome: 'refused', why: 'This schedule gave up and is waiting for you. Nothing started.', told: false };
|
|
422
422
|
if (hooks.busy ?? busy(job)) return told('busy', 'A run of this job is still going. This one starts when it is done.');
|
|
423
423
|
try {
|
|
424
|
-
const room = checkMonthlyRoom({ capUsd: schedule.spec.budgetUsd, home: deps.home, sessionsRoot: deps.sessionsRoot });
|
|
424
|
+
const room = checkMonthlyRoom({ capUsd: schedule.spec.budgetUsd, home: deps.home, sessionsRoot: deps.sessionsRoot, now });
|
|
425
425
|
if (!room.ok) {
|
|
426
426
|
return told('monthly-exhausted', 'Not enough money left this month for this run.', { leftUsd: room.leftUsd, needUsd: schedule.spec.budgetUsd, atLeast: room.atLeast === true });
|
|
427
427
|
}
|
package/src/panel/server.js
CHANGED
|
@@ -49,7 +49,7 @@ import { chainSpend } from '../ledger.js';
|
|
|
49
49
|
import { runBehaviour } from '../behaviour.js';
|
|
50
50
|
import { SPEND_RECORD_TYPES, floorsFromRecords } from '../ledger.js';
|
|
51
51
|
import { jobSpecHash, workflowKey } from '../job.js';
|
|
52
|
-
import {
|
|
52
|
+
import { attachMemos, learningsHanded, attachLearnings } from './handed.js';
|
|
53
53
|
import { confirmProtections } from '../authorflow.js';
|
|
54
54
|
import { createScheduleDoor } from './schedules.js';
|
|
55
55
|
import { createStarter } from './schedulestart.js';
|
|
@@ -551,6 +551,22 @@ function endedBase(summary, death, o) {
|
|
|
551
551
|
const esc = summary.lastEscalation;
|
|
552
552
|
const cat = typeof esc?.category === 'string' ? esc.category : null;
|
|
553
553
|
|
|
554
|
+
// F265: a stuck loop of refused tool arguments (bare-agent `checkArgs`): the engine recorded the fault in structured fields
|
|
555
|
+
// (`badCall`), so the sentence names what the model did instead of the raw code
|
|
556
|
+
const refused = esc?.badCall;
|
|
557
|
+
if (refused && typeof refused === 'object' && typeof refused.param === 'string' && (outcome === 'interpreter-red' || outcome === 'escalated')) {
|
|
558
|
+
const what = `${refused.param} of ${refused.tool ?? 'a tool'}`;
|
|
559
|
+
const how = refused.kind === 'arg-missing'
|
|
560
|
+
? `leaving out the ${what}`
|
|
561
|
+
: `sending the ${what} as ${refused.got === 'object' || refused.got === 'array' ? `a JSON ${refused.got}` : `a ${refused.got ?? 'wrong type'}`}${refused.expected ? ` instead of ${/^[aeiou]/.test(refused.expected) ? 'an' : 'a'} ${refused.expected}` : ''}`;
|
|
562
|
+
return {
|
|
563
|
+
reason: `The model kept ${how}, and the tool refused it every time, so the step stopped.`,
|
|
564
|
+
next: CHANGE,
|
|
565
|
+
line: 'tool call refused',
|
|
566
|
+
actions: [],
|
|
567
|
+
};
|
|
568
|
+
}
|
|
569
|
+
|
|
554
570
|
// `escalated` is a TERMINAL: its sentence may name the real governor, but it is never
|
|
555
571
|
// resumable. Two governors, never mixed (F198): the STRIKE ladder (the fix loop stopped
|
|
556
572
|
// improving) also files category `cap-halt` — it is the MONEY cap only when the spine
|
|
@@ -1630,7 +1646,12 @@ function getRunDetailBody(runid, opts) {
|
|
|
1630
1646
|
const draftingPartHere = draftingFor(row, summary, opts);
|
|
1631
1647
|
const draftingShiftHere = draftingShift(row, summary, opts);
|
|
1632
1648
|
const specForParts = resolveSpecForRow(row);
|
|
1633
|
-
|
|
1649
|
+
// the memory and the learnings each part was handed, placed where they were passed on (src/panel/handed.js)
|
|
1650
|
+
const handed = attachLearnings(
|
|
1651
|
+
attachMemos(enrichPartsWithStageKind(summary.parts, stageKindMetaFromSpec(specForParts), specForParts), rawSpineRecords),
|
|
1652
|
+
draftingPartHere, learningsHanded(rawSpineRecords),
|
|
1653
|
+
);
|
|
1654
|
+
const enrichedParts = handed.parts;
|
|
1634
1655
|
const death = deriveDeath(row, rawSpineRecords, summary.outcome);
|
|
1635
1656
|
const runName = runNameOf(row.job, runNumbers(readRunList(opts).rows).get(row.runid));
|
|
1636
1657
|
// the export row only for a run export would take — the one rule, `checkExportable`, never a copy of it
|
|
@@ -1860,7 +1881,7 @@ function getRunDetailBody(runid, opts) {
|
|
|
1860
1881
|
// tabs still never disagree about order/counts/blocked-call figures.
|
|
1861
1882
|
// a run that DIED (no job-end, runner gone — `death`, decided once above) leaves its last part in flight: that part reads
|
|
1862
1883
|
// `died`, never the "happened, so passed" default. Replay alone cannot tell died from still running, so the verdict lives here.
|
|
1863
|
-
parts: (
|
|
1884
|
+
parts: (handed.drafting && Array.isArray(enrichedParts) ? [handed.drafting, ...enrichedParts] : enrichedParts)?.map((p, i, all) => ({ ...(death.died && i === all.length - 1 ? diedFixTry(p) : p), status: partStatusFor(death.died && i === all.length - 1 && p.kind !== 'drafting' && p.outcome == null && !p.stopReason ? { ...p, stopReason: 'died' } : p) })),
|
|
1864
1885
|
replans: summary.replans,
|
|
1865
1886
|
close: summary.close,
|
|
1866
1887
|
branch: summary.branch,
|
|
@@ -1886,11 +1907,7 @@ function getRunDetailBody(runid, opts) {
|
|
|
1886
1907
|
// carries no contamination risk); `null` when the spine carries no
|
|
1887
1908
|
// `memory-cache` record at all (never armed on this run).
|
|
1888
1909
|
behaviour: scopedBehaviour(row, rawSpineRecords),
|
|
1889
|
-
// Cross-run learnings
|
|
1890
|
-
// injection (the draft, and the first replan); `hints` = the same text split into fields by learn.js's parseHintBlock (the one reader). Empty when the setting was off or nothing was readable.
|
|
1891
|
-
learnings: rawSpineRecords.filter((e) => e?.type === 'learnings' && typeof e.text === 'string').map((e) => ({ phase: String(e.phase), text: e.text, chars: e.text.length, ids: Array.isArray(e.ids) ? e.ids : [], hints: parseHintBlock(e.text) })),
|
|
1892
|
-
// a learnings file that could not be read: the plain line (null when it could)
|
|
1893
|
-
learningsError: ((r) => (r ? hintsErrorLine(String(r.hintsError)) : null))(rawSpineRecords.find((e) => e?.type === 'learnings' && typeof e.hintsError === 'string')),
|
|
1910
|
+
// Cross-run learnings now ride on the part that received them (`part.learnings`, `part.learningsError`; src/panel/handed.js).
|
|
1894
1911
|
// PRD v1.106 Part 5 F: the two Run summary rows, worded here (the page prints them)
|
|
1895
1912
|
callsLine: callsLineOf(rawSpineRecords, scopedBehaviour(row, rawSpineRecords)),
|
|
1896
1913
|
checksLine: checksLineOf(rawSpineRecords, enrichedParts),
|
package/src/plan.js
CHANGED
|
@@ -39,7 +39,7 @@ export const MAX_EXITS_PER_STEP = 2;
|
|
|
39
39
|
/** a legal-example sentence for the exit menu — shown in the planner prompt and
|
|
40
40
|
* appended to the missing-required exit red, so a redraft sees a legal shape,
|
|
41
41
|
* not only the rule (F254: `exit` is required on EVERY step) */
|
|
42
|
-
export const EXIT_EXAMPLE = 'Legal exit examples: a step
|
|
42
|
+
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>"}].';
|
|
43
43
|
/** plan size bound — per-step rounds bound the spend, but an unbounded step
|
|
44
44
|
* COUNT is still an unbounded claim on the wallet; same 8 as loop.maxIterations */
|
|
45
45
|
export const MAX_PLAN_STEPS = 8;
|
|
@@ -644,3 +644,40 @@ function validateExit(s, at, red, { checkNames, fence, insideFence, writeStep, t
|
|
|
644
644
|
red('exit-illegal', `${at}.exit`, `check-passes on a step with no write-class tool (${WRITE_VERBS.join('|')}) — the check's failure gap comes back to this step's own worker, which cannot edit; attach the check to the step that fixes (the operator's close already verifies the finished run)`);
|
|
645
645
|
}
|
|
646
646
|
}
|
|
647
|
+
|
|
648
|
+
/**
|
|
649
|
+
* F271 (B2) — pair a `write` grant with `edit`. A look-around step the drafter gave `write` but not `edit`, whose exits force a
|
|
650
|
+
* 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
|
|
651
|
+
* verb; the agent never asks for it, and it is added only when the SIGNED ceiling (`job.tools`, absent = the full menu) already
|
|
652
|
+
* offers `edit`, so the agent still cannot widen its own menu. `edit` is judged by the same `writeScope` fence as `write`: no
|
|
653
|
+
* authority a whole-file write did not have. No signed hash covers a plan, so none moves.
|
|
654
|
+
*
|
|
655
|
+
* A rubric step-file step is exempt: every path it declares (`target` plus the `artifact-written`/`json-valid` paths) lies under
|
|
656
|
+
* `newFileDir` (`output/steps`, the engine-owned always-new-file directory), so there is nothing to edit.
|
|
657
|
+
*
|
|
658
|
+
* Pure: never mutates `plan`; returns the SAME reference when nothing changes. `validatePlan` is untouched — the runner applies this
|
|
659
|
+
* to the validated plan, so `plan-accepted` records the plan as executed.
|
|
660
|
+
* @param {any} plan a validated plan (`validatePlan(...).plan`)
|
|
661
|
+
* @param {any} job the validateJob-green plan shape spec (its `tools` is the signed ceiling)
|
|
662
|
+
* @param {string|null} [newFileDir] the always-new-file directory whose steps are exempt, or null for none
|
|
663
|
+
* @returns {any} the plan with `edit` appended to each write-without-edit step, or `plan` itself
|
|
664
|
+
*/
|
|
665
|
+
export function pairEditGrant(plan, job, newFileDir = null) {
|
|
666
|
+
if (!isObj(plan) || !Array.isArray(plan.steps)) return plan;
|
|
667
|
+
const ceiling = isObj(job) && Array.isArray(job.tools) ? job.tools : [...TOOL_MENU];
|
|
668
|
+
if (!ceiling.includes('edit')) return plan;
|
|
669
|
+
const dir = typeof newFileDir === 'string' && newFileDir.length > 0 ? `${newFileDir.replace(/\/+$/, '')}/` : null;
|
|
670
|
+
const inNewDir = (/** @type {any} */ s) => {
|
|
671
|
+
if (dir === null) return false;
|
|
672
|
+
const paths = [s.target, ...(Array.isArray(s.exit) ? s.exit : []).filter((/** @type {any} */ e) => e && (e.type === 'artifact-written' || e.type === 'json-valid')).map((/** @type {any} */ e) => e.path)]
|
|
673
|
+
.filter((/** @type {any} */ x) => typeof x === 'string' && x.length > 0);
|
|
674
|
+
return paths.length > 0 && paths.every((/** @type {string} */ x) => x.startsWith(dir));
|
|
675
|
+
};
|
|
676
|
+
let changed = false;
|
|
677
|
+
const steps = plan.steps.map((/** @type {any} */ s) => {
|
|
678
|
+
if (!isObj(s) || !Array.isArray(s.tools) || !s.tools.includes('write') || s.tools.includes('edit') || inNewDir(s)) return s;
|
|
679
|
+
changed = true;
|
|
680
|
+
return { ...s, tools: [...s.tools, 'edit'] };
|
|
681
|
+
});
|
|
682
|
+
return changed ? { ...plan, steps } : plan;
|
|
683
|
+
}
|