Skip to content

feat(assertions): add candidate judgment workflow (#2182) - #2204

Merged
Sinity merged 3 commits into
masterfrom
feature/feat/assertion-candidate-promotion-2182
Jun 20, 2026
Merged

Sinity merged 3 commits into
masterfrom
feature/feat/assertion-candidate-promotion-2182

Conversation

@Sinity

@Sinity Sinity commented Jun 20, 2026 •

Copy link
Copy Markdown
Owner

Summary

Adds the explicit candidate-assertion judgment workflow: candidate rows can be listed, accepted, rejected, deferred, or superseded through the assertion substrate, exposed through CLI and Python API, and surfaced as actionable archive debt.

Problem

#1883 made assertions a real substrate and transform candidates can now exist as private candidate rows, but those candidates had no durable operator workflow. A candidate could be stored and queried, yet there was no first-class judgment record, no promotion path into an active assertion, and no operator cockpit row showing that a candidate needed review. That left model/transform confidence too close to durable truth.

Solution

  • Extends polylogue/storage/sqlite/archive_tiers/user_write.py with judgment assertions plus list_assertion_candidates() and judge_assertion_candidate() helpers.
  • Adds shared AssertionJudgmentPayload / AssertionJudgmentResultPayload models in polylogue/surfaces/payloads.py.
  • Adds Python API methods Polylogue.list_assertion_candidates() and Polylogue.judge_assertion_candidate().
  • Adds polylogue ops state candidates {list,accept,reject,defer,supersede} without creating a new root command.
  • Feeds pending candidate assertions into polylogue ops debt list --kind assertion-candidate as actionable user-owned debt rows.
  • Documents candidate judgment lifecycle in docs/search.md and regenerates generated CLI/schema/quality surfaces.

Judgments are assertion rows, not a second truth system. accept and supersede create active assertions with evidence pointing back to the candidate and supersedes=("assertion:<candidate>",). reject and defer preserve a judgment reason and leave candidate lifecycle state durable. Candidate rows remain private/no-inject unless explicitly promoted or requested by a later surface.

Acceptance Matrix

  • Candidate listing with evidence/lifecycle fields: satisfied by list_assertion_candidates, API wrapper, CLI JSON list test.
  • Accept candidate into active assertion with provenance: satisfied by storage acceptance test and API test.
  • Reject and defer candidates with readable reason/status: satisfied by storage rejection and defer tests.
  • Supersede candidate with replacement lineage: satisfied by storage supersede test.
  • CLI and machine surface: satisfied by ops state candidates and Python API.
  • Archive debt integration: satisfied by assertion-candidate debt rows and projection test.
  • Candidate/no-inject default preserved: satisfied by existing assertion default behavior and promoted assertion context-policy checks.
  • Docs: docs/search.md now documents candidate, judgment, active, rejected, deferred, and superseded lifecycle semantics.

Closes #2182.

Verification

Focused behavior suite:

devtools test \
  tests/unit/storage/test_archive_tiers_assertions.py::test_candidate_assertion_acceptance_creates_active_assertion_with_lineage \
  tests/unit/storage/test_archive_tiers_assertions.py::test_candidate_assertion_rejection_preserves_reason_and_filtering \
  tests/unit/storage/test_archive_tiers_assertions.py::test_candidate_assertion_supersede_records_replacement_and_lineage \
  tests/unit/api/test_facade_contracts.py::test_facade_judges_candidate_assertion_in_user_tier \
  tests/unit/api/test_facade_contracts.py::test_no_undiscovered_async_methods \
  tests/unit/cli/test_assertion_candidates.py \
  tests/unit/operations/test_archive_debt.py::test_archive_debt_reports_candidate_assertions_as_actionable \
  -q
# 9 passed

Generated surfaces:

devtools render all --check
# sync OK for cli-reference, cli-output-schemas, openapi, devtools-reference,
# quality-reference, docs-surface, topology-status, pages, agents

Quick gate:

devtools verify --quick
# exit_code 0; ruff format/check, mypy, render all, topology, layering,
# closure-matrix, schema roundtrip, manifests, ci-workflows, doc-commands,
# lane-assertions, test-infra-currency, and test-clock-hygiene all passed

Summary by CodeRabbit

Release Notes

  • New Features

    • Added polylogue ops state candidates command group with subcommands to manage candidate assertions: accept, reject, defer, supersede, and list.
    • Assertion candidates now tracked and visible as actionable items in the debt cockpit via polylogue ops debt list --kind assertion-candidate.
  • Documentation

    • Updated CLI reference with new state candidates command documentation.
    • Added assertion candidate judgment workflow documentation with examples and command walkthroughs.

@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 20, 2026 •

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

Adds a complete candidate assertion judgment workflow. The storage tier gains AssertionKind.JUDGMENT, deterministic id helpers, and judge_assertion_candidate/list_assertion_candidates functions that implement accept/reject/defer/supersede transitions. Surface payloads, the archive facade, a new polylogue ops state candidates CLI group, and archive-debt integration are all wired together, with tests and docs updated throughout.

Changes

Candidate Assertion Judgment

Layer / File(s) Summary
Storage: judgment kind, id helpers, envelope, list/judge
polylogue/storage/sqlite/archive_tiers/user_write.py
Adds AssertionKind.JUDGMENT, deterministic id helpers for judgment and promoted-candidate assertions, ArchiveAssertionJudgmentEnvelope dataclass, and the list_assertion_candidates/judge_assertion_candidate public functions with internal helpers for candidate promotion, ref normalization, and status transitions. Exports updated via __all__.
Surface payloads: judgment types and debt kind
polylogue/surfaces/payloads.py
Introduces AssertionJudgmentPayload and AssertionJudgmentResultPayload with from_envelope constructors and field validators. Extends ArchiveDebtKind with "assertion-candidate". Updates TYPE_CHECKING imports and __all__.
Archive facade: list and judge methods
polylogue/api/archive.py
Adds _archive_judge_assertion_candidate internal helper that opens user.db, calls storage-tier judgment, and maps errors. Extends PolylogueArchiveMixin with list_assertion_candidates and judge_assertion_candidate async methods.
CLI: state candidates group and debt kind
polylogue/cli/commands/user_state.py, polylogue/cli/commands/debt.py
Registers candidates click group under state_command with list, accept, reject, defer, and supersede subcommands, all routed through _emit_candidate_judgment. Extends _DEBT_KINDS and updates the debt list docstring to include assertion-candidate.
Archive debt: candidate row generation
polylogue/operations/archive_debt.py
Adds _assertion_candidate_rows that reads user.db in read-only mode, calls list_assertion_candidates, and maps each candidate to an ArchiveDebtRowPayload with kind=assertion-candidate, stage=candidate-judgment. Wires the new kind into archive_debt_list.
Tests: storage, facade, CLI, debt
tests/unit/storage/test_archive_tiers_assertions.py, tests/unit/api/test_facade_contracts.py, tests/unit/cli/test_assertion_candidates.py, tests/unit/operations/test_archive_debt.py
Adds four storage tests for accept/reject/defer/supersede outcomes, a facade contract test for judge_assertion_candidate, CLI tests for list and accept JSON output, a debt test for candidate row generation, and updates facade method allowlists.
Docs, schema, and CLI help baselines
docs/search.md, docs/cli-reference.md, docs/schemas/cli-output/archive-debt-list.schema.json, docs/test-quality-workflows.md, tests/baselines/showcase/help-ops-state-candidates*, tests/baselines/showcase/help-ops-*.txt
Updates JSON schema kind enum, adds "Assertion Candidate Judgment" doc section, CLI reference entry, all new help-ops-state-candidates* baseline fixtures, and updates existing help baselines and test-quality snapshot counts.

Sequence Diagram(s)

sequenceDiagram
    participant Operator
    participant CLI as polylogue ops state candidates
    participant Facade as PolylogueArchiveMixin
    participant Storage as user_write.py (user.db)

    Operator->>CLI: accept <candidate_ref> --reason TEXT
    CLI->>Facade: judge_assertion_candidate(candidate_ref, decision="accept", reason=...)
    Facade->>Storage: _archive_judge_assertion_candidate → judge_assertion_candidate(conn, ...)
    Storage->>Storage: validate decision, resolve candidate
    Storage->>Storage: _promote_candidate_assertion (status→active, evidence+supersedes wiring)
    Storage->>Storage: upsert JUDGMENT assertion (deterministic id, evidence refs)
    Storage-->>Facade: ArchiveAssertionJudgmentEnvelope
    Facade-->>CLI: AssertionJudgmentResultPayload
    CLI-->>Operator: JSON or text (candidate → resulting_assertion_ref)
Loading
sequenceDiagram
    participant Operator
    participant DebtCLI as polylogue ops debt list
    participant ArchiveDebt as archive_debt_list
    participant CandidateRows as _assertion_candidate_rows
    participant Storage as user_write.py (user.db)

    Operator->>DebtCLI: --kind assertion-candidate --only-actionable
    DebtCLI->>ArchiveDebt: archive_debt_list(kind="assertion-candidate")
    ArchiveDebt->>CandidateRows: _assertion_candidate_rows(user.db path)
    CandidateRows->>Storage: list_assertion_candidates(conn)
    Storage-->>CandidateRows: list[ArchiveAssertionEnvelope]
    CandidateRows-->>ArchiveDebt: list[ArchiveDebtRowPayload] (kind=assertion-candidate, stage=candidate-judgment)
    ArchiveDebt-->>DebtCLI: ArchiveDebtListPayload
    DebtCLI-->>Operator: formatted debt rows
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

  • Sinity/polylogue#1928: Introduces mark_assertion_status(...) in user_write.py, which this PR calls directly to implement reject and defer candidate status transitions.
  • Sinity/polylogue#1973: Adds the upstream status=candidate assertion writer for transform candidates, forming the "candidate creation → candidate judgment" pipeline that this PR completes.

Suggested labels

type:test, area:storage, area:schema, area:qa

Poem

🐇 Hop through the queue, each candidate waits,
Accept or reject — the rabbit deliberates!
With supersede and defer in paw,
No silent promotion slips through raw.
The judgment is written, the lineage is clear,
From status:candidate to active, my dear! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 28.13% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'feat(assertions): add candidate judgment workflow' directly and clearly summarizes the main change in the PR—implementing an explicit candidate-assertion judgment workflow.
Description check ✅ Passed The PR description covers all major sections: Summary, Problem, Solution, Acceptance Matrix, Verification, and Risks. It addresses the repository template requirements comprehensively.
Linked Issues check ✅ Passed The PR implementation fully satisfies issue #2182 objectives: storage extensions with judgment assertions, Python API and CLI surfaces, archive debt integration, documentation updates, and comprehensive test coverage for all judgment paths.
Out of Scope Changes check ✅ Passed All changes are in-scope: storage extensions for judgments, payload models, API methods, CLI commands, archive debt integration, documentation, and tests—all directly supporting the candidate judgment workflow objective.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/feat/assertion-candidate-promotion-2182

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 and usage tips.

github-actions Bot pushed a commit that referenced this pull request Jun 20, 2026
@Sinity
Sinity merged commit 28455f9 into master Jun 20, 2026
13 of 14 checks passed
@Sinity
Sinity deleted the feature/feat/assertion-candidate-promotion-2182 branch June 20, 2026 02:10
Sinity added a commit that referenced this pull request Jun 20, 2026
## Summary

Completes the candidate-judgment follow-up surfaced by the broad
verification pass after #2204: command help aliases, facade status
routing, assertion audit coverage, and generated showcase baselines now
include the new candidate judgment surface.

## Problem

The #2182 implementation merged cleanly through CI, but a seed-testmon
verification run immediately afterward exercised broader catalog checks
and found stale surfaces: two `--limit` options lacked the expected `-l`
alias, the archive facade status route catalog did not know the new
async candidate/explain methods, the user-tier audit omitted
`AssertionKind.JUDGMENT`, and the SQL interpolation audit line keys had
shifted.

## Solution

- Added `-l` aliases to `polylogue ops debt list --limit` and `polylogue
ops state candidates list --limit`.
- Registered `explain_import`, `list_assertion_candidates`, and
`judge_assertion_candidate` in the facade route catalog.
- Added judgment assertions to the user overlay audit map.
- Updated the audited SQL line keys for the assertion projection
f-strings.
- Regenerated the two affected showcase help baselines.

## Verification

- `devtools test
tests/unit/cli/test_theme_aliases_help_markdown.py::test_flag_aliases_consistent
tests/unit/cli/test_status.py::test_archive_facade_route_catalog_covers_public_async_facade
tests/unit/storage/test_archive_tiers_user_audit.py::test_user_overlay_audit_covers_every_assertion_kind
tests/unit/storage/test_no_string_interpolated_sql.py::test_no_unaudited_string_interpolated_sql
tests/unit/storage/test_no_string_interpolated_sql.py::test_audited_sites_are_real_violations
-q` -> `5 passed`
- `devtools render all --check` -> pass
- `devtools lab scenario verify-baselines` -> `Ran 102 exercises; All
baselines match.`
- `devtools verify --quick` -> exit_code 0

Closes #2182
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.

feat(assertions): promote candidate claims through explicit operator judgment

1 participant