verification package

Reviewed against commit 8a2cb42ad on 2026-10-23.

Reference: generated package page orchestrata_ultimate.verification (66 modules in 9,151 lines of code across the root and 16 subpackages); key modules types, spec_completeness, implementation_scanner, traceability, review, verification engine. The orchestrator reaches the package through its verification_gate (orchestrator); the RTM and spec model it checks against are explained in the orchestrata overview (section 9), and the requirement-checklist parser is in openspec.

The story

orchestrata_ultimate.verification is the Verification Agent (Spec 035, historically Spec 007b) — the part of the pipeline whose job is to refuse to take generated work on faith. Orchestrata's volks produce code and artifacts at speed; something has to answer, formally and repeatably, the question "does this actually satisfy the requirements?" This package is that answer. It turns natural-language requirements into formal constraints, evaluates them (with Prolog and a chain of LLM judges), advances the work through named checkpoints, verifies proofs, runs a deterministic no-LLM code review, applies automated fixes, and — when attempts are exhausted or a requirement is genuinely impossible — escalates to a human rather than declaring false success.

A verification pass flows through a few clearly separated stages. Requirements enter through requirements/requirements_parser.py, which converts natural language into Constraint objects (the shared vocabulary of the whole package lives in types.py: ConstraintType, VerificationStatus, CheckpointName, ProofType, SessionStatus, plus dataclasses like Constraint, VerificationResult, Proof and Suggestion). requirements/prolog_generator.py translates those constraints into Prolog predicates so constraints/evaluator.ConstraintEvaluator can check them mechanically. From there the work advances through the checkpoint machinery — checkpoints/definitions.py names the stages and their criteria, checkpoints/verifier.CheckpointVerifier performs the state transitions, and checkpoints/concurrent.ConcurrentCheckpointEvaluator evaluates them in parallel — while proofs/verifier.ProofVerifier validates the four proof types that supervisors attach to their claims. orchestration/coordinator.VerificationCoordinator conducts this whole workflow, and verification/engine.VerificationEngine is the core engine that produces VerificationResults, with verification/feedback.FeedbackGenerator converting failures into actionable Suggestions that flow back to the executing agent for another attempt.

The package deliberately keeps two verification styles side by side. The LLM side is embodied by three cooperating agent roles in agents/ (an ExecutionAgent that implements, a SupervisorAgent that reviews and generates proofs, and a VerificationAgent that verifies), whose model calls route through the models/ subpackage — an LLMModel protocol behind a ModelRegistry and ModelFallbackChain, with concrete wrappers for Claude Opus, Deepseek R1, Grok/MiniMax and Qwen Max, configured by config/verification_config.py. The deterministic side is the review/ subpackage: run_deterministic_review collects the workspace and runs four check families (correctness, quality, safety, structure) without any model in the loop, then issue_triage.prioritize_issues sorts and caps the findings. When failures are mechanical, autofix/run_all_autofixes repairs them automatically — format, import and Redis fix families each returning an AutofixResult — before the work is re-verified. edge_cases/ and impossibility/ guard the boundaries: known edge cases are stored and detected, and requirements that cannot be satisfied are routed to the ImpossibilityHandler instead of an infinite retry loop, with escalation_handler.EscalationHandler handing the case to a human once max attempts are spent.

Around the edges, the package collaborates with the rest of orchestrata through thin adapters rather than direct coupling: protocols/verification_cxp.VerificationCXPAdapter speaks the CXP message protocol to other agents, integrations/intent_broker.IntentBrokerAdapter connects to the Intent Broker, integrations/redis_manager.VerificationRedisManager persists verification state in Redis, and session/verification_session.VerificationSessionManager tracks long-running verification sessions. Finally, the package root re-exports its spec-conformance surface used project-wide: traceability.py (the standalone @traces-decorator engine that scans source for requirement traces and generates the Requirements Traceability Matrix) and spec_completeness.evaluate_spec_completeness (Prolog-based checklist evaluation) — which is why nearly every module in the dependency graph points at traces and types.

Key responsibilities

Class diagram

Core data model (types.py)

The dataclasses that flow between every stage. A Constraint enters the pipeline; a VerificationResult or CheckpointResult comes out; a Proof/ProofResult pair carries a supervisor's claim and its verdict; a Suggestion carries feedback back to the executor. (Generated from the AST, render-verified.)

Diagram projects-orchestrata-ultimate-modules-verification-1

Verification engine core

The Prolog/deterministic evaluation spine: the engine composes a constraint evaluator and a checkpoint verifier; the concurrent evaluator fans checkpoints out; the proof verifier validates the four proof types; the feedback generator turns failures into suggestions. (Generated from the AST, render-verified.)

Diagram projects-orchestrata-ultimate-modules-verification-2

Agents, orchestration and models

The three cooperating agent roles plus the coordinator that conducts the CXP workflow, and the pluggable LLM layer behind them. LLMModel is a Protocol; ModelFallbackChain structurally satisfies it and wraps an ordered list of models so one failure falls through to the next. (Generated from the AST, render-verified.)

Diagram projects-orchestrata-ultimate-modules-verification-3

Boundary guards

What stops the pipeline from looping forever or lying about success: escalation to a human, contradiction/impossibility detection, and edge-case detection backed by a small store. (Generated from the AST, render-verified.)

Diagram projects-orchestrata-ultimate-modules-verification-4

Type hierarchy

The package's inheritance is mostly a set of StrEnum vocabularies plus the LLMModel protocol (generated from the AST, render-verified):

Diagram projects-orchestrata-ultimate-modules-verification-5

Module dependency diagram

Internal module imports within orchestrata_ultimate.verification (generated from the AST, render-verified):

Diagram projects-orchestrata-ultimate-modules-verification-6

Module inventory

