Make describe.WithCallback emit bare lines, move newline to the sink (Fixes #127) - #128
Merged
Merged
Conversation
…ixes #127) WithCallback previously appended a trailing newline to every line, forcing all consumers of DescribeWithCallback to receive terminated lines. It now emits each indented line bare and lets the callback decide termination. Add describe.Printfln, a Printf-compatible stdout sink that appends the newline, and repoint every type's Describe to it so stdout output is byte-identical. The describe.md skill is updated to document the bare-line contract.
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.
Linked Issue
Closes #127Root Cause
describe.WithCallbackappended a trailing newline to every line (printf("%s%s\n", ...)). Line termination is a sink concern, but the renderer owned it, so any customPrintfsink passed throughDescribeWithCallbackwas forced to receive newline-terminated lines and could not join, buffer, or re-terminate them differently.Fix Description
WithCallbacknow emits each indented line bare —printf("%s%s", prefix, line)— leaving termination to the callback. To preserveDescribe's stdout behavior, adddescribe.Printfln, aPrintf-compatible sink that writes to stdout and appends the newline, and repoint every type'sDescribefromfmt.Printftodescribe.Printfln.The newline simply moved from the renderer to the default sink, so
Describeoutput is unchanged; callers usingDescribeWithCallbackdirectly now control termination (e.g.fmt.Fprintf(&buf, f+"\n", a...)to collect into a buffer, or omit\nto join their own way).The
describe.mdskill document is updated to describe the bare-line contract, the newPrintflnsink, and the adjusted testing checklist.How Verified
go build ./...,go vet ./...,gofmt -l— all clean.go test ./...— all packages pass.TestDescribeLayeringConsistencyconfirmsDescribe(0)output is byte-identical:strings.Join(DescribeList(), "\n") + "\n". Existing describe/SDDL/round-trip suites pass unchanged.Test Coverage
Existing:
utils/describehelper tests andsecuritydescriptordescribe-consistency/indent tests already exercise the changed path; bothWithCallback(now bare) andDescribe(now viaPrintfln) are covered, and the layering identity test guards against regressions.Scope of Change
utils/describe/describe.go(WithCallback + new Printfln), the 15 structure files (eachDescriberepointed todescribe.Printfln), anddescribe.md(skill doc; newly tracked).Describestdout output is byte-identical.Risk and Rollout
Behavioral change is limited to direct callers of
DescribeWithCallbackwith a custom sink: they now receive un-terminated lines.Describe(the common entry point) is unchanged. Safe to merge.Notes
describe.mdis a design/skill document that was created after the previous PRs and is committed here for the first time so it stays in sync with the implementation.