2.5 KiB
2.5 KiB
Natural Language to Policy Rule Compiler (Policy Studio Copilot)
Module
AdvisoryAI
Status
IMPLEMENTED
Description
AI-powered natural language to lattice rule translation engine including PolicyIntentType parsing, LatticeRuleGenerator, property-based test synthesizer for generated rules, and PolicyBundleCompiler. Transforms plain-English policy descriptions into formal stella-dsl@1 rules with live preview and conflict visualization.
Implementation Details
- Modules:
src/AdvisoryAi/StellaOps.AdvisoryAI/PolicyStudio/ - Key Classes:
AiPolicyIntentParser(src/AdvisoryAi/StellaOps.AdvisoryAI/PolicyStudio/AiPolicyIntentParser.cs) - parses natural language into structured policy intents using LLMLatticeRuleGenerator(src/AdvisoryAi/StellaOps.AdvisoryAI/PolicyStudio/LatticeRuleGenerator.cs) - generates K4 lattice rules from parsed policy intentsPropertyBasedTestSynthesizer(src/AdvisoryAi/StellaOps.AdvisoryAI/PolicyStudio/PropertyBasedTestSynthesizer.cs) - synthesizes property-based test cases for generated rulesPolicyBundleCompiler(src/AdvisoryAi/StellaOps.AdvisoryAI/PolicyStudio/PolicyBundleCompiler.cs) - compiles generated rules into a deployable policy bundlePolicyIntent(src/AdvisoryAi/StellaOps.AdvisoryAI/PolicyStudio/PolicyIntent.cs) - policy intent model with type, constraints, and conditionsInMemoryPolicyIntentStore(src/AdvisoryAi/StellaOps.AdvisoryAI/PolicyStudio/InMemoryPolicyIntentStore.cs) - stores policy intents for iterative refinementNullPolicyIntentParser(src/AdvisoryAi/StellaOps.AdvisoryAI/PolicyStudio/NullPolicyIntentParser.cs) - no-op parser for testing
- Interfaces:
IPolicyIntentParser,IPolicyRuleGenerator,ITestCaseSynthesizer - Source: SPRINT_20251226_017_AI_policy_copilot.md
E2E Test Plan
- Submit a natural language policy description (e.g., "block critical CVEs without a fix") and verify
AiPolicyIntentParserproduces a structuredPolicyIntent - Verify
LatticeRuleGeneratortranslates the intent into valid stella-dsl@1 lattice rules - Verify
PropertyBasedTestSynthesizergenerates test cases that exercise the generated rule's accept/reject boundaries - Verify
PolicyBundleCompilercompiles rules into a deployable bundle with correct schema version - Verify
InMemoryPolicyIntentStoresupports iterative refinement: modify an intent and regenerate rules - Verify conflict detection: generate two conflicting rules and verify the compiler reports the conflict