Commit Graph

31 Commits

Author SHA1 Message Date
collins
7cf67153de refactor(types): remove Gas Town type constants from beads core (bd-w2zz4)
Remove Gas Town-specific type constants (TypeMolecule, TypeGate, TypeConvoy,
TypeMergeRequest, TypeSlot, TypeAgent, TypeRole, TypeRig, TypeEvent, TypeMessage)
from internal/types/types.go.

Beads now only has core work types built-in:
- bug, feature, task, epic, chore

All Gas Town types are now purely custom types with no special handling in beads.
Use string literals like "gate" or "molecule" when needed, and configure
types.custom in config.yaml for validation.

Changes:
- Remove Gas Town type constants from types.go
- Remove mr/mol aliases from Normalize()
- Update bd types command to only show core types
- Replace all constant usages with string literals throughout codebase
- Update tests to use string literals

This decouples beads from Gas Town, making it a generic issue tracker.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-21 10:36:59 -08:00
Peter Chanthamynavong
fc8437ed08 fix(mol): substitute title/desc vars in root molecule bead
When pouring a formula with `title` and `desc` variables defined,
the root molecule's title and description now use {{title}} and
{{desc}} placeholders that get substituted during pour.

Previously, the root was always assigned the formula name and static
description, ignoring these common variables. Child beads correctly
substituted variables, but the root did not.

Fixes #852
2026-01-02 16:00:54 -08:00
jasper
b73085962c feat: Implement Step.Gate evaluation (Phase 1: Human Gates)
This implements Phase 1 of the Step.Gate feature (bd-7zka.2):

- bd cook now creates gate issues for steps with gate fields
- Gate issues have type=gate and block the gated step via dependency
- bd list filters out gate issues by default (use --include-gates to show)
- New bd gate command with list and resolve subcommands

Gate types supported in Phase 1:
- human: Manual closure via bd close or bd gate resolve

Implementation details:
- createGateIssue() in cook.go creates gate issues with proper metadata
- collectSteps() creates gate dependencies when processing gated steps
- IssueFilter.ExcludeTypes added to storage layer for type-based filtering
- Gate command provides dedicated UX for gate management

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-01 16:25:59 -08:00
beads/crew/emma
ee34a74e90 feat: implement Step.Condition evaluation in bd cook (bd-7zka.1)
Add compile-time step filtering based on formula variables:
- New EvaluateStepCondition function for {{var}} truthy and equality checks
- FilterStepsByCondition to exclude steps based on conditions
- Integration into pour, wisp, and mol bond commands
- Supports: {{var}}, {{var}} == value, {{var}} != value

Steps with conditions that evaluate to false are excluded from the
cooked formula, along with their children.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-31 00:33:11 -08:00
beads/polecats/jade
44853d1690 fix: bd cook now looks up formula names from registry (bd-hp8g)
bd cook previously treated its argument as a file path only. Now it first
tries to load by name from the formula registry (.beads/formulas/), and
only falls back to parsing as a file path if that fails.

This enables commands like `bd cook beads-release` to work without
specifying the full path to the formula file.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-30 22:08:06 -08:00
Steve Yegge
0521910503 fix: --var flag now allows commas in values (#786)
Changed all --var flags from StringSlice to StringArray.
StringSlice splits on commas, breaking values like 'desc=A, B, C'.
StringArray only splits on separate --var flags.

Affected commands: pour, cook, wisp, mol distill, mol bond, template instantiate

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-29 16:17:51 -08:00
Steve Yegge
1bb61c5ffe refactor: Break up 275-line runCook into focused helpers (bd-8zbo)
Extracted 5 helper functions from the monolithic runCook function:

- parseCookFlags: Parse and validate command-line flags (~40 lines)
- loadAndResolveFormula: Parse, resolve, apply transformations (~60 lines)
- outputCookDryRun: Display dry-run preview (~60 lines)
- outputCookEphemeral: Output resolved formula as JSON (~30 lines)
- persistCookFormula: Create proto bead in database (~45 lines)

Main runCook function reduced from ~275 to ~65 lines with clear flow:
1. Parse flags → 2. Validate store → 3. Load formula
4. Extract metadata → 5. Handle mode (dry-run/ephemeral/persist)

Benefits:
- Each helper is single-responsibility and testable
- Added cookFlags struct for type-safe flag passing
- Error handling uses proper error returns instead of os.Exit
- Clear separation of concerns

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-28 16:37:30 -08:00
Steve Yegge
1d4eb6d94c refactor: Consolidate duplicated step collection functions in cook.go (bd-9btu)
Replaced three near-identical functions with a single unified collectSteps()
that uses a callback strategy for label handling:

- Removed collectStepsRecursive() (DB version)
- Removed collectStepsToSubgraph() (in-memory version)
- Removed collectStepIDMappings() (now handled by unified function)

The new collectSteps() function:
- Takes optional labelHandler callback for DB path (extracts labels separately)
- Takes optional issueMap for in-memory path
- Always builds idMapping for dependency resolution
- Eliminates ~60 lines of duplicated code

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-28 16:15:17 -08:00
Steve Yegge
f459f8ef7f refactor: Extract stepTypeToIssueType helper to remove duplicated switch (bd-j3dj)
Extracted duplicated switch statement for mapping step type strings to
types.IssueType into a single helper function. This removes code
duplication between collectStepsToSubgraph() and collectStepsRecursive().

The new stepTypeToIssueType() function:
- Converts 'task', 'bug', 'feature', 'epic', 'chore' to types
- Returns types.TypeTask for empty or unrecognized types
- Used by both functions with children-override-to-epic logic preserved
2025-12-28 15:42:24 -08:00
Steve Yegge
f46cc2e798 chore: remove issue ID references from comments and changelogs
Strip (bd-xxx), (gt-xxx) suffixes from code comments and changelog
entries. The descriptions remain meaningful without the ephemeral
issue IDs.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-28 10:05:16 -08:00
Steve Yegge
dfc796589f feat: add pour warning for vapor-phase formulas, improve help text, add doctor check
- Add Phase field to Formula type to indicate recommended instantiation phase
- Add warning in 'bd mol pour' when formula has phase="vapor"
- Improve pour/wisp help text with clear comparison of when to use each
- Add CheckPersistentMolIssues doctor check to detect mol- issues in JSONL
- Update beads-release.formula.json with phase="vapor"

This helps prevent accidental persistence of ephemeral workflow issues.
2025-12-28 01:34:01 -08:00
Steve Yegge
1611f16751 refactor: remove unused bd pin/unpin/hook commands (bd-x0zl)
Analysis found these commands are dead code:
- gt never calls `bd pin` - uses `bd update --status=pinned` instead
- Beads.Pin() wrapper exists but is never called
- bd hook functionality duplicated by gt mol status
- Code comment says "pinned field is cosmetic for bd hook visibility"

Removed:
- cmd/bd/pin.go
- cmd/bd/unpin.go
- cmd/bd/hook.go

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-27 16:02:15 -08:00
Steve Yegge
c8b912cbe6 bd sync: 2025-12-27 15:56:42 2025-12-27 15:56:42 -08:00
Steve Yegge
05304e3ab1 Merge origin/main, fix test git init for modern git 2025-12-27 00:17:36 -08:00
Steve Yegge
15cfef0247 Update documentation for bd mol pour/wisp command structure
Updated all documentation and help text to reflect:
- bd pour → bd mol pour
- bd ephemeral → bd mol wisp
- bd ephemeral list → bd mol wisp list
- bd ephemeral gc → bd mol wisp gc

Files updated:
- docs/MOLECULES.md
- docs/CLI_REFERENCE.md
- docs/ARCHITECTURE.md
- docs/DELETIONS.md
- skills/beads/references/MOLECULES.md
- cmd/bd/mol_catalog.go
- cmd/bd/mol_current.go
- cmd/bd/mol_distill.go
- cmd/bd/cook.go
2025-12-26 23:52:59 -08:00
Ryan Snodgrass
350a78f1ba fix: resolve all golangci-lint errors
Fixes 15 pre-existing lint issues:

errcheck (6 issues):
- mol_distill.go: Add _ = for f.Close() and os.Remove()
- routed.go: Add _ = for routedStorage.Close() (4 locations)

gosec (8 issues):
- maintenance.go, routes.go: Add nolint for G304 (file paths from known dirs)
- mol_distill.go: Add nolint for G304 (file creation in known search paths)
- formula.go: Change WriteFile permissions from 0644 to 0600 (G306)
- gate.go: Add nolint for G204 (exec.Command with trusted AwaitID fields)

misspell (1 issue):
- gate.go: Fix "cancelled" -> "canceled" in comment

unparam (2 issues):
- cook.go, controlflow.go: Add nolint for functions returning always-nil error

Also:
- Update pre-commit-hooks to v6.0.0
- Add lint step to "Landing the Plane" session-end protocol
2025-12-26 19:20:03 -05:00
Steve Yegge
e91f0de8d1 feat(formula): Add inline step expansion (gt-8tmz.35)
Steps can now declare their own expansion using the Expand field:

  steps:
    - id: design
      expand: rule-of-five
      expand_vars:
        iterations: 3

This is more convenient than compose.expand for single-step expansions.
The step is replaced by the expansion template with variables substituted.

Reuses existing expandStep() and mergeVars() from gt-8tmz.34.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-25 20:46:12 -08:00
Steve Yegge
abf672243c feat: Compile-time vs runtime cooking (gt-8tmz.23)
Add --mode flag (compile/runtime) and --var flag to bd cook command.

Compile-time mode (default):
- Keeps {{variable}} placeholders intact
- Use for: modeling, estimation, contractor handoff

Runtime mode (triggered by --var or --mode=runtime):
- Substitutes variables with provided values
- Validates all required variables have values
- Use for: final validation before pour

Also updates --dry-run output to clearly show which mode is active
and display substituted values in runtime mode.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-25 18:40:15 -08:00
Steve Yegge
258d183e25 Add waits_for handling to collectDependenciesToSubgraph (gt-8tmz.38)
The ephemeral proto path (collectDependenciesToSubgraph) was missing
waits_for handling that was already implemented in collectDependencies
for persisted protos. This ensures fanout gate dependencies are created
correctly for both ephemeral and persisted formula cooking.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-25 17:40:51 -08:00
Steve Yegge
ba17898365 Implement fanout gate: waits-for children aggregation (gt-8tmz.38)
- 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>
2025-12-25 17:33:54 -08:00
Steve Yegge
54a051aba3 gt-4v1eo: Implement ephemeral protos - cook formulas inline
Major refactor of molecular chemistry to make protos ephemeral:
- Formulas are now cooked directly to in-memory TemplateSubgraph
- No more proto beads stored in the database

Changes:
- cook.go: Add cookFormulaToSubgraph() and resolveAndCookFormula()
  for in-memory formula cooking
- template.go: Add VarDefs field to TemplateSubgraph for default
  value handling, add extractRequiredVariables() and
  applyVariableDefaults() helpers
- pour.go: Try formula loading first for any name (not just mol-)
- wisp.go: Same pattern as pour
- mol_bond.go: Use resolveOrCookToSubgraph() for in-memory subgraphs
- mol_catalog.go: List formulas from disk instead of DB proto beads
- mol_distill.go: Output .formula.json files instead of proto beads

Flow: Formula (.formula.json) -> pour/wisp (cook inline) -> Mol/Wisp

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-25 17:22:00 -08:00
Steve Yegge
56deb02d2a feat: Support ephemeral protos: cook inline for pour/wisp/bond (bd-rciw)
Changes:
- bd cook: outputs proto JSON to stdout by default, add --persist flag
  for legacy behavior (write to database)
- bd pour: accepts formula names, cooks inline as ephemeral proto,
  spawns mol, then cleans up temporary proto
- bd wisp create: accepts formula names, cooks inline as ephemeral proto,
  creates wisp, then cleans up temporary proto
- bd mol bond: already supported ephemeral protos (gt-8tmz.25)

The ephemeral proto pattern avoids persisting templates in the database.
Protos are only needed temporarily during spawn operations - the spawned
mol/wisp is what gets persisted.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-25 17:04:31 -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
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
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
cfb1196044 Implement expansion operators for formula composition (gt-8tmz.3)
Add expand and map operators that apply macro-style template expansion:
- expand(target, template) - replace a single step with expanded template
- map(select, template) - replace all matching steps with expanded template

The expansion formula type (e.g., rule-of-five) uses a template field with
{target} and {target.description} placeholders that are substituted when
applied to target steps.

Changes:
- Add Template field to Formula struct for expansion formulas
- Add ExpandRule and MapRule types to ComposeRules
- Implement ApplyExpansions in new expand.go
- Add LoadByName method to Parser for loading expansion formulas
- Integrate expansion into bd cook command
- Add comprehensive tests

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-25 02:11:03 -08:00
Steve Yegge
a643b9ab67 Implement advice operators for formula composition (gt-8tmz.2)
Add Lisp-style advice operators to the formula DSL:
- before(target, step) - insert step before target
- after(target, step) - insert step after target
- around(target, wrapper) - wrap target with before/after

Features:
- Glob pattern matching for targets (*.implement, shiny.*, etc)
- Pointcut matching by type or label
- Step reference substitution ({step.id}, {step.title})
- Automatic dependency chaining

New types: AdviceRule, AdviceStep, AroundAdvice, Pointcut
New functions: ApplyAdvice, MatchGlob, MatchPointcut

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-25 01:53:43 -08:00
Steve Yegge
e6ce0d6365 refactor: Switch formula format from YAML to JSON
- 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>
2025-12-25 01:37:22 -08:00
Steve Yegge
f28785d2dc feat(formula): support needs and waits_for fields, add --prefix flag
- 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>
2025-12-24 13:59:38 -08:00
Steve Yegge
d1c4526e6e fix(formula): address code review findings
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>
2025-12-24 13:50:19 -08:00
Steve Yegge
4fdcda4568 feat(formula): add formula parser and bd cook command (bd-weu8, bd-wa2l)
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>
2025-12-24 13:42:01 -08:00