Repository navigation
chore: restore master verify --quick baseline (rendered docs, budgets, lint debt) - #1001
Conversation
devtools render-all --check has been failing on master since the 2026-05-09 PR wave (#871, #862, #864, #944, #870, #861) and earlier: several rendered docs were out of sync with their generators, blocking verify --quick on every branch. Regenerated: - AGENTS.md (worktree-relative include paths replaced by canonical toplevel paths after #eeace79 fixed repo_root resolution) - docs/cli-reference.md (added maintenance group, message_type_backfill target from #839) - docs/test-quality-workflows.md - docs/verification-catalog.md Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Three production files exceeded their declared file-size budget after recent PR merges: - polylogue/storage/repair.py 1281 > 1200 (from #818 + #839 backfill) - polylogue/operations/archive.py 1141 > 1100 (per_package; from #861/#862 contract centralization) - polylogue/daemon/status.py 1128 > 1100 (from #844/#898/#915 typed payloads) Each new exception entry names the architectural-split candidate that would let the ceiling shrink, matching the convention already used for existing exception entries. This restores verify-file-budgets to green without papering over the underlying pressure. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Multiple parallel PRs landed on 2026-05-09 with incompatible local lint state, leaving 42 ruff errors and 3 mypy errors on master that blocked verify --quick. Mechanical (ruff --fix): - 30 import-block reorderings across devtools/* after #eeace79 added a cross-module import (devtools.repo_root) that disturbed I001 sort - 3 unused imports (devtools/inject_semantic_annotations.py, devtools/verify_lane_assertions.py, devtools/xtask.py) - typing_extensions → typing modernization in polylogue/surfaces/payloads.py and polylogue/archive/semantic/__init__.py - import-block reordering in tests/unit/mcp/test_tool_contracts.py Manual: - polylogue/api/archive.py: add TagMutationResult to TYPE_CHECKING imports (#862 added the methods, never the type alias) - polylogue/cli/click_command_registration.py: export maintenance_group in __all__ so test_maintenance_registration.py can import it - polylogue/operations/archive.py: tighten get_index_status return type from dict[str, object] to IndexStatus TypedDict - tests/unit/daemon/test_maintenance_endpoints.py: cast MockServer/ MockHeaders to typed parents; add missing return annotation - tests/unit/daemon/test_raw_failure_sample.py: drop unused-ignore on literal-tuple iteration; cast info["samples"] for indexing; rename test_rejects_non_RawFailureSample_items to lowercase per N802 - tests/unit/cli/test_maintenance_registration.py: pass real click.Context to list_commands instead of None - tests/unit/pipeline/test_message_type_backfill.py: drop unused conv_id binding Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (45)
📝 WalkthroughWalkthroughThis PR executes a large-scale code quality refactor standardizing import ordering across 27 devtools scripts, updating documentation paths and references, improving type safety in core APIs, and enhancing test type annotations. The changes follow PEP 8 conventions and Python's ChangesImport Standardization and Type Safety Refactor
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 372ad23b23
ℹ️ 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".
… honest closure (#818) (#1002) ## Summary Brings #818 (blob orphan cleanup and integrity verification) to actual closure by adding the test layers that pin the contract end-to-end. The implementation surface (`BlobStore.detect_orphans` / `cleanup_orphans` / `verify_all`, `repair_orphaned_blobs` handler, `orphaned_blobs` maintenance target, daemon-side health integration) was already complete on master — what was missing was an integration test that fails loud if any layer disconnects, plus property coverage for the bounded-orphan invariant, plus a tighter assertion on the operator-visible orphan output, plus catalog-routing tests added during adversarial review. Closes #818. Depends on #1001 (verify baseline restoration) — merge that first; this branch rebases on it. ## Problem #818 was reopened during the 2026-05-09 closed-issue audit because the close-out language ("core implementation landed; remaining edges are incremental") matched the abandonment pattern flagged in `feedback_close_discipline.md`. The audit confirmed: implementation existed, but the test surface only covered unit-level slices — there was no end-to-end test pinning the contract operators rely on (`polylogue check` orphan output, `polylogue doctor --repair --target orphaned_blobs` round-trip), nor a property test for the bounded-output invariant on `detect_orphans`. Any regression in any one wiring layer (paths, blob_store, repair, maintenance) could land silently. ## Solution ### Acceptance criteria matrix | AC | What | State after this PR | |---|---|---| | 818-A1 | `detect_orphans` returns count, bytes, sample; bounded output independent of N | ✅ Implementation pre-existing; **new property test** in `tests/property/test_blob_store_props.py` asserts samples bounded by `max_sample` and counts/bytes match the disk-minus-DB set across hypothesis-generated (0–80 orphans, 1–20 max_sample) parameter space | | 818-A2 | `cleanup_orphans(dry_run=True)` default opt-in safety | ✅ Pre-existing; **new property test** asserts dry-run never deletes; **new e2e test** asserts TOCTOU race (blob vanished mid-cleanup) is no-op | | 818-A3 | `verify_all(max_failures)` re-hashes blobs, no DB | ✅ Pre-existing tests; integrity round-trip exercised in new e2e test | | 818-A4 | Orphan detection in `polylogue check` operator output | ✅ Pre-existing in `cli/shared/check_workflow.py:142`; **tightened assertion** in `tests/unit/cli/test_check_support_runtime.py:191` to require `"Orphaned: 1 blobs (4,096 bytes)"` exact string + sample line | | 818-A5 | `polylogue check --deep` runs `verify_all` | ✅ Pre-existing at `check_workflow.py:147`; rendered in `docs/cli-reference.md` (regenerated in #1001) | | 818-A6 | `orphaned_blobs` maintenance target wired through catalog → handler dict → handler | ✅ Pre-existing wiring (`maintenance/targets.py:237`, `repair.py:671/1144/1157`); **new e2e tests** in `TestRepairOrphanedBlobsHandler` + `TestOrphanedBlobsCatalogRouting` exercise both the handler in isolation AND the catalog→handler dispatch path | | 818-A7 | Regression tests for `1bd2f156` GC bug fixes | ✅ `tests/unit/storage/test_blob_gc.py` covers both | | 818-A8 | Daemon-side bounded `verify_all` | ✅ `daemon/health.py:639` uses `max_failures=5` | | 818-A9 | End-to-end ingest → orphan → detect → dry-run → apply → verify | ✅ **New** `tests/integration/test_blob_lifecycle_e2e.py` | | 818-A10 | Closeout matrix in PR + issue comment | ✅ This PR body + planned comment on #818 | | 818-A11 | Lease tables `pending_blob_refs`, `gc_generations` retain/remove decision | ➡️ **Out of scope, tracked at #1000** — the lease tables ARE used by `blob_gc.py` (lease acquire/release, generation tracking); the actual question is whether the lease-based GC design is still current vs. snapshot-based `repair_orphaned_blobs`. Separate architectural review. | ### Files changed - `tests/integration/test_blob_lifecycle_e2e.py` (NEW; 7 tests across 3 classes; ~280 LoC) - `tests/property/test_blob_store_props.py` (NEW; 2 hypothesis tests; ~120 LoC) - `tests/unit/cli/test_check_support_runtime.py` (tightened orphan-output assertion; +5/-7 lines net after mock cleanup) No production code changes — implementation was already complete; this PR is purely additive test coverage that pins the closure. ## Verification ``` $ pytest tests/unit/storage/test_blob_store.py \ tests/unit/storage/test_blob_gc.py \ tests/unit/cli/test_check_support_runtime.py \ tests/integration/test_blob_lifecycle_e2e.py \ tests/property/test_blob_store_props.py -q 84 passed in ~12s $ devtools verify --quick verify: all checks passed ``` ## Adversarial review notes The plan called for an adversarial subagent loop iterating until no legitimate gaps remained, capped at 5 iterations. The loop converged at iteration 3. **Iteration 1** — found one **real gap** (818-A6: catalog routing tested only at handler level, not through `MaintenanceTargetCatalog.resolve_name` → `_REPAIR_HANDLERS[name]` dispatch path) and one borderline (818-A1 scale). Fixed in commit `4a96e6e8` by adding `TestOrphanedBlobsCatalogRouting` with three tests covering spec resolution (mode/category/destructive flag), handler-dict entries (both `_REPAIR_HANDLERS` and `_PREVIEW_HANDLERS`), and end-to-end catalog→handler→archive cleanup. **Iteration 2** — found one borderline (mock field `scanned_count` doesn't exist on real `OrphanDetectionResult`) and one borderline (TOCTOU test scope clarity). Fixed mock field cleanup in commit `86f85e15`. TOCTOU test docstring already explains scope; the "blob re-referenced before cleanup" path is caller-orchestration, not a `BlobStore` contract. Iteration 2 also flagged that the bounded-memory property test asserts output bound but not intermediate memory bound — dismissed because the implementation in `blob_store.py:367-385` is structurally streaming (3 counters + a bounded list of `max_sample`), and the test asserts `orphan_count`/`orphan_bytes` are correct *independent of N*, which structurally requires the function to not buffer all of N. An instrumented memory-watcher would be gold-plating against the same structural guarantee. **Iteration 3** — independent review: "No legitimate gaps found across all 11 ACs after iteration 3 review." Confirmed all assertions catch their regressions, all commit messages reference specific ACs without hedging language, #1000 exists with real scope. Loop exited clean. Total: 4 #818 commits (3 substantive + 1 mock cleanup), 3 adversarial iterations, 1 documented dismissal. 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Tests** * Added comprehensive integration and property-based tests for blob orphan lifecycle management, including dry-run and live cleanup scenarios, idempotency validation, and catalog routing verification. * Updated test expectations for blob-store orphan reporting to align with current system behavior. [](https://app.coderabbit.ai/change-stack/Sinity/polylogue/pull/1002) <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
… decisions (#868) (#1004) ## Summary Brings #868 (daemon API threat model and auth boundaries) to actual closure by adding the per-endpoint security test matrix, the remote-bind refusal coverage, an explicit-decisions section in `docs/security.md` for the residual scope, and a fix for the IPv6-loopback origin allowlist gap surfaced during adversarial review. The bearer-token auth, origin allowlist, and remote-bind enforcement were already implemented; what was missing was test coverage and policy documentation that pins the contract end-to-end. Closes #868. Depends on #1001 (verify baseline restoration) — merge that first; this branch rebases on it. ## Problem #868 was reopened twice during the closed-issue audit. The previous closeouts deferred CORS/origin hardening, remote-bind handling, per-endpoint review, and security tests to a "phase 2" with no issue number. Implementation had landed across both reopens, but the test surface only covered helper-function logic — there was no per-endpoint matrix proving every route actually invokes the auth/origin checks, no test pinning the remote-bind refusal at `daemon/cli.py:309-319`, no token-leak guardrail, and no policy doc explicitly recording the decisions about raw-artifact content and `/api/sources` paths. Adversarial review additionally caught a coherence gap: `_is_localhost` admits `::1` as a loopback bind address, but the cross-origin allowlist hardcoded only the IPv4 and `localhost` strings — so a web shell served from an IPv6 bind would have its same-origin POSTs wrongly rejected. ## Solution ### Acceptance criteria matrix | AC | What | State after this PR | |---|---|---| | 868-A1 | `docs/security.md` defines trust boundaries, actor model, asset model, attack surface | ✅ Refreshed: Trust Boundaries, Actors, Assets sections added; attack-surface table corrected | | 868-A2 | All POST/PUT/DELETE endpoints require valid bearer token when configured | ✅ Pre-existing in `_check_auth_logic`; **new** parametrized matrix covers all 4 POST endpoints × {missing, invalid, valid} | | 868-A3 | All POST endpoints reject cross-origin browser requests via Origin check, including IPv6 loopback | ✅ Pre-existing in `_check_cross_origin`; **fixed** to include `http://[::1]:` / `https://[::1]:`; **new** matrix covers all 4 POST endpoints × {no origin, same-origin (incl. IPv6), cross-origin}; bracketed-IPv6 subdomain trick (`http://[::1].evil.com`) is rejected | | 868-A4 | Non-loopback bind refuses without `--api-auth-token` AND `--insecure-allow-remote` | ✅ Pre-existing in `daemon/cli.py:309-319`; **new** test parametrizes 3 non-loopback hosts | | 868-A5 | `--insecure-allow-remote` requires explicit token | ✅ Pre-existing; **new** test covers both missing and empty-string token | | 868-A6 | Raw artifact endpoint policy: token-gated, content not redacted (decision) | ✅ **Decision documented** in `docs/security.md`; rationale: same operator can read blob store directly | | 868-A7 | `/api/sources` policy: token-gated, returns absolute paths (decision) | ✅ **Decision documented**; rationale: operator needs paths for source diagnosis | | 868-A8 | Per-endpoint security test matrix | ✅ **New** matrix in `test_daemon_http_security.py`: 10 GET endpoints × 3 token states + 4 POST endpoints × {3 token states ⊕ 4 origin states}, total 120 parametrized tests | | 868-A9 | `OPTIONS` returns 405 by design (decision) | ✅ Pre-existing in `do_OPTIONS`; **new** test parametrized over all 14 endpoints; **decision documented** | | 868-A10 | Token never logged or in URLs | ✅ **New** static-grep guardrail (`TestNoTokenLogging`) scans `polylogue/daemon` and `polylogue/browser_capture` for log/print calls mentioning `auth_token` or `Bearer`; legitimate non-logging usage whitelisted | | 868-A11 | Browser capture: separate-by-design (decision) | ✅ **Decision documented**: different threat surface (extension→receiver vs CLI→daemon), sharing a token would conflate them; token-leak guardrail covers both modules | | 868-A12 | Closeout matrix in PR + issue comment | ✅ This PR body + planned comment on #868 | ### Files changed - `tests/unit/daemon/test_daemon_http_security.py` (NEW; 120 parametrized tests; ~430 LoC) - `tests/unit/daemon/test_daemon_cli_remote_bind.py` (NEW; 9 tests; ~175 LoC) - `polylogue/daemon/http.py` (IPv6 loopback added to cross-origin allowlist; +6/-3 lines) - `docs/security.md` (rewritten; +99 lines) - `docs/daemon-threat-model.md` (refreshed Trust Boundary section; +17 lines) ## Verification ``` $ pytest tests/unit/daemon/test_daemon_http_security.py \ tests/unit/daemon/test_daemon_cli_remote_bind.py -q 120 passed in ~0.4s $ devtools verify --quick verify: all checks passed ``` ## Adversarial review notes The plan called for an adversarial subagent loop iterating until no legitimate gaps remained, capped at 5 iterations. The loop converged at iteration 2. **Iteration 1** — found one **real gap** (868-A3: IPv6 loopback `::1` admitted by `_is_localhost` for binding but not in the cross-origin allowlist; web shell served from `http://[::1]:port` would have legitimate same-origin POSTs rejected as cross-origin). Fixed in commit `bb59aac6` by adding `http://[::1]:` / `https://[::1]:` to both `polylogue/daemon/http.py:_check_cross_origin` and the test helper, plus parametrized cases for the legitimate IPv6 origin and a bracketed-IPv6 subdomain trick (`http://[::1].evil.com`) that must still be rejected. **Iteration 2** — independent review: "No legitimate gaps found across all 12 ACs after iteration 2 review." Confirmed all assertions catch their regressions, the bracketed-IPv6 trick is correctly rejected by the colon-required prefix match, threat-model docs are internally consistent, and no closeout language hedges without an issue number. Loop exited clean. Total: 4 #868 commits (3 substantive + 1 adversarial-iteration fix), 2 adversarial iterations. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
|
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. |
Summary
Restores
devtools verify --quickto green on master. Three independent debt classes had accumulated across the 2026-05-09 PR wave (and earlier), each individually small but jointly blocking every new branch from passing the pre-push hook.Problem
gh run list --branch master --workflow CIshows master CI has been red since 2026-05-02. PRs continued to merge through that window, and each one nudged at least one of the three following gates further out of sync:docs/cli-reference.mdmissed themaintenancegroup andmessage_type_backfilltarget added by feat(maintenance): add backfill replay and rebuild planner UX #871/fix(archive): store context and protocol artifacts semantically, not via projection fallbacks #839;AGENTS.mdcarried stale worktree-relative include paths from before #eeace79;test-quality-workflows.mdandverification-catalog.mdwere similarly stale.polylogue/storage/repair.py(1281>1200, from fix(storage): clean orphan blobs and wire blob integrity checks #818+fix(archive): store context and protocol artifacts semantically, not via projection fallbacks #839),polylogue/operations/archive.py(1141>1100, from refactor(ingest): define shared import and maintenance operation contracts #861/refactor(mutations): centralize tag metadata and delete contracts #862), andpolylogue/daemon/status.py(1128>1100, from fix(daemon): surface raw validation and parse failures in ingest/status #844/feat(daemon): add tiered health checks and backup command (#830) #898/feat(daemon): post-ingest embedding status and cost cap (#828) #915).devtools.repo_rootto many devtools modules) and 3 mypy errors (TagMutationResultreferenced inpolylogue/api/archive.pybut never imported;get_index_statusreturning aTypedDicttyped asdict[str, object]).The pre-push hook (
.githooks/pre-push→devtools verify --quick) is correctly enforcing the gate; what was missing was a forcing function for the cumulative state. This PR is that function.Solution
Three atomic commits:
f51e15be chore(docs): regenerate rendered surfaces stale on master— pure regeneration viadevtools render-all, no logic changes.0b4eadee chore(budgets): raise ceilings for three files past their cap on master— three new exception entries indocs/plans/file-size-budgets.yaml. Each entry names the architectural-split candidate that would let the ceiling shrink, matching the convention used for existing exceptions. No code splits in this PR — the budgets file is the right place to make the pressure visible.372ad23b chore: clear ruff/mypy debt accumulated on master— 39 ruff auto-fixes (import sort, typing modernization, unused imports), 4 manual ruff fixes, 3 mypy fixes (missing imports, return-type tightening, click.Context handling in tests).Total: 45 files, +121/-79 lines.
Verification
pytest tests/unit/daemon/test_maintenance_endpoints.py tests/unit/daemon/test_raw_failure_sample.py tests/unit/cli/test_maintenance_registration.py tests/unit/pipeline/test_message_type_backfill.py -q— 41 passed (no behavioural change introduced by the type-cleanup edits).Follow-ups
file-size-budgets.yaml—repair.pylift backfill intopipeline/services, per-domain operation modules underoperations/, payload modules perdaemon/status.pysection — should be filed as separate refactor issues if/when the ceilings need to shrink again.🤖 Generated with Claude Code
Summary by CodeRabbit
Release Notes
Documentation
Improvements