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.
Files changed (139) hide show
  1. package/CHANGELOG.md +83 -0
  2. package/bareloop.context.md +73 -12
  3. package/package.json +3 -3
  4. package/src/authorflow.js +148 -46
  5. package/src/authoring.js +21 -4
  6. package/src/authorjob.js +82 -3
  7. package/src/authorreadout.js +20 -3
  8. package/src/authorrun.js +1 -1
  9. package/src/authorscout.js +9 -6
  10. package/src/bridges.js +4 -3
  11. package/src/cardschedule.js +42 -0
  12. package/src/carrystore.js +1 -1
  13. package/src/checkpick.js +576 -0
  14. package/src/checksuggest.js +28 -0
  15. package/src/checkwords.js +25 -0
  16. package/src/cli.js +1 -1
  17. package/src/config.js +24 -1
  18. package/src/declaredclose.js +1 -1
  19. package/src/destpoint.js +149 -0
  20. package/src/draftspend.js +39 -0
  21. package/src/factwords.js +14 -1
  22. package/src/job.js +81 -1
  23. package/src/jobblock.js +9 -0
  24. package/src/labelscan.js +11 -0
  25. package/src/launcher.js +10 -6
  26. package/src/learn.js +6 -4
  27. package/src/mcpchecks.js +52 -0
  28. package/src/mcppick.js +36 -0
  29. package/src/mcpsources.js +77 -0
  30. package/src/mcpuse.js +97 -0
  31. package/src/natural.js +23 -0
  32. package/src/pagemap.js +5 -2
  33. package/src/panel/authorroutes.js +90 -15
  34. package/src/panel/authorsession.js +183 -21
  35. package/src/panel/index.html +686 -26
  36. package/src/panel/jobgrid.js +117 -0
  37. package/src/panel/jobplan.js +31 -15
  38. package/src/panel/scheduler.js +80 -13
  39. package/src/panel/schedules.js +189 -28
  40. package/src/panel/schedulestart.js +44 -13
  41. package/src/panel/server.js +438 -33
  42. package/src/panel/settingsroutes.js +133 -3
  43. package/src/panel/status.js +22 -2
  44. package/src/panel/tickets.js +44 -0
  45. package/src/pickrecord.js +145 -0
  46. package/src/plan.js +31 -2
  47. package/src/planrun.js +71 -15
  48. package/src/prcheckout.js +259 -0
  49. package/src/readshim.js +3 -2
  50. package/src/replay.js +6 -0
  51. package/src/reuse.js +3 -3
  52. package/src/revises.js +56 -0
  53. package/src/rubricstep.js +62 -16
  54. package/src/run.js +10 -1
  55. package/src/runexport.js +2 -0
  56. package/src/runlist.js +3 -2
  57. package/src/schedulewords.js +46 -4
  58. package/src/source.js +81 -7
  59. package/src/stepmcp.js +86 -0
  60. package/src/ticket.js +113 -0
  61. package/src/ticketfilter.js +76 -0
  62. package/src/ticketlabels.js +79 -0
  63. package/src/ticketmcp.js +111 -0
  64. package/src/ticketnext.js +35 -0
  65. package/src/ticketrepo.js +98 -0
  66. package/src/ticketschedule.js +32 -0
  67. package/src/ticketshape.js +45 -0
  68. package/src/tools.js +9 -0
  69. package/src/trigger.js +14 -2
  70. package/src/triggerclock.js +7 -3
  71. package/src/triggerfiles.js +19 -11
  72. package/src/triggertickets.js +244 -0
  73. package/src/u-readout.js +2 -2
  74. package/src/userrun.js +146 -10
  75. package/src/validate.js +3 -1
  76. package/src/worktree.js +43 -1
  77. package/types/authorflow.d.ts +128 -28
  78. package/types/authorjob.d.ts +16 -3
  79. package/types/authorreadout.d.ts +9 -2
  80. package/types/authorscout.d.ts +4 -2
  81. package/types/bridges.d.ts +4 -3
  82. package/types/cardschedule.d.ts +24 -0
  83. package/types/checkpick.d.ts +297 -0
  84. package/types/checksuggest.d.ts +30 -0
  85. package/types/checkwords.d.ts +14 -0
  86. package/types/config.d.ts +7 -0
  87. package/types/destpoint.d.ts +87 -0
  88. package/types/draftspend.d.ts +16 -0
  89. package/types/factwords.d.ts +7 -0
  90. package/types/job.d.ts +13 -0
  91. package/types/jobblock.d.ts +9 -0
  92. package/types/labelscan.d.ts +7 -0
  93. package/types/launcher.d.ts +7 -2
  94. package/types/mcpchecks.d.ts +8 -0
  95. package/types/mcppick.d.ts +33 -0
  96. package/types/mcpsources.d.ts +51 -0
  97. package/types/mcpuse.d.ts +15 -0
  98. package/types/natural.d.ts +2 -0
  99. package/types/pagemap.d.ts +2 -1
  100. package/types/panel/authorroutes.d.ts +11 -2
  101. package/types/panel/authorsession.d.ts +58 -3
  102. package/types/panel/jobgrid.d.ts +405 -0
  103. package/types/panel/jobplan.d.ts +10 -4
  104. package/types/panel/scheduler.d.ts +7 -2
  105. package/types/panel/schedules.d.ts +124 -4
  106. package/types/panel/schedulestart.d.ts +21 -3
  107. package/types/panel/server.d.ts +427 -6
  108. package/types/panel/settingsroutes.d.ts +4 -2
  109. package/types/panel/status.d.ts +16 -2
  110. package/types/panel/tickets.d.ts +61 -0
  111. package/types/pickrecord.d.ts +88 -0
  112. package/types/plan.d.ts +1 -0
  113. package/types/prcheckout.d.ts +151 -0
  114. package/types/readshim.d.ts +4 -3
  115. package/types/replay.d.ts +3 -0
  116. package/types/reuse.d.ts +2 -2
  117. package/types/revises.d.ts +23 -0
  118. package/types/rubricstep.d.ts +14 -5
  119. package/types/run.d.ts +18 -1
  120. package/types/runlist.d.ts +6 -3
  121. package/types/schedulewords.d.ts +29 -2
  122. package/types/source.d.ts +40 -4
  123. package/types/stepmcp.d.ts +40 -0
  124. package/types/ticket.d.ts +114 -0
  125. package/types/ticketfilter.d.ts +34 -0
  126. package/types/ticketlabels.d.ts +44 -0
  127. package/types/ticketmcp.d.ts +84 -0
  128. package/types/ticketnext.d.ts +33 -0
  129. package/types/ticketrepo.d.ts +118 -0
  130. package/types/ticketschedule.d.ts +21 -0
  131. package/types/ticketshape.d.ts +37 -0
  132. package/types/tools.d.ts +1 -0
  133. package/types/trigger.d.ts +9 -1
  134. package/types/triggerclock.d.ts +6 -2
  135. package/types/triggerfiles.d.ts +13 -5
  136. package/types/triggertickets.d.ts +110 -0
  137. package/types/userrun.d.ts +50 -0
  138. package/types/validate.d.ts +1 -0
  139. package/types/worktree.d.ts +19 -0
package/src/authorjob.js CHANGED
@@ -120,6 +120,9 @@ import { runFitCheck, fitQuestionText, notFoundList, isGoOn } from './fitcheck.j
120
120
  import { pageContentChars } from './pagefetch.js';
121
121
  import { runAuthorScout, buildSeedListing, SCOUT_ATTEMPTS } from './authorscout.js';
122
122
  import { runPageMap, askableFromLook, tooManyAsksText } from './pagemap.js';
123
+ import { scopedRules, checkAsks } from './checkpick.js';
124
+ import { matchRecord, entriesFromAnswers } from './pickrecord.js';
125
+ import { runCheckSuggest } from './checksuggest.js';
123
126
  import {
124
127
  DECLARED_GAP_PREFIX, DECLARED_GENRES, guardNames, isDeclaredClose, validateCloseDecl,
125
128
  } from './declaredclose.js';
@@ -436,12 +439,13 @@ function composerRefusal(reds) {
436
439
  * signerFix?: Function|any, proposeFn?: Function, compileOpts?: object,
437
440
  * ask?: ((step: {kind: string, [k: string]: any}) => Promise<string|null>)|null,
438
441
  * answerQuestions?: ((o: {questions: {line: number, question: string, rule?: number, source?: string, ask?: string, reading?: string}[], dropped: {reason: string, raw: any}[], confirmed: any}) =>
439
- * Promise<{jobLines: {n: number, text: string, rule?: string}[], answers: Record<string|number, any>, left?: {line: number, rule: number}[]}|null>)|null,
442
+ * Promise<{jobLines: {n: number, text: string, rule?: string}[], answers: Record<string|number, any>, left?: {line: number, rule: number}[], picks?: any[]}|null>)|null,
443
+ * pickGenerate?: Function|null, carriedPicks?: any[]|null, onPicks?: (o: {entries: any[], kept: {line: number, rule: number, entry: any}[]}) => void,
440
444
  * confirmGenerate?: Function|null, isRepo?: boolean,
441
445
  * langResult?: {kind: string, candidates?: string[], [k: string]: any}|null}} o
442
446
  * @returns {Promise<{ok: boolean, refusal: Refusal|null, verdictType: string|null,
443
447
  * closeDecl: any, seedRef: string|null, authoring: any, judged: any, reds: Red[],
444
- * stop: string|null, cost: any, interview: any, confirmed: any}>}
448
+ * stop: string|null, cost: any, interview: any, confirmed: any, checkPicks?: any}>}
445
449
  */
446
450
  export async function authorCloseForJob({
447
451
  answers, repoPath = null, lang, verdictType = null, questions = null,
@@ -479,6 +483,11 @@ export async function authorCloseForJob({
479
483
  // `fitFn` null is an explicit "no check" (a test seam). With no `fitAsk` (the CLI door) it never runs.
480
484
  fitFn = runFitCheck, fitAsk = null, onFit = () => {},
481
485
  authorFn = authorClose, authorOpts = {},
486
+ // R10 (fwd am16): the model boundary of the check-suggestion call (a `makeLoopGenerate` bound to SUGGEST_SYSTEM). ABSENT = no pick path: nothing is suggested or asked and the
487
+ // drafted declaration is validated as it always was (a test seam, like `lookFn: null`).
488
+ pickGenerate = null,
489
+ // R10 (fwd am17/am18): the picks record of the draft this one follows (`readRecordFile`), and the seam that receives this draft's record + the picks it kept. ABSENT = every rule is asked.
490
+ carriedPicks = null, onPicks = () => {},
482
491
  // SOFTGREEN modules 4+5. `signerFix` is the D5 seam: a function (or a value)
483
492
  // carrying the SIGNER's corrected artifacts back. Absent means the proposal is
484
493
  // signed as proposed, and `signJudgedArtifacts` records which of the two
@@ -676,13 +685,18 @@ export async function authorCloseForJob({
676
685
  // existing one (`answerQuestions`: answer required, no skip, the answer becomes a `~` rule on its line; `normalizeQuestions` keeps at most
677
686
  // MAX_QUESTIONS). The answer "drop it" adds no rule: the rule is put on the look's own dropped list, so it reads Not checked on the
678
687
  // confirm card, in the signed plan and in the drafter's block, and can never be written back as a check.
688
+ /** the look's code-forced asks that were put to the person (they count toward the cap with the pick asks) @type {any[]} */
689
+ let lookAsks = [];
679
690
  if (answerQuestions && lang === RUBRIC_LANG && survey?.state === 'PRESENT' && survey.facts?.look && typeof survey.facts.look === 'object' && Array.isArray(jobLines)) {
680
- const candidates = askableFromLook(survey.facts.look, jobLines);
691
+ // R10: a rule the pick path scopes in is settled by its own ask (a proposal, or "I can't check this"), so the look does not also ask "I can't check this on the page" about it
692
+ const picksOwn = pickGenerate ? new Set(scopedRules(jobLines, { inputs, look: survey.facts.look }).map((r) => `${r.line}:${r.rule}`)) : new Set();
693
+ const candidates = askableFromLook(survey.facts.look, jobLines).filter((c) => !(c.ask === 'cant-check' && picksOwn.has(`${c.line}:${c.rule}`)));
681
694
  if (candidates.length > MAX_QUESTIONS) {
682
695
  return { ...base, interview, verdictType: picked, seedRef: seed, reds: [{ code: 'look-asks-too-many', path: 'jobLines', detail: tooManyAsksText(candidates) }], stop: 'look-asks-too-many', cost: null };
683
696
  }
684
697
  const kept = normalizeQuestions(candidates, [...new Set(candidates.map((q) => q.line))]);
685
698
  if (kept.kept.length > 0) {
699
+ lookAsks = candidates;
686
700
  onPhase('look-ask', { questions: kept.kept.length });
687
701
  const updated = await answerQuestions({ questions: kept.kept, dropped: kept.dropped, confirmed: null });
688
702
  if (updated === null) return { ...base, interview, verdictType: picked, seedRef: seed, reds: [], stop: 'confirm-abandoned', cost: null };
@@ -697,6 +711,56 @@ export async function authorCloseForJob({
697
711
  }
698
712
  }
699
713
 
714
+ // R10 (fwdloop M10 am16, ruled 2026-11-09): for a rubric job, ONE paid call suggests a check from bareguard's own list for each `~` rule that code scopes in (src/checkpick.js
715
+ // `scopedRules`); code keeps a suggestion only if its rule is on the list and every number and word is the rule's own (`keepOrDrop`); then CODE asks, through the same ask
716
+ // path as the look's asks: a kept check is proposed (not counted toward the cap), nothing kept reads "I can't check this" (counted: the look's asks plus these, at most
717
+ // MAX_QUESTIONS). The plan carries exactly the checks the person picked; the drafter writes none.
718
+ /** @type {{rules: {line: number, rule: number, text: string}[], picks: any[], left: {line: number, rule: number}[], rows: any[]}|null} */
719
+ let checkPicks = null;
720
+ if (answerQuestions && pickGenerate && lang === RUBRIC_LANG && survey?.state === 'PRESENT' && Array.isArray(jobLines)) {
721
+ const scoped = scopedRules(jobLines, { inputs, look: survey.facts?.look ?? null });
722
+ if (scoped.length > 0) {
723
+ // am17/am18: a pick follows its line's WORDS and its rule's exact words; one still matching is kept (not sent to the call, not asked, not counted), a changed or new rule is asked
724
+ const matched = matchRecord(Array.isArray(carriedPicks) ? carriedPicks : [], jobLines, scoped);
725
+ /** @type {ReturnType<typeof checkAsks>} */
726
+ let asks = [];
727
+ let sug = null;
728
+ if (matched.askRules.length > 0) {
729
+ onPhase('check-suggest', { rules: matched.askRules.length });
730
+ sug = await runCheckSuggest({ jobLines, scoped: matched.askRules, generate: pickGenerate, ceilingUsd, onCall, priorCalls: survey?.calls ?? [], priorRaws: survey?.raws ?? [] });
731
+ // the call's spend joins the survey's, so the ONE ceiling the later stages enforce already holds it
732
+ survey.calls = [...(survey.calls ?? []), ...sug.calls];
733
+ survey.raws = [...(survey.raws ?? []), ...sug.raws];
734
+ asks = checkAsks(sug.rows);
735
+ }
736
+ const counted = asks.filter((a) => a.counted);
737
+ if (lookAsks.length + counted.length > MAX_QUESTIONS) {
738
+ return { ...base, interview, verdictType: picked, seedRef: seed, reds: [{ code: 'look-asks-too-many', path: 'jobLines', detail: tooManyAsksText([...lookAsks, ...counted]) }], stop: 'look-asks-too-many', cost: null };
739
+ }
740
+ /** @type {{picks?: any[], left?: {line: number, rule: number}[], jobLines: any[], answers: any}|null} */
741
+ let updated = { jobLines, answers: interview.answers, picks: [], left: [] };
742
+ if (asks.length > 0) {
743
+ onPhase('check-ask', { questions: asks.length });
744
+ updated = await answerQuestions({ questions: asks, dropped: [], confirmed: null });
745
+ if (updated === null) return { ...base, interview, verdictType: picked, seedRef: seed, reds: [], stop: 'confirm-abandoned', cost: null };
746
+ jobLines = updated.jobLines;
747
+ interview.answers = updated.answers;
748
+ }
749
+ const newPicks = Array.isArray(updated.picks) ? updated.picks : [];
750
+ const newLeft = Array.isArray(updated.left) ? updated.left : [];
751
+ const keptPicks = matched.picks.map((p) => ({ ...p, kept: true }));
752
+ const keptLeft = matched.left.map((l) => ({ ...l, kept: true }));
753
+ const answeredLeft = newLeft.filter((l) => scoped.some((r) => r.line === l.line && r.rule === l.rule));
754
+ // the record this draft hands on: the picks it kept, as they were, and the picks just answered, keyed by words
755
+ onPicks({
756
+ entries: [...matched.kept.map((k) => k.entry), ...entriesFromAnswers(jobLines, scoped, newPicks, answeredLeft)],
757
+ kept: matched.kept.map((k) => ({ line: k.line, rule: k.rule, entry: k.entry })),
758
+ });
759
+ checkPicks = { rules: scoped, picks: [...keptPicks, ...newPicks], left: [...keptLeft, ...answeredLeft], rows: sug?.rows ?? [] };
760
+ base.checkPicks = checkPicks;
761
+ }
762
+ }
763
+
700
764
  // ── THE CONFIRM TURN'S PAID HALF (PRD item 33 M3 piece 4) ──────────────────
701
765
  // Slotted between the scout and the listing: it reuses the scout's own
702
766
  // survey (ruling 4 — never a second read of the source) and needs nothing
@@ -739,6 +803,8 @@ export async function authorCloseForJob({
739
803
  const confirm = await runConfirmTurn({
740
804
  verdictType: picked, answers: interview.answers, questions: questions ?? questionsFor(picked),
741
805
  facts: survey.facts, listing: null, writeScope, isRepo, lang, worseThanBefore, inputs, jobLines,
806
+ ...(authorOpts?.ticket === true ? { ticket: true } : {}),
807
+ ...(checkPicks ? { settled: checkPicks.rules } : {}),
742
808
  generate: confirmGenerate, book: confirmBook, ask, onPhase,
743
809
  });
744
810
  // DISTINCT from `runConfirmTurn`'s own per-round 'confirm-done' (fired once
@@ -792,6 +858,7 @@ export async function authorCloseForJob({
792
858
  // PART 1c: a rubric job asks nothing piecemeal on a failed try - it stops, and the person reviews the whole job (the one early
793
859
  // ask is about a `~` rule the look could not find, above)
794
860
  ...(answerQuestions && lang !== RUBRIC_LANG ? { offerQuestions: true } : {}),
861
+ ...(checkPicks ? { checkPicks } : {}),
795
862
  ...authorOpts,
796
863
  });
797
864
  // P7 item 5: the drafter, on the last try after two failed ones, asked. The person answers (required, no skip); each
@@ -812,6 +879,7 @@ export async function authorCloseForJob({
812
879
  scout: survey, listing: seeds, generate, ceilingUsd, onPhase, onCall, writeScope,
813
880
  priorCalls: (authored.cost?.calls ?? []).slice(scoutCalls), priorRaws: (authored.raws ?? []).slice(scoutRaws),
814
881
  confirmed, jobLines, inputs,
882
+ ...(checkPicks ? { checkPicks } : {}),
815
883
  ...authorOpts,
816
884
  offerQuestions: false,
817
885
  });
@@ -867,6 +935,8 @@ export async function authorCloseForJob({
867
935
  ...(authored.declaration.refused?.length
868
936
  ? { refused: authored.declaration.refused.map((/** @type {any} */ r) => ({ line: r.line, ...(Number.isInteger(r.rule) ? { rule: r.rule } : {}), reason: redactSecrets(String(r.reason)) })) }
869
937
  : {}),
938
+ // keep-both: the person's picks, as code recorded them at the draft (the signed close reads this to tell a pick from a drafter-written count beside a fact)
939
+ ...(authored.declaration.picks?.length ? { picks: structuredClone(authored.declaration.picks) } : {}),
870
940
  // the lines the always-on guards cover (names and numbers only, nothing free-text)
871
941
  ...(authored.declaration.guardLines?.length
872
942
  ? { guardLines: authored.declaration.guardLines.map((/** @type {any} */ g) => ({ guard: g.guard, lines: [...g.lines] })) }
@@ -967,6 +1037,7 @@ export async function authorCloseForJob({
967
1037
  seedRef: seed,
968
1038
  authoring: authored,
969
1039
  judged,
1040
+ ...(checkPicks ? { checkPicks } : {}),
970
1041
  reds: authored.reds,
971
1042
  stop: authored.stop,
972
1043
  cost: authored.cost,
@@ -1072,6 +1143,14 @@ export function assembleSpec(specDraft, { closeDecl, verdictType }) {
1072
1143
  throw new Error('the spec draft carries trigger — a schedule is set only by the person, in the panel\'s two-click schedule '
1073
1144
  + 'door, never by a draft. Remove the field from the draft');
1074
1145
  }
1146
+ // MCP + tickets (piece 1): the MCP source, flow type, ticket filter and watch are set by CODE from the person's card pick, never by a draft
1147
+ // (the agent never widens its own tool menu). Refused by name, like `trigger`.
1148
+ for (const f of ['mcp', 'flowType', 'ticketFilter', 'ticketWatch']) {
1149
+ if (draft[f] !== undefined) {
1150
+ throw new Error(`the spec draft carries ${f} — the MCP source and ticket fields are set by code from the person's card pick, `
1151
+ + 'and signed by the person, never by a draft. Remove the field from the draft');
1152
+ }
1153
+ }
1075
1154
  return { ...draft, verdictType, closeDecl };
1076
1155
  }
1077
1156
 
@@ -871,6 +871,21 @@ const listText = (v) => {
871
871
  /** the sentence when the gates refuse with no red at all (the close already passes on the untouched repository) */
872
872
  const SEED_GREEN_SENTENCE = 'Nothing in the close fails on the repository as it is, so there is nothing for a run to do.';
873
873
 
874
+ /** the sentence and the to-do when a rubric / page job's close has no check that can fail (hamr ruling 2026-11-10) */
875
+ const NO_CHECK_SENTENCE = 'This job has no check that can fail: no `~` rule, and no check the AI built was kept. A run needs at least one check, a quoted fact or a count. Without one, its pass would prove nothing. For an answer nobody checks, a plain chat AI is the right tool.';
876
+ const NO_CHECK_TODO = 'add a `~` rule (for example the version, the date, or "under 80 words"), or answer the question with what the output must contain';
877
+
878
+ /**
879
+ * Code's reading of a declared close: a rubric (text-lang) close with no real check, only always-on stages such as
880
+ * files-changed, or rubric-step stages holding no part. Decided from the close alone, never by a model.
881
+ * @param {any} closeDecl @returns {boolean}
882
+ */
883
+ export function isNoCheckRubricClose(closeDecl) {
884
+ if (!closeDecl || closeDecl.lang !== 'text' || !Array.isArray(closeDecl.stages)) return false;
885
+ return !closeDecl.stages.some((/** @type {any} */ st) => st && st.kind !== 'files-changed'
886
+ && (st.kind !== 'rubric-step' || (Array.isArray(st.params?.parts) && st.params.parts.length > 0)));
887
+ }
888
+
874
889
  /**
875
890
  * Plain sentences for the reds of a refused signing, one or more per red. Card and practice-case reds reuse the
876
891
  * proposal table; an unknown code is a generic sentence that quotes the code.
@@ -904,14 +919,16 @@ export function signingKinds() {
904
919
 
905
920
  /**
906
921
  * THE MESSAGE a person reads when the signing gates refuse. The panel's failed step and the CLI print exactly this.
907
- * @param {{reds: PlainRed[], refusal?: {detail?: string}|null, cases?: any,
922
+ * @param {{reds: PlainRed[], refusal?: {detail?: string}|null, cases?: any, closeDecl?: any,
908
923
  * spend?: {knownUsd?: number|null, spendComplete?: boolean|null}|null}} o
909
924
  * @returns {string}
910
925
  */
911
- export function signingStopText({ reds, refusal = null, cases = null, spend = null }) {
926
+ export function signingStopText({ reds, refusal = null, cases = null, spend = null, closeDecl = null }) {
912
927
  const reasons = signingReasons(reds, { cases });
913
928
  if (reasons.length === 0) {
914
- reasons.push({ kind: 'seed-green', sentence: SEED_GREEN_SENTENCE, todo: 'check that the close measures the right thing, or describe a sharper problem',
929
+ const noCheck = isNoCheckRubricClose(closeDecl);
930
+ reasons.push({ kind: 'seed-green', sentence: noCheck ? NO_CHECK_SENTENCE : SEED_GREEN_SENTENCE,
931
+ todo: noCheck ? NO_CHECK_TODO : 'check that the close measures the right thing, or describe a sharper problem',
915
932
  red: { code: '', path: '', detail: String(refusal?.detail ?? '') } });
916
933
  }
917
934
  const unique = [...new Set(reasons.map((x) => x.sentence))];
package/src/authorrun.js CHANGED
@@ -1238,7 +1238,7 @@ export async function main(argv, deps = {}) {
1238
1238
  if (!signing.ok) {
1239
1239
  const t = costSoFar();
1240
1240
  out(`\n${signingStopText({
1241
- reds: signing.reds ?? [], refusal: signing.refusal,
1241
+ reds: signing.reds ?? [], refusal: signing.refusal, closeDecl: spec.closeDecl,
1242
1242
  spend: { knownUsd: t.knownUsd ?? null, spendComplete: t.spendComplete ?? null },
1243
1243
  })}`);
1244
1244
  }
@@ -376,7 +376,7 @@ const defaultLoop = (/** @type {any} */ { system, policy, onLlmResult, provider,
376
376
  * @param {{workdir: string, provider?: any,
377
377
  * rounds?: number, minBytes?: number, blobMax?: number, maxTokens?: number, ctx?: boolean,
378
378
  * attempts?: number, ceilingUsd?: number|null, callTimeoutMs?: number,
379
- * onCall?: (call: {label: string, costUsd: number|null, unpricedRounds: number, thinkingStatus?: string}) => void,
379
+ * onCall?: (call: {label: string, costUsd: number|null, unpricedRounds: number, thinkingStatus?: string, raw?: string}) => void,
380
380
  * createLoop?: (o: {system: string, policy: any, onLlmResult: any, provider: any, rates?: {in: number, out: number}}) => any,
381
381
  * rates?: {in: number, out: number}|null, callOptions?: Record<string, any>,
382
382
  * createSurveyor?: (o: {workdir: string, granted: readonly string[], ctx: boolean}) => Promise<any>}} o
@@ -438,8 +438,10 @@ export async function runAuthorScout({
438
438
  // raw already rides. It REPORTS and decides nothing; the ceiling still binds
439
439
  // through `capStop` between calls, untouched.
440
440
  // bare-agent's per-run `thinkingStatus` rides the reporting seam only, never the stored entry (see makeCostBook.add)
441
- onCall({ ...call, ...(r?.thinkingStatus === undefined ? {} : { thinkingStatus: r.thinkingStatus }) });
442
- return raws.push(scrubRaw({ label, attempt, text: r?.text })) - 1;
441
+ // R9 (Part B 4): the scrubbed answer rides the same report, so the session's drafting log keeps what an unusable scout answer said (an empty one adds nothing)
442
+ const kept = scrubRaw({ label, attempt, text: r?.text });
443
+ onCall({ ...call, ...(kept.text === '' ? {} : { raw: kept.text }), ...(r?.thinkingStatus === undefined ? {} : { thinkingStatus: r.thinkingStatus }) });
444
+ return raws.push(kept) - 1;
443
445
  };
444
446
  // TIGHTEN-ONLY: an operator may lower the ceiling, never raise it. A garbage
445
447
  // value floors at one attempt rather than at zero — a scout that never ran is
@@ -679,7 +681,7 @@ export const LOOK_RECOVERY_PROMPT = 'You are out of looking turns. Report NOW, f
679
681
  * Run the look. `createLoop` is the same seam the repo scout has; nothing else here needs a live process.
680
682
  * @param {{texts: Record<string, string>, inputs: {n: number, label: string}[], jobLines: {n: number, text: string, rule?: string, rules?: string[]}[],
681
683
  * provider?: any, rounds?: number, maxTokens?: number, ceilingUsd?: number|null, callTimeoutMs?: number,
682
- * onCall?: (call: {label: string, costUsd: number|null, unpricedRounds: number, thinkingStatus?: string}) => void,
684
+ * onCall?: (call: {label: string, costUsd: number|null, unpricedRounds: number, thinkingStatus?: string, raw?: string}) => void,
683
685
  * createLoop?: (o: {system: string, policy: any, onLlmResult: any, provider: any, rates?: {in: number, out: number}}) => any,
684
686
  * rates?: {in: number, out: number}|null, callOptions?: Record<string, any>,
685
687
  * prove?: (source: string, phrase: string) => number}} o
@@ -701,8 +703,9 @@ export async function runInputLook({
701
703
  const record = (/** @type {string} */ label, /** @type {any} */ r) => {
702
704
  const call = { label, ...priceOf(r) };
703
705
  calls.push(call);
704
- onCall({ ...call, ...(r?.thinkingStatus === undefined ? {} : { thinkingStatus: r.thinkingStatus }) });
705
- raws.push(scrubRaw({ label, attempt: 1, text: r?.text }));
706
+ const kept = scrubRaw({ label, attempt: 1, text: r?.text });
707
+ onCall({ ...call, ...(kept.text === '' ? {} : { raw: kept.text }), ...(r?.thinkingStatus === undefined ? {} : { thinkingStatus: r.thinkingStatus }) });
708
+ raws.push(kept);
706
709
  };
707
710
  const settled = async (/** @type {Promise<any>} */ p) => {
708
711
  try { return await p; } catch (e) {
package/src/bridges.js CHANGED
@@ -50,7 +50,8 @@ export const BRIDGE_SCHEMA = 'bridge-v1';
50
50
  * SOFTGREEN MODULE 6 — the verdict classes whose greens are minted QUARANTINED.
51
51
  *
52
52
  * The standing ruling (PRD v1.53, given a mechanism by v1.71 §3): *softgreen
53
- * passes are quarantined from learning credit until the judged floor is proven*,
53
+ * passes are quarantined from learning credit until the judged floor is proven*
54
+ * (learning credit = reuse/bridge credit),
54
55
  * and **the signer's `accept` at the review door is what releases it**.
55
56
  *
56
57
  * `soft-green` and NOT `hitl`: the hold is about the young JUDGE, not about every
@@ -65,7 +66,7 @@ export const QUARANTINED_VERDICTS = Object.freeze(['soft-green']);
65
66
  * spelling, because three literals is how a hold silently becomes a breakage. */
66
67
  export const QUARANTINED_CODE = 'quarantined';
67
68
 
68
- /** does a green under this verdict class earn its learning credit at the close, or
69
+ /** does a green under this verdict class earn its reuse credit at the close, or
69
70
  * does it wait for a person? Absent/unknown means green's behaviour, byte for byte
70
71
  * — the pre-softgreen path is the default and stays untouched.
71
72
  * @param {unknown} verdictType @returns {boolean} */
@@ -525,7 +526,7 @@ export function reuseEligibility(bridge) {
525
526
  /**
526
527
  * THE REVIEW DOOR, written down (PRD v1.71 §3). The person read the finished run
527
528
  * and said one of three things; this records that on the run's own row, and — for
528
- * `accept` on a HELD green — releases the learning credit that green has been
529
+ * `accept` on a HELD green — releases the reuse credit that green has been
529
530
  * carrying unspent.
530
531
  *
531
532
  * Three properties, and each is a ruling rather than a convenience:
@@ -0,0 +1,42 @@
1
+ // MCP + tickets piece 9 (ITEM33-BUILD R7, port of fwd's `cardSchedule`, src/panel/authortrigger.js@v0.29.0): the $0 check of the New job card's Schedule row, before any session exists.
2
+ // The row's pick becomes the typed trigger the job is signed with (`spec.trigger`): "Every day at HH:MM" is the card's own data, "When a new ticket arrives" is filled from the card's
3
+ // Inputs (exactly one issues-list line) and the pick's tools, the same `ticketLookOf` the sign-time check and the scheduler's look read. By hand = no schedule at all: the key stays absent,
4
+ // so a job with no schedule hashes exactly as before. Pure; writes nothing.
5
+ import { validateTrigger, isClockTrigger, isTicketTrigger } from './trigger.js';
6
+ import { ticketInputLabels, ticketLookOf } from './ticketschedule.js';
7
+ import { parseTicketList } from './ticketshape.js';
8
+
9
+ /**
10
+ * @param {any} card the card as submitted (`card.schedule` = {kind, hour?, minute?, day?} or absent / null / {kind: 'hand'})
11
+ * @param {{ flowType: 'plain'|'mcp'|'tickets', pick: {server: string, tools: string[]}|null, inputs: Array<{label: string, value: string}>, hasSchedule?: (job: string) => boolean }} o
12
+ * `hasSchedule(job)` = the job (by the card's name) already has a schedule file: the card does not overwrite it
13
+ * @returns {{ok: true, trigger: import('./trigger.js').Trigger|null} | {ok: false, error: string}}
14
+ */
15
+ export function cardScheduleOf(card, o) {
16
+ const pick = card?.schedule;
17
+ if (pick === undefined || pick === null || pick.kind === 'hand') return { ok: true, trigger: null };
18
+ /** @param {string} error */
19
+ const no = (error) => ({ ok: /** @type {const} */ (false), error });
20
+ if (typeof pick !== 'object' || Array.isArray(pick)) return no('The Schedule is not something this card can sign. Nothing spent.');
21
+ if (typeof card.jobName === 'string' && card.jobName !== '' && o.hasSchedule?.(card.jobName)) {
22
+ return no(`The job "${card.jobName}" already has a schedule. Change it with Cancel / modify schedule on one of its runs. Nothing spent.`);
23
+ }
24
+ /** @type {unknown} */
25
+ let want = pick;
26
+ if (pick.kind === 'new-ticket') {
27
+ const spec = { flowType: o.flowType, mcp: o.pick, inputs: o.inputs };
28
+ const labels = ticketInputLabels(spec);
29
+ if (labels.length === 0) {
30
+ // the same sentence the sign-time check would say (not a Tickets job, no issues list, no list_issues signed)
31
+ const first = (o.inputs.find((i) => { const l = parseTicketList(i.value); return l.ok && l.kind === 'issue'; }) ?? o.inputs.find((i) => i.label))?.label ?? '';
32
+ const look = ticketLookOf(spec, { kind: 'new-ticket', input: first });
33
+ return no(`${look.ok ? 'This job cannot start on a new ticket.' : look.say.replace(/ Nothing was changed\.$/, '')} Nothing spent.`);
34
+ }
35
+ if (labels.length !== 1) return no('When a new ticket arrives needs exactly one ticket list in Inputs. Nothing spent.');
36
+ want = { kind: 'new-ticket', input: labels[0] };
37
+ }
38
+ const tv = validateTrigger(want);
39
+ if (!tv.ok) return no(`${tv.say}. Nothing spent.`);
40
+ if (!isClockTrigger(tv.trigger) && !isTicketTrigger(tv.trigger)) return no('The New job card can start a job every day or on a new ticket. A file trigger is set after the first good run. Nothing spent.');
41
+ return { ok: true, trigger: tv.trigger };
42
+ }
package/src/carrystore.js CHANGED
@@ -1,6 +1,6 @@
1
1
  // The carry note's store (M1, F258): the run-level record behind src/carrynote.js. It captures the worker's read-class tool
2
2
  // calls AT THE SOURCE (the worker's tool objects, result SUMMARIES only, never file
3
- // content), reads the run's edits from the WORKING TREE (git diff against the run's start commit, never the spine), renders
3
+ // content), reads the run's edits from the WORKING TREE (git diff against the run's start commit, never the spine), renders
4
4
  // the note and persists its state under `<workdir>/.smoke/carry/state.json` (an arbiter book: the worker's fs.deny covers
5
5
  // `.smoke`, so it cannot read it; the gate audit, spine and bridges live there too). There is no switch: the memo is
6
6
  // always on (hamr 2026-11-01).