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
@@ -18,6 +18,9 @@ import { VERIFICATOARE, FINALITY_SITES, VERIFY_PROOF, incarca } from './reguli.m
|
||||
import { acumulator, pica, trece, nemasurat, verdictUnic } from './verdict.mjs';
|
||||
|
||||
const RPC = { 2800: process.env.AERE_CONFORMANCE_RPC_2800 || 'https://rpc.aere.network', 28001: process.env.AERE_CONFORMANCE_RPC_28001 || 'https://testnet-rpc.aere.network' };
|
||||
// a verifier that takes the reference verifier as a DEPENDENCY (the trust chain judges its envelopes with it) gets the real one even
|
||||
// while the planting control substitutes a planted copy for the envelopes this file judges itself
|
||||
const VERIFY_PROOF_DEP = process.env.AERE_CONF_VERIFY_PROOF_DEP || VERIFY_PROOF;
|
||||
const LANT = (n) => (n === 28001 ? 'chain 28001, a testnet' : 'chain ' + n);
|
||||
const ARTIFACTE = Object.values(VERIFICATOARE).flatMap((v) => v.artifacts);
|
||||
const toateRegulile = Object.values(VERIFICATOARE).flatMap((v) => Object.values(v.reguli).map((r) => r[0]));
|
||||
@@ -30,11 +33,11 @@ function ruleaza(cmd, args, timeout) {
|
||||
});
|
||||
}
|
||||
/** The envelope, judged by the reference verifier; its levels land in the accumulator under the public rule ids. */
|
||||
async function plic(acc, env, { online, chain }) {
|
||||
async function plic(acc, env, { online, chain, raw }) {
|
||||
if (!fs.existsSync(VERIFY_PROOF)) throw new Error('the AIP-23 reference verifier is not at ' + VERIFY_PROOF + ' (AERE_VERIFY_PROOF=<verify-proof.mjs>)');
|
||||
const claim = env && typeof env === 'object' ? env.notarization : null; let judecat = env;
|
||||
if (!online && claim) { judecat = { ...env }; delete judecat.notarization; }
|
||||
const f = path.join(fs.mkdtempSync(path.join(os.tmpdir(), 'aere-conf-')), 'envelope.json'); fs.writeFileSync(f, JSON.stringify(judecat === undefined ? null : judecat));
|
||||
const f = path.join(fs.mkdtempSync(path.join(os.tmpdir(), 'aere-conf-')), 'envelope.json'); fs.writeFileSync(f, typeof raw === 'string' ? raw : JSON.stringify(judecat === undefined ? null : judecat)); // `raw`: the text of a file that is not JSON
|
||||
const lant = Number(chain || (claim && claim.chainId) || 28001);
|
||||
const args = [VERIFY_PROOF, f, '--json']; if (online) { if (!RPC[lant]) throw new Error('no endpoint known for chain ' + lant); args.push('--chain', String(lant), '--rpc', RPC[lant]); }
|
||||
let r; try { r = await ruleaza(process.execPath, args, online ? 240000 : 60000); } finally { fs.rmSync(path.dirname(f), { recursive: true, force: true }); }
|
||||
@@ -57,6 +60,7 @@ async function plic(acc, env, { online, chain }) {
|
||||
if (loc[0].level === 'anchoring') nemasurat(acc, 'finality', 'not-applicable', 'nothing is anchored, so no certificate covers it');
|
||||
else nemasurat(acc, 'anchoring', 'not-reached', 'the anchor certificate did not verify, the notary state under it was not read');
|
||||
} else ambele(fin.state === 'ABSENT' ? 'absent' : fin.state === 'PENDING' ? 'pending' : 'unmeasurable', fin.detail);
|
||||
return j;
|
||||
}
|
||||
const faraPlic = (acc) => { for (const l of ['authenticity', 'anchoring', 'finality']) nemasurat(acc, l, 'not-judged', 'this artifact carries no AIP-23 envelope; its commitment is signed or anchored through one, judged as the artifact `envelope`'); };
|
||||
/** The rules a module named, as public ids at their levels; `text` is the module's own reasons. */
|
||||
@@ -68,7 +72,7 @@ function reguli(acc, verifier, surse, motive, titlu) {
|
||||
|
||||
async function judeca(artifact, input, online) {
|
||||
const acc = acumulator();
|
||||
if (artifact === 'envelope') await plic(acc, input.envelope, { online, chain: input.chain });
|
||||
if (artifact === 'envelope') await plic(acc, input.envelope, { online, chain: input.chain, raw: input.raw });
|
||||
else if (artifact === 'payment-risk') {
|
||||
const M = await incarca('risc'); const v = M.judeca(input.policy, input.inputs);
|
||||
if ((v.decision === 'ALLOW') !== (v.rules.length === 0)) throw new Error('the risk module refused without naming a rule');
|
||||
@@ -79,10 +83,57 @@ async function judeca(artifact, input, online) {
|
||||
reguli(acc, 'payment-receipt', r.reguli, r.motive, 'no rule of the receipt verifier refused' + (r.chainChecked ? ' (transaction facts supplied)' : ' (no transaction facts supplied)'));
|
||||
await plic(acc, input.receipt && input.receipt.envelope, { online, chain: input.chain });
|
||||
} else if (artifact === 'market-timeline') {
|
||||
const M = await incarca('piata'); const r = M.judeca(input);
|
||||
// the envelope first: WHEN it was notarized is the reading of the reference verifier under the anchor (its finality level's
|
||||
// `certified`), handed to the judge. A `certified` the artifact brings itself is dropped: that reading is never the artifact's.
|
||||
const M = await incarca('piata'); const { certified: adus, ...cronologie } = input; let certified = null;
|
||||
if (input.envelope) { const j = await plic(acc, input.envelope, { online, chain: input.chainId }); const f = (j.levels || []).find((x) => x.level === 'finality'); if (f && f.state === 'PASSED' && f.certified) certified = { ...f.certified, statementHash: input.envelope.statementHash }; } else faraPlic(acc);
|
||||
const r = M.judeca(certified ? { ...cronologie, certified } : cronologie);
|
||||
if (r.verdict === 'INCOMPLETE') nemasurat(acc, 'integrity', 'incomplete', 'the timeline is not terminal (' + (r.status || 'no job or no events') + ')');
|
||||
else { if ((r.verdict === 'VALID') !== (r.reguli.length === 0)) throw new Error('the market judge refused without naming a rule'); reguli(acc, 'market-timeline', r.reguli, r.motive, 'no rule of the market judge refused (status ' + r.status + ')'); }
|
||||
if (input.envelope) await plic(acc, input.envelope, { online, chain: input.chainId }); else faraPlic(acc);
|
||||
} else if (artifact === 'audit-log' || artifact === 'audit-inclusion' || artifact === 'audit-consistency') {
|
||||
// an audit log against its own chain and, when given, an attested head; an inclusion or a consistency proof against tree heads.
|
||||
// The checks of a head's signature are the sidecar's whichever file calls them: their rules are mapped there.
|
||||
const S = VERIFICATOARE['audit-log'].reguli, T = VERIFICATOARE['audit-tree'].reguli; let r, semnat = null;
|
||||
if (artifact === 'audit-log') { const M = await incarca('sidecar'); r = input.head !== undefined ? M.verificaFataDeCap(input.log, input.head, { semnatar: input.signer || null }) : M.verificaJurnal(input.log); if (r.ok && input.head !== undefined) semnat = r.semnatDe; }
|
||||
else { const M = await incarca('arbore'); r = artifact === 'audit-inclusion' ? M.verificaIncludere(input.proof, { cap: input.head || null, semnatar: input.signer || null }) : M.verificaConsistenta(input.proof, { vechi: input.older, nou: input.newer, semnatar: input.signer || null }); if (r.ok) semnat = r.semnatDe || r.semnatNou || null; }
|
||||
if (r.ok) { trece(acc, 'integrity', 'no rule of the audit log verifier refused'); if (semnat) trece(acc, 'authenticity', 'the head is signed with ML-DSA-65 by key ' + String(semnat).slice(0, 18) + (input.signer ? '.., the expected signer' : '.. (not compared with an expected signer)')); else nemasurat(acc, 'authenticity', 'absent', 'no signed head'); }
|
||||
else { const m = (artifact === 'audit-log' ? S[r.regula] : T[r.regula] || S[r.regula]); if (!m) throw new Error('the audit log verifier refused without a rule this suite maps: ' + r.regula); pica(acc, m[1], m[0], r.motiv);
|
||||
nemasurat(acc, m[1] === 'integrity' ? 'authenticity' : 'integrity', 'not-reached', 'the verifier stopped at its first refusal'); }
|
||||
for (const l of ['anchoring', 'finality']) nemasurat(acc, l, 'not-judged', 'an audit head is anchored by notarizing its envelope, judged as the artifact `envelope`');
|
||||
} else if (artifact === 'agent-ledger') {
|
||||
// an agent's signed ledger, verified as a stranger would: the policy re-hashed, the identity bound to the key, every signature, the
|
||||
// chain, and every decision re-derived by replaying the policy
|
||||
const M = await incarca('ledger'); const R = VERIFICATOARE['agent-ledger'].reguli; const o = { policy: input.policy, policyHash: input.policyHash, anchors: input.anchors || [], notBefore: input.notBefore === undefined ? null : input.notBefore, revocations: input.revocations || [] };
|
||||
if (input.maxTime !== undefined) o.maxTime = input.maxTime;
|
||||
const r = M.verifyLedger(input.ledger, o);
|
||||
if (r.ok) { trece(acc, 'integrity', `the ledger verifies under its policy: ${r.seq} entries, ${r.allowedPayments} allowed payments, time ${r.time.lowerBound}`); trece(acc, 'authenticity', 'the agent id is derived from its ML-DSA-65 key and every entry is signed by it'); }
|
||||
else { const m = R[r.rule]; if (!m) throw new Error('the ledger verifier refused without a rule this suite maps: ' + r.rule); pica(acc, m[1], m[0], r.error); nemasurat(acc, m[1] === 'integrity' ? 'authenticity' : 'integrity', 'not-reached', 'the verifier stopped at its first refusal'); }
|
||||
for (const l of ['anchoring', 'finality']) nemasurat(acc, l, 'not-judged', 'a ledger head is anchored by notarizing its envelope, judged as the artifact `envelope`');
|
||||
} else if (artifact === 'ai-trust-bundle') {
|
||||
// the trust chain of an AI result, judged by its own verifier (which runs the reference verifier on each envelope and the agents'
|
||||
// and the audit log's verifiers on theirs). Offline, a notarization claimed by the attestation, the runtime record or the audit
|
||||
// head is taken out of the copy judged (those envelopes are not hashed into the ledger) and reported as not checked.
|
||||
const M = await incarca('aitrust'); const b = JSON.parse(JSON.stringify(input.bundle === undefined ? null : input.bundle)); let claim = false; const ob = (x) => !!x && typeof x === 'object';
|
||||
const lant = Number((ob(b) && ob(b.witness) && b.witness.chainId) || input.chain || 28001);
|
||||
if (!online && ob(b)) {
|
||||
for (const e of [ob(b.version) && b.version.attestation, ob(b.runtime) && b.runtime.record, ob(b.runtime) && b.runtime.head]) if (ob(e) && e.notarization) { delete e.notarization; claim = true; }
|
||||
if (ob(b.provenance) && ob(b.provenance.proofOfAi) && b.provenance.proofOfAi.notarization) { nemasurat(acc, 'integrity', 'claim-not-checked', 'the Proof of AI envelope claims a notarization: this bundle is judged only with the chain (--online)'); return verdictUnic(artifact, acc); }
|
||||
}
|
||||
if (online && !RPC[lant]) throw new Error('no endpoint known for chain ' + lant);
|
||||
const v = await M.verifica(b, { verifyProof: VERIFY_PROOF_DEP, rpc: online ? RPC[lant] : null, chain: online ? lant : null });
|
||||
const R = VERIFICATOARE['ai-trust'].reguli; const st = v.levels, det = v.details;
|
||||
for (const l of Object.keys(st)) if (st[l] === 'FAILED') { const r = R[det[l].reason]; if (!r) throw new Error('ai-trust named a rule this suite does not map: ' + det[l].reason); pica(acc, r[1], r[0], det[l].detail); }
|
||||
const INT = ['version', 'runtime', 'permissions', 'provenance'];
|
||||
const nem = INT.find((l) => st[l] === 'UNMEASURED');
|
||||
if (nem) nemasurat(acc, 'integrity', 'unmeasurable', nem + ': ' + det[nem].reason);
|
||||
else if (st.form === 'PASSED' && st.permissions === 'PASSED' && st.provenance === 'PASSED') trece(acc, 'integrity', 'the links hold: ' + INT.map((l) => l + ' ' + st[l]).join(', '));
|
||||
if (st.identity === 'PASSED') trece(acc, 'authenticity', det.identity.detail); else if (st.identity !== 'FAILED') nemasurat(acc, 'authenticity', 'not-reached', 'the identity level was not reached');
|
||||
const ambele = (cause, reason) => { nemasurat(acc, 'anchoring', cause, reason); nemasurat(acc, 'finality', cause, reason); };
|
||||
if (st.witness === 'PASSED') { trece(acc, 'anchoring', det.witness.detail); trece(acc, 'finality', 'the post-quantum certificate of the covering anchor verified (' + LANT(lant) + '; the finality is that chain\'s)'); }
|
||||
else if (st.witness === 'FAILED') nemasurat(acc, 'finality', 'not-applicable', 'no head of this ledger is anchored');
|
||||
else if (st.witness === 'UNMEASURED') ambele(online ? 'unmeasurable' : 'claim-not-checked', online ? String(det.witness.detail).slice(0, 200) : 'the bundle brings notarized heads; this run was offline, they were not read');
|
||||
else if (st.form === 'PASSED') ambele('unwitnessed', 'no witness: every time in this bundle is the statement of whoever holds the keys');
|
||||
if (claim) nemasurat(acc, 'anchoring', 'claim-not-checked', 'an envelope of the bundle claims a notarization; this run was offline, the claim was not checked');
|
||||
} else if (artifact.startsWith('dataset-')) {
|
||||
const M = await incarca('baza'); let r;
|
||||
if (artifact === 'dataset-record') r = M.verificaInregistrare(input.record, input.commitment);
|
||||
|
||||
Reference in new issue
Block a user