Skip to content

Docs: tamper example, quickstart output, unknown-source edge test - #6

Closed
AshSgDe29071999 wants to merge 1 commit into
AgentPostmortem:mainfrom
AshSgDe29071999:docs/tamper-quickstart-edge-tests
Closed

Docs: tamper example, quickstart output, unknown-source edge test#6
AshSgDe29071999 wants to merge 1 commit into
AgentPostmortem:mainfrom
AshSgDe29071999:docs/tamper-quickstart-edge-tests

Conversation

@AshSgDe29071999

Copy link
Copy Markdown

Summary

Addresses the first-run and “what does failure look like” gaps, plus one real verifier edge case.

Fixes #4 — what a tampered receipt looks like

  • New examples/tamper.py builds a receipt then walks each failure mode from tests/test_tamper.py:
    1. sources — source content edited after signing
    2. grounding — citation swapped to an unknown source id
    3. merkle — merkle root edited by hand
    4. re-sign — payload edited and re-signed with a different key (signature passes; signer_pin catches it)
  • Representative output pasted into the README under What failure looks like.

Fixes #1 — quickstart

  • Quickstart now has install, the minimal snippet, and an expected verification output block so copy-paste is self-checking.

Fixes #2 — untested edge case

  • verify_receipt(..., source_contents={..., "never-retrieved": "..."}) must fail the sources check with an explicit unknown source detail rather than being silently ignored.
  • Covered in tests/test_verifier.py::test_unknown_source_id_in_contents_fails_sources_check.

Design choices

  • Tamper demo mirrors test fixtures (same SOURCES/ANSWER as conftest.py) so printed checks match what pytest already asserts.
  • Re-sign case is split into 4a (no pin → valid) and 4b (pin original key → fail) because that is the non-obvious threat-model point.
  • Edge test targets the API contract of verify_sources, not a trivial empty-input fluff case.

Test plan

  • pytest -q
  • python examples/tamper.py
  • ruff check .

Walk each verification failure mode in examples/tamper.py (sources,
grounding, merkle, re-sign with a different key) and paste representative
output into the README. Improve the quickstart with install + expected
verification output. Cover the untested case where source_contents maps an
id the receipt never recorded.

Fixes #1
Fixes #2
Fixes #4
@AshSgDe29071999 AshSgDe29071999 closed this by deleting the head repository Aug 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant