Description
Add prefix deletion support to integrity.Typed while maintaining backward compatibility. The task has two parts:
- Verify current behavior: Ensure
Delete without options only deletes exact keys, not prefixes
- Add prefix deletion option: New
WithPrefixDelete() option that deletes all keys under a prefix, including hashes and signatures
Implementation Steps
Part 1: Verify Current Behavior
- Add tests confirming
Delete("prefix") doesn't affect "prefix/child"
- Check that
namer.GenerateNames rejects names ending with /
- Verify storage drivers perform exact key matches, not prefix deletions
- Add defensive check in
Delete method to ensure keys don't end with /
Part 2: Add Prefix Deletion Option
- Create
deleteOptions struct in integrity package
- Add
WithPrefixDelete() option function
- Update
Typed.Delete to handle prefix deletion:
- Use
namer.Prefix(name, true) for prefix-based key generation
- Generate all possible key patterns for value/hash/signature keys under prefix
- Use
operation.Get with prefix to find existing keys, then delete them
- Ensure proper handling of nested keys with hashes and signatures
- Update
namer to support prefix-based key enumeration
Examples
Current Behavior (Exact Match)
// Deletes only "/test/key", "/test/key/hash/sha256", "/test/key/sig/rsa"
err := typed.Delete(ctx, "key")
New Prefix Deletion
// Deletes all keys under "/test/prefix/" including nested values and
err := typed.Delete(ctx, "prefix/", integrity.WithPrefixDelete())
Mixed Usage
// Store structure:
// - /test/users/alice
// - /test/hash/sha256/users/alice/
// - /test/users/bob
// - /test/hash/sha256/users/bob/
// Deletes only alice's keys
typed.Delete(ctx, "users/alice")
// Deletes all users (alice, bob, and their hashes/signatures)
typed.Delete(ctx, "users/", integrity.WithPrefixDelete())
Tests
- Exact deletion tests
- Prefix deletion tests
- Integration tests
Checklist
Description
Add prefix deletion support to
integrity.Typedwhile maintaining backward compatibility. The task has two parts:Deletewithout options only deletes exact keys, not prefixesWithPrefixDelete()option that deletes all keys under a prefix, including hashes and signaturesImplementation Steps
Part 1: Verify Current Behavior
Delete("prefix")doesn't affect"prefix/child"namer.GenerateNamesrejects names ending with/Deletemethod to ensure keys don't end with/Part 2: Add Prefix Deletion Option
deleteOptionsstruct inintegritypackageWithPrefixDelete()option functionTyped.Deleteto handle prefix deletion:namer.Prefix(name, true)for prefix-based key generationoperation.Getwith prefix to find existing keys, then delete themnamerto support prefix-based key enumerationExamples
Current Behavior (Exact Match)
New Prefix Deletion
Mixed Usage
Tests
Checklist