fix: address code-review findings from #13 (hardening + dead-code removal)#25
Merged
Conversation
…oval) Correctness / data-loss (must-fix): - join: bound !include resolution depth (maxIncludeDepth) so a corrupt or hostile split tree fails as a clean InputError instead of exhausting the goroutine stack (M1). Adds a deep-nesting regression test. - yamltree: make SaveFile and SaveRaw atomic (temp file in the same dir + os.Rename), so a crash/interrupt/disk-full mid-write can no longer truncate an existing document or leave a partial split tree (M3). - join: stop swallowing filepath.Abs failure; surface it rather than keying the cycle guard by an ambiguous relative path (M2). Dead-code removal (H1): - Drop the unused `opts *globalOptions` parameter from newSplitCmd/newJoinCmd/ newVerifyCmd, and remove the built-but-unused internal/progress package and its cli wrapper (and the now-unused progressbar dependency). Robustness / tests: - cli: logLevelRank now reports unknown levels instead of silently defaulting to "error"; EffectiveLogLevel falls back to the default level explicitly (L2). - cli: report the directory the user passed when a split root.yml is missing, not a synthesized path they never typed (L1). - cli: share one package-level discard logger instead of allocating per miss (n3). - split: add a regression test pinning canReconstruct's no-wrap precondition (fails if yamltree.Save ever sets an encoder width); comment the per-dir namer (n2). - split: assert the in-file anchor/alias round-trips through join, not just that split accepts it (g1). Refs #13. go build/vet/test/-race and golangci-lint all clean. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Addresses the still-valid findings from #13 (see the re-review update). Scope agreed: must-fix correctness items + safe robustness/tests + removing the H1 dead plumbing.
Correctness / data-loss
join.resolvenow caps!includenesting atmaxIncludeDepth(100), surfaced as a cleanInputError, so a corrupt/hostile split tree fails cleanly instead of a fatal goroutine-stack overflow. New deep-nesting regression test.yamltree.SaveFile/SaveRawnow write a temp file in the same dir andos.Renameinto place. Protects bothjoin --out(overwrite) and split's multi-file output tree from truncation/partial state on crash/interrupt/disk-full.filepath.Abserror. No longer keys the cycle guard by an ambiguous relative path; the (rare)Absfailure is surfaced.H1 — remove dead plumbing
opts *globalOptionsparameter fromnewSplitCmd/newJoinCmd/newVerifyCmd.internal/progresspackage + its CLI wrapper, and the now-orphanedschollz/progressbardependency (go mod tidy).Robustness / tests
logLevelRankreports unknown levels ((int, bool)) instead of silently defaulting toerror;EffectiveLogLevelfalls back to the default level explicitly (with new rank constants).root.ymlnow reports the directory the user passed, not a synthesized<dir>/root.yml.slug.NewNamer().*basepreserved), not just that split accepts it.canReconstruct's no-wrap precondition: a long single-line scalar nested deep must round-trip unwrapped. Fails if anyone addsSetWidthtoyamltree.Save.Deferred
--output json+ progress for subcommands) — not implemented; the plumbing was removed rather than wired, per the agreed scope. Worth a separate feature issue if-o jsonoutput is wanted.PersistentPreRunE) and cosmetic usage-string drift — left for a follow-up.Validation
go build ./...,go vet ./...,go test -race ./..., andgolangci-lint run ./...all clean.Refs #13.
🤖 Generated with Claude Code