beads/internal/storage/issueops
Stephanie Jarmak 05c7835e9d
feat(storage): honor .beads/config.yaml types.custom in server-side validation (#4024) (#4026)
* feat(storage): honor .beads/config.yaml types.custom in server-side validation (#4024)

ResolveCustomTypesInTx previously consulted config.GetCustomTypesFromYAML
only in a narrow error-fallback path: when both the custom_types table AND
the types.custom config-string read had failed. As a result, a project that
declared types.custom in .beads/config.yaml (the version-controlled config
shape that downstream wrappers like gastownhall/gascity expect) could not
create or update beads of those types — server-side schema validation
rejected them because it never saw the YAML entries.

Overlay model (per #4024's proposed behavior):
  - Built-in types stay as the enforced floor (handled by IsValidWithCustom).
  - Database custom_types are the next layer (operator-/agent-installed types).
  - .beads/config.yaml types.custom is the topmost union-add (project-extension
    types declared in version-controlled config).
  - A bead whose type is in none of the three still fails validation cleanly.

Extracts mergeWithYAMLCustomTypes(dbTypes, yamlGetter) as a pure helper so
the union logic is unit-testable without sql.Tx mocking. The new helper:
  - Preserves order: DB types first, YAML-only types appended in declared order.
  - Dedupes whitespace-trimmed entries.
  - Drops empty/whitespace-only entries.
  - Tolerates nil getter and nil dbTypes.

Tests in internal/storage/issueops/config_helpers_test.go:
  - TestMergeWithYAMLCustomTypes — 7 table cases: both empty, yaml-only,
    db-only, db+disjoint-yaml union, db+overlapping-yaml dedup, yaml
    internal-dup dedup, whitespace dropping.
  - TestMergeWithYAMLCustomTypes_NilGetter — explicit nil-getter guard.

The pre-existing ResolveCustomTypesInTx error-fallback path is preserved:
when the config-string read errors AND YAML has types, return the YAML
overlay anyway with the original error — so a stable-bd project running
pre-#3691 doesn't lose its types.custom validation just because the
config-string read errored.

Downstream context: this unblocks gastownhall/gascity#2154 (the Gas City
side, which writes types.custom into .beads/config.yaml via
gc-beads-bd.sh's ensure_types_custom_in_yaml). Once this lands and bd
deployments adopt the fixed build, Gas City projects no longer need the
fallback workaround of mirroring types.custom into the database side.

* fix: address PR #4026 review findings (#4024)

Two findings from Copilot review:

1. ResolveCustomTypesInTx returned the YAML overlay alongside a non-nil
   error when the in-tx config-string read failed. In-tx callers
   (NewBatchContext, UpdateIssueInTx) treat any error as fatal, so the
   YAML-fallback path was effectively unreachable on pre-migration /
   degraded DBs — defeating the #4024 overlay goal precisely in the
   scenario the overlay was meant to cover. Mirror
   ResolveCustomStatusesDetailedInTx: when YAML supplies types, return
   them with a nil error; otherwise propagate the DB error. Extracted
   into customTypesYAMLFallback for unit testing without sql.Tx mocking.

2. getConfigList (the helper backing GetCustomTypesFromYAML /
   GetInfraTypesFromYAML / GetCustomStatusesFromYAML) used
   viper.GetString + comma-split, which silently ignored the YAML
   sequence form named in #4024 (`types: { custom: [step, wisp] }`).
   List-form .beads/config.yaml declarations therefore yielded an empty
   overlay. Try viper.GetStringSlice first (supports both block-list
   and inline-flow syntaxes), keeping the comma-split fallback for the
   legacy `types.custom = "step,wisp"` string form.

Tests: TestCustomTypesYAMLFallback covers the fallback decision;
TestGetCustomTypesFromYAML_ListForm and TestGetCustomTypesFromYAML_InlineListForm
pin both YAML sequence syntaxes.

Refs: gastownhall/beads#4024

---------

Co-authored-by: sjarmak <stephanie.jarmak1@gmail.com>
2026-05-21 10:26:53 -07:00
..
as_of.go /{cmd,internal}: implement as of 2026-03-19 12:49:44 -07:00
batching.go fix(storage): preserve mixed issue and wisp reads (#3991) 2026-05-21 06:50:42 -07:00
batching_test.go fix(storage): preserve mixed issue and wisp reads (#3991) 2026-05-21 06:50:42 -07:00
blocked.go /{cmd,internal}: remove depends_on_id 2026-05-19 10:17:49 -07:00
blocked_test.go /{cmd,internal}: remove depends_on_id 2026-05-19 10:17:49 -07:00
bulk_ops.go fix(storage): preserve mixed issue and wisp reads (#3991) 2026-05-21 06:50:42 -07:00
child_id.go /internal/storage: remove dual tx 2026-05-15 12:07:41 -07:00
claim.go Add atomic ready claim (GH-3570) 2026-04-28 07:11:13 -07:00
close.go /{cmd,internal}: update and close issue methods 2026-03-18 19:15:33 -07:00
comments.go fix(storage): preserve mixed issue and wisp reads (#3991) 2026-05-21 06:50:42 -07:00
commit_pending.go /{cmd,internal}: refactor again 2026-03-17 18:11:37 -07:00
compaction.go /{cmd,internal}: remove depends_on_id 2026-05-19 10:17:49 -07:00
config_helpers.go feat(storage): honor .beads/config.yaml types.custom in server-side validation (#4024) (#4026) 2026-05-21 10:26:53 -07:00
config_helpers_test.go feat(storage): honor .beads/config.yaml types.custom in server-side validation (#4024) (#4026) 2026-05-21 10:26:53 -07:00
config_metadata.go /{cmd,internal}: move local only state to dolt ignored tables 2026-04-14 14:47:30 -07:00
create.go {CHANGELOG.md,internal}: cleanup and release notes 2026-05-15 13:11:39 -07:00
cycles.go /{cmd,internal}: remove depends_on_id 2026-05-19 10:17:49 -07:00
delete.go fix(storage): preserve mixed issue and wisp reads (#3991) 2026-05-21 06:50:42 -07:00
dependencies.go fix(storage): preserve mixed issue and wisp reads (#3991) 2026-05-21 06:50:42 -07:00
dependencies_test.go fix(storage): preserve mixed issue and wisp reads (#3991) 2026-05-21 06:50:42 -07:00
dependency_queries.go fix(storage): preserve mixed issue and wisp reads (#3991) 2026-05-21 06:50:42 -07:00
dependency_queries_test.go fix(storage): preserve mixed issue and wisp reads (#3991) 2026-05-21 06:50:42 -07:00
dependency_tree.go fix(dep): show dependency type in bd dep tree output (GH#3565) (#3647) 2026-05-02 14:25:33 -07:00
diff.go /internal/storage/{dolt,embeddeddolt,issueops}: implement methods 2026-03-20 11:46:28 -07:00
epic_closure.go fix(storage): preserve mixed issue and wisp reads (#3991) 2026-05-21 06:50:42 -07:00
events.go /{cmd,internal}: wip sync and data EmbeddedDoltStore methods 2026-03-24 12:01:16 -07:00
federation.go /{cmd,internal}: wip sync and data EmbeddedDoltStore methods 2026-03-24 12:01:16 -07:00
filters.go /{cmd,internal}: remove depends_on_id 2026-05-19 10:17:49 -07:00
filters_test.go perf(search): tighten label and partial-id queries (#3967) 2026-05-16 02:44:45 -07:00
get_issue.go perf(get): query primary issues before wisp fallback (#4003) 2026-05-18 03:37:02 -07:00
helpers.go fix(config): reject issue-prefix config set 2026-04-24 07:52:50 -07:00
helpers_test.go fix: update gate_test.go for multi-rig removal and fix gofmt in issueops tests (#2907) 2026-03-29 14:01:48 -07:00
history.go /internal/storage/{dolt,embeddeddolt,issueops}: implement methods 2026-03-20 11:46:28 -07:00
labels.go fix(dolt): preserve label hydration wisp-set callers 2026-05-02 13:35:48 -07:00
molecule.go /{cmd,internal}: remove depends_on_id 2026-05-19 10:17:49 -07:00
promote.go fix(storage): preserve mixed issue and wisp reads (#3991) 2026-05-21 06:50:42 -07:00
ready_work.go fix(storage): preserve mixed issue and wisp reads (#3991) 2026-05-21 06:50:42 -07:00
ready_work_test.go fix(storage): preserve mixed issue and wisp reads (#3991) 2026-05-21 06:50:42 -07:00
scan.go feat(issues): add started_at timestamp (GH#2796) (#3206) 2026-04-14 09:24:08 -07:00
search.go fix(storage): preserve mixed issue and wisp reads (#3991) 2026-05-21 06:50:42 -07:00
stale.go perf(storage): amortize per-ID wisp routing via WispIDSetInTx (#3453) 2026-04-24 13:39:42 -07:00
statistics.go /internal/storage: wip, refactor 2026-03-24 17:28:13 -07:00
update.go fix(storage): preserve mixed issue and wisp reads (#3991) 2026-05-21 06:50:42 -07:00
wisp_filter_convert.go feat: add ListWisps method to Storage interface (fix-merge PR #2783) 2026-03-26 19:33:28 -07:00
wisp_routing.go fix(dolt): batch wisp-ID partition in bulk hydrators (GH#3414) 2026-05-02 13:27:24 -07:00
wisp_routing_test.go perf(storage): amortize per-ID wisp routing via WispIDSetInTx (#3453) 2026-04-24 13:39:42 -07:00