* fix(issueops): one create priority default; HTTP absent priority is P2 The CLI defaulted `bd create` to P2, but issues:create, issues:batchCreate and batch:apply create items left Issue.Priority at 0 when `priority` was absent, so a gc/curl create stored P0 (critical) against the spec's "absent means the default". The default now lives in one place, the shared create preparation (PreparePublicCreateRequest), behind a presence flag because Issue.Priority's zero value is P0: - issueops.CreateRequest.DefaultPriority, BatchCreateItem.DefaultPriority and CreateItem.DefaultPriority ask for issueops.DefaultCreatePriority (2); setting it with a non-zero priority is ErrValidation (ValidateCreatePriority, shared with the HTTP client); - every Lifecycle.Create, BatchCreator and BatchApplier leg (dolt, embedded, uow) reaches it; CloneCreateBatchRequest now keeps scalar item members; - the three handlers set the flag for an absent member and never make up 0; the HTTP client omits `priority` for it (wirePriority) only when the server advertises the new additive issues.create.defaultPriority token, read from the cached handshake before the dial; an older server reads an absent priority as P0, so the client sends DefaultCreatePriority (2) explicitly to it (pinCreateDefaultPriority). An explicit 0 is still sent; - `bd create` without --priority, `bd create --graph` nodes without priority and `bd create --file` templates without ### Priority rely on the flag; the flag's displayed default and the dry-run previews read the library constant. CLI output is byte-identical (checked against origin/main). Spec: the three priority descriptions now say the create default is P2 on a server advertising issues.create.defaultPriority (apigen regenerated); the wireshape golden already had priority optional, so no wire-shape change. Conformance: RunLifecycleCreateAppliesTheDefaultPriority, RunBatchCreatorAppliesTheDefaultPriority and RunBatchApplyAppliesTheDefaultPriority on dolt, embedded, uow and http, plus handler and client encoding tests, and TestCreateSendsTheDefaultPriorityToAServerThatPredatesIt (new client, handshake without the token: all three create roles send 2). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(issueops): apply review fixups for the default create priority (bd-kb61wg) Apply the minor and nit findings from the review of #7426: - CHANGELOG: tell out-of-tree storage backends they must honor DefaultPriority (store issueops.DefaultCreatePriority, refuse it with a non-zero priority as ErrValidation) and which conformance cases check it; scope "CLI output is unchanged" to the in-tree backends. - bd create --file: pin the default-priority path. The e2e test asserts the printed priorities, and a buildMarkdownBatchRequest unit test pins the flag and priority for an absent, a 0 and a 1 `### Priority`. Deleting `DefaultPriority: !template.PrioritySet` now fails both. - bd create --file: warn on stderr about a `### Priority` that does not parse, as the `### Type` case already does, instead of dropping it silently. - httpclient: document pinCreateDefaultPriority's same-build assumption (the handshake is cached per Store, so a stale one is silent here), and test its no-context and failed-handshake branches on all three roles. - Formula steps, `bd q` and `bd todo add` spell issueops.DefaultCreatePriority instead of the literal 2. - Conformance: the batch-creator and batch-apply default-priority cases also pin DefaultPriority with a non-zero priority as ErrValidation with nothing written. Agent-Signature: claude-code-claude-opus-5-5-max on behalf of Julian Knutsen Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(issueops): mark the out-of-tree DefaultPriority change BREAKING (bd-0tcn1o) Apply the minor findings from the relaunch review of #7426: - CHANGELOG: move the obligation on out-of-tree storage backends out of the `### Fixed` entry into its own `### Changed` entry, led by "BREAKING (out-of-tree storage backends)" as the close-guard change and the earlier out-of-tree contract changes are; RELEASING.md asks breaking changes to carry their migration. The entry says what such a backend used to receive from `bd create`, `--graph` and `--file` (priority 2), what it receives now (priority 0 with DefaultPriority set), the migration, and the conformance cases that check it. The `### Fixed` entry keeps the HTTP P2 fix, points at the new entry, and names the stale-handshake residual that only a code comment named: a create that lands on an older build behind the same URL still stores P0. - bd cook: the proto root, the gate issue and the cooked formula root spell issueops.DefaultCreatePriority instead of the literal 2, as the formula steps in the same file already do. No behavior change. Not taken: - The literal 2s in create_form.go, gate.go and linear.go, and the "default 2" in todo.go's --priority help: explicit P2s outside the migrated paths (the help string also feeds the generated CLI reference). Left for a follow-up sweep. - Reusing in.priorityDefault in the direct bd create route: that route builds no createInput (gatherCreateInput runs only on the proxied and --file routes, and each returns), so there is nothing to reuse. - A member-level range check in the single-create HTTP decode, as the batch shapes have: the asymmetry predates this PR, and the role still refuses an out-of-range priority on all three shapes. Agent-Signature: claude-code-claude-opus-5-5-max on behalf of Julian Knutsen Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
138 lines
4.8 KiB
Go
138 lines
4.8 KiB
Go
package main
|
|
|
|
// End-to-end cover for `bd create --file` on the DIRECT route, which is where
|
|
// this command's behaviour changed when it moved onto issueops.BatchCreator.
|
|
// They run the real bd binary against an isolated embedded-Dolt workspace and
|
|
// reuse create_deps_atomic_test.go's hermetic environment and output helpers.
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
// writeMarkdownPlan writes a plan file and returns its path.
|
|
func writeMarkdownPlan(t *testing.T, dir, name, body string) string {
|
|
t.Helper()
|
|
path := filepath.Join(dir, name)
|
|
if err := os.WriteFile(path, []byte(body), 0o600); err != nil {
|
|
t.Fatalf("write markdown plan: %v", err)
|
|
}
|
|
return path
|
|
}
|
|
|
|
func TestCreateFromMarkdownFile(t *testing.T) {
|
|
bd := buildBDForInitTests(t)
|
|
dir := t.TempDir()
|
|
runCreateDepsBD(t, bd, dir, "init", "--backend", "dolt", "--prefix", "test",
|
|
"--quiet", "--non-interactive", "--skip-hooks", "--skip-agents")
|
|
|
|
t.Run("creates_every_template_in_the_file", func(t *testing.T) {
|
|
plan := writeMarkdownPlan(t, dir, "plan.md", `## First from file
|
|
|
|
Opening body.
|
|
|
|
### Priority
|
|
1
|
|
|
|
### Type
|
|
bug
|
|
|
|
### Labels
|
|
api, batch
|
|
|
|
## Second from file
|
|
|
|
### Description
|
|
Second body.
|
|
`)
|
|
out := runCreateDepsBD(t, bd, dir, "create", "--file", plan)
|
|
if !strings.Contains(out, "Created 2 issues from") {
|
|
t.Errorf("create --file output = %q, want the two-issue summary", out)
|
|
}
|
|
// The second template names no priority, so it asks the role for the
|
|
// default rather than spelling 2; a role that missed the ask stores P0.
|
|
for _, want := range []string{"First from file [P1, bug]", "Second from file [P2, task]"} {
|
|
if !strings.Contains(out, want) {
|
|
t.Errorf("create --file output = %q, want %q", out, want)
|
|
}
|
|
}
|
|
titles := createDepsIssueTitles(t, bd, dir)
|
|
for _, title := range []string{"First from file", "Second from file"} {
|
|
if !titles[title] {
|
|
t.Errorf("issue %q was not created", title)
|
|
}
|
|
}
|
|
})
|
|
|
|
// The direct route used to hand the whole slice to the store's batch create
|
|
// with no create-only guard and no per-item content validation. A file the
|
|
// workspace refuses now refuses WHOLE, so a caller can fix the file and
|
|
// re-run it without working out which half landed.
|
|
t.Run("a_refused_template_leaves_nothing_behind", func(t *testing.T) {
|
|
plan := writeMarkdownPlan(t, dir, "half-bad.md", `## Lands before the refusal
|
|
|
|
### Description
|
|
Fine.
|
|
|
|
## Names a dependency that does not exist
|
|
|
|
### Dependencies
|
|
test-nosuchissue
|
|
`)
|
|
out, err := runCreateDepsBDRaw(bd, dir, "create", "--file", plan)
|
|
if err == nil {
|
|
t.Fatalf("create --file with an unresolvable dependency exited 0; output:\n%s", out)
|
|
}
|
|
titles := createDepsIssueTitles(t, bd, dir)
|
|
if titles["Lands before the refusal"] {
|
|
t.Error(`issue "Lands before the refusal" persisted despite the file being refused: ` +
|
|
"a --file create is all or nothing")
|
|
}
|
|
if titles["Names a dependency that does not exist"] {
|
|
t.Error("the refusing template itself persisted")
|
|
}
|
|
})
|
|
|
|
// --ephemeral is not in singleIssueOnlyFlags, so this route has always
|
|
// ACCEPTED it while building the issues without reading it: a caller who
|
|
// asked for scratch work got durable rows and no warning.
|
|
t.Run("ephemeral_is_honoured_rather_than_accepted_and_ignored", func(t *testing.T) {
|
|
plan := writeMarkdownPlan(t, dir, "scratch.md", `## Scratch from file
|
|
|
|
### Description
|
|
Ephemeral body.
|
|
`)
|
|
out := runCreateDepsBD(t, bd, dir, "create", "--file", plan, "--ephemeral", "--json")
|
|
if !strings.Contains(out, `"ephemeral": true`) && !strings.Contains(out, `"ephemeral":true`) {
|
|
t.Errorf("create --file --ephemeral --json does not report an ephemeral row:\n%s", out)
|
|
}
|
|
// And the durable listing does not carry it, which is the half a
|
|
// caller asking for scratch work actually depends on.
|
|
if createDepsIssueTitles(t, bd, dir)["Scratch from file"] {
|
|
t.Error(`"Scratch from file" is in the durable listing; --file --ephemeral must create a wisp`)
|
|
}
|
|
})
|
|
|
|
// The edges the file declares are written with the issues, in the same
|
|
// transaction — including an edge onto an issue created EARLIER in the file.
|
|
t.Run("writes_the_edges_the_file_declares", func(t *testing.T) {
|
|
blocker := strings.TrimSpace(runCreateDepsBD(t, bd, dir, "create", "file edge blocker", "--silent"))
|
|
if blocker == "" {
|
|
t.Fatal("blocker create returned empty ID")
|
|
}
|
|
plan := writeMarkdownPlan(t, dir, "edges.md", `## Blocked by an existing issue
|
|
|
|
### Dependencies
|
|
`+blocker+`
|
|
`)
|
|
runCreateDepsBD(t, bd, dir, "create", "--file", plan)
|
|
// --direction=up is what the blocker BLOCKS, which is where the edge
|
|
// the file declared shows up.
|
|
out := runCreateDepsBD(t, bd, dir, "dep", "tree", blocker, "--direction=up", "--json")
|
|
if !strings.Contains(out, "Blocked by an existing issue") {
|
|
t.Errorf("the declared edge was not written; dependents of %s:\n%s", blocker, out)
|
|
}
|
|
})
|
|
}
|