Skip to content

Decouple the graph language from the runtime - #1500

Merged
akashgit merged 1 commit into
mainfrom
decouple-language
Sep 11, 2026
Merged

akashgit merged 1 commit into
mainfrom
decouple-language

Conversation

@akashgit

Copy link
Copy Markdown
Owner

What

Breaks the two runtime couplings in the graph language so factory.workflow imports with zero runtime deps (pydantic + stdlib only):

  1. primitives.py inlines the tiny ProjectState enum and replaces the FactoryConfig field type on Factory with dict[str, Any] (it was never read by the language).
  2. definitions.py imports ProjectState from primitives instead of factory.models.
  3. __init__.py no longer re-exports WorkflowExecutor / ExecutionResult — DSH is the runtime, not the executor.

Why

This is the first step of extracting refactory's graph semantics into a standalone language package (the PyTorch-analogy split: refactory = semantics, DSH = runtime). The runtime files (executor/skill_export/llm_loop/… ) still live in the repo and still work, but they are no longer reachable through the language import.

Tests

  • pytest tests/test_workflow_primitives.py tests/test_workflow_definitions.py — 95 passed
  • pytest tests/test_outer_loop/ — 563 passed
  • SRF graph suite — 496 passed, 1 skipped

…executor imports)

primitives.py inlines ProjectState and drops the FactoryConfig runtime type;
definitions.py imports ProjectState from primitives; __init__.py no longer
re-exports WorkflowExecutor/ExecutionResult. factory.workflow now imports with
zero runtime deps (pydantic + stdlib). DSH is the runtime.
@akashgit
akashgit merged commit 4262d36 into main Sep 11, 2026
2 of 3 checks passed
@github-actions

Copy link
Copy Markdown

Sentrux Quality Report

Absolute

Scanning ....
[scan] git ls-files: 651 total, 637 kept, 14 dropped (ext:14, meta:0, big:0)
[build_project_map] 637 files, 108 unique dirs, 100 cache misses, 5.3ms
[resolve] 1293 resolved, 1680 unresolved (of 2973 total specs)
[resolve_imports] project_map 5.4ms, suffix_idx 1.2ms, suffix_resolve 20.0ms, total 26.6ms
[build_graphs] 637 files | maps 2.4ms, imports 26.8ms, calls+inherit 7.0ms, total 36.2ms | 1292 import, 10486 call, 4 inherit edges
sentrux check — 3 rules checked

Quality: 4400

✗ [Error] max_cc: 9 function(s) exceed max cyclomatic complexity of 30
    factory/workflow/executor.py:_execute_data (cc=53)
    factory/outer_loop/reflector.py:_extract_eval_patterns (cc=46)
    factory/cli/_ceo_helpers.py:_validate_ceo_flags (cc=43)
    factory/cli/_ceo_helpers.py:_execute_ceo (cc=43)
    factory/outer_loop/mutations.py:_try_mutation (cc=40)
    examples/chess_evolve.py:main (cc=33)
    factory/cli/_task_builder.py:_build_ceo_task (cc=32)
    factory/outer_loop/reflector.py:_llm_reflect (cc=32)
    factory/outer_loop/mutations.py:validate_and_repair (cc=31)

✗ 1 violation(s) found

Diff (vs base branch)

Scanning ....
[scan] git ls-files: 651 total, 637 kept, 14 dropped (ext:14, meta:0, big:0)
[build_project_map] 637 files, 108 unique dirs, 100 cache misses, 5.4ms
[resolve] 1293 resolved, 1680 unresolved (of 2973 total specs)
[resolve_imports] project_map 5.5ms, suffix_idx 1.2ms, suffix_resolve 23.0ms, total 29.7ms
[build_graphs] 637 files | maps 2.6ms, imports 29.9ms, calls+inherit 7.6ms, total 40.2ms | 1292 import, 10486 call, 4 inherit edges
sentrux gate — structural regression check

Quality:      4415 -> 4400
Coupling:     0.81 → 0.81
Cycles:       3 → 4
God files:    3 → 3

Distance from Main Sequence: 0.35

✗ DEGRADED
  ✗ Cycles increased: 3 → 4

@codecov

codecov Bot commented Sep 11, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.76%. Comparing base (f0d28a0) to head (7ad78fe).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1500   +/-   ##
=======================================
  Coverage   83.75%   83.76%           
=======================================
  Files         225      225           
  Lines       25757    25760    +3     
  Branches     4209     4209           
=======================================
+ Hits        21574    21578    +4     
  Misses       3201     3201           
+ Partials      982      981    -1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

colehurwitz added a commit that referenced this pull request Sep 15, 2026
…low.primitives (#1504)

After PR #1500 decoupled the graph language from the runtime, Workflow.trigger's
type signature references primitives.ProjectState, but 23 workflow/test files
still imported from factory.models — creating 68 mypy arg-type errors.

This changes all 23 files to import ProjectState from factory.workflow.primitives,
which is the correct source for the workflow subsystem per the decoupling design.

Files changed:
- 3 core workflow modules (research, deep_research, deep_qa)
- 11 contributed benchmark workflows
- 9 contributed benchmark test files

Verification:
- mypy factory/ | grep arg-type → 0 results
- pytest factory/workflow/contributed/ → 257 passed
- ruff check → all passed

Co-authored-by: Cole Hurwitz <colehurwitz@users.noreply.github.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant