bareloop 0.56.0 → 0.58.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (93) hide show
  1. package/CHANGELOG.md +80 -0
  2. package/README.md +3 -3
  3. package/bareloop.context.md +75 -214
  4. package/package.json +2 -2
  5. package/src/authorflow.js +71 -136
  6. package/src/authoring.js +5 -124
  7. package/src/authorjob.js +125 -417
  8. package/src/authorreadout.js +105 -355
  9. package/src/authorrun.js +70 -234
  10. package/src/authorscout.js +9 -1
  11. package/src/blockasks.js +12 -17
  12. package/src/bundlerun.js +4 -1
  13. package/src/checkblock.js +297 -75
  14. package/src/checklist.js +1 -1
  15. package/src/checkpick.js +9 -5
  16. package/src/cli.js +3 -3
  17. package/src/declaredclose.js +45 -112
  18. package/src/destpoint.js +1 -1
  19. package/src/draftspend.js +20 -4
  20. package/src/fencepointcall.js +76 -0
  21. package/src/guarddescriptions.js +14 -0
  22. package/src/index.js +3 -43
  23. package/src/interviewrun.js +13 -8
  24. package/src/job.js +20 -1
  25. package/src/jobblock.js +11 -46
  26. package/src/judged.js +13 -1229
  27. package/src/kinds.js +10 -348
  28. package/src/noteask.js +124 -0
  29. package/src/pagedry.js +27 -5
  30. package/src/pagemap.js +7 -29
  31. package/src/pagerules.js +18 -3
  32. package/src/panel/authorroutes.js +15 -4
  33. package/src/panel/authorsession.js +201 -167
  34. package/src/panel/importrun.js +0 -1
  35. package/src/panel/index.html +43 -18
  36. package/src/panel/jobplan.js +54 -19
  37. package/src/panel/server.js +90 -69
  38. package/src/panel/status.js +3 -0
  39. package/src/pickrecord.js +15 -54
  40. package/src/planrun.js +4 -48
  41. package/src/promptregisters.js +7 -17
  42. package/src/providerrows.js +0 -36
  43. package/src/providers.js +4 -25
  44. package/src/questionbox.js +34 -30
  45. package/src/reviewdoor.js +1 -1
  46. package/src/rowresults.js +69 -0
  47. package/src/rubricstep.js +136 -28
  48. package/src/run.js +2 -15
  49. package/src/stagewords.js +24 -0
  50. package/src/userrun.js +14 -111
  51. package/types/authorflow.d.ts +51 -137
  52. package/types/authoring.d.ts +1 -14
  53. package/types/authorjob.d.ts +14 -55
  54. package/types/authorreadout.d.ts +52 -80
  55. package/types/authorrun.d.ts +20 -0
  56. package/types/blockasks.d.ts +5 -11
  57. package/types/checkblock.d.ts +147 -28
  58. package/types/checklist.d.ts +2 -2
  59. package/types/checkpick.d.ts +5 -3
  60. package/types/cli.d.ts +1 -3
  61. package/types/declaredclose.d.ts +5 -33
  62. package/types/draftspend.d.ts +16 -2
  63. package/types/fencepointcall.d.ts +68 -0
  64. package/types/guarddescriptions.d.ts +7 -0
  65. package/types/index.d.ts +2 -4
  66. package/types/job.d.ts +8 -0
  67. package/types/jobblock.d.ts +8 -38
  68. package/types/judged.d.ts +7 -357
  69. package/types/kinds.d.ts +4 -104
  70. package/types/noteask.d.ts +76 -0
  71. package/types/pagedry.d.ts +13 -0
  72. package/types/pagemap.d.ts +2 -5
  73. package/types/pagerules.d.ts +7 -0
  74. package/types/panel/authorsession.d.ts +37 -5
  75. package/types/panel/jobplan.d.ts +15 -3
  76. package/types/panel/server.d.ts +46 -13
  77. package/types/panel/status.d.ts +5 -0
  78. package/types/pickrecord.d.ts +8 -13
  79. package/types/planrun.d.ts +1 -22
  80. package/types/providerrows.d.ts +0 -31
  81. package/types/providers.d.ts +3 -19
  82. package/types/questionbox.d.ts +20 -6
  83. package/types/rowresults.d.ts +23 -0
  84. package/types/rubricstep.d.ts +43 -7
  85. package/types/run.d.ts +1 -20
  86. package/types/stagewords.d.ts +11 -0
  87. package/types/userrun.d.ts +0 -1
  88. package/src/calibrate.js +0 -702
  89. package/src/cardauthor.js +0 -502
  90. package/src/fitcheck.js +0 -168
  91. package/types/calibrate.d.ts +0 -201
  92. package/types/cardauthor.d.ts +0 -358
  93. package/types/fitcheck.d.ts +0 -119
package/src/authorrun.js CHANGED
@@ -101,8 +101,7 @@
101
101
  // in; a draft missing one, or naming one the provider factory
102
102
  // does not know, dies here loud, listing the known table.
103
103
  import { keysForDoor } from './keysfile.js';
104
- import { judgeRatesFor, judgeRowFor, keyNameFor, keyValueOf, ratesFor, ratesOfLine, resolveWorker, rowsForHome } from './providerrows.js';
105
- import { ConfigError } from './config.js';
104
+ import { keyNameFor, keyValueOf, ratesFor, ratesOfLine, resolveWorker, rowsForHome } from './providerrows.js';
106
105
  import {
107
106
  readFileSync, writeFileSync, appendFileSync, mkdirSync, existsSync, statSync,
108
107
  } from 'node:fs';
@@ -116,24 +115,25 @@ import {
116
115
  import {
117
116
  makeLoopGenerate, CONFIRM_MENU, confirmSystemFor,
118
117
  } from './authorflow.js';
119
- import { defaultJudgeLoop, resolveJobJudge } from './judged.js';
120
118
  import { validateJob, jobSpecHash, resolveWorkerModel } from './job.js';
121
119
  import { scanSecrets, redactSecrets } from './validate.js';
122
120
  import { detectLanguage } from './detectlang.js';
123
121
  import { RUBRIC_LANG } from './authoring.js';
124
122
  import { rubricGoal } from './rubricstep.js';
125
123
  import { LEDGER_SYSTEM } from './checklist.js';
124
+ import { FENCE_POINT_SYSTEM } from './fencepointcall.js';
126
125
  import { ROW_EDIT_SYSTEM } from './rowedit.js';
127
126
  import { moveFile } from './movefile.js';
128
- import { closeJudges, GATE_AUDIT_FILE } from './kinds.js';
127
+ import { GATE_AUDIT_FILE } from './kinds.js';
129
128
  import { resolveProvider, buildRunnerProviders, apiKeyProblem } from './providers.js';
130
129
  import { commandFor } from './invoke.js';
131
130
  import { readSourceManifest, missingDependencies, nonRepoSourceMessage, isRubricFilesManifest } from './source.js';
132
131
  import { tallyCalls } from './text.js';
133
132
  import { splitReadNotes } from './pagedropwords.js';
133
+ import { answerEffectWords } from './questionbox.js';
134
134
  import {
135
- declarationLines, rubricLines, calibrationLines, parseCeiling, ceilingLine, crashRecord, phaseLine,
136
- openQuestionLines, answeredQuestionLines, fellBackLines, PLAIN_PROPOSAL_STOPS, proposalStopText, signingStopText,
135
+ declarationLines, parseCeiling, ceilingLine, crashRecord, phaseLine,
136
+ openQuestionLines, answeredQuestionLines, fellBackLines, signingStopText, buildReadout,
137
137
  } from './authorreadout.js';
138
138
 
139
139
  /** Thrown to unwind `main` to an exit code without ever calling
@@ -162,6 +162,60 @@ class ExitSignal extends Error {
162
162
  * never a script path they never invoked and may not have on disk.
163
163
  */
164
164
 
165
+ /**
166
+ * The lines the CLI prints for one question the plan raised: the ask, then (try-3 question, Addendum 2026-11-14 (c) piece 5) what the answer does, in the panel's own words ("This replaces: ..." or
167
+ * "This adds a new rule to line N"). Pure.
168
+ * @param {{index?: number, total?: number, question?: string, line?: number, replaces?: string, adds?: boolean, [k: string]: any}} step @returns {string[]}
169
+ */
170
+ export function answerPromptLines(step) {
171
+ const effect = answerEffectWords(step);
172
+ return [
173
+ `Question ${step.index} of ${step.total} the plan raised — it must be answered before the plan can be signed (pick "Start over" or "Fix" instead if you cannot answer it):`,
174
+ ` ? ${step.question}`,
175
+ ...(effect === null ? [] : [` ${effect}`]),
176
+ ];
177
+ }
178
+
179
+ /** the tag of a row by its kind, one spelling with the panel: `~ [you]`, `! [agent]`, `$ [default]` (a check with no row kind says nothing) @param {unknown} by @returns {string} */
180
+ const rowTag = (by) => (by === 'you' ? '~ [you]' : by === 'agent' ? '! [agent]' : by === 'default' ? '$ [default]' : '');
181
+
182
+ /**
183
+ * The confirm turn's plan as the CLI prints it, read from the SAME rows the panel card draws (Addendum 2026-11-14 (c) piece 3): every check is its row (line, tag, words), the protections are the
184
+ * write fence only for a job whose list holds the guards. A plan that carries no row items (a repo job) prints its plain `checks` as before. Pure: one string per printed line.
185
+ * @param {any} p the confirm plan @returns {string[]}
186
+ */
187
+ export function confirmPlanLines(p) {
188
+ /** @type {string[]} */
189
+ const out = ['THE PLAN — read before you pick:', ` goal ${JSON.stringify(p.goal ?? '')}`, ' checks it will compose:'];
190
+ const items = Array.isArray(p.checkItems) && p.checkItems.length ? p.checkItems : null;
191
+ if (items) {
192
+ for (const c of items) {
193
+ const line = Array.isArray(c.fromLine) && Number.isInteger(c.fromLine[0]) && c.fromLine[0] >= 1 ? `line ${c.fromLine[0]}: ` : '';
194
+ const tag = rowTag(c.by);
195
+ out.push(` · ${line}${tag ? `${tag} ` : ''}${c.text}`);
196
+ }
197
+ } else for (const c of p.checks ?? []) out.push(` · ${c}`);
198
+ // (a one-list job's guards and fence are rows above; the heading shows only when something is left)
199
+ if ((p.protections ?? []).length) {
200
+ out.push(' protections (always-on guards, never named in the goal):');
201
+ for (const g of p.protections) out.push(` · ${g}`);
202
+ }
203
+ const { notChecked: unchecked, readNotes } = splitReadNotes(p.notChecked, p.signedFacts);
204
+ if (unchecked.length) {
205
+ out.push(' you asked for these, but nothing checks them:');
206
+ for (const n of unchecked) out.push(` · ${n}`);
207
+ }
208
+ if (readNotes.length) {
209
+ out.push(` how the page was read · ${readNotes.length}:`);
210
+ for (const n of readNotes) out.push(` · ${n}`);
211
+ }
212
+ if ((p.questions ?? []).length) {
213
+ out.push(' open questions:');
214
+ for (const q of p.questions ?? []) out.push(` ? ${q}`);
215
+ }
216
+ return out;
217
+ }
218
+
165
219
  /**
166
220
  * Parses this script's own argv shape and runs the authoring pipeline
167
221
  * (scout, declaration loop, D9's gates) against the given (or real)
@@ -484,38 +538,6 @@ export async function main(argv, deps = {}) {
484
538
  const baseUrl = W.baseUrl;
485
539
  const AUTHOR_ROW = W.row;
486
540
 
487
- // THE JUDGE THIS RUN'S OWN WORKER RESOLVES TO (PRD item 32.1) — resolved ONCE,
488
- // here, from the DRAFT, and reused for BOTH the compose-time stamp (the
489
- // declaration-authoring call's own `judgeModel` argument, below) and the
490
- // calibration gate (`prepareSigning`'s `judgeModel` argument, further down).
491
- // `resolveJobJudge` is the one
492
- // spelling of "the named provider's own `tiers.sonnet` defaults an absent
493
- // model, then a signed `judge` override wins" that `scripts/run-u.mjs`
494
- // applies at run time (`resolveWorkerModel` + `resolveJudge`) — spelling that
495
- // composition twice by hand, once here at the wrong identity (the AUTHORING
496
- // provider/model) and once at the gate, was the bug this fixes: a close
497
- // calibrated against judge X got stamped with model Y, and only the run-time
498
- // read (`scripts/run-u.mjs:1144`) used the job's real worker, so the mismatch
499
- // surfaced as a recalibration refusal on the close's first real run.
500
- // `assembleSpec` carries `provider`/`model`/`judge` from the draft into the
501
- // spec untouched, so resolving again from the assembled spec below (where the
502
- // identity is guaranteed valid, because `validateJob` has already passed by
503
- // then) returns the byte-identical pair — one rule, read twice, not two rules.
504
- //
505
- // This first read runs BEFORE `validateJob` has seen the draft, so a draft
506
- // naming an unresolvable provider or a malformed `judge` override THROWS here
507
- // — caught, because that draft is going to red cleanly at `validateJob` a few
508
- // lines below regardless, and the placeholder this falls back to is discarded
509
- // unsigned the moment it does.
510
- const resolveDraftJudge = (/** @type {any} */ d) => {
511
- try {
512
- return resolveJobJudge(d, PROVIDER_NAME, resolveWorkerModel);
513
- } catch {
514
- return { provider: PROVIDER_NAME, model: MODEL };
515
- }
516
- };
517
- const draftJudge = resolveDraftJudge(draft);
518
-
519
541
  // Secrets load from the environment; they never enter argv (a command line is
