Skip to content

fix(contract): avoid partial index repair when a later resource fails validation - #1153

Closed
jeffrey-graham wants to merge 1 commit into
mind-vault-1:mainfrom
jeffrey-graham:fix/issue-1070-atomic-index-repair
Closed

jeffrey-graham wants to merge 1 commit into
mind-vault-1:mainfrom
jeffrey-graham:fix/issue-1070-atomic-index-repair

Conversation

@jeffrey-graham

@jeffrey-graham jeffrey-graham commented Nov 10, 2026 •

Copy link
Copy Markdown

Summary

Validates all entries in repair_index and repair_tag_index (bounds check, validate_resource_id, resource existence and supported schema version via load, and duplicate detection) before performing any storage mutations or index cleanup.

  • Prevents partial index state when a later entry in ids fails validation (InvalidResourceId, NotFound, UnsupportedResourceSchema, or DuplicateInRepair).
  • Adds focused unit tests in contract/contracts/vault-registry/src/test.rs and contract/contracts/vault-registry/src/test/lifecycle_roles.rs verifying that ResourceCount, IndexKey, TagCount, TagEntry, and NextTagSeq remain completely unchanged when any later item fails.
  • Updates contract/README.md, docs/index-repair.md, and docs/tag-index-repair-design.md.

Verification

  • cargo test repair_ && cargo test readme_ && cargo test event_schema_ && cargo test storage_key_ (28/28 passed)

Closes #1070

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.

[Contract] [Bug] Avoid partial index repair when a later resource fails validation

1 participant