bareloop 0.49.0 → 0.51.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 +43 -0
- package/bareloop.context.md +23 -8
- package/package.json +3 -3
- package/src/authorflow.js +14 -1
- package/src/facts.js +54 -6
- package/src/factwords.js +12 -1
- package/src/handoff.js +100 -0
- package/src/inputlook.js +6 -1
- package/src/job.js +6 -1
- package/src/pagedropwords.js +8 -3
- package/src/pagedry.js +21 -7
- package/src/pagefetch.js +75 -12
- package/src/pagemap.js +15 -3
- package/src/pagerules.js +207 -24
- package/src/panel/authorsession.js +2 -0
- package/src/panel/index.html +29 -11
- package/src/plan.js +5 -1
- package/src/planrun.js +35 -4
- package/src/readshim.js +17 -1
- package/src/rubricstep.js +36 -5
- package/src/source.js +3 -3
- package/src/stagewords.js +12 -3
- package/types/authorflow.d.ts +8 -0
- package/types/facts.d.ts +27 -2
- package/types/factwords.d.ts +6 -1
- package/types/handoff.d.ts +39 -0
- package/types/inputlook.d.ts +2 -0
- package/types/pagedry.d.ts +4 -1
- package/types/pagefetch.d.ts +31 -4
- package/types/pagerules.d.ts +13 -1
- package/types/plan.d.ts +4 -0
- package/types/readshim.d.ts +1 -0
- package/types/rubricstep.d.ts +2 -1
- package/types/source.d.ts +12 -2
- package/types/stagewords.d.ts +7 -2
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,49 @@ 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.51.0] - 2026-10-29
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- **A handoff note: later workers are told which files earlier workers read (F253).** The next step or fix ask of a run (a retry of the same step too) gets a code-written map appended to its first prompt: one line per file an earlier ask read, with its line count and, from the LiteCtx index, its function names and line ranges. Capped at 8,000 characters (oldest paths dropped first, with a marker); arbiter books, `.git` and anything outside the job root are never named; scout and drafter prompts are unchanged. On by default; a signed spec's optional `handoffNote: false` turns it off (absent keeps the old hash). One report-only `handoff-note` spine record per note given. A resumed leg starts with an empty map.
|
|
13
|
+
- **An online/offline dot in the panel header, left of Settings.** When the panel's node process dies the open page used to look exactly like a live one; the Runs list read (already polled every 10 s) now paints a green "online" on any HTTP reply, even an error, and a red "offline" only when the read fails with no HTTP status. No new endpoint or timer. `getJSON` now tags its HTTP error with `.status` (message unchanged).
|
|
14
|
+
|
|
15
|
+
### Fixed
|
|
16
|
+
|
|
17
|
+
- **A page render error no longer paints the online dot offline.** If drawing the Runs list threw after the fetch had succeeded, the error fell into the same handler as a failed read and the header showed "offline" while the panel was up. The render now has its own guard that logs the error to the browser console; only a real fetch failure (no HTTP reply) paints offline.
|
|
18
|
+
- **A command check now names its own command in the panel (F256).** Every check that runs a command used to read "does the test suite pass?", so a whole-repo `npx tsc --noEmit --strict` check and the real test suite read the same question. It now quotes the signed command: `does "npm test" exit clean?`, `does "npx tsc --noEmit --strict" exit clean?`. A check with no command falls back to its own name, as before.
|
|
19
|
+
- **The drafter is told to count one file with scope, never a path in `lineMatch` or a region anchor, with an example (F255).** The author prompt's parser description now says: to count lines about one file or folder, keep `lineMatch` general (e.g. `error TS\d+`) and put the file or folder in `scope.includePrefixes`, because a path in `lineMatch` stops matching once that file is clean and the check becomes a broken instrument instead of reading zero; it shows one legal `count-not-worse` example. Prompt-only; the validator is unchanged. Proven in a $0.73 drafter POC (path-in-parser 8/10 before, 0/10 after), not yet in a live run.
|
|
20
|
+
- **The planner is told `exit` is required on every step, with a legal example (F254).** The plan prompt called `exit` "1..2 form checks" and never said every step needs one, and a redraft got only the validator's rule. The prompt now says `REQUIRED on EVERY step` and shows two legal `exit` shapes, and the missing-exit red carries the same example. On deepseek-flash first drafts refused 8 of 23 before and 1 of 24 after; plan-red 1 before, 0 after.
|
|
21
|
+
- **The read shim no longer tells a later attempt it already holds a file it never received.** Every `ask()` builds a fresh Loop with a fresh transcript, but the shim's delivered-ledger lived for the whole worker, so attempt 2 re-reading a file attempt 1 had fully received got "unchanged since you read it, you already hold all N bytes" about bytes its model never saw. The ledger now resets at the start of each `ask()` (not at `askFrom`, which continues the same transcript); the run-level MEMORY-CACHE counts are untouched. (F252)
|
|
22
|
+
|
|
23
|
+
## [0.50.0] - 2026-10-28
|
|
24
|
+
|
|
25
|
+
### Added
|
|
26
|
+
|
|
27
|
+
- **A date in a signed language and a decimal comma can be a fact (F249).** A `date` fact may sign `lang` (`en de fr es it pt nl`) and a `number` or `money` fact `decimal` (`","`); the page-word map may now name `date` and `number` and give `lang` / `decimal`, and is told a label must appear once on its page line and sit right before the value. A signed `lang` whose month names are not on the page, or a `decimal: ","` with no comma-decimal amount on the page, is left under Not checked with a plain reason.
|
|
28
|
+
- **A currency sign is filed by how the page writes it (F249).** A sign glued to the number (`29,99€`, `€399`) is read as a currency, a sign after a space (`29,99 €`) as a unit, and both when the page writes both, whichever box the AI listed it in; a sign legally in both boxes is no longer dropped as listed twice, and a sign listed twice whose page form needs one box says which box it kept.
|
|
29
|
+
- **A page-form fact's claim text is written as the quote spells the value (F249).** For a fact that signs `lang` or `decimal` the worker's value stays canonical (`2026-10-26`, `1057.65`, bareguard's typed binding) but the text bareguard scans for numbers is now the quote's own spelling (`26 October 2026`, `1.057,65`), taken from bareguard's evidence span, so a correct value is no longer red on "the number is not in the quote". Facts that sign neither are checked once, as before.
|
|
30
|
+
- **The "can it read" check follows the forms a price fact signs (F249).** For a money fact that signs `decimal: ","` the check now finds its candidate lines with the comma, the `.` or space thousands marks and a glued or spaced sign (`48,49€`, `UVP: 1.057,65 €`, `1 089€`), and hands the checker the canonical amount (`48.49`, `1057.65`, `1089`); before, `48,49` read as 4849 and a good page was left under Not checked. Grading is still bareguard's own.
|
|
31
|
+
- **A fact named "last updated" is no longer refused as a count (F249).** "One result is one record; ask for N results instead" fired on any name holding "last"; "last" followed directly by a word ending in "ed" ("last updated", "last modified") now passes. "last flight", "latest", "next" and every other counting name are refused as before.
|
|
32
|
+
- **A drafter that drops a fact's `lang` or `decimal` is refused at $0 (F249).** When the page look gave a fact a `lang` or `decimal`, the signed fact must sign the same value; otherwise validation reds with `the fact "released" must sign lang "de", as the page look found. Nothing spent.`, instead of signing an ISO-only date or a point-decimal that reds at run time.
|
|
33
|
+
|
|
34
|
+
### Changed
|
|
35
|
+
|
|
36
|
+
- **bareguard `^0.26.0` to `^0.27.0`.** Its page forms (a date in a signed language, a decimal comma, a currency sign glued after the number) are what the Added entries above build on; an existing signed spec reads as before.
|
|
37
|
+
- **barebrowse `^0.24.1` to `^0.25.0`.** A consent popup that shows 1-3 seconds after load is now closed on the first read of a page, so a page behind a late popup reads as the page. bareloop still asks for the same `act` read; barebrowse's new data mode is not used yet.
|
|
38
|
+
- **A money unit listed twice is refused in plain words.** Units that are the same once marks (`**`, `__`) and spaces are removed (`**pp**` and `pp`) now stop at the $0 signing pre-flight naming the fact and both units, instead of bareguard's raw error; bareloop's own partial copy of that rule is gone.
|
|
39
|
+
|
|
40
|
+
### Fixed
|
|
41
|
+
|
|
42
|
+
- **A page line with a very long run of digits no longer slows drafting.** The price-mark read, its trailing-mark trim and the comma-decimal page check are now linear (a 40,000-digit line took about 2 seconds, now milliseconds); what they return is unchanged.
|
|
43
|
+
- **A page that loads only its menus, or times out, is fetched up to 3 times.** A web address whose page came back as just the site's header and menus (seen on a Dell laptop page, fine on the next try) used to stop drafting at once. Now the whole fetch is tried again, with a fresh browser and a 3 second pause, up to 3 attempts in all; only a menus-only page or a timeout is retried (a refused address, a bot check, any other load error or an empty page stops on the first try). If all 3 fail the stop reads the same with "(tried 3 times)" added. One attempt still waits at most 90 seconds, so a page that keeps timing out can take about 4.5 minutes before it stops.
|
|
44
|
+
- **A money fact's decimal mark is picked by code from how the page writes its prices.** The mark comes from the amounts next to the fact's currency sign (a comma and two digits, like "1.058,47 €"), so a fact the page-map AI signed without a decimal, or with the wrong one, still reads (live: Dell de-de laptops).
|
|
45
|
+
- **Panel: a `~` rule line in "The job" box shows `~` in the gutter, as fwdloop does.** Numbering is unchanged.
|
|
46
|
+
- **A price form that reads no amount on the page is dropped before the same-value rule.** A unit such as "ohne MwSt." sitting alone on its own line has no amount next to it, so it is now dropped first and the form that does read ("€") is kept, instead of the whole price fact falling to Not checked (seen live on Dell de-de laptops).
|
|
47
|
+
- **A page that loads only its site menus is re-read on the same open page until it settles.** The page is read again every 2 seconds for up to 20 seconds before a try counts as failed. A failed fetch now records what each try saw (size, time, the first 300 characters, secret-masked) in the draft log.
|
|
48
|
+
- **A blank word in the AI's page answer is left out.** An empty or spaces-only entry in a fact's words, currencies or units names nothing; it is dropped when the answer is read, with no note, and a list left empty counts as absent. It no longer shows as `"" is not written on the page.`.
|
|
49
|
+
- **A `~` rule whose fact is checked no longer also shows under Not checked.** The blank unit above made the page-read note unreadable to the splitter, so a kept fact's word notes were listed as Not checked; they now sit under how the page was read. A rule whose fact really drops still shows under Not checked.
|
|
50
|
+
|
|
8
51
|
## [0.49.0] - 2026-10-26
|
|
9
52
|
|
|
10
53
|
### Added
|
package/bareloop.context.md
CHANGED
|
@@ -159,6 +159,7 @@ minting claim, or the shell-owned retry cap — all unknown-field reds.
|
|
|
159
159
|
| `closeTimeoutMs` | optional integer ms `>= CLOSE_TIMEOUT_FLOOR_MS` (120,000 — hamr's arbiter floor, 2026-09-07) | PRD item 27/M3's SIGNED override for the close's own per-stage wall-clock cap. Absent (the normal case): the run autosets it from a $0 seed timing pass — `max(FLOOR, K × slowest measured stage)`, `K = 5` (hamr, 2026-09-07: "2 and 5 are fine"). Present: the operator's own number wins outright and may legally sit ABOVE *or below* the autoset estimate (the rates-passthrough shape, F113 — never tighten-only). Arbiter territory exactly like `budgetUsd`/`maxWallMs`/`close[].sha256`: the authoring pipeline's `assembleSpec` refuses a draft carrying it |
|
|
160
160
|
| `model` | optional non-empty string, the exact model id of a line ticked in Settings > Providers | the WORKER's model. A job carries its own model (P8: bareloop has no default); a spec signed before that (no `model`, perhaps no `baseUrl`) runs on the line `--model <id>` names (plus `--provider <KEY>` when two keys tick it) — the signed hash is untouched. Present, it wins over a `--model` flag outright, and a flag naming a different id is refused (`resolveWorkerModel`, `src/job.js`) rather than silently overridden. Part of the signed hash like every other field. Worker only — the JUDGE's model comes from the `judge` row below, which DEFAULTS to this same worker model |
|
|
161
161
|
| `thinking` | optional boolean | the job's "Thinking on" tick (P8): absent = off, and an old spec keeps the hash it always had; present it is signed like `model`. Covers DRAFTING and the rubric JUDGE, and makes every WORKER call think (see "Thinking on" below) |
|
|
162
|
+
| `handoffNote` | optional boolean | the handoff note switch: absent = ON, only an explicit `false` turns it off; an old spec keeps the hash it always had, and a present value is signed (the switch enters `jobSpecHash` and `workflowKey`; the note's text never does). Not shown in the panel. See "Handoff note" below |
|
|
162
163
|
| `judge` | optional `{provider, model}`, both non-empty; `provider` from the `PROVIDERS` menu | the signed JUDGE override (PRD item 32). Absent, the judge resolves to this job's own `provider`/`model` (`resolveJudge`) — which is what lets a non-Anthropic job judge without a second account. Present, it pins a judge deliberately different from the worker (an independent reader). Both halves are required together: a judge with a provider and no model is an identity nobody signed. Part of the signed hash, so changing it kills the signature and forces recalibration. Unknown nested keys red — no smuggling level exists in a signed spec. The drafting agent cannot express it: naming your own examiner is arbiter territory |
|
|
163
164
|
| `writeScope` | array of contained globs | the operator's outer fence; the plan's own scopes must fit inside it, same containment code |
|
|
164
165
|
| `steps` | RETIRED | operator-authored `steps[]` was deleted (PRD v1.32); a spec carrying it reds `shape-retired:steps` by name rather than half-running |
|
|
@@ -363,7 +364,7 @@ middle writes; `validatePlan` gates it against the SIGNED job spec before tokens
|
|
|
363
364
|
| `steps[].model` | optional; `sonnet` (`STEP_MODELS`) | the step's model TIER — a menu, never a model string the agent spells (`sonnet` is a schema token meaning this job's worker model; the runner maps it, there is no tier table). `opus` is deliberately absent: reserved for work the human assigns, never plan-selectable; `haiku` was removed 2026-08-06 as a reversible ATTRIBUTION PROBE (F87, see `STEP_MODELS`), so the menu is one entry deep and the field is no longer offered in the drafting prompt. The field and its validator branch STAY: `model: "sonnet"` still validates, a stored bridge declaring it still loads, and restoring haiku is a one-token edit — this is not a finding that haiku is incapable. **The narrowing binds only what the AGENT may express.** Which real model a tier maps to, and what the caller runs as its own default worker model, stay the OPERATOR's: `providerFor` is yours, and the in-repo runner's `--model haiku` probe knob is untouched (PRD v1.36) — the runner's tier map is deliberately WIDER than the plan menu. Off-menu reds `invalid-value`. A step naming a tier when the caller supplied no `providerFor` factory is an `interpreter-red` STOP, never a silent run on the default tier |
|
|
364
365
|
| `steps[].attempts` | optional; int `>= 1` | **RETIRED and INERT (F79) — it bounds nothing.** A step's iterations are governed by the STRIKE LADDER (below), which is shell-owned and inexpressible from the plan. The field is no longer offered in the drafting prompt and the runner ignores it; it is deliberately still ACCEPTED, because stored bridge plans carry it and a plan minted under one runner's number must not red under another's. The shape is still checked (a known field holding garbage stays a `bounds` red); the old `<= capRuns` ceiling is gone with the cap it named. It was previously TIGHTEN-only — which meant a step that needed MORE iterations could not ask, and drafters measurably tightened it instead (F77) |
|
|
365
366
|
| `steps[].scope` | optional; one value from the SAME menu `tree-changed` uses | narrows this step's live WRITE fence to a subset of the signed `writeScope` — chosen from the offered scope menu (below), never authored. Off-menu reds `invalid-value` carrying the menu |
|
|
366
|
-
| `steps[].exit` | 1..2 items (`MAX_EXITS_PER_STEP`), ALL must pass (AND-only, no OR/NOT) | closed menu (`EXIT_TYPES`): `artifact-written(path, pattern?)` · `tree-changed(scope)` · `json-valid(path)` · `check-passes(name)`. **`tree-changed.scope` is a MENU, not a glob the agent authors** — the runner enumerates the signed fence entries plus the real directories beneath them (shallowest-first, capped at `MAX_SCOPE_MENU`=24; `legalScopes` in `src/plan.js`), `planPrompt` lists them verbatim, and `validatePlan` accepts membership only — the SAME array on both sides, so what was offered is what is accepted; omitted, it derives from `writeScope` alone — never a free-text fallback. An off-menu value that escapes the fence still reds `scope-escape` (the ledger's attribution class), an in-fence unoffered value reds `invalid-value` carrying the menu. `runPlan` emits `scope-menu {offered, truncated, offerableCount?, cap?}` so a capped menu is never silently complete. `check-passes` must name a stage on the close's DERIVED menu (`check-unknown` red names the offered menu — no operator authors this list, it comes straight from `checkMenu(close)`); on a write-granted step it must be paired with `tree-changed` (`exit-illegal` — the seed tree is green, a lone check would pass untouched, F17/F46). **`check-passes` also requires a write-class verb (`write`/`edit`) on the SAME step** (`exit-illegal` — BREAKING for plan authors: a read-only "verify" step carrying a check used to validate and no longer does). A failing check's gap is re-delivered to that step's OWN worker, so a step holding a check must be able to act on it; a read-only one is a mailbox with no hands and stalls to cap on a byte-identical gap (measured on 4 of 4 drafted plans). The check belongs on the step that fixes; the run's final verification is the operator's close, which the agent never authors. The rule is stated identically in the drafter prompt and the validator, so the two can never disagree — and it is suppressed when `tools` failed to parse (the step's hands are unknowable then, and the real defect already redded: one defect, one red). `artifact-written.pattern` must compile AND survive a ReDoS shape check — an unbounded quantifier over a group that itself repeats unboundedly (`(a+)+`, `(\d*)*`, even wrapped: `((a+))+`) is an `invalid-value` red (F49, catastrophic-backtracking footgun; rewrite without a repeated group inside a repeat). Exits verify FORM, not truth — progress gates; the operator's close stays the one arbiter |
|
|
367
|
+
| `steps[].exit` | 1..2 items (`MAX_EXITS_PER_STEP`), ALL must pass (AND-only, no OR/NOT) | closed menu (`EXIT_TYPES`): `artifact-written(path, pattern?)` · `tree-changed(scope)` · `json-valid(path)` · `check-passes(name)`. **`tree-changed.scope` is a MENU, not a glob the agent authors** — the runner enumerates the signed fence entries plus the real directories beneath them (shallowest-first, capped at `MAX_SCOPE_MENU`=24; `legalScopes` in `src/plan.js`), `planPrompt` lists them verbatim, and `validatePlan` accepts membership only — the SAME array on both sides, so what was offered is what is accepted; omitted, it derives from `writeScope` alone — never a free-text fallback. `exit` is REQUIRED on every step: the planner prompt says so and shows one legal example (`EXIT_EXAMPLE`, `src/plan.js`), and the `missing-required` red carries the same example (F254). An off-menu value that escapes the fence still reds `scope-escape` (the ledger's attribution class), an in-fence unoffered value reds `invalid-value` carrying the menu. `runPlan` emits `scope-menu {offered, truncated, offerableCount?, cap?}` so a capped menu is never silently complete. `check-passes` must name a stage on the close's DERIVED menu (`check-unknown` red names the offered menu — no operator authors this list, it comes straight from `checkMenu(close)`); on a write-granted step it must be paired with `tree-changed` (`exit-illegal` — the seed tree is green, a lone check would pass untouched, F17/F46). **`check-passes` also requires a write-class verb (`write`/`edit`) on the SAME step** (`exit-illegal` — BREAKING for plan authors: a read-only "verify" step carrying a check used to validate and no longer does). A failing check's gap is re-delivered to that step's OWN worker, so a step holding a check must be able to act on it; a read-only one is a mailbox with no hands and stalls to cap on a byte-identical gap (measured on 4 of 4 drafted plans). The check belongs on the step that fixes; the run's final verification is the operator's close, which the agent never authors. The rule is stated identically in the drafter prompt and the validator, so the two can never disagree — and it is suppressed when `tools` failed to parse (the step's hands are unknowable then, and the real defect already redded: one defect, one red). `artifact-written.pattern` must compile AND survive a ReDoS shape check — an unbounded quantifier over a group that itself repeats unboundedly (`(a+)+`, `(\d*)*`, even wrapped: `((a+))+`) is an `invalid-value` red (F49, catastrophic-backtracking footgun; rewrite without a repeated group inside a repeat). Exits verify FORM, not truth — progress gates; the operator's close stays the one arbiter |
|
|
367
368
|
|
|
368
369
|
**A step has exactly ONE check slot — plan for it.** The three exit rules above compose into
|
|
369
370
|
a ceiling worth stating on its own, because it decides what a plan can enforce *during* a
|
|
@@ -644,6 +645,8 @@ plan with the first leg's spend carried as prior spend and `offerQuestions: fals
|
|
|
644
645
|
plan's open questions) are a separate, unchanged mechanism: they are asked before drafting, about the plan; try-3 questions
|
|
645
646
|
are asked after two failed drafts, about a job line.
|
|
646
647
|
|
|
648
|
+
**Handoff note (per job; hamr 2026-10-28, F253).** When a worker's ask ends, code records the files it READ (the allowed `shell_read` and `ctx_get` calls; scout, step and fix asks all feed it). The NEXT step or fix ask of the same run, a retry of the same step included, gets a note appended to its first user prompt under the fixed heading `== Files earlier workers in this run read (a map only; contents are not included; line ranges as ctx_recall prints them) ==`, one line per file: `- <path> (<N> lines): <symbol> <a>-<b>, ...`. Code writes it, never a model; it names files and carries no content. The symbol map is the LiteCtx index's named chunks, refreshed before the note is built when the worker holds a retrieval verb, and dropped for a plain line count when the index is missing (LiteCtx indexes git-tracked files only) or older than the file. The scout and the drafter are never handed a note. Capped at 8,000 characters (`HANDOFF_CAP`, src/handoff.js): the oldest paths go first with a `[trimmed: N older path(s)]` marker. The arbiter's books (`.smoke`, `.litectx`, the gate audit), `.git`, `.bareloop` and anything outside the job root are never named. The store lives in memory for one leg: a resumed leg starts empty, so its first ask gets no note and later ones do. Each note given is one report-only spine record `{type:'handoff-note', phase, iteration, chars, paths}` (a path COUNT, never a name; catalogue entry `handoff-note` under the spine records). Switch: the signed spec's optional boolean `handoffNote`, absent = on, `false` = off (no note, no record).
|
|
649
|
+
|
|
647
650
|
**Thinking on (per job; hamr 2026-10-11).** The New job card has a "Thinking on" tick under Model, unticked by default, saved in the SIGNED job as the optional
|
|
648
651
|
boolean `thinking` (absent = off; an old spec and any unticked job keep the hash they would have had; a ticked job's `jobSpecHash` and `workflowKey` differ). It
|
|
649
652
|
covers DRAFTING (scout, confirm, author, revise, structure retries) AND the rubric JUDGE, and as the think-everywhere override it makes every WORKER call think too (below). A Reuse card does not
|
|
@@ -1362,7 +1365,7 @@ measured correctness point); and `validatePlan` reds `read-blind` on any step gr
|
|
|
1362
1365
|
without `recall` and `get`. Where only the DIFF runs, nothing is capped (a first read delivers
|
|
1363
1366
|
whole, whatever the size), an unchanged re-read re-delivers rather than pointing, and G1 does not
|
|
1364
1367
|
exist — G1 is the cap's compensation, and an arm that caps nothing has nothing to compensate for.
|
|
1365
|
-
The ledger is per worker, so
|
|
1368
|
+
The ledger is per `ask()`, not per worker: every `ask()` builds a fresh transcript, so the ledger resets at the start of each one (F252; a later attempt's re-read gets the bytes, never a pointer for bytes its model never saw), while an `askFrom` continuation keeps the same transcript and its ledger. The run-level MEMORY-CACHE counts do not reset. On the native (clipipe) surface a CAPPING
|
|
1366
1369
|
arm replaces the CLI-display cap rather than stacking on it; a non-capping arm leaves that wrapper
|
|
1367
1370
|
installed *inside* the shim, so native never loses its bound. Default-flip pending a paid contrast;
|
|
1368
1371
|
see CHANGELOG for the replay numbers behind it.
|
|
@@ -2737,6 +2740,16 @@ unreferenced loose objects are left. Gitignored files inside the fence are seen
|
|
|
2737
2740
|
changed nothing in scope emits nothing, and a failed capture emits `gitError` with empty lists: a record,
|
|
2738
2741
|
never a verdict, and it never throws. No prompt carries it; the learnings cards read it ("What changed").
|
|
2739
2742
|
|
|
2743
|
+
#### `handoff-note` — a note handed to a worker ask (`src/handoff.js`, `src/planrun.js`)
|
|
2744
|
+
|
|
2745
|
+
One report-only spine record per handoff note given: `{type:'handoff-note', phase, iteration, chars, paths}`.
|
|
2746
|
+
`phase` is `step:<id>` or `fix`; `iteration` is the round iteration at the ask; `chars` is the note's length in
|
|
2747
|
+
characters (at most 8,000); `paths` is a COUNT of the files the note lists after any trimming, never a name.
|
|
2748
|
+
`runPlan` writes it right before the ask runs, once per step or close-fix ask that actually receives a note: an
|
|
2749
|
+
ask with nothing yet read gets no note and no record, and the scout and the drafter are never handed one. It
|
|
2750
|
+
carries no cost fields (not a spend record) and no verdict. The switch is the signed spec's optional boolean
|
|
2751
|
+
`handoffNote`: absent = on, `false` = off (no note, no record). The prose rules are under "Handoff note".
|
|
2752
|
+
|
|
2740
2753
|
### `replayRun(spineEvents, auditEvents?, { runId? })` / `formatReplay(summary)` / `summarizeForAllLine(summary)` / `formatAllLines(entries)` — `src/replay.js`
|
|
2741
2754
|
|
|
2742
2755
|
`summarizeForAllLine(summary)` reduces one `replayRun` summary to one `--all`/directory-
|
|
@@ -3539,7 +3552,7 @@ key you want first (the panel picks the row by the Model menu).
|
|
|
3539
3552
|
lowered from the original 2s per F195 — `listRuns()` re-replays every archived spine on
|
|
3540
3553
|
every call, ~457ms CPU at 250 rows, open/escalated), except the tick right after the open
|
|
3541
3554
|
run stops being live, which forces one immediate list refresh so that row's glyph doesn't
|
|
3542
|
-
wait up to 10s. Both fetches skip re-rendering when the payload's JSON is byte-identical to
|
|
3555
|
+
wait up to 10s. The Runs list read is also the panel's heartbeat for the topbar online dot (see "Panel topbar"). Both fetches skip re-rendering when the payload's JSON is byte-identical to
|
|
3543
3556
|
the last one, restore each pane's scroll position across a poll-driven rebuild, and pause
|
|
3544
3557
|
while the tab is hidden (`document.hidden`), catching up immediately on
|
|
3545
3558
|
`visibilitychange`. The Audit tab does **not** join this loop — it refetches only when
|
|
@@ -4449,7 +4462,7 @@ A **Rubric** job whose first Input is the full path of a FILE (not a repo folder
|
|
|
4449
4462
|
- **Panel wording.** `stageQuestionText` words a rubric-step stage "line N — does its output pass the line's checks?". The worker brief also tells the worker to copy every number, time and price in a claim exactly as the input writes it ("9:27 AM", not "09:27").
|
|
4450
4463
|
- **Shown == run (run mv5bk400).** The plan card after drafting is built from the signed close (`checksOfClose`, code-written sentences), not from the confirm turn's prose. A countable part may list the confirmed checks it carries out in `covers` (the composer prompt numbers them `#n`); `reconcileRubricPlan` moves every confirmed check no part covers to Not checked ("... — nothing in this close counts it or checks it against a quote"). `signRun` calls `planMatchesClose(session.state.finalPlan.checkItems, closeDecl)` and refuses, spawning nothing, when the two differ. `minClaims` / `maxClaims` (parts with `value` + `source`) count the claims listed under an input: `flattenStep` takes the count from the file's own `cites.<label>` list as the field `claims:<label>` and bareguard's `min`/`max` compares it. A free-text note is never a check.
|
|
4451
4464
|
- **Labels.** A text close carries `genre: "TEXT"` (`genreForLang`; `TYPES` is for code languages, and a genre must match its language); its spine records carry no `judgedCount` (no judge ran); the progress list words a file job's steps from `FILE_JOB_STEP_LABELS` ("copying input files", "reading input files").
|
|
4452
|
-
- **Panel topbar.** `bareloop · v<version> · automate a job, verified`: the version is bareloop's own package.json, read once when the panel starts and templated into the page when it is served (`__BARELOOP_PANEL_VERSION__`), so it is the version the process runs, not what package.json says now.
|
|
4465
|
+
- **Panel topbar.** `bareloop · v<version> · automate a job, verified`: the version is bareloop's own package.json, read once when the panel starts and templated into the page when it is served (`__BARELOOP_PANEL_VERSION__`), so it is the version the process runs, not what package.json says now. Right of the host line and left of Settings sits the online dot (`#online-dot`): the Runs list read (the 10 s poll, no new endpoint or timer) paints green `online` on any HTTP reply, even an error status or a 200 whose body will not parse, and red `offline` only when the read fails with no HTTP status (the panel process is gone); a page render error after a good read never paints it offline.
|
|
4453
4466
|
- **After drafting, the code-worded card is the only plan on screen (run mv5e1ktb).** The confirm turn's plan bubble is the drafter's own prose (written before any close existed) and used to stay in the thread above the code-worded card; when the rubric card is ready the earlier `kind:'plan'` messages are dropped. `partSentence` now reads "1 line" / "1 word" for a count of one.
|
|
4454
4467
|
- **Each `~` guardrail is its own row on the plan card.** `planFromSpec` / `planFromConfirm` lines carry `rules: string[]` (the line's own `rules`, else the joined `rule` split on "; "); `renderJobPlan` draws one `~ rule` row per rule under its numbered line, in the plan card and the Job tab alike (one renderer). Gutter numbers stay on job lines only.
|
|
4455
4468
|
- **The review door's held line is true for a no-judge close.** Credit is held by VERDICT CLASS (`quarantinesCredit`: soft-green), whether or not a judge ran; the door now says "this is a rubric (soft-green) job, so its green earns NO reuse and NO learning credit until you accept it, whether or not a judge ran". Wording only; `bridges.js`/`reuse.js`/the Reuse refusal still say "rendered by the judged floor".
|
|
@@ -4457,15 +4470,17 @@ A **Rubric** job whose first Input is the full path of a FILE (not a repo folder
|
|
|
4457
4470
|
|
|
4458
4471
|
### Required facts — a line that finds, lists or looks something up (Part 1b, `src/facts.js`, `docs/product/ITEM33-BUILD.md` "Addendum 2026-10-13" and "Part 1c", PRD item 33 RF1–RF22)
|
|
4459
4472
|
|
|
4460
|
-
Check what the person asked for, not what the worker chose to write. bareloop needs bareguard `^0.
|
|
4473
|
+
Check what the person asked for, not what the worker chose to write. bareloop needs bareguard `^0.27.0` (`cited` + `decides`, bind-only and `text` decides, word-edge anchors; 0.24 lets money currency/unit be lists, ruling #65; bareloop facts now carry them, see "Currency and unit lists" below; 0.25 returns `full.evidence`, the spans the Result tab marks, see `rubric-evidence`).
|
|
4461
4474
|
|
|
4462
4475
|
- **The part.** A `rubric-step` stage's `params.parts` may hold ONE part of `class: "fact"` (a line that finds, lists or looks up): `{ text, class: "fact", source: <input label>, facts: [{ name, shape, unit? | currency?, phrase?, anchor?, until?, rule?, aiProposal? }], count?: { min?, max? }, rules?: [n], covers?: [n] }`. `shape` is `money | number | date | time | phrase | text`; `rule` is `{ op: lt | lte | gt | gte, value }` or `{ op: "between", lo, hi }` (not on `text` or `phrase`); `money` names at least one of `unit` (the input's own words, e.g. `"US dollars"`) or `currency` (`$ € £`), and may name both, each one value or a list (below); `phrase` carries the fixed `phrase` the quote must contain; `anchor` / `until` are labels copied VERBATIM from the input. A fact name is letters, spaces, `_` or `-` only (it is written into the claim text bareguard scans for numbers). A line with a fact part has no word, section or claim-count parts (a drafting red). Code fills `tested` (the early-test evidence) and `sample` (what the drafter saw of a big input) into the signed part; a model-written one is replaced.
|
|
4463
4476
|
- **The step file.** `output/steps/<n>.json` of a facts line is `{ "results": [ { "quote": "...", "values": { "<fact name>": "<value as the quote writes it>" } } ] }` — no free text, no `cites`. ONE quote per result holds all its facts, so a worker cannot mix a price from one result with a time from another. `buildStepSpec` makes one bareguard `cited` check with `decides` (the fact's index is its `d<j>` key; a phrase fact is a presence decide and takes no value). The claim text is written by CODE from the values (`name: value; ...`); a `count` becomes `min` / `max` on the number of results. Every value is compared by shape and exactly (`8:15 AM` equals `08:15`, `389` equals `389.00`); a red names the result and the fact in plain words (`plainFactItem`). A JSON number in `values` is read as the string it prints as.
|
|
4464
4477
|
- **No record cutting (Part 1c).** A fact part carries no `record`, `tested` or `sample` (a `record` field is an unknown-field red). The worker's brief says "one quote per result, copied from that result's own text" (bareguard's quote cap of 4000 characters stays its own). Drafting does not grade: it only proves each fact CAN be checked (below).
|
|
4465
4478
|
- **Repeat rule (Part 1c M1, M4).** On a fact line asking for N results (`count.min`), `checkFactWords` (`src/factwords.js`, the one owner) refuses at $0 an anchor label the label list counts fewer than N times (`rubric-fact-label-rare`) and a `phrase` fact whose words `countPhrase` finds in the input fewer than N times (`rubric-fact-phrase-rare`); count 1 or none keeps a once-only one legal. `RUBRIC_RULES` states both.
|
|
4466
4479
|
- **The look, then the draft (Part 1c; the default look is now the page-word map, next bullet).** For a rubric job on files, `authorCloseForJob` runs the look (`lookFn`, default `runPageMap`; the older search-and-read `runInputLook` in `src/authorscout.js`, pure parts in `src/inputlook.js`, is unwired from the default path) on the frozen input text BEFORE the confirm turn and the draft, when a `provider` is present (`lookFn: null` = no look; a panel test that replaces `generate` gets none unless it passes `lookFn`). Read-only by construction: tools `search_input` / `read_input` over in-memory text, `LOOK_ROUNDS` 8, a reserved final round whose only tool is the strict answer form `report_look`, spend metered into the drafting book (`calls` absorbed like the repo scout's). Its report (facts with a label picked from the list, prose lines, not-found entries) is verified by code (`verifyLookReport`: a label off the list, an unknown shape/line/input, or a phrase not in the source is moved to not-found, named) and rendered into the drafter's prompt (`renderLookReport`); a failed or reportless look is an ABSENT survey and stops drafting at $0 (`scout-absent`, "the first look at your repo or input did not complete"). Every place, date or name in the job line is a fact too, bound to the label before it (a direction = phrase facts `Leaves <place>` / `arrives at <place>`); prose lines and their `~` limits are not looked up.
|
|
4467
|
-
- **The page-word map (idea A core, `src/pagemap.js`, `src/pagerules.js`, `docs/product/ITEM33-BUILD.md` "Addendum 2026-10-18 — Idea A core").** The default `lookFn` is `runPageMap`: ONE AI call per page input (the job's drafter identity, thinking off, booked per call into `draft-log.jsonl`, cap checked before each call) maps the job to the page's OWN words as `{"facts":[{name, from, shape: place|money|time|phrase, words, currency?, unit?}]}`; it takes the old look's arguments and returns the same envelope. Plain code then keeps or drops each word (`applyPageRules(text, mapping, jobLines)` -> `{ facts, dropped }`, pure, ported from the frozen POC): found-on-page (count >= 1), N2 (a label written 2+ times inside one page line is unusable), R1 (a second label stays only if it reads the same values as the first), U1 (a label the page writes AFTER the number, "EUR 490 total", becomes a unit; a label with no number either side is dropped), R1L (a unit/currency form stays only if it reads the same numbers as the primary form; units first; before R1L the forms are sorted by code - a sign is a currency, any other form a unit, whichever box the AI used), S1 (a fact name that counts results is refused; two facts may not share shape AND label). After the rules, `dryReadMoney` (`src/pagedry.js`, called by `runPageMap`) grades an honest claim on every result line with the run's own checker; a money fact that reads none is left under Not checked (`reads-no-result`); then `dryReadPhrases` reads each kept phrase fact against those same result lines (the lines the job's kept money facts read) and drops a phrase found in none of them whole as `phrase-no-result` (Not checked: `"Rome" is on the page but in none of its results, so it is not checked.`); with no kept money fact the result lines are unknown and phrase facts pass untouched. The AI never grades; the answer is read strictly (no JSON repair): a malformed or truncated answer is retried ONCE, twice is the plain stop "The AI's answer about the page was not readable twice. Nothing was signed." (an ABSENT survey; a draft is not a run, so no Resume); one retry on a transport error (booked unpriced, so `spendComplete=false`) or a 429 (the vendor's stated wait). The scrubbed raw answer rides each call into `draft-log.jsonl` (`call.raw`), unsigned, so a run can be replayed at $0. A drafted fact may use only words the map KEPT: a signed anchor, closing label, unit or currency that was dropped is the red `rubric-fact-word-dropped` with the drop's reason, and an anchor must be a kept label (`rubric-fact-label-off-list`, now against the kept set).
|
|
4468
|
-
- **
|
|
4480
|
+
- **The page-word map (idea A core, `src/pagemap.js`, `src/pagerules.js`, `docs/product/ITEM33-BUILD.md` "Addendum 2026-10-18 — Idea A core").** The default `lookFn` is `runPageMap`: ONE AI call per page input (the job's drafter identity, thinking off, booked per call into `draft-log.jsonl`, cap checked before each call) maps the job to the page's OWN words as `{"facts":[{name, from, shape: place|money|time|date|number|phrase, words, currency?, unit?, lang?, decimal?}]}`; it takes the old look's arguments and returns the same envelope. Plain code then keeps or drops each word (`applyPageRules(text, mapping, jobLines)` -> `{ facts, dropped }`, pure, ported from the frozen POC): found-on-page (count >= 1), N2 (a label written 2+ times inside one page line is unusable), R1 (a second label stays only if it reads the same values as the first), U1 (a label the page writes AFTER the number, "EUR 490 total", becomes a unit; a label with no number either side is dropped), R1L (a unit/currency form stays only if it reads the same numbers as the primary form; units first; before R1L the forms are sorted by code - a sign is a currency, any other form a unit, whichever box the AI used), S1 (a fact name that counts results is refused - "last updated" / "last modified" name when a thing changed and are not counting names; two facts may not share shape AND label). After the rules, `dryReadMoney` (`src/pagedry.js`, called by `runPageMap`) grades an honest claim on every result line with the run's own checker; a money fact that reads none is left under Not checked (`reads-no-result`); then `dryReadPhrases` reads each kept phrase fact against those same result lines (the lines the job's kept money facts read) and drops a phrase found in none of them whole as `phrase-no-result` (Not checked: `"Rome" is on the page but in none of its results, so it is not checked.`); with no kept money fact the result lines are unknown and phrase facts pass untouched. The AI never grades; the answer is read strictly (no JSON repair; a blank entry in `words`, `currency` or `unit` - empty or only spaces - is left out at parse with no note, a list left empty is absent, and the rest of the fact stands): a malformed or truncated answer is retried ONCE, twice is the plain stop "The AI's answer about the page was not readable twice. Nothing was signed." (an ABSENT survey; a draft is not a run, so no Resume); one retry on a transport error (booked unpriced, so `spendComplete=false`) or a 429 (the vendor's stated wait). The scrubbed raw answer rides each call into `draft-log.jsonl` (`call.raw`), unsigned, so a run can be replayed at $0. A drafted fact may use only words the map KEPT: a signed anchor, closing label, unit or currency that was dropped is the red `rubric-fact-word-dropped` with the drop's reason, and an anchor must be a kept label (`rubric-fact-label-off-list`, now against the kept set).
|
|
4481
|
+
- **Page forms: `lang` and `decimal` (bareguard 0.27, `src/facts.js`, `src/pagerules.js`).** A `date` fact may sign `lang` (`en de fr es it pt nl`: the language of the month names the page writes; absent = ISO `2026-10-26` only) and a `number` or `money` fact may sign `decimal` (`"."` or `","`; absent = `.`). Both ride the signed decide unchanged and are refused on any other shape. The worker writes the CANONICAL value for such a fact (a date as `YYYY-MM-DD`, an amount with a point and no thousands marks); code writes the claim text as the quote spells the value (`full.evidence`'s value span from a first check of the same file, then a second check with the text written so), so bareguard's number scan compares like with like. Only a fact that signs `lang` or `decimal` takes the second pass; every other fact's claim text is the worker's value, as before. Before a fact is signed, page rules drop it to Not checked when a signed `lang` has no full month name of that language on the page (`lang-not-on-page`) or a signed `decimal: ","` has no comma-decimal amount on the page (`decimal-not-on-page`; a thousands-grouped count such as `133,330` is not one).
|
|
4482
|
+
- **Sign by page form, and the dry read (F249, `src/pagerules.js`, `src/pagedry.js`).** A currency sign is filed by how the page writes it next to the number, in the lines that hold the fact's label (the whole page when it has none): glued to the number (`29,99€`, `€399`) = `currency`, after a space (`29,99 €`) = `unit`, both when the page writes both (bareguard 0.27 accepts the same symbol in both boxes and counts the same amount as one price); the box the AI listed it in does not matter. `dryReadMoney` finds candidate lines in every form the fact signs (a decimal comma, `.` or space thousands, a glued or spaced sign) and passes the checker the canonical amount.
|
|
4483
|
+
- **Currency and unit lists (idea A core, `src/facts.js`).** A money fact's `unit` and `currency` may each be one string (every spec signed before lists) or a non-empty list: at most 3 currencies (`$ € £` only; a code like `EUR` is a unit) and 10 units, none repeated (two units that are the same once `**`, `__` and extra spaces are removed are one unit, bareguard 0.26+: the signing pre-flight asks bareguard at $0 and, when it refuses such a list, says in plain words which fact lists the same unit twice and to keep one - `dupUnitWords`, `src/rubricstep.js`), a unit at most 100 characters, enforced by our own plain reds before bareguard is asked. A string reads exactly as a one-element list and is never rewritten, so an old signed spec keeps its bytes and hash. The first listed form is the primary one in the plan row and the worker brief; others read "or". `checkFactWords` requires EVERY listed unit and sign to be on the page.
|
|
4469
4484
|
- **No silent drop (idea A core, `src/pagedropwords.js`, `withDropNotes` in `src/rubricstep.js`).** Every word, fact or `~` rule the page rules drop is shown as Not checked with a plain sentence from ONE table (no other file writes a drop reason). Before validation `withDropNotes` appends to the declaration: `closeDecl.refused` `{ line, rule, reason }` for a dropped fact whose `~` rule no part carries (never a line-level refusal; a rule the drafter already listed is not listed twice), and one line in `closeDecl.notes` for any other drop, including a word cut from a fact that is still checked. Those word-level lines are not "Not checked": `splitReadNotes` / `isReadNote` (`src/pagedropwords.js`) sort a row whose every sentence only says which written form of a still-checked fact was not used (not on the page, listed twice, not the same values, list limits, and an `s1` copy of a fact that is still signed) into `readNotes`, shown in their own fold "How the page was read · N" right after Not checked (plan card, Job tab, Result tab `readNotes`, CLI confirm menu) and not counted in it; a whole fact left out (`no-label`, `reads-no-result`, `phrase-no-result`, an `s1` copy of an unsigned fact) stays Not checked. The signed fact names come from `signedFactNames(closeDecl)` (older specs too) or the look at the confirm turn (`plan.signedFacts`). The confirm card gets the same lines (`plan.notChecked`) before drafting is paid for, and the drafter's look block says `NOT CHECKED (rule n)` / `LEFT OUT`. Nothing about this changes a signed spec's verdict rules; it is the Not checked list, in the person's words.
|
|
4470
4485
|
- **Time facts get the dry read (F236/F237, `dryReadTimes` in `src/pagedry.js`, called by `runPageMap` between the money and phrase dry reads).** For each kept time fact with a label, the candidate lines are every page line holding a label word with a clock time (H:MM or HH:MM, optional AM/PM) somewhere after it; each is graded as an honest claim (quote = the line, value = its first time after the label, fact `{shape:'time', anchor: label}`, no window) by the run's own `gradeStep`. A fact with no green line is dropped whole as `reads-no-time` and stays Not checked: `the page never shows a time right after "<label>", so it is not checked.` (rendered like its neighbours: `line 1: "<the ~ rule>" — the page never shows a time right after "Departure time", so it is not checked.`). It catches an impossible label only; a label that reads a wrong time is kept and left to the person at Accept. Other shapes, and a time fact with no label word, pass through untouched.
|
|
4471
4486
|
- **Labels are picked, never typed (`src/labelscan.js`).** `scanLabels(text)` lists, per shape (money, number, date, time, text), the words right before each value with counts (top 40 per shape; one generic scan, no per-site table; a page reader's `[ref=N]` tags are ignored). `labelOnList(scan, shape, idOrText)` is the one test (id or exact words, white-space blind). The look and the drafter pick labels only from the list shown in the prompt (`renderLabelList`). Fact-line reds are plain sentences; the confirm step and the drafter share one rule text (`RUBRIC_RULES`), and the drafter's per-shape field guide is generated from bareguard's `rubricVocabulary`.
|
|
@@ -4474,7 +4489,7 @@ Check what the person asked for, not what the worker chose to write. bareloop ne
|
|
|
4474
4489
|
- **The prose step.** A line that writes keeps its word / section / line counts. When any fact line comes BEFORE it, code puts one `numbersFromFacts` part on it (`withFactBindings`; the model never writes it, and a missing or wrong one is a drafting red): every number in `text` must appear in a quote of those fact lines' step files (bareguard's `numbersInQuote`: token match, not canonical, so `v0.41.0` is one token). The card says, under Not checked, `line N: what the text says — you judge it at Accept`. At the close, a tied earlier line whose step file does not exist yet (the seed read, before any worker wrote) is a normal red ("line N's answer is not there yet"), never an instrument stop; only an unreadable file is a stop.
|
|
4475
4490
|
- **The plan card.** One code-worded row per fact under its line, read by the one reader (`checksOfClose` / `factRows`) the confirm card, the Job tab (`planFromSpec`) and the sign-time `planMatchesClose` share, e.g. `fact · price — money in US dollars, at most 450 US dollars, after "Price", quoted from "Flights"`, then the count row. A `~` rule the drafter listed as not checked reads `line N: "<rule as written>" — <reason>`.
|
|
4476
4491
|
- **The worker brief.** `rubricGoal({ ..., closeDecl })` adds a code-written brief per line (`lineBriefs`): a facts line gets its facts and its count; a text line that follows gets "every number must be copied exactly as written in a quote you wrote for job line N". `stepFileContract()` names both shapes.
|
|
4477
|
-
- **Web addresses as inputs (Part 1c, `src/pagefetch.js`, `src/source.js`).** An Inputs line may be `label: https://...` (also a rubric card's FIRST line; `looksLikeRubricInput`). `fetchPageText(url)` calls barebrowse `connect({ incognito: true, blockPrivateNetwork: true })` (`CONNECT_OPTIONS`) → `goto` → `waitForNetworkIdle({ idle: 1500, timeout: 20000 })` (bounded; a page that never settles is read as it stands) → `snapshot({ mode: 'act' })`, always closing the browser, with our own 90 s deadline (L1: a load-time `browse()` snapshot gave 77,951, 8,801 or 719 characters of the same results page; L2: a page whose text outside the banner / navigation / contentinfo landmarks is under `MIN_CONTENT_CHARS` = 100 (`pageContentChars`) is a stop too, "only the site's own header and menus", and an input with no content never reaches the look or an early ask: the survey is ABSENT, "holds nothing to read", nothing spent); an empty or under-200-character page (`MIN_PAGE_CHARS`), a bot challenge, an unreachable address, a credentialed or secret-shaped address, or a page carrying a secret shape is a plain-words $0 stop on its line. `proveRubricInputs({ ..., fetchUrl })` freezes the page text under `input/<label>.txt` and records `url` on the manifest input row. A FRESH `run-u --spec` start (not `--resume` / `--door` / `--decide`) calls `refreezeUrlInputs`: it fetches every recorded address again, writes that text into the prepared tree, commits it as the new seed and rewrites `source.json` (new `sha256` and `seed`, `draftSha256` keeps what the look saw) BEFORE the worker starts (inside `execute`, AFTER the run's row is listed with its pid and cap, so the Runs list shows it while the page loads; the Run tab reads "fetching the page…" until `source.json` carries `refrozenAt`), so quotes are checked against the run's copy and the worker reads it, never the live page. A failed or empty fetch stops the run (the row is settled at $0 as `failed` with the plain reason, `refused before start`, and the monthly claim is freed), "The run did not start. Nothing spent." A rubric job on a URL or file is recognised by the signed spec's verdict type on a Reuse and on a scheduled fire (`startSession`, `src/panel/authorroutes.js`), so line 1 is not proved as a repo path; a fresh job reads it from the card. Plan card (L3): `settlePersonsWords` (called in `authorClose` before validation) unmarks AI's proposal on a limit made of the person's own numbers, swaps in the one explicit positive time range the person wrote, and drops a `refused` entry for a `~` rule a part of its line carries; the look's fact may carry `forRule` (a rule it numbered from its own knowledge, marked AI's proposal), which removes that rule from the look's not-found list so it is not asked. Test seams: `fetchPageText(url, { connect })`, `deps.fetchUrl` (`run-u`), `deps.fetchUrl` / `deps.lookFn` (`createSession`).
|
|
4492
|
+
- **Web addresses as inputs (Part 1c, `src/pagefetch.js`, `src/source.js`).** An Inputs line may be `label: https://...` (also a rubric card's FIRST line; `looksLikeRubricInput`). `fetchPageText(url)` calls barebrowse `connect({ incognito: true, blockPrivateNetwork: true })` (`CONNECT_OPTIONS`) → `goto` → `waitForNetworkIdle({ idle: 1500, timeout: 20000 })` (bounded; a page that never settles is read as it stands) → `snapshot({ mode: 'act' })`, always closing the browser, with our own 90 s deadline per attempt (L1: a load-time `browse()` snapshot gave 77,951, 8,801 or 719 characters of the same results page; L2: a page whose text outside the banner / navigation / contentinfo landmarks is under `MIN_CONTENT_CHARS` = 100 (`pageContentChars`) is a stop too, "only the site's own header and menus", and an input with no content never reaches the look or an early ask: the survey is ABSENT, "holds nothing to read", nothing spent). **Retries:** a header-only snapshot is first re-read on the same open page every 2 s (`SETTLE_INTERVAL_MS`) for up to 20 s (`SETTLE_BUDGET_MS`) before the attempt counts as header-only; the whole fetch (fresh browser each time, 3 s pause, `RETRY_WAIT_MS`) is then tried up to 3 times in all (`FETCH_ATTEMPTS`), but ONLY a header-only page or a timeout is retried - a refused or private address, a bot challenge, any other load error, an empty page and a non-text answer stop on the first try. When all attempts fail the stop reads the same with "(tried 3 times)" added, and the panel's drafting appends a `page-fetch-attempts` line (`no`, `attempts: [{chars, ms, head}]` of the header-only tries, secret-masked) to `draft-log.jsonl`. An empty or under-200-character page (`MIN_PAGE_CHARS`), a bot challenge, an unreachable address, a credentialed or secret-shaped address, or a page carrying a secret shape is a plain-words $0 stop on its line. `proveRubricInputs({ ..., fetchUrl })` freezes the page text under `input/<label>.txt` and records `url` on the manifest input row. A FRESH `run-u --spec` start (not `--resume` / `--door` / `--decide`) calls `refreezeUrlInputs`: it fetches every recorded address again, writes that text into the prepared tree, commits it as the new seed and rewrites `source.json` (new `sha256` and `seed`, `draftSha256` keeps what the look saw) BEFORE the worker starts (inside `execute`, AFTER the run's row is listed with its pid and cap, so the Runs list shows it while the page loads; the Run tab reads "fetching the page…" until `source.json` carries `refrozenAt`), so quotes are checked against the run's copy and the worker reads it, never the live page. A failed or empty fetch stops the run (the row is settled at $0 as `failed` with the plain reason, `refused before start`, and the monthly claim is freed), "The run did not start. Nothing spent." A rubric job on a URL or file is recognised by the signed spec's verdict type on a Reuse and on a scheduled fire (`startSession`, `src/panel/authorroutes.js`), so line 1 is not proved as a repo path; a fresh job reads it from the card. Plan card (L3): `settlePersonsWords` (called in `authorClose` before validation) unmarks AI's proposal on a limit made of the person's own numbers, swaps in the one explicit positive time range the person wrote, and drops a `refused` entry for a `~` rule a part of its line carries; the look's fact may carry `forRule` (a rule it numbered from its own knowledge, marked AI's proposal), which removes that rule from the look's not-found list so it is not asked. Test seams: `fetchPageText(url, { connect })`, `deps.fetchUrl` (`run-u`), `deps.fetchUrl` / `deps.lookFn` (`createSession`).
|
|
4478
4493
|
- **Ask at once, only about intent (I1; the asks are now code-forced from the page map, see "The look reads, code asks" below).** A `~` rule the look cannot tie to a kept page word becomes a question worded by code (`askableFromLook`, `src/pagemap.js`: line and rule named), asked before the confirm turn through the existing question gate (`answerQuestions`; `normalizeQuestions` caps it at `MAX_QUESTIONS`); the answer is a new `~` rule on that line. A rubric job on files never offers the piecemeal try-3 question; its failed-draft stop (`draftStopText({ wholeJob: true })`) says to review the whole job and submit it again.
|
|
4479
4494
|
- **Known limits (documented, not built around).** Airport codes like SFO have no stable label on a flight page: direction is checkable only through the full airport names the page uses. An unanchored `text` fact cannot tell which field a value sits in. `am` / `pm` in lower case and `9:27AM` are malformed times; `v0.41.0` is one token. A fact step's quote proves the value is in a real record, not that it is the RIGHT record: "the cheapest" and "the last 3" are Not checked. Verified on real files only; the live proof (DeepSeek, both jobs through the panel) has not been run.
|
|
4480
4495
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bareloop",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.51.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",
|
|
@@ -28,8 +28,8 @@
|
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"bare-agent": "^0.52.0",
|
|
31
|
-
"barebrowse": "^0.
|
|
32
|
-
"bareguard": "^0.
|
|
31
|
+
"barebrowse": "^0.25.0",
|
|
32
|
+
"bareguard": "^0.27.0",
|
|
33
33
|
"litectx": "^0.32.0"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
package/src/authorflow.js
CHANGED
|
@@ -863,6 +863,8 @@ export const PARAM_SCHEMAS = Object.freeze({
|
|
|
863
863
|
additionalProperties: false,
|
|
864
864
|
},
|
|
865
865
|
aiProposal: { type: 'boolean', description: 'true when the rule\'s number is YOURS (made out of the person\'s words), not one the person wrote' },
|
|
866
|
+
lang: { enum: ['en', 'de', 'fr', 'es', 'it', 'pt', 'nl'], description: 'date only: the language the input writes the month name in; leave it out for a date written 2026-10-26. Copy it from the look' },
|
|
867
|
+
decimal: { enum: ['.', ','], description: 'number or money only: the mark the input writes before the decimals; leave it out for "." Copy it from the look' },
|
|
866
868
|
},
|
|
867
869
|
required: ['name', 'shape'],
|
|
868
870
|
additionalProperties: false,
|
|
@@ -1070,7 +1072,16 @@ THE PARSER reads ONE number out of a command's output, as signed arithmetic over
|
|
|
1070
1072
|
region "whole-output", or {anchor, capture} to search only inside the part of the output the
|
|
1071
1073
|
anchor locates. A region that cannot be located is a broken instrument.
|
|
1072
1074
|
sign ${SIGNS.join(' | ')}. Subtraction is how you exclude things that were reported but did
|
|
1073
|
-
not actually happen
|
|
1075
|
+
not actually happen.
|
|
1076
|
+
|
|
1077
|
+
To count lines about one file or folder, keep lineMatch general (match the error line itself, e.g.
|
|
1078
|
+
"error TS\\d+") and put the file or folder in scope.includePrefixes. Never put a file path inside
|
|
1079
|
+
lineMatch or inside a region anchor: once that file is clean the command still fails on other files,
|
|
1080
|
+
nothing matches, and the check stops as a broken instrument instead of reading zero.
|
|
1081
|
+
|
|
1082
|
+
{"kind": "count-not-worse", "params": {"cmd": "npm", "args": ["run", "typecheck", "--", "--strict"],
|
|
1083
|
+
"parser": {"terms": [{"lineMatch": "error TS\\\\d+", "capture": null, "sign": 1, "aggregate": "sum", "region": "whole-output"}]},
|
|
1084
|
+
"scope": {"includePrefixes": ["src/target.js"]}, "direction": "lower-is-better", "baseline": 0}}`;
|
|
1074
1085
|
}
|
|
1075
1086
|
|
|
1076
1087
|
/**
|
|
@@ -1445,6 +1456,8 @@ export const REQUIRED_FACTS_BRIEF = 'REQUIRED FACTS — what a line that finds,
|
|
|
1445
1456
|
+ 'Copy the forms the look gives for the fact, in its order (the first is the main one); a form the look does not give is refused at $0.\n'
|
|
1446
1457
|
+ ' - A word the look lists under NOT CHECKED or LEFT OUT is never used in a fact - not as a label, a closing label, a unit or a currency - and is refused at $0 with the reason if you do. '
|
|
1447
1458
|
+ 'A fact or ~ rule listed under NOT CHECKED is not turned into a check: code lists it under Not checked for the person, so you do not write it into "refused" yourself.\n'
|
|
1459
|
+
+ ' - A date fact whose look line gives a "lang" is signed with that lang, and a number or money fact whose look line gives a "decimal" is signed with that decimal; copy it exactly (a fact that does not is refused at $0, nothing spent). "lang" goes on a date only and "decimal" on a number or money only. '
|
|
1460
|
+
+ 'For such a fact the worker writes the value in one canonical form (a date as YYYY-MM-DD, an amount with a point before the decimals), not as the quote writes it. A fact the look lists under NOT CHECKED for its month names or its decimal comma is not signed.\n'
|
|
1448
1461
|
+ ' - When one result holds several values of one kind (leaves / arrives, subtotal / total) give the fact an anchor, the label that sits right before the value you mean.\n'
|
|
1449
1462
|
+ ' - Set aiProposal true on a fact whose number you made out of their words.\n'
|
|
1450
1463
|
+ RUBRIC_RULES + '\n'
|
package/src/facts.js
CHANGED
|
@@ -18,7 +18,11 @@ export const FACT_OPS = Object.freeze(['lt', 'lte', 'gt', 'gte', 'between']);
|
|
|
18
18
|
/** bareguard signs at most this many decides on one `cited` check */
|
|
19
19
|
export const MAX_FACTS = 10;
|
|
20
20
|
/** every field a fact may carry */
|
|
21
|
-
const FACT_FIELDS = Object.freeze(['name', 'shape', 'unit', 'currency', 'phrase', 'anchor', 'until', 'rule', 'aiProposal']);
|
|
21
|
+
const FACT_FIELDS = Object.freeze(['name', 'shape', 'unit', 'currency', 'phrase', 'anchor', 'until', 'rule', 'aiProposal', 'lang', 'decimal']);
|
|
22
|
+
/** the languages whose month names bareguard 0.27 reads on a `date` fact (its `lang`), each with the name a person reads; absent `lang` = ISO YYYY-MM-DD only */
|
|
23
|
+
export const FACT_LANGS = Object.freeze({ en: 'English', de: 'German', fr: 'French', es: 'Spanish', it: 'Italian', pt: 'Portuguese', nl: 'Dutch' });
|
|
24
|
+
/** the decimal marks a number or money fact may sign (bareguard 0.27 `decimal`); absent = "." */
|
|
25
|
+
export const FACT_DECIMALS = Object.freeze(['.', ',']);
|
|
22
26
|
/** every field a part of class `fact` may carry (the shared ones are checked by rubricStepShapeReds) */
|
|
23
27
|
export const FACT_PART_FIELDS = Object.freeze(['source', 'facts', 'count']);
|
|
24
28
|
/** a fact's name appears in the claim text bareguard scans for numbers, so it carries letters only (no digit can red the claim) */
|
|
@@ -97,7 +101,6 @@ export function factShapeReds(part, w, red) {
|
|
|
97
101
|
const list = asList(us);
|
|
98
102
|
if (list.length > MAX_UNITS) red('invalid-value', `${fw}.unit`, `at most ${MAX_UNITS} units (${list.length} given)`);
|
|
99
103
|
else if (list.some((u) => u.length > MAX_UNIT_CHARS)) red('invalid-value', `${fw}.unit`, `a unit is at most ${MAX_UNIT_CHARS} characters`);
|
|
100
|
-
else if (new Set(list.map((u) => u.replace(/\s+/g, ' ').trim())).size !== list.length) red('invalid-value', `${fw}.unit`, 'the units are not repeated (two that differ only in spaces are the same unit)');
|
|
101
104
|
}
|
|
102
105
|
}
|
|
103
106
|
if (has('currency')) {
|
|
@@ -109,6 +112,14 @@ export function factShapeReds(part, w, red) {
|
|
|
109
112
|
else if (new Set(list).size !== list.length) red('invalid-value', `${fw}.currency`, 'the currencies are not repeated');
|
|
110
113
|
}
|
|
111
114
|
}
|
|
115
|
+
if (has('lang')) {
|
|
116
|
+
if (f.shape !== 'date') red('invalid-value', `${fw}.lang`, 'only a date fact carries lang (the language the page writes its month names in); leave it out for a date written 2026-10-26');
|
|
117
|
+
else if (typeof f.lang !== 'string' || !Object.hasOwn(FACT_LANGS, f.lang)) red('invalid-value', `${fw}.lang`, `one of ${Object.keys(FACT_LANGS).join(' | ')}`);
|
|
118
|
+
}
|
|
119
|
+
if (has('decimal')) {
|
|
120
|
+
if (f.shape !== 'number' && f.shape !== 'money') red('invalid-value', `${fw}.decimal`, 'only a number or money fact carries decimal (the mark the page writes before the decimals)');
|
|
121
|
+
else if (!FACT_DECIMALS.includes(f.decimal)) red('invalid-value', `${fw}.decimal`, 'one of "." | ","');
|
|
122
|
+
}
|
|
112
123
|
if (f.shape === 'phrase') {
|
|
113
124
|
if (!nonEmpty(f.phrase)) red('invalid-value', `${fw}.phrase`, 'the fixed words the quote must contain, copied from the input');
|
|
114
125
|
for (const k of ['anchor', 'until', 'rule']) if (has(k)) red('invalid-value', `${fw}.${k}`, 'a phrase is fixed words the quote must contain; it has no anchor, until or rule');
|
|
@@ -147,6 +158,8 @@ export function factDecides(part) {
|
|
|
147
158
|
const d = { valueKind: f.shape };
|
|
148
159
|
if (f.shape === 'money') { if (f.unit !== undefined) d.unit = f.unit; if (f.currency !== undefined) d.currency = f.currency; }
|
|
149
160
|
if (f.anchor !== undefined) d.anchor = f.anchor;
|
|
161
|
+
if (f.lang !== undefined) d.lang = f.lang;
|
|
162
|
+
if (f.decimal !== undefined) d.decimal = f.decimal;
|
|
150
163
|
if (f.until !== undefined) d.until = f.until;
|
|
151
164
|
if (f.rule) {
|
|
152
165
|
d.op = f.rule.op;
|
|
@@ -161,11 +174,17 @@ export function factDecides(part) {
|
|
|
161
174
|
* from the values the worker gave (the worker writes no claim text): `name: value; name: value`. A phrase fact contributes its
|
|
162
175
|
* own signed words. A result that is not an object, or has no string quote, still becomes a claim — an empty one — so
|
|
163
176
|
* bareguard reds it by name rather than the result vanishing.
|
|
164
|
-
*
|
|
177
|
+
*
|
|
178
|
+
* A fact that signs a page form (`lang` or `decimal`) carries a CANONICAL value ("2026-10-26", "1057.65": bareguard's typed binding, `values.d<j>`),
|
|
179
|
+
* but bareguard's number scan compares the claim TEXT with the quote's own digits, so the text must spell the value the way the quote does
|
|
180
|
+
* ("26 October 2026", "1.057,65"). That spelling is `asWritten[result][fact index]`: the value span bareguard itself reported for that quote
|
|
181
|
+
* ({@link writtenSpans}); a fact with no span there reads the value the worker gave.
|
|
182
|
+
* @param {any} part @param {unknown} results @param {(Record<number, string>|undefined)[]} [asWritten]
|
|
183
|
+
* @returns {{claim: string, quote: string, values?: Record<string, string>}[]}
|
|
165
184
|
*/
|
|
166
|
-
export function factClaims(part, results) {
|
|
185
|
+
export function factClaims(part, results, asWritten = []) {
|
|
167
186
|
const list = Array.isArray(results) ? results : [];
|
|
168
|
-
return list.map((/** @type {any} */ r) => {
|
|
187
|
+
return list.map((/** @type {any} */ r, /** @type {number} */ i) => {
|
|
169
188
|
const given = isRec(r) && isRec(r.values) ? r.values : null;
|
|
170
189
|
/** @type {Record<string, string>} */
|
|
171
190
|
const values = {};
|
|
@@ -176,12 +195,36 @@ export function factClaims(part, results) {
|
|
|
176
195
|
const v = given && Object.hasOwn(given, f.name) ? given[f.name] : undefined;
|
|
177
196
|
// a JSON number is the value as written ("389"): converted, never repaired; anything else is left for bareguard to red
|
|
178
197
|
const s = typeof v === 'number' && Number.isFinite(v) ? String(v) : v;
|
|
179
|
-
if (typeof s === 'string') { values[`d${j}`] = s; said.push(`${f.name}: ${s}`); } else if (s !== undefined) { /** @type {any} */ (values)[`d${j}`] = s; }
|
|
198
|
+
if (typeof s === 'string') { values[`d${j}`] = s; said.push(`${f.name}: ${asWritten[i]?.[j] ?? s}`); } else if (s !== undefined) { /** @type {any} */ (values)[`d${j}`] = s; }
|
|
180
199
|
});
|
|
181
200
|
return { claim: said.join('; '), quote: isRec(r) && typeof r.quote === 'string' ? r.quote : '', values };
|
|
182
201
|
});
|
|
183
202
|
}
|
|
184
203
|
|
|
204
|
+
/**
|
|
205
|
+
* Where bareguard read each page-form fact's value inside each quote, as the quote spells it: from `checkStep`'s `full.evidence` (one entry per
|
|
206
|
+
* claim: `text` = the normalized quote the decides ran on, `spans` = where each decide read its anchor, value and unit/currency). Only a fact that
|
|
207
|
+
* signs `lang` or `decimal` is looked up; the span is the decide's `value` span (the one equal to the claim's own value when bareguard flags it).
|
|
208
|
+
* @param {any} part @param {any[]|undefined} evidence @returns {(Record<number, string>|undefined)[]} per claim index
|
|
209
|
+
*/
|
|
210
|
+
export function writtenSpans(part, evidence) {
|
|
211
|
+
/** @type {(Record<number, string>|undefined)[]} */
|
|
212
|
+
const out = [];
|
|
213
|
+
for (const e of Array.isArray(evidence) ? evidence : []) {
|
|
214
|
+
if (!isRec(e) || !Number.isInteger(e.claim) || typeof e.text !== 'string' || !Array.isArray(e.spans)) continue;
|
|
215
|
+
/** @type {Record<number, string>} */
|
|
216
|
+
const row = {};
|
|
217
|
+
part.facts.forEach((/** @type {any} */ f, /** @type {number} */ j) => {
|
|
218
|
+
if (f.lang === undefined && f.decimal === undefined) return;
|
|
219
|
+
const mine = e.spans.filter((/** @type {any} */ sp) => isRec(sp) && sp.decide === j && sp.role === 'value' && Number.isInteger(sp.start) && Number.isInteger(sp.end));
|
|
220
|
+
const sp = mine.find((/** @type {any} */ x) => x.matched === true) ?? mine[0];
|
|
221
|
+
if (sp) row[j] = e.text.slice(sp.start, sp.end);
|
|
222
|
+
});
|
|
223
|
+
if (Object.keys(row).length) out[e.claim] = row;
|
|
224
|
+
}
|
|
225
|
+
return out;
|
|
226
|
+
}
|
|
227
|
+
|
|
185
228
|
/** @param {unknown} n @param {string} shape @param {any} f @returns {string} one bound, as the person would say it */
|
|
186
229
|
function sayBound(n, shape, f) {
|
|
187
230
|
if (shape === 'money') return moneyAs(f, /** @type {string|number} */ (n), false);
|
|
@@ -219,6 +262,8 @@ export function factSentence(f, source) {
|
|
|
219
262
|
if (f.shape === 'phrase') bits.push('phrase', `must say "${f.phrase}"`);
|
|
220
263
|
else {
|
|
221
264
|
bits.push(f.shape === 'money' ? `money in ${moneyForms(f).join(' or ')}` : f.shape);
|
|
265
|
+
if (f.lang !== undefined) bits.push(`month names in ${FACT_LANGS[/** @type {keyof typeof FACT_LANGS} */ (f.lang)] ?? f.lang}`);
|
|
266
|
+
if (f.decimal === ',') bits.push('decimal comma');
|
|
222
267
|
if (f.rule) bits.push(ruleWords(f));
|
|
223
268
|
else if (f.anchor === undefined) bits.push('as the quote writes it');
|
|
224
269
|
if (f.anchor !== undefined) bits.push(f.until !== undefined ? `the words after "${f.anchor}" up to "${f.until}"` : `after "${f.anchor}"`);
|
|
@@ -237,6 +282,9 @@ export function factBrief(f) {
|
|
|
237
282
|
/** @type {string[]} */
|
|
238
283
|
const bits = [f.shape === 'money' ? `an amount in ${moneyForms(f).join(' or ')}` : `a ${f.shape}`];
|
|
239
284
|
if (f.shape === 'text') bits[0] = 'words';
|
|
285
|
+
// a fact that signs a page form is read in that form, but the value the worker writes is canonical (bareguard's typed binding): say so
|
|
286
|
+
if (f.lang !== undefined) bits.push(`write the date as YYYY-MM-DD (the quote writes it with ${FACT_LANGS[/** @type {keyof typeof FACT_LANGS} */ (f.lang)] ?? f.lang} month names)`);
|
|
287
|
+
if (f.decimal === ',') bits.push('write the amount with a point before the decimals and no thousands marks, e.g. 1057.65 (the quote writes a comma before the decimals)');
|
|
240
288
|
if (f.anchor !== undefined) bits.push(f.until !== undefined ? `the words right after "${f.anchor}" up to "${f.until}"` : `right after "${f.anchor}"`);
|
|
241
289
|
if (f.rule) bits.push(`must be ${ruleWords(f)}`);
|
|
242
290
|
return `${f.name} — ${bits.join(', ')}`;
|
package/src/factwords.js
CHANGED
|
@@ -53,7 +53,7 @@ const listOf = (shape) => /** @type {any} */ (['money', 'number', 'date', 'time'
|
|
|
53
53
|
* What the page-word map (src/pagemap.js) KEPT and DROPPED for one input: the sets the second proof reads. A look from the old search-and-read
|
|
54
54
|
* path has no `dropped` list, so it gives null and the label is proved against the code-made list as before.
|
|
55
55
|
* @param {{facts?: any[], dropped?: (import('./pagerules.js').Dropped & {source?: string})[]}|null|undefined} look @param {string} source
|
|
56
|
-
* @returns {{labels: Set<string>, units: Set<string>, currencies: Set<string>, words: Set<string>, dropped: Map<string, import('./pagerules.js').Dropped
|
|
56
|
+
* @returns {{labels: Set<string>, units: Set<string>, currencies: Set<string>, words: Set<string>, dropped: Map<string, import('./pagerules.js').Dropped>, forms: {labels: Set<string>, lang?: string, decimal?: string}[]}|null}
|
|
57
57
|
*/
|
|
58
58
|
export function keptSetOf(look, source) {
|
|
59
59
|
if (!look || !Array.isArray(look.dropped)) return null;
|
|
@@ -68,6 +68,8 @@ export function keptSetOf(look, source) {
|
|
|
68
68
|
currencies: set(facts.flatMap((f) => f.currency ?? [])),
|
|
69
69
|
words: set(facts.flatMap((f) => [...f.words, ...(f.unit ?? []), ...(f.currency ?? [])])),
|
|
70
70
|
dropped,
|
|
71
|
+
forms: facts.filter((f) => f.shape !== 'phrase' && (f.lang !== undefined || f.decimal !== undefined))
|
|
72
|
+
.map((f) => ({ labels: new Set(f.words.map((w) => normLabel(String(w)))), lang: f.lang, decimal: f.decimal })),
|
|
71
73
|
};
|
|
72
74
|
}
|
|
73
75
|
|
|
@@ -119,6 +121,15 @@ export function checkFactWords({ part, text, line, scan = scanLabels(text), kept
|
|
|
119
121
|
red('rubric-fact-label-rare', `${who}: the label ${JSON.stringify(row.label)} is in the input "${src}" only ${row.count} time${row.count === 1 ? '' : 's'}, but this line asks for ${n} results, so a label that sits in each result must be there at least ${n} times. Pick a label from the list that is counted ${n} or more times.`);
|
|
120
122
|
}
|
|
121
123
|
}
|
|
124
|
+
// a look fact that carries lang / decimal: the signed fact must sign the same, or a drafter that drops it signs a fact that reds at run time
|
|
125
|
+
if (kept && f.anchor !== undefined && f.shape !== 'phrase') {
|
|
126
|
+
const mine = kept.forms.filter((k) => k.labels.has(normLabel(String(f.anchor))));
|
|
127
|
+
if (mine.length && !mine.some((k) => (k.lang === undefined || k.lang === f.lang) && (k.decimal === undefined || k.decimal === (f.decimal ?? '.')))) {
|
|
128
|
+
const k = mine[0];
|
|
129
|
+
const [field, value] = k.lang !== undefined && k.lang !== f.lang ? ['lang', k.lang] : ['decimal', k.decimal];
|
|
130
|
+
reds.push({ code: 'rubric-fact-form-unsigned', detail: `line ${line}: the fact ${JSON.stringify(f.name)} must sign ${field} ${JSON.stringify(value)}, as the page look found. Nothing spent.` });
|
|
131
|
+
}
|
|
132
|
+
}
|
|
122
133
|
if (f.until !== undefined) dropRed('closing label', f.until);
|
|
123
134
|
if (f.until !== undefined && countExact(text, f.until) < 1) red('rubric-fact-word-missing', `${who}: ${JSON.stringify(f.until)} is not in the input "${src}". Copy the closing words from the input, or leave them out.`);
|
|
124
135
|
if (f.shape === 'phrase' && typeof f.phrase === 'string') {
|
package/src/handoff.js
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
// The handoff note (F253): a map of the files earlier workers in THIS run read, appended to the next step/fix
|
|
2
|
+
// worker's first prompt. Code-written only, never a model; names files, never carries their content.
|
|
3
|
+
// The switch is the signed spec's `handoffNote` (absent = on, only `false` turns it off; see src/job.js).
|
|
4
|
+
import { readFileSync, statSync } from 'node:fs';
|
|
5
|
+
import { isAbsolute, relative, resolve } from 'node:path';
|
|
6
|
+
import { isArbiterBook } from './kinds.js';
|
|
7
|
+
|
|
8
|
+
/** The one cap on a note, in characters. */
|
|
9
|
+
export const HANDOFF_CAP = 8000;
|
|
10
|
+
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) ==';
|
|
11
|
+
/** Per-entry symbol-map cap, so one huge file cannot eat the whole note. */
|
|
12
|
+
const ENTRY_MAP_CAP = 500;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Is this repo-relative path off limits to a note: outside the job root, an arbiter book (the one list,
|
|
16
|
+
* `isArbiterBook`: .smoke — spine, attempt-diff, bridges — .litectx, the gate audit), or inside `.git` / `.bareloop`.
|
|
17
|
+
* @param {string} rel
|
|
18
|
+
*/
|
|
19
|
+
export function isHandoffExcluded(rel) {
|
|
20
|
+
if (rel === '' || rel === '..' || rel.startsWith('../') || isAbsolute(rel)) return true;
|
|
21
|
+
if (isArbiterBook(rel) !== null) return true;
|
|
22
|
+
return rel.split('/').some((seg) => seg === '.git' || seg === '.bareloop');
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Wrap the worker's read-class tools (the real names come from the caller: shell_read, ctx_get) so a call that
|
|
27
|
+
* reached `execute` (the gate already allowed it) and returned a file's text is reported to `onRead`.
|
|
28
|
+
* Wraps in place: tool objects are fresh per worker.
|
|
29
|
+
* @param {{name: string, execute: Function}[]} tools
|
|
30
|
+
* @param {string[]} names
|
|
31
|
+
* @param {(absPath: string) => void} onRead
|
|
32
|
+
* @param {string} workdir
|
|
33
|
+
*/
|
|
34
|
+
export function trackReads(tools, names, onRead, workdir) {
|
|
35
|
+
for (const t of tools) {
|
|
36
|
+
if (!names.includes(t.name)) continue;
|
|
37
|
+
const inner = t.execute;
|
|
38
|
+
t.execute = async (/** @type {any} */ args) => {
|
|
39
|
+
const r = await inner(args);
|
|
40
|
+
if (typeof r === 'string' && typeof args?.path === 'string' && !/^ctx_get failed/.test(r)) {
|
|
41
|
+
const abs = isAbsolute(args.path) ? args.path : resolve(workdir, args.path);
|
|
42
|
+
try { if (statSync(abs).isFile()) onRead(abs); } catch { /* not a file: nothing was read */ }
|
|
43
|
+
}
|
|
44
|
+
return r;
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Run-level store of the paths earlier workers read. Newest read last; a re-read moves a path to newest.
|
|
51
|
+
* In memory only: a resumed leg starts empty (the first ask of a resumed leg gets no note, later asks do).
|
|
52
|
+
* @param {{workdir: string}} o
|
|
53
|
+
*/
|
|
54
|
+
export function createHandoffStore({ workdir }) {
|
|
55
|
+
/** @type {Set<string>} insertion order = oldest first */
|
|
56
|
+
const paths = new Set();
|
|
57
|
+
/** @param {Iterable<string>} absPaths */
|
|
58
|
+
const absorb = (absPaths) => {
|
|
59
|
+
for (const a of absPaths) {
|
|
60
|
+
const rel = relative(workdir, a).split('\\').join('/');
|
|
61
|
+
if (isHandoffExcluded(rel)) continue;
|
|
62
|
+
paths.delete(rel);
|
|
63
|
+
paths.add(rel);
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* @param {{getNode?: (rel: string) => any}} [o] `getNode`: the LiteCtx index's node for a path (its `chunks`)
|
|
68
|
+
* @returns {{text: string, paths: number}} text '' when nothing was read; else heading + body, length <= HANDOFF_CAP
|
|
69
|
+
*/
|
|
70
|
+
const render = ({ getNode = () => null } = {}) => {
|
|
71
|
+
if (paths.size === 0) return { text: '', paths: 0 };
|
|
72
|
+
const lineCount = (/** @type {string} */ rel) => { try { return readFileSync(resolve(workdir, rel), 'utf8').split('\n').length; } catch { return null; } };
|
|
73
|
+
const entries = [...paths].map((rel) => {
|
|
74
|
+
const n = lineCount(rel);
|
|
75
|
+
let node = null;
|
|
76
|
+
try { node = getNode(rel); } catch { node = null; }
|
|
77
|
+
// Fresh index only: a node whose last chunk ends past the file's current end is stale — fall back to the count.
|
|
78
|
+
const named = (node?.chunks ?? []).filter((/** @type {any} */ c) => c.symbol);
|
|
79
|
+
const fresh = n !== null && named.every((/** @type {any} */ c) => c.endLine <= n);
|
|
80
|
+
let map = '';
|
|
81
|
+
let more = 0;
|
|
82
|
+
for (let i = 0; fresh && i < named.length; i++) {
|
|
83
|
+
const c = named[i];
|
|
84
|
+
const piece = `${c.symbol} ${c.startLine}-${c.endLine}`;
|
|
85
|
+
if ((map ? map.length + 2 : 0) + piece.length > ENTRY_MAP_CAP) { more = named.length - i; break; }
|
|
86
|
+
map += (map ? ', ' : '') + piece;
|
|
87
|
+
}
|
|
88
|
+
return `- ${rel}${n === null ? '' : ` (${n} lines)`}${map ? `: ${map}` : ''}${more ? `, +${more} more` : ''}`;
|
|
89
|
+
});
|
|
90
|
+
const wrap = (/** @type {string[]} */ es, /** @type {number} */ dropped) => `${HANDOFF_HEADING}\n${dropped ? `[trimmed: ${dropped} older path(s)]\n` : ''}${es.join('\n')}`;
|
|
91
|
+
let dropped = 0;
|
|
92
|
+
let out = wrap(entries, 0);
|
|
93
|
+
while (out.length > HANDOFF_CAP && dropped < entries.length) {
|
|
94
|
+
dropped++;
|
|
95
|
+
out = wrap(entries.slice(dropped), dropped);
|
|
96
|
+
}
|
|
97
|
+
return { text: out, paths: entries.length - dropped };
|
|
98
|
+
};
|
|
99
|
+
return { absorb, render, size: () => paths.size };
|
|
100
|
+
}
|
package/src/inputlook.js
CHANGED
|
@@ -149,7 +149,7 @@ export function lookPrompt({ jobLines, labels, lists }) {
|
|
|
149
149
|
}
|
|
150
150
|
|
|
151
151
|
/** @typedef {{line: number, name: string, shape: string, source: string, label?: string, labelId?: string, value?: string, phrase?: string, example: string, rule?: any, aiProposal?: boolean, forRule?: number, reading?: import('./pagerules.js').Reading,
|
|
152
|
-
* words?: string[], labels?: string[], unit?: string[], currency?: string[]}} LookFact `words` / `labels` / `unit` / `currency`: what the page-word map kept (idea A core) */
|
|
152
|
+
* words?: string[], labels?: string[], unit?: string[], currency?: string[], lang?: string, decimal?: string}} LookFact `words` / `labels` / `unit` / `currency`: what the page-word map kept (idea A core) */
|
|
153
153
|
/** @typedef {{line: number, rule?: number, words?: string, why: string}} LookNotFound */
|
|
154
154
|
/** @typedef {{facts: LookFact[], prose: {line: number, text?: string}[], notFound: LookNotFound[], dropped?: import('./pagerules.js').Dropped[]}} LookReport */
|
|
155
155
|
|
|
@@ -168,6 +168,8 @@ export function lookFactOf(k, source) {
|
|
|
168
168
|
else { out.labels = [...k.words]; if (k.words.length) out.label = k.words[0]; }
|
|
169
169
|
if (k.unit) out.unit = [...k.unit];
|
|
170
170
|
if (k.currency) out.currency = [...k.currency];
|
|
171
|
+
if (k.lang !== undefined) out.lang = k.lang;
|
|
172
|
+
if (k.decimal !== undefined) out.decimal = k.decimal;
|
|
171
173
|
if (k.forRule !== undefined) out.forRule = k.forRule;
|
|
172
174
|
if (k.reading) out.reading = { ...k.reading };
|
|
173
175
|
return out;
|
|
@@ -251,6 +253,9 @@ export function renderLookReport(report) {
|
|
|
251
253
|
else bits.push('no label (read by its unit or sign alone)');
|
|
252
254
|
if (f.unit?.length) bits.push(`unit ${quote(f.unit)}`);
|
|
253
255
|
if (f.currency?.length) bits.push(`currency ${quote(f.currency)}`);
|
|
256
|
+
// a page form the page rules proved is on the page: the drafter signs it as given, never a guess (the run reads that form and no other)
|
|
257
|
+
if (f.lang !== undefined) bits.push(`lang ${JSON.stringify(f.lang)} (the page writes the month name in this language: sign it as the fact's lang)`);
|
|
258
|
+
if (f.decimal !== undefined) bits.push(`decimal ${JSON.stringify(f.decimal)} (the page writes this mark before the decimals: sign it as the fact's decimal)`);
|
|
254
259
|
}
|
|
255
260
|
} else if (f.phrase !== undefined) bits.push(`the quote must say ${JSON.stringify(f.phrase)}`);
|
|
256
261
|
else if (f.label !== undefined) bits.push(`label ${JSON.stringify(f.label)} (id ${f.labelId})`);
|