beads/cmd/bd/testdata
Jack J Garzella 7be354810f
feat(formula): make primitives discoverable to coding agents (GH#3621) (#3781)
* feat(formula): add bd formula schema reflection-driven primitive index (beads-9ib)

Generates internal/formula/schema_gen.go from types.go via go:generate,
exposing all 18 exported structs (Formula, Step, LoopSpec, OnCompleteSpec,
etc.) with field types, json/toml tags, required-flag, and doc comments.

Surfaced via:
  bd formula schema                 # list every primitive
  bd formula schema loop            # show LoopSpec fields
  bd formula primitives on_complete # alias + snake_case match
  bd formula schema --json          # machine-readable

Lookup prefers exact match over Spec/Rule(s) suffix-strip, so "gate"
resolves to Gate (not GateRule). Fields tagged json:"-" (Step.SourceFormula,
Step.SourceLocation) are excluded.

TestSchemaGenIsCurrent re-runs the AST walker in-memory and byte-diffs
against the committed schema_gen.go, so a new struct in types.go without
a regen will fail CI.

Item 2 of GH#3621.

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

* feat(formula): point bd formula --help at the primitive index (beads-lnf)

Extends the cobra Long descriptions on `formula`, `formula list`, and
`formula show` so an agent reading any of them is told that
`bd formula schema` (alias `primitives`), the curated
`examples/formulas/primitives/` directory, and the website primitives
reference exist. Without these pointers, agents land on the formula
surface and conclude there is no primitive index — which is the exact
failure mode GH#3621 is closing.

Adds cmd/bd/testdata/formula_help.txt as the regression gate: a
scripttest that runs `bd formula --help` (plus `--help` on the list
and show subcommands) and asserts the four pointers are present. If
someone deletes a pointer, the snapshot fails.

website/docs/cli-reference/formula.md is auto-generated from the Long
descriptions via `bd help --doc formula`, so the website doc inherits
the pointers on its next regeneration with no manual edit.

Item 1 of GH#3621.

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

* feat(formula): curated primitive examples + smoke harness (beads-0sp)

Adds examples/formulas/primitives/ with one minimal `.formula.toml` per
empirically wired primitive in internal/formula/types.go:

  loop-count    LoopSpec.count       expand body 3x → .iter1.work…
  loop-range    LoopSpec.range/var   {n} substitutes into title
  children-epic Step.Children        epic + children w/ sibling needs
  branch-fanin  ComposeRules.Branch  fork-join, deploy depends on 3 sibs
  condition     Step.Condition       var-driven step inclusion
  gate-timer    Step.Gate            sibling gate-typed issue blocks step

Each fixture has a header doc-comment explaining the primitive in
plain language; README.md indexes them with a one-line description
each and points back at `bd formula schema`.

cmd/bd/formula_primitives_test.go is the smoke harness: for each
fixture it parses, cooks through the full transformation pipeline
(loops → branches → gates → advice → expansions → conditions), and
asserts the primitive's observable effect on the cooked subgraph
(issue IDs, blocking deps, substituted titles, gate await_type).
Cooks against an in-memory subgraph rather than a Dolt-backed temp
DB so the harness exercises the primitive transformation, not the
persistence/auto-export infrastructure.

A subtest fails if a fixture is added to the directory without a
registered assertion in cases[] — the harness exists to prove
primitives are wired, not just that fixtures parse.

Explicitly omits an `on_complete` fixture; that primitive is a
runtime no-op as of v1.0.3 and ships with beads-i02's resolution,
not this epic.

Item 3 of GH#3621.

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

* fix(formula): satisfy CI gosec G306 + regen CLI doc for new help text

Two CI fixes for the formula primitives PR:

  - internal/formula/cmd/schemagen/main.go:26 — drop WriteFile perms
    from 0644 to 0600 (gosec G306).
  - website/docs/cli-reference/formula.md and the v1.0.0 mirror —
    regenerated from the updated `bd formula --help` Long text via
    scripts/generate-cli-docs.sh, using a CGO_ENABLED=0 bd build to
    match CI.

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

* fix(formula): distinguish schema from wired primitives

* fix(formula): regen schema_gen.go for rebase onto current main

Upstream main's Formula struct gained an Intent field after PR #3781 was
opened; regenerate schema_gen.go via go generate so
TestSchemaGenIsCurrent passes after rebasing the PR's commits onto
current main.

Maintainer fix-merge for gastownhall/beads#3781.

Agent-Signature: claude-fable-5-medium on behalf of matt wilkie

---------

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-authored-by: matt wilkie <maphew@gmail.com>
2026-07-06 22:26:41 -07:00
..
auto_export.txt fix(init): make JSONL auto-export opt-in (#4063) 2026-05-21 16:21:00 -07:00
blocked.txt Switch from hex to Base36 encoding for issue IDs (GH #213) 2025-11-03 12:02:15 -08:00
close.txt Switch from hex to Base36 encoding for issue IDs (GH #213) 2025-11-03 12:02:15 -08:00
close_errors.txt test: add error case and missing command script tests (dolt-test-evu) 2026-02-07 18:47:41 -08:00
comments.txt test: add error case and missing command script tests (dolt-test-evu) 2026-02-07 18:47:41 -08:00
config.txt test: add error case and missing command script tests (dolt-test-evu) 2026-02-07 18:47:41 -08:00
create.txt Add scripttest-based integration tests (#59) 2025-10-16 17:11:54 -07:00
create_errors.txt test: add error case and missing command script tests (dolt-test-evu) 2026-02-07 18:47:41 -08:00
delete.txt test: add error case and missing command script tests (dolt-test-evu) 2026-02-07 18:47:41 -08:00
delete_errors.txt test: add error case and missing command script tests (dolt-test-evu) 2026-02-07 18:47:41 -08:00
dep_add.txt fix: Update dep_add test to match current show output format 2025-11-04 00:23:25 -08:00
dep_errors.txt test: add error case and missing command script tests (dolt-test-evu) 2026-02-07 18:47:41 -08:00
dep_remove.txt Switch from hex to Base36 encoding for issue IDs (GH #213) 2025-11-03 12:02:15 -08:00
dep_tree.txt Switch from hex to Base36 encoding for issue IDs (GH #213) 2025-11-03 12:02:15 -08:00
export.txt fix: remove nonexistent -i flag from bd import references (#3200) 2026-04-11 12:31:38 -07:00
formula_help.txt feat(formula): make primitives discoverable to coding agents (GH#3621) (#3781) 2026-07-06 22:26:41 -07:00
help.txt Add scripttest-based integration tests (#59) 2025-10-16 17:11:54 -07:00
import.txt fix: remove nonexistent -i flag from bd import references (#3200) 2026-04-11 12:31:38 -07:00
init.txt Fix config system: rename config.json → metadata.json, fix config.yaml loading 2025-11-02 14:31:22 -08:00
label.txt test: add error case and missing command script tests (dolt-test-evu) 2026-02-07 18:47:41 -08:00
lint.txt test: add error case and missing command script tests (dolt-test-evu) 2026-02-07 18:47:41 -08:00
list.txt Add scripttest-based integration tests (#59) 2025-10-16 17:11:54 -07:00
prime_content.txt feat: surface quality/lifecycle commands in prime, template, and doctor (fix-merge PR #2664) 2026-03-20 17:50:24 -07:00
quickstart.txt Add scripttest-based integration tests (#59) 2025-10-16 17:11:54 -07:00
ready.txt Add scripttest-based integration tests (#59) 2025-10-16 17:11:54 -07:00
search.txt test: add error case and missing command script tests (dolt-test-evu) 2026-02-07 18:47:41 -08:00
show.txt Switch from hex to Base36 encoding for issue IDs (GH #213) 2025-11-03 12:02:15 -08:00
show_errors.txt test: add error case and missing command script tests (dolt-test-evu) 2026-02-07 18:47:41 -08:00
stats.txt Switch from hex to Base36 encoding for issue IDs (GH #213) 2025-11-03 12:02:15 -08:00
update.txt docs(claim): standardize start-work semantics to --claim (#2070) 2026-02-24 22:11:39 -08:00
update_errors.txt test: add error case and missing command script tests (dolt-test-evu) 2026-02-07 18:47:41 -08:00
version.txt Add scripttest-based integration tests (#59) 2025-10-16 17:11:54 -07:00