feat(contracts): add access history tracking to AccessControl#132
Open
Mercy017 wants to merge 1 commit into
Open
feat(contracts): add access history tracking to AccessControl#132Mercy017 wants to merge 1 commit into
Mercy017 wants to merge 1 commit into
Conversation
Adds the missing acceptance criterion from GuardZero144#92: grant_access, revoke_access, and extend_access already covered permission definition, access checking, grant logic, and revocation logic, but nothing tracked access history. - New AccessHistoryEntry (permission_id, grantee, resource_id, actor, action, timestamp) appended on every grant/revoke/extend, plus a new get_access_history(permission_id) query returning the full log oldest-first. - New AccessControlEvent (Granted/Revoked/Extended) published on each action for off-chain observability, following the same env.events().publish pattern verification.rs already uses for revocation. - History entries live in persistent storage (TTL-bumped, ~31 day extend), not instance storage, so reading/writing history doesn't serialize the contract's whole instance data set - mirroring the perf pattern already established for verification.rs's persistent-storage migration (docs/PERFORMANCE.md). Existing permission records are left on instance storage as before; refactoring those is out of scope here. - A dedicated AccessDataKey::History(u64) key type keeps the new persistent entries in their own storage namespace, so they can't collide with the existing ad hoc tuple/string keys used for permission records. 4 new integration tests cover: a single grant recording one entry, grant+ extend+revoke appending three entries in order, an empty history for an unknown permission_id, and per-permission isolation of history. Verified: cargo fmt --check, cargo clippy --all-targets -D warnings, cargo test --features testutils (125 passed, includes the 4 new tests), cargo build --release --target wasm32-unknown-unknown. Closes GuardZero144#92
|
@Mercy017 is attempting to deploy a commit to the Josie's projects Team on Vercel. A member of the Team first needs to authorize it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #92.
AccessControlalready covered permission definition, access checking, grant logic, and revocation logic — the one missing acceptance criterion was history tracking. This adds it.Changes
AccessHistoryEntry(permission_id,grantee,resource_id,actor,action,timestamp) appended on everygrant_access/revoke_access/extend_access, plus a newget_access_history(permission_id)query returning the full log oldest-first.AccessControlEvent(Granted/Revoked/Extended) published on each action for off-chain observability — mirrors theenv.events().publishpatternverification.rsalready uses for revocation.verification.rs(seedocs/PERFORMANCE.md). Existing permission records are left on instance storage as-is; refactoring those is a separate concern, out of scope here.AccessDataKey::History(u64)key type keeps the new persistent entries in their own storage namespace so they can't collide with the existing ad hoc tuple/string keys used for permission records.Tests
4 new integration tests in
integration_tests.rs:permission_idreturns empty historypermission_idAcceptance criteria
Verification
cargo fmt -- --check— cleancargo clippy --all-targets -- -D warnings— cleancargo test --features testutils— 125 passed, 0 failed (includes the 4 new tests)cargo build --release --target wasm32-unknown-unknown— succeedsNote: only the test-snapshot files affected by this change are included. Several other pre-existing, unrelated tests in
integration_tests.rs(credential-sharing flows) had no committed snapshot yet in this checkout and generated new local snapshot files on the full test run — those are left untouched here to keep this PR scoped to #92.