Skip to content

feat(storage): import retained manifest snapshots - #611

Merged
fishmingyu merged 8 commits into
mainfrom
feat/retained-manifest-import-v2
Aug 16, 2026
Merged

feat(storage): import retained manifest snapshots#611
fishmingyu merged 8 commits into
mainfrom
feat/retained-manifest-import-v2

Conversation

@fishmingyu

@fishmingyu fishmingyu commented Aug 12, 2026

Copy link
Copy Markdown
Member

Summary

Adds the direct retained RepoManifest M1 bootstrap path on top of the merged
storage authority foundations. The importer consumes authenticated strict
context and source identities, streams canonical BM25/vector artifacts into
CAS, retains their exact receipts through catalog publication, and publishes
an identity-closed schema-v4 snapshot/ref without trusting caller paths or
mutable public projections.

Changes

  • Plan and replay canonical view-bundle v1 archives directly from authenticated
    readers, including exact token/layout validation and bounded stream cleanup.
  • Consume detached workspace-plan and repository-source identities throughout
    portable and strict artifact validation.
  • Add retained-import object-store/catalog capabilities, canonical response
    budgets, backend-neutral namespace identities, and SQLite pre-ref aggregate
    response validation with transactional rollback.
  • Import selected BM25/vector views and per-file member objects, persist a
    reversible internal manifest v2 projection, and attest the final ref and
    summary.
  • Retain the exact CAS receipt set across the first catalog write, final receipt
    verification, snapshot publication, and post-publication attestation so a
    compliant GC cannot reclaim an object during publication.
  • Document the direct M1 at-least-once boundary and prove that an exact retry
    converges after interruption following the SQLite commit.
  • Record the remaining materialization/export, production runtime wiring, GC
    implementation/policy, and M2 fenced-publication work.

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update
  • Refactoring
  • Performance improvement
  • Tests

Testing

  • Tests pass locally
  • Added new tests for the changes
  • Full unit tier: 5,970 passed, 71 skipped, 191 deselected; the only manual
    deselection is an exact-main host-umask baseline failure.
  • Storage and retained-import suite: 421 passed.
  • Compiler suite: 599 passed with the same exact-main host-umask test
    deselected.
  • Retained manifest importer file: 11 passed.
  • Strict MkDocs build, full branch pre-commit hooks, and git diff --check
    passed.

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings
  • Any dependent changes have been merged and published

@github-actions github-actions Bot added type/docs Documentation type/test Test-related scope/compiler Index compiler, manifest, build integration labels Aug 12, 2026
@fishmingyu
fishmingyu force-pushed the feat/retained-artifact-authority-v2 branch from 634b94b to a27a220 Compare August 16, 2026 01:21
Base automatically changed from feat/retained-artifact-authority-v2 to main August 16, 2026 01:39
Plan and replay canonical view-bundle v1 bytes through retained publication readers without reopening paths or materializing temporary archives. Bind replay to exact subtree authority, drain successful partial consumers, abort failed consumers, and preserve cancellation-aware cleanup.

Verified with Python 3.10 and 3.12 view-bundle tests, the atomic/CAS/contract regression surface, and pinned formatting/lint checks.
Reject hostile scalar subclasses nested inside otherwise exact directory ownership tokens and compare canonical built-in snapshots instead of attacker-controlled dataclass equality.

Verified with the view-bundle suite and pinned formatting, lint, and compile checks.
Add backend-neutral namespace and retained-import capabilities, canonical response attestation, bounded compound generations, and SQLite pre-publication response checks. Oversized aggregate responses now fail inside the publication transaction before refs move.

Verified with the complete storage test suite and focused aggregate rollback probes.
Validate strict context receipts against retained repository sources, stream canonical view bundles and members into CAS, publish identity-closed catalog snapshots, and retain a reversible v2 manifest projection. Keep all artifact validation ahead of CAS and all receipt checks ahead of catalog publication.

Verified with real BM25/vector imports, failure injection, retry, source/receipt mutation, backend attestation, and near-limit profile tests.
Add a callback-shaped object retention contract and keep LocalCAS receipt verification, catalog registration, snapshot publication, and attestation inside one cancellation-safe lifecycle fence.

This closes the gap where a point-in-time receipt could be reclaimed before its catalog reference became durable.
Document authenticated bundle replay, direct schema-v4 bootstrap import, projection closure, and the remaining export, runtime, GC, and fenced-job work.
Assert that every catalog mutation and attestation occurs after object retention begins, and that both success and failure release the scope.
Document the direct importer at-least-once boundary and prove that an exact retry converges after interruption following the SQLite commit.

Verified with the retained manifest importer tests, strict MkDocs build, pre-commit, and the full local unit tier.
@fishmingyu
fishmingyu force-pushed the feat/retained-manifest-import-v2 branch from a532ad7 to a97b0a8 Compare August 16, 2026 01:46
@fishmingyu
fishmingyu marked this pull request as ready for review August 16, 2026 01:54
@fishmingyu
fishmingyu merged commit 8eedbaf into main Aug 16, 2026
23 checks passed
@fishmingyu
fishmingyu deleted the feat/retained-manifest-import-v2 branch August 16, 2026 01:58

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

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

Comment thread codenib/storage/models.py
Comment on lines +197 to +198
if len(raw_members) > MAX_VIEW_GENERATION_MEMBERS:
raise StorageValidationError("view generation has too many member objects")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Preserve previously valid large generations

When opening a schema-v4 catalog created by the previous release, a generation may legally contain more than 32,768 member objects because the old normalizer imposed no limit and view bundles support up to 100,000 files by default. This new read-time check makes _validate_view_generation_input() classify that persisted generation as an identity conflict, so resolve_ref() and get_manifest_summary() can no longer serve an already-published snapshot after upgrade. Because the schema remains v4 and no migration handles these rows, apply the limit only when accepting new data or add an explicit migration/versioning strategy for existing catalogs.

Useful? React with 👍 / 👎.

Comment on lines +1636 to +1641
if not receipt.zip_members or len(receipt.zip_members) != len(receipt.members) + 1:
raise StorageIntegrityError("planned view bundle ZIP inventory is incomplete")
if receipt.manifest_bytes != _manifest_bytes(
receipt.view_type,
receipt.members,
):

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Bind the receipt inventory to retained ownership

When a caller modifies both the public plan and its accessible _receipt, this validation proves only that the forged ZIP fields are internally consistent; it never checks that receipt.members still equals the file records in receipt.source_ownership. A caller can therefore replace the inventory with an empty or partial tuple, rebuild the manifest/layout and digest, and successfully consume a bundle that omits authenticated source files—the later subtree projection check still passes because it validates the unchanged ownership token independently. Reconstruct and compare the expected ArtifactMember tuple from the retained ownership before accepting the receipt.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope/compiler Index compiler, manifest, build integration type/docs Documentation type/test Test-related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant