Skip to content

feat: add portable optimize workflow for MCMC sampler optimization - #1413

Closed
xukai92 wants to merge 1 commit into
mainfrom
factory/run-8bfc5da4
Closed

feat: add portable optimize workflow for MCMC sampler optimization#1413
xukai92 wants to merge 1 commit into
mainfrom
factory/run-8bfc5da4

Conversation

@xukai92

@xukai92 xukai92 commented Aug 31, 2026

Copy link
Copy Markdown
Collaborator

Closes the optimize workflow task from the approved strategy spec.

Changes

  • Added .factory/workflows/optimize.py — an 18-node portable workflow DAG for single-function MCMC sampler optimization:
    • Precondition check (FnNode): validates --focus function exists in Reference/Reference.jl
    • Parallel research (3 AgentNodes): semantics, conventions, and Julia perf researchers via fork/join
    • Research gate (GateNode/CEO): reviews research quality with RELOOP to fork_research
    • Strategist (AgentNode): synthesizes research into prioritized optimization strategy
    • Strategy gate (GateNode/USER): user approval before implementation
    • Builder (AgentNode, max_iterations=3): implements optimizations with RELOOP from QA gate
    • Build gate (GateNode/CEO): verifies builder output
    • Parallel QA (3 FnNodes): conformance replay, test suite, benchmark via fork/join
    • QA gate (GateNode/fn): deterministic check with RELOOP to builder (max 3)
    • Archivist (AgentNode, async): records optimization results
  • Added tests/test_workflow_optimize.py with 24 tests covering:
    • Graph validation (no orphans, no unreachable nodes)
    • Trigger function (requires mode='optimize' + focus)
    • RELOOP edges (gate_qa→builder, gate_build→builder, gate_research→fork_research)
    • Node count (18) and type assertions
    • Fork/join consistency (research and QA)
    • Sacred constraints in builder prompt
  • Workflow is auto-discovered by WorkflowRegistry as a project-local workflow
  • Requires --mode optimize --focus <function_name> to activate

18-node DAG with parallel research (semantics, conventions, Julia perf),
user-approved strategy gate, builder with RELOOP (max 3 iterations),
parallel QA (conformance replay, tests, benchmark), and async archival.

Auto-discovered by WorkflowRegistry from .factory/workflows/optimize.py.
Requires --mode optimize --focus <function_name>.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

Sentrux Quality Report

Absolute

Scanning ....
[scan] git ls-files: 628 total, 614 kept, 14 dropped (ext:14, meta:0, big:0)
[build_project_map] 614 files, 110 unique dirs, 101 cache misses, 5.3ms
[resolve] 1163 resolved, 1576 unresolved (of 2739 total specs)
[resolve_imports] project_map 5.4ms, suffix_idx 1.0ms, suffix_resolve 18.7ms, total 25.1ms
[build_graphs] 614 files | maps 2.2ms, imports 25.3ms, calls+inherit 6.0ms, total 33.4ms | 1162 import, 8414 call, 1 inherit edges
sentrux check — 3 rules checked

Quality: 4448

✗ [Error] max_cc: 6 function(s) exceed max cyclomatic complexity of 30
    factory/cli/_ceo_helpers.py:_validate_ceo_flags (cc=43)
    factory/cli/_ceo_helpers.py:_execute_ceo (cc=43)
    examples/chess_evolve.py:main (cc=33)
    factory/cli/_task_builder.py:_build_ceo_task (cc=32)
    factory/cli/run.py:cmd_run (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: 628 total, 614 kept, 14 dropped (ext:14, meta:0, big:0)
[build_project_map] 614 files, 110 unique dirs, 101 cache misses, 5.4ms
[resolve] 1163 resolved, 1576 unresolved (of 2739 total specs)
[resolve_imports] project_map 5.5ms, suffix_idx 1.0ms, suffix_resolve 18.5ms, total 25.0ms
[build_graphs] 614 files | maps 2.3ms, imports 25.2ms, calls+inherit 5.8ms, total 33.2ms | 1162 import, 8414 call, 1 inherit edges
sentrux gate — structural regression check

Quality:      4448 -> 4448
Coupling:     0.80 → 0.80
Cycles:       4 → 4
God files:    3 → 3

Distance from Main Sequence: 0.35

✓ No degradation detected

@xukai92

xukai92 commented Aug 31, 2026

Copy link
Copy Markdown
Collaborator Author

Workflow deployed as portable file to mcmc-lean instead.

@xukai92 xukai92 closed this Aug 31, 2026
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