@mnemom/mnemom 0.17.35 → 0.17.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commands/agent-run.d.ts +4 -0
- package/dist/commands/agent-run.js +9 -1
- package/dist/commands/agent-share-render.js +1 -1
- package/dist/commands/scan.d.ts +13 -3
- package/dist/commands/scan.js +48 -10
- package/dist/index.js +3 -2
- package/dist/lib/config.d.ts +7 -0
- package/dist/lib/config.js +21 -0
- package/dist/lib/scan/pr-source.js +2 -0
- package/dist/lib/scan/repo-picker.d.ts +32 -0
- package/dist/lib/scan/repo-picker.js +80 -0
- package/node_modules/@mnemom/aip-verifier/LICENSE +190 -0
- package/node_modules/@mnemom/aip-verifier/dist/claim-lint-CVITIRcU.d.cts +478 -0
- package/node_modules/@mnemom/aip-verifier/dist/claim-lint-CVITIRcU.d.ts +478 -0
- package/node_modules/@mnemom/aip-verifier/dist/index.cjs +971 -0
- package/node_modules/@mnemom/aip-verifier/dist/index.cjs.map +1 -0
- package/node_modules/@mnemom/aip-verifier/dist/index.d.cts +330 -0
- package/node_modules/@mnemom/aip-verifier/dist/index.d.ts +330 -0
- package/node_modules/@mnemom/aip-verifier/dist/index.js +933 -0
- package/node_modules/@mnemom/aip-verifier/dist/index.js.map +1 -0
- package/node_modules/@mnemom/aip-verifier/dist/render-lines.cjs +879 -0
- package/node_modules/@mnemom/aip-verifier/dist/render-lines.cjs.map +1 -0
- package/node_modules/@mnemom/aip-verifier/dist/render-lines.d.cts +96 -0
- package/node_modules/@mnemom/aip-verifier/dist/render-lines.d.ts +96 -0
- package/node_modules/@mnemom/aip-verifier/dist/render-lines.js +875 -0
- package/node_modules/@mnemom/aip-verifier/dist/render-lines.js.map +1 -0
- package/node_modules/@mnemom/aip-verifier/package.json +86 -0
- package/node_modules/@noble/ed25519/LICENSE +21 -0
- package/node_modules/@noble/ed25519/README.md +371 -0
- package/node_modules/@noble/ed25519/index.d.ts +391 -0
- package/node_modules/@noble/ed25519/index.js +933 -0
- package/node_modules/@noble/ed25519/index.ts +1134 -0
- package/node_modules/@noble/ed25519/package.json +54 -0
- package/node_modules/@noble/hashes/LICENSE +21 -0
- package/node_modules/@noble/hashes/README.md +478 -0
- package/node_modules/@noble/hashes/_blake.d.ts +20 -0
- package/node_modules/@noble/hashes/_blake.js +59 -0
- package/node_modules/@noble/hashes/_md.d.ts +95 -0
- package/node_modules/@noble/hashes/_md.js +209 -0
- package/node_modules/@noble/hashes/_u64.d.ts +36 -0
- package/node_modules/@noble/hashes/_u64.js +77 -0
- package/node_modules/@noble/hashes/argon2.d.ts +148 -0
- package/node_modules/@noble/hashes/argon2.js +577 -0
- package/node_modules/@noble/hashes/blake1.d.ts +162 -0
- package/node_modules/@noble/hashes/blake1.js +630 -0
- package/node_modules/@noble/hashes/blake2.d.ts +203 -0
- package/node_modules/@noble/hashes/blake2.js +573 -0
- package/node_modules/@noble/hashes/blake3.d.ts +68 -0
- package/node_modules/@noble/hashes/blake3.js +310 -0
- package/node_modules/@noble/hashes/eskdf.d.ts +91 -0
- package/node_modules/@noble/hashes/eskdf.js +225 -0
- package/node_modules/@noble/hashes/hkdf.d.ts +70 -0
- package/node_modules/@noble/hashes/hkdf.js +152 -0
- package/node_modules/@noble/hashes/hmac.d.ts +50 -0
- package/node_modules/@noble/hashes/hmac.js +93 -0
- package/node_modules/@noble/hashes/index.d.ts +1 -0
- package/node_modules/@noble/hashes/index.js +34 -0
- package/node_modules/@noble/hashes/legacy.d.ts +107 -0
- package/node_modules/@noble/hashes/legacy.js +348 -0
- package/node_modules/@noble/hashes/package.json +91 -0
- package/node_modules/@noble/hashes/pbkdf2.d.ts +66 -0
- package/node_modules/@noble/hashes/pbkdf2.js +176 -0
- package/node_modules/@noble/hashes/scrypt.d.ts +98 -0
- package/node_modules/@noble/hashes/scrypt.js +304 -0
- package/node_modules/@noble/hashes/sha2.d.ts +176 -0
- package/node_modules/@noble/hashes/sha2.js +446 -0
- package/node_modules/@noble/hashes/sha3-addons.d.ts +533 -0
- package/node_modules/@noble/hashes/sha3-addons.js +973 -0
- package/node_modules/@noble/hashes/sha3.d.ts +208 -0
- package/node_modules/@noble/hashes/sha3.js +475 -0
- package/node_modules/@noble/hashes/src/_blake.ts +67 -0
- package/node_modules/@noble/hashes/src/_md.ts +227 -0
- package/node_modules/@noble/hashes/src/_u64.ts +111 -0
- package/node_modules/@noble/hashes/src/argon2.ts +693 -0
- package/node_modules/@noble/hashes/src/blake1.ts +677 -0
- package/node_modules/@noble/hashes/src/blake2.ts +648 -0
- package/node_modules/@noble/hashes/src/blake3.ts +344 -0
- package/node_modules/@noble/hashes/src/eskdf.ts +265 -0
- package/node_modules/@noble/hashes/src/hkdf.ts +161 -0
- package/node_modules/@noble/hashes/src/hmac.ts +130 -0
- package/node_modules/@noble/hashes/src/index.ts +33 -0
- package/node_modules/@noble/hashes/src/legacy.ts +361 -0
- package/node_modules/@noble/hashes/src/pbkdf2.ts +219 -0
- package/node_modules/@noble/hashes/src/scrypt.ts +375 -0
- package/node_modules/@noble/hashes/src/sha2.ts +486 -0
- package/node_modules/@noble/hashes/src/sha3-addons.ts +1157 -0
- package/node_modules/@noble/hashes/src/sha3.ts +525 -0
- package/node_modules/@noble/hashes/src/utils.ts +978 -0
- package/node_modules/@noble/hashes/src/webcrypto.ts +283 -0
- package/node_modules/@noble/hashes/utils.d.ts +560 -0
- package/node_modules/@noble/hashes/utils.js +687 -0
- package/node_modules/@noble/hashes/webcrypto.d.ts +121 -0
- package/node_modules/@noble/hashes/webcrypto.js +228 -0
- package/package.json +5 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/crypto.ts","../src/verify.ts","../src/canonical.ts","../src/statements.ts","../src/verify-record.ts","../src/claim-table.ts","../src/claim-lint.ts","../src/render-estimate.ts","../src/sharecard.ts"],"names":["hexToBytes","bytesToHex","sha256","utf8ToBytes","verifyAsync","reasons","flags","statements","isObject"],"mappings":";;;;;;;AAsBO,SAAS,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AAA;AACnD,EAAA,MAAM,CAAA,GAAI,IAAA;AACV,EAAA,IAAI,EAAA,GAAK,KAAA;AACT,EAAA,IAAI;AACF,IAAA,MAAM,EAAA,GAAK,OAAO,OAAA,CAAQ,SAAA,KAAc,WAAW,UAAA,CAAW,OAAA,CAAQ,SAAS,CAAA,GAAI,OAAA,CAAQ,SAAA;AAC3F,IAAA,EAAA,GAAK,MAAMJ,mBAAAA,CAAY,gBAAA,CAAiB,CAAA,CAAE,SAAS,CAAA,EAAGD,oBAAAA,CAAY,qBAAA,CAAsB,CAAuC,CAAC,CAAA,EAAG,EAAA,EAAI,EAAE,MAAA,EAAQ,OAAO,CAAA;AAAA,EAC1J,CAAA,CAAA,MAAQ;AACN,IAAA,EAAA,GAAK,KAAA;AAAA,EACP;AACA,EAAA,IAAI,CAAC,EAAA,EAAI,OAAO,IAAA,CAAK,CAAC,gCAAgC,CAAC,CAAA;AACvD,EAAA,OAAO,EAAE,KAAA,EAAO,IAAA,EAAM,KAAA,EAAO,CAAA,CAAE,MAAM,GAAA,CAAI,CAAC,CAAA,MAAO,EAAE,GAAG,CAAA,EAAE,CAAE,CAAA,EAAG,MAAA,EAAQ,EAAC,EAAE;AAC1E","file":"index.cjs","sourcesContent":["/**\n * Cryptographic helpers for AIP certificate verification.\n *\n * Uses @noble/ed25519 for signatures and @noble/hashes for SHA-256.\n * All operations are offline — no network calls.\n */\n\nimport { verifyAsync } from \"@noble/ed25519\";\nimport { sha256 } from \"@noble/hashes/sha2.js\";\nimport {\n bytesToHex,\n hexToBytes,\n utf8ToBytes,\n} from \"@noble/hashes/utils.js\";\n\nimport type { MerkleSibling } from \"./types.js\";\n\n// ---------------------------------------------------------------------------\n// Encoding helpers\n// ---------------------------------------------------------------------------\n\n/** Decode a standard base-64 string to Uint8Array. */\nexport function base64ToUint8(b64: string): Uint8Array {\n const binary = atob(b64);\n const bytes = new Uint8Array(binary.length);\n for (let i = 0; i < binary.length; i++) {\n bytes[i] = binary.charCodeAt(i);\n }\n return bytes;\n}\n\n/** Decode a hex string to Uint8Array. */\nexport function hexToUint8(hex: string): Uint8Array {\n return hexToBytes(hex);\n}\n\n// ---------------------------------------------------------------------------\n// SHA-256\n// ---------------------------------------------------------------------------\n\n/** SHA-256 hash of a UTF-8 string, returned as lowercase hex. */\nexport function sha256Hex(input: string): string {\n return bytesToHex(sha256(utf8ToBytes(input)));\n}\n\n// ---------------------------------------------------------------------------\n// Ed25519 signature verification\n// ---------------------------------------------------------------------------\n\n/**\n * Verify an Ed25519 signature.\n *\n * @param signature - Base-64 encoded signature.\n * @param payload - The signed payload string (UTF-8).\n * @param publicKey - Ed25519 public key as Uint8Array.\n * @returns `true` if valid, `false` otherwise.\n */\nexport async function verifySignature(\n signature: string,\n payload: string,\n publicKey: Uint8Array,\n): Promise<boolean> {\n try {\n const sigBytes = base64ToUint8(signature);\n const msgBytes = utf8ToBytes(payload);\n return await verifyAsync(sigBytes, msgBytes, publicKey);\n } catch {\n return false;\n }\n}\n\n// ---------------------------------------------------------------------------\n// Merkle proof verification\n// ---------------------------------------------------------------------------\n\n/**\n * Verify a Merkle inclusion proof by walking from leaf to root.\n *\n * Each sibling specifies whether it sits on the `\"left\"` or `\"right\"` side.\n * The combined hash at each level is `SHA-256(left || right)` in hex.\n */\nexport function verifyMerkleProof(\n leafHash: string,\n siblings: MerkleSibling[],\n expectedRoot: string,\n): boolean {\n let current = leafHash;\n\n for (const sibling of siblings) {\n const pair =\n sibling.position === \"left\"\n ? sibling.hash + current\n : current + sibling.hash;\n current = sha256Hex(pair);\n }\n\n return current === expectedRoot;\n}\n\n// ---------------------------------------------------------------------------\n// Chain hash computation\n// ---------------------------------------------------------------------------\n\n/**\n * Recompute a chain hash from its constituent parts.\n *\n * Format: `SHA-256(prevChainHash|checkpointId|verdict|thinkingBlockHash|inputCommitment|timestamp)`\n *\n * When `prevChainHash` is `null` the literal string `\"genesis\"` is used.\n */\nexport function computeChainHash(\n prevChainHash: string | null,\n checkpointId: string,\n verdict: string,\n thinkingBlockHash: string,\n inputCommitment: string,\n timestamp: string,\n): string {\n const prev = prevChainHash ?? \"genesis\";\n const preimage = [\n prev,\n checkpointId,\n verdict,\n thinkingBlockHash,\n inputCommitment,\n timestamp,\n ].join(\"|\");\n\n return sha256Hex(preimage);\n}\n","/**\n * Main certificate verification logic.\n *\n * Given a trusted public key (and optionally a Merkle root), verifies\n * an AIP Integrity Certificate entirely offline.\n */\n\nimport {\n verifySignature,\n computeChainHash,\n verifyMerkleProof,\n hexToUint8,\n} from \"./crypto.js\";\n\nimport type {\n IntegrityCertificate,\n VerificationResult,\n VerifierOptions,\n CheckResult,\n} from \"./types.js\";\n\n// ---------------------------------------------------------------------------\n// Public API\n// ---------------------------------------------------------------------------\n\n/**\n * Verify an AIP Integrity Certificate offline.\n *\n * Performs four checks:\n *\n * 1. **Signature** — Ed25519 verification of the signed payload.\n * 2. **Chain** — Recomputes chain hash and compares with the certificate.\n * 3. **Merkle** — If the certificate carries a Merkle proof *and*\n * `options.merkleRoot` is supplied, verifies the inclusion proof.\n * Otherwise the check is skipped (returns `null`).\n * 4. **Verdict derivation** — If the certificate carries a verdict derivation\n * proof, verifies structural integrity (journal fields match certificate\n * claims). STARK receipt verification is deferred to server-side.\n *\n * @param certificate - The integrity certificate to verify.\n * @param options - Public key and optional Merkle root.\n * @returns Verification result with per-check details.\n */\nexport async function verifyCertificate(\n certificate: IntegrityCertificate,\n options: VerifierOptions,\n): Promise<VerificationResult> {\n const publicKey = resolvePublicKey(options.publicKey);\n\n const signature = await checkSignature(certificate, publicKey);\n const chain = checkChain(certificate);\n const merkle = checkMerkle(certificate, options.merkleRoot);\n const verdictDerivation = checkVerdictDerivation(\n certificate,\n options.verdictDerivationImageId,\n );\n\n const allValid =\n signature.valid &&\n chain.valid &&\n (merkle === null || merkle.valid) &&\n (verdictDerivation === null || verdictDerivation.valid);\n\n return {\n valid: allValid,\n checks: { signature, chain, merkle, verdict_derivation: verdictDerivation },\n certificate_id: certificate.certificate_id,\n verified_at: new Date().toISOString(),\n };\n}\n\n// ---------------------------------------------------------------------------\n// Internal helpers\n// ---------------------------------------------------------------------------\n\n/** Normalize public key to Uint8Array. */\nfunction resolvePublicKey(key: string | Uint8Array): Uint8Array {\n if (typeof key === \"string\") {\n return hexToUint8(key);\n }\n return key;\n}\n\n/** Verify the Ed25519 signature over the signed payload. */\nasync function checkSignature(\n cert: IntegrityCertificate,\n publicKey: Uint8Array,\n): Promise<CheckResult> {\n const { value, signed_payload } = cert.proofs.signature;\n\n const valid = await verifySignature(value, signed_payload, publicKey);\n\n return {\n valid,\n details: valid\n ? \"Ed25519 signature is valid\"\n : \"Ed25519 signature verification failed\",\n };\n}\n\n/** Recompute chain hash and compare. */\nfunction checkChain(cert: IntegrityCertificate): CheckResult {\n const expected = computeChainHash(\n cert.proofs.chain.prev_chain_hash,\n cert.subject.checkpoint_id,\n cert.claims.verdict,\n cert.input_commitments.thinking_block_hash,\n cert.input_commitments.combined_commitment,\n cert.issued_at,\n );\n\n const valid = expected === cert.proofs.chain.chain_hash;\n\n return {\n valid,\n details: valid\n ? \"Chain hash matches recomputed value\"\n : `Chain hash mismatch: expected ${expected}, got ${cert.proofs.chain.chain_hash}`,\n };\n}\n\n/** Verify Merkle inclusion proof, if present and root is provided. */\nfunction checkMerkle(\n cert: IntegrityCertificate,\n merkleRoot: string | undefined,\n): CheckResult | null {\n if (cert.proofs.merkle === null) {\n return null;\n }\n\n if (merkleRoot === undefined) {\n return null;\n }\n\n const { leaf_hash, inclusion_proof, root } = cert.proofs.merkle;\n\n // Verify that the certificate's stated root matches the expected root.\n if (root !== merkleRoot) {\n return {\n valid: false,\n details: `Merkle root mismatch: certificate claims ${root}, expected ${merkleRoot}`,\n };\n }\n\n const valid = verifyMerkleProof(leaf_hash, inclusion_proof, merkleRoot);\n\n return {\n valid,\n details: valid\n ? \"Merkle inclusion proof is valid\"\n : \"Merkle inclusion proof verification failed\",\n };\n}\n\n/**\n * Verify verdict derivation proof structural integrity.\n *\n * Checks that the journal fields in the proof match the certificate's claims\n * and input commitments. Does NOT verify the STARK receipt itself — that\n * requires the SP1 verifier (server-side or future WASM).\n *\n * If `expectedImageId` is provided, also verifies the proof was generated\n * by the expected guest program.\n */\nfunction checkVerdictDerivation(\n cert: IntegrityCertificate,\n expectedImageId: string | undefined,\n): CheckResult | null {\n const proof = cert.proofs.verdict_derivation;\n if (proof === null || proof === undefined) {\n return null;\n }\n\n // Validate proof method\n if (![\"SP1-STARK\", \"RISC-Zero-STARK\"].includes(proof.method)) {\n return {\n valid: false,\n details: `Unknown verdict derivation method: ${proof.method}`,\n };\n }\n\n // Validate required fields are present\n if (!proof.journal || !proof.image_id || !proof.receipt) {\n return {\n valid: false,\n details: \"Verdict derivation proof is missing required fields (journal, image_id, or receipt)\",\n };\n }\n\n // If an expected image ID is provided, verify it matches\n if (expectedImageId !== undefined && proof.image_id !== expectedImageId) {\n return {\n valid: false,\n details: `Image ID mismatch: proof has ${proof.image_id}, expected ${expectedImageId}`,\n };\n }\n\n // Parse the journal to verify structural integrity\n let journal: {\n verdict?: string;\n action?: string;\n concerns_hash?: string;\n thinking_hash?: string;\n card_hash?: string;\n values_hash?: string;\n };\n try {\n journal = JSON.parse(proof.journal);\n } catch {\n return {\n valid: false,\n details: \"Failed to parse verdict derivation journal as JSON\",\n };\n }\n\n // Verify journal verdict matches certificate claims\n if (journal.verdict !== undefined) {\n const certVerdict = cert.claims.verdict;\n if (journal.verdict !== certVerdict) {\n return {\n valid: false,\n details: `Journal verdict \"${journal.verdict}\" does not match certificate verdict \"${certVerdict}\"`,\n };\n }\n }\n\n // Verify journal thinking_hash matches input commitments\n if (journal.thinking_hash !== undefined) {\n const certThinkingHash = cert.input_commitments.thinking_block_hash;\n if (journal.thinking_hash !== certThinkingHash) {\n return {\n valid: false,\n details: `Journal thinking_hash does not match certificate input_commitments.thinking_block_hash`,\n };\n }\n }\n\n // Verify journal card_hash matches input commitments\n if (journal.card_hash !== undefined) {\n const certCardHash = cert.input_commitments.card_hash;\n if (journal.card_hash !== certCardHash) {\n return {\n valid: false,\n details: `Journal card_hash does not match certificate input_commitments.card_hash`,\n };\n }\n }\n\n // Verify journal values_hash matches input commitments\n if (journal.values_hash !== undefined) {\n const certValuesHash = cert.input_commitments.values_hash;\n if (journal.values_hash !== certValuesHash) {\n return {\n valid: false,\n details: `Journal values_hash does not match certificate input_commitments.values_hash`,\n };\n }\n }\n\n return {\n valid: true,\n details: \"Verdict derivation proof is structurally valid (STARK receipt verification deferred to server)\",\n };\n}\n","/**\n * Canonical JSON, byte-identical to mnemom-api `src/attestation/crypto.ts`\n * (`canonicalJson`): object keys sorted recursively, no whitespace, arrays\n * kept in order, primitives through `JSON.stringify`.\n *\n * Every signed record statement commits to this serialisation of the\n * statement minus its `signature` field, exactly the way\n * `AAP-TransparencyRoot/v1` does (mnemom-api `src/transparency/root_publisher.ts`).\n */\n\nexport function canonicalJson(value: unknown): string {\n if (value === null || typeof value !== \"object\") {\n return JSON.stringify(value);\n }\n if (Array.isArray(value)) {\n return `[${value.map(canonicalJson).join(\",\")}]`;\n }\n const record = value as Record<string, unknown>;\n const entries = Object.keys(record)\n .sort()\n .map((k) => `${JSON.stringify(k)}:${canonicalJson(record[k])}`);\n return `{${entries.join(\",\")}}`;\n}\n\n/** Decode base64url (padding optional) to bytes. Throws on malformed input. */\nexport function base64urlToUint8(input: string): Uint8Array {\n if (typeof input !== \"string\" || !/^[A-Za-z0-9_-]*={0,2}$/.test(input)) {\n throw new Error(\"not base64url\");\n }\n const b64 = input.replace(/-/g, \"+\").replace(/_/g, \"/\").replace(/=+$/, \"\");\n const padded = b64 + \"===\".slice(0, (4 - (b64.length % 4)) % 4);\n const binary = atob(padded);\n const out = new Uint8Array(binary.length);\n for (let i = 0; i < binary.length; i++) out[i] = binary.charCodeAt(i);\n return out;\n}\n","/**\n * Record statements: the four signed statement types the Mnemom record is\n * built from, their bundle, and the JWKS they verify against.\n *\n * Shape (design \"The record\", decisions T2, T3, T12):\n *\n * - Every statement carries `typ` (domain separation), `signing_key_id` (the\n * `kid` of an Ed25519 key in the published JWKS) and a detached `signature`:\n * base64url Ed25519 over `canonicalJson(statement minus signature)`.\n * - Statements link by digest. A statement's digest is the lowercase sha256\n * hex of that same canonical commitment. `previous_digest` points at the\n * previous build of the same record; a PR record lists the conduct records\n * it rolls up; an outcome and a share card name the statement they derive\n * from.\n * - A conduct record cites checkpoints by their signed `combined_commitment`\n * (T12). A citation with no `card_hash` is flagged \"card hash not recorded\";\n * one with no signed commitment is flagged \"card not bound\". Flags never\n * make a statement invalid: they tell the reader how strong the binding is.\n * - A share card carries only measured lines, outcome lines, and verdict\n * lines shown with their coverage. Any other class fails the card.\n */\n\n// ---------------------------------------------------------------------------\n// JWKS\n// ---------------------------------------------------------------------------\n\n/**\n * One key from the published JWKS. Only Ed25519 OKP keys with `alg: EdDSA`\n * are used: a key whose `alg` is absent or anything else is refused with\n * `key_not_ed25519`, so the field is required here as it is at runtime.\n */\nexport interface RecordJwk {\n kty: string;\n crv?: string;\n x?: string;\n kid?: string;\n alg: string;\n use?: string;\n [k: string]: unknown;\n}\n\n/** The published key set, as served at `/v1/.well-known/jwks.json`. */\nexport interface RecordJwks {\n keys: RecordJwk[];\n}\n\n// ---------------------------------------------------------------------------\n// Statements\n// ---------------------------------------------------------------------------\n\nexport const STATEMENT_TYPES = [\n \"AAP-ConductRecord/v1\",\n \"AAP-PRRecord/v1\",\n \"AAP-Outcome/v1\",\n \"AAP-ShareCard/v1\",\n] as const;\n\nexport type StatementTyp = (typeof STATEMENT_TYPES)[number];\n\nexport const BUNDLE_TYP = \"AAP-RecordBundle/v1\" as const;\n\n/** Fields every signed statement carries. */\nexport interface SignedStatementBase {\n typ: StatementTyp;\n /** `kid` of the signing key in the JWKS. */\n signing_key_id: string;\n /** base64url Ed25519 signature over `canonicalJson(statement minus signature)`. */\n signature: string;\n /** Optional, must equal `EdDSA` when present. */\n alg?: string;\n /** ISO 8601 time the statement was built. */\n built_at?: string;\n /** Digest of the previous build of this record, or null for the first build (T2). */\n previous_digest?: string | null;\n /** `kid` of the key that made `commitment_signature`, or null when the attestation failed open. */\n commitment_key_id?: string | null;\n /** Generic unit the statement is about, e.g. `pull_request`. */\n unit_kind?: string;\n [k: string]: unknown;\n}\n\n/** A checkpoint cited by a conduct record (T12). */\nexport interface CheckpointCitation {\n checkpoint_id: string;\n /** sha256 hex of the alignment card the checkpoint was judged against, or null when not recorded. */\n card_hash?: string | null;\n /** The checkpoint's signed `combined_commitment`, or null when none was signed. */\n combined_commitment?: string | null;\n /** The checkpoint certificate's signature over its own payload (own key, own payload per T3). */\n commitment_signature?: string | null;\n [k: string]: unknown;\n}\n\nexport interface ConductRecordStatement extends SignedStatementBase {\n typ: \"AAP-ConductRecord/v1\";\n /** Lineage the record is keyed on (T1), e.g. a conversation id. */\n lineage_key?: string;\n checkpoints?: CheckpointCitation[];\n}\n\nexport interface PRRecordStatement extends SignedStatementBase {\n typ: \"AAP-PRRecord/v1\";\n /** Digests of the conduct records this PR record rolls up. */\n conduct_digests?: string[];\n /** Head SHA from before the App's bundle commit. */\n head_sha?: string;\n}\n\nexport interface OutcomeStatement extends SignedStatementBase {\n typ: \"AAP-Outcome/v1\";\n /** Digest of the PR record this outcome belongs to. */\n pr_record_digest?: string;\n merge_sha?: string;\n}\n\n/** Claim classes a share card may carry. */\nexport const CARD_LINE_CLASSES = [\"measured\", \"verdict\", \"outcome\"] as const;\nexport type CardLineClass = (typeof CARD_LINE_CLASSES)[number];\n\nexport interface ShareCardLine {\n class: string;\n text: string;\n /** Required on a verdict line: \"N of M judged\". */\n coverage?: { judged: number; total: number } | null;\n [k: string]: unknown;\n}\n\nexport interface ShareCardStatement extends SignedStatementBase {\n typ: \"AAP-ShareCard/v1\";\n /** Digest of the statement the card's lines were taken from. */\n source_digest?: string;\n lines?: ShareCardLine[];\n}\n\nexport type SignedStatement =\n | ConductRecordStatement\n | PRRecordStatement\n | OutcomeStatement\n | ShareCardStatement;\n\n/** A customer-held bundle: statements in build order. */\nexport interface RecordBundle {\n typ: typeof BUNDLE_TYP;\n statements: SignedStatement[];\n [k: string]: unknown;\n}\n\n// ---------------------------------------------------------------------------\n// Results\n// ---------------------------------------------------------------------------\n\n/**\n * Named reasons a statement fails. Stable strings: tampered fixtures assert\n * on them, and every renderer prints them as they are.\n */\nexport const REASONS = {\n not_an_object: \"not_an_object\",\n unknown_typ: \"unknown_typ\",\n unsupported_alg: \"unsupported_alg\",\n signing_key_id_missing: \"signing_key_id_missing\",\n signature_missing: \"signature_missing\",\n signature_malformed: \"signature_malformed\",\n key_not_found: \"key_not_found\",\n key_not_ed25519: \"key_not_ed25519\",\n signature_invalid: \"signature_invalid\",\n bundle_not_an_object: \"bundle_not_an_object\",\n bundle_unknown_typ: \"bundle_unknown_typ\",\n bundle_statements_missing: \"bundle_statements_missing\",\n digest_malformed: \"digest_malformed\",\n linked_statement_wrong_typ: \"linked_statement_wrong_typ\",\n card_line_class_not_allowed: \"card_line_class_not_allowed\",\n card_verdict_without_coverage: \"card_verdict_without_coverage\",\n} as const;\n\nexport type Reason = (typeof REASONS)[keyof typeof REASONS];\n\n/** Named flags. A flag weakens a binding but never invalidates a statement. */\nexport const FLAGS = {\n card_hash_not_recorded: \"card hash not recorded\",\n card_not_bound: \"card not bound\",\n linked_statement_not_in_bundle: \"linked statement not in bundle\",\n} as const;\n\nexport type Flag = (typeof FLAGS)[keyof typeof FLAGS];\n\nexport interface StatementFlag {\n flag: Flag;\n /** `checkpoint_id` or the digest the flag is about. */\n subject: string;\n}\n\nexport interface StatementVerificationResult {\n valid: boolean;\n typ: string | null;\n /** sha256 hex of the canonical commitment, or null when the input is not an object. */\n digest: string | null;\n signing_key_id: string | null;\n reasons: Reason[];\n flags: StatementFlag[];\n}\n\nexport interface RecordVerificationResult {\n valid: boolean;\n /** Reasons at the bundle level, plus every statement reason prefixed by its index. */\n reasons: string[];\n flags: StatementFlag[];\n statements: StatementVerificationResult[];\n verified_at: string;\n}\n","/**\n * Offline verification of record statements and bundles.\n *\n * `verify(statement | bundle, jwks)` is the one entry point the CLI, CI,\n * the PR check and the web pages all call. It never touches the network:\n * the caller hands it the published JWKS.\n *\n * Order of checks for one statement, fail-closed, same as the SDK's\n * `JwksClient.verify` (mnemom-platform `shared/sdk/src/jwks.ts`):\n *\n * 1. shape and `typ` (domain separation, T3)\n * 2. `alg`, exact-match `EdDSA`, before any key material is touched\n * 3. `signing_key_id` and `signature` present and well formed\n * 4. key lookup by `kid`; the key must be an Ed25519 OKP key with `alg: EdDSA`\n * 5. Ed25519 over `canonicalJson(statement minus signature)`\n * 6. per-type rules (share card line classes, verdict coverage)\n * 7. flags on cited checkpoints (T12), which never change `valid`\n */\n\nimport { verifyAsync } from \"@noble/ed25519\";\nimport { sha256 } from \"@noble/hashes/sha2.js\";\nimport { bytesToHex, utf8ToBytes } from \"@noble/hashes/utils.js\";\n\nimport { canonicalJson, base64urlToUint8 } from \"./canonical.js\";\nimport {\n BUNDLE_TYP,\n CARD_LINE_CLASSES,\n FLAGS,\n REASONS,\n STATEMENT_TYPES,\n type CheckpointCitation,\n type Reason,\n type RecordBundle,\n type RecordJwk,\n type RecordJwks,\n type RecordVerificationResult,\n type ShareCardLine,\n type SignedStatement,\n type StatementFlag,\n type StatementTyp,\n type StatementVerificationResult,\n} from \"./statements.js\";\n\nconst DIGEST_RE = /^[0-9a-f]{64}$/;\n\nfunction isObject(v: unknown): v is Record<string, unknown> {\n return typeof v === \"object\" && v !== null && !Array.isArray(v);\n}\n\n/**\n * The bytes a statement's signature covers: canonical JSON of the statement\n * with `signature` removed. Exported so a signer in another language can be\n * checked against it byte for byte.\n */\nexport function statementCommitment(statement: Record<string, unknown>): string {\n const { signature: _signature, ...rest } = statement;\n return canonicalJson(rest);\n}\n\n/** Lowercase sha256 hex of a statement's commitment: how statements link (T2). */\nexport function statementDigest(statement: Record<string, unknown>): string {\n return bytesToHex(sha256(utf8ToBytes(statementCommitment(statement))));\n}\n\n/** Pick the Ed25519 key for `kid`, or say why none can be used. */\nfunction selectKey(jwks: RecordJwks, kid: string): { key?: Uint8Array; reason?: Reason } {\n const keys = isObject(jwks) && Array.isArray(jwks.keys) ? jwks.keys : [];\n const jwk = keys.find((k: RecordJwk) => isObject(k) && k.kid === kid);\n if (!jwk) return { reason: REASONS.key_not_found };\n // Exact-match allowlist on the key as well as the statement: a key that\n // is not declared `EdDSA` is never used, whatever its curve says.\n if (jwk.alg !== \"EdDSA\" || jwk.kty !== \"OKP\" || jwk.crv !== \"Ed25519\" || typeof jwk.x !== \"string\") {\n return { reason: REASONS.key_not_ed25519 };\n }\n let key: Uint8Array;\n try {\n key = base64urlToUint8(jwk.x);\n } catch {\n return { reason: REASONS.key_not_ed25519 };\n }\n if (key.length !== 32) return { reason: REASONS.key_not_ed25519 };\n return { key };\n}\n\nfunction checkpointFlags(checkpoints: unknown): StatementFlag[] {\n if (!Array.isArray(checkpoints)) return [];\n const flags: StatementFlag[] = [];\n for (const c of checkpoints as CheckpointCitation[]) {\n if (!isObject(c)) continue;\n const subject = typeof c.checkpoint_id === \"string\" ? c.checkpoint_id : \"<no checkpoint_id>\";\n if (typeof c.card_hash !== \"string\" || c.card_hash.length === 0) {\n flags.push({ flag: FLAGS.card_hash_not_recorded, subject });\n }\n const bound =\n typeof c.combined_commitment === \"string\" &&\n c.combined_commitment.length > 0 &&\n typeof c.commitment_signature === \"string\" &&\n c.commitment_signature.length > 0;\n if (!bound) flags.push({ flag: FLAGS.card_not_bound, subject });\n }\n return flags;\n}\n\nfunction shareCardReasons(lines: unknown): Reason[] {\n if (!Array.isArray(lines)) return [];\n const reasons: Reason[] = [];\n for (const line of lines as ShareCardLine[]) {\n if (!isObject(line) || !(CARD_LINE_CLASSES as readonly string[]).includes(line.class as string)) {\n reasons.push(REASONS.card_line_class_not_allowed);\n continue;\n }\n if (line.class === \"verdict\") {\n const cov = line.coverage;\n const ok =\n isObject(cov) &&\n Number.isInteger(cov.judged) &&\n Number.isInteger(cov.total) &&\n (cov.judged as number) >= 0 &&\n (cov.total as number) >= (cov.judged as number);\n if (!ok) reasons.push(REASONS.card_verdict_without_coverage);\n }\n }\n return [...new Set(reasons)];\n}\n\n/**\n * Every digest reference a statement carries, as written. An absent field\n * is skipped, and `previous_digest: null` is the first build (T2); anything\n * else that is not a 64-hex string is reported as `digest_malformed` rather\n * than dropped, so a non-string entry in `conduct_digests` cannot pass\n * unnoticed.\n */\nfunction digestFieldsOf(statement: Record<string, unknown>): unknown[] {\n const out: unknown[] = [];\n if (statement.previous_digest !== undefined && statement.previous_digest !== null) {\n out.push(statement.previous_digest);\n }\n if (statement.pr_record_digest !== undefined) out.push(statement.pr_record_digest);\n if (statement.source_digest !== undefined) out.push(statement.source_digest);\n if (statement.conduct_digests !== undefined) {\n // `conduct_digests` is a list; anything else is malformed even when it\n // happens to look like one digest.\n if (Array.isArray(statement.conduct_digests)) out.push(...statement.conduct_digests);\n else out.push(null);\n }\n return out;\n}\n\n/**\n * Verify one signed statement against the published JWKS.\n * Never throws and never calls the network.\n */\nexport async function verifyStatement(\n statement: unknown,\n jwks: RecordJwks,\n): Promise<StatementVerificationResult> {\n const fail = (\n reasons: Reason[],\n partial: Partial<StatementVerificationResult> = {},\n ): StatementVerificationResult => ({\n valid: false,\n typ: null,\n digest: null,\n signing_key_id: null,\n flags: [],\n ...partial,\n reasons,\n });\n\n if (!isObject(statement)) return fail([REASONS.not_an_object]);\n const typ = typeof statement.typ === \"string\" ? statement.typ : null;\n const digest = statementDigest(statement);\n const kid = typeof statement.signing_key_id === \"string\" ? statement.signing_key_id : null;\n const base = { typ, digest, signing_key_id: kid };\n\n if (!typ || !(STATEMENT_TYPES as readonly string[]).includes(typ)) {\n return fail([REASONS.unknown_typ], base);\n }\n // Algorithm-confusion guard: before any key lookup.\n if (statement.alg !== undefined && statement.alg !== \"EdDSA\") {\n return fail([REASONS.unsupported_alg], base);\n }\n if (!kid) return fail([REASONS.signing_key_id_missing], base);\n if (typeof statement.signature !== \"string\" || statement.signature.length === 0) {\n return fail([REASONS.signature_missing], base);\n }\n let sig: Uint8Array;\n try {\n sig = base64urlToUint8(statement.signature);\n } catch {\n return fail([REASONS.signature_malformed], base);\n }\n if (sig.length !== 64) return fail([REASONS.signature_malformed], base);\n\n const selected = selectKey(jwks, kid);\n if (!selected.key) return fail([selected.reason as Reason], base);\n\n let sigOk = false;\n try {\n sigOk = await verifyAsync(sig, utf8ToBytes(statementCommitment(statement)), selected.key);\n } catch {\n sigOk = false;\n }\n if (!sigOk) return fail([REASONS.signature_invalid], base);\n\n const reasons: Reason[] = [];\n for (const d of digestFieldsOf(statement)) {\n if (typeof d !== \"string\" || !DIGEST_RE.test(d)) {\n reasons.push(REASONS.digest_malformed);\n break;\n }\n }\n if (typ === \"AAP-ShareCard/v1\") reasons.push(...shareCardReasons(statement.lines));\n\n const flags = typ === \"AAP-ConductRecord/v1\" ? checkpointFlags(statement.checkpoints) : [];\n\n return {\n valid: reasons.length === 0,\n typ,\n digest,\n signing_key_id: kid,\n reasons,\n flags,\n };\n}\n\n/** Which statement types a link field may point at. */\nconst LINK_TARGETS: Record<string, readonly StatementTyp[] | \"same\"> = {\n previous_digest: \"same\",\n conduct_digests: [\"AAP-ConductRecord/v1\"],\n pr_record_digest: [\"AAP-PRRecord/v1\"],\n source_digest: [\"AAP-ConductRecord/v1\", \"AAP-PRRecord/v1\", \"AAP-Outcome/v1\"],\n};\n\n/**\n * Verify a statement or a whole bundle against the published JWKS.\n *\n * For a bundle every statement is verified on its own, then the links\n * between them are checked: a digest that names a statement in the bundle\n * must name one of the right type. A digest that names nothing in the\n * bundle is flagged, not failed, because a long session's earlier\n * statements may live outside the bundle (design, open questions).\n */\nexport async function verify(\n input: SignedStatement | RecordBundle | unknown,\n jwks: RecordJwks,\n): Promise<RecordVerificationResult> {\n const verified_at = new Date().toISOString();\n const result = (\n valid: boolean,\n reasons: string[],\n flags: StatementFlag[],\n statements: StatementVerificationResult[],\n ): RecordVerificationResult => ({ valid, reasons, flags, statements, verified_at });\n\n if (!isObject(input)) return result(false, [REASONS.bundle_not_an_object], [], []);\n\n // Something shaped like a bundle (it carries `statements`) under a typ\n // that is neither the bundle typ nor a statement typ: say so, instead of\n // reporting it as one unknown statement.\n if (\n input.typ !== BUNDLE_TYP &&\n Array.isArray(input.statements) &&\n !(STATEMENT_TYPES as readonly string[]).includes(input.typ as string)\n ) {\n return result(false, [REASONS.bundle_unknown_typ], [], []);\n }\n\n // A bare statement.\n if (input.typ !== BUNDLE_TYP) {\n const one = await verifyStatement(input, jwks);\n return result(one.valid, one.reasons.map((r) => `0:${r}`), one.flags, [one]);\n }\n\n const rawStatements: unknown[] | null = Array.isArray(input.statements) ? input.statements : null;\n if (!rawStatements) {\n return result(false, [REASONS.bundle_statements_missing], [], []);\n }\n\n const statements: StatementVerificationResult[] = [];\n for (const s of rawStatements) statements.push(await verifyStatement(s, jwks));\n\n const byDigest = new Map<string, StatementVerificationResult>();\n statements.forEach((s) => {\n if (s.digest) byDigest.set(s.digest, s);\n });\n\n const reasons: string[] = [];\n const flags: StatementFlag[] = [];\n statements.forEach((s, i) => {\n s.reasons.forEach((r) => reasons.push(`${i}:${r}`));\n flags.push(...s.flags);\n const raw = rawStatements[i];\n if (!s.valid || !isObject(raw)) return;\n for (const [field, targets] of Object.entries(LINK_TARGETS)) {\n const value = raw[field];\n const digests = Array.isArray(value) ? value : [value];\n for (const d of digests) {\n if (typeof d !== \"string\") continue;\n const linked = byDigest.get(d);\n if (!linked) {\n flags.push({ flag: FLAGS.linked_statement_not_in_bundle, subject: d });\n continue;\n }\n const allowed = targets === \"same\" ? [s.typ as StatementTyp] : targets;\n if (!linked.typ || !allowed.includes(linked.typ as StatementTyp)) {\n reasons.push(`${i}:${REASONS.linked_statement_wrong_typ}`);\n }\n }\n }\n });\n\n return result(reasons.length === 0, reasons, flags, statements);\n}\n","/**\n * The claim table (design decision T5): one table mapping record fields to\n * the claim class they may be rendered as and, for goal and protection lines,\n * the verb each mode produces. Every renderer and the verifier read this\n * table; copy is never written per renderer.\n *\n * Rules the table encodes (design \"Claim classes and verbs\", \"Cost\",\n * \"Share cards\"):\n * - A line is exactly one class. \"Safe\", \"correct\" and \"prevented\" never appear.\n * - No protection or goal line carries a dollar figure.\n * - An implicit goal line never says \"sealed\"; goals off read \"not checked\".\n * - The verb comes from the area's mode at the time of the act and, for a\n * protection act, its verdict. \"Stopped\" shows the tool name and never its\n * arguments; on a card, no tool name at all.\n * - Cards carry measured, outcome and covered verdict lines only. Estimates\n * and savings never appear on a card or a PR comment (T8).\n * - No benchmark line ships until the head-to-head is published with its\n * losing arms; no savings percentage appears anywhere until then.\n */\n\nexport const CLAIM_CLASSES = [\"measured\", \"verdict\", \"estimate\", \"benchmark\", \"outcome\"] as const;\nexport type ClaimClass = (typeof CLAIM_CLASSES)[number];\n\n/**\n * Where a rendering is shown. Cards are the share card and the period card.\n * `share_card` is the `AAP-ShareCard/v1` record statement's lines\n * (`RecordShareCardLine`, statements.ts: `{class, text, coverage}`), the shape\n * `verify` checks; not the MNE-9022 numeric card (sharecard.ts `ShareCardLine`).\n */\nexport const SURFACES = [\"record_page\", \"check_summary\", \"pr_comment\", \"share_card\", \"period_card\"] as const;\nexport type Surface = (typeof SURFACES)[number];\n\nexport const CARD_SURFACES: readonly Surface[] = [\"share_card\", \"period_card\"];\n\n/** Surfaces that never show the savings estimate, even once it qualifies (T8). */\nexport const ESTIMATE_FORBIDDEN_SURFACES: readonly Surface[] = [\"pr_comment\", \"share_card\", \"period_card\"];\n\n/** Protection and goal area modes, as stored at the act. */\nexport const MODES = [\"off\", \"observe\", \"nudge\", \"enforce\"] as const;\nexport type Mode = (typeof MODES)[number];\n\n/**\n * The verb each mode produces at its strongest verdict. `off` produces no line, or\n * \"not checked\". A protection act's verb also depends on its verdict: see\n * `protectionVerb`.\n */\nexport const MODE_VERBS: Record<Mode, string> = {\n off: \"not checked\",\n observe: \"flagged\",\n nudge: \"flagged, agent nudged\",\n enforce: \"stopped\",\n};\n\n/** A protection act's verdict, as stored at the act (mnemom-api `ProtectionVerdict`). */\nexport const PROTECTION_VERDICTS = [\"pass\", \"warn\", \"nudge\", \"quarantine\", \"block\"] as const;\nexport type ProtectionVerdict = (typeof PROTECTION_VERDICTS)[number];\n\n/**\n * The verb one protection act produces, from the mode and verdict stored at the act; null\n * means the act has no line (mode off, or a pass). Mirrors mnemom-api\n * `src/record/claims.ts` `protectionVerb`: under enforce only a block or quarantine\n * \"stopped\" anything and anything else is \"flagged\"; under nudge only a nudge verdict\n * reads \"flagged, agent nudged\".\n */\nexport function protectionVerb(mode: Mode, verdict: ProtectionVerdict): string | null {\n if (mode === \"off\" || verdict === \"pass\") return null;\n if (mode === \"observe\") return MODE_VERBS.observe;\n if (mode === \"nudge\") return verdict === \"nudge\" ? MODE_VERBS.nudge : MODE_VERBS.observe;\n return verdict === \"block\" || verdict === \"quarantine\" ? MODE_VERBS.enforce : MODE_VERBS.observe;\n}\n\n/** How the goal was set. An implicit goal is never read as sealed (T16). */\nexport const GOAL_MODES = [\"sealed\", \"implicit\", \"off\"] as const;\nexport type GoalMode = (typeof GOAL_MODES)[number];\n\nexport interface ClaimTableEntry {\n class: ClaimClass;\n /** True for the goal and protection areas: the verb comes from the mode. */\n verb_by_mode: boolean;\n /** True when the line may carry a money figure (model cost and μ only). */\n money_allowed: boolean;\n /** Surfaces this field may appear on; absent means every surface. */\n surfaces?: readonly Surface[];\n}\n\nexport const CLAIM_TABLE = {\n commits_recorded: { class: \"measured\", verb_by_mode: false, money_allowed: false },\n messages_from_person: { class: \"measured\", verb_by_mode: false, money_allowed: false },\n compactions: { class: \"measured\", verb_by_mode: false, money_allowed: false },\n tokens_sent_vs_reaching: { class: \"measured\", verb_by_mode: false, money_allowed: false },\n peak_context: { class: \"measured\", verb_by_mode: false, money_allowed: false },\n model_cost: { class: \"measured\", verb_by_mode: false, money_allowed: true },\n mu_cost: { class: \"measured\", verb_by_mode: false, money_allowed: true },\n approval: { class: \"measured\", verb_by_mode: false, money_allowed: false },\n /** How the goal was set: \"sealed contract\", \"implicit goal\" or \"not checked\" (M7: its own measured line). */\n goal_mode: { class: \"measured\", verb_by_mode: false, money_allowed: false },\n goal: { class: \"verdict\", verb_by_mode: true, money_allowed: false },\n /** The protection area's mode when no act is shown: \"not checked\" under off. */\n protection_mode: { class: \"measured\", verb_by_mode: false, money_allowed: false },\n protection: { class: \"verdict\", verb_by_mode: true, money_allowed: false },\n autonomy: { class: \"measured\", verb_by_mode: false, money_allowed: false },\n savings_estimate: {\n class: \"estimate\",\n verb_by_mode: false,\n money_allowed: true,\n surfaces: [\"record_page\", \"check_summary\"],\n },\n benchmark: { class: \"benchmark\", verb_by_mode: false, money_allowed: false },\n outcome: { class: \"outcome\", verb_by_mode: false, money_allowed: false },\n} as const satisfies Record<string, ClaimTableEntry>;\n\nexport type ClaimField = keyof typeof CLAIM_TABLE;\n\nexport function isClaimField(field: unknown): field is ClaimField {\n return typeof field === \"string\" && Object.prototype.hasOwnProperty.call(CLAIM_TABLE, field);\n}\n\n/**\n * Line keys the builder (mnemom-api `src/record/claims.ts`) writes on a\n * statement's `lines[]`, mapped to the claim-table field each one renders\n * (cross-lane pick M6). `protection.act.<n>` maps to `protection` for any n.\n */\nexport const LINE_KEY_FIELDS: Readonly<Record<string, ClaimField>> = {\n \"cost.model\": \"model_cost\",\n \"cost.mu\": \"mu_cost\",\n \"goal.mode\": \"goal_mode\",\n \"goal.verdict\": \"goal\",\n \"protection.mode\": \"protection_mode\",\n \"people.messages\": \"messages_from_person\",\n \"context.compactions\": \"compactions\",\n};\n\nconst PROTECTION_ACT_KEY = /^protection\\.act\\.\\d+$/;\n\n/** The claim-table field a statement line key renders, or undefined for a key the table does not know. */\nexport function fieldForLineKey(key: unknown): ClaimField | undefined {\n if (typeof key !== \"string\") return undefined;\n if (PROTECTION_ACT_KEY.test(key)) return \"protection\";\n return Object.prototype.hasOwnProperty.call(LINE_KEY_FIELDS, key) ? LINE_KEY_FIELDS[key] : undefined;\n}\n","/**\n * claim-lint: the mechanical check every rendering passes (criterion K1.17).\n *\n * A rendering is a surface plus the lines shown on it. Each line names its\n * class, its text, and when it comes from a mode-bearing area, the mode stored\n * at the act. The lint returns every violation with a stable rule name; it\n * never rewrites a line.\n *\n * Line shape (cross-lane pick M6): a signed statement carries\n * `{class, key, text}` per line, with the builder's keys (`cost.model`,\n * `goal.verdict`, `protection.act.0`, ...). The renderer attaches `mode`,\n * `verdict`, `goal_mode`, `tool_name` and `coverage` from the statement's\n * `goal` and `protection` blocks before linting. The lint resolves `field`\n * from `key` when `field` is absent, and off a card reads a verdict line's\n * coverage from the \"<n> of <m> turns judged\" words when no `coverage` object\n * is attached.\n *\n * On `share_card` the lines are the record share card statement's lines\n * (`RecordShareCardLine`, statements.ts `{class, text, coverage}`), the ones\n * `verify` checks in `shareCardReasons`. The MNE-9022 card (sharecard.ts,\n * `{id, kind, label, value, statement_hash}`) carries no `class` and is not a\n * `Rendering`; linting its lines as-is reports `one_class_per_line` on each.\n *\n * Rules, each from the claim table (T5) and the design's claim rules:\n * one_class_per_line class is one of the five, and matches the field's class\n * forbidden_word \"safe\", \"correct\", \"prevented\" never appear\n * money_on_goal_or_protection no dollar figure on a goal or protection line\n * implicit_goal_sealed an implicit goal line never says \"sealed\"\n * goal_off_not_checked with goals off the goal line reads \"not checked\"\n * estimate_on_forbidden_surface no estimate or savings on a card or PR comment\n * verb_mismatch the verb is the one the mode and the act's verdict produce, exactly\n * (mnemom-api `protectionVerb`); a tool name follows \"stopped\" only\n * enforce_without_tool_name \"stopped\" names the tool off-card\n * tool_name_on_card a card never shows a tool name\n * tool_arguments_shown tool arguments never appear\n * trust_claim no minutes-to-trust, review-time or re-checking claim\n * savings_percentage no savings percentage anywhere until the board exists\n * benchmark_not_published no benchmark line ships yet\n * verdict_without_coverage off a card, a goal verdict always shows its coverage (\"N of M turns\n * judged\") and a protection act, one recorded decision, carries none;\n * on a card every verdict line carries a `coverage` object, as\n * `verify` requires (`card_verdict_without_coverage`)\n * card_class_not_allowed a card carries measured, outcome and verdict lines only\n * period_card_without_revert a period card renders its reverts\n * field_not_on_surface the field is not shown on this surface\n * provisional_mu_on_card a provisional μ amount (\"≈ N μ (pending)\", A-S-001) never appears on a card:\n * cards keep K1.17 and read \"μ pending\" at most\n * provisional_mu_off_cost_line a provisional μ amount appears on the μ cost line and nowhere else\n */\n\nimport {\n CARD_SURFACES,\n CLAIM_CLASSES,\n CLAIM_TABLE,\n ESTIMATE_FORBIDDEN_SURFACES,\n MODES,\n MODE_VERBS,\n PROTECTION_VERDICTS,\n SURFACES,\n fieldForLineKey,\n isClaimField,\n protectionVerb,\n type ClaimClass,\n type ClaimTableEntry,\n type GoalMode,\n type Mode,\n type ProtectionVerdict,\n type Surface,\n} from \"./claim-table.js\";\n\nexport interface RenderedLine {\n /** Record field the line renders; when present its class must match the claim table. */\n field?: string;\n /** Builder line key (`cost.model`, `goal.verdict`, `protection.act.0`, ...); resolves `field` when that is absent. */\n key?: string;\n class: string;\n text: string;\n /** Mode stored at the act, for goal and protection lines. */\n mode?: Mode;\n /** Verdict stored at a protection act; required with nudge and enforce, whose verb depends on it. */\n verdict?: ProtectionVerdict;\n /** How the goal was set, for goal lines. */\n goal_mode?: GoalMode;\n /** Tool the act concerned; shown only after \"stopped\", and never on a card. */\n tool_name?: string;\n /** Never rendered; present here only so the lint can prove it is absent from the text. */\n tool_arguments?: unknown;\n /** \"N of M judged\". Required on every verdict line on a card; off a card a goal verdict may say it in words instead. */\n coverage?: { judged: number; total: number } | null;\n [k: string]: unknown;\n}\n\nexport interface Rendering {\n surface: Surface;\n lines: RenderedLine[];\n [k: string]: unknown;\n}\n\nexport const LINT_RULES = {\n one_class_per_line: \"one_class_per_line\",\n forbidden_word: \"forbidden_word\",\n money_on_goal_or_protection: \"money_on_goal_or_protection\",\n implicit_goal_sealed: \"implicit_goal_sealed\",\n goal_off_not_checked: \"goal_off_not_checked\",\n estimate_on_forbidden_surface: \"estimate_on_forbidden_surface\",\n verb_mismatch: \"verb_mismatch\",\n enforce_without_tool_name: \"enforce_without_tool_name\",\n tool_name_on_card: \"tool_name_on_card\",\n tool_arguments_shown: \"tool_arguments_shown\",\n trust_claim: \"trust_claim\",\n savings_percentage: \"savings_percentage\",\n benchmark_not_published: \"benchmark_not_published\",\n verdict_without_coverage: \"verdict_without_coverage\",\n card_class_not_allowed: \"card_class_not_allowed\",\n period_card_without_revert: \"period_card_without_revert\",\n field_not_on_surface: \"field_not_on_surface\",\n provisional_mu_on_card: \"provisional_mu_on_card\",\n provisional_mu_off_cost_line: \"provisional_mu_off_cost_line\",\n unknown_surface: \"unknown_surface\",\n} as const;\n\nexport type LintRule = (typeof LINT_RULES)[keyof typeof LINT_RULES];\n\nexport interface LintViolation {\n rule: LintRule;\n /** Index of the line in the rendering, or -1 for a rendering-level violation. */\n line: number;\n text: string;\n}\n\nexport interface LintResult {\n ok: boolean;\n violations: LintViolation[];\n}\n\n/**\n * A rule about two things in one clause (\"38% … cheaper\", \"50 mmu … pending\"), read in a\n * single left-to-right pass so the cost stays linear in the line's length; a regex bridge\n * such as `\\d+%[^.\\n]*\\bword\\b` re-scans the clause from every start (CodeQL\n * js/polynomial-redos). `tokens` is global; its named groups are the tokens, `brk` (a\n * full stop or newline outside a number) ends the clause. A number is one token: its digit\n * run always matches and its tail (\"%\", \"mmu\") is an optional named group, so no match can\n * fail after reading digits and no number is re-read from inside its run.\n */\ninterface ClauseRule {\n tokens: RegExp;\n /** [first, then]: the rule holds when `then` follows `first` in one clause. */\n pairs: ReadonlyArray<readonly [string, string]>;\n /** Tokens that make the rule hold on their own. */\n alone?: readonly string[];\n}\n\nfunction clauseHas(text: string, rule: ClauseRule): boolean {\n const seen = new Set<string>();\n for (const m of text.matchAll(rule.tokens)) {\n const kind = Object.entries(m.groups ?? {}).find(([, v]) => v !== undefined)?.[0];\n if (kind === undefined) continue;\n if (kind === \"brk\") {\n seen.clear();\n continue;\n }\n if (rule.alone?.includes(kind)) return true;\n if (rule.pairs.some(([first, then]) => then === kind && seen.has(first))) return true;\n seen.add(kind);\n }\n return false;\n}\n\nconst FORBIDDEN_WORD = /\\b(safe|safely|unsafe|correct|correctly|incorrect|prevent|prevents|prevented|preventing|prevention)\\b/i;\n/**\n * A currency figure. A spelled-out amount is read from the first digit of its run only\n * (`(?<!\\d,+)`), so a long \"9,9,9,…\" is scanned once rather than from every digit.\n */\nconst MONEY = /(?:\\$|€|£|¥)\\s?\\d|\\b(?<!\\d,+)\\d[\\d,]*(?:\\.\\d+)?\\s?(?:USD|EUR|GBP|dollars?|cents?)\\b/i;\nconst SEALED = /\\bsealed\\b/i;\nconst ESTIMATE_WORDS = /\\b(estimate[ds]?|estimation|saving|savings|saved|would have cost|counterfactual)\\b/i;\nconst TRUST_CLAIM =\n /\\b(minutes?|seconds?|hours?)\\s+to\\s+trust\\b|\\btrust(ed)?\\s+in\\s+(under\\s+|about\\s+)?\\d+\\s*(minutes?|seconds?|hours?|min|s|h)\\b|\\breview[- ]time\\b|\\btime\\s+to\\s+review\\b|\\bwithout\\s+re-?check(ing)?\\b|\\bno\\s+need\\s+to\\s+(re-?check|review)\\b|\\btrust(ed)?\\s+without\\b/i;\n/** A savings percentage: a percent and a saving word in one clause, either order (\"less\" only after). */\nconst SAVINGS_PERCENTAGE: ClauseRule = {\n tokens:\n /\\d+(?<percent>(?:\\.\\d+)?\\s?%)?|\\b(?<less>less)\\b|\\b(?<saving>sav(?:e[sd]?|ings?)|cheaper|reduction|reduced)\\b|(?<brk>[.\\n])/gi,\n pairs: [\n [\"percent\", \"saving\"],\n [\"percent\", \"less\"],\n [\"saving\", \"percent\"],\n ],\n};\nconst REVERT = /\\brevert(s|ed)?\\b/i;\n/**\n * A provisional μ amount (A-S-001): an approximate figure with a pending marker,\n * \"≈ 50000 mmu (pending)\" or \"≈ 50 μ (pending)\". A bare \"μ pending\" (K1.4) carries no\n * amount and is not provisional. Either half alone is enough to count: a \"≈\" before a\n * figure, or a figure with \"pending\" beside it, so a renderer cannot shed one marker to\n * slip the amount onto a card.\n */\nconst PROVISIONAL_MU: ClauseRule = {\n tokens:\n /(?<approx>(?:≈|~|\\bapprox(?:\\.|imately)?\\b|\\babout\\b)\\s*\\d[\\d,]*(?:\\.\\d+)?\\s*(?:mmu\\b|mu\\b|μ|µ))|\\d[\\d,]*(?<amount>(?:\\.\\d+)?\\s*(?:mmu\\b|mu\\b|μ|µ))?|\\b(?<pending>pending)\\b|(?<brk>[.\\n])/gi,\n alone: [\"approx\"],\n pairs: [\n [\"amount\", \"pending\"],\n [\"pending\", \"amount\"],\n ],\n};\nconst NOT_CHECKED = /^not checked$/i;\n/** Coverage written into a verdict line's words by the builder: \"4 of 12 turns judged\". */\nconst COVERAGE_IN_TEXT = /\\b(\\d+)\\s+of\\s+(\\d+)\\s+turns\\s+judged\\b/i;\n\n/** Each verb's words, keyed by the mode whose `MODE_VERBS` entry it is. */\nconst MODE_VERB_REGEX: Record<Mode, RegExp> = {\n off: NOT_CHECKED,\n observe: /\\bflagged\\b/i,\n nudge: /\\bflagged, agent nudged\\b/i,\n enforce: /\\bstopped\\b/i,\n};\n\n/** Verbs that must not appear beside a verb: another verb read as this one. */\nconst OTHER_MODE_VERBS: Record<Mode, RegExp[]> = {\n off: [/\\bflagged\\b/i, /\\bnudged\\b/i, /\\bstopped\\b/i],\n observe: [/\\bnudged\\b/i, /\\bstopped\\b/i],\n nudge: [/\\bstopped\\b/i],\n enforce: [/\\bflagged\\b/i, /\\bnudged\\b/i],\n};\n\nfunction isObject(v: unknown): v is Record<string, unknown> {\n return typeof v === \"object\" && v !== null && !Array.isArray(v);\n}\n\n/** A `coverage` object as `verify` accepts it on a share card line (verify-record.ts `shareCardReasons`). */\nfunction coverageObjectValid(cov: unknown): boolean {\n return (\n isObject(cov) &&\n Number.isInteger(cov.judged) &&\n Number.isInteger(cov.total) &&\n (cov.judged as number) >= 0 &&\n (cov.total as number) >= (cov.judged as number)\n );\n}\n\n/** Coverage from the attached object, or, when none is attached, from the builder's words. */\nfunction coverageShown(line: RenderedLine): boolean {\n const cov = line.coverage;\n if (cov !== undefined) return coverageObjectValid(cov);\n const m = COVERAGE_IN_TEXT.exec(line.text);\n return m !== null && Number(m[2]) >= Number(m[1]);\n}\n\n/**\n * The verb a mode-bearing line must show, as the `MODE_VERBS` key it reads as, or undefined\n * when the line should not exist or its verb cannot be known: a pass verdict, an unknown\n * verdict, or nudge or enforce with no verdict attached (each has two verbs).\n */\nfunction expectedVerb(mode: Mode, verdict: unknown): Mode | undefined {\n if (mode === \"off\") return \"off\";\n if (verdict === undefined) return mode === \"observe\" ? \"observe\" : undefined;\n if (!(PROTECTION_VERDICTS as readonly unknown[]).includes(verdict)) return undefined;\n const verb = protectionVerb(mode, verdict as ProtectionVerdict);\n return MODES.find((m) => MODE_VERBS[m] === verb);\n}\n\nfunction escapeRegExp(s: string): string {\n return s.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n}\n\nfunction argumentsAppear(text: string, args: unknown): boolean {\n if (args === undefined || args === null) return false;\n const needles: string[] = [];\n const walk = (v: unknown): void => {\n if (typeof v === \"string\") {\n if (v.length >= 3) needles.push(v);\n } else if (typeof v === \"number\" || typeof v === \"boolean\") {\n needles.push(String(v));\n } else if (Array.isArray(v)) {\n v.forEach(walk);\n } else if (isObject(v)) {\n Object.values(v).forEach(walk);\n }\n };\n walk(args);\n if (needles.length === 0) return false;\n try {\n needles.push(JSON.stringify(args));\n } catch {\n /* unserialisable arguments: the walked values are enough */\n }\n return needles.some((n) => n.length > 0 && text.includes(n));\n}\n\nfunction lintLine(surface: Surface, line: RenderedLine, index: number, out: LintViolation[]): void {\n const push = (rule: LintRule): void => {\n out.push({ rule, line: index, text: isObject(line) && typeof line.text === \"string\" ? line.text : \"\" });\n };\n if (!isObject(line) || typeof line.text !== \"string\" || typeof line.class !== \"string\") {\n push(LINT_RULES.one_class_per_line);\n return;\n }\n const text = line.text;\n const onCard = CARD_SURFACES.includes(surface);\n // The field named on the line wins; a builder key resolves it otherwise (M6).\n const field = line.field !== undefined ? line.field : fieldForLineKey(line.key);\n\n // one class per line: a known class, and the field's class when the field is named.\n const cls = line.class as ClaimClass;\n if (!(CLAIM_CLASSES as readonly string[]).includes(cls)) {\n push(LINT_RULES.one_class_per_line);\n } else if (field !== undefined) {\n if (!isClaimField(field)) {\n push(LINT_RULES.one_class_per_line);\n } else {\n const entry: ClaimTableEntry = CLAIM_TABLE[field];\n if (entry.class !== cls) push(LINT_RULES.one_class_per_line);\n if (entry.surfaces && !(entry.surfaces as readonly Surface[]).includes(surface)) {\n push(LINT_RULES.field_not_on_surface);\n }\n }\n }\n // A line of one class never borrows another class's words.\n if (cls !== \"estimate\" && ESTIMATE_WORDS.test(text)) push(LINT_RULES.one_class_per_line);\n\n if (FORBIDDEN_WORD.test(text)) push(LINT_RULES.forbidden_word);\n\n const isGoal = field === \"goal\" || field === \"goal_mode\";\n const isProtection = field === \"protection\" || field === \"protection_mode\";\n if ((isGoal || isProtection) && MONEY.test(text)) push(LINT_RULES.money_on_goal_or_protection);\n if (field !== undefined && isClaimField(field) && !CLAIM_TABLE[field].money_allowed) {\n if (!isGoal && !isProtection && MONEY.test(text)) push(LINT_RULES.one_class_per_line);\n }\n\n if (isGoal) {\n if (line.goal_mode === \"implicit\" && SEALED.test(text)) push(LINT_RULES.implicit_goal_sealed);\n if (line.goal_mode === \"off\" && !NOT_CHECKED.test(text.trim())) push(LINT_RULES.goal_off_not_checked);\n }\n\n if (cls === \"estimate\" || ESTIMATE_WORDS.test(text)) {\n if (ESTIMATE_FORBIDDEN_SURFACES.includes(surface)) push(LINT_RULES.estimate_on_forbidden_surface);\n }\n\n if (line.mode !== undefined) {\n const verb = (MODES as readonly string[]).includes(line.mode) ? expectedVerb(line.mode, line.verdict) : undefined;\n const name = typeof line.tool_name === \"string\" ? line.tool_name.trim() : \"\";\n const nameShown = name.length > 0 && new RegExp(`(^|[^A-Za-z0-9_])${escapeRegExp(name)}([^A-Za-z0-9_]|$)`).test(text);\n if (verb === undefined) {\n push(LINT_RULES.verb_mismatch);\n } else if (!MODE_VERB_REGEX[verb].test(verb === \"off\" ? text.trim() : text)) {\n push(LINT_RULES.verb_mismatch);\n } else if (OTHER_MODE_VERBS[verb].some((re) => re.test(text))) {\n push(LINT_RULES.verb_mismatch);\n } else if (verb !== \"enforce\" && nameShown && !onCard) {\n // The builder names the tool after \"stopped\" only (mnemom-api `protectionActLine`).\n push(LINT_RULES.verb_mismatch);\n }\n if (onCard) {\n if (nameShown) push(LINT_RULES.tool_name_on_card);\n } else if (verb === \"enforce\" && !nameShown) {\n push(LINT_RULES.enforce_without_tool_name);\n }\n }\n if (argumentsAppear(text, line.tool_arguments)) push(LINT_RULES.tool_arguments_shown);\n\n // A-S-001: a provisional μ amount lives on the μ cost line and never on a card (K1.17).\n if (clauseHas(text, PROVISIONAL_MU)) {\n if (onCard) push(LINT_RULES.provisional_mu_on_card);\n if (field !== \"mu_cost\") push(LINT_RULES.provisional_mu_off_cost_line);\n }\n\n if (TRUST_CLAIM.test(text)) push(LINT_RULES.trust_claim);\n if (clauseHas(text, SAVINGS_PERCENTAGE)) push(LINT_RULES.savings_percentage);\n if (cls === \"benchmark\") push(LINT_RULES.benchmark_not_published);\n if (cls === \"verdict\") {\n // A card carries the coverage object on every verdict line, the rule `verify` enforces on a\n // signed share card; off a card a protection act has none and a goal verdict may say it in words.\n const covered = onCard ? coverageObjectValid(line.coverage) : field === \"protection\" || coverageShown(line);\n if (!covered) push(LINT_RULES.verdict_without_coverage);\n }\n if (onCard && cls !== \"measured\" && cls !== \"verdict\" && cls !== \"outcome\") push(LINT_RULES.card_class_not_allowed);\n}\n\n/** Lint one rendering. Never throws; a malformed rendering is a violation. */\nexport function lintRendering(rendering: unknown): LintResult {\n const violations: LintViolation[] = [];\n if (!isObject(rendering) || !Array.isArray(rendering.lines)) {\n return { ok: false, violations: [{ rule: LINT_RULES.unknown_surface, line: -1, text: \"\" }] };\n }\n const surface = rendering.surface;\n if (!(SURFACES as readonly unknown[]).includes(surface)) {\n return { ok: false, violations: [{ rule: LINT_RULES.unknown_surface, line: -1, text: String(surface) }] };\n }\n const lines = rendering.lines as RenderedLine[];\n lines.forEach((line, i) => lintLine(surface as Surface, line, i, violations));\n\n if (surface === \"period_card\") {\n const hasRevert = lines.some(\n (l) => isObject(l) && l.class === \"outcome\" && typeof l.text === \"string\" && REVERT.test(l.text),\n );\n if (!hasRevert) violations.push({ rule: LINT_RULES.period_card_without_revert, line: -1, text: \"\" });\n }\n\n return { ok: violations.length === 0, violations };\n}\n\n/** Lint several renderings and keep each result keyed by its position. */\nexport function lintRenderings(renderings: unknown[]): LintResult[] {\n return renderings.map(lintRendering);\n}\n\n/** The `goal` block a conduct record statement carries (mnemom-api `src/record/builder.ts`). */\nexport interface StatementGoalBlock {\n mode: GoalMode;\n [k: string]: unknown;\n}\n\n/** One entry of a conduct record statement's `protection.acts[]`. */\nexport interface StatementProtectionAct {\n mode: Mode;\n verdict: ProtectionVerdict;\n tool_name: string | null;\n [k: string]: unknown;\n}\n\n/** A statement line as the builder signs it: one class, a stable key, the words shown. */\nexport interface StatementLine {\n class: string;\n key: string;\n text: string;\n}\n\n/**\n * Attach the lint context a signed statement's lines leave out (cross-lane\n * pick M6). The statement carries `{class, key, text}` only; this returns the\n * same lines with `goal_mode` on `goal.*` lines, and `mode`, `verdict` and\n * `tool_name` on `protection.act.*` lines, read from the statement's `goal`\n * and `protection.acts` blocks (`protection.act.<i>` is `acts[i]`). Coverage\n * stays in the verdict line's words; a card renderer attaches the `coverage`\n * object itself. The text is never changed.\n */\nexport function attachLineContext(\n lines: readonly StatementLine[],\n goal: StatementGoalBlock | null | undefined,\n protection: { acts: readonly StatementProtectionAct[] } | null | undefined,\n): RenderedLine[] {\n return lines.map((line) => {\n const out: RenderedLine = { class: line.class, key: line.key, text: line.text };\n if (line.key.startsWith(\"goal.\") && goal) out.goal_mode = goal.mode;\n if (line.key === \"protection.mode\") out.mode = \"off\";\n const act = /^protection\\.act\\.(\\d+)$/.exec(line.key);\n if (act && protection) {\n const entry = protection.acts[Number(act[1])];\n if (entry) {\n out.mode = entry.mode;\n out.verdict = entry.verdict;\n if (entry.tool_name) out.tool_name = entry.tool_name;\n }\n }\n return out;\n });\n}\n","/**\n * The render-estimate rule (criterion K4.4, design decision T8).\n *\n * The savings estimate stays off every rendering until the estimator gives a\n * conservative net lower bound. Today's estimator overstates: it uses median\n * benchmark savings, starts counting at 60k tokens, does not subtract μ, and\n * never shows a loss. `estimateQualifies` is the registry's rule written as a\n * pure function over the estimator's self-description, so a renderer and the\n * verifier reach the same answer. Even when it qualifies, the estimate never\n * appears on a PR comment or a share card.\n */\n\nimport { ESTIMATE_FORBIDDEN_SURFACES, SURFACES, type Surface } from \"./claim-table.js\";\n\n/** Tokens above which the gateway's context work is counted (the 200k line). */\nexport const ESTIMATE_COUNTING_FLOOR_TOKENS = 200_000;\n\nexport interface EstimateDescription {\n /** How the per-request saving is derived. Only a lower bound qualifies. */\n method: \"lower_bound\" | \"median\" | \"mean\" | string;\n /** Tokens from which the estimator starts counting. Must be at least the 200k line. */\n counting_floor_tokens: number;\n /** True when μ is subtracted from the gross saving. */\n net_of_mu: boolean;\n /** True when the estimator reports a loss as a negative figure rather than clamping at zero. */\n reports_loss: boolean;\n /** The net lower bound itself, in the same currency as model cost. */\n net_lower_bound?: number;\n [k: string]: unknown;\n}\n\nexport const ESTIMATE_DISQUALIFIERS = {\n not_an_object: \"not_an_object\",\n method_not_lower_bound: \"method_not_lower_bound\",\n counting_floor_below_200k: \"counting_floor_below_200k\",\n not_net_of_mu: \"not_net_of_mu\",\n never_shows_loss: \"never_shows_loss\",\n value_not_finite: \"value_not_finite\",\n} as const;\n\nexport type EstimateDisqualifier = (typeof ESTIMATE_DISQUALIFIERS)[keyof typeof ESTIMATE_DISQUALIFIERS];\n\nexport interface EstimateQualification {\n qualifies: boolean;\n reasons: EstimateDisqualifier[];\n}\n\nfunction isObject(v: unknown): v is Record<string, unknown> {\n return typeof v === \"object\" && v !== null && !Array.isArray(v);\n}\n\n/** The registry's `estimate_qualifies` rule: a conservative net lower bound. */\nexport function estimateQualifies(estimate: unknown): EstimateQualification {\n if (!isObject(estimate)) return { qualifies: false, reasons: [ESTIMATE_DISQUALIFIERS.not_an_object] };\n const reasons: EstimateDisqualifier[] = [];\n if (estimate.method !== \"lower_bound\") reasons.push(ESTIMATE_DISQUALIFIERS.method_not_lower_bound);\n const floor = estimate.counting_floor_tokens;\n if (typeof floor !== \"number\" || !Number.isFinite(floor) || floor < ESTIMATE_COUNTING_FLOOR_TOKENS) {\n reasons.push(ESTIMATE_DISQUALIFIERS.counting_floor_below_200k);\n }\n if (estimate.net_of_mu !== true) reasons.push(ESTIMATE_DISQUALIFIERS.not_net_of_mu);\n if (estimate.reports_loss !== true) reasons.push(ESTIMATE_DISQUALIFIERS.never_shows_loss);\n if (typeof estimate.net_lower_bound !== \"number\" || !Number.isFinite(estimate.net_lower_bound)) {\n reasons.push(ESTIMATE_DISQUALIFIERS.value_not_finite);\n }\n return { qualifies: reasons.length === 0, reasons };\n}\n\nexport const RENDER_ESTIMATE_REASONS = {\n unknown_surface: \"unknown_surface\",\n surface_never_shows_estimate: \"surface_never_shows_estimate\",\n estimate_does_not_qualify: \"estimate_does_not_qualify\",\n} as const;\n\nexport interface RenderEstimateDecision {\n render: boolean;\n reasons: string[];\n}\n\n/**\n * Whether a rendering on `surface` may show the estimate. False on a PR\n * comment or any card regardless of the estimate; otherwise the registry's\n * rule decides. A missing estimate never renders.\n */\nexport function shouldRenderEstimate(estimate: unknown, surface: unknown): RenderEstimateDecision {\n if (!(SURFACES as readonly unknown[]).includes(surface)) {\n return { render: false, reasons: [RENDER_ESTIMATE_REASONS.unknown_surface] };\n }\n if (ESTIMATE_FORBIDDEN_SURFACES.includes(surface as Surface)) {\n return { render: false, reasons: [RENDER_ESTIMATE_REASONS.surface_never_shows_estimate] };\n }\n const q = estimateQualifies(estimate);\n if (!q.qualifies) {\n return { render: false, reasons: [RENDER_ESTIMATE_REASONS.estimate_does_not_qualify, ...q.reasons] };\n }\n return { render: true, reasons: [] };\n}\n","/**\n * AAP-ShareCard/v1 — canonicalizer and offline verifier (MNE-9022).\n *\n * A share card is a signed set of numeric lines, each committing to the hash\n * of the signed statement it was derived from. Signing follows the\n * AAP-TransparencyRoot/v1 pattern (mnemom-api src/transparency/root_publisher.ts):\n * Ed25519 over canonical JSON (sorted keys, no whitespace) of the card MINUS\n * `signature`, with its own pinned `typ`. Renderers must display only the\n * `lines` returned by a successful verification.\n *\n * This module verifies only. It never handles private keys.\n */\n\nimport { verifyAsync } from \"@noble/ed25519\";\nimport { utf8ToBytes } from \"@noble/hashes/utils.js\";\n\nimport { canonicalJson } from \"./canonical.js\";\nimport { hexToUint8 } from \"./crypto.js\";\n\nexport const SHARE_CARD_TYP = \"AAP-ShareCard/v1\";\n\nexport type ShareCardLineKind = \"count\" | \"revert\";\n\nexport interface ShareCardLine {\n id: string;\n kind: ShareCardLineKind;\n label: string;\n value: number;\n statement_hash: string;\n}\n\nexport interface ShareCardStatementRef {\n typ: string;\n hash: string;\n}\n\nexport interface ShareCard {\n typ: string;\n card_id: string;\n period: { start: string; end: string };\n issued_at: string;\n signing_key_id: string;\n statements: ShareCardStatementRef[];\n lines: ShareCardLine[];\n /** base64url Ed25519 signature over canonicalJson(card minus signature). */\n signature: string;\n}\n\nexport interface ShareCardVerification {\n valid: boolean;\n /** Empty unless `valid`. Renderers must show only these. */\n lines: ShareCardLine[];\n errors: string[];\n}\n\n/** Keys that identify a repo, branch, PR or commit; never allowed anywhere. */\nconst IDENTIFYING_KEYS = new Set([\n \"repo\", \"repository\", \"repo_name\", \"branch\", \"branch_name\", \"ref\",\n \"pr\", \"pr_title\", \"pull_request\", \"title\", \"commit\", \"commit_message\",\n \"commit_sha\", \"message\", \"author\", \"email\", \"url\", \"path\",\n]);\n\nconst CARD_KEYS = [\"typ\", \"card_id\", \"period\", \"issued_at\", \"signing_key_id\", \"statements\", \"lines\", \"signature\"];\nconst PERIOD_KEYS = [\"start\", \"end\"];\nconst STATEMENT_KEYS = [\"typ\", \"hash\"];\nconst LINE_KEYS = [\"id\", \"kind\", \"label\", \"value\", \"statement_hash\"];\nconst HEX64 = /^[0-9a-f]{64}$/;\nconst DATE = /^\\d{4}-\\d{2}-\\d{2}$/;\n/** Opaque identifiers: no \"/\", no free text. Mirrored in schemas/aap-sharecard.schema.json. */\nconst OPAQUE_ID = /^[a-z0-9_-]{1,64}$/;\n/**\n * TODO(MNE-9022): label -> fixed label ID enum pending format sign-off.\n * Until then labels are restricted to a short, plain-text charset so they\n * cannot carry repo paths, branches, PR refs or URLs.\n */\nconst LABEL = /^[A-Za-z0-9 .,()+-]{1,40}$/;\nconst LABEL_MAX = 40;\n/**\n * Statement types a v1 card may commit to: the three signed record statements\n * (C5-R3). The share card itself (\"AAP-ShareCard/v1\") and the bundle are not\n * valid sources. Mirrored in schemas/aap-sharecard.schema.json.\n */\nexport const SHARE_CARD_STATEMENT_TYPES: readonly string[] = [\n \"AAP-ConductRecord/v1\",\n \"AAP-PRRecord/v1\",\n \"AAP-Outcome/v1\",\n];\nconst SIGNATURE_LEN = 86; // 64 bytes, unpadded base64url\nconst RFC3339 = /^(\\d{4})-(\\d{2})-(\\d{2})T(\\d{2}):(\\d{2}):(\\d{2})(?:\\.\\d+)?(?:Z|([+-])(\\d{2}):(\\d{2}))$/;\n\nfunction isCalendarDate(y: number, m: number, d: number): boolean {\n if (m < 1 || m > 12 || d < 1) return false;\n const dim = [31, y % 4 === 0 && (y % 100 !== 0 || y % 400 === 0) ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][m - 1]!;\n return d <= dim;\n}\n\nfunction isRfc3339(v: string): boolean {\n const m = RFC3339.exec(v);\n if (!m) return false;\n const [y, mo, d, h, mi, se] = m.slice(1, 7).map(Number) as [number, number, number, number, number, number];\n if (!isCalendarDate(y, mo, d) || h > 23 || mi > 59 || se > 59) return false;\n if (m[7] !== undefined && (Number(m[8]) > 23 || Number(m[9]) > 59)) return false;\n return true;\n}\n\n/** Sorted-key, whitespace-free JSON; identical to mnemom-api canonicalJson. One implementation for every signed statement (canonical.ts). */\nexport { canonicalJson };\n\n/** The exact string that is signed: canonical JSON of the card minus `signature`. */\nexport function shareCardSigningInput(card: Record<string, unknown>): string {\n const { signature: _signature, ...rest } = card;\n return canonicalJson(rest);\n}\n\nfunction bytesToBase64url(b: Uint8Array): string {\n let bin = \"\";\n for (const x of b) bin += String.fromCharCode(x);\n return btoa(bin).replace(/\\+/g, \"-\").replace(/\\//g, \"_\").replace(/=+$/, \"\");\n}\n\n/** Strict decode: exactly 86 chars that re-encode to the identical string (no malleable trailing bits). */\nfunction base64urlToBytes(s: string): Uint8Array {\n if (s.length !== SIGNATURE_LEN || !/^[A-Za-z0-9_-]+$/.test(s)) throw new Error(\"bad base64url\");\n const padded = s.replace(/-/g, \"+\").replace(/_/g, \"/\") + \"===\".slice(0, (4 - (s.length % 4)) % 4);\n const bin = atob(padded);\n const out = new Uint8Array(bin.length);\n for (let i = 0; i < bin.length; i++) out[i] = bin.charCodeAt(i);\n if (out.length !== 64 || bytesToBase64url(out) !== s) throw new Error(\"non-canonical base64url\");\n return out;\n}\n\nfunction isObj(v: unknown): v is Record<string, unknown> {\n return typeof v === \"object\" && v !== null && !Array.isArray(v);\n}\n\nfunction exactKeys(obj: Record<string, unknown>, allowed: string[], where: string, errors: string[]): void {\n for (const k of Object.keys(obj)) {\n if (IDENTIFYING_KEYS.has(k.toLowerCase())) errors.push(`${where}: identifying field \"${k}\" is not allowed`);\n else if (!allowed.includes(k)) errors.push(`${where}: unknown field \"${k}\"`);\n }\n for (const k of allowed) if (!(k in obj)) errors.push(`${where}: missing field \"${k}\"`);\n}\n\n/** Structural validation (no signature check). Returns error strings. */\nexport function validateShareCardShape(card: unknown): string[] {\n const errors: string[] = [];\n if (!isObj(card)) return [\"card: not an object\"];\n exactKeys(card, CARD_KEYS, \"card\", errors);\n if (card.typ !== SHARE_CARD_TYP) errors.push(`card: typ must be ${SHARE_CARD_TYP}`);\n if (typeof card.card_id !== \"string\" || !OPAQUE_ID.test(card.card_id)) errors.push(\"card: card_id must be an opaque id matching ^[a-z0-9_-]{1,64}$\");\n if (typeof card.issued_at !== \"string\" || !isRfc3339(card.issued_at)) errors.push(\"card: issued_at must be an RFC 3339 date-time\");\n if (typeof card.signing_key_id !== \"string\" || !card.signing_key_id) errors.push(\"card: signing_key_id must be a non-empty string\");\n if (typeof card.signature !== \"string\") errors.push(\"card: signature must be a string\");\n else {\n try {\n base64urlToBytes(card.signature);\n } catch {\n errors.push(\"card: signature must be a canonical 86-char unpadded base64url Ed25519 signature\");\n }\n }\n\n if (!isObj(card.period)) errors.push(\"period: not an object\");\n else {\n exactKeys(card.period, PERIOD_KEYS, \"period\", errors);\n for (const k of PERIOD_KEYS) {\n const v = card.period[k];\n if (typeof v !== \"string\" || !DATE.test(v) || !isCalendarDate(Number(v.slice(0, 4)), Number(v.slice(5, 7)), Number(v.slice(8, 10)))) {\n errors.push(`period.${k}: must be a real calendar date YYYY-MM-DD`);\n }\n }\n const { start, end } = card.period;\n if (typeof start === \"string\" && typeof end === \"string\" && DATE.test(start) && DATE.test(end) && start > end) {\n errors.push(\"period: start must be <= end\");\n }\n }\n\n const hashes = new Set<string>();\n const referenced = new Set<string>();\n const lineIds = new Set<string>();\n if (!Array.isArray(card.statements) || card.statements.length === 0) errors.push(\"statements: must be a non-empty array\");\n else\n card.statements.forEach((s, i) => {\n if (!isObj(s)) return void errors.push(`statements[${i}]: not an object`);\n exactKeys(s, STATEMENT_KEYS, `statements[${i}]`, errors);\n if (typeof s.typ !== \"string\" || !SHARE_CARD_STATEMENT_TYPES.includes(s.typ)) {\n errors.push(`statements[${i}].typ: must be one of ${SHARE_CARD_STATEMENT_TYPES.join(\", \")}`);\n }\n if (typeof s.hash !== \"string\" || !HEX64.test(s.hash)) errors.push(`statements[${i}].hash: must be 64 lowercase hex`);\n else hashes.add(s.hash);\n });\n\n if (!Array.isArray(card.lines) || card.lines.length === 0) errors.push(\"lines: must be a non-empty array\");\n else\n card.lines.forEach((l, i) => {\n if (!isObj(l)) return void errors.push(`lines[${i}]: not an object`);\n exactKeys(l, LINE_KEYS, `lines[${i}]`, errors);\n if (typeof l.id !== \"string\" || !OPAQUE_ID.test(l.id)) errors.push(`lines[${i}].id: must be an opaque id matching ^[a-z0-9_-]{1,64}$`);\n else if (lineIds.has(l.id)) errors.push(`lines[${i}].id: duplicate line id \"${l.id}\"`);\n else lineIds.add(l.id);\n if (l.kind !== \"count\" && l.kind !== \"revert\") errors.push(`lines[${i}].kind: must be \"count\" or \"revert\"`);\n if (typeof l.label !== \"string\" || !l.label || l.label.length > LABEL_MAX || /[/#]|:\\/\\/|www\\./i.test(l.label) || !LABEL.test(l.label)) {\n errors.push(`lines[${i}].label: must be short plain text (max ${LABEL_MAX}), no \"/\", \"#\" or URLs`);\n }\n if (typeof l.value !== \"number\" || !Number.isSafeInteger(l.value) || l.value < 0) errors.push(`lines[${i}].value: must be a non-negative integer`);\n if (typeof l.statement_hash !== \"string\" || !HEX64.test(l.statement_hash)) errors.push(`lines[${i}].statement_hash: must be 64 lowercase hex`);\n else if (!hashes.has(l.statement_hash)) errors.push(`lines[${i}].statement_hash: not committed in statements`);\n else referenced.add(l.statement_hash);\n });\n for (const h of hashes) if (!referenced.has(h)) errors.push(`statements: ${h} is not referenced by any line`);\n return errors;\n}\n\n/**\n * Verify a share card offline against a trusted Ed25519 public key.\n * Fails closed: on any error `lines` is empty so nothing can be rendered.\n */\nexport async function verifyShareCard(\n card: unknown,\n options: { publicKey: string | Uint8Array },\n): Promise<ShareCardVerification> {\n const fail = (errors: string[]): ShareCardVerification => ({ valid: false, lines: [], errors });\n const shapeErrors = validateShareCardShape(card);\n if (shapeErrors.length > 0) return fail(shapeErrors);\n const c = card as ShareCard;\n let ok = false;\n try {\n const pk = typeof options.publicKey === \"string\" ? hexToUint8(options.publicKey) : options.publicKey;\n ok = await verifyAsync(base64urlToBytes(c.signature), utf8ToBytes(shareCardSigningInput(c as unknown as Record<string, unknown>)), pk, { zip215: false });\n } catch {\n ok = false;\n }\n if (!ok) return fail([\"signature: verification failed\"]);\n return { valid: true, lines: c.lines.map((l) => ({ ...l })), errors: [] };\n}\n"]}
|
|
@@ -0,0 +1,330 @@
|
|
|
1
|
+
import { S as SignedStatement, R as RecordBundle, a as RecordJwks, b as RecordVerificationResult, c as StatementVerificationResult } from './claim-lint-CVITIRcU.cjs';
|
|
2
|
+
export { B as BUNDLE_TYP, C as CARD_LINE_CLASSES, d as CARD_SURFACES, e as CLAIM_CLASSES, f as CLAIM_TABLE, g as CardLineClass, h as CheckpointCitation, i as ClaimClass, j as ClaimField, k as ClaimTableEntry, l as ConductRecordStatement, E as ESTIMATE_FORBIDDEN_SURFACES, F as FLAGS, m as Flag, G as GOAL_MODES, n as GoalMode, L as LINE_KEY_FIELDS, o as LINT_RULES, p as LintResult, q as LintRule, r as LintViolation, M as MODES, s as MODE_VERBS, t as Mode, O as OutcomeStatement, P as PROTECTION_VERDICTS, u as PRRecordStatement, v as ProtectionVerdict, w as REASONS, x as Reason, y as RecordJwk, z as RecordShareCardLine, A as RenderedLine, D as Rendering, H as STATEMENT_TYPES, I as SURFACES, J as ShareCardStatement, K as SignedStatementBase, N as StatementFlag, Q as StatementGoalBlock, T as StatementLine, U as StatementProtectionAct, V as StatementTyp, W as Surface, X as attachLineContext, Y as fieldForLineKey, Z as isClaimField, _ as lintRendering, $ as lintRenderings, a0 as protectionVerb } from './claim-lint-CVITIRcU.cjs';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Certificate and proof types for AIP integrity verification.
|
|
6
|
+
*
|
|
7
|
+
* These types describe the structure of an integrity certificate
|
|
8
|
+
* produced by the AIP attestation pipeline, and the result of
|
|
9
|
+
* verifying one offline.
|
|
10
|
+
*/
|
|
11
|
+
/** A single concern identified during integrity analysis. */
|
|
12
|
+
interface CertificateConcern {
|
|
13
|
+
category: string;
|
|
14
|
+
severity: string;
|
|
15
|
+
description: string;
|
|
16
|
+
}
|
|
17
|
+
/** Subject of the integrity certificate — identifies what was analyzed. */
|
|
18
|
+
interface CertificateSubject {
|
|
19
|
+
checkpoint_id: string;
|
|
20
|
+
agent_id: string;
|
|
21
|
+
session_id: string;
|
|
22
|
+
card_id: string;
|
|
23
|
+
}
|
|
24
|
+
/** Claims made by the integrity analysis. */
|
|
25
|
+
interface CertificateClaims {
|
|
26
|
+
verdict: string;
|
|
27
|
+
concerns: CertificateConcern[];
|
|
28
|
+
confidence: number;
|
|
29
|
+
reasoning_summary: string;
|
|
30
|
+
analysis_model: string;
|
|
31
|
+
analysis_duration_ms: number;
|
|
32
|
+
}
|
|
33
|
+
/** Cryptographic commitments over the analysis inputs. */
|
|
34
|
+
interface InputCommitments {
|
|
35
|
+
thinking_block_hash: string;
|
|
36
|
+
card_hash: string;
|
|
37
|
+
values_hash: string;
|
|
38
|
+
context_hash: string;
|
|
39
|
+
model_version: string;
|
|
40
|
+
combined_commitment: string;
|
|
41
|
+
}
|
|
42
|
+
/** Ed25519 signature proof. */
|
|
43
|
+
interface SignatureProof {
|
|
44
|
+
algorithm: "Ed25519";
|
|
45
|
+
key_id: string;
|
|
46
|
+
value: string;
|
|
47
|
+
signed_payload: string;
|
|
48
|
+
}
|
|
49
|
+
/** Hash-chain position proof. */
|
|
50
|
+
interface ChainProof {
|
|
51
|
+
chain_hash: string;
|
|
52
|
+
prev_chain_hash: string | null;
|
|
53
|
+
position: number;
|
|
54
|
+
}
|
|
55
|
+
/** A single sibling node in a Merkle inclusion proof. */
|
|
56
|
+
interface MerkleSibling {
|
|
57
|
+
hash: string;
|
|
58
|
+
position: "left" | "right";
|
|
59
|
+
}
|
|
60
|
+
/** Merkle tree inclusion proof. */
|
|
61
|
+
interface MerkleProof {
|
|
62
|
+
leaf_hash: string;
|
|
63
|
+
leaf_index: number;
|
|
64
|
+
root: string;
|
|
65
|
+
tree_size: number;
|
|
66
|
+
inclusion_proof: MerkleSibling[];
|
|
67
|
+
}
|
|
68
|
+
/** Zero-knowledge verdict derivation proof (SP1 STARK). */
|
|
69
|
+
interface VerdictDerivationProof {
|
|
70
|
+
method: "SP1-STARK" | "RISC-Zero-STARK";
|
|
71
|
+
image_id: string;
|
|
72
|
+
receipt: string;
|
|
73
|
+
journal: string;
|
|
74
|
+
verified_at: string;
|
|
75
|
+
}
|
|
76
|
+
/** All cryptographic proofs attached to a certificate. */
|
|
77
|
+
interface CertificateProofs {
|
|
78
|
+
signature: SignatureProof;
|
|
79
|
+
chain: ChainProof;
|
|
80
|
+
merkle: MerkleProof | null;
|
|
81
|
+
verdict_derivation: VerdictDerivationProof | null;
|
|
82
|
+
}
|
|
83
|
+
/** Verification endpoint URLs (informational, not used offline). */
|
|
84
|
+
interface VerificationEndpoints {
|
|
85
|
+
keys_url: string;
|
|
86
|
+
certificate_url: string;
|
|
87
|
+
verify_url: string;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* An AIP Integrity Certificate.
|
|
91
|
+
*
|
|
92
|
+
* Produced by the attestation pipeline and cryptographically bound
|
|
93
|
+
* to the integrity checkpoint it attests.
|
|
94
|
+
*/
|
|
95
|
+
interface IntegrityCertificate {
|
|
96
|
+
"@context": "https://mnemom.ai/aip/v1";
|
|
97
|
+
type: "IntegrityCertificate";
|
|
98
|
+
version: "1.0.0";
|
|
99
|
+
certificate_id: string;
|
|
100
|
+
issued_at: string;
|
|
101
|
+
subject: CertificateSubject;
|
|
102
|
+
claims: CertificateClaims;
|
|
103
|
+
input_commitments: InputCommitments;
|
|
104
|
+
proofs: CertificateProofs;
|
|
105
|
+
verification: VerificationEndpoints;
|
|
106
|
+
}
|
|
107
|
+
/** Result of a single verification check. */
|
|
108
|
+
interface CheckResult {
|
|
109
|
+
valid: boolean;
|
|
110
|
+
details: string;
|
|
111
|
+
}
|
|
112
|
+
/** Aggregated result of verifying an integrity certificate. */
|
|
113
|
+
interface VerificationResult {
|
|
114
|
+
valid: boolean;
|
|
115
|
+
checks: {
|
|
116
|
+
signature: CheckResult;
|
|
117
|
+
chain: CheckResult;
|
|
118
|
+
merkle: CheckResult | null;
|
|
119
|
+
verdict_derivation: CheckResult | null;
|
|
120
|
+
};
|
|
121
|
+
certificate_id: string;
|
|
122
|
+
verified_at: string;
|
|
123
|
+
}
|
|
124
|
+
/** Options for the certificate verifier. */
|
|
125
|
+
interface VerifierOptions {
|
|
126
|
+
/** Ed25519 public key as hex string or Uint8Array. */
|
|
127
|
+
publicKey: string | Uint8Array;
|
|
128
|
+
/** Expected Merkle root (hex). If provided, Merkle proof is verified against it. */
|
|
129
|
+
merkleRoot?: string;
|
|
130
|
+
/** Expected SP1 image ID (hex). If provided, verdict derivation proof is checked against it. */
|
|
131
|
+
verdictDerivationImageId?: string;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Main certificate verification logic.
|
|
136
|
+
*
|
|
137
|
+
* Given a trusted public key (and optionally a Merkle root), verifies
|
|
138
|
+
* an AIP Integrity Certificate entirely offline.
|
|
139
|
+
*/
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Verify an AIP Integrity Certificate offline.
|
|
143
|
+
*
|
|
144
|
+
* Performs four checks:
|
|
145
|
+
*
|
|
146
|
+
* 1. **Signature** — Ed25519 verification of the signed payload.
|
|
147
|
+
* 2. **Chain** — Recomputes chain hash and compares with the certificate.
|
|
148
|
+
* 3. **Merkle** — If the certificate carries a Merkle proof *and*
|
|
149
|
+
* `options.merkleRoot` is supplied, verifies the inclusion proof.
|
|
150
|
+
* Otherwise the check is skipped (returns `null`).
|
|
151
|
+
* 4. **Verdict derivation** — If the certificate carries a verdict derivation
|
|
152
|
+
* proof, verifies structural integrity (journal fields match certificate
|
|
153
|
+
* claims). STARK receipt verification is deferred to server-side.
|
|
154
|
+
*
|
|
155
|
+
* @param certificate - The integrity certificate to verify.
|
|
156
|
+
* @param options - Public key and optional Merkle root.
|
|
157
|
+
* @returns Verification result with per-check details.
|
|
158
|
+
*/
|
|
159
|
+
declare function verifyCertificate(certificate: IntegrityCertificate, options: VerifierOptions): Promise<VerificationResult>;
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Offline verification of record statements and bundles.
|
|
163
|
+
*
|
|
164
|
+
* `verify(statement | bundle, jwks)` is the one entry point the CLI, CI,
|
|
165
|
+
* the PR check and the web pages all call. It never touches the network:
|
|
166
|
+
* the caller hands it the published JWKS.
|
|
167
|
+
*
|
|
168
|
+
* Order of checks for one statement, fail-closed, same as the SDK's
|
|
169
|
+
* `JwksClient.verify` (mnemom-platform `shared/sdk/src/jwks.ts`):
|
|
170
|
+
*
|
|
171
|
+
* 1. shape and `typ` (domain separation, T3)
|
|
172
|
+
* 2. `alg`, exact-match `EdDSA`, before any key material is touched
|
|
173
|
+
* 3. `signing_key_id` and `signature` present and well formed
|
|
174
|
+
* 4. key lookup by `kid`; the key must be an Ed25519 OKP key with `alg: EdDSA`
|
|
175
|
+
* 5. Ed25519 over `canonicalJson(statement minus signature)`
|
|
176
|
+
* 6. per-type rules (share card line classes, verdict coverage)
|
|
177
|
+
* 7. flags on cited checkpoints (T12), which never change `valid`
|
|
178
|
+
*/
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* The bytes a statement's signature covers: canonical JSON of the statement
|
|
182
|
+
* with `signature` removed. Exported so a signer in another language can be
|
|
183
|
+
* checked against it byte for byte.
|
|
184
|
+
*/
|
|
185
|
+
declare function statementCommitment(statement: Record<string, unknown>): string;
|
|
186
|
+
/** Lowercase sha256 hex of a statement's commitment: how statements link (T2). */
|
|
187
|
+
declare function statementDigest(statement: Record<string, unknown>): string;
|
|
188
|
+
/**
|
|
189
|
+
* Verify one signed statement against the published JWKS.
|
|
190
|
+
* Never throws and never calls the network.
|
|
191
|
+
*/
|
|
192
|
+
declare function verifyStatement(statement: unknown, jwks: RecordJwks): Promise<StatementVerificationResult>;
|
|
193
|
+
/**
|
|
194
|
+
* Verify a statement or a whole bundle against the published JWKS.
|
|
195
|
+
*
|
|
196
|
+
* For a bundle every statement is verified on its own, then the links
|
|
197
|
+
* between them are checked: a digest that names a statement in the bundle
|
|
198
|
+
* must name one of the right type. A digest that names nothing in the
|
|
199
|
+
* bundle is flagged, not failed, because a long session's earlier
|
|
200
|
+
* statements may live outside the bundle (design, open questions).
|
|
201
|
+
*/
|
|
202
|
+
declare function verify(input: SignedStatement | RecordBundle | unknown, jwks: RecordJwks): Promise<RecordVerificationResult>;
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* The render-estimate rule (criterion K4.4, design decision T8).
|
|
206
|
+
*
|
|
207
|
+
* The savings estimate stays off every rendering until the estimator gives a
|
|
208
|
+
* conservative net lower bound. Today's estimator overstates: it uses median
|
|
209
|
+
* benchmark savings, starts counting at 60k tokens, does not subtract μ, and
|
|
210
|
+
* never shows a loss. `estimateQualifies` is the registry's rule written as a
|
|
211
|
+
* pure function over the estimator's self-description, so a renderer and the
|
|
212
|
+
* verifier reach the same answer. Even when it qualifies, the estimate never
|
|
213
|
+
* appears on a PR comment or a share card.
|
|
214
|
+
*/
|
|
215
|
+
/** Tokens above which the gateway's context work is counted (the 200k line). */
|
|
216
|
+
declare const ESTIMATE_COUNTING_FLOOR_TOKENS = 200000;
|
|
217
|
+
interface EstimateDescription {
|
|
218
|
+
/** How the per-request saving is derived. Only a lower bound qualifies. */
|
|
219
|
+
method: "lower_bound" | "median" | "mean" | string;
|
|
220
|
+
/** Tokens from which the estimator starts counting. Must be at least the 200k line. */
|
|
221
|
+
counting_floor_tokens: number;
|
|
222
|
+
/** True when μ is subtracted from the gross saving. */
|
|
223
|
+
net_of_mu: boolean;
|
|
224
|
+
/** True when the estimator reports a loss as a negative figure rather than clamping at zero. */
|
|
225
|
+
reports_loss: boolean;
|
|
226
|
+
/** The net lower bound itself, in the same currency as model cost. */
|
|
227
|
+
net_lower_bound?: number;
|
|
228
|
+
[k: string]: unknown;
|
|
229
|
+
}
|
|
230
|
+
declare const ESTIMATE_DISQUALIFIERS: {
|
|
231
|
+
readonly not_an_object: "not_an_object";
|
|
232
|
+
readonly method_not_lower_bound: "method_not_lower_bound";
|
|
233
|
+
readonly counting_floor_below_200k: "counting_floor_below_200k";
|
|
234
|
+
readonly not_net_of_mu: "not_net_of_mu";
|
|
235
|
+
readonly never_shows_loss: "never_shows_loss";
|
|
236
|
+
readonly value_not_finite: "value_not_finite";
|
|
237
|
+
};
|
|
238
|
+
type EstimateDisqualifier = (typeof ESTIMATE_DISQUALIFIERS)[keyof typeof ESTIMATE_DISQUALIFIERS];
|
|
239
|
+
interface EstimateQualification {
|
|
240
|
+
qualifies: boolean;
|
|
241
|
+
reasons: EstimateDisqualifier[];
|
|
242
|
+
}
|
|
243
|
+
/** The registry's `estimate_qualifies` rule: a conservative net lower bound. */
|
|
244
|
+
declare function estimateQualifies(estimate: unknown): EstimateQualification;
|
|
245
|
+
declare const RENDER_ESTIMATE_REASONS: {
|
|
246
|
+
readonly unknown_surface: "unknown_surface";
|
|
247
|
+
readonly surface_never_shows_estimate: "surface_never_shows_estimate";
|
|
248
|
+
readonly estimate_does_not_qualify: "estimate_does_not_qualify";
|
|
249
|
+
};
|
|
250
|
+
interface RenderEstimateDecision {
|
|
251
|
+
render: boolean;
|
|
252
|
+
reasons: string[];
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* Whether a rendering on `surface` may show the estimate. False on a PR
|
|
256
|
+
* comment or any card regardless of the estimate; otherwise the registry's
|
|
257
|
+
* rule decides. A missing estimate never renders.
|
|
258
|
+
*/
|
|
259
|
+
declare function shouldRenderEstimate(estimate: unknown, surface: unknown): RenderEstimateDecision;
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* Canonical JSON, byte-identical to mnemom-api `src/attestation/crypto.ts`
|
|
263
|
+
* (`canonicalJson`): object keys sorted recursively, no whitespace, arrays
|
|
264
|
+
* kept in order, primitives through `JSON.stringify`.
|
|
265
|
+
*
|
|
266
|
+
* Every signed record statement commits to this serialisation of the
|
|
267
|
+
* statement minus its `signature` field, exactly the way
|
|
268
|
+
* `AAP-TransparencyRoot/v1` does (mnemom-api `src/transparency/root_publisher.ts`).
|
|
269
|
+
*/
|
|
270
|
+
declare function canonicalJson(value: unknown): string;
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* AAP-ShareCard/v1 — canonicalizer and offline verifier (MNE-9022).
|
|
274
|
+
*
|
|
275
|
+
* A share card is a signed set of numeric lines, each committing to the hash
|
|
276
|
+
* of the signed statement it was derived from. Signing follows the
|
|
277
|
+
* AAP-TransparencyRoot/v1 pattern (mnemom-api src/transparency/root_publisher.ts):
|
|
278
|
+
* Ed25519 over canonical JSON (sorted keys, no whitespace) of the card MINUS
|
|
279
|
+
* `signature`, with its own pinned `typ`. Renderers must display only the
|
|
280
|
+
* `lines` returned by a successful verification.
|
|
281
|
+
*
|
|
282
|
+
* This module verifies only. It never handles private keys.
|
|
283
|
+
*/
|
|
284
|
+
|
|
285
|
+
declare const SHARE_CARD_TYP = "AAP-ShareCard/v1";
|
|
286
|
+
type ShareCardLineKind = "count" | "revert";
|
|
287
|
+
interface ShareCardLine {
|
|
288
|
+
id: string;
|
|
289
|
+
kind: ShareCardLineKind;
|
|
290
|
+
label: string;
|
|
291
|
+
value: number;
|
|
292
|
+
statement_hash: string;
|
|
293
|
+
}
|
|
294
|
+
interface ShareCardStatementRef {
|
|
295
|
+
typ: string;
|
|
296
|
+
hash: string;
|
|
297
|
+
}
|
|
298
|
+
interface ShareCard {
|
|
299
|
+
typ: string;
|
|
300
|
+
card_id: string;
|
|
301
|
+
period: {
|
|
302
|
+
start: string;
|
|
303
|
+
end: string;
|
|
304
|
+
};
|
|
305
|
+
issued_at: string;
|
|
306
|
+
signing_key_id: string;
|
|
307
|
+
statements: ShareCardStatementRef[];
|
|
308
|
+
lines: ShareCardLine[];
|
|
309
|
+
/** base64url Ed25519 signature over canonicalJson(card minus signature). */
|
|
310
|
+
signature: string;
|
|
311
|
+
}
|
|
312
|
+
interface ShareCardVerification {
|
|
313
|
+
valid: boolean;
|
|
314
|
+
/** Empty unless `valid`. Renderers must show only these. */
|
|
315
|
+
lines: ShareCardLine[];
|
|
316
|
+
errors: string[];
|
|
317
|
+
}
|
|
318
|
+
/** The exact string that is signed: canonical JSON of the card minus `signature`. */
|
|
319
|
+
declare function shareCardSigningInput(card: Record<string, unknown>): string;
|
|
320
|
+
/** Structural validation (no signature check). Returns error strings. */
|
|
321
|
+
declare function validateShareCardShape(card: unknown): string[];
|
|
322
|
+
/**
|
|
323
|
+
* Verify a share card offline against a trusted Ed25519 public key.
|
|
324
|
+
* Fails closed: on any error `lines` is empty so nothing can be rendered.
|
|
325
|
+
*/
|
|
326
|
+
declare function verifyShareCard(card: unknown, options: {
|
|
327
|
+
publicKey: string | Uint8Array;
|
|
328
|
+
}): Promise<ShareCardVerification>;
|
|
329
|
+
|
|
330
|
+
export { type CertificateClaims, type CertificateConcern, type CertificateProofs, type CertificateSubject, type ChainProof, type CheckResult, ESTIMATE_COUNTING_FLOOR_TOKENS, ESTIMATE_DISQUALIFIERS, type EstimateDescription, type EstimateDisqualifier, type EstimateQualification, type InputCommitments, type IntegrityCertificate, type MerkleProof, type MerkleSibling, RENDER_ESTIMATE_REASONS, RecordBundle, RecordJwks, RecordVerificationResult, type RenderEstimateDecision, SHARE_CARD_TYP, type ShareCard, type ShareCardLine, type ShareCardLineKind, type ShareCardStatementRef, type ShareCardVerification, type SignatureProof, SignedStatement, StatementVerificationResult, type VerdictDerivationProof, type VerificationEndpoints, type VerificationResult, type VerifierOptions, canonicalJson, estimateQualifies, shareCardSigningInput, shouldRenderEstimate, statementCommitment, statementDigest, validateShareCardShape, verify, verifyCertificate, verifyShareCard, verifyStatement };
|