Skip to content

fix: Make canonical usage a prerequisite stage, not a profile-publisher side effect - #5312

Merged
Sinity merged 2 commits into
masterfrom
fix/w8-profile-publication
Sep 20, 2026
Merged

Sinity merged 2 commits into
masterfrom
fix/w8-profile-publication

Conversation

@Sinity

@Sinity Sinity commented Sep 20, 2026

Copy link
Copy Markdown
Owner

Summary

The epic's central defect: publish_prepared_session_profile refreshed and committed the provider-usage rollup inside itself, so publication altered its own premise and then relied on another pass to notice. Usage reconciliation is now its own derivation, registered as a prerequisite of session_profile.

Five production files are IN the derived schema closure — this must land before any rebuild starts. INDEX_SCHEMA_VERSION 104 → 105.

3 of 8 acceptance criteria are met. The other five are stated below rather than claimed.

The fix, with the defect reproduced

Removed _refresh_provider_usage_rollup(conn, ...) and its conn.commit() from the publisher. Reconciliation is now session_usage_rollup, registered before session_profile and named as a concrete prerequisite key.

Anti-vacuity was measured, not asserted. Restoring the publisher refresh + commit and dropping the prerequisite reproduces the doomed first pass exactly:

KeyOutcome(domain=session_profile, outcome=PENDING, reason=PendingReason.BINDING_MOVED)
assert [PENDING] == [DONE]

Truthful refusal is proven separately: publish_session_usage_rollup returns False and session_model_usage is byte-identical, because the refresh now lives inside the same BEGIN IMMEDIATE the refusal rolls back.

Pricing meaning is unchanged — the same reconciliation, disjoint token lanes and catalog repricing run; session_insight_compute_binding is retained as the exact-content backstop, which AC6 requires until the input writers adopt the revision contract.

AC1 was already satisfied — no change manufactured

derivation.py:88-99 already opens with tuple(dict.fromkeys(assertion_ids)) and compares SQL set cardinality against the deduplicated length. The three-line correction the bead describes is present at head.

The inherited reds were vacuous and red

Three test_session_profile_derivation.py failures reproduced on clean worktrees at both f7bc76213 and the branch base. Cause: SessionBuilder leaves messages.input_tokens NULL, so input_tokens + 4096 evaluated to NULL — the mutation was a no-op. The parametrizations were simultaneously vacuous and failing. Fixed forward in 2d0af1bb1; that file now has zero failures.

Ratchet movement, stated deliberately

schema-closure-baseline.json     563 → 564   added ['.../usage_rollup.py']   removed []
writer-module-census-baseline    +1 entry    {'file': '.../usage_rollup.py', 'tiers': ['index']}

Genuine growth from one new production module that defines derived-tier behaviour and mutates the index tier. No pre-existing member was dropped from either baseline.

Version conflict resolved, not overwritten

#5308 had already claimed INDEX_SCHEMA_VERSION 104 for the trigram drop. Resolved during rebase by keeping master's v104 block and moving session_usage_rollup_bindings to v105 with its own classification comment.

Not done, and why

  • AC4/AC7 (marker lifetime). The profile-driven marker-presence gate is still live. Retiring it needs a durable applied-position sink in user.db — and user.db has no version chain at head, so that is additive DDL in USER_DDL, not a numbered migration. Shape recorded for the next worker: a session_marker_delivery derivation whose publish runs lower_markers and advances the applied position in one transaction, after which the gate is deleted.
  • AC3/AC6 sequence item D (migrate profile input writers to a same-commit fence + pending demand, then retire the scan and the backstop) is the next unit and is independent of the marker work.
  • ia88n option (b) not started. Its stated blocker — this derivation kernel — is now landed and production-adopted, so it is dispatchable with no remaining prerequisite and no write-scope collision.

Bead-status accuracy

bp12n.1's rollup reports "3/3 children complete — eligible for close". It is not close-eligible: 5 of 8 acceptance criteria remain unsatisfied at this candidate.

Risk identified, not reproduced — worth its own bead

security/excision.py:1266 hard-deletes assertions by target_ref. lower_markers preserves terminal judgments only when the row still exists, so a hard-deleted row makes existing is None and it re-inserts as CANDIDATE. Meanwhile _marker_assertions_present counts rows regardless of status, so a hard-deleted marker assertion leaves the profile permanently STALE and republishing every pass.

If the excised session or message survives in the index, that loop would resurrect deliberately excised material. I did not build the reproduction — it needs a real excision-then-converge run. Stated as a risk, not a confirmed defect.

Verification

172 passed across the session-derivation, kernel-law and daemon-convergence suites after rebase. devtools verify --quick all 23 gates ok. render all --check exit 0, zero out of sync.

🤖 Generated with Claude Code

https://claude.ai/code/session_015WCh9YW3cRfsg3CZBKU7Fq

Sinity and others added 2 commits September 21, 2026 00:53
…er side effect

polylogue-bp12n.1 AC2. The session-profile publisher ran
`_refresh_provider_usage_rollup` and committed it *before* checking whether
the partition it had already prepared was still applicable. The prepared
bundle had read the pre-refresh rollup, so the exact-value check that follows
necessarily failed for every session whose rollup had drifted: the first
computation was doomed by construction, a second pass did the real work, and
`False` came back from a call that had already committed a usage change.

Canonical usage reconciliation is now its own derivation
(`session_usage_rollup`), registered before the profile domain and named as a
concrete `prerequisite_keys` edge, so the kernel settles a session's rollup
first and the profile is prepared from values publication will actually find.
`publish_prepared_session_profile` now owns exactly one transaction and
commits exactly one thing: the prepared four-table family.

The rollup's output rows are totals and cannot say which message and
provider-event values were summed to make them, so the domain keeps a
value-complete input binding beside them in a new derived table
`session_usage_rollup_bindings`. It carries an input digest and a recipe
version and nothing else -- no timestamp, no attempt counter, no status.
The recipe includes a digest of the in-process pricing catalog, because
`_reprice_model_usage_rows` reads catalog data that no archive value covers.

Pricing meaning is unchanged: the same `_refresh_provider_usage_rollup` runs,
with the same provider reconciliation, disjoint token lanes and repricing.
`session_insight_compute_binding` is retained as the exact-content backstop.

INDEX_SCHEMA_VERSION 103 -> 104, ADDITIVE_DERIVED. The bulk rebuild stamps the
binding for every chunk it already reconciles, so a build leaves no rollup
work behind for the first recurring pass.

Verification: devtools test tests/unit/storage/test_session_usage_rollup_derivation.py
tests/unit/storage/test_session_profile_derivation.py
tests/unit/daemon/test_selected_session_parts.py
tests/unit/daemon/test_convergence_restart_law.py; devtools gate layering;
devtools gate schema-closure.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_015WCh9YW3cRfsg3CZBKU7Fq
Inherited red, reproduced on a clean origin/master worktree at both 8f7814a
and f7bc762: three parametrizations of
tests/unit/storage/test_session_profile_derivation.py failed.

`SessionBuilder` leaves `messages.input_tokens` / `output_tokens` NULL, and
`UPDATE messages SET input_tokens = input_tokens + 4096` evaluates to NULL --
so the "mutate one output-affecting value" step changed nothing, the binding
correctly did not move, and the test asserted "stale" against an archive
nobody had touched. The parametrizations were vacuous and red at the same
time.

COALESCE the token lanes so the mutation lands. Anti-vacuity is unchanged and
now real: drop `input_tokens`/`output_tokens` from
SESSION_INPUT_PROJECTION_COLUMNS and these go green while the profile is
stale.

Verification: devtools test tests/unit/storage/test_session_profile_derivation.py
-- PASSED, 0 failures (was 3).

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_015WCh9YW3cRfsg3CZBKU7Fq
@coderabbitai

coderabbitai Bot commented Sep 20, 2026

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 47 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 8a57301d-6cf4-4c3a-9820-c5033a599b9d

📥 Commits

Reviewing files that changed from the base of the PR and between f7bc762 and 2d0af1b.

📒 Files selected for processing (14)
  • docs/plans/schema-closure-baseline.json
  • docs/plans/writer-module-census-baseline.json
  • polylogue/daemon/session_profile_composition.py
  • polylogue/operations/session_profile_convergence.py
  • polylogue/storage/derived/session/derivation.py
  • polylogue/storage/derived/session/rebuild.py
  • polylogue/storage/derived/session/usage_rollup.py
  • polylogue/storage/sqlite/archive_tiers/archive_tiers_specs.py
  • polylogue/storage/sqlite/archive_tiers/index.py
  • tests/infra/convergence_harness.py
  • tests/unit/daemon/test_convergence_restart_law.py
  • tests/unit/daemon/test_selected_session_parts.py
  • tests/unit/storage/test_session_profile_derivation.py
  • tests/unit/storage/test_session_usage_rollup_derivation.py

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for security reviews. Please try again later.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 20, 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-20T23:45:41.388950Z 2d0af1b 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: 2d0af1bb1a

ℹ️ 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 f6f899c into master Sep 20, 2026
3 checks passed
@Sinity
Sinity deleted the fix/w8-profile-publication branch September 20, 2026 23:53
Sinity added a commit that referenced this pull request Sep 21, 2026
#5322)

## Summary

The ingest-path refresh wrote `session_profiles` rows without stamping
the input
binding it computed from, so its own output could never be found stale.

## Problem

`storage/derived/session/refresh.py` is a second live writer of
`session_profiles` / `session_latency_profiles`, reached from
`pipeline/services/ingest_batch/_core.py:3067` and
`storage/repository/archive/writes/sessions.py:5`. It published rows
without the
input-binding stamp that the derivation path uses to decide staleness —
so a
row it wrote was doomed by construction: no later pass could tell
whether the
inputs behind it had moved.

## Solution

Stamp the binding the refresh actually computed from. The row now
carries the
same evidence the derivation path carries, so staleness is decidable for
both
writers.

This does **not** retire `refresh.py` as a second writer — that needs
`SessionInsightCounts` field changes which `rebuild.py:2211,2409` also
populate,
and `rebuild.py` was outside this dispatch's scope. What lands here is
the
doomed-by-construction half.

## Verification

- `devtools test tests/unit/storage/test_session_insight_refresh.py` —
**40 passed**,
  including 3 new tests over the live ingest materialize route
  `_apply_session_insight_session_update(s)_async`
- **Two anti-vacuity mutations executed**, not asserted: removing the
stamp → 3
failed / 37 passed; pinning `input_content_hash="frozen-constant"` → 3
failed /
  37 passed. A constant stamp does not survive.
- `devtools test tests/unit/pipeline/test_ingest_batch.py` — passed (the
  production caller of the changed function)
- `devtools verify --quick` — exit 0, 23 gates
- `devtools render all --check` — exit 0, `grep -ci 'out of sync'` = 0
- `devtools schema closure polylogue/storage/derived/session/refresh.py`
→ **out**.
  The only production file edited, so **no identity move and no rebuild
  constraint**.

## Two refutations worth recording

**The bead's two self-justifying probes are stale.** Duplicate `::note:`
presence
is deduped at `derivation.py:88-99` with `dict.fromkeys`, comment naming
the
reason; the usage-committing publication wrapper was removed by #5312,
which made
usage a prerequisite domain (`derivation.py:539`). Neither survives on
dead code
— `publish_session_profile` (`derivation.py:411`) is a callerless
predecessor and
a separate entry, not either probe.

**The 2026-09-15 design note's "four families, only two have owners" is
wrong at
head.** `threads` (`index.py:955`) and `session_tag_rollups`
(`index.py:1718`)
are **VIEWS**, and provider/day is a read-time grouping helper
(`derived/session/aggregates.py`). There are no retained
thread/tag/provider-day
aggregate tables, so they need no partition key, inspect query or atomic
replacement. The retained family is **two** tables, not four; work-event
and
phase rows were already retired.

## Residuals

- AC5/AC6 and the marker half of AC7 are **blocked by lane ownership**,
and the
worker stopped rather than editing: separating marker delivery from
profile
  validity requires registering a domain in
`daemon/session_profile_composition.py:59` and changing where the
prepared
bundle binds `marker_candidates` (`rebuild.py:1839`). One lane needs to
own
  daemon composition + `rebuild.py` + `derivation.py` together.
- AC4's third clause (a candidate present only in a superseded input
surviving
coalescing) is reproducible at the storage level today, but fixing it is
the
full source-to-user batch/cursor protocol including a durable
`source.db`
  addition behind a verified backup. Out of one PR's scope.
- Inherited red, reproduced on a clean tree:
`tests/unit/storage/test_session_insight_profiles.py` fails **2**, not
the 1 the
  known-red baseline records.

Advances polylogue-ylh7v.

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

https://claude.ai/code/session_015WCh9YW3cRfsg3CZBKU7Fq

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

## Summary

Two beads in one PR. `jytge` gets a working two-arm finished-build
equivalence
comparison; `1xc.14.1`'s pilot moves onto the declared artifact owner.
Along the
way, a 30-second production stall was measured and attributed.

## `jytge` — the comparator had zero consumers *and* was broken

