Skip to content

fix: use detected default branch instead of hardcoded main in CEO workflow#731

Closed
osilkin98 wants to merge 2 commits into
mainfrom
factory/run-c7d4143a
Closed

fix: use detected default branch instead of hardcoded main in CEO workflow#731
osilkin98 wants to merge 2 commits into
mainfrom
factory/run-c7d4143a

Conversation

@osilkin98

Copy link
Copy Markdown
Collaborator

Closes #730

Changes

  • Replaced 7 hardcoded main references in factory/agents/prompts/ceo.md with $TARGET_BRANCH (PR targets, baseline SHA lookups, guard violation checkout)
  • Added TARGET_BRANCH resolution instruction near the start of the CEO prompt so the variable is set from .factory/config.json each cycle
  • Changed _build_ceo_task in factory/cli.py to always inject the resolved target branch (via _read_target_branch), not only when --branch is explicitly passed
  • Added error handling in _read_target_branch to gracefully fall back to "main" if detect_default_branch fails

…kflow

Replace 7 hardcoded 'main' references in CEO prompt with $TARGET_BRANCH
and always inject the resolved target branch in _build_ceo_task, even
when no --branch override is provided.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@github-actions

github-actions Bot commented Jun 24, 2026

Copy link
Copy Markdown

Sentrux Quality Report

Running sentrux check...
Scanning ....
[scan] git ls-files: 259 total, 249 kept, 10 dropped (ext:10, meta:0, big:0)
[build_project_map] 249 files, 42 unique dirs, 38 cache misses, 4.3ms
[resolve] 376 resolved, 659 unresolved (of 1035 total specs)
[resolve_imports] project_map 4.3ms, suffix_idx 0.5ms, suffix_resolve 10.5ms, total 15.3ms
[build_graphs] 249 files | maps 1.0ms, imports 15.4ms, calls+inherit 3.0ms, total 19.5ms | 375 import, 3843 call, 0 inherit edges
sentrux check — 2 rules checked

Quality: 4967

✗ [Error] max_cc: 4 function(s) exceed max cyclomatic complexity of 30
    factory/cli.py:cmd_ceo (cc=78)
    factory/cli.py:_welcome_wizard (cc=39)
    factory/cli.py:cmd_run (cc=36)
    factory/study.py:study_project_local (cc=36)

✗ 1 violation(s) found

@codecov

codecov Bot commented Jun 24, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.84%. Comparing base (600cad3) to head (fa19b46).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #731   +/-   ##
=======================================
  Coverage   87.83%   87.84%           
=======================================
  Files          70       70           
  Lines       10699    10704    +5     
=======================================
+ Hits         9398     9403    +5     
  Misses       1301     1301           

☔ 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.

@osilkin98

Copy link
Copy Markdown
Collaborator Author

✅ Factory Review: KEEP

Verdict: KEEP
Reason: All hardcoded main references replaced with $TARGET_BRANCH in ceo.md; CLI unconditionally injects resolved branch; guard check clean; 176 smoke tests pass; no critical issues

Experiment: #3
Hypothesis: Replace hardcoded main in CEO prompt and always inject resolved target branch in CLI

Score Comparison

Metric Value
Before 0.0000
After 0.0000
Delta +0.0000
Threshold 0.6000

Guard Checks

Check Result
eval_immutable ✅ PASS
scope ✅ PASS
git_clean ✅ PASS

Precheck Gate

Guard check passed clean. No eval scores available (eval_command empty). Smoke tests: 176 passed.

Code Review Notes

  • try/except around detect_default_branch correctly handles missing git/non-repo dirs with main fallback
  • TARGET_BRANCH resolution in ceo.md provides shell-level variable for all git commands
  • 9 hardcoded main refs in git commands replaced consistently
  • Unconditional Target Branch injection in _build_ceo_task ensures CEO always knows the branch
  • No remaining hardcoded main in git command patterns (grep verified)

Posted by Factory CEO

If .factory/config.json doesn't exist, the cat command fails and
TARGET_BRANCH becomes empty. Add 2>/dev/null to suppress errors
from both cat and python3, and fall back to "main" if the pipeline
fails entirely.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@osilkin98 osilkin98 marked this pull request as ready for review June 24, 2026 02:13
@osilkin98

Copy link
Copy Markdown
Collaborator Author

✅ Factory Review: KEEP

Verdict: KEEP
Reason: All 9 hardcoded main refs replaced with $TARGET_BRANCH, CLI always injects resolved branch

Experiment: #3
Hypothesis: Replace hardcoded main in CEO prompt and always inject resolved target branch in CLI

Score Comparison

Metric Value
Before 0.6166
After 0.6213
Delta +0.0047
Threshold 0.6000

Guard Checks

Check Result
scope ✅ PASS
eval_immutable ✅ PASS

Posted by Factory CEO

@osilkin98

Copy link
Copy Markdown
Collaborator Author

Closing this as it was posted on version 1 factory

@osilkin98 osilkin98 closed this Jun 28, 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.

fix: use detected default branch instead of hardcoded main in CEO workflow

2 participants