bareloop 0.48.0 → 0.49.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 CHANGED
@@ -5,6 +5,27 @@ 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.49.0] - 2026-10-26
9
+
10
+ ### Added
11
+
12
+ - **A launcher `6 update` option (and `bareloop update`).** It asks npm for the newest bareloop only when you press it (nothing goes online at start or in the background). Newest: `You have the newest bareloop (X).` A newer one: `bareloop Y is out. You have X.` and `Update now? (y/n)`; `y` runs `npm install -g bareloop@latest` and says to pick 3 restart (from the menu) or to run `bareloop restart` (typed as `bareloop update`), `n` leaves it. The install gives up after 5 minutes: its npm child is ended and the same "The update did not finish" line shows. If npm cannot be reached: `Could not reach npm to check. Try again later.`
13
+
14
+ ### Fixed
15
+
16
+ - **A page fetch's browser no longer outlives bareloop.** If bareloop is killed or crashes while reading a web address, the browser it started now exits with it (barebrowse 0.24.1; Firefox needs `setpriv`, Chromium needs nothing). Old leftover browser folders in `/tmp` are cleaned on the next fetch.
17
+ - **"yes, " in front of your own reading is no longer signed.** When a question about a `~` rule is answered "yes, check it as departure between 05:00 and 21:59", the rule now reads "check it as departure between 05:00 and 21:59". A leading "yes," or "agree:" (the word, then a comma or colon) is dropped from the signed `~` rule and the rest is kept word for word; any other start is kept whole; a bare "yes" or "agree" still accepts the reading, and a yes in the middle of a sentence is left alone. "yes, drop it" on a rule the page cannot check drops it. (F240)
18
+ - **Two money units that differ only in spaces are one unit.** Page rules now trim and collapse spaces in each listed unit (so "US dollars" and " US dollars" become one), and a spec that still carries such a pair is refused at no cost in bareloop's own words ("the units are not repeated") instead of by bareguard 0.26.
19
+ - **A time label the run cannot read is now Not checked (F236, F237).** A time fact is read against the page by the same checker the run uses before it is signed. If the page never shows a time right after the label (for example "Departure time" on a page that writes "Departure time:"), the fact is left out and shown under Not checked: `the page never shows a time right after "Departure time", so it is not checked.` It only catches a label that can never read; a label that reads a wrong time is kept and left to you at Accept.
20
+
21
+ ### Changed
22
+
23
+ - **Menu numbers.** The panel line gains `6 update`; the job line is now `7 export 8 run 9 resume 10 history`. `5 install` with nothing to do now says `Already set up. This does not update bareloop. Pick 6 update for that.`
24
+ - **barebrowse `^0.21.0` to `^0.24.1`.** No change to how bareloop calls it.
25
+ - **bareguard `^0.25.1` to `^0.26.0`.** Its one break for bareloop is the money-unit rule above; the new table rules (`cells`, `table`, `diff`) are not used here.
26
+ - **Piped input never installs on `bareloop update`.** The rule was "no terminal never installs", but the command always had an asker, so `echo y | bareloop update` (or a pipe into the menu's `6`) ran `npm install -g`. When stdin is not a terminal it now prints `To update: npm install -g bareloop@latest` and exits 0.
27
+ - **"agree with the shown price" is no longer cut to "with the shown price".** The F240 lead-word strip first also took a bare space, then a hyphen or dash, as a separator, so it ate real words ("yes or no questions only" signed as "or no questions only", "yes-no questions only" as "no questions only"). Now only a leading `yes` or `agree` directly followed by a comma or colon is dropped from the signed `~` rule; any other start is kept whole.
28
+
8
29
  ## [0.48.0] - 2026-10-25
9
30
 
10
31
  ### Added
package/README.md CHANGED
@@ -24,6 +24,10 @@ bareloop finds that path for you. Write your problem in plain language, as steps
24
24
 
25
25
  The harness (budget, time, what it may touch) and the judge both sit **outside** the agent loop. The agent can't judge itself. Every run is recorded, so you can audit it and replay it at $0 and see exactly what happened.
26
26
 
27
+ <p align="center">
28
+ <img src="https://raw.githubusercontent.com/hamr0/bareloop/main/docs/media/panel-walkthrough.gif" alt="The bareloop panel: write a job, the runs list, a rubric run waiting for Accept, its Result, Audit and signed Job, then a repo run ready to merge" width="900">
29
+ </p>
30
+
27
31
  ## Two kinds of jobs
28
32
 
29
33
  **Deterministic (code)**: code decides. Tests pass, the linter is quiet, the build exits clean. If no check exists yet, say what you need and the agent builds that check first.
@@ -137,8 +141,8 @@ cd ./my-job.bareloop && npm install
137
141
  bareloop run "my-job (run-3)" --repo /path/to/checkout --approve <bundleHash printed above>
138
142
  ```
139
143
 
140
- Bare `bareloop` is one menu: the panel (1 start, 2 stop, 3 restart, 4 status, 5 install) and the jobs
141
- (6 export, 7 run, 8 resume, 9 history), each asking for what it needs. `export` only ships a run that
144
+ Bare `bareloop` is one menu: the panel (1 start, 2 stop, 3 restart, 4 status, 5 install, 6 update) and the jobs
145
+ (7 export, 8 run, 9 resume, 10 history), each asking for what it needs. `update` checks npm only when you press it and offers to install the newer version. `export` only ships a run that
142
146
  already earned a real green, and only repo jobs for now. The first `run` on a new machine asks you to
143
147
  approve the bundle's printed hash; once that run goes green, later runs need no re-approval as long
144
148
  as the bundle stays unchanged. Every run works in its own fresh git worktree, commits a green on its
@@ -738,7 +738,7 @@ attempt PLUS its close. Unpriced is never free: a null cost is a `pricing-red` s
738
738
  never retried, and the ladder is otherwise ONE retry (`JUDGE_ATTEMPTS`) — after that a broken
739
739
  judge is an instrument stop, never a red about the tree.
740
740
 
741
- **The rulebook, and what each rule can raise** (`JUDGE_RULES` in `src/judged.js`; every rule carries a plain-words `means` the case-proposal prompt renders, so a proposed practice case never expects a red the rule cannot raise). The judge only POINTS (quotes lines verbatim); code does every check; unsure is red; the judge never says pass/fail. Quotes are matched by bareguard's `quoteIn(..., {wholeLines:true})` (`wholeLines` arrived in bareguard 0.21; bareloop now needs `^0.25.1`): a contiguous run of whole artifact lines, so a bare fragment cannot pass by hiding in a longer line, while a dropped leading `* ` of a JSDoc tag line still matches. `has-doc` checks only that a JSDoc block sits directly above the function (read off the artifact by `docBlockAbove`; the judge's quote is a pointer that must lie inside that block), so a documented function never breaks it. **`says-what`** (the doc's description must say more than the function's own name) reds when the described prose, minus a fixed list of function words and the name's own words (camel/snake/kebab, light inflections, and a prefix echo such as `init`/`initialize` when the shorter word is at least 4 letters), leaves nothing; no description, or an unlocatable quote, reds. It catches a pure name echo only ("Returns the total." for `getTotal` passes), and with NO doc block at all it stays silent and leaves the red to `has-doc` (the card is not required to carry both). `params` reds a declared parameter with no tag, an `@param` naming no parameter (each destructured slot absorbs one unmatched root tag), and, when the doc names any field of a simple destructured parameter, a missing field; `@param options` alone for `{ x, y }` passes. `returns` reds a returning function with no `@returns`. A practice case that expects a `has-doc` red on a function that has a block is refused as a legality red before any call (`validateCalibrationSet`).
741
+ **The rulebook, and what each rule can raise** (`JUDGE_RULES` in `src/judged.js`; every rule carries a plain-words `means` the case-proposal prompt renders, so a proposed practice case never expects a red the rule cannot raise). The judge only POINTS (quotes lines verbatim); code does every check; unsure is red; the judge never says pass/fail. Quotes are matched by bareguard's `quoteIn(..., {wholeLines:true})` (`wholeLines` arrived in bareguard 0.21; bareloop now needs `^0.26.0`): a contiguous run of whole artifact lines, so a bare fragment cannot pass by hiding in a longer line, while a dropped leading `* ` of a JSDoc tag line still matches. `has-doc` checks only that a JSDoc block sits directly above the function (read off the artifact by `docBlockAbove`; the judge's quote is a pointer that must lie inside that block), so a documented function never breaks it. **`says-what`** (the doc's description must say more than the function's own name) reds when the described prose, minus a fixed list of function words and the name's own words (camel/snake/kebab, light inflections, and a prefix echo such as `init`/`initialize` when the shorter word is at least 4 letters), leaves nothing; no description, or an unlocatable quote, reds. It catches a pure name echo only ("Returns the total." for `getTotal` passes), and with NO doc block at all it stays silent and leaves the red to `has-doc` (the card is not required to carry both). `params` reds a declared parameter with no tag, an `@param` naming no parameter (each destructured slot absorbs one unmatched root tag), and, when the doc names any field of a simple destructured parameter, a missing field; `@param options` alone for `{ x, y }` passes. `returns` reds a returning function with no `@returns`. A practice case that expects a `has-doc` red on a function that has a block is refused as a legality red before any call (`validateCalibrationSet`).
742
742
 
743
743
  **A judged stage may only judge files inside the job's write fence** (`judgedOutsideFence`, `src/authoring.js`, called from `validateDeclaration`, which every door reaches: the authoring revise loop, `validateCloseDecl` at signing and runner pre-flight, and `validateJob` for hand-written or reused specs). A path outside `writeScope` reds `judged-outside-write-scope` at draft time, because a finding on a file the run is fenced out of can never be fixed. With no fence to compare against (the plain-folder deferral) the rule is not run.
744
744
 
@@ -3293,8 +3293,8 @@ same seam `tests/planrun-*.test.js` uses. `deps` also accepts `env`, `stdout`, `
3293
3293
  `now`, `stdin` — omit any of them and the real `process.*` equivalent is used.
3294
3294
 
3295
3295
  Bare `bareloop` (no sub-command) is the **launcher menu** (PANEL-BUILD.md addendum L, `src/launcher.js`): two header lines, then
3296
- `panel: 1 start 2 stop 3 restart 4 status 5 install`, `jobs: 6 export 7 run 8 resume 9 history`, `q quit`. The header is printed first by EVERY call (menu and each of
3297
- `bareloop start | stop | restart | status | install`), from one function:
3296
+ `panel: 1 start 2 stop 3 restart 4 status 5 install 6 update`, `jobs: 7 export 8 run 9 resume 10 history`, `q quit`. The header is printed first by EVERY call (menu and each of
3297
+ `bareloop start | stop | restart | status | install | update`), from one function:
3298
3298
 
3299
3299
  ```
3300
3300
  bareloop 0.47.0 · installed ✓ · panel running at http://127.0.0.1:4701
@@ -3318,10 +3318,11 @@ changes them, and a piped or `NO_COLOR` run prints the plain words above (the th
3318
3318
  `--yes` skips it. Not running: `Panel not running.`, exit 0. Several found: all stopped, `N panels stopped.`. Any other option (e.g. `--port`) is refused in plain words. Runs are separate processes and keep going.
3319
3319
  - **`bareloop status`** → header plus `pid N · version X · N draft(s) open · N schedule(s) on`. Exit 0 running, 3 not running. A panel whose version differs from the CLI's shows `(version X — stop and start to use Y)` after its URL in the header (yellow on a terminal).
3320
3320
  - **`bareloop install`** → creates only what is missing (folder mode 700, `.env` with the keys-file comment lines, mode 600, `config.json`); never reads a key value;
3321
- `Already installed, nothing to do.` when there is nothing to add. Needs node >= 22.
3321
+ `Already set up. This does not update bareloop. Pick 6 update for that.` when there is nothing to add. Needs node >= 22.
3322
+ - **`bareloop update`** (menu 6; `updateCmd` in `src/launcher.js`, one function for both doors; PRD v1.116) → the ONLY launcher command that goes online, and only when pressed: `GET https://registry.npmjs.org/bareloop/latest` (global `fetch`, 5 s deadline; nothing goes online at start, in the panel or in the background). Versions compare numerically (major.minor.patch). Newest: `You have the newest bareloop (X).` Newer: `bareloop Y is out. You have X.` then `Update now? (y/n) ` on the menu's asker; `y`/`yes` runs `npm install -g bareloop@latest` (no shell, output shown; a 300 s deadline ends the npm child with SIGTERM and counts as not finished) and prints `Updated to Y. Then pick 3 restart.` (from the menu) or `Updated to Y. Then run bareloop restart.` (typed as `bareloop update`), or on a non-zero exit / spawn error `The update did not finish. Run it yourself: npm install -g bareloop@latest` (exit 1); `n`/`no`/`q` prints `Not updated. To update later: npm install -g bareloop@latest`; an empty Enter or other text asks once more, a second ends as `n`; with no terminal (piped or redirected stdin, even if the pipe says `y`; `terminal: false` from `src/cli.js`) or no asker it never installs and prints `To update: npm install -g bareloop@latest`. Any registry failure (timeout, offline, non-200, bad JSON, no version): `Could not reach npm to check. Try again later.`, exit 1. Test seams: `deps.launcher.npmFetch`, `npmSpawn`, `npmDeadlineMs`.
3322
3323
 
3323
- **One menu (PRD v1.114, F245).** Bare `bareloop` prints the header, then `panel: 1 start 2 stop 3 restart 4 status 5 install`, `jobs: 6 export 7 run 8 resume 9 history` and `q quit`. Each job command asks for what it needs
3324
- (typed flags skip the question): **export** lists the green runs as numbered `job (run-N)` names, then asks the output folder; **run** asks the bundle (the last 10 known bundles are listed newest first, numbered, as run name + folder; a number picks one, a run name or a folder reaches an older one; none known: `No exported bundles yet. Export one with 6.` and it ends), the repo, then
3324
+ **One menu (PRD v1.114, F245).** Bare `bareloop` prints the header, then `panel: 1 start 2 stop 3 restart 4 status 5 install 6 update`, `jobs: 7 export 8 run 9 resume 10 history` and `q quit`. Each job command asks for what it needs
3325
+ (typed flags skip the question): **export** lists the green runs as numbered `job (run-N)` names, then asks the output folder; **run** asks the bundle (the last 10 known bundles are listed newest first, numbered, as run name + folder; a number picks one, a run name or a folder reaches an older one; none known: `No exported bundles yet. Export one with 7.` and it ends), the repo, then
3325
3326
  the `$` cap and the time cap (Enter keeps the signed ones); **resume** lists the stopped / capped bundle runs the engine would resume, then offers more money / time; **history** asks the bundle and prints what `bareloop history <bundle>` prints.
3326
3327
  `q` at any question ends the command cleanly (nothing run, exit `0`). A required question answered with an empty Enter is asked once more; a second empty Enter ends that command with a plain line (nothing chosen, nothing run), exit `0`. `interview`, `author`, `replay` and `runs backfill` are no longer commands
3327
3328
  (`node scripts/run-replay.mjs`, `scripts/run-interview.mjs`, `scripts/run-author.mjs` run from a source checkout; the library functions the panel uses stay). `run-u` is still dispatched by name (`bareloop run-u <flags…>`: the panel spawns it) but is listed nowhere.
@@ -4456,7 +4457,7 @@ A **Rubric** job whose first Input is the full path of a FILE (not a repo folder
4456
4457
 
4457
4458
  ### 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)
4458
4459
 
4459
- Check what the person asked for, not what the worker chose to write. bareloop needs bareguard `^0.25.1` (`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`).
4460
+ Check what the person asked for, not what the worker chose to write. bareloop needs bareguard `^0.26.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`).
4460
4461
 
4461
4462
  - **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.
4462
4463
  - **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,8 +4465,9 @@ Check what the person asked for, not what the worker chose to write. bareloop ne
4464
4465
  - **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.
4465
4466
  - **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.
4466
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).
4467
- - **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, 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.
4468
+ - **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 differ only in spaces are one unit, bareguard 0.26: the page-rule pool trims and collapses spaces so twins collapse, and the shape check says it in our own words), 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.
4468
4469
  - **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
+ - **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.
4469
4471
  - **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`.
4470
4472
  - **Found-once check (`src/factwords.js`, `checkDeclarationWords`, run after validation in `authorClose`).** Every anchor must be on the input's label list for its shape, and every `until`, phrase and unit must be in the source once (white-space blind: U+202F, U+00A0; phrases whole-word, case-blind). A miss is a red naming the word and the input: `rubric-fact-label-off-list`, `rubric-fact-word-missing`, `rubric-fact-unread` (an input that cannot be read is a red, never a skipped check). Nothing is graded; finding and grading are the run's and the close's job.
4471
4473
  - **No silently dropped rule (RF16).** When a close holds a fact part or any part with `rules`, every `~` rule of every job line must be carried out by a part (its number in the part's `rules`, 1 = the first `~` rule) or listed in `refused` as `{ line, rule, reason }`, or its whole line refused; a rule that is none is a $0 red (`rubric-rule-dropped`). `refused` entries may now carry `rule`. A number the person did not write (a bound not found in the line's own words) must be marked `aiProposal: true` (the card says "AI's proposal — check it"), and an AI-proposed time limit must be `between`, never one-sided (RF17).
@@ -4503,5 +4505,5 @@ For an integrating agent reading a run's record:
4503
4505
  - **`draft-log.jsonl` `human` rows** `{no, source: confirm | look | try-3, question, answer, line?, at}`; the answer is secret-masked before it is written and the row exists only when the question was answered.
4504
4506
  - **Money line** `moneyWithDraft(spendCore, draftUsd, budgetUsd, draftComplete, runUsd)`: `$run run + $draft drafting = $total of $cap`; without `runUsd` the sum is omitted. The panel's own spelling is `panelMoney2` (`src/panelmoney.js`, one Node owner; `src/panel/index.html` carries a pinned browser copy): 2 decimals from a cent up, 4 decimals for a real amount under a cent (`$0.0054`), `<$0.0001` below that, exact zero `$0.00`, null `unknown`; the CLI's `money()` keeps its own 4 decimals.
4505
4507
  - Not built from the signed spec (see the Part 5 commits): the early ask about a number the AI made (T1), because the data it needs does not exist at that point; T1 is replaced by Part 5b below. The "fetching the page…" state (Q2) was built after the run-start refetch moved to after the run is listed: the sign progress list shows the step (`settleFetchingStep`, `src/panel/authorroutes.js`) and a listed run with no log yet reads "fetching the page… the run has not started yet" (`startingStub`, `webFetchState`), both read from `source.json`'s `refrozenAt`.
4506
- - **The look reads, code asks (PRD v1.107 Part 5b; `src/pagemap.js`).** A map fact on a `time` or `money` shape may carry an optional `reading: {op, value | lo, hi}` (the signed-rule `op` set; a time bound is a string, a money bound a number); any other `reading` makes the whole map answer malformed (no repair). `askableFromLook(look, jobLines)` sorts every `~` rule: a kept page word carries it (no ask); a `reading` whose bound is NOT in the person's own words (`boundInWords`, the same test as `rubric-fact-unmarked`; it reads the words by kind, F242: a number bound is said only as a bare number or an amount's number, a time bound only as a time token with the hour's leading zero ignored, a date bound only as a date token, never a piece of a token) asks `Your line N says "<rule>". I read it as: <fact> <ruleWords>. Agree?`; a rule no kept fact carries asks `... I can't check this on the page. Drop it?`. Readings come first, then can't-check asks. `agree` (or `yes`) writes the reading as a `~` rule in plain words, so the bound is the person's own and the fact signs plain; a typed answer is the `~` rule instead; `drop it` on a can't-check ask adds no rule and leaves it Not checked. `MAX_QUESTIONS` is 3: more asks than that stops the draft before the confirm turn (stop `look-asks-too-many`, no extra spend) with `tooManyAsksText`, a code-written list of every ask and its reading. Asks carry `ask: 'reading' | 'cant-check'` (and `reading` for the agree text) through `normalizeQuestions`.
4508
+ - **The look reads, code asks (PRD v1.107 Part 5b; `src/pagemap.js`).** A map fact on a `time` or `money` shape may carry an optional `reading: {op, value | lo, hi}` (the signed-rule `op` set; a time bound is a string, a money bound a number); any other `reading` makes the whole map answer malformed (no repair). `askableFromLook(look, jobLines)` sorts every `~` rule: a kept page word carries it (no ask); a `reading` whose bound is NOT in the person's own words (`boundInWords`, the same test as `rubric-fact-unmarked`; it reads the words by kind, F242: a number bound is said only as a bare number or an amount's number, a time bound only as a time token with the hour's leading zero ignored, a date bound only as a date token, never a piece of a token) asks `Your line N says "<rule>". I read it as: <fact> <ruleWords>. Agree?`; a rule no kept fact carries asks `... I can't check this on the page. Drop it?`. Readings come first, then can't-check asks. `agree` (or `yes`) writes the reading as a `~` rule in plain words, so the bound is the person's own and the fact signs plain; a typed answer is the `~` rule instead (F240: a leading agree word directly followed by a comma or colon, as in `yes, check it as ...` or `agree: ...`, is stripped by `stripAgreeLead` in `src/pagemap.js` before the rule is signed; a bare space, a hyphen or any dash after the word is not a separator, so `yes-no questions only` is kept whole); `drop it` on a can't-check ask adds no rule and leaves it Not checked. `MAX_QUESTIONS` is 3: more asks than that stops the draft before the confirm turn (stop `look-asks-too-many`, no extra spend) with `tooManyAsksText`, a code-written list of every ask and its reading. Asks carry `ask: 'reading' | 'cant-check'` (and `reading` for the agree text) through `normalizeQuestions`.
4507
4509
  - **The fit check (F243, `src/fitcheck.js`; `docs/product/ITEM33-BUILD.md` "Addendum 2026-10-21 — fit check build spec").** Rubric jobs only, once, after the inputs are frozen and the content gate passes and BEFORE the look; it runs only when the caller passes the answer seam `fitAsk` to `authorCloseForJob` (the panel; the CLI door and any test without it never run it; `fitFn: null` = no check). `runFitCheck` makes ONE AI call (the drafter identity, the drafting thinking rule, label `fit-check`, cap checked before the call) that splits each job line (no `~` rules) into asks copied from that line and quotes the page for each; plain code (`decideFit`) decides: an ask is found only if `found` is true AND its quote is on an input (whitespace and case ignored), a found-with-off-page-quote is `madeUp` and counts as not found, a reply with an ask not copied from its line or a line with no ask is malformed (one retry). All found = `fits` (nothing shown); any not found = `ask`: one question through the panel `ask` seam (`I found X of Y of your asks on this page. Not found: <ask> (line N), .... Type go on to keep drafting, or anything else to stop and change the job or the page.`); `go on` continues to the look, anything else stops `fit-stopped` (plain words in `draftStopText`), no answer is `confirm-abandoned`. The answer is not a `~` rule and changes nothing in the job. Failure is OPEN: a cut, two unreadable replies, a failed call or a cap stop is `absent`, chat says "The fit check did not finish; drafting goes on." and drafting goes on. The result is one `fit-check` row in `draft-log.jsonl`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bareloop",
3
- "version": "0.48.0",
3
+ "version": "0.49.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.21.0",
32
- "bareguard": "^0.25.1",
31
+ "barebrowse": "^0.24.1",
32
+ "bareguard": "^0.26.0",
33
33
  "litectx": "^0.32.0"
34
34
  },
35
35
  "devDependencies": {
package/src/bundlerun.js CHANGED
@@ -73,7 +73,7 @@ export async function bundleMain(args, {
73
73
  let guided = guidedIn;
74
74
  if (bundleDirArg === undefined) {
75
75
  if (!askable || !ask) return usage();
76
- const r = await askBundle({ ask, out, ...(home === undefined ? {} : { home }), none: 'No exported bundles yet. Export one with 6.', cancelled: 'No bundle chosen, nothing run.' });
76
+ const r = await askBundle({ ask, out, ...(home === undefined ? {} : { home }), none: 'No exported bundles yet. Export one with 7.', cancelled: 'No bundle chosen, nothing run.' });
77
77
  if ('end' in r) return 0;
78
78
  bundleDirArg = r.ref;
79
79
  guided = true;
package/src/cli.js CHANGED
@@ -37,7 +37,7 @@ import { bundleMain } from './bundlerun.js';
37
37
  // rather than re-parsing argv a second time here keeps exactly one code
38
38
  // path for the flag grammar; `src/cli.js` only supplies the deps shape
39
39
  // (`out`/`err`/`env`) this command's own callers already use.
40
- import { startCmd, stopCmd, restartCmd, statusCmd, installCmd, menuCmd } from './launcher.js';
40
+ import { startCmd, stopCmd, restartCmd, statusCmd, installCmd, updateCmd, menuCmd } from './launcher.js';
41
41
  import { askBundle, resolveBundleRef, listResumableBundleRuns, RECENT_BUNDLES } from './bundleref.js';
42
42
  import { makePaint } from './tty-colour.js';
43
43
  import { main as runUMain } from './userrun.js';
@@ -228,7 +228,7 @@ async function doHistory(args, { out, err, cwd, ask, canAsk, deps }) {
228
228
  let bundleDirArg = args[0];
229
229
  if (!bundleDirArg) {
230
230
  if (!canAsk) { err('usage: bareloop history <bundle>'); return 1; }
231
- const r = await askBundle({ ask, out, ...(home === undefined ? {} : { home }), none: 'No exported bundles yet. Export one with 6.', cancelled: 'No bundle chosen, nothing shown.' });
231
+ const r = await askBundle({ ask, out, ...(home === undefined ? {} : { home }), none: 'No exported bundles yet. Export one with 7.', cancelled: 'No bundle chosen, nothing shown.' });
232
232
  if ('end' in r) return 0;
233
233
  bundleDirArg = r.ref;
234
234
  }
@@ -271,11 +271,11 @@ function doRuns(_args, { out, deps }) {
271
271
  }
272
272
 
273
273
  /**
274
- * The launcher doors (L, PANEL-BUILD.md addendum 2026-10-24): the bare `bareloop` menu and `start | stop | status | install`. All logic is
274
+ * The launcher doors (L, PANEL-BUILD.md addendum 2026-10-24): the bare `bareloop` menu and `start | stop | status | install | update`. All logic is
275
275
  * `src/launcher.js`; this only supplies the home (the SAME one `main` resolved for the keys file and config.json) and the line reader.
276
276
  * `deps.launcher` is the test seam for every OS touch (ports, spawn, kill, opener, clock).
277
- * @param {string} cmd 'menu' | 'start' | 'stop' | 'status' | 'install' @param {string[]} rest
278
- * @param {any} deps @param {{ out: (s: string) => void, err: (s: string) => void, ask: (q: string) => Promise<string> }} io @param {string|undefined} home
277
+ * @param {string} cmd 'menu' | 'start' | 'stop' | 'status' | 'install' | 'update' @param {string[]} rest
278
+ * @param {any} deps @param {{ out: (s: string) => void, err: (s: string) => void, ask: (q: string) => Promise<string>, canAsk: boolean }} io @param {string|undefined} home
279
279
  * @returns {Promise<number>}
280
280
  */
281
281
  async function runLauncher(cmd, rest, deps, io, home) {
@@ -290,12 +290,13 @@ async function runLauncher(cmd, rest, deps, io, home) {
290
290
  resume: () => doResumeMenu(jobCtx),
291
291
  history: () => doHistory([], jobCtx),
292
292
  };
293
- const d = { home, jobs, ask, paint: makePaint(deps.stdout ?? process.stdout, rawEnv), paintErr: makePaint(deps.stderr ?? process.stderr, rawEnv), ...(deps.launcher ?? {}) };
293
+ const d = { home, jobs, ask, terminal: io.canAsk, paint: makePaint(deps.stdout ?? process.stdout, rawEnv), paintErr: makePaint(deps.stderr ?? process.stderr, rawEnv), ...(deps.launcher ?? {}) };
294
294
  if (cmd === 'start') return startCmd(io, d);
295
295
  if (cmd === 'stop') return stopCmd(rest, io, d);
296
296
  if (cmd === 'restart') return restartCmd(rest, io, d);
297
297
  if (cmd === 'status') return statusCmd(io, d);
298
298
  if (cmd === 'install') return installCmd(io, d);
299
+ if (cmd === 'update') return updateCmd(io, d);
299
300
  return menuCmd(io, d);
300
301
  }
301
302
 
@@ -340,7 +341,7 @@ async function mainInner(argv, deps, holder) {
340
341
  if (keys.warning && cmd && ['run', 'run-u', 'panel'].includes(cmd)) err(`WARNING: ${keys.warning}`);
341
342
  const launcherHome = keys.home ?? deps.runlistHome;
342
343
  if (!cmd) return runLauncher('menu', [], { ...deps, stdout }, ctx, launcherHome);
343
- if (cmd === 'start' || cmd === 'stop' || cmd === 'restart' || cmd === 'status' || cmd === 'install') return runLauncher(cmd, rest, { ...deps, stdout }, ctx, launcherHome);
344
+ if (cmd === 'start' || cmd === 'stop' || cmd === 'restart' || cmd === 'status' || cmd === 'install' || cmd === 'update') return runLauncher(cmd, rest, { ...deps, stdout }, ctx, launcherHome);
344
345
  // the old form (`export <jobs/x.json> --registry <dir> --out <dir>`) is the bench's; the new one is by run name
345
346
  if (cmd === 'export') return rest.includes('--registry') ? doExport(rest, ctx) : doExportRun(rest, ctx);
346
347
  if (cmd === 'run') return bundleMain(rest, { ...ctx, keysHome: keys.home, parseFlags, printReds });
@@ -365,6 +366,6 @@ async function mainInner(argv, deps, holder) {
365
366
  // and spine/gate-audit reads over `127.0.0.1` only. `deps.runlistHome`
366
367
  // rides through the same injectable seam `run`/`run-u` already use.
367
368
  if (cmd === 'panel') return panelMain(rest, { out, err, runlistHome: deps.runlistHome, env: deps.env });
368
- err(`unknown command ${JSON.stringify(cmd)} — one of: export, run, history, runs, panel, start, stop, restart, status, install`);
369
+ err(`unknown command ${JSON.stringify(cmd)} — one of: export, run, history, runs, panel, start, stop, restart, status, install, update`);
369
370
  return 1;
370
371
  }
package/src/facts.js CHANGED
@@ -97,7 +97,7 @@ export function factShapeReds(part, w, red) {
97
97
  const list = asList(us);
98
98
  if (list.length > MAX_UNITS) red('invalid-value', `${fw}.unit`, `at most ${MAX_UNITS} units (${list.length} given)`);
99
99
  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).size !== list.length) red('invalid-value', `${fw}.unit`, 'the units are not repeated');
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
101
  }
102
102
  }
103
103
  if (has('currency')) {
package/src/launcher.js CHANGED
@@ -29,6 +29,8 @@ const WAIT_DEADLINE_MS = 10_000;
29
29
  /** how long `start` keeps asking a TAKEN port that stays silent before it refuses to open another panel next to it */
30
30
  const SILENT_PORT_WAIT_MS = 10_000;
31
31
  const POLL_MS = 100;
32
+ /** not in the signed text: how long `npm install -g` may run before its own child is killed */
33
+ const NPM_DEADLINE_MS = 300_000;
32
34
  const MIN_NODE_MAJOR = 22;
33
35
  const RULE_WIDTH = 56;
34
36
 
@@ -49,6 +51,10 @@ const RULE_WIDTH = 56;
49
51
  * @property {number} [silentWaitMs] how long start keeps asking a taken, silent port (default 10 s)
50
52
  * @property {string} [nodeVersion] default process.versions.node
51
53
  * @property {typeof fetch} [fetchImpl]
54
+ * @property {(cmd: string, args: string[], o: object) => any} [npmSpawn] runs `npm install -g bareloop@latest` for `update` (default node:child_process spawn, no shell)
55
+ * @property {number} [npmDeadlineMs] how long `update`'s npm install may run before its child is killed (default 300 s)
56
+ * @property {boolean} [terminal] false = no person at a terminal (piped / redirected stdin): `update` then never installs, it prints the command (absent = ask)
57
+ * @property {typeof fetch} [npmFetch] the registry check of `update` only (default the global fetch); nothing else ever goes online
52
58
  * @property {(cmd: string, args: string[], o: object) => any} [spawnFn] default node:child_process spawn
53
59
  * @property {(pid: number, sig: string|number) => void} [kill] default process.kill
54
60
  * @property {((target: string) => Promise<boolean>)} [open] default the shared OS opener
@@ -266,7 +272,7 @@ export async function installCmd(io, d, shown) {
266
272
  return 1;
267
273
  }
268
274
  }
269
- if (made.length === 0) { io.out('Already installed, nothing to do.'); return 0; }
275
+ if (made.length === 0) { io.out('Already set up. This does not update bareloop. Pick 6 update for that.'); return 0; }
270
276
  io.out('Installed. Created:');
271
277
  for (const m of made) io.out(` ${m}`);
272
278
  return 0;
@@ -291,6 +297,69 @@ export async function statusCmd(io, d, shown) {
291
297
  return 0;
292
298
  }
293
299
 
300
+ /** @param {string} v @returns {number[]|null} major, minor, patch of `1.2.3` (a `-pre` tail is ignored); null when it is not that shape */
301
+ function parseVersion(v) {
302
+ const m = /^(\d+)\.(\d+)\.(\d+)/.exec(v);
303
+ return m ? [Number(m[1]), Number(m[2]), Number(m[3])] : null;
304
+ }
305
+
306
+ /** @param {number[]} a @param {number[]} b @returns {boolean} a is newer than b */
307
+ const isNewer = (a, b) => ((a[0] - b[0]) || (a[1] - b[1]) || (a[2] - b[2])) > 0;
308
+
309
+ /**
310
+ * `bareloop update` — the only launcher command that goes online, and only when pressed: reads the newest published version from the npm
311
+ * registry (5 s deadline) and says whether there is a newer one. It installs nothing; it tells the person the command.
312
+ * @param {{out: (s: string) => void, err: (s: string) => void}} io @param {LauncherDeps & {version?: string}} d @param {{lines: string[], panels: Panel[]}} [shown]
313
+ * @returns {Promise<number>}
314
+ */
315
+ export async function updateCmd(io, d, shown) {
316
+ await headerOnce(io, d, shown);
317
+ const mine = d.version ?? packageVersion();
318
+ /** @type {number[]|null} */
319
+ let latest = null;
320
+ /** @type {string} */
321
+ let latestText = '';
322
+ try {
323
+ const res = await (d.npmFetch ?? fetch)('https://registry.npmjs.org/bareloop/latest', { signal: AbortSignal.timeout(5000) });
324
+ if (res.ok) {
325
+ const j = /** @type {{version?: unknown}} */ (await res.json());
326
+ latestText = typeof j?.version === 'string' ? j.version : '';
327
+ latest = parseVersion(latestText);
328
+ }
329
+ } catch { /* offline, timeout, bad JSON: the one plain line below */ }
330
+ const have = parseVersion(mine);
331
+ if (!latest || !have) {
332
+ fail(io, d, 'Could not reach npm to check. Try again later.');
333
+ return 1;
334
+ }
335
+ if (!isNewer(latest, have)) { io.out(`You have the newest bareloop (${mine}).`); return 0; }
336
+ const manual = 'npm install -g bareloop@latest';
337
+ io.out(`bareloop ${latestText} is out. You have ${mine}.`);
338
+ if (!d.ask || d.terminal === false) { io.out(`To update: ${manual}`); return 0; }
339
+ // an empty Enter or other text asks once more; a second one ends as "no"
340
+ let yes = false;
341
+ for (let i = 0; i < 2; i += 1) {
342
+ const a = (await d.ask('Update now? (y/n) ')).trim().toLowerCase();
343
+ if (a === 'y' || a === 'yes') { yes = true; break; }
344
+ if (a === 'n' || a === 'no' || a === 'q') break;
345
+ }
346
+ if (!yes) { io.out(`Not updated. To update later: ${manual}`); return 0; }
347
+ const ok = await new Promise((resolve) => {
348
+ let timer;
349
+ const end = (/** @type {boolean} */ v) => { clearTimeout(timer); resolve(v); };
350
+ try {
351
+ const child = (d.npmSpawn ?? realSpawn)('npm', ['install', '-g', 'bareloop@latest'], { stdio: 'inherit' });
352
+ // not in the signed text: npm may run this long, then its own child is ended (aligned with fwdloop)
353
+ timer = setTimeout(() => { try { child.kill('SIGTERM'); } catch { /* already gone */ } end(false); }, d.npmDeadlineMs ?? NPM_DEADLINE_MS);
354
+ child.once('error', () => end(false));
355
+ child.once('close', (code) => end(code === 0));
356
+ } catch { end(false); }
357
+ });
358
+ if (!ok) { fail(io, d, `The update did not finish. Run it yourself: ${manual}`); return 1; }
359
+ io.out(`Updated to ${latestText}. Then ${shown ? 'pick 3 restart' : 'run bareloop restart'}.`); // the menu door (shown) has the menu; the subcommand door has none
360
+ return 0;
361
+ }
362
+
294
363
  /**
295
364
  * Wait until `port` stops (gone=true) or starts (gone=false) answering whoami as bareloop.
296
365
  * @param {LauncherDeps} d @param {number} port @param {boolean} gone
@@ -484,8 +553,8 @@ export async function restartCmd(args, io, d, shown) {
484
553
  }
485
554
 
486
555
  /**
487
- * The bare `bareloop` menu (PRD v1.114, one menu): the panel's four choices, the four job commands, one question. Runs the chosen command
488
- * and returns its exit code. The job commands (6 export, 7 run, 8 resume, 9 history) are `d.jobs`, supplied by the CLI: each prompts for
556
+ * The bare `bareloop` menu (PRD v1.114, one menu): the panel's six choices, the four job commands, one question. Runs the chosen command
557
+ * and returns its exit code. The job commands (7 export, 8 run, 9 resume, 10 history) are `d.jobs`, supplied by the CLI: each prompts for
489
558
  * what it needs on the same asker this menu uses.
490
559
  * @param {{out: (s: string) => void, err: (s: string) => void}} io @param {LauncherDeps & {version?: string, jobs?: {export: () => Promise<number>, run: () => Promise<number>, resume: () => Promise<number>, history: () => Promise<number>}}} d
491
560
  * @returns {Promise<number>}
@@ -498,8 +567,8 @@ export async function menuCmd(io, d) {
498
567
  if (!P.on) io.out('');
499
568
  const n = (/** @type {string} */ k) => P.boldCyan(k);
500
569
  const ind = P.on ? ' ' : '';
501
- io.out(`${ind}panel: ${n('1')} start ${n('2')} stop ${n('3')} restart ${n('4')} status ${n('5')} install`);
502
- io.out(`${ind}jobs: ${n('6')} export ${n('7')} run ${n('8')} resume ${n('9')} history`);
570
+ io.out(`${ind}panel: ${n('1')} start ${n('2')} stop ${n('3')} restart ${n('4')} status ${n('5')} install ${n('6')} update`);
571
+ io.out(`${ind}jobs: ${n('7')} export ${n('8')} run ${n('9')} resume ${n('10')} history`);
503
572
  io.out(`${ind}${n('q')} quit`);
504
573
  const choice = ask ? (await ask(`${P.cyan('>')} `)).trim().toLowerCase() : 'q';
505
574
  // the header is already on screen: the chosen command reuses it instead of printing it a second time
@@ -508,10 +577,11 @@ export async function menuCmd(io, d) {
508
577
  if (choice === '3' || choice === 'restart') return restartCmd([], io, d, h);
509
578
  if (choice === '4' || choice === 'status') return statusCmd(io, d, h);
510
579
  if (choice === '5' || choice === 'install') return installCmd(io, d, h);
511
- const jobChoices = { 6: 'export', export: 'export', 7: 'run', run: 'run', 8: 'resume', resume: 'resume', 9: 'history', history: 'history' };
580
+ if (choice === '6' || choice === 'update') return updateCmd(io, d, h);
581
+ const jobChoices = { 7: 'export', export: 'export', 8: 'run', run: 'run', 9: 'resume', resume: 'resume', 10: 'history', history: 'history' };
512
582
  const job = Object.hasOwn(jobChoices, choice) ? jobChoices[choice] : undefined; // never `constructor` / `__proto__`
513
583
  if (job !== undefined && d.jobs) return d.jobs[/** @type {'export'|'run'|'resume'|'history'} */ (job)]();
514
584
  if (choice === '' || choice === 'q' || choice === 'quit') return 0;
515
- fail(io, d, `unknown choice ${JSON.stringify(choice)} — one of: 1, 2, 3, 4, 5, 6, 7, 8, 9, q`);
585
+ fail(io, d, `unknown choice ${JSON.stringify(choice)} — one of: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, q`);
516
586
  return 1;
517
587
  }
@@ -22,6 +22,7 @@ const WORDS = /** @type {Record<string, (d: Dropped) => string>} */ ({
22
22
  'limit-unit': (d) => `Only the first 10 units are used; "${d.word}" was left out.`,
23
23
  'unit-too-long': (d) => `"${d.word}" is longer than 100 characters, so it was not used.`,
24
24
  'reads-no-result': () => "the price rule could not read a price in the page's results, so it is not checked.",
25
+ 'reads-no-time': (d) => `the page never shows a time right after "${d.other}", so it is not checked.`,
25
26
  'phrase-no-result': (d) => `"${d.other}" is on the page but in none of its results, so it is not checked.`,
26
27
  'person-left': () => 'You chose to leave it Not checked.',
27
28
  'bad-shape': (d) => `The AI named a kind of value for "${d.fact}" that a check cannot read.`,
package/src/pagedry.js CHANGED
@@ -4,6 +4,7 @@
4
4
  // uses - no copy of its logic here. A fact that reads no result line is dropped as `reads-no-result` and shows under Not checked.
5
5
  // No limits, no counts, no pass bar: only "can it read". Async (gradeStep is), so it sits beside applyPageRules, not inside it: the caller is
6
6
  // src/pagemap.js `runPageMap`. No I/O, no clock, no model.
7
+ // TIME DRY READ (docs/logs/time-dryread-poc-PREREG.md, F236/F237): the same "can it read" for TIME facts - `dryReadTimes` below.
7
8
 
8
9
  import { createHash } from 'node:crypto';
9
10
  import { gradeStep } from './rubricstep.js';
@@ -17,6 +18,23 @@ const AFTER_LABEL = new RegExp(`^\\s*(?:[$€£]\\s*)?(${NUM})`);
17
18
  /** the label every dry-read claim is made under (the checker only needs one name; the fact's own is not read) */
18
19
  const CLAIM = 'price';
19
20
  const SOURCE = 'page';
21
+ const CLAIM_TIME = 'time';
22
+
23
+ /**
24
+ * How many of `lines` the run's real checker reads green as an honest claim of `fact`: each line is graded alone by `gradeStep` (quote = the line,
25
+ * the claim named `claim` carrying the line's value). The one grading call money and time dry reads share.
26
+ * @param {string} text the frozen page text @param {string} sha its sha256 @param {object} fact the signed fact @param {string} claim the claim name inside `fact`
27
+ * @param {{quote: string, value: string}[]} lines @returns {Promise<number>}
28
+ */
29
+ async function greenLines(text, sha, fact, claim, lines) {
30
+ let n = 0;
31
+ for (const r of lines) {
32
+ const params = { step: 1, parts: [{ text: 'dry read', class: 'fact', source: SOURCE, covers: [1], facts: [fact] }] };
33
+ const g = await gradeStep({ params, bytes: JSON.stringify({ results: [{ quote: r.quote, values: { [claim]: r.value } }] }), outputBytes: null, inputs: { [SOURCE]: text } }, { [SOURCE]: sha });
34
+ if (g.verdict === 'green') n += 1;
35
+ }
36
+ return n;
37
+ }
20
38
 
21
39
  /**
22
40
  * The result lines of a kept money fact: with a label, every page line where a kept label is followed by a number (one sign between allowed);
@@ -73,12 +91,7 @@ export async function dryReadMoney(text, facts) {
73
91
  if (k.shape !== 'money') { kept.push(k); continue; }
74
92
  const fact = signedOf(k);
75
93
  const lines = moneyResultLines(text, k);
76
- let n = 0;
77
- for (const r of lines) {
78
- const params = { step: 1, parts: [{ text: 'dry read', class: 'fact', source: SOURCE, covers: [1], facts: [fact] }] };
79
- const g = await gradeStep({ params, bytes: JSON.stringify({ results: [{ quote: r.quote, values: { [CLAIM]: r.value } }] }), outputBytes: null, inputs: { [SOURCE]: text } }, { [SOURCE]: sha });
80
- if (g.verdict === 'green') n += 1;
81
- }
94
+ const n = await greenLines(text, sha, fact, CLAIM, lines);
82
95
  reads[k.name] = n;
83
96
  results[k.name] = lines.length;
84
97
  if (n > 0) { kept.push(k); continue; }
@@ -122,3 +135,61 @@ export async function dryReadPhrases(text, facts) {
122
135
  }
123
136
  return { facts: kept, dropped, reads };
124
137
  }
138
+
139
+ /** a clock time as the page writes it: H:MM or HH:MM, then an optional AM/PM (any case, a space between allowed) */
140
+ const CLOCK = /\d{1,2}:\d{2}(?:\s?[AaPp][Mm])?/;
141
+
142
+ /**
143
+ * The candidate lines of a kept time fact: a LOOSE finder (it only collects). Every page line where a kept label word has a clock time anywhere
144
+ * after it; the value is that line's first time after the label. Whether the run's checker can read it is not decided here.
145
+ * @param {string} text @param {KeptFact} k @returns {{quote: string, value: string}[]}
146
+ */
147
+ export function timeCandidateLines(text, k) {
148
+ const raw = text.split('\n');
149
+ const squashed = linesOf(text);
150
+ /** @type {{quote: string, value: string}[]} */
151
+ const out = [];
152
+ squashed.forEach((ln, i) => {
153
+ for (const w of k.words) {
154
+ for (let at = ln.indexOf(w); at !== -1; at = ln.indexOf(w, at + w.length)) {
155
+ const m = CLOCK.exec(ln.slice(at + w.length));
156
+ if (m) { out.push({ quote: raw[i].trim(), value: m[0] }); return; }
157
+ }
158
+ }
159
+ });
160
+ return out;
161
+ }
162
+
163
+ /**
164
+ * The same "can it read" for TIME facts (F236: the label "Departure time" sat on a page that writes "Departure time:", the colon right after it, so
165
+ * no time could ever be read after the label, and the fact was signed anyway). Each candidate line of a kept time fact is graded as an HONEST claim
166
+ * (quote = that line, value = its first time after the label) by the real `gradeStep`, signed like a run would sign it (name, shape, anchor = the
167
+ * primary label; no window, as dryReadMoney leaves the limits out). A fact with no green line is dropped whole as `reads-no-time`.
168
+ * No counts, no pass bar. A time fact with no label word has nothing to anchor a read to (a run could not sign it either), so it passes through untouched.
169
+ * Facts of other shapes pass through untouched. It catches an IMPOSSIBLE label only: a label that reads a WRONG time is kept (left to the person at Accept).
170
+ * @param {string} text the frozen page text @param {KeptFact[]} facts what the money dry read kept
171
+ * @returns {Promise<{facts: KeptFact[], dropped: Dropped[], reads: Record<string, number>, results: Record<string, number>}>}
172
+ * `reads` / `results` = candidate lines the checker read / found, per fact name (for tests and reports; no verdict derives from the numbers)
173
+ */
174
+ export async function dryReadTimes(text, facts) {
175
+ const sha = createHash('sha256').update(text).digest('hex');
176
+ /** @type {KeptFact[]} */
177
+ const kept = [];
178
+ /** @type {Dropped[]} */
179
+ const dropped = [];
180
+ /** @type {Record<string, number>} */
181
+ const reads = {};
182
+ /** @type {Record<string, number>} */
183
+ const results = {};
184
+ for (const k of facts) {
185
+ if (k.shape !== 'time' || !k.words.length) { kept.push(k); continue; }
186
+ const fact = { name: CLAIM_TIME, shape: 'time', anchor: k.words[0] };
187
+ const lines = timeCandidateLines(text, k);
188
+ const n = await greenLines(text, sha, fact, CLAIM_TIME, lines);
189
+ reads[k.name] = n;
190
+ results[k.name] = lines.length;
191
+ if (n > 0) { kept.push(k); continue; }
192
+ dropped.push({ line: k.line, ...(k.forRule === undefined ? {} : { rule: k.forRule }), fact: k.name, other: k.words[0], reason: 'reads-no-time' });
193
+ }
194
+ return { facts: kept, dropped, reads, results };
195
+ }
package/src/pagemap.js CHANGED
@@ -15,7 +15,7 @@ import { isOutputCutOff } from './authorflow.js';
15
15
  import { AUTHOR_CALL_TIMEOUT_MS, AUTHOR_SCOUT_MAX_TOKENS, SURVEY_CAUSES } from './authorscout.js';
16
16
  import { lineRules, boundInWords, wordsSaidOn } from './rubricstep.js';
17
17
  import { applyPageRules, validReading } from './pagerules.js';
18
- import { dryReadMoney, dryReadPhrases } from './pagedry.js';
18
+ import { dryReadMoney, dryReadTimes, dryReadPhrases } from './pagedry.js';
19
19
  import { ruleWords } from './facts.js';
20
20
  import { lookFactOf } from './inputlook.js';
21
21
 
@@ -167,10 +167,12 @@ export async function runPageMap({
167
167
  const kept = applyPageRules(texts[label], mapping, jobLines);
168
168
  // money build v2: "can it read" - a money fact whose forms read no result line of the page, by the run's own checker, is Not checked
169
169
  const read = await dryReadMoney(texts[label], kept.facts);
170
+ // time dry read (F236/F237): a time fact whose label has no time the run's checker can read after it is Not checked
171
+ const tim = await dryReadTimes(texts[label], read.facts);
170
172
  // hamr 3a: a phrase fact is read against the same result lines (only when the job keeps a money fact)
171
- const phr = await dryReadPhrases(texts[label], read.facts);
173
+ const phr = await dryReadPhrases(texts[label], tim.facts);
172
174
  for (const f of phr.facts) facts.push(lookFactOf(f, label));
173
- for (const d of [...kept.dropped, ...read.dropped, ...phr.dropped]) dropped.push({ ...d, source: label });
175
+ for (const d of [...kept.dropped, ...read.dropped, ...tim.dropped, ...phr.dropped]) dropped.push({ ...d, source: label });
174
176
  maps.push({ source: label, facts: mapping.facts.length });
175
177
  looks.push(label);
176
178
  }
@@ -188,6 +190,18 @@ export const isDropIt = (text) => String(text ?? '').trim().replace(/\.$/, '').t
188
190
  const AGREE_WORDS = ['agree', 'yes'];
189
191
  /** @param {unknown} text @returns {boolean} */
190
192
  export const isAgree = (text) => AGREE_WORDS.includes(String(text ?? '').trim().replace(/[.!]$/, '').toLowerCase());
193
+ /**
194
+ * F240: an answer that opens with an agree word IMMEDIATELY followed by a comma or a colon (spaces allowed only after it) and more text
195
+ * ("yes, check it as ...", "agree: the outbound flight") is the person's own reading with a courtesy word in front: the word and the
196
+ * comma/colon go, the rest stays word for word. No hyphen or dash of any kind and no bare space counts, so "yes-no questions only",
197
+ * "agree-ment on price", "yes - departs", "yes departs" and "yesterday, ..." are kept whole. A bare "yes"/"agree" (isAgree) and a text that
198
+ * only contains the word later are returned untouched.
199
+ * @param {string} text @returns {string}
200
+ */
201
+ export const stripAgreeLead = (text) => {
202
+ const m = String(text ?? '').match(new RegExp(`^(?:${AGREE_WORDS.join('|')})[,:]\\s*(\\S[\\s\\S]*)$`, 'i'));
203
+ return m ? m[1].trim() : String(text ?? '');
204
+ };
191
205
 
192
206
  /** @typedef {{line: number, rule: number, source: 'look', question: string, ask: 'reading'|'cant-check', ruleText: string, reading?: string}} LookAsk
193
207
  * `reading` = the plain words an `agree` writes as a `~` rule (a reading ask only) */
package/src/pagerules.js CHANGED
@@ -228,7 +228,8 @@ export function applyPageRules(text, mapping, jobLines) {
228
228
  // form the AI listed in either box is pooled and moved to the box its own shape belongs to
229
229
  const listedCurrencies = (Array.isArray(f.currency) ? f.currency : []).map(String);
230
230
  // a currency SIGN listed in BOTH unit and currency is said once: the unit copy goes (fwd F71 drafts)
231
- const listedUnits = (Array.isArray(f.unit) ? f.unit : []).map(String).filter((u) => {
231
+ // bareguard 0.26: two units equal after whitespace normalization are one form, so trim + collapse here and the twins collapse in the pool
232
+ const listedUnits = (Array.isArray(f.unit) ? f.unit : []).map((u) => String(u).replace(/\s+/g, ' ').trim()).filter((u) => {
232
233
  if (!(CURRENCY_SYMBOLS.includes(u) && listedCurrencies.includes(u))) return true;
233
234
  drop(f, u, 'sign-twice');
234
235
  return false;
@@ -53,7 +53,7 @@ import { closeJudges } from '../kinds.js';
53
53
  import { RUBRIC_LANG } from '../authoring.js';
54
54
  import { rubricGoal, reconcileRubricPlan, signedFactNames } from '../rubricstep.js';
55
55
  import { redactSecrets } from '../validate.js';
56
- import { isDropIt, isAgree } from '../pagemap.js';
56
+ import { isDropIt, isAgree, stripAgreeLead } from '../pagemap.js';
57
57
  import { FIT_ABSENT_NOTE } from '../fitcheck.js';
58
58
  import { tallyCalls } from '../text.js';
59
59
  import { appendDraftLog } from '../draftspend.js';
@@ -1067,6 +1067,8 @@ export function createSession(card, deps = {}) {
1067
1067
  // PRD v1.107 Part 5b: a code-forced look question about a `~` rule. A can't-check ask answered "drop it" adds NO rule; the caller puts that
1068
1068
  // rule on the look's Not checked list. A reading ask answered "agree" adds the code's reading, in plain words, as the `~` rule (so the
1069
1069
  // bound is now the person's own words); anything else typed is the person's own rule, word for word.
1070
+ // F240: "yes, check it as ..." is the person's own words minus the leading "yes,"
1071
+ if (q.source === 'look') text = stripAgreeLead(text);
1070
1072
  if (q.source === 'look' && q.ask === 'reading' && typeof q.reading === 'string' && isAgree(text)) text = q.reading;
1071
1073
  if (q.source === 'look' && q.ask === 'cant-check' && Number.isInteger(q.rule) && isDropIt(text)) { left.push({ line: q.line, rule: /** @type {number} */ (q.rule) }); continue; }
1072
1074
  const line = jobLines.find((l) => l.n === q.line);
@@ -14,6 +14,10 @@
14
14
  * @property {number} [silentWaitMs] how long start keeps asking a taken, silent port (default 10 s)
15
15
  * @property {string} [nodeVersion] default process.versions.node
16
16
  * @property {typeof fetch} [fetchImpl]
17
+ * @property {(cmd: string, args: string[], o: object) => any} [npmSpawn] runs `npm install -g bareloop@latest` for `update` (default node:child_process spawn, no shell)
18
+ * @property {number} [npmDeadlineMs] how long `update`'s npm install may run before its child is killed (default 300 s)
19
+ * @property {boolean} [terminal] false = no person at a terminal (piped / redirected stdin): `update` then never installs, it prints the command (absent = ask)
20
+ * @property {typeof fetch} [npmFetch] the registry check of `update` only (default the global fetch); nothing else ever goes online
17
21
  * @property {(cmd: string, args: string[], o: object) => any} [spawnFn] default node:child_process spawn
18
22
  * @property {(pid: number, sig: string|number) => void} [kill] default process.kill
19
23
  * @property {((target: string) => Promise<boolean>)} [open] default the shared OS opener
@@ -126,6 +130,21 @@ export function statusCmd(io: {
126
130
  lines: string[];
127
131
  panels: Panel[];
128
132
  }): Promise<number>;
133
+ /**
134
+ * `bareloop update` — the only launcher command that goes online, and only when pressed: reads the newest published version from the npm
135
+ * registry (5 s deadline) and says whether there is a newer one. It installs nothing; it tells the person the command.
136
+ * @param {{out: (s: string) => void, err: (s: string) => void}} io @param {LauncherDeps & {version?: string}} d @param {{lines: string[], panels: Panel[]}} [shown]
137
+ * @returns {Promise<number>}
138
+ */
139
+ export function updateCmd(io: {
140
+ out: (s: string) => void;
141
+ err: (s: string) => void;
142
+ }, d: LauncherDeps & {
143
+ version?: string;
144
+ }, shown?: {
145
+ lines: string[];
146
+ panels: Panel[];
147
+ }): Promise<number>;
129
148
  /**
130
149
  * `bareloop start` — find a running panel first; else start one detached on the first free port 4700..4709, wait until it answers,
131
150
  * open the page.
@@ -175,8 +194,8 @@ export function restartCmd(args: string[], io: {
175
194
  panels: Panel[];
176
195
  }): Promise<number>;
177
196
  /**
178
- * The bare `bareloop` menu (PRD v1.114, one menu): the panel's four choices, the four job commands, one question. Runs the chosen command
179
- * and returns its exit code. The job commands (6 export, 7 run, 8 resume, 9 history) are `d.jobs`, supplied by the CLI: each prompts for
197
+ * The bare `bareloop` menu (PRD v1.114, one menu): the panel's six choices, the four job commands, one question. Runs the chosen command
198
+ * and returns its exit code. The job commands (7 export, 8 run, 9 resume, 10 history) are `d.jobs`, supplied by the CLI: each prompts for
180
199
  * what it needs on the same asker this menu uses.
181
200
  * @param {{out: (s: string) => void, err: (s: string) => void}} io @param {LauncherDeps & {version?: string, jobs?: {export: () => Promise<number>, run: () => Promise<number>, resume: () => Promise<number>, history: () => Promise<number>}}} d
182
201
  * @returns {Promise<number>}
@@ -242,6 +261,22 @@ export type LauncherDeps = {
242
261
  */
243
262
  nodeVersion?: string | undefined;
244
263
  fetchImpl?: typeof fetch | undefined;
264
+ /**
265
+ * runs `npm install -g bareloop@latest` for `update` (default node:child_process spawn, no shell)
266
+ */
267
+ npmSpawn?: ((cmd: string, args: string[], o: object) => any) | undefined;
268
+ /**
269
+ * how long `update`'s npm install may run before its child is killed (default 300 s)
270
+ */
271
+ npmDeadlineMs?: number | undefined;
272
+ /**
273
+ * false = no person at a terminal (piped / redirected stdin): `update` then never installs, it prints the command (absent = ask)
274
+ */
275
+ terminal?: boolean | undefined;
276
+ /**
277
+ * the registry check of `update` only (default the global fetch); nothing else ever goes online
278
+ */
279
+ npmFetch?: typeof fetch | undefined;
245
280
  /**
246
281
  * default node:child_process spawn
247
282
  */
@@ -33,5 +33,31 @@ export function dryReadPhrases(text: string, facts: KeptFact[]): Promise<{
33
33
  dropped: Dropped[];
34
34
  reads: Record<string, number>;
35
35
  }>;
36
+ /**
37
+ * The candidate lines of a kept time fact: a LOOSE finder (it only collects). Every page line where a kept label word has a clock time anywhere
38
+ * after it; the value is that line's first time after the label. Whether the run's checker can read it is not decided here.
39
+ * @param {string} text @param {KeptFact} k @returns {{quote: string, value: string}[]}
40
+ */
41
+ export function timeCandidateLines(text: string, k: KeptFact): {
42
+ quote: string;
43
+ value: string;
44
+ }[];
45
+ /**
46
+ * The same "can it read" for TIME facts (F236: the label "Departure time" sat on a page that writes "Departure time:", the colon right after it, so
47
+ * no time could ever be read after the label, and the fact was signed anyway). Each candidate line of a kept time fact is graded as an HONEST claim
48
+ * (quote = that line, value = its first time after the label) by the real `gradeStep`, signed like a run would sign it (name, shape, anchor = the
49
+ * primary label; no window, as dryReadMoney leaves the limits out). A fact with no green line is dropped whole as `reads-no-time`.
50
+ * No counts, no pass bar. A time fact with no label word has nothing to anchor a read to (a run could not sign it either), so it passes through untouched.
51
+ * Facts of other shapes pass through untouched. It catches an IMPOSSIBLE label only: a label that reads a WRONG time is kept (left to the person at Accept).
52
+ * @param {string} text the frozen page text @param {KeptFact[]} facts what the money dry read kept
53
+ * @returns {Promise<{facts: KeptFact[], dropped: Dropped[], reads: Record<string, number>, results: Record<string, number>}>}
54
+ * `reads` / `results` = candidate lines the checker read / found, per fact name (for tests and reports; no verdict derives from the numbers)
55
+ */
56
+ export function dryReadTimes(text: string, facts: KeptFact[]): Promise<{
57
+ facts: KeptFact[];
58
+ dropped: Dropped[];
59
+ reads: Record<string, number>;
60
+ results: Record<string, number>;
61
+ }>;
36
62
  export type KeptFact = import("./pagerules.js").KeptFact;
37
63
  export type Dropped = import("./pagerules.js").Dropped;
@@ -139,6 +139,7 @@ export const MAP_UNREADABLE: "The AI's answer about the page was not readable tw
139
139
  export const DROP_IT: "drop it";
140
140
  export function isDropIt(text: unknown): boolean;
141
141
  export function isAgree(text: unknown): boolean;
142
+ export function stripAgreeLead(text: string): string;
142
143
  /**
143
144
  * `reading` = the plain words an `agree` writes as a `~` rule (a reading ask only)
144
145
  */