`tests/unit/sources/test_finished_build_equivalence.py` runs two
production
shapes of `backfill_historical_revision_evidence` over one sealed 8-raw
input:
retained active-index (the `RawObservationPublisher.publish` shape)
versus owned
inactive generation + sealed session shard (the cold-build shape). Both
arms
reach canonical logical digest `36ce5814f06a`.

**The refutation that made this possible**: that comparator had **zero
consumers**
at head, and `compared_table_census()` refused outright because #5312
added
`session_usage_rollup_bindings` with no classification — so **every**
`capture_finished_build_output` call, including the sealed 516-raw
benchmark, was
red between f6f899c and 75f5812. #5315 landed the identical
classification an
hour later; theirs was kept on rebase.

`FinishedBuildResourceProbe` brackets route + terminal reads, and
capture asserts
FTS readiness and zero open debt **before** any receipt value is
produced.

**Anti-vacuity executed in-test**: one unresolved `convergence_debt` row
makes
capture raise "convergence debt remains"; one deleted `blocks` row makes
the
comparator raise "derived table blocks differs".

## ⚠ A 30-second production stall, attributed not corrected

The fresh-generation+shard arm spends **30.02 s of its 30.15 s** in
`spill_prefetch.decode_concurrent` at **0.24 s CPU** — one reparse
burning a full
SQLite `busy_timeout`.

Probe, three runs: 7 raws AUTO **30.04 s**; 8 raws AUTO **30.05 s**; 8
raws with
`pipeline_decode=False` **0.10 s** with byte-identical output.

**This 30 s sits inside the sealed 516-raw benchmark's measured
interval.** The
fix belongs in `sources/revision_backfill.py` (prefetcher index
connection versus
the EXCLUSIVE-locked bulk-build writer), outside this write scope. Filed
separately.

A receipt bug found by the same investigation is fixed here:
`stage_timings_s`
mixed counters with durations, so `spill_prefetch.reparse_hits=8.0` was
reported
as the dominant "8-second phase". Counters are now excluded by name, and
any key
exceeding the route total is refused.

## `1xc.14.1` — the pilot now consumes the declared owner

`pilot_artifact` acquires through `build_integration_archive()`, which
**had zero
consumers** while the GC reachability entry `default/integration`
protected a key
nothing built. The private cache root and the in-fixture double build
are deleted.

Measured from the executed mutation receipt: the pre-migration
private-cache shape
cost `construction_seconds=1.176649` and `write_bytes=10,096,640` per
module
acquisition and **could never hit the published artifact**.

A byte-generation gap is closed: generation previously ran inside a
module fixture
before any guard was armed. One cold acquisition now runs inside
`sqlite_work_counter` with **zero connections on any tier**.

**A dedup was considered and refuted**: folding the pilot's lease/clone
fixtures
into `corpus_fixtures`-owned factories would have made them
function-scoped, and
every lease acquisition runs `_validate_artifact_with_retry` (re-SHA256
of every
file plus five quick_checks). That "dedup" would have **added** a full
artifact
revalidation per test — exactly the duplicated work AC7 targets.

## Verification

- `test_finished_build_equivalence.py` — 4 passed in 91.10s
- `test_finished_build_measurement.py -k "not declared_scale"` — 2
passed (the
sealed benchmark still binds its capability boundary after helpers
moved)
- `test_resource_pilot.py` — 13 passed in 28.44s
- `test_integration_profile.py` — 8 passed (the recipe owner the pilot
now consumes)
- **Anti-vacuity executed**: restoring the private cache root and
opening one index
  tier during generation → 2 failed, as designed
- `devtools verify --quick` — exit 0, no FAILED lines
- `devtools render all --check` — exit 0, `grep -ci 'out of sync'` = 0
- `devtools schema closure` — **all five edited files `out`**

## Residuals

- `jytge` stays **open**: this is preparable evidence, not final archive
acceptance. The sealed 516-raw arm needs a dedicated host window — and
should be
re-measured **after** the prefetcher stall is fixed, or 30 s gets baked
into the
  first committed baseline.
- `1xc.14.1` AC5 (payload tails, ordering/revision relations, wider
element kinds)
  and lab-AC4 (retiring other bespoke builders) are untouched.
- **Corrected write scopes**: `1xc.14.1`'s declared globs are far wider
than
  needed — actual is `tests/infra/pilot_resources.py` and
  `tests/unit/scenarios/test_resource_pilot.py` only. `jytge`'s declared
  `tests/unit/sources/test_live_batch.py` does not exist at head.
