bareloop 0.55.0 → 0.56.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 +47 -0
- package/bareloop.context.md +4 -2
- package/package.json +2 -2
- package/src/authorflow.js +141 -264
- package/src/authoring.js +2 -3
- package/src/authorjob.js +117 -88
- package/src/authorreadout.js +9 -15
- package/src/authorrun.js +13 -4
- package/src/behaviour.js +14 -0
- package/src/blockasks.js +43 -0
- package/src/checkblock.js +772 -0
- package/src/checklist.js +128 -0
- package/src/checkpick.js +30 -312
- package/src/checkwords.js +3 -1
- package/src/declaredclose.js +30 -1
- package/src/destpoint.js +3 -1
- package/src/draftspend.js +46 -0
- package/src/facts.js +8 -1
- package/src/fitcheck.js +5 -3
- package/src/pagemap.js +15 -3
- package/src/panel/authorroutes.js +15 -3
- package/src/panel/authorsession.js +133 -46
- package/src/panel/index.html +194 -22
- package/src/panel/jobplan.js +85 -33
- package/src/panel/server.js +52 -7
- package/src/pickrecord.js +19 -1
- package/src/placerule.js +355 -0
- package/src/promptregisters.js +11 -0
- package/src/questionbox.js +112 -0
- package/src/rowedit.js +115 -0
- package/src/rubricstep.js +212 -125
- package/src/run.js +10 -2
- package/src/userrun.js +46 -1
- package/types/authorflow.d.ts +32 -139
- package/types/authorjob.d.ts +24 -6
- package/types/authorreadout.d.ts +4 -10
- package/types/behaviour.d.ts +12 -0
- package/types/blockasks.d.ts +37 -0
- package/types/checkblock.d.ts +361 -0
- package/types/checklist.d.ts +134 -0
- package/types/checkpick.d.ts +3 -140
- package/types/declaredclose.d.ts +4 -0
- package/types/destpoint.d.ts +2 -0
- package/types/draftspend.d.ts +21 -0
- package/types/fitcheck.d.ts +7 -1
- package/types/pagemap.d.ts +4 -0
- package/types/panel/authorsession.d.ts +13 -2
- package/types/panel/jobgrid.d.ts +8 -8
- package/types/panel/jobplan.d.ts +48 -10
- package/types/panel/server.d.ts +14 -13
- package/types/pickrecord.d.ts +12 -0
- package/types/placerule.d.ts +194 -0
- package/types/questionbox.d.ts +87 -0
- package/types/rowedit.d.ts +32 -0
- package/types/rubricstep.d.ts +91 -48
- package/types/run.d.ts +10 -1
package/src/authorflow.js
CHANGED
|
@@ -87,10 +87,11 @@ import {
|
|
|
87
87
|
import { buildSeedListing, cleanEntry, SURVEY_CAUSES, AUTHOR_CALL_TIMEOUT_MS } from './authorscout.js';
|
|
88
88
|
import { extractArtifact, priceOf, scrubRaw, tallyCalls, capStop, callCasualty } from './text.js';
|
|
89
89
|
import { redactSecrets } from './validate.js';
|
|
90
|
-
import {
|
|
91
|
-
import {
|
|
90
|
+
import { ledgerRecord } from './checklist.js';
|
|
91
|
+
import { ROW_EDIT_REVISE, rowEditUserText, rowEditChannel, editsOf } from './rowedit.js';
|
|
92
|
+
import { REASON, CheckBlock } from './checkblock.js';
|
|
93
|
+
import { stepFileContract, inputLabelsOf, stepFileRel, readFrozenInputs, lineRules } from './rubricstep.js';
|
|
92
94
|
import { dropRows, dropLine } from './pagedropwords.js';
|
|
93
|
-
import { factShapeGuide } from './facts.js';
|
|
94
95
|
import { renderLookReport } from './inputlook.js';
|
|
95
96
|
import { checkDeclarationWords, labelListsFor } from './factwords.js';
|
|
96
97
|
import { ticketFilterReds, ticketFilterBlock, ticketPerRunFacts, TICKET_FILTER_SCHEMA_WORDS } from './ticketfilter.js';
|
|
@@ -836,7 +837,6 @@ export const PARAM_SCHEMAS = Object.freeze({
|
|
|
836
837
|
value: { type: 'integer', minimum: 1, description: 'minClaims / maxClaims: the number of claims asked for' },
|
|
837
838
|
source: { type: 'string', minLength: 1, description: 'cited: the label of the input a quote must come from' },
|
|
838
839
|
domains: { type: 'array', minItems: 1, items: { type: 'string', minLength: 1 }, description: 'guard only: the web domains the rule is about' },
|
|
839
|
-
covers: { type: 'array', minItems: 1, uniqueItems: true, items: { type: 'integer', minimum: 1 }, description: 'the number(s) of the CONFIRMED check(s) this part carries out' },
|
|
840
840
|
rules: { type: 'array', minItems: 1, uniqueItems: true, items: { type: 'integer', minimum: 1 }, description: 'the number(s) of the job line\'s ~ rules this part carries out (1 = the first ~ rule under the line)' },
|
|
841
841
|
facts: {
|
|
842
842
|
type: 'array',
|
|
@@ -1240,21 +1240,28 @@ export function writeScopeBlock(writeScope) {
|
|
|
1240
1240
|
* meaning from `openQuestions` (which means "could not resolve"): the two
|
|
1241
1241
|
* never merge.
|
|
1242
1242
|
* @param {{checks: string[], checkItems?: {text: string, fromLine: number[]|null}[], protections: string[], openQuestions?: string[], notChecked?: string[],
|
|
1243
|
-
* answeredQuestions?: string[]}} confirmed
|
|
1244
|
-
* @param {{numbered?: boolean}} [o] `numbered` (a rubric job on files): each confirmed check carries its `#n`, which a part cites in `covers`
|
|
1243
|
+
* answeredQuestions?: string[], goalOnly?: boolean}} confirmed
|
|
1245
1244
|
*/
|
|
1246
|
-
export function confirmedBlock(confirmed
|
|
1245
|
+
export function confirmedBlock(confirmed) {
|
|
1247
1246
|
const checks = confirmed.checks ?? [];
|
|
1248
1247
|
const protections = confirmed.protections ?? [];
|
|
1249
1248
|
const openQuestions = confirmed.openQuestions ?? [];
|
|
1250
1249
|
const notChecked = confirmed.notChecked ?? [];
|
|
1251
1250
|
const answeredQuestions = confirmed.answeredQuestions ?? [];
|
|
1251
|
+
// a rubric job's confirm turn plans the goal only (its checks are the list's): no check list and no "the person confirmed" text
|
|
1252
|
+
if (confirmed.goalOnly === true) {
|
|
1253
|
+
return 'ALWAYS-ON PROTECTIONS \u2014 already enforced by this run and unchanged by the job; never compose one of these as a check:\n\n'
|
|
1254
|
+
+ `${protections.map((p) => ` - ${p}`).join('\n') || ' (none)'}\n`
|
|
1255
|
+
+ (notChecked.length ? `\nTHESE WERE ASKED FOR, BUT NOTHING CHECKS THEM (state these in your notes):\n\n${notChecked.map((n) => ` - ${n}`).join('\n')}\n` : '')
|
|
1256
|
+
+ (answeredQuestions.length ? `\nQUESTIONS THE PERSON ANSWERED \u2014 binding:\n\n${answeredQuestions.map((a) => ` - ${a}`).join('\n')}\n` : '')
|
|
1257
|
+
+ (openQuestions.length ? `\nOPEN QUESTIONS (state these in your notes, never decide them silently):\n\n${openQuestions.map((q) => ` - ${q}`).join('\n')}\n` : '');
|
|
1258
|
+
}
|
|
1252
1259
|
return 'THE CONFIRMED PLAN — the person already saw and confirmed this in the confirm turn\n\n'
|
|
1253
1260
|
+ 'Compose stages for these checks and no other — a genre never adds a check the goal did not ask for, and '
|
|
1254
1261
|
+ 'neither do you:\n\n'
|
|
1255
1262
|
+ `${(confirmed.checkItems?.length
|
|
1256
|
-
? confirmed.checkItems.map((c
|
|
1257
|
-
: checks.map((c
|
|
1263
|
+
? confirmed.checkItems.map((c) => ` - ${c.fromLine && c.fromLine.length ? `[line ${c.fromLine.join(', ')}] ` : ''}${c.text}`)
|
|
1264
|
+
: checks.map((c) => ` - ${c}`)).join('\n') || ' (none)'}\n\n`
|
|
1258
1265
|
+ 'These protections are already always-on and unchanged by this plan — never compose one of these as a check:\n\n'
|
|
1259
1266
|
+ `${protections.map((p) => ` - ${p}`).join('\n') || ' (none)'}\n\n`
|
|
1260
1267
|
+ (notChecked.length
|
|
@@ -1322,7 +1329,7 @@ export function jobLineTagBlock(count, guardNames = []) {
|
|
|
1322
1329
|
* writeScope?: string[]|null,
|
|
1323
1330
|
* jobLines?: {n: number}[]|null, inputs?: {n: number, label: string, value: string}[]|null,
|
|
1324
1331
|
* confirmed?: {checks: string[], checkItems?: {text: string, fromLine: number[]|null}[], protections: string[], openQuestions?: string[], notChecked?: string[], answeredQuestions?: string[]}|null,
|
|
1325
|
-
* labelLists?: string[]|null,
|
|
1332
|
+
* labelLists?: string[]|null,
|
|
1326
1333
|
* }} o
|
|
1327
1334
|
*/
|
|
1328
1335
|
export function authorPrompt({
|
|
@@ -1337,16 +1344,11 @@ export function authorPrompt({
|
|
|
1337
1344
|
confirmed = null,
|
|
1338
1345
|
// PART 1c: the label lists code made from the frozen inputs (src/labelscan.js `renderLabelList`); a label is picked from them
|
|
1339
1346
|
labelLists = null,
|
|
1340
|
-
// R10: the `~` rules code settles from the person's own picks (src/checkpick.js); ABSENT = byte-identical prompt
|
|
1341
|
-
settled = null,
|
|
1342
1347
|
}) {
|
|
1343
1348
|
// PART 1a: a rubric job on the person's own local files has no repository, no genre template and no tool to measure with —
|
|
1344
1349
|
// it gets its own brief (`rubricAuthorPrompt`), which still ends in the same declaration tool and the same guards
|
|
1345
1350
|
// an absent catalogue is the language's own menu (`catalogueForLang`), so a code job's prompt never lists a rubric-only kind
|
|
1346
1351
|
const catalogue = catalogueIn ?? catalogueForLang(lang);
|
|
1347
|
-
if (lang === RUBRIC_LANG) {
|
|
1348
|
-
return rubricAuthorPrompt({ answers, questions, facts, listingBlock, verdictType, guards, mode, catalogue, writeScope, jobLines, inputs, confirmed, labelLists, settled });
|
|
1349
|
-
}
|
|
1350
1352
|
const statement = CLASS_STATEMENTS[String(verdictType)] ?? null;
|
|
1351
1353
|
if (statement === null) {
|
|
1352
1354
|
throw new Error(`[authorflow] the authoring prompt needs the verdict class the user picked, and "${verdictType}" `
|
|
@@ -1463,180 +1465,6 @@ export const RUBRIC_FILES_STATEMENT = 'The person declared this job SOFT-GREEN a
|
|
|
1463
1465
|
+ 'Compose ONE rubric-step stage per numbered job line, after the mandatory guard, and name only limits the person actually '
|
|
1464
1466
|
+ 'asked for. A part you cannot express that way is not approximated by a stage that means something else.';
|
|
1465
1467
|
|
|
1466
|
-
/**
|
|
1467
|
-
* THE RUBRIC RULES, in one place (live fix B1): what the confirm step and the drafter are both told about turning the person's words
|
|
1468
|
-
* into checks. The confirm note ({@link RUBRIC_CONFIRM_NOTE}) and the composer brief ({@link REQUIRED_FACTS_BRIEF}) interpolate THIS
|
|
1469
|
-
* constant, so the two cannot drift (in smv6k6l8dxkzs the confirm step planned a limit the drafter then could not carry, and the
|
|
1470
|
-
* drafter added an airport code the person never wrote). Field-neutral: neither turn needs the other's field names.
|
|
1471
|
-
*/
|
|
1472
|
-
export const RUBRIC_RULES = 'THE RULES FOR TURNING THE PERSON\'S WORDS INTO CHECKS (the same for every turn of this job):\n - A limit the person WROTE ("under $450") is a rule that can be checked: plan it as a limit with its number.\n'
|
|
1473
|
-
+ ' - A number YOU make out of their words ("not a red-eye" becomes a departure time between 06:00 and 21:00) is your proposal, marked '
|
|
1474
|
-
+ 'as the AI\'s proposal for the person to check; a limit on a time that you propose is a RANGE (between), never one-sided. The input does '
|
|
1475
|
-
+ 'not have to hold the person\'s word (it holds no "red-eye"): the limit goes on the time the input DOES hold (e.g. the one after "Departure time:"), as a '
|
|
1476
|
-
+ 'range marked as the AI\'s proposal.\n'
|
|
1477
|
-
+ ' - Names, labels and units are the INPUT\'s own words, copied exactly as the input writes them. When the input does not use the '
|
|
1478
|
-
+ 'person\'s word (they wrote SFO, the input says San Francisco International Airport), use the words the input uses; never invent a '
|
|
1479
|
-
+ 'word the input does not hold, and never add a code (like SFO) that the person did not write and the input does not hold.\n'
|
|
1480
|
-
+ ' - A label for a line that asks for N results (a count of N) must sit in each result, so the label list must count it N or more times '
|
|
1481
|
-
+ '(the x-number beside it). A label counted fewer times is on the page once or twice (a sort tab, a switch) and is refused at $0 with its count.\n'
|
|
1482
|
-
+ ' - The same holds for the words a "must say" (phrase) fact makes each quote say: they must be in the input at least N times for N results. Words counted fewer times (page-header words like "from San Francisco" when each result says "Leaves San Francisco International Airport") are refused at $0 with their count; pick words every result says, or drop the check.';
|
|
1483
|
-
|
|
1484
|
-
/**
|
|
1485
|
-
* R10: the `~` rules code settles from the person's own picks, as the composer is told them. The drafter writes no check for these and lists nothing for them under
|
|
1486
|
-
* "refused": code puts the picked check, or the Not checked row, on the stage itself.
|
|
1487
|
-
* @param {{line: number, rule: number, text: string}[]} settled @returns {string}
|
|
1488
|
-
*/
|
|
1489
|
-
export function settledBlock(settled) {
|
|
1490
|
-
return 'SETTLED BY CODE - the person picked how these ~ rules are checked\n\n'
|
|
1491
|
-
+ settled.map((r) => `- line ${r.line}, ~ rule ${r.rule}: "${r.text}"`).join('\n')
|
|
1492
|
-
+ '\n\nFor these rules code writes the check the person picked, or the Not checked row, itself: write NO part and NO "refused" entry for them. '
|
|
1493
|
-
+ 'You never write a word, section, line, list-item or phrase count part (maxWords, minWords, maxLines, listItems, sections, sectionOrder, sectionWords, mustCarry, blockLines, nonEmpty) for any rule: only code does.';
|
|
1494
|
-
}
|
|
1495
|
-
|
|
1496
|
-
/**
|
|
1497
|
-
* REQUIRED FACTS, as the composer is told them (PART 1b, PRD item 33 RF1–RF17). The shape of the fact part is in the catalogue and the
|
|
1498
|
-
* schema; this is the judgement the schema cannot carry: what becomes a fact, where its words come from, and what is Not checked.
|
|
1499
|
-
*/
|
|
1500
|
-
export const REQUIRED_FACTS_BRIEF = 'REQUIRED FACTS — what a line that finds, lists or looks something up leaves behind\n\n'
|
|
1501
|
-
+ 'For such a line write ONE part of class "fact". The worker\'s file for that line holds only results, each with ONE quote copied '
|
|
1502
|
-
+ 'from the input and the value of every fact as the quote writes it — no free text. Code checks every value against its quote.\n'
|
|
1503
|
-
+ ' - The facts come from the job line itself AND from its ~ rules: "SFO to LAX" is a from fact and a to fact even with no ~ line. '
|
|
1504
|
-
+ 'One fact per thing the person asked for. Give every fact a shape. A rule (op, value, or between lo and hi) only where the person '
|
|
1505
|
-
+ 'asked for a limit.\n'
|
|
1506
|
-
+ ' - THE LOOK above is what a read of the inputs found: write the facts from it. Copy every label (anchor), unit and phrase EXACTLY '
|
|
1507
|
-
+ 'as the look gives it (the look\'s phrase facts become phrase facts with the same words), and say in "notes" when you used the input\'s '
|
|
1508
|
-
+ 'words instead of the person\'s. A label (anchor) is PICKED from the labels the look found in the input, never typed; one that is not '
|
|
1509
|
-
+ 'among them is refused at $0. What the look could not find is not checked: list it under "refused" in the person\'s words.\n'
|
|
1510
|
-
+ ' - A money fact names at least one of "unit" (the words the input writes after the amount) or "currency" (a sign: $, € or £), and may name both. Each is one value or a list: '
|
|
1511
|
-
+ 'at most 3 currencies and 10 units, none repeated, a unit at most 100 characters. A code like EUR is a unit (it is read after the number), never a currency. '
|
|
1512
|
-
+ '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'
|
|
1513
|
-
+ ' - 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. '
|
|
1514
|
-
+ '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'
|
|
1515
|
-
+ ' - 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. '
|
|
1516
|
-
+ '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'
|
|
1517
|
-
+ ' - 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'
|
|
1518
|
-
+ ' - Set aiProposal true on a fact whose number you made out of their words.\n'
|
|
1519
|
-
+ RUBRIC_RULES + '\n'
|
|
1520
|
-
+ ' - How MANY results were asked for is a count ("3 releases": count {min: 3, max: 3}). WHICH ones ("the last", "the newest") and '
|
|
1521
|
-
+ 'anything else you cannot express as a shape and a rule ("the cheapest", "the best", "a good pick") is NOT CHECKED: list it in "refused" as {"line": N, "rule": the number of that ~ rule, "reason": the '
|
|
1522
|
-
+ 'person\'s own words}. EVERY ~ rule of a line must be carried out by a part (list its number in the part\'s "rules", 1 = the first ~ '
|
|
1523
|
-
+ 'rule under the line) or be listed in "refused"; a rule that is neither is refused at $0.\n'
|
|
1524
|
-
+ ' - A line that WRITES (a summary, a report) needs no part for a word, section, line, list-item or phrase count: code adds the checks the person picked for it. Code ties its numbers to the facts of the lines '
|
|
1525
|
-
+ 'before it; you do not add that.\n'
|
|
1526
|
-
+ ' - A look fact that says "carries ~ rule N" is how the look carried that rule: put N in the fact part\'s "rules" and do not also list rule N in "refused".\n'
|
|
1527
|
-
+ ' - A line has ONE fact part. A look fact that carries a ~ rule goes INSIDE the line\'s one fact part (add its rule number to that part\'s "rules" and its fact to "facts"), never as a fact part of its own: two fact parts on one line are refused at $0. '
|
|
1528
|
-
+ 'A count of words, bullets or list items the person picked is a pick, not a "count" on the fact part; "count" is only how many results were asked for.\n'
|
|
1529
|
-
+ ' - A ~ rule that you carry out as a fact (a limit on a time, a price, a date: "not a red-eye" is a time fact with a between rule) is carried by the '
|
|
1530
|
-
+ 'fact part: list its number in that part\'s "rules". It is NOT also a part of its own: on a line that lists facts, a part of class judged or none '
|
|
1531
|
-
+ 'is refused. A rule you cannot express as a shape and a rule goes in "refused", never into a part.\n'
|
|
1532
|
-
+ ' - "covers" and "rules" are fields of the PART, written once on it as a list of numbers. A fact never has a "covers" or a "rules" field.\n'
|
|
1533
|
-
+ ' - ONE stage per job line, holding ALL of that line\'s facts (and its other parts). Two stages for one line are refused: put a '
|
|
1534
|
-
+ '~ rule\'s fact (a "not a red-eye" time) on the same stage as the line\'s other facts.\n'
|
|
1535
|
-
+ ' - WHICH SHAPE TAKES WHICH FIELDS (a field a shape does not take is refused):\n'
|
|
1536
|
-
+ factShapeGuide();
|
|
1537
|
-
|
|
1538
|
-
/**
|
|
1539
|
-
* The composer prompt for a rubric job on local files (Part 1a, docs/product/ITEM33-BUILD.md). There is no repository
|
|
1540
|
-
* and no survey: the facts are the numbered inputs and the listing is the frozen tree (input/ files, output/). It states
|
|
1541
|
-
* the step-file contract the worker is also told ({@link stepFileContract}), so the stage and the file cannot drift.
|
|
1542
|
-
* @param {{answers: Record<string|number, string>, questions?: Record<string|number, string>, facts: any, listingBlock: string,
|
|
1543
|
-
* verdictType: string, guards: {name: string, kind: string, params: Record<string, any>, fill: string[]}[],
|
|
1544
|
-
* mode?: 'tool'|'text', catalogue?: Record<string, any>, writeScope?: string[]|null,
|
|
1545
|
-
* jobLines?: {n: number}[]|null, inputs?: {n: number, label: string, value: string}[]|null, confirmed?: any,
|
|
1546
|
-
* labelLists?: string[]|null, settled?: {line: number, rule: number, text: string}[]|null,
|
|
1547
|
-
* }} o
|
|
1548
|
-
* @returns {string}
|
|
1549
|
-
*/
|
|
1550
|
-
export function rubricAuthorPrompt({
|
|
1551
|
-
answers, questions = GREEN_QUESTIONS, facts, listingBlock, verdictType, guards,
|
|
1552
|
-
mode = 'tool', catalogue = KIND_CATALOGUE, writeScope = null, jobLines = null, inputs = null, confirmed = null, labelLists = null, settled = null,
|
|
1553
|
-
}) {
|
|
1554
|
-
const interview = Object.entries(questions)
|
|
1555
|
-
.map(([n, q]) => `Q${n}. ${q}\nA${n}. ${answers?.[n] ?? '(no answer given)'}`)
|
|
1556
|
-
.join('\n\n');
|
|
1557
|
-
const role = `You are composing the close for one job.
|
|
1558
|
-
|
|
1559
|
-
The close is what decides whether a run of this job came back DONE. It runs after the work is
|
|
1560
|
-
finished, it is the only truth, and nothing else can overrule it. It is a list of STAGES. Each
|
|
1561
|
-
stage names a kind from the catalogue below and fills that kind's parameters. Stages run in the
|
|
1562
|
-
order you declare them.
|
|
1563
|
-
|
|
1564
|
-
Two sources fed you this brief and neither of them is you:
|
|
1565
|
-
- the person who wants the job done answered an interview, below, in their own words. They are
|
|
1566
|
-
not a software engineer and did not name commands, thresholds or patterns;
|
|
1567
|
-
- the person's own text files, frozen into the job. There is no code repository: the files sit
|
|
1568
|
-
under input/ and the run writes only under output/.`;
|
|
1569
|
-
const guardJson = guards.map((g) => ({
|
|
1570
|
-
name: g.name,
|
|
1571
|
-
kind: g.kind,
|
|
1572
|
-
params: { ...g.params, ...Object.fromEntries(g.fill.map((f) => [f, FILL_MARKER])) },
|
|
1573
|
-
}));
|
|
1574
|
-
const output = mode === 'tool'
|
|
1575
|
-
? `HOW TO ANSWER
|
|
1576
|
-
|
|
1577
|
-
Call the ${DECLARATION_TOOL_NAME} tool exactly once. Its arguments ARE the declaration: an ordered
|
|
1578
|
-
"stages" array, plus "notes" for anything you could not express, and "refused" for a job line no stage can check.
|
|
1579
|
-
Do not write the declaration as text.
|
|
1580
|
-
|
|
1581
|
-
Stage names are unique. Every parameter name comes from the catalogue and no other. No parameter is
|
|
1582
|
-
left as a placeholder. You never write a number the person did not ask for.`
|
|
1583
|
-
: `HOW TO ANSWER
|
|
1584
|
-
|
|
1585
|
-
A single JSON object and nothing else: an ordered "stages" array, plus "notes" for anything you
|
|
1586
|
-
could not express, and "refused" for a job line no stage can check.
|
|
1587
|
-
|
|
1588
|
-
Stage names are unique. Every parameter name comes from the catalogue and no other. No parameter is
|
|
1589
|
-
left as a placeholder. You never write a number the person did not ask for.`;
|
|
1590
|
-
return [
|
|
1591
|
-
role,
|
|
1592
|
-
`WHAT THE PERSON DECLARED "DONE" TO MEAN — their answer, not yours\n\n${RUBRIC_FILES_STATEMENT}`,
|
|
1593
|
-
`THE INTERVIEW — the person's own words\n\n${interview}`
|
|
1594
|
-
+ (inputs && inputs.length ? `\n\n${renderInputs(inputs)}` : ''),
|
|
1595
|
-
...(jobLines && jobLines.length ? [jobLineTagBlock(jobLines.length)] : []),
|
|
1596
|
-
...(writeScope && writeScope.length ? [writeScopeBlock(writeScope)] : []),
|
|
1597
|
-
...(confirmed ? [confirmedBlock(confirmed, { numbered: true }),
|
|
1598
|
-
'EVERY CONFIRMED CHECK IS COMPOSED OR MOVED, NEVER DROPPED\n\nThe person saw the numbered checks above. On each countable or fact part that carries one of them out, list its number in the PART\'s "covers" (once on the part, never on a fact inside it). '
|
|
1599
|
-
+ 'A confirmed check that no part covers is not silently left out: it is moved to Not checked before signing, and the person is told. '
|
|
1600
|
-
+ 'To count "N things listed", use minClaims / maxClaims (it counts the claims listed under an input); anything else you cannot count is not composed.'] : []),
|
|
1601
|
-
REQUIRED_FACTS_BRIEF,
|
|
1602
|
-
...(Array.isArray(settled) && settled.length ? [settledBlock(settled)] : []),
|
|
1603
|
-
`THE STEP FILES — what the worker leaves behind for each job line\n\n${stepFileContract()}\n\n`
|
|
1604
|
-
+ 'The rubric-step stage for job line N reads exactly that file, output/steps/N.json. It names the inputs (by label) the '
|
|
1605
|
-
+ 'step must cite from, and the limits on its "text".',
|
|
1606
|
-
`THE FILES — the inputs the person pointed at, frozen into the job\n\n${JSON.stringify(withoutLook(facts), null, 2)}`
|
|
1607
|
-
+ (listingBlock ? `\n\n${listingBlock}` : ''),
|
|
1608
|
-
...(Array.isArray(labelLists) && labelLists.length ? [labelLists.join('\n\n')] : []),
|
|
1609
|
-
...(facts && facts.look ? [renderLookReport(facts.look)] : []),
|
|
1610
|
-
rubricCatalogueBlock(catalogue, { verdictType }),
|
|
1611
|
-
'MANDATORY GUARDS — already placed and already parameterised\n\n'
|
|
1612
|
-
+ 'This kind of job carries a stage the person did not ask for. It is fixed and you may not change, drop, rename, or '
|
|
1613
|
-
+ `re-kind it. The ONLY thing you fill in is each "${FILL_MARKER}" slot, from the interview:\n\n${JSON.stringify(guardJson, null, 2)}\n\n`
|
|
1614
|
-
+ 'Place it first: it is cheap, and the first red ends the judgement.',
|
|
1615
|
-
output,
|
|
1616
|
-
].join('\n\n---\n\n');
|
|
1617
|
-
}
|
|
1618
|
-
|
|
1619
|
-
/** the facts object without the look's report (that is its own block, written by code) @param {any} facts */
|
|
1620
|
-
function withoutLook(facts) {
|
|
1621
|
-
if (!facts || typeof facts !== 'object' || !('look' in facts)) return facts;
|
|
1622
|
-
const { look: _look, ...rest } = facts;
|
|
1623
|
-
return rest;
|
|
1624
|
-
}
|
|
1625
|
-
|
|
1626
|
-
/**
|
|
1627
|
-
* The kind rows of the catalogue, without the command-output parser text a rubric job never needs.
|
|
1628
|
-
* @param {Record<string, any>} catalogue @param {{verdictType?: string|null}} [o]
|
|
1629
|
-
*/
|
|
1630
|
-
function rubricCatalogueBlock(catalogue, { verdictType = null } = {}) {
|
|
1631
|
-
const menu = classMenu(verdictType, catalogue);
|
|
1632
|
-
const rows = Object.entries(catalogue).filter(([name, spec]) => menu.includes(name) && !spec.locked).map(([name, spec]) => `- ${name}\n ${spec.shape}\n required: ${spec.required.join(', ')}`
|
|
1633
|
-
+ `${spec.optional.length ? ` optional: ${spec.optional.join(', ')}` : ''}\n asserts: ${spec.asserts}`);
|
|
1634
|
-
return `THE KIND CATALOGUE — these are the only kinds that exist.
|
|
1635
|
-
You parameterise kinds. You never write a script, a shell fragment, or a new kind.
|
|
1636
|
-
|
|
1637
|
-
${rows.join('\n\n')}`;
|
|
1638
|
-
}
|
|
1639
|
-
|
|
1640
1468
|
// ── 3. THE MEASURED BLOCKS ───────────────────────────────────────────────────
|
|
1641
1469
|
|
|
1642
1470
|
/** F6, at the rendering boundary: an absent number is unknown, never 0. */
|
|
@@ -1693,12 +1521,14 @@ export function renderSeedReadBlock(rows, { gapCap = REVISE_GAP_CAP } = {}) {
|
|
|
1693
1521
|
* a credential crossed unmasked before this line existed. Applied to the whole
|
|
1694
1522
|
* rendered block rather than one field, so a red added to the validator is
|
|
1695
1523
|
* scrubbed by construction rather than by remembering.
|
|
1696
|
-
* @param {{kind: 'validation'|'artifact', reds: (Red|string)[], cap?: number}} o
|
|
1524
|
+
* @param {{kind: 'validation'|'artifact'|'edits', reds: (Red|string)[], cap?: number}} o
|
|
1697
1525
|
*/
|
|
1698
1526
|
export function renderRejectBlock({ kind, reds, cap = REVISE_RED_CAP }) {
|
|
1699
1527
|
const head = kind === 'validation'
|
|
1700
1528
|
? 'MEASURED VALIDATION — your declaration was rejected by the validator before any stage could run:'
|
|
1701
|
-
:
|
|
1529
|
+
: kind === 'edits'
|
|
1530
|
+
? 'MEASURED EDITS — some of your edits were refused; each refusal is its own and your other edits stand:'
|
|
1531
|
+
: 'MEASURED PARSE — your reply could not be read as one declaration:';
|
|
1702
1532
|
const rendered = (reds ?? []).map((r) => (typeof r === 'string' ? r : `${r.code} at ${r.path || '(root)'}: ${r.detail}${typeof r.hint === 'string' ? ` ${r.hint}` : ''}`));
|
|
1703
1533
|
const shown = rendered.slice(0, cap);
|
|
1704
1534
|
const tail = rendered.length > shown.length
|
|
@@ -2261,21 +2091,12 @@ const confirmChannel = () => ({
|
|
|
2261
2091
|
* {@link CLASS_STATEMENTS} already use, rather than a code matcher over prose.
|
|
2262
2092
|
*/
|
|
2263
2093
|
/**
|
|
2264
|
-
* What the confirm turn tells the model about a rubric job on local text files (model-facing, registered).
|
|
2265
|
-
*
|
|
2266
|
-
* input must back. Everything else the person asked for is named in `notChecked`, in their words.
|
|
2094
|
+
* What the confirm turn tells the model about a rubric job on local text files (model-facing, registered). The turn plans the goal only: the checks of the job are the one list's
|
|
2095
|
+
* (`src/checklist.js`), made before the draft, never this turn's.
|
|
2267
2096
|
*/
|
|
2268
|
-
export const RUBRIC_CONFIRM_NOTE = 'THIS JOB HAS NO REPOSITORY. Its inputs are the person\'s own text files, and each numbered job line leaves ONE '
|
|
2269
|
-
+ '
|
|
2270
|
-
+ '
|
|
2271
|
-
+ 'limit on that text (words, lines, sections, words per section); a claim that must be backed by a quote copied from a named input; '
|
|
2272
|
-
+ 'and a REQUIRED FACT, something a line finds (a price, a date, a time, a name, a phrase) with a limit only if the person gave one '
|
|
2273
|
-
+ '— plan one fact check for each thing the line asks to find, including those named in the line itself ("SFO to LAX"). Plan a check '
|
|
2274
|
-
+ 'only for what the person asked for in those terms; '
|
|
2275
|
-
+ 'anything that needs reading the text to judge it (tone, quality, accuracy), any superlative ("the cheapest", "the best") and any '
|
|
2276
|
-
+ 'choice of WHICH ones ("the last", "the newest") goes in `notChecked`, in the person\'s own words; how MANY results were asked for is '
|
|
2277
|
-
+ 'a count and can be checked.\n'
|
|
2278
|
-
+ RUBRIC_RULES;
|
|
2097
|
+
export const RUBRIC_CONFIRM_NOTE = 'THIS JOB HAS NO REPOSITORY. Its inputs are the person\'s own text files, and each numbered job line leaves ONE file the run writes. '
|
|
2098
|
+
+ 'The checks of this job are made elsewhere: plan none. Send an empty checks list, an empty notChecked list and an empty questions list, '
|
|
2099
|
+
+ 'and write ONE sentence saying what the job does, from the numbered job lines.';
|
|
2279
2100
|
|
|
2280
2101
|
export const CONFIRM_SYSTEM = 'You read what a NON-ENGINEER answered, plus a read-only survey or listing of their '
|
|
2281
2102
|
+ 'own repository, and draft a PLAN for a job\'s definition of done: the checks you plan to compose and one '
|
|
@@ -2296,6 +2117,14 @@ export const CONFIRM_SYSTEM = 'You read what a NON-ENGINEER answered, plus a rea
|
|
|
2296
2117
|
+ 'where an answer is genuinely missing — never to double-check something already answered. You cannot read '
|
|
2297
2118
|
+ 'anything and you cannot run anything: everything you know is in the message you are given.';
|
|
2298
2119
|
|
|
2120
|
+
/** the confirm turn's system prompt for a rubric job (model-facing, registered): a one-sentence goal, no check of its own */
|
|
2121
|
+
export const CONFIRM_GOAL_SYSTEM = 'You read what a NON-ENGINEER answered, plus the numbered job lines and the inputs they pointed at, and write a one-sentence goal for the job. '
|
|
2122
|
+
+ 'You never propose a check, a gap or a question: the checks of this job are made elsewhere. '
|
|
2123
|
+
+ 'You cannot read anything and you cannot run anything: everything you know is in the message you are given.';
|
|
2124
|
+
|
|
2125
|
+
/** the confirm turn's system prompt for a job of this language: a rubric job's is the goal-only one @param {string} lang @returns {string} */
|
|
2126
|
+
export const confirmSystemFor = (lang) => (lang === RUBRIC_LANG ? CONFIRM_GOAL_SYSTEM : CONFIRM_SYSTEM);
|
|
2127
|
+
|
|
2299
2128
|
/**
|
|
2300
2129
|
* The confirm turn's per-round prompt (model-facing, registered). Shows the
|
|
2301
2130
|
* person's own answers with their labels (the signed table's Field/Holds
|
|
@@ -2314,10 +2143,9 @@ export const CONFIRM_SYSTEM = 'You read what a NON-ENGINEER answered, plus a rea
|
|
|
2314
2143
|
* @param {{answers: Record<string|number, string>, questions: Record<string|number, string>,
|
|
2315
2144
|
* labels?: Record<string|number, string>, facts?: any, listing?: string|null,
|
|
2316
2145
|
* writeScope?: string[]|null, isRepo: boolean, lang: string, worseThanBefore?: string,
|
|
2317
|
-
* fixText?: string|null, protections?: string[], inputs?: {n: number, label: string, value: string}[]|null, ticket?: boolean
|
|
2318
|
-
* settled?: {line: number, rule: number, text: string}[]|null}} o
|
|
2146
|
+
* fixText?: string|null, protections?: string[], inputs?: {n: number, label: string, value: string}[]|null, ticket?: boolean}} o
|
|
2319
2147
|
*/
|
|
2320
|
-
export function confirmPrompt({ answers, questions, labels = {}, facts = null, listing = null, writeScope = null, isRepo, lang, worseThanBefore = '', fixText = null, protections = [], inputs = null, ticket = false
|
|
2148
|
+
export function confirmPrompt({ answers, questions, labels = {}, facts = null, listing = null, writeScope = null, isRepo, lang, worseThanBefore = '', fixText = null, protections = [], inputs = null, ticket = false }) {
|
|
2321
2149
|
const lines = ['THE PERSON\'S OWN ANSWERS (a non-engineer; read exactly what they wrote, invent nothing beyond it):'];
|
|
2322
2150
|
for (const k of Object.keys(questions)) {
|
|
2323
2151
|
const label = labels[k] ? ` (${labels[k]})` : '';
|
|
@@ -2333,7 +2161,6 @@ export function confirmPrompt({ answers, questions, labels = {}, facts = null, l
|
|
|
2333
2161
|
// needing judgement lands in `notChecked` instead of being promised as a check
|
|
2334
2162
|
if (lang === RUBRIC_LANG) lines.push('', RUBRIC_CONFIRM_NOTE);
|
|
2335
2163
|
// R10: the `~` rules code settles from the person's own picks are not yours to plan: a check for them is code's, a gap is code's Not checked row
|
|
2336
|
-
if (Array.isArray(settled) && settled.length) lines.push('', `SETTLED BY CODE - the person picked how these ~ rules are checked; plan no check for them and list none under notChecked:\n${settled.map((/** @type {any} */ r) => ` - line ${r.line}: "${r.text}"`).join('\n')}`);
|
|
2337
2164
|
// MCP + tickets R5 (F285): a Tickets job's confirm turn is told the ticket is picked per run and a priority/label line is code's, so it never asks the person which ticket
|
|
2338
2165
|
if (ticket) lines.push('', ticketPerRunFacts());
|
|
2339
2166
|
if (writeScope) lines.push(`WRITE SCOPE (the fence — the run may write only here): ${writeScope.join(', ')}`);
|
|
@@ -2389,7 +2216,7 @@ async function askConfirmPlan({ convo, generate, mode, book, label }) {
|
|
|
2389
2216
|
* ask: (step: {kind: string, [k: string]: any}) => Promise<string|null>,
|
|
2390
2217
|
* onPhase?: (phase: string, data?: any) => void, mode?: 'tool'|'text',
|
|
2391
2218
|
* worseThanBefore?: string, inputs?: {n: number, label: string, value: string}[]|null,
|
|
2392
|
-
* jobLines?: {n: number}[]|null, ticket?: boolean,
|
|
2219
|
+
* jobLines?: {n: number}[]|null, ticket?: boolean, card?: {checkItems: {text: string, fromLine: number[], by: 'agent'|'you'|'default', key?: string}[], notChecked: string[], notCheckedBy?: Record<string, string>}|null, block?: CheckBlock|null, cardOf?: (() => any)|null}} o retired field (hamr's ruling 2026-09-28):
|
|
2393
2220
|
* `worseThanBefore` is never asked any more and defaults to `''` — a
|
|
2394
2221
|
* caller may still pass a string through (kept for a future, non-ask
|
|
2395
2222
|
* source of the same constraint), it just never comes from an ask() step.
|
|
@@ -2415,9 +2242,13 @@ export async function runConfirmTurn({
|
|
|
2415
2242
|
jobLines = null,
|
|
2416
2243
|
// MCP + tickets R5 (F285): the job reads tickets; absent = the confirm prompt is byte-identical
|
|
2417
2244
|
ticket = false,
|
|
2418
|
-
//
|
|
2419
|
-
|
|
2245
|
+
// a rubric job's check rows as the card readers read them (`cardOfClose` over `block.closeView()`): the card draws them, nothing else. SHOWN only: the accepted plan below never carries them
|
|
2246
|
+
card = null,
|
|
2247
|
+
// the live check block of a rubric job and the reader that draws its rows (`() => cardOfClose(...)`): the confirm card's Drop and Add are instant row edits ($0, no AI) through the block, and the card is redrawn from its rows
|
|
2248
|
+
block = null, cardOf = null,
|
|
2420
2249
|
}) {
|
|
2250
|
+
/** a rubric job's confirm turn plans the goal only (its checks are the list's) */
|
|
2251
|
+
const goalOnly = lang === RUBRIC_LANG;
|
|
2421
2252
|
/** @typedef {null|'cap-halt'|'pricing-red'|'provider-red'|'artifact-red'|'confirm-abandoned'|'confirm-restart'} ConfirmStop */
|
|
2422
2253
|
/** @returns {{ok: boolean, stop: ConfirmStop, rounds: number, accepted: null, reds: Red[], cost: any}} */
|
|
2423
2254
|
const base = () => ({ ok: false, stop: null, rounds: 0, accepted: null, reds: [], cost: book.report() });
|
|
@@ -2487,14 +2318,14 @@ export async function runConfirmTurn({
|
|
|
2487
2318
|
let convo = [{
|
|
2488
2319
|
role: 'user',
|
|
2489
2320
|
content: confirmPrompt({
|
|
2490
|
-
answers, questions, labels, facts, listing, writeScope, isRepo, lang: resolvedLang, worseThanBefore, protections, inputs, ticket,
|
|
2321
|
+
answers, questions, labels, facts, listing, writeScope, isRepo, lang: resolvedLang, worseThanBefore, protections, inputs, ticket,
|
|
2491
2322
|
}),
|
|
2492
2323
|
}];
|
|
2493
2324
|
|
|
2494
2325
|
for (let round = 1; round <= 2; round += 1) {
|
|
2495
2326
|
if (fixText) {
|
|
2496
2327
|
convo = [...convo, { role: 'user', content: confirmPrompt({
|
|
2497
|
-
answers, questions, labels, facts, listing, writeScope, isRepo, lang: resolvedLang, worseThanBefore, fixText, protections, inputs, ticket,
|
|
2328
|
+
answers, questions, labels, facts, listing, writeScope, isRepo, lang: resolvedLang, worseThanBefore, fixText, protections, inputs, ticket,
|
|
2498
2329
|
}) }];
|
|
2499
2330
|
}
|
|
2500
2331
|
onPhase('confirm-round', { round });
|
|
@@ -2524,13 +2355,26 @@ export async function runConfirmTurn({
|
|
|
2524
2355
|
// model's own honest gap list, carried through unchanged.
|
|
2525
2356
|
// NO SILENT DROP (idea A core, spec 4.5): what the page rules removed is said HERE too, in the same words as the signed plan, before
|
|
2526
2357
|
// drafting is paid for. The words come from the one table (src/pagedropwords.js).
|
|
2358
|
+
// a rubric job's turn keeps nothing but the goal of the model's plan: its checks, gaps and questions are the list's to make, so code discards any it sent
|
|
2359
|
+
if (goalOnly) r.plan = { ...r.plan, checks: [], notChecked: [], questions: [] };
|
|
2527
2360
|
const notChecked = [...(r.plan.notChecked ?? [])];
|
|
2528
2361
|
for (const row of dropRows(facts?.look?.dropped)) { const text = dropLine(row, jobLines, lineRules); if (!notChecked.includes(text)) notChecked.push(text); }
|
|
2529
2362
|
const checkItems = normalizeChecks(r.plan.checks);
|
|
2530
2363
|
r.plan = { ...r.plan, checks: checkItems.map((c) => c.text), checkItems };
|
|
2531
|
-
|
|
2364
|
+
// the rows of the check block, drawn by the same readers as the signed card (hamr 2026-11-12: the confirm card showed no row the block had built); shown only, never accepted
|
|
2365
|
+
const planFor = (/** @type {any} */ c) => ({
|
|
2366
|
+
...r.plan, ...(c === null ? {} : { checkItems: c.checkItems, checks: c.checkItems.map((/** @type {any} */ x) => x.text) }), protections, notChecked: c === null ? notChecked : [...new Set([...notChecked, ...c.notChecked])], ...(c?.notCheckedBy ? { notCheckedBy: c.notCheckedBy } : {}),
|
|
2367
|
+
signedFacts: (Array.isArray(facts?.look?.facts) ? facts.look.facts : []).map((/** @type {any} */ f) => String(f?.name)),
|
|
2368
|
+
...(block !== null && cardOf !== null ? { suggested: block.suggestedView(), editable: true } : {}),
|
|
2369
|
+
});
|
|
2370
|
+
const plan = planFor(card);
|
|
2532
2371
|
onPhase('confirm-done', { round, plan });
|
|
2533
|
-
|
|
2372
|
+
// Drop and Add on the confirm card: a row edit through the block (the choice decides), reconciled, then the card is drawn again from the rows. $0: no model call is made here
|
|
2373
|
+
const edit = block !== null && cardOf !== null ? (/** @type {'drop'|'add'} */ op, /** @type {string} */ key) => {
|
|
2374
|
+
const res = block.rowChoice(key, op);
|
|
2375
|
+
return res.ok ? { ok: true, plan: planFor(cardOf()), choices: block.choicesRecord() } : res;
|
|
2376
|
+
} : null;
|
|
2377
|
+
const picked = await ask({ kind: 'menu', field: CONFIRM_MENU, plan, ...(edit ? { edit } : {}) });
|
|
2534
2378
|
if (picked === null) return abandon(round);
|
|
2535
2379
|
if (picked === 'start-over') return { ...base(), stop: /** @type {ConfirmStop} */ ('confirm-restart'), rounds: round, cost: book.report() };
|
|
2536
2380
|
|
|
@@ -2541,7 +2385,7 @@ export async function runConfirmTurn({
|
|
|
2541
2385
|
ok: true, stop: null, rounds: round,
|
|
2542
2386
|
accepted: {
|
|
2543
2387
|
goal: String(r.plan.goal ?? ''), checks: [...(r.plan.checks ?? [])], checkItems: [...(r.plan.checkItems ?? [])], protections: [...protections],
|
|
2544
|
-
lang: resolvedLang, worseThanBefore,
|
|
2388
|
+
lang: resolvedLang, worseThanBefore, ...(goalOnly ? { goalOnly: true } : {}),
|
|
2545
2389
|
// every question forced above was answered in order, so what's left
|
|
2546
2390
|
// unresolved is honestly empty — computed FROM questionsFromPlan
|
|
2547
2391
|
// rather than a hardcoded `[]`, so this stays true if the forcing
|
|
@@ -2562,7 +2406,7 @@ export async function runConfirmTurn({
|
|
|
2562
2406
|
ok: true, stop: null, rounds: round,
|
|
2563
2407
|
accepted: {
|
|
2564
2408
|
goal: redactSecrets(String(typed).trim()), checks: [...(r.plan.checks ?? [])], checkItems: [...(r.plan.checkItems ?? [])], protections: [...protections],
|
|
2565
|
-
lang: resolvedLang, worseThanBefore,
|
|
2409
|
+
lang: resolvedLang, worseThanBefore, ...(goalOnly ? { goalOnly: true } : {}),
|
|
2566
2410
|
openQuestions: questionsFromPlan(r.plan).slice(answeredQuestions.length),
|
|
2567
2411
|
notChecked: [...notChecked], answeredQuestions,
|
|
2568
2412
|
},
|
|
@@ -2584,7 +2428,7 @@ export async function runConfirmTurn({
|
|
|
2584
2428
|
ok: true, stop: null, rounds: round,
|
|
2585
2429
|
accepted: {
|
|
2586
2430
|
goal: String(r.plan.goal ?? ''), checks: [...(r.plan.checks ?? [])], checkItems: [...(r.plan.checkItems ?? [])], protections: [...protections],
|
|
2587
|
-
lang: resolvedLang, worseThanBefore, openQuestions: [...questionsFromPlan(r.plan), redactedFix], notChecked: [...notChecked],
|
|
2431
|
+
lang: resolvedLang, worseThanBefore, ...(goalOnly ? { goalOnly: true } : {}), openQuestions: [...questionsFromPlan(r.plan), redactedFix], notChecked: [...notChecked],
|
|
2588
2432
|
},
|
|
2589
2433
|
reds: [], cost: book.report(),
|
|
2590
2434
|
};
|
|
@@ -2597,22 +2441,6 @@ export async function runConfirmTurn({
|
|
|
2597
2441
|
throw new Error('[authorflow] runConfirmTurn fell through its 2-round cap without returning');
|
|
2598
2442
|
}
|
|
2599
2443
|
|
|
2600
|
-
/**
|
|
2601
|
-
* PRD v1.131 tick 4 (rubric jobs, the LAST try only; the caller gates both): the last try failed the gate, so the AI's own broken parts are dropped to Not checked (`dropExtras`) and the plan
|
|
2602
|
-
* is bound and checked ONCE more with the same gate (`redo`). Returns the new settled declaration and its result when that passes; `null` = nothing dropped, the plan is refused as today (the
|
|
2603
|
-
* try passed already, a red sits on a part the picks built or on no part, or the re-check is still red).
|
|
2604
|
-
* @param {{pre: any, v: {ok: boolean, reds: any[]}, jobLines: any[]|null|undefined, redo: (d: any) => any}} o
|
|
2605
|
-
* @returns {{pre: any, v: any}|null}
|
|
2606
|
-
*/
|
|
2607
|
-
export function dropAfterLastTry({ pre, v, jobLines, redo }) {
|
|
2608
|
-
if (v.ok) return null;
|
|
2609
|
-
const out = dropExtras(pre, v.reds, jobLines);
|
|
2610
|
-
if ('refused' in out) return null;
|
|
2611
|
-
const next = withFactBindings(out.declaration);
|
|
2612
|
-
const again = redo(next);
|
|
2613
|
-
return again.ok ? { pre: next, v: again } : null;
|
|
2614
|
-
}
|
|
2615
|
-
|
|
2616
2444
|
/**
|
|
2617
2445
|
* THE AUTHORING FLOW.
|
|
2618
2446
|
*
|
|
@@ -2659,7 +2487,7 @@ export function dropAfterLastTry({ pre, v, jobLines, redo }) {
|
|
|
2659
2487
|
* priorCalls?: {label: string, costUsd: number|null, unpricedRounds: number}[]|null,
|
|
2660
2488
|
* priorRaws?: any[]|null,
|
|
2661
2489
|
* jobLines?: {n: number, text: string}[]|null, inputs?: {n: number, label: string, value: string}[]|null,
|
|
2662
|
-
* offerQuestions?: boolean, ticket?: boolean,
|
|
2490
|
+
* offerQuestions?: boolean, ticket?: boolean, block?: CheckBlock|null, editGenerate?: Function|null,
|
|
2663
2491
|
* confirmed?: {checks: string[], checkItems?: {text: string, fromLine: number[]|null}[], protections: string[], openQuestions?: string[], notChecked?: string[], answeredQuestions?: string[]}|null}} o
|
|
2664
2492
|
*/
|
|
2665
2493
|
export async function authorClose({
|
|
@@ -2704,8 +2532,10 @@ export async function authorClose({
|
|
|
2704
2532
|
// MCP + tickets piece 2 (R5): the job reads tickets, so the drafter is told about the ticket filter, the schema offers the optional `ticketFilter` property and a proposal is
|
|
2705
2533
|
// checked by the one reader (src/ticketfilter.js). ABSENT = every other job: prompt, schema and validation byte-identical.
|
|
2706
2534
|
ticket = false,
|
|
2707
|
-
//
|
|
2708
|
-
|
|
2535
|
+
// the rubric job's CheckBlock (src/checkblock.js), built before the first try: the AI sends row edits, code builds every check and assembles the declaration from the rows. ABSENT = every other caller.
|
|
2536
|
+
block = null,
|
|
2537
|
+
// the row-edit turn's own model boundary (ROW_EDIT_SYSTEM); a test that replaces `generate` need not bring one
|
|
2538
|
+
editGenerate = null,
|
|
2709
2539
|
}) {
|
|
2710
2540
|
// PART 1a: the menu this close may draw from — a rubric job on local files sees its own two kinds, a code job never sees
|
|
2711
2541
|
// the rubric-only ones (`catalogueForLang`). Everything below (prompt, schema, validator, env) reads THIS one catalogue.
|
|
@@ -2879,16 +2709,35 @@ export async function authorClose({
|
|
|
2879
2709
|
const frozen = await readFrozenInputs(workdir, inputs.map((i) => i.label));
|
|
2880
2710
|
if (frozen.ok) { inputTexts = frozen.texts; labelLists = labelListsFor(frozen.texts, facts?.look ?? null); }
|
|
2881
2711
|
}
|
|
2882
|
-
//
|
|
2883
|
-
|
|
2884
|
-
|
|
2885
|
-
|
|
2886
|
-
|
|
2887
|
-
|
|
2888
|
-
|
|
2889
|
-
|
|
2890
|
-
|
|
2891
|
-
|
|
2712
|
+
// every rubric job drafts through the check block (src/authorjob.js builds it, with the person's answers applied); a caller that brings none (a direct authorClose call) gets the block of the look alone, nobody to ask
|
|
2713
|
+
if (block === null && lang === RUBRIC_LANG && inputTexts !== null && Array.isArray(jobLines)) {
|
|
2714
|
+
block = new CheckBlock({ texts: inputTexts, labels: (inputs ?? []).map((/** @type {any} */ i) => i.label), asks: false });
|
|
2715
|
+
block.fromJob(jobLines);
|
|
2716
|
+
block.addLook(Array.isArray(facts?.look?.facts) ? facts.look.facts : [], Array.isArray(facts?.look?.dropped) ? facts.look.dropped : []);
|
|
2717
|
+
block.reconcile();
|
|
2718
|
+
}
|
|
2719
|
+
/** the row-edit turn replaces the drafter's declaration for a rubric job: the model boundary and the declaration code assembles from the block's rows */
|
|
2720
|
+
const rowEdits = block !== null && lang === RUBRIC_LANG;
|
|
2721
|
+
const draftGenerate = rowEdits && editGenerate ? editGenerate : generate;
|
|
2722
|
+
/** the declaration of a rubric job, assembled by code from the rows: the mandatory guards, then the block's stages (hamr 2026-11-12, ruling 6), the rule rows no check carries as `refused`, the picks code recorded */
|
|
2723
|
+
const assemble = () => {
|
|
2724
|
+
const c = /** @type {CheckBlock} */ (block).reconcile();
|
|
2725
|
+
/** @type {{line: number, rule?: number, reason: string}[]} */
|
|
2726
|
+
const refused = /** @type {CheckBlock} */ (block).rows.filter((r) => r.kind === 'rule' && r.state !== 'built').map((r) => ({ line: r.line, rule: r.rule, reason: String(r.reason ?? 'not checked') }));
|
|
2727
|
+
// a job line no check could be built for (no stage) is refused as a line, in code's plain words, so the draft gate sees it covered and the end check (hasBuiltCheck) can say "no check" in its own words
|
|
2728
|
+
for (const l of jobLines ?? []) if (!c.stages.some((/** @type {any} */ st) => Array.isArray(st.fromLine) && st.fromLine.includes(l.n))) refused.push({ line: l.n, reason: REASON.noRule });
|
|
2729
|
+
const picks = /** @type {CheckBlock} */ (block).picksOf(c);
|
|
2730
|
+
// a guard's one fill slot (`allowPrefixes`) is the signed write fence, the very value the old drafter was told to copy: for a rubric job the run writes only under output/
|
|
2731
|
+
const fence = Array.isArray(writeScope) && writeScope.length ? [...writeScope] : ['output/'];
|
|
2732
|
+
return { stages: [...guards.map((/** @type {any} */ g) => ({ name: g.name, kind: g.kind, params: { ...g.params, ...Object.fromEntries((g.fill ?? []).map((/** @type {string} */ f) => [f, fence])) } })), ...c.stages], ...(refused.length ? { refused } : {}), ...(picks.length ? { picks } : {}) };
|
|
2733
|
+
};
|
|
2734
|
+
const prompt = rowEdits
|
|
2735
|
+
? rowEditUserText({ jobLines: jobLines ?? [], look: facts?.look ?? null, texts: inputTexts ?? {} }) + (ticket ? `\n\n${ticketFilterBlock()}` : '')
|
|
2736
|
+
: authorPrompt({
|
|
2737
|
+
answers, questions, facts, listingBlock: /** @type {string} */ (seeds.block),
|
|
2738
|
+
lang, verdictType, guards, ownedEnvNames, mode: structuredMode, catalogue, writeScope, confirmed, jobLines, inputs,
|
|
2739
|
+
labelLists,
|
|
2740
|
+
}) + (ticket ? `\n\n${ticketFilterBlock()}` : '');
|
|
2892
2741
|
// the draft gate on one settled declaration: validation, then (PART 1c, rubric) code proves, at $0, that every label is PICKED from the input's own list and every word a fact depends
|
|
2893
2742
|
// on is really in the source (white-space blind, once is enough). A word that is not found is a red naming the word and the input; the drafter revises like it does for any validation red.
|
|
2894
2743
|
const checkDraft = (/** @type {any} */ d) => {
|
|
@@ -2899,9 +2748,6 @@ export async function authorClose({
|
|
|
2899
2748
|
}
|
|
2900
2749
|
return r;
|
|
2901
2750
|
};
|
|
2902
|
-
// PRD v1.131 tick 7: per try (by call label), the retention counts of a rubric draft; the one that stands is reported once at the end
|
|
2903
|
-
/** @type {Map<string, ReturnType<typeof retentionOf>>} */
|
|
2904
|
-
const retentions = new Map();
|
|
2905
2751
|
/** @type {any[]} */
|
|
2906
2752
|
let messages = [{ role: 'user', content: prompt }];
|
|
2907
2753
|
/** the drafter's PROPOSED ticket filter of the accepted iteration (a Tickets job only); the person signs it, the spec carries it, the close never does @type {any} */
|
|
@@ -2989,7 +2835,10 @@ export async function authorClose({
|
|
|
2989
2835
|
// P7 item 5: a mechanism, never a wish. Only the last try of the full ladder carries the property, and only when the
|
|
2990
2836
|
// two before it both failed (validation or the seed read; `questionLines` is set at the end of the second one, below).
|
|
2991
2837
|
const askOpen = questionLines !== null && i === revisionCap;
|
|
2992
|
-
const ask =
|
|
2838
|
+
const ask = rowEdits
|
|
2839
|
+
? { ...(await askStructured({ messages, generate: draftGenerate, mode: structuredMode, retries: retryCap, label, book, channel: rowEditChannel(ticket) })), declaration: null }
|
|
2840
|
+
: await askDeclaration({ messages, generate, mode: structuredMode, retries: retryCap, label, book, catalogue: catalogueIn, kinds: Object.keys(catalogue), verdictType, questions: askOpen, ticket });
|
|
2841
|
+
if (rowEdits) ask.declaration = ask.artifact;
|
|
2993
2842
|
messages = ask.convo;
|
|
2994
2843
|
// `ticketFilter` is never part of the declaration (the close): taken out before validation, checked by its own reader below, and kept beside the declaration
|
|
2995
2844
|
/** @type {any} */
|
|
@@ -3088,16 +2937,26 @@ export async function authorClose({
|
|
|
3088
2937
|
}
|
|
3089
2938
|
previous = { d: ask.declaration, f: proposedFilter ?? null };
|
|
3090
2939
|
|
|
3091
|
-
//
|
|
3092
|
-
|
|
3093
|
-
|
|
2940
|
+
// a rubric job: ONE reply of row edits, each judged alone by the block; the declaration is assembled from the rows (a refused edit costs the others nothing)
|
|
2941
|
+
let pre = ask.declaration;
|
|
2942
|
+
/** @type {any[]} */
|
|
2943
|
+
let refusedEdits = [];
|
|
2944
|
+
if (rowEdits) {
|
|
2945
|
+
const rec = /** @type {CheckBlock} */ (block).applyDelta({ label, edits: editsOf(ask.declaration) });
|
|
2946
|
+
refusedEdits = rec.edits.filter((/** @type {any} */ e) => e.accepted !== true);
|
|
2947
|
+
pre = assemble();
|
|
2948
|
+
iter.edits = rec.edits.map((/** @type {any} */ e) => ({ op: e?.op, accepted: e.accepted === true, ...(e.accepted === true ? {} : { refusedBecause: e.refusedBecause }) }));
|
|
2949
|
+
onPhase('draft-ledger-try', { label, kept: rec.edits.length - refusedEdits.length, refused: refusedEdits.map((/** @type {any} */ e) => ({ op: String(e?.op), reason: String(e.refusedBecause) })) });
|
|
2950
|
+
}
|
|
3094
2951
|
let v = checkDraft(pre);
|
|
3095
|
-
//
|
|
3096
|
-
if (!v.ok
|
|
3097
|
-
|
|
3098
|
-
|
|
2952
|
+
// a gate red on the code-built declaration is OUR bug (hamr 2026-11-12, ruling 3): the plan stops in plain words, the AI is never asked to fix it
|
|
2953
|
+
if (rowEdits && !v.ok) {
|
|
2954
|
+
fatal = [{ code: 'plan-red', path: 'closeDecl', detail: `The plan code built from your checks did not pass its own gate (${v.reds.slice(0, 2).map((/** @type {Red} */ r) => `${r.code} at ${r.path || '(root)'}: ${r.detail}`).join('; ')}). That is a fault in the build, not in your job: nothing was spent on a close.` }];
|
|
2955
|
+
stop = 'plan-red';
|
|
2956
|
+
iter.validation = { ok: false, reds: v.reds.map(scrubRed), scoped: v.scoped };
|
|
2957
|
+
lastValidation = { ok: false, reds: v.reds.map(scrubRed) };
|
|
2958
|
+
break;
|
|
3099
2959
|
}
|
|
3100
|
-
if (lang === RUBRIC_LANG) retentions.set(label, retentionOf(ask.declaration, pre, jobLines));
|
|
3101
2960
|
// MCP + tickets piece 2: a proposed ticket filter is read by the ONE reader (src/ticketfilter.js); its reds carry a legal example and go back to the drafter like any red
|
|
3102
2961
|
if (v.ok && ticket && proposedFilter !== undefined) {
|
|
3103
2962
|
const fr = ticketFilterReds(proposedFilter);
|
|
@@ -3118,6 +2977,7 @@ export async function authorClose({
|
|
|
3118
2977
|
|
|
3119
2978
|
/** @type {string} */
|
|
3120
2979
|
let measured;
|
|
2980
|
+
let seedFailed = false;
|
|
3121
2981
|
if (!v.ok) {
|
|
3122
2982
|
// a validation red IS a measurement of the declaration, so it rides the
|
|
3123
2983
|
// same channel and counts as a revision (addendum 5)
|
|
@@ -3156,6 +3016,7 @@ export async function authorClose({
|
|
|
3156
3016
|
measuredIterations.push({ label, declaration: injected.declaration, seedRead: rows, droppedEnv: injected.dropped });
|
|
3157
3017
|
const sf = seedReadFailure(rows, injected.declaration, guards.map((/** @type {any} */ g) => g.name), (jobLines ?? []).map((l) => l.n));
|
|
3158
3018
|
tryFails[i] = sf.failed ? { lines: sf.lines } : null;
|
|
3019
|
+
seedFailed = sf.failed;
|
|
3159
3020
|
if (sf.failed) {
|
|
3160
3021
|
const guardNames = guards.map((/** @type {any} */ g) => g.name);
|
|
3161
3022
|
const stoppedNames = [...new Set(rows.filter((/** @type {any} */ r) => !guardNames.includes(r?.stage) && r?.verdict === 'instrument-stop').map((/** @type {any} */ r) => String(r.stage)))];
|
|
@@ -3168,6 +3029,8 @@ export async function authorClose({
|
|
|
3168
3029
|
}
|
|
3169
3030
|
}
|
|
3170
3031
|
|
|
3032
|
+
// hamr 2026-11-12 (ruling 3): a rubric job revises only when the last reply had refused edits OR the seed read failed; else the plan stands
|
|
3033
|
+
if (rowEdits && v.ok && refusedEdits.length === 0 && !seedFailed) { stop = 'settled'; break; }
|
|
3171
3034
|
if (i === revisionCap) { stop = 'max-revisions'; break; }
|
|
3172
3035
|
|
|
3173
3036
|
// P7 item 5: the NEXT try is the last of a full ladder, and this one AND the first both FAILED — either failed validation
|
|
@@ -3178,6 +3041,16 @@ export async function authorClose({
|
|
|
3178
3041
|
questionLines = second && second.lines.length ? second.lines : null;
|
|
3179
3042
|
}
|
|
3180
3043
|
|
|
3044
|
+
if (rowEdits) {
|
|
3045
|
+
// the revise turn carries each refused edit's own reason, and the seed read when it failed, and nothing else
|
|
3046
|
+
const blocks = [];
|
|
3047
|
+
if (refusedEdits.length) blocks.push(renderRejectBlock({ kind: 'edits', reds: refusedEdits.map((/** @type {any} */ e) => `edit ${String(e?.op)}: ${String(e.refusedBecause)}`) }));
|
|
3048
|
+
blocks.push(v.ok ? (seedFailed ? measured : '') : measured);
|
|
3049
|
+
const editTurn = `${blocks.filter(Boolean).join('\n\n')}\n\n${ROW_EDIT_REVISE}`;
|
|
3050
|
+
iter.reviseTurn = { bytes: Buffer.byteLength(editTurn) };
|
|
3051
|
+
messages = [...messages, { role: 'assistant', content: ask.raw.trim() || '(the reply carried no text)' }, { role: 'user', content: editTurn }];
|
|
3052
|
+
continue;
|
|
3053
|
+
}
|
|
3181
3054
|
const turn = buildReviseTurn(measured);
|
|
3182
3055
|
// A TRIPWIRE, not behaviour: it can only fire once something else is
|
|
3183
3056
|
// already broken, so it is the one guard in this module the mutation
|
|
@@ -3210,7 +3083,7 @@ export async function authorClose({
|
|
|
3210
3083
|
// it by reading only `declaration`/`seedRead`/`finalFrom`.
|
|
3211
3084
|
/** @type {{from: string, to: string, brokenStages: string[]}|null} */
|
|
3212
3085
|
let fellBack = null;
|
|
3213
|
-
if (measuredIterations.length) {
|
|
3086
|
+
if (measuredIterations.length && !rowEdits) {
|
|
3214
3087
|
const last = measuredIterations[measuredIterations.length - 1];
|
|
3215
3088
|
if (!isSoundMeasurement(last.seedRead)) {
|
|
3216
3089
|
for (let k = measuredIterations.length - 2; k >= 0; k -= 1) {
|
|
@@ -3231,9 +3104,11 @@ export async function authorClose({
|
|
|
3231
3104
|
}
|
|
3232
3105
|
}
|
|
3233
3106
|
|
|
3234
|
-
// PRD v1.131 tick 7: ONE retention record when a rubric draft ends (accepted or stopped), counts only; the panel writes it into the drafting log
|
|
3235
|
-
|
|
3236
|
-
|
|
3107
|
+
// PRD v1.131 tick 7: ONE retention record when a rubric draft ends (accepted or stopped), counts only; the panel writes it into the drafting log. Read from the block's rows.
|
|
3108
|
+
if (rowEdits) {
|
|
3109
|
+
onPhase('draft-retention', { lines: /** @type {CheckBlock} */ (block).retention() });
|
|
3110
|
+
onPhase('draft-ledger', { rows: ledgerRecord(/** @type {any} */ (block).rows) });
|
|
3111
|
+
}
|
|
3237
3112
|
|
|
3238
3113
|
const reds = fatal.length ? fatal : (lastValidation && !lastValidation.ok ? lastValidation.reds : []);
|
|
3239
3114
|
return {
|
|
@@ -3267,6 +3142,8 @@ export async function authorClose({
|
|
|
3267
3142
|
stop,
|
|
3268
3143
|
// P7 item 5: what the person is asked (empty on every other stop)
|
|
3269
3144
|
questions: stop === 'questions-open' ? askedQuestions : [],
|
|
3145
|
+
// the one check list's final rows against the declaration that stands (the signed close carries them as `closeDecl.list`); null = no list
|
|
3146
|
+
ledger: rowEdits && accepted !== null ? /** @type {CheckBlock} */ (block).signedRows() : null,
|
|
3270
3147
|
revisions: Math.max(0, iterations.length - 1),
|
|
3271
3148
|
};
|
|
3272
3149
|
}
|