bareloop 0.34.0 → 0.35.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 +31 -0
- package/bareloop.context.md +241 -13
- package/package.json +1 -1
- package/src/bundlerun.js +13 -4
- package/src/draftspend.js +82 -0
- package/src/exits.js +10 -1
- package/src/interviewrun.js +7 -7
- package/src/job.js +37 -0
- package/src/judged.js +2 -2
- package/src/kinds.js +2 -1
- package/src/ledger.js +101 -5
- package/src/legs.js +171 -0
- package/src/monthly.js +111 -72
- package/src/panel/authorroutes.js +84 -14
- package/src/panel/authorsession.js +408 -113
- package/src/panel/importroutes.js +359 -0
- package/src/panel/importrun.js +203 -0
- package/src/panel/index.html +1071 -184
- package/src/panel/runroutes.js +219 -0
- package/src/panel/server.js +839 -70
- package/src/panel/status.js +51 -0
- package/src/planrun.js +60 -26
- package/src/providerrows.js +17 -0
- package/src/ralph.js +3 -0
- package/src/replay.js +139 -19
- package/src/replayio.js +11 -4
- package/src/reuse.js +20 -3
- package/src/run.js +6 -3
- package/src/runlist.js +75 -7
- package/src/text.js +20 -0
- package/src/u-readout.js +9 -1
- package/src/u-watchdog.mjs +4 -2
- package/src/userrun.js +138 -57
- package/types/draftspend.d.ts +53 -0
- package/types/job.d.ts +25 -0
- package/types/ledger.d.ts +44 -0
- package/types/legs.d.ts +103 -0
- package/types/monthly.d.ts +23 -18
- package/types/panel/authorroutes.d.ts +23 -1
- package/types/panel/authorsession.d.ts +109 -2
- package/types/panel/importroutes.d.ts +129 -0
- package/types/panel/importrun.d.ts +77 -0
- package/types/panel/runroutes.d.ts +32 -0
- package/types/panel/server.d.ts +255 -2
- package/types/panel/status.d.ts +51 -0
- package/types/planrun.d.ts +13 -21
- package/types/providerrows.d.ts +12 -0
- package/types/replay.d.ts +25 -1
- package/types/replayio.d.ts +2 -2
- package/types/reuse.d.ts +5 -0
- package/types/run.d.ts +6 -2
- package/types/runlist.d.ts +52 -2
- package/types/text.d.ts +19 -0
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,37 @@ All notable changes to bareloop are documented here. Format:
|
|
|
5
5
|
[SemVer](https://semver.org/spec/v2.0.0.html). Pre-1.0: **minor** = a ladder rung or
|
|
6
6
|
feature lands, **patch** = docs, fixes, scaffolding.
|
|
7
7
|
|
|
8
|
+
## [0.35.0] - 2026-10-05
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- **One run = one id (resume).** A resume now continues the SAME run: one runid, one spine file, a `leg-resume` marker opens each new leg (`legsOf` is the one owner of leg boundaries). Outcome is the last leg's, money is each leg's own spend summed once, wall is the sum of leg windows with the gap between legs excluded. The run list keeps one row; the panel shows one card (`resumed xN`), an Audit leg divider, and a dotted map connector. Resume readers (`readResume`, pause age gate, `deathAtOf`) read the latest leg.
|
|
13
|
+
- **Panel Stop.** `POST /api/runs/:runid/stop` writes a stop request that is read at the round boundary where the money cap binds (not between steps), so a one-step run can be stopped. The leg ends as the resumable outcome `stopped` (`stopped` joins the checkpoint outcomes); resume re-enters the cut step. The page says "stopping after this turn...".
|
|
14
|
+
- **Panel Resume.** `POST /api/runs/:runid/resume`, a Resume mode on the run's Job tab where only the money and time caps are inputs ("Money cap ($)", "Time cap (min)", Sign & resume). Changed caps write `resolved-spec-r<k>.json` beside the original. A cap at or below what is already spent or used is refused at $0.
|
|
15
|
+
- **Ended block.** Every finished run carries one code-owned reason / next line (`ended` on the run detail, `endedLine` on the run list), shown on the Audit tab and under the job name on the card. Resume is listed only when the engine would accept it; a strike-governor cap-halt is no longer read as the money cap.
|
|
16
|
+
- **Reuse workflow.** Green runs (and imported jobs) offer [Reuse workflow] in the Run tab's top action row: the origin's signed spec is copied and only five boxes are open (Source, Destination, money cap, time cap, Model; the server refuses any other change). `workflowKey(spec)` identifies "the same job" (signed spec without source, destination, budget, wall, provider/model; `jobSpecHash` untouched). The estimate line reads "Same job - G green - N not green - about $X and M min a run", with unknown said, never rendered as $0. Red rows say "Change the job: + New."
|
|
17
|
+
- **Read-only Import.** A guarded folder browser (`GET /api/fs/list`, folders only, no symlinks, depth-3 search for job bundles, remembers the last folder), `POST /api/imports`, `GET /api/imports[/:id]`, rows in `<home>/imports.jsonl`, re-read on every view ("changed since import", "folder not found"). An imported job opens in the normal Run / Audit / Job tabs: an IMPORTED box, then the SUMMARY and MAP of its latest green run (from the bundle's spine, else its bridge, else "no green run in this bundle"). Reuse re-verifies the bundle and every close stage's signed bytes at the moment of reuse; the person signs it here. Re-importing a folder updates its one row.
|
|
18
|
+
- **Runs list.** Runs/workflows first, imported jobs below; one code-owned status table (sign to word) read by run cards, expanded rows, the header, imported rows and MAP step cards; step names as written; Audit step rows wear the Run tab's sign and word.
|
|
19
|
+
- **Monthly claims.** Settled per leg: a resumed run stays one listed row and only the leg's claim is released.
|
|
20
|
+
- **Chat panel rework.** One chronological progress list (every pipeline step is one line that updates in place; a resumed step appends a new line; detail on its own line; one drafting line carrying model and cap), sitting under the thread above the ask box and auto-scrolling when it changes while live. One wide main button whose wording follows the moment (Start drafting / Sign & run / Check again / Send / Sign & run). The Chat tab always opens on an empty job card with Clear (or Abandon while a session is live and unsigned) on the card; `+ New` is gone. Ask box is a wrapping textarea (Enter sends, Shift+Enter is a newline) dimmed until there is something to reply to; job-card free-text boxes wrap and auto-grow; focused field gets the accent border. The card is fully locked while a drafting session is live.
|
|
21
|
+
- **`POST /api/author/:id/abandon`** ends a live authoring session: terminal phase `abandoned`, releases the one-at-a-time lock, keeps booked drafting spend, books an in-flight call's usage, starts no new model call.
|
|
22
|
+
- **`GET /api/author/live`**: a refreshed Chat page re-attaches to the one live authoring session (reuse included), card refilled from the session's own copy.
|
|
23
|
+
- **Run summary** counts steps, not parts (a stopped-then-continued step is one step); a halted step's time stops at its leg's end.
|
|
24
|
+
|
|
25
|
+
### Fixed
|
|
26
|
+
|
|
27
|
+
- **F122 2A (b):** a step worker round cut at `max_tokens` (`truncated:max_tokens`) is now a failed attempt on the strike ladder, not provider-red; the same holds for the close-fix loop (the cut round is discarded, its spend stays booked, the next fix prompt carries a cut-off note). Scout, drafter and replan keep provider-red.
|
|
28
|
+
- **F212:** a single-file `writeScope` is now seen by the tree snapshot, so `tree-changed` no longer reads 0 files changed when the worker edited that file.
|
|
29
|
+
- **F213:** drafting spend of an authoring session that never became a run is booked (`draft-spend.json` written after every metered call, counted by the monthly and Money readers, attributed by start time).
|
|
30
|
+
- Authoring refusals at $0: a repo source's absolute Destination is refused before any model call (one rule for the fresh and Reuse card; a repo Destination is the write fence); the non-repo refusal names what the door found (single file / plain folder / other); the reuse refusal names the provider in plain words.
|
|
31
|
+
- A dead panel token (server restarted) shows one reload line and stops the Chat poll; a session's refusal is recorded once, in the progress line only.
|
|
32
|
+
- Panel: a live run headline no longer reads `undefined` for wall time; a run with no spine yet reads "starting..."; live cards carry the same money/time floors as the right pane; Ended reasons are plain words with no raw engine detail; the IMPORTED box names the run behind each exported-history price; Providers keys-file path is never a hardcoded guess.
|
|
33
|
+
|
|
34
|
+
### Changed
|
|
35
|
+
|
|
36
|
+
- Tests that spawn a real runner take HOME and keys from a scratch dir (`cleanEnv()`), and pause/checkpoint fixtures are relative to today (the 60-day pause TTL expired a literal 2026-08-04 date). Test-only.
|
|
37
|
+
- Small refactors: one spelling of the panel bind address in the Host and Origin guards; judge-round `rateSource` uses the one `rateSourceFields` helper; `monthly.js` header describes the held-money refusal form.
|
|
38
|
+
|
|
8
39
|
## [0.34.0] - 2026-10-01
|
|
9
40
|
|
|
10
41
|
### Fixed
|
package/bareloop.context.md
CHANGED
|
@@ -1112,7 +1112,9 @@ from ralph's shipped `runClose` because one runs a DECLARATION and the other an
|
|
|
1112
1112
|
|
|
1113
1113
|
The shell's own fixed code for the closed exit menu — nothing here executes
|
|
1114
1114
|
agent-authored text. `snapshotScope` hashes every file under a scope prefix (the
|
|
1115
|
-
"before" side of `tree-changed`; a missing dir snapshots empty
|
|
1115
|
+
"before" side of `tree-changed`; a missing dir snapshots empty; a scope whose prefix names a single
|
|
1116
|
+
regular FILE — a file-valued `writeScope` becomes `src/x.js/**` — snapshots that one file, keyed by the
|
|
1117
|
+
prefix, F212: a readdir on a file used to read as an empty tree forever). `evalExits` is AND-only
|
|
1116
1118
|
and never short-circuits — the result names EVERY failing wall (`{ pass, results }`,
|
|
1117
1119
|
each result `{ type, pass, detail?, fault? }`). `tree-changed` reads OUTCOME (bytes vs
|
|
1118
1120
|
the snapshot): an identical re-write is NOT a change (F43) and git status is never
|
|
@@ -1229,7 +1231,7 @@ known-answer round-trip before tokens: `smoke-red` — a silent degradation thro
|
|
|
1229
1231
|
|
|
1230
1232
|
Outcomes: `green | already-green | escalated | unapproved-spec | job-red | smoke-red |
|
|
1231
1233
|
plan-red | check-red | close-red | close-unsupported | recipe-stale | branch-red | pricing-red |
|
|
1232
|
-
provider-red | interpreter-red | cap-halt | wall-halt | step-stalled |
|
|
1234
|
+
provider-red | interpreter-red | cap-halt | wall-halt | stopped | step-stalled |
|
|
1233
1235
|
step-red:<id> | runner-drained`.
|
|
1234
1236
|
|
|
1235
1237
|
**`runner-drained` (F140/PRD item 28(c))** is a distinct class from every outcome above: it is
|
|
@@ -1380,9 +1382,13 @@ ambiguity, not a merge. `resolveHumanRuling(fresh, held)` is the exported seam t
|
|
|
1380
1382
|
`branch-red` is the WORK BRANCH refusing (below): the patient is not a git checkout, its
|
|
1381
1383
|
branch namespace has no free name, or a resume's recorded branch is gone. Zero tokens, and
|
|
1382
1384
|
never a fallback to working on the branch the run was handed. `provider-red` is a
|
|
1383
|
-
transport throw or a
|
|
1384
|
-
BA-6 — before which it laundered into a clean finish, F25): no
|
|
1385
|
-
round's spend is only partly known (F6).
|
|
1385
|
+
transport throw, or a scout/drafter/replan round the API cut off mid-generation
|
|
1386
|
+
(`truncated:max_tokens`, BA-6 — before which it laundered into a clean finish, F25): no
|
|
1387
|
+
verdict exists and the failed round's spend is only partly known (F6). A STEP or FIX-loop
|
|
1388
|
+
worker round cut at `max_tokens` is NOT provider-red (F122 "2A" half b, hamr 2026-10-05, fix
|
|
1389
|
+
phase added by ruling A): it is a failed attempt — the round is booked, its output discarded,
|
|
1390
|
+
an `attempt-bounded` record carries the reason `output cut at the token limit (max_tokens)`,
|
|
1391
|
+
and the step's strike ladder (or the fix governor) applies as for any failed attempt. `cap-halt` is the wallet; `wall-halt` is the clock
|
|
1386
1392
|
(F64 — a timeout derived from the run's own deadline is a governance stop, never a transport
|
|
1387
1393
|
casualty). **`cap-halt` reaches you from the close-fix loop too, not only from a step:** the
|
|
1388
1394
|
shell spells exhaustion (strikes on a step, and — since v1.46 — strikes in the fix loop as
|
|
@@ -2320,6 +2326,47 @@ watchdog `--wall-ms 0`, which it defaulted to `null` and armed no deadline at al
|
|
|
2320
2326
|
still advertising one. The refusal names the lever: raise `maxWallMs`, which moves the spec hash
|
|
2321
2327
|
and is re-signed.
|
|
2322
2328
|
|
|
2329
|
+
**A resume is the SAME run — one runid, one spine file, a `leg-resume` marker inside (P5-R, hamr
|
|
2330
|
+
2026-10-02: "one run, one id, one file").** `bareloop run-u --resume <runid|path>` and `bareloop run
|
|
2331
|
+
<bundle> --resume <runid>` never mint a new id and never open a second file: the new leg APPENDS to the
|
|
2332
|
+
halted run's own spine (`u-<runid>.jsonl`, or `<bundleDir>/runs/<runid>/spine.jsonl`).
|
|
2333
|
+
- **The leg's first record is `leg-resume {leg: N, after, at}`** — `after` is how the previous leg ended
|
|
2334
|
+
(its `job-end` outcome, `'died'` when it recorded none) — written BEFORE the outside watchdog spawns (the
|
|
2335
|
+
watchdog judges a run dead by its file going quiet). `seq` continues from the file's own highest
|
|
2336
|
+
(`makeSpine(file, {startSeq})`). Then the leg's own `job-start`, which keeps the declared fold
|
|
2337
|
+
(`priorSpentUsd`/`priorWallMs`/…): the budget ceiling still folds prior spend.
|
|
2338
|
+
- **A torn tail is never edited.** If the file does not end in `\n` (a kill mid-append), the resume writes
|
|
2339
|
+
ONE `\n` and starts a fresh line: the torn bytes stay exactly as they were, alone on their own line
|
|
2340
|
+
directly before the marker. The spine is append-only forever.
|
|
2341
|
+
- **`legsOf(events)` (`src/legs.js`, internal — not exported from the package root) is the ONE owner of where
|
|
2342
|
+
a leg starts and ends**, returning `{leg, start, end, records, jobStart, jobEnd, outcome, after, startMs,
|
|
2343
|
+
endMs}`; a spine with no marker (every run written before P5-R, and every run nobody resumed) is ONE leg.
|
|
2344
|
+
`parseSpineText` tolerates exactly one torn line directly before a marker (and the file's own last two
|
|
2345
|
+
lines); any other unparseable line is a corrupt log. Every reader goes through it: the resume reader
|
|
2346
|
+
(`readResume` windows a direct spine at the latest leg that reached a `job-start`; `checkpointAgeGate` and
|
|
2347
|
+
`deathAtOf` look only at the latest leg's terminal), `replayRun`, the monthly limit, the run list, the
|
|
2348
|
+
panel, the end-of-run readout (this leg only), `bundlerun`'s history.
|
|
2349
|
+
- **Money has ONE basis per reader: the sum of each leg's own rounds** (`SPEND_RECORD_TYPES`, echoes
|
|
2350
|
+
excluded; `legSpend`/`runSpend`/`chainSpend` in `src/ledger.js`) — never the rounds plus a declared prior,
|
|
2351
|
+
so leg 1 is counted once. **Time is the sum of each leg's own window, the gap between legs excluded**
|
|
2352
|
+
(only working time charges the wall). **The outcome is the LAST leg's.** A run is live iff its last leg has
|
|
2353
|
+
no `job-end` and its runner is alive. An unknown figure reads as unknown / "at least", never as less.
|
|
2354
|
+
- **Side files are per leg.** The gate audit: leg 2+ APPENDS to `u-<runid>-gate-audit.jsonl` (never a
|
|
2355
|
+
rename-overwrite). The watchdog's kill note: `<spine>.leg<N>.watchdog.json` for N ≥ 2 (`u-watchdog.mjs
|
|
2356
|
+
--report <path>`; leg 1 keeps `<spine>.watchdog.json`). `.lag.jsonl` accumulates.
|
|
2357
|
+
- **The run list keeps ONE row per run.** A resume appends `{type:'leg-start', runid, leg, pid, capUsd, at}`;
|
|
2358
|
+
`readRunList` folds it: the row's live `pid`/`capUsd` are the latest leg's, and it carries `leg`. `settled`
|
|
2359
|
+
and `released` entries carry an optional `leg` (absent = leg 1): a later leg's `released` gives back THAT
|
|
2360
|
+
leg's claim and never removes the run, and the monthly hold is taken per leg (`claimRun({leg})`; a
|
|
2361
|
+
resumed leg's own earlier legs count as spent money, never as a hold).
|
|
2362
|
+
- **Refusals stay**: a run whose last leg is live (pid from the latest `leg-start`), a green run, or a
|
|
2363
|
+
non-resumable terminal is refused. `bareloop run`'s `history.jsonl` writes one row per LEG
|
|
2364
|
+
(`leg: N` from leg 2, no `resumedFrom`) and `run.json` is rewritten unchanged (same worktree, the run's
|
|
2365
|
+
own start).
|
|
2366
|
+
- **Not covered by this ruling, and unchanged:** the review-door `rerun` (`--door <runid> --decide rerun`)
|
|
2367
|
+
is a NEW run with a new runid (its door reader folds the answered run's chain spend); Reuse workflow in
|
|
2368
|
+
the panel is a new run.
|
|
2369
|
+
|
|
2323
2370
|
**A pause checkpoint is answered on the same command line** (N4, 2026-08-12 §5.2 — the
|
|
2324
2371
|
terminal is the v1 surface; the panel is N6's). The reference runner takes
|
|
2325
2372
|
`--decide accept|rerun|pause` with `--text` for the rerun door, gated on the SAME
|
|
@@ -2997,8 +3044,8 @@ separate tarball step).
|
|
|
2997
3044
|
README.md the operator questions, in the order `bareloop run` asks them
|
|
2998
3045
|
blessing.json absent at export; written by the run that first greens it
|
|
2999
3046
|
history.jsonl absent at export; one line appended per `bareloop run` on this machine
|
|
3000
|
-
runs/<runid>/ absent at export; one per
|
|
3001
|
-
close's books) and run.json ({runid, worktree, seed, repo, at
|
|
3047
|
+
runs/<runid>/ absent at export; one per RUN (a resume continues it) — spine.jsonl, gate-audit.jsonl,
|
|
3048
|
+
close/ (the close's books) and run.json ({runid, worktree, seed, repo, at})
|
|
3002
3049
|
```
|
|
3003
3050
|
|
|
3004
3051
|
**`bundleHash`** = sha256 over the sorted `path:contentSha256` lines of exactly `spec.json`
|
|
@@ -3204,7 +3251,8 @@ key you want first (the panel picks the row by the Model menu).
|
|
|
3204
3251
|
different from the recorded one is a stop, exit `1`, spending nothing; `--repo` is optional
|
|
3205
3252
|
on a resume) and hands the engine `resumeRun` on that run's spine — the engine's own gates
|
|
3206
3253
|
(checkpoint age, tree-at-seed, liveness) and spend fold apply, so `--budget` can never widen
|
|
3207
|
-
a resume. The new leg
|
|
3254
|
+
a resume. The new leg appends to the SAME `runs/<runid>/spine.jsonl` behind a `leg-resume` marker
|
|
3255
|
+
(P5-R): no new id, run dir or worktree. The resume command a halted leg prints carries that leg's own
|
|
3208
3256
|
`--budget`/`--wall`, only if you passed them (a tightened ceiling never silently reverts to the signed
|
|
3209
3257
|
one). After a MONEY halt the line does NOT repeat the exhausted `--budget` (chain spend is folded, so
|
|
3210
3258
|
it would halt again at once); it prints `--budget <more than $<spent so far>, at most $<signed
|
|
@@ -3223,7 +3271,8 @@ key you want first (the panel picks the row by the Model menu).
|
|
|
3223
3271
|
inputs); `--door`/`--decide`/`--review-door` are not exposed on `run`.
|
|
3224
3272
|
8. `appendHistory` — one `history.jsonl` line off this leg's own `job-end`: `{ runid, at,
|
|
3225
3273
|
outcome, spentUsd, spendComplete, budgetUsd, maxWallMs, worktree, branch, bundleHash,
|
|
3226
|
-
approveHash,
|
|
3274
|
+
approveHash, leg? }` (the `bundleHash` ↔ `approveHash` pairing, POC fact 2; one row per LEG of the
|
|
3275
|
+
one run — `leg: N` from the second leg, no `resumedFrom`).
|
|
3227
3276
|
`spentUsd`/`spendComplete` are never fabricated as `0` when unknown. No `job-end` (a $0
|
|
3228
3277
|
refusal, a crash) writes no row. A `green` outcome on a still-unblessed bundle also calls
|
|
3229
3278
|
`bless(bundleDir, { bundleHash, runid, outcome, host })`.
|
|
@@ -3295,7 +3344,7 @@ key you want first (the panel picks the row by the Model menu).
|
|
|
3295
3344
|
$0: no interview, no author, no run trigger, no key ever read. A row is `{ at, runid, job,
|
|
3296
3345
|
spine, patient, via }` — `spine`/`patient` are always absolute paths (`patient: null` when
|
|
3297
3346
|
not known, e.g. every `via:"backfill"` row: no spine record carries a run's workdir);
|
|
3298
|
-
`via` is `'run-u'`, `'bundle'`, or `'backfill'`. `bareloop run-u` and `bareloop run` (the
|
|
3347
|
+
`via` is `'run-u'`, `'bundle'`, or `'backfill'`. A RESUMED run is still one row: `readRunList` folds its `leg-start` entries into it (`leg`, and the latest leg's `pid`/`capUsd`; P5-R). `bareloop run-u` and `bareloop run` (the
|
|
3299
3348
|
bundle path) each append their own row at run START, before the first paid call — a
|
|
3300
3349
|
list-append failure is caught at both call sites and printed loudly to stderr
|
|
3301
3350
|
(`WARNING: could not add this run to ~/.config/bareloop/runs.jsonl (…)`); the run itself
|
|
@@ -3385,9 +3434,17 @@ key you want first (the panel picks the row by the Model menu).
|
|
|
3385
3434
|
never a reimplementation of any gate. `GET /api/author/model-check?model=<id>` is the $0 readiness probe the job card runs
|
|
3386
3435
|
before Start (`checkProviderReachable`, `src/providers.js` — a models-list GET only, never a
|
|
3387
3436
|
completion; the page sees the key's NAME and a status word, never the value). `POST
|
|
3388
|
-
/api/author/:id/check-deps` is the install-gap's "Check again" (`phase:'install-needed'`:
|
|
3437
|
+
/api/author/:id/check-deps` is the install-gap's "Check again" (the main button's wording while waiting on an install) (`phase:'install-needed'`:
|
|
3389
3438
|
the session waits on the person's own install, then re-runs `missingDependencies` on the
|
|
3390
|
-
same copy — bareloop never installs). `
|
|
3439
|
+
same copy — bareloop never installs). `POST /api/author/:id/abandon` (the Chat card's **Abandon** button, 2026-10-05) ends a
|
|
3440
|
+
LIVE, unsigned session: phase becomes the terminal `abandoned` (releasing the one-at-a-time lock), money already booked
|
|
3441
|
+
stays booked (`draftSpentUsd` is never zeroed; a call in flight still books its usage), no NEW model call starts;
|
|
3442
|
+
`400` on a session that is not live, `404` unknown id, same guard as the other author routes. After `signed` the card's
|
|
3443
|
+
button reads **Clear** and only empties the card (a run is stopped from the Run tab). `GET /api/author/live` →
|
|
3444
|
+
`{ok, sessionId, state}` of the ONE live (non-terminal) session, or `{sessionId:null, state:null}`: a refreshed page
|
|
3445
|
+
re-attaches to it from the server's session map (nothing is stored page-side). A panel restart mints a new token and
|
|
3446
|
+
loses the in-memory sessions: the page then shows one "reload this page" line and stops the Chat poll (no auto-reload;
|
|
3447
|
+
drafting money already spent stays booked via `draft-spend.json`, below). `GET /api/author/:id` polls the session's state
|
|
3391
3448
|
(phase, chat messages, cost, `revisesLeft`, `specHash` once prepared). `POST /api/author/
|
|
3392
3449
|
:id/send {text}` answers whatever the confirm turn is currently asking (the `language` pick or a plan's
|
|
3393
3450
|
own follow-up question — the old `worseThanBefore` ask is retired, 2026-09-28) — refused outright when the pending ask is the
|
|
@@ -3412,6 +3469,167 @@ key you want first (the panel picks the row by the Model menu).
|
|
|
3412
3469
|
`signing.json`, the two files `bareloop author` itself already writes). Edit/re-sign, the
|
|
3413
3470
|
`~/.config/bareloop/.env` keys-file loader, and Settings have landed (P4a/P4b — see "Settings" below).
|
|
3414
3471
|
|
|
3472
|
+
- **Panel P5 — the Ended block (`docs/product/PANEL-BUILD.md` Addendum 2026-10-02, item 1)** →
|
|
3473
|
+
`GET /api/runs/:runid` carries `ended` = `{reason, next, line, actions:[{id,label}]}` for every
|
|
3474
|
+
FINISHED run (green too; `null` while the run is live), and `GET /api/runs` carries `endedLine`
|
|
3475
|
+
(the card's one short line under the job name, e.g. `money cap — resume`). Both come from ONE
|
|
3476
|
+
code-owned function, `endedFor` (`src/panel/server.js`): fixed sentences keyed by the run's
|
|
3477
|
+
outcome, with only
|
|
3478
|
+
numbers and the engine's own recorded detail slotted in — never model text. The table:
|
|
3479
|
+
green/already-green → "Goal met." (a `destination-refused` record turns it into "…the output
|
|
3480
|
+
could not be delivered (detail)."); cap-halt → "Money cap reached ($X of $Y)." / "Raise the cap,
|
|
3481
|
+
then Resume."; wall-halt → "Time cap reached."; provider-red → "The model provider failed
|
|
3482
|
+
(detail)."; step-stalled → "A step stopped making progress."; plan-red/check-red/step-red/escalated
|
|
3483
|
+
→ "Goal not met — the checks said no (last gap)."; close-red → "The check itself broke
|
|
3484
|
+
(instrument fault), not your goal."; `escalated` is a terminal and never resumable — its escalation of
|
|
3485
|
+
category `cap-halt` with `spend.strikes` is the STRIKE governor, read "The fix loop stopped improving
|
|
3486
|
+
(S of L tries, no check got better)." (card line `stopped improving`), and is the money cap ONLY when
|
|
3487
|
+
the spine has a `money-halt` record or the job-end outcome is `cap-halt` itself; every other terminal → "Stopped before or outside the work
|
|
3488
|
+
(code: <outcome>)." (never the raw engine detail — it can name retired surfaces; raw detail appears only as the quoted check gap on "goal not met" and the provider error, both capped at 120 characters; a destination-refused green reads "…could not be delivered." with no detail); a run with no `job-end` whose process is gone (glyph `?`, never `✗`) →
|
|
3489
|
+
"Stopped with no ending recorded (last thing it did: …)." `actions` holds `resume` ONLY when
|
|
3490
|
+
the engine would accept a resume (`resumePlanFor`: the same `readResume`/`CHECKPOINT_OUTCOMES`/
|
|
3491
|
+
`checkpointAgeGate` readers the engine refuses with, plus a signed `resolved-spec.json` /
|
|
3492
|
+
`resolved-spec-r<k>.json` beside the run whose hash is the one the run's `job-start` carries);
|
|
3493
|
+
otherwise `next` says why Resume is not available. `resume` on the detail is
|
|
3494
|
+
`{budgetUsd, maxWallMin, spentUsd, spendComplete}` (the confirm box's prefill) or `null`. The
|
|
3495
|
+
result glyphs are unchanged. The reuse button is described under Reuse workflow, below.
|
|
3496
|
+
**Status words (click-through 2026-10-04)** → every run row, run detail and imported row carries `status`
|
|
3497
|
+
`{key, sign, word}` from ONE table (`src/panel/status.js`): `[▶] running · [·] waiting · [✓] passed · [✗] failed ·
|
|
3498
|
+
[✗] capped · [✗] stopped · [?] died`; `glyph` is that sign. Mapping: green/already-green/satisfied → passed; no
|
|
3499
|
+
job-end + runner alive → running, gone → died; cap-halt, wall-halt, and an escalation that is a money-halt or wall-halt
|
|
3500
|
+
→ capped; `stopped` → stopped; every other outcome (plan-red, check-red, step-red, close-red, provider-red,
|
|
3501
|
+
step-stalled, other escalations, refusals) → failed. The detail also carries `startedAt` and `endedAt` (the last
|
|
3502
|
+
`job-end` timestamp, null while live or died). `GET /api/imports` rows and `GET /api/imports/:id` carry `runStatus`
|
|
3503
|
+
(passed, or null when the bundle shows no green) and `runReason` (`goal met`). The Ended block's lines for died and
|
|
3504
|
+
stopped runs are `no ending recorded` and `you pressed Stop` (each `— resume` when Resume is offered).
|
|
3505
|
+
**Resume (item 2)** → `POST /api/runs/:runid/resume` (`src/panel/runroutes.js`), behind
|
|
3506
|
+
`checkHumanGuard` (token + own address, like `/api/author/*`); body `{budgetUsd?, maxWallMin?}`
|
|
3507
|
+
(blank = the signed caps). `404` unknown run; `409` when `resumePlanFor` says the engine would
|
|
3508
|
+
refuse (`Resume is not available for this run (why).`); `400` for a bad cap, a money cap at or below what is already spent (or a time cap at or below the time
|
|
3509
|
+
used) — refused at $0 before any write or spawn — or the monthly $
|
|
3510
|
+
limit (same library check and text as Sign & run). If a cap changed, the new spec is written as
|
|
3511
|
+
`resolved-spec-r<k>.json` beside the original and its hash is approved; the signed spec the run
|
|
3512
|
+
started under is never overwritten, and a run resumed under `r<k>` is resumed again under the
|
|
3513
|
+
spec whose hash its `job-start` carries. The spawn is `setsid --wait systemd-inhibit node
|
|
3514
|
+
bin/bareloop.mjs run-u --spec <spec> --resume <runid> --approve <hash>` (array argv, detached,
|
|
3515
|
+
log `resume-<runid>-<ms>.log` beside the spec; `--draft-spent-usd`/`--draft-spend-incomplete`
|
|
3516
|
+
ride along from the run's `job-start`, so the one cap still covers drafting). `--wait` hands back
|
|
3517
|
+
the engine's own exit code: an exit inside the settle window (6s) is the engine's own refusal and
|
|
3518
|
+
the log tail is returned as `error` verbatim; otherwise `{ok:true, runid, specHash, capsChanged,
|
|
3519
|
+
log}`. The run keeps its runid and its one list row: the resumed leg appends to the same spine (P5-R,
|
|
3520
|
+
`leg-start` in the run list), it never appears as a new run. The page's Resume button opens the
|
|
3521
|
+
caps form (prefilled, "spent so far") and `Sign & resume` is the human click.
|
|
3522
|
+
**Stop (item 5)** → `POST /api/runs/:runid/stop` (`src/panel/runroutes.js`, `checkHumanGuard`, no body).
|
|
3523
|
+
It writes the run's STOP REQUEST, a file `<spine>.stop` (`stopFilePath(spine)`, `src/legs.js` — the one
|
|
3524
|
+
spelling), and signals nothing. `404` unknown run; `409` when the run's LATEST leg is not live
|
|
3525
|
+
(`runIsAlive`) or its spine does not exist yet (still starting). The ENGINE half is library code, so
|
|
3526
|
+
CLI runs honour the file too (no new CLI command): `runJob`/`runPlan` take `stopFile`, and `run-u`/the
|
|
3527
|
+
panel's spawn pass `<spine>.stop`. The seam is the ROUND BOUNDARY of a step worker — where the money cap binds
|
|
3528
|
+
(`src/planrun.js`, the `metered` round callback): file present = delete it, emit `stop-requested
|
|
3529
|
+
{phase, step, iteration, round}`, end the Loop after that round; `ask` then throws category `stopped`
|
|
3530
|
+
and the step loop files it as job-end outcome `stopped` the way a mid-step cap-halt is filed
|
|
3531
|
+
(`spendComplete` exact — nothing is in flight at a round boundary). One owner, one check: a one-step run
|
|
3532
|
+
and a long step both stop within one turn. Resume re-enters that step. The request file is cleared three times: when honoured, when the
|
|
3533
|
+
leg ends (`finally`), and at the start of the next leg (a click that raced a leg's end never stops a
|
|
3534
|
+
resume). `stopped` is in `CHECKPOINT_OUTCOMES`: resumable like a `cap-halt`, the same run continues as a
|
|
3535
|
+
new leg at the next step. `GET /api/runs/:runid` carries `live` and `stopping` (a stop request is on
|
|
3536
|
+
disk and the leg is live); Ended row `stopped` = "You stopped it." / "Resume." / `[Resume]`, card line
|
|
3537
|
+
`stopped — resume`, Audit divider `stopped: you stopped it · resumed <when>`. The page shows `[Stop]`
|
|
3538
|
+
in the Run tab's action area while live, "stopping after this turn…" after the click, and the same
|
|
3539
|
+
`[Resume]` there once the engine would accept one. The seam reads the file in STEP workers only
|
|
3540
|
+
(`phase` `step:<id>`): the scout, plan and close-fix rounds never read it, so a Stop clicked while the run
|
|
3541
|
+
is in one of those phases is not honoured until a step round runs again, and is otherwise cleared when
|
|
3542
|
+
the leg ends — the money and time caps still bind throughout.
|
|
3543
|
+
**Reuse workflow (replaces P5 item 3's Start from this, 2026-10-03)** — a button on GREEN runs only (the Run tab's
|
|
3544
|
+
action row and the Ended block; `ended.actions` carries `{id:'reuse', label:'Reuse workflow'}` on green and
|
|
3545
|
+
green-with-destination-refused rows, and on no other: a red row's next line is "Change the job: Clear the card and draft a new one.", and
|
|
3546
|
+
stopped/capped/died rows offer `resume` only) and on every imported job. It opens the Chat tab's New job card
|
|
3547
|
+
filled from the SIGNED job: a NEW run (new runid), never a rerun, nothing drafted ($0). **Only five boxes are
|
|
3548
|
+
open — Source, Destination, Model, $ cap, Time cap**; every other box (check type, model, job name, goal, success,
|
|
3549
|
+
guardrails, judge examples) is the signed workflow, greyed, and the SERVER refuses a start that changed one
|
|
3550
|
+
(`400 "<Field> is locked on a reused workflow — Clear the card to change it"`; the page is never trusted).
|
|
3551
|
+
Changing a locked box is Clear (the Chat card's top-right button), which drafts. Routes, behind `checkHumanGuard`:
|
|
3552
|
+
`GET /api/author/start-from?runid=<id>` or `?import=<id>` → `{ok, origin, card, from:'signed job'|'imported job',
|
|
3553
|
+
note, locked:[…], open:['source','destination','model','capUsd','maxWallMs'], specHash, workflowKey, trackRecord:{runs,
|
|
3554
|
+
green, notGreen, live, finished, avgSpendUsd, avgWallMs}, line}` (`404` unknown, `409` with an `error` when
|
|
3555
|
+
there is nothing to copy: no log, the run's signed job is not on disk, or an imported job that changed, lost its
|
|
3556
|
+
dependency or no longer matches its signed bytes); `POST /api/author/start` accepts `startFrom: <runid>` or
|
|
3557
|
+
`startFrom: {importId}` beside the card and answers `{ok, sessionId, reuse, state}`. The old
|
|
3558
|
+
`POST /api/author/start-from-check` and the "Changed — new job" mode are gone. **Identity, two keys:** the
|
|
3559
|
+
signature hash `jobSpecHash` is unchanged (it covers the caps and the write fence — what the person signs);
|
|
3560
|
+
`workflowKey(spec)` (`src/job.js`, not exported from the package root) is a sha256 over the signed spec WITHOUT
|
|
3561
|
+
`source`, `destination`, `writeScope`, `budgetUsd` and `maxWallMs` (`REUSE_OPEN_SPEC_FIELDS`) AND without `provider`,
|
|
3562
|
+
`baseUrl` and `model` (`WORKFLOW_KEY_IDENTITY_FIELDS`; `jobSpecHash` still covers all of them). A reuse copies the
|
|
3563
|
+
origin's signed spec, sets only `writeScope` (from Destination), `budgetUsd`, `maxWallMs` and the worker from the
|
|
3564
|
+
chosen Model Name (`buildReuseSpec(origin, card, rows)`: `provider`; `baseUrl` when the row has one; `model` only
|
|
3565
|
+
when the Name is not the provider's default tier — spelled as authoring spells it; a RUBRIC origin with no `judge`
|
|
3566
|
+
first gets `judge` = its own resolved judge identity so the judge never follows the worker; an explicit judge is
|
|
3567
|
+
kept; deterministic jobs get none), and signs under a
|
|
3568
|
+
NEW `jobSpecHash` with the SAME `workflowKey` (the session refuses a spec whose key moved). Locked boxes carry the
|
|
3569
|
+
signed values read by the Job tab's own readers. **Estimate line** above the card: "Same job — G green · N not
|
|
3570
|
+
green · about $X and M min a run", from every LISTED run whose signed spec has the same `workflowKey` AND ran the same worker (provider + baseUrl + model) as the Model box now names — `GET /api/author/start-from?…&model=<Name>` recomputes it when the box changes; none = "Same job — no runs yet on this model" (one run =
|
|
3571
|
+
one entry via `legsOf`; the averages read FINISHED runs with exact figures — spend from `chainSpend`, working time
|
|
3572
|
+
from `legsWallMs`, resume gaps excluded); unknown is said ("no finished run yet to price or time", "cost not
|
|
3573
|
+
recorded", "time not recorded"), never $0 or 0 min; no registry, no plan handover. **An imported job** (its provider is not forced: the chosen Settings row is the worker; a card with no matching row opens with no Name picked) is
|
|
3574
|
+
re-verified at the moment of reuse — `readBundle` (the bundle hash covers every close script), `checkBundleDeps`,
|
|
3575
|
+
and every close stage's signed sha256 against the bytes on disk over the spec with `$BARELOOP_BUNDLE` resolved to
|
|
3576
|
+
the folder — then reused the same way; the close scripts stay in the verified folder (the engine re-verifies
|
|
3577
|
+
their bytes at run start and before every close run). An operator-written command close has no declaration for
|
|
3578
|
+
`prepareSigning` to ground (it refuses one by design), so that session's gate is the byte check, and the hash the
|
|
3579
|
+
person signs at `[Sign & run]` is the spec's own. The ONE wide card button (below the message box; wording from `mainButtonFor`: Start drafting / Sign & run / Check again / Send / disabled) reads `Sign & run` on a Reuse card (one click: the page signs the
|
|
3580
|
+
prepared hash as soon as the session reports `prepared`; the server re-checks it). `card.json` (the form text)
|
|
3581
|
+
is still written beside `resolved-spec.json` when a session reaches `prepared`.
|
|
3582
|
+
**The progress list (2026-10-04)** — `GET /api/author/:id` state carries `steps: [{id, label, status:
|
|
3583
|
+
'running'|'done'|'failed', detail}]`, one entry per pipeline step in first-seen order, updated in place (ids/labels:
|
|
3584
|
+
`STEP_LABELS`, `src/panel/authorsession.js`); `progressLabel` is the running step's label. A refusal sets
|
|
3585
|
+
`state.error` and fails exactly one step with the same text as its `detail`; pipeline text is never a chat message
|
|
3586
|
+
(`messages` holds person/model turns only). Two last steps, `hash` ("generating hash", detail `spec hash <full hash>`, done at sign-prepare) and `signed` ("signed hash", pushed by `signRun` when the sign is accepted); the old "SIGNING PREPARED" / "signed — … run starting detached" thread bubbles are gone. The page draws each step's `detail` on its own `> ` line under the step. Destination follows the Source: for a repo source it is the write
|
|
3587
|
+
fence (relative `writeScope` globs, never proven as a directory); for a folder source an absolute directory. Both
|
|
3588
|
+
are refused at $0, before any model call (the same rule on a fresh and a Reuse card): an ABSOLUTE
|
|
3589
|
+
Destination on a repo source → `Destination must be a path inside the repo, like src/digest.js` (before the
|
|
3590
|
+
copy); a source that is not a git repo → a plain refusal worded by the kind the source door recorded (a single
|
|
3591
|
+
file: "Source must be the repo folder — put the file in Destination"; a plain folder or a URL: "not a code
|
|
3592
|
+
project (no git repo found)").
|
|
3593
|
+
**Import, read only (item 4)** — `src/panel/importroutes.js`. The Workflows toolbar's `[Import]` opens a folder
|
|
3594
|
+
browser plus a paste box; an imported job is an exported bundle folder the person can LOOK at: nothing runs,
|
|
3595
|
+
nothing is signed, the folder is never written. Routes, all behind `checkHumanGuard` (token + own address —
|
|
3596
|
+
new disk exposure, so the strict guard, not the Host guard the plain GETs use): `GET /api/fs/list?path=`
|
|
3597
|
+
→ `{ok, requested, path, parent, bundle, entries:[{name, path, bundle:true}], truncated, stopped, visited, depth}`
|
|
3598
|
+
(job BUNDLES only — a folder holding a regular file `manifest.json` — found by searching DOWN from `path` at most
|
|
3599
|
+
`depth` = 3 folders; `name` is the path relative to `path`, `path` the absolute one; symlinks never followed,
|
|
3600
|
+
`node_modules`/`.git`/dot-folders skipped, a bundle is never descended into, unreadable folders skipped silently;
|
|
3601
|
+
capped at 5000 folders visited (`stopped`) and 200 bundles (`truncated`); starts at the home folder when `path` is blank);
|
|
3602
|
+
`POST /api/imports {path}` → `{ok, id, job, dir}` (`readBundle` must come back clean — a plain or tampered
|
|
3603
|
+
folder is `400` and records nothing); `GET /api/imports` (the list, every bundle RE-READ now) and
|
|
3604
|
+
`GET /api/imports/:id` (one view). Imported list: `<home>/imports.jsonl`, one `{at, dir, job, bundleHash}` line
|
|
3605
|
+
per FOLDER (a re-import replaces that folder's line; a file already holding duplicates lists once per real path, newest wins; mode 0600 in the 0700 config home); `id` = the first 12 hex of
|
|
3606
|
+
sha256(real path). **Path safety:** the path is expanded (`~`, `~/…` only), refused if it holds a NUL byte, is
|
|
3607
|
+
over 4096 bytes or is not absolute, then `resolve`d and `realpath`ed — the REAL folder is listed and recorded
|
|
3608
|
+
and the response says which it chose (`path` beside `requested`); a non-directory is refused; a SYMLINK inside the
|
|
3609
|
+
search is never listed and never followed; names only, never file contents. **Status, re-read on every list/view:** `ok`, `changed` ("changed since import",
|
|
3610
|
+
red: a different/tampered/unreadable bundle) or `missing` ("folder not found"). The view carries goal,
|
|
3611
|
+
`checkType`, `success` (the close stage names), `guardrails`, `budgetUsd`/`maxWallMs`, `model`, the history
|
|
3612
|
+
the bundle shipped (`history:{greens,reds,total,recent}`, read from the bridges' history rows) and
|
|
3613
|
+
`approved`/`approvedText` — approval on THIS machine is `verifyBlessing` (the first green run here writes
|
|
3614
|
+
`blessing.json`): approved / not approved yet / stale. The row reads `imported · view only`; the view opens in
|
|
3615
|
+
the same Run / Audit / Job tabs as any run (Audit: "no log — this job ran on another machine"), and its one
|
|
3616
|
+
button, `[Reuse workflow]` in the Run tab's top action row, reuses the bundle's signed job as described above.
|
|
3617
|
+
`GET /api/imports/:id` also carries `runsHere` (how many `runs/<runid>/` folders in the bundle hold a readable
|
|
3618
|
+
`spine.jsonl`) and `run`, what the Run tab shows below the imported facts: `{kind:'spine', id, runid, at}` (the
|
|
3619
|
+
newest run in the bundle's own `runs/` that ended green; `id` is `<importId>~<runid>`), else `{kind:'bridge', runid,
|
|
3620
|
+
at, detail}` (the bridge's green version rendered as a run detail, fields the bridge does not carry left `null`),
|
|
3621
|
+
else `{kind:'none'}`; never throws. **An imported bundle's run is served read only** through the ordinary run routes
|
|
3622
|
+
under that composite id: `GET /api/runs/<importId>~<runid>` (detail), `…/audit` and `…/rounds` (and `…/job`) read
|
|
3623
|
+
the spine inside the bundle (`importrun.js` `safeSpinePath`: a checked name, `lstat`ed, a link never followed); an
|
|
3624
|
+
unknown import or run is `404`. Such a run is never in `GET /api/runs`, never live (`live`/`stopping` are false,
|
|
3625
|
+
no pid), never resumable or stoppable from the panel.
|
|
3626
|
+
**Run-card fixes (item 6)** → a listed run whose runner is alive but whose spine is not written
|
|
3627
|
+
yet reads `starting: true` (list AND detail; glyph `▶`, every figure null, `fileMissing:false`) —
|
|
3628
|
+
never `file missing`; a row whose runner is gone and whose spine is absent stays `fileMissing`.
|
|
3629
|
+
`GET /api/runs` rows now carry `spendFloorUsd`/`wallFloorMs` for a LIVE spine too (previously died
|
|
3630
|
+
only; both `null` once a `job-end` exists), the same `deriveDeath` floors the detail carries, so a
|
|
3631
|
+
live card reads "$X so far · running Ym" exactly like the right pane.
|
|
3632
|
+
|
|
3415
3633
|
- **`bareloop run-u <flags…>`** (PANEL-BUILD.md P0 task 2/4) → the person-path run flow
|
|
3416
3634
|
(the JOBS-table/`--spec` runner, resume, the review door — `docs/logs/FINDINGS.md`'s
|
|
3417
3635
|
U-mode). `src/cli.js`'s `run-u` dispatch hands `rest` straight to
|
|
@@ -3509,7 +3727,8 @@ and leaves the worktree in place until the human removes it.
|
|
|
3509
3727
|
|
|
3510
3728
|
**`history.jsonl` row shape** — one JSON object per line, one line per `bareloop run` on this
|
|
3511
3729
|
machine: `{ runid, at, outcome, spentUsd, spendComplete, budgetUsd, maxWallMs, worktree,
|
|
3512
|
-
branch, bundleHash, approveHash }
|
|
3730
|
+
branch, bundleHash, approveHash, leg? }` (`leg` only from a resumed run's second leg: the same `runid`,
|
|
3731
|
+
one row per leg). `bundleHash` is the bundle's own signed manifest hash
|
|
3513
3732
|
(unchanged across tightened runs); `approveHash` is the hash of the actual, possibly-
|
|
3514
3733
|
tightened, `$BARELOOP_BUNDLE`-resolved spec that run executed — the two are recorded side
|
|
3515
3734
|
by side so a tightened run's real approval can never be confused with the bundle's headline
|
|
@@ -3585,6 +3804,15 @@ spends; the CLI prints it to stderr, exit 2) and at the panel's Sign & run (`sig
|
|
|
3585
3804
|
same text under `#jf-cap-money` via `GET /api/author/monthly-check?cap=`. "This month" is the local
|
|
3586
3805
|
calendar month; a died or incomplete-spend run makes the total an "at least" figure.
|
|
3587
3806
|
|
|
3807
|
+
*Drafting spend that never became a run* (2026-10-05, F213). A panel authoring session writes
|
|
3808
|
+
`<session dir>/draft-spend.json` (`{ sessionId, spentUsd, spendComplete, provider, baseUrl, model,
|
|
3809
|
+
startedAt, updatedAt }`, atomic) after every metered call, so an abandoned, refused or restarted session's
|
|
3810
|
+
drafting money is not lost. `readLegs` (hence `monthSpend`, `spendSummary`, `checkMonthlyRoom` and the Money
|
|
3811
|
+
tab) adds every `<home>/panel-sessions/<id>/` that has one and whose folder holds no listed run's `spine` or
|
|
3812
|
+
`patient` (a signed run already carries its drafting spend via `--draft-spent-usd`; no double count). It lands in
|
|
3813
|
+
the month of `startedAt` (the first call), under the provider row it was drafted on; `spendComplete: false` or an
|
|
3814
|
+
unreadable file makes the figure an "at least". It is not a run: no wall, not in the `runs` count.
|
|
3815
|
+
|
|
3588
3816
|
*Hold until done.* A run CLAIMS the limit when it starts and holds it until it is done — no lock file,
|
|
3589
3817
|
records only. `claimRun` (`src/monthly.js`) writes the run's row FIRST (it carries its `pid` and
|
|
3590
3818
|
`capUsd`), then reads `runs.jsonl`: earlier claims come first, and only the claims ABOVE its own row count
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bareloop",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.35.0",
|
|
4
4
|
"description": "Workflows that earn their own design, with receipts — agent-authored workflows for repeated, long, verifiable jobs that improve across runs under an un-gameable gate.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.js",
|
package/src/bundlerun.js
CHANGED
|
@@ -23,6 +23,7 @@ import {
|
|
|
23
23
|
} from './bundle.js';
|
|
24
24
|
import { jobSpecHash } from './job.js';
|
|
25
25
|
import { parseJsonl } from './replayio.js';
|
|
26
|
+
import { legsOf } from './legs.js';
|
|
26
27
|
import { startRun, resumeRun } from './userrun.js';
|
|
27
28
|
|
|
28
29
|
/**
|
|
@@ -117,7 +118,9 @@ export async function bundleMain(args, {
|
|
|
117
118
|
// after its own $0 refusals, so a refusal leaves no worktree behind. A RESUME is the one
|
|
118
119
|
// exception: it re-enters the SAME worktree its halted run left (recorded in that run's
|
|
119
120
|
// `run.json`), and a gone tree is a stop, never a silent fresh start.
|
|
120
|
-
|
|
121
|
+
// P5-R (hamr 2026-10-02: one run, one id, one file): a RESUME is the same run — same runid, same run dir, same
|
|
122
|
+
// spine; the engine appends the new leg to it. Only a fresh run mints an id.
|
|
123
|
+
const runid = resumeArg !== undefined ? resumeArg : now().toString(36);
|
|
121
124
|
/** @type {string} */
|
|
122
125
|
let repo;
|
|
123
126
|
/** @type {string} */
|
|
@@ -126,6 +129,8 @@ export async function bundleMain(args, {
|
|
|
126
129
|
let worktree;
|
|
127
130
|
/** @type {string|null} */
|
|
128
131
|
let deadSpine = null;
|
|
132
|
+
/** the run's own first-leg stamp, kept when a later leg rewrites `run.json` (it is the run's start, not the leg's) @type {string|null} */
|
|
133
|
+
let firstAt = null;
|
|
129
134
|
if (resumeArg !== undefined) {
|
|
130
135
|
if (!/^[a-z0-9]+$/.test(resumeArg)) { err(`--resume ${JSON.stringify(resumeArg)} is not a run id of this bundle`); return 1; }
|
|
131
136
|
const deadRunJson = join(bundleDir, 'runs', resumeArg, 'run.json');
|
|
@@ -150,6 +155,7 @@ export async function bundleMain(args, {
|
|
|
150
155
|
repo = rec.repo;
|
|
151
156
|
seed = rec.seed;
|
|
152
157
|
worktree = rec.worktree;
|
|
158
|
+
if (typeof rec.at === 'string') firstAt = rec.at;
|
|
153
159
|
deadSpine = join(bundleDir, 'runs', resumeArg, 'spine.jsonl');
|
|
154
160
|
} else {
|
|
155
161
|
repo = resolve(cwd, /** @type {string} */ (repoArg));
|
|
@@ -189,7 +195,7 @@ export async function bundleMain(args, {
|
|
|
189
195
|
}
|
|
190
196
|
mkdirSync(runDir, { recursive: true });
|
|
191
197
|
writeFileSync(join(runDir, 'run.json'), `${JSON.stringify({
|
|
192
|
-
runid, worktree, seed, repo, at: new Date(now()).toISOString(),
|
|
198
|
+
runid, worktree, seed, repo, at: firstAt ?? new Date(now()).toISOString(),
|
|
193
199
|
}, null, 2)}\n`);
|
|
194
200
|
};
|
|
195
201
|
|
|
@@ -227,7 +233,9 @@ export async function bundleMain(args, {
|
|
|
227
233
|
// 7. history + (on a first green) the blessing — off THIS run's own spine, tolerant of
|
|
228
234
|
// a torn line. No job-end (a $0 refusal, a crash) means no history row, as ever.
|
|
229
235
|
const events = existsSync(spineFile) ? parseJsonl(spineFile).records : [];
|
|
230
|
-
|
|
236
|
+
// the LATEST leg's terminal: an earlier leg's job-end on the same file is a row already written for it
|
|
237
|
+
const legs = legsOf(events);
|
|
238
|
+
const je = legs.at(-1)?.jobEnd ?? null;
|
|
231
239
|
if (!je) return engineCode;
|
|
232
240
|
const outcome = je.outcome;
|
|
233
241
|
const spentUsd = je.spentUsd ?? null;
|
|
@@ -246,7 +254,8 @@ export async function bundleMain(args, {
|
|
|
246
254
|
branch,
|
|
247
255
|
bundleHash: manifest.bundleHash,
|
|
248
256
|
approveHash,
|
|
249
|
-
|
|
257
|
+
// one row per LEG of the one run; the first leg's row keeps the shape it always had
|
|
258
|
+
...(legs.length > 1 ? { leg: legs.length } : {}),
|
|
250
259
|
});
|
|
251
260
|
if (outcome === 'green' && !bundle.blessing) {
|
|
252
261
|
bless(bundleDir, {
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
// Drafting spend that never became a run (self-review 2026-10-05, hamr's ruling A).
|
|
2
|
+
//
|
|
3
|
+
// A panel authoring session pays for model calls (survey, declaration, confirm turn) BEFORE any run exists.
|
|
4
|
+
// That spend rode only in memory (`state.draftSpentUsd`) and reached disk when the session was signed and run
|
|
5
|
+
// (`--draft-spent-usd` -> the run's spine). Abandon, a refusal, or a panel restart lost it, while the monthly
|
|
6
|
+
// limit and the Money tab never counted it. So the session writes `<session dir>/draft-spend.json` after EVERY
|
|
7
|
+
// metered call (one owner: the session's `onCall`, src/panel/authorsession.js), and the money readers
|
|
8
|
+
// (`readLegs`, src/monthly.js) add every session folder that carries one and NEVER became a run.
|
|
9
|
+
//
|
|
10
|
+
// "Became a run" = some run-list row's `spine` or `patient` path sits inside that session's folder: a signed run
|
|
11
|
+
// already carries its drafting spend through `--draft-spent-usd`, so counting the file too would double it.
|
|
12
|
+
// Month attribution is the file's `startedAt` (the first metered call): fixed once written, so a session's
|
|
13
|
+
// figure never moves between months as spend continues, the same start-date rule a run's leg uses.
|
|
14
|
+
// `spendComplete: false` = "at least", never $0 (F6).
|
|
15
|
+
import { existsSync, readdirSync, readFileSync, renameSync, writeFileSync } from 'node:fs';
|
|
16
|
+
import { join, resolve, sep } from 'node:path';
|
|
17
|
+
import { readRunList, runlistHome } from './runlist.js';
|
|
18
|
+
|
|
19
|
+
export const DRAFT_SPEND_FILE = 'draft-spend.json';
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* @typedef {object} DraftSpend
|
|
23
|
+
* @property {string} sessionId
|
|
24
|
+
* @property {number} spentUsd the known floor of the session's drafting spend
|
|
25
|
+
* @property {boolean} spendComplete false = `spentUsd` is a floor ("at least")
|
|
26
|
+
* @property {string|null} provider the worker's provider shape (`anthropic-api` | `openai-api` | ...)
|
|
27
|
+
* @property {string|null} baseUrl
|
|
28
|
+
* @property {string|null} model
|
|
29
|
+
* @property {string} startedAt ISO, the first metered call
|
|
30
|
+
* @property {string} updatedAt ISO, the latest metered call
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* (Re)write `<dir>/draft-spend.json` atomically (tmp + rename).
|
|
35
|
+
* @param {string} dir the session's folder
|
|
36
|
+
* @param {DraftSpend} rec
|
|
37
|
+
* @returns {void}
|
|
38
|
+
*/
|
|
39
|
+
export function writeDraftSpend(dir, rec) {
|
|
40
|
+
const file = join(dir, DRAFT_SPEND_FILE);
|
|
41
|
+
const tmp = `${file}.tmp`;
|
|
42
|
+
writeFileSync(tmp, `${JSON.stringify(rec, null, 2)}\n`);
|
|
43
|
+
renameSync(tmp, file);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** @param {string} p @param {string} dir @returns {boolean} */
|
|
47
|
+
const inside = (p, dir) => typeof p === 'string' && (resolve(p) === dir || resolve(p).startsWith(dir + sep));
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Every session folder's drafting spend that never became a run.
|
|
51
|
+
* @param {{ home?: string, sessionsRoot?: string }} [opts] `home` = the bareloop config dir (as everywhere in src/monthly.js); the sessions live in `<home>/panel-sessions` unless `sessionsRoot` names them
|
|
52
|
+
* @returns {DraftSpend[]}
|
|
53
|
+
*/
|
|
54
|
+
export function readOrphanDraftSpends(opts = {}) {
|
|
55
|
+
const root = resolve(opts.sessionsRoot ?? join(runlistHome(opts.home), 'panel-sessions'));
|
|
56
|
+
if (!existsSync(root)) return [];
|
|
57
|
+
/** @type {string[]} */
|
|
58
|
+
let names;
|
|
59
|
+
try { names = readdirSync(root); } catch { return []; }
|
|
60
|
+
const { rows } = readRunList({ home: opts.home });
|
|
61
|
+
/** @type {DraftSpend[]} */
|
|
62
|
+
const out = [];
|
|
63
|
+
for (const name of names) {
|
|
64
|
+
const dir = join(root, name);
|
|
65
|
+
const file = join(dir, DRAFT_SPEND_FILE);
|
|
66
|
+
if (!existsSync(file)) continue;
|
|
67
|
+
if (rows.some((r) => inside(r.spine, dir) || (r.patient && inside(r.patient, dir)))) continue;
|
|
68
|
+
try {
|
|
69
|
+
const j = JSON.parse(readFileSync(file, 'utf8'));
|
|
70
|
+
if (!j || typeof j !== 'object' || !Number.isFinite(j.spentUsd)) throw new Error('unreadable');
|
|
71
|
+
out.push({
|
|
72
|
+
sessionId: String(j.sessionId ?? name), spentUsd: j.spentUsd, spendComplete: j.spendComplete === true,
|
|
73
|
+
provider: typeof j.provider === 'string' ? j.provider : null, baseUrl: typeof j.baseUrl === 'string' ? j.baseUrl : null,
|
|
74
|
+
model: typeof j.model === 'string' ? j.model : null, startedAt: String(j.startedAt), updatedAt: String(j.updatedAt),
|
|
75
|
+
});
|
|
76
|
+
} catch {
|
|
77
|
+
// a file that names money but cannot be read is unknown spend: an "at least" of $0, dated unknown
|
|
78
|
+
out.push({ sessionId: name, spentUsd: 0, spendComplete: false, provider: null, baseUrl: null, model: null, startedAt: 'unreadable', updatedAt: 'unreadable' });
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return out;
|
|
82
|
+
}
|
package/src/exits.js
CHANGED
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
// unrunnable check is a stop, never a silent pass).
|
|
24
24
|
|
|
25
25
|
import { createHash } from 'node:crypto';
|
|
26
|
-
import { readFile, readdir } from 'node:fs/promises';
|
|
26
|
+
import { readFile, readdir, stat } from 'node:fs/promises';
|
|
27
27
|
import { join } from 'node:path';
|
|
28
28
|
import { globToPrefix } from './validate.js';
|
|
29
29
|
|
|
@@ -62,6 +62,15 @@ export async function snapshotScope(dir, scope) {
|
|
|
62
62
|
const prefix = globToPrefix(scope);
|
|
63
63
|
/** @type {Map<string, string>} */
|
|
64
64
|
const snap = new Map();
|
|
65
|
+
// A scope whose prefix names a single regular FILE (a file-valued writeScope
|
|
66
|
+
// becomes `src/x.js/**`) snapshots that one file, keyed by the prefix itself —
|
|
67
|
+
// readdir on a file throws ENOTDIR, which read as an empty tree forever (F212).
|
|
68
|
+
try {
|
|
69
|
+
if ((await stat(join(dir, prefix))).isFile()) {
|
|
70
|
+
snap.set(prefix, createHash('sha256').update(await readFile(join(dir, prefix))).digest('hex'));
|
|
71
|
+
return snap;
|
|
72
|
+
}
|
|
73
|
+
} catch { /* missing or unreadable: fall through to the directory path */ }
|
|
65
74
|
/** @type {string[]} */
|
|
66
75
|
let entries;
|
|
67
76
|
try {
|
package/src/interviewrun.js
CHANGED
|
@@ -743,7 +743,7 @@ export async function main(argv, deps = {}) {
|
|
|
743
743
|
say(`It runs under the AUTHORING ceiling (${CEILING_USD === null ? 'UNBOUNDED — you gave no --budget' : `$${CEILING_USD}`}), which is not the job's $${draft.budgetUsd}.`);
|
|
744
744
|
say('It stops at prepareSigning: it never signs, and it never runs the job.');
|
|
745
745
|
} else {
|
|
746
|
-
say('NEXT — running
|
|
746
|
+
say('NEXT — running bareloop author on this source stops right away, at $0: no scout, no confirm turn, no model call.');
|
|
747
747
|
say('It never signs and never runs the job — bareloop has no checks for this kind of job yet.');
|
|
748
748
|
}
|
|
749
749
|
say('');
|
|
@@ -781,11 +781,11 @@ export async function main(argv, deps = {}) {
|
|
|
781
781
|
if (!KEYED) {
|
|
782
782
|
say('');
|
|
783
783
|
if (providerEnvKey && keyProblem) {
|
|
784
|
-
say(` (${providerEnvKey} is set but ${keyProblem} —
|
|
784
|
+
say(` (${providerEnvKey} is set but ${keyProblem} — bareloop author refuses without a clean key; secrets are never trimmed or repaired, only reported)`);
|
|
785
785
|
} else {
|
|
786
786
|
say(providerEnvKey
|
|
787
|
-
? ` (${providerEnvKey} is not set in this shell —
|
|
788
|
-
: ` (provider "${PROVIDER}" is not in the runnable table —
|
|
787
|
+
? ` (${providerEnvKey} is not set in this shell — bareloop author refuses without it; secrets load from the environment, never the tree)`
|
|
788
|
+
: ` (provider "${PROVIDER}" is not in the runnable table — bareloop author will refuse it loud; this is not a key problem)`);
|
|
789
789
|
}
|
|
790
790
|
// The repair, in plain words and WITHOUT a command: which secret store a person
|
|
791
791
|
// keeps their key in is theirs, and printing one specific incantation would be
|
|
@@ -802,9 +802,9 @@ export async function main(argv, deps = {}) {
|
|
|
802
802
|
: null;
|
|
803
803
|
if (depsGapAtHandoff) {
|
|
804
804
|
say('');
|
|
805
|
-
say(` The copy still has no installed packages (${depsGapAtHandoff.reason}) —
|
|
805
|
+
say(` The copy still has no installed packages (${depsGapAtHandoff.reason}) — bareloop author would only instrument-stop on it.`);
|
|
806
806
|
say(` cd ${prep.tree} && ${depsGapAtHandoff.command}`);
|
|
807
|
-
say(' then run
|
|
807
|
+
say(' then run bareloop author yourself with the command above.');
|
|
808
808
|
}
|
|
809
809
|
say('');
|
|
810
810
|
// The default is NO, and it is the same lean the pause's doors take: the answer that
|
|
@@ -835,7 +835,7 @@ export async function main(argv, deps = {}) {
|
|
|
835
835
|
say('');
|
|
836
836
|
const child = spawnSyncFn(process.execPath, [BARELOOP_BIN, 'author', ...childArgs], { stdio: 'inherit' });
|
|
837
837
|
if (child.error) {
|
|
838
|
-
say(`
|
|
838
|
+
say(`bareloop author could not be started (${child.error.message}) — the command above still stands.`);
|
|
839
839
|
exitCode = 2;
|
|
840
840
|
} else {
|
|
841
841
|
// the child's own exit is the answer: a refusal there is a RESULT, and flattening
|