beads/internal/formula
Isis Anisoptera ef0ec061fa
fix(cook/pour): honor declared formula step types instead of squashing them to task (#5520)
* Stop cook coercing non-whitelisted formula step types to task

stepTypeToIssueType had a hardcoded five-type switch whose default
branch silently turned every other step type — custom types like
"duty", but also built-ins like decision, spike, and story — into
task. Pass the type through with Normalize() instead, defaulting to
task only when the step type is empty.

No validation is added here: pour already registers non-built-in
types via ensureSubgraphCustomTypes and the storage layer validates
against types.custom, the same division of labor as bd create --type.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YLWg73gpPfwinj1jn3UhmU

* Fix custom-type registration gaps and honor declared parent step types

Review follow-ups to the cook/pour type passthrough (GH#5443):

- bd cook --persist now registers custom step types via
  ensureSubgraphCustomTypes, matching the pour path
- doltTransaction.SetConfig syncs custom_types/custom_statuses tables so
  in-transaction registration is visible to validation
- Wisp creation builds its validation BatchContext on regularTx (new
  issueops.CreateIssuesInTxWithContext), so a custom type registered in
  the same transaction validates on the dolt server backend
- Parent steps with a declared type keep it; only an undeclared type
  defaults to epic
- Step types are trimmed before normalizing; types.custom is serialized
  with json.Marshal; doctor's multirepo checks parse it JSON-first
- Registration gates on IsBuiltIn() so built-in types like event are not
  churned into types.custom
- Regression test runs against a local dolt sql-server when the Docker
  test container is unavailable

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YLWg73gpPfwinj1jn3UhmU

* Consolidate duplicated custom-type plumbing behind shared issueops helpers

Cleanup pass over the GH#5443 branch:

- Export issueops.ParseTypesConfigValue and point the doctor, domain/db,
  template.go's comma-split hack, and config_helpers.go's own inline
  copies at it instead of five parallel JSON-or-CSV parsers.
- Extract issueops.SyncConfigTables to own the config-key -> normalized
  table mapping; all four SetConfig implementations now share it.
- Build one BatchContext per doltTransaction create call: hoisted above
  the wisp/regular branch in CreateIssue, shared across both legs in
  CreateIssues (drops 4 redundant config reads on mixed batches).
- CreateIssuesInTxWithContext sets SkipChildCounterReconcile on a
  shallow copy so the caller's context is reusable.
- Retype ensureSubgraphCustomTypes as ensureCustomTypesForIssues taking
  []*types.Issue, removing cook's throwaway TemplateSubgraph wrapper.
- Rebuild setupLocalServerStore on the setupWispCascadeStore recipe:
  t.Cleanup teardown and CreateIfMissing instead of hand-rolled
  CREATE DATABASE / initSchemaOnDB / shelled dolt init.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YLWg73gpPfwinj1jn3UhmU

* Stop auto-registering formula custom types; flatten unregistered to task/epic

Pour and cook --persist no longer write step types into types.custom.
A step type that is neither built-in nor already registered is flattened
with a warning — to epic when the step has children (matching the
undeclared-parent default), task otherwise. Operators opt in with
bd config set types.custom before pouring; a typo'd step type can no
longer become a permanently registered custom type.

ensureCustomTypesForIssues (the read-merge-write into types.custom)
becomes flattenUnregisteredIssueTypes, reading types.custom through the
transaction plus config.yaml-declared types to match insert validation.
The now-unused molConfigWriter interface is gone.

Also lands the code-review fixes on the same plumbing:
- storeMolWriter.GetConfig routes through the bound transaction, fixing
  out-of-tx config reads (lost-update window; MaxOpenConns=1 hang).
- doltTransaction.SetConfig invalidates DoltStore's config caches via
  the shared invalidateConfigCaches, so long-lived processes stop
  serving stale custom type/status sets.
- doctor's unknown-type check uses IsBuiltIn instead of a stale 6-type
  hardcoded list that would have flagged spike/story/gate as unknown.
- schema backfill uses issueops.ParseTypesConfigValue (no import cycle;
  the old copy kept untrimmed JSON elements).
- Dead EnsureCustomTypeInTx (misleading GH#3213 doc, wrote table-only
  rows the sync invariant wipes) and dead GetCustomTypesTx deleted.

Step.Type docs updated and schema_gen.go regenerated via go generate.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YLWg73gpPfwinj1jn3UhmU

* Fold the last SetConfig path into SyncConfigTables; cleanups

Follow-up cleanup on the custom-types work.

EmbeddedDoltStore.SetConfig still carried the hand-rolled `switch key`
that the other four SetConfig paths replaced with SyncConfigTables, so
the helper's stated invariant — every SetConfig path keeps the
projection in step — had a hole. Route it through the helper, then
unexport syncCustomTypesTable/syncCustomStatusesTable: with no callers
left outside SyncConfigTables, the single-entry-point rule is enforced
by the compiler rather than by a comment.

Smaller cleanups alongside it:

- Drop linearConfigReader; it was the same single-method interface as
  configReader, in the same package.
- flattenUnregisteredIssueTypes built three collections where one does
  the job. Seed `unknown` directly and delete registered types, losing
  the string/IssueType round-trip.
- Use WarnError instead of open-coding its Fprintf.
- processStepToIssue trimmed step.Type twice, once inside
  stepTypeToIssueType and again for the epic default; hoist to one
  declaredType so the two can't drift.
- Remove the `typesStr == ""` guard in readTypesFromDB, left behind
  when its loop became ParseTypesConfigValue (which returns nil for
  empty).
- Rename the BatchContext copy in CreateIssuesInTxWithContext from
  `local` to `batch` instead of reassigning the parameter, so bc
  provably stays the caller's pointer.
- Lead storeMolWriter.GetConfig's doc with the reason that still
  applies (second pool connection deadlocks at MaxOpenConns=1); nothing
  registers types in-transaction during pour any more.

No behavior change. gofmt, go vet, and the affected tests pass;
golangci-lint was not available locally.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YLWg73gpPfwinj1jn3UhmU

---------

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-08-10 05:36:33 -07:00
..
cmd/schemagen feat(formula): make primitives discoverable to coding agents (GH#3621) (#3781) 2026-07-06 22:26:41 -07:00
schemagen feat(formula): make primitives discoverable to coding agents (GH#3621) (#3781) 2026-07-06 22:26:41 -07:00
advice.go chore: remove issue ID references from comments and changelogs 2025-12-28 10:05:16 -08:00
advice_test.go fix: Prevent aspect self-matching infinite recursion (gt-8tmz.16) 2025-12-25 12:21:23 -08:00
condition.go fix: Address code review issues in condition evaluator 2025-12-25 14:00:56 -08:00
condition_test.go style: run gofmt across entire codebase (bd-nmk12) 2026-02-07 19:35:20 -08:00
controlflow.go chore: remove issue ID references from comments and changelogs 2025-12-28 10:05:16 -08:00
controlflow_test.go Implement computed range expansion for loops (gt-8tmz.27) 2025-12-25 17:48:35 -08:00
expand.go feat(cook): support standalone expansion formula execution in bd mol wisp (#1903) 2026-02-22 13:00:25 -08:00
expand_test.go feat(cook): support standalone expansion formula execution in bd mol wisp (#1903) 2026-02-22 13:00:25 -08:00
intent_test.go feat(formula): surface intent field in JSON output (maintainer cherry-pick from PR #4056) (#4081) 2026-07-06 22:21:56 -07:00
parser.go Merge branch 'main' into fix/cross-repo-github-gates 2026-08-02 23:38:17 -07:00
parser_test.go Merge branch 'main' into fix/cross-repo-github-gates 2026-08-02 23:38:17 -07:00
range.go Implement computed range expansion for loops (gt-8tmz.27) 2025-12-25 17:48:35 -08:00
range_test.go style: run gofmt across entire codebase (bd-nmk12) 2026-02-07 19:35:20 -08:00
schema.go feat(formula): make primitives discoverable to coding agents (GH#3621) (#3781) 2026-07-06 22:26:41 -07:00
schema_gen.go fix(cook/pour): honor declared formula step types instead of squashing them to task (#5520) 2026-08-10 05:36:33 -07:00
schema_gen_test.go feat(formula): make primitives discoverable to coding agents (GH#3621) (#3781) 2026-07-06 22:26:41 -07:00
schema_test.go feat(formula): make primitives discoverable to coding agents (GH#3621) (#3781) 2026-07-06 22:26:41 -07:00
stepcondition.go feat: add negation support for step conditions (!{{var}}) 2025-12-31 00:37:59 -08:00
stepcondition_test.go style: run gofmt across entire codebase (bd-nmk12) 2026-02-07 19:35:20 -08:00
types.go fix(cook/pour): honor declared formula step types instead of squashing them to task (#5520) 2026-08-10 05:36:33 -07:00