feat: intermediate chain condition steps, graph-version cache invalidation, rolling-hash chain keys; fix vacuous rigor invariants
Chain intermediates (rule-based reachability):
- ChainRule: a condition step ({ rule, conditionStep }) at an INTERMEDIATE
position is now EXPANDED from the current node — the rule's base edges'
destinations, filtered by its defeaters/requirements — and traversal
continues from each discovered node. Adds _expandRuleFromSrc / direct /
logical(union/intersection) / defeasible / nested-chain expansion.
- RuleEvaluator: _subjectIsObject flag for unary predicate calls whose subject
entity IS the object parameter (trusted(other) inside peer_trusted(user,
other)); previously only subject-var unary calls (_subjectAsObject) were
handled, so object-var unary defeaters never fired.
Graph-version cache invalidation:
- Arbiter gains a monotonic _graphVersion, incremented on every relation
mutation. ChainRule result cache, RuleEvaluator rule-result cache, and
DecisionCache rule cache now stamp entries with the graph version and treat
any mismatch as a miss — graph mutations can no longer serve stale
chain/authorization results.
Rolling-hash cache keys:
- UnifiedKeyManager.createChainKey now builds a 53-bit rolling hash (dual
FNV-1a lanes, exact for ints/floats/strings/nested configs) instead of
JSON.stringify — no string allocation or serialization on the chain-cache
hot path. Composite keys stay structured strings because the direct-check
cache pattern-invalidates by relation ID.
Rigor invariant migration (correctness):
- All 43 rigor test files' throw-based invariants ({ error, errorMessage } =>
!error && !errorMessage) never saw fn throws — vacuous. Migrated to
({ actual }) => actual !== undefined, which fails on any thrown violation
while passing legitimate null-skips. The migration immediately surfaced
two latent bugs, now fixed:
* node-manager/graph-indices skip paths returned bare undefined (falsy
sentinel) — return { skipped: true }.
* complex-graph-values-crucible expiry section rewrote values equal to the
mutation loop's last write; the engine (by design) keeps the old
timestamp on same-value rewrites so the pre-expiry grant never
materialized. Now writes guaranteed-different values.
This commit is contained in:
@@ -91,7 +91,7 @@ describe('NodeManager index invariants (rigor)', () => {
|
||||
)
|
||||
],
|
||||
rigor.crucible([
|
||||
rigor.invariant('inverse-maps', ({ error, errorMessage }) => !error && !errorMessage)
|
||||
rigor.invariant('inverse-maps', ({ actual }) => actual !== undefined)
|
||||
])
|
||||
).run({ seed: 'node-manager-inverse-maps', effort: 800 , artifacts: { dir: '', persist: 'never' }});
|
||||
|
||||
@@ -131,7 +131,7 @@ describe('NodeManager index invariants (rigor)', () => {
|
||||
)
|
||||
],
|
||||
rigor.crucible([
|
||||
rigor.invariant('addNode-idempotent', ({ error, errorMessage }) => !error && !errorMessage)
|
||||
rigor.invariant('addNode-idempotent', ({ actual }) => actual !== undefined)
|
||||
])
|
||||
).run({ seed: 'node-manager-add-idempotent', effort: 800 , artifacts: { dir: '', persist: 'never' }});
|
||||
|
||||
@@ -184,7 +184,7 @@ describe('NodeManager index invariants (rigor)', () => {
|
||||
)
|
||||
],
|
||||
rigor.crucible([
|
||||
rigor.invariant('size-invariant', ({ error, errorMessage }) => !error && !errorMessage)
|
||||
rigor.invariant('size-invariant', ({ actual }) => actual !== undefined)
|
||||
])
|
||||
).run({ seed: 'node-manager-size-invariant', effort: 1500 , artifacts: { dir: '', persist: 'never' }});
|
||||
|
||||
@@ -198,7 +198,7 @@ describe('NodeManager index invariants (rigor)', () => {
|
||||
it('nextNodeId advances monotonically across distinct addNode calls', async () => {
|
||||
async function check(keys, types) {
|
||||
const { manager, arbiter } = makeManager();
|
||||
if (keys.length !== types.length) return; // skip ill-formed
|
||||
if (keys.length !== types.length) return { skipped: true }; // skip ill-formed
|
||||
const ids = [];
|
||||
for (let i = 0; i < keys.length; i++) {
|
||||
ids.push(manager.addNode(keys[i], types[i]));
|
||||
@@ -247,7 +247,7 @@ describe('NodeManager index invariants (rigor)', () => {
|
||||
)
|
||||
],
|
||||
rigor.crucible([
|
||||
rigor.invariant('monotonic-ids', ({ error, errorMessage }) => !error && !errorMessage)
|
||||
rigor.invariant('monotonic-ids', ({ actual }) => actual !== undefined)
|
||||
])
|
||||
).run({ seed: 'node-manager-monotonic-ids', effort: 800 , artifacts: { dir: '', persist: 'never' }});
|
||||
|
||||
@@ -293,7 +293,7 @@ describe('NodeManager index invariants (rigor)', () => {
|
||||
)
|
||||
],
|
||||
rigor.crucible([
|
||||
rigor.invariant('removeNode-cleanup', ({ error, errorMessage }) => !error && !errorMessage)
|
||||
rigor.invariant('removeNode-cleanup', ({ actual }) => actual !== undefined)
|
||||
])
|
||||
).run({ seed: 'node-manager-remove-cleanup', effort: 800 , artifacts: { dir: '', persist: 'never' }});
|
||||
|
||||
@@ -333,7 +333,7 @@ describe('NodeManager index invariants (rigor)', () => {
|
||||
)
|
||||
],
|
||||
rigor.crucible([
|
||||
rigor.invariant('clearNodes-resets', ({ error, errorMessage }) => !error && !errorMessage)
|
||||
rigor.invariant('clearNodes-resets', ({ actual }) => actual !== undefined)
|
||||
])
|
||||
).run({ seed: 'node-manager-clear-resets', effort: 500 , artifacts: { dir: '', persist: 'never' }});
|
||||
|
||||
@@ -386,7 +386,7 @@ describe('NodeManager index invariants (rigor)', () => {
|
||||
)
|
||||
],
|
||||
rigor.crucible([
|
||||
rigor.invariant('updateNodeData-merges', ({ error, errorMessage }) => !error && !errorMessage)
|
||||
rigor.invariant('updateNodeData-merges', ({ actual }) => actual !== undefined)
|
||||
])
|
||||
).run({ seed: 'node-manager-update-merge', effort: 800 , artifacts: { dir: '', persist: 'never' }});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user