Skip to content

feat(assertions): add reviewed candidate judgment flow - #2791

Merged
Sinity merged 12 commits into
masterfrom
feature/fanout/annotation-judgment
Jul 13, 2026
Merged

Sinity merged 12 commits into
masterfrom
feature/fanout/annotation-judgment

Conversation

@Sinity

@Sinity Sinity commented Jul 12, 2026 •

Copy link
Copy Markdown
Owner

Summary

Advances the assertion review surface: deterministic finding candidates and
ordinary assertion candidates can be bulk-judged by an authenticated reviewer,
promoted with explicit injection authorization, and triaged through both
mark candidates and polylogue judge.

Problem

The user-tier substrate could write candidates, but judging was a single-item,
non-idempotent operation. Ordinary MCP write authority could not be cleanly
separated from a reviewer’s power to promote claims, leaving the proposed
candidate-to-judgment loop incomplete.

Solution

  • Add per-item-SAVEPOINT bulk judgment with applied/idempotent/failed results.
    Exact retries preserve immutable review history; changed decision or injection
    authorization fails closed.
  • Keep automated writers at candidate + inject=false; only promotion via a
    reviewer-selected --inject creates an injectable active assertion.
  • Add AssertionKind.FINDING and deterministic upsert_findings_as_assertions,
    reusing the existing candidate lifecycle without a user-tier migration.
  • Add multi-ref query-first candidate commands and polylogue judge terminal
    triage (noninteractive list/accept/reject JSON paths plus fzf/editor flow).
  • Add MCP candidate read tools and review-only judgment tools. Role order is
    read < write < review < admin; supplied actor_ref remains provenance only.
  • Regenerate CLI/OpenAPI/schema/topology outputs and update writer/MCP contract
    inventories.

Acceptance matrix

Bead Status Notes
polylogue-37t.12 partial Bulk savepoints, exact retry/conflict semantics, injection authorization, query CLI, and review-only MCP tools are implemented. Typed resolved evidence previews and a real adapter-to-storage integration proof remain under this Bead. Its “no second root command” wording conflicts with polylogue-p5g’s required root polylogue judge; this branch follows the latter requirement and does not mark that conflict satisfied.
polylogue-p5g partial Root polylogue judge supports pending list, scripted accept/reject JSON, kind/since filtering, filtered batch acceptance, interactive fzf selection, and editor-backed replacement promotion. Age/source fields, resolved excerpts, an evidence-open action, daily status/health output, and expiry behavior remain in this Bead’s scope.
polylogue-rxdo.4 partial FINDING has a deterministic candidate writer, queue inclusion, user-audit surface, lifecycle promotion, and generated schema coverage. A direct proof that all finding evidence references resolve and the required provenance projection remain unproven here.
polylogue-mrxt deferred to operator use Existing ordinary mark writes already create a MARK assertion. Creating the required first real local-archive row is intentionally not fabricated in this isolated test worktree.

Verification

  • nix develop --command devtools test tests/unit/storage/test_archive_tiers_assertions.py tests/unit/cli/test_assertion_candidates.py tests/unit/cli/test_judge_command.py tests/unit/mcp/test_assertion_judgment_tools.py tests/unit/mcp/test_envelope_contracts.py tests/unit/mcp/test_per_tool_contracts.py
    • 258 passed.
  • nix develop --command devtools test tests/unit/storage/test_archive_tiers_user_audit.py
    • 2 passed; every assertion kind, including finding, has a user-audit surface.
  • nix develop --command devtools verify --quick
    • format, lint, mypy, render, topology, layering, schema roundtrip, and all
      quick verification lanes passed.

The first broad -k 'assertion or judge or annotation' attempt was stopped
when pytest was blocked in host filesystem I/O; it did not supply a test result.
The narrowed production-route suite above completed green.

Anti-vacuity

  • test_bulk_judgment_is_partial_idempotent_and_injection_is_reviewer_controlled
    calls the production SQLite writer and fails if savepoints, exact-retry
    handling, injection authorization, or deduplication are removed.
  • test_findings_reuse_candidate_judgment_lifecycle_and_deduplicate calls the
    production finding writer and judge path; it fails if FINDING is omitted
    from the candidate lifecycle or its deterministic identity changes.
  • test_judge_noninteractive_accept_uses_bulk_lifecycle_payload invokes the
    real root Click command and fails if it stops using the bulk facade contract.
  • test_assertion_review_tools_require_review_capability builds real MCP role
    registries and fails if review tools leak to ordinary write authority.

Ref polylogue-mrxt.
Ref polylogue-37t.12.
Ref polylogue-p5g.
Ref polylogue-rxdo.

@coderabbitai

coderabbitai Bot commented Jul 12, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

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

Next review available in: 21 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

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 reviews.

How do review 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 refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 88026e9d-8e1b-401e-a079-fbb27d7c5a35

📥 Commits

Reviewing files that changed from the base of the PR and between 4fde802 and 3ca664c.

📒 Files selected for processing (26)
  • docs/cli-reference.md
  • docs/openapi/search.yaml
  • docs/plans/layering.yaml
  • docs/plans/topology-target.yaml
  • docs/schemas/cli-output/query-unit-envelope.schema.json
  • docs/topology-status.md
  • polylogue/api/archive.py
  • polylogue/cli/click_command_registration.py
  • polylogue/cli/commands/judge.py
  • polylogue/cli/query_verbs.py
  • polylogue/core/enums.py
  • polylogue/mcp/cli.py
  • polylogue/mcp/server_mutation_tools.py
  • polylogue/mcp/server_support.py
  • polylogue/mcp/server_tools.py
  • polylogue/storage/sqlite/archive_tiers/user_audit.py
  • polylogue/storage/sqlite/archive_tiers/user_write.py
  • polylogue/surfaces/payloads.py
  • tests/infra/mcp.py
  • tests/unit/api/test_facade_contracts.py
  • tests/unit/cli/test_assertion_candidates.py
  • tests/unit/cli/test_judge_command.py
  • tests/unit/mcp/test_assertion_judgment_tools.py
  • tests/unit/mcp/test_envelope_contracts.py
  • tests/unit/mcp/test_per_tool_contracts.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/fanout/annotation-judgment

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.

@Sinity
Sinity marked this pull request as ready for review July 12, 2026 21:27

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 437ea41b6d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread polylogue/mcp/server_mutation_tools.py Resolved
Comment thread polylogue/cli/commands/judge.py Resolved
@Sinity

Sinity commented Jul 12, 2026

Copy link
Copy Markdown
Owner Author

Adversarial review iteration 1

Findings and changes:

  • The MCP supersede adapters dropped replacement kind/body/value, and judge --kind filtered after the queue limit. Both are addressed in 34f009659, with focused CLI/MCP tests.
  • Finding re-materialization could overwrite a reviewed candidate. bcf7ddeff preserves any non-candidate materialization and its storage test covers the regression.
  • Divergent duplicate entries in one bulk request could be silently collapsed. 3b7c1c7b4 now reports one failed outcome for that candidate before any transition; equivalent assertion:<id> and bare-id duplicates still collapse normally. POLYLOGUE_PYTEST_BASETEMP_ROOT=/realm/tmp/polylogue-pytest nix develop --command devtools test tests/unit/storage/test_archive_tiers_assertions.py reported 28 passed.
  • The PR body had overclaimed completion. It now records the unresolved 37t.12/p5g/rxdo.4 criteria and the 37t.12-versus-p5g root-command conflict explicitly.

What survived scrutiny: reviewer authority separation, per-item savepoints, exact retry behavior, and generated surface updates remain covered by the committed focused tests. No Bead status was changed and this PR remains draft.

@Sinity

Sinity commented Jul 12, 2026

Copy link
Copy Markdown
Owner Author

Adversarial review iteration 2

Finding and change:

  • The per-candidate savepoints were outermost SQLite transactions, so each successful item committed at RELEASE rather than participating in one batch boundary. d9a840956 adds an enclosing batch savepoint, rolls it back and releases it on an unexpected exception, and retains the item-level savepoints for ordinary per-ref failures.

Verification:

  • POLYLOGUE_PYTEST_BASETEMP_ROOT=/realm/tmp/polylogue-pytest nix develop --command devtools test tests/unit/storage/test_archive_tiers_assertions.py selected 29 tests with exit status 0.
  • nix develop --command ruff check polylogue/storage/sqlite/archive_tiers/user_write.py tests/unit/storage/test_archive_tiers_assertions.py and the corresponding mypy command both passed.

The regression test fault-injects an unexpected second-item failure through the production writer and fails if the enclosing rollback is removed: it verifies neither the earlier candidate promotion nor its judgment persists, and that the connection has no stranded transaction. No Bead status was changed; the PR remains draft.

@Sinity

Sinity commented Jul 12, 2026

Copy link
Copy Markdown
Owner Author

Adversarial review iteration 3

Findings and changes in 82e4c2949:

  • Edit-and-accept passed the candidate wrapper kind as a replacement kind. For transform candidates this overrode the normal embedded claim-kind resolver. The terminal helper now promotes the edited body without forcing a replacement kind, so the storage lifecycle selects the same active kind as an ordinary accept.
  • A supersede retry was considered idempotent using only decision and injection authorization. Judgment rows now retain canonical replacement kind/body/value, and retry comparison includes reason, reviewer provenance, and replacement intent. Legacy supersede rows that lack replacement intent fail closed rather than claiming an edited retry was already applied.

Verification:

  • POLYLOGUE_PYTEST_BASETEMP_ROOT=/realm/tmp/polylogue-pytest nix develop --command devtools test tests/unit/storage/test_archive_tiers_assertions.py tests/unit/cli/test_judge_command.py reported 32 passed.
  • Focused Ruff and mypy passed; the pushed pre-push quick gate reported format, lint, mypy, render, topology, layering, closure matrix, schema roundtrip, and manifests green before continuing its remaining shared checks.

