bareloop 0.57.0 → 0.58.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 +45 -0
- package/bareloop.context.md +11 -8
- package/package.json +1 -1
- package/src/authorflow.js +50 -62
- package/src/authorjob.js +100 -30
- package/src/authorreadout.js +88 -0
- package/src/authorrun.js +63 -24
- package/src/authorscout.js +9 -1
- package/src/blockasks.js +11 -16
- package/src/checkblock.js +227 -31
- package/src/checkpick.js +0 -5
- package/src/declaredclose.js +38 -6
- package/src/draftspend.js +20 -4
- package/src/fencepointcall.js +76 -0
- package/src/guarddescriptions.js +14 -0
- package/src/kinds.js +5 -1
- package/src/pagemap.js +7 -29
- package/src/panel/authorroutes.js +6 -1
- package/src/panel/authorsession.js +108 -32
- package/src/panel/index.html +38 -13
- package/src/panel/jobplan.js +49 -16
- package/src/panel/server.js +66 -6
- package/src/planrun.js +2 -0
- package/src/promptregisters.js +5 -0
- package/src/questionbox.js +32 -20
- package/src/reviewdoor.js +1 -1
- package/src/rowresults.js +69 -0
- package/src/rubricstep.js +110 -22
- package/src/stagewords.js +24 -0
- package/types/authorflow.d.ts +42 -79
- package/types/authorjob.d.ts +3 -2
- package/types/authorreadout.d.ts +44 -0
- package/types/authorrun.d.ts +20 -0
- package/types/blockasks.d.ts +5 -10
- package/types/checkblock.d.ts +115 -11
- package/types/checkpick.d.ts +0 -3
- package/types/declaredclose.d.ts +3 -1
- package/types/draftspend.d.ts +16 -2
- package/types/fencepointcall.d.ts +68 -0
- package/types/guarddescriptions.d.ts +7 -0
- package/types/kinds.d.ts +1 -0
- package/types/pagemap.d.ts +2 -5
- package/types/panel/authorsession.d.ts +3 -2
- package/types/panel/jobplan.d.ts +13 -1
- package/types/panel/server.d.ts +41 -16
- package/types/questionbox.d.ts +20 -6
- package/types/rowresults.d.ts +23 -0
- package/types/rubricstep.d.ts +34 -7
- package/types/stagewords.d.ts +11 -0
package/src/authorjob.js
CHANGED
|
@@ -105,7 +105,7 @@ 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.
|
|
107
107
|
import {
|
|
108
|
-
GENRE_LANGUAGES, RUBRIC_LANG, DECLARABLE_LANGUAGES, genreForLang, LOCKED_KINDS, TYPES_GENRE, VERDICT_CLASSES, LOCKED_CLASSES, LIVE_CLASSES,
|
|
108
|
+
GENRE_LANGUAGES, RUBRIC_LANG, classGuards, DECLARABLE_LANGUAGES, genreForLang, LOCKED_KINDS, TYPES_GENRE, VERDICT_CLASSES, LOCKED_CLASSES, LIVE_CLASSES,
|
|
109
109
|
UNLISTED_CLASSES, MENU_CLASSES,
|
|
110
110
|
} from './authoring.js';
|
|
111
111
|
import {
|
|
@@ -116,7 +116,7 @@ import { thinkingCallOptions, assertThinkingMode } from './thinking.js';
|
|
|
116
116
|
import { pageContentChars } from './pagefetch.js';
|
|
117
117
|
import { runAuthorScout, buildSeedListing, SCOUT_ATTEMPTS } from './authorscout.js';
|
|
118
118
|
import { runPageMap, tooManyAsksText } from './pagemap.js';
|
|
119
|
-
import { CheckBlock } from './checkblock.js';
|
|
119
|
+
import { CheckBlock, REASON } from './checkblock.js';
|
|
120
120
|
import { questionsOfBlock, applyChoices } from './blockasks.js';
|
|
121
121
|
import { askNotes } from './noteask.js';
|
|
122
122
|
import { renderJobLines } from './jobblock.js';
|
|
@@ -124,6 +124,7 @@ import { scopedRules, codeScope, plainWords, obviousCheck } from './checkpick.js
|
|
|
124
124
|
import { matchRecord, entriesFromAnswers, KEPT_WORDS } from './pickrecord.js';
|
|
125
125
|
import { runCheckSuggest } from './checksuggest.js';
|
|
126
126
|
import { runLedgerSuggest, ledgerRecord } from './checklist.js';
|
|
127
|
+
import { runFencePoint } from './fencepointcall.js';
|
|
127
128
|
import {
|
|
128
129
|
DECLARED_GAP_PREFIX, DECLARED_GENRES, guardNames, isDeclaredClose, validateCloseDecl,
|
|
129
130
|
} from './declaredclose.js';
|
|
@@ -439,7 +440,7 @@ function composerRefusal(reds) {
|
|
|
439
440
|
* ask?: ((step: {kind: string, [k: string]: any}) => Promise<string|null>)|null,
|
|
440
441
|
* answerQuestions?: ((o: {questions: {line: number, question: string, rule?: number, source?: string, ask?: string, reading?: string, key?: string}[], dropped: {reason: string, raw: any}[], confirmed: any}) =>
|
|
441
442
|
* 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,
|
|
442
|
-
* pickGenerate?: Function|null, ledgerGenerate?: Function|null, noteFn?: Function|null, onJobLines?: ((jobLines: any[]) => void)|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,
|
|
443
|
+
* pickGenerate?: Function|null, ledgerGenerate?: Function|null, fenceGenerate?: Function|null, noteFn?: Function|null, onJobLines?: ((jobLines: any[]) => void)|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,
|
|
443
444
|
* confirmGenerate?: Function|null, isRepo?: boolean,
|
|
444
445
|
* langResult?: {kind: string, candidates?: string[], [k: string]: any}|null}} o
|
|
445
446
|
* @returns {Promise<{ok: boolean, refusal: Refusal|null, verdictType: string|null,
|
|
@@ -480,6 +481,8 @@ export async function authorCloseForJob({
|
|
|
480
481
|
// 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
|
|
481
482
|
// (a test seam, like `pickGenerate`); the CLI and the panel always bring it.
|
|
482
483
|
ledgerGenerate = null,
|
|
484
|
+
// the repo job's pointing call (src/fencepointcall.js): ONE small call BEFORE the asks that points a `~` rule at a file the write fence keeps; code proves it. ABSENT = no pointing: every unproven rule is asked
|
|
485
|
+
fenceGenerate = null,
|
|
483
486
|
// 2026-11-14 (b): the note question (src/noteask.js), asked ONLY when a rubric line is facts-only; ABSENT = never asked (every older caller and test)
|
|
484
487
|
noteFn = null,
|
|
485
488
|
// one rule in, one rule out: called with the job lines rebuilt from the check list after an answer (the seam that shows the job text updates itself); ABSENT = nothing shows it
|
|
@@ -659,10 +662,45 @@ export async function authorCloseForJob({
|
|
|
659
662
|
onPhase('scout-done', { state: survey?.state ?? null, facts: Object.keys(survey?.facts ?? {}).length });
|
|
660
663
|
}
|
|
661
664
|
|
|
665
|
+
/**
|
|
666
|
+
* The code-forced ask rounds of the check block, ONE flow for every job (hamr 2026-11-15): the rows code cannot settle are asked (cap 3 counted), the person's choice goes back through the block, and the job text is rebuilt
|
|
667
|
+
* from the list. Only a rule with something to Agree to is asked (a look's reading, a proposed count check); a rule no check can prove is Not checked at once, never asked (option A, hamr 2026-11-15). Returns `{stop}` (a finished return) or `{answered}`.
|
|
668
|
+
* @param {import('./checkblock.js').CheckBlock} blk @param {NonNullable<typeof answerQuestions>} answerFn the seam that asks the person @returns {Promise<{stop: any}|{answered: {picks: any[], left: any[]}}>}
|
|
669
|
+
*/
|
|
670
|
+
const askRounds = async (blk, answerFn) => {
|
|
671
|
+
/** 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[]}} */
|
|
672
|
+
const answered = { picks: [], left: [] };
|
|
673
|
+
for (let round = 0; round < 3 && blk.open.length > 0; round += 1) {
|
|
674
|
+
const asks = questionsOfBlock(blk);
|
|
675
|
+
const counted = asks.filter((a) => a.counted);
|
|
676
|
+
if (counted.length > MAX_QUESTIONS) {
|
|
677
|
+
return { stop: { ...base, interview, verdictType: picked, seedRef: seed, reds: [{ code: 'look-asks-too-many', path: 'jobLines', detail: tooManyAsksText(asks, blk.repo !== null ? '' : undefined) }], stop: 'look-asks-too-many', cost: null } };
|
|
678
|
+
}
|
|
679
|
+
// 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
|
|
680
|
+
const shown = asks.map((a) => ({ ...a, question: redactSecrets(a.question) }));
|
|
681
|
+
if (shown.length === 0) break;
|
|
682
|
+
onPhase(shown.every((a) => a.ask === 'check') ? 'check-ask' : 'look-ask', { questions: shown.length });
|
|
683
|
+
const updated = await answerFn({ questions: shown, dropped: [], confirmed: null });
|
|
684
|
+
if (updated === null) return { stop: { ...base, interview, verdictType: picked, seedRef: seed, reds: [], stop: 'confirm-abandoned', cost: null } };
|
|
685
|
+
jobLines = updated.jobLines;
|
|
686
|
+
interview.answers = updated.answers;
|
|
687
|
+
answered.picks.push(...(Array.isArray(updated.picks) ? updated.picks : []));
|
|
688
|
+
answered.left.push(...(Array.isArray(updated.left) ? updated.left : []));
|
|
689
|
+
const refused = applyChoices(blk, Array.isArray(updated.choices) ? updated.choices : []);
|
|
690
|
+
// one rule in, one rule out (hamr 2026-11-14): the list replaced each answered rule, so the job text is rebuilt FROM the list (its one owner) and handed back to the seam that shows it
|
|
691
|
+
const rebuilt = blk.jobLinesView(jobLines);
|
|
692
|
+
jobLines = rebuilt;
|
|
693
|
+
interview.answers = { ...interview.answers, 1: renderJobLines(rebuilt) };
|
|
694
|
+
if (typeof onJobLines === 'function') onJobLines(rebuilt);
|
|
695
|
+
if (refused.length === 0) break;
|
|
696
|
+
}
|
|
697
|
+
return { answered };
|
|
698
|
+
};
|
|
699
|
+
|
|
662
700
|
// 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:
|
|
663
701
|
// 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
|
|
664
702
|
// 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
|
|
665
|
-
// cannot settle and applies the person's CHOICE (agree | drop
|
|
703
|
+
// cannot settle and applies the person's CHOICE (agree | drop, buttons only) with `applyAnswer`. Every check comes from the rows; no other store holds one.
|
|
666
704
|
/** @type {import('./checkblock.js').CheckBlock|null} */
|
|
667
705
|
let block = null;
|
|
668
706
|
/** the picks the person made (kept and answered) this draft, as the picks record carries them */
|
|
@@ -672,6 +710,7 @@ export async function authorCloseForJob({
|
|
|
672
710
|
const look = survey.facts?.look && typeof survey.facts.look === 'object' ? survey.facts.look : null;
|
|
673
711
|
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' });
|
|
674
712
|
block.fromJob(jobLines);
|
|
713
|
+
block.setGuards(classGuards({ verdictType: picked, lang }).map((g) => g.name), Array.isArray(writeScope) && writeScope.length ? writeScope : ['output/']);
|
|
675
714
|
block.addLook(Array.isArray(look?.facts) ? look.facts : [], Array.isArray(look?.dropped) ? look.dropped : []);
|
|
676
715
|
/** the rules a count pick settles, as the record knows them (a scoped rule is a counting `~` rule code scopes in) */
|
|
677
716
|
const scoped = answerQuestions ? scopedRules(jobLines, { inputs, look }) : [];
|
|
@@ -715,32 +754,9 @@ export async function authorCloseForJob({
|
|
|
715
754
|
// 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
|
|
716
755
|
// MAX_QUESTIONS counted asks is a job to rewrite, not a questionnaire: nothing is asked and the stop lists every ask.
|
|
717
756
|
if (answerQuestions) {
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
const asks = questionsOfBlock(block, pickGenerate ? scoped : []);
|
|
722
|
-
const counted = asks.filter((a) => a.counted);
|
|
723
|
-
if (counted.length > MAX_QUESTIONS) {
|
|
724
|
-
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 };
|
|
725
|
-
}
|
|
726
|
-
// 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
|
|
727
|
-
const shown = asks.map((a) => ({ ...a, question: redactSecrets(a.question) }));
|
|
728
|
-
if (shown.length === 0) break;
|
|
729
|
-
onPhase(shown.every((a) => a.ask === 'check' || a.ask === 'no-check') ? 'check-ask' : 'look-ask', { questions: shown.length });
|
|
730
|
-
const updated = await answerQuestions({ questions: shown, dropped: [], confirmed: null });
|
|
731
|
-
if (updated === null) return { ...base, interview, verdictType: picked, seedRef: seed, reds: [], stop: 'confirm-abandoned', cost: null };
|
|
732
|
-
jobLines = updated.jobLines;
|
|
733
|
-
interview.answers = updated.answers;
|
|
734
|
-
answered.picks.push(...(Array.isArray(updated.picks) ? updated.picks : []));
|
|
735
|
-
answered.left.push(...(Array.isArray(updated.left) ? updated.left : []));
|
|
736
|
-
const refused = applyChoices(block, Array.isArray(updated.choices) ? updated.choices : []);
|
|
737
|
-
// one rule in, one rule out (hamr 2026-11-14): the list replaced each answered rule, so the job text is rebuilt FROM the list (its one owner) and handed back to the seam that shows it
|
|
738
|
-
const rebuilt = block.jobLinesView(jobLines);
|
|
739
|
-
jobLines = rebuilt;
|
|
740
|
-
interview.answers = { ...interview.answers, 1: renderJobLines(rebuilt) };
|
|
741
|
-
if (typeof onJobLines === 'function') onJobLines(rebuilt);
|
|
742
|
-
if (refused.length === 0) break;
|
|
743
|
-
}
|
|
757
|
+
const ar = await askRounds(block, answerQuestions);
|
|
758
|
+
if ('stop' in ar) return ar.stop;
|
|
759
|
+
const answered = ar.answered;
|
|
744
760
|
// 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
|
|
745
761
|
if (scoped.length > 0) {
|
|
746
762
|
// the record keeps the FINAL words of each rule (an answer replaced the rule it was asked about), numbered on this card
|
|
@@ -753,6 +769,15 @@ export async function authorCloseForJob({
|
|
|
753
769
|
} else block.reconcile();
|
|
754
770
|
}
|
|
755
771
|
|
|
772
|
+
// A repo job runs through the SAME check block (hamr 2026-11-15: "same flow as rubric, no exceptions; only the TYPE of checks varies"): its `$` rows are known now (the confirm card draws them); its `~` rule rows
|
|
773
|
+
// are made once the repo listing is read, and its `!` work-stage rows once the draft stands.
|
|
774
|
+
/** @type {import('./checkblock.js').CheckBlock|null} */
|
|
775
|
+
let repoBlock = null;
|
|
776
|
+
if (block === null && isRepo && lang !== RUBRIC_LANG && Array.isArray(jobLines) && jobLines.length > 0) {
|
|
777
|
+
repoBlock = new CheckBlock({ texts: {}, labels: [], asks: Boolean(answerQuestions), repo: { files: null, writeScope: Array.isArray(writeScope) && writeScope.length ? [...writeScope] : null } });
|
|
778
|
+
repoBlock.setGuards(classGuards({ verdictType: picked, lang }).map((g) => g.name), Array.isArray(writeScope) && writeScope.length ? writeScope : null);
|
|
779
|
+
}
|
|
780
|
+
|
|
756
781
|
// ── THE CONFIRM TURN'S PAID HALF (PRD item 33 M3 piece 4) ──────────────────
|
|
757
782
|
// Slotted between the scout and the listing: it reuses the scout's own
|
|
758
783
|
// survey (ruling 4 — never a second read of the source) and needs nothing
|
|
@@ -802,6 +827,11 @@ export async function authorCloseForJob({
|
|
|
802
827
|
const cardOf = () => cardOfClose({ closeDecl: block.closeView(), jobLines, ledger: block.rows.map((r) => ({ key: r.key, words: r.kind === 'rule' ? [r.text ?? ''] : (r.words ?? []) })) });
|
|
803
828
|
return { card: cardOf(), cardOf, block };
|
|
804
829
|
})() : {}),
|
|
830
|
+
// a repo job's card is its rows too (Addendum 2026-11-15 (d)): the `$ [default]` guards and the write fence, known before drafting, read from the same block; the `~` rules and the `!` stages get their rows later
|
|
831
|
+
...(repoBlock ? (() => {
|
|
832
|
+
const closeDecl = repoBlock.closeView();
|
|
833
|
+
return { card: { ...cardOfClose({ closeDecl, jobLines }), closeDecl } };
|
|
834
|
+
})() : {}),
|
|
805
835
|
});
|
|
806
836
|
// DISTINCT from `runConfirmTurn`'s own per-round 'confirm-done' (fired once
|
|
807
837
|
// per round when a plan arrives) — this is the WRAPPER's own line, once,
|
|
@@ -838,6 +868,29 @@ export async function authorCloseForJob({
|
|
|
838
868
|
onPhase('listing-done', { files: seeds?.files?.length ?? null, stop: seeds?.stop ?? null });
|
|
839
869
|
}
|
|
840
870
|
|
|
871
|
+
// a repo job's `~` rule rows (a rule is kept only when code finds a repo path in the person's own words that the write fence keeps; every other rule is asked about, as a rubric rule is), once the listing is read
|
|
872
|
+
if (repoBlock !== null && seeds != null && seeds.stop == null && Array.isArray(seeds.files)) {
|
|
873
|
+
repoBlock.setGuards(classGuards({ verdictType: picked, lang }).map((g) => g.name), Array.isArray(writeScope) && writeScope.length ? writeScope : null);
|
|
874
|
+
repoBlock.setListing(seeds.files);
|
|
875
|
+
repoBlock.fromJob(jobLines ?? []);
|
|
876
|
+
repoBlock.reconcile();
|
|
877
|
+
// point -> code proves -> asks -> draft (the rubric's order): the AI points a rule at a listing path, row edits judge it alone; only when the job has `~` rules and the listing has paths outside the fence
|
|
878
|
+
// the folders holding outside files are listed too (`test/`), so a rule that names a folder can be pointed at it
|
|
879
|
+
const outside = [...repoBlock.outsideFolders().map((d) => `${d}/`), ...repoBlock.outsideScope()];
|
|
880
|
+
if (fenceGenerate && outside.length > 0 && repoBlock.rows.some((r) => r.kind === 'rule')) {
|
|
881
|
+
onPhase('fence-point', {});
|
|
882
|
+
const fp = await runFencePoint({ jobLines: jobLines ?? [], outside, writeScope, generate: fenceGenerate, ceilingUsd, onCall, priorCalls: survey?.calls ?? [], priorRaws: survey?.raws ?? [] });
|
|
883
|
+
if (survey != null) { survey.calls = [...(survey.calls ?? []), ...fp.calls]; survey.raws = [...(survey.raws ?? []), ...fp.raws]; }
|
|
884
|
+
const rec = repoBlock.applyDelta({ label: 'pre:fence-point', pre: true, edits: fp.edits });
|
|
885
|
+
repoBlock.reconcile();
|
|
886
|
+
onPhase('fence-point-done', { edits: fp.edits, results: rec.edits.map((/** @type {any} */ e) => ({ op: e.op, line: e.line, rule: e.rule, path: e.path, accepted: e.accepted === true, ...(e.accepted === true ? {} : { refusedBecause: String(e.refusedBecause) }) })), sent: fp.edits.length, kept: rec.edits.filter((/** @type {any} */ e) => e.accepted === true).length, reason: fp.reason, refused: rec.edits.filter((/** @type {any} */ e) => e.accepted !== true).map((/** @type {any} */ e) => String(e.refusedBecause)) });
|
|
887
|
+
}
|
|
888
|
+
if (answerQuestions) {
|
|
889
|
+
const ar = await askRounds(repoBlock, answerQuestions);
|
|
890
|
+
if ('stop' in ar) return ar.stop;
|
|
891
|
+
}
|
|
892
|
+
}
|
|
893
|
+
|
|
841
894
|
// The declaration ladder. The REVISION CAP is deliberately not quoted here:
|
|
842
895
|
// the tighten-only clamp lives in `authorClose` (and `authorOpts` may lower
|
|
843
896
|
// it), so a number spelled at this call site could disagree with the one the
|
|
@@ -941,6 +994,23 @@ export async function authorCloseForJob({
|
|
|
941
994
|
: {}),
|
|
942
995
|
};
|
|
943
996
|
|
|
997
|
+
// A repo job signs its list through the same block (hamr 2026-11-15): its `~` rule rows (kept by the fence or Not checked with a REASON), the drafter's work stages as `!` rows, the `$` guards and the fence.
|
|
998
|
+
// `refused` is built from the rows in code, as a rubric job's is: the drafter's line-level refusals, then each `~` rule row no check carries.
|
|
999
|
+
if (repoBlock !== null && closeDecl.list === undefined && !closeDecl.stages.some((/** @type {any} */ s) => s && s.kind === 'rubric-step')) {
|
|
1000
|
+
const guardNames = classGuards({ verdictType: picked, lang }).map((g) => g.name);
|
|
1001
|
+
repoBlock.setGuards(guardNames, Array.isArray(writeScope) && writeScope.length ? writeScope : null);
|
|
1002
|
+
repoBlock.asks = false; // nobody is asked after the draft stands: a rule not settled now is Not checked
|
|
1003
|
+
repoBlock.syncJob(jobLines ?? []);
|
|
1004
|
+
repoBlock.addStages(closeDecl.stages, { guardNames, refused: closeDecl.refused ?? [], guardLines: closeDecl.guardLines ?? [] });
|
|
1005
|
+
if (Array.isArray(carriedChoices)) { repoBlock.carryChoices(carriedChoices); onChoices(repoBlock.choicesRecord()); }
|
|
1006
|
+
const view = repoBlock.closeView();
|
|
1007
|
+
const lineRefusals = repoBlock.rows.filter((r) => r.kind === 'stage' && r.refusal === true).map((r) => ({ line: r.line, reason: REASON.noRule }));
|
|
1008
|
+
const ruleRefusals = repoBlock.rows.filter((r) => r.kind === 'rule' && r.state !== 'built').map((r) => ({ line: r.line, rule: r.rule, reason: String(r.reason ?? 'not checked') }));
|
|
1009
|
+
closeDecl.stages = view.stages;
|
|
1010
|
+
closeDecl.list = view.list;
|
|
1011
|
+
if (lineRefusals.length || ruleRefusals.length) closeDecl.refused = [...lineRefusals, ...ruleRefusals]; else delete closeDecl.refused;
|
|
1012
|
+
}
|
|
1013
|
+
|
|
944
1014
|
return {
|
|
945
1015
|
ok: true,
|
|
946
1016
|
refusal: null,
|
package/src/authorreadout.js
CHANGED
|
@@ -26,6 +26,9 @@
|
|
|
26
26
|
import { scrubRaw } from './text.js';
|
|
27
27
|
import { panelMoney2 } from './panelmoney.js';
|
|
28
28
|
import { redactSecrets } from './validate.js';
|
|
29
|
+
import { cardOfClose, fenceOfClose, fenceRowText, refusedOf, stepFileRel, lineRules, FENCE_KEY } from './rubricstep.js';
|
|
30
|
+
import { decidedWords } from './draftspend.js';
|
|
31
|
+
import { ticketFilterWords } from './ticketfilter.js';
|
|
29
32
|
|
|
30
33
|
/**
|
|
31
34
|
* @param {{goal?: string|null, closeDecl?: any}} spec the RESOLVED spec — the bytes
|
|
@@ -179,6 +182,8 @@ export function phaseLine(phase, data = {}) {
|
|
|
179
182
|
case 'scout-done': return `· scout ${data.state ?? 'unknown'} — ${data.facts ?? 0} fact(s)`;
|
|
180
183
|
case 'look': return '· looking at your input — a read-only search for the facts the job asks for…';
|
|
181
184
|
case 'look-done': return `· look ${data.state ?? 'unknown'} — ${data.facts ?? 0} fact(s) can be checked`;
|
|
185
|
+
case 'fence-point': return '· pointing at the files your rules keep as they are…';
|
|
186
|
+
case 'fence-point-done': return data.reason ? `· pointing failed (${data.reason}); those rules are asked about` : `· ${data.kept ?? 0} of ${data.sent ?? 0} pointer(s) proved by code`;
|
|
182
187
|
case 'ledger-suggest': return '· suggesting extra checks from your input…';
|
|
183
188
|
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`; }
|
|
184
189
|
case 'draft-ledger-try': return `· ${data.label}: ${data.kept ?? '?'} edit(s) kept, ${(data.refused ?? []).length} refused`;
|
|
@@ -620,3 +625,86 @@ export function redsRecord(reds, { signing = false } = {}) {
|
|
|
620
625
|
return out;
|
|
621
626
|
});
|
|
622
627
|
}
|
|
628
|
+
|
|
629
|
+
/** The draft readout's section headings: the ONE list (fwd v0.34.0 `READOUT_HEADS`). `buildReadout` writes them from here and `readoutHeadIndexes` finds them by it, so the panel's bold and the text cannot drift. */
|
|
630
|
+
export const READOUT_HEADS = Object.freeze({
|
|
631
|
+
inputs: 'INPUTS',
|
|
632
|
+
steps: 'STEPS',
|
|
633
|
+
fence: 'WRITE FENCE',
|
|
634
|
+
notChecked: 'REFUSED / NOT CHECKED',
|
|
635
|
+
jobLines: 'JOB LINES',
|
|
636
|
+
answers: 'YOUR ANSWERS',
|
|
637
|
+
});
|
|
638
|
+
|
|
639
|
+
/** The readout's top line prefix: ONE owner for the text `buildReadout` writes and the bold `readoutHeadIndexes` finds. */
|
|
640
|
+
export const READOUT_HEADER_PREFIX = 'DRAFT READOUT \u2014 NOT SIGNED \u2014 job ';
|
|
641
|
+
|
|
642
|
+
/** Zero-based indexes of the header and heading lines in a readout's text (split on "\n"): the panel draws those bold. @param {string} text @returns {number[]} */
|
|
643
|
+
export function readoutHeadIndexes(text) {
|
|
644
|
+
const heads = new Set(Object.values(READOUT_HEADS));
|
|
645
|
+
/** @type {number[]} */
|
|
646
|
+
const idx = [];
|
|
647
|
+
String(text).split('\n').forEach((l, i) => { if (heads.has(/** @type {any} */ (l)) || l.startsWith(READOUT_HEADER_PREFIX)) idx.push(i); });
|
|
648
|
+
return idx;
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
/** @param {number|null|undefined} ms the signed time cap in words; an absent one reads unbounded, never 0 @returns {string} */
|
|
652
|
+
function capTimeWords(ms) {
|
|
653
|
+
if (typeof ms !== 'number' || !Number.isFinite(ms) || ms <= 0) return 'no time cap set';
|
|
654
|
+
return ms < 60000 ? `${Math.round(ms / 1000)} s` : `${Math.round(ms / 60000)} min`;
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
/**
|
|
658
|
+
* The plain-text readout of the draft the person is about to sign (hamr 2026-11-15, copied from fwdloop v0.34.0 `buildReadout`; ASKS, SEND TARGET, flows root and grants are fwd-only and not here).
|
|
659
|
+
* DISPLAY ONLY: built from the signed resolved spec, the draft log and the session's own figures; never signed, never stored, never part of the hash. Pure. The check rows are `cardOfClose`'s (the same reader and tags the card draws),
|
|
660
|
+
* the fence is `fenceRowText`'s, the Not checked rows are `ruleNotCheckedItems`'s plus the `refusedOf` rows it leaves out. The whole text goes through `redactSecrets`.
|
|
661
|
+
* @param {{spec: any, name?: string, modelId?: string|null, rounds: number, costUsd: number|null, spendComplete?: boolean, specHash?: string|null, source?: string, destination?: string,
|
|
662
|
+
* humans?: {question: string, answer: string, line?: number, choice?: string, words?: string}[], ledger?: {key: string, words: string[]}[]|null}} o
|
|
663
|
+
* `costUsd` = the known drafting spend; `spendComplete` false = a provider call was unpriced, so it reads "at least"
|
|
664
|
+
* @returns {string}
|
|
665
|
+
*/
|
|
666
|
+
export function buildReadout({ spec, name, modelId = null, rounds, costUsd, spendComplete = true, specHash = null, source = '', destination = '', humans = [], ledger = null }) {
|
|
667
|
+
const jobLines = Array.isArray(spec?.jobLines) ? spec.jobLines : [];
|
|
668
|
+
const closeDecl = spec?.closeDecl;
|
|
669
|
+
const card = cardOfClose({ closeDecl, jobLines, ledger });
|
|
670
|
+
const out = [];
|
|
671
|
+
out.push(`${READOUT_HEADER_PREFIX}${name ?? spec?.job ?? '?'}`, '');
|
|
672
|
+
const cost = typeof costUsd === 'number' ? (spendComplete === false ? `at least ${panelMoney2(costUsd)} (a provider call is unpriced)` : panelMoney2(costUsd)) : 'unknown';
|
|
673
|
+
out.push(`Drafted by: ${modelId ?? spec?.model ?? '?'} in ${rounds} round(s), cost ${cost}`);
|
|
674
|
+
out.push(`Cap: ${typeof spec?.budgetUsd === 'number' ? panelMoney2(spec.budgetUsd) : 'unknown'} (money) \u00B7 ${capTimeWords(spec?.maxWallMs)} (time)`, '');
|
|
675
|
+
out.push(READOUT_HEADS.inputs);
|
|
676
|
+
if (source) out.push(` source = ${source}`);
|
|
677
|
+
for (const i of Array.isArray(spec?.inputs) ? spec.inputs : []) out.push(` ${i.n}. ${i.label} = ${i.value}`);
|
|
678
|
+
if (destination) out.push(` destination = ${destination}`);
|
|
679
|
+
if (spec?.mcp && typeof spec.mcp === 'object') out.push(` mcp: ${spec.mcp.server} \u00B7 tools: ${(spec.mcp.tools ?? []).join(', ')}`);
|
|
680
|
+
const filter = ticketFilterWords(spec?.ticketFilter);
|
|
681
|
+
if (filter) out.push(` ticket filter: ${filter}`);
|
|
682
|
+
out.push('', READOUT_HEADS.steps);
|
|
683
|
+
const rubricLines = new Set((Array.isArray(closeDecl?.stages) ? closeDecl.stages : []).filter((/** @type {any} */ st) => st?.kind === 'rubric-step' && Number.isInteger(st.params?.step)).map((/** @type {any} */ st) => st.params.step));
|
|
684
|
+
for (const l of jobLines) {
|
|
685
|
+
out.push(` (line ${l.n}) ${l.text}`);
|
|
686
|
+
if (rubricLines.has(l.n)) out.push(` writes: ${stepFileRel(l.n)}`);
|
|
687
|
+
for (const c of card.checkItems.filter((x) => x.fromLine[0] === l.n)) out.push(` check: ${c.text} [${c.by}]`);
|
|
688
|
+
}
|
|
689
|
+
// the job-level rows (the always-on guards, line 0) serve no one line; the fence row is told once under its own head below
|
|
690
|
+
for (const c of card.checkItems.filter((x) => x.fromLine[0] === 0 && x.key !== FENCE_KEY)) out.push(` always: ${c.text} [${c.by}]`);
|
|
691
|
+
const fence = fenceOfClose(closeDecl);
|
|
692
|
+
if (fence) out.push('', READOUT_HEADS.fence, ` ${fenceRowText(fence)}`);
|
|
693
|
+
const refusedRest = refusedOf(closeDecl).filter((r) => !(Number.isInteger(r.rule) || r.fromList));
|
|
694
|
+
if (card.notChecked.length || refusedRest.length) {
|
|
695
|
+
out.push('', READOUT_HEADS.notChecked);
|
|
696
|
+
for (const t of card.notChecked) out.push(` ${t}${card.notCheckedBy[t] ? ` [${card.notCheckedBy[t]}]` : ''}`);
|
|
697
|
+
for (const r of refusedRest) out.push(` line ${r.line}: ${r.reason}`);
|
|
698
|
+
}
|
|
699
|
+
out.push('', READOUT_HEADS.jobLines);
|
|
700
|
+
for (const l of jobLines) {
|
|
701
|
+
out.push(` ${l.n}. ${l.text}`);
|
|
702
|
+
for (const r of lineRules(l)) out.push(` ~ ${r}`);
|
|
703
|
+
}
|
|
704
|
+
if (specHash) out.push('', `Plan hash: ${specHash}`);
|
|
705
|
+
if (humans.length) {
|
|
706
|
+
out.push('', READOUT_HEADS.answers);
|
|
707
|
+
for (const h of humans) out.push(` ${Number.isInteger(h.line) ? `line ${h.line}: ` : ''}${decidedWords(h) ?? `${h.question} \u2014 ${h.answer}`}`);
|
|
708
|
+
}
|
|
709
|
+
return redactSecrets(`${out.join('\n')}\n`);
|
|
710
|
+
}
|
package/src/authorrun.js
CHANGED
|
@@ -121,6 +121,7 @@ import { detectLanguage } from './detectlang.js';
|
|
|
121
121
|
import { RUBRIC_LANG } from './authoring.js';
|
|
122
122
|
import { rubricGoal } from './rubricstep.js';
|
|
123
123
|
import { LEDGER_SYSTEM } from './checklist.js';
|
|
124
|
+
import { FENCE_POINT_SYSTEM } from './fencepointcall.js';
|
|
124
125
|
import { ROW_EDIT_SYSTEM } from './rowedit.js';
|
|
125
126
|
import { moveFile } from './movefile.js';
|
|
126
127
|
import { GATE_AUDIT_FILE } from './kinds.js';
|
|
@@ -129,9 +130,10 @@ import { commandFor } from './invoke.js';
|
|
|
129
130
|
import { readSourceManifest, missingDependencies, nonRepoSourceMessage, isRubricFilesManifest } from './source.js';
|
|
130
131
|
import { tallyCalls } from './text.js';
|
|
131
132
|
import { splitReadNotes } from './pagedropwords.js';
|
|
133
|
+
import { answerEffectWords } from './questionbox.js';
|
|
132
134
|
import {
|
|
133
135
|
declarationLines, parseCeiling, ceilingLine, crashRecord, phaseLine,
|
|
134
|
-
openQuestionLines, answeredQuestionLines, fellBackLines, signingStopText,
|
|
136
|
+
openQuestionLines, answeredQuestionLines, fellBackLines, signingStopText, buildReadout,
|
|
135
137
|
} from './authorreadout.js';
|
|
136
138
|
|
|
137
139
|
/** Thrown to unwind `main` to an exit code without ever calling
|
|
@@ -160,6 +162,60 @@ class ExitSignal extends Error {
|
|
|
160
162
|
* never a script path they never invoked and may not have on disk.
|
|
161
163
|
*/
|
|
162
164
|
|
|
165
|
+
/**
|
|
166
|
+
* The lines the CLI prints for one question the plan raised: the ask, then (try-3 question, Addendum 2026-11-14 (c) piece 5) what the answer does, in the panel's own words ("This replaces: ..." or
|
|
167
|
+
* "This adds a new rule to line N"). Pure.
|
|
168
|
+
* @param {{index?: number, total?: number, question?: string, line?: number, replaces?: string, adds?: boolean, [k: string]: any}} step @returns {string[]}
|
|
169
|
+
*/
|
|
170
|
+
export function answerPromptLines(step) {
|
|
171
|
+
const effect = answerEffectWords(step);
|
|
172
|
+
return [
|
|
173
|
+
`Question ${step.index} of ${step.total} the plan raised — it must be answered before the plan can be signed (pick "Start over" or "Fix" instead if you cannot answer it):`,
|
|
174
|
+
` ? ${step.question}`,
|
|
175
|
+
...(effect === null ? [] : [` ${effect}`]),
|
|
176
|
+
];
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/** the tag of a row by its kind, one spelling with the panel: `~ [you]`, `! [agent]`, `$ [default]` (a check with no row kind says nothing) @param {unknown} by @returns {string} */
|
|
180
|
+
const rowTag = (by) => (by === 'you' ? '~ [you]' : by === 'agent' ? '! [agent]' : by === 'default' ? '$ [default]' : '');
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* The confirm turn's plan as the CLI prints it, read from the SAME rows the panel card draws (Addendum 2026-11-14 (c) piece 3): every check is its row (line, tag, words), the protections are the
|
|
184
|
+
* write fence only for a job whose list holds the guards. A plan that carries no row items (a repo job) prints its plain `checks` as before. Pure: one string per printed line.
|
|
185
|
+
* @param {any} p the confirm plan @returns {string[]}
|
|
186
|
+
*/
|
|
187
|
+
export function confirmPlanLines(p) {
|
|
188
|
+
/** @type {string[]} */
|
|
189
|
+
const out = ['THE PLAN — read before you pick:', ` goal ${JSON.stringify(p.goal ?? '')}`, ' checks it will compose:'];
|
|
190
|
+
const items = Array.isArray(p.checkItems) && p.checkItems.length ? p.checkItems : null;
|
|
191
|
+
if (items) {
|
|
192
|
+
for (const c of items) {
|
|
193
|
+
const line = Array.isArray(c.fromLine) && Number.isInteger(c.fromLine[0]) && c.fromLine[0] >= 1 ? `line ${c.fromLine[0]}: ` : '';
|
|
194
|
+
const tag = rowTag(c.by);
|
|
195
|
+
out.push(` · ${line}${tag ? `${tag} ` : ''}${c.text}`);
|
|
196
|
+
}
|
|
197
|
+
} else for (const c of p.checks ?? []) out.push(` · ${c}`);
|
|
198
|
+
// (a one-list job's guards and fence are rows above; the heading shows only when something is left)
|
|
199
|
+
if ((p.protections ?? []).length) {
|
|
200
|
+
out.push(' protections (always-on guards, never named in the goal):');
|
|
201
|
+
for (const g of p.protections) out.push(` · ${g}`);
|
|
202
|
+
}
|
|
203
|
+
const { notChecked: unchecked, readNotes } = splitReadNotes(p.notChecked, p.signedFacts);
|
|
204
|
+
if (unchecked.length) {
|
|
205
|
+
out.push(' you asked for these, but nothing checks them:');
|
|
206
|
+
for (const n of unchecked) out.push(` · ${n}`);
|
|
207
|
+
}
|
|
208
|
+
if (readNotes.length) {
|
|
209
|
+
out.push(` how the page was read · ${readNotes.length}:`);
|
|
210
|
+
for (const n of readNotes) out.push(` · ${n}`);
|
|
211
|
+
}
|
|
212
|
+
if ((p.questions ?? []).length) {
|
|
213
|
+
out.push(' open questions:');
|
|
214
|
+
for (const q of p.questions ?? []) out.push(` ? ${q}`);
|
|
215
|
+
}
|
|
216
|
+
return out;
|
|
217
|
+
}
|
|
218
|
+
|
|
163
219
|
/**
|
|
164
220
|
* Parses this script's own argv shape and runs the authoring pipeline
|
|
165
221
|
* (scout, declaration loop, D9's gates) against the given (or real)
|
|
@@ -716,26 +772,7 @@ export async function main(argv, deps = {}) {
|
|
|
716
772
|
return readFreeText(false);
|
|
717
773
|
}
|
|
718
774
|
if (step.kind === 'menu') {
|
|
719
|
-
const
|
|
720
|
-
out('THE PLAN — read before you pick:');
|
|
721
|
-
out(` goal ${JSON.stringify(p.goal ?? '')}`);
|
|
722
|
-
out(' checks it will compose:');
|
|
723
|
-
for (const c of p.checks ?? []) out(` · ${c}`);
|
|
724
|
-
out(' protections (always-on guards, never named in the goal):');
|
|
725
|
-
for (const g of p.protections ?? []) out(` · ${g}`);
|
|
726
|
-
const { notChecked: unchecked, readNotes } = splitReadNotes(p.notChecked, p.signedFacts);
|
|
727
|
-
if (unchecked.length) {
|
|
728
|
-
out(' you asked for these, but nothing checks them:');
|
|
729
|
-
for (const n of unchecked) out(` · ${n}`);
|
|
730
|
-
}
|
|
731
|
-
if (readNotes.length) {
|
|
732
|
-
out(` how the page was read · ${readNotes.length}:`);
|
|
733
|
-
for (const n of readNotes) out(` · ${n}`);
|
|
734
|
-
}
|
|
735
|
-
if ((p.questions ?? []).length) {
|
|
736
|
-
out(' open questions:');
|
|
737
|
-
for (const q of p.questions ?? []) out(` ? ${q}`);
|
|
738
|
-
}
|
|
775
|
+
for (const l of confirmPlanLines(step.plan ?? {})) out(l);
|
|
739
776
|
const keys = /** @type {(keyof typeof CONFIRM_MENU)[]} */ (Object.keys(CONFIRM_MENU));
|
|
740
777
|
keys.forEach((k, i) => out(` ${i + 1}. ${CONFIRM_MENU[k]}`));
|
|
741
778
|
for (;;) {
|
|
@@ -754,9 +791,7 @@ export async function main(argv, deps = {}) {
|
|
|
754
791
|
// "Confirm"/"Type the goal yourself" cannot proceed until it is
|
|
755
792
|
// answered, right here, with no extra model call. A blank line re-asks
|
|
756
793
|
// the same question ("Start over" or "Fix" are the ways out).
|
|
757
|
-
|
|
758
|
-
+ 'be signed (pick "Start over" or "Fix" instead if you cannot answer it):');
|
|
759
|
-
out(` ? ${step.question}`);
|
|
794
|
+
for (const l of answerPromptLines(step)) out(l);
|
|
760
795
|
return readFreeText(false);
|
|
761
796
|
}
|
|
762
797
|
if (step.kind === 'goal') {
|
|
@@ -854,6 +889,7 @@ export async function main(argv, deps = {}) {
|
|
|
854
889
|
ask, confirmGenerate, isRepo: !RUBRIC_FILES, langResult,
|
|
855
890
|
// 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
|
|
856
891
|
ledgerGenerate: RUBRIC_FILES ? makeLoopGenerate(provider, { system: LEDGER_SYSTEM, rates: authorPrice?.rates ?? null }) : null,
|
|
892
|
+
fenceGenerate: RUBRIC_FILES ? null : makeLoopGenerate(provider, { system: FENCE_POINT_SYSTEM, rates: authorPrice?.rates ?? null }),
|
|
857
893
|
// the drafter's row-edit reply of a rubric job (src/rowedit.js), its own system text
|
|
858
894
|
editGenerate: RUBRIC_FILES ? makeLoopGenerate(provider, { system: ROW_EDIT_SYSTEM, rates: authorPrice?.rates ?? null }) : null,
|
|
859
895
|
});
|
|
@@ -1095,6 +1131,9 @@ export async function main(argv, deps = {}) {
|
|
|
1095
1131
|
out('\nSIGNING PREPARED — NOT SIGNED. This script stops here, by design.');
|
|
1096
1132
|
out(` the resolved spec is ${specFile} and it hashes to ${hash}`);
|
|
1097
1133
|
out(' read the seed evidence above; if the close measures your job, the signature is yours to give.');
|
|
1134
|
+
// the same draft readout the panel Chat shows (hamr 2026-11-15; src/authorreadout.js, the one owner): what the person is about to sign, from the signed spec through the card's own readers
|
|
1135
|
+
out('');
|
|
1136
|
+
for (const l of buildReadout({ spec, rounds: totalCost.calls.length, costUsd: totalCost.knownUsd, spendComplete: totalCost.spendComplete, specHash: hash }).trimEnd().split('\n')) out(` ${l}`);
|
|
1098
1137
|
for (const l of openQuestionLines(authored.confirmed)) out(` ${l}`);
|
|
1099
1138
|
for (const l of answeredQuestionLines(authored.confirmed)) out(` ${l}`);
|
|
1100
1139
|
// F185 — the loose end this fix closes: until now this screen named no
|
package/src/authorscout.js
CHANGED
|
@@ -804,9 +804,17 @@ export const cleanEntry = (e) => String(e ?? '').split(' (')[0].trim().replace(/
|
|
|
804
804
|
* @returns {Promise<{stop: string, files: null}|{stop: null, files: string[]}>}
|
|
805
805
|
*/
|
|
806
806
|
export async function seedFileList(workdir, seedRef) {
|
|
807
|
-
|
|
807
|
+
const r = await seedListing(workdir, seedRef);
|
|
808
|
+
if (r.stop !== null) return r;
|
|
809
|
+
// the engine's own stores are never the person's files: a patient that tracks bareloop's `.bareloop/`, `.smoke/` or `.litectx/` must not offer them to the drafter or to code's proofs (hamr 2026-11-15: a leftover
|
|
810
|
+
// `.bareloop/wt/.../src/sum.js` "kept" a rule). A prefix at the repo root only: `src/.smoke/x` is the person's own path.
|
|
811
|
+
const own = [...ARBITER_BOOK_STORES, BARELOOP_STORE];
|
|
812
|
+
return { stop: null, files: r.files.filter((f) => !own.some((s) => f === s || f.startsWith(`${s}/`))) };
|
|
808
813
|
}
|
|
809
814
|
|
|
815
|
+
/** the engine's own repo-root store of work trees and notes, beside the arbiter books */
|
|
816
|
+
const BARELOOP_STORE = '.bareloop';
|
|
817
|
+
|
|
810
818
|
/** `src/*` style entries match by segment; everything else is a path prefix.
|
|
811
819
|
* @param {string} entry @returns {(f: string) => boolean} */
|
|
812
820
|
function matcherFor(entry) {
|
package/src/blockasks.js
CHANGED
|
@@ -1,29 +1,24 @@
|
|
|
1
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 |
|
|
3
|
-
|
|
4
|
-
import {
|
|
2
|
+
// code could not settle (reading | check), BUTTONS ONLY (hamr 2026-11-15: Agree, and Drop it on a proposed check). A rule no check can prove has no question: it is Not checked at once (src/checkblock.js).
|
|
3
|
+
// The block's `open` list is the source; the person's CHOICE (agree | drop) goes back through `block.applyAnswer`.
|
|
4
|
+
import { readingQuestion } from './pagemap.js';
|
|
5
|
+
import { plainWords } from './checkpick.js';
|
|
5
6
|
|
|
6
|
-
/** @typedef {{key: string, rowKey: string, line: number, rule: number, source: 'look', ask: 'reading'|'
|
|
7
|
+
/** @typedef {{key: string, rowKey: string, line: number, rule: number, source: 'look', ask: 'reading'|'check', ruleText: string, question: string, counted: boolean, reading?: string, check?: Record<string, any>}} BlockAsk */
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
|
-
* The questions the block has open, in the order the person meets them: the look's readings, then the
|
|
10
|
-
*
|
|
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[]}
|
|
10
|
+
* The questions the block has open, in the order the person meets them: the look's readings, then the pick path's check proposals in rule order (a proposal is not counted toward the 3-ask cap).
|
|
11
|
+
* @param {import('./checkblock.js').CheckBlock} block @returns {BlockAsk[]}
|
|
13
12
|
*/
|
|
14
|
-
export function questionsOfBlock(block
|
|
15
|
-
const rank = { reading: 0,
|
|
13
|
+
export function questionsOfBlock(block) {
|
|
14
|
+
const rank = { reading: 0, check: 1 };
|
|
16
15
|
return block.open.map((/** @type {any} */ q) => {
|
|
17
16
|
const row = block.rows.find((r) => r.key === q.rowKey);
|
|
18
17
|
const rule = Number(row?.rule);
|
|
19
18
|
const base = { key: q.key, rowKey: q.rowKey, line: q.line, rule, source: /** @type {'look'} */ ('look'), ruleText: String(q.ruleText) };
|
|
20
19
|
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
|
-
|
|
22
|
-
|
|
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)) };
|
|
20
|
+
const words = plainWords(q.proposal);
|
|
21
|
+
return { ...base, ask: /** @type {'check'} */ ('check'), counted: false, reading: words, check: q.proposal, question: `Line ${q.line}, guardrail "${q.ruleText}": I propose ${words}.` };
|
|
27
22
|
}).sort((a, b) => rank[a.ask] - rank[b.ask]);
|
|
28
23
|
}
|
|
29
24
|
|