@mnemom/mnemom 0.17.36 → 0.17.38-next.0
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 +11 -0
- package/dist/commands/agent-run.js +37 -0
- package/dist/commands/agent-share-render.d.ts +5 -5
- package/dist/commands/agent-share-render.js +9 -7
- package/dist/commands/agent-share-test-issuer.d.ts +1 -1
- package/dist/commands/agent-share-test-issuer.js +1 -1
- package/dist/commands/agent.d.ts +8 -1
- package/dist/commands/agent.js +14 -3
- package/dist/commands/scan.d.ts +15 -2
- package/dist/commands/scan.js +48 -3
- package/dist/host/commands.js +4 -1
- package/dist/host/owner.d.ts +2 -0
- package/dist/host/verbs.d.ts +16 -1
- package/dist/host/verbs.js +45 -3
- package/dist/index.js +1 -1
- package/dist/lib/commit-report.d.ts +7 -13
- package/dist/lib/commit-report.js +12 -5
- package/dist/lib/conduct-receipt.d.ts +8 -3
- package/dist/lib/conduct-receipt.js +29 -7
- package/dist/lib/experimental.d.ts +1 -1
- package/dist/lib/experimental.js +1 -12
- package/dist/lib/runner/executor-client.d.ts +5 -0
- package/dist/lib/runner/executor-client.js +8 -0
- package/dist/lib/runner/job.d.ts +37 -0
- package/dist/lib/runner/job.js +74 -1
- package/dist/lib/runner/phases.d.ts +7 -2
- package/dist/lib/runner/phases.js +7 -2
- package/dist/lib/runner/proxy.d.ts +26 -2
- package/dist/lib/runner/proxy.js +33 -1
- package/dist/lib/runner/record-commit.d.ts +16 -0
- package/dist/lib/runner/record-commit.js +7 -0
- package/dist/lib/scan/spend/anthropic-usage.d.ts +20 -1
- package/dist/lib/scan/spend/anthropic-usage.js +32 -7
- package/dist/lib/scan/spend/anthropic-wif.d.ts +42 -0
- package/dist/lib/scan/spend/anthropic-wif.js +153 -0
- package/dist/vendor/durable-contract/index.js +6 -3
- package/dist/vendor/shared/durable-contract/cli-surface.js +2 -2
- package/dist/vendor/shared/durable-contract/codes.js +4 -1
- package/package.json +2 -5
- package/node_modules/@mnemom/aip-verifier/LICENSE +0 -190
- package/node_modules/@mnemom/aip-verifier/dist/claim-lint-CVITIRcU.d.cts +0 -478
- package/node_modules/@mnemom/aip-verifier/dist/claim-lint-CVITIRcU.d.ts +0 -478
- package/node_modules/@mnemom/aip-verifier/dist/index.cjs +0 -971
- package/node_modules/@mnemom/aip-verifier/dist/index.cjs.map +0 -1
- package/node_modules/@mnemom/aip-verifier/dist/index.d.cts +0 -330
- package/node_modules/@mnemom/aip-verifier/dist/index.d.ts +0 -330
- package/node_modules/@mnemom/aip-verifier/dist/index.js +0 -933
- package/node_modules/@mnemom/aip-verifier/dist/index.js.map +0 -1
- package/node_modules/@mnemom/aip-verifier/dist/render-lines.cjs +0 -879
- package/node_modules/@mnemom/aip-verifier/dist/render-lines.cjs.map +0 -1
- package/node_modules/@mnemom/aip-verifier/dist/render-lines.d.cts +0 -96
- package/node_modules/@mnemom/aip-verifier/dist/render-lines.d.ts +0 -96
- package/node_modules/@mnemom/aip-verifier/dist/render-lines.js +0 -875
- package/node_modules/@mnemom/aip-verifier/dist/render-lines.js.map +0 -1
- package/node_modules/@mnemom/aip-verifier/package.json +0 -86
- package/node_modules/@noble/ed25519/LICENSE +0 -21
- package/node_modules/@noble/ed25519/README.md +0 -371
- package/node_modules/@noble/ed25519/index.d.ts +0 -391
- package/node_modules/@noble/ed25519/index.js +0 -933
- package/node_modules/@noble/ed25519/index.ts +0 -1134
- package/node_modules/@noble/ed25519/package.json +0 -54
- package/node_modules/@noble/hashes/LICENSE +0 -21
- package/node_modules/@noble/hashes/README.md +0 -478
- package/node_modules/@noble/hashes/_blake.d.ts +0 -20
- package/node_modules/@noble/hashes/_blake.js +0 -59
- package/node_modules/@noble/hashes/_md.d.ts +0 -95
- package/node_modules/@noble/hashes/_md.js +0 -209
- package/node_modules/@noble/hashes/_u64.d.ts +0 -36
- package/node_modules/@noble/hashes/_u64.js +0 -77
- package/node_modules/@noble/hashes/argon2.d.ts +0 -148
- package/node_modules/@noble/hashes/argon2.js +0 -577
- package/node_modules/@noble/hashes/blake1.d.ts +0 -162
- package/node_modules/@noble/hashes/blake1.js +0 -630
- package/node_modules/@noble/hashes/blake2.d.ts +0 -203
- package/node_modules/@noble/hashes/blake2.js +0 -573
- package/node_modules/@noble/hashes/blake3.d.ts +0 -68
- package/node_modules/@noble/hashes/blake3.js +0 -310
- package/node_modules/@noble/hashes/eskdf.d.ts +0 -91
- package/node_modules/@noble/hashes/eskdf.js +0 -225
- package/node_modules/@noble/hashes/hkdf.d.ts +0 -70
- package/node_modules/@noble/hashes/hkdf.js +0 -152
- package/node_modules/@noble/hashes/hmac.d.ts +0 -50
- package/node_modules/@noble/hashes/hmac.js +0 -93
- package/node_modules/@noble/hashes/index.d.ts +0 -1
- package/node_modules/@noble/hashes/index.js +0 -34
- package/node_modules/@noble/hashes/legacy.d.ts +0 -107
- package/node_modules/@noble/hashes/legacy.js +0 -348
- package/node_modules/@noble/hashes/package.json +0 -91
- package/node_modules/@noble/hashes/pbkdf2.d.ts +0 -66
- package/node_modules/@noble/hashes/pbkdf2.js +0 -176
- package/node_modules/@noble/hashes/scrypt.d.ts +0 -98
- package/node_modules/@noble/hashes/scrypt.js +0 -304
- package/node_modules/@noble/hashes/sha2.d.ts +0 -176
- package/node_modules/@noble/hashes/sha2.js +0 -446
- package/node_modules/@noble/hashes/sha3-addons.d.ts +0 -533
- package/node_modules/@noble/hashes/sha3-addons.js +0 -973
- package/node_modules/@noble/hashes/sha3.d.ts +0 -208
- package/node_modules/@noble/hashes/sha3.js +0 -475
- package/node_modules/@noble/hashes/src/_blake.ts +0 -67
- package/node_modules/@noble/hashes/src/_md.ts +0 -227
- package/node_modules/@noble/hashes/src/_u64.ts +0 -111
- package/node_modules/@noble/hashes/src/argon2.ts +0 -693
- package/node_modules/@noble/hashes/src/blake1.ts +0 -677
- package/node_modules/@noble/hashes/src/blake2.ts +0 -648
- package/node_modules/@noble/hashes/src/blake3.ts +0 -344
- package/node_modules/@noble/hashes/src/eskdf.ts +0 -265
- package/node_modules/@noble/hashes/src/hkdf.ts +0 -161
- package/node_modules/@noble/hashes/src/hmac.ts +0 -130
- package/node_modules/@noble/hashes/src/index.ts +0 -33
- package/node_modules/@noble/hashes/src/legacy.ts +0 -361
- package/node_modules/@noble/hashes/src/pbkdf2.ts +0 -219
- package/node_modules/@noble/hashes/src/scrypt.ts +0 -375
- package/node_modules/@noble/hashes/src/sha2.ts +0 -486
- package/node_modules/@noble/hashes/src/sha3-addons.ts +0 -1157
- package/node_modules/@noble/hashes/src/sha3.ts +0 -525
- package/node_modules/@noble/hashes/src/utils.ts +0 -978
- package/node_modules/@noble/hashes/src/webcrypto.ts +0 -283
- package/node_modules/@noble/hashes/utils.d.ts +0 -560
- package/node_modules/@noble/hashes/utils.js +0 -687
- package/node_modules/@noble/hashes/webcrypto.d.ts +0 -121
- package/node_modules/@noble/hashes/webcrypto.js +0 -228
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/claim-table.ts","../src/claim-lint.ts","../src/render-estimate.ts","../src/canonical.ts","../src/crypto.ts","../src/sharecard.ts","../src/statements.ts","../src/verify-record.ts","../src/render-lines.ts"],"names":["isObject","hexToBytes","fail","verifyAsync","utf8ToBytes","bytesToHex","sha256","reasons","flags","statements","isObj","STATEMENT_KEYS"],"mappings":";;;;;;;AAoBO,IAAM,gBAAgB,CAAC,UAAA,EAAY,SAAA,EAAW,UAAA,EAAY,aAAa,SAAS,CAAA;AAShF,IAAM,WAAW,CAAC,aAAA,EAAe,eAAA,EAAiB,YAAA,EAAc,cAAc,aAAa,CAAA;AAG3F,IAAM,aAAA,GAAoC,CAAC,YAAA,EAAc,aAAa,CAAA;AAGtE,IAAM,2BAAA,GAAkD,CAAC,YAAA,EAAc,YAAA,EAAc,aAAa,CAAA;AAGlG,IAAM,KAAA,GAAQ,CAAC,KAAA,EAAO,SAAA,EAAW,SAAS,SAAS,CAAA;AAQnD,IAAM,UAAA,GAAmC;AAAA,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O,CAAC,CAAA;AAAA,IACvD;AACA,IAAA,IAAI,aAAa,KAAA,EAAO;AACtB,MAAA,IAAI,IAAA,CAAK,cAAc,KAAA,CAAA,EAAW,OAAO,KAAK,CAAC,CAAA,CAAE,WAAW,CAAC,CAAA;AAC7D,MAAA,OAAO,MAAM,qBAAA,CAAsB,KAAA,EAAO,OAAA,EAAS,KAAK,SAAS,CAAA;AAAA,IACnE;AACA,IAAA,IAAI,CAAC,KAAK,IAAA,EAAM,OAAO,KAAK,CAAC,CAAA,CAAE,WAAW,CAAC,CAAA;AAC3C,IAAA,OAAO,MAAM,oBAAA,CAAqB,KAAA,EAAO,OAAA,EAAS,KAAK,IAAI,CAAA;AAAA,EAC7D,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,IAAA,CAAK,CAAC,CAAA,CAAE,cAAc,CAAC,CAAA;AAAA,EAChC;AACF","file":"render-lines.cjs","sourcesContent":["/**\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 * 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 * 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 * 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","/**\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 * Card line renderer (MNE-9026, criterion K4.3/K4.4, design C5-R6).\n *\n * `renderLines` turns signed input into the lines a share card or period card\n * may show, and nothing else. Every line is derived from a statement that\n * verified against the published key: there is no parameter that accepts a\n * typed number, a string or an estimate. Only measured, outcome and\n * verdict-with-coverage lines come out. Fail closed: on any problem `lines` is\n * empty, so a renderer that prints `result.lines` prints nothing.\n *\n * FLAG-GATED. This module is NOT re-exported from the package index. It is\n * reachable only via the `@mnemom/aip-verifier/render-lines` subpath, and even\n * there it returns `render_lines_disabled` (no lines) unless the caller passes\n * `opts.enabled: true` or the environment sets `AIP_RENDER_LINES=1`. Default\n * behavior and the existing published API are unchanged.\n *\n * Accepted inputs (`opts` says which key verifies them):\n * 1. A record bundle or a single `AAP-ShareCard/v1` record statement\n * (`{class, text, coverage}` lines), verified with `opts.jwks` through the\n * existing `verify`. A period card additionally needs signed\n * `AAP-Outcome/v1` statements in the bundle: its revert line is derived\n * from them, never typed.\n * 2. The MNE-9022 numeric card (`card_id`, `{id, kind, label, value}` lines),\n * verified with `opts.publicKey` through the existing `verifyShareCard`.\n *\n * Every rendered line is re-checked with `lintRendering` on the chosen\n * surface; any violation makes the whole render fail.\n */\n\nimport { lintRendering } from \"./claim-lint.js\";\nimport type { LintViolation } from \"./claim-lint.js\";\nimport { shouldRenderEstimate } from \"./render-estimate.js\";\nimport { validateShareCardShape, verifyShareCard } from \"./sharecard.js\";\nimport { verify } from \"./verify-record.js\";\nimport type { RecordJwks } from \"./statements.js\";\n\n/**\n * One line the CLI (or any consumer) may print, verbatim. Contract:\n * - `class` is exactly one of `measured`, `outcome`, `verdict`. No estimate,\n * benchmark or savings class can be produced.\n * - `text` is display text, already claim-lint clean. Print it as is; never\n * append a figure, tool name, repo, org or person.\n * - `coverage` is present on every `verdict` line (\"judged of total\") and\n * absent on the other classes.\n * - `revert` is true on the line that reports reverts. A period card always\n * contains at least one such line.\n * Structurally assignable to claim-lint's `RenderedLine`.\n */\nexport interface RenderedLine {\n class: \"measured\" | \"outcome\" | \"verdict\";\n text: string;\n coverage?: { judged: number; total: number };\n revert?: true;\n}\n\nexport type RenderSurface = \"share_card\" | \"period_card\";\n\nexport interface RenderLinesOptions {\n /** Which card is being drawn. Default `share_card`. */\n surface?: RenderSurface;\n /** Explicit flag. Also on when `AIP_RENDER_LINES=1`. */\n enabled?: boolean;\n /** Published JWKS, to verify record statements. */\n jwks?: RecordJwks;\n /** Trusted Ed25519 public key (hex or bytes), to verify a numeric card. */\n publicKey?: string | Uint8Array;\n}\n\nexport const RENDER_LINES_REASONS = {\n render_lines_disabled: \"render_lines_disabled\",\n unknown_surface: \"unknown_surface\",\n not_verifiable: \"not_verifiable\",\n missing_key: \"missing_key\",\n no_share_card_statement: \"no_share_card_statement\",\n identifying_field: \"identifying_field\",\n line_class_not_allowed: \"line_class_not_allowed\",\n line_malformed: \"line_malformed\",\n no_lines: \"no_lines\",\n period_card_without_outcomes: \"period_card_without_outcomes\",\n period_card_without_revert_line: \"period_card_without_revert_line\",\n estimate_not_renderable: \"estimate_not_renderable\",\n lint_failed: \"lint_failed\",\n} as const;\n\nexport interface RenderLinesResult {\n ok: boolean;\n /** Empty unless `ok`. */\n lines: RenderedLine[];\n /** Stable reason strings; prefixed detail follows a colon. */\n reasons: string[];\n /** claim-lint violations when `lint_failed`. */\n violations?: LintViolation[];\n}\n\nconst R = RENDER_LINES_REASONS;\n\n/** Flag read; safe where `process` does not exist (Workers, browsers). */\nexport function renderLinesEnabled(opts?: RenderLinesOptions): boolean {\n if (opts?.enabled === true) return true;\n const env = (globalThis as { process?: { env?: Record<string, string | undefined> } }).process?.env;\n return env?.AIP_RENDER_LINES === \"1\";\n}\n\nconst fail = (reasons: string[], violations?: LintViolation[]): RenderLinesResult => ({\n ok: false,\n lines: [],\n reasons,\n ...(violations ? { violations } : {}),\n});\n\nfunction isObj(v: unknown): v is Record<string, unknown> {\n return typeof v === \"object\" && v !== null && !Array.isArray(v);\n}\n\n/**\n * Keys a record share card statement may carry. Anything else (repo, org,\n * person, goal text, tool name, estimate, ...) fails the render, even though\n * the statement is signed: a signature proves origin, not that a field is safe\n * to show.\n */\nconst STATEMENT_KEYS = new Set([\n \"typ\", \"signing_key_id\", \"signature\", \"alg\", \"built_at\", \"previous_digest\",\n \"commitment_key_id\", \"unit_kind\", \"source_digest\", \"lines\",\n]);\nconst STATEMENT_LINE_KEYS = new Set([\"class\", \"text\", \"coverage\"]);\nconst COVERAGE_KEYS = new Set([\"judged\", \"total\"]);\n\nfunction unknownKeys(o: Record<string, unknown>, allowed: Set<string>, where: string): string[] {\n return Object.keys(o).filter((k) => !allowed.has(k)).map((k) => `${R.identifying_field}:${where}.${k}`);\n}\n\n/** Fixed, signed-outcome vocabulary: the outcome statement's `outcome` field never prints raw. */\nfunction outcomeKind(s: Record<string, unknown>): \"reverted\" | \"accepted\" | null {\n if (typeof s.outcome !== \"string\") return null;\n if (s.outcome === \"accepted_no_revert\") return \"accepted\";\n if (s.outcome === \"reverted\") return \"reverted\";\n return null;\n}\n\nfunction finish(surface: RenderSurface, lines: RenderedLine[]): RenderLinesResult {\n if (lines.length === 0) return fail([R.no_lines]);\n if (surface === \"period_card\" && !lines.some((l) => l.revert === true)) {\n return fail([R.period_card_without_revert_line]);\n }\n // Lint the exact text a consumer will print; the `revert` marker is ours, not a lint field.\n const lintLines = lines.map(({ revert: _revert, ...l }) => l);\n const lint = lintRendering({ surface, lines: lintLines });\n if (!lint.ok) return fail([R.lint_failed], lint.violations);\n return { ok: true, lines, reasons: [] };\n}\n\nasync function renderFromStatements(input: Record<string, unknown>, surface: RenderSurface, jwks: RecordJwks): Promise<RenderLinesResult> {\n const v = await verify(input, jwks);\n if (!v.valid) return fail([R.not_verifiable, ...v.reasons]);\n\n const statements = (Array.isArray(input.statements) ? input.statements : [input]) as Record<string, unknown>[];\n const cards = statements.filter((s) => isObj(s) && s.typ === \"AAP-ShareCard/v1\");\n if (cards.length === 0) return fail([R.no_share_card_statement]);\n\n const errors: string[] = [];\n const lines: RenderedLine[] = [];\n cards.forEach((card, ci) => {\n errors.push(...unknownKeys(card, STATEMENT_KEYS, `card${ci}`));\n const raw = Array.isArray(card.lines) ? (card.lines as unknown[]) : [];\n raw.forEach((l, i) => {\n const where = `card${ci}.lines[${i}]`;\n if (!isObj(l)) return void errors.push(`${R.line_malformed}:${where}`);\n errors.push(...unknownKeys(l, STATEMENT_LINE_KEYS, where));\n if (l.class !== \"measured\" && l.class !== \"outcome\" && l.class !== \"verdict\") {\n return void errors.push(`${R.line_class_not_allowed}:${where}`);\n }\n if (typeof l.text !== \"string\" || l.text.length === 0) return void errors.push(`${R.line_malformed}:${where}`);\n const out: RenderedLine = { class: l.class, text: l.text };\n if (l.class === \"verdict\") {\n const c = l.coverage;\n if (!isObj(c)) return void errors.push(`${R.line_malformed}:${where}.coverage`);\n errors.push(...unknownKeys(c, COVERAGE_KEYS, `${where}.coverage`));\n out.coverage = { judged: c.judged as number, total: c.total as number };\n } else if (l.coverage !== undefined && l.coverage !== null) {\n errors.push(`${R.identifying_field}:${where}.coverage`);\n }\n // `revert` is never inferred from display text (\"Accepted, no revert in 7 days\" is a clean outcome);\n // it is set only on the line derived from signed AAP-Outcome/v1 values below, or a numeric `revert` kind.\n lines.push(out);\n });\n });\n\n if (surface === \"period_card\") {\n const outcomes = statements.filter((s) => isObj(s) && s.typ === \"AAP-Outcome/v1\");\n if (outcomes.length === 0) errors.push(R.period_card_without_outcomes);\n else {\n const kinds = outcomes.map(outcomeKind);\n if (kinds.includes(null)) errors.push(`${R.line_malformed}:outcome`);\n else {\n const reverted = kinds.filter((k) => k === \"reverted\").length;\n // Always present on a period card, including \"0 of N\": silence about reverts is not allowed.\n lines.push({ class: \"outcome\", text: `${reverted} of ${kinds.length} changes reverted`, revert: true });\n }\n }\n }\n if (errors.length > 0) return fail(errors);\n return finish(surface, lines);\n}\n\nasync function renderFromNumericCard(card: unknown, surface: RenderSurface, publicKey: string | Uint8Array): Promise<RenderLinesResult> {\n // Shape first: identifying fields get their own named reason.\n const shape = validateShareCardShape(card);\n if (shape.length > 0) {\n const ident = shape.some((e) => /identifying field/.test(e));\n return fail([ident ? R.identifying_field : R.not_verifiable, ...shape]);\n }\n const v = await verifyShareCard(card, { publicKey });\n if (!v.valid) return fail([R.not_verifiable, ...v.errors]);\n const lines: RenderedLine[] = v.lines.map((l) =>\n l.kind === \"revert\"\n ? { class: \"outcome\", text: `${l.label}: ${l.value}`, revert: true }\n : { class: \"measured\", text: `${l.label}: ${l.value}` },\n );\n return finish(surface, lines);\n}\n\n/**\n * Derive the lines to show for a card from signed input. See the module doc\n * for accepted inputs and the flag. Never throws.\n */\nexport async function renderLines(input: unknown, opts: RenderLinesOptions = {}): Promise<RenderLinesResult> {\n try {\n if (!renderLinesEnabled(opts)) return fail([R.render_lines_disabled]);\n const surface = opts.surface ?? \"share_card\";\n if (surface !== \"share_card\" && surface !== \"period_card\") return fail([R.unknown_surface]);\n if (!isObj(input)) return fail([R.not_verifiable]);\n // An estimate has no input path: reject one handed in alongside, then render nothing from it.\n if (\"estimate\" in input || \"savings\" in input) {\n const d = shouldRenderEstimate(input.estimate ?? input.savings, surface);\n return fail([R.estimate_not_renderable, ...d.reasons]);\n }\n if (\"card_id\" in input) {\n if (opts.publicKey === undefined) return fail([R.missing_key]);\n return await renderFromNumericCard(input, surface, opts.publicKey);\n }\n if (!opts.jwks) return fail([R.missing_key]);\n return await renderFromStatements(input, surface, opts.jwks);\n } catch {\n return fail([R.not_verifiable]);\n }\n}\n"]}
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import { a as RecordJwks, r as LintViolation } from './claim-lint-CVITIRcU.cjs';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Card line renderer (MNE-9026, criterion K4.3/K4.4, design C5-R6).
|
|
5
|
-
*
|
|
6
|
-
* `renderLines` turns signed input into the lines a share card or period card
|
|
7
|
-
* may show, and nothing else. Every line is derived from a statement that
|
|
8
|
-
* verified against the published key: there is no parameter that accepts a
|
|
9
|
-
* typed number, a string or an estimate. Only measured, outcome and
|
|
10
|
-
* verdict-with-coverage lines come out. Fail closed: on any problem `lines` is
|
|
11
|
-
* empty, so a renderer that prints `result.lines` prints nothing.
|
|
12
|
-
*
|
|
13
|
-
* FLAG-GATED. This module is NOT re-exported from the package index. It is
|
|
14
|
-
* reachable only via the `@mnemom/aip-verifier/render-lines` subpath, and even
|
|
15
|
-
* there it returns `render_lines_disabled` (no lines) unless the caller passes
|
|
16
|
-
* `opts.enabled: true` or the environment sets `AIP_RENDER_LINES=1`. Default
|
|
17
|
-
* behavior and the existing published API are unchanged.
|
|
18
|
-
*
|
|
19
|
-
* Accepted inputs (`opts` says which key verifies them):
|
|
20
|
-
* 1. A record bundle or a single `AAP-ShareCard/v1` record statement
|
|
21
|
-
* (`{class, text, coverage}` lines), verified with `opts.jwks` through the
|
|
22
|
-
* existing `verify`. A period card additionally needs signed
|
|
23
|
-
* `AAP-Outcome/v1` statements in the bundle: its revert line is derived
|
|
24
|
-
* from them, never typed.
|
|
25
|
-
* 2. The MNE-9022 numeric card (`card_id`, `{id, kind, label, value}` lines),
|
|
26
|
-
* verified with `opts.publicKey` through the existing `verifyShareCard`.
|
|
27
|
-
*
|
|
28
|
-
* Every rendered line is re-checked with `lintRendering` on the chosen
|
|
29
|
-
* surface; any violation makes the whole render fail.
|
|
30
|
-
*/
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* One line the CLI (or any consumer) may print, verbatim. Contract:
|
|
34
|
-
* - `class` is exactly one of `measured`, `outcome`, `verdict`. No estimate,
|
|
35
|
-
* benchmark or savings class can be produced.
|
|
36
|
-
* - `text` is display text, already claim-lint clean. Print it as is; never
|
|
37
|
-
* append a figure, tool name, repo, org or person.
|
|
38
|
-
* - `coverage` is present on every `verdict` line ("judged of total") and
|
|
39
|
-
* absent on the other classes.
|
|
40
|
-
* - `revert` is true on the line that reports reverts. A period card always
|
|
41
|
-
* contains at least one such line.
|
|
42
|
-
* Structurally assignable to claim-lint's `RenderedLine`.
|
|
43
|
-
*/
|
|
44
|
-
interface RenderedLine {
|
|
45
|
-
class: "measured" | "outcome" | "verdict";
|
|
46
|
-
text: string;
|
|
47
|
-
coverage?: {
|
|
48
|
-
judged: number;
|
|
49
|
-
total: number;
|
|
50
|
-
};
|
|
51
|
-
revert?: true;
|
|
52
|
-
}
|
|
53
|
-
type RenderSurface = "share_card" | "period_card";
|
|
54
|
-
interface RenderLinesOptions {
|
|
55
|
-
/** Which card is being drawn. Default `share_card`. */
|
|
56
|
-
surface?: RenderSurface;
|
|
57
|
-
/** Explicit flag. Also on when `AIP_RENDER_LINES=1`. */
|
|
58
|
-
enabled?: boolean;
|
|
59
|
-
/** Published JWKS, to verify record statements. */
|
|
60
|
-
jwks?: RecordJwks;
|
|
61
|
-
/** Trusted Ed25519 public key (hex or bytes), to verify a numeric card. */
|
|
62
|
-
publicKey?: string | Uint8Array;
|
|
63
|
-
}
|
|
64
|
-
declare const RENDER_LINES_REASONS: {
|
|
65
|
-
readonly render_lines_disabled: "render_lines_disabled";
|
|
66
|
-
readonly unknown_surface: "unknown_surface";
|
|
67
|
-
readonly not_verifiable: "not_verifiable";
|
|
68
|
-
readonly missing_key: "missing_key";
|
|
69
|
-
readonly no_share_card_statement: "no_share_card_statement";
|
|
70
|
-
readonly identifying_field: "identifying_field";
|
|
71
|
-
readonly line_class_not_allowed: "line_class_not_allowed";
|
|
72
|
-
readonly line_malformed: "line_malformed";
|
|
73
|
-
readonly no_lines: "no_lines";
|
|
74
|
-
readonly period_card_without_outcomes: "period_card_without_outcomes";
|
|
75
|
-
readonly period_card_without_revert_line: "period_card_without_revert_line";
|
|
76
|
-
readonly estimate_not_renderable: "estimate_not_renderable";
|
|
77
|
-
readonly lint_failed: "lint_failed";
|
|
78
|
-
};
|
|
79
|
-
interface RenderLinesResult {
|
|
80
|
-
ok: boolean;
|
|
81
|
-
/** Empty unless `ok`. */
|
|
82
|
-
lines: RenderedLine[];
|
|
83
|
-
/** Stable reason strings; prefixed detail follows a colon. */
|
|
84
|
-
reasons: string[];
|
|
85
|
-
/** claim-lint violations when `lint_failed`. */
|
|
86
|
-
violations?: LintViolation[];
|
|
87
|
-
}
|
|
88
|
-
/** Flag read; safe where `process` does not exist (Workers, browsers). */
|
|
89
|
-
declare function renderLinesEnabled(opts?: RenderLinesOptions): boolean;
|
|
90
|
-
/**
|
|
91
|
-
* Derive the lines to show for a card from signed input. See the module doc
|
|
92
|
-
* for accepted inputs and the flag. Never throws.
|
|
93
|
-
*/
|
|
94
|
-
declare function renderLines(input: unknown, opts?: RenderLinesOptions): Promise<RenderLinesResult>;
|
|
95
|
-
|
|
96
|
-
export { RENDER_LINES_REASONS, type RenderLinesOptions, type RenderLinesResult, type RenderSurface, type RenderedLine, renderLines, renderLinesEnabled };
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import { a as RecordJwks, r as LintViolation } from './claim-lint-CVITIRcU.js';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Card line renderer (MNE-9026, criterion K4.3/K4.4, design C5-R6).
|
|
5
|
-
*
|
|
6
|
-
* `renderLines` turns signed input into the lines a share card or period card
|
|
7
|
-
* may show, and nothing else. Every line is derived from a statement that
|
|
8
|
-
* verified against the published key: there is no parameter that accepts a
|
|
9
|
-
* typed number, a string or an estimate. Only measured, outcome and
|
|
10
|
-
* verdict-with-coverage lines come out. Fail closed: on any problem `lines` is
|
|
11
|
-
* empty, so a renderer that prints `result.lines` prints nothing.
|
|
12
|
-
*
|
|
13
|
-
* FLAG-GATED. This module is NOT re-exported from the package index. It is
|
|
14
|
-
* reachable only via the `@mnemom/aip-verifier/render-lines` subpath, and even
|
|
15
|
-
* there it returns `render_lines_disabled` (no lines) unless the caller passes
|
|
16
|
-
* `opts.enabled: true` or the environment sets `AIP_RENDER_LINES=1`. Default
|
|
17
|
-
* behavior and the existing published API are unchanged.
|
|
18
|
-
*
|
|
19
|
-
* Accepted inputs (`opts` says which key verifies them):
|
|
20
|
-
* 1. A record bundle or a single `AAP-ShareCard/v1` record statement
|
|
21
|
-
* (`{class, text, coverage}` lines), verified with `opts.jwks` through the
|
|
22
|
-
* existing `verify`. A period card additionally needs signed
|
|
23
|
-
* `AAP-Outcome/v1` statements in the bundle: its revert line is derived
|
|
24
|
-
* from them, never typed.
|
|
25
|
-
* 2. The MNE-9022 numeric card (`card_id`, `{id, kind, label, value}` lines),
|
|
26
|
-
* verified with `opts.publicKey` through the existing `verifyShareCard`.
|
|
27
|
-
*
|
|
28
|
-
* Every rendered line is re-checked with `lintRendering` on the chosen
|
|
29
|
-
* surface; any violation makes the whole render fail.
|
|
30
|
-
*/
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* One line the CLI (or any consumer) may print, verbatim. Contract:
|
|
34
|
-
* - `class` is exactly one of `measured`, `outcome`, `verdict`. No estimate,
|
|
35
|
-
* benchmark or savings class can be produced.
|
|
36
|
-
* - `text` is display text, already claim-lint clean. Print it as is; never
|
|
37
|
-
* append a figure, tool name, repo, org or person.
|
|
38
|
-
* - `coverage` is present on every `verdict` line ("judged of total") and
|
|
39
|
-
* absent on the other classes.
|
|
40
|
-
* - `revert` is true on the line that reports reverts. A period card always
|
|
41
|
-
* contains at least one such line.
|
|
42
|
-
* Structurally assignable to claim-lint's `RenderedLine`.
|
|
43
|
-
*/
|
|
44
|
-
interface RenderedLine {
|
|
45
|
-
class: "measured" | "outcome" | "verdict";
|
|
46
|
-
text: string;
|
|
47
|
-
coverage?: {
|
|
48
|
-
judged: number;
|
|
49
|
-
total: number;
|
|
50
|
-
};
|
|
51
|
-
revert?: true;
|
|
52
|
-
}
|
|
53
|
-
type RenderSurface = "share_card" | "period_card";
|
|
54
|
-
interface RenderLinesOptions {
|
|
55
|
-
/** Which card is being drawn. Default `share_card`. */
|
|
56
|
-
surface?: RenderSurface;
|
|
57
|
-
/** Explicit flag. Also on when `AIP_RENDER_LINES=1`. */
|
|
58
|
-
enabled?: boolean;
|
|
59
|
-
/** Published JWKS, to verify record statements. */
|
|
60
|
-
jwks?: RecordJwks;
|
|
61
|
-
/** Trusted Ed25519 public key (hex or bytes), to verify a numeric card. */
|
|
62
|
-
publicKey?: string | Uint8Array;
|
|
63
|
-
}
|
|
64
|
-
declare const RENDER_LINES_REASONS: {
|
|
65
|
-
readonly render_lines_disabled: "render_lines_disabled";
|
|
66
|
-
readonly unknown_surface: "unknown_surface";
|
|
67
|
-
readonly not_verifiable: "not_verifiable";
|
|
68
|
-
readonly missing_key: "missing_key";
|
|
69
|
-
readonly no_share_card_statement: "no_share_card_statement";
|
|
70
|
-
readonly identifying_field: "identifying_field";
|
|
71
|
-
readonly line_class_not_allowed: "line_class_not_allowed";
|
|
72
|
-
readonly line_malformed: "line_malformed";
|
|
73
|
-
readonly no_lines: "no_lines";
|
|
74
|
-
readonly period_card_without_outcomes: "period_card_without_outcomes";
|
|
75
|
-
readonly period_card_without_revert_line: "period_card_without_revert_line";
|
|
76
|
-
readonly estimate_not_renderable: "estimate_not_renderable";
|
|
77
|
-
readonly lint_failed: "lint_failed";
|
|
78
|
-
};
|
|
79
|
-
interface RenderLinesResult {
|
|
80
|
-
ok: boolean;
|
|
81
|
-
/** Empty unless `ok`. */
|
|
82
|
-
lines: RenderedLine[];
|
|
83
|
-
/** Stable reason strings; prefixed detail follows a colon. */
|
|
84
|
-
reasons: string[];
|
|
85
|
-
/** claim-lint violations when `lint_failed`. */
|
|
86
|
-
violations?: LintViolation[];
|
|
87
|
-
}
|
|
88
|
-
/** Flag read; safe where `process` does not exist (Workers, browsers). */
|
|
89
|
-
declare function renderLinesEnabled(opts?: RenderLinesOptions): boolean;
|
|
90
|
-
/**
|
|
91
|
-
* Derive the lines to show for a card from signed input. See the module doc
|
|
92
|
-
* for accepted inputs and the flag. Never throws.
|
|
93
|
-
*/
|
|
94
|
-
declare function renderLines(input: unknown, opts?: RenderLinesOptions): Promise<RenderLinesResult>;
|
|
95
|
-
|
|
96
|
-
export { RENDER_LINES_REASONS, type RenderLinesOptions, type RenderLinesResult, type RenderSurface, type RenderedLine, renderLines, renderLinesEnabled };
|