feat(hitl): implement structured AuditingData schema and validation policy#1553
Open
YuvikaLimboo wants to merge 1 commit intomofa-org:mainfrom
Open
feat(hitl): implement structured AuditingData schema and validation policy#1553YuvikaLimboo wants to merge 1 commit intomofa-org:mainfrom
YuvikaLimboo wants to merge 1 commit intomofa-org:mainfrom
Conversation
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
This PR introduces a high-integrity Auditing Layer to the mofa-kernel. It transitions the system from "stringly-typed" metadata to a deterministic, schema-backed AuditingData structure. This is a foundational requirement for my GSoC 2026 Proposal (Idea #17 : Human loop pauses at any node for manual review).
🔗 Related Issues
Closes : #1502
Related to GSoC 2026 Idea: #17 (Human loop pauses at any node for manual review)
🧠 Context
To support enterprise-grade AI agents in high-stakes environments (Fintech/Web3), we need a "Holy Trinity" Validation Pipeline. This PR solves the problem of fragile HashMap lookups by enforcing:
Context Capture: via the new AuditingData struct.
Policy Enforcement: via the AuditValidationPolicy.
Safety Constraints: via defined AuditError enums.
🛠️ Changes
crates/mofa-kernel/src/hitl/context.rs: Added AuditingData struct and with_auditing_data builder.
crates/mofa-kernel/src/hitl/error.rs: Defined AuditError enum for structured security reporting.
crates/mofa-kernel/src/hitl/policy.rs: Implemented AuditValidationPolicy and integration tests.
🧪 How you Tested
Ran internal integration tests for serialization: cargo test -p mofa-kernel hitl
Verified AuditValidationPolicy correctly triggers HITL requests based on metadata presence.
Confirmed zero regressions in existing HITL logic.
📸 Screenshots / Logs (if applicable)
⚠️ Breaking Changes
Plaintext
test_auditing_data_integration: PASSED
test_audit_validation_policy_triggers: PASSED
[x] No breaking changes
🧹 Checklist
Code Quality
[x] Code follows Rust idioms and project conventions
[x] cargo fmt run
[x] cargo clippy passes without warnings
Testing
[x] Tests added/updated
[x] cargo test passes locally without any error
🧩 Additional Notes for Reviewers
This implementation is designed to be modular so that other developers can adopt the AuditingData schema for their own specific application domains without modifying the core kernel logic.