Skip to content

Milestone 11 — Evidence provenance

State: complete and merged. Implementation PR #33 was reviewed at head 29dbdc7d881a86a912bd9fb5886af5c70a1bfa8e against main at 233678767bed6dde7deb10b30eb547c0509dfd31 and merged as de4d0a21641d541c035e25f4b4025af8be35c874.

Scope and implementation

Baseline: origin/main at 233678767bed6dde7deb10b30eb547c0509dfd31. This change adds the version 2 typed core evidence envelope, a project-authorized provenance projection API, generated TypeScript types, a task inspector tab with task/run/source/revision filters and cursor pagination, a minimized Harness² fixture contract, a bounded artifact checksum reconciliation action, and durable late gateway usage reconciliation. Source rows remain authoritative; usage corrections append new ledger events. See docs/integrations/evidence-plane.md for the source matrix, contracts, retention and backup guidance.

The API omits prompt/completion content, raw webhook JSON, tool arguments/results, and artifact bytes. Gateway billed spend, estimated spend, and unknown usage are labeled separately; provider-reported spend remains unknown unless supplied by a source. Failed webhook receipts are marked retryable and artifact bytes remain checksum_unverified until a member runs the integrity check. The integrity action reads at most 64 MiB, writes no external effect, and appends a deduplicated domain audit event for a repeated identical result. Late gateway usage reports are operator/admin-only, explicitly labeled as unverified submissions, and use durable source-observation IDs, bounded retries (12 attempts), and append-only usage_reconciled ledger events protected against concurrent duplicates. A worker retries due receipts every 30 seconds in batches of at most 100. The additive migration is 8c7e2d1f4a90.

Verification evidence

Command Result
uv run ruff check apps/api tests scripts Passed.
pnpm lint && pnpm typecheck Passed; strict mypy reported 53 source files with no issues.
PYTHONPATH=apps/api uv run pytest -q tests/test_evidence_plane.py tests/test_contracts.py tests/test_api_auth.py 16 passed, one upstream Starlette/httpx deprecation warning.
TEST_DATABASE_URL=postgresql+asyncpg://postgres@127.0.0.1:56448/harnessa_m11_test TEST_REDIS_URL=redis://127.0.0.1:56449/7 uv run pytest -q tests/integration/test_evidence_plane.py -m integration 3 passed on disposable PostgreSQL 16.13 and Redis 8.10.2. Covered source joins, project isolation and pre-return authorization recheck, omitted prompt, unknown/partial usage, operator-only import, worker retry to unique match, concurrent duplicate replay, 106 specification revisions across cursor pages, latest-run staleness beyond 100 runs, concurrent artifact integrity checks with a single audit event, and sparse revision pagination across 100+ nonmatches.
PYTHONPATH=apps/api UV_OFFLINE=1 uv run --offline pytest -q tests/test_evidence_plane.py 6 passed. Includes malformed cursor handling and POSIX/Windows traversal rejection for Harness² fixture paths.
TEST_DATABASE_URL=postgresql+asyncpg://postgres@127.0.0.1:56448/harnessa_m11_test TEST_REDIS_URL=redis://127.0.0.1:56449/7 pnpm test Passed: 254 unit tests (one skipped), 65 integration tests, 29 web tests, 2 cloud portal tests, marketing static build, and the 85% coverage gate (aggregate 85.58% lines / 85.45% statements).
uv run --with-requirements requirements-docs.txt mkdocs build --strict --site-dir /tmp/harnessa-m11-docs Passed; Evidence provenance and Milestone 11 were added to the docs navigation.
Required GitHub checks on final head Local CI passed on push run 39959059314 and pull-request run 39959070576; CodeQL passed for Python and JavaScript/TypeScript; Documentation build passed.
Independent exact-head review Comment-only review 5628685588 reviewed 29dbdc7d881a86a912bd9fb5886af5c70a1bfa8e against the recorded base and found no actionable findings. All review threads are resolved. No approval was submitted; live Protect main requires zero approvals and retains Local CI, CodeQL and review-thread resolution, with bypass disabled.
Merge evidence PR #33 merged at 2026-10-23T13:20:12Z; merge commit de4d0a21641d541c035e25f4b4025af8be35c874 is the refreshed origin/main head.
Browser Harness task-inspector acceptance Rendered task inspector shows source/revision/hash and distinct unknown spend labels; artifact integrity action changed checksum_unverified to verified and displayed the audit event.
Alembic uv run alembic heads reports one head, 8c7e2d1f4a90; the disposable PostgreSQL schema was freshly migrated and an explicit downgrade/upgrade cycle returned to the same head.

OpenAPI TypeScript generation used the local FastAPI app schema to capture the final contract: PYTHONPATH=apps/api uv run python -c 'import json; from harnessa.main import app; open("/tmp/harnessa-openapi-m11-final.json","w").write(json.dumps(app.openapi()))' followed by pnpm --filter @harnessa/contracts exec openapi-typescript /tmp/harnessa-openapi-m11-final.json -o src/generated.ts.

Remaining acceptance work

  • Existing M10 tests cover duplicate webhook replay; Harness² remains a deterministic trust-labeled contract until a real importer is approved in its later milestone.
  • Proposals M11-R1 through M11-R11 were accepted and fixed: duplicate-import concurrency, scheduled retry, unverified-source labeling, docs navigation, downgrade after persisted corrections, child-row cursor pagination, typed Harness² evidence fields, Windows traversal rejection, authorization revalidation, the duplicate child-pagination report, and partial-token certainty. M11-R12 was rejected with evidence: Python binascii.Error is a ValueError, already caught by _cursor; the malformed single-character cursor regression returns HTTP 422. M11-R13 was accepted and fixed by querying the latest run independently of the 100-row evidence page; an integration fixture with 106 runs confirms the current GitHub object is not marked stale against an older run. M11-R14 was accepted and fixed by locking the scoped artifact row before checking for an existing integrity audit; two concurrent checks return the same event ID and leave exactly one audit row. Every proposal received one maintainer response and all threads were resolved.
  • The independent final-head review of 29dbdc7d881a86a912bd9fb5886af5c70a1bfa8e found no actionable findings. Required checks passed, and PR #33 merged under the live repository rules. Prompt 11 is archived unchanged; M12 is the next active milestone.

Migration, rollback, and external setup

Migration 8c7e2d1f4a90 adds the usage import receipt table, provider-reported spend column, and usage_reconciled ledger event type. Its downgrade keeps the ledger check constraint compatible with already-persisted usage_reconciled events while removing the new receipt table and observation/provider columns. The downgrade/upgrade cycle is verified against disposable PostgreSQL 16.13, including after a persisted correction event. For rollback, stop usage import writers, export or retain gateway import receipts, then run uv run alembic downgrade -1 before reverting code; this removes import receipts. Artifact integrity checks are read-only apart from their domain audit event. Live provider setup is not required for the deterministic fixture path; no real provider credential, GitHub App, or paid request was used. No secrets were added to this report.