520
542
  // world-readable on /proc) and they are never printed.
521
543
  // The key is the chosen row's own variable (P8: no built-in name). Names only.
@@ -538,15 +560,6 @@ export async function main(argv, deps = {}) {
538
560
  const al = ratesOfLine(W.line);
539
561
  authorPrice = al ? { ...al, envName: AUTHOR_ROW.envName } : null;
540
562
  }
541
- /** The judge's key follows the RESOLVED judge provider's own env var, with
542
- * `JUDGE_API_KEY` as the role-named override in front (PRD item 32.3) — the same
543
- * contract `scripts/run-u.mjs` keeps, so one story covers both surfaces. When the
544
- * judge IS the authoring provider this is the key already read above. */
545
- const judgeRowOf = (/** @type {{provider: string, model?: string|null}} */ j) => judgeRowFor(keyCfg, j, PROVIDER_NAME, AUTHOR_ROW);
546
- const judgeKeyFor = (/** @type {string} */ providerName) => (
547
- env.JUDGE_API_KEY ?? (providerName === PROVIDER_NAME ? apiKey : keyValueOf(env, judgeRowFor(keyCfg, { provider: providerName }, PROVIDER_NAME, AUTHOR_ROW)?.envName))
548
- );
549
-
550
563
  /** F6 — an unpriced call makes the TOTAL unknown, and unknown is reported as
551
564
  * UNKNOWN. `?? 0` launders unknown into $0, and a bare floor that reads as exact
552
565
  * is F6 in an honest coat, so the floor is marked `≥`.
@@ -577,17 +590,9 @@ export async function main(argv, deps = {}) {
577
590
  out(` ${ceilingLine(CEILING_USD)}`);
578
591
  out(' stops at prepareSigning — this script NEVER signs and NEVER runs the job\n');
579
592
 
580
- // F190 (docs/wiki/FINDINGS.md) — this used to be a hand-rolled `makeProvider`
581
- // call, a duplicate of the SAME construction `buildRunnerProviders` already
582
- // owns for `src/cli.js`. Routed through the one owner now: the judge half of
583
- // this call is a THROWAWAY (`judgeProviderName`/`judgeModel`/`judgeBaseUrl` all
584
- // equal the author's own identity, so `buildRunnerProviders`' own reuse check
585
- // returns the SAME instance as `provider` rather than constructing a second
586
- // one) — the real judge identity is not resolved until after `validateJob`,
587
- // further down, where a second call takes only its `.judgeProvider`.
593
+ // F190 (docs/wiki/FINDINGS.md): the one owner of the provider construction (`buildRunnerProviders`), shared with src/cli.js.
588
594
  const { provider } = buildRunnerProviders({
589
595
  providerName: PROVIDER_NAME, apiKey, model: MODEL, baseUrl, legacyMaxTokens: AUTHOR_ROW.legacyMaxTokens,
590
- judgeApiKey: apiKey, judgeModel: MODEL, judgeProviderName: PROVIDER_NAME, judgeBaseUrl: baseUrl,
591
596
  });
592
597
  emit('author-start', { runid, source: SOURCE, lang: LANG, verdictType: VERDICT, provider: PROVIDER_NAME, model: MODEL, baseUrl: baseUrl ?? null, job: draft?.job ?? null, timeoutMs: TIMEOUT_MS, ceilingUsd: CEILING_USD });
593
598
 
@@ -767,26 +772,7 @@ export async function main(argv, deps = {}) {
767
772
  return readFreeText(false);
768
773
  }
769
774
  if (step.kind === 'menu') {
770
- const p = step.plan ?? {};
771
- out('THE PLAN — read before you pick:');
772
- out(` goal ${JSON.stringify(p.goal ?? '')}`);
773
- out(' checks it will compose:');
774
- for (const c of p.checks ?? []) out(` · ${c}`);
775
- out(' protections (always-on guards, never named in the goal):');
776
- for (const g of p.protections ?? []) out(` · ${g}`);
777
- const { notChecked: unchecked, readNotes } = splitReadNotes(p.notChecked, p.signedFacts);
778
- if (unchecked.length) {
779
- out(' you asked for these, but nothing checks them:');
780
- for (const n of unchecked) out(` · ${n}`);
781
- }
782
- if (readNotes.length) {
783
- out(` how the page was read · ${readNotes.length}:`);
784
- for (const n of readNotes) out(` · ${n}`);
785
- }
786
- if ((p.questions ?? []).length) {
787
- out(' open questions:');
788
- for (const q of p.questions ?? []) out(` ? ${q}`);
789
- }
775
+ for (const l of confirmPlanLines(step.plan ?? {})) out(l);
790
776
  const keys = /** @type {(keyof typeof CONFIRM_MENU)[]} */ (Object.keys(CONFIRM_MENU));
791
777
  keys.forEach((k, i) => out(` ${i + 1}. ${CONFIRM_MENU[k]}`));
792
778
  for (;;) {
@@ -805,9 +791,7 @@ export async function main(argv, deps = {}) {
805
791
  // "Confirm"/"Type the goal yourself" cannot proceed until it is
806
792
  // answered, right here, with no extra model call. A blank line re-asks
807
793
  // the same question ("Start over" or "Fix" are the ways out).
808
- out(`Question ${step.index} of ${step.total} the plan raised — it must be answered before the plan can `
809
- + 'be signed (pick "Start over" or "Fix" instead if you cannot answer it):');
810
- out(` ? ${step.question}`);
794
+ for (const l of answerPromptLines(step)) out(l);
811
795
  return readFreeText(false);
812
796
  }
813
797
  if (step.kind === 'goal') {
@@ -868,13 +852,6 @@ export async function main(argv, deps = {}) {
868
852
  // `provider` drives the scout; `generate` is the declaration model boundary (one
869
853
  // bare-agent Loop per call, the tool wired to end the call it is used in).
870
854
  const authored = await authorCloseForJob({
871
- // the judge that will certify this close's calibration set, if it composes a
872
- // judged stage (PRD item 32.1). A DRAFT CAN carry a signed `judge` override
873
- // already (`judge` is an OPERATOR field, not one of `AUTHORED_SPEC_FIELDS`) —
874
- // `draftJudge`, resolved once above from the draft's own `provider`/`model`/
875
- // `judge`, is what the spec will resolve to at run time (`scripts/run-u.mjs`),
876
- // not this authoring run's own drafting identity.
877
- judgeModel: draftJudge.model,
878
855
  answers,
879
856
  verdictType: VERDICT,
880
857
  repoPath: SOURCE,
@@ -912,6 +889,7 @@ export async function main(argv, deps = {}) {
912
889
  ask, confirmGenerate, isRepo: !RUBRIC_FILES, langResult,
913
890
  // the one check list of a rubric job (src/checklist.js): same list as the panel, its one call bound to its own system text; this door asks nothing for it
914
891
  ledgerGenerate: RUBRIC_FILES ? makeLoopGenerate(provider, { system: LEDGER_SYSTEM, rates: authorPrice?.rates ?? null }) : null,
892
+ fenceGenerate: RUBRIC_FILES ? null : makeLoopGenerate(provider, { system: FENCE_POINT_SYSTEM, rates: authorPrice?.rates ?? null }),
915
893
  // the drafter's row-edit reply of a rubric job (src/rowedit.js), its own system text
916
894
  editGenerate: RUBRIC_FILES ? makeLoopGenerate(provider, { system: ROW_EDIT_SYSTEM, rates: authorPrice?.rates ?? null }) : null,
917
895
  });
@@ -997,15 +975,6 @@ export async function main(argv, deps = {}) {
997
975
  if (r.red) out(` red: ${JSON.stringify(r.red)}`);
998
976
  for (const e of refusalEvents(r)) emit(e.type, e);
999
977
  }
1000
- // a refused rubric proposal reads in plain words FIRST (the same text the panel shows), the technical reds after
1001
- if (PLAIN_PROPOSAL_STOPS.includes(String(authored.stop))) {
1002
- out(`\n${proposalStopText({
1003
- stop: String(authored.stop), reds: authored.reds ?? [],
1004
- cases: authored.judged?.signed?.cases ?? authored.judged?.proposal?.proposal?.cases ?? null,
1005
- spend: authored.cost ? { knownUsd: authored.cost.knownUsd ?? null, spendComplete: authored.cost.spendComplete ?? null } : null,
1006
- source: authored.judged?.source === 'signer' ? 'signer' : 'proposal',
1007
- })}`);
1008
- }
1009
978
  for (const red of authored.reds ?? []) {
1010
979
  out(`\nRED ${red.code} at ${red.path}\n${red.detail}`);
1011
980
  emit('job-red', red);
@@ -1053,21 +1022,6 @@ export async function main(argv, deps = {}) {
1053
1022
  // this block is otherwise reachable only after a paid scout and a paid model call,
1054
1023
  // and a readout no test can reach is a readout nothing checks.
1055
1024
  for (const l of declarationLines(spec)) out(l);
1056
- // …and, for a close that JUDGES, the two artifacts the judge is signed with.
1057
- // NAMED DEFERRAL, said out loud rather than implied: this script's ONE
1058
- // interactive seam is the confirm turn above (PRD item 33 M3 piece 4,
1059
- // step S4) — it does not ALSO offer the D5 fix step here, so the
1060
- // proposal is signed AS PROPOSED. The library seam exists
1061
- // (`authorCloseForJob({signerFix})`) and the interactive surface for IT
1062
- // is the interview's and the UI's (N6), which is the same split the
1063
- // guard battery already lives under here: shown, not edited at this surface.
1064
- const rubric = rubricLines(spec);
1065
- if (rubric.length) {
1066
- for (const l of rubric) out(l);
1067
- out(` source ${authored.judged?.source ?? 'unknown'}`
1068
- + (authored.judged?.source === 'proposal' ? ' (proposed and stored unedited — this script offers no fix step)' : ''));
1069
- for (const s of authored.judged?.scrubbed ?? []) out(` MASKED ${s.path} — the stored bytes differ from what was typed`);
1070
- }
1071
1025
  out(`written ${specFile}`);
1072
1026
 
1073
1027
  // `shellCapUsd` COUPLES to the spec's own budget, exactly as run-u does it at the
@@ -1088,97 +1042,6 @@ export async function main(argv, deps = {}) {
1088
1042
  } else {
1089
1043
  // ── 3. D9's gates. Nothing here judges the close; it measures it. ────────
1090
1044
  //
1091
- // THE JUDGE SEAM, wired only when the close actually judges. It is a
1092
- // A SEPARATE provider instance for the judge: its tier is never the
1093
- // drafter's model and never agent-selectable, and §4.2's safety argument is
1094
- // worth exactly as much as the tier its injection evidence was measured on.
1095
- // Absent it, `prepareSigning` refuses the close as a wiring gap rather than
1096
- // signing an ungraded ruler.
1097
- const judges = closeJudges(spec.closeDecl);
1098
- // THE JUDGE, RESOLVED (PRD item 32.1) — the job's OWN worker provider and
1099
- // model by default, a signed `judge` override when the spec names one.
1100
- // Resolved from the ASSEMBLED SPEC through the same `resolveJobJudge` call
1101
- // as `draftJudge` above; `provider`/`model`/`judge` reached here unchanged
1102
- // from the draft, so this is the identical pair — the calibration gate
1103
- // STAMPS the graded set with whatever this resolves to, so the identity
1104
- // that certifies the floor here must be the identity the close will later
1105
- // refuse to grade without (and the identity `scripts/run-u.mjs` resolves).
1106
- const judge = judges
1107
- ? resolveJobJudge(spec, PROVIDER_NAME, resolveWorkerModel)
1108
- : null;
1109
- // the judge's price: the judge model's own row (`judgeRatesFor`) — on the author's endpoint when the
1110
- // judge is the same provider, else the row for the judge's own provider. A bad one refuses here,
1111
- // before the calibration gate spends anything — beside the judge-key check, the same door.
1112
- /** @type {ReturnType<typeof ratesFor>} */
1113
- let judgePrice = null;
1114
- if (judge) {
1115
- try {
1116
- judgePrice = judgeRatesFor(judge, PROVIDER_NAME, baseUrl, authorPrice, keyCfg);
1117
- } catch (e) {
1118
- if (!(e instanceof ConfigError)) throw e;
1119
- err(`${e.message} — refusing before the calibration gate spends anything`);
1120
- archiveGateAudit();
1121
- throw new ExitSignal(2);
1122
- }
1123
- }
1124
- // F181 — the judge key is required exactly when `judges` is true (this
1125
- // script has no presence check on it today; adding one is out of this
1126
- // finding's scope). What this door DOES owe, the same as the worker
1127
- // key above: a resolved value that IS present but carries a shape an
1128
- // HTTP header cannot refuses here, before the calibration gate spends
1129
- // anything, rather than crashing mid-call.
1130
- // `if (judge)` rather than `if (judges)`: identical at runtime (`judge`
1131
- // is non-null exactly when `judges` is true, by the ternary just above)
1132
- // but this form is what actually narrows `judge` for tsc below, honestly,
1133
- // rather than a cast past what it can prove.
1134
- if (judge) {
1135
- const judgeKeyValue = judgeKeyFor(judge.provider);
1136
- const judgeKeyProblem = judgeKeyValue ? apiKeyProblem(judgeKeyValue) : null;
1137
- if (judgeKeyProblem) {
1138
- const judgeEnvName = env.JUDGE_API_KEY ? 'JUDGE_API_KEY' : (judgeRowOf(judge)?.envName ?? judge.provider);
1139
- err(`${judgeEnvName} ${judgeKeyProblem} — refusing rather than crashing mid-call (never trimmed or repaired; fix the value at its source)`);
1140
- // F186 — the scout above already ran and may have left its own gate
1141
- // audit in the tree. Under `process.exit()` this path used to skip
1142
- // the finally block below entirely, so the audit was archived here
1143
- // explicitly. A thrown ExitSignal now DOES reach the finally block
1144
- // (unlike process.exit()) — archiveGateAudit() runs again there —
1145
- // but the call stays here too: it is idempotent (`gateAuditArchived`
1146
- // guards it), and this keeps the archive from ever depending on the
1147
- // finally block running first, the same defensive reasoning F186
1148
- // was written under.
1149
- archiveGateAudit();
1150
- throw new ExitSignal(2);
1151
- }
1152
- }
1153
- // F190 — `baseUrl` rides along only when the judge is the SAME provider
1154
- // as the author/worker: a spec's `baseUrl` is the AUTHOR's endpoint, and
1155
- // handing it to a different vendor's client is the silent-misconfiguration
1156
- // class `endpointKey` exists to prevent (a DeepSeek key sent to the
1157
- // openai-api default host, e.g.). Routed through `buildRunnerProviders`
1158
- // (the ONE owner of this construction — `src/cli.js` and, above,
1159
- // this file's own author provider) rather than a hand-rolled
1160
- // `makeProvider` call: the `providerName`/`apiKey`/`model`/`tierModels`/
1161
- // `baseUrl` half repeats the author's own identity (so its `provider`
1162
- // half of the return, unused here, is a throwaway — never a second live
1163
- // instance of the author's client), and the `judge*` half is this run's
1164
- // OWN resolved judge — the identical conditional `scripts/run-u.mjs`'s
1165
- // own call already applies.
1166
- // an if/else, not the equivalent ternary — the ternary's own ok-branch
1167
- // object literal did not narrow `judge` for tsc; this form does, the
1168
- // same real-narrowing reasoning as the `if (judge)` above.
1169
- let judgeProvider = null;
1170
- if (judge) {
1171
- judgeProvider = buildRunnerProviders({
1172
- providerName: PROVIDER_NAME, apiKey, model: MODEL, baseUrl, legacyMaxTokens: AUTHOR_ROW.legacyMaxTokens,
1173
- judgeApiKey: judgeKeyFor(judge.provider), judgeModel: judge.model, judgeProviderName: judge.provider,
1174
- judgeBaseUrl: judge.provider === PROVIDER_NAME ? baseUrl : (judgeRowOf(judge)?.baseUrl.trim() || undefined),
1175
- judgeLegacyMaxTokens: judge.provider === PROVIDER_NAME ? AUTHOR_ROW.legacyMaxTokens : (judgeRowOf(judge)?.legacyMaxTokens ?? false),
1176
- }).judgeProvider;
1177
- }
1178
- if (judge) {
1179
- out(`\ncalibration gate — REAL judge calls at ${judge.model} on ${judge.provider}, one per case plus the injection battery.`);
1180
- out(' this is the only gate that spends money, and it runs after every free one.');
1181
- }
1182
1045
  // the end check: a rubric close with no real check is refused here, whatever the seed gate would say (the stop words are printed below from signingStopText)
1183
1046
  const signing = authored.hasBuiltCheck === false
1184
1047
  ? { ok: false, reds: [], refusal: null, specHash: null, seedRef: authored.seedRef, gates: { declaration: { ok: true, grounded: '-' }, precheck: null, seedVerdict: null }, work: [], guards: [], stops: [] }
@@ -1187,20 +1050,6 @@ export async function main(argv, deps = {}) {
1187
1050
  // gate 1a re-runs the job validator inside prepareSigning — same coupling, or
1188
1051
  // the spec that just passed above would fail the gate that signs it
1189
1052
  shellCapUsd: spec.budgetUsd,
1190
- // …and the SAME operator ceiling the scout and the declaration loop ran under,
1191
- // with everything they spent folded in. The gate is this run's third and
1192
- // largest paid seam; without both halves the advertised budget and the
1193
- // enforced budget are two different numbers, and re-invoking a seam under one
1194
- // number would silently widen it.
1195
- ceilingUsd: CEILING_USD,
1196
- priorCalls: [...metered],
1197
- judgeLoop: judgeProvider ? (o) => defaultJudgeLoop({ provider: judgeProvider, system: o.system, rates: judgePrice?.rates ?? null, thinking: spec.thinking === true }) : null,
1198
- // the seam's other half (PRD item 32.1): the graded set is STAMPED with
1199
- // this, and the close later refuses to grade under any other identity.
1200
- judgeModel: judge?.model ?? null,
1201
- // the gate's spend joins the run's ONE metered list, under the judge call's
1202
- // own label — a close's calibration is money like any other money (F12)
1203
- onJudgeCost: (c) => onCall({ label: `${c.label}:${c.id}`, costUsd: c.costUsd, unpricedRounds: c.unpricedRounds }),
1204
1053
  });
1205
1054
  const signingFile = writeOut('signing.json', signing);
1206
1055
  emit('signing', { ok: signing.ok, specHash: signing.specHash, seedRef: signing.seedRef, gates: signing.gates });
@@ -1209,28 +1058,15 @@ export async function main(argv, deps = {}) {
1209
1058
  out('\ngates');
1210
1059
  out(` 1 declaration ${g.declaration?.ok ? 'PASS' : 'FAIL'} grounded=${g.declaration?.grounded ?? '-'}${g.declaration?.scoped ? ` scoped=${JSON.stringify(g.declaration.scoped)}` : ''}`);
1211
1060
  out(` 2 precheck ${g.precheck === null ? 'not reached' : (g.precheck.ok ? 'PASS — every stage ran' : `FAIL — ${g.precheck.stops.length} stage(s) could not run`)}`);
1212
- // ruling 3: the judged-ONLY close clears this gate on its calibration, so the
1213
- // line says PASS and names the proof — printing FAIL beside a signable spec
1214
- // would be the readout disagreeing with the gate it reports on
1215
1061
  out(` 3 seed verdict ${g.seedVerdict === null
1216
1062
  ? 'not reached'
1217
1063
  : (g.seedVerdict.ok
1218
1064
  ? `PASS — work red at seed: ${g.seedVerdict.workRed.join(', ')}`
1219
- : (g.seedVerdict.satisfiedBy === 'calibration'
1220
- ? 'PASS via the CALIBRATION gate — this close carries a judged stage'
1221
- : 'FAIL — no work stage is red at the seed'))}`);
1065
+ : 'FAIL — no work stage is red at the seed')}`);
1222
1066
  if (g.seedVerdict) {
1223
1067
  out(` red at seed: ${g.seedVerdict.redAtSeed.join(', ') || '(none)'}`);
1224
1068
  out(` green at seed: ${g.seedVerdict.greenAtSeed.join(', ') || '(none)'}`);
1225
- // ruling 3 (widened 2026-10-09): a close with a judged stage clears gate 3 on its calibration instead,
1226
- // and the surface SAYS which proof carried it rather than leaving a reader
1227
- // to wonder why an empty workRed list passed
1228
- if (g.seedVerdict.satisfiedBy === 'calibration') {
1229
- out(' a judged stage skips the seed read (ruling 8), so this close\'s proof that its judged stage CAN fail is');
1230
- out(' the graded calibration set below — signed cases it must red as well as ones it must pass.');
1231
- }
1232
1069
  }
1233
- if (judges) for (const l of calibrationLines(g.calibration)) out(l);
1234
1070
 
1235
1071
  /** the seed evidence a user READS to decide whether this close measures their
1236
1072
  * job. `value`/`baseline` print as `unknown` when absent — never as 0. */
@@ -1275,13 +1111,10 @@ export async function main(argv, deps = {}) {
1275
1111
  if (signing.specHash && signing.specHash !== hash) {
1276
1112
  out(` NOTE prepareSigning hashed ${signing.specHash} — the validator normalized the spec; sign the resolved one.`);
1277
1113
  }
1278
- // THE WHOLE RUN's spend, off the ONE metered list — which now has two
1279
- // populations in it. Gates 1-3 spend no tokens (they run commands); gate 4
1280
- // buys a real judge call per case, so a line saying "the gates spend no
1281
- // tokens" would have been false the moment a judged close reached here.
1114
+ // THE WHOLE RUN's spend, off the ONE metered list. Gates 1-3 spend no tokens (they run commands).
1282
1115
  out(`authoring ${costLine(authored.cost)}`);
1283
1116
  const totalCost = costSoFar();
1284
- out(`total cost ${costLine(totalCost)}${judges ? ' (includes the calibration gate\'s judge calls)' : ' (gates 1-3 spend no tokens — they run commands)'}`);
1117
+ out(`total cost ${costLine(totalCost)} (gates 1-3 spend no tokens — they run commands)`);
1285
1118
  // hamr's ruling 2026-09-28 ("one cap covers drafting + run") — this
1286
1119
  // run's own known FLOOR (never $0 on an unpriced call, F6), handed to
1287
1120
  // the run-u command below as `--draft-spent-usd` so the SIGNED run's
@@ -1298,6 +1131,9 @@ export async function main(argv, deps = {}) {
1298
1131
  out('\nSIGNING PREPARED — NOT SIGNED. This script stops here, by design.');
1299
1132
  out(` the resolved spec is ${specFile} and it hashes to ${hash}`);
1300
1133
  out(' read the seed evidence above; if the close measures your job, the signature is yours to give.');
1134
+ // the same draft readout the panel Chat shows (hamr 2026-11-15; src/authorreadout.js, the one owner): what the person is about to sign, from the signed spec through the card's own readers
1135
+ out('');
1136
+ for (const l of buildReadout({ spec, rounds: totalCost.calls.length, costUsd: totalCost.knownUsd, spendComplete: totalCost.spendComplete, specHash: hash }).trimEnd().split('\n')) out(` ${l}`);
1301
1137
  for (const l of openQuestionLines(authored.confirmed)) out(` ${l}`);
1302
1138
  for (const l of answeredQuestionLines(authored.confirmed)) out(` ${l}`);
1303
1139
  // F185 — the loose end this fix closes: until now this screen named no
@@ -804,9 +804,17 @@ export const cleanEntry = (e) => String(e ?? '').split(' (')[0].trim().replace(/
804
804
  * @returns {Promise<{stop: string, files: null}|{stop: null, files: string[]}>}
805
805
  */
806
806
  export async function seedFileList(workdir, seedRef) {
807
- return seedListing(workdir, seedRef);
807
+ const r = await seedListing(workdir, seedRef);
808
+ if (r.stop !== null) return r;
809
+ // the engine's own stores are never the person's files: a patient that tracks bareloop's `.bareloop/`, `.smoke/` or `.litectx/` must not offer them to the drafter or to code's proofs (hamr 2026-11-15: a leftover
810
+ // `.bareloop/wt/.../src/sum.js` "kept" a rule). A prefix at the repo root only: `src/.smoke/x` is the person's own path.
811
+ const own = [...ARBITER_BOOK_STORES, BARELOOP_STORE];
812
+ return { stop: null, files: r.files.filter((f) => !own.some((s) => f === s || f.startsWith(`${s}/`))) };
808
813
  }
809
814
 
815
+ /** the engine's own repo-root store of work trees and notes, beside the arbiter books */
816
+ const BARELOOP_STORE = '.bareloop';
817
+
810
818
  /** `src/*` style entries match by segment; everything else is a path prefix.
811
819
  * @param {string} entry @returns {(f: string) => boolean} */
812
820
  function matcherFor(entry) {
package/src/blockasks.js CHANGED
@@ -1,29 +1,24 @@
1
1
  // The questions of the check block, as the answer gate reads them (`answerQuestions`, src/questionbox.js): ONE spelling of the question words, written by code from a row that
2
- // code could not settle (reading | cant-check | check). The block's `open` list is the source; the person's CHOICE (agree | drop | rule) goes back through `block.applyAnswer`.
3
- import { readingQuestion, cantCheckQuestion } from './pagemap.js';
4
- import { plainWords, HOW_TO_ANSWER, CANT_CHECK_WORDS } from './checkpick.js';
2
+ // code could not settle (reading | check), BUTTONS ONLY (hamr 2026-11-15: Agree, and Drop it on a proposed check). A rule no check can prove has no question: it is Not checked at once (src/checkblock.js).
3
+ // The block's `open` list is the source; the person's CHOICE (agree | drop) goes back through `block.applyAnswer`.
4
+ import { readingQuestion } from './pagemap.js';
5
+ import { plainWords } from './checkpick.js';
5
6
 
6
- /** @typedef {{key: string, rowKey: string, line: number, rule: number, source: 'look', ask: 'reading'|'cant-check'|'no-check'|'check', ruleText: string, question: string, counted: boolean, reading?: string, check?: Record<string, any>, pairRule?: number}} BlockAsk */
7
+ /** @typedef {{key: string, rowKey: string, line: number, rule: number, source: 'look', ask: 'reading'|'check', ruleText: string, question: string, counted: boolean, reading?: string, check?: Record<string, any>}} BlockAsk */
7
8
 
8
9
  /**
9
- * The questions the block has open, in the order the person meets them: the look's readings, then the look's can't-checks, then the pick path's asks (a proposal or a can't-check about a rule the pick path owns) in rule order (a proposal is not counted toward the 3-ask cap).
10
- * A can't-check about a rule the PICK path owns (`scoped`: src/checkpick.js scopedRules, every `~` rule of a file job) is the pick path's own ask, `no-check`, in fwd's words (a "Line N, guardrail ...: I can't check this" ask
11
- * whose answer the panel records as a pick, so Revise carries it: am17/am18/am21); any other can't-check is the look's own ask about a page.
12
- * @param {import('./checkblock.js').CheckBlock} block @param {{line: number, rule: number}[]} [scoped] @returns {BlockAsk[]}
10
+ * The questions the block has open, in the order the person meets them: the look's readings, then the pick path's check proposals in rule order (a proposal is not counted toward the 3-ask cap).
11
+ * @param {import('./checkblock.js').CheckBlock} block @returns {BlockAsk[]}
13
12
  */
14
- export function questionsOfBlock(block, scoped = []) {
15
- const rank = { reading: 0, 'cant-check': 1, 'no-check': 2, check: 2 };
13
+ export function questionsOfBlock(block) {
14
+ const rank = { reading: 0, check: 1 };
16
15
  return block.open.map((/** @type {any} */ q) => {
17
16
  const row = block.rows.find((r) => r.key === q.rowKey);
18
17
  const rule = Number(row?.rule);
19
- const base = { key: q.key, rowKey: q.rowKey, line: q.line, rule, source: /** @type {'look'} */ ('look'), ruleText: String(q.ruleText), ...(row?.pairWith !== undefined ? { pairRule: row.pairWith } : {}) };
18
+ const base = { key: q.key, rowKey: q.rowKey, line: q.line, rule, source: /** @type {'look'} */ ('look'), ruleText: String(q.ruleText) };
20
19
  if (q.ask === 'reading') return { ...base, ask: /** @type {'reading'} */ ('reading'), counted: true, reading: String(q.proposal), question: readingQuestion(q.line, String(q.ruleText), String(q.proposal)) };
21
- if (q.ask === 'check') {
22
- const words = plainWords(q.proposal);
23
- return { ...base, ask: /** @type {'check'} */ ('check'), counted: false, reading: words, check: q.proposal, question: `Line ${q.line}, guardrail "${q.ruleText}": I propose ${words}. ${HOW_TO_ANSWER(q.line, true)}` };
24
- }
25
- if (scoped.some((x) => x.line === q.line && x.rule === rule)) return { ...base, ask: /** @type {'no-check'} */ ('no-check'), counted: true, question: `Line ${q.line}, guardrail "${q.ruleText}": ${CANT_CHECK_WORDS} ${HOW_TO_ANSWER(q.line, false)}` };
26
- return { ...base, ask: /** @type {'cant-check'} */ ('cant-check'), counted: true, question: cantCheckQuestion(q.line, String(q.ruleText)) };
20
+ const words = plainWords(q.proposal);
21
+ return { ...base, ask: /** @type {'check'} */ ('check'), counted: false, reading: words, check: q.proposal, question: `Line ${q.line}, guardrail "${q.ruleText}": I propose ${words}.` };
27
22
  }).sort((a, b) => rank[a.ask] - rank[b.ask]);
28
23
  }
29
24
 
package/src/bundlerun.js CHANGED
@@ -24,7 +24,7 @@ import {
24
24
  import { askRequired, isQuit } from './prompts.js';
25
25
  import { askBundle, resolveBundleRef } from './bundleref.js';
26
26
  import { rowsForHome, chatLines } from './providerrows.js';
27
- import { jobSpecHash } from './job.js';
27
+ import { jobSpecHash, oldJobWords } from './job.js';
28
28
  import { addWorktree, worktreePath, commitWork } from './worktree.js';
29
29
  import { parseJsonl } from './replayio.js';
30
30
  import { legsOf } from './legs.js';
@@ -93,6 +93,9 @@ export async function bundleMain(args, {
93
93
  // the repo. Any red (incl. bundle-tampered) stops here.
94
94
  const bundle = readBundle(bundleDir);
95
95
  if (!bundle.ok) { printReds(bundle.reds, err); return 1; }
96
+ // hamr 2026-11-14 (piece 6): a bundle of a job made with PASS/FAIL examples or the old judge does not run; old runs are not repaired
97
+ const oldJob = oldJobWords(bundle.spec);
98
+ if (oldJob !== null) { err(oldJob); return 1; }
96
99
 
97
100
  // 1b. F128 — the bundle's OWN node_modules must carry `bareloop` before anything else
98
101
  // runs. Left unchecked, the close crashes deep inside runJob's close-first precheck with