Orchestrata Ultimate / Specs / 019-intent-impact-analyzer
019-intent-impact-analyzer: Intent Impact Analyzer
The Intent Impact Analyzer is an intelligent analysis system that processes submitted intents to determine the scope of work, affected code areas, and creates parallel execution plans for multiple agents.
At a glance
| Item | Value |
|---|---|
| Spec directory | specs/019-intent-impact-analyzer/ |
| Status line in the spec | Implemented |
| Requirement IDs defined | 47 |
With a @traces citation in src/ |
40 (85.1%) |
With a @traces citation in tests/ |
0 (0.0%) |
| Tracked files | 6 |
| RTM page | 019-intent-impact-analyzer |
Reading this spec
The Intent Impact Analyzer processes a submitted intent to work out the scope of the work, the code areas it affects, and a parallel execution plan for several agents. Before it, intents went straight to agents without any understanding of their full scope, of cascading changes through dependencies, or of how to split work across agents.
The scope is six user stories: intent classification, dependency impact analysis, test impact analysis, interface verification and parallel execution planning (critical), and refactoring plan generation (high). Ten functional groups run from classification, entity extraction and target identification through dependency analysis, impact severity ranking, test discovery, interface contract extraction, breaking change detection, backward compatibility verification and parallel task identification. Requirement IDs use the REQ-019- prefix.
The approach in the overview is to classify the intent text (the terminology table names the classes NEW_REQUIREMENT, NEW_SPEC, FEATURE, BUGFIX and REFACTOR), query the knowledge graph for affected packages, modules and files, follow dependency relationships to find all affected code, identify test files that need updates, create a parallel plan with agent assignments, and verify interface compatibility before execution.
In the code, the work is done by the analyst Volk: orchestrata_ultimate/agents/volks/analyst/agent and orchestrata_ultimate/agents/volks/analyst/parsers, with single-requirement citations in orchestrata_ultimate/orchestrator/impact/planner, orchestrata_ultimate/orchestrator/impact/dependency_analyzer and orchestrata_ultimate/orchestrator/impact/classifier. The per-requirement view is on the RTM page.
The spec's status line reads Implemented. It tracks 6 files and defines 47 requirement IDs. The full text follows below.
Measured coverage is 40 of 47 requirements cited by at least one @traces in src/ (85.1%), spread over 6 modules; the module citing the most of them is orchestrata_ultimate/agents/volks/analyst/agent (23 requirements). In tests/, 0 requirements are cited by a test-side @traces.
Coverage gaps: 7 requirements have no citing symbol. The largest untraced groups are REQ-019-* (7). Untraced means no @traces names the ID; the behaviour may still exist in code that was never annotated. Test-side citations are thinner than code-side ones (0 against 40).
Requirements
Checkbox is the state recorded in the requirements checklist; Traced by is the count of src/ symbols whose @traces names the ID.
| ID | Done | Requirement | Traced by |
|---|---|---|---|
REQ-019-001 |
no | AnalystVolk must define alias U:BA and role "Business Analyst" | 3 |
REQ-019-002 |
no | AnalystVolk must extend BaseVolk and comply with all BaseVolk interface contracts | 2 |
REQ-019-003 |
no | process() must route messages with subject "implement" to _handle_analysis() | 1 |
REQ-019-004 |
no | process() must route messages with subject "analyze_requirements" to _handle_analysis() | 1 |
REQ-019-005 |
no | _handle_analysis() must extract raw requirements from the incoming CXP message payload | 2 |
REQ-019-006 |
no | _handle_analysis() must assemble a full context string prior to invoking the LLM, including agent alias, role, and session context | 1 |
REQ-019-007 |
no | _handle_analysis() must include conversation history in the LLM context when history is present in the session | 1 |
REQ-019-008 |
no | _handle_analysis() must call the configured LLM provider with ANALYST_SYSTEM_PROMPT as the system prompt | 2 |
REQ-019-009 |
no | _handle_analysis() must pass the assembled context and raw requirements as the user message to the LLM | 2 |
REQ-019-010 |
no | _handle_analysis() must invoke all six parser functions on the raw LLM output string | 2 |
REQ-019-011 |
no | _handle_analysis() must store parsed user stories and requirements to the Knowledge Graph via KGDesignStore | 2 |
REQ-019-012 |
no | _handle_analysis() must escalate to U:PM after successful analysis regardless of KG storage outcome | 1 |
REQ-019-013 |
no | parse_project_type() must accept the raw LLM output string as its sole argument | 1 |
REQ-019-014 |
no | parse_project_type() must use a regex to locate and return the value of the PROJECT_TYPE field | 1 |
REQ-019-015 |
no | parse_project_type() must return an empty string when the PROJECT_TYPE field is absent from the output | 1 |
REQ-019-016 |
no | parse_technology() must extract all key-value pairs within the TECHNOLOGY block | 1 |
REQ-019-017 |
no | parse_technology() must return a dict mapping each technology key (language, framework, packaging, testing, deployment) to its value | 1 |
REQ-019-018 |
no | parse_technology() must return an empty dict when the TECHNOLOGY block is absent | 1 |
REQ-019-019 |
no | parse_spec_metadata() must extract all key-value pairs within the SPEC_METADATA block | 1 |
REQ-019-020 |
no | parse_spec_metadata() must return a dict of spec metadata fields | 1 |
REQ-019-021 |
no | parse_spec_metadata() must return an empty dict when the SPEC_METADATA block is absent | 1 |
REQ-019-022 |
no | parse_user_stories() must extract every US-NNN entry from the USER_STORIES block | 3 |
REQ-019-023 |
no | parse_user_stories() must capture the acceptance criteria associated with each US-NNN entry | 3 |
REQ-019-024 |
no | parse_user_stories() must return a list of dicts, each containing "id", "description", and "acceptance_criteria" keys | 2 |
REQ-019-025 |
no | parse_requirements() must extract every REQ-NNN-USn-NNN entry from the REQUIREMENTS block | 3 |
REQ-019-026 |
no | parse_requirements() must return a list of dicts, each containing "id" and "description" keys | 2 |
REQ-019-027 |
no | parse_nfrs() must extract every NFR-NNN entry from the NON_FUNCTIONAL block | 2 |
REQ-019-028 |
no | parse_nfrs() must capture the category associated with each NFR-NNN entry | 2 |
REQ-019-029 |
no | parse_nfrs() must return a list of dicts, each containing "id", "category", and "description" keys | 2 |
REQ-019-030 |
no | KGDesignStore must be initialised lazily — instantiated only on first use, not at volk startup | 1 |
REQ-019-031 |
no | _handle_analysis() must store each parsed user story as a node in the KG via KGDesignStore | 2 |
REQ-019-032 |
no | _handle_analysis() must store each parsed requirement as a node in the KG, linked to its parent user story | 2 |
REQ-019-033 |
no | KG storage failures must be caught, logged, and must not prevent escalation to U:PM | 1 |
REQ-019-034 |
no | _handle_analysis() must store structured requirements under the active session identifier | 1 |
REQ-019-035 |
no | _handle_analysis() must send the escalation CXP message to U:PM (not U:Ox or any other volk) | 1 |
REQ-019-036 |
no | The escalation CXP subject must be "scope_review" | 1 |
REQ-019-037 |
no | The escalation payload must include the original raw requirements text under the key "requirements" | 1 |
REQ-019-038 |
no | The escalation payload must include a "task_summary" field summarising the analyst output | 1 |
REQ-019-039 |
no | The escalation payload must include a "prolog_facts" field containing Prolog-compatible fact assertions derived from the parsed output | 1 |
REQ-019-040 |
no | The escalation payload must include "project_type", "technology", "spec_metadata", "user_stories", "structured_requirements", "nfrs", and "analyst_output" fields | 1 |
REQ-019-041 |
no | ANALYST_SYSTEM_PROMPT must instruct the LLM to classify the project type and emit it under the PROJECT_TYPE section header | none |
REQ-019-042 |
no | ANALYST_SYSTEM_PROMPT must instruct the LLM to determine and emit technology decisions (language, framework, packaging, testing, deployment) under the TECHNOLOGY section header | none |
REQ-019-043 |
no | ANALYST_SYSTEM_PROMPT must instruct the LLM to emit spec metadata under the SPEC_METADATA section header | none |
REQ-019-044 |
no | ANALYST_SYSTEM_PROMPT must require user story IDs in the format US-NNN (zero-padded three-digit integer) | none |
REQ-019-045 |
no | ANALYST_SYSTEM_PROMPT must require each user story to include at least one acceptance criterion | none |
REQ-019-046 |
no | ANALYST_SYSTEM_PROMPT must require functional requirement IDs in the format REQ-NNN-USn-NNN | none |
REQ-019-047 |
no | ANALYST_SYSTEM_PROMPT must require NFR IDs in the format NFR-NNN and mandate a category label on every NFR | none |
Code that traces this spec
Checklists
checklists/constitutional.md
SPEC-019 Constitutional Checklist — Intent Impact Analyzer (Business Analyst Volk)
- [ ] CONST-019-001: AnalystVolk must not store or log raw LLM output containing user requirements beyond the active session boundary; data must be scoped to the session in all persistence operations
- [ ] CONST-019-002: AnalystVolk must not impersonate any other volk alias; all CXP messages it sends must carry FROM = U:BA
- [ ] CONST-019-003: AnalystVolk must not send CXP messages directly to U:Ox bypassing U:PM for scope decisions; escalation path is always U:BA → U:PM
- [ ] CONST-019-004: AnalystVolk must not discard or overwrite requirements provided by U:Cx; original text must be forwarded verbatim in the escalation payload
- [ ] CONST-019-005: AnalystVolk must not generate or propose technology decisions outside the TECHNOLOGY block; decisions outside that block must be ignored in downstream parsing
- [ ] CONST-019-006: AnalystVolk must not claim analysis success if the LLM call fails; errors must propagate as structured error CXP messages, not silent no-ops
- [ ] CONST-019-007: KG storage must never block or delay escalation to U:PM; storage operations must be best-effort and non-blocking on failure
- [ ] CONST-019-008: AnalystVolk must not fabricate requirement IDs; all IDs must be parsed directly from LLM output using the defined regex patterns
- [ ] CONST-019-009: ANALYST_SYSTEM_PROMPT must not contain instructions that lead the LLM to recommend proprietary or vendor-locked technologies without flagging the constraint explicitly
- [ ] CONST-019-010: AnalystVolk must not retain parsed structured data (user stories, requirements) in memory beyond the lifetime of a single _handle_analysis() invocation; KG is the authoritative store
- [ ] CONST-019-011: AnalystVolk must enforce that every escalated payload contains all seven required payload keys; partial payloads must be rejected and an error must be emitted before sending
- [ ] CONST-019-012: AnalystVolk must not modify the conversation history it reads; history is read-only input to the LLM context
- [ ] CONST-019-013: All regex parsers must be stateless and side-effect-free; parsers must not modify any shared state or volk instance variables
- [ ] CONST-019-014: AnalystVolk must respect PAM++ governance boundaries — it must not execute code, write files, or perform any action outside its defined analysis and escalation responsibilities
- [ ] CONST-019-015: AnalystVolk must not send duplicate escalation messages for the same incoming CXP packet; idempotency must be enforced via message_id tracking
checklists/requirements.md
The requirement list above comes from this file; 0 of 47 checkbox items are ticked.
checklists/testing.md
SPEC-019 Testing Checklist — Intent Impact Analyzer (Business Analyst Volk)
Volk Identity & Routing
- [ ] TEST-019-001: Verify AnalystVolk.alias == "U:BA" and AnalystVolk.role == "Business Analyst"
- [ ] TEST-019-002: Verify AnalystVolk inherits from BaseVolk and passes all BaseVolk interface assertions
- [ ] TEST-019-003: Verify process() dispatches a CXP message with subject "implement" to _handle_analysis()
- [ ] TEST-019-004: Verify process() dispatches a CXP message with subject "analyze_requirements" to _handle_analysis()
Analysis Pipeline
- [ ] TEST-019-005: Verify _handle_analysis() extracts raw requirements from the CXP payload without transformation
- [ ] TEST-019-006: Verify _handle_analysis() builds a context string containing agent alias, role, and session context before LLM call
- [ ] TEST-019-007: Verify _handle_analysis() appends conversation history to the LLM context when history exists in the session
- [ ] TEST-019-008: Verify _handle_analysis() invokes the LLM with ANALYST_SYSTEM_PROMPT as the system prompt
- [ ] TEST-019-009: Verify _handle_analysis() passes assembled context + raw requirements as the user message to the LLM
- [ ] TEST-019-010: Verify _handle_analysis() calls all six parser functions on the LLM output string
- [ ] TEST-019-011: Verify _handle_analysis() calls KGDesignStore to store user stories and requirements after parsing
- [ ] TEST-019-012: Verify _handle_analysis() sends an escalation CXP to U:PM even when KG storage raises an exception
Parsers — parse_project_type
- [ ] TEST-019-013: Verify parse_project_type() returns the correct value from a well-formed LLM output containing PROJECT_TYPE
- [ ] TEST-019-014: Verify parse_project_type() returns an empty string when PROJECT_TYPE is absent from the output
- [ ] TEST-019-015: Verify parse_project_type() handles multi-word project type values without truncation
Parsers — parse_technology
- [ ] TEST-019-016: Verify parse_technology() returns a dict with all five keys (language, framework, packaging, testing, deployment) from a complete TECHNOLOGY block
- [ ] TEST-019-017: Verify parse_technology() returns an empty dict when the TECHNOLOGY block is absent
- [ ] TEST-019-018: Verify parse_technology() handles TECHNOLOGY blocks with a subset of keys without raising an exception
Parsers — parse_spec_metadata
- [ ] TEST-019-019: Verify parse_spec_metadata() returns a dict of all key-value pairs from a well-formed SPEC_METADATA block
- [ ] TEST-019-020: Verify parse_spec_metadata() returns an empty dict when the SPEC_METADATA block is absent
- [ ] TEST-019-021: Verify parse_spec_metadata() handles SPEC_METADATA blocks with atypical key names without data loss
Parsers — parse_user_stories
- [ ] TEST-019-022: Verify parse_user_stories() returns a list containing one entry per US-NNN found in a multi-story output
- [ ] TEST-019-023: Verify each returned dict contains "id", "description", and "acceptance_criteria" keys with non-empty values
- [ ] TEST-019-024: Verify parse_user_stories() returns an empty list when no US-NNN entries are present
Parsers — parse_requirements
- [ ] TEST-019-025: Verify parse_requirements() extracts every REQ-NNN-USn-NNN entry from a well-formed REQUIREMENTS block
- [ ] TEST-019-026: Verify each returned dict contains "id" and "description" keys with values matching the source text
Parsers — parse_nfrs
- [ ] TEST-019-027: Verify parse_nfrs() extracts every NFR-NNN entry from a well-formed NON_FUNCTIONAL block
- [ ] TEST-019-028: Verify each returned dict contains "id", "category", and "description" keys
- [ ] TEST-019-029: Verify parse_nfrs() returns an empty list when the NON_FUNCTIONAL block is absent
Knowledge Graph Storage
- [ ] TEST-019-030: Verify KGDesignStore is not instantiated before the first call to _handle_analysis()
- [ ] TEST-019-031: Verify each parsed user story results in exactly one node creation call on KGDesignStore
- [ ] TEST-019-032: Verify each parsed requirement results in exactly one node creation call on KGDesignStore, linked to its parent user story
- [ ] TEST-019-033: Verify a KGDesignStore exception does not prevent the escalation CXP from being sent to U:PM
- [ ] TEST-019-034: Verify stored items carry the active session identifier as a field or relationship attribute
Escalation
- [ ] TEST-019-035: Verify the escalation CXP message is addressed to U:PM and only U:PM
- [ ] TEST-019-036: Verify the escalation CXP subject field equals "scope_review"
- [ ] TEST-019-037: Verify the escalation payload "requirements" key contains the original raw requirements text unmodified
- [ ] TEST-019-038: Verify the escalation payload "task_summary" key is present and non-empty
- [ ] TEST-019-039: Verify the escalation payload "prolog_facts" key contains valid Prolog fact syntax
- [ ] TEST-019-040: Verify the escalation payload contains all seven required keys: requirements, task_summary, prolog_facts, project_type, technology, spec_metadata, user_stories, structured_requirements, nfrs, analyst_output
ANALYST_SYSTEM_PROMPT
- [ ] TEST-019-041: Verify ANALYST_SYSTEM_PROMPT contains the literal string "PROJECT_TYPE" as a section marker
- [ ] TEST-019-042: Verify ANALYST_SYSTEM_PROMPT contains the literal string "TECHNOLOGY" as a section marker and references language, framework, packaging, testing, and deployment
- [ ] TEST-019-043: Verify ANALYST_SYSTEM_PROMPT contains the literal string "SPEC_METADATA" as a section marker
- [ ] TEST-019-044: Verify ANALYST_SYSTEM_PROMPT specifies the US-NNN zero-padded three-digit ID format explicitly
- [ ] TEST-019-045: Verify ANALYST_SYSTEM_PROMPT requires at least one acceptance criterion per user story
- [ ] TEST-019-046: Verify ANALYST_SYSTEM_PROMPT specifies the REQ-NNN-USn-NNN ID format explicitly
- [ ] TEST-019-047: Verify ANALYST_SYSTEM_PROMPT specifies the NFR-NNN format and mandates a category label on every NFR
Other tracked files
specs/019-intent-impact-analyzer/README.mdspecs/019-intent-impact-analyzer/compliance-audit.md
Full spec text
Verbatim from specs/019-intent-impact-analyzer/spec.md; headings are pushed down two levels.
SPEC-019: Intent Impact Analyzer
Metadata
- Spec ID: 019-intent-impact-analyzer
- Title: Intent Impact Analyzer
- Version: 1.0.0
- Author: Mohamed
- Status: Implemented
- Created: 2026-03-29
- Last Updated: 2026-04-09
- Priority: P0
- Components: ImpactAnalyzer, DependencyGraph, ParallelPlanner, InterfaceVerifier
- Dependencies: orchestrata-orchestrator, orchestrata-knowledge, orchestrata-agents
- Implementation Branch: spec-019-implementation
Overview
What
The Intent Impact Analyzer is an intelligent analysis system that processes submitted intents to determine the scope of work, affected code areas, and creates parallel execution plans for multiple agents.
Why
- Intents currently go directly to agents without understanding the full scope
- No analysis of whether it's a new requirement/spec/feature
- No understanding of cascading changes through dependencies
- No parallel execution planning for multiple agents
- No interface verification before changes
How
- Analyzes intent text to classify as requirement/spec/feature
- Queries knowledge graph for affected packages, modules, files
- Analyzes dependency relationships to find all affected code
- Identifies test files that need updates
- Creates parallel execution plan with agent assignments
- Verifies interface compatibility before execution
Terminology
| Term | Definition |
|---|---|
| Intent Classification | Categorization of intent as NEW_REQUIREMENT, NEW_SPEC, FEATURE, BUGFIX, REFACTOR |
| Impact Scope | The set of packages/modules/files affected by the intent |
| Dependency Graph | Neo4j graph showing imports, calls, inherits relationships |
| Parallel Plan | Execution plan with independent tasks that can run concurrently |
| Agent Task | A unit of work assigned to a specific agent type |
| Interface Contract | The public API of a module (functions, classes) |
| Breaking Change | An interface change that breaks existing callers |
User Scenarios
US-001: Intent Classification (Critical)
As a developer I want the system to classify my intent So that I know if it's a new requirement, spec, feature, or bugfix
Acceptance Criteria:
- Classify intent as NEW_REQUIREMENT, NEW_SPEC, FEATURE, BUGFIX, REFACTOR
- Extract key entities (file names, function names, class names)
- Identify target package/module
- Confidence score for classification
US-002: Dependency Impact Analysis (Critical)
As a developer I want to know all files affected by my intent So that I understand the full scope of changes
Acceptance Criteria:
- Query dependency graph from target file/module
- Find all upstream dependencies (files that import/use target)
- Find all downstream dependencies (files target imports/uses)
- Identify circular dependencies
- Rank by impact severity (direct vs transitive)
US-003: Test Impact Analysis (Critical)
As a developer I want to know which tests will be affected So that I can plan test updates
Acceptance Criteria:
- Find unit tests for affected modules
- Find integration tests that touch affected code
- Identify test patterns (pytest, unittest)
- Estimate test coverage impact
US-004: Interface Verification (Critical)
As a developer I want the system to verify interface compatibility So that I avoid breaking changes
Acceptance Criteria:
- Extract current interface contracts
- Predict interface changes from intent
- Detect breaking changes
- Suggest interface additions vs modifications
- Verify backward compatibility
US-005: Parallel Execution Planning (Critical)
As a developer I want a plan that multiple agents can execute in parallel So that I can speed up development
Acceptance Criteria:
- Identify independent tasks
- Group tasks by package/module
- Assign tasks to agent types (U:Cd, U:Qa, U:Ar)
- Define task dependencies
- Estimate parallelization efficiency
- Create execution order with parallel branches
US-006: Refactoring Plan Generation (High)
As a developer I want a comprehensive refactoring plan So that I can execute changes systematically
Acceptance Criteria:
- Sequence changes by dependency order
- Identify migration steps
- Include rollback points
- Define verification checkpoints
Architecture
┌─────────────────────────────────────────────────────────────────────────┐
│ INTENT IMPACT ANALYZER │
├─────────────────────────────────────────────────────────────────────────┤
│ │
│ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │
│ │ Intent │ │ Impact │ │ Dependency │ │
│ │ Classifier │───▶│ Analyzer │───▶│ Graph │ │
│ └──────────────┘ └──────────────┘ └──────────────┘ │
│ │ │ │ │
│ ▼ ▼ ▼ │
│ ┌────────────────────────────────────────────────────────────────┐ │
│ │ Impact Report │ │
│ │ • Classification • Affected files │ │
│ │ • Confidence • Dependency chain │ │
│ │ • Entities • Test coverage │ │
│ └────────────────────────────────────────────────────────────────┘ │
│ │ │
│ ▼ │
│ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │
│ │ Interface │ │ Test │ │ Parallel │ │
│ │ Verifier │ │ Analyzer │ │ Planner │ │
│ └──────────────┘ └──────────────┘ └──────────────┘ │
│ │ │ │ │
│ ▼ ▼ ▼ │
│ ┌────────────────────────────────────────────────────────────────┐ │
│ │ Execution Plan │ │
│ │ • Agent assignments • Task dependencies │ │
│ │ • Parallel branches • Verification checkpoints │ │
│ └────────────────────────────────────────────────────────────────┘ │
│ │
└─────────────────────────────────────────────────────────────────────────┘
Data Models
IntentClassification
@dataclass
class IntentClassification:
type: IntentType # NEW_REQUIREMENT, NEW_SPEC, FEATURE, BUGFIX, REFACTOR
confidence: float
entities: list[str] # File names, function names, class names
target_package: Optional[str]
target_module: Optional[str]
ImpactScope
@dataclass
class ImpactScope:
target_package: str
target_module: str
affected_packages: list[str]
affected_modules: list[str]
affected_files: list[str]
upstream_dependencies: list[str] # Files that import this
downstream_dependencies: list[str] # Files this imports
test_files: list[str]
severity: ImpactSeverity # LOW, MEDIUM, HIGH, CRITICAL
InterfaceContract
@dataclass
class InterfaceContract:
module_path: str
classes: list[ClassInterface]
functions: list[FunctionInterface]
@dataclass
class ClassInterface:
name: str
public_methods: list[str]
attributes: list[str]
@dataclass
class FunctionInterface:
name: str
parameters: list[str]
return_type: Optional[str]
BreakingChange
@dataclass
class BreakingChange:
type: BreakingType # REMOVED, RENAMED, SIGNATURE_CHANGE
entity: str
old_contract: Optional[InterfaceContract]
severity: ImpactSeverity
ParallelPlan
@dataclass
class ParallelPlan:
total_tasks: int
parallel_branches: list[TaskBranch]
estimated_speedup: float
critical_path: list[str]
@dataclass
class TaskBranch:
agent_type: str # U:Cd, U:Qa, U:Ar
tasks: list[AgentTask]
dependencies: list[tuple[str, str]] # (task_id, depends_on_task_id)
@dataclass
class AgentTask:
task_id: str
description: str
target_files: list[str]
agent_type: str
priority: int
Integration Points
With Intent Broker
- Add impact analysis as step 2.5 in pipeline (between validate and route)
- Store ImpactReport in Intent.metadata
- Use ParallelPlan for agent dispatch
With Knowledge Graph
- Query Module and Package nodes for target
- Query IMPORTS and CALLS relationships
- Query TestResult nodes for coverage
With Agents
- Pass ParallelPlan.tasks to agent pool
- Track task completion via CXP
- Verify results at checkpoints
Query Patterns
Find Affected Files
MATCH (target:Module {name: $module_name})
OPTIONAL MATCH (target)<-[:IMPORTS]-(upstream:File)
OPTIONAL MATCH (target)-[:IMPORTS]->(downstream:File)
RETURN upstream, downstream
Find Tests
MATCH (test:File)-[:DEFINES]->(tc:Class)
WHERE tc.name CONTAINS 'Test' OR tc.name ENDS WITH 'Test'
OPTIONAL MATCH (test)-[:IMPORTS]->(target:File {path: $target_path})
RETURN test
Find Interface
MATCH (m:Module {name: $module_name})
MATCH (m)-[:HAS_FILE]->(f:File)-[:DEFINES]->(c:Class)
RETURN c.name as class, collect(DISTINCT c.methods) as methods
Functional Requirements
FR-001: Intent Classification
The system MUST classify intents into one of: NEW_REQUIREMENT, NEW_SPEC, FEATURE, BUGFIX, REFACTOR with a confidence score >= 0.85.
FR-002: Entity Extraction
The system MUST extract file names, function names, and class names from intent text with >= 90% accuracy.
FR-003: Target Identification
The system MUST identify target package and module from intent context with >= 90% accuracy.
FR-004: Dependency Analysis
The system MUST query the dependency graph to find all upstream and downstream dependencies within 3 hops.
FR-005: Impact Severity Ranking
The system MUST rank affected files by severity: CRITICAL (direct), HIGH (1 hop), MEDIUM (2 hops), LOW (3 hops).
FR-006: Test Discovery
The system MUST identify all test files affected by the impact scope, including unit tests and integration tests.
FR-007: Interface Contract Extraction
The system MUST extract current interface contracts including public methods, parameters, and return types.
FR-008: Breaking Change Detection
The system MUST detect breaking changes including: REMOVED, RENAMED, SIGNATURE_CHANGE with >= 95% accuracy.
FR-009: Backward Compatibility Verification
The system MUST verify backward compatibility and suggest additions vs modifications.
FR-010: Parallel Task Identification
The system MUST identify independent tasks that can execute in parallel with zero dependencies between them.
FR-011: Agent Assignment
The system MUST assign tasks to agent types: U:Cd (Code), U:Qa (Quality), U:Ar (Architecture) based on task requirements.
FR-012: Execution Order Generation
The system MUST generate execution order with parallel branches and define task dependencies.
FR-013: Parallelization Efficiency
The system MUST calculate estimated speedup factor >= 2.0 for typical multi-agent scenarios.
FR-014: Impact Report Generation
The system MUST generate a complete ImpactReport within 5 seconds for standard intents.
FR-015: Circular Dependency Detection
The system MUST detect and highlight circular dependencies in the impact scope.
Error Conditions
| ID | Condition | Handling |
|---|---|---|
| ERR-001 | Intent text is blank | Return error with message "Intent text is required" |
| ERR-002 | Intent text exceeds 10000 characters | Truncate and warn user, proceed with analysis |
| ERR-003 | Target module not found in knowledge graph | Return partial impact analysis with warning "Module not indexed" |
| ERR-004 | Knowledge graph connection unavailable | Return error with message "Knowledge graph unavailable" |
| ERR-005 | Classification confidence < 0.5 | Flag as LOW_CONFIDENCE, suggest manual review |
| ERR-006 | Circular dependency detected | Include in report, mark CRITICAL severity, suggest refactoring |
| ERR-007 | Breaking change detected | Block execution, require explicit override from user |
| ERR-008 | No parallelizable tasks found | Generate sequential plan, explain why parallelization not possible |
| ERR-009 | Agent pool unavailable | Queue tasks, notify user of delay |
| ERR-010 | Task execution timeout | Log timeout, attempt retry with exponential backoff (max 3 retries) |
| ERR-011 | Interface verification fails | Generate detailed change report, suggest migration path |
| ERR-012 | Test files not found | Warn user, proceed with file changes only |
| ERR-013 | Insufficient permissions for target files | Report authorization error, do not proceed |
| ERR-014 | Neo4j query timeout | Retry query once, then return partial results with warning |
| ERR-015 | Invalid intent type classification | Default to FEATURE, flag for manual review |
API Contracts
ImpactAnalyzer
class ImpactAnalyzer:
def analyze_intent(intent: str, context: dict) -> ImpactReport:
"""
Analyze an intent and generate impact report.
Args:
intent: Natural language intent description
context: Additional context (optional)
Returns:
ImpactReport with classification, scope, and plan
"""
def classify_intent(intent: str) -> IntentClassification:
"""
Classify intent type and extract entities.
Returns:
IntentClassification with type, confidence, entities
"""
def analyze_dependencies(target_module: str) -> ImpactScope:
"""
Analyze dependency impact for target module.
Returns:
ImpactScope with affected packages, modules, files
"""
ParallelPlanner
class ParallelPlanner:
def create_plan(impact_scope: ImpactScope) -> ParallelPlan:
"""
Create parallel execution plan from impact scope.
Returns:
ParallelPlan with tasks, branches, dependencies
"""
def identify_independent_tasks(impact_scope: ImpactScope) -> list[AgentTask]:
"""
Identify tasks that can run in parallel.
Returns:
List of independent AgentTask objects
"""
def assign_agents(tasks: list[AgentTask]) -> list[TaskBranch]:
"""
Assign tasks to appropriate agent types.
Returns:
List of TaskBranch objects grouped by agent type
"""
InterfaceVerifier
class InterfaceVerifier:
def extract_contract(module_path: str) -> InterfaceContract:
"""
Extract interface contract from module.
Returns:
InterfaceContract with classes and functions
"""
def predict_changes(intent: str, current: InterfaceContract) -> list[BreakingChange]:
"""
Predict interface changes from intent.
Returns:
List of BreakingChange objects
"""
def verify_compatibility(changes: list[BreakingChange]) -> CompatibilityResult:
"""
Verify backward compatibility of proposed changes.
Returns:
CompatibilityResult with is_compatible flag and suggestions
"""
Non-Functional Requirements
Performance
- Impact analysis MUST complete within 5 seconds for standard intents
- Parallel planning MUST complete within 2 seconds
- Interface verification MUST complete within 1 second
Scalability
- System MUST handle 100+ affected files in impact scope
- System MUST support 20+ parallel tasks in execution plan
- System MUST maintain < 100ms query time for knowledge graph
Reliability
- System MUST have 99.9% uptime for impact analysis
- Failed analyses MUST be retryable without side effects
- Knowledge graph MUST be eventually consistent within 10 seconds
Technical Design
Processing Pipeline
- Intent Parsing: Parse intent text, extract entities
- Classification: Classify intent type with confidence score
- Target Resolution: Identify target package/module
- Dependency Query: Query knowledge graph for affected code
- Impact Calculation: Calculate severity and scope
- Test Discovery: Find affected test files
- Interface Analysis: Extract and analyze contracts
- Breaking Change Detection: Identify incompatible changes
- Parallel Planning: Generate execution plan
- Report Generation: Compile final ImpactReport
Data Flow
Intent Text → Classifier → ImpactAnalyzer → Knowledge Graph
↓
ImpactScope ← Dependency Graph
↓
InterfaceVerifier → TestAnalyzer
↓
ParallelPlanner
↓
ImpactReport
Examples
Example 1: Feature Implementation
Intent: "Add authentication middleware to the user service"
Classification: FEATURE (confidence: 0.92)
Impact Scope:
- Target: user-service
- Affected: auth-middleware, token-validator
- Severity: HIGH
Parallel Plan:
- Branch 1 (U:Cd): Create auth-middleware, update user-service
- Branch 2 (U:Ar): Design token-validator interface
- Branch 3 (U:Qa): Write tests for auth flow
Example 2: Breaking Change
Intent: "Remove deprecated getUser method from UserService"
Breaking Change: REMOVED (severity: CRITICAL)
Verification: FAILS backward compatibility
Action: Block execution, suggest deprecation path
Security
Authentication
- All impact analysis requests MUST include valid API key
- Knowledge graph queries MUST use authenticated session
Authorization
- Users can only analyze projects they have access to
- Sensitive modules MAY be restricted from analysis
Input Validation
- Intent text MUST be sanitized before processing
- Module paths MUST be validated against allowed directories
- No arbitrary code execution from intent text
Audit Logging
- All analysis requests MUST be logged with timestamp
- Breaking changes MUST be logged for compliance
- Access denied events MUST trigger security alert
Governance
Change Management
- Breaking changes MUST be reviewed by senior engineer
- Impact scope > 10 files requires approval
- Parallel plans MUST be reviewed before execution
Quality Gates
- Classification confidence MUST be >= 0.85
- All identified tests MUST be updatable
- No execution of plans with ERR-006 or ERR-007
Visual Architecture
Class Diagram
Diagram source shown as text: Mermaid could not parse it (Error: Parse error on line 11:).
classDiagram-direction LR
class GovernanceEngine {
+__init__()
#_load_default_policies(): dict[str, Any]
+async check(action: str, context: dict[str, Any]): bool
#async _check_edit_file(context: dict[str, Any]): bool
#async _check_create_project(context: dict[str, Any]): bool
#async _check_execute_command(context: dict[str, Any]): bool
}
Unit Tests
- Test IntentClassification accuracy (mock LLM)
- Test ImpactScope calculation
- Test ParallelPlan generation
Integration Tests
- Test Knowledge Graph integration
- Test Agent pool integration
- Test end-to-end analysis pipeline
Coverage Targets
- Minimum 80% code coverage
- All error conditions MUST have test cases
Success Criteria
Core Functionality
- [ ] Intent classification accuracy >= 85%
- [ ] Dependency analysis complete within 3 hops
- [ ] Breaking change detection >= 95% accurate
- [ ] Parallel planning produces speedup >= 2.0
Performance
- [ ] Impact analysis < 5 seconds p95
- [ ] Query time < 100ms p95
- [ ] System available 99.9%
Quality
- [ ] No ERR-007 bypasses without approval
- [ ] All error conditions tested
- [ ] Documentation complete
Observability
Logging Requirements
- Component Logging
- Log all major operations with appropriate log levels
- Include correlation IDs for request tracing
- Log performance metrics for critical operations
- Log errors with full context for debugging
Metrics Requirements
- Performance Metrics
- Operation duration histograms
- Request/error rate counters
- Resource utilization gauges
- Business metrics relevant to domain
Tracing Requirements
- Distributed Tracing
- Trace propagation across component boundaries
- Span attributes for domain-specific context
- Trace sampling based on operational needs
Alerting Requirements
- Critical Alerts
- Error rate spikes
- Performance degradation
- Resource exhaustion
- Business metric anomalies
Dashboard Requirements
- Operational Dashboard
- Real-time system health
- Performance trends
- Error analysis
- Resource monitoring
Revision History
| Version | Date | Changes | Author |
|---|---|---|---|
| 1.0.0 | 2026-03-29 | Initial spec | Mohamed |
| 1.0.1 | 2026-04-09 | Added missing sections per SPEC_STANDARD | Mohamed |