bareloop 0.54.0 → 0.55.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 +83 -0
- package/bareloop.context.md +73 -12
- package/package.json +3 -3
- package/src/authorflow.js +148 -46
- package/src/authoring.js +21 -4
- package/src/authorjob.js +82 -3
- package/src/authorreadout.js +20 -3
- package/src/authorrun.js +1 -1
- package/src/authorscout.js +9 -6
- package/src/bridges.js +4 -3
- package/src/cardschedule.js +42 -0
- package/src/carrystore.js +1 -1
- package/src/checkpick.js +576 -0
- package/src/checksuggest.js +28 -0
- package/src/checkwords.js +25 -0
- package/src/cli.js +1 -1
- package/src/config.js +24 -1
- package/src/declaredclose.js +1 -1
- package/src/destpoint.js +149 -0
- package/src/draftspend.js +39 -0
- package/src/factwords.js +14 -1
- package/src/job.js +81 -1
- package/src/jobblock.js +9 -0
- package/src/labelscan.js +11 -0
- package/src/launcher.js +10 -6
- package/src/learn.js +6 -4
- package/src/mcpchecks.js +52 -0
- package/src/mcppick.js +36 -0
- package/src/mcpsources.js +77 -0
- package/src/mcpuse.js +97 -0
- package/src/natural.js +23 -0
- package/src/pagemap.js +5 -2
- package/src/panel/authorroutes.js +90 -15
- package/src/panel/authorsession.js +183 -21
- package/src/panel/index.html +686 -26
- package/src/panel/jobgrid.js +117 -0
- package/src/panel/jobplan.js +31 -15
- package/src/panel/scheduler.js +80 -13
- package/src/panel/schedules.js +189 -28
- package/src/panel/schedulestart.js +44 -13
- package/src/panel/server.js +438 -33
- package/src/panel/settingsroutes.js +133 -3
- package/src/panel/status.js +22 -2
- package/src/panel/tickets.js +44 -0
- package/src/pickrecord.js +145 -0
- package/src/plan.js +31 -2
- package/src/planrun.js +71 -15
- package/src/prcheckout.js +259 -0
- package/src/readshim.js +3 -2
- package/src/replay.js +6 -0
- package/src/reuse.js +3 -3
- package/src/revises.js +56 -0
- package/src/rubricstep.js +62 -16
- package/src/run.js +10 -1
- package/src/runexport.js +2 -0
- package/src/runlist.js +3 -2
- package/src/schedulewords.js +46 -4
- package/src/source.js +81 -7
- package/src/stepmcp.js +86 -0
- package/src/ticket.js +113 -0
- package/src/ticketfilter.js +76 -0
- package/src/ticketlabels.js +79 -0
- package/src/ticketmcp.js +111 -0
- package/src/ticketnext.js +35 -0
- package/src/ticketrepo.js +98 -0
- package/src/ticketschedule.js +32 -0
- package/src/ticketshape.js +45 -0
- package/src/tools.js +9 -0
- package/src/trigger.js +14 -2
- package/src/triggerclock.js +7 -3
- package/src/triggerfiles.js +19 -11
- package/src/triggertickets.js +244 -0
- package/src/u-readout.js +2 -2
- package/src/userrun.js +146 -10
- package/src/validate.js +3 -1
- package/src/worktree.js +43 -1
- package/types/authorflow.d.ts +128 -28
- package/types/authorjob.d.ts +16 -3
- package/types/authorreadout.d.ts +9 -2
- package/types/authorscout.d.ts +4 -2
- package/types/bridges.d.ts +4 -3
- package/types/cardschedule.d.ts +24 -0
- package/types/checkpick.d.ts +297 -0
- package/types/checksuggest.d.ts +30 -0
- package/types/checkwords.d.ts +14 -0
- package/types/config.d.ts +7 -0
- package/types/destpoint.d.ts +87 -0
- package/types/draftspend.d.ts +16 -0
- package/types/factwords.d.ts +7 -0
- package/types/job.d.ts +13 -0
- package/types/jobblock.d.ts +9 -0
- package/types/labelscan.d.ts +7 -0
- package/types/launcher.d.ts +7 -2
- package/types/mcpchecks.d.ts +8 -0
- package/types/mcppick.d.ts +33 -0
- package/types/mcpsources.d.ts +51 -0
- package/types/mcpuse.d.ts +15 -0
- package/types/natural.d.ts +2 -0
- package/types/pagemap.d.ts +2 -1
- package/types/panel/authorroutes.d.ts +11 -2
- package/types/panel/authorsession.d.ts +58 -3
- package/types/panel/jobgrid.d.ts +405 -0
- package/types/panel/jobplan.d.ts +10 -4
- package/types/panel/scheduler.d.ts +7 -2
- package/types/panel/schedules.d.ts +124 -4
- package/types/panel/schedulestart.d.ts +21 -3
- package/types/panel/server.d.ts +427 -6
- package/types/panel/settingsroutes.d.ts +4 -2
- package/types/panel/status.d.ts +16 -2
- package/types/panel/tickets.d.ts +61 -0
- package/types/pickrecord.d.ts +88 -0
- package/types/plan.d.ts +1 -0
- package/types/prcheckout.d.ts +151 -0
- package/types/readshim.d.ts +4 -3
- package/types/replay.d.ts +3 -0
- package/types/reuse.d.ts +2 -2
- package/types/revises.d.ts +23 -0
- package/types/rubricstep.d.ts +14 -5
- package/types/run.d.ts +18 -1
- package/types/runlist.d.ts +6 -3
- package/types/schedulewords.d.ts +29 -2
- package/types/source.d.ts +40 -4
- package/types/stepmcp.d.ts +40 -0
- package/types/ticket.d.ts +114 -0
- package/types/ticketfilter.d.ts +34 -0
- package/types/ticketlabels.d.ts +44 -0
- package/types/ticketmcp.d.ts +84 -0
- package/types/ticketnext.d.ts +33 -0
- package/types/ticketrepo.d.ts +118 -0
- package/types/ticketschedule.d.ts +21 -0
- package/types/ticketshape.d.ts +37 -0
- package/types/tools.d.ts +1 -0
- package/types/trigger.d.ts +9 -1
- package/types/triggerclock.d.ts +6 -2
- package/types/triggerfiles.d.ts +13 -5
- package/types/triggertickets.d.ts +110 -0
- package/types/userrun.d.ts +50 -0
- package/types/validate.d.ts +1 -0
- package/types/worktree.d.ts +19 -0
package/src/authorflow.js
CHANGED
|
@@ -87,11 +87,13 @@ import {
|
|
|
87
87
|
import { buildSeedListing, cleanEntry, SURVEY_CAUSES, AUTHOR_CALL_TIMEOUT_MS } from './authorscout.js';
|
|
88
88
|
import { extractArtifact, priceOf, scrubRaw, tallyCalls, capStop, callCasualty } from './text.js';
|
|
89
89
|
import { redactSecrets } from './validate.js';
|
|
90
|
+
import { applyPicks, dropExtras, fillAndMergeFacts, moveUncheckable, retentionOf, settleRules } from './checkpick.js';
|
|
90
91
|
import { stepFileContract, inputLabelsOf, stepFileRel, readFrozenInputs, withFactBindings, settlePersonsWords, withDropNotes, lineRules } from './rubricstep.js';
|
|
91
92
|
import { dropRows, dropLine } from './pagedropwords.js';
|
|
92
93
|
import { factShapeGuide } from './facts.js';
|
|
93
|
-
import { renderLookReport
|
|
94
|
-
import { checkDeclarationWords } from './factwords.js';
|
|
94
|
+
import { renderLookReport } from './inputlook.js';
|
|
95
|
+
import { checkDeclarationWords, labelListsFor } from './factwords.js';
|
|
96
|
+
import { ticketFilterReds, ticketFilterBlock, ticketPerRunFacts, TICKET_FILTER_SCHEMA_WORDS } from './ticketfilter.js';
|
|
95
97
|
|
|
96
98
|
const require = createRequire(import.meta.url);
|
|
97
99
|
const { Loop } = require('bare-agent');
|
|
@@ -830,10 +832,8 @@ export const PARAM_SCHEMAS = Object.freeze({
|
|
|
830
832
|
properties: {
|
|
831
833
|
text: { type: 'string', minLength: 1, description: 'the constraint, in the person\'s own words' },
|
|
832
834
|
class: { enum: ['countable', 'fact', 'judged', 'guard', 'none'] },
|
|
833
|
-
check: { enum: ['
|
|
834
|
-
value: { type: 'integer', minimum: 1, description: '
|
|
835
|
-
names: { type: 'array', minItems: 1, items: { type: 'string', minLength: 1 }, description: 'sections / sectionWords: the section names' },
|
|
836
|
-
wordsPerSection: { type: 'integer', minimum: 1 },
|
|
835
|
+
check: { enum: ['cited', 'minClaims', 'maxClaims'], description: 'countable only; minClaims / maxClaims count the claims listed under the input named in source' },
|
|
836
|
+
value: { type: 'integer', minimum: 1, description: 'minClaims / maxClaims: the number of claims asked for' },
|
|
837
837
|
source: { type: 'string', minLength: 1, description: 'cited: the label of the input a quote must come from' },
|
|
838
838
|
domains: { type: 'array', minItems: 1, items: { type: 'string', minLength: 1 }, description: 'guard only: the web domains the rule is about' },
|
|
839
839
|
covers: { type: 'array', minItems: 1, uniqueItems: true, items: { type: 'integer', minimum: 1 }, description: 'the number(s) of the CONFIRMED check(s) this part carries out' },
|
|
@@ -940,9 +940,10 @@ export function schemaCoverage(catalogue = KIND_CATALOGUE) {
|
|
|
940
940
|
* `kinds` (Part 1a) narrows the branches to the kinds a language may use (`catalogueForLang`) WITHOUT narrowing the coverage check,
|
|
941
941
|
* which stays over the whole catalogue; null (the default) = no narrowing.
|
|
942
942
|
* @param {Record<string, any>} [catalogue]
|
|
943
|
-
*
|
|
943
|
+
* `ticket` (MCP + tickets piece 2) adds the optional top-level `ticketFilter` property for a job that reads tickets; absent, the schema is byte-identical.
|
|
944
|
+
* @param {{verdictType?: string|null, questions?: boolean, kinds?: string[]|null, ticket?: boolean}} [o]
|
|
944
945
|
*/
|
|
945
|
-
export function declarationSchema(catalogue = KIND_CATALOGUE, { verdictType = null, questions = false, kinds = null } = {}) {
|
|
946
|
+
export function declarationSchema(catalogue = KIND_CATALOGUE, { verdictType = null, questions = false, kinds = null, ticket = false } = {}) {
|
|
946
947
|
const cov = schemaCoverage(catalogue);
|
|
947
948
|
if (!cov.ok) {
|
|
948
949
|
throw new Error('[authorflow] the declaration schema does not cover the catalogue — '
|
|
@@ -1016,6 +1017,17 @@ export function declarationSchema(catalogue = KIND_CATALOGUE, { verdictType = nu
|
|
|
1016
1017
|
},
|
|
1017
1018
|
description: 'optional: which job lines the always-on guards already cover (a line whose every ask a mandatory guard checks needs no stage of its own)',
|
|
1018
1019
|
},
|
|
1020
|
+
...(ticket ? {
|
|
1021
|
+
ticketFilter: {
|
|
1022
|
+
type: 'object',
|
|
1023
|
+
properties: {
|
|
1024
|
+
priority: { type: 'array', items: { type: 'string', enum: ['P0', 'P1', 'P2', 'P3'] }, description: 'priorities a ticket must have; only when a job line names them' },
|
|
1025
|
+
labels: { type: 'array', items: { type: 'string' }, description: 'label names, one of which a ticket must carry; only when a job line names them' },
|
|
1026
|
+
},
|
|
1027
|
+
additionalProperties: false,
|
|
1028
|
+
description: TICKET_FILTER_SCHEMA_WORDS,
|
|
1029
|
+
},
|
|
1030
|
+
} : {}),
|
|
1019
1031
|
...(questions ? {
|
|
1020
1032
|
questions: {
|
|
1021
1033
|
type: 'array',
|
|
@@ -1037,13 +1049,13 @@ export function declarationSchema(catalogue = KIND_CATALOGUE, { verdictType = nu
|
|
|
1037
1049
|
* The output channel. It records and acknowledges; it takes no action, which is
|
|
1038
1050
|
* why handing it to a toolless authoring call does not reopen D3.
|
|
1039
1051
|
* @param {{calls: any[]}} box
|
|
1040
|
-
* @param {{catalogue?: Record<string, any>, verdictType?: string|null, questions?: boolean, kinds?: string[]|null}} [o]
|
|
1052
|
+
* @param {{catalogue?: Record<string, any>, verdictType?: string|null, questions?: boolean, kinds?: string[]|null, ticket?: boolean}} [o]
|
|
1041
1053
|
*/
|
|
1042
|
-
export function declarationTool(box, { catalogue = KIND_CATALOGUE, verdictType = null, questions = false, kinds = null } = {}) {
|
|
1054
|
+
export function declarationTool(box, { catalogue = KIND_CATALOGUE, verdictType = null, questions = false, kinds = null, ticket = false } = {}) {
|
|
1043
1055
|
return {
|
|
1044
1056
|
name: DECLARATION_TOOL_NAME,
|
|
1045
1057
|
description: 'Deliver the finished close. Call this exactly once, with the whole declaration as its arguments.',
|
|
1046
|
-
parameters: declarationSchema(catalogue, { verdictType, questions, kinds }),
|
|
1058
|
+
parameters: declarationSchema(catalogue, { verdictType, questions, kinds, ticket }),
|
|
1047
1059
|
execute: async (/** @type {any} */ args) => { box.calls.push(args); return DECLARATION_ACK; },
|
|
1048
1060
|
};
|
|
1049
1061
|
}
|
|
@@ -1310,7 +1322,7 @@ export function jobLineTagBlock(count, guardNames = []) {
|
|
|
1310
1322
|
* writeScope?: string[]|null,
|
|
1311
1323
|
* jobLines?: {n: number}[]|null, inputs?: {n: number, label: string, value: string}[]|null,
|
|
1312
1324
|
* confirmed?: {checks: string[], checkItems?: {text: string, fromLine: number[]|null}[], protections: string[], openQuestions?: string[], notChecked?: string[], answeredQuestions?: string[]}|null,
|
|
1313
|
-
* labelLists?: string[]|null,
|
|
1325
|
+
* labelLists?: string[]|null, settled?: {line: number, rule: number, text: string}[]|null,
|
|
1314
1326
|
* }} o
|
|
1315
1327
|
*/
|
|
1316
1328
|
export function authorPrompt({
|
|
@@ -1325,13 +1337,15 @@ export function authorPrompt({
|
|
|
1325
1337
|
confirmed = null,
|
|
1326
1338
|
// PART 1c: the label lists code made from the frozen inputs (src/labelscan.js `renderLabelList`); a label is picked from them
|
|
1327
1339
|
labelLists = null,
|
|
1340
|
+
// R10: the `~` rules code settles from the person's own picks (src/checkpick.js); ABSENT = byte-identical prompt
|
|
1341
|
+
settled = null,
|
|
1328
1342
|
}) {
|
|
1329
1343
|
// PART 1a: a rubric job on the person's own local files has no repository, no genre template and no tool to measure with —
|
|
1330
1344
|
// it gets its own brief (`rubricAuthorPrompt`), which still ends in the same declaration tool and the same guards
|
|
1331
1345
|
// an absent catalogue is the language's own menu (`catalogueForLang`), so a code job's prompt never lists a rubric-only kind
|
|
1332
1346
|
const catalogue = catalogueIn ?? catalogueForLang(lang);
|
|
1333
1347
|
if (lang === RUBRIC_LANG) {
|
|
1334
|
-
return rubricAuthorPrompt({ answers, questions, facts, listingBlock, verdictType, guards, mode, catalogue, writeScope, jobLines, inputs, confirmed, labelLists });
|
|
1348
|
+
return rubricAuthorPrompt({ answers, questions, facts, listingBlock, verdictType, guards, mode, catalogue, writeScope, jobLines, inputs, confirmed, labelLists, settled });
|
|
1335
1349
|
}
|
|
1336
1350
|
const statement = CLASS_STATEMENTS[String(verdictType)] ?? null;
|
|
1337
1351
|
if (statement === null) {
|
|
@@ -1467,6 +1481,18 @@ export const RUBRIC_RULES = 'THE RULES FOR TURNING THE PERSON\'S WORDS INTO CHEC
|
|
|
1467
1481
|
+ '(the x-number beside it). A label counted fewer times is on the page once or twice (a sort tab, a switch) and is refused at $0 with its count.\n'
|
|
1468
1482
|
+ ' - The same holds for the words a "must say" (phrase) fact makes each quote say: they must be in the input at least N times for N results. Words counted fewer times (page-header words like "from San Francisco" when each result says "Leaves San Francisco International Airport") are refused at $0 with their count; pick words every result says, or drop the check.';
|
|
1469
1483
|
|
|
1484
|
+
/**
|
|
1485
|
+
* R10: the `~` rules code settles from the person's own picks, as the composer is told them. The drafter writes no check for these and lists nothing for them under
|
|
1486
|
+
* "refused": code puts the picked check, or the Not checked row, on the stage itself.
|
|
1487
|
+
* @param {{line: number, rule: number, text: string}[]} settled @returns {string}
|
|
1488
|
+
*/
|
|
1489
|
+
export function settledBlock(settled) {
|
|
1490
|
+
return 'SETTLED BY CODE - the person picked how these ~ rules are checked\n\n'
|
|
1491
|
+
+ settled.map((r) => `- line ${r.line}, ~ rule ${r.rule}: "${r.text}"`).join('\n')
|
|
1492
|
+
+ '\n\nFor these rules code writes the check the person picked, or the Not checked row, itself: write NO part and NO "refused" entry for them. '
|
|
1493
|
+
+ 'You never write a word, section, line, list-item or phrase count part (maxWords, minWords, maxLines, listItems, sections, sectionOrder, sectionWords, mustCarry, blockLines, nonEmpty) for any rule: only code does.';
|
|
1494
|
+
}
|
|
1495
|
+
|
|
1470
1496
|
/**
|
|
1471
1497
|
* REQUIRED FACTS, as the composer is told them (PART 1b, PRD item 33 RF1–RF17). The shape of the fact part is in the catalogue and the
|
|
1472
1498
|
* schema; this is the judgement the schema cannot carry: what becomes a fact, where its words come from, and what is Not checked.
|
|
@@ -1495,9 +1521,11 @@ export const REQUIRED_FACTS_BRIEF = 'REQUIRED FACTS — what a line that finds,
|
|
|
1495
1521
|
+ 'anything else you cannot express as a shape and a rule ("the cheapest", "the best", "a good pick") is NOT CHECKED: list it in "refused" as {"line": N, "rule": the number of that ~ rule, "reason": the '
|
|
1496
1522
|
+ 'person\'s own words}. EVERY ~ rule of a line must be carried out by a part (list its number in the part\'s "rules", 1 = the first ~ '
|
|
1497
1523
|
+ 'rule under the line) or be listed in "refused"; a rule that is neither is refused at $0.\n'
|
|
1498
|
-
+ ' - A line that WRITES (a summary, a report)
|
|
1524
|
+
+ ' - A line that WRITES (a summary, a report) needs no part for a word, section, line, list-item or phrase count: code adds the checks the person picked for it. Code ties its numbers to the facts of the lines '
|
|
1499
1525
|
+ 'before it; you do not add that.\n'
|
|
1500
1526
|
+ ' - A look fact that says "carries ~ rule N" is how the look carried that rule: put N in the fact part\'s "rules" and do not also list rule N in "refused".\n'
|
|
1527
|
+
+ ' - A line has ONE fact part. A look fact that carries a ~ rule goes INSIDE the line\'s one fact part (add its rule number to that part\'s "rules" and its fact to "facts"), never as a fact part of its own: two fact parts on one line are refused at $0. '
|
|
1528
|
+
+ 'A count of words, bullets or list items the person picked is a pick, not a "count" on the fact part; "count" is only how many results were asked for.\n'
|
|
1501
1529
|
+ ' - A ~ rule that you carry out as a fact (a limit on a time, a price, a date: "not a red-eye" is a time fact with a between rule) is carried by the '
|
|
1502
1530
|
+ 'fact part: list its number in that part\'s "rules". It is NOT also a part of its own: on a line that lists facts, a part of class judged or none '
|
|
1503
1531
|
+ 'is refused. A rule you cannot express as a shape and a rule goes in "refused", never into a part.\n'
|
|
@@ -1515,13 +1543,13 @@ export const REQUIRED_FACTS_BRIEF = 'REQUIRED FACTS — what a line that finds,
|
|
|
1515
1543
|
* verdictType: string, guards: {name: string, kind: string, params: Record<string, any>, fill: string[]}[],
|
|
1516
1544
|
* mode?: 'tool'|'text', catalogue?: Record<string, any>, writeScope?: string[]|null,
|
|
1517
1545
|
* jobLines?: {n: number}[]|null, inputs?: {n: number, label: string, value: string}[]|null, confirmed?: any,
|
|
1518
|
-
* labelLists?: string[]|null,
|
|
1546
|
+
* labelLists?: string[]|null, settled?: {line: number, rule: number, text: string}[]|null,
|
|
1519
1547
|
* }} o
|
|
1520
1548
|
* @returns {string}
|
|
1521
1549
|
*/
|
|
1522
1550
|
export function rubricAuthorPrompt({
|
|
1523
1551
|
answers, questions = GREEN_QUESTIONS, facts, listingBlock, verdictType, guards,
|
|
1524
|
-
mode = 'tool', catalogue = KIND_CATALOGUE, writeScope = null, jobLines = null, inputs = null, confirmed = null, labelLists = null,
|
|
1552
|
+
mode = 'tool', catalogue = KIND_CATALOGUE, writeScope = null, jobLines = null, inputs = null, confirmed = null, labelLists = null, settled = null,
|
|
1525
1553
|
}) {
|
|
1526
1554
|
const interview = Object.entries(questions)
|
|
1527
1555
|
.map(([n, q]) => `Q${n}. ${q}\nA${n}. ${answers?.[n] ?? '(no answer given)'}`)
|
|
@@ -1571,6 +1599,7 @@ left as a placeholder. You never write a number the person did not ask for.`;
|
|
|
1571
1599
|
+ 'A confirmed check that no part covers is not silently left out: it is moved to Not checked before signing, and the person is told. '
|
|
1572
1600
|
+ 'To count "N things listed", use minClaims / maxClaims (it counts the claims listed under an input); anything else you cannot count is not composed.'] : []),
|
|
1573
1601
|
REQUIRED_FACTS_BRIEF,
|
|
1602
|
+
...(Array.isArray(settled) && settled.length ? [settledBlock(settled)] : []),
|
|
1574
1603
|
`THE STEP FILES — what the worker leaves behind for each job line\n\n${stepFileContract()}\n\n`
|
|
1575
1604
|
+ 'The rubric-step stage for job line N reads exactly that file, output/steps/N.json. It names the inputs (by label) the '
|
|
1576
1605
|
+ 'step must cite from, and the limits on its "text".',
|
|
@@ -1670,7 +1699,7 @@ export function renderRejectBlock({ kind, reds, cap = REVISE_RED_CAP }) {
|
|
|
1670
1699
|
const head = kind === 'validation'
|
|
1671
1700
|
? 'MEASURED VALIDATION — your declaration was rejected by the validator before any stage could run:'
|
|
1672
1701
|
: 'MEASURED PARSE — your reply could not be read as one declaration:';
|
|
1673
|
-
const rendered = (reds ?? []).map((r) => (typeof r === 'string' ? r : `${r.code} at ${r.path || '(root)'}: ${r.detail}`));
|
|
1702
|
+
const rendered = (reds ?? []).map((r) => (typeof r === 'string' ? r : `${r.code} at ${r.path || '(root)'}: ${r.detail}${typeof r.hint === 'string' ? ` ${r.hint}` : ''}`));
|
|
1674
1703
|
const shown = rendered.slice(0, cap);
|
|
1675
1704
|
const tail = rendered.length > shown.length
|
|
1676
1705
|
? [` [${rendered.length - shown.length} of ${rendered.length} reds withheld — the cap is ${cap}]`]
|
|
@@ -1841,7 +1870,7 @@ export function resolveSourcePrefixes({ workdir, sourcePaths, seedFiles }) {
|
|
|
1841
1870
|
*/
|
|
1842
1871
|
/**
|
|
1843
1872
|
* @param {{ceilingUsd?: number|null,
|
|
1844
|
-
* onCall?: (call: {label: string, costUsd: number|null, unpricedRounds: number, thinkingStatus?: string}) => void}} [o]
|
|
1873
|
+
* onCall?: (call: {label: string, costUsd: number|null, unpricedRounds: number, thinkingStatus?: string, raw?: string}) => void}} [o]
|
|
1845
1874
|
* `ceilingUsd` is the OPERATOR's ceiling; `null`/absent is UNBOUNDED.
|
|
1846
1875
|
* `onCall` is a REPORTING seam fired as each metered call lands — the shell's
|
|
1847
1876
|
* only chance to know what has been spent while the run is still alive. It is
|
|
@@ -1861,10 +1890,13 @@ export function makeCostBook({ ceilingUsd = null, onCall = () => {} } = {}) {
|
|
|
1861
1890
|
add(label, r, attempt = 1) {
|
|
1862
1891
|
const call = { label, ...priceOf(r) };
|
|
1863
1892
|
entries.push(call);
|
|
1864
|
-
|
|
1893
|
+
const kept = scrubRaw({ label, attempt, text: r?.text, reason: r?.error ? String(r.error) : null });
|
|
1894
|
+
raws.push(kept);
|
|
1865
1895
|
// bare-agent's per-run `thinkingStatus` ('applied' | 'unsupported' | 'ignored' | 'unknown') rides the REPORTING seam only —
|
|
1866
|
-
// never the stored entry, so the cost report and every persisted shape stay as they were; absent when thinkingMode was not sent
|
|
1867
|
-
|
|
1896
|
+
// never the stored entry, so the cost report and every persisted shape stay as they were; absent when thinkingMode was not sent.
|
|
1897
|
+
// R9 (Part B 4): the call's scrubbed answer rides the same seam (secret-masked and bounded by `scrubRaw`, the one mask owner), so the session's drafting log keeps what an
|
|
1898
|
+
// unusable draft try actually said; an empty answer (a tool-delivered reply) adds nothing
|
|
1899
|
+
onCall({ ...call, ...(kept.text === '' ? {} : { raw: kept.text }), ...(r?.thinkingStatus === undefined ? {} : { thinkingStatus: r.thinkingStatus }) });
|
|
1868
1900
|
return entries.at(-1);
|
|
1869
1901
|
},
|
|
1870
1902
|
/** @param {{label: string, costUsd: number|null, unpricedRounds: number}[]} calls
|
|
@@ -2089,12 +2121,12 @@ export async function askStructured({ messages, generate, mode, retries, label,
|
|
|
2089
2121
|
/** THE DECLARATION CHANNEL — the one this loop has always used. Its schema is
|
|
2090
2122
|
* CLASS-SCOPED, like the prompt's catalogue block: the two must offer one set of
|
|
2091
2123
|
* kinds, or the composer reads about a kind it cannot call.
|
|
2092
|
-
* @param {{catalogue: Record<string, any>, verdictType: string, questions?: boolean, kinds?: string[]|null}} o */
|
|
2093
|
-
const declarationChannel = ({ catalogue, verdictType, questions = false, kinds = null }) => ({
|
|
2124
|
+
* @param {{catalogue: Record<string, any>, verdictType: string, questions?: boolean, kinds?: string[]|null, ticket?: boolean}} o */
|
|
2125
|
+
const declarationChannel = ({ catalogue, verdictType, questions = false, kinds = null, ticket = false }) => ({
|
|
2094
2126
|
name: DECLARATION_TOOL_NAME,
|
|
2095
2127
|
instruction: STRUCTURE_INSTRUCTION_TOOL,
|
|
2096
2128
|
textPath: 'declaration',
|
|
2097
|
-
tool: (/** @type {{calls: any[]}} */ box) => declarationTool(box, { catalogue, verdictType, questions, kinds }),
|
|
2129
|
+
tool: (/** @type {{calls: any[]}} */ box) => declarationTool(box, { catalogue, verdictType, questions, kinds, ticket }),
|
|
2098
2130
|
});
|
|
2099
2131
|
|
|
2100
2132
|
/** The declaration ask, over the shared ladder. `declaration` is `artifact`
|
|
@@ -2102,11 +2134,11 @@ const declarationChannel = ({ catalogue, verdictType, questions = false, kinds =
|
|
|
2102
2134
|
* anonymous artifact, and one word for two things is how a reader loses which.
|
|
2103
2135
|
* @param {{messages: any[], generate: Function, mode: 'tool'|'text', retries: number,
|
|
2104
2136
|
* label: string, book: ReturnType<typeof makeCostBook>, catalogue: Record<string, any>,
|
|
2105
|
-
* verdictType: string, questions?: boolean, kinds?: string[]|null}} o
|
|
2137
|
+
* verdictType: string, questions?: boolean, kinds?: string[]|null, ticket?: boolean}} o
|
|
2106
2138
|
*/
|
|
2107
|
-
async function askDeclaration({ messages, generate, mode, retries, label, book, catalogue, verdictType, questions = false, kinds = null }) {
|
|
2139
|
+
async function askDeclaration({ messages, generate, mode, retries, label, book, catalogue, verdictType, questions = false, kinds = null, ticket = false }) {
|
|
2108
2140
|
const r = await askStructured({
|
|
2109
|
-
messages, generate, mode, retries, label, book, channel: declarationChannel({ catalogue, verdictType, questions, kinds }),
|
|
2141
|
+
messages, generate, mode, retries, label, book, channel: declarationChannel({ catalogue, verdictType, questions, kinds, ticket }),
|
|
2110
2142
|
});
|
|
2111
2143
|
return { ...r, declaration: r.artifact };
|
|
2112
2144
|
}
|
|
@@ -2282,9 +2314,10 @@ export const CONFIRM_SYSTEM = 'You read what a NON-ENGINEER answered, plus a rea
|
|
|
2282
2314
|
* @param {{answers: Record<string|number, string>, questions: Record<string|number, string>,
|
|
2283
2315
|
* labels?: Record<string|number, string>, facts?: any, listing?: string|null,
|
|
2284
2316
|
* writeScope?: string[]|null, isRepo: boolean, lang: string, worseThanBefore?: string,
|
|
2285
|
-
* fixText?: string|null, protections?: string[], inputs?: {n: number, label: string, value: string}[]|null
|
|
2317
|
+
* fixText?: string|null, protections?: string[], inputs?: {n: number, label: string, value: string}[]|null, ticket?: boolean,
|
|
2318
|
+
* settled?: {line: number, rule: number, text: string}[]|null}} o
|
|
2286
2319
|
*/
|
|
2287
|
-
export function confirmPrompt({ answers, questions, labels = {}, facts = null, listing = null, writeScope = null, isRepo, lang, worseThanBefore = '', fixText = null, protections = [], inputs = null }) {
|
|
2320
|
+
export function confirmPrompt({ answers, questions, labels = {}, facts = null, listing = null, writeScope = null, isRepo, lang, worseThanBefore = '', fixText = null, protections = [], inputs = null, ticket = false, settled = null }) {
|
|
2288
2321
|
const lines = ['THE PERSON\'S OWN ANSWERS (a non-engineer; read exactly what they wrote, invent nothing beyond it):'];
|
|
2289
2322
|
for (const k of Object.keys(questions)) {
|
|
2290
2323
|
const label = labels[k] ? ` (${labels[k]})` : '';
|
|
@@ -2299,6 +2332,10 @@ export function confirmPrompt({ answers, questions, labels = {}, facts = null, l
|
|
|
2299
2332
|
// PART 1a: a rubric job on the person's own text files. The model is told what a check CAN be here, so that anything
|
|
2300
2333
|
// needing judgement lands in `notChecked` instead of being promised as a check
|
|
2301
2334
|
if (lang === RUBRIC_LANG) lines.push('', RUBRIC_CONFIRM_NOTE);
|
|
2335
|
+
// R10: the `~` rules code settles from the person's own picks are not yours to plan: a check for them is code's, a gap is code's Not checked row
|
|
2336
|
+
if (Array.isArray(settled) && settled.length) lines.push('', `SETTLED BY CODE - the person picked how these ~ rules are checked; plan no check for them and list none under notChecked:\n${settled.map((/** @type {any} */ r) => ` - line ${r.line}: "${r.text}"`).join('\n')}`);
|
|
2337
|
+
// MCP + tickets R5 (F285): a Tickets job's confirm turn is told the ticket is picked per run and a priority/label line is code's, so it never asks the person which ticket
|
|
2338
|
+
if (ticket) lines.push('', ticketPerRunFacts());
|
|
2302
2339
|
if (writeScope) lines.push(`WRITE SCOPE (the fence — the run may write only here): ${writeScope.join(', ')}`);
|
|
2303
2340
|
if (protections.length > 0) {
|
|
2304
2341
|
lines.push(
|
|
@@ -2352,7 +2389,7 @@ async function askConfirmPlan({ convo, generate, mode, book, label }) {
|
|
|
2352
2389
|
* ask: (step: {kind: string, [k: string]: any}) => Promise<string|null>,
|
|
2353
2390
|
* onPhase?: (phase: string, data?: any) => void, mode?: 'tool'|'text',
|
|
2354
2391
|
* worseThanBefore?: string, inputs?: {n: number, label: string, value: string}[]|null,
|
|
2355
|
-
* jobLines?: {n: number}[]|null}} o retired field (hamr's ruling 2026-09-28):
|
|
2392
|
+
* jobLines?: {n: number}[]|null, ticket?: boolean, settled?: {line: number, rule: number, text: string}[]|null}} o retired field (hamr's ruling 2026-09-28):
|
|
2356
2393
|
* `worseThanBefore` is never asked any more and defaults to `''` — a
|
|
2357
2394
|
* caller may still pass a string through (kept for a future, non-ask
|
|
2358
2395
|
* source of the same constraint), it just never comes from an ask() step.
|
|
@@ -2376,6 +2413,10 @@ export async function runConfirmTurn({
|
|
|
2376
2413
|
inputs = null,
|
|
2377
2414
|
// PART 1a: the numbered job lines, so a rubric job's per-line file protections are listed from code
|
|
2378
2415
|
jobLines = null,
|
|
2416
|
+
// MCP + tickets R5 (F285): the job reads tickets; absent = the confirm prompt is byte-identical
|
|
2417
|
+
ticket = false,
|
|
2418
|
+
// R10: the `~` rules settled by the person's picks (src/checkpick.js); ABSENT = the confirm prompt is byte-identical
|
|
2419
|
+
settled = null,
|
|
2379
2420
|
}) {
|
|
2380
2421
|
/** @typedef {null|'cap-halt'|'pricing-red'|'provider-red'|'artifact-red'|'confirm-abandoned'|'confirm-restart'} ConfirmStop */
|
|
2381
2422
|
/** @returns {{ok: boolean, stop: ConfirmStop, rounds: number, accepted: null, reds: Red[], cost: any}} */
|
|
@@ -2446,14 +2487,14 @@ export async function runConfirmTurn({
|
|
|
2446
2487
|
let convo = [{
|
|
2447
2488
|
role: 'user',
|
|
2448
2489
|
content: confirmPrompt({
|
|
2449
|
-
answers, questions, labels, facts, listing, writeScope, isRepo, lang: resolvedLang, worseThanBefore, protections, inputs,
|
|
2490
|
+
answers, questions, labels, facts, listing, writeScope, isRepo, lang: resolvedLang, worseThanBefore, protections, inputs, ticket, settled,
|
|
2450
2491
|
}),
|
|
2451
2492
|
}];
|
|
2452
2493
|
|
|
2453
2494
|
for (let round = 1; round <= 2; round += 1) {
|
|
2454
2495
|
if (fixText) {
|
|
2455
2496
|
convo = [...convo, { role: 'user', content: confirmPrompt({
|
|
2456
|
-
answers, questions, labels, facts, listing, writeScope, isRepo, lang: resolvedLang, worseThanBefore, fixText, protections, inputs,
|
|
2497
|
+
answers, questions, labels, facts, listing, writeScope, isRepo, lang: resolvedLang, worseThanBefore, fixText, protections, inputs, ticket, settled,
|
|
2457
2498
|
}) }];
|
|
2458
2499
|
}
|
|
2459
2500
|
onPhase('confirm-round', { round });
|
|
@@ -2556,6 +2597,22 @@ export async function runConfirmTurn({
|
|
|
2556
2597
|
throw new Error('[authorflow] runConfirmTurn fell through its 2-round cap without returning');
|
|
2557
2598
|
}
|
|
2558
2599
|
|
|
2600
|
+
/**
|
|
2601
|
+
* PRD v1.131 tick 4 (rubric jobs, the LAST try only; the caller gates both): the last try failed the gate, so the AI's own broken parts are dropped to Not checked (`dropExtras`) and the plan
|
|
2602
|
+
* is bound and checked ONCE more with the same gate (`redo`). Returns the new settled declaration and its result when that passes; `null` = nothing dropped, the plan is refused as today (the
|
|
2603
|
+
* try passed already, a red sits on a part the picks built or on no part, or the re-check is still red).
|
|
2604
|
+
* @param {{pre: any, v: {ok: boolean, reds: any[]}, jobLines: any[]|null|undefined, redo: (d: any) => any}} o
|
|
2605
|
+
* @returns {{pre: any, v: any}|null}
|
|
2606
|
+
*/
|
|
2607
|
+
export function dropAfterLastTry({ pre, v, jobLines, redo }) {
|
|
2608
|
+
if (v.ok) return null;
|
|
2609
|
+
const out = dropExtras(pre, v.reds, jobLines);
|
|
2610
|
+
if ('refused' in out) return null;
|
|
2611
|
+
const next = withFactBindings(out.declaration);
|
|
2612
|
+
const again = redo(next);
|
|
2613
|
+
return again.ok ? { pre: next, v: again } : null;
|
|
2614
|
+
}
|
|
2615
|
+
|
|
2559
2616
|
/**
|
|
2560
2617
|
* THE AUTHORING FLOW.
|
|
2561
2618
|
*
|
|
@@ -2602,7 +2659,7 @@ export async function runConfirmTurn({
|
|
|
2602
2659
|
* priorCalls?: {label: string, costUsd: number|null, unpricedRounds: number}[]|null,
|
|
2603
2660
|
* priorRaws?: any[]|null,
|
|
2604
2661
|
* jobLines?: {n: number, text: string}[]|null, inputs?: {n: number, label: string, value: string}[]|null,
|
|
2605
|
-
* offerQuestions?: boolean,
|
|
2662
|
+
* offerQuestions?: boolean, ticket?: boolean, checkPicks?: {rules: {line: number, rule: number, text: string}[], picks: any[], left: {line: number, rule: number}[]}|null,
|
|
2606
2663
|
* confirmed?: {checks: string[], checkItems?: {text: string, fromLine: number[]|null}[], protections: string[], openQuestions?: string[], notChecked?: string[], answeredQuestions?: string[]}|null}} o
|
|
2607
2664
|
*/
|
|
2608
2665
|
export async function authorClose({
|
|
@@ -2644,6 +2701,11 @@ export async function authorClose({
|
|
|
2644
2701
|
// full drafting ladder (the author call plus both revisions), and only after the two before it both failed validation,
|
|
2645
2702
|
// is offered the optional `questions` property — see `askOpen` below. Absent = byte-identical to today.
|
|
2646
2703
|
offerQuestions = false,
|
|
2704
|
+
// MCP + tickets piece 2 (R5): the job reads tickets, so the drafter is told about the ticket filter, the schema offers the optional `ticketFilter` property and a proposal is
|
|
2705
|
+
// checked by the one reader (src/ticketfilter.js). ABSENT = every other job: prompt, schema and validation byte-identical.
|
|
2706
|
+
ticket = false,
|
|
2707
|
+
// R10 (fwd am16): the person's check picks for the `~` rules code settled, `{rules, picks, left, jobLines}`. ABSENT = every other caller: the declaration is validated as drafted.
|
|
2708
|
+
checkPicks = null,
|
|
2647
2709
|
}) {
|
|
2648
2710
|
// PART 1a: the menu this close may draw from — a rubric job on local files sees its own two kinds, a code job never sees
|
|
2649
2711
|
// the rubric-only ones (`catalogueForLang`). Everything below (prompt, schema, validator, env) reads THIS one catalogue.
|
|
@@ -2815,15 +2877,35 @@ export async function authorClose({
|
|
|
2815
2877
|
let labelLists = null;
|
|
2816
2878
|
if (lang === RUBRIC_LANG && Array.isArray(inputs) && inputs.length > 0) {
|
|
2817
2879
|
const frozen = await readFrozenInputs(workdir, inputs.map((i) => i.label));
|
|
2818
|
-
if (frozen.ok) { inputTexts = frozen.texts; labelLists =
|
|
2880
|
+
if (frozen.ok) { inputTexts = frozen.texts; labelLists = labelListsFor(frozen.texts, facts?.look ?? null); }
|
|
2819
2881
|
}
|
|
2882
|
+
// R10: the picks settled against the lines as they stand now (the answers are already `~` rules on them); the draft carries exactly these checks and these Not checked rows
|
|
2883
|
+
const settledPicks = checkPicks ? settleRules(checkPicks.rules, checkPicks.picks, checkPicks.left, jobLines ?? []) : null;
|
|
2884
|
+
// a rubric job only: what no rule can check goes under Not checked before the picks are applied (every other kind of job keeps its reds)
|
|
2885
|
+
// then (rubric only) a one-input job's missing source is filled and a line's several fact parts are merged into one when that is safe, after the picks' count strip
|
|
2886
|
+
const picked = (/** @type {any} */ d) => fillAndMergeFacts(applyPicks(moveUncheckable(d, jobLines ?? [], lang === RUBRIC_LANG), settledPicks), inputLabelsOf(inputs), lang === RUBRIC_LANG);
|
|
2820
2887
|
const prompt = authorPrompt({
|
|
2821
2888
|
answers, questions, facts, listingBlock: /** @type {string} */ (seeds.block),
|
|
2822
2889
|
lang, verdictType, guards, ownedEnvNames, mode: structuredMode, catalogue, writeScope, confirmed, jobLines, inputs,
|
|
2823
|
-
labelLists,
|
|
2824
|
-
});
|
|
2890
|
+
labelLists, ...(checkPicks ? { settled: checkPicks.rules } : {}),
|
|
2891
|
+
}) + (ticket ? `\n\n${ticketFilterBlock()}` : '');
|
|
2892
|
+
// the draft gate on one settled declaration: validation, then (PART 1c, rubric) code proves, at $0, that every label is PICKED from the input's own list and every word a fact depends
|
|
2893
|
+
// on is really in the source (white-space blind, once is enough). A word that is not found is a red naming the word and the input; the drafter revises like it does for any validation red.
|
|
2894
|
+
const checkDraft = (/** @type {any} */ d) => {
|
|
2895
|
+
let r = validateDeclaration(d, { catalogue, listing: seedFiles, guards, envOwned: ownedEnvNames, verdictType, writeScope, jobLines, inputLabels: inputLabelsOf(inputs) });
|
|
2896
|
+
if (r.ok && lang === RUBRIC_LANG) {
|
|
2897
|
+
const words = checkDeclarationWords(r.declaration, inputTexts, facts?.look ?? null);
|
|
2898
|
+
if (words.length > 0) r = { ...r, ok: false, reds: [...r.reds, ...words], declaration: null };
|
|
2899
|
+
}
|
|
2900
|
+
return r;
|
|
2901
|
+
};
|
|
2902
|
+
// PRD v1.131 tick 7: per try (by call label), the retention counts of a rubric draft; the one that stands is reported once at the end
|
|
2903
|
+
/** @type {Map<string, ReturnType<typeof retentionOf>>} */
|
|
2904
|
+
const retentions = new Map();
|
|
2825
2905
|
/** @type {any[]} */
|
|
2826
2906
|
let messages = [{ role: 'user', content: prompt }];
|
|
2907
|
+
/** the drafter's PROPOSED ticket filter of the accepted iteration (a Tickets job only); the person signs it, the spec carries it, the close never does @type {any} */
|
|
2908
|
+
let acceptedTicketFilter;
|
|
2827
2909
|
/** @type {any[]} */
|
|
2828
2910
|
const iterations = [];
|
|
2829
2911
|
/** @type {any} */
|
|
@@ -2907,8 +2989,16 @@ export async function authorClose({
|
|
|
2907
2989
|
// P7 item 5: a mechanism, never a wish. Only the last try of the full ladder carries the property, and only when the
|
|
2908
2990
|
// two before it both failed (validation or the seed read; `questionLines` is set at the end of the second one, below).
|
|
2909
2991
|
const askOpen = questionLines !== null && i === revisionCap;
|
|
2910
|
-
const ask = await askDeclaration({ messages, generate, mode: structuredMode, retries: retryCap, label, book, catalogue: catalogueIn, kinds: Object.keys(catalogue), verdictType, questions: askOpen });
|
|
2992
|
+
const ask = await askDeclaration({ messages, generate, mode: structuredMode, retries: retryCap, label, book, catalogue: catalogueIn, kinds: Object.keys(catalogue), verdictType, questions: askOpen, ticket });
|
|
2911
2993
|
messages = ask.convo;
|
|
2994
|
+
// `ticketFilter` is never part of the declaration (the close): taken out before validation, checked by its own reader below, and kept beside the declaration
|
|
2995
|
+
/** @type {any} */
|
|
2996
|
+
let proposedFilter;
|
|
2997
|
+
if (ticket && ask.declaration && typeof ask.declaration === 'object' && Object.hasOwn(ask.declaration, 'ticketFilter')) {
|
|
2998
|
+
const { ticketFilter: tf, ...restDecl } = ask.declaration;
|
|
2999
|
+
proposedFilter = tf;
|
|
3000
|
+
ask.declaration = restDecl;
|
|
3001
|
+
}
|
|
2912
3002
|
/** @type {{reason: string, raw: any}[]} */
|
|
2913
3003
|
let droppedQuestions = [];
|
|
2914
3004
|
if (askOpen && ask.declaration && typeof ask.declaration === 'object' && Object.hasOwn(ask.declaration, 'questions')) {
|
|
@@ -2990,22 +3080,28 @@ export async function authorClose({
|
|
|
2990
3080
|
// early stop: an unchanged declaration has the previous iteration's
|
|
2991
3081
|
// measurements by definition — re-executing it buys nothing and costs a
|
|
2992
3082
|
// full close
|
|
2993
|
-
if (previous && canonical(ask.declaration) === canonical(previous)) {
|
|
3083
|
+
if (previous && canonical({ d: ask.declaration, f: proposedFilter ?? null }) === canonical(previous)) {
|
|
2994
3084
|
iter.validation = '(identical declaration — see the previous iteration)';
|
|
2995
3085
|
iter.seedRead = '(identical declaration — see the previous iteration)';
|
|
2996
3086
|
stop = 'unchanged';
|
|
2997
3087
|
break;
|
|
2998
3088
|
}
|
|
2999
|
-
previous = ask.declaration;
|
|
3089
|
+
previous = { d: ask.declaration, f: proposedFilter ?? null };
|
|
3000
3090
|
|
|
3001
3091
|
// PART 1b: code puts the number tie on every prose step that follows a fact step, before anything is validated or signed
|
|
3002
|
-
|
|
3003
|
-
|
|
3004
|
-
|
|
3005
|
-
//
|
|
3006
|
-
if (v.ok && lang === RUBRIC_LANG) {
|
|
3007
|
-
const
|
|
3008
|
-
if (
|
|
3092
|
+
const settled = withFactBindings(withDropNotes(settlePersonsWords(picked(ask.declaration), jobLines), facts?.look?.dropped, jobLines));
|
|
3093
|
+
let pre = settled;
|
|
3094
|
+
let v = checkDraft(pre);
|
|
3095
|
+
// PRD v1.131 tick 4: only after the LAST try of a rubric draft failed, the AI's own broken parts are dropped to Not checked and the plan is checked ONCE more; else the plan is refused as today
|
|
3096
|
+
if (!v.ok && lang === RUBRIC_LANG && i === revisionCap) {
|
|
3097
|
+
const dropped = dropAfterLastTry({ pre, v, jobLines, redo: checkDraft });
|
|
3098
|
+
if (dropped) { pre = dropped.pre; v = dropped.v; }
|
|
3099
|
+
}
|
|
3100
|
+
if (lang === RUBRIC_LANG) retentions.set(label, retentionOf(ask.declaration, pre, jobLines));
|
|
3101
|
+
// MCP + tickets piece 2: a proposed ticket filter is read by the ONE reader (src/ticketfilter.js); its reds carry a legal example and go back to the drafter like any red
|
|
3102
|
+
if (v.ok && ticket && proposedFilter !== undefined) {
|
|
3103
|
+
const fr = ticketFilterReds(proposedFilter);
|
|
3104
|
+
if (fr.length > 0) v = { ...v, ok: false, reds: [...v.reds, ...fr], declaration: null };
|
|
3009
3105
|
}
|
|
3010
3106
|
// SCRUBBED HERE, once, where the reds enter this module's records — the same
|
|
3011
3107
|
// boundary rule `renderRejectBlock` already states, applied to the OTHER
|
|
@@ -3053,6 +3149,7 @@ export async function authorClose({
|
|
|
3053
3149
|
onPhase('seed-read-done', { call: label, stages: stageCount });
|
|
3054
3150
|
iter.seedRead = rows;
|
|
3055
3151
|
accepted = injected.declaration;
|
|
3152
|
+
acceptedTicketFilter = proposedFilter;
|
|
3056
3153
|
acceptedSeedRead = rows;
|
|
3057
3154
|
finalFrom = label;
|
|
3058
3155
|
measured = renderSeedReadBlock(rows);
|
|
@@ -3134,6 +3231,10 @@ export async function authorClose({
|
|
|
3134
3231
|
}
|
|
3135
3232
|
}
|
|
3136
3233
|
|
|
3234
|
+
// PRD v1.131 tick 7: ONE retention record when a rubric draft ends (accepted or stopped), counts only; the panel writes it into the drafting log
|
|
3235
|
+
const standing = fellBack ? retentions.get(fellBack.to) : [...retentions.values()].at(-1);
|
|
3236
|
+
if (standing) onPhase('draft-retention', { lines: standing });
|
|
3237
|
+
|
|
3137
3238
|
const reds = fatal.length ? fatal : (lastValidation && !lastValidation.ok ? lastValidation.reds : []);
|
|
3138
3239
|
return {
|
|
3139
3240
|
// `ok` means A SIGNABLE CLOSE EXISTS, and nothing more. A dead socket on a
|
|
@@ -3143,6 +3244,7 @@ export async function authorClose({
|
|
|
3143
3244
|
// Why the loop ended is never hidden: `stop` names it and `reds` carries it.
|
|
3144
3245
|
ok: accepted !== null,
|
|
3145
3246
|
declaration: accepted,
|
|
3247
|
+
...(ticket && acceptedTicketFilter !== undefined ? { ticketFilter: acceptedTicketFilter } : {}),
|
|
3146
3248
|
seedRead: acceptedSeedRead,
|
|
3147
3249
|
iterations,
|
|
3148
3250
|
reds,
|
package/src/authoring.js
CHANGED
|
@@ -353,14 +353,14 @@ export const KIND_CATALOGUE = Object.freeze({
|
|
|
353
353
|
optional: Object.freeze([]),
|
|
354
354
|
pathParams: Object.freeze([]),
|
|
355
355
|
shape: 'step: integer (the job line number), parts: [{text: string, class: "countable" | "fact" | "judged" | "guard" | "none", '
|
|
356
|
-
+ 'check?: "
|
|
357
|
-
+ '
|
|
356
|
+
+ 'check?: "cited" | "minClaims" | "maxClaims", value?: integer, '
|
|
357
|
+
+ 'source?: string (an input label), domains?: string[], covers?: integer[], rules?: integer[], '
|
|
358
358
|
+ 'fact parts: facts?: [{name, shape: "money"|"number"|"date"|"time"|"phrase"|"text", unit?|currency? (each one value or a list; money names at least one), phrase?, anchor?, until?, '
|
|
359
359
|
+ 'rule?: {op, value | lo+hi}, aiProposal?: boolean}], count?: {min?, max?}}]',
|
|
360
360
|
asserts: 'the file output/<step>.json under output/steps/ exists, is a JSON object, and its "text" is present and within the '
|
|
361
361
|
+ 'limits the person asked for. Write ONE rubric-step stage per numbered job line (step = that line number, fromLine = [that line]). '
|
|
362
362
|
+ 'In "parts" list each constraint the person put on that line, in their own words, and SORT it: "countable" when a machine can '
|
|
363
|
-
+ '
|
|
363
|
+
+ 'quote it (word, section, line, list-item and phrase counts are never yours: code adds the ones the person picked) or '
|
|
364
364
|
+ 'when claims must be backed by a quote from a named input (check cited, source = the input label), or when a number of '
|
|
365
365
|
+ 'quoted claims is asked for (minClaims / maxClaims with value and source: it counts the claims listed under that input); '
|
|
366
366
|
+ 'a line that FINDS, LISTS or LOOKS UP something gets ONE part of class "fact" instead (source = the input label, '
|
|
@@ -1526,7 +1526,9 @@ export function validateDeclaration(declaration, opts = {}) {
|
|
|
1526
1526
|
if (haveGuards) checkGuards({ declaration, guards: /** @type {any[]} */ (guards), red });
|
|
1527
1527
|
checkJobLines({ declaration, stages, jobLines, guards: haveGuards ? /** @type {any[]} */ (guards) : [], red });
|
|
1528
1528
|
// PART 1a (R11): the sorting rules for the rubric-step stages — plain-words reds, judged and web parts refused in this build
|
|
1529
|
-
|
|
1529
|
+
// keep-both: the record of the person's picks (code writes it, the signed spec carries it) is what lets a countable part sit beside a fact
|
|
1530
|
+
checkPickRecord(declaration.picks, red);
|
|
1531
|
+
checkRubricParts(stages, { inputLabels, red, picks: Array.isArray(declaration.picks) ? declaration.picks : null });
|
|
1530
1532
|
// PART 1b (RF16, RF17): every ~ rule is a check or Not checked; the AI's own numbers are marked and a time range is a range
|
|
1531
1533
|
checkRubricRules(stages, { jobLines, refused: declaration.refused, red });
|
|
1532
1534
|
|
|
@@ -1534,6 +1536,21 @@ export function validateDeclaration(declaration, opts = {}) {
|
|
|
1534
1536
|
return { ok, reds, declaration: ok ? normalizeDeclaration(declaration) : null, grounded: haveListing, scoped, ceiling };
|
|
1535
1537
|
}
|
|
1536
1538
|
|
|
1539
|
+
/**
|
|
1540
|
+
* keep-both: the SHAPE of the record of the person's picks, `picks: [{line, part}]` (code writes it from the settled picks, `applyPicks`; the signed close carries it;
|
|
1541
|
+
* `checkRubricParts` reads it). A bad entry is a plain red, never a crash.
|
|
1542
|
+
* @param {unknown} picks @param {(c: string, p: string, d: string, e?: object) => void} red
|
|
1543
|
+
*/
|
|
1544
|
+
function checkPickRecord(picks, red) {
|
|
1545
|
+
if (picks === undefined) return;
|
|
1546
|
+
if (!Array.isArray(picks)) { red('invalid-value', 'picks', 'an array of {line, part} - the person\'s picked checks, written by code'); return; }
|
|
1547
|
+
picks.forEach((/** @type {any} */ e, /** @type {number} */ j) => {
|
|
1548
|
+
if (!isObj(e) || !Number.isInteger(e.line) || !isObj(e.part) || e.part.class !== 'countable') {
|
|
1549
|
+
red('invalid-value', `picks[${j}]`, '{line, part}: a job line number and the picked countable part');
|
|
1550
|
+
}
|
|
1551
|
+
});
|
|
1552
|
+
}
|
|
1553
|
+
|
|
1537
1554
|
/**
|
|
1538
1555
|
* P7 rules 1-3 of the job block, at $0, in the gate that can still revise: every `fromLine` is a non-empty, duplicate-free array of real job line numbers (one check may serve several lines);
|
|
1539
1556
|
* every numbered job line has at least one stage OR a refusal reason in `refused` (a note in `notes` does NOT cover a
|