beads/internal
gascity-eddie[bot] 395e7beec0
fix(config): stop bd config set dropping the file's trailing newline (#7669)
* fix(config): keep config.yaml's trailing newline on bd config set

updateYamlKey's flat-key path, which `bd config set` takes for every
single-segment key, read the document with bufio.Scanner and joined the
lines back with "\n". ScanLines drops the final terminator, so the result
was exactly one newline short of any terminated config.yaml:
"issue_prefix: vp\ndolt.mode: server\n" came back without its final
newline, a spurious no-newline-at-end-of-file change in a git-tracked file.

Re-attach the input's own trailing run at the return, the tail
commentOutYamlKey got for the unset side in #6749. One statement covers
both the in-place and the appended branch, and a document without a
trailing newline still does not acquire one. The TODO that recorded the
defect is removed in the next commit.

The test file's header now covers both verbs; the set test follows the
unset ones.

AC: AC-1
Agent-Signature: claude-code-claude-opus-5-5-max on behalf of Julian Knutsen
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* chore(config): drop the TODO that deferred the bd config set newline fix

The TODO above updateYamlKey's return recorded that `bd config set` was
knowingly left one newline short, as a scope call in #6749. The previous
commit fixed that, so the TODO now describes a defect that no longer exists.

Check: searching internal/config/yaml_config.go for the phrase
"`bd config set` is knowingly left unfixed" finds one match at the base
and none after this commit.

AC: AC-11
Agent-Signature: claude-code-claude-opus-5-5-max on behalf of Julian Knutsen
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test(config): pin a set's blank-line trailing run, not just a final newline

A config.yaml that ends in one or two blank lines came back from
`bd config set` one newline short, so the output still ended in "\n".
Compare the exact trailing run, as the unset table does, so that loss
stays visible. Both rows fail on the base code (run "\n" vs "\n\n", and
"\n\n" vs "\n\n\n") and pass with the tail fix.

AC: AC-2
Agent-Signature: claude-code-claude-opus-5-5-max on behalf of Julian Knutsen
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test(config): pin the appended key's terminator on bd config set

When the key is absent, updateYamlKey appends it as the new last line,
and the old join left that line unterminated: "x\n" came back
"x\n\nnewkey: \"v\"". Pin the exact output for "x\n", where the separator
blank line is kept and the newline follows the new key, plus a table row
for the trailing run. Both fail on the base code and pass with the tail
fix.

AC: AC-3
Agent-Signature: claude-code-claude-opus-5-5-max on behalf of Julian Knutsen
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test(config): pin a set appended over a blank-line tail

For "x\n\n" without the key, the existing blank line already separates,
so updateYamlKey adds no second one and the document's own two-newline
run now follows the new key: "x\n\nnewkey: \"v\"\n\n". Restoring a single
newline would leave this exact shape one short again, so pin it exactly,
plus the matching table row. Both fail on the base code, which returned
"x\n\nnewkey: \"v\"", and pass with the tail fix.

AC: AC-4
Agent-Signature: claude-code-claude-opus-5-5-max on behalf of Julian Knutsen
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test(config): pin that a set does not invent a trailing newline

The repair re-attaches the document's own trailing run instead of appending
a newline, so a config.yaml that ends without one still ends without one
after `bd config set`. Pin that for both branches: a present key rewritten
in place, and an absent key appended as the new last line.

This passes on the base as well; it is a pin on "preserve, not append".
The always-append mutant (`return out + "\n", nil`) turns both inputs red.

AC: AC-5
Agent-Signature: claude-code-claude-opus-5-5-max on behalf of Julian Knutsen
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test(config): pin a set's output on a CRLF config.yaml

A set of a single-segment key has always rewritten a CRLF document to LF,
because the scan drops each line's "\r". What the old join added on top was
a missing terminator: "actor: a\r\nother: x\r\n" came back
"actor: \"b\"\nother: x". With the restored tail it comes back
"actor: \"b\"\nother: x\n", which is also how an unset of the same document
ends.

Pin the exact output, and check the trailing run against commentOutYamlKey
on the same input, in a subtest named after unset's CRLF subtest. It fails
on the base (exact and parity) and passes with the tail from AC-1.

AC: AC-6
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(config): keep a CRLF config.yaml's blank-line tail on bd config set

