Skip to content

feat: add NextLabel and Question.Labels - #11

Merged
linkdata merged 3 commits into
mainfrom
question-labels
Aug 29, 2026
Merged

feat: add NextLabel and Question.Labels#11
linkdata merged 3 commits into
mainfrom
question-labels

Conversation

@linkdata

@linkdata linkdata commented Aug 29, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • NextLabel(name string, offset int) (next int, end bool): a drop-in for dns.NextLabel on names this package produces — EDM's setQuestionLabels loop keeps its shape and drops the import. dnswire controls the escaping (dots inside labels are always \.), so a forward scan that skips escape sequences replaces miekg's backslash-parity backtracking. Offset must be a label start.
  • Question.Labels: range-over-func iterator built on NextLabel, yielding labels in presentation form without dots; the root yields nothing.

Supersedes #10, which GitHub closed when its stacked base branch was merged and deleted.

Verification

  • Unit tests: TestNextLabel walks empty, root, plain, escaped-dot, escaped-backslash and \DDD names step by step; TestQuestionLabels covers the iterator including early break. Coverage stays 100% under -race.

  • Differential harness: every decoded name is split with dns.NextLabel, and at each label start dnswire.NextLabel must return the same (next, end) — 200k deterministic messages agree.

  • BenchmarkLabels (ns/op, zero allocs everywhere):

    name dnswire.NextLabel loop dns.NextLabel loop Question.Labels
    www.example.com. 7.27 8.71 9.51
    a\.b.\000\255x.example. 9.12 11.00 10.82

Summary by CodeRabbit

  • New Features
    • Added label iteration for DNS question names in presentation format.
    • Added a helper for advancing through labels while correctly handling escaped dots and trailing dots.
  • Documentation
    • Expanded the README with guidance on label iteration and compatibility with the miekg/dns equivalent.
  • Tests
    • Added coverage for root, escaped, ordinary, and partially iterated names.
    • Added differential validation and benchmarks across label-processing implementations.

@coderabbitai

coderabbitai Bot commented Aug 29, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: d0bb89fb-b5aa-46ef-b297-20c6d349fb40

📥 Commits

Reviewing files that changed from the base of the PR and between 2157559 and bcb11f2.

📒 Files selected for processing (5)
  • README.md
  • benchmarks/benchmark_test.go
  • benchmarks/differential_test.go
  • dnswire.go
  • dnswire_test.go

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The PR adds Question.Labels and NextLabel for presentation-form DNS label parsing. It documents the APIs, adds unit tests, compares results with miekg/dns, and benchmarks three label-splitting implementations.

Changes

Domain label iteration

Layer / File(s) Summary
Label iteration API
dnswire.go, dnswire_test.go, README.md
Question.Labels yields labels without allocation and supports early termination. NextLabel handles escaped content, offsets, and terminal labels. Tests cover root, ordinary, escaped, and octal-escaped names. The README documents both APIs.
Cross-implementation validation
benchmarks/differential_test.go, benchmarks/benchmark_test.go
Differential checks compare label sequences and offsets with miekg/dns. BenchmarkLabels compares Question.Labels, dnswire.NextLabel, and miekg/dns NextLabel for typical and escaped names.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: ⚪ Minimal · up to bcb11

This change adds label iteration and boundary helpers for decoded DNS names, with coverage for escaped, root, and ordinary names. No actionable merge-blocking risk remains after normal checks and review.

Poem

A rabbit hops through labels bright
Escaped dots stay in sight
NextLabel marks where names end
Tests compare each parsing friend
Benchmarks race through root and hare
Clean DNS paths now fill the air

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely identifies the two main additions: NextLabel and Question.Labels.
Docstring Coverage ✅ Passed Docstring coverage is 88.89% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 9 functions across 4 files. (1 skipped: 1 u…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 88.89% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 9 functions across 4 files. (1 skipped: 1 unsupported.)

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Labels yields a name's presentation-form labels without allocating,
splitting exactly as miekg/dns NextLabel does, so callers that only
need labels can drop that dependency. The differential harness checks
every decoded name against NextLabel; a benchmark compares the two.
NextLabel is a drop-in for miekg/dns NextLabel on names this package
produces, so callers keep their existing loops and drop the import.
On the escaping dnswire emits a forward scan that skips escape
sequences replaces the backslash-parity backtracking, measuring 17%
faster than miekg/dns on typical and escape-heavy names. The
differential harness checks every step of every decoded name against
miekg/dns.
@linkdata

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 29, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@linkdata
linkdata merged commit b58bcb7 into main Aug 29, 2026
3 checks passed
@linkdata
linkdata deleted the question-labels branch August 29, 2026 15:20
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