Skip to content

Re-scope the contradiction scanner and schedule it #89

Description

@markfreeman-dot-dev

v2 migration #100M7-lifecycle (epic #15) · Size S · Architecture

Goal

Keep the scanner checks v2 needs, run them over petri.sqlite on optional cron, keep petri scan on-demand with exit codes intact.

Context

This issue owns the scanner rework; M4-dbos only disables the queue-dependent categories and points here. Most of the v1 scanner's 10 categories die in v2 (queue-schema checks with M4-dbos, verdict-drift checks with M2-agents); what survives is domain-data integrity over petri.sqlite.

Scope

In:

  • Category inventory naming keep/retire and the obsoleting mechanism (M2-agents typed verdicts, M4-dbos queue deletion), committed as a docs note.
  • auto_fix and scan_loop decision (scanner.py:152-187): manual-only behind an explicit flag, or retired; scheduled runs never auto-fix.
  • Surviving checks rewritten in petri/analysis/scanner.py over petri/query/; ScanIssue replaced with a Pydantic model.
  • DBOS.create_schedule in the v2 app-bootstrap module, cron from a petri.yaml key (croniter); petri scan runs the same workflow synchronously, exit-1-on-findings.
  • scan_completed events via the domain-event seam (payload in EVENT_DATA_MODELS); root span petri.* (dish id, findings count, trigger source). Tests: test_scanner_v2.py, test_scan_schedule.py.

Out:

  • No scanning of generated adapter config beyond what v2 still generates (D5).
  • No dashboard scan-findings UI beyond the events.

Acceptance criteria

  • All 10 v1 categories accounted for: each rewritten for v2 or mapped to the mechanism that makes it impossible, with a one-line rationale; the auto_fix/scan_loop decision is recorded.
  • A seeded phantom edge (edge to a nonexistent cell id) is detected in unit tests.
  • A malformed event row (data payload failing its registered model under envelope {id, cell_id, timestamp, type, agent, iteration, data}) is detected in unit tests.
  • With config key absent, no schedule registers; with a test cron, a scan fires within the poll window appending exactly one scan_completed event per firing, no duplicates across a mid-interval restart; scheduled runs never invoke auto_fix.
  • petri scan reports the same findings as the scheduled run on identical state, and exits 1 when findings exist and 0 otherwise.
  • Both paths emit a root span with petri.* attributes (dish id, findings count, trigger source).

Pointers

  • petri/analysis/scanner.py:23-30,66-149,152-187,339,364,387,435 — hierarchy, dispatch, retiring checks
  • petri/cli/scan.py; petri/models.py:199-226 EVENT_DATA_MODELS
  • petri/query/ (M6 read layer); petri/storage/edge_registry.py (edges table)
  • v2 app-bootstrap — register DBOS.create_schedule before launch; never @DBOS.scheduled; M2-agents/M4-dbos obsoleting mechanisms

#N in this issue refers to entries in docs/field-reports.md, not issues in this repo.
To claim this issue, leave a comment. Questions welcome — see CONTRIBUTING.md.

Metadata

Metadata

Assignees

No one assigned

    Labels

    durable-executionExecutionBackend seam, DBOS, queueslifecycleRe-decomposition, feed, scan, analystmigration-v2Part of the v2 migration backlogobservabilityOpenTelemetry, spans, cost accountingsize:MRough effort: a day or two

    Type

    No type

    Projects

    Status
    Todo

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions