Skip to content

chore: Collapse redundant derived tables before the wipe - #4630

Merged
Sinity merged 13 commits into
masterfrom
feature/packet/polylogue-avlt5
Sep 3, 2026
Merged

Sinity merged 13 commits into
masterfrom
feature/packet/polylogue-avlt5

Conversation

@Sinity

@Sinity Sinity commented Sep 3, 2026

Copy link
Copy Markdown
Owner

Summary

Collapse action pairing, delegation facts, thread membership, thread summaries, and session tag rollups into query-time views over canonical index evidence. Remove their write-side refresh and bulk rebuild paths, and group thread search hits through messages_fts.

Problem

These index-tier tables duplicated derivable facts and imposed convergence and delete work against large archives. The measured redundancies were thread_sessions as a root-session restatement, action_pairs as a materialized action pairing, delegation_facts as a duplicate delegation projection, and session_tag_rollups as an oversized aggregate cache. Attachments remain normalized canonical evidence.

Solution

Fresh index DDL declares five compatibility views and no corresponding tables. Session insight rebuild and refresh paths retain only per-session materializations. Delegation and action readers continue through the public relation names. Schema disposition marks the five views DERIVE, and index schema v81 declares the lifecycle as a semantic reparse because existing persisted rows cannot be retained when tables become views.

Verification

  • nix develop --accept-flake-config --command devtools verify --quick: passed.
  • Affected selector covering storage, API, maintenance, canary, and insight materialization tests: 700 passed.
  • nix develop --accept-flake-config --command devtools test tests/unit/storage/test_archive_tiers_archive.py::test_read_open_rejects_stale_index_with_generation_and_lifecycle_action: 1 passed.
  • git diff --check: passed.
  • No durable-tier DDL paths changed.

@Sinity
Sinity enabled auto-merge (squash) September 3, 2026 20:31
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 3, 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-03T21:12:45.748783Z d0b1f36 New commits
ℹ️ 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.

@coderabbitai

coderabbitai Bot commented Sep 3, 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: Team

Run ID: 10f568bb-52f0-4e49-a496-8db1b518d408


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 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: 672d0dd804

ℹ️ 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 force-pushed the feature/packet/polylogue-avlt5 branch from 672d0dd to d0b1f36 Compare September 3, 2026 21:01
@Sinity
Sinity merged commit be45deb into master Sep 3, 2026
3 of 4 checks passed
@Sinity
Sinity deleted the feature/packet/polylogue-avlt5 branch September 3, 2026 21:07

@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: d0b1f36acd

ℹ️ 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 added a commit that referenced this pull request Sep 5, 2026
…4692)

## Summary
Fixes seven root causes from the 2026-09-05 master corpus reds (106
failed / 20,455 passed), profile/delegation/storage cluster:

- fix(storage): select the input_row_count the profile record reads (`no
such column: total_input_tokens`)
- fix(storage): insight presence counts views, not only tables
(`threads`/`delegations`/`actions` are views; exports withheld every
row)
- fix(storage): retain an ambiguous-owner attachment as typed unowned
(PR #4644 dropped it before its row was written; bead polylogue-c9qxh)
- fix(maintenance): absent stats for an empty table are not missing
coverage
- test: supply parent-dispatch evidence delegation resolution now
requires; read profile totals and ingest seams at their current
locations; follow embedding reuse and the declared content-hash
partition; classify new index tables and satisfy the threads view
dependency

## Verification
Lane batches: `450 passed` (batch 1620), then `5 failed, 664 passed in
654 s` (batch 1628) on the listed cluster plus touched modules.
`devtools verify --quick` green after one typing fix by the coordinator.

## Residuals (deliberately not fixed, with reasons)
- `test_session_revision_projection_golden_hashes`: message-level hash
drift unexplained by any diff in the identity modules; regenerating
would launder a possible identity regression.
- `assert_readable_archive_layout` still raises the pre-migration
`SchemaVersionMismatchError` on skew (#4626 half-landed); flipping it
changes MCP error codes; needs a caller audit.
- `test_refresh_thread_reorder_only_touches_changed_span`: #4630 made
`_refresh_thread` a no-op; design decision, not a patch.
- `test_insights_status_plain`, two `test_reindex_campaign` tests,
`test_full_reindex_and_incremental_convergence_have_equal_derived_models`:
still red in batch 1628.
- `perf_floors` and `codex_804` timed out under five-lane host
contention.

Beads: polylogue-7r19s, polylogue-xtstx, polylogue-c9qxh

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_01DNGJ3awfNrsLaMdHgQZvid

---------

Co-authored-by: Claude Fable 5.1 <[email protected]>
Sinity added a commit that referenced this pull request Sep 29, 2026
)

## Summary

Lands worker 8's review-debt fixes for `polylogue-1tyq5.107`, `.108` and
`.109` (storage reads, usage, query objects, connection profile),
rebased onto current master and reviewed. Of 52 findings: 24 fixed with
regression tests, 9 already fixed on master, 19 not reached.

## Problem

The worker's commit could not be run by its author. On review, several
fixes were right in intent but wrong in shape:
- the writer refusal of unprovisioned tiers also removed the index
version-zero exemption and changed attached-sibling and reader checks;
- `ReadFrame.resume` rebound on every external commit, which resets
`data_version` and would hide a mixed source census from
`_require_current_source_census_frame`;
- the effective-context fix changed the API route only, leaving the
pinned `read.effective_context` operation reading own rows with the old
boundary rule;
- the profile snapshot fix covered only the batch read;
- the attachment-library order used `attachment_refs.position`, an
identity coordinate rather than a display ordinal;
- the subscription conversion reported $0 for an unrated model or an
undeclared tier.

## Solution

- Worker commit, rebased unchanged.
- Follow-up commit: writers refuse a never-provisioned tier only when
they open it directly; every reader path keeps master's absent-tier
answer. `resume` rebinds only for a held read transaction and refuses
while a stream pins the snapshot. `effective_context_window` plus one
boundary query is now the single owner for both effective-context
routes, and both compose the lineage transcript. Single, batch and list
profile reads hold one snapshot. Library pages order by attachment ID
within a message, matching the session read. Checkpoint blockers stay
named when the checkpoint failed. The cumulative lane uses the same
counter-evidence rule as the request lane. Subscription equivalents are
`None` when the rate or tier is unknown. `put_query` raises instead of
asserting.

No Origin to Provider reversal is added. `coverage.provider` was already
present and is unchanged.

## Verification

- `agentctl job start polylogue verify_quick --workspace
/realm/worktrees/salvage-w8 --wait` → job 2311 `succeeded` (head
65a248e762, same tree as 02c3d8c).
- `agentctl job start polylogue pytest_focused --workspace
/realm/worktrees/salvage-w8 --wait -- <30 test files>` → job 2314: `790
passed, 4 failed`. All four failures are inherited: job 2294 reproduces
them with every production file reset to `origin/master`:
-
`test_diagnostics.py::test_latency_plain_zero_rows_reports_unknown_drop_accounting`
-
`test_facade_contracts.py::test_archive_facet_buckets_count_unique_sessions_for_duplicate_hits`
  - `test_facade_contracts.py::test_no_undiscovered_async_methods`
-
`test_mapped_bytes_budget.py::test_async_attached_tier_profiles_map_main_only[configure_read_connection]`
- Anti-vacuity: in a worktree with every changed production file reset
to `origin/master`, the new regression tests fail on their assertions
(job 2262: `40 failed`; job 2315: `3 failed`, covering the revised
attachment test, the updated budget test and the cumulative-lane test).

## Self-review

- **Siblings and owners.** Effective context had two deciders, the API
route and `operations/read_view_extras.py`. Both now call
`effective_context_window`. The one-snapshot fix covers all three
profile reads. Reportedness now uses the same counter-evidence rule for
the request and cumulative lanes. The schema refusal applies only where
a writer opens a tier. Reader, sibling, sealed-staging and
`assert_tier_schema_supported` callers keep master behaviour.
- **The fix itself.** Rebinding on any stale `revalidate()` would have
defeated the census end check, so it was dropped.
`ReadFrameExpiredError` from `resume` during a stream is an existing
typed error, and the census never resumes mid-stream. The `assert` in
`put_query` became a raise.
- **Memory and limits.** Session-cost IDs page at the connection's
physical bind limit, with no new cap. Both effective-context routes
still compose the whole transcript, as `get_messages` already did. See
residuals.
- **Cost per unit.** Attachment-library paging still uses the existing
OFFSET. The new `LEFT JOIN messages` is on the primary key.
- **Interruption.** The added read transactions roll back in `finally`.
`ReadFrame.close` retires stream cursors before closing the connection.
- **Ordering and races.** Messages, boundary and blocks are read in one
snapshot, as are profile rows and usage. `resume` never proves an anchor
on a held snapshot.
- **Failure classification.** A canonical-DDL build failure is
`upgrade_runtime`, separate from `retry` and drift. Checkpoint blockers
are kept on error.
- **Silent outcomes.** A lane without counter evidence is `unavailable`,
and a lane with an explicit zero is `reported`. An unknown subscription
rate or tier is `None`, not $0.
- **Cleanup on failure.** Every added `BEGIN DEFERRED` ends with
`ROLLBACK` in `finally`.
- **Identity and keys.** No hash or ID changes.
- **Lossless transforms.** Not applicable.
- **Degenerate inputs.** NaN and infinite snapshot bounds are refused.
Negative or reversed boundary ranges fall back to the plain prefix. An
empty ID list returns early.
- **Consumers.** The CLI renderer uses the lane fields.
`test_mapped_bytes_budget` was updated to three writers.
`read_view_extras` uses the new owner.
- **Tests and stubs.** The monkeypatch targets (`_own_messages`,
`read_model_usage_batch_async`, `_resolve_subscription_tier_setting`)
exist and are called on the production route. Each test states its
anti-vacuity condition.
- **Trust boundaries.** No change.

## Per-finding dispositions

| key | disposition | evidence | test |
|---|---|---|---|
| 107-01 (#4642) | not reached | still real: Invalidation returns
children, not the former parent cohorts; only the current session
receives an explicit delegation refresh. | — |
| 107-02 (#4690) | not reached | still real: LIKE requires an immediate
subagents basename and the parent check uses parts[-3]. | — |
| 107-03 (#4642) | not reached | still real: Retired-alias invalidation
selects only resolved links to the withdrawing claimant; graph inbound
lookup only addresses the written session. | — |
| 107-04 (#4690) | not reached | still real: Unresolved multi-name
observations are skipped and sidecars can bind the known sibling; no
full parent cohort revisit on a second child arrival. | — |
| 107-05 (#4056) | not reached | still real: Every controller submits to
one four-worker adapter, regardless of its capacity. | — |
| 107-06 (#4606) | fixed-already |
`polylogue/storage/sqlite/connection_profile.py:900-910; :1193-1206`
holds on current master | — |
| 107-07 (#4610) | fixed-already |
`polylogue/storage/sqlite/connection_profile.py:932-945` holds on
current master | — |
| 107-08 (#4611) | fixed-already |
`polylogue/storage/sqlite/connection_profile.py:932-945` holds on
current master | — |
| 107-09 (#4687) | fixed | `_assert_schema_supported` keeps the
empty-tier exemption for read-only opens only;
`open_connection`/`open_daemon_connection` on a never-provisioned tier
now raise `SchemaSkew` before any SQL. Attached siblings keep the
absent-tier read answer. |
`test_writers_refuse_an_uninitialized_durable_tier` |
| 107-10 (#5248) | fixed | `mapped_bytes_budget` and
`MappedBytesBudgetCheck.concurrent_profile_budget_bytes` count three
ordinary writer profiles (index, source, publication reservation). |
`test_memory_budget_includes_source_and_reservation_writers` |
| 107-11 (#4794) | not reached | still real: A pathname stat after
opening can stamp the connection with a replacement inode. | — |
| 107-12 (#4794) | fixed | `ReadFrame.resume` rebinds a live frame whose
connection holds a read transaction before proving the anchor, and
refuses with `ReadFrameExpiredError` while a stream pins the snapshot. |
`test_resume_releases_a_held_snapshot_before_proving_the_anchor,
::test_resume_refuses_while_a_stream_pins_the_snapshot` |
| 107-13 (#5401) | not reached | still real: Cancel interrupts a running
statement but leaves a cursor suspended at yield open. | — |
| 107-14 (#5401) | fixed | `ReadFrame.close` closes registered stream
cursors before the connection, so later generator cleanup has nothing to
do. | `test_stream_can_be_closed_after_its_frame` |
| 107-15 (#5401) | fixed | `read_frame` and `ReadFrame.__init__` refuse
NaN and infinite snapshot bounds. |
`test_read_frame_rejects_nonfinite_snapshot_bounds` |
| 107-16 (#4183) | fixed | `format_session_markdown` uses the recorded
`source_url` when an attachment has no local path. |
`test_markdown_uses_remote_attachment_urls_without_a_local_path` |
| 107-17 (#5454) | not reached | still real: The session filter selects
physical attachment refs only, excluding a composed parent prefix. | — |
| 107-18 (#5454) | fixed | The attachment library orders by session sort
key (newest first), then message position/variant, then attachment ID
within a message (as the session read does), before LIMIT/OFFSET. |
`test_attachment_library_pages_keep_session_and_transcript_order` |
| 107-19 (#5420) | fixed-already |
`polylogue/analysis/archive_models.py:79;
polylogue/storage/derived/session/profiles.py:248;
polylogue/storage/sqlite/queries/mappers_insight_profiles.py:54-56`
holds on current master | — |
| 107-20 (#4985) | fixed | `effective_context_window` (the single owner,
used by both the API and the pinned `read.effective_context` operation)
falls back to the plain prefix unless 0 <= start <= end. |
`test_effective_context_rejects_invalid_ranges` |
| 107-21 (#4985) | fixed | The boundary query selects the newest
compaction first; an incomplete newest row yields the plain prefix
instead of an older summary. |
`test_newest_incomplete_compaction_does_not_reuse_an_older_summary` |
| 107-22 (#4357) | fixed | Both effective-context routes now compose the
lineage transcript before applying the local boundary. |
`test_effective_context_includes_a_forks_inherited_prefix,
::test_pinned_operation_and_api_share_one_effective_context_decision` |
| 107-23 (#4357) | fixed | Messages and the boundary are read in one
deferred read transaction. |
`test_effective_context_reads_boundary_in_the_message_snapshot` |
| 107-24 (#4577) | fixed | Single, batch and list profile reads hold one
read snapshot across the profile rows and the usage overlay. |
`test_profile_rows_and_usage_overlay_share_one_snapshot` |
| 107-25 (#4630) | not reached | still real: LIMIT is applied to thread
ids before hydration drops roots without profiles. | — |
| 108-01 (#4200) | fixed | `put_query` returns the persisted row
(including promotion metadata) after the idempotent insert. |
`test_put_query_returns_existing_promotion_contract` |
| 108-02 (#4200) | not reached | still real: The tombstone predicate
checks only the caller-provided result_set_id. | — |
| 108-03 (#4357) | fixed | `get_effective_context` hydrates blocks and
derived text inside the same snapshot as the messages. |
`test_effective_context_hydrates_structured_tool_blocks` |
| 108-04 (#4799) | fixed | Compaction context snapshots take `event
position + 1`, leaving position 0 to the session-start snapshot. |
`test_context_snapshot_start_precedes_the_first_compaction` |
| 108-05 (#4546) | fixed-already |
`polylogue/storage/sqlite/schema_manifest.py:92-129` holds on current
master | — |
| 108-06 (#4546) | fixed | A failure to build the canonical index
manifest is classified `upgrade_runtime`, separately from archive read
failures (`retry`) and drift. |
`test_canonical_ddl_runtime_failure_requests_runtime_upgrade` |
| 108-07 (#4579) | fixed-already |
`polylogue/storage/sqlite/archive_tiers/archive.py:6694-6697;
:8603-8616; polylogue/storage/sqlite/queries/sessions_search.py:25-27;
polylogue/mcp/server_support.py:546-555` holds on current master | — |
| 108-08 (#4637) | fixed-already |
`polylogue/storage/sqlite/schema.py:113-128;
polylogue/storage/sqlite/schema_bootstrap.py:87-101` holds on current
master | — |
| 108-09 (#4637) | not reached | still real: An installed read-only
source tree cannot host the persistent memo, so short-lived processes
recompute source closures. | — |
| 108-10 (#4601) | not reached | still real: The existing async
identity-adoption helper inserts without a commit. A compliant fix must
remove unsupported legacy adoption rather than perpetuate it. | — |
| 108-11 (#5401) | fixed | Read frames are named as checkpoint blockers
only when the checkpoint left busy pages or undrained log, or failed. |
`test_successful_checkpoint_does_not_label_current_snapshot_as_a_blocker`
|
| 108-12 (#4317) | not reached | still real: Cumulative input always
subtracts cache; origin is explicitly discarded. | — |
| 108-13 (#4317) | not reached | still real: Duplicate non-Codex
disjoint-input report, retained separately. | — |
| 108-14 (#4317) | not reached | still real: The exported canonical
projection has no production caller; writer paths still fold usage
separately. | — |
| 108-15 (#4317) | not reached | still real: Each cumulative session
rebuilds the entire grouped dictionary. | — |
| 108-16 (#4317) | not reached | still real: Default tuple ordering
compares nullable model names against strings in projection and rollup.
| — |
| 108-17 (#4317) | fixed-already | `polylogue/storage/usage.py:237-247`
holds on current master | — |
| 108-18 (#4317) | not reached | still real: Reasoning-only or
total-only evidence can become a complete zero-cost projection. | — |
| 108-19 (#4317) | not reached | still real: Costs are rounded to six
decimal places before further aggregation. | — |
| 108-20 (#4927) | fixed-already | `polylogue/storage/usage.py:589-595`
holds on current master | — |
| 108-21 (#4927) | fixed | The plaintext usage report renders
`provider_request_lanes`/`provider_cumulative_lanes` and prints
`unavailable` for an unreported lane. |
`test_usage_cli_renders_disjoint_lanes_and_unavailable_requests` |
| 108-22 (#4927) | fixed | Request-lane reportedness counts events that
carry a last/request counter (`request_counter_event_count`), in both
the SQL and streaming stats paths. The cumulative lane follows the same
counter-evidence rule. |
`test_request_lane_reportedness_requires_request_counter_evidence` |
| 108-23 (#4927) | fixed | Same change: cumulative-only events stay
`unavailable`; an explicit request zero stays `reported`. |
`test_request_lane_reportedness_requires_request_counter_evidence` |
| 108-24 (#4293) | fixed | The cache-rate coverage check runs before a
stored priced cost is reused. |
`test_stored_price_does_not_hide_a_missing_cache_rate` |
| 108-25 (#4217) | fixed | `session_usage_costs_for_connection` batches
IDs at the connection's `SQLITE_LIMIT_VARIABLE_NUMBER`. |
`test_session_cost_lookup_pages_at_the_connection_bind_limit` |
| 109-01 (#4217) | fixed | Model names are normalized before the credit
lookup; a token-bearing row whose model still has no credit rate makes
the session's subscription amount unknown (None), not $0. |
`test_session_subscription_fallback_normalizes_provider_qualified_models,
::test_session_subscription_amount_is_unknown_without_a_rate_or_tier` |
| 109-02 (#4217) | fixed | Credits pass through `credits_to_usd` with
the archive's configured tier (default `pro`); a tier the catalog no
longer declares yields None. |
`test_session_subscription_amount_is_dollars_not_raw_credits` |

Worker claims narrowed rather than rejected: 107-09, 107-12, 107-18,
107-22 and 107-24 (see Problem), and 109-01/109-02 (fail closed). No
worker `fixed` claim was dropped as not real.

## Derived-identity closure

`devtools schema closure` on the changed files. IN:
`storage/sqlite/connection_profile.py`, `queries/attachment_records.py`,
`queries/message_query_reads.py`, `query_objects.py`,
`query_store_archive.py`, `run_projection_relations.py`, `schema.py`,
`wal_checkpoint.py`, `storage/usage.py`. Out:
`cli/commands/diagnostics.py`, `operations/read_view_extras.py`,
`rendering/core_markdown.py`,
`queries/session_insight_profile_reads.py`. Land this before a rebuild
starts.

## Residuals

- 19 findings remain not reached, and their beads stay open.
- The pinned `read.effective_context` operation returns messages without
hydrated blocks. The API route hydrates them. This predates the PR.
- Both effective-context routes compose the full transcript in memory,
as `get_messages` does.
- `_attach_sibling_tiers` still admits an empty sibling tier on a writer
connection. Only direct writer opens refuse.
- Four inherited test failures on master are listed above.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_015pdKaZWyGe6Ngvsz468dzg

---------

Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
Sinity added a commit that referenced this pull request Sep 29, 2026
## Summary

Lands 24 verified storage fixes from the worker-6 Codex-debt batch
(beads polylogue-1tyq5.101, .102, .103). Each fix was rechecked against
current master and has a regression test on its production route. One
worker fix was dropped because it contradicts documented policy
(103-09). The other 50 findings are recorded below as fixed-already,
stale, refuted or not reached.

## Problem

The worker could not run tests. Its draft (ca8dbff) was based on
e1a2f75, and master has moved on since then. Each "fixed" claim
therefore had to be checked again on current master. The defects that
remain on master:

- **Material admission** (`storage/materials.py`)
  - A valid JSON document larger than 2 MB was marked `malformed`.
- Multi-record NDJSON was marked `malformed` too, because it is not a
single JSON value.
- ZIP entry names were copied without a bound into durable manifest
metadata.
- Readmitting a material returned the caller's arguments rather than the
stored row.
- An idempotent retry matched its own row and was rewritten as
`duplicate`.
- A malformed URL raised out of the API before any durable claim was
recorded.
  - A material linked twice to one evidence ref was listed twice.
- A chunked response carrying a stale `Content-Length` was stored as
`partial`.
  - A redirected HTTP failure did not record which hop failed.
  - A relative file path raised in `Path.as_uri`.
- **Raw frontier** (`storage/raw_retention.py`)
- The integrity projection and the selected-frontier admission helpers
opened `source.db` with `validate_schema=False`. A source tier at an
unadmitted schema version could then report healthy frontier evidence.
- A pinned operation read with no ops handle fell back to opening the
live `ops.db` path.
- **Index tier and reads**
- Trigger-maintained action pairs copied the stale outcome cached on the
tool_use block. Pair outcomes now come from the paired result block.
- A work-event payload could override the validated
`event_id`/`summary`.
- Reviving or re-deleting a displaced saved view cleared another view's
watch.
- A NaN or infinite metadata value was accepted on first write, after
which the key could not be changed.
  - An empty aggregate page reported `total_groups=0`.
  - Session timestamps dropped their milliseconds.
- The observed-tool rollup and the observed-event relation, including
its status pushdown, reinterpreted a retained exit code 0 as success
even when the canonical outcome was a deliberate `unknown`.
- Changing an attachment ref's target or position did not invalidate the
profile binding.
- `list_embedding_catchup_runs` rejected the `completed_with_failures`
status that its writer accepts.
- **Bootstrap** (`archive_tiers/bootstrap.py`)
  - The OPS same-digest shortcut returned without enabling foreign keys.
- A failure after `.bootstrap` was published, but before the format
marker, left an archive that could not be recovered.

## Solution

Most fixes are the worker's patch, with these changes:

- **101-02:** JSON documents are validated as a stream with
`ijson.basic_parse`, so a large material is never loaded as Python
objects. NDJSON is parsed line by line.
- **101-04:** readmission returns the persisted row and does not
overwrite stored filename, media type, privacy or supersession metadata.
The worker's version replaced them with the new call's arguments,
including `None`.
- **101-05:** the extra "never mark malformed as duplicate" condition is
dropped. Only the self-match is fixed.
- **101-21:** the siblings are fixed too:
`raw_frontier_blocked_raw_ids`, `_raw_frontier_blocked_selected_paths`
and `raw_frontier_blocked_source_paths` open `source.db` with schema
admission and report `SchemaSkew` as unavailable.
- **101-23:** the ops-unavailable branch is typed and explicit.
- **103-15:** the finding's cited route (evidence summary) already reads
`result_state` on master. The same defect is fixed in the two remaining
readers: the rollup and `run_projection_relations` (projection and
pushdown).
- **103-09 dropped:** see the table.

## Verification

- `agentctl job start polylogue pytest_focused --workspace
/realm/worktrees/salvage-w6 -- <28 files>` (job 2539): 631 passed, 12
failed, 1 error. The same 9 failures and 1 error occur on base (job
2601: `test_user_state_contracts` FacadeDaemonRequiredError x7,
`test_session_partition_convergence` x2,
`test_frontier_admission::test_changed_keys_beyond_one_batch_are_all_checked`
timeout). The other 3 were test defects in the new file (DSL `AND`,
source-tier raw lookup), fixed and rerun in job 2603: 43 passed, 1
failed (the same base timeout).
- Revert proof: the production files restored from origin/master, with
the new tests kept (job 2540): 35 failed. Every new test fails, each on
the defect it names (for example `ValueError: relative paths can't be
expressed as file URIs`, `DID NOT RAISE`, `KeyError:
'uncompressed_bytes'`, and assertion failures).
- `agentctl job start polylogue verify_quick --workspace
/realm/worktrees/salvage-w6` (job 2639): `verify: PASSED exit=0` at
2fcacb6 (the first run, job 2559, failed on a moved
sqlite-degradation anchor; the anchor was updated in the baseline).

## Self-review

**Sibling sites.** Each defect class was searched across the codebase.
- Unchecked durable-tier opens: three sibling source opens in
`raw_retention.py` were fixed. The two `ops.db` opens keep
`validate_schema=False`, because OPS is a disposable tier whose identity
converges in place.
- Exit-code success reinterpretation: the rollup and both observed-event
sites were fixed. `archive.py` still has error-count columns that count
error signals; they make no success claim, so they were left unchanged.
`archive/actions/parsing.py` and `rendering/semantic_cards.py` are
presentation-layer and out of scope.
- The watch-clearing fix covers both `save_view` and `delete_view`.

**Cancellation and shutdown.** No loops or long-running work were added.

**Unbounded reads.** JSON validation now streams rather than
materializing a whole document. The ZIP manifest no longer copies names.
`admit_material_file` still reads the whole file (103-13, not reached).

**Fail-open fallbacks.** Removed rather than added: the pinned read no
longer falls back to the live ops path. Schema skew now blocks admission
instead of passing silently.

**Compatibility shims.** None added.

**Removed symbols.** The unused `require_operation_lifecycle_status`
import is gone. No monkeypatch targets or fakes reference anything
removed.

**Tests prove the production route.** Every test goes through
`admit_material`/`acquire_material`, `ArchiveStore`,
`initialize_active_archive_root`, the trigger DDL, or the query route
(`query_unit_counts`). The revert run shows they fail on master's code.

## Per-finding table

| key | disposition | evidence | test |
|---|---|---|---|
| 101-01 #5249 `polylogue/storage/index_generation.py:1599` |
fixed-already | `polylogue/daemon/cli.py:3376`: Shutdown discard is
submitted through write_coordinator.run_sync before coordinator drain. |
— |
| 101-02 #4241 `polylogue/storage/materials.py:73` | fixed | Validates
the whole document as a stream (ijson) and NDJSON record by record;
trailing garbage stays malformed. |
test_material_json_admission_validates_the_complete_document,
test_material_ndjson_admission_parses_each_record. |
| 101-03 #4241 `polylogue/storage/materials.py:80` | fixed | Manifest
keeps entry_count and uncompressed_bytes only; names stay in the
retained CAS bytes. |
test_material_zip_manifest_does_not_copy_entry_names. |
| 101-04 #4241 `polylogue/storage/materials.py:139` | fixed |
admit_material returns the persisted row (get_material) instead of its
arguments; stored filename/media/privacy/creation time are not
overwritten on readmission. |
test_material_readmission_returns_the_persisted_row. |
| 101-05 #4320 `polylogue/storage/materials.py:150` | fixed | Duplicate
detection excludes the admitted material_id. |
test_material_readmission_does_not_duplicate_itself (a distinct
observation of the same bytes is still 'duplicate'). |
| 101-06 #4320 `polylogue/storage/materials.py:236` | fixed-already |
`polylogue/storage/materials.py:662-674;
polylogue/storage/materials.py:715-720`: List extracts IDs from tuple
rows or sqlite3.Row; get_material maps cursor.description for tuples. |
— |
| 101-07 #4623 `polylogue/storage/materials.py:240` | fixed | URL
parsing and InvalidURL/ValueError from connection construction become a
durable non-retryable 'malformed' claim. |
test_material_invalid_url_is_a_durable_malformed_claim,
test_material_invalid_http_target_is_a_durable_claim. |
| 101-08 #4241 `polylogue/storage/materials.py:240` | fixed | Evidence
filter uses EXISTS, one row per material. |
test_material_evidence_listing_returns_one_observation_per_identity. |
| 101-09 #5408 `polylogue/storage/materials.py:262` | fixed |
Content-Length is ignored when Transfer-Encoding frames the response. |
test_material_chunked_response_ignores_stale_content_length. |
| 101-10 #4623 `polylogue/storage/materials.py:315` | fixed | HTTP
failure diagnostic carries the failing hop URL when it differs from
source_uri. | test_material_http_error_retains_redirect_destination. |
| 101-11 #4623 `polylogue/storage/materials.py:345` | fixed |
admit_material_file uses Path.absolute() before as_uri(). |
test_material_relative_file_admission_retains_success_or_absence. |
| 101-12 #4623 `polylogue/storage/materials.py:345` | fixed | Same fix
as the sibling comment on this line (Path.absolute()). |
test_material_relative_file_admission_retains_success_or_absence. |
| 101-13 #4623 `polylogue/storage/materials.py:347` | not reached |
`polylogue/storage/materials.py:591-594`: Local material admission reads
the entire file into memory. | — |
| 101-14 #5626 `polylogue/storage/materials.py:741` | not reached |
`polylogue/storage/materials.py:739-752`: Timestamp/hash keyset cursor
can miss subsequent inserts sorting before the cursor at the same
timestamp. | — |
| 101-15 #4039
`polylogue/storage/raw_authority_verdict_projection.py:103` | not
reached |
`polylogue/storage/raw_authority_verdict_projection.py:86-148`:
Projection promotes every byte-proven append leaf independently of
accepted-chain ambiguity. | — |
| 101-16 #4556 `polylogue/storage/raw_failure_lifecycle.py:111` |
fixed-already | `polylogue/storage/raw_failure_lifecycle.py:124-139`:
Ordinary source open performs admission and reports SchemaSkewError as
unavailable. | — |
| 101-17 #5301 `polylogue/storage/raw_reconciler.py:213` | not reached |
`polylogue/storage/raw_reconciler.py:108-127`: Renamed pass_id payload
still advertises the previous census.v1 schema. | — |
| 101-18 #5350 `polylogue/storage/raw_reconciler.py:324` | refuted |
`polylogue/storage/raw_reconciler.py:314-381`: Explicitly requires an
archive predating the raw-ID change; current assignment is fresh v1 with
no carry-forward of that state. | — |
| 101-19 #5350 `polylogue/storage/raw_reconciler.py:549` | refuted |
`polylogue/storage/raw_reconciler.py:564-615`: Requests migration of
durable candidate assertions from a deleted framework; outside the
fresh-v1/no-carry-forward contract. | — |
| 101-20 #5301 `polylogue/storage/raw_reconciler.py:1049` | not reached
| `polylogue/storage/raw_reconciler.py:394-473`: Blocker ID selection
only searches its proposed ID; a unique open plan conflict can suppress
the insert while returning a nonexistent ID. | — |
| 101-21 #4556 `polylogue/storage/raw_retention.py:1231` | fixed |
Frontier projection opens source.db with schema admission and reports
SchemaSkew as unavailable; the selected-frontier admission helpers
(raw_frontier_blocked_raw_ids, _raw_frontier_blocked_selected_paths,
raw_frontier_blocked_source_paths) do the same. |
test_frontier_projection_refuses_a_source_from_a_newer_schema. |
| 101-22 #4683 `polylogue/storage/raw_retention.py:1302` | not reached |
`polylogue/storage/raw_retention.py:1387-1420`: Admission attributes a
sampled million-row projection without refusing truncated populations. |
— |
| 101-23 #5020 `polylogue/storage/raw_retention.py:1688` | fixed | With
ops_conn=None the pinned snapshot reports cursor status 'unknown' and
never opens ops_db_path. |
test_pinned_frontier_does_not_substitute_a_live_ops_file_for_missing_reader.
|
| 101-24 #5371 `polylogue/storage/raw_retention.py:2350` | not reached |
`polylogue/storage/raw_retention.py:2478-2491`: Residual test uses
post-filter candidate count, which cannot prove the SQL selection was
exhausted. | — |
| 101-25 #4538
`polylogue/storage/search_providers/sqlite_vec_runtime.py:98` |
fixed-already |
`polylogue/storage/search_providers/sqlite_vec_runtime.py:239-249`:
Managed provider rejects missing active index before attempting
attachment; pinned snapshot uses read-only attachment at 120-133. | — |
| 102-01 #4538
`polylogue/storage/search_providers/sqlite_vec_runtime.py:115` | not
reached |
`polylogue/storage/search_providers/sqlite_vec_runtime.py:34-108;251-256`:
Managed connections rebuild and hash the complete eligible-message TEMP
projection on each acquisition. | — |
| 102-02 #5274 `polylogue/storage/source_generation_receipts.py:252` |
not reached | `polylogue/operations/daemon_ingest.py:881-999`:
Historical receipt serializes raw identities/completeness but not
source-item blockers and member dispositions. | — |
| 102-03 #4719 `polylogue/storage/sqlite/action_pairs.py:44` | fixed |
Action pairs take the outcome from the paired result block, 'no_result'
when absent, matching _reconcile_tool_use_outcomes. |
test_action_pairs_follow_paired_result_updates_and_deletes. |
| 102-04 #5275 `polylogue/storage/sqlite/archive_tiers/__init__.py:43` |
fixed-already |
`polylogue/storage/sqlite/archive_tiers/__init__.py:21-26;42-49`:
Exported durable tier constants and ARCHIVE_VERSION_BY_TIER all use
version one. | — |
| 102-05 #4201 `polylogue/storage/sqlite/archive_tiers/archive.py:416` |
fixed-already | `polylogue/mcp/archive_support.py:165-179;
polylogue/surfaces/payloads.py:1311-1315`: MCP delegates to canonical
hydration and the shared summary envelope explicitly supplies
terminal_state, total_cost_usd, cost_provenance and relative_time. | — |
| 102-06 #4353 `polylogue/storage/sqlite/archive_tiers/archive.py:1085`
| not reached |
`polylogue/storage/sqlite/archive_tiers/archive.py:1622-1629`:
Work-event append reverses public Origin into guessed Provider. | — |
| 102-07 #4353 `polylogue/storage/sqlite/archive_tiers/archive.py:1086`
| fixed | Validated event_id and summary are merged after the caller
payload. | test_work_event_payload_cannot_override_validated_identity. |
| 102-08 #4816 `polylogue/storage/sqlite/archive_tiers/archive.py:2459`
| stale | `polylogue/storage/sqlite/archive_tiers/archive.py:4492-4513`:
Named list_session_work_event_insights LIKE implementation is gone;
current insight dispatch is elsewhere. No claim of testing successor
search. | — |
| 102-09 #4225 `polylogue/storage/sqlite/archive_tiers/archive.py:2542`
| not reached | `polylogue/storage/sqlite/archive_tiers/archive.py:3168;
polylogue/storage/sqlite/archive_tiers/archive.py:3952`: Full catalog
coverage sets cost_is_estimated=0, confusing completeness with monetary
authority. | — |
| 102-10 #4293 `polylogue/storage/sqlite/archive_tiers/archive.py:2681`
| not reached |
`polylogue/storage/sqlite/archive_tiers/archive.py:3351-3360;3400-3419`:
Outer cohort dedup count is reused for raw-model breakdown and status
classification. | — |
| 102-11 #4395 `polylogue/storage/sqlite/archive_tiers/archive.py:2957`
| fixed-already |
`polylogue/storage/sqlite/archive_tiers/archive.py:3280;3311;3351`:
Session populations use json_group_array and lossless
_decode_session_id_set instead of comma splitting. | — |
| 102-12 #4692 `polylogue/storage/sqlite/archive_tiers/archive.py:3380`
| fixed-already |
`polylogue/storage/sqlite/archive_tiers/archive.py:3971;8398`: Profile
SELECT and domain mapper both carry input_content_hash. | — |
| 102-13 #5408 `polylogue/storage/sqlite/archive_tiers/archive.py:5215`
| fixed | save_view clears the previous name's watch only when this view
still owns that name. |
test_resurrected_view_rename_does_not_clear_another_views_watch. |
| 102-14 #5408 `polylogue/storage/sqlite/archive_tiers/archive.py:5284`
| fixed | delete_view clears the watch only on a successful delete of
the name's active owner. |
test_redeleting_view_does_not_clear_reassigned_name_watch. |
| 102-15 #5307 `polylogue/storage/sqlite/archive_tiers/archive.py:6193`
| not reached |
`polylogue/storage/sqlite/archive_tiers/archive.py:6222-6229`: Provider
usage readiness takes archive-global status counters, not the requested
origin/time scope. | — |
| 102-16 #5307 `polylogue/storage/sqlite/archive_tiers/archive.py:6195`
| not reached |
`polylogue/storage/sqlite/archive_tiers/archive.py:6222-6229`: Provider
usage readiness hardcodes stale count zero and only compares row
coverage. | — |
| 102-17 #4238 `polylogue/storage/sqlite/archive_tiers/archive.py:6730`
| not reached |
`polylogue/storage/sqlite/archive_tiers/archive.py:7688-7699`: Display
duration subtracts normalized session endpoints, including synthesized
endpoints. | — |
| 102-18 #4649 `polylogue/storage/sqlite/archive_tiers/archive.py:7271`
| not reached |
`polylogue/storage/sqlite/archive_tiers/archive.py:8140-8146`: Missing
persisted provenance is labeled with current materializer version. | — |
| 102-19 #5362 `polylogue/storage/sqlite/archive_tiers/archive.py:7408`
| not reached |
`polylogue/storage/sqlite/archive_tiers/archive.py:7672-7679`: All
heuristic titles are suppressed, not only prompt echoes. | — |
| 102-20 #4221 `polylogue/storage/sqlite/archive_tiers/archive.py:7539`
| stale | `polylogue/storage/sqlite/archive_tiers/archive.py:8454-8504`:
Former profile-cost fallback was removed; current cost insight uses
canonical usage authority and reports no_tokens explicitly rather than
labeling fallback as catalog-priced. | — |
| 102-21 #4804 `polylogue/storage/sqlite/archive_tiers/archive.py:7839`
| fixed | set_user_metadata canonicalizes every value before the first
write, so NaN/inf are refused inside the transaction. |
test_metadata_first_write_refuses_nonfinite_json_atomically. |
| 102-22 #5275
`polylogue/storage/sqlite/archive_tiers/archive_plan.py:189` |
fixed-already |
`polylogue/storage/sqlite/archive_tiers/archive_plan.py:181-213`: Schema
fingerprint and version readers now use canonical
open_readonly_connection URI construction. | — |
| 102-23 #5275
`polylogue/storage/sqlite/archive_tiers/archive_plan.py:261` | stale |
`polylogue/storage/sqlite/archive_tiers/archive_plan.py:181-223;bootstrap.py:877-924`:
initialize_archive_tier_files_from_plan is deleted; ordinary fresh root
bootstrap now records and admits pending intent. | — |
| 102-24 #5356
`polylogue/storage/sqlite/archive_tiers/archive_query_reads.py:3424` |
fixed | The aggregate page selects a count row over all groups joined to
the requested page, so an empty page keeps total_groups. |
test_empty_aggregate_page_preserves_total_group_count. |
| 102-25 #5514
`polylogue/storage/sqlite/archive_tiers/archive_tiers_specs.py:48` |
fixed-already |
`polylogue/storage/sqlite/archive_tiers/vocabulary_inventory.py:138-153`:
core_types is scanned before consumer re-exports, retaining declaration
ownership. | — |
| 103-01 #5521
`polylogue/storage/sqlite/archive_tiers/archive_tiers_specs.py:49` | not
reached | `docs/atlas/00-core.md:59-67;docs/atlas/storage.md:35-40`:
Identity anchors no longer point at their generated-key declarations. |
— |
| 103-02 #4678
`polylogue/storage/sqlite/archive_tiers/archive_tiers_specs.py:729` |
fixed | Session created_at/updated_at project
strftime('%Y-%m-%dT%H:%M:%fZ', ms/1000.0). |
test_session_record_reads_preserve_milliseconds. |
| 103-03 #4177
`polylogue/storage/sqlite/archive_tiers/archive_tiers_specs.py:885` |
not reached | `polylogue/maintenance/archive_verification.py:1443-1467`:
Lineage sanity checks message existence but not branch-point content
address agreement. | — |
| 103-04 #5476
`polylogue/storage/sqlite/archive_tiers/archive_tiers_specs.py:1217` |
not reached | `docs/atlas/storage.md:79-87`: Session-link/branch-point
explanation anchors shifted away from their declarations. | — |
| 103-05 #4302 `polylogue/storage/sqlite/archive_tiers/bootstrap.py:249`
| not reached |
`polylogue/storage/sqlite/archive_tiers/bootstrap.py:435-451;501-561`:
OPS sentinel fast path neither recreates nor refuses missing canonical
objects. | — |
| 103-06 #4302 `polylogue/storage/sqlite/archive_tiers/bootstrap.py:249`
| fixed | _materialize_archive_tier enables foreign keys before the OPS
same-digest shortcut. |
test_cached_ops_initialization_enables_connection_foreign_keys. |
| 103-07 #4560 `polylogue/storage/sqlite/archive_tiers/bootstrap.py:254`
| fixed-already |
`polylogue/storage/sqlite/archive_tiers/bootstrap.py:407-417`: Derived
identity stamp is followed by conn.commit(). | — |
| 103-08 #4560 `polylogue/storage/sqlite/archive_tiers/bootstrap.py:845`
| fixed-already |
`polylogue/storage/sqlite/archive_tiers/bootstrap.py:1159-1178`: Stored
user_version is admitted before materialization; skew raises SchemaSkew.
| — |
| 103-09 #4560 `polylogue/storage/sqlite/archive_tiers/bootstrap.py:846`
| dropped (not a defect) | ops.db identity converges in place by
documented policy (`initialize_archive_database`); worker's refusal
reverted | — |
| 103-10 #5275 `polylogue/storage/sqlite/archive_tiers/bootstrap.py:848`
| fixed-already |
`polylogue/storage/sqlite/archive_tiers/bootstrap.py:877-905`: Pending
fresh bootstrap intent is validated and exempts incomplete first
creation from completed-marker admission. | — |
| 103-11 #5275 `polylogue/storage/sqlite/archive_tiers/bootstrap.py:883`
| fixed-already |
`polylogue/storage/sqlite/archive_tiers/bootstrap.py:888-920`: Marker
admission and fresh-bootstrap classification are keyed to durable tier
files, not replaceable-only tiers. | — |
| 103-12 #5275 `polylogue/storage/sqlite/archive_tiers/bootstrap.py:959`
| fixed | Fresh bootstrap publishes (or validates an already published)
format marker before the completed bootstrap marker, so the pending
intent survives until both exist. |
test_fresh_bootstrap_format_publication_failure_is_resumable. |
| 103-13 #4323 `polylogue/storage/sqlite/archive_tiers/embeddings.py:20`
| refuted |
`polylogue/storage/sqlite/archive_tiers/embeddings.py:7;26-31`: Finding
requires opening the pre-v1 version-five vector table; this assignment
starts fresh with embeddings version one and canonical model column, no
prior archives. | — |
| 103-14 #4719 `polylogue/storage/sqlite/archive_tiers/index.py:868` |
not reached |
`polylogue/storage/sqlite/archive_tiers/archive_query_reads.py:121-143;1066-1088`:
Public action row and selected column list omit canonical
unknown-outcome reason. | — |
| 103-15 #4719 `polylogue/storage/sqlite/archive_tiers/index.py:877` |
fixed | The cited evidence-summary route already reads result_state on
master (operations/http_read_models.py read_session_evidence). The same
exit-code reinterpretation remained in
list_tool_observed_event_count_rows and the observed-event relation and
its status pushdown (run_projection_relations.py); all three now map
only the canonical tool_outcome. |
test_observed_tool_rollup_respects_canonical_outcome_over_exit_code. |
| 103-16 #4630 `polylogue/storage/sqlite/archive_tiers/index.py:1090` |
not reached |
`polylogue/storage/sqlite/archive_tiers/index.py:1319-1320`: Thread
search projection only includes thread ID, repo and session IDs;
evidence-kind/support terms are absent. | — |
| 103-17 #5312 `polylogue/storage/sqlite/archive_tiers/index.py:1257` |
fixed-already | `tests/infra/reindex_differential.py:95-98`:
session_usage_rollup_bindings now has an explicit exact deterministic
census classification. | — |
| 103-18 #5410 `polylogue/storage/sqlite/archive_tiers/index.py:1499` |
fixed | session_profile_binding_refs_au now fires on attachment_id and
position updates. |
test_attachment_reference_identity_and_order_invalidate_profile_binding.
|
| 103-19 #4630 `polylogue/storage/sqlite/archive_tiers/index.py:1786` |
not reached |
`polylogue/storage/sqlite/archive_tiers/index.py:2150-2158`: Child
monetary amount may use provider evidence while its estimated flag is
derived from catalog coverage. | — |
| 103-20 #4630 `polylogue/storage/sqlite/archive_tiers/index.py:1919` |
not reached | `polylogue/storage/sqlite/archive_tiers/index.py:2289`:
Tag-rollup materialized_at is literal query-time rather than an ISO
timestamp or missing value. | — |
| 103-21 #5373 `polylogue/storage/sqlite/archive_tiers/ops.py:209` |
refuted |
`polylogue/storage/sqlite/archive_tiers/ops.py:1-220;bootstrap.py:888-909`:
Finding asks to carry and drop objects in archives from the prior OPS
schema. Fresh-v1/no-prior-state assignment excludes that upgrade. | — |
| 103-22 #5521
`polylogue/storage/sqlite/archive_tiers/ops_write.py:1237` | fixed |
list_embedding_catchup_runs validates the filter with
OperationRunStatus, the writer's vocabulary. |
test_embedding_catchup_filter_accepts_completed_with_failures. |
| 103-23 #4324
`polylogue/storage/sqlite/archive_tiers/read_insights.py:28` |
fixed-already |
`polylogue/storage/sqlite/archive_tiers/read_insights.py:27-36`:
Date-window parser delegates to shared parse_query_date. | — |
| 103-24 #4354
`polylogue/storage/sqlite/archive_tiers/read_insights.py:82` | not
reached |
`polylogue/storage/sqlite/archive_tiers/read_insights.py:123-145`:
Episode context scans only physical session messages and misses composed
inherited prefix. | — |
| 103-25 #4354
`polylogue/storage/sqlite/archive_tiers/read_insights.py:83` |
fixed-already |
`polylogue/storage/sqlite/archive_tiers/read_insights.py:115-136`: LIMIT
3 is inside the row-producing subqueries consumed by GROUP_CONCAT. | — |

## Derived-identity closure

All ten changed production files are members of the checked-in
`docs/plans/schema-closure-baseline.json`:

`storage/materials.py`, `storage/raw_retention.py`,
`storage/sqlite/action_pairs.py`,
`storage/sqlite/run_projection_relations.py`, and in
`storage/sqlite/archive_tiers/`: `archive.py`, `archive_query_reads.py`,
`archive_tiers_specs.py`, `bootstrap.py`, `index.py`, `ops_write.py`.

The index trigger DDL, the session timestamp projection and the
action-pair lowering all change, so the derived identity moves. This
must land before the fresh rebuild. `devtools schema closure` could not
run in this checkout because its environment is not provisioned, so
membership was read from the committed baseline.

## Residuals

- 26 findings are not reached, and they stay open in their beads. Among
them are 101-13 (local file admission reads the whole file into memory)
and 101-14 (keyset cursor).
- Session `created_at`/`updated_at` strings change format from
`YYYY-MM-DD HH:MM:SS` to ISO-8601 `...T...sssZ`. No reader in this
repository parses the old format; `annotations/join.py` slices the first
10 characters, which is unaffected.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_015pdKaZWyGe6Ngvsz468dzg

---------

Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
@Sinity

Sinity commented Sep 29, 2026

Copy link
Copy Markdown
Owner Author

Closing out open Codex review threads on this PR (evidence checked against master at ef10e59):

Resolving the fixed, stale and refuted threads; tracked threads stay open.

@Sinity

Sinity commented Sep 29, 2026

Copy link
Copy Markdown
Owner Author

Closing out open Codex review threads on this PR (evidence checked against master at 64a9bd0):

Resolving every thread listed; confirmed defects are fixed under the named bead.

@Sinity

Sinity commented Sep 29, 2026

Copy link
Copy Markdown
Owner Author

Closing out open Codex review threads on this PR (evidence checked against master at 0914f89):

Resolving every thread listed; confirmed defects are fixed under the named bead.

@Sinity

Sinity commented Sep 29, 2026

Copy link
Copy Markdown
Owner Author

Closing out open Codex review threads on this PR (evidence checked against master at 5d56c3a):

Resolving every thread listed; confirmed defects are fixed under the named bead.

Sinity added a commit that referenced this pull request Oct 5, 2026
## Summary
Preserve thread support search through the public API and MCP registry
projection, before paging.

## Problem
Original polylogue-5gj19 finding 42.F021 (PR #4630 discussion
3928525476) describes strong-thread search returning no rows because the
SQL relation omits support evidence. The current public
`ArchiveStore.iter_thread_insights` still searched only session
identity/title/repository/branch. MCP additionally discarded the
existing `expression` before its registry fetch.

Original 42.F118 (discussion 3928525464) describes paging roots then
dropping those without profiles in the former async list adapter. The
shipped public replacement from 74cc6b4
already hydrates session evidence without that exclusion; this change
qualifies its actual API/MCP page behavior and removes the unused
predecessor. Original 43.F114 (PR #4228 discussion 3860697570)
identifies a stale paste-filter test oracle.

## Solution
Search the public payload's shared support vocabulary and support level
in the existing SQL selection before LIMIT/OFFSET. Forward registry text
search only to descriptors declaring their existing `query` field,
preserving reference resolution precedence. Keep search/filter/page
operands in response context and retain direct offset refinement for
budgeted registry pages; framed DSL pages retain q2 authority.

Remove the unused async list adapter, DTO and mapper together. Keep
retained exact thread-record reads. Correct the paste refusal oracle to
the actual typed field/value and retain the accepted
`has_paste_evidence` control. Document the current search and paging
contract.

## Verification
- `agentctl job start polylogue pytest_focused --workspace
/home/sinity/.codex/worktrees/attachment-coordinate-evidence/polylogue
-- tests/unit/storage/test_thread_search_parity.py
tests/unit/mcp/test_query_request_contracts.py
tests/unit/mcp/test_bounded_query_transport.py
tests/unit/mcp/test_reference_query_pipeline.py
tests/unit/mcp/test_insight_projection_derivation.py
tests/unit/storage/test_thread_profile_read_authority.py
tests/unit/core/test_threads_runtime.py
tests/unit/core/test_insight_registry_parity.py
tests/unit/operations/test_insight_reads.py`: job 9049 SUCCESS, **56
passed / 56 collected**; receipt
`20261005T021731Z-focused-test-1988670-1d4e7fa1`.
- `agentctl job start polylogue verify_quick --workspace
/home/sinity/.codex/worktrees/attachment-coordinate-evidence/polylogue`:
job 9050 SUCCESS, **all 12 gates passed**; receipt
`20261005T021748Z-quick-1989117-ffac36fc`.
- `devtools schema closure
polylogue/storage/sqlite/archive_tiers/archive.py`: **IN**. Land before
reconvergence; no live rebuild was performed.
- Initial route probes 9044/9045 failed because the test server replaced
explicit fixture runtime config with ambient config. The corrected
explicit service construction passed 9046 and the final owning
selection; original failure receipts remain preserved.

## Self-review
Reviewed the coherent delta once, including connected budget refinement
and removed consumers.

1. ✓ Siblings/owners: public SQL/payload vocabulary shared;
API/MCP/export use the same reader.
2. ✓ Fix: parameter ordering and descriptor-field forwarding checked; 56
controls pass.
3. ✓ Memory/limits: filter in SQL; hydrate selected page only; no new
cap.
4. ✓ Cost: existing SQL and offset window retained; no archive-wide
Python hydration.
5. N/A interruption: no new loop or mutation; existing read lifetime
retained.
6. ✓ Ordering/races: existing ordered relation and read custody
preserved.
7. ✓ Failure classification: existing typed read/refusal paths retained;
typed paste oracle checked.
8. ✓ Outcomes: existing terminal owner retained; empty page and
unprofiled readable root exercised.
9. N/A cleanup: no new owned resource or write boundary.
10. N/A identity/keys: no durable ID/key change; derived closure
membership recorded.
11. ✓ Lossless transforms: narrowing retains original search and
advances offset; q2 controls pass.
12. ✓ Degenerate inputs: absent term and exhausted page exercised.
13. ✓ Consumers: both dispatch helpers, response budget owner, docs and
tests updated; unused predecessor removed.
14. ✓ Tests/stubs: real writer/API/MCP route with explicit runtime
ownership; reference precedence tested.
15. ✓ Trust: neutral synthetic fixtures only; no private archive or
receipt contents tracked.

## Residuals
The broader polylogue-5gj19 group remains open. F118 is qualified
against its shipped replacement, not claimed as a newly introduced
profile gate. Existing SQL offset/search work can scale with the
selected relation; this does not claim constant-time search. No
fresh-agent/model trials, live rebuild or shared Native/Runtime worktree
edits.
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