TOML and JSON formulas accepted `metadata = { ... }` on a step
without error, but the field was silently dropped:
- `formula.Step` had no `Metadata` field, so the TOML/JSON parsers
discarded the table during decode.
- `processStepToIssue` built the template issue with no metadata.
- `cloneSubgraph` omitted `Metadata` when spawning the mol/wisp,
so even if the template carried it, the poured bead did not.
Add `Step.Metadata map[string]interface{}` so the parser keeps the
table, marshal it to JSON in `processStepToIssue`, and copy the raw
bytes through in `cloneSubgraph`. `bd cook` now shows `metadata`
under each step, and `bd mol pour` / `bd mol wisp` land the bead
with the declared keys.
* fix(formula): resolve worktree-aware search paths (beads-oto)
intent(formula): worktree users should resolve formulas from the active shared .beads registry instead of cwd-only paths
decision(formula-search): route CLI help, formula lookup, and distill output hints through formula.DefaultSearchPaths so search path display matches runtime behavior
constraint(worktree): keep cwd/.beads fallback when no beads project is resolved so local formula registries still work before init
* fix(formula): align mol seed help with resolved search paths
intent(formula-help): worktree users should see the active beads workspace path instead of stale cwd-based guidance
constraint(formula-runtime): seed already resolves formulas through the shared default search helper so this change only updates the displayed contract
* test(formula): isolate worktree parser repo hooks
intent(formula-tests): keep worktree search path coverage focused on formula resolution instead of developer git hook state
constraint(git-test-repos): global core.hooksPath can inject failing pre-commit hooks into temp repos and break the setup commit
decision(formula-tests): reuse ForceRepoLocalHooksPath so the new worktree test follows the repo's existing git test isolation rule
* test(formula): simplify search-path test setup (beads-6kum)
intent(formula-tests): keep the new search-path coverage easy to extend without re-reading repetitive test scaffolding
constraint(formula-tests): helper extraction must preserve the hook-isolation and cache-reset behavior added for worktree coverage
decision(formula-tests): centralize repo init, fixture writing, and canonical path handling into local test helpers so each case stays focused on its assertions
bd formula list counted convoy formulas in the header total but omitted
them from the rendered output because typeOrder only had workflow,
expansion, and aspect sections. Add convoy to the type order, add the
🚐 icon, register TypeConvoy as a valid FormulaType, and update the
--type flag help text.
Fixessteveyegge/beads#2825🤖 Generated with [Nori](https://nori.ai)
Co-Authored-By: Nori <contact@tilework.tech>
Child steps with the same ID as a parent step now replace the parent
step in-place (preserving DAG position) rather than being appended,
which caused Validate() to reject the formula with "duplicate id".
This matches the documented behavior and how vars already work.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
VarDef.Default was a plain string, so Go zero value "" was
indistinguishable from an explicit default="". This caused 50+ formula
variables with default="" (meaning "optional, skip if empty") to be
treated as required, breaking gt sling for operational formulas.
Change Default from string to *string: nil = no default specified,
non-nil (including &"") = has explicit default. Mechanical change
across all consumer sites with consistent nil-check pattern.
Fixes: steveyegge/gastown#1551
Co-authored-by: julianknutsen <julianknutsen@users.noreply.github.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Executed-By: beads/crew/emma
Rig: beads
Role: crew
Add UnmarshalTOML method to VarDef to handle both simple string
assignments and full table definitions:
[vars]
wisp_type = "patrol" # simple string -> Default = "patrol"
[vars.component] # table with full definition
description = "Component name"
required = true
Fixes bd-8l59: Formula parser rejects simple string vars in [vars] section
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
BurntSushi/toml cannot match TOML keys like `depends_on` to Go struct
fields like `DependsOn` because the underscore breaks field name matching.
Only `json:` tags were present, causing these fields to be silently ignored
when parsing .formula.toml files.
This adds `toml:` tags to all snake_case fields:
- Step.DependsOn, Step.Needs (step dependencies)
- Step.WaitsFor (fanout gate)
- Step.ExpandVars (expansion variables)
- Step.OnComplete (completion hooks)
- OnCompleteSpec.ForEach (iteration)
- ComposeRules.BondPoints (composition)
- BondPoint.AfterStep, BondPoint.BeforeStep (attachment points)
Added TestParseTOML_SnakeCaseFields to verify depends_on, needs, and
waits_for are correctly parsed from TOML formulas.
Fixes: https://github.com/steveyegge/beads/issues/1449
Add tests for parsing the Gate field in formula steps:
- TestParse_GateField: JSON parsing with all gate fields
- TestParse_GateFieldTOML: TOML parsing
- TestParse_GateFieldMinimal: minimal gate with only type
- TestParse_GateFieldWithAllTypes: all gate types (gh:run, gh:pr, timer, human, bead, mail)
- TestParse_GateInChildStep: gate in nested child steps
The Gate struct and Step.Gate field already existed. These tests
verify TOML and JSON parsing works correctly.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add children-of(step-id) syntax for explicit spawner reference
- Add WaitsForSpec type and ParseWaitsFor() helper
- Update cook.go to create DepWaitsFor dependencies with metadata
- Infer spawner from first needs entry when using all-children
- Add validation tests for children-of() syntax
- Add unit tests for ParseWaitsFor()
This completes the Christmas Ornament aggregation pattern:
- survey-workers does for-each → creates N children
- aggregate waits-for children-of(survey-workers)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
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>
When bd cook encounters a circular extends chain (A extends B extends A),
the error message now shows the full chain: "cycle-a -> cycle-b -> cycle-a"
instead of just "circular extends detected: cycle-a".
This makes debugging circular dependencies much easier by showing exactly
which formulas are involved in the cycle.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Change file extension from .formula.yaml to .formula.json
- Replace gopkg.in/yaml.v3 with encoding/json in parser
- Remove yaml struct tags, keep json tags only
- Update all test cases to use JSON format
- Update documentation references
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- bd-hr39: Add `needs` field to Step as alias for depends_on. Converts
to blocking dependencies between sibling steps during cooking.
- bd-j4cr: Add `waits_for` field to Step. Values: all-children or
any-children. Preserved as gate:<value> label during cooking.
- bd-47qx: Add --prefix flag to bd cook command to prepend a prefix
to proto IDs, enabling use of project prefixes like gt-.
Includes validation, dry-run output, and comprehensive tests.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Fixes from self-review of formula parser and bd cook:
1. Atomicity: Add cleanup on failure in cookFormula - if labels/deps
transaction fails, delete the already-created issues
2. Validation: Add recursive depends_on validation for child steps
and validate priority ranges for children
3. Documentation: Mark unimplemented fields (Expand, ExpandVars,
Condition, Gate) with TODO(future) comments
4. Thread safety: Add note that Parser is NOT thread-safe
5. Error messages: Track first definition location for duplicate ID
errors (e.g., "duplicate id at steps[1], first defined at steps[0]")
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Implements a new formula system for defining workflow templates in YAML:
- internal/formula/types.go: YAML schema types for .formula.yaml files
- Formula, Step, VarDef, ComposeRules, BondPoint, Gate types
- Support for workflow, expansion, and aspect formula types
- Variable definitions with required, default, enum, and pattern
- internal/formula/parser.go: Parser with extends/inheritance support
- Parse formula files from multiple search paths
- Resolve extends references for formula inheritance
- Variable extraction and substitution
- Variable validation (required, enum, pattern)
- cmd/bd/cook.go: bd cook command to compile formulas into protos
- Parse and resolve formula YAML
- Create proto bead with template label
- Create child issues for each step
- Set up parent-child and blocking dependencies
- Support --dry-run, --force, --search-path flags
Example workflow:
bd cook mol-feature.formula.yaml
bd pour mol-feature --var component=Auth --var framework=react
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>