Module Purpose
__init__.py Package entry — Verification Agent (Spec 035, historically 007b); re-exports spec-completeness + traceability API
types.py Core type definitions: ConstraintType, VerificationStatus, CheckpointName, ProofType, SessionStatus enums; Constraint, VerificationResult, Proof, ProofResult, CheckpointResult, Suggestion dataclasses
escalation_handler.py EscalationHandler — escalation from max attempts to a human
spec_completeness.py Spec completeness evaluation via Prolog (evaluate_spec_completeness)
implementation_scanner.py The evidence half of the spec-completeness check (added after the first version of this page; rebuilt 2026-08-12 around the AST layer): scans a project's AST for proof that each spec requirement was built and emits implemented/2 facts, through a registry of detectors (DetectorMeta, EvidenceRecord, EvidenceContext). A name that appears only in a comment, docstring or string literal can no longer count as evidence.
_non_python_scan.py Non-Python evidence collection for implementation_scanner (NonPythonSymbol, NonPythonSource, JS/TS symbols and a diagnostic).
rtm_constraints.py RTM integrity constraints (SPEC-033 REQ-033-C4): RtmFacts, RtmViolation and check_rtm(facts), which asserts the facts as ground Prolog facts and enumerates every violation.
traceability.py Standalone traceability engine for spec verification — TraceInfo, Requirement, UserStory, ValidationReport, RTMReport; scans @traces decorators and generates the RTM
agents/execution_agent.py ExecutionAgent — implements solutions
agents/supervisor_agent.py SupervisorAgent — reviews work, generates proofs
agents/verification_agent.py VerificationAgent — the verifying agent itself
autofix/engine.py Autofix engine — run_all_autofixes runs all fixes in order
autofix/format_fixes.py Format-related fixes (line length, parse_args, F821 datetime)
autofix/import_fixes.py Import-related fixes (relative imports, import order, missing stdlib/bare-name imports)
autofix/redis_fixes.py Redis-related fixes (aioredis, sync redis, decode, hardcoded host, xadd/hset dicts)
autofix/helpers.py Shared autofix helpers (walk_python_files)
autofix/types.py AutofixResult result type
checkpoints/definitions.py Checkpoint definitions and criteria (get_next_checkpoint, get_checkpoint_predicates)
checkpoints/verifier.py CheckpointVerifier — checkpoint verification and state transitions
checkpoints/concurrent.py ConcurrentCheckpointEvaluator — concurrent checkpoint evaluation
config/verification_config.py ModelConfig, VerificationConfig settings
constraints/definitions.py Constraint type helpers (is_blocking, group_by_type, sort_by_priority, filter_by_type)
constraints/evaluator.py ConstraintEvaluator — evaluates constraints against work
edge_cases/database.py EdgeCaseDatabase — edge case storage and retrieval
edge_cases/detector.py Edge case detection system — EdgeCase, EdgeCaseSeverity, EdgeCaseCategory, EdgeCaseCoverage, EdgeCaseDetector
impossibility/handler.py ImpossibilityHandler — impossibility detection and handling
integrations/intent_broker.py IntentBrokerAdapter — Intent Broker integration
integrations/redis_manager.py VerificationRedisManager — Redis integration for verification state
models/base_model.py LLMModel protocol, ModelRegistry, ModelFallbackChain
models/opus.py ClaudeOpusModel — Claude Opus 4 wrapper for verification
models/deepseek_r1.py DeepseekR1Model wrapper
models/grok4_minimax.py GrokMiniMaxModel wrapper
models/qwen_max.py QwenMaxModel wrapper
orchestration/coordinator.py VerificationCoordinator — verification workflow coordination
proofs/verifier.py ProofVerifier — proof verification (4 proof types)
protocols/verification_cxp.py VerificationCXPAdapter — CXP protocol adapter for verification messages
requirements/requirements_parser.py RequirementsParser — natural-language requirements → formal constraints
requirements/constraint_definitions.py Predefined constraint specifications/templates (get_constraints_by_type, get_constraint_by_id)
requirements/prolog_generator.py PrologGenerator — converts Constraint objects into Prolog predicates
review/engine.py Review engine — run_deterministic_review, format_review_report; orchestrates all deterministic checks
review/checks_correctness.py Correctness checks: imports, file completeness, entry points, dependency declaration
review/checks_quality.py Quality checks: type hints, mutable defaults, docstrings, line length
review/checks_safety.py Safety checks: security, env access, test isolation, TODOs, mocks, lint
review/checks_structure.py Structure checks: function length/args, placeholders/stubs, error handling, nesting depth, god objects
review/helpers.py Review helpers: parsing, pyproject deps, workspace file collection
review/issue_triage.py Issue triage — prioritize_issues sorts/caps issues by severity
review/types.py Type aliases for the deterministic review module
session/verification_session.py VerificationSessionManager — verification session management
verification/engine.py VerificationEngine — core verification engine
verification/feedback.py FeedbackGenerator — actionable feedback generation

types.py

types.py is the shared vocabulary the entire package is written in, and the reason nearly every arrow in the dependency diagram converges on types. It defines the five StrEnum families — ConstraintType (functional/quality/performance/security), VerificationStatus (satisfied/not_met/partial/error/pending), CheckpointName (core_implementation → final_verification), ProofType (exhaustive_search/logical_deduction/mathematical/practical_explanation) and SessionStatus (active/completed/failed/escalated) — together with the dataclasses that flow between stages: a Constraint enters the pipeline, a VerificationResult or CheckpointResult comes out, a Proof/ProofResult pair carries a supervisor's claim and its verdict, and a Suggestion carries feedback back to the executor. Because every subpackage (constraints, checkpoints, proofs, agents, orchestration, review) speaks these types, they can be composed freely without knowing about each other's internals.

Class map (generated)

Generated from the live source AST by scripts/gen-module-class-diagrams.py — do not hand-edit. Abstract classes have a green border; members listed are those defined on the class itself (inherited members excluded). Solid empty-triangle arrows = in-package inheritance; dashed arrows into dashed boxes = external/stdlib/cross-package bases; filled diamond = composition (constructed in __init__); open diamond = aggregation (annotated/injected reference); diamond edge labels name the owning attribute.

verification class map