Skip to content

API Reference parrot.e2e.evidence

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot.e2e.evidence

View source

Capture verifiable source/environment identity for E2E evidence (FEAT-581, M2).

capture_identity() is the single entry point every caller (the M3 runner, before and after execution; the M2 evidence verifier landing in TASK-3523) uses to snapshot exactly what a run was validated against, per spec §2 "Evidence Identity and Gate Evaluation":

Before and after execution, hash a canonical sorted manifest of tracked
files plus nonignored untracked files, including modes and relevant
symlink targets. Exclude only declared generated artifacts
(``artifacts/logs/e2e/``, this feature's run evidence/candidates, pytest
caches, bytecode) and SDD task bookkeeping (``sdd/tasks/``,
``sdd/ledger/``). Do not exclude arbitrary source, templates, specs,
plans or dependencies. Hash the plan/spec separately. Any relevant
mutation invalidates the run. Environment fingerprint includes
interpreter version/path, installed distribution versions, ``uv.lock``,
selected model, target/tool versions, nonsecret fixture configuration
and opt-in settings; exclude credential values.

This module lists tracked/untracked files via async Git subprocesses (never subprocess.run/Popen blocking the event loop) and hashes their content with the standard library. It has no target/provider imports of its own (target adapters land in M4) and never persists or logs a credential value — only whether an opt-in secret is configured, never its content.

Manifest entries never carry raw file bytes, only path, mode (a git-style octal mode: 100644 regular, 100755 executable, 120000 symlink) and a content marker (a sha256:<hex> digest for regular files, or symlink:<target> recording the raw readlink() target string — never the dereferenced target's content, since a dangling or escaping symlink target must still be captured as identity data without resolving it).

TargetConfig.options is deliberately excluded from the environment fingerprint: per-adapter option-key allow-listing is deferred to M4 (see parrot.e2e.plan module docstring), so this module cannot yet tell a nonsecret fixture toggle from a credential-shaped value placed there ahead of that validation. Only each target's kind/profile (fixed, schema-validated enums) are folded into the fingerprint as a target/tool identity signal.

verify_evidence() (TASK-3523) is this module's read-only counterpart: it validates a previously persisted :class:~parrot.e2e.models.E2EVerdict against the plan's declared coverage, its own artifact hashes and a freshly recomputed :class:SourceIdentity, per spec §2 "Evidence Identity and Gate Evaluation" and "New Public Interfaces". It never executes pytest or a target adapter itself -- those are the M3 runner's (parrot.e2e.runner, not yet implemented) responsibility, including writing sdd/state/<feature_id>/e2e/latest.json (an atomically-written pointer, {"run_id": ...}, updated only once teardown/cleanup for that run is verified complete) and sdd/state/<feature_id>/e2e/runs/<run_id>/e2e-verdict.json. Both paths already fall inside capture_identity's own excluded sdd/state/<feature_id>/e2e/ manifest prefix, so persisting or reading evidence never perturbs the very identity it is validated against.

Two distinct failure shapes are used deliberately: a normal, absent, or objectively-failed/blocked run returns a :class:VerificationResult (MISSING/FAIL/BLOCKED) -- "MISSING is synthesized by verification, not a fabricated successful run" -- while a malformed, tampered or stale evidence blob that cannot be trusted at all raises :class:~parrot.e2e.errors.E2EEvidenceError ("fails closed"), matching that exception class's own documented contract.

Function capture_identity

Hash the normative source manifest and nonsecret environment inputs.

capture_identity(plan: E2EPlan, *, worktree: Path) -> SourceIdentity

Parameter Type Default Description
plan E2EPlan The already-validated :class:E2EPlan (e.g. from :func:parrot.e2e.plan.load_plan) whose feature_id scopes the excluded run-evidence directory, whose spec_path is hashed separately, and whose content (including budget.model) is hashed as plan_sha256.
worktree Path Candidate worktree root; must already exist and be a Git checkout with at least one commit.

Returns: SourceIdentity — A fully validated :class:SourceIdentity snapshot.

Raises:

  • E2EConfigError — If worktree does not exist or is not a directory, the git executable is unavailable, any Git command fails (e.g. worktree is not a Git repository, or has no commits), plan.spec_path escapes worktree or does not resolve to a file, or a manifest-listed path vanishes or becomes unreadable while being hashed.

Function verify_evidence

Validate immutable run artifacts and current implementation identity.

Locates the plan's feature-scoped evidence pointer, loads and schema- validates the persisted :class:E2EVerdict it names, verifies every referenced artifact's hash, confirms the run's own before/after source identity never changed mid-execution, recomputes the current :class:SourceIdentity via :func:capture_identity and requires it to match the recorded one (spec §2: "accept only matching commit or content-identical descendant" -- content hashes, not the commit SHA itself, gate acceptance), then evaluates exact node coverage, required per-node pytest phase outcomes and target/runner cleanup.

verify_evidence(plan_path: Path, *, worktree: Path) -> VerificationResult

Parameter Type Default Description
plan_path Path Path to the e2e-plan.md document (see :func:parrot.e2e.plan.load_plan); its resolved location must lie inside worktree.
worktree Path Candidate worktree root; must already exist and be a Git checkout with at least one commit.

Returns: VerificationResult — class:VerificationResult: * PASS -- policy none (explicit exemption, no execution fabricated), or every required codified node passed with a clean setup/call/teardown and verified cleanup. * MISSING -- no evidence pointer/verdict found yet, or the recorded run was interrupted (SIGINT/SIGTERM) and therefore cannot be validated at all. * BLOCKED -- zero nodes were collected, or every collected node was merely skipped (a no-test/all-skipped run is never a PASS). * FAIL -- a required node did not pass (including a skip/xfail/ xpass/missing outcome or a failed setup/call/teardown phase), or recorded target/runner cleanup was not verified complete.

Raises:

  • E2EConfigError — If worktree/plan_path cannot be resolved, or the plan itself fails :func:parrot.e2e.plan.load_plan validation (propagated unchanged).
  • E2EEvidenceError — If the located evidence is malformed (invalid JSON, failed :class:E2EVerdict schema validation, an unsafe pointer run_id, a feature_id mismatch), tampered (an artifact's content no longer matches its recorded hash, or selected_node_ids/collected_node_ids disagree with the plan's own current declared/selected node IDs), records a source identity mutation during its own execution (before != after), or its recorded identity no longer matches the current implementation (stale: source, spec, plan or environment changed since the run) -- this "fails closed" per spec §2.

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally