bareloop 0.49.0 → 0.50.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,34 @@ 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.50.0] - 2026-10-28
9
+
10
+ ### Added
11
+
12
+ - **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.
13
+ - **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.
14
+ - **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.
15
+ - **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.
16
+ - **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.
17
+ - **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.
18
+
19
+ ### Changed
20
+
21
+ - **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.
22
+ - **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.
23
+ - **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.
24
+
25
+ ### Fixed
26
+
27
+ - **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.
28
+ - **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.
29
+ - **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).
30
+ - **Panel: a `~` rule line in "The job" box shows `~` in the gutter, as fwdloop does.** Numbering is unchanged.
31
+ - **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).
32
+ - **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.
33
+ - **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.`.
34
+ - **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.
35
+
8
36
  ## [0.49.0] - 2026-10-26
9
37
 
10
38
  ### Added
@@ -4457,15 +4457,17 @@ A **Rubric** job whose first Input is the full path of a FILE (not a repo folder
4457
4457
 
4458
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)
4459
4459
 
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
+ 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
4461
 
4462
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.
4463
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
4464
  - **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
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.
4466
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.
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
- - **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.
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|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).
4468
+ - **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).
4469
+ - **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.
4470
+ - **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
4471
  - **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
4472
  - **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
4473
  - **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 +4476,7 @@ Check what the person asked for, not what the worker chose to write. bareloop ne
4474
4476
  - **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
4477
  - **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
4478
  - **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`).
4479
+ - **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
4480
  - **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
4481
  - **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
4482
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bareloop",
3
- "version": "0.49.0",
3
+ "version": "0.50.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.24.1",
32
- "bareguard": "^0.26.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,
@@ -1445,6 +1447,8 @@ export const REQUIRED_FACTS_BRIEF = 'REQUIRED FACTS — what a line that finds,
1445
1447
  + '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
1448
  + ' - 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
1449
  + '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'
1450
+ + ' - 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. '
1451
+ + '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
1452
  + ' - 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
1453
  + ' - Set aiProposal true on a fact whose number you made out of their words.\n'
1450
1454
  + 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
