fwdloop 0.33.0 → 0.34.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/bin/fwdloop +14 -2
- package/package.json +1 -1
- package/src/auditchecks.js +6 -4
- package/src/authoring.js +4 -3
- package/src/blockasks.js +3 -2
- package/src/blockassemble.js +40 -21
- package/src/blockdraft.js +8 -13
- package/src/blockpick.js +11 -1
- package/src/checkblock.js +95 -56
- package/src/checklist.js +1 -1
- package/src/checklistsign.js +1 -1
- package/src/checkpick.js +7 -73
- package/src/declaration.js +9 -7
- package/src/drafter.js +152 -130
- package/src/noteask.js +62 -0
- package/src/pageask.js +5 -68
- package/src/pagedry.js +27 -4
- package/src/pagerules.js +19 -3
- package/src/panel/author.js +3 -3
- package/src/panel/authorcard.js +34 -11
- package/src/panel/index.html +7 -1
- package/src/pickrecord.js +42 -54
- package/src/planrebuild.js +16 -6
- package/src/rowedit.js +35 -5
- package/src/rubricstep.js +9 -1
- package/src/setup.js +1 -1
- package/src/sheetblock.js +17 -7
- package/src/sheetbuild.js +151 -0
- package/src/sheetchecks.js +3 -2
- package/src/sheetfind.js +4 -4
- package/src/sheetlook.js +14 -3
- package/src/sheetoffer.js +50 -5
- package/src/sheetrows.js +18 -2
- package/src/ticket-draft.js +4 -21
- package/src/ticketrows.js +100 -0
- package/types/auditchecks.d.ts +2 -1
- package/types/authoring.d.ts +4 -2
- package/types/blockasks.d.ts +1 -2
- package/types/blockassemble.d.ts +20 -3
- package/types/blockdraft.d.ts +4 -12
- package/types/blockpick.d.ts +5 -0
- package/types/checkblock.d.ts +32 -17
- package/types/checklist.d.ts +3 -3
- package/types/checkpick.d.ts +4 -34
- package/types/declaration.d.ts +7 -0
- package/types/drafter.d.ts +15 -355
- package/types/noteask.d.ts +52 -0
- package/types/pageask.d.ts +0 -35
- package/types/pagedry.d.ts +13 -0
- package/types/pagerules.d.ts +7 -0
- package/types/panel/authorcard.d.ts +13 -8
- package/types/panel/authorflows.d.ts +4 -4
- package/types/panel/data.d.ts +1 -1
- package/types/pickrecord.d.ts +47 -13
- package/types/rowedit.d.ts +16 -1
- package/types/rubricstep.d.ts +3 -0
- package/types/sheetblock.d.ts +11 -4
- package/types/sheetbuild.d.ts +84 -0
- package/types/sheetchecks.d.ts +2 -1
- package/types/sheetfind.d.ts +2 -2
- package/types/sheetoffer.d.ts +26 -1
- package/types/sheetrows.d.ts +8 -0
- package/types/ticket-draft.d.ts +3 -49
- package/types/ticketrows.d.ts +61 -0
- package/src/repairs.js +0 -38
- package/types/repairs.d.ts +0 -13
package/bin/fwdloop
CHANGED
|
@@ -52,7 +52,7 @@ import { panelMain } from '../src/panel/server.js';
|
|
|
52
52
|
import { launcherMain } from '../src/launcher.js';
|
|
53
53
|
import { isInteractive, confirmTypedName, NEEDS_TTY } from '../src/sign-confirm.js';
|
|
54
54
|
import { draftToDir, draftKeyRefusal, signDraft, SIGN_LINE, costText, questionsRefusal } from '../src/authoring.js';
|
|
55
|
-
import { readRecordFile, readRowChoices, readSheetDropped } from '../src/pickrecord.js';
|
|
55
|
+
import { readRecordFile, readRowChoices, readSheetDropped, readColumns } from '../src/pickrecord.js';
|
|
56
56
|
import { userInfo } from 'node:os';
|
|
57
57
|
import { pageAddressesOf, pageAddressRefusal } from '../src/pagefetch.js';
|
|
58
58
|
import { ticketListsOf, isTicketNumber, TICKET_NUMBER_WORDS } from '../src/ticket-shape.js';
|
|
@@ -885,6 +885,7 @@ async function cmdDraft(rest) {
|
|
|
885
885
|
'no-questions': { type: 'boolean' },
|
|
886
886
|
// M10 piece 3: the rules the person left Not checked ("drop it"), as `<line>.<rule>` pairs, e.g. `1.2,3.1` (the panel passes this to the redraft after the answers)
|
|
887
887
|
left: { type: 'string' },
|
|
888
|
+
columns: { type: 'string' },
|
|
888
889
|
// M10 am16: the checks the person picked and the answers that were not a pick, as JSON (the panel passes this to the redraft after the answers)
|
|
889
890
|
picks: { type: 'string' },
|
|
890
891
|
// M10 am17: the record file of the plan this draft follows (a Revise, or the redraft after the answers); its kept picks skip the suggestion and the asks
|
|
@@ -914,6 +915,14 @@ async function cmdDraft(rest) {
|
|
|
914
915
|
leftRules.push({ line: Number(m[1]), rule: Number(m[2]) });
|
|
915
916
|
}
|
|
916
917
|
|
|
918
|
+
// M17 ruling 2: the columns the person agreed for words that are no `~` rule, `[{line, word, column}]`; told to the AI on the list turn, never a `~` line
|
|
919
|
+
/** @type {any[]} */
|
|
920
|
+
let columnAnswers = [];
|
|
921
|
+
if (values.columns !== undefined) {
|
|
922
|
+
try { columnAnswers = JSON.parse(values.columns); } catch { columnAnswers = []; }
|
|
923
|
+
if (!Array.isArray(columnAnswers) || columnAnswers.some((x) => !x || !Number.isInteger(x.line) || typeof x.word !== 'string' || typeof x.column !== 'string')) fail('draft: --columns takes a JSON list of {line, word, column}');
|
|
924
|
+
}
|
|
925
|
+
|
|
917
926
|
/** @type {any[]|undefined} */
|
|
918
927
|
let checkPicks;
|
|
919
928
|
if (values.picks !== undefined) {
|
|
@@ -927,10 +936,11 @@ async function cmdDraft(rest) {
|
|
|
927
936
|
let carriedChoices;
|
|
928
937
|
/** @type {any[]|undefined} */
|
|
929
938
|
let carriedSheetDropped;
|
|
939
|
+
let carriedColumns;
|
|
930
940
|
if (values.carry !== undefined) {
|
|
931
941
|
const abs = resolve(values.carry);
|
|
932
942
|
const g = readFileInside(dirname(abs), basename(abs));
|
|
933
|
-
if (g.ok) { carriedPicks = readRecordFile(abs) ?? undefined; carriedChoices = readRowChoices(abs) ?? undefined; carriedSheetDropped = readSheetDropped(abs) ?? undefined; } // a missing or unreadable record is no record: every guardrail is asked, as before
|
|
943
|
+
if (g.ok) { carriedPicks = readRecordFile(abs) ?? undefined; carriedChoices = readRowChoices(abs) ?? undefined; carriedSheetDropped = readSheetDropped(abs) ?? undefined; carriedColumns = readColumns(abs) ?? undefined; } // a missing or unreadable record is no record: every guardrail is asked, as before
|
|
934
944
|
}
|
|
935
945
|
|
|
936
946
|
let injected = {};
|
|
@@ -991,10 +1001,12 @@ async function cmdDraft(rest) {
|
|
|
991
1001
|
name: values.name,
|
|
992
1002
|
noQuestions: values['no-questions'] === true,
|
|
993
1003
|
...(leftRules.length ? { leftRules } : {}),
|
|
1004
|
+
...(columnAnswers.length ? { columnAnswers } : {}),
|
|
994
1005
|
...(checkPicks === undefined ? {} : { checkPicks }),
|
|
995
1006
|
...(carriedPicks === undefined ? {} : { carriedPicks }),
|
|
996
1007
|
...(carriedChoices === undefined ? {} : { carriedChoices }),
|
|
997
1008
|
...(carriedSheetDropped === undefined ? {} : { carriedSheetDropped }),
|
|
1009
|
+
...(carriedColumns === undefined ? {} : { carriedColumns }),
|
|
998
1010
|
draftThinking: values.thinking === true ? 'on' : 'off',
|
|
999
1011
|
flowType,
|
|
1000
1012
|
...(values.mcp ? { mcpServer: values.mcp } : {}),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fwdloop",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.34.0",
|
|
4
4
|
"description": "Describe a job as steps and guardrails; an agent builds the workflow, pauses for humans where you said, checks every step happened, and reruns it under budgets it cannot touch.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.js",
|
package/src/auditchecks.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// What a run recorded for a check is read off its diary (`checks` rows: each check numbered with its `ok`, and for a list line its `part`); nothing is re-derived. What this throws away: the checks of a line off the list
|
|
4
4
|
// (the sheet and the older plans keep their own Audit rows), and the per-try history (the LAST try of a step is the one that closed it).
|
|
5
5
|
import { listLinesOf } from './checklistsign.js';
|
|
6
|
-
import { listPartRows } from './checked.js';
|
|
6
|
+
import { listPartRows, notCheckedView } from './checked.js';
|
|
7
7
|
import { EVERY_STEP, EVERY_STEP_TEXTS } from './try-checks.js';
|
|
8
8
|
import { sheetRowsOf } from './sheetrows.js';
|
|
9
9
|
|
|
@@ -13,7 +13,7 @@ export const AUDIT_NO_RESULT = 'no result recorded';
|
|
|
13
13
|
/**
|
|
14
14
|
* @param {any} declaration the signed plan @param {any[]} diary the run's `checks` rows (src/diary.js readChecks) @param {{items?: string[], by?: Record<string, string>}|null} notChecked the sign row's Not-checked block
|
|
15
15
|
* @param {{lines?: any[], csvRoles?: string[]}} [sheet] the signed job lines and CSV roles: a plan whose list has sheet rows (M16 am4) shows them here, tagged by where each comes from (hamr 2026-11-14)
|
|
16
|
-
* @returns {{checks: AuditCheckRow[], notChecked: AuditCheckRow[], always: AuditCheckRow[]}|null} null for a plan with no list (it keeps its own Audit rows)
|
|
16
|
+
* @returns {{checks: AuditCheckRow[], notChecked: AuditCheckRow[], readNotes: string[], always: AuditCheckRow[]}|null} null for a plan with no list (it keeps its own Audit rows)
|
|
17
17
|
* @typedef {{text: string, by: 'you'|'agent'|'default'|null, result: 'passed'|'failed'|'none'|'not-checked'}} AuditCheckRow
|
|
18
18
|
*/
|
|
19
19
|
export function auditChecksOf(declaration, diary, notChecked, { lines: jobLines = [], csvRoles = [] } = {}) {
|
|
@@ -40,8 +40,10 @@ export function auditChecksOf(declaration, diary, notChecked, { lines: jobLines
|
|
|
40
40
|
checks.push({ text: `line ${r.line} \u00b7 ${r.text}`, by: r.by, result: got === undefined ? 'none' : got.ok ? 'passed' : 'failed' });
|
|
41
41
|
}
|
|
42
42
|
const by = notChecked?.by ?? {};
|
|
43
|
+
// M17 am4 (C3): the Audit splits a reading note from Not checked as the card and the Job tab do (src/checked.js notCheckedView)
|
|
44
|
+
const view = notCheckedView(notChecked?.items ?? [], declaration);
|
|
43
45
|
/** @type {AuditCheckRow[]} */
|
|
44
|
-
const notRows =
|
|
46
|
+
const notRows = view.items.map((t) => ({ text: t, by: by[t] === 'you' || by[t] === 'agent' || by[t] === 'default' ? /** @type {'you'|'agent'|'default'} */ (by[t]) : null, result: 'not-checked' }));
|
|
45
47
|
// the two checks every step has (src/try-checks.js #1 and #2): passed when every step that ran them passed, failed when one did not
|
|
46
48
|
const every = (/** @type {string} */ text) => {
|
|
47
49
|
const seen = (Array.isArray(diary) ? diary : []).flatMap((d) => (d.checks ?? []).filter((/** @type {any} */ c) => c.source === EVERY_STEP && c.text === text));
|
|
@@ -49,5 +51,5 @@ export function auditChecksOf(declaration, diary, notChecked, { lines: jobLines
|
|
|
49
51
|
};
|
|
50
52
|
/** @type {AuditCheckRow[]} */
|
|
51
53
|
const always = EVERY_STEP_TEXTS.map((text) => ({ text, by: /** @type {'default'} */ ('default'), result: every(text) }));
|
|
52
|
-
return { checks, notChecked: notRows, always };
|
|
54
|
+
return { checks, notChecked: notRows, readNotes: view.readNotes, always };
|
|
53
55
|
}
|
package/src/authoring.js
CHANGED
|
@@ -337,7 +337,7 @@ export function writePlanFiles(dir, files, opts = {}) {
|
|
|
337
337
|
* `onResult({ ok })` (M4d am32): called once, after the spend is booked and just before the result files are written (the CLI gives its monthly hold back there).
|
|
338
338
|
*/
|
|
339
339
|
export async function draftToDir({
|
|
340
|
-
proseFile, dir, root, name, slot, model, draftThinking = /** @type {'on'|'off'} */ ('off'), keyNames, env = process.env, provider, rates, modelId, noQuestions = false, onResult, fetchPage, leftRules, checkPicks, carriedPicks, carriedChoices, carriedSheetDropped, proseRead,
|
|
340
|
+
proseFile, dir, root, name, slot, model, draftThinking = /** @type {'on'|'off'} */ ('off'), keyNames, env = process.env, provider, rates, modelId, noQuestions = false, onResult, fetchPage, leftRules, columnAnswers, carriedColumns, checkPicks, carriedPicks, carriedChoices, carriedSheetDropped, proseRead,
|
|
341
341
|
flowType = /** @type {'plain'|'mcp'|'tickets'} */ ('plain'), mcpServer = /** @type {string|undefined} */ (undefined), mcpPick = /** @type {any} */ (undefined), mcpServers = /** @type {string[]|undefined} */ (undefined),
|
|
342
342
|
}) {
|
|
343
343
|
const refuse = (reds) => ({ ok: false, wrote: false, reds, costUsd: 0 });
|
|
@@ -417,11 +417,12 @@ export async function draftToDir({
|
|
|
417
417
|
/** @type {any[]|null} */
|
|
418
418
|
let rowChoices = null; // a Revise's carried Drop/Add choices, handed back by draft() and kept in the same record
|
|
419
419
|
/** @type {any[]} */
|
|
420
|
+
let columnRecord = []; // the agreed columns of this plan (fresh and carried), kept in the same record (M17 ruling 2)
|
|
420
421
|
let sheetDropped = []; // the sheet checks this plan has dropped (a Revise's carried ones, applied by draft()), kept in the same record
|
|
421
422
|
/** @type {any} */
|
|
422
423
|
let pickRecord = null; // M10 am17: handed by draft() as it learns it; the last one handed is this draft's (written below, the one writer)
|
|
423
424
|
const result = await draft({
|
|
424
|
-
proseText: prose.text, slot, model, provider, rates, modelId, env, onBook, priorSpend, offerQuestions: !noQuestions, draftThinking, draftDir: path.join(dir, PAGES_DIR), fetchPage, learnHints, ...(leftRules === undefined ? {} : { leftRules }), ...(checkPicks === undefined ? {} : { checkPicks }), ...(carriedPicks === undefined ? {} : { carriedPicks }), ...(carriedChoices === undefined ? {} : { carriedChoices, onChoices: (rec) => { rowChoices = rec; } }), ...(carriedSheetDropped === undefined ? {} : { carriedSheetDropped }), onSheetDropped: (rec) => { sheetDropped = rec; }, onPickRecord: (r) => { pickRecord = r; },
|
|
425
|
+
proseText: prose.text, slot, model, provider, rates, modelId, env, onBook, priorSpend, offerQuestions: !noQuestions, draftThinking, draftDir: path.join(dir, PAGES_DIR), fetchPage, learnHints, ...(leftRules === undefined ? {} : { leftRules }), ...(columnAnswers === undefined ? {} : { columnAnswers }), ...(carriedColumns === undefined ? {} : { carriedColumns }), onColumns: (rec) => { columnRecord = rec; }, ...(checkPicks === undefined ? {} : { checkPicks }), ...(carriedPicks === undefined ? {} : { carriedPicks }), ...(carriedChoices === undefined ? {} : { carriedChoices, onChoices: (rec) => { rowChoices = rec; } }), ...(carriedSheetDropped === undefined ? {} : { carriedSheetDropped }), onSheetDropped: (rec) => { sheetDropped = rec; }, onPickRecord: (r) => { pickRecord = r; },
|
|
425
426
|
flowType, mcp, ...(mcpServers === undefined ? {} : { mcpServers }),
|
|
426
427
|
});
|
|
427
428
|
if (result.stop === 'pre-flight') {
|
|
@@ -454,7 +455,7 @@ export async function draftToDir({
|
|
|
454
455
|
// Amendments 24/25: the questions and the drafter's own "not checked" reading are written BEFORE log.json/spec.hash (the panel reads those
|
|
455
456
|
// two as "the draft finished"), as their own files: never in the readout, so never in the hash.
|
|
456
457
|
if (result.questions?.length) files[QUESTIONS_FILE] = scrub(dj({ questions: result.questions }), secrets);
|
|
457
|
-
if (pickRecord !== null) files[RECORD_FILE] = scrub(dj({ ...pickRecord, ...(rowChoices === null ? {} : { rowChoices }), ...(sheetDropped.length ? { sheetDropped } : {}) }), secrets); // M10 am17: the picks carried to the next plan (this drafting folder only, never a run folder)
|
|
458
|
+
if (pickRecord !== null) files[RECORD_FILE] = scrub(dj({ ...pickRecord, ...(rowChoices === null ? {} : { rowChoices }), ...(sheetDropped.length ? { sheetDropped } : {}), ...(columnRecord.length ? { columns: columnRecord } : {}) }), secrets); // M10 am17: the picks carried to the next plan (this drafting folder only, never a run folder)
|
|
458
459
|
files[NOT_CHECKED_FILE] = scrub(dj({ notChecked: result.notChecked ?? [], ...(result.notCheckedBy && Object.keys(result.notCheckedBy).length ? { by: result.notCheckedBy } : {}) }), secrets); // M16 item 5: the tag of each line that tells a row
|
|
459
460
|
if (result.pageLooks || result.sheetLooks) files[PAGE_LOOK_FILE] = scrub(dj({ pages: result.pageLooks ?? [], ...(result.sheetLooks ? { sheets: result.sheetLooks } : {}), look: result.look ?? { facts: [], dropped: [] } }), secrets);
|
|
460
461
|
files['log.json'] = scrub(dj({
|
package/src/blockasks.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
// borrowed-from: bareloop src/blockasks.js@v0.57.0 (c18df406)
|
|
1
2
|
// borrowed-from: bareloop src/blockasks.js@v0.56.0 (3383cce)
|
|
2
3
|
// 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
|
|
3
4
|
// 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`.
|
|
4
5
|
import { readingQuestion, cantCheckQuestion } from './pageask.js';
|
|
5
6
|
import { plainWords, HOW_TO_ANSWER, CANT_CHECK_WORDS } from './checkpick.js';
|
|
6
7
|
|
|
7
|
-
/** @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
|
|
8
|
+
/** @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>}} BlockAsk */
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* 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).
|
|
@@ -17,7 +18,7 @@ export function questionsOfBlock(block, scoped = []) {
|
|
|
17
18
|
return block.open.map((/** @type {any} */ q) => {
|
|
18
19
|
const row = block.rows.find((r) => r.key === q.rowKey);
|
|
19
20
|
const rule = Number(row?.rule);
|
|
20
|
-
const base = { key: q.key, rowKey: q.rowKey, line: q.line, rule, source: /** @type {'look'} */ ('look'), ruleText: String(q.ruleText)
|
|
21
|
+
const base = { key: q.key, rowKey: q.rowKey, line: q.line, rule, source: /** @type {'look'} */ ('look'), ruleText: String(q.ruleText) };
|
|
21
22
|
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)) };
|
|
22
23
|
if (q.ask === 'check') {
|
|
23
24
|
const words = plainWords(q.proposal);
|
package/src/blockassemble.js
CHANGED
|
@@ -3,18 +3,21 @@
|
|
|
3
3
|
// a fact part -> close.cited = {source, facts, count}, class green; the source is added to the step's reads by code
|
|
4
4
|
// a countable part -> a picked check (M10 am22 (1)-(3)): close.shape.picked on a softgreen step, close.picked on a fact (or sheet) step with the line in pickedLines
|
|
5
5
|
// the numbers tie -> close.numbersFrom (M16 am3 (2), R7)
|
|
6
|
-
// no part -> hitl
|
|
6
|
+
// no part -> hitl; the rows' Not-checked reasons are the list's own (no `unjudgeable` record, M17 am4)
|
|
7
7
|
// Whatever the AI wrote for these checks (close.cited, close.shape, close.picked, close.class) is dropped. The block's signed rows become the declaration's `checkList`, which the sign and the
|
|
8
8
|
// run-start gate prove (src/checklistsign.js). A fwd line keeps ONE close per line, whose class must equal the class its guardrail earns (signed, M4d): so a line with no guardrail of the
|
|
9
9
|
// person's own can carry only the numbers tie; any other check the list built there cannot be signed on it and its rows are signed Not checked, with that reason.
|
|
10
10
|
|
|
11
|
+
/** M17 am5 item 2 (D3): the reason a `~` rule on a signed Ask line is Not checked, the signed words */
|
|
12
|
+
export const ASK_LINE_REASON = 'you judge it at the Ask';
|
|
13
|
+
|
|
11
14
|
/** what a row says when its check cannot ride a line that has no guardrail of its own (the class of a line comes from its guardrail) */
|
|
12
15
|
export const NO_GUARDRAIL_WORDS = 'This line has no guardrail of yours, so a check on it cannot be signed; you judge it at the Ask.';
|
|
13
16
|
|
|
14
|
-
import { factsOfLook } from './citedcheck.js';
|
|
15
17
|
import { REASON, renderCard } from './checkblock.js';
|
|
16
18
|
import { dropSentence } from './pagedropwords.js';
|
|
17
19
|
import { KEPT_WORDS } from './pickrecord.js';
|
|
20
|
+
import { lineRules } from './pagebits.js';
|
|
18
21
|
|
|
19
22
|
const isRec = (/** @type {unknown} */ v) => v !== null && typeof v === 'object' && !Array.isArray(v);
|
|
20
23
|
|
|
@@ -42,19 +45,13 @@ export function pickedOf(part) {
|
|
|
42
45
|
}
|
|
43
46
|
|
|
44
47
|
/**
|
|
45
|
-
* @param {{declaration: Record<string, any>, block: import('./checkblock.js').CheckBlock, lines: {n: number, guardrail?: string|null}[], lineSet: Set<number>}} o
|
|
46
|
-
* `lineSet` = the lines the block was given; `lines` = the signed lines (a guardrail decides the class)
|
|
48
|
+
* @param {{declaration: Record<string, any>, block: import('./checkblock.js').CheckBlock, lines: {n: number, guardrail?: string|null}[], lineSet: Set<number>, askLines?: Set<number>}} o
|
|
49
|
+
* `lineSet` = the lines the block was given; `lines` = the signed lines (a guardrail decides the class); `askLines` = the signed Ask lines: each `~` rule on one is a Not-checked line here, never skipped (M17 am5 item 2)
|
|
47
50
|
* @returns {{declaration: Record<string, any>, notChecked: string[], notCheckedBy: Record<string, 'you'|'agent'|'default'>, built: Set<number>}} `built` = the lines that got a check from the block (a red naming one of them is a fault of the build)
|
|
48
51
|
*/
|
|
49
|
-
export function assembleFromBlock({ declaration, block, lines, lineSet }) {
|
|
52
|
+
export function assembleFromBlock({ declaration, block, lines, lineSet, askLines = new Set() }) {
|
|
50
53
|
if (!isRec(declaration) || !Array.isArray(declaration.steps)) return { declaration, notChecked: [], notCheckedBy: {}, built: new Set() };
|
|
51
54
|
const c = block.reconcile();
|
|
52
|
-
// fwd's signed R2c (M10 am7 item 2; bareloop v0.56.0 has no such rule, M16 am3 (1): fwd's rule stays): a place the page-read grew to phrases is checked with EVERY phrase, one phrase fact each,
|
|
53
|
-
// not with the one word the block built it from
|
|
54
|
-
const placeFactsOf = (/** @type {any} */ part, /** @type {number} */ n) => {
|
|
55
|
-
const places = /** @type {any[]} */ (block.lookFacts).filter((k) => k.line === n && Array.isArray(k.phrases) && (k.source === undefined || k.source === part.source));
|
|
56
|
-
return part.facts.flatMap((/** @type {any} */ f) => { const k = f.shape === 'phrase' ? places.find((x) => String(x.name) === f.name) : undefined; return k ? factsOfLook(k) : [f]; });
|
|
57
|
-
};
|
|
58
55
|
const partsOf = (/** @type {number} */ n) => c.map.filter((m) => m.line === n).map((m) => ({ ...c.parts[m.part], oldIndex: c.map.filter((x) => x.line === n).findIndex((x) => x.part === m.part) }));
|
|
59
56
|
const guarded = (/** @type {number} */ n) => typeof lines.find((l) => l.n === n)?.guardrail === 'string' && String(lines.find((l) => l.n === n)?.guardrail).trim() !== '';
|
|
60
57
|
/** @type {Set<number>} */ const built = new Set();
|
|
@@ -63,8 +60,6 @@ export function assembleFromBlock({ declaration, block, lines, lineSet }) {
|
|
|
63
60
|
/** @type {Set<number>} */ const notSignable = new Set();
|
|
64
61
|
/** @type {Set<number>} */ const pickedLines = new Set(Array.isArray(declaration.pickedLines) ? declaration.pickedLines : []);
|
|
65
62
|
const guardrailClasses = isRec(declaration.guardrailClasses) ? { ...declaration.guardrailClasses } : {};
|
|
66
|
-
const unjudgeable = isRec(declaration.unjudgeable) ? { ...declaration.unjudgeable } : {};
|
|
67
|
-
const rowsOn = (/** @type {number} */ n) => block.rows.filter((r) => r.line === n && r.kind !== 'floor' && !r.hidden && r.state === 'not-checked');
|
|
68
63
|
const steps = declaration.steps.map((/** @type {any} */ st) => {
|
|
69
64
|
const n = st?.fromLine;
|
|
70
65
|
if (!isRec(st) || !Number.isInteger(n) || !lineSet.has(n)) return st;
|
|
@@ -85,7 +80,7 @@ export function assembleFromBlock({ declaration, block, lines, lineSet }) {
|
|
|
85
80
|
const close = { ...(sheet ? { sheet } : {}), ...(Array.isArray(old.columns) ? { columns: old.columns } : {}) };
|
|
86
81
|
if (fact) {
|
|
87
82
|
close.class = 'green';
|
|
88
|
-
close.cited = { source: fact.source, facts:
|
|
83
|
+
close.cited = { source: fact.source, facts: fact.facts, ...(isRec(fact.count) ? { count: fact.count } : {}) };
|
|
89
84
|
} else close.class = sheet ? 'green' : picks.length ? 'softgreen' : 'hitl';
|
|
90
85
|
if (picks.length) {
|
|
91
86
|
const checks = picks.map(pickedOf);
|
|
@@ -99,12 +94,10 @@ export function assembleFromBlock({ declaration, block, lines, lineSet }) {
|
|
|
99
94
|
// the class of a line with a guardrail is the class its close ended in; a hitl one says why in the rows' own Not-checked reasons
|
|
100
95
|
for (const n of lineSet) {
|
|
101
96
|
const mine = steps.find((/** @type {any} */ st) => isRec(st) && st.fromLine === n);
|
|
102
|
-
// the classes of a list line are code's: a line with no guardrail of the person's has no class entry
|
|
103
|
-
if (!guarded(n)) { delete guardrailClasses[String(n)];
|
|
97
|
+
// the classes of a list line are code's: a line with no guardrail of the person's has no class entry, whatever the AI sent
|
|
98
|
+
if (!guarded(n)) { delete guardrailClasses[String(n)]; continue; }
|
|
104
99
|
if (!mine) continue;
|
|
105
100
|
guardrailClasses[String(n)] = mine.close.class;
|
|
106
|
-
if (mine.close.class === 'hitl') unjudgeable[String(n)] = [...new Set(rowsOn(n).map((r) => notCheckedWords(r.reason, r)).filter(Boolean))].join(' ') || 'No check was picked for it, so you judge it at the Ask.';
|
|
107
|
-
else delete unjudgeable[String(n)];
|
|
108
101
|
}
|
|
109
102
|
const served = new Set(steps.filter((/** @type {any} */ st) => isRec(st)).map((/** @type {any} */ st) => st.fromLine));
|
|
110
103
|
/** the signed list: the block's signed fields per row, the parts renumbered to the close's order, a row whose check cannot ride its line signed Not checked @type {any[]} */
|
|
@@ -122,8 +115,7 @@ export function assembleFromBlock({ declaration, block, lines, lineSet }) {
|
|
|
122
115
|
const notChecked = checkList.filter((r) => r.state === 'not-checked' && r.kind !== 'floor').map((r) => {
|
|
123
116
|
const own = block.rows.find((x) => x.key === r.key);
|
|
124
117
|
if (own?.hidden) return null;
|
|
125
|
-
|
|
126
|
-
const row = own?.parent ? { ...own, cantAsked: block.rows.find((x) => x.key === own.parent)?.cantAsked === true, keptFromLast: own.keptFromLast ?? block.rows.find((x) => x.key === own.parent)?.keptFromLast } : own;
|
|
118
|
+
const row = own;
|
|
127
119
|
// any other row is told in the words the card draws it with (renderCard; never the row's key)
|
|
128
120
|
// a `~` rule is told in the signed table's form, `not checked · "<rule>" — <reason>` (M10 am16 (5)); any other row names its line
|
|
129
121
|
const kept = row?.keptFromLast === true ? ` (${KEPT_WORDS})` : ''; // M10 am17 (6)
|
|
@@ -131,10 +123,37 @@ export function assembleFromBlock({ declaration, block, lines, lineSet }) {
|
|
|
131
123
|
if (r.by === 'you' || r.by === 'agent' || r.by === 'default') notCheckedBy[line] = r.by;
|
|
132
124
|
return line;
|
|
133
125
|
}).filter((x) => x !== null);
|
|
126
|
+
for (const l of lines) {
|
|
127
|
+
if (!askLines.has(l.n) || typeof l.guardrail !== 'string') continue;
|
|
128
|
+
for (const rule of lineRules({ rule: l.guardrail })) {
|
|
129
|
+
const line = `not checked · "${rule}" — ${ASK_LINE_REASON}`;
|
|
130
|
+
if (!notChecked.includes(line)) notChecked.push(line);
|
|
131
|
+
notCheckedBy[line] = 'you';
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
134
|
/** @type {Record<string, any>} */
|
|
135
135
|
const listed = checkList.filter((r) => served.has(r.line)); // a line no step serves is refused as a line; its rows are not signed
|
|
136
136
|
/** @type {Record<string, any>} */
|
|
137
|
-
const out = { ...declaration, steps, guardrailClasses,
|
|
137
|
+
const out = { ...declaration, steps, guardrailClasses, checkList: listed };
|
|
138
138
|
if (pickedLines.size) out.pickedLines = [...pickedLines].sort((a, b) => a - b); else delete out.pickedLines;
|
|
139
139
|
return { declaration: out, notChecked: /** @type {string[]} */ (notChecked), notCheckedBy, built };
|
|
140
140
|
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* M17 am5 / P5: a green sheet step the builder (src/sheetbuild.js) reported as holding no built check has nothing to check it: its close becomes `hitl` (the class is decided here, never in the sheet files),
|
|
144
|
+
* the class on its line follows, and its rules are the Not-checked lines the builder gave. A plan signed before M17 is never passed through here.
|
|
145
|
+
* @param {Record<string, any>} declaration @param {{line: number, lost: string[]}[]} unbuilt
|
|
146
|
+
* @returns {{declaration: Record<string, any>, lines: number[], lost: string[]}}
|
|
147
|
+
*/
|
|
148
|
+
export function closeUnbuiltSheetSteps(declaration, unbuilt) {
|
|
149
|
+
if (!isRec(declaration) || !Array.isArray(declaration.steps) || unbuilt.length === 0) return { declaration, lines: [], lost: [] };
|
|
150
|
+
const lines = unbuilt.map((u) => u.line);
|
|
151
|
+
const steps = declaration.steps.map((/** @type {any} */ st) => (isRec(st) && lines.includes(st.fromLine) && isRec(st.close) && st.close.class === 'green' ? { ...st, close: { class: 'hitl' } } : st));
|
|
152
|
+
/** @type {Record<string, any>} */
|
|
153
|
+
const out = { ...declaration, steps };
|
|
154
|
+
if (isRec(declaration.guardrailClasses)) {
|
|
155
|
+
out.guardrailClasses = { ...declaration.guardrailClasses };
|
|
156
|
+
for (const n of lines) out.guardrailClasses[String(n)] = 'hitl';
|
|
157
|
+
}
|
|
158
|
+
return { declaration: out, lines, lost: unbuilt.flatMap((u) => u.lost) };
|
|
159
|
+
}
|
package/src/blockdraft.js
CHANGED
|
@@ -5,6 +5,7 @@ import { redactSecrets } from './redact.js';
|
|
|
5
5
|
import { newJobBlock } from './blocklines.js';
|
|
6
6
|
import { EDIT_OPS } from './checkblock.js';
|
|
7
7
|
import { isCountGuardrail } from './declaration.js';
|
|
8
|
+
import { ticketRuleField } from './ticketrows.js';
|
|
8
9
|
|
|
9
10
|
/** the cap of refusals one revise turn carries (bareloop REVISE_RED_CAP) */
|
|
10
11
|
export const REVISE_RED_CAP = 20;
|
|
@@ -32,25 +33,19 @@ export function isBuildFault(red, builtLines) {
|
|
|
32
33
|
/**
|
|
33
34
|
* The block of a draft (M16 item 2): the person's `~` rules and `$` defaults, then the look's facts, then the picks the person made (kept from the last draft, and just answered), reconciled once.
|
|
34
35
|
* Fresh answers go through `carry` like the kept ones (the draft is a child process: the answer comes back as a pick or a left rule), and are not marked "kept".
|
|
35
|
-
*
|
|
36
|
-
* @param {{leaveOut?: {line: number, rule: number}[], texts: Record<string, string>, jobLines: any[], look: {facts: any[], dropped: any[]}, kept: {picks: any[], left: any[], askRules: any[]}, fresh: {picks: any[], left: {line: number, rule: number}[]}, asks: boolean, countScope: (t: string) => boolean, scoped?: {line: number, rule: number}[]}} o
|
|
36
|
+
* @param {{leaveOut?: {line: number, rule: number}[], texts: Record<string, string>, jobLines: any[], look: {facts: any[], dropped: any[]}, kept: {picks: any[], left: any[], askRules: any[]}, fresh: {picks: any[], left: {line: number, rule: number}[]}, asks: boolean, countScope: (t: string) => boolean}} o
|
|
37
37
|
*/
|
|
38
|
-
export function setUpBlock({ texts, jobLines, look, kept, fresh, asks, countScope,
|
|
38
|
+
export function setUpBlock({ texts, jobLines, look, kept, fresh, asks, countScope, leaveOut = [] }) {
|
|
39
39
|
const block = newJobBlock({ texts, jobLines, asks, countScope });
|
|
40
40
|
// M16 item 4: a Tickets job's own guardrails (the signed ticketFilter / ticketWatch) are not rows of the list; the rule numbers of the other rules stay as written
|
|
41
41
|
if (leaveOut.length) block.rows = block.rows.filter((r) => !(r.kind === 'rule' && leaveOut.some((x) => x.line === r.line && x.rule === r.rule)));
|
|
42
42
|
// a rule the person left is the block's own `left` row (carry, below); the look's person-left drop would say it twice
|
|
43
43
|
block.addLook(look.facts, look.dropped.filter((d) => d.reason !== 'person-left'));
|
|
44
|
-
block.carry({ picks: kept.picks, left: kept.left }
|
|
44
|
+
block.carry({ picks: kept.picks, left: kept.left });
|
|
45
45
|
const rowOf = (/** @type {number} */ line, /** @type {number} */ rule) => block.ruleRows(line).find((x) => x.rule === rule);
|
|
46
46
|
block.carry({ picks: fresh.picks, left: fresh.left });
|
|
47
47
|
for (const x of [...fresh.picks, ...fresh.left]) { const r = rowOf(x.line, x.rule); if (r && !kept.picks.some((k) => k.line === x.line && k.rule === x.rule) && !kept.left.some((k) => k.line === x.line && k.rule === x.rule)) delete r.keptFromLast; }
|
|
48
48
|
block.reconcile();
|
|
49
|
-
for (const r of scoped) {
|
|
50
|
-
const row = rowOf(r.line, r.rule);
|
|
51
|
-
if (row && !kept.askRules.some((a) => a.line === r.line && a.rule === r.rule) && !row.pick && !row.cantAsked && !row.left && !row.parent) row.folded = true;
|
|
52
|
-
}
|
|
53
|
-
block.reconcile();
|
|
54
49
|
return block;
|
|
55
50
|
}
|
|
56
51
|
|
|
@@ -82,10 +77,10 @@ export const editRecord = (rec) => rec.edits.map((e) => ({ op: e?.op, accepted:
|
|
|
82
77
|
/**
|
|
83
78
|
* M16 item 4 ("Tickets `ticketFilter` and `ticketWatch` stay as they are"): the rules of a Tickets job that are not the block's. Before M16 only a count guardrail of such a job (it signs a
|
|
84
79
|
* ticket page input, which routes its guardrails: src/checkpick.js codeScope) was picked or asked; every other rule ("priority P1 only", "run a ticket again when its state changes") was the
|
|
85
|
-
* declaration's own typed ticketFilter / ticketWatch, never asked and never listed as Not checked.
|
|
86
|
-
* @param {string} flowType @param {{n: number, rules?: string[]}[]} jobLines @
|
|
80
|
+
* declaration's own typed ticketFilter / ticketWatch, never asked and never listed as Not checked. Since M17 am6 these rules are ticket rows (src/ticketrows.js), so one the look tied to a fact is left out of the block too: it shows once, as the ticket row.
|
|
81
|
+
* @param {string} flowType @param {{n: number, rules?: string[]}[]} jobLines @returns {{line: number, rule: number}[]}
|
|
87
82
|
*/
|
|
88
|
-
export function ticketLeaveOut(flowType, jobLines
|
|
83
|
+
export function ticketLeaveOut(flowType, jobLines) {
|
|
89
84
|
if (flowType !== 'tickets') return [];
|
|
90
|
-
return jobLines.flatMap((l) => (l.rules ?? []).map((t, i) => ({ line: l.n, rule: i + 1, t })).filter((x) =>
|
|
85
|
+
return jobLines.flatMap((l) => (l.rules ?? []).map((t, i) => ({ line: l.n, rule: i + 1, t })).filter((x) => ticketRuleField(x.t) !== null && !isCountGuardrail(x.t)).map((x) => ({ line: x.line, rule: x.rule })));
|
|
91
86
|
}
|
package/src/blockpick.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
// borrowed-from: bareloop src/checkpick.js@v0.
|
|
1
|
+
// borrowed-from: bareloop src/checkpick.js@v0.57.0 (c18df406)
|
|
2
|
+
// first ported from: bareloop src/checkpick.js@v0.56.0 (3383cce) (isCountable, keepOrDrop, countCheck, partOfPick, sameRuleWords and what they call; HOW_TO_ANSWER and CANT_CHECK_WORDS are fwd's own, src/checkpick.js, the same words)
|
|
2
3
|
// This file is bareloop's checkpick.js. fwd already has a src/checkpick.js (the M10 am16 pick path, whose keepOrDrop and countCheck differ from these); the check block calls THESE,
|
|
3
4
|
// so they live here under another name and the am16 module is left as it is.
|
|
4
5
|
// The pick vocabulary and its keep-or-drop: a suggested check is kept only if its rule is on bareguard's list and offered here, it carries only that rule's own fields, and every
|
|
@@ -132,6 +133,15 @@ export function keepOrDrop(guardrail, sug) {
|
|
|
132
133
|
return { kept: true, check };
|
|
133
134
|
}
|
|
134
135
|
|
|
136
|
+
/**
|
|
137
|
+
* The check a counting rule's own words already ARE ("exactly 3 list items" -> listItems 3), or null. No obvious asks (hamr 2026-11-14): such a rule is settled as written, never proposed back to the person.
|
|
138
|
+
* @param {string} text @returns {Record<string, any>|null}
|
|
139
|
+
*/
|
|
140
|
+
export function obviousCheck(text) {
|
|
141
|
+
const c = countCheck(text);
|
|
142
|
+
return c !== null && c !== undefined && sameRuleWords(text, plainWords(/** @type {any} */ (c))) ? c : null;
|
|
143
|
+
}
|
|
144
|
+
|
|
135
145
|
/**
|
|
136
146
|
* The check CODE proposes for a count rule when the call yields none (R10, ours; fwd has no such fallback): a bullets / list-items / points count -> listItems N (exact; "at most / up to / no more than / fewer than / under / below" -> maxListItems, "at least / minimum / no fewer than / more than" -> minListItems, F315), a lines count ->
|
|
137
147
|
* maxLines N, ONE word number -> minWords N when the rule says "at least / minimum / more than", else maxWords N. A section count names no sections, so none is built; a rule naming two different counts ("3 bullets under 80 words") is not built either; a rule with
|