fwdloop 0.29.0 → 0.31.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/package.json +2 -2
- package/src/added-end.js +60 -0
- package/src/authoring.js +14 -8
- package/src/checked.js +11 -9
- package/src/checkpick.js +67 -6
- package/src/checkwords.js +5 -0
- package/src/citedcheck.js +14 -0
- package/src/closers.js +32 -2
- package/src/declaration.js +49 -2
- package/src/draft-steps.js +3 -3
- package/src/drafter.js +41 -9
- package/src/jobkey.js +3 -1
- package/src/model-step.js +14 -8
- package/src/pageask.js +36 -5
- package/src/panel/author.js +17 -6
- package/src/panel/authorcard.js +12 -8
- package/src/panel/data.js +5 -3
- package/src/panel/index.html +42 -10
- package/src/panel/result.js +2 -1
- package/src/plain-checks.js +15 -3
- package/src/provider.js +1 -1
- package/src/repairs.js +38 -0
- package/src/runner.js +47 -10
- package/src/setup.js +11 -5
- package/src/sheetblock.js +2 -1
- package/src/sheetfind.js +3 -1
- package/src/ticket-draft.js +2 -2
- package/src/ticket-labels.js +2 -2
- package/src/try-checks.js +13 -3
- package/src/whole-job.js +71 -0
- package/types/added-end.d.ts +62 -0
- package/types/authoring.d.ts +2 -1
- package/types/checkpick.d.ts +35 -0
- package/types/checkwords.d.ts +4 -0
- package/types/citedcheck.d.ts +6 -0
- package/types/closers.d.ts +4 -2
- package/types/declaration.d.ts +3 -0
- package/types/drafter.d.ts +16 -0
- package/types/model-step.d.ts +18 -3
- package/types/pageask.d.ts +12 -2
- package/types/panel/data.d.ts +1 -1
- package/types/panel/jobgrid.d.ts +1 -1
- package/types/plain-checks.d.ts +9 -1
- package/types/repairs.d.ts +13 -0
- package/types/sheetfind.d.ts +1 -0
- package/types/try-checks.d.ts +1 -7
- package/types/whole-job.d.ts +70 -0
package/src/plain-checks.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
// change (the job line, the guardrail, the inputs, the destination) or to Draft again when it is the AI's own form error; every rule has one (am15 item 3).
|
|
7
7
|
// The first two rules' `say` already ends with their fix, as the page has always shown them.
|
|
8
8
|
|
|
9
|
-
/** @type {ReadonlyArray<{re: RegExp, say: string|null, fix: string}>} `say` null = the checker's own sentence, as it is without its "declaration: " prefix */
|
|
9
|
+
/** @type {ReadonlyArray<{re: RegExp, say: string|null, fix: string, first?: boolean}>} `say` null = the checker's own sentence, as it is without its "declaration: " prefix */
|
|
10
10
|
export const PLAN_CHECK_RULES = Object.freeze([
|
|
11
11
|
{ re: /which is not in the job line's words/, say: "A section name in the plan's check is not in your job line. Change the job line to use the section words you want.", fix: 'Change the job line to use the section words you want.' },
|
|
12
12
|
{ re: /the job line says .*; the check says/, say: "The sections in the plan's check come in a different order than your job line. Change the job line to change the order.", fix: 'Change the job line to change the order.' },
|
|
@@ -21,6 +21,8 @@ export const PLAN_CHECK_RULES = Object.freeze([
|
|
|
21
21
|
{ re: /not in the catalogue|not wired|which is not signed|checkpoint/, say: 'A step uses a tool that is not available for this job.', fix: 'Draft again; if it repeats, say in the job line what that step should do.' },
|
|
22
22
|
{ re: /reads artifact|is a duplicate|\.reads must|\.emits must/, say: 'The steps do not pass their results to each other in a workable order.', fix: 'Draft again.' },
|
|
23
23
|
{ re: /ask at line \d+|signed ask at line|ask slot/, say: 'The ask on one of your lines is not set up as a plain stop where you decide.', fix: 'Check the line that starts with Ask in your job, then Draft again.' },
|
|
24
|
+
// M4d am38 item 1: `first: true` = this red is the one explained whenever it is among the reds (pickPlanRed), not only when it comes first.
|
|
25
|
+
{ re: /send at line \d+ .* is not granted a catalogue primitive of class "write"/, say: 'Your last line sends to your Destination, but your job puts other work on it. Make your last line the one that sends, or move that work above it, then Draft again.', fix: 'Make your last line the one that sends, or move that work above it, then Draft again.', first: true },
|
|
24
26
|
{ re: /send at line \d+|signed send at line|send slot/, say: 'The send step is not set up to follow your accept and write only to your destination.', fix: 'Check the Destination on the card, then Draft again.' },
|
|
25
27
|
{ re: /hitl after the last signed ask/, say: 'A step after your last ask would leave without your seeing it, so it is refused.', fix: 'Move the lines you want to check before your last Ask line, then Draft again.' },
|
|
26
28
|
{ re: /is a pause .* unsigned line/, say: 'A step pauses at a line you did not sign as an ask.', fix: 'Mark the line you want to stop at with Ask, then Draft again.' },
|
|
@@ -35,8 +37,18 @@ export const PLAN_CHECK_RULES = Object.freeze([
|
|
|
35
37
|
export const GENERIC_SAY = 'One of the checks on the plan failed.';
|
|
36
38
|
export const GENERIC_FIX = 'Draft again.';
|
|
37
39
|
|
|
38
|
-
/** The rules as the page takes them: JSON, the regex as its source text. */
|
|
39
|
-
export const pageRules = () => PLAN_CHECK_RULES.map((r) => ({ re: r.re.source, say: r.say }));
|
|
40
|
+
/** The rules as the page takes them: JSON, the regex as its source text. `first` rides along so a page that picks a red reads the same rule data. */
|
|
41
|
+
export const pageRules = () => PLAN_CHECK_RULES.map((r) => ({ re: r.re.source, say: r.say, ...(r.first === true ? { first: true } : {}) }));
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* M4d amendment 38 item 1: the ONE decision of which red is explained: the first red a `first` rule matches, else the first red (am15 item 3).
|
|
45
|
+
* @param {ReadonlyArray<string>} reds
|
|
46
|
+
* @returns {string|undefined}
|
|
47
|
+
*/
|
|
48
|
+
export function pickPlanRed(reds) {
|
|
49
|
+
const list = Array.isArray(reds) ? reds : [];
|
|
50
|
+
return list.find((t) => PLAN_CHECK_RULES.some((r) => r.first === true && r.re.test(String(t)))) ?? list[0];
|
|
51
|
+
}
|
|
40
52
|
|
|
41
53
|
/**
|
|
42
54
|
* @param {unknown} raw one raw refusal text
|
package/src/provider.js
CHANGED
|
@@ -41,7 +41,7 @@ import { OpenAI, Anthropic, Gemini } from 'bare-agent/providers';
|
|
|
41
41
|
* marker on the instance (`this.lastMalformedToolCall`, reset at the top of
|
|
42
42
|
* every `generate()` call) — the one channel `runModelStepOnPrimitives`
|
|
43
43
|
* (same provider reference) can read after `loop.run()` returns. We require
|
|
44
|
-
* bare-agent >=0.50 (package.json `^0.
|
|
44
|
+
* bare-agent >=0.50 (package.json `^0.59.0`) and never patch around its
|
|
45
45
|
* private response internals.
|
|
46
46
|
*/
|
|
47
47
|
class MalformedToolCallTolerantOpenAI extends OpenAI {
|
package/src/repairs.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// M10 am27 (2): code repairs of the two mechanical plan mistakes F169 found in 13 of 20 F168 drafts. Each repair is returned as a line of text and logged on the draft
|
|
2
|
+
// entry (`repaired`), so it is visible. Neither repair grants a primitive, changes a class, or writes a check.
|
|
3
|
+
// (1) a green step whose `close.cited.source` is a declared source role the step does not read: the role is added to its `reads`.
|
|
4
|
+
// (2) an `unjudgeable` entry for a line whose guardrailClasses says green: the entry is dropped and the line stays green.
|
|
5
|
+
// Throws away: the `unjudgeable` reason text of a dropped entry (kept only inside the `repaired` line).
|
|
6
|
+
/**
|
|
7
|
+
* @param {any} declaration the drafter's declaration (not changed) @param {{sources?: {role?: string, kind?: string}[]}} arbiter
|
|
8
|
+
* @returns {{declaration: any, repaired: string[]}}
|
|
9
|
+
*/
|
|
10
|
+
export function repairDeclaration(declaration, arbiter) {
|
|
11
|
+
const isRec = (/** @type {unknown} */ v) => v !== null && typeof v === 'object' && !Array.isArray(v);
|
|
12
|
+
if (!isRec(declaration)) return { declaration, repaired: [] };
|
|
13
|
+
/** @type {string[]} */
|
|
14
|
+
const repaired = [];
|
|
15
|
+
const roles = new Set((arbiter?.sources ?? []).filter((s) => typeof s?.role === 'string').map((s) => /** @type {string} */ (s.role)));
|
|
16
|
+
let out = declaration;
|
|
17
|
+
if (Array.isArray(declaration.steps)) {
|
|
18
|
+
out = {
|
|
19
|
+
...out,
|
|
20
|
+
steps: declaration.steps.map((/** @type {any} */ st, /** @type {number} */ i) => {
|
|
21
|
+
const src = isRec(st) && isRec(st.close) && st.close.class === 'green' && isRec(st.close.cited) ? st.close.cited.source : undefined;
|
|
22
|
+
if (typeof src !== 'string' || !roles.has(src) || !Array.isArray(st.reads) || st.reads.includes(src)) return st;
|
|
23
|
+
repaired.push(`steps[${i}].reads: added "${src}" (its cited check reads it)`);
|
|
24
|
+
return { ...st, reads: [...st.reads, src] };
|
|
25
|
+
}),
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
if (isRec(declaration.unjudgeable) && isRec(declaration.guardrailClasses)) {
|
|
29
|
+
const un = { ...declaration.unjudgeable };
|
|
30
|
+
for (const key of Object.keys(un)) {
|
|
31
|
+
if (declaration.guardrailClasses[key] !== 'green') continue;
|
|
32
|
+
repaired.push(`unjudgeable: dropped the entry for line ${key} (its class is green; reason was: ${String(un[key]).slice(0, 160)})`);
|
|
33
|
+
delete un[key];
|
|
34
|
+
}
|
|
35
|
+
out = { ...out, unjudgeable: un };
|
|
36
|
+
}
|
|
37
|
+
return { declaration: repaired.length ? out : declaration, repaired };
|
|
38
|
+
}
|
package/src/runner.js
CHANGED
|
@@ -77,6 +77,7 @@ import {
|
|
|
77
77
|
import { readJobThinking, readModelRecord, takeLearningsRecord } from './flowmodel.js';
|
|
78
78
|
import { readRunInputs, writeRunStart } from './runfile.js';
|
|
79
79
|
import { buildMemo } from './memo.js';
|
|
80
|
+
import { wholeJobAskIndex, wholeJobText } from './whole-job.js';
|
|
80
81
|
import { fetchPageText, isWebUrl } from './pagefetch.js';
|
|
81
82
|
import { readTicketMcp, configForServer, remoteRefusal, mcpStartOpts, startRefusal, firstLine } from './ticket-mcp.js';
|
|
82
83
|
import { createMCPBridge, discoverServers } from 'bare-agent/mcp';
|
|
@@ -1004,7 +1005,7 @@ async function runStepTries({
|
|
|
1004
1005
|
// M4d am25: `thinkingMode` is the ONE decision of what this try asks of thinking (`stepThinkingMode`); the model step only passes it on.
|
|
1005
1006
|
// M10 am7 item 3: `cited` is the fact part of a green step that quotes a saved page - the form of its ANSWER ({results: [{quote, values}]}) and the facts it must hold,
|
|
1006
1007
|
// told to the step in plain words by the model step. It is not the check: the quotes are checked by `closeCited` against the run's own copy.
|
|
1007
|
-
const stepMeta = Object.freeze({ class: step.close?.class ?? null, cited: step.close?.class === 'green' && step.close.cited ? step.close.cited : null, sheet: step.close?.class === 'green' && Array.isArray(step.close.sheet) ? step.close.sheet : null, attempt, step: step?.emits ?? step?.goal ?? null, thinkingMode: stepThinkingMode({ boxOn: thinkingBox, attempt }) });
|
|
1008
|
+
const stepMeta = Object.freeze({ class: step.close?.class ?? null, cited: step.close?.class === 'green' && step.close.cited ? step.close.cited : null, sheet: step.close?.class === 'green' && Array.isArray(step.close.sheet) ? step.close.sheet : null, withText: step.close?.class === 'green' && Array.isArray(step.close.picked) && step.close.picked.length > 0, picked: step.close?.class === 'green' && Array.isArray(step.close.picked) ? step.close.picked : null, attempt, step: step?.emits ?? step?.goal ?? null, thinkingMode: stepThinkingMode({ boxOn: thinkingBox, attempt }) });
|
|
1008
1009
|
|
|
1009
1010
|
const stopSeam = readStop ? Object.freeze({ stopRequested: readStop }) : undefined;
|
|
1010
1011
|
|
|
@@ -1398,19 +1399,19 @@ export async function runFlow({
|
|
|
1398
1399
|
|
|
1399
1400
|
// M4d am25: the run keeps the job's "Thinking on" box as it is now (read by `readJobThinking` on every try and every resume); taken here, recorded in `run.json` once the inputs are frozen
|
|
1400
1401
|
const thinkingBox = readModelRecord(flowDir)?.thinking === true;
|
|
1401
|
-
// M8 item 6: the first run from a freshly signed flow takes the learnings its draft was handed (the Audit box); a run that kept its own plan already has its record; a failure never stops the run
|
|
1402
|
-
if (!runOwnsPlan(runDir)) {
|
|
1403
|
-
try { takeLearningsRecord(flowDir, runDir); } catch (/** @type {any} */ e) {
|
|
1404
|
-
try { appendRow(join(runDir, LEARN_ERROR_FILE), { at: now(), error: redactSecrets(`learnings record: ${e?.message ?? e}`).split('\n')[0] }); } catch { /* best-effort */ }
|
|
1405
|
-
}
|
|
1406
|
-
}
|
|
1407
|
-
|
|
1408
1402
|
const frozen = await freezeInputs(runDir, sources ?? [], { fetchPage, tableRoles: sheetRolesOf(declaration.steps), mcp: declaration.mcp, ticketFilter: declaration.ticketFilter });
|
|
1409
1403
|
if (!frozen.ok) {
|
|
1410
1404
|
return haltRun({
|
|
1411
1405
|
flowDir, runDir, runId, capUsd, startedAt, now, nowMs: getNowMs, signatureHash: signature.flow, outcome: 'preflight-red', red: frozen.red, spent: { value: 0 },
|
|
1412
1406
|
});
|
|
1413
1407
|
}
|
|
1408
|
+
// M8 item 6: the first run from a freshly signed flow takes the learnings its draft was handed (the Audit box); a run that kept its own plan already has its record; taken only once the inputs froze, so a run refused at its inputs leaves it; a failure never stops the run
|
|
1409
|
+
if (!runOwnsPlan(runDir)) {
|
|
1410
|
+
try { takeLearningsRecord(flowDir, runDir); } catch (/** @type {any} */ e) {
|
|
1411
|
+
try { appendRow(join(runDir, LEARN_ERROR_FILE), { at: now(), error: redactSecrets(`learnings record: ${e?.message ?? e}`).split('\n')[0] }); } catch { /* best-effort */ }
|
|
1412
|
+
}
|
|
1413
|
+
}
|
|
1414
|
+
|
|
1414
1415
|
// M8b item 1: the run's start record, written once: the model it started on (M4d am33), the "Thinking on" box (M4d am25) and the frozen inputs
|
|
1415
1416
|
writeRunStart(runDir, { model: runModel ?? null, thinking: thinkingBox, inputs: /** @type {any[]} */ (frozen.manifest), rerun: rerunOf ?? null });
|
|
1416
1417
|
// M12 piece 3 (item 9): a ticket the signed labels do not match, or a closed one, ends here: skipped, $0, nothing else runs
|
|
@@ -1605,6 +1606,8 @@ async function runAskSlot({
|
|
|
1605
1606
|
runStartedAt,
|
|
1606
1607
|
// M13 item 5: the job's signed `mcp.server`; a redo of the step before the ask runs it again with its signed MCP tools
|
|
1607
1608
|
mcpServer = /** @type {string|null} */ (null),
|
|
1609
|
+
// M13 am9: set only for the Ask that shows the whole job; rebuilds `{text}` from the saved outputs after a redo changed one
|
|
1610
|
+
rebuildPrior = /** @type {null | (() => ({ok:true,value:any}|{ok:false,red:string}))} */ (null),
|
|
1608
1611
|
}) {
|
|
1609
1612
|
let redone = initialRedone;
|
|
1610
1613
|
let currentPrior = priorArtifact;
|
|
@@ -1794,6 +1797,11 @@ async function runAskSlot({
|
|
|
1794
1797
|
// case `writeArtifact` allows to overwrite on purpose.
|
|
1795
1798
|
writeArtifact(runDir, priorId, currentPrior, { overwrite: true });
|
|
1796
1799
|
artifacts[priorId] = currentPrior;
|
|
1800
|
+
if (rebuildPrior) {
|
|
1801
|
+
const whole = rebuildPrior();
|
|
1802
|
+
if (!whole.ok) return { type: 'halted', outcome: 'red', red: whole.red };
|
|
1803
|
+
currentPrior = whole.value;
|
|
1804
|
+
}
|
|
1797
1805
|
// eslint-disable-next-line no-continue
|
|
1798
1806
|
continue;
|
|
1799
1807
|
}
|
|
@@ -1844,6 +1852,9 @@ async function foldFromStep({
|
|
|
1844
1852
|
}) {
|
|
1845
1853
|
let runAcceptedThisRun = acceptedThisRun;
|
|
1846
1854
|
let runUnjudged = unjudgedSinceLastAsk;
|
|
1855
|
+
// M13 am9: the Ask that shows the whole job (-1 = none: a job signed before am8 is unchanged)
|
|
1856
|
+
const wholeIdx = wholeJobAskIndex({ steps, askLines, sendLines });
|
|
1857
|
+
const rebuildWhole = () => wholeJobText({ steps, askLines, lastAskIndex: wholeIdx, readResult: (id) => readArtifactResult(runDir, id) });
|
|
1847
1858
|
|
|
1848
1859
|
for (let i = i0; i < steps.length; i += 1) {
|
|
1849
1860
|
const step = steps[i];
|
|
@@ -1955,7 +1966,17 @@ async function foldFromStep({
|
|
|
1955
1966
|
: `ask: prior artifact "${priorId}" for step "${step.goal}" — ${priorArtifactResult.red}`,
|
|
1956
1967
|
});
|
|
1957
1968
|
}
|
|
1958
|
-
|
|
1969
|
+
let priorArtifact = priorArtifactResult.value;
|
|
1970
|
+
if (i === wholeIdx) {
|
|
1971
|
+
const whole = rebuildWhole();
|
|
1972
|
+
if (!whole.ok) {
|
|
1973
|
+
return haltRun({
|
|
1974
|
+
flowDir, runDir, runId, capUsd, startedAt: runStartedAt, now, nowMs, signatureHash, spent, priorSpendComplete: spendComplete.value, attempts: attemptsLog, artifacts,
|
|
1975
|
+
outcome: 'red', red: whole.red,
|
|
1976
|
+
});
|
|
1977
|
+
}
|
|
1978
|
+
priorArtifact = whole.value;
|
|
1979
|
+
}
|
|
1959
1980
|
|
|
1960
1981
|
// M2 amendment 1 item 2: every hitl artifact carried since the
|
|
1961
1982
|
// previous ask goes to THIS ask as evidence, alongside the ask step's
|
|
@@ -1976,6 +1997,7 @@ async function foldFromStep({
|
|
|
1976
1997
|
priorStepNo: priorStepIndex + 1,
|
|
1977
1998
|
priorPrevStepId: priorStepIndex > 0 ? (steps[priorStepIndex - 1].emits ?? null) : null,
|
|
1978
1999
|
priorArtifact,
|
|
2000
|
+
rebuildPrior: i === wholeIdx ? rebuildWhole : null,
|
|
1979
2001
|
redoCap,
|
|
1980
2002
|
effectiveCeilingUsd,
|
|
1981
2003
|
capUsd,
|
|
@@ -2636,7 +2658,21 @@ export async function resumeRun({
|
|
|
2636
2658
|
// `priorId` names a step strictly earlier than the parked ask
|
|
2637
2659
|
// (state.stepIndex), so i < state.stepIndex — already proven `ok` by the
|
|
2638
2660
|
// "was this step already done" gate above; safe to collapse here.
|
|
2639
|
-
|
|
2661
|
+
let priorArtifact = readArtifact(runDir, priorId);
|
|
2662
|
+
// M13 am9: the Ask that shows the whole job rebuilds `{text}` from the saved outputs, as the first pass did
|
|
2663
|
+
const wholeIdx = wholeJobAskIndex({ steps, askLines, sendLines });
|
|
2664
|
+
const rebuildWhole = () => wholeJobText({ steps, askLines, lastAskIndex: wholeIdx, readResult: (id) => readArtifactResult(runDir, id) });
|
|
2665
|
+
if (state.stepIndex === wholeIdx) {
|
|
2666
|
+
const whole = rebuildWhole();
|
|
2667
|
+
if (!whole.ok) {
|
|
2668
|
+
return haltRun({
|
|
2669
|
+
flowDir, runDir, runId, capUsd, startedAt: runStartedAt, now, nowMs: getNowMs, signatureHash: state.signatureHash, spent, priorSpendComplete: spendComplete.value, attempts: attemptsLog, artifacts,
|
|
2670
|
+
outcome: 'red', red: whole.red,
|
|
2671
|
+
resumeAt: { stepIndex: state.stepIndex, flowRoot: root, flowName: name, inputsManifest: state.inputsManifest, unjudged: state.evidenceUnjudged ?? [], redone: typeof state.redone === 'number' ? state.redone : 0 },
|
|
2672
|
+
});
|
|
2673
|
+
}
|
|
2674
|
+
priorArtifact = whole.value;
|
|
2675
|
+
}
|
|
2640
2676
|
|
|
2641
2677
|
const oneShotAskStep = makeOneShotThenParkAskStep({ decision: answer.decision, reason: answer.reason, artifactSha256: answer.artifactSha256 });
|
|
2642
2678
|
|
|
@@ -2650,6 +2686,7 @@ export async function resumeRun({
|
|
|
2650
2686
|
priorStepNo: priorStepIndex + 1,
|
|
2651
2687
|
priorPrevStepId: priorStepIndex > 0 ? (steps[priorStepIndex - 1].emits ?? null) : null,
|
|
2652
2688
|
priorArtifact,
|
|
2689
|
+
rebuildPrior: state.stepIndex === wholeIdx ? rebuildWhole : null,
|
|
2653
2690
|
redoCap,
|
|
2654
2691
|
effectiveCeilingUsd,
|
|
2655
2692
|
capUsd,
|
package/src/setup.js
CHANGED
|
@@ -61,22 +61,28 @@ function planRow(sessionDir, rel, kind, n) {
|
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
/**
|
|
64
|
-
* M10 am2 item 4: one row per question the
|
|
65
|
-
* from the answer files). The question, the answer, the line and the time, plus the proposal and the rule the answer added as their own fields (never cut
|
|
64
|
+
* M10 am2 item 4 (and M14 am3: also a question the drafter raised): one row per question the plan asked and the person answered, in the plan folder that
|
|
65
|
+
* raised it (the draft log's human rows, read from the answer files). The question, the answer, the line and the time, plus the proposal and the rule the answer added as their own fields (never cut
|
|
66
66
|
* out of the question text). A question nobody answered leaves no row.
|
|
67
67
|
* @param {string} sessionDir @param {string} rel
|
|
68
68
|
*/
|
|
69
69
|
function humanRows(sessionDir, rel) {
|
|
70
|
-
|
|
70
|
+
/** @type {any[]} the look rows carry look-only fields (and a recorded choice), the drafter rows do not */
|
|
71
|
+
const answered = readQuestions(join(sessionDir, rel)).questions.filter((q) => q.answer !== null).map((q) => (q.source === 'look' ? {
|
|
71
72
|
kind: 'human', n: q.k, at: q.at ?? null, source: 'look', ask: q.ask, question: q.question, answer: q.answer, line: q.line,
|
|
72
|
-
ruleNo: q.ruleNo, ruleText: q.ruleText, proposal: q.proposal ?? null, rule: q.rule ?? null,
|
|
73
|
+
ruleNo: q.ruleNo, ruleText: q.ruleText, proposal: q.proposal ?? null, rule: q.rule ?? null, ...(q.choice === undefined ? {} : { choice: q.choice }),
|
|
74
|
+
} : {
|
|
75
|
+
// M14 am3: a question the drafter raised and the person answered is the same row, with no look-only fields (so no picked label)
|
|
76
|
+
kind: 'human', n: q.k, at: q.at ?? null, question: q.question, answer: q.answer, line: q.line,
|
|
73
77
|
}));
|
|
78
|
+
// a kept row's n counts the answered LOOK rows only, as before M14 am3 (a page-look row never changes)
|
|
79
|
+
const lookAnswered = answered.filter((r) => r.source === 'look').length;
|
|
74
80
|
// M10 am17 (6): a pick kept from the last draft is the same row, from this plan's picks record (not an answer file), its answer being the words `kept from last draft`
|
|
75
81
|
const kept = Array.isArray(readJson(join(sessionDir, rel), RECORD_FILE)?.kept) ? readJson(join(sessionDir, rel), RECORD_FILE).kept : [];
|
|
76
82
|
const keptRows = kept.map((k, i) => {
|
|
77
83
|
const [ask] = checkAsks([{ line: k.line, rule: k.rule, text: k.ruleText, check: k.check ?? null, why: null }]);
|
|
78
84
|
return {
|
|
79
|
-
kind: 'human', n:
|
|
85
|
+
kind: 'human', n: lookAnswered + i + 1, at: null, source: 'look', ask: ask.ask, question: ask.question, answer: KEPT_WORDS, line: k.line,
|
|
80
86
|
ruleNo: k.rule, ruleText: k.ruleText, proposal: ask.reading ?? null, rule: k.added ?? null,
|
|
81
87
|
};
|
|
82
88
|
});
|
package/src/sheetblock.js
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
// A green "found" is the step's OWN claimed value in plain words (a number, or a count of rows / days / bands / groups); a string claim (a looked-up cell) is never
|
|
8
8
|
// repeated, because it is cell text. A red "found" is bareguard's gap words (row numbers and counts), never a cell's text.
|
|
9
9
|
// Third outcomes, named: a line the run never reached (no record) carries no verdict; a check the record lacks carries none (the page shows no mark).
|
|
10
|
+
import { labelled } from './checkwords.js';
|
|
10
11
|
import { isDeepStrictEqual } from 'node:util';
|
|
11
12
|
import { rubricVocabulary } from 'bareguard';
|
|
12
13
|
import { lineRules } from './pagebits.js';
|
|
@@ -90,7 +91,7 @@ export function sheetLineBlocks({ declaration, lines, csvRoles = [], record }) {
|
|
|
90
91
|
const words = sheetCheckSentence(c);
|
|
91
92
|
const cw = coversWords(rules);
|
|
92
93
|
/** @type {any} */
|
|
93
|
-
const e = { id: typeof c.id === 'string' ? c.id : '', name, words, covers: rules, coversWords: cw, text: [name, ...(words === name ? [] : [words]), ...(cw ? [cw] : [])].join(' — ') };
|
|
94
|
+
const e = { id: typeof c.id === 'string' ? c.id : '', name, words, covers: rules, coversWords: cw, text: labelled([name, ...(words === name ? [] : [words]), ...(cw ? [cw] : [])].join(' — '), 'agent') }; // M10 am22 (4): the AI wrote every sheet check
|
|
94
95
|
const res = newest && Array.isArray(newest.results) ? newest.results.find((/** @type {any} */ r) => isRec(r) && r.id === c.id) : undefined;
|
|
95
96
|
if (isRec(res) && typeof res.ok === 'boolean') {
|
|
96
97
|
e.ok = res.ok;
|
package/src/sheetfind.js
CHANGED
|
@@ -47,4 +47,6 @@ export function findColumn(csvText, word) {
|
|
|
47
47
|
* `no column 'Price'; 'Amount' has numbers in 40 of 40 rows. Use it? Answer "agree", or type your own words (your answer is added as a new ~ rule on line N).`
|
|
48
48
|
* @param {string} word @param {FoundAsk} found @param {number} line @returns {string}
|
|
49
49
|
*/
|
|
50
|
-
export const columnQuestion = (word, found, line) => `no column '${word}'; '${found.column}' has numbers in ${found.numbers} of ${found.rows} rows. Use it
|
|
50
|
+
export const columnQuestion = (word, found, line) => `no column '${word}'; '${found.column}' has numbers in ${found.numbers} of ${found.rows} rows. Use it?${columnTail(line)}`;
|
|
51
|
+
/** @param {number} line @returns {string} the answer words the column question ends with (M10 am29: the panel cuts exactly this) */
|
|
52
|
+
export const columnTail = (line) => ` Answer "agree", or type your own words (your answer is added as a new ~ rule on line ${line}).`;
|
package/src/ticket-draft.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// M12 piece 3 (docs/wiki/the-module-ladder.md, "M12 scope (restart)" item 4): what the DRAFTER is told about a ticket role, and what it may suggest.
|
|
2
2
|
// A ticket role is a signed page input (`source <role> = page:<address>`) whose address is a GitHub issues list: it is never fetched at draft (one ticket is read
|
|
3
|
-
// per run through the job's MCP tools). The drafter may SUGGEST the job's `mcp`/`mcpTools` (issue_read) and a `ticketFilter` (priority / label names); a human
|
|
3
|
+
// per run through the job's MCP tools). The drafter may SUGGEST the job's `mcp`/`mcpTools` (issue_read), and MUST add a `ticketFilter` (priority / label names) when a guardrail names a priority or a label; a human
|
|
4
4
|
// signs it and code decides at run. The first facts line is F90c's, the line that made the drafter read a ticket role at all (FINDINGS F90c, F92).
|
|
5
5
|
import { discoverServers } from 'bare-agent/mcp';
|
|
6
6
|
import { startableMcpServers } from './mcp-sources.js';
|
|
@@ -63,7 +63,7 @@ export function ticketSchemaParts({ flowType, tools }) {
|
|
|
63
63
|
labels: { type: 'array', items: { type: 'string' }, description: 'label names, one of which a ticket must carry; only when a guardrail names them' },
|
|
64
64
|
},
|
|
65
65
|
additionalProperties: false,
|
|
66
|
-
description: '
|
|
66
|
+
description: 'required when a guardrail names a priority or a label: put those values here; leave it out only when no guardrail names one',
|
|
67
67
|
},
|
|
68
68
|
ticketWatch: { type: 'array', items: { type: 'string', enum: ['state', 'labels'] }, description: 'optional: suggest only for a guardrail that says to run a ticket again when its state or its labels change' },
|
|
69
69
|
},
|
package/src/ticket-labels.js
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
// Three outcomes are kept apart: skip (a definite miss, or closed), run (a match), run-with-`unsure` (an off-scale or unreadable label goes to a human at the
|
|
5
5
|
// ask, NEVER skipped). Normaliser borrowed in shape from fwdloop poc/mcp/f96/f96.mjs (the F96 rules, 12 of 12 on real tickets), re-shaped to a pure function.
|
|
6
6
|
|
|
7
|
-
/** `P0`..`P3`, optionally after `priority`, `priority:`, `priority /` or `priority -`;
|
|
8
|
-
const PRIORITY_LABEL = /^(?:priority\s*[:/-]?\s*)?p([0-3])(?![
|
|
7
|
+
/** `P0`..`P3`, optionally after `priority`, `priority:`, `priority /` or `priority -`; no letter or digit may follow the digit (`P12`, `p2p` are no priority; `P1-urgent` is P1) */
|
|
8
|
+
const PRIORITY_LABEL = /^(?:priority\s*[:/-]?\s*)?p([0-3])(?![a-z0-9])/;
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* One priority value from a ticket's labels: `P0`..`P3`; `unsure` when two different ones are present, or when a label names a priority on another scale
|
package/src/try-checks.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
// checks. A check that did not run (the done check halts before the others) is not listed. A hitl close has no mechanical check, so it adds none.
|
|
4
4
|
import { createHash } from 'node:crypto';
|
|
5
5
|
import { serializeArtifact } from './ask.js';
|
|
6
|
+
import { labelled } from './checkwords.js';
|
|
6
7
|
|
|
7
8
|
export const EVERY_STEP = 'every step';
|
|
8
9
|
|
|
@@ -44,6 +45,14 @@ export function outputRecord(step, artifact) {
|
|
|
44
45
|
* @param {any} step @param {any} artifact @param {{verdict: string, red?: string|null, checks?: Array<{text:string, ok:boolean, result:string|null}>}} closed
|
|
45
46
|
*/
|
|
46
47
|
export function closeRecords(step, artifact, closed) {
|
|
48
|
+
const rows = factRecords(step, artifact, closed);
|
|
49
|
+
// M10 am22 (1): the picks on a fact line are rows after the fact rows, each judged on the answer's text
|
|
50
|
+
const picks = Array.isArray(/** @type {any} */ (closed).pickChecks) ? /** @type {any} */ (closed).pickChecks : [];
|
|
51
|
+
return [...rows, ...picks.map((/** @type {any} */ c, i) => ({ n: rows.length + 3 + i, text: labelled(c.text, 'picked'), ok: c.ok, result: c.result, source: lineSource(step) }))];
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** @param {any} step @param {any} artifact @param {any} closed */
|
|
55
|
+
function factRecords(step, artifact, closed) {
|
|
47
56
|
const source = lineSource(step);
|
|
48
57
|
if (closed.verdict === 'unparseable' || closed.verdict === 'crash') {
|
|
49
58
|
return [{
|
|
@@ -53,13 +62,13 @@ export function closeRecords(step, artifact, closed) {
|
|
|
53
62
|
if (step?.close?.class === 'green' && Array.isArray(step?.close?.sheet) && Array.isArray(closed.checks)) {
|
|
54
63
|
// M10b piece 2: each signed sheet check is its own row, worded by `sheetCheckSentence`, judged by bareguard
|
|
55
64
|
return closed.checks.map((c, i) => ({
|
|
56
|
-
n: 3 + i, text: c.text, ok: c.ok, result: c.result, source,
|
|
65
|
+
n: 3 + i, text: labelled(c.text, 'agent'), ok: c.ok, result: c.result, source,
|
|
57
66
|
}));
|
|
58
67
|
}
|
|
59
68
|
if (step?.close?.class === 'green' && step?.close?.cited) {
|
|
60
69
|
const n = Array.isArray(artifact?.results) ? artifact.results.length : 0;
|
|
61
70
|
return [{
|
|
62
|
-
n: 3, text: 'every result is quoted from the saved copy and passes its rules', ok: closed.verdict === 'green', result: `${n} result${n === 1 ? '' : 's'}`, source,
|
|
71
|
+
n: 3, text: labelled('every result is quoted from the saved copy and passes its rules', 'agent'), ok: Array.isArray(/** @type {any} */ (closed).pickChecks) && closed.cited?.check ? closed.cited.check.verdict === 'green' : closed.verdict === 'green', result: `${n} result${n === 1 ? '' : 's'}`, source,
|
|
63
72
|
}];
|
|
64
73
|
}
|
|
65
74
|
if (step?.close?.class === 'green') {
|
|
@@ -68,7 +77,8 @@ export function closeRecords(step, artifact, closed) {
|
|
|
68
77
|
n: 3, text: 'every cited field matches its source', ok: closed.verdict === 'green', result: `${n} field${n === 1 ? '' : 's'}`, source,
|
|
69
78
|
}];
|
|
70
79
|
}
|
|
80
|
+
// M10 am22 (4): a softgreen check is the person's when it is one of their picks, the drafter's otherwise; the one-key row is code's own and carries no label
|
|
71
81
|
return (closed.checks ?? []).map((c, i) => ({
|
|
72
|
-
n: 3 + i, text: c.text, ok: c.ok, result: c.result, source,
|
|
82
|
+
n: 3 + i, text: /** @type {any} */ (c).id === 'keys' ? c.text : labelled(c.text, /^pick\d+$/.test(String(/** @type {any} */ (c).id)) ? 'picked' : 'agent'), ok: c.ok, result: c.result, source,
|
|
73
83
|
}));
|
|
74
84
|
}
|
package/src/whole-job.js
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
// M13 am9: the file holds the whole job. ONE writer of the whole-job text (`wholeJobText`), ONE finder of the Ask that shows it (`wholeJobAskIndex`).
|
|
2
|
+
// The last Ask before the added `write it out` shows every step's result in job order, built by code from each step's saved output (never picked by the AI):
|
|
3
|
+
// a work step is one section `## Line <n>: <line words>` + `renderSentMd(<its saved output>)` (the M15 form, unchanged); an Ask before it is one line
|
|
4
|
+
// `Line <n>: you accepted this at the Ask.`; the last Ask itself and the send line are not sections. The accepted artifact is `{text}`, so the send ships it unchanged.
|
|
5
|
+
// Throws away: nothing of a step's saved output beyond what `renderSentMd` already drops. Third outcomes: a work step with no readable saved output refuses, naming the step.
|
|
6
|
+
import { renderSentMd } from './send.js';
|
|
7
|
+
import { addedLinesOf } from './added-end.js';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* The index of the Ask that shows the whole job: the Ask the added send reads, only when the plan has the am8 added `write it out`. A job signed before am8
|
|
11
|
+
* (its send line is the person's own words) finds -1 and keeps today's behaviour exactly.
|
|
12
|
+
* @param {{ steps: { fromLine: number, goal: string, emits?: string, reads?: string[] }[], askLines: Map<number, any>, sendLines: Map<number, any> }} p
|
|
13
|
+
* @returns {number} -1 = none
|
|
14
|
+
*/
|
|
15
|
+
export function wholeJobAskIndex({ steps, askLines, sendLines }) {
|
|
16
|
+
if (sendLines.size !== 1) return -1;
|
|
17
|
+
const send = [...sendLines.values()][0];
|
|
18
|
+
const lines = steps.map((s) => ({ n: s.fromLine, text: s.goal }));
|
|
19
|
+
if (!addedLinesOf(lines, { sends: [...sendLines.values()], asks: [...askLines.values()] }).has(send.line)) return -1;
|
|
20
|
+
const sendStep = steps.find((s) => s.fromLine === send.line);
|
|
21
|
+
const askIds = (sendStep?.reads ?? []).filter((id) => steps.some((s) => s.emits === id && askLines.has(s.fromLine)));
|
|
22
|
+
if (askIds.length !== 1) return -1;
|
|
23
|
+
return steps.findIndex((s) => s.emits === askIds[0]);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* @param {{ steps: { fromLine: number, goal: string, emits?: string }[], askLines: Map<number, any>, lastAskIndex: number,
|
|
28
|
+
* readResult: (id: string) => ({ ok: true, value: any } | { ok: false, missing: true } | { ok: false, missing: false, red: string }) }} p
|
|
29
|
+
* @returns {{ ok: true, value: { text: string } } | { ok: false, red: string }}
|
|
30
|
+
*/
|
|
31
|
+
export function wholeJobText({ steps, askLines, lastAskIndex, readResult }) {
|
|
32
|
+
/** @type {string[]} */
|
|
33
|
+
const parts = [];
|
|
34
|
+
for (let i = 0; i < lastAskIndex; i += 1) {
|
|
35
|
+
const s = steps[i];
|
|
36
|
+
if (askLines.has(s.fromLine)) {
|
|
37
|
+
parts.push(`Line ${s.fromLine}: you accepted this at the Ask.`);
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
const r = readResult(/** @type {string} */ (s.emits));
|
|
41
|
+
if (!r.ok) {
|
|
42
|
+
return {
|
|
43
|
+
ok: false,
|
|
44
|
+
red: r.missing
|
|
45
|
+
? `ask: the saved output "${s.emits}" of step "${s.goal}" is missing — refusing to show the whole job`
|
|
46
|
+
: `ask: the saved output "${s.emits}" of step "${s.goal}" — ${r.red}`,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
parts.push(`## Line ${s.fromLine}: ${s.goal}\n${renderSentMd(r.value)}`);
|
|
50
|
+
}
|
|
51
|
+
return { ok: true, value: { text: parts.join('\n\n') } };
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* M13 am9 item 4: the plan shows the last Ask as reading every step. Code sets the Ask's `reads` to every work step's emits before it (the nearest one first, so a
|
|
56
|
+
* redo still re-runs the step just before the Ask; the rest in job order). Only a plan with the am8 added end; any other plan comes back as it was.
|
|
57
|
+
* @template {{ fromLine: number, goal: string, emits?: string, reads?: string[], primitives?: string[] }} S
|
|
58
|
+
* @param {S[]} steps @param {{ asks?: { line: number }[], sends?: { line: number }[] }} arbiter
|
|
59
|
+
* @returns {S[]}
|
|
60
|
+
*/
|
|
61
|
+
export function readEveryStep(steps, arbiter) {
|
|
62
|
+
if (!Array.isArray(steps) || !steps.every((s) => s && typeof s === 'object')) return steps;
|
|
63
|
+
const askLines = new Map((arbiter?.asks ?? []).map((a) => [a.line, a]));
|
|
64
|
+
const sendLines = new Map((arbiter?.sends ?? []).map((x) => [x.line, x]));
|
|
65
|
+
const idx = wholeJobAskIndex({ steps, askLines, sendLines });
|
|
66
|
+
if (idx < 1) return steps;
|
|
67
|
+
const work = steps.slice(0, idx).filter((s) => !askLines.has(s.fromLine) && typeof s.emits === 'string').map((s) => /** @type {string} */ (s.emits));
|
|
68
|
+
if (work.length === 0) return steps;
|
|
69
|
+
const reads = [work[work.length - 1], ...work.slice(0, -1)];
|
|
70
|
+
return steps.map((s, i) => (i === idx ? { ...s, reads } : s));
|
|
71
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @param {{ n: number, text: string, ask: null | { wait: string|null, question: string }, guardrails: string[] }[]} steps `parseJobBox` steps
|
|
3
|
+
* @param {string} destination the card's Destination ('' = none)
|
|
4
|
+
* @returns {{ steps: { n: number, text: string, ask: null | { wait: string|null, question: string }, guardrails: string[] }[], added: number[] }} the steps with the end added, and the numbers of the added lines
|
|
5
|
+
*/
|
|
6
|
+
export function addEnd(steps: {
|
|
7
|
+
n: number;
|
|
8
|
+
text: string;
|
|
9
|
+
ask: null | {
|
|
10
|
+
wait: string | null;
|
|
11
|
+
question: string;
|
|
12
|
+
};
|
|
13
|
+
guardrails: string[];
|
|
14
|
+
}[], destination: string): {
|
|
15
|
+
steps: {
|
|
16
|
+
n: number;
|
|
17
|
+
text: string;
|
|
18
|
+
ask: null | {
|
|
19
|
+
wait: string | null;
|
|
20
|
+
question: string;
|
|
21
|
+
};
|
|
22
|
+
guardrails: string[];
|
|
23
|
+
}[];
|
|
24
|
+
added: number[];
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* The added lines of a plan, found again from its signed lines and arbiter: the send line when it reads `write it out`, and the Ask just before it
|
|
28
|
+
* when that reads `check the result with me`. A job signed before M13 am8 (its send line is the person's own words) finds none.
|
|
29
|
+
* @param {{ n: number, text: string }[]} lines @param {{ sends?: { line: number }[], asks?: { line: number }[] }} arbiter
|
|
30
|
+
* @returns {Set<number>}
|
|
31
|
+
*/
|
|
32
|
+
export function addedLinesOf(lines: {
|
|
33
|
+
n: number;
|
|
34
|
+
text: string;
|
|
35
|
+
}[], arbiter: {
|
|
36
|
+
sends?: {
|
|
37
|
+
line: number;
|
|
38
|
+
}[];
|
|
39
|
+
asks?: {
|
|
40
|
+
line: number;
|
|
41
|
+
}[];
|
|
42
|
+
}): Set<number>;
|
|
43
|
+
/**
|
|
44
|
+
* The lines a person typed, found again from a signed job: the signed lines without the send line (the last line when it is the send; today's `write it out`, or
|
|
45
|
+
* the person's own words in a job signed before am8) and without an added Ask before it. ONE reader for the Edit card (`cardFromSigned`) and the job identity (`jobKeyOfSigned`).
|
|
46
|
+
* @template {{ n: number, text: string }} L
|
|
47
|
+
* @param {L[]} lines @param {{ sends?: { line: number }[], asks?: { line: number }[] }} arbiter
|
|
48
|
+
* @returns {L[]}
|
|
49
|
+
*/
|
|
50
|
+
export function typedLinesOf<L extends {
|
|
51
|
+
n: number;
|
|
52
|
+
text: string;
|
|
53
|
+
}>(lines: L[], arbiter: {
|
|
54
|
+
sends?: {
|
|
55
|
+
line: number;
|
|
56
|
+
}[];
|
|
57
|
+
asks?: {
|
|
58
|
+
line: number;
|
|
59
|
+
}[];
|
|
60
|
+
}): L[];
|
|
61
|
+
export const ADDED_ASK_QUESTION: "check the result with me";
|
|
62
|
+
export const ADDED_WRITE: "write it out";
|
package/types/authoring.d.ts
CHANGED
|
@@ -23,7 +23,7 @@ export function specHash({ proseText, declarationText, inputFactsText, readoutTe
|
|
|
23
23
|
* answer file counts as no answer. No questions file = `{ questions: [], open: [] }`.
|
|
24
24
|
* @param {string} planDir
|
|
25
25
|
* A question the page look raised (M10 piece 3) also carries `source: 'look'`, `ask` ('reading' | 'cant-check'), `ruleNo`, `ruleText` and `proposal`; an answer file carries `at`.
|
|
26
|
-
* @returns {{ questions: {k:number, line:number, question:string, answer:string|null, at?:string, rule?:string|null, source?:string, ask?:string, ruleNo?:number, ruleText?:string, proposal?:string|null, check?:Record<string, any>, pairRule?:number}[], open: {k:number, line:number, question:string, answer:null}[] }}
|
|
26
|
+
* @returns {{ questions: {k:number, line:number, question:string, answer:string|null, at?:string, rule?:string|null, choice?:'agree'|'drop'|'rule', source?:string, ask?:string, ruleNo?:number, ruleText?:string, proposal?:string|null, check?:Record<string, any>, pairRule?:number}[], open: {k:number, line:number, question:string, answer:null}[] }}
|
|
27
27
|
*/
|
|
28
28
|
export function readQuestions(planDir: string): {
|
|
29
29
|
questions: {
|
|
@@ -33,6 +33,7 @@ export function readQuestions(planDir: string): {
|
|
|
33
33
|
answer: string | null;
|
|
34
34
|
at?: string;
|
|
35
35
|
rule?: string | null;
|
|
36
|
+
choice?: "agree" | "drop" | "rule";
|
|
36
37
|
source?: string;
|
|
37
38
|
ask?: string;
|
|
38
39
|
ruleNo?: number;
|
package/types/checkpick.d.ts
CHANGED
|
@@ -62,6 +62,13 @@ export function rowsFromAnswer(scoped: {
|
|
|
62
62
|
check: Record<string, any> | null;
|
|
63
63
|
why: string | null;
|
|
64
64
|
}[];
|
|
65
|
+
/**
|
|
66
|
+
* The check CODE proposes for a count rule when the call yields none: a bullets / list-items / points count -> listItems N, a lines count -> maxLines N, ONE word number ->
|
|
67
|
+
* 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 is
|
|
68
|
+
* not built either; a rule with several word numbers or a range is not guessed. The result passes `keepOrDrop`, so every number is one the rule names.
|
|
69
|
+
* @param {string} text @returns {Record<string, any>|null}
|
|
70
|
+
*/
|
|
71
|
+
export function countCheck(text: string): Record<string, any> | null;
|
|
65
72
|
/**
|
|
66
73
|
* The asks for the rows: `Line n, guardrail "<…>": I propose <check in plain words>.` for a kept check, `Line n, guardrail "<…>": I can't check this. Your own words, or
|
|
67
74
|
* Not checked?` when nothing was kept. A proposal is not counted toward am1's cap; a can't-check ask is (am16 (5)).
|
|
@@ -112,10 +119,37 @@ export function applyPicks(declaration: any, rules: ReturnType<typeof scopedRule
|
|
|
112
119
|
line: number;
|
|
113
120
|
reason: "person-left" | "own-words" | "no-pick";
|
|
114
121
|
}) => string): any;
|
|
122
|
+
/**
|
|
123
|
+
* M10 am27 (4) RETENTION record of one draft (record only, counts, no words). Per job line: `aiParts` = the cited facts the drafter wrote on that line (a `cited` close counts once per
|
|
124
|
+
* fact, at least 1), `kept` = how many are still in the final declaration, `dropped` = what code removed, `picks` = the line has the person's picks; `classAsked` / `classFinal`
|
|
125
|
+
* = the line's close class as the drafter sent it and as it ended. Pure.
|
|
126
|
+
* @param {any} drafted the declaration as the drafter sent it @param {any} final the declaration the draft ended with @param {any[]|null|undefined} jobLines @param {Iterable<number>} [pickLines]
|
|
127
|
+
* @returns {{line: number, aiParts: number, kept: number, dropped: number, picks: boolean, classAsked: string|null, classFinal: string|null}[]}
|
|
128
|
+
*/
|
|
129
|
+
export function retentionOf(drafted: any, final: any, jobLines: any[] | null | undefined, pickLines?: Iterable<number>): {
|
|
130
|
+
line: number;
|
|
131
|
+
aiParts: number;
|
|
132
|
+
kept: number;
|
|
133
|
+
dropped: number;
|
|
134
|
+
picks: boolean;
|
|
135
|
+
classAsked: string | null;
|
|
136
|
+
classFinal: string | null;
|
|
137
|
+
}[];
|
|
115
138
|
/** the one tool the suggestion call is forced to use */
|
|
116
139
|
export const SUGGEST_TOOL: "suggest_checks";
|
|
117
140
|
export function hasRoutingInput(sources: any[] | undefined): boolean;
|
|
118
141
|
export function codeScope(sources: any[] | undefined, g: string): "in" | "out";
|
|
142
|
+
export function offerRules(lines: {
|
|
143
|
+
n: number;
|
|
144
|
+
guardrail?: string;
|
|
145
|
+
}[], arbiter: any, facts: {
|
|
146
|
+
line: number;
|
|
147
|
+
forRule?: number;
|
|
148
|
+
}[]): {
|
|
149
|
+
line: number;
|
|
150
|
+
rule: number;
|
|
151
|
+
text: string;
|
|
152
|
+
}[];
|
|
119
153
|
export const SUGGEST_SYSTEM: string;
|
|
120
154
|
/** the forced tool's parameter schema: one `anyOf` variant per offered rule, plus `none` */
|
|
121
155
|
export const SUGGEST_SCHEMA: Readonly<{
|
|
@@ -134,6 +168,7 @@ export const SUGGEST_SCHEMA: Readonly<{
|
|
|
134
168
|
}>;
|
|
135
169
|
/** the can't-check ask, as the signed words say it */
|
|
136
170
|
export const CANT_CHECK_WORDS: "I can't check this. Your own words, or Not checked?";
|
|
171
|
+
export function HOW_TO_ANSWER(line: number, agree: boolean): string;
|
|
137
172
|
/**
|
|
138
173
|
* `check` = the check the person agreed to (null for their own words); `added` = the `~` rule the answer wrote on the line; `own` = their own words
|
|
139
174
|
*/
|
package/types/checkwords.d.ts
CHANGED
|
@@ -12,3 +12,7 @@ export function plainWords(c: {
|
|
|
12
12
|
}): string;
|
|
13
13
|
/** the rules of bareguard's list a person may pick here (text rules only: the ones a plain answer can be judged by) */
|
|
14
14
|
export const OFFERED: readonly string[];
|
|
15
|
+
/** M10 am22 (4): who added a check, the ONE place these two words live. The plan card, the Job tab and the Audit trail write them after the check's words. */
|
|
16
|
+
export const LABEL_AGENT: "[agent]";
|
|
17
|
+
export const LABEL_PICKED: "[you picked]";
|
|
18
|
+
export function labelled(text: string, by: "agent" | "picked"): string;
|
package/types/citedcheck.d.ts
CHANGED
|
@@ -57,6 +57,12 @@ export function citedBrief(part: any): {
|
|
|
57
57
|
eachResultHolds: string[];
|
|
58
58
|
howMany: string | null;
|
|
59
59
|
};
|
|
60
|
+
/**
|
|
61
|
+
* M10 am28: what a page-quoting step is told about the picks (am22) on its line, one plain line per pick, the values and what counts, never a verdict and never
|
|
62
|
+
* another guardrail. A list item is what bareguard's listItems counts: its own line starting with "1." or "- " followed by a space and its text.
|
|
63
|
+
* @param {any[]} picked @returns {string[]}
|
|
64
|
+
*/
|
|
65
|
+
export function toldPicks(picked: any[]): string[];
|
|
60
66
|
/**
|
|
61
67
|
* Every plan-card row a fact part carries: its facts, then its count (bareloop's factRows).
|
|
62
68
|
* @param {any} part @returns {string[]}
|
package/types/closers.d.ts
CHANGED
|
@@ -71,7 +71,7 @@ export function renderSoftgreenGaps(gaps: any[], shape: {
|
|
|
71
71
|
* Async because bareguard's `checkStep` is.
|
|
72
72
|
*
|
|
73
73
|
* @param {any} artifact
|
|
74
|
-
* @param {{ maxWords?: number, sections?: string[], wordsPerSection?: number, linesPerInvoice?: number, mustCarry?: string[] }} shape
|
|
74
|
+
* @param {{ maxWords?: number, sections?: string[], wordsPerSection?: number, linesPerInvoice?: number, mustCarry?: string[], picked?: any[] }} shape
|
|
75
75
|
* @returns {Promise<CloseVerdict>}
|
|
76
76
|
*/
|
|
77
77
|
export function closeSoftgreen(artifact: any, shape: {
|
|
@@ -80,11 +80,12 @@ export function closeSoftgreen(artifact: any, shape: {
|
|
|
80
80
|
wordsPerSection?: number;
|
|
81
81
|
linesPerInvoice?: number;
|
|
82
82
|
mustCarry?: string[];
|
|
83
|
+
picked?: any[];
|
|
83
84
|
}): Promise<CloseVerdict>;
|
|
84
85
|
/**
|
|
85
86
|
* The one dispatcher — `close by declared class` (M2 scope item 4).
|
|
86
87
|
*
|
|
87
|
-
* @param {{ close?: { class?: string, shape?: Record<string, any>, cited?: any, columns?: {source: string, column: string}[], sheet?: any[] } }} step
|
|
88
|
+
* @param {{ close?: { class?: string, shape?: Record<string, any>, picked?: any[], cited?: any, columns?: {source: string, column: string}[], sheet?: any[] } }} step
|
|
88
89
|
* @param {unknown} artifact
|
|
89
90
|
* @param {{ reads: Record<string, any>, businessDate: string, source?: {ok: true, text: string, sha256: string}|{ok: false, red: string}|null, sheet?: any }} ctx
|
|
90
91
|
* `source` (M10 piece 4) = the run's own frozen copy a cited step reads, from `readRunSource`; only a step whose close carries `cited` reads it
|
|
@@ -95,6 +96,7 @@ export function closeByClass(step: {
|
|
|
95
96
|
close?: {
|
|
96
97
|
class?: string;
|
|
97
98
|
shape?: Record<string, any>;
|
|
99
|
+
picked?: any[];
|
|
98
100
|
cited?: any;
|
|
99
101
|
columns?: {
|
|
100
102
|
source: string;
|