-
-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Labels
P2-highHigh priority - important for milestone completionHigh priority - important for milestone completioncross-zomeCross-zome integration and coordinationCross-zome integration and coordinationphase-2-governancePhase 2 - Enhanced governance & process integration (current)Phase 2 - Enhanced governance & process integration (current)testingTest infrastructure, scenarios, integration testsTest infrastructure, scenarios, integration testszome-governanceGovernance zome - validation, economic events, commitmentsGovernance zome - validation, economic events, commitments
Milestone
Description
Summary
Build the testing infrastructure needed to verify the governance-as-operator pattern: a mock governance engine for isolated resource zome testing, and cross-zome integration tests for the full Request-Evaluate-Apply flow.
Context
The governance-as-operator pattern introduces cross-zome dependencies that require new testing approaches:
- Resource zome tests need to mock governance decisions to test in isolation
- Integration tests need to verify the full cross-zome flow
- The pure-function GovernanceEngine needs comprehensive unit tests
Technical Implementation
1. Mock Governance Engine
pub struct MockGovernanceEngine {
approval_mode: ApprovalMode,
}
pub enum ApprovalMode {
ApproveAll,
RejectAll,
RoleBased(Vec<String>),
Conditional(Box<dyn Fn(&GovernanceTransitionRequest) -> bool>),
}This enables resource zome tests to:
- Test approved transitions without real governance logic
- Test rejection handling without complex rule setup
- Test specific role-based scenarios
2. Unit Tests for GovernanceEngine
Test the pure-function evaluation logic:
- Permission checks (authorized, unauthorized, various roles)
- Rule evaluation (access requirements, usage limits, transfer conditions)
- State transition validation (valid/invalid action-state combinations)
- Edge cases (empty rules, multiple failures, boundary conditions)
3. Cross-Zome Integration Tests (Tryorama)
End-to-end scenarios:
- Resource creation → use request → governance approval → state change → event generated
- Transfer request → permission check → custody change → PPR generation
- Unauthorized action → governance rejection → no state change → rejection logged
- Multi-agent scenarios with different roles requesting different actions
4. Test Helpers
- Factory functions for creating test resources, specs, agents with roles
- Assertion helpers for verifying governance results
- Test fixtures for common governance rule configurations
Acceptance Criteria
-
MockGovernanceEnginewithApproveAll,RejectAll,RoleBased,Conditionalmodes - Unit tests for
GovernanceEngine::evaluate_transitionpure function - Unit tests cover: approvals, permission denials, rule violations, invalid states
- Cross-zome integration tests using Tryorama for full flow
- Integration tests cover: approved transfers, rejected actions, multi-agent scenarios
- Test helpers and factory functions for common setup
- All tests pass with
bun run tests
Dependencies
- Define cross-zome interface types for governance-as-operator protocol #41 (Cross-zome interface types)
- Implement pure-function GovernanceEngine for state transition evaluation #42 (GovernanceEngine implementation)
- Refactor resource zome to use Request-Evaluate-Apply pattern #43 (Resource zome Request-Evaluate-Apply pattern)
Definition of Done
- Mock engine implemented
- Unit test suite comprehensive
- Integration tests pass
- Test helpers documented
- Code review completed
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
P2-highHigh priority - important for milestone completionHigh priority - important for milestone completioncross-zomeCross-zome integration and coordinationCross-zome integration and coordinationphase-2-governancePhase 2 - Enhanced governance & process integration (current)Phase 2 - Enhanced governance & process integration (current)testingTest infrastructure, scenarios, integration testsTest infrastructure, scenarios, integration testszome-governanceGovernance zome - validation, economic events, commitmentsGovernance zome - validation, economic events, commitments
Type
Projects
Status
Backlog