Skip to content

feat: Converge aggregate insights by canonical partition with value-com… - #4849

Merged
Sinity merged 3 commits into
masterfrom
batch/polylogue-20260911-012038-1221117f/integration
Sep 11, 2026
Merged

Sinity merged 3 commits into
masterfrom
batch/polylogue-20260911-012038-1221117f/integration

Conversation

@Sinity

@Sinity Sinity commented Sep 11, 2026

Copy link
Copy Markdown
Owner

Batch polylogue-20260911-012038-1221117f on base da315a9794bf.

polylogue-ylh7v Converge aggregate insights by canonical partition with value-complete staleness

  • 1. Every retained aggregate family declares a typed partition key, semantic recipe version, upstream dependency projection, inspect query, and atomic replacement.
  • 2. The output relation is correctness authority. Binding rows exist only for valid-empty output or identity the rows cannot carry, and they commit to every input value used, not merely to IDs. There i
  • 3. Red law for the measured defect: materialize, then mutate an output-affecting value (role, model, token count, tag) with identical IDs, timestamps, partition, and count; inspection must become non-
  • 4. Incremental append, replacement, deletion, reparenting, provider/day move, tag and profile mutation, and clean rebuild all converge to equal semantic relations, including zero-output partitions and
  • 5. Deleting the disposable scheduling hints and restarting reconstructs the same pending set. Bounded work is deterministic and starvation-resistant; poison in one partition does not suppress siblings
  • 6. Sync and async execution share one planner and SQL implementation.
  • 7. Refresh guards, timestamps, durable resume state, duplicate planners, and repair wrappers are deleted with no compatibility owner left; report line, schema, and test reductions.
  • 8. Property tests permute event order and batch boundaries; fault tests cover stale frame, crash before and after publish, valid empty output, excess rows, and deleted hints. Mutating one dependency p
  • 9. Verification: devtools test tests/unit/insights tests/unit/daemon -k 'aggregate or partition or convergence'; restart fault scenario; devtools verify --quick; devtools verify.

Sinity and others added 3 commits September 11, 2026 04:41
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
@Sinity
Sinity enabled auto-merge (squash) September 11, 2026 03:16
@coderabbitai

coderabbitai Bot commented Sep 11, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 743b162a-f2f8-4552-9d12-0e516d9f4cd2


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.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 11, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-11T03:21:31.728585Z e4fba5c PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

@Sinity
Sinity merged commit 5bca575 into master Sep 11, 2026
3 checks passed
@Sinity
Sinity deleted the batch/polylogue-20260911-012038-1221117f/integration branch September 11, 2026 03:21
Sinity added a commit that referenced this pull request Sep 13, 2026
#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]>
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