Anti-vacuity: the storage regression makes a changed supersede replacement conflict while an identical request is idempotent; removing the durable replacement comparison reverses those results. The CLI regression calls the production edit adapter and fails if it again supplies the transform wrapper kind. No Bead status was changed; the PR remains draft.

@Sinity

Sinity commented Jul 12, 2026

Copy link
Copy Markdown
Owner Author

Adversarial review iteration 4

Findings and changes in 18e9adaa9:

  • Bulk MCP judgments converted arbitrary JSON values with bool(...), so the string "false" became injection authorization. The adapter now requires an actual boolean and returns invalid_assertion_judgment before calling the review facade for invalid input.
  • Replacement fields could alter an accept promotion even though only supersede history recorded them. The storage transition now rejects replacement kind/body/value for every decision except supersede, preserving one durable and retryable edit route.

Verification:

  • POLYLOGUE_PYTEST_BASETEMP_ROOT=/realm/tmp/polylogue-pytest nix develop --command devtools test tests/unit/storage/test_archive_tiers_assertions.py tests/unit/mcp/test_assertion_judgment_tools.py completed with exit status 0.
  • Focused Ruff and mypy passed; the shared pre-push quick verification completed and pushed 18e9adaa9.

Anti-vacuity: the MCP regression invokes the registered review tool and proves it never calls the production facade for string injection input; changing back to truthiness makes it fail. The storage regression calls the production candidate transition and proves an attempted accepting replacement leaves no active assertion. No Bead status was changed; the PR remains draft.

@Sinity

Sinity commented Jul 12, 2026

Copy link
Copy Markdown
Owner Author

Adversarial review iteration 5

Finding and change in 76861c720:

  • Bulk MCP supersede input silently converted non-string replacement kind/body values to None. That could promote the original candidate while recording an immutable supersede. The adapter now rejects non-null wrong types before calling the production review facade.

Verification:

  • POLYLOGUE_PYTEST_BASETEMP_ROOT=/realm/tmp/polylogue-pytest nix develop --command devtools test tests/unit/mcp/test_assertion_judgment_tools.py reported 4 passed.
  • Focused Ruff and mypy passed; the pre-push quick gate completed and pushed 76861c720.

Anti-vacuity: the registered review-tool test submits an integer replacement_kind, asserts the typed error response, and proves the review facade is never invoked. Restoring silent coercion makes the test fail. No Bead status was changed; the PR remains draft.

@Sinity

Sinity commented Jul 12, 2026

Copy link
Copy Markdown
Owner Author

Adversarial review iteration 6 — zero new findings

After git fetch origin, a hostile review of origin/master...HEAD, all four Beads and their notes/AC, current PR body, inline feedback, and top-level review feedback found no new actionable correctness, authority, lifecycle, transaction, or claim-integrity defect. The two CodeRabbit findings remain addressed in their inline replies; CodeRabbit is rate-limited rather than reporting a substantive new review. Known GitHub Actions initialization failures remain the account-billing infrastructure pattern specified outside this PR.

The branch is clean at 76861c720; no Bead status changed and this draft PR is not merged.

@Sinity

Sinity commented Jul 12, 2026

Copy link
Copy Markdown
Owner Author

Final acceptance-criteria matrix (honest scope)

Bead Status Evidence / remaining scope
polylogue-mrxt deferred-to-bead An ordinary MARK write exists, but its criterion requires a real local-archive product-use row. This isolated worktree must not fabricate that operator event.
polylogue-37t.12 storage transitions + bulk semantics satisfied Candidate-only machine writes, explicit review injection, immutable retry/conflict behavior, outer transaction plus per-item savepoints, and strict bulk input handling are covered by production storage/MCP tests.
polylogue-37t.12 CLI/disclosure/real-route proof deferred-to-bead The query commands support multi-ref outcomes, but typed resolved evidence previews and the stipulated end-to-end CLI+MCP+active-claim proof remain absent.
polylogue-37t.12 root-command wording misframed Its “no parallel root command” instruction conflicts directly with polylogue-p5g’s required root polylogue judge; this branch implements the latter and does not claim the former satisfied.
polylogue-p5g deferred-to-bead This PR supplies root list/scripted/filtered/bulk/fzf/editor triage over the lifecycle. Age/source fields, resolved excerpts, open-evidence action, full exit health/scope summary, 60-day expiry, and bare-status health remain.
polylogue-rxdo.4 deferred-to-bead FINDING now has deterministic candidate writing, queue/lifecycle reuse, repeat idempotency, reviewed-materialization protection, generated contracts, and user audit coverage. A direct finding-reference resolve proof plus the requested provenance projection remain.

Focused production-route verification recorded in this PR: storage assertion lifecycle tests, judge CLI tests, and MCP review-tool tests, all using /realm/tmp/polylogue-pytest; focused Ruff/mypy and every pushed quick verification gate passed. No Beads were closed.