- The new equivalence file runs 36–91 s, dominated by that 30 s stall.
It drops to
a few seconds once fixed; **no tolerance or timing assertion encodes the
defect**.

Advances polylogue-jytge and polylogue-1xc.14.1.

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

https://claude.ai/code/session_015WCh9YW3cRfsg3CZBKU7Fq

---------

Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
Sinity added a commit that referenced this pull request Sep 22, 2026
PR #5312 removed the hidden usage commit from the *prepared* session-profile
publisher only. The same reconciliation survived on the unprepared route:
`publish_session_profile` rebuilds through `rebuild_session_insights_sync`,
whose chunk loop re-aggregated `session_model_usage` and stamped the usage
domain's binding for every session it touched. A call whose subject is a
profile therefore rewrote canonical usage and certified a rollup no caller
asked it to reconcile — and could still return False afterwards, which is the
untruthful refusal polylogue-bp12n.1 AC2 forbids.

`SESSION_USAGE_ROLLUP_DOMAIN` already exists and is already a declared
prerequisite of the profile domain, so the reconciliation now lives there
outright: `_refresh_provider_usage_rollup`, its async twin and the binding
stamp move out of `rebuild.py` into `usage_rollup.py` as
`reconcile_session_usage_rollup(s)`, verbatim aggregation, provider
reconciliation, disjoint token lanes and catalog repricing. This also removes
the inverted lazy import `usage_rollup` needed to call back into `rebuild`.

The rebuild keeps the stage under an explicit `reconcile_usage_rollup` flag:
a bulk index rebuild owns both jobs and commits the rollup rows, their stamp
and the profiles built from them in one chunk transaction, and the mutation
actuator states that choice rather than inheriting it. A profile publisher
passes False, and because the profile's stored binding covers the rollup's
inputs rather than its rows, `publish_session_profile` refuses a session whose
rollup the prerequisite has not settled instead of silently publishing against
superseded cost values. Both refusals now commit nothing.

Verification: devtools test over the session profile/rollup/partition/insight
rebuild and mutation-actuator suites (185 passed), plus the wider readiness /
rebuild-route / actuator route selection (248 passed); devtools verify --quick;
devtools render all --check (0 "out of sync"). Anti-vacuity executed, not
asserted: passing `reconcile_usage_rollup=True` from `publish_session_profile`
turns the skewed rollup 10200 back into the ingest total 1200 inside a profile
publication (test_profile_publish_writes_no_usage red); deleting the
prerequisite guard publishes against a MISSING rollup
(test_profile_needs_a_settled_rollup red). The skew is load-bearing — on an
archive whose rollup already agrees with its inputs a refresh rewrites the same
numbers and neither test could tell the fix from the defect.

Derived index schema identity moves dba2f05e -> df72816c (ops unchanged); all
six changed production files were already closure IN, so membership is
unchanged and no --update is needed.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01ToWqpkXotr573DiQex5vcy
Sinity added a commit that referenced this pull request Sep 22, 2026
…5386)

## Summary

`polylogue-bp12n.1` AC2 and the refresh-wrapper half of AC7. The bead's
rollup read *"3/3 children complete — eligible for close"*; that was
wrong, and this is the half that is now actually true.

## Problem (at `ba2c63c47`)

PR #5312 cleaned only the **prepared** publisher.
`_refresh_provider_usage_rollup` + `_stamp_refreshed_usage_bindings`
survived in the `rebuild_session_insights_sync`/`_async` chunk loops,
reachable from `publish_session_profile` **and** from
`InsightsRebuildActuator.apply` — a real mutation actuator. So
publishing a profile performed a hidden committed write to canonical
usage.

## Solution

The reconciliation moves to `storage/derived/session/usage_rollup.py` as
`reconcile_session_usage_rollup(_async)` /
`reconcile_session_usage_rollups(_async)` — aggregation, provider
reconciliation, token lanes and catalog repricing moved **verbatim**,
with no provider total re-summed a second way.

