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/authoring.js
CHANGED
|
@@ -354,7 +354,7 @@ export const KIND_CATALOGUE = Object.freeze({
|
|
|
354
354
|
pathParams: Object.freeze([]),
|
|
355
355
|
shape: 'step: integer (the job line number), parts: [{text: string, class: "countable" | "fact" | "judged" | "guard" | "none", '
|
|
356
356
|
+ 'check?: "cited" | "minClaims" | "maxClaims", value?: integer, '
|
|
357
|
-
+ 'source?: string (an input label), domains?: string[],
|
|
357
|
+
+ 'source?: string (an input label), domains?: string[], rules?: integer[], '
|
|
358
358
|
+ 'fact parts: facts?: [{name, shape: "money"|"number"|"date"|"time"|"phrase"|"text", unit?|currency? (each one value or a list; money names at least one), phrase?, anchor?, until?, '
|
|
359
359
|
+ 'rule?: {op, value | lo+hi}, aiProposal?: boolean}], count?: {min?, max?}}]',
|
|
360
360
|
asserts: 'the file output/<step>.json under output/steps/ exists, is a JSON object, and its "text" is present and within the '
|
|
@@ -366,8 +366,7 @@ export const KIND_CATALOGUE = Object.freeze({
|
|
|
366
366
|
+ 'a line that FINDS, LISTS or LOOKS UP something gets ONE part of class "fact" instead (source = the input label, '
|
|
367
367
|
+ 'facts = the required facts, count = how many results): its step file holds only filled facts and no free text, so '
|
|
368
368
|
+ 'give such a line no word, section or claim-count parts; list in "rules" the number of every ~ rule a part carries out; '
|
|
369
|
-
+ '
|
|
370
|
-
+ 'covers is moved to Not checked before signing); "judged" when only reading '
|
|
369
|
+
+ '"judged" when only reading '
|
|
371
370
|
+ 'it could decide; "guard" for a rule about web sources (domains); "none" when you cannot sort it. Never turn a part you cannot '
|
|
372
371
|
+ 'count or quote into a countable one by guessing a number.',
|
|
373
372
|
}),
|
package/src/authorjob.js
CHANGED
|
@@ -100,7 +100,7 @@
|
|
|
100
100
|
|
|
101
101
|
import { jobSpecHash, validateJob } from './job.js';
|
|
102
102
|
import { seedAtHead, seedListing, seedRead as runSeedRead, makeSeedTrees, judgedStages, closeJudges } from './kinds.js';
|
|
103
|
-
import { inputLabelsOf, readFrozenInputs, lineRules } from './rubricstep.js';
|
|
103
|
+
import { inputLabelsOf, readFrozenInputs, lineRules, cardOfClose } from './rubricstep.js';
|
|
104
104
|
import { proverOf } from './factwords.js';
|
|
105
105
|
// SOFTGREEN modules 4 and 5 — the compile the interview's Q6/Q7 answers land in,
|
|
106
106
|
// and the gate that decides whether the ruler they describe is a ruler.
|
|
@@ -113,16 +113,19 @@ import {
|
|
|
113
113
|
} from './authoring.js';
|
|
114
114
|
import {
|
|
115
115
|
QUESTION_SETS, questionsFor, requiredAnswersFor, authorClose, makeCostBook,
|
|
116
|
-
runConfirmTurn, LANGUAGE_PICK_FIELD,
|
|
116
|
+
runConfirmTurn, LANGUAGE_PICK_FIELD, MAX_QUESTIONS,
|
|
117
117
|
} from './authorflow.js';
|
|
118
118
|
import { thinkingCallOptions, assertThinkingMode } from './thinking.js';
|
|
119
119
|
import { runFitCheck, fitQuestionText, notFoundList, isGoOn } from './fitcheck.js';
|
|
120
120
|
import { pageContentChars } from './pagefetch.js';
|
|
121
121
|
import { runAuthorScout, buildSeedListing, SCOUT_ATTEMPTS } from './authorscout.js';
|
|
122
|
-
import { runPageMap,
|
|
123
|
-
import {
|
|
124
|
-
import {
|
|
122
|
+
import { runPageMap, tooManyAsksText } from './pagemap.js';
|
|
123
|
+
import { CheckBlock } from './checkblock.js';
|
|
124
|
+
import { questionsOfBlock, applyChoices } from './blockasks.js';
|
|
125
|
+
import { scopedRules, codeScope, plainWords } from './checkpick.js';
|
|
126
|
+
import { matchRecord, entriesFromAnswers, KEPT_WORDS } from './pickrecord.js';
|
|
125
127
|
import { runCheckSuggest } from './checksuggest.js';
|
|
128
|
+
import { runLedgerSuggest, ledgerRecord } from './checklist.js';
|
|
126
129
|
import {
|
|
127
130
|
DECLARED_GAP_PREFIX, DECLARED_GENRES, guardNames, isDeclaredClose, validateCloseDecl,
|
|
128
131
|
} from './declaredclose.js';
|
|
@@ -438,14 +441,14 @@ function composerRefusal(reds) {
|
|
|
438
441
|
* authorFn?: Function, authorOpts?: object, writeScope?: string[]|null,
|
|
439
442
|
* signerFix?: Function|any, proposeFn?: Function, compileOpts?: object,
|
|
440
443
|
* ask?: ((step: {kind: string, [k: string]: any}) => Promise<string|null>)|null,
|
|
441
|
-
* answerQuestions?: ((o: {questions: {line: number, question: string, rule?: number, source?: string, ask?: string, reading?: string}[], dropped: {reason: string, raw: any}[], confirmed: any}) =>
|
|
442
|
-
* Promise<{jobLines: {n: number, text: string, rule?: string}[], answers: Record<string|number, any>, left?: {line: number, rule: number}[], picks?: any[]}|null>)|null,
|
|
443
|
-
* pickGenerate?: Function|null, carriedPicks?: any[]|null, onPicks?: (o: {entries: any[], kept: {line: number, rule: number, entry: any}[]}) => void,
|
|
444
|
+
* answerQuestions?: ((o: {questions: {line: number, question: string, rule?: number, source?: string, ask?: string, reading?: string, key?: string}[], dropped: {reason: string, raw: any}[], confirmed: any}) =>
|
|
445
|
+
* Promise<{jobLines: {n: number, text: string, rule?: string}[], answers: Record<string|number, any>, left?: {line: number, rule: number}[], picks?: any[], choices?: {key: string, choice: string, text?: string}[]}|null>)|null,
|
|
446
|
+
* pickGenerate?: Function|null, ledgerGenerate?: Function|null, editGenerate?: Function|null, carriedPicks?: any[]|null, carriedChoices?: any[]|null, onChoices?: (rec: any[]) => void, onPicks?: (o: {entries: any[], kept: {line: number, rule: number, entry: any}[]}) => void,
|
|
444
447
|
* confirmGenerate?: Function|null, isRepo?: boolean,
|
|
445
448
|
* langResult?: {kind: string, candidates?: string[], [k: string]: any}|null}} o
|
|
446
449
|
* @returns {Promise<{ok: boolean, refusal: Refusal|null, verdictType: string|null,
|
|
447
450
|
* closeDecl: any, seedRef: string|null, authoring: any, judged: any, reds: Red[],
|
|
448
|
-
* stop: string|null, cost: any, interview: any, confirmed: any,
|
|
451
|
+
* stop: string|null, cost: any, interview: any, confirmed: any, picked?: {line: number, text: string}[], hasBuiltCheck?: boolean, notBuilt?: {line: number, text: string}[]}>}
|
|
449
452
|
*/
|
|
450
453
|
export async function authorCloseForJob({
|
|
451
454
|
answers, repoPath = null, lang, verdictType = null, questions = null,
|
|
@@ -486,8 +489,15 @@ export async function authorCloseForJob({
|
|
|
486
489
|
// R10 (fwd am16): the model boundary of the check-suggestion call (a `makeLoopGenerate` bound to SUGGEST_SYSTEM). ABSENT = no pick path: nothing is suggested or asked and the
|
|
487
490
|
// drafted declaration is validated as it always was (a test seam, like `lookFn: null`).
|
|
488
491
|
pickGenerate = null,
|
|
492
|
+
// the model boundary of the list call (a `makeLoopGenerate` bound to LEDGER_SYSTEM), rubric jobs only. ABSENT = the list is built from the look and the defaults with no suggestion call
|
|
493
|
+
// (a test seam, like `pickGenerate`); the CLI and the panel always bring it.
|
|
494
|
+
ledgerGenerate = null,
|
|
495
|
+
// the row-edit turn's own model boundary (src/rowedit.js ROW_EDIT_SYSTEM); a test that replaces `generate` need not bring one
|
|
496
|
+
editGenerate = null,
|
|
489
497
|
// R10 (fwd am17/am18): the picks record of the draft this one follows (`readRecordFile`), and the seam that receives this draft's record + the picks it kept. ABSENT = every rule is asked.
|
|
490
498
|
carriedPicks = null, onPicks = () => {},
|
|
499
|
+
// hamr 2026-11-13 (N-2): the Drop/Add choices of the draft this one follows (the picks record file's `rowChoices`); a Revise keeps them, code still judges every one
|
|
500
|
+
carriedChoices = null, onChoices = () => {},
|
|
491
501
|
// SOFTGREEN modules 4+5. `signerFix` is the D5 seam: a function (or a value)
|
|
492
502
|
// carrying the SIGNER's corrected artifacts back. Absent means the proposal is
|
|
493
503
|
// signed as proposed, and `signJudgedArtifacts` records which of the two
|
|
@@ -613,6 +623,8 @@ export async function authorCloseForJob({
|
|
|
613
623
|
// arrived at by accident.
|
|
614
624
|
/** @type {any} */
|
|
615
625
|
let survey = scout;
|
|
626
|
+
/** the frozen input texts the list's word proof reads (a rubric job with a look) @type {Record<string, string>|null} */
|
|
627
|
+
let ledgerTexts = null;
|
|
616
628
|
// PART 1a: a rubric job on local files has no repository to survey. PART 1c: its survey is the LOOK - a read-only, bounded, paid
|
|
617
629
|
// look at the person's frozen input text that reports which facts can be checked and with which label (picked from a code-made
|
|
618
630
|
// list). Without a look (`lookFn` null, or no model boundary) the survey is just the numbered inputs, known to code at $0.
|
|
@@ -620,6 +632,7 @@ export async function authorCloseForJob({
|
|
|
620
632
|
const inputList = (Array.isArray(inputs) ? inputs : []).map((i) => ({ n: i.n, label: i.label }));
|
|
621
633
|
const frozen = lookFn && provider && Array.isArray(jobLines) && jobLines.length > 0 && inputList.length > 0
|
|
622
634
|
? await readFrozenInputs(workdir, inputList.map((i) => i.label)) : null;
|
|
635
|
+
if (frozen !== null && frozen.ok) ledgerTexts = frozen.texts;
|
|
623
636
|
if (frozen !== null && !frozen.ok) {
|
|
624
637
|
survey = { state: 'ABSENT', reason: `the look at your input could not start: ${frozen.why}`, cause: 'call-failed', budgetStop: null, calls: [], raws: [], facts: null };
|
|
625
638
|
} else if (frozen !== null && lookFn && !Object.values(frozen.texts).some((t) => pageContentChars(t) > 0)) {
|
|
@@ -639,7 +652,8 @@ export async function authorCloseForJob({
|
|
|
639
652
|
onPhase('fit-check-done', { state: fit.state });
|
|
640
653
|
onFit({ state: fit.state, asks: fit.asks, notFound: fit.notFound });
|
|
641
654
|
if (fit.state === 'ask') {
|
|
642
|
-
const
|
|
655
|
+
const foundAsks = fit.asks.filter((/** @type {any} */ a) => !a.ignored && a.found).map((/** @type {any} */ a) => ({ line: a.line, ask: a.ask }));
|
|
656
|
+
const answer = await fitAsk(fitQuestionText({ found: foundAsks.length, foundAsks, total: fit.asks.filter((/** @type {any} */ a) => !a.ignored).length, notFound: fit.notFound }));
|
|
643
657
|
if (answer === null) return { ...base, interview, verdictType: picked, seedRef: seed, reds: [], stop: 'confirm-abandoned', cost: null };
|
|
644
658
|
if (!isGoOn(answer)) {
|
|
645
659
|
return { ...base, interview, verdictType: picked, seedRef: seed, reds: [{ code: 'fit-stopped', path: 'jobLines', detail: notFoundList(fit.notFound) }], stop: 'fit-stopped', cost: null };
|
|
@@ -678,87 +692,92 @@ export async function authorCloseForJob({
|
|
|
678
692
|
onPhase('scout-done', { state: survey?.state ?? null, facts: Object.keys(survey?.facts ?? {}).length });
|
|
679
693
|
}
|
|
680
694
|
|
|
681
|
-
//
|
|
682
|
-
//
|
|
683
|
-
//
|
|
684
|
-
//
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
/**
|
|
689
|
-
let
|
|
690
|
-
if (
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
695
|
+
// THE CHECK BLOCK of a rubric job (src/checkblock.js; hamr 2026-11-12: "one flow one place ai suggestes ! code adds $ and code decides what worked/doable"). It is made once here, after the look:
|
|
696
|
+
// the person's `~` rules and `$` defaults, then the look's facts (a fact tied to a `~` rule is a link on that row), then the last draft's picks Revise keeps (am17/am18/am21). The AI's two
|
|
697
|
+
// helpers (the pick call for count rules, the call for extra `!` checks) send ROW EDITS through the SAME door as the drafter's reply (`applyDelta`). Code then asks (cap 3) about what it
|
|
698
|
+
// cannot settle and applies the person's CHOICE (agree | drop | their own words) with `applyAnswer`. Every check comes from the rows; no other store holds one.
|
|
699
|
+
/** @type {import('./checkblock.js').CheckBlock|null} */
|
|
700
|
+
let block = null;
|
|
701
|
+
/** the picks the person made (kept and answered) this draft, as the picks record carries them */
|
|
702
|
+
/** @type {{kept: any[]}|null} */
|
|
703
|
+
let carried = null;
|
|
704
|
+
if (lang === RUBRIC_LANG && survey?.state === 'PRESENT' && Array.isArray(jobLines) && ledgerTexts) {
|
|
705
|
+
const look = survey.facts?.look && typeof survey.facts.look === 'object' ? survey.facts.look : null;
|
|
706
|
+
block = new CheckBlock({ texts: ledgerTexts, labels: (Array.isArray(inputs) ? inputs : []).map((i) => i.label), asks: Boolean(answerQuestions), split: true, countScope: (t) => Boolean(pickGenerate) && codeScope(inputs, t) === 'in' });
|
|
707
|
+
block.fromJob(jobLines);
|
|
708
|
+
block.addLook(Array.isArray(look?.facts) ? look.facts : [], Array.isArray(look?.dropped) ? look.dropped : []);
|
|
709
|
+
/** the rules a count pick settles, as the record knows them (a scoped rule is a counting `~` rule code scopes in) */
|
|
710
|
+
const scoped = answerQuestions ? scopedRules(jobLines, { inputs, look }) : [];
|
|
711
|
+
const matched = matchRecord(Array.isArray(carriedPicks) ? carriedPicks : [], jobLines, scoped);
|
|
712
|
+
carried = { kept: matched.kept };
|
|
713
|
+
block.carry({ picks: matched.picks, left: matched.left }, matched.askRules);
|
|
714
|
+
// a rule the record folded into another ask (a broken pair's partner) is neither asked nor given the old check: Not checked, in the pick path's own words
|
|
715
|
+
for (const r of scoped) {
|
|
716
|
+
const row = block.ruleRows(r.line).find((x) => x.rule === r.rule);
|
|
717
|
+
if (row && !matched.askRules.some((a) => a.line === r.line && a.rule === r.rule) && !row.pick && !row.cantAsked && !row.left && !row.parent) row.folded = true;
|
|
696
718
|
}
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
onPhase('
|
|
701
|
-
const
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
const ruleText = lineRules(jobLines.find((l) => l.n === lf.line) ?? {})[lf.rule - 1];
|
|
707
|
-
if (ruleText === undefined) continue;
|
|
708
|
-
const look = survey.facts.look;
|
|
709
|
-
look.dropped = [...(Array.isArray(look.dropped) ? look.dropped : []), { line: lf.line, rule: lf.rule, fact: ruleText, reason: 'person-left', source: 'person' }];
|
|
710
|
-
}
|
|
719
|
+
block.reconcile();
|
|
720
|
+
// the pick call: one suggestion per counting rule the record did not keep; each kept suggestion is a `pick` edit
|
|
721
|
+
if (answerQuestions && pickGenerate && matched.askRules.length > 0) {
|
|
722
|
+
onPhase('check-suggest', { rules: matched.askRules.length });
|
|
723
|
+
const sug = await runCheckSuggest({ jobLines, scoped: matched.askRules, generate: pickGenerate, ceilingUsd, onCall, priorCalls: survey?.calls ?? [], priorRaws: survey?.raws ?? [] });
|
|
724
|
+
survey.calls = [...(survey.calls ?? []), ...sug.calls];
|
|
725
|
+
survey.raws = [...(survey.raws ?? []), ...sug.raws];
|
|
726
|
+
block.applyDelta({ label: 'pre:check-suggest', pre: true, edits: sug.rows.filter((r) => r.check).map((r) => ({ op: 'pick', line: r.line, rules: [r.rule], check: r.check })) });
|
|
727
|
+
block.reconcile();
|
|
711
728
|
}
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
const matched = matchRecord(Array.isArray(carriedPicks) ? carriedPicks : [], jobLines, scoped);
|
|
725
|
-
/** @type {ReturnType<typeof checkAsks>} */
|
|
726
|
-
let asks = [];
|
|
727
|
-
let sug = null;
|
|
728
|
-
if (matched.askRules.length > 0) {
|
|
729
|
-
onPhase('check-suggest', { rules: matched.askRules.length });
|
|
730
|
-
sug = await runCheckSuggest({ jobLines, scoped: matched.askRules, generate: pickGenerate, ceilingUsd, onCall, priorCalls: survey?.calls ?? [], priorRaws: survey?.raws ?? [] });
|
|
731
|
-
// the call's spend joins the survey's, so the ONE ceiling the later stages enforce already holds it
|
|
732
|
-
survey.calls = [...(survey.calls ?? []), ...sug.calls];
|
|
733
|
-
survey.raws = [...(survey.raws ?? []), ...sug.raws];
|
|
734
|
-
asks = checkAsks(sug.rows);
|
|
729
|
+
// the call for extra `!` checks (count, phrase): its proposals are edits like the drafter's own
|
|
730
|
+
if (ledgerGenerate) {
|
|
731
|
+
onPhase('ledger-suggest', {});
|
|
732
|
+
const lg = await runLedgerSuggest({ jobLines, texts: ledgerTexts, generate: ledgerGenerate, ceilingUsd, onCall, priorCalls: survey?.calls ?? [], priorRaws: survey?.raws ?? [] });
|
|
733
|
+
survey.calls = [...(survey.calls ?? []), ...lg.calls];
|
|
734
|
+
survey.raws = [...(survey.raws ?? []), ...lg.raws];
|
|
735
|
+
/** @type {any[]} */
|
|
736
|
+
const adds = [];
|
|
737
|
+
for (const e of lg.extra) {
|
|
738
|
+
const line = Number.isInteger(e?.line) ? e.line : 1;
|
|
739
|
+
if (e?.kind === 'count') adds.push({ op: 'add', kind: 'count', line, min: e.min, max: e.max });
|
|
740
|
+
else if (e?.kind === 'phrase' && typeof e.phrase === 'string') adds.push({ op: 'add', kind: 'phrase', line, name: e.phrase, words: [e.phrase], source: e.source });
|
|
735
741
|
}
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
742
|
+
block.applyDelta({ label: 'pre:ledger-suggest', pre: true, edits: adds });
|
|
743
|
+
block.reconcile();
|
|
744
|
+
}
|
|
745
|
+
// a Revise keeps the last draft's Drop/Add choices (the suggestions exist now); code still judges every one when the list is reconciled
|
|
746
|
+
if (Array.isArray(carriedChoices)) { block.carryChoices(carriedChoices); onChoices(block.choicesRecord()); }
|
|
747
|
+
block.reconcile();
|
|
748
|
+
onPhase('ledger-built', { rows: ledgerRecord(/** @type {any} */ (block.rows)) });
|
|
749
|
+
// the code-forced asks (PRD v1.106 Part 5 Q3 T2, v1.107 Part 5b, R10): a reading code proposes, a rule the page cannot check, a check proposed for a counting rule. More than
|
|
750
|
+
// MAX_QUESTIONS counted asks is a job to rewrite, not a questionnaire: nothing is asked and the stop lists every ask.
|
|
751
|
+
if (answerQuestions) {
|
|
752
|
+
/** what the person answered, across the rounds: the picks and the rules they left, for the record this draft hands on @type {{picks: any[], left: any[]}} */
|
|
753
|
+
const answered = { picks: [], left: [] };
|
|
754
|
+
for (let round = 0; round < 3 && block.open.length > 0; round += 1) {
|
|
755
|
+
const asks = questionsOfBlock(block, pickGenerate ? scoped : []);
|
|
756
|
+
const counted = asks.filter((a) => a.counted);
|
|
757
|
+
if (counted.length > MAX_QUESTIONS) {
|
|
758
|
+
return { ...base, interview, verdictType: picked, seedRef: seed, reds: [{ code: 'look-asks-too-many', path: 'jobLines', detail: tooManyAsksText(asks) }], stop: 'look-asks-too-many', cost: null };
|
|
759
|
+
}
|
|
760
|
+
// the asks go to the person whole (key, check, reading, counted, pairRule): normalizeQuestions keeps only a model's question fields and would drop the proposal an Agree button needs
|
|
761
|
+
const shown = asks.map((a) => ({ ...a, question: redactSecrets(a.question) }));
|
|
762
|
+
if (shown.length === 0) break;
|
|
763
|
+
onPhase(shown.every((a) => a.ask === 'check' || a.ask === 'no-check') ? 'check-ask' : 'look-ask', { questions: shown.length });
|
|
764
|
+
const updated = await answerQuestions({ questions: shown, dropped: [], confirmed: null });
|
|
745
765
|
if (updated === null) return { ...base, interview, verdictType: picked, seedRef: seed, reds: [], stop: 'confirm-abandoned', cost: null };
|
|
746
766
|
jobLines = updated.jobLines;
|
|
747
767
|
interview.answers = updated.answers;
|
|
768
|
+
answered.picks.push(...(Array.isArray(updated.picks) ? updated.picks : []));
|
|
769
|
+
answered.left.push(...(Array.isArray(updated.left) ? updated.left : []));
|
|
770
|
+
const refused = applyChoices(block, Array.isArray(updated.choices) ? updated.choices : []);
|
|
771
|
+
if (refused.length === 0) break;
|
|
748
772
|
}
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
kept: matched.kept.map((k) => ({ line: k.line, rule: k.rule, entry: k.entry })),
|
|
758
|
-
});
|
|
759
|
-
checkPicks = { rules: scoped, picks: [...keptPicks, ...newPicks], left: [...keptLeft, ...answeredLeft], rows: sug?.rows ?? [] };
|
|
760
|
-
base.checkPicks = checkPicks;
|
|
761
|
-
}
|
|
773
|
+
// the record this draft hands on, written whether or not anything was asked (a draft that kept every pick still carries them forward): the picks it kept, as they were, and the picks just answered, keyed by words
|
|
774
|
+
if (scoped.length > 0) {
|
|
775
|
+
onPicks({
|
|
776
|
+
entries: [...carried.kept.map((k) => k.entry), ...entriesFromAnswers(jobLines, scoped, answered.picks, answered.left.filter((l) => scoped.some((r) => r.line === l.line && r.rule === l.rule)))],
|
|
777
|
+
kept: carried.kept.map((k) => ({ line: k.line, rule: k.rule, entry: k.entry })),
|
|
778
|
+
});
|
|
779
|
+
}
|
|
780
|
+
} else block.reconcile();
|
|
762
781
|
}
|
|
763
782
|
|
|
764
783
|
// ── THE CONFIRM TURN'S PAID HALF (PRD item 33 M3 piece 4) ──────────────────
|
|
@@ -804,8 +823,12 @@ export async function authorCloseForJob({
|
|
|
804
823
|
verdictType: picked, answers: interview.answers, questions: questions ?? questionsFor(picked),
|
|
805
824
|
facts: survey.facts, listing: null, writeScope, isRepo, lang, worseThanBefore, inputs, jobLines,
|
|
806
825
|
...(authorOpts?.ticket === true ? { ticket: true } : {}),
|
|
807
|
-
...(checkPicks ? { settled: checkPicks.rules } : {}),
|
|
808
826
|
generate: confirmGenerate, book: confirmBook, ask, onPhase,
|
|
827
|
+
// the rows the block has built, read by the signed card's own readers (cardOfClose): the confirm card draws them under their lines
|
|
828
|
+
...(block ? (() => {
|
|
829
|
+
const cardOf = () => cardOfClose({ closeDecl: block.closeView(), jobLines, ledger: block.rows.map((r) => ({ key: r.key, words: r.kind === 'rule' ? [r.text ?? ''] : (r.words ?? []) })) });
|
|
830
|
+
return { card: cardOf(), cardOf, block };
|
|
831
|
+
})() : {}),
|
|
809
832
|
});
|
|
810
833
|
// DISTINCT from `runConfirmTurn`'s own per-round 'confirm-done' (fired once
|
|
811
834
|
// per round when a plan arrives) — this is the WRAPPER's own line, once,
|
|
@@ -858,7 +881,7 @@ export async function authorCloseForJob({
|
|
|
858
881
|
// PART 1c: a rubric job asks nothing piecemeal on a failed try - it stops, and the person reviews the whole job (the one early
|
|
859
882
|
// ask is about a `~` rule the look could not find, above)
|
|
860
883
|
...(answerQuestions && lang !== RUBRIC_LANG ? { offerQuestions: true } : {}),
|
|
861
|
-
...(
|
|
884
|
+
...(block ? { block, editGenerate } : {}),
|
|
862
885
|
...authorOpts,
|
|
863
886
|
});
|
|
864
887
|
// P7 item 5: the drafter, on the last try after two failed ones, asked. The person answers (required, no skip); each
|
|
@@ -879,7 +902,7 @@ export async function authorCloseForJob({
|
|
|
879
902
|
scout: survey, listing: seeds, generate, ceilingUsd, onPhase, onCall, writeScope,
|
|
880
903
|
priorCalls: (authored.cost?.calls ?? []).slice(scoutCalls), priorRaws: (authored.raws ?? []).slice(scoutRaws),
|
|
881
904
|
confirmed, jobLines, inputs,
|
|
882
|
-
...(
|
|
905
|
+
...(block ? { block, editGenerate } : {}),
|
|
883
906
|
...authorOpts,
|
|
884
907
|
offerQuestions: false,
|
|
885
908
|
});
|
|
@@ -937,6 +960,8 @@ export async function authorCloseForJob({
|
|
|
937
960
|
: {}),
|
|
938
961
|
// keep-both: the person's picks, as code recorded them at the draft (the signed close reads this to tell a pick from a drafter-written count beside a fact)
|
|
939
962
|
...(authored.declaration.picks?.length ? { picks: structuredClone(authored.declaration.picks) } : {}),
|
|
963
|
+
// the one check list's final rows (no words), signed with the close: what each row ended as, and the part that carries it
|
|
964
|
+
...(Array.isArray(authored.ledger) && authored.ledger.length ? { list: structuredClone(authored.ledger) } : {}),
|
|
940
965
|
// the lines the always-on guards cover (names and numbers only, nothing free-text)
|
|
941
966
|
...(authored.declaration.guardLines?.length
|
|
942
967
|
? { guardLines: authored.declaration.guardLines.map((/** @type {any} */ g) => ({ guard: g.guard, lines: [...g.lines] })) }
|
|
@@ -1037,7 +1062,11 @@ export async function authorCloseForJob({
|
|
|
1037
1062
|
seedRef: seed,
|
|
1038
1063
|
authoring: authored,
|
|
1039
1064
|
judged,
|
|
1040
|
-
|
|
1065
|
+
// the checks the person picked, for the plan card's "You picked" rows (read from the block's rows)
|
|
1066
|
+
...(block ? { hasBuiltCheck: block.hasBuiltCheck() } : {}),
|
|
1067
|
+
// the suggestions code could not build, one plain sentence each: the Audit's draft lines, never the card (hamr 2026-11-13, F-b)
|
|
1068
|
+
...(block ? { notBuilt: block.unbuiltSuggestions() } : {}),
|
|
1069
|
+
...(block ? { picked: block.rows.filter((r) => r.kind === 'rule' && r.pick).map((r) => ({ line: r.line, text: `${plainWords(r.pick)}${r.keptFromLast ? ` \u00B7 ${KEPT_WORDS}` : ''}` })) } : {}),
|
|
1041
1070
|
reds: authored.reds,
|
|
1042
1071
|
stop: authored.stop,
|
|
1043
1072
|
cost: authored.cost,
|
package/src/authorreadout.js
CHANGED
|
@@ -316,6 +316,10 @@ export function phaseLine(phase, data = {}) {
|
|
|
316
316
|
case 'scout-done': return `· scout ${data.state ?? 'unknown'} — ${data.facts ?? 0} fact(s)`;
|
|
317
317
|
case 'look': return '· looking at your input — a read-only search for the facts the job asks for…';
|
|
318
318
|
case 'look-done': return `· look ${data.state ?? 'unknown'} — ${data.facts ?? 0} fact(s) can be checked`;
|
|
319
|
+
case 'ledger-suggest': return '· suggesting extra checks from your input…';
|
|
320
|
+
case 'ledger-built': { const rows = Array.isArray(data.rows) ? data.rows : []; const not = rows.filter((/** @type {any} */ r) => r.state === 'not-checked').length; return `· the list of checks: ${rows.length} row(s), ${not} not checked`; }
|
|
321
|
+
case 'draft-ledger-try': return `· ${data.label}: ${data.kept ?? '?'} edit(s) kept, ${(data.refused ?? []).length} refused`;
|
|
322
|
+
case 'draft-ledger': { const rows = Array.isArray(data.rows) ? data.rows : []; const n = (/** @type {string} */ st) => rows.filter((/** @type {any} */ r) => r.state === st).length; return `· the list at the end: ${n('built')} built, ${n('not-checked')} not checked`; }
|
|
319
323
|
case 'listing': return '· listing the files the declaration may name…';
|
|
320
324
|
case 'listing-done': return `· listing ${data.stop ? `STOPPED (${data.stop})` : `${data.files ?? 'unknown'} file(s)`}`;
|
|
321
325
|
case 'author': return '· authoring the close declaration…';
|
|
@@ -676,6 +680,7 @@ export const STOP_HEADS = {
|
|
|
676
680
|
'calibration-missing': 'Drafting stopped: the practice cases that prove the rubric were missing, so the check could not be trusted.',
|
|
677
681
|
'invalid-set': 'Drafting stopped: the rubric and its practice cases do not fit together, so they could not be graded.',
|
|
678
682
|
'broken-close': 'Drafting stopped: the final check the model wrote could not run.',
|
|
683
|
+
'plan-red': 'Drafting stopped: the plan code built from your checks did not pass its own gate. That is a fault in the build, not in your job.',
|
|
679
684
|
'listing-absent': 'Drafting stopped: the list of your files was not available, so the checks could not name any.',
|
|
680
685
|
'listing-conflict': 'Drafting stopped: the list of your files was given twice and the two did not agree.',
|
|
681
686
|
'listing-unreadable': 'Drafting stopped: your repo\'s file list could not be read.',
|
|
@@ -695,6 +700,7 @@ const STOP_TODO = /** @type {Record<string, string>} */ ({
|
|
|
695
700
|
'listing-unreadable': 'check the repo is a readable git repo with at least one commit, then draft again.',
|
|
696
701
|
'confirm-abandoned': 'start a new draft when you are ready; nothing more was spent.',
|
|
697
702
|
'confirm-restart': 'change the answers you want and start the draft again.',
|
|
703
|
+
'plan-red': 'draft again; if it stops the same way twice, report it (nothing was spent on a close).',
|
|
698
704
|
});
|
|
699
705
|
|
|
700
706
|
/** a stop code this table does not know: still plain words, never the code */
|
|
@@ -875,17 +881,6 @@ const SEED_GREEN_SENTENCE = 'Nothing in the close fails on the repository as it
|
|
|
875
881
|
const NO_CHECK_SENTENCE = 'This job has no check that can fail: no `~` rule, and no check the AI built was kept. A run needs at least one check, a quoted fact or a count. Without one, its pass would prove nothing. For an answer nobody checks, a plain chat AI is the right tool.';
|
|
876
882
|
const NO_CHECK_TODO = 'add a `~` rule (for example the version, the date, or "under 80 words"), or answer the question with what the output must contain';
|
|
877
883
|
|
|
878
|
-
/**
|
|
879
|
-
* Code's reading of a declared close: a rubric (text-lang) close with no real check, only always-on stages such as
|
|
880
|
-
* files-changed, or rubric-step stages holding no part. Decided from the close alone, never by a model.
|
|
881
|
-
* @param {any} closeDecl @returns {boolean}
|
|
882
|
-
*/
|
|
883
|
-
export function isNoCheckRubricClose(closeDecl) {
|
|
884
|
-
if (!closeDecl || closeDecl.lang !== 'text' || !Array.isArray(closeDecl.stages)) return false;
|
|
885
|
-
return !closeDecl.stages.some((/** @type {any} */ st) => st && st.kind !== 'files-changed'
|
|
886
|
-
&& (st.kind !== 'rubric-step' || (Array.isArray(st.params?.parts) && st.params.parts.length > 0)));
|
|
887
|
-
}
|
|
888
|
-
|
|
889
884
|
/**
|
|
890
885
|
* Plain sentences for the reds of a refused signing, one or more per red. Card and practice-case reds reuse the
|
|
891
886
|
* proposal table; an unknown code is a generic sentence that quotes the code.
|
|
@@ -919,14 +914,13 @@ export function signingKinds() {
|
|
|
919
914
|
|
|
920
915
|
/**
|
|
921
916
|
* THE MESSAGE a person reads when the signing gates refuse. The panel's failed step and the CLI print exactly this.
|
|
922
|
-
* @param {{reds: PlainRed[], refusal?: {detail?: string}|null, cases?: any,
|
|
923
|
-
* spend?: {knownUsd?: number|null, spendComplete?: boolean|null}|null}} o
|
|
917
|
+
* @param {{reds: PlainRed[], refusal?: {detail?: string}|null, cases?: any, noCheck?: boolean,
|
|
918
|
+
* spend?: {knownUsd?: number|null, spendComplete?: boolean|null}|null}} o `noCheck` = the check block has no built check (block.hasBuiltCheck() is false): the stop is the end check's own words
|
|
924
919
|
* @returns {string}
|
|
925
920
|
*/
|
|
926
|
-
export function signingStopText({ reds, refusal = null, cases = null, spend = null,
|
|
921
|
+
export function signingStopText({ reds, refusal = null, cases = null, spend = null, noCheck = false }) {
|
|
927
922
|
const reasons = signingReasons(reds, { cases });
|
|
928
923
|
if (reasons.length === 0) {
|
|
929
|
-
const noCheck = isNoCheckRubricClose(closeDecl);
|
|
930
924
|
reasons.push({ kind: 'seed-green', sentence: noCheck ? NO_CHECK_SENTENCE : SEED_GREEN_SENTENCE,
|
|
931
925
|
todo: noCheck ? NO_CHECK_TODO : 'check that the close measures the right thing, or describe a sharper problem',
|
|
932
926
|
red: { code: '', path: '', detail: String(refusal?.detail ?? '') } });
|
package/src/authorrun.js
CHANGED
|
@@ -114,7 +114,7 @@ import {
|
|
|
114
114
|
REFUSAL_LIB, REFUSAL_CATEGORY,
|
|
115
115
|
} from './authorjob.js';
|
|
116
116
|
import {
|
|
117
|
-
makeLoopGenerate, CONFIRM_MENU,
|
|
117
|
+
makeLoopGenerate, CONFIRM_MENU, confirmSystemFor,
|
|
118
118
|
} from './authorflow.js';
|
|
119
119
|
import { defaultJudgeLoop, resolveJobJudge } from './judged.js';
|
|
120
120
|
import { validateJob, jobSpecHash, resolveWorkerModel } from './job.js';
|
|
@@ -122,6 +122,8 @@ import { scanSecrets, redactSecrets } from './validate.js';
|
|
|
122
122
|
import { detectLanguage } from './detectlang.js';
|
|
123
123
|
import { RUBRIC_LANG } from './authoring.js';
|
|
124
124
|
import { rubricGoal } from './rubricstep.js';
|
|
125
|
+
import { LEDGER_SYSTEM } from './checklist.js';
|
|
126
|
+
import { ROW_EDIT_SYSTEM } from './rowedit.js';
|
|
125
127
|
import { moveFile } from './movefile.js';
|
|
126
128
|
import { closeJudges, GATE_AUDIT_FILE } from './kinds.js';
|
|
127
129
|
import { resolveProvider, buildRunnerProviders, apiKeyProblem } from './providers.js';
|
|
@@ -822,7 +824,7 @@ export async function main(argv, deps = {}) {
|
|
|
822
824
|
* bound to `CONFIRM_SYSTEM`, never the authoring `generate` above (that one
|
|
823
825
|
* is bound to `AUTHOR_SYSTEM`). Same provider instance, a different system
|
|
824
826
|
* prompt: reusing `generate` would run the wrong system prompt silently. */
|
|
825
|
-
const confirmGenerate = makeLoopGenerate(provider, { system:
|
|
827
|
+
const confirmGenerate = makeLoopGenerate(provider, { system: confirmSystemFor(LANG), rates: authorPrice?.rates ?? null });
|
|
826
828
|
|
|
827
829
|
// ── PLAIN-FOLDER SOURCE: A NAMED $0 STOP, NO MODEL CALL (F191; PRD item 33 M3
|
|
828
830
|
// piece 4, step S6, D5 amended 2026-09-21) ──────────────────────────────────
|
|
@@ -908,6 +910,10 @@ export async function main(argv, deps = {}) {
|
|
|
908
910
|
// travels through unchanged — its `ambiguous` shape is what the confirm
|
|
909
911
|
// turn's own $0 half (D7) asks about, before the scout.
|
|
910
912
|
ask, confirmGenerate, isRepo: !RUBRIC_FILES, langResult,
|
|
913
|
+
// the one check list of a rubric job (src/checklist.js): same list as the panel, its one call bound to its own system text; this door asks nothing for it
|
|
914
|
+
ledgerGenerate: RUBRIC_FILES ? makeLoopGenerate(provider, { system: LEDGER_SYSTEM, rates: authorPrice?.rates ?? null }) : null,
|
|
915
|
+
// the drafter's row-edit reply of a rubric job (src/rowedit.js), its own system text
|
|
916
|
+
editGenerate: RUBRIC_FILES ? makeLoopGenerate(provider, { system: ROW_EDIT_SYSTEM, rates: authorPrice?.rates ?? null }) : null,
|
|
911
917
|
});
|
|
912
918
|
const authoredFile = writeOut('authored.json', authored);
|
|
913
919
|
emit('authored', { ok: authored.ok, stop: authored.stop, seedRef: authored.seedRef, cost: authored.cost, reds: authored.reds });
|
|
@@ -1173,7 +1179,10 @@ export async function main(argv, deps = {}) {
|
|
|
1173
1179
|
out(`\ncalibration gate — REAL judge calls at ${judge.model} on ${judge.provider}, one per case plus the injection battery.`);
|
|
1174
1180
|
out(' this is the only gate that spends money, and it runs after every free one.');
|
|
1175
1181
|
}
|
|
1176
|
-
|
|
1182
|
+
// the end check: a rubric close with no real check is refused here, whatever the seed gate would say (the stop words are printed below from signingStopText)
|
|
1183
|
+
const signing = authored.hasBuiltCheck === false
|
|
1184
|
+
? { ok: false, reds: [], refusal: null, specHash: null, seedRef: authored.seedRef, gates: { declaration: { ok: true, grounded: '-' }, precheck: null, seedVerdict: null }, work: [], guards: [], stops: [] }
|
|
1185
|
+
: await prepareSigning({
|
|
1177
1186
|
spec, workdir: SOURCE, seedRef: authored.seedRef, timeoutMs: TIMEOUT_MS,
|
|
1178
1187
|
// gate 1a re-runs the job validator inside prepareSigning — same coupling, or
|
|
1179
1188
|
// the spec that just passed above would fail the gate that signs it
|
|
@@ -1238,7 +1247,7 @@ export async function main(argv, deps = {}) {
|
|
|
1238
1247
|
if (!signing.ok) {
|
|
1239
1248
|
const t = costSoFar();
|
|
1240
1249
|
out(`\n${signingStopText({
|
|
1241
|
-
reds: signing.reds ?? [], refusal: signing.refusal,
|
|
1250
|
+
reds: signing.reds ?? [], refusal: signing.refusal, noCheck: authored.hasBuiltCheck === false,
|
|
1242
1251
|
spend: { knownUsd: t.knownUsd ?? null, spendComplete: t.spendComplete ?? null },
|
|
1243
1252
|
})}`);
|
|
1244
1253
|
}
|
package/src/behaviour.js
CHANGED
|
@@ -122,6 +122,20 @@ export function runBehaviour(events, { runId } = {}) {
|
|
|
122
122
|
};
|
|
123
123
|
}
|
|
124
124
|
|
|
125
|
+
/**
|
|
126
|
+
* How many write/edit attempts the gate DENIED (they fell outside the write scope), from gate-audit records alone. One write-class test (action `type`
|
|
127
|
+
* write|edit, as `workerWrites`' reader in src/planrun.js uses), deny-decision only: an allowed write is never counted. Pure.
|
|
128
|
+
* @param {Array<{action?: {type?: string}, decision?: string|null}>} events
|
|
129
|
+
* @returns {number}
|
|
130
|
+
*/
|
|
131
|
+
export function writesBlocked(events) {
|
|
132
|
+
let n = 0;
|
|
133
|
+
for (const e of Array.isArray(events) ? events : []) {
|
|
134
|
+
if (e?.decision === 'deny' && (e.action?.type === 'write' || e.action?.type === 'edit')) n += 1;
|
|
135
|
+
}
|
|
136
|
+
return n;
|
|
137
|
+
}
|
|
138
|
+
|
|
125
139
|
/**
|
|
126
140
|
* Render a {@link runBehaviour} summary as the agreed printable block
|
|
127
141
|
* (2–4 short lines). A zero-call run formats plainly ("0 tool calls") rather
|
package/src/blockasks.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
// The questions of the check block, as the answer gate reads them (`answerQuestions`, src/questionbox.js): ONE spelling of the question words, written by code from a row that
|
|
2
|
+
// code could not settle (reading | cant-check | check). The block's `open` list is the source; the person's CHOICE (agree | drop | rule) goes back through `block.applyAnswer`.
|
|
3
|
+
import { readingQuestion, cantCheckQuestion } from './pagemap.js';
|
|
4
|
+
import { plainWords, HOW_TO_ANSWER, CANT_CHECK_WORDS } from './checkpick.js';
|
|
5
|
+
|
|
6
|
+
/** @typedef {{key: string, rowKey: string, line: number, rule: number, source: 'look', ask: 'reading'|'cant-check'|'no-check'|'check', ruleText: string, question: string, counted: boolean, reading?: string, check?: Record<string, any>, pairRule?: number}} BlockAsk */
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* The questions the block has open, in the order the person meets them: the look's readings, then the look's can't-checks, then the pick path's asks (a proposal or a can't-check about a rule the pick path owns) in rule order (a proposal is not counted toward the 3-ask cap).
|
|
10
|
+
* A can't-check about a rule the PICK path owns (`scoped`: src/checkpick.js scopedRules, every `~` rule of a file job) is the pick path's own ask, `no-check`, in fwd's words (a "Line N, guardrail ...: I can't check this" ask
|
|
11
|
+
* whose answer the panel records as a pick, so Revise carries it: am17/am18/am21); any other can't-check is the look's own ask about a page.
|
|
12
|
+
* @param {import('./checkblock.js').CheckBlock} block @param {{line: number, rule: number}[]} [scoped] @returns {BlockAsk[]}
|
|
13
|
+
*/
|
|
14
|
+
export function questionsOfBlock(block, scoped = []) {
|
|
15
|
+
const rank = { reading: 0, 'cant-check': 1, 'no-check': 2, check: 2 };
|
|
16
|
+
return block.open.map((/** @type {any} */ q) => {
|
|
17
|
+
const row = block.rows.find((r) => r.key === q.rowKey);
|
|
18
|
+
const rule = Number(row?.rule);
|
|
19
|
+
const base = { key: q.key, rowKey: q.rowKey, line: q.line, rule, source: /** @type {'look'} */ ('look'), ruleText: String(q.ruleText), ...(row?.pairWith !== undefined ? { pairRule: row.pairWith } : {}) };
|
|
20
|
+
if (q.ask === 'reading') return { ...base, ask: /** @type {'reading'} */ ('reading'), counted: true, reading: String(q.proposal), question: readingQuestion(q.line, String(q.ruleText), String(q.proposal)) };
|
|
21
|
+
if (q.ask === 'check') {
|
|
22
|
+
const words = plainWords(q.proposal);
|
|
23
|
+
return { ...base, ask: /** @type {'check'} */ ('check'), counted: false, reading: words, check: q.proposal, question: `Line ${q.line}, guardrail "${q.ruleText}": I propose ${words}. ${HOW_TO_ANSWER(q.line, true)}` };
|
|
24
|
+
}
|
|
25
|
+
if (scoped.some((x) => x.line === q.line && x.rule === rule)) return { ...base, ask: /** @type {'no-check'} */ ('no-check'), counted: true, question: `Line ${q.line}, guardrail "${q.ruleText}": ${CANT_CHECK_WORDS} ${HOW_TO_ANSWER(q.line, false)}` };
|
|
26
|
+
return { ...base, ask: /** @type {'cant-check'} */ ('cant-check'), counted: true, question: cantCheckQuestion(q.line, String(q.ruleText)) };
|
|
27
|
+
}).sort((a, b) => rank[a.ask] - rank[b.ask]);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* The person's choices back into the block, one by one (the choice decides, never the words). A choice the block refuses is returned with its plain reason; the question stays open.
|
|
32
|
+
* @param {import('./checkblock.js').CheckBlock} block @param {{key: string, choice: string, text?: string}[]} choices @returns {{key: string, why: string}[]}
|
|
33
|
+
*/
|
|
34
|
+
export function applyChoices(block, choices) {
|
|
35
|
+
/** @type {{key: string, why: string}[]} */
|
|
36
|
+
const refused = [];
|
|
37
|
+
for (const c of choices) {
|
|
38
|
+
const r = block.applyAnswer(c.key, c.choice, c.text);
|
|
39
|
+
if (!r.ok) refused.push({ key: c.key, why: r.why });
|
|
40
|
+
}
|
|
41
|
+
block.reconcile();
|
|
42
|
+
return refused;
|
|
43
|
+
}
|