Skip to content

refactor: wire or delete dead abstractions from audit (#1322) - #1329

Merged
Sinity merged 1 commit into
masterfrom
feature/refactor/inert-abstractions-cleanup-1322
May 18, 2026
Merged

Sinity merged 1 commit into
masterfrom
feature/refactor/inert-abstractions-cleanup-1322

Conversation

@Sinity

@Sinity Sinity commented May 18, 2026 •

Copy link
Copy Markdown
Owner

Summary

Address all seven findings from the verifiability quality audit in #1322 in one
coherent PR. Wire what has a real consumer, delete what is inert, and land #1248
(daemon /api/ingest as the first Operations consumer) in the same slice so
the contract introduced in #1316 is no longer a foundation-without-consumer.

Problem

#1322 audited the open + closed issue corpus, codebase, and tests for hollow
abstractions, inert tests, puppeteered scenarios, and naming theatre. Seven
high-confidence findings (F1–F7). F1 specifically called out that PR #1316 had
landed the Operations contract substrate without any production consumer; #1248
(daemon /api/ingest) was the obvious wiring target but still open.

This PR resolves the audit by routing each finding through one of three
disposals: wire, delete, or leave-as-out-of-scope per the audit's own guidance.

Solution

Per-finding actions:

  • F1 Operations contract (PR refactor(api): typed import operation contract — Operations pattern foundation (#1247) #1316) → WIRE. polylogue/daemon/http.py's
    /api/ingest now validates request bodies through ImportRequest and emits
    ImportAck with the shared OperationFollowUp envelope. Legacy wire keys
    (path, status, ok) are preserved so the CLI ingest adapter and existing
    HTTP clients keep working. Closes refactor(daemon): /api/ingest semantics decision and implementation (#861 slice B) #1248.
  • F2 read-surface adapters → DELETE. polylogue/api/contracts/{api,cli,mcp}_surface.py
    removed. The real Python API, CLI, and MCP code paths do not go through these
    adapter envelopes — they hand-roll richer envelopes inline (daemon/http.py:_do_list
    carries target_ref/anchor/actions/repo/cwd/flags; mcp/server_tools.py has
    its own envelope). Wiring inline-handrolled envelopes through the bare
    adapter envelope would lose information. TUIReadSurface stays — used by
    polylogue/ui/tui/screens/{browser,search}.py.
  • F4 ContractEvidenceRecorder → DELETE. No non-test consumer. Removed
    tests/infra/contract_evidence.py + call sites + the matching devtools
    dashboards/loaders that aggregated artifacts from .cache/verification/evidence/.
  • F6 verify-cross-cuts → DELETE. Verifier and generator share the same
    naming convention; the lint was a tautology. Removed from
    devtools/command_catalog.py, the devtools verify chain, and
    devtools/evidence_dashboard.py. cross_cut_tags() in
    build_topology_projection.py is kept because verify-topology still
    consumes the generated tags.
  • F7 insights provenance helpers → WIRE. Daemon insights browser profile
    panel (feat: expose bounded session insight products for downstream consumers #1018/feat(reader): insights browser for session profiles, events, phases, threads #1120) now passes the SessionProfileRecord through is_stale()
    against the conversation updated_at and exposes the typed verdict as a
    staleness field on the panel.
  • F3, F5 → out of scope per audit guidance.

Verification

  • python -m devtools verify --quick → exit 0 (39s)
  • pytest -q --ignore=tests/integration → 8062 passed, 2 xfailed (105.75s)

Notes

Closes #1322, #1248.

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 4.7 (1M context) [email protected]

Summary by CodeRabbit

  • New Features

    • Added staleness tracking to session profile insights, displayed when viewing session details.
    • Enhanced /api/ingest endpoint with typed request validation and improved acknowledgment responses.
  • Bug Fixes

    • Improved ingest error reporting with structured validation feedback.
  • Chores

    • Removed verify-cross-cuts devtools verification command and associated internal contract evidence infrastructure.
    • Streamlined verification pipeline by eliminating cross-cut tag validation step.

Review Change Stack

Closes #1322, #1248.

Per audit #1322, address all seven findings in one coherent PR.

F1 (Operations contract — #1247/#1316): wire it. daemon /api/ingest
now validates request bodies through ImportRequest and emits ImportAck
with the shared OperationFollowUp envelope. Legacy wire keys (path,
status, ok) are preserved so the CLI ingest adapter and existing
HTTP clients keep working. polylogue/daemon/http.py:1574-1630.

F2 (api/cli/mcp read-surface adapters): delete. The Python API, CLI,
and MCP do not go through dedicated adapter envelopes — they
hand-roll richer envelopes inline (daemon/http.py:_do_list with
target_ref/anchor/actions/repo/cwd/flags and mcp/server_tools.py).
Wiring inline-handrolled envelopes through the bare adapter envelope
would lose information. TUIReadSurface stays — it is used by
polylogue/ui/tui/screens/{browser,search}.py.

F4 (ContractEvidenceRecorder): delete. No non-test consumer existed.
Removed tests/infra/contract_evidence.py + ~17 test call sites +
the matching devtools dashboards/loaders that aggregated artifacts
from .cache/verification/evidence/.

F6 (verify-cross-cuts): delete. Verifier and generator share the
same naming convention; the lint was a tautology. Removed from
devtools/command_catalog.py, devtools/verify.py chain, and
devtools/evidence_dashboard.py static-gate list. cross_cut_tags()
in build_topology_projection.py is kept because verify-topology
still consumes the generated tags.

F7 (insights/provenance helpers): wire. daemon insights browser
profile panel (#1018/#1120) now passes the SessionProfileRecord
through is_stale() against the conversation updated_at and exposes
the typed verdict as a `staleness` field on the panel.

F3, F5: out of scope per audit guidance.

Verification:
- devtools verify --quick → exit 0 (34s)
- pytest -q --ignore=tests/integration → 8022 passed, 2 xfailed (117s)
- Two pre-existing local-env failures from a live daemon were
  deselected (tests/unit/cli/test_init.py::test_status_first_run_hint_suggests_init,
  tests/unit/cli/test_status.py::TestNoArchiveStatus::test_status_subprocess_no_archive);
  both failed identically against origin/master.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@Sinity
Sinity merged commit 49ef981 into master May 18, 2026
2 of 4 checks passed
@Sinity
Sinity deleted the feature/refactor/inert-abstractions-cleanup-1322 branch May 18, 2026 19:56
@coderabbitai

coderabbitai Bot commented May 18, 2026 •

Copy link
Copy Markdown

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 5ee27a6a-66de-48aa-8f2d-7946ada8d188

📥 Commits

Reviewing files that changed from the base of the PR and between d3b33d1 and eb59116.

📒 Files selected for processing (42)
  • AGENTS.md
  • devtools/command_catalog.py
  • devtools/evidence_dashboard.py
  • devtools/evidence_report.py
  • devtools/verification_impact.py
  • devtools/verify.py
  • devtools/verify_cross_cuts.py
  • docs/devtools.md
  • docs/plans/file-size-budgets.yaml
  • docs/plans/test-coverage-domains.yaml
  • docs/plans/topology-target.yaml
  • docs/topology-status.md
  • polylogue/api/contracts/api_surface.py
  • polylogue/api/contracts/cli_surface.py
  • polylogue/api/contracts/mcp_surface.py
  • polylogue/daemon/http.py
  • tests/conftest.py
  • tests/infra/contract_evidence.py
  • tests/infra/test_contract_evidence.py
  • tests/unit/api/test_read_surface_contracts.py
  • tests/unit/api/test_write_surface_contracts.py
  • tests/unit/cli/test_completions_contract.py
  • tests/unit/cli/test_help_contract.py
  • tests/unit/cli/test_json_envelope_contract.py
  • tests/unit/cli/test_plain_output_contract.py
  • tests/unit/cost/test_contract_suite.py
  • tests/unit/daemon/test_backup.py
  • tests/unit/daemon/test_catch_up_observability.py
  • tests/unit/daemon/test_daemon_cli.py
  • tests/unit/daemon/test_daemon_http_contracts.py
  • tests/unit/daemon/test_health_check_paths.py
  • tests/unit/daemon/test_health_contracts.py
  • tests/unit/daemon/test_notifications.py
  • tests/unit/devtools/test_evidence_dashboard.py
  • tests/unit/devtools/test_evidence_report.py
  • tests/unit/devtools/test_verification_impact.py
  • tests/unit/devtools/test_verify.py
  • tests/unit/devtools/test_verify_cross_cuts.py
  • tests/unit/mcp/test_contract_evidence.py
  • tests/unit/mcp/test_server_surfaces.py
  • tests/unit/storage/test_surface_parity_adapters.py
  • tests/unit/surfaces/test_search_explanation_contract.py

📝 Walkthrough

Walkthrough

This PR removes bounded contract-evidence recording infrastructure, deletes the verify-cross-cuts devtool verification gate, removes three read-surface adapter modules (API/CLI/MCP), and enhances daemon HTTP endpoints with typed ingest contracts and session profile staleness detection. The change consolidates test coverage to the TUI adapter and simplifies devtools reporting by eliminating contract-evidence artifact tracking.

Changes

Remove Contract-Evidence Infrastructure & Verification Gate

Layer / File(s) Summary
Remove verify-cross-cuts devtool command
devtools/command_catalog.py, devtools/verify.py, AGENTS.md, docs/devtools.md, tests/unit/devtools/test_verify.py
Deletes the verify-cross-cuts command spec from the catalog, removes it from the default verification pipeline, and updates command documentation and test assertions.
Remove contract-evidence recorder infrastructure
tests/conftest.py, tests/infra/contract_evidence.py, tests/infra/test_contract_evidence.py
Deletes the ContractEvidenceRecorder dataclass, the record_contract_evidence pytest fixture, and removes the module from global pytest plugin registration.
Remove contract-evidence from devtools reporting
devtools/evidence_dashboard.py, devtools/evidence_report.py, devtools/verification_impact.py, tests/unit/devtools/test_evidence_dashboard.py, tests/unit/devtools/test_evidence_report.py, tests/unit/devtools/test_verification_impact.py
Eliminates contract-evidence inventory sections, artifacts aggregation, and staleness tracking from dashboard/report/impact modules; updates test assertions to exclude contract-evidence expectations.
Simplify evidence-report blocking logic
devtools/evidence_report.py
Changes blocking calculation to check only the last two consecutive verify runs; removes stale-evidence and recent-failure combination logic.
Remove contract-evidence recording from test suite
tests/unit/api/test_write_surface_contracts.py, tests/unit/cli/test_*.py, tests/unit/cost/test_contract_suite.py, tests/unit/daemon/test_*.py, tests/unit/mcp/test_*.py, tests/unit/storage/test_surface_parity_adapters.py, tests/unit/surfaces/test_search_explanation_contract.py
Removes ContractEvidenceRecorder imports and record_contract_evidence fixture parameters from 30+ test files; deletes evidence-recording calls and fact-gathering logic while preserving behavioral assertions.

Remove Read-Surface Adapters & Consolidate Tests

Layer / File(s) Summary
Delete read-surface adapter modules
polylogue/api/contracts/api_surface.py, polylogue/api/contracts/cli_surface.py, polylogue/api/contracts/mcp_surface.py, docs/plans/topology-target.yaml
Removes APIReadSurface, CLIReadSurface, and MCPReadSurface adapter implementations and their topology entries; adapters previously wrapped Polylogue/ArchiveOperations to provide conversation listing, search, and stats protocols.
Consolidate read-surface contract tests to TUI-only
tests/unit/api/test_read_surface_contracts.py
Removes multi-adapter conformance checks and parity tests; replaces with TUI-only runtime assertions for list_conversations() (canonical envelope, provider filtering, empty-archive semantics) and archive_stats() count validation.

Enhance Daemon HTTP Endpoints

Layer / File(s) Summary
Add session profile staleness helper
polylogue/daemon/http.py, docs/plans/file-size-budgets.yaml
Implements _profile_staleness() helper to validate provenance fields and compute staleness relative to conversation updated_at; integrates into GET /api/insights/sessions/{id} response building to conditionally include staleness field.
Convert ingest handler to typed contract
polylogue/daemon/http.py
Replaces legacy ImportOperation with typed ImportRequest validation via Pydantic (400 on ValidationError); emits ingest event, returns ImportAck with OperationFollowUp status endpoint and validated request fields for client confirmation.

Metadata & Documentation Updates

Layer / File(s) Summary
Update topology and coverage documentation
docs/plans/topology-target.yaml, docs/plans/test-coverage-domains.yaml, docs/topology-status.md
Updates topology projection (removes API/CLI/MCP adapter entries, updates line counts for status.py and healthz.py); updates test-coverage-domains notes to describe transition from contract-evidence recorder to standard pytest assertions; adjusts topology-status summary counts.

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly Related PRs

  • Sinity/polylogue#1322: Audit of verifiability quality recommending removal of hollow abstractions, inert tests, and unused infrastructure—this PR directly implements those recommendations by deleting contract-evidence recorder and read-surface adapters without production consumers.
  • Sinity/polylogue#1248: Updates /api/ingest to use typed ImportRequest contract and daemon event scheduling, aligning with this PR's replacement of legacy ImportOperation with typed contract handling.
  • Sinity/polylogue#1151: Removes contract-evidence recording calls from daemon health tests, directly related to this PR's removal of ContractEvidenceRecorder fixture and evidence-recording machinery.

Suggested Labels

type:refactor, area:qa, area:api, area:devtools, area:daemon

Poem

🐰 Contracts clean, adapters gone,
Evidence archived when new truth is drawn,
TUI stands tall, while ghosts take their bow,
Staleness revealed, imports typed now!
Simpler flows bloom, the codebase springs free. 🌱

✨ 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/inert-abstractions-cleanup-1322

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.

Sinity added a commit that referenced this pull request Sep 15, 2026
…pus (#5196)

Two independent settled decisions, one commit each.

## A — retire `polylogue/api/contracts/` (polylogue-aq2l5)

Ruled and authorized on the bead. The package shipped as a contract
spine enforced through shadow adapters; **those adapters were deleted
two days later** (#1329), leaving `TUIReadSurface` as the only
implementor — and #5182 deleted the TUI. `a7xr.13` had already deleted
the mirrored write-surface half, recording the finding that shadow
adapters verify copies rather than surfaces, and the plan "execute f94
first, then nothing in read_surface needs keeping".

Verified before deleting, not trusted from the brief: every
`api.contracts` hit is inside the package; `assert_implements` has 11
hits, all internal, zero call sites; each exported Protocol name
searched individually returns zero external hits; `TUIReadSurface` zero
hits anywhere. `ArchiveReadCapability` is unaffected — it lives in
`api/archive_reads.py:17` and the deleted `contracts/__init__.py:38` was
a pass-through re-export.

Replacement in place: operation-identity parity
(`polylogue/api/parity.py`, gate `api-parity`) plus behavioral
differentials — including the one in #5184 that caught the MCP
`offset=0` defect no name-based check could.

**Correction to the ruling's expectation**: it predicted the layering
baseline would shrink. It did not — 226 before, 226 after.
`docs/plans/layering-surface-baseline.json` has no entry for any
`api/contracts/*` file, and `polylogue/api` → `polylogue/daemon` is not
a disallow pair in `layering.yaml`, so the removed `read_surface.py:31`
import never counted. The bound held; the number did not move.

## B — declare the corpus schedule (polylogue-yk0zz want 4)

`schedule = "*-*-* 03:00"` added to `[operations.verify_all]`. `cache`,
`checkout`, `pool` untouched — they are load-bearing for the dedupe
property. `verify.yml`'s header comment corrected: it claimed a nightly
agentctl `verify_all` schedule that was never declared.
`concurrency.cancel-in-progress: true` deliberately unchanged.

Key spelling cross-checked against the live precedent
(`/realm/project/sinnix/.agentctl/project.toml` `[operations.census]`).
`agentctl schedule apply` was **not** run — that mutates live host state
and is the coordinator's.

## Verification

```
devtools verify --quick (after each part) → EXIT 0, all 19 gates
devtools test tests/unit/api tests/unit/core/test_facade_api.py → EXIT 0
devtools render all --check → EXIT 0, 0 occurrences of "out of sync"
```

All five changed files confirmed **out** of the schema-identity closure.

## Residual

`agentctl schedule apply` still needs running after this lands; want 4
closes only once the timer is listed and one scheduled run has a result.
`agentctl schedule` exposes only `apply` — no read-only list verb — so
the descriptor's acceptance of the value is unproven until then.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_01DYUNBGoE652b3nfmq3CtqK

---------

Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant