Orchestrata Ultimate / Specs / 027-junior-volk
027-junior-volk: Junior Developer Volk
The Junior Developer Volk (J:Junior) is the code generation agent in Orchestrata. It reviews architecture designs by asking structured blocking questions through a converging review cycle, then generates implementation code using the configured driver backend (orchestrata-drivers). After generation it scans the workspace and validates all generated Python file imports against the project pyproject.toml.
At a glance
| Item | Value |
|---|---|
| Spec directory | specs/027-junior-volk/ |
| Status line in the spec | Implemented |
| Requirement IDs defined | 70 |
With a @traces citation in src/ |
56 (80.0%) |
With a @traces citation in tests/ |
0 (0.0%) |
| Tracked files | 6 |
| RTM page | 027-junior-volk |
Reading this spec
The Junior Developer Volk (J:Junior) is the code generation agent of Orchestrata. It first reviews an architecture design by asking structured blocking questions through a converging review cycle, and then generates implementation code using the configured driver backend. After generation it scans the workspace and validates dependencies. The spec's reasons are that code generation needs a deliberate review gate so that nothing is built on an incomplete design, that unconstrained question loops would block delivery, and that undeclared third-party imports are caught before CI.
The scope is three user stories (the Architect triggers a design review, the CodeDirector requests code generation, and the Junior detects undeclared dependencies) and twelve functional requirements: review trigger, LLM-driven analysis, checklist evaluation, convergence enforcement, question parsing, code generation trigger, driver execution, workspace scanning, dependency validation, result reporting, auto-READY enforcement and error handling. Requirement IDs use the REQ-027- prefix.
The key decisions are that JuniorVolk extends BaseVolk and receives CXP packets on two subjects, design_review and code_generate. The review uses a 7-item checklist (C1 to C7) at temperature 0.0. Convergence rules cap the questions: at most 5 in cycle 1 (checklist items C1 to C5 only), at most 3 in cycle 2, and automatic READY from cycle 3. Code generation obtains a driver from the driver factory of spec 025, then runs workspace scanning and dependency validation. Results go to U:Ar (design review) and U:Cd (code generation).
In the code, almost all citations are in orchestrata_ultimate/agents/volks/junior/volk, with minor ones in orchestrata_ultimate/verification/review/helpers. The per-requirement view is on the RTM page.
The spec's status line reads Implemented. It tracks 6 files and defines 70 requirement IDs. The full text follows below.
Measured coverage is 56 of 70 requirements cited by at least one @traces in src/ (80.0%), spread over 3 modules; the module citing the most of them is orchestrata_ultimate/agents/volks/junior/volk (56 requirements). In tests/, 0 requirements are cited by a test-side @traces.
Coverage gaps: 14 requirements have no citing symbol. The largest untraced groups are REQ-027-* (14). 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 56).
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-027-001 |
no | JuniorVolk defined as subclass of BaseVolk in orchestrata-agents | 1 |
REQ-027-002 |
no | JuniorVolk alias set to J:Junior |
1 |
REQ-027-003 |
no | JuniorVolk role set to Junior Developer |
1 |
REQ-027-004 |
no | JuniorVolk initialises workspace from PROJECT_WORKSPACE_ROOT |
1 |
REQ-027-005 |
no | JuniorVolk initialises files_created as empty list |
1 |
REQ-027-006 |
no | JuniorVolk initialises junior_output as None |
1 |
REQ-027-007 |
no | process(packet) routes design_review subject to _handle_design_review() |
1 |
REQ-027-008 |
no | process(packet) routes implement subject to _handle_implement() |
1 |
REQ-027-009 |
no | process(packet) returns None for unrecognised subjects |
1 |
REQ-027-010 |
no | process(packet) extracts graph context from packet payload via extract_graph_context() |
1 |
REQ-027-011 |
no | _handle_design_review() sets status = WorkStatus.IN_PROGRESS on entry |
1 |
REQ-027-012 |
no | _handle_design_review() reads design_cycle from packet.payload (default 1) |
1 |
REQ-027-013 |
no | _handle_design_review() sets current_thread from packet.thread_id |
1 |
REQ-027-014 |
no | When design_cycle >= MAX_DESIGN_REVIEW_CYCLES, _auto_ready() is called without invoking the LLM |
1 |
REQ-027-015 |
no | When design_cycle < MAX_DESIGN_REVIEW_CYCLES, LLM is called via _call_design_review_llm() |
1 |
REQ-027-016 |
no | LLM response appended to output_artifacts with section header |
1 |
REQ-027-017 |
no | DESIGN_REVIEW_PROMPT contains checklist items C1 through C7 |
none |
REQ-027-018 |
no | C1 covers Import Paths (exact package path for every file in FILE_TREE) | none |
REQ-027-019 |
no | C2 covers Function Signatures (complete signature for every public function) | none |
REQ-027-020 |
no | C3 covers Dependency Graph (implementation order determinable) | none |
REQ-027-021 |
no | C4 covers pyproject.toml (all third-party dependencies named) | none |
REQ-027-022 |
no | C5 covers FILE_TREE vs API_SPEC consistency (every file has an API entry) | none |
REQ-027-023 |
no | C6 covers Error Handling and is labelled NOT blocking | none |
REQ-027-024 |
no | C7 covers Test Strategy and is labelled NOT blocking | none |
REQ-027-025 |
no | Convergence rule: Cycle 1 allows max 5 questions on C1-C5 only | none |
REQ-027-026 |
no | Convergence rule: Cycle 2 allows max 3 questions on C1-C5 only | none |
REQ-027-027 |
no | Convergence rule: Cycle 3+ forces READY verdict regardless of LLM output | none |
REQ-027-028 |
no | DESIGN_REVIEW_PROMPT instructs the LLM never to ask about C6 or C7 |
none |
REQ-027-029 |
no | DESIGN_REVIEW_PROMPT instructs the LLM never to re-ask an already-answered question |
none |
REQ-027-030 |
no | LLM called with temperature=0.0 for deterministic review output |
1 |
REQ-027-031 |
no | CODING_STANDARDS appended to DESIGN_REVIEW_PROMPT with brace-escaping |
none |
REQ-027-032 |
no | parse_questions() extracts numbered lines after QUESTIONS: as question items |
1 |
REQ-027-033 |
no | parse_questions() extracts bulleted lines (dash prefix) as question items |
2 |
REQ-027-034 |
no | parse_questions() stops extraction on first non-question non-empty line |
2 |
REQ-027-035 |
no | _build_review_response() returns READY packet when VERDICT: READY found in response |
1 |
REQ-027-036 |
no | _build_review_response() returns READY packet when no questions are parsed |
1 |
REQ-027-037 |
no | _build_review_response() returns QUESTIONS packet when questions are parsed and verdict is not READY |
1 |
REQ-027-038 |
no | design_feedback packet addressed to U:Ar |
1 |
REQ-027-039 |
no | design_feedback payload contains verdict, response, design_cycle |
1 |
REQ-027-040 |
no | design_feedback payload contains questions list only when verdict is QUESTIONS |
1 |
REQ-027-041 |
no | _auto_ready() sets status = WorkStatus.RESOLVED |
1 |
REQ-027-042 |
no | _auto_ready() sets current_thread = None |
1 |
REQ-027-043 |
no | _auto_ready() emits design_feedback packet with verdict = READY |
1 |
REQ-027-044 |
no | _auto_ready() payload response contains a human-readable auto-READY message |
1 |
REQ-027-045 |
no | _handle_implement() sets status = WorkStatus.IN_PROGRESS on entry |
1 |
REQ-027-046 |
no | _handle_implement() calls _apply_project_dir() to override workspace if project_dir is in payload |
2 |
REQ-027-047 |
no | _handle_implement() resolves driver via get_driver(volk="J:Junior", workspace=self.workspace) |
1 |
REQ-027-048 |
no | Driver execute() receives aider_prompt, files, and is_fix from packet payload |
1 |
REQ-027-049 |
no | Driver output stored in self.junior_output and appended to output_artifacts |
1 |
REQ-027-050 |
no | scan_workspace() called after driver execution to populate self.files_created |
1 |
REQ-027-051 |
no | validate_dependencies() called with workspace and files_created after scan |
1 |
REQ-027-052 |
no | Dependency issues logged via _log_deps_issues() at WARNING level |
2 |
REQ-027-053 |
no | implementation_complete packet addressed to U:Cd |
1 |
REQ-027-054 |
no | implementation_complete payload contains files_created, output, success, deps_issues |
1 |
REQ-027-055 |
no | status set to WorkStatus.RESOLVED after implementation completes |
1 |
REQ-027-056 |
no | scan_workspace() returns empty list when workspace directory does not exist |
1 |
REQ-027-057 |
no | scan_workspace() excludes hidden directories (names starting with .) |
1 |
REQ-027-058 |
no | scan_workspace() excludes __pycache__ directories |
1 |
REQ-027-059 |
no | scan_workspace() excludes directories with names starting with Module: |
1 |
REQ-027-060 |
no | scan_workspace() excludes hidden files (names starting with .) |
1 |
REQ-027-061 |
no | scan_workspace() returns paths as relative to workspace |
1 |
REQ-027-062 |
no | scan_workspace() returns paths in sorted order |
1 |
REQ-027-063 |
no | validate_dependencies() returns empty list when pyproject.toml has no declared dependencies |
2 |
REQ-027-064 |
no | validate_dependencies() skips non-.py files in files_created |
1 |
REQ-027-065 |
no | validate_dependencies() uses _parse_file() to parse each Python file AST |
3 |
REQ-027-066 |
no | validate_dependencies() skips files that cannot be parsed (None from _parse_file()) |
2 |
REQ-027-067 |
no | validate_dependencies() collects local project modules from src/ subdirectories |
2 |
REQ-027-068 |
no | validate_dependencies() calls check_dependency_declaration() per file |
3 |
REQ-027-069 |
no | Issue strings formatted as [CHECK_ID] rel_path: description |
2 |
REQ-027-070 |
yes | JuniorVolk decorated with @traces(spec="027", story="Volk Identity and Lifecycle", reqs=["REQ-027-001", "REQ-027-002", "REQ-027-003", "REQ-027-004", "REQ-027-005", "REQ-027-006"]) |
1 |
Code that traces this spec
| Module | Symbols | Requirements |
|---|---|---|
orchestrata_ultimate/agents/volks/junior/volk |
17 | 56 |
orchestrata_ultimate/verification/review/checks_correctness |
1 | 1 |
orchestrata_ultimate/verification/review/helpers |
2 | 2 |
Checklists
checklists/constitutional.md
Junior Developer Volk Constitutional Checklist
Determinism and Convergence
- [ ] CONST-027-001: The design review loop MUST terminate within
MAX_DESIGN_REVIEW_CYCLEScycles without external intervention - [ ] CONST-027-002: LLM calls for design review MUST use
temperature=0.0to produce deterministic, reproducible verdicts - [ ] CONST-027-003:
auto-READYMUST fire unconditionally whendesign_cycle >= MAX_DESIGN_REVIEW_CYCLES, regardless of design quality - [ ] CONST-027-004: Convergence rules (cycle 1 ≤ 5 questions, cycle 2 ≤ 3 questions) MUST be enforced by the prompt, not by post-processing
- [ ] CONST-027-005:
parse_questions()MUST be deterministic — same input always produces same question list
CXP Protocol Compliance
- [ ] CONST-027-006: All outbound packets MUST conform to the CXP packet format defined in SPEC-004
- [ ] CONST-027-007:
design_feedbackpackets MUST always be addressed toU:Ar - [ ] CONST-027-008:
implementation_completepackets MUST always be addressed toU:Cd - [ ] CONST-027-009:
thread_idMUST be propagated unchanged from inbound to outbound packet - [ ] CONST-027-010:
work_statuson outbound packets MUST use only validWorkStatusenum values
Separation of Concerns
- [ ] CONST-027-011: JuniorVolk MUST NOT make architectural decisions — it reviews and implements only
- [ ] CONST-027-012: JuniorVolk MUST NOT modify the design — it asks questions or proceeds
- [ ] CONST-027-013:
validate_dependencies()MUST report issues but MUST NOT block or refuse code delivery - [ ] CONST-027-014:
scan_workspace()MUST be read-only — it MUST NOT create, delete, or modify files - [ ] CONST-027-015: Driver selection MUST be delegated entirely to
get_driver()— JuniorVolk MUST NOT hardcode a backend
checklists/requirements.md
The requirement list above comes from this file; 1 of 70 checkbox items are ticked.
checklists/testing.md
Junior Developer Volk Testing Checklist
Volk Identity and Initialisation
- [ ] TEST-027-001: Instantiate JuniorVolk and verify
alias == "J:Junior" - [ ] TEST-027-002: Instantiate JuniorVolk and verify
role == "Junior Developer" - [ ] TEST-027-003: Instantiate JuniorVolk and verify
workspace == PROJECT_WORKSPACE_ROOT - [ ] TEST-027-004: Instantiate JuniorVolk and verify
files_created == [] - [ ] TEST-027-005: Instantiate JuniorVolk and verify
junior_output is None
CXP Routing
- [ ] TEST-027-006:
process()with subjectdesign_reviewcalls_handle_design_review() - [ ] TEST-027-007:
process()with subjectimplementcalls_handle_implement() - [ ] TEST-027-008:
process()with unrecognised subject returns None - [ ] TEST-027-009:
process()withdesign_reviewsubject extracts graph context from payload
Design Review — LLM Path
- [ ] TEST-027-010:
_handle_design_review()withdesign_cycle=1callscall_llmwith DESIGN_REVIEW_PROMPT - [ ] TEST-027-011:
_handle_design_review()withdesign_cycle=2callscall_llmwith DESIGN_REVIEW_PROMPT - [ ] TEST-027-012:
_handle_design_review()withdesign_cycle=1setsstatus = WorkStatus.IN_PROGRESSbefore LLM call - [ ] TEST-027-013:
_handle_design_review()appends LLM response tooutput_artifactswith cycle header - [ ] TEST-027-014: LLM response containing
VERDICT: READYproducesdesign_feedbackpacket withverdict=READY - [ ] TEST-027-015: LLM response containing questions produces
design_feedbackpacket withverdict=QUESTIONSand non-emptyquestions - [ ] TEST-027-016:
design_feedbackpacket is addressed toU:Ar - [ ] TEST-027-017:
design_feedbackpayload contains correctdesign_cycleinteger - [ ] TEST-027-018: READY verdict sets
status = WorkStatus.RESOLVEDandcurrent_thread = None - [ ] TEST-027-019: QUESTIONS verdict sets
status = WorkStatus.RESOLVEDandcurrent_thread = None
Design Review — auto-READY
- [ ] TEST-027-020:
_handle_design_review()withdesign_cycle=3triggers_auto_ready()without callingcall_llm - [ ] TEST-027-021:
_handle_design_review()withdesign_cycle=4triggers_auto_ready()without callingcall_llm - [ ] TEST-027-022:
_auto_ready()returnsdesign_feedbackpacket addressed toU:Ar - [ ] TEST-027-023:
_auto_ready()payload hasverdict=READY - [ ] TEST-027-024:
_auto_ready()setsstatus = WorkStatus.RESOLVED - [ ] TEST-027-025:
_auto_ready()setscurrent_thread = None
parse_questions
- [ ] TEST-027-026:
parse_questions()returns empty list for response with no QUESTIONS section - [ ] TEST-027-027:
parse_questions()extracts numbered questions afterQUESTIONS:line - [ ] TEST-027-028:
parse_questions()extracts bulleted questions (dash prefix) afterQUESTIONS:line - [ ] TEST-027-029:
parse_questions()stops at first non-question non-empty line - [ ] TEST-027-030:
parse_questions()returns empty list for response withVERDICT: READYonly - [ ] TEST-027-031:
parse_questions()handles empty string input without raising
_build_review_response
- [ ] TEST-027-032:
_build_review_response()returns READY packet whenVERDICT: READYappears in response - [ ] TEST-027-033:
_build_review_response()returns READY packet whenparse_questions()returns empty list - [ ] TEST-027-034:
_build_review_response()returns QUESTIONS packet when questions are non-empty and no READY verdict - [ ] TEST-027-035: QUESTIONS packet payload contains
questionskey with list of strings
_build_review_prompt
- [ ] TEST-027-036:
_build_review_prompt()includesarchitecturevalue from payload - [ ] TEST-027-037:
_build_review_prompt()includesrequirementsvalue from payload - [ ] TEST-027-038:
_build_review_prompt()includesfile_treevalue from payload - [ ] TEST-027-039:
_build_review_prompt()includesapi_specvalue from payload - [ ] TEST-027-040:
_build_review_prompt()includesclass_diagramsection when class_diagram is present - [ ] TEST-027-041:
_build_review_prompt()omits class_diagram section when field is absent
Implementation — Core Flow
- [ ] TEST-027-042:
_handle_implement()withproject_dirin payload setsself.workspaceto that value - [ ] TEST-027-043:
_handle_implement()withoutproject_dirin payload leavesself.workspaceunchanged - [ ] TEST-027-044:
_handle_implement()callsget_driver()withvolk="J:Junior"and currentworkspace - [ ] TEST-027-045:
_handle_implement()passesaider_prompt,files,is_fixfrom payload todriver.execute() - [ ] TEST-027-046:
_handle_implement()stores driver output inself.junior_output - [ ] TEST-027-047:
_handle_implement()appends driver output tooutput_artifacts - [ ] TEST-027-048:
_handle_implement()callsscan_workspace()and stores result inself.files_created - [ ] TEST-027-049:
_handle_implement()callsvalidate_dependencies()with workspace and files_created - [ ] TEST-027-050:
_handle_implement()logs dependency issues whendeps_issuesis non-empty - [ ] TEST-027-051:
implementation_completepacket is addressed toU:Cd - [ ] TEST-027-052:
implementation_completepayload containsfiles_created,output,success,deps_issues - [ ] TEST-027-053:
statusisWorkStatus.RESOLVEDafter_handle_implement()completes
scan_workspace
- [ ] TEST-027-054:
scan_workspace()with non-existent path returns empty list - [ ] TEST-027-055:
scan_workspace()returns relative paths (not absolute) - [ ] TEST-027-056:
scan_workspace()returns sorted list - [ ] TEST-027-057:
scan_workspace()excludes hidden directories (.git,.venv) - [ ] TEST-027-058:
scan_workspace()excludes__pycache__directories - [ ] TEST-027-059:
scan_workspace()excludes directories starting withModule: - [ ] TEST-027-060:
scan_workspace()excludes hidden files (.DS_Store,.gitignore) - [ ] TEST-027-061:
scan_workspace()includes all non-hidden files in non-excluded directories - [ ] TEST-027-062:
scan_workspace()returns empty list for empty workspace directory
validate_dependencies
- [ ] TEST-027-063:
validate_dependencies()returns empty list when no pyproject.toml exists - [ ] TEST-027-064:
validate_dependencies()returns empty list when pyproject.toml has no dependencies - [ ] TEST-027-065:
validate_dependencies()skips non-.py files infiles_created - [ ] TEST-027-066:
validate_dependencies()skips files that fail AST parsing - [ ] TEST-027-067:
validate_dependencies()returns issue strings for undeclared third-party imports - [ ] TEST-027-068:
validate_dependencies()returns empty list when all imports are declared - [ ] TEST-027-069: Issue strings match format
[CHECK_ID] rel_path: description - [ ] TEST-027-070:
validate_dependencies()excludes local project modules fromsrc/in issue detection
Edge Cases
- [ ] TEST-027-071:
process()with empty payload dict does not raise - [ ] TEST-027-072:
_handle_design_review()with missingdesign_cyclekey defaults to cycle 1 - [ ] TEST-027-073:
_handle_implement()with missingaider_promptpasses empty string to driver - [ ] TEST-027-074:
_handle_implement()with missingfilespasses empty list to driver - [ ] TEST-027-075:
_handle_implement()with missingis_fixpasses False to driver - [ ] TEST-027-076:
scan_workspace()with workspace containing only hidden files returns empty list - [ ] TEST-027-077:
validate_dependencies()with emptyfiles_createdlist returns empty list - [ ] TEST-027-078:
parse_questions()with only a QUESTIONS header and no following lines returns empty list
Other tracked files
specs/027-junior-volk/README.mdspecs/027-junior-volk/compliance-audit.md
Full spec text
Verbatim from specs/027-junior-volk/spec.md; headings are pushed down two levels.
SPEC-027: Junior Developer Volk
Metadata
- Spec ID: 027-junior-volk
- Title: Junior Developer Volk (J:Junior)
- Author: Mohamed
- Status: Implemented
- Created: 2026-04-04
- Last Updated: 2026-04-09
- Priority: P1
- Version: 1.0.0
Overview
What
The Junior Developer Volk (J:Junior) is the code generation agent in Orchestrata. It reviews architecture designs by asking structured blocking questions through a converging review cycle, then generates implementation code using the configured driver backend (orchestrata-drivers). After generation it scans the workspace and validates all generated Python file imports against the project pyproject.toml.
Why
- Code generation requires a deliberate review gate before implementation to avoid building on incomplete designs
- Unconstrained question loops block delivery — convergence rules enforce a deterministic end state
- Dependency validation catches undeclared third-party imports before the code reaches CI
- A standardised volk interface (BaseVolk + CXP) keeps the orchestration pipeline composable and governable
How
- JuniorVolk extends BaseVolk and receives CXP packets on two subjects:
design_reviewandcode_generate design_reviewinvokes DESIGN_REVIEW_PROMPT (7-item checklist C1-C7) viallm.call()with temperature 0.0- Convergence rules cap questions: cycle 1 ≤ 5 questions (C1-C5 only), cycle 2 ≤ 3 questions, cycle 3+ auto-READY
code_generatecallsDriverFactory.get_driver()from orchestrata-drivers, executes the aider prompt, then runsscan_workspace()andvalidate_dependencies()- Results are sent via CXP:
design_review/resultto U:Ar,code_generate/resultto U:Cd
User Scenarios
US-001: Architect Triggers Design Review
- As a Architect (U:Ar)
- I want to submit an architecture design packet to JuniorVolk for review
- So that I can identify blocking implementation gaps before code generation begins
Acceptance Criteria:
- [ ] CXP packet with subject
design_reviewis routed to JuniorVolk - [ ] LLM returns either READY or QUESTIONS verdict
- [ ] If QUESTIONS, blocking questions reference specific checklist items (C1-C5)
- [ ] Convergence rules enforce termination within 3 cycles
US-002: Code Director Requests Code Generation
- As a Code Director (U:Cd)
- I want to request code generation after design approval
- So that implementation files are created in the workspace
Acceptance Criteria:
- [ ] CXP packet with subject
code_generatetriggers driver backend - [ ] Generated files are written to configured workspace
- [ ] scan_workspace() returns sorted list of created files
- [ ] validate_dependencies() checks all Python imports against pyproject.toml
US-003: JuniorVolk Detects Undeclared Dependencies
- As a JuniorVolk
- I want to validate generated Python files for undeclared dependencies
- So that CI failures due to missing imports are caught early
Acceptance Criteria:
- [ ] AST parsing extracts all import statements from generated .py files
- [ ] Imports cross-referenced against pyproject.toml declared dependencies
- [ ] Local project modules in src/ subdirectories are recognized as valid
- [ ] Undeclared dependencies reported in result packet to U:Cd
Terminology
| Term | Definition |
|---|---|
| Design Review | A structured LLM-driven analysis of an architecture design packet to identify blocking implementation gaps |
| Convergence Rules | Hard limits on question count per cycle that guarantee the review loop terminates within 3 cycles |
| DESIGN_REVIEW_PROMPT | The system prompt containing the 7-item review checklist (C1-C7) and convergence rules |
| READY | Verdict returned by the LLM (or forced by auto-READY) indicating the design is sufficient to implement |
| QUESTIONS | Verdict returned when the LLM identifies blocking gaps; includes structured numbered questions referencing C1-C5 |
| Design Cycle | Integer tracking how many review iterations have occurred on a given design; sourced from CXP packet |
| auto-READY | Forced READY verdict emitted when cycle >= 3 without consulting the LLM |
| Driver Backend | The code generation engine resolved via DriverFactory from orchestrata-drivers (e.g. aider) |
| workspace | Absolute path to the project directory where generated files are written; defaults to PROJECT_WORKSPACE_ROOT |
| scan_workspace | Module-level function that walks the workspace tree and returns sorted relative paths of created files |
| validate_dependencies | Module-level function that parses generated .py files and checks imports against pyproject.toml declared deps |
| C1-C7 | Checklist item identifiers in DESIGN_REVIEW_PROMPT: C1=Import Paths, C2=Function Signatures, C3=Dependency Graph, C4=pyproject.toml, C5=File Tree consistency, C6=Error Handling (non-blocking), C7=Test Strategy (non-blocking) |
| aider_prompt | The natural language prompt passed to the driver backend instructing it what code to write |
Data Models
JuniorVolkState
{
"current_cycle": {
"type": "integer",
"minimum": 1,
"maximum": 3,
"description": "Current design review cycle"
},
"design_approved": {
"type": "boolean",
"description": "Whether the design has been approved"
},
"pending_questions": {
"type": "array",
"items": {
"type": "string"
},
"description": "Blocking questions from last review cycle"
}
}
DesignReviewPacket (Inbound)
{
"subject": "design_review",
"payload": {
"architecture_narrative": {
"type": "string",
"required": true,
"description": "Architecture narrative"
},
"feature_requirements": {
"type": "string",
"required": true,
"description": "Feature requirements"
},
"file_module_layout": {
"type": "string",
"required": true,
"description": "Proposed file/module layout"
},
"function_signatures": {
"type": "string",
"required": true,
"description": "Function signatures and API contracts"
},
"class_diagram": {
"type": "string",
"required": false,
"description": "Optional class relationship diagram"
},
"cycle": {
"type": "integer",
"required": false,
"default": 1,
"description": "Current cycle number"
}
}
}
CodeGeneratePacket (Inbound)
{
"subject": "code_generate",
"payload": {
"instruction": {
"type": "string",
"required": true,
"description": "Natural language instruction for driver"
},
"existing_files": {
"type": "array",
"items": {"type": "string"},
"required": false,
"description": "Existing files to pass to driver"
},
"is_bugfix": {
"type": "boolean",
"required": false,
"default": false,
"description": "True if this is a bug-fix pass"
},
"workspace_override": {
"type": "string",
"required": false,
"description": "Override workspace path"
}
}
}
DesignReviewResultPacket (Outbound)
{
"subject": "design_review/result",
"destination": "U:Ar",
"payload": {
"verdict": {
"type": "string",
"enum": ["READY", "QUESTIONS"],
"description": "Review verdict"
},
"llm_response": {
"type": "string",
"description": "Full LLM response text"
},
"cycle": {
"type": "integer",
"description": "Cycle number at time of response"
},
"blocking_questions": {
"type": "array",
"items": {"type": "string"},
"description": "Blocking questions (only when verdict=QUESTIONS)"
}
}
}
CodeGenerateResultPacket (Outbound)
{
"subject": "code_generate/result",
"destination": "U:Cd",
"payload": {
"files_created": {
"type": "array",
"items": {"type": "string"},
"description": "Sorted relative paths of generated files"
},
"driver_output": {
"type": "string",
"description": "Raw driver backend output"
},
"success": {
"type": "boolean",
"description": "Whether the driver reported success"
},
"dependency_issues": {
"type": "array",
"items": {"type": "string"},
"description": "Undeclared dependency issues (null if none)"
}
}
}
Functional Requirements
FR-001: Design Review Trigger
JuniorVolk MUST accept inbound CXP packets with subject design_review containing architecture design information.
FR-002: LLM-Driven Review Analysis
JuniorVolk MUST invoke DESIGN_REVIEW_PROMPT via LLM with temperature 0.0 to ensure deterministic output.
FR-003: Checklist Evaluation
JuniorVolk MUST evaluate all C1-C5 blocking items and may consider C6-C7 non-blocking items per DESIGN_REVIEW_PROMPT.
FR-004: Convergence Enforcement
JuniorVolk MUST enforce convergence rules: cycle 1 max 5 questions (C1-C5), cycle 2 max 3 questions, cycle 3+ auto-READY.
FR-005: Question Parsing
JuniorVolk MUST parse QUESTIONS verdict to extract numbered and bulleted questions from LLM response text.
FR-006: Code Generation Trigger
JuniorVolk MUST accept inbound CXP packets with subject code_generate containing natural language instructions.
FR-007: Driver Backend Execution
JuniorVolk MUST resolve and execute code generation via DriverFactory from orchestrata-drivers.
FR-008: Workspace Scanning
JuniorVolk MUST execute scan_workspace() after code generation to enumerate created files.
FR-009: Dependency Validation
JuniorVolk MUST execute validate_dependencies() to check generated Python imports against pyproject.toml.
FR-010: Result Reporting
JuniorVolk MUST send result packets to appropriate destinations (U:Ar for design_review, U:Cd for code_generate).
FR-011: Auto-READY Enforcement
JuniorVolk MUST emit READY verdict without LLM call when cycle >= 3.
FR-012: Error Handling
JuniorVolk MUST handle driver failures gracefully and report error status in result packets.
Error Conditions
| ID | Condition | Handling |
|---|---|---|
| ERR-001 | Malformed design_review packet (missing required fields) | Reject packet, return error to U:Ar |
| ERR-002 | LLM call timeout (>60s) | Retry once, then return error verdict |
| ERR-003 | Invalid cycle number (non-integer or <1) | Default to cycle 1 |
| ERR-004 | Malformed code_generate packet | Reject packet, return error to U:Cd |
| ERR-005 | Driver backend failure | Report failure in result, include driver error message |
| ERR-006 | Workspace directory not accessible | Return error in files_created, include path issue |
| ERR-007 | pyproject.toml not found in workspace | Skip validation, return null dependency_issues |
| ERR-008 | AST parsing failure for generated file | Skip file, add to dependency_issues as "PARSE_ERROR" |
| ERR-009 | Undeclared third-party import detected | Add to dependency_issues list |
| ERR-010 | Max cycles exceeded without convergence | Force auto-READY, log warning |
| ERR-011 | CXP routing failure (unknown subject) | Reject packet, log error |
| ERR-012 | Missing DESIGN_REVIEW_PROMPT | Raise configuration error at startup |
| ERR-013 | DriverFactory resolution failure | Report in result packet |
| ERR-014 | Question parsing finds no valid questions | Default to auto-READY |
| ERR-015 | Missing instruction in code_generate | Reject packet with validation error |
API Contracts
JuniorVolk Class
class JuniorVolk(BaseVolk):
def __init__(self, config: JuniorVolkConfig) -> None:
"""Initialize JuniorVolk with configuration."""
async def handle_design_review(self, packet: CXPPacket) -> CXPPacket:
"""Process design review request.
Args:
packet: CXP packet with subject 'design_review'
Returns:
CXP packet with subject 'design_review/result'
"""
async def handle_code_generate(self, packet: CXPPacket) -> CXPPacket:
"""Process code generation request.
Args:
packet: CXP packet with subject 'code_generate'
Returns:
CXPPacket with subject 'code_generate/result'
"""
Module Functions
def scan_workspace(workspace: str) -> List[str]:
"""Walk workspace directory and return sorted relative file paths.
Args:
workspace: Absolute path to project directory
Returns:
Sorted list of relative file paths
Exclusions:
- Hidden directories (starting with .)
- __pycache__ directories
- Directories starting with test_
"""
def validate_dependencies(workspace: str, files_created: List[str]) -> List[str]:
"""Validate Python imports against pyproject.toml.
Args:
workspace: Absolute path to project directory
files_created: List of relative file paths to validate
Returns:
List of issue strings (null if no issues)
Issue Format:
- "{file}:{line}: Undeclared import: {module}"
- "{file}: PARSE_ERROR: {error_message}"
"""
Non-Functional Requirements
Performance Targets
| Operation | Target (P95) |
|---|---|
| Design review LLM call | < 30s |
| auto-READY (no LLM) | < 5ms |
| Driver code generation | < 5min |
| scan_workspace (1000 files) | < 100ms |
| validate_dependencies (50 files) | < 2s |
Scalability
- JuniorVolk MUST handle concurrent design review and code generation requests
- Workspace scan MUST support directories with 10,000+ files
Reliability
- LLM calls MUST be retried once on timeout before failing
- All file operations MUST use absolute paths to prevent path confusion
Technical Design
Component Diagram
┌─────────────────────────────────────────────────────────────────┐
│ Orchestrata │
│ │
│ ┌──────────────┐ design_review ┌──────────────────┐ │
│ │ U:Ar │─────────────────────▶│ │ │
│ │ (Architect) │ │ JuniorVolk │ │
│ │ │◀─────────────────────│ (J:Junior) │ │
│ └──────────────┘ design_review/result│ │ │
│ │ │ │
│ ┌──────────────┐ code_generate │ │ │
│ │ U:Cd │───────────────────────────│ │ │
│ │(Code Director) │ │ │
│ │ │◀──────────────────────────│ │ │
│ └──────────────┘ code_generate/result └──────┬──────┘ │
│ │ │
│ ▼ │
│ ┌────────────────────────────────┐│
│ │ orchestrata-drivers ││
│ │ (DriverFactory: aider) ││
│ └────────────────────────────────┘│
│ │
└─────────────────────────────────────────────────────────────────┘
Class Structure
JuniorVolk (extends BaseVolk)
├── __init__(config: JuniorVolkConfig)
├── handle_design_review(packet: CXPPacket) -> CXPPacket
├── handle_code_generate(packet: CXPPacket) -> CXPPacket
├── _call_llm_for_review(design_packet: DesignReviewData) -> LLMResponse
├── _parse_questions(llm_response: str) -> List[str]
├── _enforce_convergence(cycle: int, questions: List[str]) -> str
└── _execute_driver(instruction: str, files: List[str], is_bugfix: bool) -> DriverResult
Module Functions (standalone)
├── scan_workspace(workspace: str) -> List[str]
└── validate_dependencies(workspace: str, files_created: List[str]) -> List[str]
Convergence Rules Implementation
CONVERGENCE_RULES = {
1: {"max_questions": 5, "allowed_items": ["C1", "C2", "C3", "C4", "C5"]},
2: {"max_questions": 3, "allowed_items": ["C1", "C2", "C3", "C4", "C5"]},
3: {"auto_ready": True}
}
Examples
Example 1: Design Review - READY Verdict
Inbound Packet:
{
"subject": "design_review",
"payload": {
"architecture_narrative": "Microservice for user authentication...",
"feature_requirements": "JWT tokens, refresh mechanism...",
"file_module_layout": "src/auth/, src/api/, src/models/",
"function_signatures": "def authenticate(username, password) -> User",
"cycle": 1
}
}
Outbound Packet:
{
"subject": "design_review/result",
"destination": "U:Ar",
"payload": {
"verdict": "READY",
"llm_response": "All blocking items C1-C5 are satisfied...",
"cycle": 1,
"blocking_questions": []
}
}
Example 2: Design Review - QUESTIONS Verdict
Outbound Packet:
{
"subject": "design_review/result",
"destination": "U:Ar",
"payload": {
"verdict": "QUESTIONS",
"llm_response": "The following blocking issues were identified...",
"cycle": 1,
"blocking_questions": [
"C1: Import Paths - What is the exact package path for src/api/?",
"C4: pyproject.toml - Which third-party dependencies are required?"
]
}
}
Example 3: Code Generation Success
Outbound Packet:
{
"subject": "code_generate/result",
"destination": "U:Cd",
"payload": {
"files_created": [
"src/auth/__init__.py",
"src/auth/jwt.py",
"src/models/user.py"
],
"driver_output": "Created 3 files...",
"success": true,
"dependency_issues": []
}
}
Security
Input Validation
- All CXP packet payloads MUST be validated against schema before processing
- Architecture narrative and instruction fields MUST be truncated at 50,000 characters
- File paths in scan_workspace MUST be validated to remain within workspace bounds
Workspace Access
- JuniorVolk MUST only access files within configured workspace directory
- Path traversal attacks MUST be prevented by validating all file paths
Audit Logging
- All design review requests MUST be logged with cycle number
- All code generation requests MUST be logged with file count
- All dependency validation failures MUST be logged
Governance
PAM++ Integration
- JuniorVolk MUST be governed by PAM++ (SPEC-007a)
- Execution MUST follow authorized workflow patterns
- Resource limits MUST be enforced per governance policy
Traceability
- All CXP packets MUST include trace IDs for debugging
- JuniorVolk MUST emit trace events for key operations
Visual Architecture
Class Diagram
Diagram source shown as text: Mermaid could not parse it (Error: Parse error on line 15:).
classDiagram-direction LR
class ArchitectAgent {
$agent_type: ClassVar[str] = 'U:Ar'
---
+__init__(model: str = 'claude-3-5-haiku', agent_name: str = '')
+async analyze_impact(file_path: str, old_string: str, new_string: str, context: dict[str, Any] | None = None): dict[str, Any]
+async design_solution(requirements: dict[str, Any]): dict[str, Any]
+async review_architecture(architecture: dict[str, Any]): dict[str, Any]
}
class BaseAgent <<pydantic>> {
-model: str = Field(default='claude-3-5-haiku', description='Model identifier for the agent', min_length=1, strict=True)
-agent_id: str = Field(default='', description='Unique agent identifier', strict=True)
-agent_name: str = Field(default='', description='Human-readable agent name', strict=True)
$agent_type: ClassVar[str] = 'U:Base'
$_instance_counters: ClassVar[dict[str, int]] = {}
---
{@classmethod} +validate_model(v: str): str
+__init__(**data: Any): None
#_generate_unique_id(): str
+model_post_init(__context: Any): None
+async receive_message(message: Any, sender: str | None = None): Any
}
class CodeDirectorAgent {
$agent_type: ClassVar[str] = 'U:Cd'
---
+__init__(model: str = 'claude-3-5-sonnet', agent_name: str = '')
+async execute_edit(file_path: str, old_string: str, new_string: str, context: dict[str, Any] | None = None): dict[str, Any]
+async review_code(code: str, requirements: dict[str, Any]): dict[str, Any]
+async implement_feature(spec: dict[str, Any]): dict[str, Any]
}
class QualityAssuranceAgent {
$agent_type: ClassVar[str] = 'U:Qa'
---
+__init__(model: str = 'claude-3-5-sonnet', agent_name: str = '')
+async review_edit(file_path: str, old_string: str, new_string: str, context: dict[str, Any] | None = None): dict[str, Any]
+async run_tests(test_suite: str): dict[str, Any]
+async audit_security(code: str): dict[str, Any]
}
class UserExperienceAgent {
$agent_type: ClassVar[str] = 'U:Ux'
---
+__init__(model: str = 'claude-3-5-haiku', agent_name: str = '')
+async review_ux(file_path: str, old_string: str, new_string: str, context: dict[str, Any] | None = None): dict[str, Any]
+async design_ui(requirements: dict[str, Any]): dict[str, Any]
+async evaluate_accessibility(ui: dict[str, Any]): dict[str, Any]
}
BaseAgent <|-- ArchitectAgent
BaseModel <|-- BaseAgent
BaseAgent <|-- CodeDirectorAgent
BaseAgent <|-- QualityAssuranceAgent
BaseAgent <|-- UserExperienceAgent
Dependencies
| Package | Version | Purpose |
|---|---|---|
| orchestrata-core | latest | BaseVolk, CXPPacket, WorkStatus, PROJECT_WORKSPACE_ROOT, CODING_STANDARDS, traces |
| orchestrata-agents | latest | BaseVolk base class |
| orchestrata-cxp | latest | CXPPacket, WorkStatus |
| orchestrata-llm | latest | LLM client for design review LLM calls |
| orchestrata-drivers | latest | DriverFactory for code generation backend |
| orchestrata-verification | latest | scan_workspace, validate_dependencies |
| Python | 3.14t | Runtime |
Testing
Unit Tests
- Test question parsing for numbered and bulleted formats
- Test convergence rule enforcement for all cycle values
- Test validate_dependencies with mock pyproject.toml
Integration Tests
- Test CXP packet routing for design_review subject
- Test CXP packet routing for code_generate subject
- Test end-to-end design review flow with mock LLM
Test Scenarios
- TC-001: Design review with READY verdict
- TC-002: Design review with QUESTIONS verdict
- TC-003: Code generation with success
- TC-004: Code generation with driver failure
- TC-005: Dependency validation with undeclared import
- TC-006: Auto-READY enforcement at cycle 3
Integration Points
Inbound
- U:Ar (Architect): Sends
design_reviewpackets - U:Cd (Code Director): Sends
code_generatepackets
Outbound
- U:Ar: Receives
design_review/resultpackets - U:Cd: Receives
code_generate/resultpackets
External
- orchestrata-drivers: Provides DriverFactory for code generation
- LLM Provider: Provides design review analysis via orchestrata-llm
Success Criteria
Core Functionality
- [ ] JuniorVolk processes design_review packets and returns valid verdicts
- [ ] Convergence rules enforce termination within 3 cycles
- [ ] Code generation creates files in workspace
- [ ] Dependency validation detects undeclared imports
Quality
- [ ] All FR-001 through FR-012 implemented
- [ ] All ERR-001 through ERR-015 error conditions handled
- [ ] Performance targets met for all operations
Integration
- [ ] CXP protocol correctly implemented
- [ ] Trace events emitted for key operations
- [ ] PAM++ governance integration functional
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 | Author | Changes |
|---|---|---|---|
| 1.0.0 | 2026-04-04 | Mohamed | Initial implementation |
| 1.0.1 | 2026-04-09 | Mohamed | Added User Scenarios, Data Models, Functional Requirements, Error Conditions, Examples, Security, Governance, Testing sections per SPEC_STANDARD.md |