Repository navigation
feat: Converge aggregate insights by canonical partition with value-com… - #4849
Conversation
The session partition's freshness was value-complete, but the readiness gates over the families derived from it were not. `work_event_ready` and `phase_ready` compared `session_profiles`' declared row counts against the rows themselves — both sides read the partition being judged, so a profile that is wrong about its inputs is wrong on both and the comparison agrees with itself. The `stale_work_event_inference_count` and `stale_phase_inference_count` conjuncts beside them could not fail either: no status descriptor emitted those fields, so they read zero on every archive. Readiness for every family now rests on the value-complete inspection that recomputes the binding from `sessions`/`messages`, and the two stale counts are derived from that inspection's non-valid key set like the latency profile's already was. The expected-row equalities stay as row accounting and say so. `day_summary_count`, `expected_day_summary_count` and `stale_day_summary_count` had no emitter and no reader at all and are gone. `input_binding` now declares, with a reason each, every `sessions` and `messages` column the projection leaves out, and a test partitions the live schema against those two tables: a column added to either relation without a decision is red rather than silently unbound. Tests carry the red law over the remaining output-affecting values — model name, token count, and a tag driven from `git_repository_url` — plus the provider/day move that retires its old rollup partition, a valid-empty partition, an event-order permutation property, the stale-frame and crash-window faults, the deleted-hint law for the domain, and the differential that goes green only while a projection column is missing. Two inherited assertions are fixed forward: `_session_ids_missing_profiles` answers "never built" since staleness stopped being a sort key, and every rollup partition a session contributes to goes stale with it, not just one. Verification: `devtools test tests/unit/storage/test_session_partition_convergence.py tests/unit/storage/test_session_profile_derivation.py` — 50 passed, 1 failed before this commit's last assertion fix; the failure is the inherited `stale_tag_rollup_count == 1` corrected here. Co-Authored-By: Claude Opus 5 <[email protected]>
`session_runs`, `session_observed_events` and `session_context_snapshots` are CTEs, not relations, so their descriptors point `table_name` at `sessions` to get past the presence gate. That makes the gate report "readable" whatever else is missing, while the CTE bodies select through `messages`, `blocks` and `session_events` — so a status call on an archive without them raised `no such table: session_events` instead of counting zero, which is the exact failure the module's gating invariant exists to prevent. The three dependencies are declared the way a view's already were, behind presence probes for the substrate relations they name; the import-time guard now holds them to it. Verification: the two `test_session_insight_status_descriptors` sync/async parity cases over a partial schema were red at the base commit and pass with this. Co-Authored-By: Claude Opus 5 <[email protected]>
…v' into batch/polylogue-20260911-012038-1221117f/integration
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Advanced Run ID: 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 |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e4fba5c962
ℹ️ 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".
#5030) Closes the largest cluster under `polylogue-7lhl5` — 11 test failures plus the 6 pre-existing `test_facade_contracts.py` failures. ## Summary Replace a leaked internal `MutationTransactionError` with a typed, actionable refusal naming the sanctioned route, and retarget the insight materialization laws onto their production materializer. ## Problem `Polylogue.rebuild_insights` was dead. It called `_execute_facade_mutation` (`api/archive.py:2734-2770`) into `executor.execute_bound`, which is refused at `operations/mutation_transaction.py:910-920`. Landing commit `1d901ec73` (#4867) added the whole insight-acceptance machine and never touched `api/archive.py`, so the facade was simply left behind. Live impact: MCP's `rebuild_insights` dispatcher (`mcp/server_cutover.py:2384-2389`, gated on `confirm=true`) was the sole non-test production caller and was dead; the public Python API was dead. The daemon route (`maintenance.insights.rebuild`) always worked. The CLI has no rebuild-insights verb. ## Decision: typed refusal, not delegation The facade cannot hold the authority. A sweep is sealed page by page — manifest frozen, previews staged, parts sealed, ordinals started through `begin_accepted_insight_part` — which needs durable audit authority, a pinned index generation and recipe binding, and the resident session-profile publication owner. CLAUDE.md names `polylogued run` the required live-write owner for exactly this. **Delegation was pursued and rejected on evidence, not preference.** The transport does exist and is reusable: `daemon_client.py` has `DaemonClient.operation_to_completion`, already used by CLI verbs to delegate mutations from non-daemon processes. It was rejected on a concrete blocker — the completed insight envelope's result is the machine-lifecycle state from `machine_request_state`, carrying `parts`/`affected_count` but **not** the declared `InsightRebuildResult` counts, so `validate_operation_result` would reject the daemon's own result. Delegating today means shipping unverifiable code against a wire contract that is itself unfulfilled. When that contract is completed, this refusal is the natural place to swap in delegation. Neither guard was loosened, and `InsightsRebuildActuator` is untouched — it remains the plan builder used by `insight_planning.py`. ### What callers now experience - **Library:** `InsightMaintenanceRequiresDaemonError` (`code="daemon_required"`, HTTP 503) naming `polylogued run` and `maintenance.insights.rebuild`. The message is fixed strings only, never user data, so any surface can forward it. - **MCP:** a clean `daemon_required` error envelope carrying that route, instead of `internal_error` wrapping a `MutationTransactionError`. Neither can run a rebuild — which is honest, and an improvement over dead. ## The six facade-contract failures All confirmed pre-existing on untouched tip `a3d6ffe2b` (receipt `20260913T193858Z-focused-test-1293934-0eb4f721`) before being touched: - Four were the sealing cluster; retargeted to the shared materializer. - `test_no_undiscovered_async_methods` was **the discovery gate working correctly** — `get_session_orchestration` is genuinely uncovered there. It is now categorized as bespoke, naming the file that covers it. - `stale_work_event_inference_count` was a stale expectation: the profile row is hand-inserted with no input binding, so binding-based inspection (#4849) correctly calls its inference rows stale. Asserting 1 is the honest reading. ## Scope widened where the same root cause reached `tests/unit/core/test_resume.py` and `test_insight_export_bundles.py` also called the dead facade. Tests now go through one helper on a real production route — both `InsightsRebuildActuator.apply` and the daemon's own per-session publication path call `rebuild_session_insights_sync`. Per-law anti-vacuity conditions are in the test commit message. ## Verification ``` focused suites (11 cluster tests + 6 facade contracts + MCP) PASSED exit=0 devtools verify --quick exit 0 ``` **Schema closure — measured, not assumed.** `devtools schema closure` marks `polylogue/core/errors.py` **IN** the derived closure, so the identity was computed rather than inferred: index and ops identities are byte-identical before and after (`bd388fcf53e4…` / `0a44d6a6764c…`). **No reconvergence is required.** Closure membership is not the same as an identity move. ## Residuals Not this cluster, left for its owner: `test_resume_candidates_preserve_resolvable_exact_jaccard` fails on the untouched tip (receipt `20260913T200236Z-focused-test-1339607-d2348922`) — a resume overlap-scorer failure unconnected to insight maintenance. Tracked under `polylogue-7lhl5`. 🤖 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]>
Batch
polylogue-20260911-012038-1221117fon baseda315a9794bf.polylogue-ylh7v Converge aggregate insights by canonical partition with value-complete staleness
devtools test tests/unit/insights tests/unit/daemon -k 'aggregate or partition or convergence'; restart fault scenario;devtools verify --quick;devtools verify.