Commit Graph

4056 Commits

Author SHA1 Message Date
Jordan Hubbard
59413baac2 sqlite: stop migrations clobbering pinned/template
Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
2025-12-26 12:04:06 -04:00
Jordan Hubbard
1f5ed550fe test: cover daemon autostart paths
Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
2025-12-26 10:45:42 -04:00
Jordan Hubbard
6790fb2f2d test: cover rpc client gate + shutdown
Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
2025-12-26 10:19:30 -04:00
Jordan Hubbard
eab0b3ac41 test: raise memory storage coverage 2025-12-26 10:14:28 -04:00
Jordan Hubbard
6c37a58148 test: report total coverage from make test
Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
2025-12-26 09:47:48 -04:00
Jordan Hubbard
7af3106610 doctor: add fs fault injection and lock contention coverage
Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
2025-12-26 09:22:45 -04:00
Jordan Hubbard
8166207eb4 doctor: add JSONL integrity check/fix and harden repairs
Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
2025-12-26 08:18:25 -04:00
Jordan Hubbard
1a4f06ef8c doctor: harden corruption repair and JSONL config
Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
2025-12-26 04:29:29 -04:00
Jordan Hubbard
b089aaa0d6 tests: add chaos doctor repair coverage and stabilize git init
Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
2025-12-25 21:50:13 -04:00
Jordan Hubbard
1184bd1e59 doctor: add git hygiene checks and DB integrity auto-fix
Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
2025-12-25 21:35:44 -04:00
Steve Yegge
c1fefc1bc4 bd sync: 2025-12-25 16:55:34 2025-12-25 16:55:34 -08:00
Steve Yegge
788e07be00 bd sync: 2025-12-25 14:49:21 2025-12-25 16:55:27 -08:00
Steve Yegge
76f2179ea4 bd sync: 2025-12-25 14:06:00 2025-12-25 16:55:27 -08:00
Steve Yegge
e410b9b08d bd sync: 2025-12-25 13:56:03 2025-12-25 16:55:27 -08:00
Steve Yegge
f1493a2fff docs: add info.go versionChanges entry for 0.37.0
20 agent-actionable changes:
- 9 new features (control flow, aspects, formula commands, etc.)
- 3 breaking changes (YAML→JSON, mol run removed, wisp architecture)
- 8 bug fixes

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-25 16:51:26 -08:00
Steve Yegge
35e8c06f3e feat: add beads-release formula for molecular releases
18-step workflow covering full release cycle:
- Preflight checks (git status, pull)
- Documentation (CHANGELOG, info.go)
- Version bump (wraps bump-version.sh)
- Git operations (commit, tag, push)
- CI verification
- Artifact verification (GitHub, npm, PyPI)
- Local installation and daemon restart

Replaces ad-hoc release process with structured molecular workflow.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-25 16:51:26 -08:00
Steve Yegge
73e56d0876 Fix in-place mutation in ApplyBranches/ApplyGates (gt-v1pcg)
- ApplyBranches and ApplyGates now clone steps before modifying,
  matching the immutability pattern of ApplyLoops and ApplyAdvice
- Added internal applyBranchesWithMap/applyGatesWithMap for efficiency
- ApplyControlFlow builds stepMap once for both (gt-gpgdv optimization)
- Added cloneStepsRecursive helper
- Added TestApplyBranches_Immutability and TestApplyGates_Immutability

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-25 16:48:37 -08:00
Steve Yegge
3b3f844484 fix: Address code review issues in bd mol bond formula support
Fixes from review of gt-8tmz.25 implementation:

1. Dry-run no longer cooks formulas - added resolveOrDescribe() for
   dry-run mode that checks if operand exists without cooking

2. Ephemeral protos now cleaned up after successful bond, not just
   on error

3. Unique proto IDs to avoid collision - ephemeral protos use format
   "_ephemeral-<formula>-<timestamp>" instead of formula name

4. Removed unused vars parameter from resolveOrCookFormula

5. Added informative output showing formulas will be cooked and
   cleaned up

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-25 16:47:03 -08:00
Steve Yegge
6bb11c4297 docs: update CHANGELOG [Unreleased] for 0.37.0
Comprehensive changelog entries for all changes since v0.36.0:
- 8 new features (control flow, aspects, stale detection, etc.)
- 3 breaking changes (YAML→JSON, wisp architecture, mol run removal)
- 13 bug fixes
- 2 documentation updates

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-25 16:43:37 -08:00
Steve Yegge
cb6f3cdb5e feat: Add formula name support to bd mol bond (gt-8tmz.25)
Bond command now accepts formula names (e.g., mol-polecat-arm) in addition
to issue IDs. When a formula name is given:

1. Looks up the formula using formula.Parser
2. Resolves inheritance and applies transformations (control flow, advice,
   expansions, aspects)
3. Cooks the formula inline to create an ephemeral proto
4. Uses the cooked proto for bonding

This eliminates the need for pre-cooked proto beads in the database,
enabling more dynamic workflow composition.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-25 16:39:27 -08:00
Steve Yegge
d2f71773cb fix: Chain iterations after nested loop expansion (gt-zn35j)
Fixes a bug where outer iteration chaining was lost when nested loops
were expanded. The problem was:

1. chainLoopIterations set: outer.iter2.inner depends on outer.iter1.inner
2. ApplyLoops recursively expanded nested loops
3. outer.iter2.inner became outer.iter2.inner.iter1.work, etc.
4. The dependency was lost (referenced non-existent ID)

The fix:
- Move recursive ApplyLoops BEFORE chaining
- Add chainExpandedIterations that finds iteration boundaries by ID prefix
- Works with variable step counts per iteration (nested loops expand differently)

Now outer.iter2's first step correctly depends on outer.iter1's LAST step,
ensuring sequential execution of outer iterations.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-25 16:35:28 -08:00
Steve Yegge
bce4f8f2d4 feat: Add source tracing metadata to cooked steps (gt-8tmz.18)
Add SourceFormula and SourceLocation fields to track where each step
came from during the cooking process. This enables debugging of complex
compositions with inheritance, expansion, and advice.

Changes:
- Added SourceFormula and SourceLocation fields to Step struct (formula/types.go)
- Added same fields to Issue struct (types/types.go)
- Added SetSourceInfo() to parser.go - sets source on all steps after parsing
- Updated cook.go to copy source fields from Step to Issue
- Updated dry-run output to display source info: [from: formula@location]
- Updated advice.go to set source on advice-generated steps
- Updated controlflow.go to preserve source on loop-expanded steps
- Updated expand.go to preserve source on template-expanded steps

The source location format is:
- steps[N] - regular step at index N
- steps[N].children[M] - child step
- steps[N].loop.body[M] - loop body step
- template[N] - expansion template step
- advice - step inserted by advice transformation

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-25 16:27:48 -08:00
Steve Yegge
b43358b600 feat: Add nested loop support in control flow (gt-zn35j)
Enables loops within loop bodies to be properly expanded:

- Copy Loop field in expandLoopIteration (was intentionally omitted)
- Add cloneLoopSpec for deep copying of LoopSpec with body steps
- Recursively call ApplyLoops at end of expandLoop to expand nested loops
- Also copy OnComplete field for consistency

Nested IDs follow natural chaining pattern:
  outer.iter1.inner.iter2.step

Tested with 2-level and 3-level nesting scenarios.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-25 16:22:58 -08:00
Steve Yegge
47cc84de3a fix(docs): standardize sync branch name and daemon syntax (GH#376)
- Replace beads-metadata with beads-sync throughout docs
  (matches code default and internal examples)
- Fix bd daemon start → bd daemon --start (correct flag syntax)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-25 16:22:09 -08:00
Steve Yegge
3034fc392e fix(doctor): handle installed_plugins.json v2 format (GH#741)
Claude Code's installed_plugins.json changed from v1 (plugins as structs)
to v2 (plugins as arrays). Update GetClaudePluginVersion() to handle both.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-25 16:20:02 -08:00
Steve Yegge
a42fac8cb9 feat: Add on_complete/for-each runtime expansion types (gt-8tmz.8)
Implements the schema and validation for runtime dynamic expansion:

- Add OnCompleteSpec type for step completion triggers
- Add on_complete field to Step struct
- Validate for_each path format (must start with "output.")
- Validate bond is required with for_each (and vice versa)
- Validate parallel and sequential are mutually exclusive
- Add cloneOnComplete for proper step cloning
- Add comprehensive tests for parsing and validation

The runtime executor (in gastown) will interpret these fields to:
- Bond N molecules when step completes based on output.collection
- Run bonded molecules in parallel or sequential order
- Pass item/index context via vars substitution

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-25 16:07:57 -08:00
Steve Yegge
8b5168f1a3 fix: Control flow review fixes (gt-8tmz.4)
Critical bug fixes identified during code review:

1. External dependency rewriting: Dependencies on steps OUTSIDE the loop
   are now preserved as-is instead of being incorrectly prefixed.

2. Children dependency rewriting: Child step dependencies are now properly
   rewritten with iteration context.

3. Missing fields: Added Expand, ExpandVars, Gate fields to loop expansion.

4. Condition validation: Loop `until` conditions are now validated with
   ParseCondition to catch syntax errors early.

5. Label format: Changed gate and loop labels from colon-delimited to
   JSON format for unambiguous parsing:
   - gate:{"condition":"expr"}
   - loop:{"until":"expr","max":N}

Added TestApplyLoops_ExternalDependencies to verify the fix.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-25 15:02:07 -08:00
Steve Yegge
4f065024b5 feat: Implement control flow operators (gt-8tmz.4)
Add loop, branch, and gate operators for formula step transformation:

- LoopSpec: Fixed-count loops expand body N times with chained iterations.
  Conditional loops expand once with runtime metadata labels.
- BranchRule: Fork-join patterns wire dependencies for parallel paths.
- GateRule: Adds condition labels for runtime evaluation before steps.

Types added to types.go:
- LoopSpec (count/until/max/body)
- BranchRule (from/steps/join)
- GateRule (before/condition)
- Loop field on Step
- Branch/Gate arrays on ComposeRules

New controlflow.go with ApplyLoops, ApplyBranches, ApplyGates, and
ApplyControlFlow convenience function. Wired into cook.go before
advice and expansion operators.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-25 14:52:21 -08:00
Steve Yegge
2ff17686d0 feat(prime): add no-git-ops config to disable git ops in session close (GH#593)
Users who want manual control over git commits can now set:

  bd config set no-git-ops true

This makes `bd prime` output the stealth-mode session close protocol
(just `bd sync --flush-only`) instead of the full git add/commit/push
workflow. Useful when:

- You want to verify work before committing
- Claude tries to auto-commit after context compaction
- You have a custom git workflow

The --stealth flag still works as before for one-off use.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-25 14:25:45 -08:00
Steve Yegge
6d23689736 fix(init): guard git.IsWorktree() with isGitRepo() check (GH#727)
On Windows, running `bd init` outside a git repository could hang
indefinitely because git.IsWorktree() runs `git rev-parse --git-dir`
which may hang on Windows when not in a git repo.

The fix adds an isGitRepo() check before calling git.IsWorktree() in
both the main init flow and the checkExistingBeadsData helper.

Regression introduced in e01b7412 (Git worktree compatibility).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-25 14:13:59 -08:00
Steve Yegge
d2b1656c5d fix: Make child→parent dep fix opt-in with --fix-child-parent (bd-cuek)
GH#740: bd doctor --fix was auto-removing child→parent dependencies,
calling them an 'anti-pattern'. While these often indicate modeling
mistakes (deadlock), they may be intentional in some workflows.

Changes:
- Add --fix-child-parent flag (required to remove child→parent deps)
- Remove ChildParentDependencies from default --fix set
- Update warning message to reference new flag
- Update comments to reflect more nuanced understanding

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-25 14:05:55 -08:00
Steve Yegge
c9aa755ddc fix: Address code review issues in condition evaluator
- Empty set 'all' returns false (avoids premature gate passing)
- Add proper error handling for Atoi in count comparisons
- Extract inline regex to package-level var (performance)
- Handle == and != in compareString function
- Add nil/bool value handling in compare function
- Add tests for edge cases: empty children, nil output, bool values

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-25 14:00:56 -08:00
Steve Yegge
efdaa93789 fix: Use FatalErrorRespectJSON across all commands (bd-28sq)
Convert all fmt.Fprintf(os.Stderr, ...) + os.Exit(1) patterns to use
FatalErrorRespectJSON for consistent JSON error output:
- dep.go: dependency commands (add, remove, tree, cycles)
- label.go: label commands (add, remove, list, list-all)
- comments.go: comment commands (list, add)
- epic.go: epic commands (status, close-eligible)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-25 13:56:19 -08:00
Steve Yegge
f56f3615e8 feat: Add condition evaluator for gates and loops (gt-8tmz.7)
Implements mechanical condition evaluation for formula control flow:
- Step status checks: step.status == 'complete'
- Step output access: step.output.approved == true
- Aggregates: children(step).all(status == 'complete'), steps.complete >= 3
- External checks: file.exists('go.mod'), env.CI == 'true'

Conditions are intentionally limited to keep evaluation decidable.
No arbitrary code execution allowed.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-25 13:54:21 -08:00
Steve Yegge
d9bf695791 fix: Use FatalErrorRespectJSON for JSON-consistent error output (bd-28sq.1)
Replace fmt.Fprintf(os.Stderr, ...) + os.Exit(1) patterns with
FatalErrorRespectJSON() in updateCmd, closeCmd, and editCmd.

This ensures that when --json flag is set, errors are returned as
JSON objects ({"error": "message"}) instead of plain text.

Fixes: bd-28sq.1
2025-12-25 13:41:06 -08:00
Steve Yegge
6da9610ba6 bd sync: 2025-12-25 13:40:56 2025-12-25 13:40:56 -08:00
Steve Yegge
e7735f0083 bd sync: 2025-12-25 13:32:48 2025-12-25 13:32:57 -08:00
Steve Yegge
29501c7aeb feat: Add stale molecules check to bd doctor (bd-6a5z)
Extends bd doctor to detect complete-but-unclosed molecules (epics where
all children are closed but root is still open).

- Added CheckStaleMolecules() to doctor/maintenance.go
- Added resolveBeadsDir() helper to follow Gas Town redirect files
- Check appears in Maintenance category with warning severity
- Shows example IDs and suggests 'bd mol stale' for review

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-25 12:42:55 -08:00
Steve Yegge
df3a6bff43 bd sync: 2025-12-25 12:42:51 2025-12-25 12:42:51 -08:00
Steve Yegge
09d053233e feat: Add bd formula list/show commands (gt-8tmz.14)
Implements formula management commands:
- bd formula list: Lists formulas from all search paths
- bd formula show <name>: Shows formula details, steps, composition rules

Search paths in priority order:
1. .beads/formulas/ (project)
2. ~/.beads/formulas/ (user)
3. ~/gt/.beads/formulas/ (town)

Features:
- Type filtering (--type workflow|expansion|aspect)
- JSON output support (--json)
- Shows variables, steps, advice, bond points, and aspects
- Formulas in earlier paths shadow later ones

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-25 12:38:00 -08:00
Steve Yegge
92e99c8201 feat: Add bd mol stale command to detect complete-but-unclosed molecules (bd-anv2)
Implements command to find epics/molecules where all children are closed
but the root is still open. Helps identify work that's done but not
formally closed.

Flags:
  --blocking   Only show molecules blocking other work
  --unassigned Only show unassigned molecules
  --all        Include molecules with 0 children
  --json       Machine-readable output

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-25 12:31:24 -08:00
Steve Yegge
fe661887ae bd sync: 2025-12-25 12:31:14 2025-12-25 12:31:14 -08:00
Steve Yegge
fd57f61f34 fix: Prevent aspect self-matching infinite recursion (gt-8tmz.16)
ApplyAdvice now collects original step IDs before applying rules and
only matches steps in that set. This prevents advice patterns (like "*")
from matching their own inserted before/after steps.

Added test case demonstrating that a "*" pattern only adds advice to
original steps, not to inserted steps.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-25 12:21:23 -08:00
Steve Yegge
6311fbaebf bd sync: 2025-12-25 12:18:37 2025-12-25 12:18:37 -08:00
Steve Yegge
71dc671dd6 bd sync: 2025-12-25 12:18:21 2025-12-25 12:18:21 -08:00
Steve Yegge
516c62e543 feat: Add aspect composition support (gt-8tmz.5)
- Add Aspects field to ComposeRules for listing aspect formulas
- Apply aspects during cooking after expansions
- Aspects are loaded by name and their advice rules are applied

Usage in formula:
  "compose": {
    "aspects": ["security-audit", "logging"]
  }

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-25 12:15:12 -08:00
Steve Yegge
de1a9559fa fix: Map expansion now matches nested child steps (gt-8tmz.33)
The map rule was only iterating over top-level steps, missing nested
children. Now uses buildStepMap to include all steps at any depth.

Added test case for map expansion over nested children.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-25 12:08:05 -08:00
Steve Yegge
2f9d423ac8 fix: Prevent bd sync from committing non-.beads files (bd-trgb)
gitCommit() was adding the JSONL file but then committing ALL staged
changes (no pathspec). If other files were staged (e.g., deletions from
git add -A), they would be swept into the bd sync commit.

Fixed by adding pathspec to both gitCommit() and commitToExternalBeadsRepo()
so they only commit what they explicitly staged.

This was the root cause of PR #722 files being deleted - they were staged
for deletion in the working tree and got committed by bd sync.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-25 12:05:46 -08:00
Steve Yegge
2392496b0c bd sync: 2025-12-25 12:05:37 2025-12-25 12:05:37 -08:00
Steve Yegge
451c9e4630 bd sync: 2025-12-25 11:56:39 2025-12-25 11:56:47 -08:00