Skip to content

fix: read stale indexes at their own version and refresh drifted fixtures - #4563

Merged
Sinity merged 3 commits into
masterfrom
fix/red-classes
Sep 2, 2026
Merged

Sinity merged 3 commits into
masterfrom
fix/red-classes

Conversation

@Sinity

@Sinity Sinity commented Sep 2, 2026

Copy link
Copy Markdown
Owner

Summary

Three independent red classes, each landed as its own commit:

  1. fix(devtools) — the index fast-forward tool reads the index it is about to carry forward without asserting that index is already at the runtime's version.
  2. test — four hand-built fixtures pinned index shapes the runtime has moved past.
  3. fix(surfaces) — the message-row envelope drops identity_source, which its own mask declares public.

Problem and solution, per class

Fast-forward reads

#4485's open-time tier check refused both pre-forward reads in a tool whose purpose is an index at a non-current version:

polylogue.core.errors.SchemaSkewError: index schema skew: expected 37, found 36

_inspect_clean_database returns that version as its result and _sample_manifest samples the index being carried, so both read with validate_schema=False. The candidate-index read after the forward keeps the check: that index is at the target version and must be.

Fixtures pinned to superseded shapes

  • test_lineage_validation stamped and asserted user_version = 73; both now derive from INDEX_SCHEMA_VERSION.
  • test_reindex_canary_cli stamped 43 on an index it had just seeded at the current version; the scenario is a title backfill and the version literal was incidental.
  • test_envelope's hand-built blocks table predates tool_outcome (#4539), so the coordination evidence query failed with no such column: r.tool_outcome.
  • test_web_reader asserted an uppercase doctype; the renderer emits the lowercase HTML5 form.

identity_source on the message row

_MESSAGE_MASK declares the field public and the render envelope publishes it, but the row envelope's field_order omitted it. message_row_envelope_from_domain builds the row envelope by dumping the render envelope, so every paginated message read failed closed with extra_forbidden. The row envelope now lists the field where the mask puts it; the generated CLI-output schemas are regenerated to match. _FakeApi in the CLI message tests gains the config the read path builds its authority envelope from.

Verification

devtools test <file> -p no:randomly -n 2:

file before after
tests/unit/cli/test_messages.py 7 failed 13 passed
tests/unit/coordination/test_envelope.py 3 failed 1 failed
tests/unit/devtools/test_lineage_validation.py 21 failed 8 failed
tests/unit/devtools/test_index_fast_forward.py 25 SchemaSkewError 0 SchemaSkewError

devtools verify --quick green.

Residual risk

test_index_fast_forward.py is still red on ArchiveLocationError from #4411's symlink-farm discrimination, which refuses the two-root index-generation layout both that suite and test_daemon_status.py document as legitimate. test_lineage_validation.py's remaining 8 come from the read envelope's behaviour on its hand-built partial index. Both are separate causes, not addressed here.

🤖 Generated with Claude Code

https://claude.ai/code/session_01YGi8wLWGR2HYBh8p8fXFXz

Sinity and others added 3 commits September 2, 2026 22:07
The fast-forward tool exists to carry an index whose version is not the
runtime's, and both of its pre-forward reads opened that index through
the version check #4485 added:

    polylogue.core.errors.SchemaSkewError: index schema skew:
    expected 37, found 36

`_inspect_clean_database` reads that version as its return value and
`_sample_manifest` samples the index being carried, so both read with
validation off. The candidate-index read after the forward keeps the
check: that index is at the target version and must be.

Verification: devtools test tests/unit/devtools/test_index_fast_forward.py
-p no:randomly -n 2 — the 25 SchemaSkewError failures are gone; the file
remains red on an unrelated ArchiveLocationError from #4411's
symlink-farm discrimination, reported separately.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01YGi8wLWGR2HYBh8p8fXFXz
Four fixtures pinned shapes the runtime has moved past, so the tier
version check refused them:

- `test_lineage_validation` stamped `PRAGMA user_version = 73` and
  asserted 73; it now stamps and asserts `INDEX_SCHEMA_VERSION`.
- `test_reindex_canary_cli` stamped `user_version = 43` on an index it
  had just seeded at the current version. The scenario is a title
  backfill; the version literal was incidental and is gone.
- `test_envelope`'s hand-built `blocks` table predates `tool_outcome`
  (#4539), so the coordination evidence query failed with
  `no such column: r.tool_outcome`.
- `test_web_reader` asserted an uppercase doctype; the renderer emits
  the lowercase HTML5 form, and the assertion is now case-insensitive.

Verification: devtools test -p no:randomly -n 2 —
test_lineage_validation.py 21 failed → 8 (remaining failures are the
read envelope's behaviour on that fixture, a separate cause);
test_envelope.py 3 failed → 1.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01YGi8wLWGR2HYBh8p8fXFXz
`_MESSAGE_MASK` declares `identity_source` public and the render
envelope publishes it, but the row envelope's `field_order` omitted it.
`message_row_envelope_from_domain` builds the row envelope by dumping
the render envelope, so every paginated message read failed closed:

    ValidationError: 1 validation error for MessageRowEnvelope
    identity_source
      Extra inputs are not permitted

The row envelope now lists the field where the mask puts it, and the
generated CLI-output schemas are regenerated to match.

`_FakeApi` in the CLI message tests gains the `config` the read path
builds its authority envelope from, so the double exercises the
production route instead of stopping short of it.

Verification: devtools test tests/unit/cli/test_messages.py
-p no:randomly -n 2 → 13 passed (was 7 failed).

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01YGi8wLWGR2HYBh8p8fXFXz
@Sinity
Sinity merged commit 3d2dba1 into master Sep 2, 2026
1 of 3 checks passed
@coderabbitai

coderabbitai Bot commented Sep 2, 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: 91eec3c8-6f49-4d3e-a835-cc143e451b8d


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.

@Sinity
Sinity deleted the fix/red-classes branch September 2, 2026 20:20

@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: 044dd51c79

ℹ️ 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".

@chatgpt-codex-connector

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-02T20:24:56.953692Z 044dd51 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.

Sinity added a commit that referenced this pull request Sep 3, 2026
…ure (#4573)

## Summary

Two red test classes, one product-code-adjacent bug each in test
infrastructure, plus the seeded-cache GC grace default.

## Problem (evidence)

**Class A — 7 errors in `tests/unit/infra/test_pathology_zoo.py`**, all
at fixture setup with `ValueError: immutable fixture clone failed
authenticated file-set validation`.

Not a stale cache entry: the cached tree validates byte-for-byte against
its manifest. `_clone_immutable_tree_unlocked` computed its expected set
as

```python
source_files = _manifest_file_entries(artifact.files) if artifact.files else _archive_files(artifact.root)
expected = {path: (size, digest) for path, size, digest in source_files}
```

`_manifest_file_entries` returns `(path, size, digest)` records;
`_archive_files` returns `{"path":…, "size":…, "sha256":…}` dicts.
Iterating the dict branch unpacks its *keys*, so `expected` was the
single entry `{"path": ("size", "sha256")}`. Adding the diverging paths
to the error message showed it directly: `missing=['path'] extra=[<the
entire real tree>]`.

The unpinned branch is `clone_pathology_zoo`, which clones an
already-materialized tree by passing `files=()`. Every such clone
refused unconditionally.

**Class B — 8 failures in
`tests/unit/devtools/test_lineage_validation.py`.** The envelope is
right; the fixture is wrong. The census reads through
`read_archive_session_envelope`, the production route, against a
hand-built partial index. Index schema v85 (#4563) added
`attachment_refs.direction` and `producer_ref`, which
`polylogue/storage/sqlite/queries/attachment_records.py` selects; the
fixture still declared the v84 subset, so every composed read raised
`OperationalError: no such column: r.direction` and surfaced as
`composed_messages=None` / `safe=False`.

**GC grace period.** `gc_seeded_archive_artifacts` defaulted to a 24 h
window. The cache, per-key, and final-root flocks already hold across
every inspect/delete interval, so an in-flight build, lease, or clone is
excluded without reference to age; the window was retention, not
protection.

## Solution

- Normalize both branches through `_manifest_file_entries` so the
comparison always sees `(path, size, digest)`.
- Name the diverging paths in the validation failure (bounded to 8 per
category), so the next occurrence is diagnosable from the message alone.
- Add the production columns of every route-backed table to the
hand-built index, plus the `attachment_native_ids` table the same query
joins.
- Add
`test_hand_built_index_declares_every_production_column_of_route_backed_tables`:
the next schema bump fails by name here instead of as "no such column"
inside an envelope read. Layering `initialize_archive_tier` over the
shaped tables was tried first and does not work — its indexes and views
reference columns the deliberately-partial tables do not carry (`no such
column: sort_key_ms`).
- `SEEDED_ARTIFACT_GC_GRACE_PERIOD_S = 10 * 60`, used by both the
function default and `--grace-period-s`. Leases are flock markers with
no time bound of their own, so there is no lease bound to adopt; ten
minutes covers only the unlocked instant between publication and a new
tree's first lease.

## Verification

```
devtools test tests/unit/infra/test_pathology_zoo.py -n 2
  before: 2 passed, 7 errors     after: 9 passed
devtools test tests/unit/devtools/test_lineage_validation.py -n 2
  before: 15 passed, 8 failed    after: 24 passed  (23 + the new drift guard)
devtools test tests/unit/infra/test_workload_artifacts.py -n 2 -k "unpinned_source or fast_and_copy_clones"
  6 passed  (includes the new test_clone_from_unpinned_source_authenticates_the_enumerated_file_set)
devtools verify --quick
  12 gates ok
```

Anti-vacuity for the new clone test: the first clone is red if the
enumerated records are not normalized before comparison; the tampered
clone is wrongly accepted if the comparison is dropped.

## Residuals

Four failures in `tests/unit/infra/test_workload_artifacts.py` are
inherited, verified by stashing this diff and rerunning at the clean
branch base (ec8d119) — identical set, identical failures:
`test_seeded_archive_is_reused_by_a_later_commit`,
`test_seeded_archive_publishes_valid_immutable_real_pipeline_artifact`,
`test_seeded_archive_corruption_is_refused_by_a_fresh_process`,
`test_artifact_gc_preserves_active_per_key_lock_and_query_lease`. The
first reports `NameError: name '_SMALL_SPECS' is not defined` from a
`python -c` subprocess program that does not define it. All four pass
`grace_period_s` explicitly where relevant, so the GC default change is
not implicated. Not fixed here; out of both beads' scope.

Verification is selected, not the corpus.

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

https://claude.ai/code/session_01YGi8wLWGR2HYBh8p8fXFXz

Co-authored-by: Claude Fable 5.1 <[email protected]>
Sinity added a commit that referenced this pull request Sep 3, 2026
…ed fixtures (#4579)

## Summary

Six red classes from the 2026-09-03 corpus run, each its own commit.
Four
are product defects the tests were reporting correctly; two are fixtures
pinned to shapes the runtime has moved past.

## Problem and solution, per class

### The rebuild preflight refuses a non-current index (19 tests)

`validate_schema_inference_receipt` opens the active index to project
the
live blob universe, under the runtime schema check. A rebuild is the
route
that carries a non-current index forward, so the check refused the
archives the rebuild exists for:

```
RebuildDerivedStateProvenanceError: index schema skew: expected 85, found 43
```

That read now opens at the index's own version. `#4563` removed the
canary fixture's `PRAGMA user_version = 43` as an incidental literal; it
is load-bearing — an expected difference approves a canary only when the
compared generations cross the delta that authorizes it, and delta 44
owns `sessions.title_ref`/`title_confidence`. Restored, with the reason
written down.

### A missing message FTS surface closed every read (1 + 1 tests)

`messages_fts` is contentless, trigger-maintained, and rebuildable from
`blocks`. The read-path manifest check refused the whole index when it
was
absent, so a search index that had not converged made the archive
unreadable and `/api/sessions?query=` answered 503. A read now admits a
manifest diff confined to that surface and the search route reports the
degraded route state it already models. Any other diff still refuses;
the
write path is unchanged. Fixes
`test_degraded_search_index_returns_route_state_not_zero_results` and
restores the degraded-search evidence in the reader visual smoke.

### The fast-forward replay could not open a pre-forward archive (24
tests)

`_replay_sample` opens the archive to parse retained raws — source-tier
evidence — and that open validated the index layout. The index beside it
is the one the run exists to carry forward, so every `prepare_forward`
raised `SchemaVersionMismatchError`. `ArchiveStore.open_existing` gains
a
read-only `validate_index_layout=False`; the actuator is its one caller.

The suite's two-version world now anchors at the live index version and
forwards to a synthetic successor, so the archive on disk is one the
runtime can open and no shipped delta pair has to stay fast-forwardable.

### Reader assertions the typed WebUI superseded (8 tests)

`/` and `/s/{id}` serve the typed WebUI, whose SSR shell carries a
bundled
module instead of the interpolated reader's inline markup and
JavaScript.
Assertions naming that markup describe the legacy shell, which now
answers
only on `/w/` and the paste routes and keeps its coverage there. The
endpoint evidence in each test is unchanged. The search-shell DOM test
is
deleted outright: its whole subject was the interpolated shell at `/`.

### The small-workload swap was left half-done (4 tests)

`#4558` pointed the artifact tests at a two-session workload. Three
sites
kept the default workload's identity: the two spawned probes name a
module
constant a `python -c` program cannot see (`NameError: _SMALL_SPECS`),
and
the GC lease test authenticates the small artifact against the c03 key.
Probes now build the specs from an importable factory; the real-pipeline
publication test builds the default workload again, since its subject is
that workload's facts rather than the cache protocol.

### `git` finds a repository by walking upward (1 test)

`test_git_commit_adapter_raises_explicitly_for_non_repository` passed in
the main checkout and failed in a worktree, where `tmp_path` sits inside
one. It caps the walk with `GIT_CEILING_DIRECTORIES`.

## Verification

`devtools test <file> -n 2`:

| file | before | after |
| --- | --- | --- |
| `tests/unit/devtools/test_index_fast_forward.py` | 24 failed | **26
passed** |
| `tests/unit/cli/test_reindex_canary_cli.py` | 19 failed | **31
passed** |
| `tests/visual/test_reader_dom_smoke.py` | 8 failed | **10 passed** |
| `tests/unit/infra/test_workload_artifacts.py` | 4 failed | **90
passed** |
| `tests/unit/storage/test_schema_policy_contracts.py` | 19 passed |
**20 passed** |
| `tests/unit/insights/test_work_effects.py` | 1 failed | **19 passed**
|
| `tests/unit/daemon/test_web_reader.py -k degraded_search_index` | 1
failed | **1 passed** |

`devtools verify --quick` green at this head.

## Residual risk

`ArchiveStore.open_existing(validate_index_layout=False)` is a new way
to
open an archive whose index is not at the runtime's shape. It is refused
for writers and has one caller.

The degraded-search admission is scoped by object-name prefix
(`messages_fts`), so a future non-FTS object sharing that prefix would
be admitted with it.

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

https://claude.ai/code/session_01YGi8wLWGR2HYBh8p8fXFXz

---------

Co-authored-by: Claude Fable 5.1 <[email protected]>
@Sinity

Sinity commented Sep 28, 2026

Copy link
Copy Markdown
Owner Author

Codex review threads on this PR whose cited code is gone (checked against master at 23f91a5):

Resolving these threads.

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