Skip to content

pkg/subenum: export Permutations and Diff helpers #197

Closed

Description

@TMHSDigital

Summary

Permutation generation and diffing are CLI-only; the library exposes just Run and Scan. Both are pure functions with no DNS and would be cheap to export.

Where

  • internal/permute/permute.go:28 (Generate is internal)
  • main_diff.go (diff logic lives in the main package)
  • pkg/subenum/subenum.go:347, 402 (only Run/Scan exported)
  • docs/library.md

Proposal

Export subenum.Permutations(seeds, words []string) []string and subenum.Diff(prev, cur []Result) Changes (added, removed, and later changed). Document both in docs/library.md.

Who benefits

Embedders building their own pipelines or monitors.

Open questions

  • API surface before 1.0 (ROADMAP says it may change); keep signatures minimal

Acceptance criteria

  • Both helpers exported with godoc and examples
  • CLI uses the same functions (no duplicate logic)

Getting started

  • Relevant files: pkg/subenum/subenum.go, internal/permute/permute.go, main_diff.go
  • How to run tests: go test ./pkg/... .
  • Related docs: docs/library.md

Filed by repo-audit/full-audit at 3139c44. Severity: low. Effort: S. audit-key: enhancement|pkg/subenum/subenum.go|library-permute-diff

Activity

  1. added
    enhancement
    good first issue
    severity: low
    on Nov 9, 2026
  2. TMHSDigital commented on Nov 10, 2026

    @TMHSDigital
    OwnerAuthor

    Partly done in ee04020: subenum.Permutations(seeds, words []string) []string now wraps internal/permute.Generate (the same generator -permute uses; nil words selects the built-in list), with tests, ExamplePermutations, a section in docs/library.md and a CHANGELOG entry. Verified with go test -race ./pkg/....

    Still open: Diff. Its logic lives in package main (main_diff.go), so exporting it without duplication means moving it to an internal package first, and three choices need settling: whether removed is a plain set difference (the CLI only reports a name removed after a fresh NXDOMAIN on a complete run, and skips excluded names), whether changed compares every record type or takes a types argument (the CLI compares only the looked-up types, CNAME targets first), and the shape of the returned Changes.

  3. TMHSDigital commented on Nov 13, 2026

    @TMHSDigital
    OwnerAuthor

    Diff done in 0998773, which closes this out along with the earlier Permutations work.

    The open questions are settled as follows:

    • API: subenum.Diff(previous, current []Result, types []string) Changes, where Changes holds Added, Removed and Changed, and each Change has Name, Previous and Current.
    • Removed: a plain set difference. Diff stays pure (no DNS), and the godoc says to re-check removed names, since the CLI reports a name removed only after a fresh NXDOMAIN on a complete run.
    • Changed: the same rule as -diff-records: sets over types (every type when nil), and only CNAME targets when an alias is involved. A previous result without records is never reported as changed.
    • No duplicate logic: the comparison moved from package main into internal/diff, which both the CLI and the library call.

    Verified with TestDiff*, ExampleDiff, internal/diff tests, the full go test ./... and golangci-lint.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementgood first issueseverity: low

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions