Skip to content

extend architecture enforcement to orchestration code (2.4.5) - #143

Open
leynos wants to merge 24 commits into
mainfrom
2-4-5-extend-architecture-enforcement-to-orchestration-code
Open

extend architecture enforcement to orchestration code (2.4.5)#143
leynos wants to merge 24 commits into
mainfrom
2-4-5-extend-architecture-enforcement-to-orchestration-code

Conversation

@leynos

@leynos leynos commented Jun 15, 2026

Copy link
Copy Markdown
Owner

Summary

This pull request completes roadmap item 2.4.5 — Extend architecture
enforcement to orchestration code
.

The branch extends Hecate architecture checks over orchestration-facing code,
splits LangGraph node logic from graph composition, extracts a provider-neutral
worker workload contract, and adds checkpoint payload boundary enforcement.

What changed

  • Split structured generation LangGraph orchestration into ports-only node code
    and an application-tier graph builder behind the existing public facade.
  • Added Hecate groups for orchestration nodes, orchestration builders, Celery
    tasks, and checkpoint payload DTOs.
  • Extracted WorkloadClass into a provider-neutral worker contract so Celery
    tasks can depend on domain/application contracts without importing Kombu.
  • Added checkpoint payload boundary checks, including structural and property
    coverage for the checkpoint serializer allow-list.
  • Added BDD architecture scenarios, normalized Hecate JSON snapshot coverage,
    and a direct Vidai Mock-backed LangGraph plan -> execute -> finish test.
  • Recorded ADR-016 and updated architecture, developer, roadmap, and execution
    plan documentation.

Validation

  • make check-fmt
  • make test (1030 passed, 3 skipped)
  • make typecheck
  • make lint
  • make markdownlint
  • make nixie
  • coderabbit review --agent after M0, M1, M2, M3, and M4; each completed with
    0 findings.

References

@coderabbitai

coderabbitai Bot commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Summary

  • Extended Hecate architecture enforcement to orchestration code with dedicated groups for LangGraph nodes, orchestration modules, worker tasks and checkpoint payloads.
  • Split LangGraph node logic from graph composition and side-effect wiring.
  • Added provider-neutral orchestration payload DTOs, JSON checkpoint validation and the shared WorkloadClass contract.
  • Added architecture fixtures and coverage across BDD, property, snapshot and Vidai Mock-backed behavioural tests.
  • Added ADR-016 and the 2.4.5 ExecPlan, with related documentation updates.
  • Refactored structured logging and addressed CodeRabbit complexity and method-length findings.

Validation passed: 1030 tests passed, 3 skipped, alongside formatting, type checking, linting, markdown linting, Nixie and staged CodeRabbit reviews.

Walkthrough

This change extends Hecate enforcement to orchestration modules, introduces provider-neutral payload DTOs and JSON checkpoint validation, splits graph nodes from assembly, centralizes structured logging, adds worker workload contracts, and expands documentation, fixtures, architecture tests, snapshots, and integration coverage.

Changes

Orchestration architecture enforcement

Layer / File(s) Summary
Architecture decisions and implementation plan
docs/adr/*, docs/execplans/*, docs/developers-guide.md, docs/episodic-podcast-generation-system-design.md, docs/langgraph-and-celery-in-hexagonal-architecture.md, docs/roadmap.md, docs/contents.md
Documents ADR-016, Hecate group boundaries, orchestration guardrails, checkpoint rules, implementation milestones, and roadmap coverage.
Provider-neutral payload and worker contracts
episodic/orchestration/*_payload*, episodic/orchestration/*_dto.py, episodic/orchestration/_types.py, episodic/worker/*, episodic/logging.py
Adds normalized orchestration DTOs, provider-neutral attachment protocols, JSON checkpoint validation, centralized structured logging, and a separate WorkloadClass enum.
Generation graph execution flow
episodic/orchestration/_graph_nodes.py, episodic/orchestration/_graph_builder.py, episodic/orchestration/langgraph.py
Separates plan, execute, and finish nodes from graph assembly while wiring checkpoint suspension, callbacks, cost recording, and compatibility exports.
Hecate configuration and architecture fixtures
pyproject.toml, tests/architecture_hecate_config.py, tests/fixtures/architecture/*
Adds orchestration checkpoint and task groups, expands allowed prefixes, and creates accepted and rejected boundary fixtures.
Validation and integration coverage
tests/test_architecture_enforcement.py, tests/test_architecture_hecate_config.py, tests/features/*, tests/steps/*, tests/test_checkpoint_payload_boundaries.py, tests/test_generation_orchestration_langgraph_vidaimock.py
Adds Hecate snapshots, BDD scenarios, provider-neutral type checks, JSON round-trip checks, configuration assertions, and Vidai Mock-backed graph tests.
Spelling configuration updates
typos.toml
Updates spelling exclusions and project-specific word mappings.

Sequence Diagram(s)

sequenceDiagram
  participant Request
  participant Planner
  participant LangGraph
  participant ToolExecutor
  participant Checkpoint
  participant CostRecorder
  Request->>LangGraph: submit generation request
  LangGraph->>Planner: plan request
  Planner-->>LangGraph: planner result
  LangGraph->>ToolExecutor: execute ordered actions
  ToolExecutor-->>LangGraph: action results
  LangGraph->>Checkpoint: suspend or persist checkpoint state
  LangGraph->>CostRecorder: record provider usage
  LangGraph-->>Request: orchestration result
Loading

Possibly related PRs

Suggested labels: Roadmap

Suggested reviewers: codescene-delta-analysis

Poem

Nodes march in ordered flight,
DTOs keep their payloads light.
Hecate guards each import door,
Checkpoints JSON-safe evermore.
Plans execute, then results gleam—
A well-typed orchestration dream.

🚥 Pre-merge checks | ✅ 18 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
User-Facing Documentation ⚠️ Warning The PR changes orchestration enforcement and checkpoint/workload behaviour, but docs/users-guide.md is untouched and lacks the new Hecate groups and ADR-016 detail. Add a users-guide section covering orchestration enforcement, checkpoint payload rules, and the WorkloadClass split, or state clearly that these changes are developer-only.
Observability ⚠️ Warning Structured logs were added, but the touched orchestration/worker surface has no tracing or metrics hooks, so boundary-crossing behaviour stays under-observed. Add spans and bounded metrics at plan/execute/finish, checkpoint persist/resume, and Celery route/task boundaries; keep stable IDs only.
✅ Passed checks (18 passed)
Check name Status Explanation
Title check ✅ Passed The title matches the PR scope and includes the roadmap item reference 2.4.5.
Description check ✅ Passed The description is clearly aligned with the orchestration enforcement changes and documentation updates.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Testing (Overall) ✅ Passed Added tests are substantive: Hecate CLI/integration checks, Hypothesis boundary properties, snapshots with real diagnostics, and a Vidai Mock end-to-end graph run.
Developer Documentation ✅ Passed Developer guide, ADR-016, system design, roadmap, and execplan all reflect the orchestration boundary changes; 2.4.5 is checked off.
Module-Level Documentation ✅ Passed All 68 touched Python modules open with a module docstring; the key orchestration modules also state their role and relationships clearly.
Testing (Unit And Behavioural) ✅ Passed Unit tests cover CLI/config errors, JSON invariants and edge cases; behavioural tests hit real Hecate and Vidai Mock workflows, not private mocks.
Testing (Property / Proof) ✅ Passed PASS: The PR adds Hypothesis coverage for checkpoint JSON round-trips and DTO neutrality, plus parametrised validator dispatch for orchestration invariants.
Testing (Compile-Time / Ui) ✅ Passed No Rust/TS compile-time surface exists here; structured Hecate and orchestration outputs are covered by focused, semantic snapshots and supporting assertions.
Unit Architecture ✅ Passed PASS: The PR makes boundaries more explicit via ports, DTOs, and split orchestration modules; commands and fallible checkpoints now expose their seams and tests cover them.
Domain Architecture ✅ Passed PASS: The PR keeps SQLAlchemy, Celery, Kombu, and JSON handling at adapter/DTO seams; the core domain remains enum/dataclass-only and imports no infrastructure.
Security And Privacy ✅ Passed No secrets, unsafe deserialisation, auth bypass, or sensitive-data leaks appear in the changed code, tests, snapshots, or docs.
Performance And Resource Use ✅ Passed New loops are linear and bounded by plan or payload size; Vidai polling has a 5s timeout, and no unbounded collections or repeated I/O were added on hot paths.
Concurrency And State ✅ Passed Concurrency is explicit: ordered async nodes, sync callback caveat, atomic checkpoint idempotency, and tests cover concurrent saves/callbacks.
Architectural Complexity And Maintainability ✅ Passed PASS: New seams are concrete and scoped; _payload_dto and WorkloadClass/log_event remove duplication, GraphExtensions is a narrow optional-collaborator bundle, and no import cycles appear.
Rust Compiler Lint Integrity ✅ Passed No Rust files or Cargo manifests are changed, so the lint-integrity check is inapplicable; no suppressions or suspicious clones appear in the touched surface.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 2-4-5-extend-architecture-enforcement-to-orchestration-code

Warning

Your free Security trial is over. An organization admin can activate billing to continue.


Comment @coderabbitai help to get the list of available commands.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @leynos, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@lodyai
lodyai Bot force-pushed the 2-4-5-extend-architecture-enforcement-to-orchestration-code branch from d6ec9f0 to ec44417 Compare June 26, 2026 17:34
@lodyai lodyai Bot changed the title Plan: extend architecture enforcement to orchestration code (2.4.5) extend architecture enforcement to orchestration code (2.4.5) Jun 26, 2026
codescene-access[bot]

This comment was marked as outdated.

codescene-access[bot]

This comment was marked as outdated.

codescene-access[bot]

This comment was marked as outdated.

codescene-access[bot]

This comment was marked as outdated.

codescene-access[bot]

This comment was marked as outdated.

codescene-access[bot]

This comment was marked as outdated.

codescene-access[bot]

This comment was marked as outdated.

codescene-access[bot]

This comment was marked as outdated.

codescene-access[bot]

This comment was marked as outdated.

codescene-access[bot]

This comment was marked as outdated.

codescene-access[bot]

This comment was marked as outdated.

codescene-access[bot]

This comment was marked as outdated.

@leynos

leynos commented Jul 21, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai Please suggest a fix for this issue and supply a prompt for an AI coding agent to enable it to apply the fix. Include the file and symbol names indicated in the issue at the head of your response. Ensure that this is validated against the current version of the codegraph.

If further refinement to address this finding would be deleterious, please supply a clear explanatory one to two paragraph markdown message I can paste into the CodeScene web ui's diagnostic suppression function so this diagnostic can be silenced.

Large Method

tests/test_architecture_hecate_config.py: test_fixture_config_writes_expected_toml_shape

What lead to degradation?

test_fixture_config_writes_expected_toml_shape has 85 lines, threshold = 70

Why does this problem occur?

Overly long functions make the code harder to read. The recommended maximum function length for the Python language is 70 lines of code. Severity: Brain Method - Complex Method - Long Method.

How to fix it?

We recommend to be careful here -- just splitting long functions don't necessarily make the code easier to read. Instead, look for natural chunks inside the functions that expresses a specific task or concern. Often, such concerns are indicated by a Code Comment followed by an if-statement. Use the EXTRACT FUNCTION refactoring to encapsulate that concern.

@leynos

leynos commented Jul 21, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai Please suggest a fix for this issue and supply a prompt for an AI coding agent to enable it to apply the fix. Include the file and symbol names indicated in the issue at the head of your response. Ensure that this is validated against the current version of the codegraph.

If further refinement to address this finding would be deleterious, please supply a clear explanatory one to two paragraph markdown message I can paste into the CodeScene web ui's diagnostic suppression function so this diagnostic can be silenced.

Complex Method

tests/test_checkpoint_payload_boundaries.py: _is_provider_neutral_origin

What lead to degradation?

_is_provider_neutral_origin has a cyclomatic complexity of 10, threshold = 9

Why does this problem occur?

A Complex Method has a high cyclomatic complexity. The recommended threshold for the Python language is a cyclomatic complexity lower than 9.

How to fix it?

There are many reasons for Complex Method. Sometimes, another design approach is beneficial such as a) modeling state using an explicit state machine rather than conditionals, or b) using table lookup rather than long chains of logic. In other scenarios, the function can be split using EXTRACT FUNCTION. Just make sure you extract natural and cohesive functions. Complex Methods can also be addressed by identifying complex conditional expressions and then using the DECOMPOSE CONDITIONAL refactoring.

Helpful refactoring examples

To get a general understanding of what this code health issue looks like - and how it might be addressed - we have prepared some diffs for illustrative purposes.

SAMPLE

# complex_method.js
 function postItem(item) {
   if (!item.id) {
-    if (item.x != null && item.y != null) {
-      post(item);
-    } else {
-      throw Error("Item must have x and y");
-    }
+    // extract a separate function for creating new item
+    postNew(item);
   } else {
-    if (item.x < 10 && item.y > 25) {
-      put(item);
-    } else {
-      throw Error("Item must have an x and y value between 10 and 25");
-    }
+    // and one for updating existing items
+    updateItem(item);
   }
 }
+
+function postNew(item) {
+  validateNew(item);
+  post(item);
+}
+
+function updateItem(item) {
+  validateUpdate(item);
+  put(item);
+}
+

@coderabbitai

This comment was marked as resolved.

@coderabbitai

This comment was marked as resolved.

@lodyai
lodyai Bot force-pushed the 2-4-5-extend-architecture-enforcement-to-orchestration-code branch from 589a65e to bd7312d Compare July 21, 2026 22:02
codescene-access[bot]

This comment was marked as outdated.

codescene-access[bot]

This comment was marked as outdated.

codescene-access[bot]

This comment was marked as outdated.

codescene-access[bot]

This comment was marked as outdated.

codescene-access[bot]

This comment was marked as outdated.

@lodyai
lodyai Bot force-pushed the 2-4-5-extend-architecture-enforcement-to-orchestration-code branch from 5cb6ed4 to 145a65f Compare July 28, 2026 22:19
codescene-access[bot]

This comment was marked as outdated.

codescene-access[bot]

This comment was marked as outdated.

leynos and others added 24 commits August 25, 2026 11:44
Draft the ExecPlan for roadmap item 2.4.5, which extends Hecate
architecture enforcement to LangGraph orchestration code, Celery tasks,
and checkpoint payloads.

The plan reconciles the roadmap's "ports only" wording with the system
design's "domain services and ports only", and proposes three new
first-match Hecate groups (orchestration, orchestration_tasks,
orchestration_checkpoint) plus two boundary fixes surfaced during
research: extracting WorkloadClass out of the kombu-coupled worker
topology module, and decoupling checkpoint DTOs from the
application-tier generation DTO barrel. It also resolves the existing
400-line limit breach in langgraph.py via a node/builder split.

Enforcement is validated through synthetic architecture fixtures
(positive and negative), a structural reflection test and a Hypothesis
property test for checkpoint payloads, a syrupy snapshot of Hecate
output, a pytest-bdd feature, and a vidai-mock-backed behavioural test
of the generation graph.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Mark the 2.4.5 ExecPlan as in progress and record the clean rebase,
post-rebase validation, PR title update, and active Lody session
reference.
Extend the synthetic Hecate fixture config with orchestration node,
task, and checkpoint groups so upcoming production rules have red
harness coverage before the real `pyproject.toml` policy changes.

Add positive and negative fixture packages for LangGraph nodes, Celery
tasks, checkpoint payloads, and grouped adapter guard cases. Record M0
completion and validation evidence in the ExecPlan.
Update the 2.4.5 ExecPlan with the CodeRabbit result for the M0
fixture-harness milestone so the plan remains resumable.
Move LangGraph node functions and graph assembly into focused modules
so architecture enforcement can target graph orchestration separately.
Note the zero-finding CodeRabbit review for the orchestration graph split milestone.
Move WorkloadClass into a provider-neutral worker module so task
architecture enforcement no longer depends on the Kombu topology module.
Note the zero-finding CodeRabbit review for the worker workload contract milestone.
Add a provider-neutral orchestration payload DTO core and retarget checkpoint serialization away from the application-coupled DTO barrel.

Group checkpoint payload modules under Hecate, add JSON-shape and structural payload boundary tests, and record the M3 decisions in the ExecPlan.
Record the clean CodeRabbit review result for the checkpoint payload boundary milestone before starting the final behavioural and documentation work.
Add behavioural and snapshot coverage for orchestration architecture
boundaries, including Vidai Mock coverage for the direct LangGraph path.

Record ADR-016, update maintainer documentation, and mark roadmap item
`2.4.5` complete.
Update the orchestration enforcement execplan with the clean CodeRabbit
review result after the M4 documentation and test coverage milestone.
Reconstruct the first-match architecture group ordering after the rebase silently duplicated the outbound adapter table. Preserve main’s updated LLM adapter prefix while restoring the branch’s orchestration, checkpoint, and worker task boundaries.
Apply the Oxford spelling forms required by the new repository spelling gate, regenerate the typos configuration, and remove a duplicated ingestion workflow block exposed by Markdown lint.
Replace conditional generic-origin validation with a validator dispatch table while preserving recursive payload-boundary semantics.

Add direct parametrized coverage for every supported origin category and unsupported generics.
Separate base architecture expectations from orchestration-specific group expectations while keeping the fixture config test as the orchestration point.
Set the ExecPlan status to `COMPLETE` and remove the stale M4 outstanding-work
statement while preserving the completed milestone and gate records.
Show the IO-bound workload member and its serialized value in both the module and class docstrings.
Document the dedicated `orchestration_nodes` boundary and its checkpoint DTO
and domain-port dependencies. Use `episodic.worker.workloads.WorkloadClass`
as the canonical task contract, while identifying the topology path as a
compatibility alias only.
Mark the ExecPlan complete and replace stale M4 implementation claims with a
completed outcome while retaining the milestone and final-gate evidence.
Give graph nodes their own strict Hecate group while allowing broader orchestration modules to assemble them. Align architecture documentation, fixture typing, diagnostics, and command-format coverage with the production policy.
Normalize non-JSON structured log fields and require checkpoint payloads to survive JSON round trips without data loss. Cover representative logging values and lossy checkpoint shapes.
Use slotted graph extensions, pass finish callbacks their DTO directly, and replace payload-boundary Any types with provider-neutral protocols. Guard Vidai Mock cleanup before process startup.
Preserve architecture fixture semantics while satisfying the stricter lint
rules from `main`. Remove the obsolete command snapshot after parametrizing
its text and JSON formats, and restore documentation required by current
public-function checks.
@leynos
leynos force-pushed the 2-4-5-extend-architecture-enforcement-to-orchestration-code branch from d161200 to 5b1e8aa Compare August 25, 2026 10:46

@codescene-access codescene-access Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gates Failed
New code is healthy (1 new file with code health below 10.00)
Enforce advisory code health rules (1 file with Code Duplication)

Our agent can fix these. Install it.

Gates Passed
4 Quality Gates Passed

Reason for failure
New code is healthy Violations Code Health Impact
test_checkpoint_payload_boundaries.py 1 rule 9.39 Suppress
Enforce advisory code health rules Violations Code Health Impact
test_checkpoint_payload_boundaries.py 1 advisory rule 9.39 Suppress

See analysis details in CodeScene

Quality Gate Profile: Pay Down Tech Debt
Install CodeScene MCP: safeguard and uplift AI-generated code. Catch issues early with our IDE extension and CLI tool.

@codescene-access codescene-access Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No quality gates enabled for this code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant