Skip to content

refactor: merge duplicate helpers in blobs, store and vault - #235

Merged
bketelsen merged 2 commits into
mainfrom
groom/merge-duplicate-helpers
Nov 14, 2026
Merged

bketelsen merged 2 commits into
mainfrom
groom/merge-duplicate-helpers

Conversation

@frostyard-machines

Copy link
Copy Markdown
Contributor

Summary

Merges 3 duplicates that the grooming pass of issue #213 lists. No change in behavior.

  • internal/blobs/blobs.go: Put and PutWant had the same steps: temp file, hash, check of the context, chmod, sync, close and publish. Now both call 1 unexported put(ctx, r, want). Only PutWant sets want; content that hashes to another ID returns ErrCorrupt. The order of the steps stays the same: PutWant checks the hash before it checks the context. The error texts stay the same. PutWant still refuses a malformed ID before it reads.
  • internal/store/queries.go, internal/store/search.go: ListNotes (noteConditions) and SearchNotes (searchNotesSQL) each wrote out the same nested-tag EXISTS clause and its 3 arguments. Now they share the constant hasTag and the function hasTagArgs. Only the whitespace inside the SQL text changes.
  • internal/vault/backlinks.go: valid was the same function as showText in write.go (strings.ToValidUTF8(..., "\uFFFD")). backlinkContext now calls showText, and valid is removed.

Risk tier

Risk tier: 1 — a refactor with no change in behavior. No changed file is in .github/risk-paths.json.

Verification

  • Characterization tests, in a separate first commit (5df9749): internal/blobs/putwant_failures_test.go. They pin PutWant's failures (a failing reader, wrong content and its error text, a cancelled context, and wrong content with a cancelled context) and that it leaves no file behind. They also pin that a malformed ID makes no directory, and that Put and PutWant store the same bytes with mode 0600. They pass on the base code.
  • make check (host, umask 022) on the base bac5e97 with the characterization tests: exit 0, 57 packages ok.
  • make check on the head: exit 0, 57 packages ok. No existing test changed.
  • The tag clause is covered by TestListNotes-style cases in internal/store/queries_test.go ("tag and nested tags, ignoring case", "tag with #") and by internal/store/filters_test.go (tag: filters, nested tags).
  • make vault-it and make sync-sim: see the comment below.
  • Revert test: exempt. This is a refactor; the evidence is the same tests green before and after.

Left out on purpose

blobs.Put and PutWant share one write path; the nested-tag condition of
ListNotes and SearchNotes is one constant; backlinks use showText, the
same function as valid. No change in behavior.
@github-actions github-actions Bot added the level:L3 Skim label Nov 14, 2026
@frostyard-machines

Copy link
Copy Markdown
Contributor Author

Review and integration record for head 4bf4770bddc17d9620b5d85c5cdc7be67666a955 (base bac5e976271515126740f6b736eda6ce989ca8d6).

Cross-review: reviewer openai/gpt-6.1-sol, coder anthropic/claude-opus-5-5. It covered all 5 changed files. Verdict: Ready, Blocking: none, no findings. It answered the question "Does any line of this diff change observable behavior?" with "none found". It checked the error texts and errors.Is matching, the order of the checks in PutWant (ID, then hash, then context), the file modes and the clean-up of the temporary file, and the SQL placeholders and arguments. It also checked that valid and showText are the same.

Integration runs (host, umask 022, at the head):

  • make vault-it: exit 0 (TestIKillNotesd/scan, /hub and /apply pass; internal/vault ok in 281.8 s).
  • make sync-sim: seeds 1 and 2 (stepwise, 10,000 steps each) passed. I stopped the run during seed 3 (each seed takes about 18 min). This PR changes no sync code. The blob write path that sync uses has its own tests in internal/blobs.

CI: all checks are green at the head.

@frostyard-machines frostyard-machines added the ready-for-human Reviewed, CI green: ready for Brian to review and merge label Nov 14, 2026
@bketelsen
bketelsen merged commit 0f80287 into main Nov 14, 2026
11 checks passed
@bketelsen
bketelsen deleted the groom/merge-duplicate-helpers branch November 14, 2026 00:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

level:L3 Skim ready-for-human Reviewed, CI green: ready for Brian to review and merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants