@rulvar/evals 1.244.0 → 1.245.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 (2) hide show
  1. package/dist/index.js +439 -120
  2. package/package.json +6 -6
package/dist/index.js CHANGED
@@ -3953,10 +3953,11 @@ const sectionalRepairRound = {
3953
3953
  const sectionalPrompt = roundPrompts.length === 2 && roundPrompts[0]?.includes("SECTIONAL ROUND") === false && roundPrompts[1]?.includes("SECTIONAL ROUND") === true && roundPrompts[1]?.includes("\"## Verdict\"") === true && roundPrompts[0]?.includes("retained evidence discipline") === false && roundPrompts[1]?.includes("retained evidence discipline") === true;
3954
3954
  const byteIdentity = value?.result === SECTIONAL_SPLICED && String(value.result).startsWith(SECTIONAL_PREFIX);
3955
3955
  const lineage = value?.claimConsistencyMeta?.passes === 2 && value.claimConsistencyMeta.firstPassFindings === 1 && value.claimConsistencyMeta.semanticRepairRounds === 1;
3956
+ const ledger = value?.repairs?.draft === 0 && value.repairs.composition === 0 && value.repairs.semantic === 1 && value.repairs.total === 1;
3956
3957
  return {
3957
3958
  observation: {
3958
- matched: outcome.status === "ok" && byteIdentity && value.claimConsistencyMeta?.findings === 0 && lineage && verdictRows.map((row) => row.verdict).join(",") === "accepted,accepted" && verdictRows.map((row) => String(row.repairsUsed)).join(",") === "0,0" && sectionalPrompt && compositions.length === 2 && judges.length === 2,
3959
- detail: `run '${outcome.status}' shipped ${value?.result === SECTIONAL_SPLICED ? "the spliced whole" : "an unexpected document"}; byte identity=${String(byteIdentity)}; sectional prompt=${String(sectionalPrompt)}; lineage=${String(lineage)}; verdicts [${verdictRows.map((row) => row.verdict).join(",")}]; ${String(compositions.length)} composition(s), ${String(judges.length)} final judge pass(es)`
3959
+ matched: outcome.status === "ok" && byteIdentity && value.claimConsistencyMeta?.findings === 0 && lineage && ledger && verdictRows.map((row) => row.verdict).join(",") === "accepted,accepted" && verdictRows.map((row) => String(row.repairsUsed)).join(",") === "0,0" && sectionalPrompt && compositions.length === 2 && judges.length === 2,
3960
+ detail: `run '${outcome.status}' shipped ${value?.result === SECTIONAL_SPLICED ? "the spliced whole" : "an unexpected document"}; byte identity=${String(byteIdentity)}; sectional prompt=${String(sectionalPrompt)}; lineage=${String(lineage)}; ledger=${String(ledger)}; verdicts [${verdictRows.map((row) => row.verdict).join(",")}]; ${String(compositions.length)} composition(s), ${String(judges.length)} final judge pass(es)`
3960
3961
  },
3961
3962
  artifacts: [jsonArtifact("outcome.json", {
3962
3963
  status: outcome.status,
@@ -4077,6 +4078,341 @@ const claimJudgeDeadArmedRefusal = {
4077
4078
  */
4078
4079
  const PATCH_RUN_ID = "fault-deterministic-patch";
4079
4080
  const PATCH_FINAL_INVERTED_GRADED = "final: an audit-write failure does not turn success into failure and the fix is production-proven [src/exec.ts:256-296].";
4081
+ const deterministicProvenancePatch = {
4082
+ name: "deterministic-provenance-patch",
4083
+ doctrine: "the finish loop performs the evidence-grade prescription host side (RV3801): a candidate whose every failure carries repair hints is patched without a provider wire and accepted with the mechanical pool untouched, the healed failure still teaches the repair round through HOST VALIDATION LESSONS, and the claim judge rules on the PATCHED document, so an inserted id satisfies provenance mechanics but never masks a false positive production claim",
4084
+ async run() {
4085
+ let judgeCalls = 0;
4086
+ const adapter = tailAdapter({
4087
+ judge: () => (judgeCalls += 1) === 1 ? TAIL_FINDS : TAIL_AGREES,
4088
+ finals: [PATCH_FINAL_INVERTED_GRADED, TAIL_FINAL_CLEAN]
4089
+ });
4090
+ const { engine, store } = tailEngine(adapter);
4091
+ const outcome = await engine.run(makeOrchestratorWorkflow("audit the executor", {
4092
+ ...TAIL_OPTS,
4093
+ claimConsistency: {
4094
+ stage: "final",
4095
+ onFound: "repair"
4096
+ },
4097
+ finishValidation: {
4098
+ validators: [evidenceGradeValidator({ artifactPattern: "run[ -]?[0-9A-HJKMNP-TV-Z]{6,26}" })],
4099
+ maxRepairs: 1
4100
+ }
4101
+ }), void 0, {
4102
+ runId: PATCH_RUN_ID,
4103
+ budgetUsd: 10
4104
+ }).result;
4105
+ const value = outcome.value;
4106
+ const entries = await store.load(PATCH_RUN_ID);
4107
+ const { compositions, judges } = tailSpans(entries);
4108
+ const verdictRows = entries.filter((entry) => entry.kind === "decision" && entry.value?.decisionType === "orchestrator_finish_validation").map((entry) => entry.value);
4109
+ const verdicts = verdictRows.map((row) => row.verdict).join(",");
4110
+ const pools = verdictRows.map((row) => String(row.repairsUsed)).join(",");
4111
+ const patch = verdictRows[0]?.deterministicRepair;
4112
+ const judgeSawPatched = adapter.calls.filter((call) => call.label === "claim-consistency-judge-final").map((call) => call.prompt)[0]?.includes(`(run ${PATCH_RUN_ID})`) === true;
4113
+ const roundPrompts = adapter.calls.filter((call) => call.label === "final-composition").map((call) => call.prompt);
4114
+ const lessonCarried = roundPrompts.length === 2 && roundPrompts[0]?.includes("HOST VALIDATION LESSONS") === false && roundPrompts[1]?.includes("HOST VALIDATION LESSONS") === true && roundPrompts[1]?.includes("evidence-grade") === true;
4115
+ const aggregate = value?.deterministicPatches?.decisions === 1 && typeof value.deterministicPatches.patches === "number" && value.deterministicPatches.patches >= 1 && /^[0-9a-f]{64}$/u.test(String(value.deterministicPatches.lastAfterHash)) && value.deterministicPatches.lastAfterHash !== value.deterministicPatches.lastBeforeHash;
4116
+ return {
4117
+ observation: {
4118
+ matched: outcome.status === "ok" && value?.result === TAIL_FINAL_CLEAN && value.claimConsistencyMeta?.findings === 0 && aggregate && verdicts === "accepted,accepted" && pools === "0,0" && patch?.outcome === "accepted" && patch.healed?.map((healed) => healed.name).join(",") === "evidence-grade" && judgeSawPatched && lessonCarried && compositions.length === 2 && judges.length === 2,
4119
+ detail: `run '${outcome.status}' shipped ${value?.result === TAIL_FINAL_CLEAN ? "the clean round document" : "an unexpected document"}; verdicts [${verdicts}], repairsUsed [${pools}] (no wire, no pool spent); patch outcome='${String(patch?.outcome)}'; envelope aggregate=${String(aggregate)}; judge saw patched=${String(judgeSawPatched)}; lesson carried=${String(lessonCarried)}; ${String(compositions.length)} composition(s), ${String(judges.length)} final judge pass(es)`
4120
+ },
4121
+ artifacts: [jsonArtifact("outcome.json", {
4122
+ status: outcome.status,
4123
+ value: outcome.value ?? null,
4124
+ envelope: outcome.envelope
4125
+ }), jsonArtifact("journal.json", entries)]
4126
+ };
4127
+ }
4128
+ };
4129
+ /**
4130
+ * RV3902: budgetPolicy 'immutable-lifetime' welds the RV2208 override
4131
+ * door shut. A resume carrying any applying ResumeOptions.run refuses
4132
+ * typed BEFORE ownership, meta writes, or any append, raise and lower
4133
+ * alike, with zero provider dispatches; a bare resume of the same run
4134
+ * stays an ordinary pure replay, because the posture pins the
4135
+ * ceilings, never the resume.
4136
+ */
4137
+ const budgetPolicyImmutable = {
4138
+ name: "budget-policy-immutable",
4139
+ doctrine: "budgetPolicy 'immutable-lifetime' refuses a resume-time ceiling override typed before ownership, raise and lower alike, with zero provider dispatches and zero durable mutations; a bare resume of the same run stays a pure replay",
4140
+ async run() {
4141
+ const store = new InMemoryStore();
4142
+ const seeded = await createEngine({
4143
+ adapters: [new FakeAdapter({ agents: { "*": "answered" } })],
4144
+ stores: { journal: store },
4145
+ defaults: ROUTING
4146
+ }).run(echoWorkflow, void 0, {
4147
+ runId: "fault-budget-policy",
4148
+ budgetUsd: 1,
4149
+ budgetPolicy: "immutable-lifetime"
4150
+ }).result;
4151
+ const entriesBefore = (await store.load("fault-budget-policy")).length;
4152
+ const overrideAdapter = new FakeAdapter({ agents: { "*": "never dispatched" } });
4153
+ let refusalText = "the override was not refused";
4154
+ let refusedTyped = false;
4155
+ try {
4156
+ await createEngine({
4157
+ adapters: [overrideAdapter],
4158
+ stores: { journal: store },
4159
+ defaults: ROUTING
4160
+ }).resume("fault-budget-policy", echoWorkflow, { run: { budgetUsd: 2 } }).result;
4161
+ } catch (thrown) {
4162
+ refusalText = errorText(thrown);
4163
+ refusedTyped = thrown instanceof ConfigError && refusalText.includes("immutable-lifetime");
4164
+ }
4165
+ const entriesAfterRefusal = (await store.load("fault-budget-policy")).length;
4166
+ const metaAfterRefusal = await store.getMeta("fault-budget-policy");
4167
+ const bare = await createEngine({
4168
+ adapters: [new FakeAdapter({ agents: { "*": "never dispatched either" } })],
4169
+ stores: { journal: store },
4170
+ defaults: ROUTING
4171
+ }).resume("fault-budget-policy", echoWorkflow).result;
4172
+ return {
4173
+ observation: {
4174
+ matched: seeded.status === "ok" && refusedTyped && overrideAdapter.calls.length === 0 && entriesAfterRefusal === entriesBefore && metaAfterRefusal?.budgetUsd === 1 && metaAfterRefusal.budgetPolicy === "immutable-lifetime" && bare.status === "ok",
4175
+ detail: `seed '${seeded.status}'; refusal typed=${String(refusedTyped)} (${refusalText.slice(0, 160)}); override dispatches=${String(overrideAdapter.calls.length)}; entries ${String(entriesBefore)} -> ${String(entriesAfterRefusal)}; meta budgetUsd=${String(metaAfterRefusal?.budgetUsd)} policy=${String(metaAfterRefusal?.budgetPolicy)}; bare resume '${bare.status}'`
4176
+ },
4177
+ artifacts: [jsonArtifact("refusal.json", {
4178
+ refusalText,
4179
+ entriesBefore,
4180
+ entriesAfterRefusal
4181
+ }), jsonArtifact("meta.json", metaAfterRefusal ?? null)]
4182
+ };
4183
+ }
4184
+ };
4185
+ /**
4186
+ * RV3907: budget.acceptanceReserve 'require' turns the two preflight
4187
+ * warning classes (`reserve-line-headroom`, `orchestrator-working-room`)
4188
+ * into a typed boot refusal BEFORE the first wire: the declared
4189
+ * acceptance tail must fit the effective cap at exact fill or better,
4190
+ * and the refusal journals its arithmetic term by term.
4191
+ */
4192
+ const acceptanceReserveRefusal = {
4193
+ name: "acceptance-reserve-refusal",
4194
+ doctrine: "budget.acceptanceReserve 'require' refuses the run typed BEFORE the first wire when the declared acceptance tail (synthesis hold + judge passes + mechanical repair + round composition + working room) does not fit the effective cap, and the refusal journals every term; the same config under the default warn posture dispatches",
4195
+ async run() {
4196
+ const store = new InMemoryStore();
4197
+ const adapter = new FakeAdapter({ agents: { "*": "never dispatched" } });
4198
+ const outcome = await createEngine({
4199
+ adapters: [adapter],
4200
+ stores: { journal: store },
4201
+ defaults: { routing: {
4202
+ loop: FAKE_MODEL_REF,
4203
+ orchestrate: FAKE_MODEL_REF,
4204
+ synthesize: FAKE_MODEL_REF,
4205
+ extract: FAKE_MODEL_REF
4206
+ } }
4207
+ }).run(makeOrchestratorWorkflow("audit the executor", {
4208
+ synthesis: { estCost: .15 },
4209
+ claimConsistency: {
4210
+ stage: "final",
4211
+ onFound: "repair",
4212
+ judge: { estCost: .2 }
4213
+ },
4214
+ finishValidation: {
4215
+ validators: [{
4216
+ name: "anything",
4217
+ validate: () => ({ ok: true })
4218
+ }],
4219
+ estRepairCostUsd: .1
4220
+ },
4221
+ budget: {
4222
+ synthesisReserveUsd: 1,
4223
+ acceptanceReserve: "require"
4224
+ }
4225
+ }), void 0, {
4226
+ runId: "fault-acceptance-reserve",
4227
+ budgetUsd: 10
4228
+ }).result;
4229
+ const refusal = (await store.load("fault-acceptance-reserve")).find((entry) => entry.value?.decisionType === "acceptance_reserve_refused");
4230
+ const terms = refusal?.value;
4231
+ return {
4232
+ observation: {
4233
+ matched: outcome.status === "error" && (outcome.error?.message ?? "").includes("acceptanceReserve 'require'") && adapter.calls.length === 0 && terms !== void 0 && Math.abs((terms.requiredUsd ?? 0) - 2.15) < 1e-9 && Math.abs((terms.effectiveCapUsd ?? 0) - 2) < 1e-9 && terms.judgePasses === 2,
4234
+ detail: `run '${outcome.status}'; dispatches=${String(adapter.calls.length)}; refusal decision=${String(refusal !== void 0)} (required ${String(terms?.requiredUsd)} vs cap ${String(terms?.effectiveCapUsd)}, ` + `judge passes ${String(terms?.judgePasses)}); ${outcome.error?.message ?? ""}`.slice(0, 400)
4235
+ },
4236
+ artifacts: [jsonArtifact("refusal.json", {
4237
+ error: outcome.error ?? null,
4238
+ decision: refusal?.value ?? null
4239
+ })]
4240
+ };
4241
+ }
4242
+ };
4243
+ const DRAFT_REPAIR_BROKEN = `${SECTIONAL_PREFIX}## Verdict\n\nfinal: the audit path is safe.
4244
+ `;
4245
+ const DRAFT_REPAIR_VERDICT_BODY = "final: the audit path is safe [src/exec.ts:256-296].\n";
4246
+ const DRAFT_REPAIR_FINAL = `${SECTIONAL_PREFIX}## Verdict\n\nfinal: the audit path is safe, composed over the healed draft [src/exec.ts:256-296].
4247
+ `;
4248
+ const coordinationDraftRepair = {
4249
+ name: "coordination-draft-repair",
4250
+ doctrine: "the workflow repair ledger counts the draft gate (RV4002): a coordination draft rejected by the contract gate and healed by a sectional resubmission is ONE draft repair on the envelope ({draft: 1, composition: 0, semantic: 0, total: 1}) with the rejected validators, the resubmitted sections, and the repair wire named; the fifth comparison run's judge rebuilt exactly this count from the raw transcript because no aggregate would answer for the workflow",
4251
+ async run() {
4252
+ let loopTurns = 0;
4253
+ const adapter = new FakeAdapter({ agents: {
4254
+ "final-composition": () => fakeToolCalls({
4255
+ name: "finish",
4256
+ args: { result: DRAFT_REPAIR_FINAL }
4257
+ }),
4258
+ "*": () => {
4259
+ loopTurns += 1;
4260
+ return loopTurns === 1 ? fakeToolCalls({
4261
+ name: "finish",
4262
+ args: { result: DRAFT_REPAIR_BROKEN }
4263
+ }) : fakeToolCalls({
4264
+ name: "finish",
4265
+ args: { sections: { "## Verdict": DRAFT_REPAIR_VERDICT_BODY } }
4266
+ });
4267
+ }
4268
+ } });
4269
+ const store = new InMemoryStore();
4270
+ const outcome = await createEngine({
4271
+ adapters: [adapter],
4272
+ stores: { journal: store },
4273
+ defaults: {
4274
+ routing: {
4275
+ loop: FAKE_MODEL_REF,
4276
+ orchestrate: FAKE_MODEL_REF,
4277
+ synthesize: FAKE_MODEL_REF,
4278
+ extract: FAKE_MODEL_REF
4279
+ },
4280
+ billingReceipts: "awaited"
4281
+ }
4282
+ }).run(makeOrchestratorWorkflow("audit the executor", {
4283
+ ...TAIL_OPTS,
4284
+ finishValidation: {
4285
+ validators: [minMatchesValidator({
4286
+ pattern: "src/[a-z]+\\.ts:\\d+",
4287
+ min: 1,
4288
+ name: "provenance-anchor"
4289
+ })],
4290
+ maxRepairs: 1,
4291
+ draftPolicy: "contract",
4292
+ sectionalRepair: { sections: ["## Verdict"] }
4293
+ }
4294
+ }), void 0, {
4295
+ runId: "fault-draft-repair",
4296
+ budgetUsd: 10
4297
+ }).result;
4298
+ const value = outcome.value;
4299
+ const entries = await store.load("fault-draft-repair");
4300
+ const gateRows = entries.filter((entry) => entry.kind === "decision" && entry.value?.decisionType === "orchestrator_draft_gate").map((entry) => entry.value);
4301
+ const repairWires = entries.filter((entry) => entry.kind === "decision" && entry.value?.decisionType === "provider-call" && entry.value.record?.phase === "repair");
4302
+ const ledger = value?.repairs?.draft === 1 && value.repairs.composition === 0 && value.repairs.semantic === 0 && value.repairs.total === 1;
4303
+ const row = value?.repairs?.rounds?.[0];
4304
+ const rowFacts = row?.stage === "draft" && Array.isArray(row.failedValidators) && row.failedValidators.join(",") === "provenance-anchor" && Array.isArray(row.sections) && row.sections.join(",") === "## Verdict" && typeof row.wireRef === "number";
4305
+ const gateFacts = gateRows.map((gate) => gate.verdict).join(",") === "rejected,accepted" && gateRows[0]?.failed?.map((f) => f.name).join(",") === "provenance-anchor" && gateRows[1]?.sections?.join(",") === "## Verdict";
4306
+ return {
4307
+ observation: {
4308
+ matched: outcome.status === "ok" && value?.result === DRAFT_REPAIR_FINAL && ledger && rowFacts && gateFacts && repairWires.length === 1,
4309
+ detail: `run '${outcome.status}'; ledger=${String(ledger)}; row=${String(rowFacts)}; gate decisions [${gateRows.map((gate) => gate.verdict).join(",")}]; ${String(repairWires.length)} repair-stamped wire(s)`
4310
+ },
4311
+ artifacts: [jsonArtifact("outcome.json", {
4312
+ status: outcome.status,
4313
+ value: outcome.value ?? null,
4314
+ envelope: outcome.envelope
4315
+ }), jsonArtifact("journal.json", entries)]
4316
+ };
4317
+ }
4318
+ };
4319
+ const COVERAGE_POOL = "A failed audit write does not mask success (`src/exec.ts:256-296`).";
4320
+ const COVERAGE_FINAL_PARTIAL = "final: an audit-write failure does not mask success [src/exec.ts:256-296]. final: the retry ladder caps at three attempts [src/retry.ts:24].";
4321
+ const strictCoveragePolicy = {
4322
+ name: "strict-coverage-policy",
4323
+ doctrine: "coveragePolicy 'strict-final' turns the coverage grade into a gate (RV4003): a final grade of 'partial' refuses acceptance typed with the grade named, and the SAME run under a declared waiver settles ok with claim_coverage_waived journaled and the waiver riding the envelope verbatim, so a non-full grade on a strict run always names who accepted it and why",
4324
+ async run() {
4325
+ const makeAdapter = () => {
4326
+ let loopTurns = 0;
4327
+ return new FakeAdapter({ agents: {
4328
+ "claim-consistency-judge-final": JSON.stringify({ contradictions: [] }),
4329
+ "final-composition": () => fakeToolCalls({
4330
+ name: "finish",
4331
+ args: { result: COVERAGE_FINAL_PARTIAL }
4332
+ }),
4333
+ worker: COVERAGE_POOL,
4334
+ "*": (call) => {
4335
+ loopTurns += 1;
4336
+ if (loopTurns === 1) return fakeToolCalls({
4337
+ name: "spawn_agent",
4338
+ args: {
4339
+ agentType: "worker",
4340
+ prompt: "read the recorded span"
4341
+ }
4342
+ });
4343
+ if (loopTurns === 2) return fakeToolCalls({
4344
+ name: "await_all",
4345
+ args: { handles: tailHandles(call.req) }
4346
+ });
4347
+ return fakeToolCalls({
4348
+ name: "finish",
4349
+ args: { result: "draft before synthesis" }
4350
+ });
4351
+ }
4352
+ } });
4353
+ };
4354
+ const strictOpts = {
4355
+ ...TAIL_OPTS,
4356
+ claimConsistency: {
4357
+ stage: "final",
4358
+ coveragePolicy: "strict-final"
4359
+ }
4360
+ };
4361
+ const refused = await tailEngine(makeAdapter()).engine.run(makeOrchestratorWorkflow("audit the executor", strictOpts), void 0, {
4362
+ runId: "fault-strict-coverage-refused",
4363
+ budgetUsd: 10
4364
+ }).result;
4365
+ const refusedData = refused.error?.data;
4366
+ const refusedTyped = refused.status === "error" && refusedData?.source === "orchestrator_claim_consistency" && refusedData.coveragePolicy === "strict-final" && refusedData.coverage === "partial";
4367
+ const waivedRig = tailEngine(makeAdapter());
4368
+ const waived = await waivedRig.engine.run(makeOrchestratorWorkflow("audit the executor", {
4369
+ ...strictOpts,
4370
+ claimConsistency: {
4371
+ ...strictOpts.claimConsistency,
4372
+ waiver: {
4373
+ principal: "release-owner",
4374
+ reason: "the uncovered anchor is a legacy path scheduled for removal"
4375
+ }
4376
+ }
4377
+ }), void 0, {
4378
+ runId: "fault-strict-coverage-waived",
4379
+ budgetUsd: 10
4380
+ }).result;
4381
+ const waivedValue = waived.value;
4382
+ const waivedDecision = (await waivedRig.store.load("fault-strict-coverage-waived")).find((entry) => entry.value?.decisionType === "claim_coverage_waived");
4383
+ const waivedOk = waived.status === "ok" && waivedValue?.claimConsistencyMeta?.coverage === "partial" && waivedValue.claimCoverageWaiver?.principal === "release-owner" && waivedValue.claimCoverageWaiver.coverage === "partial" && waivedDecision !== void 0;
4384
+ return {
4385
+ observation: {
4386
+ matched: refusedTyped && waivedOk,
4387
+ detail: `strict refusal typed=${String(refusedTyped)} (status '${refused.status}', coverage '${String(refusedData?.coverage)}'); waived settle=${String(waivedOk)} (status '${waived.status}', principal '${String(waivedValue?.claimCoverageWaiver?.principal)}', decision journaled=${String(waivedDecision !== void 0)})`
4388
+ },
4389
+ artifacts: [jsonArtifact("refused.json", {
4390
+ status: refused.status,
4391
+ error: refused.error ?? null
4392
+ }), jsonArtifact("waived.json", {
4393
+ status: waived.status,
4394
+ value: waived.value ?? null
4395
+ })]
4396
+ };
4397
+ }
4398
+ };
4399
+ const AUDIT_SNAPSHOT = {
4400
+ "src/otel.ts:18": "attributes: dropUnknown(config.exporter),",
4401
+ "src/otel.ts:19": "batchWindowMs: 500,",
4402
+ "src/retry.ts:24": "const MAX_ATTEMPTS = 3;"
4403
+ };
4404
+ const AUDIT_RESOLVE = (target) => AUDIT_SNAPSHOT[`${target.path}:${String(target.line)}`];
4405
+ const AUDIT_FINAL = [
4406
+ "# Audit",
4407
+ "",
4408
+ "## Grid",
4409
+ "",
4410
+ "No SLO observations exist anywhere in the exporter [src/otel.ts:18].",
4411
+ "",
4412
+ "## Verdict",
4413
+ "",
4414
+ "The retry ladder caps at three attempts [src/retry.ts:24]."
4415
+ ].join("\n");
4080
4416
  const SCENARIOS = [
4081
4417
  inFlightExposure,
4082
4418
  duplicateQuotaRule,
@@ -4113,151 +4449,134 @@ const SCENARIOS = [
4113
4449
  repairRoundMechanicalReserve,
4114
4450
  sectionalRepairRound,
4115
4451
  sectionalRepairRoundFallback,
4452
+ coordinationDraftRepair,
4116
4453
  {
4117
- name: "deterministic-provenance-patch",
4118
- doctrine: "the finish loop performs the evidence-grade prescription host side (RV3801): a candidate whose every failure carries repair hints is patched without a provider wire and accepted with the mechanical pool untouched, the healed failure still teaches the repair round through HOST VALIDATION LESSONS, and the claim judge rules on the PATCHED document, so an inserted id satisfies provenance mechanics but never masks a false positive production claim",
4454
+ name: "citation-entailment-audit",
4455
+ doctrine: "the citation audit reads the cited lines and judges entailment (RV4004): a citation that is mechanically valid and value-clean but not entailed by its lines is a named finding with the section and reason on the envelope, the supported control stays clean, and the armed 'fail' posture stops the run typed; the fifth comparison run shipped three exactly such citations past every built-in verifier",
4119
4456
  async run() {
4120
- let judgeCalls = 0;
4121
- const adapter = tailAdapter({
4122
- judge: () => (judgeCalls += 1) === 1 ? TAIL_FINDS : TAIL_AGREES,
4123
- finals: [PATCH_FINAL_INVERTED_GRADED, TAIL_FINAL_CLEAN]
4124
- });
4125
- const { engine, store } = tailEngine(adapter);
4126
- const outcome = await engine.run(makeOrchestratorWorkflow("audit the executor", {
4457
+ const makeAdapter = () => new FakeAdapter({ agents: {
4458
+ "citation-entailment-judge": JSON.stringify({ verdicts: [{
4459
+ row: 0,
4460
+ verdict: "unsupported",
4461
+ reason: "the line sets an exporter attribute policy, not observation absence"
4462
+ }, {
4463
+ row: 1,
4464
+ verdict: "supported",
4465
+ reason: "the line pins the attempts constant"
4466
+ }] }),
4467
+ "final-composition": () => fakeToolCalls({
4468
+ name: "finish",
4469
+ args: { result: AUDIT_FINAL }
4470
+ }),
4471
+ "*": () => fakeToolCalls({
4472
+ name: "finish",
4473
+ args: { result: "the coordination draft" }
4474
+ })
4475
+ } });
4476
+ const reported = await tailEngine(makeAdapter()).engine.run(makeOrchestratorWorkflow("audit the executor", {
4127
4477
  ...TAIL_OPTS,
4128
- claimConsistency: {
4129
- stage: "final",
4130
- onFound: "repair"
4131
- },
4132
- finishValidation: {
4133
- validators: [evidenceGradeValidator({ artifactPattern: "run[ -]?[0-9A-HJKMNP-TV-Z]{6,26}" })],
4134
- maxRepairs: 1
4135
- }
4478
+ citationAudit: { resolve: AUDIT_RESOLVE }
4136
4479
  }), void 0, {
4137
- runId: PATCH_RUN_ID,
4480
+ runId: "fault-citation-audit-report",
4138
4481
  budgetUsd: 10
4139
4482
  }).result;
4140
- const value = outcome.value;
4141
- const entries = await store.load(PATCH_RUN_ID);
4142
- const { compositions, judges } = tailSpans(entries);
4143
- const verdictRows = entries.filter((entry) => entry.kind === "decision" && entry.value?.decisionType === "orchestrator_finish_validation").map((entry) => entry.value);
4144
- const verdicts = verdictRows.map((row) => row.verdict).join(",");
4145
- const pools = verdictRows.map((row) => String(row.repairsUsed)).join(",");
4146
- const patch = verdictRows[0]?.deterministicRepair;
4147
- const judgeSawPatched = adapter.calls.filter((call) => call.label === "claim-consistency-judge-final").map((call) => call.prompt)[0]?.includes(`(run ${PATCH_RUN_ID})`) === true;
4148
- const roundPrompts = adapter.calls.filter((call) => call.label === "final-composition").map((call) => call.prompt);
4149
- const lessonCarried = roundPrompts.length === 2 && roundPrompts[0]?.includes("HOST VALIDATION LESSONS") === false && roundPrompts[1]?.includes("HOST VALIDATION LESSONS") === true && roundPrompts[1]?.includes("evidence-grade") === true;
4150
- const aggregate = value?.deterministicPatches?.decisions === 1 && typeof value.deterministicPatches.patches === "number" && value.deterministicPatches.patches >= 1 && /^[0-9a-f]{64}$/u.test(String(value.deterministicPatches.lastAfterHash)) && value.deterministicPatches.lastAfterHash !== value.deterministicPatches.lastBeforeHash;
4151
- return {
4152
- observation: {
4153
- matched: outcome.status === "ok" && value?.result === TAIL_FINAL_CLEAN && value.claimConsistencyMeta?.findings === 0 && aggregate && verdicts === "accepted,accepted" && pools === "0,0" && patch?.outcome === "accepted" && patch.healed?.map((healed) => healed.name).join(",") === "evidence-grade" && judgeSawPatched && lessonCarried && compositions.length === 2 && judges.length === 2,
4154
- detail: `run '${outcome.status}' shipped ${value?.result === TAIL_FINAL_CLEAN ? "the clean round document" : "an unexpected document"}; verdicts [${verdicts}], repairsUsed [${pools}] (no wire, no pool spent); patch outcome='${String(patch?.outcome)}'; envelope aggregate=${String(aggregate)}; judge saw patched=${String(judgeSawPatched)}; lesson carried=${String(lessonCarried)}; ${String(compositions.length)} composition(s), ${String(judges.length)} final judge pass(es)`
4155
- },
4156
- artifacts: [jsonArtifact("outcome.json", {
4157
- status: outcome.status,
4158
- value: outcome.value ?? null,
4159
- envelope: outcome.envelope
4160
- }), jsonArtifact("journal.json", entries)]
4161
- };
4162
- }
4163
- },
4164
- claimJudgeDeadArmedRefusal,
4165
- {
4166
- name: "acceptance-reserve-refusal",
4167
- doctrine: "budget.acceptanceReserve 'require' refuses the run typed BEFORE the first wire when the declared acceptance tail (synthesis hold + judge passes + mechanical repair + round composition + working room) does not fit the effective cap, and the refusal journals every term; the same config under the default warn posture dispatches",
4168
- async run() {
4169
- const store = new InMemoryStore();
4170
- const adapter = new FakeAdapter({ agents: { "*": "never dispatched" } });
4171
- const outcome = await createEngine({
4172
- adapters: [adapter],
4173
- stores: { journal: store },
4174
- defaults: { routing: {
4175
- loop: FAKE_MODEL_REF,
4176
- orchestrate: FAKE_MODEL_REF,
4177
- synthesize: FAKE_MODEL_REF,
4178
- extract: FAKE_MODEL_REF
4179
- } }
4180
- }).run(makeOrchestratorWorkflow("audit the executor", {
4181
- synthesis: { estCost: .15 },
4182
- claimConsistency: {
4183
- stage: "final",
4184
- onFound: "repair",
4185
- judge: { estCost: .2 }
4186
- },
4187
- finishValidation: {
4188
- validators: [{
4189
- name: "anything",
4190
- validate: () => ({ ok: true })
4191
- }],
4192
- estRepairCostUsd: .1
4193
- },
4194
- budget: {
4195
- synthesisReserveUsd: 1,
4196
- acceptanceReserve: "require"
4483
+ const reportedValue = reported.value;
4484
+ const reportedOk = reported.status === "ok" && reportedValue?.citationAuditMeta?.sampled === 2 && reportedValue.citationAuditMeta.supported === 1 && reportedValue.citationAuditMeta.unsupported === 1 && reportedValue.citationAuditMeta.judgeInvoked === true && reportedValue.citationFindings?.length === 1 && reportedValue.citationFindings[0]?.verdict === "unsupported" && reportedValue.citationFindings[0].anchor === "src/otel.ts:18" && reportedValue.citationFindings[0].section === "## Grid";
4485
+ const failed = await tailEngine(makeAdapter()).engine.run(makeOrchestratorWorkflow("audit the executor", {
4486
+ ...TAIL_OPTS,
4487
+ citationAudit: {
4488
+ resolve: AUDIT_RESOLVE,
4489
+ onFound: "fail"
4197
4490
  }
4198
4491
  }), void 0, {
4199
- runId: "fault-acceptance-reserve",
4492
+ runId: "fault-citation-audit-fail",
4200
4493
  budgetUsd: 10
4201
4494
  }).result;
4202
- const refusal = (await store.load("fault-acceptance-reserve")).find((entry) => entry.value?.decisionType === "acceptance_reserve_refused");
4203
- const terms = refusal?.value;
4495
+ const failData = failed.error?.data;
4496
+ const failTyped = failed.status === "error" && failData?.source === "orchestrator_citation_audit" && (failed.error?.message ?? "").includes("UNSUPPORTED");
4204
4497
  return {
4205
4498
  observation: {
4206
- matched: outcome.status === "error" && (outcome.error?.message ?? "").includes("acceptanceReserve 'require'") && adapter.calls.length === 0 && terms !== void 0 && Math.abs((terms.requiredUsd ?? 0) - 2.15) < 1e-9 && Math.abs((terms.effectiveCapUsd ?? 0) - 2) < 1e-9 && terms.judgePasses === 2,
4207
- detail: `run '${outcome.status}'; dispatches=${String(adapter.calls.length)}; refusal decision=${String(refusal !== void 0)} (required ${String(terms?.requiredUsd)} vs cap ${String(terms?.effectiveCapUsd)}, ` + `judge passes ${String(terms?.judgePasses)}); ${outcome.error?.message ?? ""}`.slice(0, 400)
4499
+ matched: reportedOk && failTyped,
4500
+ detail: `report arm=${String(reportedOk)} (status '${reported.status}', sampled ${String(reportedValue?.citationAuditMeta?.sampled)}, unsupported ${String(reportedValue?.citationAuditMeta?.unsupported)}); fail arm typed=${String(failTyped)} (status '${failed.status}')`
4208
4501
  },
4209
- artifacts: [jsonArtifact("refusal.json", {
4210
- error: outcome.error ?? null,
4211
- decision: refusal?.value ?? null
4502
+ artifacts: [jsonArtifact("reported.json", {
4503
+ status: reported.status,
4504
+ value: reported.value ?? null
4505
+ }), jsonArtifact("failed.json", {
4506
+ status: failed.status,
4507
+ error: failed.error ?? null
4212
4508
  })]
4213
4509
  };
4214
4510
  }
4215
4511
  },
4512
+ deterministicProvenancePatch,
4513
+ claimJudgeDeadArmedRefusal,
4514
+ strictCoveragePolicy,
4515
+ acceptanceReserveRefusal,
4516
+ budgetPolicyImmutable,
4216
4517
  {
4217
- name: "budget-policy-immutable",
4218
- doctrine: "budgetPolicy 'immutable-lifetime' refuses a resume-time ceiling override typed before ownership, raise and lower alike, with zero provider dispatches and zero durable mutations; a bare resume of the same run stays a pure replay",
4518
+ name: "wire-intent-unknown-outcome",
4519
+ doctrine: "billingReceipts 'intent' journals a provider-intent before every dispatched wire attempt (RV4006), and a resume that finds one with no receipt and no terminal coverage refuses the blind retry typed; the acknowledged resume journals the override and the invoice names the wire in its openIntents lane, with no invented dollars, because the outcome is exactly what the process does not know",
4219
4520
  async run() {
4220
- const store = new InMemoryStore();
4221
- const seeded = await createEngine({
4222
- adapters: [new FakeAdapter({ agents: { "*": "answered" } })],
4223
- stores: { journal: store },
4224
- defaults: ROUTING
4225
- }).run(echoWorkflow, void 0, {
4226
- runId: "fault-budget-policy",
4227
- budgetUsd: 1,
4228
- budgetPolicy: "immutable-lifetime"
4521
+ const dir = mkdtempSync(join(tmpdir(), "rulvar-fault-intent-"));
4522
+ const makeRig = () => {
4523
+ const store = new JsonlFileStore({ dir });
4524
+ return {
4525
+ engine: createEngine({
4526
+ adapters: [new FakeAdapter({ agents: { "*": "stored answer" } })],
4527
+ stores: { journal: store },
4528
+ defaults: {
4529
+ ...ROUTING,
4530
+ billingReceipts: "intent"
4531
+ }
4532
+ }),
4533
+ store
4534
+ };
4535
+ };
4536
+ const first = makeRig();
4537
+ const seeded = await first.engine.run(echoWorkflow, void 0, {
4538
+ runId: "fault-wire-intent",
4539
+ budgetUsd: 5
4229
4540
  }).result;
4230
- const entriesBefore = (await store.load("fault-budget-policy")).length;
4231
- const overrideAdapter = new FakeAdapter({ agents: { "*": "never dispatched" } });
4232
- let refusalText = "the override was not refused";
4541
+ const intentRows = (await first.store.load("fault-wire-intent")).filter((entry) => entry.value?.decisionType === "provider-intent");
4542
+ const file = readdirSync(dir).filter((name) => name.includes("fault-wire-intent") && name.endsWith(".jsonl")).map((name) => join(dir, name))[0];
4543
+ if (file === void 0) throw new Error("fault kit: no journal file for the intent scenario");
4544
+ const lines = readFileSync(file, "utf8").trim().split("\n");
4545
+ const orphan = {
4546
+ seq: Math.max(...lines.map((line) => JSON.parse(line).seq)) + 1,
4547
+ kind: "decision",
4548
+ scope: "",
4549
+ key: "pi:99999:1:1",
4550
+ status: "ok",
4551
+ spanId: "crash-window",
4552
+ site: "provider-intent",
4553
+ value: {
4554
+ decisionType: "provider-intent",
4555
+ agentRef: 99999,
4556
+ ordinal: 1,
4557
+ attempt: 1,
4558
+ servedBy: FAKE_MODEL_REF,
4559
+ requestFingerprint: "f".repeat(64)
4560
+ }
4561
+ };
4562
+ writeFileSync(file, `${lines.join("\n")}\n${JSON.stringify(orphan)}\n`, "utf8");
4563
+ const lane = invoiceFromJournal(await new JsonlFileStore({ dir }).load("fault-wire-intent"), () => .001).openIntents;
4233
4564
  let refusedTyped = false;
4565
+ let refusedMessage = "";
4234
4566
  try {
4235
- await createEngine({
4236
- adapters: [overrideAdapter],
4237
- stores: { journal: store },
4238
- defaults: ROUTING
4239
- }).resume("fault-budget-policy", echoWorkflow, { run: { budgetUsd: 2 } }).result;
4567
+ await makeRig().engine.resume("fault-wire-intent", echoWorkflow).result;
4240
4568
  } catch (thrown) {
4241
- refusalText = errorText(thrown);
4242
- refusedTyped = thrown instanceof ConfigError && refusalText.includes("immutable-lifetime");
4569
+ refusedMessage = thrown instanceof Error ? thrown.message : String(thrown);
4570
+ refusedTyped = thrown instanceof Error && thrown.name === "ConfigError" && refusedMessage.includes("unknown outcome") && refusedMessage.includes("acknowledgeOpenWireIntents");
4243
4571
  }
4244
- const entriesAfterRefusal = (await store.load("fault-budget-policy")).length;
4245
- const metaAfterRefusal = await store.getMeta("fault-budget-policy");
4246
- const bare = await createEngine({
4247
- adapters: [new FakeAdapter({ agents: { "*": "never dispatched either" } })],
4248
- stores: { journal: store },
4249
- defaults: ROUTING
4250
- }).resume("fault-budget-policy", echoWorkflow).result;
4572
+ const acked = await makeRig().engine.resume("fault-wire-intent", echoWorkflow, { acknowledgeOpenWireIntents: true }).result;
4573
+ const ackDecision = (await new JsonlFileStore({ dir }).load("fault-wire-intent")).find((entry) => entry.value?.decisionType === "open_wire_intents_acknowledged");
4251
4574
  return {
4252
4575
  observation: {
4253
- matched: seeded.status === "ok" && refusedTyped && overrideAdapter.calls.length === 0 && entriesAfterRefusal === entriesBefore && metaAfterRefusal?.budgetUsd === 1 && metaAfterRefusal.budgetPolicy === "immutable-lifetime" && bare.status === "ok",
4254
- detail: `seed '${seeded.status}'; refusal typed=${String(refusedTyped)} (${refusalText.slice(0, 160)}); override dispatches=${String(overrideAdapter.calls.length)}; entries ${String(entriesBefore)} -> ${String(entriesAfterRefusal)}; meta budgetUsd=${String(metaAfterRefusal?.budgetUsd)} policy=${String(metaAfterRefusal?.budgetPolicy)}; bare resume '${bare.status}'`
4576
+ matched: seeded.status === "ok" && intentRows.length > 0 && lane?.count === 1 && lane.rows[0]?.agentRef === 99999 && refusedTyped && acked.status === "ok" && ackDecision !== void 0,
4577
+ detail: `seed '${seeded.status}' with ${String(intentRows.length)} intent row(s); lane count=${String(lane?.count)}; refusal typed=${String(refusedTyped)}; acknowledged resume '${acked.status}' with decision journaled=${String(ackDecision !== void 0)}`
4255
4578
  },
4256
- artifacts: [jsonArtifact("refusal.json", {
4257
- refusalText,
4258
- entriesBefore,
4259
- entriesAfterRefusal
4260
- }), jsonArtifact("meta.json", metaAfterRefusal ?? null)]
4579
+ artifacts: [jsonArtifact("refusal.json", { message: refusedMessage }), jsonArtifact("lane.json", lane ?? null)]
4261
4580
  };
4262
4581
  }
4263
4582
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rulvar/evals",
3
- "version": "1.244.0",
3
+ "version": "1.245.0",
4
4
  "description": "Rulvar evals: eval cases, golden outputs, rubric and judge graders, matrix sweeps, canary fingerprint.",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
@@ -22,11 +22,11 @@
22
22
  "access": "public"
23
23
  },
24
24
  "dependencies": {
25
- "@rulvar/anthropic": "1.244.0",
26
- "@rulvar/openai": "1.244.0",
27
- "@rulvar/core": "1.244.0",
28
- "@rulvar/plan": "1.244.0",
29
- "@rulvar/testing": "1.244.0"
25
+ "@rulvar/openai": "1.245.0",
26
+ "@rulvar/plan": "1.245.0",
27
+ "@rulvar/anthropic": "1.245.0",
28
+ "@rulvar/testing": "1.245.0",
29
+ "@rulvar/core": "1.245.0"
30
30
  },
31
31
  "devDependencies": {
32
32
  "@types/node": "^22.20.1",