4fd4e20bd0
Systemic reliability gap found by the probe sweep: the compiled evaluation paths never emitted the reliability the engine computes. - Compiled _evaluateDirect omitted the relation's reliability, and the chain/multi_hop rules hardcoded reliability: 1.0 — so check() results reported 1.0 for any rule whose decision came through a chain, multi_hop, union, intersection, exclusion, or defeasible combination. - The chain and multi_hop traversals now track per-path reliability (product of edge reliabilities) and report the winning path's value; the compiled and fallback logical operators (union/intersection/exclusion, direct_list fast path, early exits) report the selected child's reliability (max/min child or OWA trace index; exclusion multiplies both legs), and normal-mode defeasible combines base x requires x defeater reliabilities. - The checker's logical fast path dropped collectedValues from union/ intersection/exclusion results; it now passes them through. - MultiHopRule.valueManager was read off relationManager where the real arbiter keeps it on the arbiter — collectValues: true on a multi_hop rule with a value-carrying edge crashed the evaluation (error result, silent denial). Now resolved at the arbiter level with a relationManager fallback for stubs. Campaign pins: reliability per kind (chain/multi_hop product, union/intersection selected child, exclusion/defeasible product), and multi_hop value collection through persistent and partial contexts.
60 lines
2.1 KiB
JavaScript
60 lines
2.1 KiB
JavaScript
/**
|
|
* rigor-smoke.test.js — verifies the @rigor/core import path works
|
|
* from the lib test directory and that a minimal campaign runs.
|
|
*
|
|
* If this test fails to import or run, none of the property tests below
|
|
* can ship.
|
|
*/
|
|
import { describe, it } from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import { rigor } from '@rigor/core';
|
|
|
|
describe('js-rigor smoke', () => {
|
|
it('exports the rigor facade', () => {
|
|
assert.ok(rigor, 'rigor is exported');
|
|
assert.equal(typeof rigor.campaign, 'function');
|
|
assert.equal(typeof rigor.crucible, 'function');
|
|
assert.ok(rigor.gen, 'rigor.gen is available');
|
|
});
|
|
|
|
it('runs a minimal campaign and returns a report', async () => {
|
|
const report = await rigor.campaign(
|
|
[
|
|
rigor.fn('abs', (n) => Math.abs(n),
|
|
rigor.args(rigor.gen.int(-100, 100)),
|
|
rigor.metrics({ n: ({ args }) => args[0] }))
|
|
],
|
|
rigor.crucible([
|
|
rigor.invariant('non-negative', ({ actual }) => actual >= 0),
|
|
rigor.invariant('idempotent', ({ actual, fn }) => fn(actual) === actual)
|
|
])
|
|
).run({ effort: 200 , artifacts: { dir: '', persist: 'never' }});
|
|
|
|
assert.ok(report, 'campaign returns a report');
|
|
assert.equal(typeof report.toTAP, 'function', 'report has toTAP()');
|
|
// The report should have iterated at least once
|
|
assert.ok(report.stats || report.coverage || report.summary,
|
|
'report has stats/coverage/summary');
|
|
});
|
|
|
|
it('detects a violated invariant with a minimal failing oracle', async () => {
|
|
const report = await rigor.campaign(
|
|
[
|
|
rigor.fn('alwaysZero', () => 0,
|
|
rigor.args(rigor.gen.int()))
|
|
],
|
|
rigor.crucible([
|
|
rigor.invariant('equals-one', ({ actual }) => actual === 1)
|
|
])
|
|
).run({ effort: 50 , artifacts: { dir: '', persist: 'never' }});
|
|
|
|
// Report shape varies — log it for debugging.
|
|
if (process.env.TEST_DEBUG === '1') {
|
|
console.log('report keys:', Object.keys(report));
|
|
console.log('report.toTAP():', report.toTAP());
|
|
}
|
|
// At minimum the report should have *some* representation of the failure.
|
|
assert.ok(report, 'report returned');
|
|
});
|
|
});
|