Skip to content

Add wait_for_review poll hooks, bounded intervals, and actionable outcome provenance - #136

Open
juggernaut7777 wants to merge 3 commits into
prooflinedev:mainfrom
juggernaut7777:feat/wait-observability-and-findings
Open

juggernaut7777 wants to merge 3 commits into
prooflinedev:mainfrom
juggernaut7777:feat/wait-observability-and-findings

Conversation

@juggernaut7777

@juggernaut7777 juggernaut7777 commented Nov 28, 2026 •

Copy link
Copy Markdown

What this adds

wait_for_review is the call most people wrap in CI or a worker, but today it only returns at the end and hides most of what it learned. This PR makes the wait observable and the outcome actionable.

1. Observable, bounded polling (sync and async)

  • on_poll(detail) runs after every non-terminal poll, before the client sleeps, so a caller can stream status or cancel early. The async client awaits the callback when it returns an awaitable.
  • poll_interval sets the first delay; max_poll_interval caps the exponential backoff (defaults 5s to 60s, unchanged today). The same call now fits a tight 2s watch and a slow 10-minute review.
  • A poll that finds no time left breaks instead of sleeping past the deadline, so the wait never overshoots its timeout.
  • poll_interval and max_poll_interval are validated before any request (finite, poll_interval > 0, max_poll_interval >= poll_interval), matching the guarantees timeout and head_commit_sha already make.

2. Findings with provenance, ready for triage

  • outcome.recorded_findings(severity=..., unresolved_only=...) returns RecordedFindings that keep the assessment behind each finding: assessment_id, environment_display_name, and from_code_assessment.
  • outcome.gap_codes returns the deduplicated reason codes for gaps and unresolved checks in recorded order.
  • Findings are ordered by severity then lifecycle state; an unknown severity sorts last instead of raising.

3. Gaps that name where and what

An INCOMPLETE outcome used to say why (reason codes) but not which environment, which risk domains, or which evidence. Those fields exist on the wire models and were dropped when a gap was built:

  • AssessmentGap.environment names the environment the gap came from, and outcome.environments lists the distinct names in recorded order.
  • AssessmentGap.domains carries the assessment's risk-domain coverage as DomainCoverage(domain, status, reason), with CONSIDERED or SKIPPED and the recorded reason. DomainCoverage is exported from the package.
  • CheckGap.files carries the files the evaluator cited, each with the revision it was read at (BASE_CODE_REVISION or PROPOSED_CODE_REVISION), and CheckGap.evaluated_at records when the answer was produced.
  • A withheld environment or domain value ([withheld: environment value]) is never surfaced, and the new metadata is validated before a gap is built, so malformed responses still raise the existing invalid-response error.

Why it is more than a poll hook. A callback is only the visible half. Interval control lets one API serve both a fast watch and a long backoff, the deadline-safe break stops the last sleep from overrunning timeout, and the gaps now carry the environment, domain coverage, and cited evidence a CI job needs to act without re-walking the review tree. The change is additive: default behaviour is byte-for-byte today's.

Severity vocabulary

Findings are filtered with the API's own labels (SERIOUS, WARNING, ...). The sort rank is forward-compatible: an unknown label sorts last.

Tests

  • tests/test_wait_and_outcomes.py: poll hooks (sync and async), awaitable callbacks, interval validation, the deadline break, gap_codes, finding provenance, environment and domain attribution, cited evidence and evaluated_at, withheld-value filtering, and invalid gap metadata.
  • Locally: full pytest 248 passed; operation and outcome contract checks pass; ruff check and ruff format --check clean; mypy clean.

Note on AGENTS.md

I left out the session's user prompts rather than publish personal text to a public repo. Happy to share context privately.

@juggernaut7777 juggernaut7777 changed the title Add wait_for_review poll hooks and provenance-aware outcome findings Add wait_for_review poll hooks, bounded interval control, and provenance-aware findings Nov 28, 2026
@juggernaut7777 juggernaut7777 changed the title Add wait_for_review poll hooks, bounded interval control, and provenance-aware findings Add wait_for_review poll hooks, bounded intervals, and actionable outcome provenance Nov 28, 2026
The API only records SERIOUS and WARNING. Do not invent HIGH in the sort rank; keep the forward-compatible contract that any future label a server sends sorts after the known ones instead of raising.
@juggernaut7777
juggernaut7777 force-pushed the feat/wait-observability-and-findings branch from 774ad20 to 748809a Compare November 30, 2026 16:02

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant