Repository navigation
test: Rebuild the embed-status fixture on the v6 embeddings schema - #5033
Conversation
Problem: `EMBEDDINGS_SCHEMA_VERSION` moved 5 -> 6
(polylogue/storage/sqlite/archive_tiers/embeddings.py:5), adding
`message_embedding_refs.message_content_hash` and making readiness an
*inspection* rather than a metadata claim: `_authoritative_archive_embedding_state`
(polylogue/storage/embeddings/status_payload.py:513) requires, per required
message, the current ref, the current message semantic hash, the complete
recipe/output-contract identity, and `EXISTS (... message_embeddings)`.
tests/unit/cli/test_embed_status_fast.py hand-built a v5-shaped embeddings.db:
`PRAGMA user_version = 5`, a plain `message_embeddings (message_id)` table with
no vectors, and a refs table with no `message_content_hash`. Inspection
therefore returned None for every test that used it. These 15 failures were
previously masked by `TypeError: unsupported embedding status configuration:
_Cfg`, fixed in the preceding commit, so they are newly visible, not new.
Solution: `_seed_archive_file_set_from_archive_tiers` now creates embeddings.db
from the production DDL via `initialize_archive_database(..., ArchiveTier.EMBEDDINGS)`
and publishes its one embedded session through the production write route --
`begin_embedding_attempt` then `complete_embedding_attempt_success` -- with a
real 1024-float vector. No embedding row is hand-inserted; a fabricated row set
is exactly how a fixture drifts from production. index.db message
`content_hash` values became real 32-byte hashes so the same value can reach
`message_embedding_refs.message_content_hash` (the column CHECKs 32 bytes).
Consequential test-body realignment in the same file:
- `embedding_failures` now comes from the production DDL, so four hand-rolled
`CREATE TABLE embedding_failures` blocks are gone and the positional INSERT
names its columns (the production table has 20).
- `message_embeddings` is a real vec0 virtual table, so reads/deletes go
through `_open_embeddings`, which loads the extension.
- Stale internal-API monkeypatches: `_archive_embedding_session_state_exact_with_timeout`
and `count_archive_embedding_session_state` no longer exist (replaced by
`_authoritative_archive_embedding_state`), and `_scalar_int_with_timeout`
grew a `params` argument.
- Two tests whose premise v6 deliberately removed are re-expressed rather than
deleted: a clean `embedding_status` ledger over a pre-v4 metadata shape now
certifies nothing, and an uninspectable archive reports nothing embedded
instead of trusting that ledger.
Anti-vacuity: new `test_status_json_reports_metadata_only_row_as_not_ready`
publishes the session through the production route, then deletes *only* the
physical vec0 vector, leaving meta, refs (with current `message_content_hash`),
`embedding_derivation_state` 'succeeded' and `embedding_status` exactly as
production wrote them. It asserts the session is no longer embedded or
retrieval-ready. Remove the `EXISTS (... message_embeddings)` conjunct from
`_authoritative_archive_embedding_state` and that test goes red; bumping the
fixture's `PRAGMA user_version` without real vectors would leave it red too.
sqlite-vec loads without difficulty here (`try_load_sqlite_vec` -> (True, None)),
so no stub was needed; the fixture fails loudly rather than degrading if the
extension is ever unavailable.
Verification:
devtools test tests/unit/cli/test_embed_status_fast.py
before (masking removed): 15 failed, 18 passed
after: 2 failed, 32 passed (34 with the new test)
receipt .cache/verify/runs/20260913T222308Z-focused-test-1667285-580342bf
Residual: the 2 remaining failures are not fixture-shaped.
`_archive_embedding_status_payload` hardwires `blocked_sessions = 0` on both
branches (status_payload.py:900,903); #5027 removed the blocked-session
lifecycle accounting that `test_status_json_reports_terminal_failures_before_ready`
and `test_status_excludes_acknowledged_terminal_failure_from_retry_backlog`
assert. Those assertions are left standing as evidence of the regression rather
than rewritten to match it.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01DYUNBGoE652b3nfmq3CtqK
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
Warning Review limit reachedNext included review available in 5 minutes. View limit detailsLimit details: You’ve used the included review currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Advanced Run ID: 📒 Files selected for processing (1)
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 |
…ad (#5034) Closes `polylogue-5mjla` (P1). A regression introduced by #5027 and caught by the fixture rebuild in #5033. ## Summary Restore blocked-session accounting by surfacing the embeddings domain's existing `failed_terminal` classification, rather than re-adding the deleted legacy SQL. ## Problem `git show 14e1d82 -- polylogue/storage/embeddings/status_payload.py` confirms #5027 deleted `legacy_blocked_sessions`, the `blocked_session_clause`, and the three-tuple exact session state, replacing all of it with two literal `blocked_sessions = 0`. So a session excluded from automatic retry by an acknowledged or terminal embedding failure was reported as **ordinary pending** — it looked like work about to happen, permanently. Reproduced: `blocked_sessions` returned `0` instead of `1`, and `_embedding_status` fell to `"none"` instead of `"partial"` because its `blocked <= 0` branch fired. ## Solution No new counter was invented, and the legacy SQL was not restored. The embeddings domain **already carries this classification**: `_archive_embedding_freshness_predicate` in `materialization.py` has three branches — `fresh_sql` / `blocked_sql` / `pending_sql` — where `blocked_sql` is "current derivation key (session, source hash, recipe hash, output contract) AND `attempt_state = 'failed_terminal'`", and `pending_sql` is literally `NOT fresh AND NOT blocked`. That same predicate already drives `_select_pending_archive_session_window_by_derivation`, which keeps these keys out of the catchup work set. **The writer was already excluding them; only the status surface had stopped saying so.** New `archive_embedding_blocked_counts_sql` reuses that predicate verbatim; the status payload owns only the read timeout. This fits the derivation model rather than working around it: pending is `required − valid(inspect)`, and a terminally refused key is neither — not valid (no output) and not pending (no retry will ever produce one). The kernel's `PendingReason.BLOCKED` / poison notion was **deliberately not** reused: that is per-pass prerequisite-closure isolation, not a durable relation a status read can query. The payload clamps `blocked` against the pending set so `embedded + pending + blocked` still equals the eligible total, and subtracts a blocked key's own still-unembedded required messages from the message-level backlog on the same basis. ### Anti-vacuity — verified by reverting, not asserted Replacing the clamp with `blocked_sessions = 0` turns both tests red: `test_status_excludes_acknowledged_terminal_failure_from_retry_backlog` fails `assert 0 == 1` on `blocked_sessions`, and `test_status_json_reports_terminal_failures_before_ready` fails `assert 1 == 0` on `pending_sessions`. Neither assertion was weakened — both were concluded correct under the new model, and the code had regressed away from them. ## Verification ``` devtools test tests/unit/cli/test_embed_status_fast.py 34 passed / 34 receipt 20260913T225039Z-focused-test-1933459-5ac841fe devtools verify --quick 15/15 gates, exit 0 devtools test test_embedding_freshness_invariant.py test_embedding_stats.py \ test_embedding_contracts.py test_embedding_pinned_status.py 76/76 ``` A wider embedding selection ran 90/91; the single failure, `test_seed_demo_archive_creates_ready_queryable_archive`, reproduces identically at `49759f25d` and is not from this change. **Schema identity does NOT move.** `devtools schema closure` reports both changed files `out`, and both identities were *computed* rather than inferred from closure membership: index `615d3e5612845629047b537a26c2046860eed4dc1cffcdcdccf6fbda773ac105`, ops `0a44d6a6764cb6687f73e14b2644265f43841c771bcf2038192ef76f5d164a7a` — byte-identical before and after. ## Other surfaces hit by the same deletion: none A dedicated sweep of #5027's 129-file commit found blocked-session accounting touched in `status_payload.py` only. `materialization.py`'s `ArchiveEmbeddingSessionState` and `blocked_sql` were never modified. The two downstream consumers — `cli/shared/embed_stats.py` (renders "Blocked sessions") and `operations/daemon_status.py` (forwards the dict into the daemon status snapshot) — are pass-throughs that were untouched and become correct with this fix. Recorded but deliberately not changed: `daemon_status.py`'s `_unavailable_embedding_status` fallback hardcodes `blocked_sessions: 0`, which predates #5027 and is the honest value for an unavailable tier. 🤖 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 * **New Features** * Embedding status now reports terminally blocked archive sessions separately from the pending backlog. * Status details now include the number of blocked sessions and their unembedded eligible messages. * Pending session and message counts are adjusted to exclude blocked work for clearer progress tracking. <!-- end of auto-generated comment: release notes by coderabbit.ai --> Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
Advances
polylogue-7lhl5. 13 of 15 remaining failures intest_embed_status_fast.pyfixed; the last 2 are a separate product regression,filed as
polylogue-5mjlaand deliberately left red as evidence.Summary
Rebuild the embed-status test fixture on the v6 embeddings schema, through the
production write route, with real sqlite-vec vectors.
Problem
EMBEDDINGS_SCHEMA_VERSIONwent 5 → 6, addingmessage_content_hashto theembedding refs. The fixture was v5-shaped, so
_embedding_refs_have_message_semanticsshort-circuited_authoritative_archive_embedding_statetoNonefor every test using it —including a literal
EmbeddingGenerationError: embedding database has schema v5, expected v6.These 15 were previously masked by 29 ×
TypeError: unsupported embedding status configuration: _Cfgand had never executed. #5032 unmasked them.Solution
_seed_archive_file_set_from_archive_tiersnow callsinitialize_archive_database(embeddings_db, ArchiveTier.EMBEDDINGS)for the realDDL, then publishes through
begin_embedding_attempt→complete_embedding_attempt_successwith a real 1024-float vector. No embeddingrow is hand-inserted. Index
content_hashvalues became real 32-byte hashes sothe same value reaches
message_embedding_refs.message_content_hash, whose CHECKrequires 32 bytes.
Building through the production route rather than fabricating rows is deliberate:
a hand-built fixture drifts from production exactly the way the
FakeArchiveStoredoubles did (
polylogue-banw4), ending up proving only that it matches itself.Anti-vacuity
New
test_status_json_reports_metadata_only_row_as_not_readydeletes only thephysical vec0 vector, leaving meta, refs (with a current
message_content_hash),embedding_derivation_state = 'succeeded'andembedding_statusexactly asproduction wrote them — then asserts
embedded_sessions == 0andretrieval_ready is False.Removing the
EXISTS (... message_embeddings)conjunct makes it red. A pragmabump without real vectors also leaves it red, which is the specific shortcut this
fixture had to avoid.
sqlite-vec: no difficulty —
try_load_sqlite_vecreturns(True, None)here.There is no stub anywhere; the fixture
pytest.fails loudly if the extension isever missing.
_open_embeddingswas added because plain connections hitno such module: vec0on any statement naming the virtual table.Verification
The 2 remaining failures are a product regression, not fixture shape
_archive_embedding_status_payloadhardwiresblocked_sessions = 0on bothbranches (
status_payload.py:900,903).git show 14e1d821fconfirms PR #5027removed
legacy_blocked_sessions, theblocked_session_clause, and thethree-tuple exact session state carrying
session_state.blocked_sessions,replacing all of it with those two constants.
Consequence: a session excluded from automatic retry by an acknowledged/terminal
embedding failure is reported as ordinary pending.
The failing assertions were left standing as evidence rather than rewritten to
match the regression — filed as
polylogue-5mjla(P1). Merging this is still anet improvement: those 2 were already failing behind the
_Cfgmask, so master'sred count falls by 13 and a real regression becomes visible instead of hidden.
🤖 Generated with Claude Code
https://claude.ai/code/session_01DYUNBGoE652b3nfmq3CtqK