The rebuild keeps it behind an explicit `reconcile_usage_rollup`
keyword: the bulk index rebuild commits rollup rows + binding stamp +
profiles in **one chunk transaction** (AC2's joint-publication branch),
the mutation actuator states that choice explicitly, and
`publish_session_profile` passes `False`.

Because the profile binding covers the rollup's **inputs** and not its
**rows**, `publish_session_profile` additionally refuses — returns
False, commits nothing — when `inspect_session_usage_rollups` does not
report VALID. The prerequisite domain is then the only writer of
canonical usage.

## Anti-vacuity — two mutations executed

1. **Revert to `reconcile_usage_rollup=True`**:
`test_profile_publish_writes_no_usage` FAILED — `At index 0 diff:
('claude-sonnet-4-5', 1200, ...) != ('claude-sonnet-4-5', 10200, ...)`.
The skewed 10200 was silently reconciled back to the ingest total inside
a profile publication.
2. **Delete the prerequisite guard**:
`test_profile_needs_a_settled_rollup` FAILED — `assert
publish_session_profile(...) is False` → `AssertionError: assert True is
False`.

Both restored; the file returns 8 passed.

The skew in mutation 1 is load-bearing and worth naming: it edits a
`session_model_usage` row directly, leaving the binding untouched so the
rollup still inspects VALID. On a fresh archive whose rollup already
agrees with its inputs, the refresh would rewrite **identical numbers**
and the test would have stayed green under its own mutation. Opposite
direction is pinned in both tests — a blanket refusal fails them.

## Verification

Exit codes read directly from `$?`, not through a filter.

```
devtools test <10 selections: usage rollup, profile derivation, partition convergence,
  insight refresh, model-usage consistency, mutation actuators, parallel fanout,
  rebuild progress, insight readiness, verify-rebuild-routes>
    -> exit 0, 207 passed in 123.11s
  base ba2c63c, identical selection
    -> exit 0, 205 passed   (207 = 205 + exactly the two new tests; no inherited red)

devtools verify --quick            exit 0, 25 gates (base control also exit 0)
devtools render all --check        exit 0, grep -c 'out of sync' = 0
```

Route census unchanged (`gate rebuild-routes` ok). Writer-module census
unchanged — `rebuild.py` and `usage_rollup.py` were both already
declared `tiers:[index]`, so moving DML between them moves no baseline
(`gate layering` ok).

## Schema identity

All six changed production files are closure **IN**, so membership is
unchanged and `gate schema-closure` passes with no `--update`. INDEX
moves `dba2f05e… → df72816c…`; OPS unchanged at `86866235…`. **Must land
before a fresh rebuild starts, never during one.** No
`INDEX_SCHEMA_VERSION` bump — that is the coordinator's per-wave call,
not a per-lane one.

## AC4 is not addressed, and its text needs repair before anyone
dispatches it

The `_STALE` marker gates are **live production**, not dead code:
`operations/session_profile_convergence.py` passes both marker
connections into `SessionProfileDerivation`, and two gates consume them
(`inspect` and `selected_part_facts`). `_marker_assertions_present`
counts rows with no status predicate, and `lower_markers` preserves
every terminal agent judgment as a row — so a human judgment does
**not** trip the gate; only a genuinely absent row does, i.e. lowering
never ran or failed. That is exactly the livelock AC4 names: a
`SessionProfileMarkerLoweringError` leaves a partition that is current
by its own binding reported STALE, so every later pass republishes the
whole profile family purely to retry a user-tier write. No delivery
cursor exists — `applied_position` / `source_batch` / `marker_cursor` /
`stream_position` return nothing across `archive_tiers` and `markers/`.

On the authoring conflict I flagged when dispatching: AC4's *"user
effects and applied stream position commit together"* reads as one
commit across `source.db` and `user.db`, which SQLite cannot do — but
the bead's own **design field disambiguates it the other way** ("the
user consumer reads a bounded contiguous batch above its own last
applied source position … under its one real user-db transaction … and
advances the applied position"). So the position is a single-file
`user.db` commit and the AC is **under-specified, not impossible**. The
repair is to restate AC4 in the design's terms.

## Residuals

- AC7's other half (removing the marker-presence gate and the
full-block-text rescan) is blocked behind AC4; deleting the gate before
the batch/cursor consumer exists would drop marker delivery entirely.
- `publish_session_profile` stays exported with route `unreached` in the
census (tests only; the daemon owner uses the prepared route). Retiring
it also means moving ~20 test call sites — a separate cut.
- `test_a_drifted_rollup_no_longer_dooms_the_first_profile_computation`
has a 127-character nodeid and cannot be selected by id (pre-existing;
see `polylogue-5coki`). The two new tests are 96 and 95.

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

https://claude.ai/code/session_01ToWqpkXotr573DiQex5vcy

Co-authored-by: Claude Opus 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.

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