Orchestrata Ultimate / Specs / 030-architect-volk
030-architect-volk: Architect Volk (U:Ar)
U:Ar is the Architect volk — the design authority in the Orchestrata pipeline. It receives validated requirements from U:PM (or UX artifacts from U:Ux) and produces five structured architecture artifacts: an architecture document, a file tree, an API spec, a class diagram, and a requirements document. It uses call_reasoner() — a reasoning-tier LLM (deepseek-reasoner or Claude Opus) — to perform deep architectural thinking via structured chain-of-thought decomposition. Designs are reviewed...
At a glance
| Item | Value |
|---|---|
| Spec directory | specs/030-architect-volk/ |
| Status line in the spec | Implemented |
| Requirement IDs defined | 45 |
With a @traces citation in src/ |
43 (95.6%) |
With a @traces citation in tests/ |
0 (0.0%) |
| Tracked files | 6 |
| RTM page | 030-architect-volk |
Reading this spec
U:Ar, the Architect Volk, is the design authority in the Orchestrata pipeline. It receives validated requirements from U:PM (or UX artifacts from U:Ux) and produces five structured artifacts: an architecture document, a file tree, an API spec, a class diagram and a requirements document. It does this with call_reasoner(), a reasoning-tier LLM call (deepseek-reasoner or Claude Opus) that uses structured chain-of-thought decomposition. Without it, generated projects have no coherent architecture, juniors lack unambiguous contracts and the architect would re-invent types that already exist.
The scope is eight user stories: initial architecture generation, the design feedback loop, monorepo context injection, project scaffold creation and design escalation to the CodeDirector (critical), and UX design integration, structured requirements propagation and graceful degradation (high). Requirement IDs use the REQ-030- prefix.
The flow stated in the overview is as follows. U:PM sends scope_validated (or U:Ux sends ux_complete). U:Ar queries Neo4j for existing monorepo types and the project tree, calls the reasoner with its prompt template and the injected context, and parses the response into five sections: ARCHITECTURE, REQUIREMENTS, FILE_TREE, API_SPEC and CLASS_DIAGRAM. The design docs are written to the project's design/ directory and committed to git. U:Ar sends a design_review packet to J:Junior and iterates on the junior's feedback, using an update template, until the verdict is READY or the design cycles reach MAX_DESIGN_CYCLES. It then escalates to U:Cd with an implement packet carrying all five artifacts and the monorepo context.
In the code, the largest tracers are orchestrata_ultimate/agents/volks/architect/volk, orchestrata_ultimate/agents/volks/architect/architect_project and orchestrata_ultimate/agents/volks/architect/architect_context. The per-requirement view is on the RTM page.
The spec's status line reads Implemented. It tracks 6 files and defines 45 requirement IDs. The full text follows below.
Measured coverage is 43 of 45 requirements cited by at least one @traces in src/ (95.6%), spread over 3 modules; the module citing the most of them is orchestrata_ultimate/agents/volks/architect/volk (25 requirements). In tests/, 0 requirements are cited by a test-side @traces.
Coverage gaps: 2 requirements have no citing symbol. The largest untraced groups are REQ-030-* (2). 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 43).
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-030-001 |
yes | U:Ar processes CXP packets with subjects: implement, scope_validated, ux_complete, design_feedback |
1 |
REQ-030-002 |
yes | U:Ar returns None for unrecognized CXP subjects | 1 |
REQ-030-003 |
yes | _handle_design() extracts requirements, task_summary, original_intent, ux_design, scope_data from packet payload |
1 |
REQ-030-004 |
yes | _handle_design() resolves project_name from project_name payload field or slugified task_summary |
1 |
REQ-030-005 |
yes | _handle_design() initialises the project directory before calling the LLM |
1 |
REQ-030-006 |
yes | _handle_design() calls call_reasoner() with ARCHITECT_PROMPT_TEMPLATE injected with task_summary, requirements, original_spec_section, monorepo_src_section |
2 |
REQ-030-007 |
yes | _handle_design() parses LLM response into five sections via _parse_design() |
2 |
REQ-030-008 |
yes | _handle_design() writes parsed sections to {project_dir}/design/ via _write_design_docs() |
none |
REQ-030-009 |
yes | _handle_design() sets design_cycles = 1 and sends design_review CXP to J:Junior |
1 |
REQ-030-010 |
yes | _handle_feedback() reads verdict, questions, and design_cycle from packet payload |
1 |
REQ-030-011 |
yes | _handle_feedback() calls _finalize_design() when verdict == "READY" |
1 |
REQ-030-012 |
yes | _handle_feedback() calls _finalize_design() when cycle >= MAX_DESIGN_CYCLES |
1 |
REQ-030-013 |
yes | _handle_feedback() calls _iterate_design() when verdict != "READY" and cycle < MAX_DESIGN_CYCLES |
1 |
REQ-030-014 |
yes | _finalize_design() sends implement CXP to U:Cd (escalation_target) |
1 |
REQ-030-015 |
yes | _finalize_design() includes all five design artifacts plus 5 additional context fields in payload |
1 |
REQ-030-016 |
yes | _finalize_design() calls _git_commit() with cycle-count message before sending |
1 |
REQ-030-017 |
yes | _iterate_design() calls call_reasoner() with ARCHITECT_UPDATE_TEMPLATE |
1 |
REQ-030-018 |
yes | _iterate_design() formats questions as numbered list for prompt injection |
1 |
REQ-030-019 |
yes | _iterate_design() increments design_cycles and writes updated docs before returning design_review CXP |
1 |
REQ-030-020 |
yes | _make_review_packet() constructs CXP with subject design_review addressed to J:Junior |
1 |
REQ-030-021 |
yes | _make_review_packet() includes all five design artifacts plus design_cycle and project context |
1 |
REQ-030-022 |
yes | _parse_design() extracts sections using ordered markers: ARCHITECTURE:, REQUIREMENTS:, FILE_TREE:, API_SPEC:, CLASS_DIAGRAM: |
1 |
REQ-030-023 |
yes | _parse_design() handles missing sections gracefully (skips absent markers) |
1 |
REQ-030-024 |
yes | _write_design_docs() writes all five artifacts as separate .md files if content non-empty |
1 |
REQ-030-025 |
yes | _load_structured_fields() extracts structured_requirements, user_stories, nfrs, spec_metadata, analyst_output |
1 |
REQ-030-026 |
yes | _load_structured_fields() prints impact report if _impact_report present in parameters field |
1 |
REQ-030-027 |
yes | _resolve_project_name() uses concierge-supplied project_name field if present |
1 |
REQ-030-028 |
yes | _resolve_project_name() falls back to _slugify(task_summary) when project_name absent |
1 |
REQ-030-029 |
yes | _slugify() produces lowercase hyphenated string, max 50 chars, with special chars stripped |
1 |
REQ-030-030 |
yes | ArchitectContextMixin._build_full_monorepo_context() assembles project tree + API source context |
2 |
REQ-030-031 |
yes | ArchitectContextMixin._build_project_tree_context() queries Neo4j for packages, modules, top classes, top functions |
2 |
REQ-030-032 |
yes | ArchitectContextMixin._build_monorepo_context() extracts CapWords from requirements text via regex |
1 |
REQ-030-033 |
yes | ArchitectContextMixin._build_monorepo_context() removes NOISE_WORDS before querying |
1 |
REQ-030-034 |
yes | ArchitectContextMixin._build_monorepo_context() queries Neo4j scoped to "orchestrata" project node |
1 |
REQ-030-035 |
yes | ArchitectContextMixin._build_monorepo_context() loads and truncates source files at 200 lines |
2 |
REQ-030-036 |
yes | ArchitectContextMixin._scan_filesystem_for_classes() scans monorepo packages as Neo4j fallback |
1 |
REQ-030-037 |
yes | ArchitectContextMixin._build_full_monorepo_context() applies brace-escaping to all context strings |
1 |
REQ-030-038 |
yes | ArchitectProjectMixin._init_project() creates 7 subdirectories in project_dir |
1 |
REQ-030-039 |
yes | ArchitectProjectMixin._init_project() writes context.json with state/deferred_work/session_history |
1 |
REQ-030-040 |
yes | ArchitectProjectMixin._init_project() runs git init in project_dir |
1 |
REQ-030-041 |
yes | ArchitectProjectMixin._init_project() creates UV venv with Python 3.14t |
1 |
REQ-030-042 |
yes | ArchitectProjectMixin._git_commit() runs git add -A then git commit -m in project_dir |
1 |
REQ-030-043 |
yes | ArchitectProjectMixin._git_commit() is a no-op when project_dir has no .git directory |
1 |
REQ-030-044 |
yes | graph_context extracted from CXP payload via extract_graph_context() and passed to call_reasoner() |
none |
REQ-030-045 |
yes | U:Ar alias is "U:Ar", role is "Architect", escalation_target is "U:Cd" | 1 |
Code that traces this spec
| Module | Symbols | Requirements |
|---|---|---|
orchestrata_ultimate/agents/volks/architect/architect_context |
10 | 9 |
orchestrata_ultimate/agents/volks/architect/architect_project |
8 | 10 |
orchestrata_ultimate/agents/volks/architect/volk |
12 | 25 |
Checklists
checklists/constitutional.md
Architect Volk (U:Ar) — Constitutional Compliance Checklist
Component: ArchitectVolk, ArchitectContextMixin, ArchitectProjectMixin Spec: 030-architect-volk Status: Compliance Review Total Compliance Items: 15
Overview
This document tracks compliance of the Architect Volk (U:Ar) with the Orchestrata Constitution. U:Ar is the design authority in the pipeline. Its constitutional obligations focus on: owning only its design artifacts (Article I), deferring governance to Prolog (Article II), maintaining session isolation per design thread (Article III), logging all design transitions (Article IV), not fabricating completed designs (Article V), producing complete artifacts before escalation (Article VI), using real LLM calls in tests (Article VII), exposing metrics on design cycle counts (Article VIII), degrading gracefully when Neo4j or tools are absent (Article IX), supporting version evolution (Article X), and maintaining this spec as the documentation authority (Article XI).
Article I: Agent Autonomy and Ownership Boundaries
Principle: U:Ar owns design artifacts within the project_dir it created. It does not modify files owned by other agents or outside its project workspace.
Compliance Requirements
- [x] CONST-030-001: U:Ar writes design artifacts exclusively to
{project_dir}/design/and never to other agents' workspaces - [x] CONST-030-002:
process()returns None for unrecognized subjects — does not attempt to handle another agent's packets - [x] CONST-030-003: U:Ar does not modify incoming CXP packets; it produces new packets only
- [x] CONST-030-004: escalation_target set at construction time ("U:Cd"); not overridden at runtime
- [x] CONST-030-005:
_git_commit()operates only within the project_dir it initialized, never in the Orchestrata monorepo
Priority: Critical Verification: Code review of volk.py and architect_project.py; assert no writes outside project_dir
Article II: Prolog as Single Source of Truth
Principle: U:Ar does not duplicate or override governance logic. Policy decisions (who may see the design, when to escalate, what constitutes a valid design) are not hardcoded.
Compliance Requirements
- [x] CONST-030-006: Design iteration cycle limit (MAX_DESIGN_CYCLES) is a configurable constant, not a Prolog-backed policy — it enforces an operational ceiling, not a governance decision
- [x] CONST-030-007: U:Ar does not evaluate Prolog predicates directly; governance enforcement is delegated to the PAM++ layer
Priority: High Verification: grep for pyswip imports in architect package; assert none found
Article III: Session Isolation
Principle: Each design thread is isolated. U:Ar's state (design_docs, design_cycles, project_dir) belongs to a single thread_id and does not leak across concurrent requests.
Compliance Requirements
- [x] CONST-030-008:
design_docs,design_cycles,project_name, andproject_dirinitialised in__init__()— each ArchitectVolk instance is thread-scoped - [x] CONST-030-009:
current_threadset from packet.thread_id at the start of each design request, ensuring context stays scoped
Priority: Critical Verification: Unit test with two concurrent packets to separate instances; assert no state cross-contamination
Article IV: Transparency and Logging
Principle: All design transitions (start, iteration, escalation) are logged. No silent drops.
Compliance Requirements
- [x] CONST-030-010: Every design phase transition is printed with agent tag
[U:Ar](start, iteration count, escalation, git commit) - [x] CONST-030-011: Forced escalation at MAX_DESIGN_CYCLES prints a warning before proceeding
Priority: Critical Verification: Capture print output in tests; assert expected phase labels present
Article V: Non-Deception
Principle: U:Ar does not claim a design is complete until all five artifacts are written to disk and committed.
Compliance Requirements
- [x] CONST-030-012:
_finalize_design()calls_write_design_docs()and_git_commit()before constructing the escalation CXP — artifacts are persisted before the claim of completion is made
Priority: Critical Verification: Integration test: assert design files exist on disk before implement CXP is returned
Article VI: Quality Gates
Principle: Designs must be complete (all five sections present) before escalation. Partial designs are not escalated silently.
Compliance Requirements
- [x] CONST-030-013:
_finalize_design()includes all five design_docs values in the implement CXP payload, including empty strings — the downstream agent sees exactly what was produced, not a filtered subset
Priority: High Verification: Assert all five keys present in finalization packet payload
Article VII: Testing Without Mocks
Principle: Tests for U:Ar use real implementations — real file I/O, real subprocess calls for git and uv, real string parsing. No mock LLM responses (use synthetic string inputs directly).
Compliance Requirements
- [x] CONST-030-014: No unittest.mock, MagicMock, patch, or AsyncMock in any test file for orchestrata-architect
- [x] CONST-030-015:
_parse_design(),_write_design_docs(),_init_project(),_git_commit(), and_slugify()tested with real file system operations in temporary directories
Priority: High
Verification: grep -r "unittest.mock\|MagicMock" packages/orchestrata-architect/ returns empty
Summary
| Article | Compliance Items | Completed | Status |
|---|---|---|---|
| I: Agent Autonomy | 5 | 5 | Complete |
| II: Prolog as Source of Truth | 2 | 2 | Complete |
| III: Session Isolation | 2 | 2 | Complete |
| IV: Transparency and Logging | 2 | 2 | Complete |
| V: Non-Deception | 1 | 1 | Complete |
| VI: Quality Gates | 1 | 1 | Complete |
| VII: Testing Without Mocks | 2 | 2 | Complete |
| TOTAL | 15 | 15 | Complete |
Last Updated: 2026-04-04 Version: 1.0.0 Maintained By: Mohamed
checklists/requirements.md
The requirement list above comes from this file; 45 of 45 checkbox items are ticked.
checklists/testing.md
Architect Volk (U:Ar) — Testing Plan
Component: ArchitectVolk, ArchitectContextMixin, ArchitectProjectMixin Spec: 030-architect-volk Status: Test Planning Phase Total Test Cases: 45
Overview
This document defines the comprehensive testing strategy for the Architect Volk (U:Ar). All tests follow the strict "no mocking" policy: real file I/O, real subprocess calls, real string parsing, and real Python object instantiation. Synthetic LLM responses are constructed as literal strings — the LLM itself is not invoked in unit tests (it is an external I/O boundary; its output is faked as a string fixture, not mocked via patch).
Test Categories Summary
| Category | Test Count | Purpose | Priority |
|---|---|---|---|
| Unit Tests | 28 | Individual function/method testing | Critical |
| Integration Tests | 12 | Multi-component workflow testing | High |
| Compliance Tests | 5 | Constitutional enforcement verification | High |
| TOTAL | 45 |
Test Infrastructure
Test File Structure
tests/
├── test_architect_volk.py # Unit: process(), _handle_design(), _handle_feedback()
├── test_architect_design.py # Unit: _parse_design(), _write_design_docs(), _make_review_packet()
├── test_architect_fields.py # Unit: _load_structured_fields(), _resolve_project_name(), _slugify()
├── test_architect_context.py # Unit: ArchitectContextMixin methods
├── test_architect_project.py # Integration: _init_project(), _write_context_json(), _git_*
└── test_architect_compliance.py # Compliance: no mocks, ownership, transparency
Synthetic LLM Response Fixture
Tests that exercise parsing use a synthetic response string — not a mock:
SYNTHETIC_RESPONSE = (
"ARCHITECTURE:\nComponent A handles X.\nComponent B handles Y.\n\n"
"REQUIREMENTS:\nFUNCTIONAL:\n1. FR-01: The system must do X.\n\n"
"FILE_TREE:\nsrc/\n├── app/\n│ └── main.py\ntests/\n└── test_main.py\n\n"
"API_SPEC:\nModule: src/app/main.py\nFunctions:\n run() -> None\n\n"
"CLASS_DIAGRAM:\nclassDiagram\n App --> Runner\n"
)
Unit Tests (28)
Process Routing (4 tests)
- [ ] TEST-030-UNIT-001:
process()routesscope_validatedto_handle_design()— verify return is design_review CXP addressed to J:Junior - [ ] TEST-030-UNIT-002:
process()routesux_completeto_handle_design()— verify identical behavior to scope_validated - [ ] TEST-030-UNIT-003:
process()routesimplementsubject to_handle_design() - [ ] TEST-030-UNIT-004:
process()returns None for unknown subject "unknown_subject"
Parse Design (5 tests)
- [ ] TEST-030-UNIT-005:
_parse_design()with well-formed 5-section response populates all five design_docs keys - [ ] TEST-030-UNIT-006:
_parse_design()with response missing FILE_TREE: marker leaves file_tree as empty string - [ ] TEST-030-UNIT-007:
_parse_design()with response missing all markers leaves all keys as empty string - [ ] TEST-030-UNIT-008:
_parse_design()correctly terminates each section at the next marker (no section bleeds into next) - [ ] TEST-030-UNIT-009:
_parse_design()strips leading/trailing whitespace from each section value
Feedback Handling (5 tests)
- [ ] TEST-030-UNIT-010:
_handle_feedback()with verdict="READY" returns implement CXP addressed to U:Cd - [ ] TEST-030-UNIT-011:
_handle_feedback()with verdict="QUESTIONS" and cycle=1 < MAX_DESIGN_CYCLES returns design_review CXP - [ ] TEST-030-UNIT-012:
_handle_feedback()with cycle >= MAX_DESIGN_CYCLES returns implement CXP regardless of verdict - [ ] TEST-030-UNIT-013:
_finalize_design()payload contains all five design artifact keys - [ ] TEST-030-UNIT-014:
_finalize_design()payload contains project_dir, task_summary, original_intent, structured_requirements, user_stories, monorepo_src_section, nfrs, spec_metadata
Iterate Design (3 tests)
- [ ] TEST-030-UNIT-015:
_iterate_design()increments design_cycles by 1 - [ ] TEST-030-UNIT-016:
_iterate_design()formats questions as numbered list in prompt (verify question text in update prompt) - [ ] TEST-030-UNIT-017:
_iterate_design()returns design_review CXP addressed to J:Junior
Review Packet (2 tests)
- [ ] TEST-030-UNIT-018:
_make_review_packet()returns CXP with subject="design_review" and to_agent="J:Junior" - [ ] TEST-030-UNIT-019:
_make_review_packet()includes design_cycle, project_dir, task_summary in payload
Structured Fields (4 tests)
- [ ] TEST-030-UNIT-020:
_load_structured_fields()extracts all five structured fields from full payload - [ ] TEST-030-UNIT-021:
_load_structured_fields()prints impact_report when_impact_reportpresent inparameters - [ ] TEST-030-UNIT-022:
_resolve_project_name()uses conciergeproject_namefield when present (slugified) - [ ] TEST-030-UNIT-023:
_resolve_project_name()falls back to slugified task_summary when project_name absent
Slugify (5 tests)
- [ ] TEST-030-UNIT-024:
_slugify("Hello World!")returns "hello-world" - [ ] TEST-030-UNIT-025:
_slugify("")returns "project" (default fallback) - [ ] TEST-030-UNIT-026:
_slugify("A" * 60)returns slug of at most 50 characters - [ ] TEST-030-UNIT-027:
_slugify("foo___bar")collapses underscores to single hyphen - [ ] TEST-030-UNIT-028:
_slugify("--leading--trailing--")strips leading and trailing hyphens
Integration Tests (12)
Project Scaffold (6 tests)
- [ ] TEST-030-INTEG-001:
_init_project()in a real temp directory creates all 7 expected subdirectories (design, src, tests, tests/unit, tests/integration, docs, requirements) - [ ] TEST-030-INTEG-002:
_init_project()writes context.json with correct schema (keys: state, deferred_work, session_history) - [ ] TEST-030-INTEG-003:
_init_project()createstests/__init__.py,tests/unit/__init__.py,tests/integration/__init__.py - [ ] TEST-030-INTEG-004:
_init_project()is idempotent — running twice on same directory does not raise and does not overwrite context.json - [ ] TEST-030-INTEG-005:
_git_commit()creates a git commit in the project_dir with expected message - [ ] TEST-030-INTEG-006:
_git_commit()is a no-op (no exception, no subprocess call) when .git directory absent
Design Doc Writing (3 tests)
- [ ] TEST-030-INTEG-007:
_write_design_docs()writes exactly 5 .md files to{project_dir}/design/when all content is non-empty - [ ] TEST-030-INTEG-008:
_write_design_docs()skips writing empty string sections (file not created) - [ ] TEST-030-INTEG-009:
_write_design_docs()produces readable UTF-8 content that matches design_docs values
Context Mixin (3 tests)
- [ ] TEST-030-INTEG-010:
_build_monorepo_context()with no CapWords in requirements (e.g., "add a task") returns empty string without crashing - [ ] TEST-030-INTEG-011:
_scan_filesystem_for_classes()with a temp directory containing a Python file with a matching class definition populates loaded dict - [ ] TEST-030-INTEG-012:
_try_load_class_file()with a 300-line Python file truncates content to 200 lines with truncation marker
Compliance Tests (5)
Constitutional Verification
- [ ] TEST-030-COMPLIANCE-001: No unittest.mock, MagicMock, patch, or AsyncMock imported in any test file for orchestrata-architect — verify via source scan
- [ ] TEST-030-COMPLIANCE-002: U:Ar writes only within project_dir —
_write_design_docs()in integration test asserts no files written outside temp dir - [ ] TEST-030-COMPLIANCE-003:
process()with unrecognized subject returns None (not exception, not empty CXP) — no silent swallowing of unknown traffic - [ ] TEST-030-COMPLIANCE-004:
_finalize_design()only returns implement CXP after_write_design_docs()succeeds — files exist on disk before packet constructed (integration test) - [ ] TEST-030-COMPLIANCE-005: MAX_DESIGN_CYCLES forced escalation prints "[U:Ar] Max design cycles" in stdout — transparency requirement met
Test Execution
Running Tests
# Run all architect tests
ci/local-ci.sh test -- -k "architect"
# Run unit tests only
uv run pytest tests/test_architect_volk.py tests/test_architect_design.py tests/test_architect_fields.py -v
# Run integration tests
uv run pytest tests/test_architect_project.py tests/test_architect_context.py -v
# Run compliance tests
uv run pytest tests/test_architect_compliance.py -v
# Run with coverage
uv run pytest tests/test_architect*.py --cov=packages/orchestrata-architect/src --cov-report=term-missing
Coverage Targets
| Module | Target | Critical Threshold |
|---|---|---|
volk.py |
95% | 90% |
architect_context.py |
90% | 85% |
architect_project.py |
95% | 90% |
architect_prompts.py |
85% | 80% |
context_builder.py |
85% | 80% |
project_init.py |
90% | 85% |
prompts.py |
80% | 75% |
| Overall | 90% | 85% |
Summary
| Category | Test Count | Completed | Progress |
|---|---|---|---|
| Unit Tests | 28 | 0 | 0% |
| Integration Tests | 12 | 0 | 0% |
| Compliance Tests | 5 | 0 | 0% |
| TOTAL | 45 | 0 | 0% |
Last Updated: 2026-04-04 Version: 1.0.0 Maintained By: Mohamed
Other tracked files
specs/030-architect-volk/README.mdspecs/030-architect-volk/compliance-audit.md
Full spec text
Verbatim from specs/030-architect-volk/spec.md; headings are pushed down two levels.
SPEC-030: Architect Volk (U:Ar)
Metadata
- Spec ID: 030-architect-volk
- Title: Architect Volk — Software Architecture & Project Scaffold Agent
- Author: Mohamed
- Status: Implemented
- Created: 2026-04-04
- Last Updated: 2026-04-04
- Priority: P0
- Components: ArchitectVolk, ArchitectContextMixin, ArchitectProjectMixin, context_builder, project_init, prompts
- Version: 1.0.0
- API Version: v1
- Compatibility: Python 3.14t, orchestrata-core >=0.7.0, orchestrata-agents >=0.7.0, Neo4j 5.x
- Package: orchestrata-architect (2,010 LOC, 9 files)
- Dependencies: orchestrata-core, orchestrata-agents, orchestrata-cxp, orchestrata-llm, orchestrata-knowledge
Overview
What
U:Ar is the Architect volk — the design authority in the Orchestrata pipeline. It receives
validated requirements from U:PM (or UX artifacts from U:Ux) and produces five structured
architecture artifacts: an architecture document, a file tree, an API spec, a class diagram,
and a requirements document. It uses call_reasoner() — a reasoning-tier LLM (deepseek-reasoner
or Claude Opus) — to perform deep architectural thinking via structured chain-of-thought
decomposition. Designs are reviewed by J:Junior in an iterative feedback loop (up to
MAX_DESIGN_CYCLES) before escalation to U:Cd (CodeDirector) for implementation.
Why
- Generated projects have no coherent architecture; files and responsibilities emerge ad-hoc
- Junior developers (J:Junior) need unambiguous contracts (signatures, types, data flow) to implement without guessing
- Without codebase context, the architect re-invents types and APIs that already exist
- Without a review loop, design mistakes cascade into implementation failures
- Without project scaffold, each project starts from zero with no standard structure
How
- U:PM sends
scope_validated(or U:Ux sendsux_complete) CXP packet to U:Ar - U:Ar queries Neo4j for existing monorepo types and project tree (ArchitectContextMixin)
- U:Ar calls
call_reasoner()with ARCHITECT_PROMPT_TEMPLATE, injecting context - LLM response is parsed into five sections: ARCHITECTURE, REQUIREMENTS, FILE_TREE, API_SPEC, CLASS_DIAGRAM
- Design docs written to
{project_dir}/design/and committed to git - U:Ar sends
design_reviewCXP to J:Junior; J:Junior responds withdesign_feedback - If verdict == "READY" or design_cycles >= MAX_DESIGN_CYCLES, escalate to U:Cd
- Otherwise, iterate using ARCHITECT_UPDATE_TEMPLATE with J:Junior's questions
- U:Cd receives
implementCXP with all five artifacts plus monorepo context
Terminology and Glossary
| Term | Definition |
|---|---|
| U:Ar | The Architect Volk — software architecture and project scaffold agent |
| U:Cd | The CodeDirector Volk — receives finalized design, drives implementation by J:Junior |
| U:PM | The PM Volk — sends scope_validated CXP to activate U:Ar |
| U:Ux | The UX Volk — sends ux_complete CXP to activate U:Ar for UI projects |
| J:Junior | The Junior Volk — reviews design artifacts and provides feedback via design_feedback CXP |
| design_review | CXP subject sent from U:Ar to J:Junior with all five design artifacts |
| design_feedback | CXP subject returned from J:Junior with verdict ("READY" / "QUESTIONS") and blocking questions |
| implement | CXP subject sent from U:Ar to U:Cd (and separately from U:PM to U:Ar) with finalized design |
| call_reasoner() | LLM client helper that invokes a reasoning-tier model (deepseek-reasoner or opus) |
| MAX_DESIGN_CYCLES | Configurable cap (default 99) on design iteration rounds before forced escalation |
| design cycle | One round of U:Ar design followed by J:Junior feedback; increments design_cycles counter |
| ArchitectContextMixin | Mixin providing Neo4j project tree and monorepo API source queries |
| ArchitectProjectMixin | Mixin providing project directory scaffold, design doc writing, git operations |
| ARCHITECT_PROMPT_TEMPLATE | Prompt template for initial architecture generation (Chain-of-Thought, 5-step methodology) |
| ARCHITECT_UPDATE_TEMPLATE | Prompt template for design iteration; incorporates current docs and J:Junior questions |
| project_dir | Absolute path to the generated project workspace on the filesystem |
| graph_context | Knowledge graph directives extracted from CXP payload via extract_graph_context() |
| scope_data | PM effort estimate and scope metadata forwarded to U:Ar in the CXP payload |
| _monorepo_src_section | Escaped brace-safe string of existing API sources injected into the design prompt |
| _slugify() | Converts task summary to a URL-safe directory name (lowercase, hyphenated, max 50 chars) |
User Scenarios & Stories
US-001: Initial Architecture Generation (Critical)
As a system operator I want a complete architecture produced from requirements before any code is written So that J:Junior implements against a coherent design with unambiguous contracts
Acceptance Criteria:
- U:Ar receives
scope_validated(orux_complete/implement) CXP and initiates design call_reasoner()called with structured 5-step chain-of-thought prompt- LLM response parsed into five sections: ARCHITECTURE, REQUIREMENTS, FILE_TREE, API_SPEC, CLASS_DIAGRAM
- All five sections written to
{project_dir}/design/as separate markdown files design_reviewCXP sent to J:Junior with all five artifacts and design cycle number- Architecture doc includes Architecture Decision Records for non-obvious choices
US-002: Design Feedback Loop (Critical)
As a system operator I want J:Junior to review the design before implementation begins So that blocking ambiguities are resolved before code is written
Acceptance Criteria:
- U:Ar receives
design_feedbackCXP with verdict and questions list - If verdict == "READY": escalate design to U:Cd via
implementCXP - If questions exist and cycles < MAX_DESIGN_CYCLES: call
call_reasoner()with ARCHITECT_UPDATE_TEMPLATE - Updated design docs written and committed after each iteration cycle
design_cyclescounter incremented on each iteration- After MAX_DESIGN_CYCLES without "READY": escalate anyway with log warning
US-003: Monorepo Context Injection (Critical)
As a architect I want existing Orchestrata APIs and types visible during design So that designed systems use real constructors and import paths, not invented ones
Acceptance Criteria:
- CapWords class names extracted from requirements text via regex
- Neo4j queried for matching classes scoped to "orchestrata" project node
- Source files loaded (capped at 200 lines each) and injected into prompt
- Filesystem fallback scan used when Neo4j is unreachable
- Project tree (packages, modules, top classes/functions) queried from Neo4j
- Combined context injected as
EXISTING API SOURCESsection in prompt - Brace-escaping applied before str.format() injection
US-004: Project Scaffold Creation (Critical)
As a developer I want a production-ready project directory created before code generation So that J:Junior has a clean workspace with proper structure from the start
Acceptance Criteria:
- Project directory created at
{PROJECT_WORKSPACE_ROOT}/{slugified_name} - Subdirectories created: design/, src/, tests/, tests/unit/, tests/integration/, docs/, requirements/
__init__.pyfiles created in tests/ directoriescontext.jsoninitialised with state/deferred_work/session_history structure- Git repository initialised with
git init - UV virtual environment created with Python 3.14t (free-threaded)
- Design finalization commits all files with descriptive message
US-005: Design Escalation to CodeDirector (Critical)
As a system operator I want finalized design forwarded to U:Cd with all artifacts So that implementation can proceed with complete context
Acceptance Criteria:
implementCXP sent to U:Cd with: architecture, requirements, file_tree, api_spec, class_diagram- CXP also carries: original_intent, project_dir, task_summary, structured_requirements, user_stories, monorepo_src_section, nfrs, spec_metadata
- WorkStatus set to IN_PROGRESS on escalation
- Design docs git-committed before escalation with cycle count in message
US-006: UX Design Integration (High)
As an architect I want UX design artifacts incorporated into the architecture So that UI projects have their component hierarchy and workflows reflected in the file tree
Acceptance Criteria:
ux_completesubject triggers same design flow asscope_validatedux_designpayload field extracted from packet- UX design injected as a labelled section in the architecture prompt
- Print confirmation when UX design is incorporated
US-007: Structured Requirements Propagation (High)
As a developer I want BA-structured requirements forwarded through the pipeline So that CodeDirector and Junior have typed requirements, not just prose
Acceptance Criteria:
structured_requirements,user_stories,nfrs,spec_metadataextracted from incoming packet_impact_reportfromparametersfield printed if present (classification, severity, affected files)- All structured fields forwarded in finalization
implementpacket to U:Cd
US-008: Graceful Degradation (High)
As a system operator I want U:Ar to continue when Neo4j or uv is unavailable So that architecture generation does not block on infrastructure failures
Acceptance Criteria:
- Neo4j connection failure returns blank string (no crash, no block)
- Filesystem scan fallback activated when Neo4j returns no results
- Filesystem scan skipped if monorepo packages directory does not exist
uv venvfailure logged at DEBUG level, not propagatedgit initfailure printed but not raised- All Neo4j operations have try/except with debug-level logging
Standardized Acceptance Criteria
| ID | Story | Criterion | Verification |
|---|---|---|---|
| AC-001 | US-001 | process() routes implement, scope_validated, ux_complete to _handle_design() |
Unit test: call process() with each subject, assert _handle_design invoked |
| AC-002 | US-001 | process() routes design_feedback to _handle_feedback() |
Unit test: call process() with design_feedback, assert _handle_feedback invoked |
| AC-003 | US-001 | Five design doc keys populated after _parse_design() |
Assert design_docs["architecture"], ["file_tree"], etc. are populated |
| AC-004 | US-001 | Design docs written to {project_dir}/design/ folder |
Assert files exist: architecture.md, requirements.md, file_tree.md, api_spec.md, class_diagram.md |
| AC-005 | US-002 | Verdict "READY" triggers escalation to U:Cd via implement CXP |
Assert return packet.to_agent == "U:Cd" and packet.subject == "implement" |
| AC-006 | US-002 | Non-READY verdict below MAX_DESIGN_CYCLES triggers design update | Assert call_reasoner called with ARCHITECT_UPDATE_TEMPLATE content |
| AC-007 | US-002 | cycle >= MAX_DESIGN_CYCLES forces escalation with warning log | Assert escalation packet sent when design_cycles >= MAX_DESIGN_CYCLES |
| AC-008 | US-002 | design_cycles incremented on each iteration | Assert design_cycles == N after N iteration rounds |
| AC-009 | US-003 | CapWords names extracted from requirements | Assert regex matches PascalCase identifiers |
| AC-010 | US-003 | Neo4j query scoped to "orchestrata" project node | Assert Cypher query contains MATCH (proj:Project {name: "orchestrata"}) |
| AC-011 | US-003 | Source files capped at 200 lines before injection | Assert truncation message appears in output >200 lines |
| AC-012 | US-003 | Brace-escaping applied to context strings | Assert {{ and }} in context passed to str.format() |
| AC-013 | US-004 | Project directories created including subdirs | Assert os.path.isdir() for all 7 subdirectories |
| AC-014 | US-004 | context.json written with correct schema | Assert JSON keys: state, deferred_work, session_history |
| AC-015 | US-004 | Git repo initialized in project_dir | Assert os.path.isdir({project_dir}/.git) |
| AC-016 | US-004 | _slugify produces safe directory names | Assert "Hello World!" -> "hello-world", length <=50 |
| AC-017 | US-005 | implement CXP carries all required payload fields | Assert 10 required fields present in packet.payload |
| AC-018 | US-006 | ux_complete subject handled identically to scope_validated | Assert process("ux_complete") calls _handle_design |
| AC-019 | US-007 | _impact_report printed when present in parameters | Assert print output contains classification and severity |
| AC-020 | US-008 | Neo4j failure returns blank string (no exception raised) | Assert _build_monorepo_context returns "" when Neo4j unreachable |
Functional Requirements
| FR-ID | Requirement |
|---|---|
| FR-001 | U:Ar processes CXP packets with subjects: implement, scope_validated, ux_complete, design_feedback |
| FR-002 | U:Ar returns None for unrecognized CXP subjects |
| FR-003 | _handle_design() extracts requirements, task_summary, original_intent, ux_design, scope_data from packet payload |
| FR-004 | _handle_design() resolves project_name from project_name payload field or slugified task_summary |
| FR-005 | _handle_design() initialises the project directory before calling the LLM |
| FR-006 | _handle_design() calls call_reasoner() with ARCHITECT_PROMPT_TEMPLATE injected with task_summary, requirements, original_spec_section, monorepo_src_section |
| FR-007 | _handle_design() parses LLM response into five sections via _parse_design() |
| FR-008 | _handle_design() writes parsed sections to {project_dir}/design/ via _write_design_docs() |
| FR-009 | _handle_design() sets design_cycles = 1 and sends design_review CXP to J:Junior |
| FR-010 | _handle_feedback() reads verdict, questions, and design_cycle from packet payload |
| FR-011 | _handle_feedback() calls _finalize_design() when verdict == "READY" |
| FR-012 | _handle_feedback() calls _finalize_design() when cycle >= MAX_DESIGN_CYCLES |
| FR-013 | _handle_feedback() calls _iterate_design() when verdict != "READY" and cycle < MAX_DESIGN_CYCLES |
| FR-014 | _finalize_design() sends implement CXP to U:Cd (escalation_target) |
| FR-015 | _finalize_design() includes all five design artifacts plus 5 additional context fields in payload |
| FR-016 | _finalize_design() calls _git_commit() with cycle-count message before sending |
| FR-017 | _iterate_design() calls call_reasoner() with ARCHITECT_UPDATE_TEMPLATE |
| FR-018 | _iterate_design() formats questions as numbered list for prompt injection |
| FR-019 | _iterate_design() increments design_cycles and writes updated docs before returning design_review CXP |
| FR-020 | _make_review_packet() constructs CXP with subject design_review addressed to J:Junior |
| FR-021 | _make_review_packet() includes all five design artifacts plus design_cycle and project context |
| FR-022 | _parse_design() extracts sections using ordered markers: ARCHITECTURE:, REQUIREMENTS:, FILE_TREE:, API_SPEC:, CLASS_DIAGRAM: |
| FR-023 | _parse_design() handles missing sections gracefully (skips absent markers) |
| FR-024 | _write_design_docs() writes all five artifacts as separate .md files if content is provided |
| FR-025 | _load_structured_fields() extracts structured_requirements, user_stories, nfrs, spec_metadata, analyst_output |
| FR-026 | _load_structured_fields() prints impact report if _impact_report present in parameters |
| FR-027 | _resolve_project_name() uses concierge-supplied project_name field if present |
| FR-028 | _resolve_project_name() falls back to _slugify(task_summary) |
| FR-029 | _slugify() produces lowercase hyphenated string, max 50 chars, with special chars stripped |
| FR-030 | ArchitectContextMixin._build_full_monorepo_context() assembles project tree + API source context |
| FR-031 | ArchitectContextMixin._build_project_tree_context() queries Neo4j for packages, modules, top classes, top functions |
| FR-032 | ArchitectContextMixin._build_monorepo_context() extracts CapWords from requirements text |
| FR-033 | ArchitectContextMixin._build_monorepo_context() removes noise words before querying |
| FR-034 | ArchitectContextMixin._build_monorepo_context() queries Neo4j with project scope filter |
| FR-035 | ArchitectContextMixin._build_monorepo_context() loads and truncates source files at 200 lines |
| FR-036 | ArchitectContextMixin._scan_filesystem_for_classes() scans monorepo packages as Neo4j fallback |
| FR-037 | ArchitectContextMixin._build_full_monorepo_context() applies brace-escaping to all context strings |
| FR-038 | ArchitectProjectMixin._init_project() creates 7 subdirectories in project_dir |
| FR-039 | ArchitectProjectMixin._init_project() writes context.json with state/deferred_work/session_history |
| FR-040 | ArchitectProjectMixin._init_project() runs git init in project_dir |
| FR-041 | ArchitectProjectMixin._init_project() creates UV venv with Python 3.14t |
| FR-042 | ArchitectProjectMixin._git_commit() runs git add -A then git commit -m in project_dir |
| FR-043 | ArchitectProjectMixin._git_commit() is a no-op when project_dir has no .git directory |
| FR-044 | graph_context extracted from CXP payload via extract_graph_context() and passed to call_reasoner() |
| FR-045 | U:Ar alias is "U:Ar", role is "Architect", escalation_target is "U:Cd" |
Non-Functional Requirements
| ID | Requirement |
|---|---|
| NFR-001 | Architecture generation latency: < 120s for projects with ≤ 20 requirements (reasoner model may be slow) |
| NFR-002 | Design update latency per iteration: < 90s |
| NFR-003 | Project scaffold creation: < 5s including git init and uv venv |
| NFR-004 | Neo4j context query: < 2s per query; silently skipped on timeout |
| NFR-005 | Memory footprint: design_docs dict never exceeds 512KB total |
| NFR-006 | Source file injection capped at 200 lines per file; no single context block exceeds 100KB |
| NFR-007 | All async methods compatible with Python 3.14t free-threaded runtime |
Security Requirements
Authentication
- U:Ar requires valid CXP packet authentication via orchestrata-core infrastructure
- No additional authentication beyond base CXP protocol required
- All CXP packets validated by orchestrata-core before reaching U:Ar
Authorization
- U:Ar processes packets from whitelisted agents only: U:PM, U:Ux, J:Junior
- U:Ar sends packets to whitelisted agents only: J:Junior, U:Cd
- Packet routing validated in
process()method before any processing
Input Validation
- All CXP packet payloads validated before access (type checking, null checks)
- Requirements text sanitized before LLM injection (no script injection)
- Neo4j queries parameterized to prevent injection attacks
- Project name slugification prevents directory traversal attacks
Audit Logging
- All CXP packet processing logged with trace_id
- Design decisions logged to git commits with cycle count
- Neo4j connection failures logged at DEBUG level
- LLM call latencies tracked for performance monitoring
- Security events logged at INFO level: invalid subjects, failed packet processing
Data Protection
- Project workspaces created with 0700 permissions (owner-only access)
- context.json files contain no secrets; only structured state data
- LLM prompts include only sanitized context; no API keys or credentials
- Source files from Neo4j truncated at 200 lines to prevent large data exposure
Secure Defaults
- Git commits fail safely if git not available (no secrets leaked)
- UV virtual environment creation fails safely (no runtime dependencies)
- Neo4j unavailable triggers graceful degradation, not failure
- All file operations use secure path joining (no path traversal)
- LLM context size capped at 100KB to prevent prompt injection
Technical Design
Pipeline Position
HUMAN → U:Cx → U:PM → (U:Ux if has_ui) → U:Ar → J:Junior → U:Ar → [feedback loop] → U:Cd → J:Junior (impl)
↑ scope_validated / ux_complete
|
U:Ar design loop:
1. _handle_design() → design_review → J:Junior
2. J:Junior design_feedback → _handle_feedback()
3. If READY or max_cycles: _finalize_design() → U:Cd
4. Else: _iterate_design() → design_review → J:Junior
CXP Message Flow
| Subject | From | To | Direction | Description |
|---|---|---|---|---|
scope_validated |
U:PM | U:Ar | incoming | Triggers initial architecture design |
ux_complete |
U:Ux | U:Ar | incoming | Triggers design with UX artifacts |
implement |
U:PM | U:Ar | incoming | Alternative trigger for direct implementation |
design_feedback |
J:Junior | U:Ar | incoming | Junior's verdict + blocking questions |
design_review |
U:Ar | J:Junior | outgoing | All five design artifacts for review |
implement |
U:Ar | U:Cd | outgoing | Finalized design escalation to CodeDirector |
Class Hierarchy
BaseVolk
└── ArchitectVolk (also inherits ArchitectProjectMixin, ArchitectContextMixin)
├── alias = "U:Ar"
├── role = "Architect"
├── escalation_target = "U:Cd"
├── design_docs: dict[str, str] (5 keys)
├── design_cycles: int
├── process() — router
├── _handle_design() — initial design
├── _handle_feedback() — feedback routing
├── _finalize_design() — escalation
├── _iterate_design() — design update
└── _make_review_packet() — J:Junior packet builder
ArchitectContextMixin
├── _build_full_monorepo_context(requirements) → str
├── _build_project_tree_context() → str
├── _build_monorepo_context(text) → str
├── _scan_filesystem_for_classes(names, loaded) → None
├── _try_load_class_file(fpath, root, names, loaded) → None
└── _slugify(text) → str
ArchitectProjectMixin
├── _init_project() → None
├── _write_context_json() → None
├── _git_init() → None
├── _create_venv() → None
├── _write_design_docs() → None
├── _parse_design(response) → None
└── _git_commit(message) → None
File Structure
packages/orchestrata-architect/
├── pyproject.toml
└── src/orchestrata/volks/architect/
├── __init__.py (re-exports ArchitectVolk)
├── volk.py (ArchitectVolk — process, _handle_design, _handle_feedback, ...)
├── architect_context.py (ArchitectContextMixin — Neo4j + filesystem context queries)
├── architect_project.py (ArchitectProjectMixin — scaffold, doc writing, git)
├── architect_prompts.py (ARCHITECT_PROMPT_TEMPLATE, ARCHITECT_UPDATE_TEMPLATE, MAX_DESIGN_CYCLES)
├── context_builder.py (standalone context builder helpers)
├── project_init.py (standalone project initialization helpers)
├── prompts.py (additional prompt templates and CODING_STANDARDS import)
└── volk_context.py (graph directives and context extraction helpers)
Data Models
DesignDocuments Schema
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "DesignDocuments",
"description": "Five architecture artifacts produced by U:Ar",
"type": "object",
"required": ["architecture", "requirements", "file_tree", "api_spec", "class_diagram"],
"properties": {
"architecture": {
"type": "string",
"description": "Component descriptions, responsibilities, ADRs, data flow",
"minLength": 0
},
"requirements": {
"type": "string",
"description": "Numbered FR/NFR/ERR requirements list",
"minLength": 0
},
"file_tree": {
"type": "string",
"description": "Exact flat file tree starting at src/ and tests/",
"minLength": 0
},
"api_spec": {
"type": "string",
"description": "Per-module imports, classes, methods, functions with signatures",
"minLength": 0
},
"class_diagram": {
"type": "string",
"description": "Mermaid or ASCII class diagram showing relationships",
"minLength": 0
}
}
}
DesignReview CXP Payload (U:Ar → J:Junior)
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "DesignReviewPayload",
"type": "object",
"required": ["architecture", "requirements", "file_tree", "api_spec", "class_diagram", "design_cycle", "project_dir", "task_summary"],
"properties": {
"architecture": { "type": "string" },
"requirements": { "type": "string" },
"file_tree": { "type": "string" },
"api_spec": { "type": "string" },
"class_diagram": { "type": "string" },
"design_cycle": { "type": "integer", "minimum": 1 },
"project_dir": { "type": "string", "description": "Absolute path to project workspace" },
"task_summary": { "type": "string" }
}
}
DesignFeedback CXP Payload (J:Junior → U:Ar)
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "DesignFeedbackPayload",
"type": "object",
"required": ["verdict"],
"properties": {
"verdict": {
"type": "string",
"enum": ["READY", "QUESTIONS"],
"description": "READY = design approved; QUESTIONS = blocking ambiguities"
},
"questions": {
"type": "array",
"items": { "type": "string" },
"description": "List of blocking questions from J:Junior"
},
"design_cycle": {
"type": "integer",
"minimum": 1
}
}
}
ImplementEscalation CXP Payload (U:Ar → U:Cd)
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "ImplementEscalationPayload",
"type": "object",
"required": ["architecture", "requirements", "file_tree", "api_spec", "class_diagram", "project_dir", "task_summary"],
"properties": {
"architecture": { "type": "string" },
"requirements": { "type": "string" },
"file_tree": { "type": "string" },
"api_spec": { "type": "string" },
"class_diagram": { "type": "string" },
"original_intent": { "type": "string" },
"project_dir": { "type": "string" },
"task_summary": { "type": "string" },
"structured_requirements": { "type": "array" },
"user_stories": { "type": "array" },
"monorepo_src_section": { "type": "string" },
"nfrs": { "type": "array" },
"spec_metadata": { "type": "object" }
}
}
Error Conditions and Edge Cases
| ERR-ID | Condition | Trigger | Handling | Severity |
|---|---|---|---|---|
| ERR-001 | Unrecognized CXP subject | packet.subject not in known set |
process() returns None; packet dropped |
Info |
| ERR-002 | Blank requirements in packet | requirements field absent or blank string |
Prompt still generated; LLM produces minimal design | Warning |
| ERR-003 | Missing project_name and task_summary | Both fields absent | _slugify("") returns "project"; project_dir uses "project" |
Warning |
| ERR-004 | LLM response missing sections | One or more section markers absent from response | _parse_design() skips absent sections; design_docs key remains blank string |
Warning |
| ERR-005 | Neo4j unreachable during context build | Connection timeout or auth failure | Blank string returned; filesystem fallback attempted | Info |
| ERR-006 | Filesystem fallback directory missing | /opt/orchestrata/packages not found |
_scan_filesystem_for_classes() returns early; no context injected |
Info |
| ERR-007 | project_dir already exists | os.makedirs called on existing path |
exist_ok=True prevents error; existing structure preserved |
Info |
| ERR-008 | Git not installed | subprocess.run(["git", "init"]) raises FileNotFoundError |
Exception caught; print message; git omitted | Warning |
| ERR-009 | uv not installed | subprocess.run(["uv", "venv"]) raises FileNotFoundError |
Exception caught; logged at DEBUG; venv omitted | Info |
| ERR-010 | MAX_DESIGN_CYCLES reached without READY | design_cycles >= MAX_DESIGN_CYCLES | _finalize_design() called; warning printed; design escalated |
Warning |
| ERR-011 | context.json already exists | _write_context_json() called on existing project |
Early return; existing file preserved | Info |
| ERR-012 | Design doc write fails | Filesystem full or permissions error | Exception propagates from _write_design_docs(); not swallowed |
Error |
| ERR-013 | Brace-unescaped context injected | str.format() encounters raw { } in context | _build_full_monorepo_context() applies replace("{","{{") before return |
Prevention |
| ERR-014 | CapWords list blank after noise removal | Requirements contain no class names | _build_monorepo_context() returns blank string immediately |
Info |
| ERR-015 | Source file >200 lines | Neo4j returns file path with 500+ line source | Content truncated with ... (truncated at 200/N lines) suffix |
Info |
| ERR-016 | LLM call timeout | call_reasoner() exceeds 120s timeout |
Exception propagates; design cycle aborted | Error |
| ERR-017 | Malformed CXP packet received | JSON parse error or missing header | Packet logged and dropped; no exception | Warning |
Performance Benchmarks
| ID | Metric | Target | Measurement Method |
|---|---|---|---|
| PR-001 | Initial design generation (LLM call) | < 120s p95 | Wall-clock from _handle_design() entry to _make_review_packet() return |
| PR-002 | Design iteration (LLM call) | < 90s p95 | Wall-clock from _iterate_design() entry to return |
| PR-003 | Project scaffold creation | < 5s | Timer around _init_project() |
| PR-004 | Neo4j project tree query | < 2s | Timer around _build_project_tree_context() |
| PR-005 | Neo4j monorepo context query | < 2s | Timer around _build_monorepo_context() |
| PR-006 | _parse_design() |
< 50ms | Timer around parse call with 50KB LLM response |
| PR-007 | _write_design_docs() |
< 200ms | Timer around doc write for 5 files |
| PR-008 | _slugify() |
< 1ms | Microbenchmark |
Testing
Testability Guidelines
| ID | Area | Test Type | Description | Verification |
|---|---|---|---|---|
| TC-001 | process() routing |
Unit | Verify each subject routes to correct handler | Mock _handle_design and _handle_feedback; assert call counts |
| TC-002 | _parse_design() |
Unit | Verify all five sections extracted from well-formed response | Supply synthetic LLM response; assert all five keys populated |
| TC-003 | _parse_design() |
Unit | Verify missing sections handled without crash | Supply response with only ARCHITECTURE: marker; assert other keys blank |
| TC-004 | _resolve_project_name() |
Unit | Verify concierge name preferred over task_summary | Supply both; assert project_name from concierge field |
| TC-005 | _resolve_project_name() |
Unit | Verify fallback to slugified task_summary | Omit project_name; assert slugified result |
| TC-006 | _slugify() |
Unit | Parametrize: plain text, special chars, long text, blank | Assert correct slug output for each case |
| TC-007 | _handle_feedback() |
Unit | Verify READY verdict triggers _finalize_design | Supply verdict="READY"; assert _finalize_design called |
| TC-008 | _handle_feedback() |
Unit | Verify cycle >= MAX_DESIGN_CYCLES triggers _finalize_design | Set design_cycles = MAX_DESIGN_CYCLES; assert forced escalation |
| TC-009 | _handle_feedback() |
Unit | Verify QUESTIONS verdict triggers _iterate_design | Supply verdict="QUESTIONS" with cycle < MAX; assert iteration |
| TC-010 | _finalize_design() |
Unit | Verify implement CXP sent to U:Cd with all required fields | Assert return packet fields |
| TC-011 | _iterate_design() |
Unit | Verify design_cycles incremented | Assert design_cycles == 2 after first iteration |
| TC-012 | _make_review_packet() |
Unit | Verify design_review CXP structure | Assert subject, to_agent, all five doc fields |
| TC-013 | _init_project() |
Integration | Verify all directories created in tmp project_dir | Create real temp dir; assert all 7 subdirs |
| TC-014 | _write_context_json() |
Integration | Verify context.json schema | Parse written file; assert keys |
| TC-015 | _git_init() |
Integration | Verify .git created | Assert .git directory exists |
| TC-016 | _write_design_docs() |
Integration | Verify all five .md files written | Assert file existence and populated content |
| TC-017 | _build_monorepo_context() |
Integration | Verify blank return when Neo4j unavailable and no packages dir | Supply env without Neo4j; assert "" returned |
| TC-018 | _scan_filesystem_for_classes() |
Integration | Verify class files found by regex | Create temp Python file with class definition; assert loaded |
| TC-019 | _try_load_class_file() |
Unit | Verify truncation at 200 lines | Create 300-line file; assert truncation marker |
| TC-020 | Noise word filtering | Unit | Verify NOISE_WORDS removed from CapWords set | Supply requirements with "Python", "Redis"; assert not in extracted set |
| TC-021 | Brace escaping | Unit | Verify {{ }} in context output | Assert result.format() does not raise KeyError |
| TC-022 | _load_structured_fields() |
Unit | Verify all structured fields extracted | Supply full payload; assert all five attributes set |
| TC-023 | _git_commit() no-op |
Unit | Verify no-op when .git missing | Assert no subprocess call when git dir absent |
| TC-024 | Graceful degradation | Unit | Neo4j import error returns blank string | Simulate import failure; assert "" returned, no exception |
| TC-025 | E-010 forced escalation | Unit | Verify warning printed at MAX_DESIGN_CYCLES | Assert "Max design cycles" in print output |
Dependencies and Environmental Assumptions
Runtime Dependencies
| Dependency | Version Range | Purpose |
|---|---|---|
| Python | >=3.14t | Free-threaded runtime, async/await support |
| orchestrata-core | >=0.7.0 | BaseVolk, CXPPacket, WorkStatus, graph_directives, infra_config |
| orchestrata-agents | >=0.7.0 | BaseVolk lifecycle, alias/role registration |
| orchestrata-cxp | >=0.7.0 | CXP packet encoding, subject constants |
| orchestrata-llm | >=0.7.0 | call_reasoner() function |
| orchestrata-knowledge | >=0.7.0 | Neo4jConfig, Neo4jClient (optional; graceful on absence) |
| git | any | Project initialisation; graceful on absence |
| uv | any | Virtual environment creation; graceful on absence |
| Neo4j | >=5.0 | Knowledge graph context queries; optional |
Environmental Assumptions
| Variable | Required | Default | Purpose |
|---|---|---|---|
NEO4J_URI |
No | — | Neo4j connection URI for context queries |
NEO4J_USERNAME |
No | — | Neo4j auth username |
NEO4J_PASSWORD |
No | — | Neo4j auth password |
PROJECT_WORKSPACE_ROOT |
Yes | From infra_config | Base directory for generated project workspaces |
Governance
Ownership
- Spec Owner: Mohamed
- Implementation Owner: orchestrata-agents team
- Review Cadence: Monthly spec review against implementation
- Breaking Change Authority: Spec owner must approve any breaking changes
Lifecycle
- Status: Implemented
- Deprecation Policy: 2 minor version warning before removal
- Migration Path: Documented in release notes
- Rollback Plan: Git revert to previous version tag
Compliance
- All error conditions must have corresponding test coverage
- All functional requirements must have traceable implementation
- All public methods require Google-style docstrings
- No mocking in test files (real implementations only)
- Performance benchmarks must pass in CI pipeline
Standards Adherence
- Follows SPEC-097 Testing Standards
- Follows SPEC-098 API Standards
- Follows SPEC-000 CLI Standards
- Code style: Black formatter, isort import sorting
- Maximum class size: 300 lines
- Maximum file size: 500 lines
Review Process
- Self-review against SPEC_STANDARD.md before PR
- Adversarial review (find gaps) by another engineer
- Second-pass review for completeness
- Final approval by spec owner
Integration Points
Incoming Integrations
| Agent | Subject | Trigger | Payload Keys |
|---|---|---|---|
| U:PM | scope_validated |
PM completes scope validation | task_summary, project_name, requirements, original_intent, structured_requirements, user_stories, nfrs, spec_metadata, scope_data |
| U:Ux | ux_complete |
UX completes UI design | task_summary, project_name, ux_design, requirements, original_intent, structured_requirements, user_stories, nfrs |
| U:PM | implement |
Direct implementation request | task_summary, project_name, requirements, original_intent, structured_requirements, user_stories, nfrs, spec_metadata |
| J:Junior | design_feedback |
Design review response | verdict, questions, design_cycle |
Outgoing Integrations
| Agent | Subject | Trigger | Payload Keys |
|---|---|---|---|
| J:Junior | design_review |
After initial design or iteration | architecture, requirements, file_tree, api_spec, class_diagram, design_cycle, project_dir, task_summary |
| U:Cd | implement |
After design finalization | architecture, requirements, file_tree, api_spec, class_diagram, project_dir, task_summary, original_intent, structured_requirements, user_stories, monorepo_src_section, nfrs, spec_metadata |
Knowledge Graph Integration
| Operation | Direction | Purpose |
|---|---|---|
| Query packages/modules | Read | Build project tree context |
| Query classes/functions | Read | Build monorepo API context |
| Query relationships | Read | Understand component dependencies |
Filesystem Integration
| Operation | Purpose | Fallback |
|---|---|---|
| Scan monorepo/packages | Find source files | Neo4j unavailable |
| Create project directory | Scaffold workspace | - |
| Write design docs | Persist artifacts | - |
| Git commit | Version control | Git unavailable |
| UV venv | Virtual environment | UV unavailable |
LLM Integration
| Function | Model Tier | Purpose |
|---|---|---|
call_reasoner() |
Reasoning (deepseek-reasoner, Claude Opus) | Initial architecture design via Chain-of-Thought |
call_reasoner() |
Reasoning | Design iteration with J:Junior feedback |
Examples and Sample Data
Example 1: Initial Design Request (U:PM → U:Ar)
{
"header": {
"from_agent": "U:PM",
"to_agent": "U:Ar",
"subject": "scope_validated",
"thread_id": "thread-042"
},
"payload": {
"task_summary": "Build a task management CLI with SQLite storage",
"project_name": "taskman",
"requirements": "1. Add tasks with name and due date\n2. List all tasks\n3. Mark tasks complete",
"original_intent": "A simple task manager for personal use",
"structured_requirements": ["Add task", "List tasks", "Complete task"],
"user_stories": [],
"nfrs": ["Response time < 200ms"],
"spec_metadata": {},
"scope_data": {"complexity_score": 0.3, "estimated_files": 5}
}
}
Example 2: Design Feedback — QUESTIONS (J:Junior → U:Ar)
{
"header": {
"from_agent": "J:Junior",
"to_agent": "U:Ar",
"subject": "design_feedback",
"thread_id": "thread-042"
},
"payload": {
"verdict": "QUESTIONS",
"design_cycle": 1,
"questions": [
"What is the exact SQLite schema for the tasks table?",
"Should completed tasks be deleted or retained with a status flag?"
]
}
}
Example 3: Design Feedback — READY (J:Junior → U:Ar)
{
"header": {
"from_agent": "J:Junior",
"to_agent": "U:Ar",
"subject": "design_feedback",
"thread_id": "thread-042"
},
"payload": {
"verdict": "READY",
"design_cycle": 2,
"questions": []
}
}
Example 4: Escalation to U:Cd (U:Ar → U:Cd)
{
"header": {
"from_agent": "U:Ar",
"to_agent": "U:Cd",
"subject": "implement",
"thread_id": "thread-042"
},
"payload": {
"architecture": "## Components\n1. CLI (typer) ...\n2. Storage (sqlite3) ...",
"requirements": "FUNCTIONAL:\n1. FR-01: Add task ...",
"file_tree": "src/\n├── taskman/\n│ ├── __init__.py\n│ ├── cli.py\n│ └── storage.py\ntests/\n└── test_cli.py",
"api_spec": "Module: src/taskman/storage.py\nClasses:\n TaskStore:\n Methods:\n add_task(name: str, due: str) -> int ...",
"class_diagram": "classDiagram\n CLI --> TaskStore\n TaskStore --> Task",
"project_dir": "/opt/orchestrata-workspaces/taskman",
"task_summary": "Build a task management CLI with SQLite storage",
"original_intent": "A simple task manager for personal use",
"structured_requirements": ["Add task", "List tasks", "Complete task"],
"user_stories": [],
"monorepo_src_section": "",
"nfrs": ["Response time < 200ms"],
"spec_metadata": {}
}
}
API Contracts
Architect Volk Service Interface
service: ArchitectVolk
version: "1.0.0"
agent_id: "U:Ar"
alias: "U:Ar"
role: "Architect"
escalation_target: "U:Cd"
inbound_subjects:
- implement
- scope_validated
- ux_complete
- design_feedback
outbound_subjects:
- design_review # to J:Junior
- implement # to U:Cd
design_artifacts:
- architecture # ARCHITECTURE: section
- requirements # REQUIREMENTS: section
- file_tree # FILE_TREE: section
- api_spec # API_SPEC: section
- class_diagram # CLASS_DIAGRAM: section
llm_tier: reasoning # call_reasoner() — deepseek-reasoner or opus
max_design_cycles: 99 # configurable in architect_prompts.py
API Versioning Metadata
| Field | Value |
|---|---|
| Spec Version | 1.0.0 |
| Package Version | 0.7.0 |
| CXP Protocol Version | 1.0.0 |
| Minimum Core Version | 0.7.0 |
| Contract Version | 1.0.0 |
| Backwards Compatibility | - (initial formal spec) |
| Breaking Change Policy | Major version bump required for: removing CXP subjects, changing required payload fields, changing escalation target |
| Deprecation Policy | Deprecated subjects supported for 2 minor versions; deprecated fields annotated in schema |
Observability Requirements
Structured Logging
| Event | Level | Fields | When |
|---|---|---|---|
ar.design.started |
INFO | task_summary, project_dir, design_cycle |
_handle_design() invoked |
ar.design.complete |
INFO | project_dir, design_cycle, artifacts_non_empty |
Initial design parsed and written |
ar.design.feedback.ready |
INFO | cycle, project_dir |
J:Junior verdict == "READY" |
ar.design.feedback.questions |
INFO | cycle, question_count |
J:Junior returns questions |
ar.design.iteration |
INFO | cycle, question_count, project_dir |
_iterate_design() invoked |
ar.design.forced_escalation |
WARN | cycle, max_cycles, project_dir |
MAX_DESIGN_CYCLES reached |
ar.context.neo4j_ok |
INFO | class_count, source_files_loaded |
Neo4j context query succeeds |
ar.context.neo4j_failed |
DEBUG | error |
Neo4j query fails |
ar.context.filesystem_fallback |
INFO | files_loaded |
Filesystem scan used |
ar.project.scaffold |
INFO | project_dir, subdirs_created |
_init_project() complete |
ar.project.git_commit |
INFO | message, project_dir |
_git_commit() succeeds |
Success Criteria
| ID | Criterion | Verification Method |
|---|---|---|
| DoD-001 | All 45 functional requirements (FR-001 through FR-045) implemented and traced via @traces |
RTM extraction shows 100% coverage |
| DoD-002 | All acceptance criteria (AC-001 through AC-020) pass in CI | ci/local-ci.sh test green with all architect tests passing |
| DoD-003 | All error conditions (ERR-001 through ERR-017) have corresponding test cases | Test file contains function for each ERR-NNN ID |
| DoD-004 | Performance benchmarks (PR-001 through PR-008) met under load | Benchmark test suite passes |
| DoD-005 | Package is 2,010 LOC across 9 files | wc -l output matches |
| DoD-006 | No class exceeds 300 lines; no file exceeds 500 lines | Error gate check passes |
| DoD-007 | 100% of public methods have Google-style docstrings | Docstring lint passes |
| DoD-008 | ci/local-ci.sh test passes at 100% with >=90% coverage |
CI pipeline green |
| DoD-009 | No mocking in any test file | grep -r "unittest.mock|MagicMock" tests/ returns no matches |
| DoD-010 | Knowledge graph has no orphan nodes after sync | link_orphan_nodes.py --dry-run returns 0 orphans |
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
Revision History
| Version | Date | Author | Changes |
|---|---|---|---|
| 1.0.0 | 2026-04-04 | Mohamed | Initial formal specification — all sections complete |
| 1.0.1 | 2026-04-09 | Mohamed | Fixed Error Conditions to use ERR-nnn IDs; Fixed Functional Requirements to use FR-nnn IDs; Added Security Requirements section; Added Governance section; Added Integration Points section; Added Revision History section |