Sinity and others added 12 commits July 13, 2026 02:52
Problem: assertion candidates could be written but review was single-item,
non-idempotent, and unavailable through a dedicated review authority.

What changed: add transactional bulk judgments with per-item savepoints,
explicit injection authorization, and deterministic FINDING candidates. Expose
the lifecycle through query-first commands, terminal judge triage, and a
review-only MCP capability.

Compatibility: ordinary writers remain candidate-only and cannot authorize
context injection. Existing single-candidate callers retain their API.

Ref polylogue-37t.12.
Ref polylogue-p5g.
Ref polylogue-rxdo.4.

Co-Authored-By: Claude <[email protected]>
Regenerate CLI, OpenAPI, output-schema, and topology projections for the
reviewed assertion judgment surface. Update the writer-entrypoint inventory
and MCP discovery/envelope pins for the new candidate review tools.

Ref polylogue-37t.12.
Ref polylogue-p5g.
Ref polylogue-rxdo.4.

Co-Authored-By: Claude <[email protected]>
Functional --since filter for judge candidates and a bulk
--accept-all-of-kind acceptance path, with real CLI coverage.

Verified: 2 focused CLI tests passed; devtools verify --quick passed.

Co-Authored-By: Claude <[email protected]>
Pass root judge kind filters into the candidate read before applying its
limit. Preserve singular and bulk MCP supersede replacement fields so review
clients can promote their corrected assertion content.

Ref polylogue-37t.12.
Ref polylogue-p5g.

Co-Authored-By: Claude <[email protected]>
Do not let an automated finding re-materialization rewrite a candidate after
an operator has accepted, rejected, deferred, or superseded it. This mirrors
the pathology writer's reviewed-row guard and preserves judgment evidence.

Ref polylogue-rxdo.4.

Co-Authored-By: Claude <[email protected]>
Problem: bulk judgment collapsed repeated candidate references before\nchecking whether their decision, injection, or replacement intent differed.\n\nWhat changed: normalize equivalent references while rejecting divergent\nduplicates with one failed per-candidate outcome before any transition runs.\n\nRef polylogue-37t.12.
Problem: the terminal judge queue limited candidates before its local\n--since filter, hiding recent work behind older rows.\n\nWhat changed: fetch the selected kind without a cap when a local time\nfilter or bulk action needs the full filtered set, then retain the 50-row\ndisplay bound for interactive and list output.\n\nRef polylogue-p5g.
Problem: outermost item savepoints committed individually, so an\nunexpected later failure could leave a partially written batch.\n\nWhat changed: wrap all per-item savepoints in a releasable outer\ntransaction savepoint and roll it back on unexpected exceptions.\n\nRef polylogue-37t.12.
Problem: terminal edits forced transform wrapper kinds and changed\nsupersede replacements could be reported as idempotent.\n\nWhat changed: edited promotion preserves the normal candidate kind resolver,\nand durable supersede request fields now make only identical retries idempotent.\n\nRef polylogue-37t.12.\nRef polylogue-p5g.
Problem: bulk MCP input coerced truthy strings into injection authorization,\nand non-supersede actions could apply unrecorded replacement data.\n\nWhat changed: require actual boolean injection input and reject replacement\nfields unless the judgment explicitly supersedes a candidate.\n\nRef polylogue-37t.12.
Problem: non-string bulk replacement fields were silently erased, allowing\na supersede to promote the original claim instead of rejecting bad input.\n\nWhat changed: require non-null replacement kind and body fields to be\nstrings before calling the review facade.\n\nRef polylogue-37t.12.
…ntract

test_no_undiscovered_async_methods flagged capture_assertion_candidate,
judge_assertion_candidates, and join_typed_annotations as undiscovered
public async Polylogue methods. capture_assertion_candidate and
join_typed_annotations were pre-existing gaps (never registered by the
PRs that introduced them); judge_assertion_candidates is new in this
branch. Add all three to BESPOKE_METHODS.
@Sinity
Sinity force-pushed the feature/fanout/annotation-judgment branch from 76861c7 to 3ca664c Compare July 13, 2026 00:53
@Sinity

Sinity commented Jul 13, 2026

Copy link
Copy Markdown
Owner Author

Merge-conductor rebase note

