Skip to content

Make describe.WithCallback emit bare lines, move newline to the sink (Fixes #127) - #128

Merged
p0dalirius merged 1 commit into
mainfrom
feature-withcallback-bare-lines
Jul 21, 2026
Merged

Make describe.WithCallback emit bare lines, move newline to the sink (Fixes #127)#128
p0dalirius merged 1 commit into
mainfrom
feature-withcallback-bare-lines

Conversation

@p0dalirius

Copy link
Copy Markdown
Collaborator

Linked Issue

Closes #127

Root Cause

describe.WithCallback appended a trailing newline to every line (printf("%s%s\n", ...)). Line termination is a sink concern, but the renderer owned it, so any custom Printf sink passed through DescribeWithCallback was forced to receive newline-terminated lines and could not join, buffer, or re-terminate them differently.

Fix Description

WithCallback now emits each indented line bare — printf("%s%s", prefix, line) — leaving termination to the callback. To preserve Describe's stdout behavior, add describe.Printfln, a Printf-compatible sink that writes to stdout and appends the newline, and repoint every type's Describe from fmt.Printf to describe.Printfln.

The newline simply moved from the renderer to the default sink, so Describe output is unchanged; callers using DescribeWithCallback directly now control termination (e.g. fmt.Fprintf(&buf, f+"\n", a...) to collect into a buffer, or omit \n to join their own way).

The describe.md skill document is updated to describe the bare-line contract, the new Printfln sink, and the adjusted testing checklist.

How Verified

  • go build ./..., go vet ./..., gofmt -l — all clean.
  • go test ./... — all packages pass.
  • TestDescribeLayeringConsistency confirms Describe(0) output is byte-identical: strings.Join(DescribeList(), "\n") + "\n". Existing describe/SDDL/round-trip suites pass unchanged.

Test Coverage

Existing: utils/describe helper tests and securitydescriptor describe-consistency/indent tests already exercise the changed path; both WithCallback (now bare) and Describe (now via Printfln) are covered, and the layering identity test guards against regressions.

Scope of Change

  • Files changed: utils/describe/describe.go (WithCallback + new Printfln), the 15 structure files (each Describe repointed to describe.Printfln), and describe.md (skill doc; newly tracked).
  • Submodule pointer updated: no
  • Behavioral changes outside the fix: none. Describe stdout output is byte-identical.

Risk and Rollout

Behavioral change is limited to direct callers of DescribeWithCallback with a custom sink: they now receive un-terminated lines. Describe (the common entry point) is unchanged. Safe to merge.

Notes

describe.md is 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.

…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.
@p0dalirius
p0dalirius merged commit e50cf34 into main Jul 21, 2026
5 checks passed
@p0dalirius
p0dalirius deleted the feature-withcallback-bare-lines branch July 21, 2026 09:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant