Orchestrata Ultimate › Plans › stage2_port_plan
Stage 2 Porting Plan: Fix, Verify, and Production-Ready
Source: plans/stage2_port_plan.md at 8a2cb42ad · last changed 2026-07-27 · first committed 2026-04-19 · 316 lines.
Prose pending.
Plan text
Stage 2 Porting Plan: Fix, Verify, and Production-Ready
Previous Plan:
plans/execution-plan.md(238 steps, 5 phases) — MARKED DONE as of 2026-04-19. Status: The bulk port produced 481 source files and 190 test files, but 54 source files have syntax errors and 29 test modules fail collection. Coverage is 24%, not 92%. Goal: Move from "bulk ported" to "production-ready" — all code compiles, all tests pass in parallel, coverage ≥90%, AST parity verified, requirements traceability validated.
How to Use This Plan
- Work top-to-bottom within a phase. Do not start Phase N+1 until Phase N gate checks pass.
- After each sub-phase, update
plans/stage2_tracker.mdwith DONE/PENDING/IN_PROGRESS. - Run gate check commands exactly as written. If they fail, stop and fix.
- Commit at every gate check (🚪) with a meaningful message.
Phase 0: Syntax Error Blitz (Critical Path)
Goal: All 481 source files must compile with py_compile.
Sub-phase 0.1: CXP Protocol (21 files)
- [ ]
cxp/constants.py— unterminated string literal - [ ]
cxp/delivery_status.py— unterminated string literal - [ ]
cxp/deterministic_ids.py— unterminated string literal - [ ]
cxp/dispatcher.py— unterminated string literal - [ ]
cxp/handler.py— leading zeros in decimal integer literals - [ ]
cxp/headers.py— unterminated string literal - [ ]
cxp/json_serializer.py— unterminated string literal - [ ]
cxp/_packet_impl.py— IndentationError (unindent does not match) - [ ]
cxp/packet.py— unterminated string literal - [ ]
cxp/payload.py— unterminated string literal - [ ]
cxp/postman_adapter.py— unmatched) - [ ]
cxp/priority.py— unmatched) - [ ]
cxp/prolog_bridge.py— unterminated string literal - [ ]
cxp/router.py— unterminated string literal - [ ]
cxp/schema.py— unmatched) - [ ]
cxp/serializer.py— unterminated string literal - [ ]
cxp/session_adapter.py— unterminated string literal - [ ]
cxp/threads.py— unterminated string literal - [ ]
cxp/thread_store.py— leading zeros in decimal integer literals - [ ]
cxp/types.py— unterminated string literal - [ ]
cxp/validator.py— leading zeros in decimal integer literals - [ ]
cxp/version_compat.py— leading zeros in decimal integer literals - [ ]
cxp/version.py— unterminated string literal - [ ]
cxp/work_status.py— unterminated string literal - [ ]
cxp/ws_client.py— unmatched) - [ ]
cxp/ws_server.py— unmatched) - [ ]
cxp/binary_serializer.py— leading zeros in decimal integer literals - [ ]
cxp/exceptions.py— unterminated string literal - [ ]
cxp/grpc_client.py— unmatched) - [ ]
cxp/grpc_server.py— unmatched) - [ ]
cxp/interfaces.py— unterminated string literal - [ ]
cxp/proto/cxp_pb2.py— unmatched) - [ ]
cxp/proto/__init__.py— unterminated string literal
Verification:
python -c "import py_compile; [py_compile.compile(f'dsrc/orchestrata_ultimate/cxp/{f}', doraise=True) for f in __import__('os').listdir('src/orchestrata_ultimate/cxp') if f.endswith('.py')]"
# Must exit 0
Sub-phase 0.2: Providers (12 files)
- [ ]
providers/adapters/anthropic_adapter.py— expected: - [ ]
providers/adapters/base.py— invalid syntax - [ ]
providers/adapters/claude_cli_adapter.py— unterminated string literal - [ ]
providers/adapters/deepseek_adapter.py— expected: - [ ]
providers/adapters/ollama_adapter.py— expected: - [ ]
providers/adapters/openai_adapter.py— expected: - [ ]
providers/adapters/openrouter_adapter.py— expected: - [ ]
providers/circuit_breaker.py— invalid syntax - [ ]
providers/cost_tracker.py— leading zeros in decimal integer literals - [ ]
providers/health_monitor.py— invalid syntax - [ ]
providers/provider_manager.py— unterminated string literal - [ ]
providers/rate_limiter.py— invalid syntax - [ ]
providers/registry.py— invalid syntax - [ ]
providers/router.py— unterminated string literal
Verification:
python -c "import py_compile, os; [py_compile.compile(os.path.join(r,f), doraise=True) for r,_,files in os.walk('src/orchestrata_ultimate/providers') for f in files if f.endswith('.py')]"
Sub-phase 0.3: Core, DI, Drivers, LLM, Postman, Orchestrator (6 files)
- [ ]
core/in_memory_redis.py—returnoutside function - [ ]
di/container.py— closing parenthesis]does not match opening( - [ ]
drivers/aider_driver.py— closing parenthesis]does not match opening( - [ ]
llm/client.py— closing parenthesis]does not match opening( - [ ]
llm/config.py— closing parenthesis]does not match opening( - [ ]
orchestrator/neo4j_audit.py— unexpected character after line continuation - [ ]
postman/postman.py— expectedexceptorfinallyblock
Verification:
python -c "
import py_compile, os
errors = []
for r, _, files in os.walk('src/orchestrata_ultimate'):
for f in files:
if f.endswith('.py'):
p = os.path.join(r, f)
try:
py_compile.compile(p, doraise=True)
except py_compile.PyCompileError as e:
errors.append(p)
print(f'Total syntax errors: {len(errors)}')
for e in errors: print(' ', e)
exit(1 if errors else 0)
"
🚪 Gate 0: Zero Syntax Errors
Command:
python -c "import py_compile, os; errors=0; [py_compile.compile(os.path.join(r,f), doraise=True) or None for r,_,files in os.walk('src/orchestrata_ultimate') for f in files if f.endswith('.py')]"
Expected: Exit 0, no output.
Phase 1: Test Collection Recovery
Goal: All 190 test files must import successfully (pytest --co exits 0 with zero ERRORs).
Sub-phase 1.1: Fix Test Import Errors (29 modules)
The following test modules fail during collection because they import broken source modules:
- [ ]
tests/agents/test_coordinator.py - [ ]
tests/agents/volks/qa/test_volk_generated.py - [ ]
tests/agents/volks/qa/test_volk.py - [ ]
tests/cxp/test_deterministic_ids.py - [ ]
tests/governance/test_prolog_gate.py - [ ]
tests/governance/test_resource_access.py - [ ]
tests/knowledge_graph/test_anomaly_detector.py - [ ]
tests/knowledge_graph/test_kg_context.py - [ ]
tests/knowledge_graph/test_knowledge_neo4j.py - [ ]
tests/knowledge_graph/test_knowledge_signatures.py - [ ]
tests/knowledge_graph/test_real_neo4j_knowledge.py - [ ]
tests/knowledge_graph/test_volk_context_injector.py - [ ]
tests/llm/test_config.py - [ ]
tests/llm/test_exceptions.py - [ ]
tests/llm/test_init.py - [ ]
tests/postman/(directory-level failure) - [ ]
tests/session/test_additional.py - [ ]
tests/session/test_kernel_session.py - [ ]
tests/session/test_real_session_context.py - [ ]
tests/test_agents.py - [ ]
tests/test_cli_generated.py - [ ]
tests/test_cxp.py - [ ]
tests/test_di.py - [ ]
tests/test_drivers.py - [ ]
tests/test_governance.py - [ ]
tests/test_kernel.py - [ ]
tests/test_llm.py - [ ]
tests/test_postman.py - [ ]
tests/test_providers.py
Approach:
- Fix the underlying source module syntax error (Phase 0).
- If test still fails collection, check for broken imports in the test file itself.
- Check for
os.environ["X"]mutations in test files (T2 violation) and replace withmonkeypatch.setenv().
🚪 Gate 1: Zero Collection Errors
Command:
uv run pytest tests/ --co -q
Expected: Exit 0, zero ERROR lines.
Phase 2: Test Failure Remediation
Goal: pytest -n auto --timeout=120 passes with 0 failures, 0 errors.
Sub-phase 2.1: Fix Runtime Failures (55 failed + 49 error)
Run the full suite, categorize failures:
- Category A: Logic bugs in ported code (fix source)
- Category B: Test assertions outdated due to renaming (Volk→Agent, etc.) — fix test
- Category C: Missing fixtures or infrastructure — add/fix conftest.py
- Category D: Environmental (Redis/Neo4j/Prolog not running) — use in-memory fallbacks
Approach:
- Run
uv run pytest tests/ -n auto --timeout=120 --tb=short 2>&1 | tee /tmp/test-failures.txt - Group failures by root cause.
- Fix Category A and B first (no external deps).
- Fix Category C (fixture/infrastructure).
- Fix Category D (environmental) last — ensure in-memory fallbacks work.
🚪 Gate 2: Zero Test Failures
Command:
uv run pytest tests/ -n auto --timeout=120
Expected: Exit 0, all green.
Phase 3: Coverage Drive
Goal: Coverage ≥90% (currently 24%).
Sub-phase 3.1: Baseline and Gap Analysis
- [ ] Run coverage report:
uv run pytest tests/ --cov=src/orchestrata_ultimate --cov-report=html --cov-report=term - [ ] Identify lowest-coverage modules (<50%)
- [ ] Cross-reference with tier assignments — prioritize Tier 0 (core) and Tier 1 (cxp, providers, agents)
Sub-phase 3.2: Fill Coverage Gaps
- [ ] Write missing unit tests for core modules
- [ ] Write missing unit tests for cxp modules
- [ ] Write missing unit tests for provider adapters
- [ ] Write missing integration tests for kernel + postman + orchestrator
- [ ] Ensure all
if __name__ == "__main__"blocks and exception branches are hit
🚪 Gate 3: 90% Coverage
Command:
uv run pytest tests/ -n auto --timeout=120 --cov=src/orchestrata_ultimate --cov-fail-under=90
Expected: Exit 0, coverage ≥90%.
Phase 4: AST Parity and Deep Compare
Goal: Source code semantically matches the frozen orchestrata monorepo.
Sub-phase 4.1: Regenerate AST Artifacts
- [ ]
python scripts/serialize_codebase_ast.py serialize --source src/orchestrata_ultimate --name orchestrata-ultimate --output plans/ast-ultimate.json - [ ]
python scripts/serialize_codebase_ast.py serialize --source /home/mohamed/workspace/orchestrata/packages --name orchestrata --output plans/ast-orchestrata.json --monorepo - [ ]
python scripts/serialize_codebase_ast.py deep-compare plans/ast-ultimate.json plans/ast-orchestrata.json --mapping plans/class-mapping.json --output plans/ast-deep-comparison.json
Sub-phase 4.2: Fix AST Gaps
- [ ] Review
plans/ast-deep-comparison.jsonforneeds_creationclasses - [ ] Review for
stubandpartialreadiness classes - [ ] Port missing methods to bring classes to
mostly_completeorequal - [ ] Update
plans/class-mapping.jsonif new class pairs are discovered
🚪 Gate 4: AST Parity
Command:
python -c "
import json
with open('plans/ast-deep-comparison.json') as f:
d = json.load(f)
needs_creation = [p for p in d.get('paired_classes',[]) if p.get('readiness') == 'needs_creation']
stubs = [p for p in d.get('paired_classes',[]) if p.get('readiness') == 'stub']
print(f'needs_creation: {len(needs_creation)}, stubs: {len(stubs)}')
exit(1 if needs_creation or stubs else 0)
"
Expected: Exit 0, zero needs_creation and zero stub classes.
Phase 5: Requirements Traceability and Production Readiness
Goal: Every spec requirement is traceable to code and tests.
Sub-phase 5.1: RTM Generation and Validation
- [ ] Run RTM generator over all spec directories:
specs/000-orchestrata-cli/throughspecs/101-ultimate-architecture/ - [ ] Ensure
@traces(spec=..., story=..., reqs=[...])annotations exist on all public API classes - [ ] Verify
verification/traceability.pycan scan the full codebase without errors - [ ] Produce
plans/rtm-report.json
Sub-phase 5.2: Code Quality Gates
- [x]
uv run ruff check src/ tests/— 0 errors - [x]
uv run black src/ tests/— no changes - [x]
uv run mypy src/— 0 errors (or documented waivers) - [x]
python scripts/architecture_checker.py— passes (91 documented violations, exits 0)
Sub-phase 5.3: Git and Release
- [ ] Squash checkpoint commits into logical conventional commits
- [ ] Tag
v0.9.0-rc1 - [ ] Run full test suite one final time
- [ ] If all gates pass, tag
v1.0.0
🚪 Gate 5: Production Ready
Commands:
uv run pytest tests/ -n auto --timeout=120 --cov=src/orchestrata_ultimate --cov-fail-under=90
uv run ruff check src/ tests/
python scripts/architecture_checker.py
Expected: All exit 0.
Current Status (2026-04-27):
pytest: ✅ 16,000 tests, 0 failuresruff: ✅ 0 errorsarchitecture_checker: ✅ exits 0 (documents 91 known violations for future refactoring)coverage: 🟡 ~90% (pending fresh full-suite measurement)mypy: ✅ 0 errors (pragmatic waivers on ~100 integration files)
Summary
| Phase | Goal | Estimated Files Touched | Gate Check |
|---|---|---|---|
| 0 | Fix 54 syntax errors | ~54 source files | py_compile clean |
| 1 | Fix 29 test collection errors | ~29 test files + deps | pytest --co clean |
| 2 | Fix 104 runtime test failures | source + tests | pytest -n auto clean |
| 3 | Drive coverage 24% → 90%+ | ~50+ new test files | --cov-fail-under=90 |
| 4 | AST parity with orchestrata | ~50 source files | Zero stubs/needs_creation |
| 5 | RTM + quality + release | docs + metadata | All gates pass |
Files to Update During Stage 2
| File | Purpose |
|---|---|
plans/stage2_tracker.md |
Live task tracker — update after every sub-phase |
plans/stage2_port_plan.md |
This plan — amend if scope changes |
context.json |
Session state — update on session close |
projectstatus.md |
High-level status — update at each gate |