bareloop 0.55.0 → 0.57.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 +82 -0
- package/README.md +3 -3
- package/bareloop.context.md +69 -209
- package/package.json +2 -2
- package/src/authorflow.js +164 -340
- package/src/authoring.js +7 -127
- package/src/authorjob.js +139 -472
- package/src/authorreadout.js +24 -368
- package/src/authorrun.js +21 -215
- package/src/behaviour.js +14 -0
- package/src/blockasks.js +43 -0
- package/src/bundlerun.js +4 -1
- package/src/checkblock.js +798 -0
- package/src/checklist.js +128 -0
- package/src/checkpick.js +39 -312
- package/src/checkwords.js +3 -1
- package/src/cli.js +3 -3
- package/src/declaredclose.js +38 -108
- package/src/destpoint.js +4 -2
- package/src/draftspend.js +46 -0
- package/src/facts.js +8 -1
- package/src/index.js +3 -43
- package/src/interviewrun.js +13 -8
- package/src/job.js +20 -1
- package/src/jobblock.js +11 -46
- package/src/judged.js +13 -1229
- package/src/kinds.js +5 -347
- package/src/noteask.js +124 -0
- package/src/pagedry.js +27 -5
- package/src/pagemap.js +15 -3
- package/src/pagerules.js +18 -3
- package/src/panel/authorroutes.js +24 -6
- package/src/panel/authorsession.js +222 -177
- package/src/panel/importrun.js +0 -1
- package/src/panel/index.html +198 -26
- package/src/panel/jobplan.js +87 -33
- package/src/panel/server.js +74 -68
- package/src/panel/status.js +3 -0
- package/src/pickrecord.js +34 -55
- package/src/placerule.js +355 -0
- package/src/planrun.js +2 -48
- package/src/promptregisters.js +13 -17
- package/src/providerrows.js +0 -36
- package/src/providers.js +4 -25
- package/src/questionbox.js +104 -0
- package/src/rowedit.js +115 -0
- package/src/rubricstep.js +234 -127
- package/src/run.js +11 -16
- package/src/userrun.js +60 -112
- package/types/authorflow.d.ts +41 -197
- package/types/authoring.d.ts +1 -14
- package/types/authorjob.d.ts +35 -59
- package/types/authorreadout.d.ts +10 -88
- package/types/behaviour.d.ts +12 -0
- package/types/blockasks.d.ts +36 -0
- package/types/checkblock.d.ts +376 -0
- package/types/checklist.d.ts +134 -0
- package/types/checkpick.d.ts +8 -140
- package/types/cli.d.ts +1 -3
- package/types/declaredclose.d.ts +7 -33
- package/types/destpoint.d.ts +2 -0
- package/types/draftspend.d.ts +21 -0
- package/types/index.d.ts +2 -4
- package/types/job.d.ts +8 -0
- package/types/jobblock.d.ts +8 -38
- package/types/judged.d.ts +7 -357
- package/types/kinds.d.ts +3 -104
- package/types/noteask.d.ts +76 -0
- package/types/pagedry.d.ts +13 -0
- package/types/pagemap.d.ts +4 -0
- package/types/pagerules.d.ts +7 -0
- package/types/panel/authorsession.d.ts +47 -5
- package/types/panel/jobgrid.d.ts +8 -8
- package/types/panel/jobplan.d.ts +48 -10
- package/types/panel/server.d.ts +27 -18
- package/types/panel/status.d.ts +5 -0
- package/types/pickrecord.d.ts +20 -13
- package/types/placerule.d.ts +194 -0
- package/types/planrun.d.ts +1 -22
- package/types/providerrows.d.ts +0 -31
- package/types/providers.d.ts +3 -19
- package/types/questionbox.d.ts +87 -0
- package/types/rowedit.d.ts +32 -0
- package/types/rubricstep.d.ts +100 -48
- package/types/run.d.ts +9 -19
- package/types/userrun.d.ts +0 -1
- package/src/calibrate.js +0 -702
- package/src/cardauthor.js +0 -502
- package/src/fitcheck.js +0 -166
- package/types/calibrate.d.ts +0 -201
- package/types/cardauthor.d.ts +0 -358
- package/types/fitcheck.d.ts +0 -113
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 {
|
|
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';
|
|
@@ -114,24 +113,25 @@ import {
|
|
|
114
113
|
REFUSAL_LIB, REFUSAL_CATEGORY,
|
|
115
114
|
} from './authorjob.js';
|
|
116
115
|
import {
|
|
117
|
-
makeLoopGenerate, CONFIRM_MENU,
|
|
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';
|
|
123
|
+
import { LEDGER_SYSTEM } from './checklist.js';
|
|
124
|
+
import { ROW_EDIT_SYSTEM } from './rowedit.js';
|
|
125
125
|
import { moveFile } from './movefile.js';
|
|
126
|
-
import {
|
|
126
|
+
import { GATE_AUDIT_FILE } from './kinds.js';
|
|
127
127
|
import { resolveProvider, buildRunnerProviders, apiKeyProblem } from './providers.js';
|
|
128
128
|
import { commandFor } from './invoke.js';
|
|
129
129
|
import { readSourceManifest, missingDependencies, nonRepoSourceMessage, isRubricFilesManifest } from './source.js';
|
|
130
130
|
import { tallyCalls } from './text.js';
|
|
131
131
|
import { splitReadNotes } from './pagedropwords.js';
|
|
132
132
|
import {
|
|
133
|
-
declarationLines,
|
|
134
|
-
openQuestionLines, answeredQuestionLines, fellBackLines,
|
|
133
|
+
declarationLines, parseCeiling, ceilingLine, crashRecord, phaseLine,
|
|
134
|
+
openQuestionLines, answeredQuestionLines, fellBackLines, signingStopText,
|
|
135
135
|
} from './authorreadout.js';
|
|
136
136
|
|
|
137
137
|
/** Thrown to unwind `main` to an exit code without ever calling
|
|
@@ -482,38 +482,6 @@ export async function main(argv, deps = {}) {
|
|
|
482
482
|
const baseUrl = W.baseUrl;
|
|
483
483
|
const AUTHOR_ROW = W.row;
|
|
484
484
|
|
|
485
|
-
// THE JUDGE THIS RUN'S OWN WORKER RESOLVES TO (PRD item 32.1) — resolved ONCE,
|
|
486
|
-
// here, from the DRAFT, and reused for BOTH the compose-time stamp (the
|
|
487
|
-
// declaration-authoring call's own `judgeModel` argument, below) and the
|
|
488
|
-
// calibration gate (`prepareSigning`'s `judgeModel` argument, further down).
|
|
489
|
-
// `resolveJobJudge` is the one
|
|
490
|
-
// spelling of "the named provider's own `tiers.sonnet` defaults an absent
|
|
491
|
-
// model, then a signed `judge` override wins" that `scripts/run-u.mjs`
|
|
492
|
-
// applies at run time (`resolveWorkerModel` + `resolveJudge`) — spelling that
|
|
493
|
-
// composition twice by hand, once here at the wrong identity (the AUTHORING
|
|
494
|
-
// provider/model) and once at the gate, was the bug this fixes: a close
|
|
495
|
-
// calibrated against judge X got stamped with model Y, and only the run-time
|
|
496
|
-
// read (`scripts/run-u.mjs:1144`) used the job's real worker, so the mismatch
|
|
497
|
-
// surfaced as a recalibration refusal on the close's first real run.
|
|
498
|
-
// `assembleSpec` carries `provider`/`model`/`judge` from the draft into the
|
|
499
|
-
// spec untouched, so resolving again from the assembled spec below (where the
|
|
500
|
-
// identity is guaranteed valid, because `validateJob` has already passed by
|
|
501
|
-
// then) returns the byte-identical pair — one rule, read twice, not two rules.
|
|
502
|
-
//
|
|
503
|
-
// This first read runs BEFORE `validateJob` has seen the draft, so a draft
|
|
504
|
-
// naming an unresolvable provider or a malformed `judge` override THROWS here
|
|
505
|
-
// — caught, because that draft is going to red cleanly at `validateJob` a few
|
|
506
|
-
// lines below regardless, and the placeholder this falls back to is discarded
|
|
507
|
-
// unsigned the moment it does.
|
|
508
|
-
const resolveDraftJudge = (/** @type {any} */ d) => {
|
|
509
|
-
try {
|
|
510
|
-
return resolveJobJudge(d, PROVIDER_NAME, resolveWorkerModel);
|
|
511
|
-
} catch {
|
|
512
|
-
return { provider: PROVIDER_NAME, model: MODEL };
|
|
513
|
-
}
|
|
514
|
-
};
|
|
515
|
-
const draftJudge = resolveDraftJudge(draft);
|
|
516
|
-
|
|
517
485
|
// Secrets load from the environment; they never enter argv (a command line is
|
|
518
486
|
// world-readable on /proc) and they are never printed.
|
|
519
487
|
// The key is the chosen row's own variable (P8: no built-in name). Names only.
|
|
@@ -536,15 +504,6 @@ export async function main(argv, deps = {}) {
|
|
|
536
504
|
const al = ratesOfLine(W.line);
|
|
537
505
|
authorPrice = al ? { ...al, envName: AUTHOR_ROW.envName } : null;
|
|
538
506
|
}
|
|
539
|
-
/** The judge's key follows the RESOLVED judge provider's own env var, with
|
|
540
|
-
* `JUDGE_API_KEY` as the role-named override in front (PRD item 32.3) — the same
|
|
541
|
-
* contract `scripts/run-u.mjs` keeps, so one story covers both surfaces. When the
|
|
542
|
-
* judge IS the authoring provider this is the key already read above. */
|
|
543
|
-
const judgeRowOf = (/** @type {{provider: string, model?: string|null}} */ j) => judgeRowFor(keyCfg, j, PROVIDER_NAME, AUTHOR_ROW);
|
|
544
|
-
const judgeKeyFor = (/** @type {string} */ providerName) => (
|
|
545
|
-
env.JUDGE_API_KEY ?? (providerName === PROVIDER_NAME ? apiKey : keyValueOf(env, judgeRowFor(keyCfg, { provider: providerName }, PROVIDER_NAME, AUTHOR_ROW)?.envName))
|
|
546
|
-
);
|
|
547
|
-
|
|
548
507
|
/** F6 — an unpriced call makes the TOTAL unknown, and unknown is reported as
|
|
549
508
|
* UNKNOWN. `?? 0` launders unknown into $0, and a bare floor that reads as exact
|
|
550
509
|
* is F6 in an honest coat, so the floor is marked `≥`.
|
|
@@ -575,17 +534,9 @@ export async function main(argv, deps = {}) {
|
|
|
575
534
|
out(` ${ceilingLine(CEILING_USD)}`);
|
|
576
535
|
out(' stops at prepareSigning — this script NEVER signs and NEVER runs the job\n');
|
|
577
536
|
|
|
578
|
-
// F190 (docs/wiki/FINDINGS.md)
|
|
579
|
-
// call, a duplicate of the SAME construction `buildRunnerProviders` already
|
|
580
|
-
// owns for `src/cli.js`. Routed through the one owner now: the judge half of
|
|
581
|
-
// this call is a THROWAWAY (`judgeProviderName`/`judgeModel`/`judgeBaseUrl` all
|
|
582
|
-
// equal the author's own identity, so `buildRunnerProviders`' own reuse check
|
|
583
|
-
// returns the SAME instance as `provider` rather than constructing a second
|
|
584
|
-
// one) — the real judge identity is not resolved until after `validateJob`,
|
|
585
|
-
// further down, where a second call takes only its `.judgeProvider`.
|
|
537
|
+
// F190 (docs/wiki/FINDINGS.md): the one owner of the provider construction (`buildRunnerProviders`), shared with src/cli.js.
|
|
586
538
|
const { provider } = buildRunnerProviders({
|
|
587
539
|
providerName: PROVIDER_NAME, apiKey, model: MODEL, baseUrl, legacyMaxTokens: AUTHOR_ROW.legacyMaxTokens,
|
|
588
|
-
judgeApiKey: apiKey, judgeModel: MODEL, judgeProviderName: PROVIDER_NAME, judgeBaseUrl: baseUrl,
|
|
589
540
|
});
|
|
590
541
|
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 });
|
|
591
542
|
|
|
@@ -822,7 +773,7 @@ export async function main(argv, deps = {}) {
|
|
|
822
773
|
* bound to `CONFIRM_SYSTEM`, never the authoring `generate` above (that one
|
|
823
774
|
* is bound to `AUTHOR_SYSTEM`). Same provider instance, a different system
|
|
824
775
|
* prompt: reusing `generate` would run the wrong system prompt silently. */
|
|
825
|
-
const confirmGenerate = makeLoopGenerate(provider, { system:
|
|
776
|
+
const confirmGenerate = makeLoopGenerate(provider, { system: confirmSystemFor(LANG), rates: authorPrice?.rates ?? null });
|
|
826
777
|
|
|
827
778
|
// ── PLAIN-FOLDER SOURCE: A NAMED $0 STOP, NO MODEL CALL (F191; PRD item 33 M3
|
|
828
779
|
// piece 4, step S6, D5 amended 2026-09-21) ──────────────────────────────────
|
|
@@ -866,13 +817,6 @@ export async function main(argv, deps = {}) {
|
|
|
866
817
|
// `provider` drives the scout; `generate` is the declaration model boundary (one
|
|
867
818
|
// bare-agent Loop per call, the tool wired to end the call it is used in).
|
|
868
819
|
const authored = await authorCloseForJob({
|
|
869
|
-
// the judge that will certify this close's calibration set, if it composes a
|
|
870
|
-
// judged stage (PRD item 32.1). A DRAFT CAN carry a signed `judge` override
|
|
871
|
-
// already (`judge` is an OPERATOR field, not one of `AUTHORED_SPEC_FIELDS`) —
|
|
872
|
-
// `draftJudge`, resolved once above from the draft's own `provider`/`model`/
|
|
873
|
-
// `judge`, is what the spec will resolve to at run time (`scripts/run-u.mjs`),
|
|
874
|
-
// not this authoring run's own drafting identity.
|
|
875
|
-
judgeModel: draftJudge.model,
|
|
876
820
|
answers,
|
|
877
821
|
verdictType: VERDICT,
|
|
878
822
|
repoPath: SOURCE,
|
|
@@ -908,6 +852,10 @@ export async function main(argv, deps = {}) {
|
|
|
908
852
|
// travels through unchanged — its `ambiguous` shape is what the confirm
|
|
909
853
|
// turn's own $0 half (D7) asks about, before the scout.
|
|
910
854
|
ask, confirmGenerate, isRepo: !RUBRIC_FILES, langResult,
|
|
855
|
+
// 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
|
|
856
|
+
ledgerGenerate: RUBRIC_FILES ? makeLoopGenerate(provider, { system: LEDGER_SYSTEM, rates: authorPrice?.rates ?? null }) : null,
|
|
857
|
+
// the drafter's row-edit reply of a rubric job (src/rowedit.js), its own system text
|
|
858
|
+
editGenerate: RUBRIC_FILES ? makeLoopGenerate(provider, { system: ROW_EDIT_SYSTEM, rates: authorPrice?.rates ?? null }) : null,
|
|
911
859
|
});
|
|
912
860
|
const authoredFile = writeOut('authored.json', authored);
|
|
913
861
|
emit('authored', { ok: authored.ok, stop: authored.stop, seedRef: authored.seedRef, cost: authored.cost, reds: authored.reds });
|
|
@@ -991,15 +939,6 @@ export async function main(argv, deps = {}) {
|
|
|
991
939
|
if (r.red) out(` red: ${JSON.stringify(r.red)}`);
|
|
992
940
|
for (const e of refusalEvents(r)) emit(e.type, e);
|
|
993
941
|
}
|
|
994
|
-
// a refused rubric proposal reads in plain words FIRST (the same text the panel shows), the technical reds after
|
|
995
|
-
if (PLAIN_PROPOSAL_STOPS.includes(String(authored.stop))) {
|
|
996
|
-
out(`\n${proposalStopText({
|
|
997
|
-
stop: String(authored.stop), reds: authored.reds ?? [],
|
|
998
|
-
cases: authored.judged?.signed?.cases ?? authored.judged?.proposal?.proposal?.cases ?? null,
|
|
999
|
-
spend: authored.cost ? { knownUsd: authored.cost.knownUsd ?? null, spendComplete: authored.cost.spendComplete ?? null } : null,
|
|
1000
|
-
source: authored.judged?.source === 'signer' ? 'signer' : 'proposal',
|
|
1001
|
-
})}`);
|
|
1002
|
-
}
|
|
1003
942
|
for (const red of authored.reds ?? []) {
|
|
1004
943
|
out(`\nRED ${red.code} at ${red.path}\n${red.detail}`);
|
|
1005
944
|
emit('job-red', red);
|
|
@@ -1047,21 +986,6 @@ export async function main(argv, deps = {}) {
|
|
|
1047
986
|
// this block is otherwise reachable only after a paid scout and a paid model call,
|
|
1048
987
|
// and a readout no test can reach is a readout nothing checks.
|
|
1049
988
|
for (const l of declarationLines(spec)) out(l);
|
|
1050
|
-
// …and, for a close that JUDGES, the two artifacts the judge is signed with.
|
|
1051
|
-
// NAMED DEFERRAL, said out loud rather than implied: this script's ONE
|
|
1052
|
-
// interactive seam is the confirm turn above (PRD item 33 M3 piece 4,
|
|
1053
|
-
// step S4) — it does not ALSO offer the D5 fix step here, so the
|
|
1054
|
-
// proposal is signed AS PROPOSED. The library seam exists
|
|
1055
|
-
// (`authorCloseForJob({signerFix})`) and the interactive surface for IT
|
|
1056
|
-
// is the interview's and the UI's (N6), which is the same split the
|
|
1057
|
-
// guard battery already lives under here: shown, not edited at this surface.
|
|
1058
|
-
const rubric = rubricLines(spec);
|
|
1059
|
-
if (rubric.length) {
|
|
1060
|
-
for (const l of rubric) out(l);
|
|
1061
|
-
out(` source ${authored.judged?.source ?? 'unknown'}`
|
|
1062
|
-
+ (authored.judged?.source === 'proposal' ? ' (proposed and stored unedited — this script offers no fix step)' : ''));
|
|
1063
|
-
for (const s of authored.judged?.scrubbed ?? []) out(` MASKED ${s.path} — the stored bytes differ from what was typed`);
|
|
1064
|
-
}
|
|
1065
989
|
out(`written ${specFile}`);
|
|
1066
990
|
|
|
1067
991
|
// `shellCapUsd` COUPLES to the spec's own budget, exactly as run-u does it at the
|
|
@@ -1082,116 +1006,14 @@ export async function main(argv, deps = {}) {
|
|
|
1082
1006
|
} else {
|
|
1083
1007
|
// ── 3. D9's gates. Nothing here judges the close; it measures it. ────────
|
|
1084
1008
|
//
|
|
1085
|
-
//
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
// Absent it, `prepareSigning` refuses the close as a wiring gap rather than
|
|
1090
|
-
// signing an ungraded ruler.
|
|
1091
|
-
const judges = closeJudges(spec.closeDecl);
|
|
1092
|
-
// THE JUDGE, RESOLVED (PRD item 32.1) — the job's OWN worker provider and
|
|
1093
|
-
// model by default, a signed `judge` override when the spec names one.
|
|
1094
|
-
// Resolved from the ASSEMBLED SPEC through the same `resolveJobJudge` call
|
|
1095
|
-
// as `draftJudge` above; `provider`/`model`/`judge` reached here unchanged
|
|
1096
|
-
// from the draft, so this is the identical pair — the calibration gate
|
|
1097
|
-
// STAMPS the graded set with whatever this resolves to, so the identity
|
|
1098
|
-
// that certifies the floor here must be the identity the close will later
|
|
1099
|
-
// refuse to grade without (and the identity `scripts/run-u.mjs` resolves).
|
|
1100
|
-
const judge = judges
|
|
1101
|
-
? resolveJobJudge(spec, PROVIDER_NAME, resolveWorkerModel)
|
|
1102
|
-
: null;
|
|
1103
|
-
// the judge's price: the judge model's own row (`judgeRatesFor`) — on the author's endpoint when the
|
|
1104
|
-
// judge is the same provider, else the row for the judge's own provider. A bad one refuses here,
|
|
1105
|
-
// before the calibration gate spends anything — beside the judge-key check, the same door.
|
|
1106
|
-
/** @type {ReturnType<typeof ratesFor>} */
|
|
1107
|
-
let judgePrice = null;
|
|
1108
|
-
if (judge) {
|
|
1109
|
-
try {
|
|
1110
|
-
judgePrice = judgeRatesFor(judge, PROVIDER_NAME, baseUrl, authorPrice, keyCfg);
|
|
1111
|
-
} catch (e) {
|
|
1112
|
-
if (!(e instanceof ConfigError)) throw e;
|
|
1113
|
-
err(`${e.message} — refusing before the calibration gate spends anything`);
|
|
1114
|
-
archiveGateAudit();
|
|
1115
|
-
throw new ExitSignal(2);
|
|
1116
|
-
}
|
|
1117
|
-
}
|
|
1118
|
-
// F181 — the judge key is required exactly when `judges` is true (this
|
|
1119
|
-
// script has no presence check on it today; adding one is out of this
|
|
1120
|
-
// finding's scope). What this door DOES owe, the same as the worker
|
|
1121
|
-
// key above: a resolved value that IS present but carries a shape an
|
|
1122
|
-
// HTTP header cannot refuses here, before the calibration gate spends
|
|
1123
|
-
// anything, rather than crashing mid-call.
|
|
1124
|
-
// `if (judge)` rather than `if (judges)`: identical at runtime (`judge`
|
|
1125
|
-
// is non-null exactly when `judges` is true, by the ternary just above)
|
|
1126
|
-
// but this form is what actually narrows `judge` for tsc below, honestly,
|
|
1127
|
-
// rather than a cast past what it can prove.
|
|
1128
|
-
if (judge) {
|
|
1129
|
-
const judgeKeyValue = judgeKeyFor(judge.provider);
|
|
1130
|
-
const judgeKeyProblem = judgeKeyValue ? apiKeyProblem(judgeKeyValue) : null;
|
|
1131
|
-
if (judgeKeyProblem) {
|
|
1132
|
-
const judgeEnvName = env.JUDGE_API_KEY ? 'JUDGE_API_KEY' : (judgeRowOf(judge)?.envName ?? judge.provider);
|
|
1133
|
-
err(`${judgeEnvName} ${judgeKeyProblem} — refusing rather than crashing mid-call (never trimmed or repaired; fix the value at its source)`);
|
|
1134
|
-
// F186 — the scout above already ran and may have left its own gate
|
|
1135
|
-
// audit in the tree. Under `process.exit()` this path used to skip
|
|
1136
|
-
// the finally block below entirely, so the audit was archived here
|
|
1137
|
-
// explicitly. A thrown ExitSignal now DOES reach the finally block
|
|
1138
|
-
// (unlike process.exit()) — archiveGateAudit() runs again there —
|
|
1139
|
-
// but the call stays here too: it is idempotent (`gateAuditArchived`
|
|
1140
|
-
// guards it), and this keeps the archive from ever depending on the
|
|
1141
|
-
// finally block running first, the same defensive reasoning F186
|
|
1142
|
-
// was written under.
|
|
1143
|
-
archiveGateAudit();
|
|
1144
|
-
throw new ExitSignal(2);
|
|
1145
|
-
}
|
|
1146
|
-
}
|
|
1147
|
-
// F190 — `baseUrl` rides along only when the judge is the SAME provider
|
|
1148
|
-
// as the author/worker: a spec's `baseUrl` is the AUTHOR's endpoint, and
|
|
1149
|
-
// handing it to a different vendor's client is the silent-misconfiguration
|
|
1150
|
-
// class `endpointKey` exists to prevent (a DeepSeek key sent to the
|
|
1151
|
-
// openai-api default host, e.g.). Routed through `buildRunnerProviders`
|
|
1152
|
-
// (the ONE owner of this construction — `src/cli.js` and, above,
|
|
1153
|
-
// this file's own author provider) rather than a hand-rolled
|
|
1154
|
-
// `makeProvider` call: the `providerName`/`apiKey`/`model`/`tierModels`/
|
|
1155
|
-
// `baseUrl` half repeats the author's own identity (so its `provider`
|
|
1156
|
-
// half of the return, unused here, is a throwaway — never a second live
|
|
1157
|
-
// instance of the author's client), and the `judge*` half is this run's
|
|
1158
|
-
// OWN resolved judge — the identical conditional `scripts/run-u.mjs`'s
|
|
1159
|
-
// own call already applies.
|
|
1160
|
-
// an if/else, not the equivalent ternary — the ternary's own ok-branch
|
|
1161
|
-
// object literal did not narrow `judge` for tsc; this form does, the
|
|
1162
|
-
// same real-narrowing reasoning as the `if (judge)` above.
|
|
1163
|
-
let judgeProvider = null;
|
|
1164
|
-
if (judge) {
|
|
1165
|
-
judgeProvider = buildRunnerProviders({
|
|
1166
|
-
providerName: PROVIDER_NAME, apiKey, model: MODEL, baseUrl, legacyMaxTokens: AUTHOR_ROW.legacyMaxTokens,
|
|
1167
|
-
judgeApiKey: judgeKeyFor(judge.provider), judgeModel: judge.model, judgeProviderName: judge.provider,
|
|
1168
|
-
judgeBaseUrl: judge.provider === PROVIDER_NAME ? baseUrl : (judgeRowOf(judge)?.baseUrl.trim() || undefined),
|
|
1169
|
-
judgeLegacyMaxTokens: judge.provider === PROVIDER_NAME ? AUTHOR_ROW.legacyMaxTokens : (judgeRowOf(judge)?.legacyMaxTokens ?? false),
|
|
1170
|
-
}).judgeProvider;
|
|
1171
|
-
}
|
|
1172
|
-
if (judge) {
|
|
1173
|
-
out(`\ncalibration gate — REAL judge calls at ${judge.model} on ${judge.provider}, one per case plus the injection battery.`);
|
|
1174
|
-
out(' this is the only gate that spends money, and it runs after every free one.');
|
|
1175
|
-
}
|
|
1176
|
-
const signing = await prepareSigning({
|
|
1009
|
+
// 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)
|
|
1010
|
+
const signing = authored.hasBuiltCheck === false
|
|
1011
|
+
? { ok: false, reds: [], refusal: null, specHash: null, seedRef: authored.seedRef, gates: { declaration: { ok: true, grounded: '-' }, precheck: null, seedVerdict: null }, work: [], guards: [], stops: [] }
|
|
1012
|
+
: await prepareSigning({
|
|
1177
1013
|
spec, workdir: SOURCE, seedRef: authored.seedRef, timeoutMs: TIMEOUT_MS,
|
|
1178
1014
|
// gate 1a re-runs the job validator inside prepareSigning — same coupling, or
|
|
1179
1015
|
// the spec that just passed above would fail the gate that signs it
|
|
1180
1016
|
shellCapUsd: spec.budgetUsd,
|
|
1181
|
-
// …and the SAME operator ceiling the scout and the declaration loop ran under,
|
|
1182
|
-
// with everything they spent folded in. The gate is this run's third and
|
|
1183
|
-
// largest paid seam; without both halves the advertised budget and the
|
|
1184
|
-
// enforced budget are two different numbers, and re-invoking a seam under one
|
|
1185
|
-
// number would silently widen it.
|
|
1186
|
-
ceilingUsd: CEILING_USD,
|
|
1187
|
-
priorCalls: [...metered],
|
|
1188
|
-
judgeLoop: judgeProvider ? (o) => defaultJudgeLoop({ provider: judgeProvider, system: o.system, rates: judgePrice?.rates ?? null, thinking: spec.thinking === true }) : null,
|
|
1189
|
-
// the seam's other half (PRD item 32.1): the graded set is STAMPED with
|
|
1190
|
-
// this, and the close later refuses to grade under any other identity.
|
|
1191
|
-
judgeModel: judge?.model ?? null,
|
|
1192
|
-
// the gate's spend joins the run's ONE metered list, under the judge call's
|
|
1193
|
-
// own label — a close's calibration is money like any other money (F12)
|
|
1194
|
-
onJudgeCost: (c) => onCall({ label: `${c.label}:${c.id}`, costUsd: c.costUsd, unpricedRounds: c.unpricedRounds }),
|
|
1195
1017
|
});
|
|
1196
1018
|
const signingFile = writeOut('signing.json', signing);
|
|
1197
1019
|
emit('signing', { ok: signing.ok, specHash: signing.specHash, seedRef: signing.seedRef, gates: signing.gates });
|
|
@@ -1200,28 +1022,15 @@ export async function main(argv, deps = {}) {
|
|
|
1200
1022
|
out('\ngates');
|
|
1201
1023
|
out(` 1 declaration ${g.declaration?.ok ? 'PASS' : 'FAIL'} grounded=${g.declaration?.grounded ?? '-'}${g.declaration?.scoped ? ` scoped=${JSON.stringify(g.declaration.scoped)}` : ''}`);
|
|
1202
1024
|
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`)}`);
|
|
1203
|
-
// ruling 3: the judged-ONLY close clears this gate on its calibration, so the
|
|
1204
|
-
// line says PASS and names the proof — printing FAIL beside a signable spec
|
|
1205
|
-
// would be the readout disagreeing with the gate it reports on
|
|
1206
1025
|
out(` 3 seed verdict ${g.seedVerdict === null
|
|
1207
1026
|
? 'not reached'
|
|
1208
1027
|
: (g.seedVerdict.ok
|
|
1209
1028
|
? `PASS — work red at seed: ${g.seedVerdict.workRed.join(', ')}`
|
|
1210
|
-
:
|
|
1211
|
-
? 'PASS via the CALIBRATION gate — this close carries a judged stage'
|
|
1212
|
-
: 'FAIL — no work stage is red at the seed'))}`);
|
|
1029
|
+
: 'FAIL — no work stage is red at the seed')}`);
|
|
1213
1030
|
if (g.seedVerdict) {
|
|
1214
1031
|
out(` red at seed: ${g.seedVerdict.redAtSeed.join(', ') || '(none)'}`);
|
|
1215
1032
|
out(` green at seed: ${g.seedVerdict.greenAtSeed.join(', ') || '(none)'}`);
|
|
1216
|
-
// ruling 3 (widened 2026-10-09): a close with a judged stage clears gate 3 on its calibration instead,
|
|
1217
|
-
// and the surface SAYS which proof carried it rather than leaving a reader
|
|
1218
|
-
// to wonder why an empty workRed list passed
|
|
1219
|
-
if (g.seedVerdict.satisfiedBy === 'calibration') {
|
|
1220
|
-
out(' a judged stage skips the seed read (ruling 8), so this close\'s proof that its judged stage CAN fail is');
|
|
1221
|
-
out(' the graded calibration set below — signed cases it must red as well as ones it must pass.');
|
|
1222
|
-
}
|
|
1223
1033
|
}
|
|
1224
|
-
if (judges) for (const l of calibrationLines(g.calibration)) out(l);
|
|
1225
1034
|
|
|
1226
1035
|
/** the seed evidence a user READS to decide whether this close measures their
|
|
1227
1036
|
* job. `value`/`baseline` print as `unknown` when absent — never as 0. */
|
|
@@ -1238,7 +1047,7 @@ export async function main(argv, deps = {}) {
|
|
|
1238
1047
|
if (!signing.ok) {
|
|
1239
1048
|
const t = costSoFar();
|
|
1240
1049
|
out(`\n${signingStopText({
|
|
1241
|
-
reds: signing.reds ?? [], refusal: signing.refusal,
|
|
1050
|
+
reds: signing.reds ?? [], refusal: signing.refusal, noCheck: authored.hasBuiltCheck === false,
|
|
1242
1051
|
spend: { knownUsd: t.knownUsd ?? null, spendComplete: t.spendComplete ?? null },
|
|
1243
1052
|
})}`);
|
|
1244
1053
|
}
|
|
@@ -1266,13 +1075,10 @@ export async function main(argv, deps = {}) {
|
|
|
1266
1075
|
if (signing.specHash && signing.specHash !== hash) {
|
|
1267
1076
|
out(` NOTE prepareSigning hashed ${signing.specHash} — the validator normalized the spec; sign the resolved one.`);
|
|
1268
1077
|
}
|
|
1269
|
-
// THE WHOLE RUN's spend, off the ONE metered list
|
|
1270
|
-
// populations in it. Gates 1-3 spend no tokens (they run commands); gate 4
|
|
1271
|
-
// buys a real judge call per case, so a line saying "the gates spend no
|
|
1272
|
-
// tokens" would have been false the moment a judged close reached here.
|
|
1078
|
+
// THE WHOLE RUN's spend, off the ONE metered list. Gates 1-3 spend no tokens (they run commands).
|
|
1273
1079
|
out(`authoring ${costLine(authored.cost)}`);
|
|
1274
1080
|
const totalCost = costSoFar();
|
|
1275
|
-
out(`total cost ${costLine(totalCost)}
|
|
1081
|
+
out(`total cost ${costLine(totalCost)} (gates 1-3 spend no tokens — they run commands)`);
|
|
1276
1082
|
// hamr's ruling 2026-09-28 ("one cap covers drafting + run") — this
|
|
1277
1083
|
// run's own known FLOOR (never $0 on an unpriced call, F6), handed to
|
|
1278
1084
|
// the run-u command below as `--draft-spent-usd` so the SIGNED run's
|
package/src/behaviour.js
CHANGED
|
@@ -122,6 +122,20 @@ export function runBehaviour(events, { runId } = {}) {
|
|
|
122
122
|
};
|
|
123
123
|
}
|
|
124
124
|
|
|
125
|
+
/**
|
|
126
|
+
* How many write/edit attempts the gate DENIED (they fell outside the write scope), from gate-audit records alone. One write-class test (action `type`
|
|
127
|
+
* write|edit, as `workerWrites`' reader in src/planrun.js uses), deny-decision only: an allowed write is never counted. Pure.
|
|
128
|
+
* @param {Array<{action?: {type?: string}, decision?: string|null}>} events
|
|
129
|
+
* @returns {number}
|
|
130
|
+
*/
|
|
131
|
+
export function writesBlocked(events) {
|
|
132
|
+
let n = 0;
|
|
133
|
+
for (const e of Array.isArray(events) ? events : []) {
|
|
134
|
+
if (e?.decision === 'deny' && (e.action?.type === 'write' || e.action?.type === 'edit')) n += 1;
|
|
135
|
+
}
|
|
136
|
+
return n;
|
|
137
|
+
}
|
|
138
|
+
|
|
125
139
|
/**
|
|
126
140
|
* Render a {@link runBehaviour} summary as the agreed printable block
|
|
127
141
|
* (2–4 short lines). A zero-call run formats plainly ("0 tool calls") rather
|
package/src/blockasks.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
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';
|
|
5
|
+
|
|
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>}} BlockAsk */
|
|
7
|
+
|
|
8
|
+
/**
|
|
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[]}
|
|
13
|
+
*/
|
|
14
|
+
export function questionsOfBlock(block, scoped = []) {
|
|
15
|
+
const rank = { reading: 0, 'cant-check': 1, 'no-check': 2, check: 2 };
|
|
16
|
+
return block.open.map((/** @type {any} */ q) => {
|
|
17
|
+
const row = block.rows.find((r) => r.key === q.rowKey);
|
|
18
|
+
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) };
|
|
20
|
+
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)) };
|
|
27
|
+
}).sort((a, b) => rank[a.ask] - rank[b.ask]);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* The person's choices back into the block, one by one (the choice decides, never the words). A choice the block refuses is returned with its plain reason; the question stays open.
|
|
32
|
+
* @param {import('./checkblock.js').CheckBlock} block @param {{key: string, choice: string, text?: string}[]} choices @returns {{key: string, why: string}[]}
|
|
33
|
+
*/
|
|
34
|
+
export function applyChoices(block, choices) {
|
|
35
|
+
/** @type {{key: string, why: string}[]} */
|
|
36
|
+
const refused = [];
|
|
37
|
+
for (const c of choices) {
|
|
38
|
+
const r = block.applyAnswer(c.key, c.choice, c.text);
|
|
39
|
+
if (!r.ok) refused.push({ key: c.key, why: r.why });
|
|
40
|
+
}
|
|
41
|
+
block.reconcile();
|
|
42
|
+
return refused;
|
|
43
|
+
}
|
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
|