Verifiable Claim Gate
Citations alone do not stop an LLM from misreading (in thousands) as millions, flipping an accounting loss (15.0) into a profit, or quoting FY2023 numbers under an FY2025 label. pdf_verify_claim gates claims against 1 to 12 canonical elementIds and emits a signed HMAC-SHA256 attestation that external harnesses can enforce before output reaches a user.
npx -y pdf-decompiler verify report.pdf \
--claim "FY2025 consolidated revenue was $42.5 million" \
--elements table:12:1 \
--provider auto
Stage 1: Local deterministic gate (0 to 1 ms, offline)
Stage 1 runs in-process on CPU with zero API tokens and zero network calls. Before checking numbers, it resolves every cited elementId against the exact documentId and extractionFingerprint. Missing, stale, or cross-generation IDs fail immediately with stale_reference.
Table unit scaling & EPS exemption
detectSourceScale() inspects tableContext.units, table titles, headers, and body lines for notes such as (in thousands), (in millions), or (in billions).
Rows matching per-share, EPS, diluted/basic share metrics, ratios, or margins are automatically exempted from multiplying by the table scale so per-share figures like $2.14 are never inflated to millions.
Accounting negatives & currencies
Parenthesized figures like (15.0) or ($42.5 million) parse as negative values. Claiming +$15.0 million triggers sign_mismatch, while explicit loss cues (loss, deficit, decline, outflow) match negative source quantities accurately.
Currency prefixes ($/USD, EUR, GBP, JPY) are normalized and checked for cross-currency contradictions.
Temporal grounding & negation polarity
extractYears() filters out currency and unit numbers and verifies that years referenced in the claim (such as FY2025 or 2026) exist in the cited source. Negation cues around shared entities catch affirmative/negative reversals.
Derived arithmetic verification
When a claim quantity is not verbatim in the table, Stage 1 checks pairwise derived relations across source numbers: sum, difference, ratio, share_percent, and pct_change.
Hard contradictions short-circuit as contradicted in 0 to 1 ms without calling Stage 2.
Stage 2: Opt-in semantic decision models
Arithmetic and unit checks cannot tell whether an agent cited the Cloud Services segment row while claiming Consolidated revenue, or swapped two entities in prose. Stage 2 evaluates semantic alignment when explicitly enabled.
provider: "auto" stays strictly offline deterministic even if API keys exist in the environment. Remote Stage 2 inference runs only when PDF_DECOMPILER_VERIFY_ALLOW_REMOTE=1 (or --allow-remote-verify) is set, or when a remote provider is explicitly passed.
| Provider value | Env key | Behavior |
|---|---|---|
"auto" (default) |
None required | Runs Stage 1 locally. Upgrades to Stage 2 only if PDF_DECOMPILER_VERIFY_ALLOW_REMOTE=1 (or --allow-remote-verify) is set and a key is present. |
"deterministic" |
None | Strictly Stage 1 local checks; never sends data off-machine. |
"jev" |
TYPESAFE_API_KEY |
TypeSafe AI Jev (jev-latest) evaluating 4 parallel calibrated noul probabilities (claim_supported, source_contradicts, unit_and_period_accurate, scope_accurate) in ~153 to 209 ms. |
"gemini-decisions" |
GEMINI_API_KEY |
Pluggable Gemini decision adapter for Stage 2 semantic scoring. |
"openai-compat" |
OPENAI_API_KEY |
OpenAI-compatible endpoint adapter for custom or self-hosted decision models. |
Cryptographic attestation, Stop Hook, and CLI gate
Every pdf_verify_claim result includes a domain-separated HMAC-SHA256 attestation object binding claimSha256, verdict ("supported", "unsubstantiated", or "contradicted"), documentId, extractionFingerprint, elementIds, sourceDigests, keyId, and issuedAt.
1. Verify programmatically with pdf-decompiler/verify
import { verifyAttestation } from 'pdf-decompiler/verify';
const check = verifyAttestation(result.attestation, process.env.PDF_DECOMPILER_ATTESTATION_KEY, {
requireSupported: true,
claim: 'FY2025 consolidated revenue was $42.5 million',
maxAgeMs: 24 * 60 * 60 * 1000,
});
if (!check.valid) {
throw new Error(`Claim rejected: ${check.reason}`);
}
2. Enforce in agent harnesses with the Stop Hook
Pair examples/hooks/verify-claims-hook.mjs with Claude Code, Codex, or Cursor stop hooks. When PDF_DECOMPILER_REQUIRE_ATTESTATION=1 is set, any response containing PDF citations (block:P:E, table:P:E, page:N, doc_...) without a valid, claim-matched, supported HMAC attestation fails closed (exit code 2), forcing the agent to verify or retract the claim.
3. Enforce in shell scripts or CI with pdf-decompiler gate
PDF_DECOMPILER_ATTESTATION_KEY="$YOUR_SECRET" \
npx -y pdf-decompiler gate \
--input verification-result.json \
--claim "FY2025 consolidated revenue was $42.5 million" \
--max-age-ms 3600000
gate exits with status 0 only when all attestations are valid, unexpired, claim-matched, and verdict === "supported"; otherwise it prints diagnostics and exits with 2.
Claim verification evaluations
A 20-claim table stress test found two false supports and six false contradictions in the offline check. Inspect the row, year and scale in the source. Signed verdicts attest to the result the verifier returned.
A 24-claim FinDVer diagnostic found nine false acceptances with the benchmark's evidence already supplied. Check the specific arithmetic operands and years before relying on a derived result.
The earlier two-stage development suite below correctly classified all 12 controls, including seven that reached the optional Jev reviewer.
| Category | Traps tested | Stage resolved | Result |
|---|---|---|---|
| Positive controls (4 cases) | Exact revenue + year, (in millions) table scale, accounting (15.0) loss, derived 25% growth |
Stage 1 + Stage 2 (jev-1.14.0) |
4 / 4 PASS |
| Local short-circuits (5 cases) | Wrong year, wrong unit (billions vs millions, thousands vs millions), sign flip (+$15M vs (15.0)), invented 2026 forecast |
Stage 1 deterministic (0 to 1 ms, 0 tokens) | 5 / 5 PASS |
| Semantic traps (3 cases) | Segment cited as consolidated, miscomputed ratio (50% vs 25%), swapped entity (Enterprise vs Cloud Services) | Stage 2 (jev-1.14.0, 156 to 157 ms) |
3 / 3 PASS |