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
@@ -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() } = {}) {
|
||||
|
||||
Reference in new issue
Block a user