- * @param {any} part @param {unknown} results @returns {{claim: string, quote: string, values?: Record<string, string>}[]}
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>}|null}
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/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})`);
@@ -3,15 +3,18 @@
3
3
  // block all read these words; no other file writes a drop reason (a test greps for it). Plain words, written by CODE from the drop's reason
4
4
  // code, never a raw code and never model-written. `<label>` is the page's own word.
5
5
 
6
+ import { FACT_LANGS } from './facts.js';
7
+
6
8
  /** @typedef {import('./pagerules.js').Dropped} Dropped */
7
9
 
8
10
  /** reason code -> the plain sentence (`d.word` = the page's word, `d.fact` = the fact's name, `d.other` = what it was compared to) */
9
11
  const WORDS = /** @type {Record<string, (d: Dropped) => string>} */ ({
10
12
  'not-on-page': (d) => `"${d.word}" is not written on the page.`,
11
13
  'no-value': (d) => `The page never shows a number right after or right before "${d.word}".`,
14
+ 'reads-no-amount': (d) => `The page never shows an amount next to "${d.word}", so it was not used to write the price.`,
12
15
  'n2': (d) => `"${d.word}" is written more than once inside one line of the page, so one result cannot show it once.`,
13
16
  'r1': (d) => `"${d.word}" does not show the same values as "${d.other}", so it was not used as a second way to read it.`,
14
- 'sign-twice': (d) => `"${d.word}" was listed twice, as a unit and as a currency; it is used once, as the currency.`,
17
+ 'sign-twice': (d) => `"${d.word}" was listed twice, as a unit and as a currency; it is used once, as the ${d.other === 'unit' ? 'unit' : 'currency'}.`,
15
18
  'r1l': (d) => d.word === d.other
16
19
  ? `"${d.word}" was listed twice, as a unit and as a currency; it is used once, as the first way to write the price.`
17
20
  : `"${d.word}" does not show the same amounts as "${d.other}", so it was not used as a second way to write the price.`,
@@ -23,6 +26,8 @@ const WORDS = /** @type {Record<string, (d: Dropped) => string>} */ ({
23
26
  'unit-too-long': (d) => `"${d.word}" is longer than 100 characters, so it was not used.`,
24
27
  'reads-no-result': () => "the price rule could not read a price in the page's results, so it is not checked.",
25
28
  'reads-no-time': (d) => `the page never shows a time right after "${d.other}", so it is not checked.`,
29
+ 'lang-not-on-page': (d) => `the page shows no month name in ${FACT_LANGS[/** @type {keyof typeof FACT_LANGS} */ (d.other ?? '')] ?? d.other}, so the date is not checked.`,
30
+ 'decimal-not-on-page': () => 'the page shows no amount written with a comma before the decimals, so it is not checked.',
26
31
  'phrase-no-result': (d) => `"${d.other}" is on the page but in none of its results, so it is not checked.`,
27
32
  'person-left': () => 'You chose to leave it Not checked.',
28
33
  'bad-shape': (d) => `The AI named a kind of value for "${d.fact}" that a check cannot read.`,
@@ -68,7 +73,7 @@ export function dropLine(row, jobLines, rulesOf) {
68
73
  // HOW THE PAGE WAS READ (run mvij7kuk, flight-c1): a drop of ONE WORD whose fact is still checked is a NOTE about the form code did not use, not
69
74
  // something left unchecked. The sentences for those reasons are WORD-level; every other sentence (a whole fact left out) keeps the line under
70
75
  // Not checked. Classified from the line's own words, so it holds for a signed spec already on disk.
71
- const WORD_REASONS = ['not-on-page', 'no-value', 'n2', 'r1', 'sign-twice', 'r1l', 'limit-currency', 'limit-unit', 'unit-too-long'];
76
+ const WORD_REASONS = ['not-on-page', 'no-value', 'reads-no-amount', 'n2', 'r1', 'sign-twice', 'r1l', 'limit-currency', 'limit-unit', 'unit-too-long'];
72
77
  /** @param {string} s */
73
78
  const esc = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
74
79
  const SENTENCE_RE = (() => {
@@ -76,7 +81,7 @@ const SENTENCE_RE = (() => {
76
81
  /** @type {string[]} */
77
82
  const alts = [];
78
83
  for (const reason of WORD_REASONS) {
79
- const probes = reason === 'r1l' ? [{ word: W, other: W }, { word: W, other: O }] : [{ word: W, other: O }];
84
+ const probes = reason === 'r1l' ? [{ word: W, other: W }, { word: W, other: O }] : reason === 'sign-twice' ? [{ word: W, other: 'currency' }, { word: W, other: 'unit' }] : [{ word: W, other: O }];
80
85
  for (const p of probes) alts.push(esc(WORDS[reason](/** @type {any} */ ({ ...p, reason, line: 0, fact: 'f' }))).split(esc(W)).join('[^"]+').split(esc(O)).join('[^"]+'));
81
86
  }
82
87
  return new RegExp(`^(?:(?:${alts.join('|')})(?: |$))+$`);
package/src/pagedry.js CHANGED
@@ -8,13 +8,16 @@
8
8
 
9
9
  import { createHash } from 'node:crypto';
10
10
  import { gradeStep } from './rubricstep.js';
11
- import { linesOf, numberAtEnd } from './pagerules.js';
11
+ import { linesOf, numberAtEnd, numberAtEndComma, NUM_COMMA } from './pagerules.js';
12
12
 
13
13
  /** @typedef {import('./pagerules.js').KeptFact} KeptFact @typedef {import('./pagerules.js').Dropped} Dropped */
14
14
 
15
15
  /** a number as the page writes it, thousands commas allowed */
16
16
  const NUM = '\\d[\\d,]*(?:\\.\\d+)?';
17
17
  const AFTER_LABEL = new RegExp(`^\\s*(?:[$€£]\\s*)?(${NUM})`);
18
+ const AFTER_LABEL_COMMA = new RegExp(`^\\s*(?:[$€£]\\s*)?(${NUM_COMMA})`);
19
+ /** the symbols a currency may be; one right before a number reads the number after it */
20
+ const SIGNS = ['$', '€', '£'];
18
21
  /** the label every dry-read claim is made under (the checker only needs one name; the fact's own is not read) */
19
22
  const CLAIM = 'price';
20
23
  const SOURCE = 'page';
@@ -38,12 +41,20 @@ async function greenLines(text, sha, fact, claim, lines) {
38
41
 
39
42
  /**
40
43
  * 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);
41
- * with no label (U1 moved it to a unit, e.g. "€533 total"), every line where a number is followed by a kept unit.
44
+ * with no label (U1 moved it to a unit, e.g. "€533 total", or a sign alone, e.g. "48,49€"), every line where a number sits right before a kept
45
+ * unit or sign, or right after a kept sign. A fact that signs `decimal: ","` is read in that form: groups of three joined by "." or a space, a comma
46
+ * before the decimals. The value is always the CANONICAL amount ("1057.65"): the typed value a claim carries, never the page's spelling.
47
+ * A LOOSE finder (it only collects): whether the run's checker can read the line is `gradeStep`'s to say.
42
48
  * @param {string} text @param {KeptFact} k @returns {{quote: string, value: string}[]}
43
49
  */
44
50
  export function moneyResultLines(text, k) {
45
51
  const raw = text.split('\n');
46
52
  const squashed = linesOf(text);
53
+ const comma = k.decimal === ',';
54
+ const afterLabel = comma ? AFTER_LABEL_COMMA : AFTER_LABEL;
55
+ const endNumber = comma ? numberAtEndComma : numberAtEnd;
56
+ /** the page's amount as a canonical decimal string */
57
+ const canon = (/** @type {string} */ a) => (comma ? a.replace(/[. ]/g, '').replace(',', '.') : a.replace(/,/g, ''));
47
58
  /** @type {{quote: string, value: string}[]} */
48
59
  const out = [];
49
60
  squashed.forEach((ln, i) => {
@@ -51,16 +62,19 @@ export function moneyResultLines(text, k) {
51
62
  let amount;
52
63
  if (k.words.length) {
53
64
  for (const w of k.words) {
54
- for (let at = ln.indexOf(w); at !== -1 && amount === undefined; at = ln.indexOf(w, at + w.length)) amount = AFTER_LABEL.exec(ln.slice(at + w.length))?.[1];
65
+ for (let at = ln.indexOf(w); at !== -1 && amount === undefined; at = ln.indexOf(w, at + w.length)) amount = afterLabel.exec(ln.slice(at + w.length))?.[1];
55
66
  if (amount !== undefined) break;
56
67
  }
57
68
  } else {
58
- for (const u of k.unit ?? []) {
59
- for (let at = ln.indexOf(u); at !== -1 && amount === undefined; at = ln.indexOf(u, at + u.length)) amount = numberAtEnd(ln.slice(0, at));
69
+ for (const u of [...(k.unit ?? []), ...(k.currency ?? [])]) {
70
+ for (let at = ln.indexOf(u); at !== -1 && amount === undefined; at = ln.indexOf(u, at + u.length)) {
71
+ amount = endNumber(ln.slice(0, at));
72
+ if (amount === undefined && SIGNS.includes(u)) amount = afterLabel.exec(ln.slice(at + u.length))?.[1];
73
+ }
60
74
  if (amount !== undefined) break;
61
75
  }
62
76
  }
63
- if (amount !== undefined) out.push({ quote: raw[i].trim(), value: amount.replace(/,/g, '') });
77
+ if (amount !== undefined) out.push({ quote: raw[i].trim(), value: canon(amount) });
64
78
  });
65
79
  return out;
66
80
  }
@@ -69,7 +83,7 @@ export function moneyResultLines(text, k) {
69
83
  * The fact as a run would sign it, for the dry read: the primary label is the anchor (none when U1 moved every label), then the kept units and currencies.
70
84
  * @param {KeptFact} k @returns {Record<string, any>}
71
85
  */
72
- const signedOf = (k) => ({ name: CLAIM, shape: 'money', ...(k.words.length ? { anchor: k.words[0] } : {}), ...(k.currency ? { currency: k.currency } : {}), ...(k.unit ? { unit: k.unit } : {}) });
86
+ const signedOf = (k) => ({ name: CLAIM, shape: 'money', ...(k.words.length ? { anchor: k.words[0] } : {}), ...(k.currency ? { currency: k.currency } : {}), ...(k.unit ? { unit: k.unit } : {}), ...(k.decimal === undefined ? {} : { decimal: k.decimal }) });
73
87
 
74
88
  /**
75
89
  * Dry-read every kept money fact; drop (as `reads-no-result`) the ones whose forms read no result line. Other facts pass through untouched.