Rebased twice onto master as mcp-ergonomics (#2790), terminal-note (#2801),
and extension-redesign (#2780) landed. The mcp-ergonomics rebase produced 5
real (non-generated-surface) conflicts across polylogue/api/archive.py,
polylogue/cli/click_command_registration.py,
polylogue/mcp/server_mutation_tools.py, polylogue/mcp/server_support.py, and
tests/unit/mcp/test_per_tool_contracts.py — all were "both sides added a
new sibling function/field/command near the same anchor" shapes, resolved
by keeping both additions (e.g. MCPRole extended to
Literal["read", "write", "review", "admin"] to carry both mcp-ergonomics'
existing roles and this PR's new "review" role; capture_assertion_candidate
and judge_assertion_candidates kept as sibling functions/methods/CLI
commands rather than one clobbering the other).

Running the focused suite surfaced a real, otherwise-silent gap:
test_no_undiscovered_async_methods failed because capture_assertion_candidate,
judge_assertion_candidates, and join_typed_annotations were never added to
BESPOKE_METHODS in tests/unit/api/test_facade_contracts.py.
capture_assertion_candidate and join_typed_annotations were pre-existing
gaps (introduced by earlier PRs, not this one) — added here since this PR is
what turned the gap into a red test.

Verification: focused suite (7 files) — 541 passed. devtools verify --quick
— 15/15 checks green.

@Sinity
Sinity merged commit 5aa34e6 into master Jul 13, 2026
3 of 15 checks passed
@Sinity
Sinity deleted the feature/fanout/annotation-judgment branch July 13, 2026 00:53
Sinity added a commit that referenced this pull request Jul 13, 2026
…807,2780,2790,2791,2795,2802,2806,2809

uwk3, jph5 (rigor-contracts #2783), bby.17 (web-cockpit #2793), dmp
(terminal-note #2801), ra3w (basetemp-fix #2807), r4no/bkff/r2kb
(extension-redesign #2780) fully satisfied — closed. nhjs (#2793), peo
(daemon-forensics #2802), 4g3n (#2780), 67ac/212.11 (demo-corpus #2795),
rsad (mcp-ergonomics #2790, real gaps remain per 5-iteration adversarial
cap), 9e5.8.4/jnj.7 (provider-origin #2806), mrxt/37t.12/p5g/rxdo.4
(annotation-judgment #2791), s7ae.8/20d.2 (live-performance-2 #2809)
partially satisfied — noted with disposition, left open.

Also discovered and documented the actual root cause of this session's
recurring bead-revert incidents: bd reimports the live database from
.beads/issues.jsonl on every CLI invocation, so a write not immediately
exported is lost the moment the next bd command runs. Every mutation in
this commit was individually export-verified against that behavior.

Co-Authored-By: Claude <[email protected]>
Sinity added a commit that referenced this pull request Jul 14, 2026
… provenance (rxdo cluster) (#2899)

## Summary

Advances the rxdo epic's core query/evidence-contract substrate: a real
(non-test-double) production `CanonicalPlanEvaluator`, wired as the
default daemon standing-query evaluator; a lossless predicate round-trip
that makes it possible; `finding:<id>` refs resolving to a queryable
provenance projection; and a declarative improvement-loop registry.

## Problem

Prior PRs (#2813, #2826, #2812, #2791) landed substantial rxdo schema
and contract substrate but explicitly flagged the same real gap in their
own closing notes: `CanonicalPlanEvaluator` had exactly one kind of
implementation anywhere in the repo — hand-rolled fakes inside test
files. `make_default_convergence_stages()` called
`make_standing_query_stage(db_path)` with no evaluator at all, so the
standing-query convergence stage was permanently inert in production.
`record_query_run()` (ops.db telemetry writer) had zero production
callers. `resolve_ref("finding:<id>")` returned the generic
substrate-pending stub even though findings have been real queryable
assertion rows since PR #2812. rxdo.11 asked for a declared loop
registry that didn't exist.

## Solution

- **`polylogue/archive/query/predicate.py`**: `predicate_from_payload()`
— a lossless round trip colocated with each predicate dataclass's own
`to_payload()`. Not a reverse-compiler over free-form text; every branch
inverts one dataclass's own projection.
- **`polylogue/archive/query/production_evaluator.py`**:
`ArchiveCanonicalPlanEvaluator`, the first real evaluator
implementation. Reconstructs a typed predicate from a durable
`query:<hash>` definition's canonical AST, binds field context through
the existing planner-internal `_bind_predicate_context` seam, executes
through the same `SessionFilter` every surface uses, and records a
bounded `ops.db` `query_runs` row (`surface="daemon-internal"`) per
evaluation — a genuine production caller of `record_query_run`. Legacy
protocol-v0 identities and non-session grains fail closed with named
errors.
- **`polylogue/daemon/convergence_stages.py`**:
`make_default_convergence_stages` now injects
`ArchiveCanonicalPlanEvaluator` by default — the named remaining item
from rxdo.5's notes.
- **`polylogue/storage/sqlite/finding_provenance.py`** +
**`polylogue/surfaces/payloads.py`** (`FindingProvenancePayload`):
`compute_finding_provenance()` re-derives a finding's declared
`query_ref`/`result_set_ref`/`baseline_ref`/`current_ref` plus generic
`evidence_refs`, resolves each live, and reports a current/stale/unknown
staleness verdict.
- **`polylogue/api/archive.py`**: `resolve_ref("finding:<id>")`
dispatches to the new resolver instead of the pending-kind stub.
- **`polylogue/insights/improvement_loops.py`**: `LOOP_REGISTRY`
declaring all 13 loop instances from the rxdo.11 design as the 5-tuple
(watch/measure/propose/judge/artifact). Every entry is
`status="horizon"` — no scheduler exists yet, and a dedicated test
asserts `active_loops()` stays empty until one does.

## Non-goals / explicitly deferred

- Cross-surface (CLI/MCP/daemon-web/API) query-run recording parity —
only the daemon-internal evaluator surface records today.
- `from result-set:<id>` / `from query:<hash>` DSL execution wired into
the CLI (rxdo.6) — the evaluator this needed now exists, but CLI/MCP
command-surface wiring is a separate, larger change against
`cli/archive_query.py` (2500+ lines) deferred to a follow-up.
- Cohort resolution (`resolve_cohort` raises `NotImplementedError`).
- rxdo.8 (DB-native analysis recipes): needs a new user-tier schema
migration slot, and polylogue-60i5's corrective contract requires a
declared window + two-consumer stabilization before any new durable
table lands. Not attempted here.
- rxdo.11's two active pilots (L1/L2 executing through a shared
scheduler): blocked on polylogue-37t.17 (L1's read-access log) and an L2
classifier-residue detector, neither of which exist. Only the
declaration registry landed.

## Verification

- `devtools test tests/unit/archive/query/test_production_evaluator.py
tests/unit/archive/query/test_predicate_payload_roundtrip.py
tests/unit/daemon/test_standing_queries_default_evaluator.py
tests/unit/insights/test_improvement_loops.py
tests/unit/api/test_facade_contracts.py
tests/unit/daemon/test_standing_queries.py
tests/unit/archive/query/test_evaluator.py
tests/unit/daemon/test_convergence_stages.py
tests/unit/daemon/test_convergence_final_state.py` — 351 passed, 6
pre-existing failures. Those 6
(`test_archive_tiers_api_timeline_insights_read_index_tier`,
`test_facade_judges_candidate_assertion_in_user_tier`,
`test_archive_tiers_api_session_costs_read_index_tier`,
`test_archive_tiers_api_tag_rollups_read_index_and_user_tiers`,
`test_archive_tiers_api_latency_profiles_read_index_tier`,
`test_archive_tiers_api_archive_coverage_reads_index_tier`) were
independently confirmed present with identical count/names on unmodified
master (verified via a temporary `git stash` + rerun of
`tests/unit/api/test_facade_contracts.py` alone).
- `mypy --strict` over all touched source + test files: clean.
- `ruff check` / `ruff format`: clean.
- `devtools render all --check`: clean (topology projection regenerated
for the 3 new modules).
- `devtools verify --quick`: exit 0 (ran automatically on push via the
pre-push hook).

## Anti-vacuity

`test_evaluate_matches_real_archive_rows` depends on the actual
predicate reconstruction + `SessionFilter` execution: removing
`predicate_from_payload()` or the `SessionFilter.list_summaries()` call
breaks it, since the assertion checks the archive actually filtered by
origin against real ingested rows (not a toy replica).
`test_evaluate_records_a_production_query_run` depends on the
`record_query_run` call: removing it breaks the test, since it reads the
row back from a real `ops.db`.
`test_default_stage_set_evaluates_a_watched_query_without_an_injected_fake`
depends on the `make_default_convergence_stages` wiring: it injects no
fake evaluator at all, only the production one reached through the real
factory function.

Ref polylogue-rxdo.2, polylogue-rxdo.3, polylogue-rxdo.4,
polylogue-rxdo.5, polylogue-rxdo.6, polylogue-rxdo.8, polylogue-rxdo.11

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **New Features**
- Finding references now display detailed provenance, evidence
resolution status, and staleness information.
- Canonical archive queries can be executed with exact session results
and safeguards against self-triggering evaluations.
- Query predicates can be reconstructed reliably from saved
representations.
  - Added a registry for tracking planned improvement loops.

- **Documentation**
- Updated topology documentation and status totals to reflect newly
registered components.

- **Tests**
- Added coverage for finding provenance, query execution, predicate
restoration, and default standing-query behavior.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Claude <[email protected]>
Sinity added a commit that referenced this pull request Jul 18, 2026
… hand ledger

Problem: docs/public-claims.yaml (schema external-claims-ledger/v2) was
a hand-maintained YAML file, a second durable claims store parallel to
the FINDING assertion substrate that PR #2791's canonical judgment
lifecycle already governs. polylogue-3tl.16 asks for public claims to
be a rendered projection over FINDING rows, judgment/supersession
state, and a shared evidence-integrity verdict instead.

Solution: polylogue/insights/measurement/public_claims.py computes one
PublicClaimProjection per stable claim key from
list_public_finding_inputs() (new adapter in
storage/finding_provenance.py) plus an injected
EvidenceIntegrityProvider.verdict_for() seam (polylogue-37t.14 is not
yet landed, so a missing verdict fails closed as unresolved, never
fresh/supported). Four presets (readme/launch/findings-page/
verified-export) filter the same computed rows -- status is computed
once, not per surface. devtools/public_claims.py + new
devtools/render_public_claims.py replace the old YAML-validator with a
render/check command; docs/public-claims.yaml becomes a generated
verified-export compatibility view. Seeds the three current
claim-vs-evidence headline findings plus the flight-recorder capability
statement via new PublicClaimDeclaration fields on the existing
additive polylogue.finding.v1 assertion payload (no user-tier schema
migration -- these are additive JSON fields on an already-JSON column).

Originated as external-agent packet ann-05-claims-view-r01 (GPT Pro
wave 2, snapshot 536a53e), unreviewed. Verified independently:

- Confirmed against live source (not the packet's claim) that no
  second durable claims table exists and no schema migration is
  required for the new FindingAssertion fields.
- git apply --check against current origin/master (12+ commits ahead
  of the packet's snapshot) failed on 3 of 29 files. Two
  (docs/plans/topology-target.yaml, docs/topology-status.md) are
  generated docs that drifted from unrelated intervening commits --
  regenerated via `devtools render topology-projection` +
  `render topology-status` rather than force-applying stale content.
  The third (user_write.py) conflicted on one import line added by
  PR #3051 (`feat: harden archive continuity closure`) landing after
  the packet's snapshot; reconciled by hand (7 of 8 hunks applied
  clean via git apply --reject, the import line added manually).
- Independently reproduced devtools verify public-claims --json (4
  claims, 9 artifacts, 3 monitored surfaces, 0 problems) and
  devtools verify layering (0 violations) -- both match the packet's
  own claimed output exactly.
- The packet flagged test_archive_tiers_api_archive_debt_reads_archive_consistency
  as a pre-existing "database source_debt is locked" failure unrelated
  to its patch. Reproduced this independently on the unrelated ann-01
  worktree (clean master plus an unrelated feature) to confirm it is
  a genuine baseline/environmental flake, not something this patch
  introduced.

Verification:
- devtools test tests/unit/insights/measurement/test_public_claims.py tests/unit/storage/test_public_claims_projection.py tests/unit/devtools/test_public_claims.py -> 31 passed
- devtools test tests/unit/scenarios/test_demo_archive_convergence.py tests/unit/storage/test_archive_tiers_assertions.py tests/unit/devtools/test_generated_surfaces.py tests/unit/devtools/test_release_readiness.py tests/unit/devtools/test_render_docs_surface.py tests/unit/devtools/test_project_motd.py tests/unit/daemon/test_standing_queries.py tests/unit/cli/test_import.py -> 84 passed
- devtools test (6 affected tests/unit/api/test_facade_contracts.py cases) -> 6 passed, 1 pre-existing unrelated flake classified above
- ruff format --check / ruff check on all 16 touched Python files -> clean
- mypy --strict on all 13 touched production/test modules -> Success, no issues
- devtools render all --check -> exit 0, no drift (includes regenerated topology projection/status)
- devtools verify public-claims --json -> ok, 0 problems
- devtools verify layering -> 0 violations
- devtools verify --quick -> exit_code 0

Ref polylogue-3tl.16

Co-Authored-By: Claude <[email protected]>
Sinity added a commit that referenced this pull request Jul 18, 2026
… hand ledger (#3065)

## Summary

Implements polylogue-3tl.16: `docs/public-claims.yaml` stops being a
hand-maintained ledger and becomes a generated projection over
`AssertionKind.FINDING` rows, the canonical judgment/supersession
lifecycle (PR #2791), and a bounded evidence-integrity verdict seam for
the not-yet-landed `polylogue-37t.14` evaluator.

## Problem

`docs/public-claims.yaml` (schema `external-claims-ledger/v2`) was a
second durable claim store maintained by hand, parallel to the FINDING
assertion substrate. A claim's public status could drift from what the
judgment lifecycle actually supports, and README/launch/findings-page
copy had no single source of truth to render from.

## Solution

- `polylogue/insights/measurement/public_claims.py`:
`project_public_claims()`
  computes one `PublicClaimProjection` per stable claim key from
  `list_public_finding_inputs()` (new read adapter in
  `storage/finding_provenance.py`), the FINDING/judgment/supersession
  facts, and an injected `EvidenceIntegrityProvider.verdict_for()` seam.
  A missing verdict fails closed as `unresolved`, never
  fresh/supported. Four presets (`readme`, `launch`, `findings-page`,
  `verified-export`) only *filter* the one already-computed projection
  -- status is never recomputed per surface.
- `polylogue/storage/sqlite/archive_tiers/user_write.py`: additive
  `PublicClaimDeclaration` + `source_epoch`/`evaluation_ref`/`frame_ref`
  fields on the existing `polylogue.finding.v1` JSON payload. No
  user-tier schema migration -- these are new keys in an already-JSON
  column.
- `devtools/public_claims.py` (existing validator, rewritten) +
  new `devtools/render_public_claims.py`: render/check command,
  registered in `generated_surfaces.py`/`command_catalog.py`/
  `docs_surface.py`/`release_readiness.py`. `docs/public-claims.yaml`
  is now the generated `verified-export` compatibility view.
- Seeds the three current claim-vs-evidence headline findings plus the
  `category.local-evidence-system` capability statement via
  `polylogue/scenarios/corpus.py`.
- Distinct fail-closed states for
broken/circular/stale/frame-incomplete/
  private-held/unsupported evidence, verified by real negative tests
  (see Verification), not just read from the packet's own claims.

## Provenance and independent verification

Originated as external-agent packet `ann-05-claims-view-r01` (GPT Pro
wave 2, snapshot `536a53efac0cbe4a2473ad379e4db49ef3fce74d`,
unreviewed). Verified adversarially rather than trusting its `TESTS.md`:

- Confirmed against live source that no second durable claims table
  exists and no schema migration is needed for the new
  `FindingAssertion` fields.
- `git apply --check` against current `origin/master` (12+ commits
  ahead of the snapshot) failed on 3 of 29 files:
  - `docs/plans/topology-target.yaml` / `docs/topology-status.md` had
    drifted from unrelated intervening commits (both are generated) --
    regenerated with `devtools render topology-projection` +
    `render topology-status` instead of force-applying stale content.
  - `polylogue/storage/sqlite/archive_tiers/user_write.py` conflicted
    on one import line added by PR #3051, landed after the packet's
    snapshot. Reconciled by hand: 7 of 8 hunks applied clean via
    `git apply --reject`, the import added manually.
- Independently reran `devtools verify public-claims --json` (4
  claims, 9 artifacts, 3 monitored surfaces, 0 problems) and
  `devtools verify layering` (0 violations) -- both match the packet's
  own claimed output exactly, not just re-asserted from its prose.
- The packet flagged
`test_archive_tiers_api_archive_debt_reads_archive_consistency`
  ("database source_debt is locked") as a pre-existing baseline
  failure unrelated to its patch. Reproduced this independently on an
  unrelated worktree (clean master plus an unrelated annotations
  feature) to confirm it's a genuine environmental flake, not
  something introduced here.

## Verification

```
devtools test tests/unit/insights/measurement/test_public_claims.py \
  tests/unit/storage/test_public_claims_projection.py tests/unit/devtools/test_public_claims.py
-> 31 passed

devtools test tests/unit/scenarios/test_demo_archive_convergence.py \
  tests/unit/storage/test_archive_tiers_assertions.py tests/unit/devtools/test_generated_surfaces.py \
  tests/unit/devtools/test_release_readiness.py tests/unit/devtools/test_render_docs_surface.py \
  tests/unit/devtools/test_project_motd.py tests/unit/daemon/test_standing_queries.py tests/unit/cli/test_import.py
-> 84 passed

devtools test (6 affected tests/unit/api/test_facade_contracts.py cases)
-> 6 passed, 1 pre-existing unrelated flake (classified above, reproduced independent of this patch)

ruff format --check / ruff check (all 16 touched Python files) -> clean
mypy --strict (all 13 touched production/test modules) -> Success, no issues
devtools render all --check -> exit 0, no drift (includes regenerated topology docs)
devtools verify public-claims --json -> ok, 0 problems
devtools verify layering -> 0 violations
devtools verify --quick -> exit_code 0
```

Not run: the full non-quick `devtools verify` (testmon inner loop) and
the post-merge heavy CI `test` suite; per-PR CI intentionally skips it.

## Follow-ups intentionally deferred

- `polylogue-37t.14` (the shared evidence-integrity evaluator) is not
  yet landed. This PR defines the narrow consumer interface
  (`EvidenceIntegrityProvider.verdict_for`) it must implement; the
  three seeded findings currently render `unknown · unresolved`
  because no verdict/canonical judgment has been supplied yet -- this
  is the honest default, not a placeholder bug.
- Coverage is currently `README.md`, `docs/demos.md`,
  `docs/findings/claim-vs-evidence.md`; a future tracked launch-post
source should be registered against the `launch` preset when it exists.

Ref polylogue-3tl.16

---------

Co-authored-by: Claude <[email protected]>
@Sinity

Sinity commented Oct 1, 2026

Copy link
Copy Markdown
Owner Author

Historical Codex triage: evidence checked at 5ebcfe5. This records that source revision; it does not claim a fresh review of current master.

  • 61.F024 / P2: fixed-already at the checked revision: The CLI converts --kind into a kinds tuple before fetching reviews and passes it with limit at polylogue/cli/commands/judge.py:427,445-449. Kind filtering no longer occurs only after retrieving an unrelated first page.

Only the rows listed above are dispositioned. Held findings remain open.

@Sinity

Sinity commented Oct 1, 2026

Copy link
Copy Markdown
Owner Author

Historical Codex triage: evidence checked at 5ebcfe5. This records that source revision; it does not claim a fresh review of current master.

Only the rows listed above are dispositioned. Held findings remain open.

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