The restored tail measures the trailing run on the raw content, where
strings.TrimRight(content, "\n") stops at the last "\r". On a CRLF file the
re-attached run was therefore always a bare "\n", however many blank lines
followed: "actor: a\r\nother: x\r\n\r\n\r\n" came back "…x\n", one newline
shorter than even the base's "…x\n\n".

Normalize CRLF the way commentOutYamlKey does before the scan, so the run is
the LF run and a set ends the file exactly as an unset of the same document
does. The scan output is unchanged, since ScanLines already drops each
line's "\r". The line sits below the nested dispatch, not at the top: some
updateNestedYamlKey branches carry "\r" through on untouched lines, and
this fix leaves that path alone.

Also correct the comment on unset's CRLF subtest, which still blamed a
leftover "\r" for the bare-"\n" tail; commentOutYamlKey normalizes up front,
so that mechanism no longer exists and the new set cases contradict it.

AC: AC-7
Agent-Signature: claude-code-claude-opus-5-5-max on behalf of Julian Knutsen
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test(config): pin the trailing newline through SetYamlConfig

setYamlConfigAtPath writes updateYamlKey's output verbatim, so the dropped
newline reached the git-tracked config.yaml. Add the writer-level twin of
TestUnsetThroughTheFileKeepsTheTrailingNewline: a .beads/config.yaml ending
in a blank line, BEADS_DIR pointed at it, SetYamlConfig("actor", "bob"),
and the re-read file must keep its "\n\n" run. It first checks that the
value landed, so an untouched file cannot pass.

On the base the run comes back "\n"; with the tail from AC-1 it is "\n\n".

AC: AC-8
Agent-Signature: claude-code-claude-opus-5-5-max on behalf of Julian Knutsen
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test(config): pin that a set of a dotted key bypasses the CRLF normalization

The CRLF normalization in updateYamlKey sits below the nested dispatch on
purpose. replaceFlatKeyLine and appendNestedYamlKey keep "\r" on the lines
they leave alone, so hoisting the line above the dispatch would silently
change what a dotted-key set writes:
"issue_prefix: vp\r\ndolt.mode: server\r\n" comes back
"issue_prefix: vp\r\ndolt.mode: \"embedded\"\n" today and would lose the
first "\r".

Compare updateYamlKey with updateNestedYamlKey on four CRLF documents for
dolt.mode: a literal dotted key, a nested block, an absent key, and a
comment-only document. This passes on the base as well; it pins the
boundary, not the nested writer's outputs. The hoisted mutant turns the
literal-dotted-key and comment-only rows red; the other two are re-marshalled
to LF either way.

AC: AC-9
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(config): append an absent key after a blank-line tail as one line

updateYamlKey's flat path appends an absent key after the scan's empty
tokens for the file's trailing blank lines, so those blank lines already
sit ahead of the new line; the tail rule then re-attached content's whole
run after it as well. A set of a new single-segment key on a file ending
in blank lines therefore repeated them at EOF: "x\n\n" came back
"x\n\nnewkey: \"v\"\n\n", "x\n\n\n" came back
"x\n\n\nnewkey: \"v\"\n\n\n", and CRLF "x\r\n\r\n" came back
"x\n\nnewkey: \"v\"\n\n" -- the diff noise this PR exists to remove.

The appended branch now re-attaches only the one terminator
bufio.Scanner dropped, and only when content had it; the in-place branch
keeps the TrimRight + content's-run rule it shares with
commentOutYamlKey. The appended-key subtest now wants
"x\n\nnewkey: \"v\"\n", adds "x\n\n\n" and CRLF rows, and drops the
comment claiming a single terminator would leave it one newline short.
The suffix-run table drops its blank-tail append row, whose expectation
assumed the file's run follows the key, and
TestSetOfAnAbsentKeyThroughTheFileAddsOneLine pins the shape through
SetYamlConfig. The doc comment states the nested boundary and the tail
rule.

Not changed here: the unchecked scanner.Err() is #7670's fix (its guard
lands right after this scan loop, and ./internal/config/ is green on the
union of both PRs). The stale bufio.Scanner narration in
commentOutYamlKey's comment stays a follow-up, since #7613 edits that
function.

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: Eddie the Engineer <julianknutsen@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Eddie the Engineer <338826946+gascity-eddie[bot]@users.noreply.github.com>
2026-10-19 08:49:00 +00:00
..
ado ci(bazel): split //scripts:scripts_test by what it reads; partition //:repo_files (#7414) 2026-10-09 05:13:07 +00:00
atomicfile ci(bazel): split //scripts:scripts_test by what it reads; partition //:repo_files (#7414) 2026-10-09 05:13:07 +00:00
audit ci(bazel): split //scripts:scripts_test by what it reads; partition //:repo_files (#7414) 2026-10-09 05:13:07 +00:00
beads ci(bazel): split //scripts:scripts_test by what it reads; partition //:repo_files (#7414) 2026-10-09 05:13:07 +00:00
ceiling ci(bazel): split //scripts:scripts_test by what it reads; partition //:repo_files (#7414) 2026-10-09 05:13:07 +00:00
compact ci(bazel): split //scripts:scripts_test by what it reads; partition //:repo_files (#7414) 2026-10-09 05:13:07 +00:00
config fix(config): stop bd config set dropping the file's trailing newline (#7669) 2026-10-19 08:49:00 +00:00
configfile ci(bazel): split //scripts:scripts_test by what it reads; partition //:repo_files (#7414) 2026-10-09 05:13:07 +00:00
creds ci(bazel): split //scripts:scripts_test by what it reads; partition //:repo_files (#7414) 2026-10-09 05:13:07 +00:00
debug ci(bazel): split //scripts:scripts_test by what it reads; partition //:repo_files (#7414) 2026-10-09 05:13:07 +00:00
doltremote ci(bazel): split //scripts:scripts_test by what it reads; partition //:repo_files (#7414) 2026-10-09 05:13:07 +00:00
doltserver ci(bazel): split //scripts:scripts_test by what it reads; partition //:repo_files (#7414) 2026-10-09 05:13:07 +00:00
doltversion ci(bazel): split //scripts:scripts_test by what it reads; partition //:repo_files (#7414) 2026-10-09 05:13:07 +00:00
eventsjournal ci(bazel): split //scripts:scripts_test by what it reads; partition //:repo_files (#7414) 2026-10-09 05:13:07 +00:00
execenv ci(bazel): split //scripts:scripts_test by what it reads; partition //:repo_files (#7414) 2026-10-09 05:13:07 +00:00
fdhygiene ci(bazel): split //scripts:scripts_test by what it reads; partition //:repo_files (#7414) 2026-10-09 05:13:07 +00:00
formula ci(bazel): split //scripts:scripts_test by what it reads; partition //:repo_files (#7414) 2026-10-09 05:13:07 +00:00
git ci(bazel): split //scripts:scripts_test by what it reads; partition //:repo_files (#7414) 2026-10-09 05:13:07 +00:00
gitenv ci(bazel): split //scripts:scripts_test by what it reads; partition //:repo_files (#7414) 2026-10-09 05:13:07 +00:00
githooksenv ci(bazel): split //scripts:scripts_test by what it reads; partition //:repo_files (#7414) 2026-10-09 05:13:07 +00:00
github ci(bazel): split //scripts:scripts_test by what it reads; partition //:repo_files (#7414) 2026-10-09 05:13:07 +00:00
gitignore feat(backend/http): public HTTP backend door, OSS registration, and bd connect (S6) (#7288) 2026-10-10 07:19:18 +00:00
gitlab ci(bazel): split //scripts:scripts_test by what it reads; partition //:repo_files (#7414) 2026-10-09 05:13:07 +00:00
gittraceenv ci(bazel): split //scripts:scripts_test by what it reads; partition //:repo_files (#7414) 2026-10-09 05:13:07 +00:00
hooks ci(bazel): split //scripts:scripts_test by what it reads; partition //:repo_files (#7414) 2026-10-09 05:13:07 +00:00
httpapi test(serve): before-parity pins for the httpapi startup event and ordinary-workspace bd serve (P13, P14) (#7679) 2026-10-19 03:26:45 +00:00
httpclient bd versions + a config switch for versioned history — the minimum cut that makes versioned beads usable (#6138) (#6661) 2026-10-18 17:28:16 +00:00
idgen ci(bazel): split //scripts:scripts_test by what it reads; partition //:repo_files (#7414) 2026-10-09 05:13:07 +00:00
jira ci(bazel): split //scripts:scripts_test by what it reads; partition //:repo_files (#7414) 2026-10-09 05:13:07 +00:00
linear ci(bazel): split //scripts:scripts_test by what it reads; partition //:repo_files (#7414) 2026-10-09 05:13:07 +00:00
lockfile ci(bazel): split //scripts:scripts_test by what it reads; partition //:repo_files (#7414) 2026-10-09 05:13:07 +00:00
memoryapi ci(bazel): split //scripts:scripts_test by what it reads; partition //:repo_files (#7414) 2026-10-09 05:13:07 +00:00
metrics ci(bazel): split //scripts:scripts_test by what it reads; partition //:repo_files (#7414) 2026-10-09 05:13:07 +00:00
migration ci(bazel): split //scripts:scripts_test by what it reads; partition //:repo_files (#7414) 2026-10-09 05:13:07 +00:00
molecules ci(bazel): split //scripts:scripts_test by what it reads; partition //:repo_files (#7414) 2026-10-09 05:13:07 +00:00
notion ci(bazel): split //scripts:scripts_test by what it reads; partition //:repo_files (#7414) 2026-10-09 05:13:07 +00:00
procid ci(bazel): split //scripts:scripts_test by what it reads; partition //:repo_files (#7414) 2026-10-09 05:13:07 +00:00
query ci(bazel): split //scripts:scripts_test by what it reads; partition //:repo_files (#7414) 2026-10-09 05:13:07 +00:00
recipes ci(bazel): split //scripts:scripts_test by what it reads; partition //:repo_files (#7414) 2026-10-09 05:13:07 +00:00
remotecache ci(bazel): split //scripts:scripts_test by what it reads; partition //:repo_files (#7414) 2026-10-09 05:13:07 +00:00
routing ci(bazel): split //scripts:scripts_test by what it reads; partition //:repo_files (#7414) 2026-10-09 05:13:07 +00:00
storage test(storage): versioned-history flag-off differential and statement pins (#6132, #6135) (#7681) 2026-10-19 03:47:00 +00:00
telemetry feat(http): bd blocked over bd serve (blocked.list), plus bd blocked --flags [--raw] (#7649) 2026-10-17 12:29:13 +00:00
templates test(setup): pin the Claude agent artifacts bd init and bd setup claude write (#7678) 2026-10-19 05:19:28 +00:00
testutil test(cmd/bd): stop tests from mutating the host checkout's .git; guard it in TestMain (wy-qlvlmf) (#7650) 2026-10-17 12:36:48 +00:00
timeparsing ci(bazel): split //scripts:scripts_test by what it reads; partition //:repo_files (#7414) 2026-10-09 05:13:07 +00:00
tracker ci(bazel): split //scripts:scripts_test by what it reads; partition //:repo_files (#7414) 2026-10-09 05:13:07 +00:00
types feat(list): bd list's remaining filters over http behind issues.list.filters (#7647) 2026-10-17 11:21:18 +00:00
ui ci(bazel): split //scripts:scripts_test by what it reads; partition //:repo_files (#7414) 2026-10-09 05:13:07 +00:00
uimd ci(bazel): split //scripts:scripts_test by what it reads; partition //:repo_files (#7414) 2026-10-09 05:13:07 +00:00
utils fix(delete): resolve ids exactly, never by prefix abbreviation (#7375) 2026-10-16 11:25:54 +00:00
validation fix(issueops): enforce the close guards on every close leg (#7425) 2026-10-09 18:30:42 +00:00
versioncheck ci(bazel): split //scripts:scripts_test by what it reads; partition //:repo_files (#7414) 2026-10-09 05:13:07 +00:00
versionedhistory bd versions + a config switch for versioned history — the minimum cut that makes versioned beads usable (#6138) (#6661) 2026-10-18 17:28:16 +00:00
workapi feat(list): bd list's remaining filters over http behind issues.list.filters (#7647) 2026-10-17 11:21:18 +00:00
workspacegate fix(workspacegate): strict --readonly never creates workspace gate files (#7672) 2026-10-19 04:31:00 +00:00
worktreeremove ci(bazel): split //scripts:scripts_test by what it reads; partition //:repo_files (#7414) 2026-10-09 05:13:07 +00:00