Skip to content

fix(tests): authenticate unpinned clones and realign the lineage fixture - #4573

Merged
Sinity merged 1 commit into
masterfrom
fix/red-cache-lineage
Sep 3, 2026
Merged

Sinity merged 1 commit into
masterfrom
fix/red-cache-lineage

Conversation

@Sinity

@Sinity Sinity commented Sep 3, 2026

Copy link
Copy Markdown
Owner

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

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.ai/code/session_01YGi8wLWGR2HYBh8p8fXFXz

The immutable-tree clone read its expected file set from `_archive_files`,
which returns manifest dicts, through an unpacking that assumes the
`(path, size, digest)` records `_manifest_file_entries` produces. Every clone
of a source without a pinned manifest therefore compared the literal keys
"path"/"size"/"sha256" against the real tree and refused.

The lineage-validation census reads through the production envelope route,
so the hand-built partial index it runs against must declare every production
column of the tables that route selects. Index schema v85 added
`attachment_refs.direction` and `producer_ref`; the fixture kept the v84
subset and every composed read failed.

Set the seeded-artifact GC grace default to the bound the locks already
imply rather than a 24 h retention window.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01YGi8wLWGR2HYBh8p8fXFXz
@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: 43375bf5-2366-4cce-b25e-075f6c239e67


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 merged commit 40c43dc into master Sep 3, 2026
2 of 3 checks passed
@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-03T02:33:42.841983Z befe1a3 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
Sinity deleted the fix/red-cache-lineage branch September 3, 2026 02:31
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