Skip to content

feat(insights): emit pathology findings as candidate assertions (#2383) - #2450

Merged
Sinity merged 1 commit into
masterfrom
feature/feat/pathology-assertion-candidates
Jun 26, 2026
Merged

Sinity merged 1 commit into
masterfrom
feature/feat/pathology-assertion-candidates

Conversation

@Sinity

@Sinity Sinity commented Jun 26, 2026

Copy link
Copy Markdown
Owner

Summary

Closes the final acceptance criterion of #2383: the deterministic pathology
detectors now emit their findings as Assertion(kind=pathology) candidate rows
that are queryable through the existing #2006 assertion-claims surface and
promotable through the standard accept/reject/defer lifecycle — with no
auto-injection into agent context.

Problem

#2448 shipped the detectors and #2449 shipped the distribution view, but both
surfaced findings only as a computed report. #2383's last AC requires detector
output to be queryable via #2006 (assertions where kind:pathology) and to
require explicit promotion (Ref #2182). Until now there was no persisted,
promotable representation of a pathology finding.

Solution

  • core/enums.py: add AssertionKind.PATHOLOGY. The assertions.kind
    column is plain TEXT with no DB CHECK, so this is schema-free — no
    user-tier SCHEMA_VERSION bump.
  • storage/.../user_write.py:
    • assertion_id_for_pathology_finding(...) — a deterministic id over
      (session, kind, detector_version, detail, evidence) so rebuilds are
      idempotent.
    • upsert_pathology_findings_as_assertions(...) — mirrors each
      PathologyFinding as a PRIVATE, non-injected
      (context_policy={"inject": False, "promotion_required": True})
      CANDIDATE assertion. An operator-promoted candidate
      (status != CANDIDATE) is never silently downgraded.
    • Register PATHOLOGY in ASSERTION_CLAIM_KINDS so it appears in the
      default claims query.
  • storage/.../user_audit.py: register the pathologies overlay surface
    so the "every AssertionKind has a surface" audit invariant holds.
  • api/archive.py: Polylogue.materialize_pathology_assertions(spec, *, limit) — runs the detectors over a matched scope (mirroring
    pathology_report, including the truncation warning) and upserts the
    candidates in one user.db transaction, returning the count written. Maps
    pathology work-packet support to inference.
  • Regenerated docs/openapi/search.yaml and
    docs/schemas/cli-output/query-unit-envelope.schema.json (the AssertionKind
    enum is embedded in both).

The loop is complete and consumed: materialize_pathology_assertions →
list_assertion_claims(kinds="pathology") (existing MCP/CLI/API query) →
mark candidates accept/reject (existing promotion lifecycle).

Verification

  • devtools test tests/unit/storage/test_archive_tiers_assertions.py → 25 passed
    (new round-trip: emit → query candidates → idempotent re-emit →
    promoted-candidate-not-downgraded; plus deterministic-id stability)
  • devtools test tests/unit/storage/test_archive_tiers_user_audit.py → 2 passed
  • devtools test tests/unit/cli/test_archive_maintenance_cli.py → 26 passed
  • devtools test tests/unit/cli/test_assertion_candidates.py → 3 passed
  • devtools test tests/unit/insights/test_postmortem.py → 27 passed
  • devtools render all --check → exit 0
  • mypy clean on all changed files

#2383 status

All acceptance criteria now satisfied:

Ref #2383

🤖 Generated with Claude Code

…ions (Ref #2383)

Problem: the pathology detectors (#2448) and the distribution view (#2449)
surfaced findings only as a computed report. #2383's final acceptance
criterion is that detector output is emitted as Assertion(kind=pathology)
candidate rows queryable via the #2006 assertion lifecycle and promotable
through the existing accept/reject/defer flow — with no auto-injection.

Solution:
- core/enums.py: add AssertionKind.PATHOLOGY. assertions.kind is plain TEXT
  with no DB CHECK, so this is schema-free (no user-tier version bump).
- storage/.../user_write.py: add assertion_id_for_pathology_finding (a
  deterministic id over session/kind/detector-version/detail/evidence) and
  upsert_pathology_findings_as_assertions, which mirrors each PathologyFinding
  as a PRIVATE, non-injected (context_policy inject=False) CANDIDATE assertion.
  An operator-promoted candidate (status != CANDIDATE) is never downgraded.
  Register PATHOLOGY in ASSERTION_CLAIM_KINDS so it appears in default claims.
- storage/.../user_audit.py: register the "pathologies" overlay surface so the
  every-kind audit invariant holds.
- api/archive.py: add Polylogue.materialize_pathology_assertions(spec, *, limit)
  — runs the detectors over a matched scope (mirroring pathology_report,
  including the truncation warning) and upserts the candidates in one user.db
  transaction, returning the count. Map "pathology" support to "inference".

The loop is complete and consumed: materialize → list_assertion_claims(
kinds="pathology") (existing MCP/CLI/API query) → mark candidates accept/reject
(existing promotion lifecycle). Nothing flows into agent context automatically.

Verification:
- devtools test tests/unit/storage/test_archive_tiers_assertions.py → 25 passed
  (round-trip: emit → query candidates → idempotent re-emit → promoted-not-downgraded)
- devtools test tests/unit/storage/test_archive_tiers_user_audit.py → 2 passed
- devtools test tests/unit/cli/test_archive_maintenance_cli.py → 26 passed
- devtools test tests/unit/cli/test_assertion_candidates.py → 3 passed
- devtools test tests/unit/insights/test_postmortem.py → 27 passed
- mypy clean on all changed files

Ref #2383

Co-Authored-By: Claude <[email protected]>
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@coderabbitai

coderabbitai Bot commented Jun 26, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@Sinity, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 22 minutes and 54 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits.

🚦 How do rate limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 946766b2-523a-4f6c-97b4-bc49203ffed0

📥 Commits

Reviewing files that changed from the base of the PR and between e7a39b3 and 4ed262d.

📒 Files selected for processing (7)
  • docs/openapi/search.yaml
  • docs/schemas/cli-output/query-unit-envelope.schema.json
  • polylogue/api/archive.py
  • polylogue/core/enums.py
  • polylogue/storage/sqlite/archive_tiers/user_audit.py
  • polylogue/storage/sqlite/archive_tiers/user_write.py
  • tests/unit/storage/test_archive_tiers_assertions.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/feat/pathology-assertion-candidates

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

github-actions Bot pushed a commit that referenced this pull request Jun 26, 2026
@Sinity
Sinity merged commit d42eec6 into master Jun 26, 2026
15 checks passed
@Sinity
Sinity deleted the feature/feat/pathology-assertion-candidates branch June 26, 2026 22:14
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