Read the source and its declared rule
The original extraction contract requires cache evidenceR2. Formula 2+3 carries cached 4 fromR1, so this input is held. The example does not evaluate formulas: an apparently obvious calculation is not permission to replace the recorded cache with an invented result.
| Record | Input JSON |
|---|---|
| Base input | {"formula":"2+3","cache":4,"cacheRevision":"R1","requiredRevision":"R2"} |
Compare the actual paths
Good output preserves formula and cache 4 while recording the evidence gap. A matching declared cache value 5 can proceed; revision matching is the supplied approval gate, not a general proof of every formula’s correctness.
| Path | Output JSON |
|---|---|
| Misleading path | {"accepted":true,"value":4,"formula":"2+3"} |
| Corrected path | {"accepted":false,"error":"cache-evidence-gap","formula":"2+3","retainedCache":4} |
import {DatabaseSync} from 'node:sqlite';
import {TextDecoder} from 'node:util';
import {inflateSync} from 'node:zlib';
import {posix} from 'node:path';
import {createHash} from 'node:crypto';
const rows=(db,sql)=>db.prepare(sql).all().map(r=>({...r}));
const failed=(action)=>{try{action();return null;}catch(e){return {code:e.errcode??e.code??e.name};}};
import assert from 'node:assert/strict';
const run=function run(i,corrected=true){
if(corrected&&(i.cache===null||i.cacheRevision!==i.requiredRevision))return {accepted:false,error:'cache-evidence-gap',formula:i.formula,retainedCache:i.cache};
return {accepted:true,value:i.cache,formula:i.formula};
};
const cases=[{"label":"misleading base","input":{"formula":"2+3","cache":4,"cacheRevision":"R1","requiredRevision":"R2"},"expected":{"accepted":true,"value":4,"formula":"2+3"},"corrected":false},{"label":"corrected base","input":{"formula":"2+3","cache":4,"cacheRevision":"R1","requiredRevision":"R2"},"expected":{"accepted":false,"error":"cache-evidence-gap","formula":"2+3","retainedCache":4},"corrected":true},{"label":"matching declared cache evidence","input":{"formula":"2+3","cache":5,"cacheRevision":"R2","requiredRevision":"R2"},"expected":{"accepted":true,"value":5,"formula":"2+3"},"corrected":true},{"label":"no cached result","input":{"formula":"2+3","cache":null,"cacheRevision":"R2","requiredRevision":"R2"},"expected":{"accepted":false,"error":"cache-evidence-gap","formula":"2+3","retainedCache":null},"corrected":true}];
for(const test of cases){
const actual=run(test.input,test.corrected);
assert.deepEqual(actual,test.expected,test.label);
console.log(test.label,actual);
}
Check boundaries before the next load
Matching R2 with cache 5 accepts. No cache remains held even if the revision label isR2.
| Case | Input JSON | Expected output JSON |
|---|---|---|
| Matching cache evidence | {"formula":"2+3","cache":5,"cacheRevision":"R2","requiredRevision":"R2"} | {"accepted":true,"value":5,"formula":"2+3"} |
| No cached result | {"formula":"2+3","cache":null,"cacheRevision":"R2","requiredRevision":"R2"} | {"accepted":false,"error":"cache-evidence-gap","formula":"2+3","retainedCache":null} |
May this importer replace cache 4 with 5 on its own?
Show the worked answer
No. It has no formula-evaluation or renewed evidence step. Hold 4 until the required cache evidence is supplied.