conformance: 97 rules of 9 verifiers, 206 vectors; verify-layer and agents refuse a classical key under an ML-DSA-65 name; market-settlement reads the notarization time from the certified read; proof-of-ai README in English
This commit is contained in:
1 parent
c9f2932e04
commit
c9798a0013
111 files changed
+15871
-292
No files matched your search
@@ -24,11 +24,14 @@ arbiter or after `ARBITRATION_TIMEOUT`, the terminal payout matching the state,
|
||||
the public spec agreeing with whoever won, and the notarized envelope naming this job's spec and result before the window closed.
|
||||
Every refusal names its rule (`reguli`). A timeline the judge cannot read is refused by name, not thrown, and so is one that lacks an
|
||||
event the job state implies: a timeline with its submission event withheld used to skip the window rule and come out VALID (found by
|
||||
the conformance suite on 2026-10-03, `conformance/`).
|
||||
the conformance suite on 2026-10-03, `conformance/`). WHEN the provider's envelope was notarized is the chain's word, not the
|
||||
envelope's: the caller hands the judge the reading of the AIP-23 reference verifier for that envelope (`certified`: the first-seen
|
||||
time held by the notary under a verified post-quantum anchor); the judge takes the time from it and only compares the envelope's own
|
||||
claim with it. Until 2026-10-03 the time was taken from the claim. Without a certified reading the judge says so (`nemasurat`).
|
||||
|
||||
```
|
||||
AERE_TESTNET_KEY_FILE=<key> AERE_ETHERS_DIR=<dir with node_modules/ethers> node proba-piata-28001.mjs # the flow on 28001 (five scenarios)
|
||||
node proba-judecata.mjs # the judge on the recorded timelines: 5 honest VALID, 15 forged or malformed INVALID, the receipt
|
||||
node proba-judecata.mjs # the judge on the recorded timelines: 7 honest VALID, 18 forged or malformed INVALID, the receipt
|
||||
node proba-judecata.mjs --control-negativ # 10 plantings on a copy of piata.mjs; each forged fixture must then be accepted
|
||||
node extrage-artefact.mjs # regenerate AereComputeMarketV3.json from the contracts build (refuses a changed source)
|
||||
```
|
||||
|
||||
@@ -89,13 +89,13 @@ export function judeca(d) {
|
||||
try { return judecaForma(d); } catch (e) { return { verdict: 'INVALID', motive: ['malformed timeline: ' + String(e.message).slice(0, 120)], reguli: ['forma'], randuri: [] }; }
|
||||
}
|
||||
function judecaForma(d) {
|
||||
const motive = [], randuri = [], reguli = new Set(); const cere = (cond, text, regula) => { if (!REGULI.includes(regula)) throw new Error('piata: undeclared rule ' + regula); if (!cond) { motive.push(text); reguli.add(regula); } return !!cond; };
|
||||
const motive = [], randuri = [], nemasurat = [], reguli = new Set(); const cere = (cond, text, regula) => { if (!REGULI.includes(regula)) throw new Error('piata: undeclared rule ' + regula); if (!cond) { motive.push(text); reguli.add(regula); } return !!cond; };
|
||||
const j = d.job, ev = d.events || []; const un = (n) => ev.find((e) => e.name === n); const toate = (n) => ev.filter((e) => e.name === n);
|
||||
const t = (e) => (e ? e.timestamp : null);
|
||||
if (!j || !ev.length) return { verdict: 'INCOMPLETE', motive: ['no job or no events'], reguli: [], randuri };
|
||||
const intregi = (...x) => x.every(Number.isInteger);
|
||||
const okForma = typeof j === 'object' && Array.isArray(ev) && ev.every((e) => e && typeof e === 'object' && typeof e.name === 'string' && e.args && typeof e.args === 'object' && typeof e.from === 'string' && intregi(e.timestamp, e.blockNumber))
|
||||
&& !!d.constants && typeof d.constants.arbiter === 'string' && intregi(d.constants.arbitrationTimeout, j.deadline, j.submittedAt, j.challengeWindow, j.status) && (d.result == null || typeof d.result === 'string') /*PAZA:forma*/;
|
||||
&& !!d.constants && typeof d.constants.arbiter === 'string' && intregi(d.constants.arbitrationTimeout, j.deadline, j.submittedAt, j.challengeWindow, j.status) && (d.result == null || typeof d.result === 'string') && (d.certified == null || (typeof d.certified === 'object' && Number.isInteger(d.certified.firstSeen))) /*PAZA:forma*/;
|
||||
if (!cere(okForma, 'malformed timeline: events need name, args, from, integer timestamp and blockNumber; the job and the constants their integer fields', 'forma')) return { verdict: 'INVALID', motive, reguli: [...reguli].sort(), randuri };
|
||||
for (const e of ev) randuri.push(`${new Date(e.timestamp * 1000).toISOString()} #${e.blockNumber} ${e.name} by ${e.from.slice(0, 10)}.. ${Object.entries(e.args).filter(([k]) => k !== 'result').map(([k, v]) => k + '=' + (H32.test(String(v)) ? String(v).slice(0, 10) + '..' : String(v).length > 20 ? String(v).slice(0, 10) + '..' : v)).join(' ')}`);
|
||||
const posted = un('JobPosted'), claimed = un('JobClaimed'), submitted = un('ResultSubmitted') || un('ResultReferenced'), disputed = un('JobDisputed'), resolved = un('DisputeResolved'), timedOut = un('DisputeTimedOut'), paid = un('JobPaid'), refunded = un('JobRefunded'), slashed = un('JobSlashed');
|
||||
@@ -140,10 +140,24 @@ function judecaForma(d) {
|
||||
const e = d.envelope, stmt = e.statement || {};
|
||||
const okE = e.kind === 'aere-proof-of-execution-attestation' && low(stmt.outputHash) === low(j.resultHash) && low(stmt.inputHash) === low(j.specHash) && sha256(Buffer.from(JSON.stringify(stmt), 'utf8')) === low(e.statementHash) /*PAZA:dovada*/;
|
||||
cere(okE, 'the execution envelope does not name this job\'s specHash/resultHash, or its statementHash is not its statement\'s', 'dovada');
|
||||
if (e.notarization && submitted) cere(Number(e.notarization.firstSeen) <= j.submittedAt + j.challengeWindow /*PAZA:dovada*/, 'the envelope was notarized only after the challenge window closed', 'dovada');
|
||||
// WHEN the envelope was notarized is the chain's word, not the envelope's: `d.certified` is the reading of the AIP-23 reference
|
||||
// verifier for THIS envelope (its finality level's `certified`: the first-seen time held by the notary under a state root that a
|
||||
// verified post-quantum anchor covers), brought by the caller who ran that verifier, never taken from the artifact. The time is
|
||||
// taken from it; the envelope's own claim is only compared with it. (2026-10-03: until then the time was taken from the claim,
|
||||
// so a claim written earlier than the truth passed.) Without a certified reading the claim is all there is: a claim that itself
|
||||
// admits lateness is refused, and the result says the time was not measured.
|
||||
const cert = d.certified || null, fereastra = j.submittedAt + j.challengeWindow;
|
||||
if (cert) {
|
||||
cere(low(cert.statementHash) === low(e.statementHash) /*PAZA:dovada*/, 'the certified reading is for another envelope than the one shown', 'dovada');
|
||||
if (submitted) cere(cert.firstSeen <= fereastra /*PAZA:dovada*/, `the chain first saw the envelope at ${cert.firstSeen}, after the challenge window closed (${fereastra})`, 'dovada');
|
||||
if (e.notarization && e.notarization.firstSeen !== undefined) cere(Number(e.notarization.firstSeen) === cert.firstSeen /*PAZA:dovada*/, `the envelope claims it was first seen at ${e.notarization.firstSeen}; the chain, read under the anchor, says ${cert.firstSeen}`, 'dovada');
|
||||
} else if (e.notarization) {
|
||||
if (submitted) cere(Number(e.notarization.firstSeen) <= fereastra /*PAZA:dovada*/, 'the envelope was notarized only after the challenge window closed (by its own claim)', 'dovada');
|
||||
nemasurat.push('the notarization time: the envelope\'s claim was not compared with a certified reading of the chain');
|
||||
}
|
||||
}
|
||||
const terminalStatus = ['Paid', 'Refunded', 'Slashed'].includes(st);
|
||||
return { verdict: motive.length ? 'INVALID' : terminalStatus ? 'VALID' : 'INCOMPLETE', motive, reguli: [...reguli].sort(), randuri, status: st, terminal, replay };
|
||||
return { verdict: motive.length ? 'INVALID' : terminalStatus ? 'VALID' : 'INCOMPLETE', motive, reguli: [...reguli].sort(), nemasurat, randuri, status: st, terminal, replay };
|
||||
}
|
||||
/** The AIP-23 settlement receipt of a terminal job: the payout transaction, the parties, the amount, the instruction (market, job, status). */
|
||||
export function chitanta(d, { createdAt = new Date().toISOString() } = {}) {
|
||||
|
||||
@@ -38,6 +38,13 @@ export function fixturi(P) {
|
||||
F.push({ nume: 'N12 S5 an event whose time is not a whole number of seconds: refused by name (form)', asteptat: 'INVALID', paza: 'forma', r: () => { const d = date('S5'); ev(d, 'JobPosted').timestamp += 0.5; return v(P.judeca(d)); } });
|
||||
F.push({ nume: 'N14 S1 finalized inside the window by a third party, with the ResultSubmitted event withheld (the window rule would be skipped): refused as not whole', asteptat: 'INVALID', paza: 'intreg', r: () => { const d = date('S1'); ev(d, 'JobPaid').timestamp = d.job.submittedAt + 1; d.events = d.events.filter((e) => e.name !== 'ResultSubmitted'); const r = P.judeca(d); return { verdict: r.verdict, detail: r.reguli.join() + ': ' + r.motive.join('; ') }; } });
|
||||
F.push({ nume: 'N15 S4 the JobClaimed event withheld (the deadline rule of an expiry would be skipped): refused as not whole', asteptat: 'INVALID', paza: 'intreg', r: () => { const d = date('S4'); d.events = d.events.filter((e) => e.name !== 'JobClaimed'); return v(P.judeca(d)); } });
|
||||
// the notarization time is the chain's (a certified reading), not the envelope's claim
|
||||
const cuCert = (d, x = {}) => ({ ...d, certified: { statementHash: d.envelope.statementHash, firstSeen: d.envelope.notarization.firstSeen, ...x } });
|
||||
F.push({ nume: 'C1 S1 with the certified reading of its envelope (the same time the claim says): VALID, nothing left unmeasured', asteptat: 'VALID', r: () => { const r = P.judeca(cuCert(date('S1'))); return { verdict: r.verdict === 'VALID' && r.nemasurat.length === 0 ? 'VALID' : 'INVALID', detail: r.motive.join('; ') + ' unmeasured: ' + r.nemasurat.length }; } });
|
||||
F.push({ nume: 'C2 S1 without a certified reading: VALID by the claim, and the judge says the time was not measured', asteptat: 'VALID', r: () => { const r = P.judeca(date('S1')); return { verdict: r.verdict === 'VALID' && r.nemasurat.length === 1 ? 'VALID' : 'INVALID', detail: r.nemasurat.join('; ') }; } });
|
||||
F.push({ nume: 'N16 S1 the envelope claims an earlier time than the chain certifies', asteptat: 'INVALID', paza: 'dovada', r: () => { const d = date('S1'); const c = cuCert(d); c.envelope.notarization.firstSeen -= 600; return v(P.judeca(c)); } });
|
||||
F.push({ nume: 'N17 S1 the chain certifies a time after the window closed, whatever the claim says', asteptat: 'INVALID', paza: 'dovada', r: () => { const d = date('S1'); return v(P.judeca(cuCert(d, { firstSeen: d.job.submittedAt + d.job.challengeWindow + 1 }))); } });
|
||||
F.push({ nume: 'N18 S1 a certified reading that is for another envelope', asteptat: 'INVALID', paza: 'dovada', r: () => v(P.judeca(cuCert(date('S1'), { statementHash: '0x' + 'dd'.repeat(32) }))) });
|
||||
F.push({ nume: 'N13 malformed timelines (no constants, an event without args, events not a list) are refused by name, never thrown', asteptat: 'INVALID', r: () => { const rez = [(d) => { delete d.constants; }, (d) => { delete d.events[0].args; }, (d) => { d.events = 'x'; }].map((f) => { const d = date('S2'); f(d); const r = P.judeca(d); return r.verdict + ':' + r.reguli.join(); }); return { verdict: rez.every((x) => x === 'INVALID:forma') ? 'INVALID' : 'VALID', detail: rez.join(' ') }; } });
|
||||
F.push({ nume: 'R1 the settlement receipt of S1 is an AIP-23 settlement envelope naming the payout tx and the provider', asteptat: 'VALID', r: () => { const d = date('S1'); const c = P.chitanta(d); const t = ev(d, 'JobPaid'); return { verdict: c.kind === 'aere-proof-of-settlement-attestation' && c.statement.txHash === t.txHash && c.statement.to.toLowerCase() === d.job.provider.toLowerCase() && c.statement.chainId === 28001 ? 'VALID' : 'INVALID', detail: c.statementHash.slice(0, 18) + '..' }; } });
|
||||
return F;
|
||||
|
||||
Reference in new issue
Block a user