Orchestrata Ultimate › Plans › spec-audit › reverify-2026-10-18 › K-harness-newer
Cluster K — harness/newer REVERIFY (SPEC-102/103/104/105)
Source: plans/spec-audit/reverify-2026-10-18/K-harness-newer.md at 8a2cb42ad · last changed 2026-10-18 · first committed 2026-10-18 · 277 lines.
Prose pending.
Plan text
Cluster K — harness/newer REVERIFY (SPEC-102/103/104/105)
Re-verification against current components branch (commit de9e996f2, 337 commits
ahead of the session-195 audits). All evidence regenerated fresh via the AST toolkit
(scripts/serialize_codebase_ast.py {symbols,refs,source}); no stale verdict trusted.
Prior audit baseline: plans/spec-audit/K-harness-greenfield.md (session 195) and
00-MASTER-PLAN.md §2/§6 (S7 Medic).
Key deltas vs. the 3-month-old audit (high-level):
- SPEC-102 — healing loop was structurally expanded (482 lines, 3-hop CXP dispatch,
diagnostics persistence, worktree path-safety) but the two defects the old audit flagged
are both still present (payload-overwrite + fabricated-pass
_repaired_trial). Scenarios now live at repo-rootharness/(not inside the package). History moved Neo4j→graph. - SPEC-103 — still DONE and still fully wired (FR-009 pipeline confirmed at new line
numbers;
enable_tool_refactoris now a config field, not a module constant). - SPEC-104 — still DONE; gained a
requirements_parser.pyhelper (Prolog facts) and grew to 38 tests. - SPEC-105 — still DONE; the
relationships.pydivergence is now resolved in the spec text (REQ-105-005), and FR-008 SHACL is now implemented + specced.
SPEC-102 Individual Volk Test Harness — PARTIAL
Specifies: A scenario-driven, on-demand (not CI) harness that exercises each volk through
real LLM + Redis/graph infra, with deterministic + LLM-judge evaluators, git-worktree/Incus
isolation, 3-trial runs, snapshot regression, a 3-hop self-healing loop, JSON+graph history,
and a CLI. Target src/orchestrata_ultimate/harness/ (+ repo-root harness/ scenarios).
Verified:
- ✅ FR-001/002 scenario model + setup hooks —
harness/models.py:42Scenario(pydantic);harness/scenario.py:182run_setup_hook,:99load_scenarios_for_volk. Shipped scenarios present at repo-rootharness/scenarios/{qa,architect,codedirector}/scenario_001.yaml+setup.pyeach (loader defaultPath("harness/scenarios")resolves there from repo root). - ✅ FR-003 dual LLM —
harness/models.pyHarnessConfig.default_llm/reasoning_llm. - ✅ FR-004/005 executors —
harness/executor.py:40CXPacketExecutor,:89DirectCallExecutor. - ✅ FR-006 3 trials —
harness/runner.py:106for trial_number in range(1, trials + 1). - ✅ FR-007 snapshots —
harness/snapshots.pySnapshotManager;runner.py:331_compare_snapshot. - ⚠️ FR-008 deterministic evaluators — registry (
harness/evaluators/__init__.py:57-78) has 5:SyntaxEvaluator,LintEvaluator,TraceEvaluator,FileExistsEvaluator,LLMJudgeEvaluator. The optionaltype_check/mypy evaluator is still absent (notype_checksymbol/module). - ✅ FR-009 LLM-judge —
harness/evaluators/llm_judge.pyLLMJudgeEvaluator. - ❌ FR-011 self-healing loop is still non-operational. Structural work landed (3-hop CXP
dispatch via
_run_hophealing.py:222,_has_valid_strategy:306, diagnostics persistence:386, worktree path-safety:443/:463), but the two defects persist:healing.py:274still overwrites the volk's reply with the outgoing packet payload (response_dict["payload"] = packet.payload) before_extract_strategy(:55) reads it. The outgoing payload for hops 1/2/3 containsaction ∈ {diagnostic, apply_repair, escalate}, never"retry"/"patch", so_extract_strategycan never match → the CXP path always exhausts tosuccess=False(3 hops). The comment at:272-273rationalizes it ("the receiving volk is expected to echo back") but the code deletes that echo.healing.py:313-323_repaired_trialstill fabricates success: docstring literally says"""Return a new TrialResult simulating a successful repair."""and returnspassed=Truecarrying the original failingevaluator_results(:319) andsnapshot_diff(:321).healing.py:374_heal_fallbackstill fabricates success ("we optimistically assume the retry succeeds") after hop 2. In the runner path it is only reachable via directdispatcher=Noneconstruction (the runner's lazydispatcherpropertyrunner.py:73-77always returns a realMessageDispatcher), but the fabricated-pass helper is shared.- Net: a repair is never re-executed + re-evaluated; "healed" success is never verified.
- ✅ FR-012 whitelist —
harness/executor.py:180enforce_whitelist,:26SecurityError. - ⚠️ FR-013/014 history —
harness/history.py:113JSONHistoryTracker+:211GraphHistoryTracker(graph failures non-fatal,runner.py:60-66). Divergence: spec FR-014 + API-contract still sayNeo4jSyncer/neo4j_uri, code targets the orchgraph (Memgraph) viacore.graph_factory.resolve_uri. - ✅ FR-015 GitLab CI —
.gitlab-ci.ymlpresent at repo root. - ✅ FR-016 CLI —
harness/cli.py6 subparsers (run/list/snapshot/report/trends/config,:354-389);__main__.pypresent. - ✅ FR-017 isolation —
harness/isolation.py:34WorktreeIsolation,:137IncusIsolation. - ✅ FR-018 timeouts —
asyncio.wait_foron setup/execute/evaluators;_run_hopHOP_TIMEOUT_SECONDS=30. - ✅ FR-019 config —
harness/config.py:23load_config(YAML + env overlay, RUL-003 raising resolvers, no localhost fallback). Repo-rootharness/config.yamlpresent. - ⚠️ FR-020 parallel —
runner.py:447-456run_volkstill runs scenarios sequentially; but the spec text was already re-worded (spec.md:210-211) to require the test suite be parallel via the threadpool runner (xdist banned). Reconciled — no code gap. - ❌ TST-002
--mock-llmstill dead config.harness/config.yaml:21declaresmock_llm: false;HarnessConfig(models.py:116-158) has nomock_llmfield;_apply_yaml(config.py:67) logs"Unknown config key: mock_llm"and drops it; no--mock-llmCLI flag; nomock_llm_responses.yamlfixture. (symbols --pattern mock_llm→ 0.) - ⚠️ SPEC-102 still not registered in
specs/SPEC_INVENTORY.md(103/104/105 are, at lines 28-30; 102 absent). - ⚠️ Spec-text divergences (stale API-contract block): spec.md:316-333 shows
redis_host: str = "localhost"/neo4j_uri: bolt://…; code usesredis_host = resolve_redis_host(),graph_uri = resolve_uri()(models.py:150-153). SpecHarnessContext.neo4j_prefix→ codegraph_prefix(models.py:110). FR-019 prose already matches code (raising resolvers); the embedded dataclass blocks are the stale part.
Remaining work / plan:
- Scope: (1) Make self-healing actually heal — after a repair hop, re-run the scenario
stage + evaluators in the same worktree and mark
passed=Trueonly when re-evaluation passes; fixhealing.py:274so_extract_strategyreads the volk's reply payload, not the outgoing one; stop_repaired_trial/_heal_fallbackfrom fabricating success. (2) Wire-or-delete the deadmock_llmconfig (addmock_llmtoHarnessConfig+ CLI flag + fixture, or drop the YAML key and TST-002). (3) Optional: add thetype_check/mypy evaluator. (4) Register SPEC-102 inSPEC_INVENTORY.md. (5) S8-Scribe doc updates: FR-014/API-contract Neo4j→graph + localhost→resolvers. - Target files:
src/orchestrata_ultimate/harness/healing.py,harness/runner.py(re-verify hook),harness/models.py+harness/cli.py+harness/config.py(mock-llm), newharness/evaluators/type_check.py,specs/SPEC_INVENTORY.md,specs/102-volk-test-harness/spec.md(API-contract block). - Approach: Thread the
Scenario+ExecutorintoSelfHealingLoop.heal(or return a "re-run requested" signal toHarnessRunner) so a hop claiming repair triggers a genuine re-execution + evaluator pass before success is declared. The mock-llm and type_check items are small and self-contained. - Dependencies: couples to kernel
MessageDispatcher/CXP (SPEC-004) and to repair-capable volks (agents/volks/); graph history already wired to orchgraph. Open spec question #4 (may a repair volk edit source, or only the worktree?) still unresolved. - Effort: M (0.5–2d) — healing re-verify is the bulk; the rest is S. Risk: med — real self-healing needs a live repair-capable volk + real CXP round-trip to test meaningfully; without it the loop stays a stub and must be honestly documented, not report fake successes.
Evidence log:
symbols --pattern SelfHealingLoop→ 10 symbols (heal:126,_run_hop:222,_has_valid_strategy:306,_repaired_trial:313,_heal_fallback:331,_save_diagnostics:386,_resolve_safe_path:443,_assert_under_worktree:463).source harness.healing --no-daemon→ full 482-line module; pinnedresponse_dict["payload"] = packet.payloadat :274,"""...simulating a successful repair.""":315,passed=True:318,evaluator_results=failure.evaluator_results:319,snapshot_diff=failure.snapshot_diff:321, "optimistically assume the retry succeeds" :374.symbols --pattern mock_llm→0 symbol(s).;grep -n mock harness/config.yaml→21:mock_llm: false;source harness.config --no-daemon→_apply_yamllogs"Unknown config key: %s"(:75).source harness.models --no-daemon→HarnessConfig(:116-158) fields — nomock_llm;HarnessContext.graph_prefix(:110).ls harness/evaluators/→ base, file_exists, lint, llm_judge, syntax, trace,__init__(notype_check).source harness.history --no-daemon→JSONHistoryTracker:113,GraphHistoryTracker:211.source harness.runner --no-daemon→ 3-trial loop :106,run_volksequential :447-456,_maybe_self_heal:351 (constructsSelfHealingLoop(dispatcher=self.dispatcher)), graph non-fatal :60-66.find harness -type f→ repo-rootharness/{config.yaml, scenarios/{qa,architect,codedirector}/ {scenario_001.yaml,setup.py}}.grep -n '102' specs/SPEC_INVENTORY.md→ absent (103/104/105 at :28-30).ls src/orchestrata_ultimate/harness/__main__.py→ present (FR-016python -m …).
SPEC-103 Tool-Calling Code Refactoring — DONE
Specifies: An LLM-driven (DeepSeek deepseek-v4-pro) tool-calling layer that refactors an
existing codebase in place — OBSERVE → MUTATE → VERIFY via a sandboxed tool registry, a tool-use
loop, a refactoring system prompt, and refactor()/arefactor(); plus provider-protocol tool fields,
DeepSeek adapter tool support, and FR-009 REFACTOR-intent pipeline routing.
Verified:
- ✅ FR-001 protocol fields —
core/protocols/providers.py:81Message(tool_calls,tool_call_id,name),:96ProviderRequest(tools,tool_choice),:118ProviderResponse(tool_calls),:200RawProviderResponse(tool_calls); all default None/empty (backward-compatible). - ✅ FR-002 DeepSeek adapter —
providers/adapters/deepseek_adapter.py:56-57serialises assistanttool_callsinto the API payload,:88-94parsesmessage.tool_callsinto the raw response;tools/tool_choiceforwarded viaparameters. - ✅ FR-003/004 sandboxed registry + 7 tools —
refactor/tools.py:38RefactorTools;_resolve(:49) rejects path escape;read_file/list_dir/grep/ast_outline/edit_file/write_file/run_check(:56-174);dispatch(:182) never raises (returnsERROR: …);TOOL_SCHEMAS(:212);_CHECK_WHITELIST(:25). - ✅ FR-005/006/007 loop + prompt + entry point —
refactor/agent.py:28REFACTOR_SYSTEM_PROMPT,:56RefactorResult,:73asyncarefactor,:158syncrefactor(never raises →status="error"); loopfor i in range(max_iterations):105, dispatches viatools.dispatch:129, echoesreasoning_content:119. - ✅ FR-008 observability —
agent.pylogs each tool call/turn viacore.logging. - ✅ FR-009 pipeline wiring — DONE.
orchestrator/intent_broker.py:82enable_tool_refactor: bool = field(default=True)(config field, hencesymbolsshows 0 top-level hits), routing guard:187-194(self._enable_tool_refactor and … IntentType.REFACTOR → _handle_refactor),_handle_refactor:381imports+awaitsarefactor:408.refs arefactor→ 1 def, 3 imports, 10 uses incl.intent_broker.py:407. - ✅
call_with_tools—llm/client.py:1030(used byagent.pyandagents/volks/base.py). - ✅ CLI —
scripts/refactor.pypresent.
Remaining work / plan: None required for the capability. Optional (both S, low risk, not
blocking): (a) flip SPEC-103 status Draft→Implemented + check DoD; (b) add the on-demand
real-DeepSeek integration test (TST-103-004; needs a live DEEPSEEK_API_KEY).
Evidence log:
symbols --pattern arefactor→refactor/agent.py:73+ intent_broker/tests uses.refs arefactor→ DEF agent.py:73, IMP intent_broker.py:391, USE intent_broker.py:407.symbols --pattern _handle_refactor→ intent_broker.py:380.source orchestrator.intent_broker --no-daemon→enable_tool_refactor:82, routing :187-194,_handle_refactor:381,await arefactor:408.source core.protocols.providers --no-daemon→ Message :81, ProviderRequest :96, ProviderResponse :118, RawProviderResponse :200 (all tool fields +@traces REQ-103-001/002/003).source providers.adapters.deepseek_adapter --no-daemon→ tool_calls serialise :56-57 / parse :88-94.source refactor.tools --no-daemon→ 7 tools +dispatch(never raises) +TOOL_SCHEMAS+ whitelist.source refactor.agent --no-daemon→ prompt :28, result :56, loop :105, dispatch :129.
SPEC-104 OpenSpec Format Support — DONE
Specifies: A self-contained orchestrata_ultimate.openspec module that detects a project's spec
folder + classifies its format (openspec/orchestrata/unknown), parses/renders/validates OpenSpec
markdown, edits specs, and scaffolds change proposals — all writes sandboxed to the detected root.
Verified:
- ✅ FR-001/002 detect + recognize —
openspec/detect.py:50detect_spec_folder(never raises),:27is_openspec(case-sensitive markers; delta or Requirement+Scenario). - ✅ FR-003 parse —
openspec/parse.py:81parse_spec, delta parse,:109validate(reports violations, no raise). - ✅ FR-004/005 render/edit —
openspec/render.py:28render_spec(+ delta/proposal/tasks renderers);openspec/repo.py:29OpenSpecRepowithcapabilities(:50),read_capability(:61),write_capability(:68),add_requirement(:76),create_change(:84, refuses overwrite). - ✅ FR-006/007 validate + sandbox —
validate()returns violation list;repo._safe(:41) mirrors the SPEC-103 path-traversal sandbox. - ✅ Data models —
openspec/models.py(OpenSpecDoc/Requirement/Scenario/Delta/SpecFolder); public re-exports in__init__.py. - ✅
openspec/requirements_parser.py(new helper: spec checklists → Prolog facts) + 38 tests (tests/openspec/test_openspec.py= 19,test_requirements_parser.py= 19). refs detect_spec_folder/refs OpenSpecRepo→ 1 def +__init__import + tests only, 0 production src uses — expected: library capability, pipeline use is optional per spec ("the refactor agent MAY invoke these"). Not orphaned.
Remaining work / plan: None required. Optional (S, low risk): flip status Draft→Implemented.
Evidence log:
symbols --pattern detect_spec_folder|is_openspec|OpenSpecRepo|parse_spec|render_spec|validate→ detect.py:50/:27, repo.py:29, parse.py:81/:109, render.py:28.refs detect_spec_folder→ DEF + IMP__init__.py+ tests USE (0 src uses).refs OpenSpecRepo --no-daemon→ 1 def, 2 imports, 1 test use (0 src uses).source openspec.requirements_parser --no-daemon→parse_requirements:68,run:117 (Prolog facts).grep -rc 'def test_' tests/openspec/→ 19 + 19.
SPEC-105 Ontology-Driven Domain Model Generation — DONE
Specifies: A skill that reads an OWL/RDFS Turtle ontology → canonical DomainModel IR →
deterministic Jinja2 codegen (screaming-architecture / modular monolith) + bidirectional IR↔ontology
round-trip, generating a temporal, insert-only (bitemporal, RDF-star) Stardog repository + SHACL
constraints. Target src/orchestrata_ultimate/domaingen/.
Verified:
- ✅ FR-001 ontology→IR —
domaingen/reader.py:190parse_ontology(rdflib; classes→Entity, datatype/object props→Field/Relationship, subClassOf→parent, functional→single, minCardinality→required). - ✅ FR-002/003 IR→ontology + round-trip —
domaingen/ttl.py:101render_ontology(deterministic). - ✅ FR-004/006 IR→code deterministic —
domaingen/generator.py:90generate_code;_topo_sort:60;_safesandbox :126; templatesentities.py.j2/init.py.j2/repository.py.j2. - ✅ FR-005 centralized logging/exceptions —
repository.py.j2importscore.logging.get_logger(:19-21) +RepositoryError(BaseError)(:32). - ✅ FR-006 temporal insert-only Stardog repo —
repository.py.j2build_insert(:53),build_tombstone(:69),build_as_of(:81),build_as_recorded(:94),build_as_valid(:104),supersede(:154),PREDICATESmap (:131),_iriinjection guard (:50).domaingen/stardog.py:27StardogConnection(SPARQL-over-HTTP). - ✅ FR-007 add-a-node bidirectional regen —
generate_code+render_ontologyshare the IR. - ✅ FR-008 SHACL — now implemented + specced.
domaingen/constraints.py:26generate_shacl;generator.py:118-119emitsconstraints.ttlalongside the domain model. - ✅ SEC-105-003 —
generator.py:30-39_FORBIDDEN_SPARQL(DELETE/DROP/CLEAR variants) generation-time guard. - ✅ CLI —
scripts/domaingen.py(parse → generate /--render-ttl). - ✅ Divergence resolved. The prior audit's "relationships.py divergence" is now in the spec:
REQ-105-005 (spec.md:138) states relationships are attributes + repository
PREDICATESmap, "not a separaterelationships.py". Templates confirm norelationships.py.j2. → no remaining divergence. - Tests:
tests/domaingen/test_domaingen.py= 25,test_reader.py= 15 (40 total). DoD nearly all[x]; only the live-Stardog round-trip is[ ](explicitly deferred — no Stardog server in this env).
Remaining work / plan: No code work required. The only open item is the on-demand live-Stardog integration test (already scoped as deferred in the DoD; unit tests assert the generated SPARQL/HTTP shape). Optional (S): flip status In Review→Implemented.
Evidence log:
symbols --pattern parse_ontology|render_ontology|generate_code|generate_shacl|StardogConnection→ reader.py:190, ttl.py:101, generator.py:90, constraints.py:26, stardog.py:27.source domaingen.generator --no-daemon→_FORBIDDEN_SPARQL:30-39,_topo_sort:60,generate_code:90,constraints.ttl:118-119,_safe:126.grep -n 'build_insert|supersede|build_as_of|build_tombstone|txFrom|PREDICATES|get_logger|RepositoryError' templates/repository.py.j2→ all present; INSERT DATA only, no UPDATE/DELETE.ls domaingen/templates/→ entities.py.j2, init.py.j2, repository.py.j2 (no relationships.py.j2).grep -rc 'def test_' tests/domaingen/→ 25 + 15.- Read
specs/105-ontology-domain-model/spec.md:138(REQ-105-005 no-relationships.py text) + DoD[x]rows (:215-221).
Cluster summary table
| Spec | Class | Effort | Hard deps |
|---|---|---|---|
| SPEC-102 Volk Test Harness | PARTIAL | M | kernel MessageDispatcher/CXP (SPEC-004) + repair-capable volks (agents/volks/) for real self-healing; graph history already wired to orchgraph |
| SPEC-103 Tool-Calling Refactor | DONE | — (opt. S) | SPEC-011 provider mgr, SPEC-028 client, SPEC-004 intent/classifier — all present + wired |
| SPEC-104 OpenSpec Format | DONE | — (opt. S) | none for the capability; optional coupling to SPEC-103 RefactorTools |
| SPEC-105 Ontology Domain Model | DONE | — (opt. S) | SPEC-100 logging/exceptions (present); external Stardog for the deferred live integration test only |
Only SPEC-102 has real remaining code work (self-healing re-verify + mock-llm wire-or-delete; type_check evaluator optional). 103/104/105 are complete; 105's former relationships.py divergence is now resolved in the spec text, leaving only the deferred live-Stardog integration test.