Skip to content

test: Replace embedding-status config doubles with a real PolylogueConfig - #5032

Merged
Sinity merged 2 commits into
masterfrom
fix/embedding-status-config-type
Sep 13, 2026
Merged

Sinity merged 2 commits into
masterfrom
fix/embedding-status-config-type

Conversation

@Sinity

@Sinity Sinity commented Sep 13, 2026

Copy link
Copy Markdown
Owner

Advances polylogue-7lhl5. Resolves 47 of the 108 failures reproduced at
14e1d821f.

Summary

Replace embedding-status config doubles with a real PolylogueConfig behind one
shared helper, and retarget four leftover insight rebuilds onto the shared
materializer.

Problem

The full corpus could not collect as one unit until #5031, so most of these tests
had never run. The measured red surface at 14e1d821f is 108 failures. Two
clusters account for 47.

Production is right — deliberately unchanged

Before editing test files, the question was whether the production nominal
dispatch in embedding_status_settings_from_config is itself wrong. It is not,
for two reasons worth recording:

  1. It is a lossy projection where identical attribute names mean different
    things.
    A legacy Config has no embedding_enabled and no
    embedding_max_cost_usd, and reaches its Voyage key via index_config;
    PolylogueConfig has all of them directly. EmbeddingStatusSettings's own
    docstring makes None mean "the supplied configuration did not observe that
    fact — not disabled, not unbounded."
    A Protocol can express which attributes
    an object has, never which vocabulary it speaks, so the two branches would
    collapse and emit Nones that read as observed-absent rather than
    unobservable.
  2. No production caller can reach the refusal. status_payload.py:1297 uses
    load_polylogue_config(); status_payload.py:1179 and
    operations/daemon_status.py:77 are typed Config | PolylogueConfig | None
    and their production callers (daemon/cli.py:3052,3057,
    daemon/status_snapshot.py:420, cli/shared/check_workflow.py:134) pass no
    config at all.

So it is a fail-loud partition guard: a third config type must be a deliberate
edit there, not a silent structural match. Fixing the tests was correct.

Solution

24d060ebf — the _Cfg cluster (29, and confined to a single file rather
than spread across the suite as first assumed). #5026's pattern is factored into
tests/infra/embedding_config.py and used from both call sites instead of
per-file copies — that duplication is exactly what the consolidation census
(#5029) is trying to reduce. test_embed_status_fast.py 32 failed → 15; zero
_Cfg TypeErrors.

96e79d095 — cluster B (18). Four callers that f494b276f missed, retargeted
onto materialize_session_insights. Readiness 4→0, taxonomy 6→0, snapshots
15→7.

Anti-vacuity

  • _Cfg: tests still drive the real
    load_polylogue_config → embedding_status_settings_from_config → EmbeddingStatusSettings route. The helper was verified behavior-identical
    (same five values; config.py:411-429 are plain pass-throughs), so nothing was
    relaxed. Reverting to a double makes them red with the same TypeError, and a
    production field rename now breaks these tests instead of being absorbed by a
    double that matches only itself.
  • Cluster B: the tests assert what the materializer produces, and
    materialize_session_insights calls rebuild_session_insights_sync — the same
    function both sanctioned owners reach — so deleting it leaves every assertion
    red. Authorization-route coverage stays separate in
    test_operation_executor_routes.py.

Verification

devtools test <5 selections>   receipts 20260913T213830Z-...-1607196-b7978ae1,
                               ...-1617758-93b10ec5, ...-1633508-61a11e02,
                               ...-1635467, ...-1640057
devtools verify --quick        14/14 gates ok

No full-corpus run (a host reaper kills long background tasks; the corpus gate
runs through the declared verify_all operation instead).

A measurement that refuted a confident inference

Cluster C was triaged as "small and clear: widen the lambdas to **_kwargs." It
was implemented and measured to be wrong — it peeled three layers
(index_path → operation_vector_connection → index_db_path) with 7 failures
surviving each round. test_query_exec_laws.py holds 38 hand-written
FakeArchiveStore copies
that have drifted from a production class that moved.
Re-synchronizing them is the duplication problem itself, not a one-liner. It was
reverted rather than chased attribute by attribute, and needs its own owner.

Deliberately left, with owners

  • Cluster A residual, 15 — test_embed_status_fast.py. Pre-existing and
    previously masked by the TypeError (confirmed three ways). Cause:
    EMBEDDINGS_SCHEMA_VERSION 5→6 added message_content_hash, so the v5-shaped
    fixture's metadata alone no longer certifies a vector. Needs a v6 fixture with
    real physical vectors under sqlite-vec, not a pragma bump.
  • Cluster C, 7 — the FakeArchiveStore drift above.
  • D1–4, 34 — reset / excise / archive-maintenance / json-output, all stale
    against daemon sole-write authority. Mechanical but needs a judgment call about
    what each should now assert; one owner for all four.
  • D5, 3 — a genuine PRODUCT BUG, filed separately: cli/commands/status.py
    rejects any non-builtin daemon_url and then renders the refusal as
    "Daemon: running" with daemon_reachable = True when no daemon exists.
  • D6 — mostly environment/timing, but test_daemon_resilience.py:362
    ((None,'signal') != ('SIGTERM','signal')) is a real shape mismatch.
  • D7 — .archive-ownership.lock PermissionError, carrying a real question
    about whether a pure read should need write access. The no running event loop
    traceback there is not a defect — caught by design at
    core/async_bridge.py:50-53.

Attribution is more spread than expected: only cluster A traces to the
convergence rewrite; B to f494b276f; C and D5 to 1d901ec73; D1–3 to
6be5d2fd7; D4 to cfc4c73ec.

🤖 Generated with Claude Code

https://claude.ai/code/session_01DYUNBGoE652b3nfmq3CtqK

Sinity and others added 2 commits September 13, 2026 23:52
…nfig

Problem: `embedding_status_settings_from_config`
(polylogue/storage/embeddings/status_payload.py:174) dispatches nominally over
`PolylogueConfig`/`Config` and raises `TypeError` for anything else.
tests/unit/cli/test_embed_status_fast.py supplied a private duck-typed `_Cfg`,
so 29 of its 32 tests failed with
`TypeError: unsupported embedding status configuration: _Cfg`.

The production dispatch is correct and was left alone. The two config types
observe *different* facts -- a legacy `Config` has no `embedding_enabled` or
`embedding_max_cost_usd` and reaches its Voyage key through `index_config` --
so `None` in `EmbeddingStatusSettings` means "this configuration type does not
observe that fact". A structural/protocol match cannot carry that distinction,
and no production caller can reach the refusal: the three call sites are
`load_polylogue_config()` (always a `PolylogueConfig`) and two parameters typed
`Config | PolylogueConfig | None` whose only production callers pass nothing.

Solution: factor the accepted pattern from #5026 into
tests/infra/embedding_config.py and use it from both test files instead of
copying a per-file helper.

Anti-vacuity: each test still drives the real
`load_polylogue_config` -> `embedding_status_settings_from_config` ->
`EmbeddingStatusSettings` route and asserts on the resulting status payload.
The helper passes the identical values the double carried, and
`PolylogueConfig`'s embedding properties (polylogue/config.py:411-429) are
plain pass-throughs, so the projected settings are unchanged; reverting the
helper to a local double makes the file red again with the same `TypeError`,
and a production rename of a projected field now breaks these tests instead of
being absorbed by a double that matches only itself.

Verification:
  devtools test tests/unit/cli/test_embed_status_fast.py \
    tests/unit/daemon/test_embedding_readiness.py
    -> 15 failed, 26 passed (was 32 failed of 41); zero `_Cfg` TypeErrors
  devtools verify --quick -> all gates ok

Residual: the 15 remaining failures in test_embed_status_fast.py are a
different, previously masked cluster (the TypeError aborted before the
assertions could run) and are diagnosed separately; they are not introduced
here.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01DYUNBGoE652b3nfmq3CtqK
Problem: 18 tests failed with `InsightMaintenanceRequiresDaemonError:
session-insight maintenance runs only through its sealed accepted-part route`.

This refusal is deliberate and correct. `f494b276f` introduced it at
polylogue/api/archive.py:6045 as the typed public replacement for an internal
`MutationTransactionError` that had been leaking to public callers: a rebuild
sweep is a sealed, page-bounded machine owned by `polylogued run`, and
`Polylogue.rebuild_insights` is deliberately not an executor route. That commit
migrated three sibling test files onto `materialize_session_insights`
(tests/infra/storage_records.py:1534) but missed four callers.

Note this is the *fix* for one of polylogue-7lhl5's clusters, not the break --
the bead's notes describe the older `MutationTransactionError` leak, which this
error type superseded.

Solution: retarget the four leftovers onto the same landed helper --
tests/unit/core/test_insight_readiness.py:46,
tests/unit/insights/test_temporal_source_taxonomy.py:192, and the module-scoped
`postmortem_archive` fixture in tests/unit/cli/test_plain_cli_snapshots.py:113.
The snapshot fixture no longer needs its HOME/XDG/archive-root env juggling,
which existed only so `Polylogue.open()` could resolve the clone.

Anti-vacuity: these tests assert what the materializer *produces* -- insight
readiness states, temporal source taxonomy tags, and durable `session_profile`
records behind the postmortem snapshots. `materialize_session_insights` calls
`rebuild_session_insights_sync`, the same function both sanctioned owners reach
(`InsightsRebuildActuator.apply` and the daemon's per-session publication
path), so the assertions still run against real materializer output; deleting
the materializer call leaves every one of them red. Authorization-route
coverage is owned separately by
tests/unit/api/test_operation_executor_routes.py, so nothing proves less here.

Verification:
  devtools test tests/unit/core/test_insight_readiness.py \
    tests/unit/insights/test_temporal_source_taxonomy.py \
    tests/unit/cli/test_plain_cli_snapshots.py
    -> 7 failed, 85 passed (was 25 failed); readiness 4->0, taxonomy 6->0,
       snapshots 15->7
  devtools verify --quick -> all gates ok

Residual: the 7 remaining snapshot failures are an unrelated test-infra defect
(`seeded_db_env` uses the sealed 0500 shared artifact uncloned, so the read
path's ownership lock hits PermissionError) and are left to their own owner.

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 27 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: 433e1765-d0df-4fe2-91bf-699ee439a6eb

📥 Commits

Reviewing files that changed from the base of the PR and between 14e1d82 and 96e79d0.

📒 Files selected for processing (6)
  • tests/infra/embedding_config.py
  • tests/unit/cli/test_embed_status_fast.py
  • tests/unit/cli/test_plain_cli_snapshots.py
  • tests/unit/core/test_insight_readiness.py
  • tests/unit/daemon/test_embedding_readiness.py
  • tests/unit/insights/test_temporal_source_taxonomy.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 49759f2 into master Sep 13, 2026
3 checks passed
@Sinity
Sinity deleted the fix/embedding-status-config-type branch September 13, 2026 22:29
Sinity added a commit that referenced this pull request Sep 13, 2026
…5033)

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.fail`s 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 14e1d82` 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.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

Development

Successfully merging this pull request may close these issues.

1 participant