Skip to content

Semantic branch names from available context (issue #350)#365

Open
mairin wants to merge 4 commits into
akashgit:mainfrom
mairin:factory/run-c8e2ad68
Open

Semantic branch names from available context (issue #350)#365
mairin wants to merge 4 commits into
akashgit:mainfrom
mairin:factory/run-c8e2ad68

Conversation

@mairin
Copy link
Copy Markdown
Contributor

@mairin mairin commented May 25, 2026

Closes #364

Changes

  • Added _slugify(text, max_length) — stdlib-only (re, unicodedata) kebab-case converter
  • Added _classify_prefix(hint, mode) — keyword-matches hint text to conventional branch prefixes (fix/docs/refactor/test/chore/feat)
  • Extended create_worktree with hint and mode kwargs: produces factory/<prefix>/<slug>-<hex4> when hint provided, falls back to factory/run-<hex8> without
  • Writes .factory_branch marker file in worktree dir for branch name reconstruction
  • Updated prune_stale to read .factory_branch marker, falling back to old factory/run- pattern for legacy dirs
  • Updated cmd_ceo and _run_single_cycle call sites to pass hint and mode
  • Added comprehensive tests for _slugify, _classify_prefix, semantic naming, fallback, and prune with marker
  • Updated test mocks in conftest.py and test_cli.py to accept new kwargs

mairin and others added 3 commits May 24, 2026 14:39
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The cmd_precheck function was building history dicts without the notes
field, so _is_infra_revert() could never match infrastructure revert
markers. This made the anti_pattern fix from the previous commit
ineffective.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace opaque `factory/run-<hex8>` branch names with semantic
`factory/<prefix>/<slug>-<hex4>` when a hint is available. Adds
`_slugify` and `_classify_prefix` helpers (stdlib-only), a
`.factory_branch` marker file for prune_stale to reconstruct branch
names, and full backward compatibility when no hint is provided.

Closes akashgit#364

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@codecov
Copy link
Copy Markdown

codecov Bot commented May 25, 2026

Codecov Report

❌ Patch coverage is 92.64706% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 87.62%. Comparing base (18be0c0) to head (b73c38b).
⚠️ Report is 72 commits behind head on main.

Files with missing lines Patch % Lines
factory/strategy.py 72.72% 3 Missing ⚠️
factory/cli.py 33.33% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #365      +/-   ##
==========================================
+ Coverage   87.38%   87.62%   +0.23%     
==========================================
  Files          57       60       +3     
  Lines        8152     9227    +1075     
==========================================
+ Hits         7124     8085     +961     
- Misses       1028     1142     +114     

☔ View full report in Codecov by Sentry.
📢 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.

@mairin
Copy link
Copy Markdown
Contributor Author

mairin commented May 25, 2026

✅ Factory Review: KEEP

Verdict: KEEP
Reason: Clean feature addition: semantic branch names with comprehensive tests, backward compat, and proper scope

Experiment: #1
Hypothesis: Semantic branch names from available context

Guard Checks

Check Result
eval_immutable ✅ PASS
scope ✅ PASS
git_clean ✅ PASS
experiment_branch ✅ PASS

Score Comparison

Metric Value
Before N/A (no eval scores recorded)
After N/A (no eval scores recorded)
Threshold 0.80

Code Quality Assessment

  • Critical issues: 0
  • Important issues: 0
  • Minor issues: 0

Code Review Notes

  • _slugify handles edge cases well: empty→"unnamed", unicode→NFKD normalized, truncation strips trailing hyphens
  • _classify_prefix priority ordering is correct: fix > docs > refactor > test > chore > feat
  • Backward compat preserved: no hint → old factory/run-<hex8> format unchanged
  • .factory_branch marker file enables correct branch cleanup for semantic-named worktrees; legacy dirs fall back to factory/run- prefix reconstruction
  • Mock signatures in conftest.py and test_cli.py updated with **kw for forward compat
  • precheck.py and strategy.py diffs visible in gh pr diff are already on main, not this branch (confirmed via git diff main...HEAD)
  • All 186 tests pass, including 19 new tests covering _slugify (7), _classify_prefix (8), semantic naming (4), prune with marker (2)
  • Only 5 files changed on the branch, all within declared scope

Precheck Gate

factory guard → clean
pytest (186 tests) → all pass
scope check → 5 files, all within factory config scope

Reviewed by Factory Reviewer Agent

…file

The .factory_branch file was written to the worktree root, making it
visible as untracked in git status and susceptible to accidental staging.
Move it to a sibling file in the parent worktrees/ directory (e.g.
run-abc123.branch alongside run-abc123/) where it's naturally covered
by .factory/'s gitignore. Also clean up the marker in remove_worktree
and prune_stale.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@mairin mairin marked this pull request as ready for review May 25, 2026 19:04
@mairin
Copy link
Copy Markdown
Contributor Author

mairin commented May 25, 2026

✅ Factory Review: KEEP

Verdict: KEEP
Reason: Semantic branch naming improves CI/PR readability. Score improved +0.0159, no regressions, all tests pass, E2E smoke test clean.

Experiment: #1
Hypothesis: Semantic branch names from available context (issue #350)

Score Comparison

Metric Value
Before 0.7766
After 0.7925
Delta +0.0159
Threshold 0.8000

Guard Checks

Check Result
scope ✅ PASS
eval_immutable ✅ PASS

Notes

  • Precheck score_direction check failed due to absolute threshold (0.7925 < 0.80) — the gap is structural (experiment_diversity and factory_effectiveness at floor values due to zero experiment history in this worktree). Score improved by +0.0159, no dimension regressed.
  • Final headless review identified 2 minor items for future improvement: (1) prune_stale fallback path for non-"run-" dirs without marker files, (2) _classify_prefix morphological variants (plurals/gerunds). Neither blocks this PR.
  • Full review pipeline: 3 iterations (scope verification, marker location fix, final review)

Posted by Factory CEO

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.

Semantic branch names from available context (issue #350)

1 participant