Repository navigation
test: Replace embedding-status config doubles with a real PolylogueConfig - #5032
Conversation
…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
|
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 27 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 (6)
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 |
…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]>
Advances
polylogue-7lhl5. Resolves 47 of the 108 failures reproduced at14e1d821f.Summary
Replace embedding-status config doubles with a real
PolylogueConfigbehind oneshared 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
14e1d821fis 108 failures. Twoclusters 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_configis itself wrong. It is not,for two reasons worth recording:
things. A legacy
Confighas noembedding_enabledand noembedding_max_cost_usd, and reaches its Voyage key viaindex_config;PolylogueConfighas all of them directly.EmbeddingStatusSettings's owndocstring makes
Nonemean "the supplied configuration did not observe thatfact — 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 thanunobservable.
status_payload.py:1297usesload_polylogue_config();status_payload.py:1179andoperations/daemon_status.py:77are typedConfig | PolylogueConfig | Noneand their production callers (
daemon/cli.py:3052,3057,daemon/status_snapshot.py:420,cli/shared/check_workflow.py:134) pass noconfig 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_Cfgcluster (29, and confined to a single file ratherthan spread across the suite as first assumed). #5026's pattern is factored into
tests/infra/embedding_config.pyand used from both call sites instead ofper-file copies — that duplication is exactly what the consolidation census
(#5029) is trying to reduce.
test_embed_status_fast.py32 failed → 15; zero_CfgTypeErrors.96e79d095— cluster B (18). Four callers thatf494b276fmissed, retargetedonto
materialize_session_insights. Readiness 4→0, taxonomy 6→0, snapshots15→7.
Anti-vacuity
_Cfg: tests still drive the realload_polylogue_config → embedding_status_settings_from_config → EmbeddingStatusSettingsroute. The helper was verified behavior-identical(same five values;
config.py:411-429are plain pass-throughs), so nothing wasrelaxed. Reverting to a double makes them red with the same
TypeError, and aproduction field rename now breaks these tests instead of being absorbed by a
double that matches only itself.
materialize_session_insightscallsrebuild_session_insights_sync— the samefunction both sanctioned owners reach — so deleting it leaves every assertion
red. Authorization-route coverage stays separate in
test_operation_executor_routes.py.Verification
No full-corpus run (a host reaper kills long background tasks; the corpus gate
runs through the declared
verify_alloperation instead).A measurement that refuted a confident inference
Cluster C was triaged as "small and clear: widen the lambdas to
**_kwargs." Itwas implemented and measured to be wrong — it peeled three layers
(
index_path→operation_vector_connection→index_db_path) with 7 failuressurviving each round.
test_query_exec_laws.pyholds 38 hand-writtenFakeArchiveStorecopies 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
test_embed_status_fast.py. Pre-existing andpreviously masked by the
TypeError(confirmed three ways). Cause:EMBEDDINGS_SCHEMA_VERSION5→6 addedmessage_content_hash, so the v5-shapedfixture's metadata alone no longer certifies a vector. Needs a v6 fixture with
real physical vectors under sqlite-vec, not a pragma bump.
FakeArchiveStoredrift above.against daemon sole-write authority. Mechanical but needs a judgment call about
what each should now assert; one owner for all four.
cli/commands/status.pyrejects any non-builtin
daemon_urland then renders the refusal as"Daemon: running" with
daemon_reachable = Truewhen no daemon exists.test_daemon_resilience.py:362(
(None,'signal') != ('SIGTERM','signal')) is a real shape mismatch..archive-ownership.lockPermissionError, carrying a real questionabout whether a pure read should need write access. The
no running event looptraceback 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 to1d901ec73; D1–3 to6be5d2fd7; D4 tocfc4c73ec.🤖 Generated with Claude Code
https://claude.ai/code/session_01DYUNBGoE652b3nfmq3CtqK