Commit graph

19 commits

Author SHA1 Message Date
Harry Miller
ce756a5b86
fix(metadata): require a JSON object for --metadata on create and update (#6035) (#6743)
* fix(metadata): require a JSON object for --metadata on create and update (#6035)

Root cause: the four --metadata entry points (create and update, each in
its direct and proxied-server variant: create.go, create_input.go,
update.go, update_input.go) carried copies of the same check, json.Valid,
which accepts any JSON value. `bd create --metadata '"oops"'` therefore
stored a bare string (or an array, number or null) as the issue's
metadata. `bd update` with the same value was refused only late, by the
storage-layer merge, with an internal unmarshal error.

Fix: one shared readMetadataFlag helper resolves the value (inline or
@file.json) and requires a top-level JSON object, refusing a string,
number, boolean, array or null with "invalid --metadata: must be a JSON
object such as {"key":"value"}, got <kind>". The rule matches what the
storage merge already enforces for update (it unmarshals into a map and
rejects null), so `{}` stays accepted and null is now refused on create
too, where it used to be stored literally. The storage layer is not
changed.

Not changed: an object whose value is a string that looks like JSON
(`{"mykey":"{\"inner\":\"v\"}"}`, the nested case in the report) is
still accepted and stored as written. Metadata values are opaque, and
refusing such strings would be a design change, not a fix.

Agent-Signature: claude-code-opus-5-5-unknown-reasoning on behalf of Harry Miller
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* test(metadata): cover boolean and null in the end-to-end create/update case (#6743 review)

Agent-Signature: claude-code-opus-5-5-unknown-reasoning on behalf of Harry Miller
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* fix(metadata): correct the null-behavior claims and the --metadata help text (#6743 review)

Maintainer review fixups for #6743. The review found no blocker and no major,
and the scorecard approved with no required changes; these are its minors and
nits.

- The helper doc comment and the CHANGELOG entry both said the new object rule
  matches what the storage merge already enforced for update. That holds for a
  string, number, boolean or array, and is false for null: json.Unmarshal of
  the literal null into a map zeroes the map and returns no error, so
  MergeMetadataJSON merged nothing and `bd update --metadata null` exited 0.
  Refusing null is a real, if small, behavior change on update, so both
  surfaces now say that instead of claiming a non-change.

- The --metadata help text on create and update advertised "JSON string", the
  one input this change exists to refuse; both now read "JSON object". The
  generated CLI docs are deliberately not regenerated alongside it:
  docs/cli-docs.pin is v1.2.2, so generate-cli-docs.sh builds bd from that tag
  rather than from the checkout, and the committed pages are refreshed at
  release. Verified both ways -- with this edit alone, check-doc-flags.sh
  Check 4 reports "PASS: generated CLI docs are fresh"; hand-editing
  docs/cli-reference/create.md to the new string instead makes it report
  "FAIL: docs/cli-reference is out of sync with live CLI help".

- The `object == nil` arm of the guard is load-bearing and read as redundant to
  both reviewers, so it now says out loud that it is what catches null, and
  names internal/httpapi/batch_apply.go as the source of the idiom. Keeping the
  unmarshal rather than switching the guard to jsonKind preserves symmetry with
  that plane; the synthesis offered either.

- jsonKind's "empty input" arm is unreachable from both callers, which sit
  behind json.Valid. Documented as defensive rather than dropped, because
  dropping it makes the byte index below panic for any future caller that has
  not validated first.

- os.ReadFile's error is wrapped with %w, so callers of this newly shared
  helper can still reach fs.ErrNotExist.

The PR body asserts the same null premise in two places (its `null` table row
and the "keeps update's existing rule" bullet) and overstates HTTP-plane
enforcement; those are corrected at finalize, since review iterations do not
touch GitHub.

No behavior change beyond the help string. `go test ./cmd/bd -run GH6035`
passes; gofmt, go vet, check-doc-flags.sh and check-doc-freshness.sh clean.

---------

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-authored-by: Julian Knutsen <julianknutsen@users.noreply.github.com>
2026-09-26 03:24:57 -07:00
Julian Knutsen
b3d17caa6d Merge release/1.3.0 into main (post-tag forward-port)
Forward-ports the 38 commits that shipped on release/1.3.0 (tagged v1.3.0 at
f45b249ce) into main, as RELEASING.md mandates after a tag. None of them had
ever been forward-ported. Recorded as a merge so main becomes a superset of
the release branch and the lineage is in the history.

Migration ordinal collision (the reason this needed a human-shaped merge):
both branches independently claimed clone-local ignored slot 0026 under
different filenames, so git merged both in with no conflict and left the
series with two migrations at ordinal 26 — a single-integer cursor cannot
address that, and migrationSource.list() panics on it.

Main's ignored/0026_add_wisps_current_revision is renumbered to 0027.
Release's 0026_dep_rekey_dedup_marker is in the shipped v1.3.0 tag, so field
stores have already recorded it at 26 and it can never move; main's twin has
never shipped in any release, so it is the one that is free to move. 0027 was
unused in the ignored series (both sides topped out at 26).

This trips check-migration-hygiene.sh Check C (frozen migrations), which has
no exemption mechanism. That is expected and accepted: breaking the collision
requires a rename, and the ignored series' cursor table is itself dolt-ignored,
so its content hashes are clone-local and never participate in the cross-clone
ContentHashSkew comparison that Check C exists to protect. Main's 0067 body is
deliberately NOT edited for the same reason in reverse — it is main-plane and
its hash IS compared across clones.

Conflicts resolved:

  CHANGELOG.md                       release's finalized [1.3.0] section kept
                                     byte-identical; main's two unreleased
                                     entries (#6023, #5859) moved up under
                                     [Unreleased] where they belong
  cmd/bd/init_safety.go              union — release's added paragraph is
  cmd/bd/init_safety_help.go         accurate against the merged code (three
                                     exit-12 sources, incl. init.go:3147)
  internal/storage/uow/dolt_sql_provider.go
                                     kept main's newProvider refactor AND
                                     release's readOnly field/assertion;
                                     newProvider gained readOnly: opts.readOnly
                                     so release's read-through-refused-migration
                                     behavior survives main's refactor
  .github/workflows/main.yml         single -timeout=30m per release's #6091
  scripts/ci_workflow_test.go        design (flag on the invocation, not in
                                     matrix.test-flags); the shadowed 25m in
                                     matrix.test-flags removed
  scripts/migration-test/lib/versions.sh
                                     union — main's darwin/arm64 corpus plus
                                     release's v1.2.2 linux/amd64 entry
  integrations/beads-mcp/uv.lock     ruff 0.16.5 (release, newer); block is
                                     internally consistent, uv lock --check ok
  default.nix                        vendorHash left at main's value and is
                                     KNOWN STALE — see below

Version stamp lands at 1.3.0 (main had been sitting at the previously-released
1.2.2, this project's between-releases pattern). check-versions.sh: 24/24.

Known follow-up: default.nix vendorHash. The merged go.mod/go.sum is a genuine
union (release's kin-openapi/oapi-codegen bumps + main's newer Dolt stack) and
matches neither side, so neither recorded hash is correct. It must be
regenerated with scripts/update-nix-vendorhash.sh. The repo's automatic fixer
(update-vendor-hash.yml) is dependabot-only and will not run on this PR.
2026-09-15 22:09:13 +00:00
Vishnu J
67b066b58e
fix(create): say --file is one issue per ## heading (#5921)
bd create --file/-f is a batch-import route: it creates one issue per
H2 ("##") heading, and ### subsections attach fields to that issue.
The old Usage was "Create multiple issues from markdown file", which
never named those semantics or --body-file. Callers who wanted "one
issue, description loaded from a file" reached for the shortest flag
and got a silent bulk import instead -- reported by @seanmartinsmith
with a 3-section briefing file (## Problem / ## Context / ##
Acceptance Criteria) that became 3 issues instead of one.

gatherCreateInput already rejects a positional title combined with
--file. That is the reporter's literal repro, so this keeps the
rejection and adds a --body-file hint on the error they actually
see. The remaining trap -- --file used alone on a section-headed
file -- is unchanged, because bd cannot tell that apart from a
genuine batch file by content.

Tests: parseMarkdownFile reproduces the trap file; gatherCreateInput
locks in the title+--file rejection and --body-file hint; flag Usage
names the per-heading behavior. The existing TestCreateFromMarkdownFile
binary path already covers well-formed --file creates.
2026-09-02 18:11:56 -07:00
Julian Knutsen
a18416484c
fix(create): wire --storage-class through the proxied, markdown, and graph input paths (#6060)
* refactor(create): extract resolveCreateStorageClass from the direct RunE

The flag→class block (parse, per-type config fallback, ephemeral spelling →
wisp plane, --no-history exclusivity, plane reconciliation) becomes one helper
so the other CLI doors can call the same decision instead of reimplementing or
skipping it. Pure refactor: the direct route's behavior and error strings are
unchanged.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* fix(create): wire --storage-class through the proxied, markdown, and graph doors

createInput carries the resolved class, so the proxied single create persists
it, routes `--storage-class ephemeral` to the wisp plane, rejects a durable
class paired with --ephemeral/--no-history, and honors the per-type
storage-class.<type> config default — all four of which it silently dropped.

buildMarkdownBatchRequest resolves the class per template, which fixes `--file`
on BOTH transports at once (one shared projection), and --graph now refuses a
plan-wide --storage-class the way it already refuses --mol-type, pointing at
the per-node storage_class field that works.

The v0 HTTP wire is unchanged: storage_class stays off the create member list
and unknown members are still refused by name. The spec gains one sentence
saying the per-type config defaults are CLI-door policy, so the divergence is
documented rather than silent.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* test(create): pin the storage-class contract on every CLI door

The pure table covers resolveCreateStorageClass end to end (three classes,
config default, alias-normalized type key, both conflict arms) plus the two
links the proxied bug broke: gatherCreateInput populating createInput and
buildCreateIssueFromInput carrying it.

storage_class_proxied_integration_test.go is the proxied mirror of the embedded
suite, asserting the raw storage_class cell on the plane each request should
have landed on — the JSON alone would have agreed with itself. It reproduces
what the field report hit (unversioned dropped, an ephemeral request minting a
durable row, the wisp-plane conflict silently collapsed, the config default
skipped) as failing assertions.

The embedded suite grows --file subtests on all four class outcomes and the
--graph rejection.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-08-29 07:16:04 -07:00
Robin Carswell
543e44aef8
fix(labels): normalize labels on write, and warn when one contains a space (#5812) (#5813)
* fix(labels): normalize labels on write, as read paths already do (#5812)

bd applies utils.NormalizeLabels (trim, drop empty, dedupe) to every label
FILTER path -- list, search, ready, orphans, count and the workapi
equivalents -- but to no label WRITE path.

That asymmetry stores labels no filter can match:

    bd create "T" --labels 'theme:a, theme:b'   # stores "theme:a", " theme:b"
    bd list --label theme:b                     # filter trims -- no match

--labels 'a, b' is the comma-space form most people type, and pflag's CSV
split leaves the leading space on the second element, so the split looks
like it worked. A filtered list that is silently short is
indistinguishable from a complete one.

Two more everyday inputs corrupt just as quietly: --labels 'a,,b' stores
an empty label, and --labels 'a,a' stores the same label twice.

Apply the existing helper on the write paths so write and read agree:
create (--labels and its --label alias, normalized after merging the two
so dedupe spans both), quick, and update (--add-label, --remove-label,
--set-labels). --remove-label matters as much as the additive flags: an
untrimmed ' theme:a' fails to match the stored label and silently removes
nothing. The --set-labels '' clear-all signal is preserved -- it is gated
on pointer identity, not slice length.

Also add a warn-only 'Label Whitespace' doctor check, since the write-path
fix does nothing for labels already stored and nothing else surfaces them.
It reports leading/trailing and blank labels only. A label whose trimmed
form still contains whitespace is deliberately not reported: that turns on
what a space between labels should mean, which this change does not
settle, and "good first issue" is a legitimate multi-word label.

Not auto-fixable by design -- trimming a damaged label can collide with a
correct label already on the same issue, which needs a human decision.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* feat(labels): warn when a stored label contains a space (#5812)

A label containing a space is almost always a comma that was meant and
missed. That is the failure behind #5812's evidence: 150 corrupt label
rows across 111 issues, found months later only because theme-by-theme
counts failed to reconcile.

The issue proposed splitting labels on whitespace as well as commas. This
deliberately does NOT do that, and the reasoning is worth recording.

A shell has exactly one mechanism for "is this one word or two", and it is
already unambiguous. All three of these send ONE argument:

    bd create T --labels 'one two'
    bd create T --labels "one two"
    bd create T --labels one\ two

They are byte-identical by the time bd sees them: quoting and backslash-
escaping are consumed by the shell, which reports only the resulting word
boundaries. It is the same mechanism that makes 'cd my\ dir' work.

Splitting on whitespace would therefore override a boundary the caller has
already explicitly set, making labels the one place on the command line
where quoting does not mean what it means everywhere else. It is also
undoable: with splitting there is no way left to ask for a label containing
a space except a second, nested layer of quotes. And it cannot deliver what
it appears to promise, since 'one two' and "one two" are indistinguishable
by the time any code could act on them.

So honor the shell's boundaries, which bd already does, and warn instead:

    ⚠ Stored "theme:a theme:b" as ONE label — it contains a space.
      If you meant several labels, separate them with commas (a,b) or
      repeat the flag.

The 150 rows would have produced 150 warnings at the keystroke, while
--labels 'good first issue' still does exactly what it says. A warning
rather than an error, because a space-containing label is a legitimate
thing to ask for and the shell has just been used to ask for it; --quiet
silences it. No command changes meaning.

Applied to the paths that write labels: create, q, --add-label and
--set-labels. Deliberately not --remove-label, because removing a
space-containing label is how the damage gets repaired and warning on the
repair is noise.

The Label Whitespace doctor check gains a matching third class so an
existing database can find the ones already in it. It is reported
separately from the untrimmed/blank classes and is not called corruption:
bd cannot tell "good first issue" from a missed comma, so it surfaces them
and a human decides.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* fix(labels): close the last raw label write, bd tag (#5812)

Review feedback on #5813. `bd tag` describes itself as "Shorthand for
'bd update <id> --add-label <label>'" and was not: update normalizes and warns,
tag passed the positional straight to AddLabel, and the proxied route passed it
to ApplyLabelPatch, which drops "" but does not trim.

Verified on a scratch DB against binaries built either side of this commit:

  before: bd tag t-fap ' theme:spaced' -> stored " theme:spaced"
          bd list --label theme:spaced -> 0 rows
  after:  bd tag t-wjz ' theme:spaced' -> stored "theme:spaced"
          bd list --label theme:spaced -> 1 row

That is the unfilterable class this PR set out to close, written by the command
whose help text promises equivalence with the one that already closed it.

Normalization happens in tag.go BEFORE the route split, so the direct and
proxied paths cannot diverge on it; runTagProxiedServer now takes the resolved
id and label rather than raw args, which removes the second entry point.

A whitespace-only label is refused (exit 1) rather than dropped. The plural
flags can discard an empty element and still honor the rest of the request;
bd tag has exactly one label to add, so dropping it would report success having
written nothing.

Also here, both from the same review:

- `bd label add` now warns too. splitLabelArg already trimmed, so it never
  stored the untrimmed class, but it could not tell a caller that
  `bd label add bd-1 'theme:a theme:b'` is ONE label. Verified firing.
- docs/core-concepts/labels.md: says plainly that import and batch ingest are
  deliberately NOT normalized (round-trip fidelity; the doctor check is what
  finds legacy damage), so the next reader does not "fix" it. Also notes that
  bare `bd doctor` is not yet supported in embedded mode (GH#3794), so the new
  Label Whitespace check reaches classic and server-mode databases only --
  "run bd doctor" was overselling to embedded users.
- CHANGELOG entries under Fixed and Added.

Co-Authored-By: Claude <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
Co-authored-by: Steve Yegge <steve.yegge@gmail.com>
2026-08-20 08:08:24 -07:00
adrian
0c4946d067
fix: normalize parsed timestamps to UTC (#5295)
* fix: normalize parsed timestamps to UTC (GH#5233)

Agent-Signature: opencode-gpt-5.6-sol-unknown-reasoning on behalf of adrian

* test: cover UTC scheduling round trips (GH#5233)

Agent-Signature: opencode-gpt-5.6-sol-unknown-reasoning on behalf of adrian

* test(count): expect UTC-normalized bounds from local-midnight date flags

TestParseCountRequestCarriesEveryFilterFlag landed on main pinning the
Location identity of parsed --*-after/--*-before bounds, which this
branch's UTC normalization changes while preserving the instant (bare
dates still resolve at the user's local midnight). Construct the
expectation the same way the contract works: local midnight, then UTC.

---------

Co-authored-by: Steve Yegge <steve.yegge@gmail.com>
2026-08-07 07:03:43 -07:00
davevan2
3e6f259608
fix(create): reject caller input that would be discarded (#4984)
* Reject create input that would be silently discarded

* fix(create): reject --allow-empty-description on direct-mode --file/--graph dispatch

Direct-mode (non-proxied) --file and --graph dispatch in cmd/bd/create.go
returned before the validateDescriptionUpdate/--allow-empty-description
check, so the flag was silently accepted-and-ignored in direct mode while
correctly rejected in proxied mode (create_input.go's
rejectSingleIssueFlagsForMarkdown/ForGraph). This closes the direct-mode
gap flagged in the 2026-07-23 CHANGES_REQUESTED review on
gastownhall/beads#4984, adding matching guards before
createIssuesFromMarkdown/createIssuesFromGraph, plus regression tests for
both rejections and a successful single-issue --allow-empty-description
round trip.

Agent-Signature: claude-sonnet-5-medium on behalf of maphew

---------

Co-authored-by: matt wilkie <maphew@gmail.com>
2026-07-28 11:52:52 -07:00
Harry Miller
011c042b3c
fix(create): reject whitespace-only titles (#4771) (#4788)
* fix(create): reject whitespace-only titles instead of accepting them

`bd create --title "   "` (and a whitespace-only positional title) was
accepted, minting a bead whose title is blank. Such a bead is functionally
invisible in every title-based view — board scans, `bd search`, title-sorted
listings — and reads as "no title" to any downstream consumer (GH#4771).

The existing guards only caught a truly empty/absent title; a title of one
or more spaces/tabs slipped past both the positional and `--title` paths.
Add a single `strings.TrimSpace(title) == ""` check after title resolution
so both paths refuse with a clear, non-zero-exit error.

Adds TestCLI_CreateRejectsEmptyTitle covering the flag and positional
whitespace cases.

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

* fix(create): cover the proxied-server path with a pre-open Args validator (PR #4788 review follow-up)

The 2026-07-24 maintainer review found the whitespace-only-title guard
correct but incomplete: it lived only in create's local-store RunE branch,
so `usesProxiedServer() == true` skipped it entirely — gatherCreateInput/
runCreateProxiedServer never re-checked, and the new test covered only the
ordinary backend, so a blank-looking bead could still be minted in proxied
mode (GH#4771).

- Moved the whitespace check into resolveTitle (cmd/bd/create_input.go),
  the helper gatherCreateInput already calls for the proxied path, and
  replaced create.go's manual title-resolution block (which duplicated
  resolveTitle's logic instead of calling it) with a call to the shared
  helper.
- Per the review's "better" option, wired resolveTitle into createCmd.Args
  (validateCreateArgs) instead of only calling it from RunE: cobra runs
  Args validation before PersistentPreRunE, so a guaranteed-to-fail
  whitespace-only title is now rejected before either backend opens a
  store or runs migrations — fixing local and proxied dispatch with one
  check, and stopping wasted migration work as a bonus.
- Added TestCLI_CreateRejectsEmptyTitle_ProxiedServerMode, which forces
  proxiedServerMode and asserts the same rejection without needing a real
  proxied server (Args validation now runs first regardless of backend).

Also noticed (out of scope for this fix, not introduced by it — verified
via `git stash` that the same failures reproduce at the unmodified PR
head): TestCLI_CreateRejectsEmptyTitle's own FlagTab subtest leaves the
shared package-level createCmd's --title flag dirty afterward (never
reset), which cascades into unrelated CLI test failures when the full
`cmd/bd` suite runs together. Made the new proxied test resilient to that
ordering dependency by resetting the flag itself, but did not fix the
root cause suite-wide — that's a pre-existing gap outside this review's
scope.

Agent-Signature: claude-fable-5-medium on behalf of maphew

---------

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-authored-by: matt wilkie <maphew@gmail.com>
2026-07-26 13:29:36 -07:00
Jacob Hausler
2a81e82fca
fix(create): reject --waits-for-gate when --waits-for is absent; add regression tests (#4918)
* fix(create): reject --waits-for-gate when --waits-for is absent; run validation before write

Two bugs in bd create's --waits-for-gate flag, both of the silent-drop family:

**Defect A — silent no-op without --waits-for.**
`bd create "title" --waits-for-gate all-children` (or any value, including
invalid ones) exited 0 and created a normal bead with no gate or dependency.
`buildWaitsFor` returned nil when spawnerID was empty, regardless of whether
--waits-for-gate was explicitly supplied. An operator who wrote --waits-for-gate
believing they had armed a hold got a success message and a fully-dispatchable
bead instead.

Fix: thread a `gateExplicit bool` parameter through `buildWaitsFor` (and the
`waitsForGateSet` field on `createInput` for the proxied-server path). When the
flag was explicitly supplied but no spawner is provided, return an error before
any write.

**Defect B — half-write when both flags are present with an invalid gate value.**
`bd create "title" --waits-for <id> --waits-for-gate TOTALLY-BOGUS` created the
bead first, then validated the gate value and errored. Callers treating a nonzero
exit as "nothing was created" were left with a dep-less, dispatchable orphan. This
was already fixed structurally by the create_atomic.go refactor (validation in
`buildWaitsFor` runs before `createIssueWithDeps`), but had no regression test.

Tests: two new sub-tests in `TestCreateDepsAtomicity` exercise both failure modes
end-to-end against a real embedded-Dolt store: the command must exit nonzero, and
no issue must appear in `bd list` or `bd ready` afterward.

Binary: go version -m $(which bd)
  path  github.com/steveyegge/beads/cmd/bd
  mod   github.com/steveyegge/beads  (devel)  vcs.modified=true

* fix(create): reject waits-for-gate on batch routes; reserve child IDs after validation

Addresses the two should-fix items from the 2026-07-23 maintainer review of
gastownhall/beads#4918 (commit 16de3982), which fixed --waits-for-gate
validation on the single-issue create path but left two gaps:

1. The non-proxied --file/--graph dispatch in create.go's RunE called
   createIssuesFromMarkdown/createIssuesFromGraph directly, bypassing
   rejectSingleIssueFlagsForMarkdown/rejectSingleIssueFlagsForGraph (which
   already list "waits-for"/"waits-for-gate" in singleIssueOnlyFlags), so
   `bd create --file plan.md --waits-for-gate BOGUS` (non-proxied) still
   exited 0. Now call the rejecters before dispatching to the batch routes,
   matching what the proxied path's gatherCreateInput already does.

2. store.GetNextChildID reserved (and committed) a child ID before
   buildWaitsFor validation ran, so `bd create --parent X --waits-for-gate
   BOGUS` (no --waits-for) burned a child ID even though the create itself
   was rejected. Moved the parseDepSpecs/buildWaitsFor validation block
   above the child-ID reservation so a failed validation leaves no gap in
   child numbering.

Adds regression tests in create_deps_atomic_test.go for both gaps: batch
route rejection for --file and --graph, and a child-ID-not-burned check
that creates a parent, fails a --waits-for-gate-without-waits-for child
create, then asserts the next real child still gets .1.

Agent-Signature: claude-sonnet-5-medium on behalf of maphew

---------

Co-authored-by: Jacob Hausler <jacob@hausler.cc>
Co-authored-by: matt wilkie <maphew@gmail.com>
2026-07-25 22:29:30 -07:00
matt wilkie
4103d985d1 fix(create): reject explicit plan ids that already exist
An explicit node id colliding with a stored issue slipped through plan
validation (which only caught intra-plan duplicates) into an insert path
with upsert semantics — the atomic graph create silently rewrote the
existing issue while reporting creation. The upsert behavior is inherited
(bd create --id does the same today), but plans mint ids in bulk, so the
exposure is much larger here.

Add an explicit-ID collision preflight to the shared plan validation:

- graphPlanConfig gains an issueExists probe; embedded supplies it from the
  store (GetIssue spans issues and wisps), proxied from the unit of work's
  per-table getters — bound to the caller's context, so the live proxied
  path probes inside the apply transaction and cannot race a concurrent
  create of the same id. Dry-run validates through the same probe.
- Deliberately not overridable by --force: that flag vouches for a foreign
  prefix, not for destroying existing data.

Also: reword the --mol-type rejection to point at the per-node mol_type
field (the old text claimed plans don't carry molecule semantics, which the
node field contradicts), and document the no-overwrite rule in the --graph
plan supplement.

Agent-Signature: claude-fable-5-xhigh on behalf of matt wilkie
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-23 21:33:38 -07:00
Isis Anisoptera
1285242c19 refactor(create): apply simplify-pass cleanups to the --graph plan paths
Reuse loadEmbeddedCustomStatuses in the embedded --status check; drop the
resolveProxiedCustomStatuses wrapper; delete the duplicate type pre-check
(ValidateWithCustom already enforces it); thread real GraphApplyOptions
through plan validation; fold the single-caller waits-for meta builders
into NewGraphEdgeDependency; share one flags->GraphApplyOptions
projection across transports; make joinNamesWithOr take a slice; guard
domain.applyGraph routing against mismatched node storage classes; add
an edge/node-dep field parity test for buildDomainGraphPlan.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-18 11:53:14 -07:00
Isis Anisoptera
24e349a494 fix(create): close code-review findings in --graph validation and 0056 migration
- Allow --force with --graph (it was rejected before GraphApplyOptions.Force
  could be populated on the proxied path); reject it explicitly for --file,
  which never consults it.
- Reject a negative estimate alias even when estimated_minutes also is set,
  instead of silently discarding it in the alias fold (GH#4064).
- Drop the YAML fallback from the graph-path custom-status helpers: statuses
  are store/server-only everywhere else (single-issue create, list filters),
  unlike custom types.
- Migration 0056: require both wisps and wisp_dependencies before selecting
  the full recompute variant, and self-assign updated_at in the issue
  UPDATEs so the derived-state recompute doesn't plant per-clone wall clock
  in a synced table (bd-578h9.19).
- Filter inline node deps by phase before constructing them, restoring
  main's ordering and halving the per-apply dependency construction.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-18 11:53:14 -07:00
Isis Anisoptera
190e358681 fix(create): close code-review findings in --graph and waits-for paths
Correctness:
- Guard against nil WaitsForSpec so `bd create --waits-for " "`
  (whitespace-only) no longer panics; also use the trimmed
  spec.SpawnerID as the dependency target in embedded mode so padded
  input matches the proxied path instead of targeting a bogus ID.
- Reject graph edges that combine spawner_key with to_id: an explicit
  to_id overrides to_key at apply time, so a key-named spawner could
  never match the ID-resolved target and the recorded gate spawner was
  silently ignored.
- Look up unknown-field hints case-insensitively, matching the
  case-insensitive known-field check, so typos like "Estimate" still
  get their corrective hint.
- Add repair migrations 0052 (issues) and ignored/0011 (wisps) that
  re-run the mixed is_blocked recompute with a NULL-safe gate predicate
  (COALESCE ... 'all-children'); migration 0047 and ignored/0007 left
  gate-less waits-for rows mis-marked as unblocked.

Cleanup:
- Return the resolved useWisp from validateGraphApplyStorageClasses
  instead of re-deriving it from Nodes[0] in the proxied path.
- Extract shared types.NewGraphEdgeDependency and types.MergeMetadataRefs
  so the embedded and domain apply paths cannot drift.
- Add types.ValidWispTypeNames/ValidMolTypeNames and use them in place of
  the hand-maintained valid-value strings scattered across create/list/ready.
- Carry custom statuses in CreateContext to drop the extra proxied-server
  config round trip.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-18 11:52:56 -07:00
Isis Anisoptera
a95605b2eb refactor(create): simplify --graph plumbing via shared validators and reflection
Apply /simplify findings to the --graph feature branch:

- Derive the known-field sets from the schema structs' json tags instead
  of hand-maintained map literals (and drop the now-tautological
  drift-guard test).
- Validate plan nodes through types.Issue.ValidateWithCustom on the same
  materialized issue the apply path stores, replacing hand-rolled
  priority/estimate/storage-class rules so plan-time and insert-time
  validation cannot drift. Plans now also get title-cap and metadata-JSON
  checks at validation time.
- Add createInput.graphApplyOptions() to build GraphApplyOptions once
  (the three inline copies had already drifted on Force).
- Compute wisp routing at the call site instead of returning it from
  buildDomainGraphPlan via an i==0 sniff.
- Skip custom-status config loads (a server round-trip in proxied mode)
  when no plan node sets a status, mirroring the explicit-ID gate.
- Reuse loadEmbeddedIDPrefixes from single-issue create's explicit-ID
  path, removing the second copy of the GH#2469 prefix precedence rule.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-18 11:52:37 -07:00
Chad Woolley
32dacb8fc1
feat(create): add status flag for initial issue status (#4536)
Add bd create --status/-s so new issues can start directly in a built-in or configured custom status. Explicit --status wins over defer-derived status while preserving defer_until.

Reuse the same custom-status validation shape as bd update and normalize typed custom status config during create insertion so values like review:wip validate as review.

Agent-Signature: codex-unknown-model-unknown-reasoning on behalf of thewoolleyman

Co-authored-by: thewoolleyman <chad@thewoolleyman.com>
2026-07-05 11:15:48 -07:00
coffeegoddd☕️✨
d7d7a34607 : refactor to use RunE, emit usage metrics, skip metrics in CI
(cherry picked from commit 9596c7233d)
2026-06-22 20:44:43 +00:00
coffeegoddd☕️✨
56ce24f237 /{cmd,internal}: more fixes 2026-05-27 10:07:45 -07:00
coffeegoddd☕️✨
9c8810723e /cmd/bd: cleaning up 2026-05-26 16:58:52 -07:00
coffeegoddd☕️✨
ac52b567d4 /{cmd,internal}: wip create 2026-05-26 14:27:54 -07:00