Skip to content

refactor(devtools): streamline verification surface — fold proof-pack and obligation-diff (#1073) - #1073

Merged
Sinity merged 3 commits into
masterfrom
feature/refactor/verification-streamline
May 16, 2026
Merged

Sinity merged 3 commits into
masterfrom
feature/refactor/verification-streamline

Conversation

@Sinity

@Sinity Sinity commented May 16, 2026 •

Copy link
Copy Markdown
Owner

Summary

Consolidates three overlapping verification entry-points (proof-pack,
obligation-diff, affected-obligations) into one command with flags.
Removes inject-semantic-annotations as a command (one-shot migration
tool; underlying function stays for tests). Fixes a latent FTS5 bug.
Net: −2 commands, −2 files, cleaner operator surface.

Problem

The devtools command catalog had accumulated redundant entry points:

  • obligation-diff was affected-obligations --markdown with no other
    unique behavior
  • proof-pack overlapped with affected-obligations at the PR-check
    layer; having both confused which to run
  • inject-semantic-annotations was a one-shot migration tool still
    appearing as a first-class operator command
  • proof-pack --check in devtools verify didn't survive catalog removal

Solution

  • Delete devtools/obligation_diff.py — folded --markdown flag into
    affected_obligations.py
  • Add --full flag to affected-obligations that delegates to the
    internal proof_pack build/evaluate/render API; --check fails on
    blocking policy
  • Move anti-vacuity reporting to render-verification-catalog --anti-vacuity
  • Remove proof-pack and inject-semantic-annotations from
    command_catalog.py
  • Update devtools verify default gate: proof-pack --check →
    affected-obligations --full --check
  • Fix all stale devtools proof-pack references in proof/diffing.py
    and tests
  • Fix fts_lifecycle.py: use FTS5 rebuild instead of delete-all
    (SQLite rejects delete-all on content= tables)

Verification

devtools verify --quick   # all 16 gates green (pre-push hook passed)

Ref #594

Summary by CodeRabbit

  • New Features

    • devtools affected-obligations now supports --markdown output and --full mode for complete proof-pack impact reporting with optional --check policy validation.
    • devtools render-verification-catalog now includes --anti-vacuity mode for anti-vacuity dashboard rendering.
  • Removed Features

    • devtools proof-pack and devtools obligation-diff commands have been removed; use devtools affected-obligations --full instead.
  • Documentation

    • Updated command catalog documentation to reflect new CLI options and removed commands.

Review Change Stack

Sinity and others added 3 commits May 16, 2026 07:53
…rop inject-semantic-annotations

- Delete devtools/obligation_diff.py — its only unique value was a
  --markdown flag; absorbed into affected_obligations.py as --markdown
- Add render_affected_obligations_markdown to affected_obligations.main
- Change default --base-ref from "master" to "origin/master" (matches
  proof_pack's operationally correct default)
- Remove inject-semantic-annotations from command catalog — the
  underlying inject_annotations() function stays for tests, but the
  command was a one-shot migration tool with no ongoing callers
- Regenerate docs/devtools.md and AGENTS.md after catalog change

Net: -1 devtools command, -1 devtools file, 129 lines deleted.

Co-Authored-By: Claude <[email protected]>
- Remove proof-pack as a user-facing devtools command; proof_pack.py
  stays as an internal library used by affected-obligations --full
- Add --full flag to affected-obligations, delegating to proof_pack
  build/evaluate/render API; --check fails on blocking policy
- Add --anti-vacuity flag to render-verification-catalog, replacing
  build_anti_vacuity_report as a command entrypoint
- Update devtools verify default gate from proof-pack --check to
  affected-obligations --full --check
- Fix all stale "devtools proof-pack" references in proof/diffing.py
  and tests
- Regenerate docs/devtools.md and AGENTS.md

Net: -1 command (proof-pack), single entry point for PR impact reports.

Co-Authored-By: Claude <[email protected]>
SQLite rejects INSERT INTO fts(fts) VALUES('delete-all') on external-
content FTS5 tables — only valid on contentless tables. Use the 'rebuild'
control command instead, which repopulates from the content= source table.

Co-Authored-By: Claude <[email protected]>
@coderabbitai

coderabbitai Bot commented May 16, 2026 •

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

This PR consolidates proof-pack and obligation-diff functionality into an expanded affected-obligations command, adds anti-vacuity dashboard reporting to render-verification-catalog, removes standalone commands, and updates the verification workflow and documentation accordingly. FTS5 rebuild logic is separately optimized to use native rebuild commands.

Changes

Consolidate proof-pack checks into affected-obligations with anti-vacuity support

Layer / File(s) Summary
affected-obligations: expand to support full reports and markdown rendering
devtools/affected_obligations.py, tests/unit/devtools/test_affected_obligations.py
affected_obligations.py adds --markdown, --full, and --check flags. --full builds a proof-pack impact report with optional check-status evaluation and non-zero exit on policy failure. --markdown in normal mode renders and returns early. Default --base-ref updated to origin/master. New test validates markdown rendering.
render-verification-catalog: add anti-vacuity dashboard mode
devtools/render_verification_catalog.py
New --anti-vacuity flag builds and emits an anti-vacuity dashboard (JSON or markdown) instead of the normal verification catalog. Exit code is determined by dashboard["flagged_count"] when --check is set. Normal catalog path remains unchanged.
Command catalog: document new modes and remove obsolete commands
devtools/command_catalog.py
render-verification-catalog examples expanded with --anti-vacuity; affected-obligations examples updated to include --markdown and --full --markdown variants using origin/master; proof-pack command entry removed; regression-capture pipeline example added.
Verification flow: switch commit tier from proof-pack to affected-obligations
devtools/verify.py, tests/unit/devtools/test_verify.py, tests/unit/proof/test_diffing.py
verify.py --commit tier switches from proof-pack --check to affected-obligations --full --check. Top-level docstring, build_verify_steps logic, and argparse help text updated. Tests expect new step labels in verification and proof-diffing checks.
Documentation: sync command references across AGENTS.md and docs/devtools.md
AGENTS.md, docs/devtools.md
Verification-lab and verification tables expanded to document --anti-vacuity and --full flags. Verification table removes obligation-diff and proof-pack rows. Maintenance section removes inject-semantic-annotations entry. Same updates applied to both files.
Proof diffing: update recommended inner-loop checks to use affected-obligations
polylogue/proof/diffing.py
coverage_manifest and proof_catalog change-kind routing replaces devtools proof-pack checks with devtools affected-obligations --full equivalents. All other routing logic and report rendering preserved.

FTS5 rebuild logic optimization

Layer / File(s) Summary
FTS lifecycle: use FTS5 rebuild command for messages_fts
polylogue/storage/fts/fts_lifecycle.py
rebuild_fts_index_sync and rebuild_fts_index_async now execute FTS5 rebuild control command for messages_fts instead of empty-then-rebuild. Operation sequence adjusted so FTS_REBUILD_SQL executes before clearing action_events_fts. Docstring updated to document FTS5 delete-all constraints.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • Sinity/polylogue#438: Both PRs modify devtools/verify.py's build_verify_steps command sequencing for the --commit tier.
  • Sinity/polylogue#690: Contrasts with the main PR by adding enforcement of devtools proof-pack --check while this PR consolidates that functionality into affected-obligations --full --check.
  • Sinity/polylogue#577: Related changes to devtools/obligation_diff.py and devtools/command_catalog.py around proof-pack and obligation-diff behavior consolidation.

Suggested labels

type:refactor, area:devtools, area:qa

Poem

🐰 We've bundled proof-pack's strength with obligations neat,
Added anti-vacuity dashboards—a verification treat!
FTS5 rebuilds now march in native command cadence,
Streamlined docs and flows for development's sweet evidence.
The proof is consolidated, the catalog runs true,
One cohesive verification path, brand new! 🌟

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 16.67% 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 clearly identifies the main change: refactoring to streamline the verification surface by consolidating overlapping devtools commands (proof-pack and obligation-diff into affected-obligations).
Description check ✅ Passed The description follows the template structure with all required sections: Summary (1-3 sentences explaining the consolidation), Problem (explaining the redundancy), Solution (listing all key changes and modules touched), and Verification (command run and results).
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ 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/refactor/verification-streamline

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.

@coderabbitai coderabbitai 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.

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
tests/unit/proof/test_diffing.py (1)

139-154: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Unify proof-catalog command expectation in both tests.

test_proof_pack_test_change_routes_to_catalog_obligations still asserts devtools proof-pack --check (Line 154), but routing now emits devtools affected-obligations --full --check. This leaves contradictory expectations for the same proof_catalog path kind.

Suggested test fix
-    assert "devtools proof-pack --check" in [check.rendered_command for check in report.inner_loop_checks]
+    assert "devtools affected-obligations --full --check" in [
+        check.rendered_command for check in report.inner_loop_checks
+    ]
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/unit/proof/test_diffing.py` around lines 139 - 154, The test
test_proof_pack_test_change_routes_to_catalog_obligations asserts the old
command "devtools proof-pack --check" but routing now emits "devtools
affected-obligations --full --check"; update the expectation in that test to
look for "devtools affected-obligations --full --check" (i.e., replace the
assertion that checks [check.rendered_command for check in
report.inner_loop_checks] contains "devtools proof-pack --check" with one that
asserts it contains "devtools affected-obligations --full --check") so both
tests consistently expect the new proof_catalog command.
polylogue/storage/fts/fts_lifecycle.py (1)

212-223: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Duplicate FTS_REBUILD_SQL execution when conversation_ids is None.

Line 212 now executes FTS_REBUILD_SQL, but line 222 still executes it again when the early-return path isn't taken. This rebuilds messages_fts twice in the conversation_ids is None case.

🔧 Proposed fix to remove redundant rebuild
     await conn.execute(FTS_REBUILD_SQL)
     await conn.execute("DELETE FROM action_events_fts")
     if conversation_ids is not None:
         await repair_fts_index_async(
             conn,
             conversation_ids,
             progress_callback=progress_callback,
             progress_desc=progress_desc,
         )
         return
-    await conn.execute(FTS_REBUILD_SQL)
     await conn.execute(ACTION_FTS_REBUILD_SQL)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@polylogue/storage/fts/fts_lifecycle.py` around lines 212 - 223, The code
currently calls await conn.execute(FTS_REBUILD_SQL) twice when conversation_ids
is None; remove the redundant rebuild by only executing FTS_REBUILD_SQL once and
keeping the existing ACTION_FTS_REBUILD_SQL execution. Concretely, adjust the
control flow in the function containing conversation_ids, conn.execute, and
repair_fts_index_async so that the initial await conn.execute(FTS_REBUILD_SQL)
is not executed unconditionally before the conversation_ids check (or remove the
later duplicate), leaving a single call to conn.execute(FTS_REBUILD_SQL) and
then conn.execute(ACTION_FTS_REBUILD_SQL) in the None case, and calling
repair_fts_index_async(...) then return in the conversation_ids is not None
case.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@devtools/affected_obligations.py`:
- Around line 37-41: Add a parse-time validation so the --check flag cannot be
used without --full: after you call parser.parse_args() (or in the function that
builds/returns args) check if args.check and not args.full and call
parser.error("The --check flag requires --full") (or raise SystemExit with the
same message) to fail fast; update the logic around parser.add_argument for
"--check" and the place where "--full" is defined to ensure the error is raised
during argument parsing rather than allowing silent success.

In `@tests/unit/devtools/test_affected_obligations.py`:
- Around line 45-60: Add a regression test in
tests/unit/devtools/test_affected_obligations.py that verifies running
affected_obligations.main with the CLI flag combination "--check" but without
"--full" exits with an error (raises SystemExit); reuse the existing monkeypatch
pattern to stub affected_obligations.changed_paths_between_refs and
affected_obligations.obligation_ids_for_ref so the test isolates argument
parsing, and assert that calling affected_obligations.main(["--check",
"--base-ref", "origin/master", "--head-ref", "HEAD"]) raises SystemExit (or
returns non-zero) to prevent future regressions in the CLI contract.

---

Outside diff comments:
In `@polylogue/storage/fts/fts_lifecycle.py`:
- Around line 212-223: The code currently calls await
conn.execute(FTS_REBUILD_SQL) twice when conversation_ids is None; remove the
redundant rebuild by only executing FTS_REBUILD_SQL once and keeping the
existing ACTION_FTS_REBUILD_SQL execution. Concretely, adjust the control flow
in the function containing conversation_ids, conn.execute, and
repair_fts_index_async so that the initial await conn.execute(FTS_REBUILD_SQL)
is not executed unconditionally before the conversation_ids check (or remove the
later duplicate), leaving a single call to conn.execute(FTS_REBUILD_SQL) and
then conn.execute(ACTION_FTS_REBUILD_SQL) in the None case, and calling
repair_fts_index_async(...) then return in the conversation_ids is not None
case.

In `@tests/unit/proof/test_diffing.py`:
- Around line 139-154: The test
test_proof_pack_test_change_routes_to_catalog_obligations asserts the old
command "devtools proof-pack --check" but routing now emits "devtools
affected-obligations --full --check"; update the expectation in that test to
look for "devtools affected-obligations --full --check" (i.e., replace the
assertion that checks [check.rendered_command for check in
report.inner_loop_checks] contains "devtools proof-pack --check" with one that
asserts it contains "devtools affected-obligations --full --check") so both
tests consistently expect the new proof_catalog command.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 7e13fa5e-85c0-431a-b030-41ac9c97e723

📥 Commits

Reviewing files that changed from the base of the PR and between 3cbf610 and 4b709f5.

📒 Files selected for processing (13)
  • AGENTS.md
  • devtools/affected_obligations.py
  • devtools/command_catalog.py
  • devtools/obligation_diff.py
  • devtools/render_verification_catalog.py
  • devtools/verify.py
  • docs/devtools.md
  • polylogue/proof/diffing.py
  • polylogue/storage/fts/fts_lifecycle.py
  • tests/unit/devtools/test_affected_obligations.py
  • tests/unit/devtools/test_obligation_diff.py
  • tests/unit/devtools/test_verify.py
  • tests/unit/proof/test_diffing.py
💤 Files with no reviewable changes (2)
  • devtools/obligation_diff.py
  • tests/unit/devtools/test_obligation_diff.py

Comment on lines +37 to +41
parser.add_argument(
"--check",
action="store_true",
help="Exit non-zero when blocking policy fails (only with --full).",
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Enforce --check/--full coupling at parse time.

--check is documented as valid only with --full, but currently it silently succeeds without --full, which can bypass policy gating in automation.

Suggested fix
     args = parser.parse_args(argv)
+    if args.check and not args.full:
+        parser.error("--check requires --full")
 
     if args.full:

Also applies to: 44-72

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@devtools/affected_obligations.py` around lines 37 - 41, Add a parse-time
validation so the --check flag cannot be used without --full: after you call
parser.parse_args() (or in the function that builds/returns args) check if
args.check and not args.full and call parser.error("The --check flag requires
--full") (or raise SystemExit with the same message) to fail fast; update the
logic around parser.add_argument for "--check" and the place where "--full" is
defined to ensure the error is raised during argument parsing rather than
allowing silent success.

Comment on lines +45 to +60
def test_main_markdown_renders_affected_obligations(
monkeypatch: pytest.MonkeyPatch,
capsys: pytest.CaptureFixture[str],
) -> None:
monkeypatch.setattr(
affected_obligations,
"changed_paths_between_refs",
lambda base_ref, head_ref: ("docs/plans/layering.yaml",),
)
monkeypatch.setattr(affected_obligations, "obligation_ids_for_ref", lambda ref: ())

assert affected_obligations.main(["--base-ref", "origin/master", "--head-ref", "HEAD", "--markdown"]) == 0

rendered = capsys.readouterr().out
assert "## Affected Verification Checks" in rendered
assert "`origin/master..HEAD`" in rendered

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion | 🟠 Major | ⚡ Quick win

Add a regression test for --check without --full.

Please add a test that asserts invalid usage fails (e.g., SystemExit from argparse), so the CLI contract can’t regress.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/unit/devtools/test_affected_obligations.py` around lines 45 - 60, Add a
regression test in tests/unit/devtools/test_affected_obligations.py that
verifies running affected_obligations.main with the CLI flag combination
"--check" but without "--full" exits with an error (raises SystemExit); reuse
the existing monkeypatch pattern to stub
affected_obligations.changed_paths_between_refs and
affected_obligations.obligation_ids_for_ref so the test isolates argument
parsing, and assert that calling affected_obligations.main(["--check",
"--base-ref", "origin/master", "--head-ref", "HEAD"]) raises SystemExit (or
returns non-zero) to prevent future regressions in the CLI contract.

@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: 4b709f5335

ℹ️ 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/storage/fts/fts_lifecycle.py Resolved
@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.

  • 73.F068 / P2: fixed-already at the checked revision: The full async rebuild at polylogue/storage/fts/fts_lifecycle.py:483 delegates once to rebuild_fts_index_sync. It no longer issues a separate full message rebuild before performing the shared synchronous lifecycle.

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