Skip to content

test: Rebuild the embed-status fixture on the v6 embeddings schema - #5033

Merged
Sinity merged 1 commit into
masterfrom
fix/embed-status-v6-fixture
Sep 13, 2026
Merged

Sinity merged 1 commit into
masterfrom
fix/embed-status-v6-fixture

Conversation

@Sinity

@Sinity Sinity commented Sep 13, 2026

Copy link
Copy Markdown
Owner

Advances polylogue-7lhl5. 13 of 15 remaining failures in
test_embed_status_fast.py fixed; the last 2 are a separate product regression,
filed as polylogue-5mjla and 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_VERSION went 5 → 6, adding message_content_hash to the
embedding refs. The fixture was v5-shaped, so
_embedding_refs_have_message_semantics short-circuited
_authoritative_archive_embedding_state to None for 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: _Cfg and had never executed. #5032 unmasked them.

Solution

_seed_archive_file_set_from_archive_tiers now calls
initialize_archive_database(embeddings_db, ArchiveTier.EMBEDDINGS) for the real
DDL, then publishes through begin_embedding_attempt →
complete_embedding_attempt_success with a real 1024-float vector. No embedding
row is hand-inserted.
Index content_hash values became real 32-byte hashes so
the same value reaches message_embedding_refs.message_content_hash, whose CHECK
requires 32 bytes.

Building through the production route rather than fabricating rows is deliberate:
a hand-built fixture drifts from production exactly the way the FakeArchiveStore
doubles did (polylogue-banw4), ending up proving only that it matches itself.

Anti-vacuity

New test_status_json_reports_metadata_only_row_as_not_ready deletes only the
physical vec0 vector, leaving meta, refs (with a current message_content_hash),
embedding_derivation_state = 'succeeded' and embedding_status exactly as
production wrote them — then asserts embedded_sessions == 0 and
retrieval_ready is False.

Removing the EXISTS (... message_embeddings) conjunct makes it red. A pragma
bump without real vectors also leaves it red, which is the specific shortcut this
fixture had to avoid.

sqlite-vec: no difficulty — try_load_sqlite_vec returns (True, None) here.
There is no stub anywhere; the fixture pytest.fails loudly if the extension is
ever missing. _open_embeddings was added because plain connections hit
no such module: vec0 on any statement naming the virtual table.

Verification

devtools test tests/unit/cli/test_embed_status_fast.py
  before:  15 failed   (after unmasking)
  after:   32 passed, 2 failed
  receipt 20260913T222928Z-focused-test-1680636-e427fc80
devtools verify --quick   all gates ok, exit 0

The 2 remaining failures are a product regression, not fixture shape

_archive_embedding_status_payload hardwires blocked_sessions = 0 on both
branches (status_payload.py:900,903). git show 14e1d821f confirms PR #5027
removed legacy_blocked_sessions, the blocked_session_clause, and the
three-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 a
net improvement: those 2 were already failing behind the _Cfg mask, so master's
red count falls by 13 and a real regression becomes visible instead of hidden.

🤖 Generated with Claude Code

https://claude.ai/code/session_01DYUNBGoE652b3nfmq3CtqK

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
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@coderabbitai

coderabbitai Bot commented Sep 13, 2026

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 5 minutes.

Check out review usage here.

View limit details

Limit 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.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 2dc11d6a-824d-4bce-9add-5f7616508966

📥 Commits

Reviewing files that changed from the base of the PR and between 49759f2 and 97cc963.

📒 Files selected for processing (1)
  • tests/unit/cli/test_embed_status_fast.py

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.

@Sinity
Sinity merged commit 88a3b1b into master Sep 13, 2026
3 checks passed
@Sinity
Sinity deleted the fix/embed-status-v6-fixture branch September 13, 2026 22:50
Sinity added a commit that referenced this pull request Sep 13, 2026
…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]>
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