Skip to content

zig-dnssec milestone 1: wire codec, DNSSEC validator, DoH stub - #4

Closed
hyperpolymath wants to merge 21 commits into
mainfrom
feat/dnssec-library
Closed

hyperpolymath wants to merge 21 commits into
mainfrom
feat/dnssec-library

Conversation

@hyperpolymath

@hyperpolymath hyperpolymath commented Oct 27, 2026 •

Copy link
Copy Markdown
Owner

Summary

Stacked on #3 (init/repo-init, the mint). Review only the commits after 2722846. Once that PR merges, this branch will be restacked onto main and retargeted. Experimental and not independently reviewed.

This PR is a pure-Zig DNS library: a wire codec, a DNSSEC validator and a DoH stub client.

Changes

  • Wire codec: RFC 1035, with strict bounds checking and name compression.
  • DNSSEC validation: RFC 4033–4035 and RFC 5155 (NSEC and NSEC3).
  • Signature algorithms: 5, 7, 8, 10, 13, 14 and 15. All signature checks use Zig's standard library; no cryptographic primitive is written here.
  • Verdicts: every answer gets one of secure | insecure | bogus | indeterminate. Failures are never downgraded to insecure.
  • DoH stub client and the dnssec-stub CLI. The deed's RSR profile gains the cli capability with it.
  • Deed housekeeping: the library's added and edited paths are declared in the variant contract (6d6a2b1), so check-variant-drift.sh passes.

Evidence (each claim is tagged in docs/reports/VERIFICATION.adoc):

  • 89 tests: RFC vectors, RFC appendix zones, 263 recorded responses replayed offline, and 16 mutation attacks. Expired signatures, wrong keys, missing chain links and tampered records all fail.
  • Cross-check against Unbound and ldns on 22 zones. Every disagreement is explained in tests/crosscheck/REPORT.adoc.
  • Fuzzing, coverage-guided and standalone, with results in docs/reports/FUZZ-RESULTS.adoc. Fuzzing found and fixed an integer overflow in name decoding. The cross-check found and fixed a DNAME bug.
  • Live validation against the real root. This was run by hand, not automated.

Security fix in this PR (commit fix(validator): never infer insecurity from an unverified RRSIG signer): a pre-merge audit found a hole in negative responses. When the authenticated NSEC/NSEC3 records were absent, one path read the Signer's Name off an unverified SOA RRSIG and treated that name's zone as authoritative for the insecurity decision. It made no signature check and no ancestry check. A forged response could name an unrelated insecure zone as signer. A secure name's tampered or signature-stripped answer would then come back as insecure (usable) instead of bogus. That breaks the invariant that a failure is never reported as insecure. Fixed, with three regression tests, and re-verified with the differential validator fuzzer (49,729 runs, 0 findings).

Known gaps:

  • Ed448, GOST and SM2 are unsupported (no vetted pure-Zig implementation).
  • No DNS-over-QUIC: Zig's standard library has no QUIC.
  • DoH is HTTP/1.1 only.
  • No RFC 5011 trust-anchor rollover.

All gaps and trust-anchor assumptions are listed in docs/architecture/THREAT-MODEL.adoc.

Found outside this code:

  • Zig 0.17.0's std.http.Client sends HTTPS requests in cleartext through a CONNECT proxy, so the DoH transport uses std.crypto.tls.Client directly.
  • RFC 8080 §6's example signatures carry a Labels value that a validator must reject.

Recommendation: have the code independently reviewed before anything relies on it.

RSR Quality Checklist

Required

  • Tests pass (zig build test 89/89; just test passes)
  • Code is formatted (zig fmt --check over build.zig src/root.zig src/wire src/dnssec src/stub src/cli src/interface/ffi tests)
  • No banned language patterns
  • No secrets, credentials, or .env files included

As Applicable

  • docs/status/ROADMAP.adoc updated
  • Documentation updated for user-facing changes
  • Repo deed updated (cli capability; variant paths)

Testing

Run locally on this tip (6d6a2b1) with Zig 0.17.0:

  • zig fmt --check …: clean
  • zig build test --summary all: 13/13 steps, 89/89 tests
  • just validate, validate-coapt, validate-claude-md, validate-repo-map, validate-state: pass
  • ./scripts/check-lock-sync.sh, bun scripts/check-action-pinning.js, bash scripts/check-adoc-renders.sh .: pass
  • estate-rules.yml replay: pass
  • just test && just quality (Idris2 0.7.0 built from 27780073): pass
  • scripts/check-variant-drift.sh against the parent pin: pass
  • standards check-rsr-profile.sh: only the two upstream rows noted on chore: mint zig-dnssec from rsr-template-repo #3

🤖 Generated with Claude Code

https://claude.ai/code/session_01J4QvDjJMgMQkerYkRoTr2V

Ran `just repo-init` (just 1.57) with: project/slug zig-dnssec, owner
hyperpolymath, type library. Then:
- deed: purpose, IS-NOT, kind (library), domain (dns-security),
  pipeline position, unique strength; clade pt (secondary sc) as chosen
  by the owner. gv-clade-index registration is left to the owner.
- deed (manifest): :purpose still described the template; it now states
  this repository's purpose, as the (ecosystem) clause does.
- CLAUDE.md regenerated from the deed (`just claude-md`).
- Removed .machine_readable/ai/PLACEHOLDERS.adoc as the mint asks.
- docs/governance/TEMPLATE-STANDARDS-AUDIT.adoc: restored the table cell
  repo-init deleted with the OpenSSF placeholder (the table no longer
  rendered).
- Restored 24 references to the template's own issues (#53, #119, #209)
  that the name substitution had turned into zig-dnssec issue numbers,
  in 21 files; one was inside a commit message that
  scripts/sweep-wellknown.sh writes.
- Regenerated docs/architecture/REPOSITORY-MAP.adoc (`just repo-map`;
  CI diffs it) and the coaptation receipt (`just coapt`), both stale
  after the mint.

Checked: `just validate`, validate-coapt, validate-claude-md,
validate-repo-map, validate-state, and a local replay of every step of
the estate-rules workflow.

Upstream template issues met (rsr-template-repo), worked around here:
- RSR_NON_INTERACTIVE=1 replaces `read` with a function that always
  succeeds, so every `while read` loop in the recipe never ends (the
  template's onboarding docs warn of this; answers were piped instead).
- In that mode, unset optional values (OPENSSF_BP_ID, ...) abort under
  `set -u`.
- Deleting placeholder lines with sed can remove a table cell.
- Global substitution of the template name also rewrites references to
  the template's issues (rsr-template-repo#209 -> zig-dnssec#209).
- repo-init leaves REPOSITORY-MAP.adoc and the coaptation receipt stale.
- The self-name pass leaves the template's purpose in the deed's
  (manifest) clause.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01F6k6Z173AKT78qpe65xR7n
@coderabbitai

coderabbitai Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Too many files!

This PR contains 227 files, which is 127 over the limit of 100.

To get a review, reduce the PR to 100 files or fewer by splitting it into smaller PRs or changing its base branch.

Upgrade to a paid plan to raise the limit.

This review couldn't start because sufficient usage credits or metered capacity aren't available. Add credits or update usage-based reviews in the billing tab, then retry.

Run configuration
Commits

Reviewing files that changed from the base of the PR and between 6cf121a and 4025364.

Files ignored due to path filters: 4
  • .github/workflows/actions.lock is excluded by !**/*.lock
  • archetypes/julia-library/actions.lock is excluded by !**/*.lock
  • mise.lock is excluded by !**/*.lock
  • tests/fuzz/corpus/decode-mutated-0001.bin is excluded by !**/*.bin
Files selected for processing: 227
  • .clinerules
  • .cursorrules
  • .devcontainer/Containerfile
  • .devcontainer/README.adoc
  • .devcontainer/devcontainer.json
  • .devcontainer/docker/devcontainer.json
  • .editorconfig
  • .envrc
  • .gitattributes
  • .github/CODEOWNERS
  • .github/CODE_OF_CONDUCT.md
  • .github/CONTRIBUTING.md
  • .github/GOVERNANCE.md
  • .github/ISSUE_TEMPLATE/config.yml
  • .github/SECURITY.md
  • .github/SUPPORT.md
  • .github/copilot-instructions.md
  • .github/dependabot.yml
  • .github/hooks/validate-deed.sh
  • .github/settings.yml
  • .github/workflows/deed-validate.yml
  • .github/workflows/dogfood-gate.yml
  • .github/workflows/rust-ci.yml
  • .github/workflows/sonarqube.yml
  • .github/workflows/zig-ci.yml
  • .gitignore
  • .machine_readable/ai/PLACEHOLDERS.adoc
  • .machine_readable/coaptation/coapt.ncl
  • .machine_readable/coaptation/coapt.sh
  • .machine_readable/coaptation/receipts/latest.toml
  • .machine_readable/coaptation/witness-map.ncl
  • .machine_readable/compliance/reuse/dep5
  • .machine_readable/configs/eclexiaiser.toml
  • .machine_readable/configs/git-cliff/cliff.toml
  • .machine_readable/configs/stapeln.toml
  • .machine_readable/contractiles/Justfile
  • .machine_readable/contractiles/README.adoc
  • .machine_readable/contractiles/adjust/adjust.k9.ncl
  • .machine_readable/contractiles/bust/bust.k9.ncl
  • .machine_readable/contractiles/dust/dust.k9.ncl
  • .machine_readable/contractiles/intend/intend.k9.ncl
  • .machine_readable/contractiles/must/must.k9.ncl
  • .machine_readable/contractiles/trust/trust.k9.ncl
  • .machine_readable/descriptiles/anchors/README.adoc
  • .machine_readable/descriptiles/provisioning_praxis.deed
  • .machine_readable/root-allow.txt
  • .machine_readable/scripts/maintenance/maint-assault.sh
  • .machine_readable/self-validating/README.adoc
  • .machine_readable/self-validating/examples/ci-config.k9.ncl
  • .machine_readable/self-validating/examples/project-metadata.k9.ncl
  • .machine_readable/self-validating/examples/setup-repo.k9.ncl
  • .machine_readable/self-validating/methodology-guard.k9.ncl
  • .machine_readable/self-validating/template-hunt.k9.ncl
  • .machine_readable/self-validating/template-kennel.k9.ncl
  • .machine_readable/self-validating/template-yard.k9.ncl
  • .windsurfrules
  • CHANGELOG.adoc
  • CITATION.cff
  • CLAUDE.md
  • CONTRIBUTING.adoc
  • Justfile
  • README.adoc
  • archetypes/README.adoc
  • archetypes/julia-library/julia-library_praxis.deed
  • archetypes/julia-library/overlay/.github/workflows/julia-ci.yml.in
  • archetypes/julia-library/overlay/.github/workflows/julia-docs.yml.in
  • archetypes/julia-library/overlay/Project.toml.in
  • archetypes/julia-library/overlay/src/PACKAGE.jl.in
  • archetypes/julia-library/overlay/test/cases/smoke.jl
  • archetypes/julia-library/overlay/test/runtests.jl
  • build.zig
  • build.zig.zon
  • build/container/Containerfile
  • build/container/README.adoc
  • build/container/compose.yaml
  • build/container/entrypoint.sh
  • build/container/stapeln/.gatekeeper.yaml
  • build/container/stapeln/compose.toml
  • build/container/stapeln/ct-build.sh
  • build/container/stapeln/deploy.k9.ncl
  • build/container/stapeln/manifest.toml
  • build/container/stapeln/rokur.toml
  • build/container/stapeln/vordr.toml
  • build/docs-seed/README.adoc
  • build/guix.scm
  • build/just/container.just
  • build/just/groove.just
  • build/just/provision-lib.sh
  • build/just/repo-init.just
  • build/manifest.scm
  • build/templates/ROADMAP.adoc.in
  • build/templates/identity.deed.in
  • docs/AFFIRMATION.adoc
  • docs/AI_INSTALLATION_GUIDE.adoc
  • docs/MAINTAINERS.adoc
  • docs/QUICKSTART.adoc
  • docs/RSR-PHILOSOPHY.adoc
  • docs/SETUP.adoc
  • docs/architecture.adoc
  • docs/architecture/REPOSITORY-MAP.adoc
  • docs/architecture/THREAT-MODEL.adoc
  • docs/attribution/CITATIONS.adoc
  • docs/contributing.adoc
  • docs/decisions/0000-template.adoc
  • docs/decisions/0001-adopt-rsr-standard.adoc
  • docs/decisions/0001-template.adoc
  • docs/developer/ABI-FFI-README.adoc
  • docs/developer/ZIG-STD-SURVEY.adoc
  • docs/governance/CRG-AUDIT-TEMPLATE.adoc
  • docs/governance/TEMPLATE-LINEAGE-AUDIT.adoc
  • docs/governance/TEMPLATE-STANDARDS-AUDIT.adoc
  • docs/onboarding/QUICKSTART-DEV.adoc
  • docs/onboarding/QUICKSTART-MAINTAINER.adoc
  • docs/onboarding/QUICKSTART-USER.adoc
  • docs/onboarding/llm-warmup-dev.adoc
  • docs/onboarding/llm-warmup-maintainer.adoc
  • docs/onboarding/llm-warmup-user.adoc
  • docs/practice/AI-CONVENTIONS.adoc
  • docs/practice/STATE-VISUALIZER-GUIDE.adoc
  • docs/practice/ci-cost-reduction.adoc
  • docs/reports/FUZZ-RESULTS.adoc
  • docs/reports/VERIFICATION.adoc
  • docs/reports/audit/pillar-audit-2026-04-15.adoc
  • docs/status/PROOF-NEEDS.adoc
  • docs/status/PROOF-STATUS.adoc
  • docs/status/READINESS.adoc
  • docs/status/ROADMAP.adoc
  • docs/status/TEST-NEEDS.adoc
  • docs/troubleshooting.adoc
  • docs/usage.adoc
  • launcher.sh
  • mise.toml
  • scripts/campaigns/www-bundle.campaign
  • scripts/check-no-placeholders.sh
  • scripts/validate-template.sh
  • sonar-project.properties
  • src/README.adoc
  • src/cli/dnssec-stub.zig
  • src/dnssec/anchors.zig
  • src/dnssec/crypto.zig
  • src/dnssec/keys.zig
  • src/dnssec/nsec.zig
  • src/dnssec/nsec3.zig
  • src/dnssec/rrset.zig
  • src/dnssec/validator.zig
  • src/interface/Abi/Foreign.idr
  • src/interface/Abi/Layout.idr
  • src/interface/Abi/README.adoc
  • src/interface/Abi/Types.idr
  • src/interface/E2e/Main.idr
  • src/interface/E2e/README.adoc
  • src/interface/E2e/abi-e2e.ipkg
  • src/interface/README.adoc
  • src/interface/ffi/README.adoc
  • src/interface/ffi/build.zig
  • src/interface/ffi/include/zig_dnssec.h
  • src/interface/ffi/src/README.adoc
  • src/interface/ffi/src/main.zig
  • src/interface/ffi/test/README.adoc
  • src/interface/ffi/test/abi_test.zig
  • src/interface/ffi/test/integration_test.zig
  • src/interface/ffi/test/seam_test.zig
  • src/root.zig
  • src/stub/client.zig
  • src/stub/doh.zig
  • src/stub/transport.zig
  • src/wire/builder.zig
  • src/wire/encoding.zig
  • src/wire/message.zig
  • src/wire/name.zig
  • src/wire/rdata.zig
  • src/wire/text.zig
  • src/wire/types.zig
  • tests/aspect_tests.sh
  • tests/crosscheck/REPORT.adoc
  • tests/crosscheck/export-fixtures.sh
  • tests/crosscheck/make-zones.sh
  • tests/crosscheck/run.sh
  • tests/crosscheck/servers.sh
  • tests/crosscheck/zones/badsig.test.signed
  • tests/crosscheck/zones/dname.test.signed
  • tests/crosscheck/zones/dssha1.test.signed
  • tests/crosscheck/zones/ecdsa256.test.signed
  • tests/crosscheck/zones/ecdsa384.test.signed
  • tests/crosscheck/zones/ed25519.test.signed
  • tests/crosscheck/zones/ed448.test.signed
  • tests/crosscheck/zones/expired.test.signed
  • tests/crosscheck/zones/highiter.test.signed
  • tests/crosscheck/zones/insecure.test.signed
  • tests/crosscheck/zones/island.test.signed
  • tests/crosscheck/zones/nodnskey.test.signed
  • tests/crosscheck/zones/notyet.test.signed
  • tests/crosscheck/zones/nsec3sha1.test.signed
  • tests/crosscheck/zones/root.anchor
  • tests/crosscheck/zones/root.signed
  • tests/crosscheck/zones/rsasha1.test.signed
  • tests/crosscheck/zones/rsasha256.test.signed
  • tests/crosscheck/zones/rsasha512.test.signed
  • tests/crosscheck/zones/tampered.test.signed
  • tests/crosscheck/zones/test.signed
  • tests/crosscheck/zones/unsigned.ecdsa256.test.signed
  • tests/crosscheck/zones/wrongkey.test.signed
  • tests/denial.zig
  • tests/e2e.sh
  • tests/e2e/template_instantiation_test.sh
  • tests/fuzz.zig
  • tests/fuzz/README.adoc
  • tests/fuzz/dnssec-fuzz.zig
  • tests/fuzz_targets.zig
  • tests/fuzz_validator.zig
  • tests/replay.zig
  • tests/testdata/crosscheck-root.anchor
  • tests/testdata/crosscheck.traces
  • tests/testdata/rfc/rfc4035-appendix-a.zone
  • tests/testdata/rfc/rfc5155-appendix-a.zone
  • tests/vectors.zig
  • tests/workflows/template_conformance_test.sh
  • www/.well-known/aibdp.json
  • www/.well-known/humans.txt
  • www/.well-known/security.txt
  • www/README.adoc
  • www/dns/records/example.invalid.zone
  • www/policies/acceptable-use.adoc
  • www/policies/ai-use.adoc
  • www/policies/privacy.adoc
  • www/public/index.html
  • zig-dnssec_chora.deed

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

The Canon lockstep job (dogfood-gate.yml) failed on every PR in the
stack: hyperpolymath/standards released canon 2.1.3 on 2026-09-30, and
this deed, minted from a template snapshot that still pinned 2.1.2,
declared the old version and gates hash.

2.1.3 is a PATCH release: the law files moved into 0-canon/, which
rewrote the paths named inside template-capability-gates.toml. The
criteria hash is unchanged; the gates hash changed. rsr-template-repo
main already declares exactly these values, so this follows the spine's
adoption (canon.lock order: spine-adopts-then-canon-releases).

  version         2.1.2 -> 2.1.3
  criteria-sha256 6a5aa885... (unchanged)
  gates-sha256    e70efd2f... -> 2f31f46d...

The (provenance) block keeps :canon-version "2.1.2": it records what the
mint was made against, beside :template-tree, and stays as history.

Checked: the workflow's own comparison step, replayed against the
fetched canon.lock, fails on the old pin (version and gates rows) and
passes on the new one. just validate, validate-coapt, validate-claude-md,
validate-repo-map, validate-state and the estate-rules replay pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01J4QvDjJMgMQkerYkRoTr2V

Copy link
Copy Markdown
Owner Author

CI status on 0e785cc: two checks are red, and neither is fixed in this PR yet.

1. Hypatia neurosymbolic scan: the scanner crashes. No finding is reported.

  • What happens: hypatia-cli.sh scan . --exit-zero dies with Segmentation fault (core dumped), exit 139, before it writes any findings. It did this on both runs: 4a2c0eb (run 40473995071) and 0e785cc (run 40475387179).
  • Deposit findings for gitbot-fleet fails only as a consequence: the hypatia-findings artifact it downloads was never produced.
  • Why this is not this PR's code: the same reusable workflow, standards@da2c748, scans C ABI seam: zig_dnssec.h, libzig_dnssec, Idris2 model #5's tree cleanly, and C ABI seam: zig_dnssec.h, libzig_dnssec, Idris2 model #5's tree is a superset of this one. chore: mint zig-dnssec from rsr-template-repo #3 scans clean too. A segfault is a crash in the scanner, whatever it was given.
  • Fix: none exists yet. The fix belongs at the source, in hyperpolymath/hypatia. I'm trying to reproduce it locally so the report names the trigger.

2. SonarCloud Code Analysis: "C Security Rating on New Code".

Canon lockstep is now green; the fix was the canon 2.1.3 re-pin inherited from #3. Zig CI test passes.


Generated by Claude Code

…re; reachable security.txt

Three mint defects found in review (Codex, on the mint PR):

1. Service name rendered as "y". The interactive repo-init prompt
   "Service name [zig-dnssec]:" received "y", so {{SERVICE_NAME}} and
   {{IMAGE}} became y across the container tier: `just container-build`
   would build, and container-push would publish, ghcr.io/hyperpolymath/y.
   Re-rendered from the template (origin/main) with SERVICE_NAME=zig-dnssec:
   for each template line carrying one of those tokens, the current line
   was first checked to equal the template rendered with "y" (every other
   token as the mint filled it), then replaced by the zig-dnssec rendering.
   51 lines in 12 files, no mismatches, no other change.

2. tests/workflows/mint_cleanup_test.sh lost its
   `<!-- TEMPLATE INSTRUCTIONS: delete only this comment -->` fixture line
   (the mint's own instruction-block strip ran over the test), which made
   the "stripped" assertion vacuous. Restored byte-for-byte from the
   template; the test now strips one block, then is idempotent.

3. security.txt Canonical named
   https://github.com/hyperpolymath/zig-dnssec/.well-known/security.txt,
   which GitHub does not serve (the template renders it that way for every
   mint). No deployed site serves www/ (pages.yml publishes site/), so it
   now names the raw content URL of the checked-in file on main.

Checked: just validate, validate-coapt, validate-claude-md,
validate-repo-map, validate-state, check-lock-sync, action pinning,
AsciiDoc render, estate-rules replay, mint_cleanup_test.sh, bash -n on
the two edited shell scripts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01J4QvDjJMgMQkerYkRoTr2V
…gial rust-ci

The mint left `(rsr-profile :capabilities ())` with an UNASSIGNED note.
standards' reference checker (scripts/check-rsr-profile.sh) rejects that
outright ("profile declares neither 'capabilities' nor 'preset'"), and
the RSR oracle then scores every capability-gated criterion as n/a, so
the published scorecard was inflated (Codex review on the mint PR).

Declared, against template-capability-gates.toml 0.3.0, the capabilities
whose gated modules this tree carries:
  zig idris2 bash library ffi abi container reproducible-build
  benchmarks governance-tier published-package formal-proofs
(formal-proofs because verification/proofs/ is present; the checker is
presence-based.) The library PR adds `cli` with the dnssec-stub CLI.

.github/workflows/rust-ci.yml is removed: the checker reports it
VESTIGIAL (no 'rust' capability) and its own remedy is to remove the
vestigial module. It ran nothing on these PRs. The source fix is in
rsr-template-repo (repo-init should prune it for non-Rust mints); that
goes on the upstream list. Its actions.lock entry goes with it.

The checker still reports two rows that are canon/template mismatches,
not choices this repo can make:
  MISSING (abi): abi.ipkg - the gate row is root-anchored, but the
    template itself keeps src/interface/abi.ipkg
  MISSING BASELINE: 0-AI-MANIFEST.a2ml or 0-AI-MANIFEST.deed - the
    template ships neither since A2ML retired
Both are for the upstream list.

Checked: check-rsr-profile.sh (only the two rows above), just validate,
validate-coapt, validate-claude-md, validate-repo-map, validate-state,
check-lock-sync, action pinning, AsciiDoc render, estate-rules replay,
Canon lockstep comparison.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01J4QvDjJMgMQkerYkRoTr2V
…inherited test record

Second round of mint defects from review (Codex, on the mint PR). The
mint's global rename of rsr-template-repo -> zig-dnssec also rewrote
detectors whose job is to find the parent name, and its token pass left
UNASSIGNED sentinels and the template's own test record in place.

- build/just/groove.just (verify-template): the stale-default check
  grepped for 'zig-dnssec', so it fired on every checkout. Restored to
  look for the parent, and anchored to the template's default line
  (project := "rsr-template-repo"): the restored bare-name grep fired on
  the Justfile's legitimate rsr-template-repo#209 citation. Controls: a
  Justfile with only a citation passes, one with the template default
  is caught.
- .machine_readable/self-validating/methodology-guard.k9.ncl: the
  state_not_template reject pattern had become 'zig-dnssec' and matched
  the journal's own title. Restored to the parent name, anchored to the
  title form "= rsr-template-repo" (the journal may cite the template);
  the comment that called the name init-safe is corrected. Controls: the
  template's ROADMAP title matches, this repo's ROADMAP (both stack tips)
  does not; nickel export evaluates.
- .mailmap: restored from the template. The mint replaced it because the
  optional alternate address was blank, dropping the existing alias.
- docs/onboarding/QUICKSTART-{DEV,MAINTAINER}.adoc: build and test
  commands, tech stack, dependencies, build output and package name were
  UNASSIGNED; filled with the real values (just build, just test, Zig
  0.17.0 + Idris2 0.7.0, zig-out/, zig-dnssec). The MUST_INVARIANTS
  token is left for the owner: it depends on the must contractile, which
  still carries the template's declaration.
- docs/status/TEST-NEEDS.adoc: carried the template's CRG C grade
  (2026-04-04) and its test inventory under this repo's name. Reset to
  "not assessed", pointing at docs/reports/VERIFICATION.adoc, which
  arrives with the library.

Checked: just validate, validate-coapt, validate-claude-md,
validate-repo-map, validate-state, check-lock-sync, action pinning,
AsciiDoc render, estate-rules replay; verify-template no longer reports
the always-on project-name warning.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01J4QvDjJMgMQkerYkRoTr2V
…s pending owner

The mint copied all six contractile declarations from rsr-template-repo
and renamed them, so this repo's machine-readable north star said
zig-dnssec is "the master template for all hyperpolymath repositories"
and "NOT a runtime library" - the opposite of the deed's purpose - and
coaptation and agents read it as project intent (Codex review).

By owner decision this is neutralised here, not authored: contractiles
are normative, and the source fix (repo-init generating declarations
from the deed instead of copying the template's) goes upstream.

- intend: the template purpose, anti-purpose, three template-maintenance
  intents and four estate wishes are removed. Abstract, Purpose and
  Anti-Purpose now say "pending owner authorship" and point at the
  deed's purpose and IS-NOT clauses. intents/wishes are empty (the
  coaptation reader treats a missing list as []). Non-gating verb.
- must, bust, dust: abstracts no longer claim this is the template; they
  say their entries were inherited at mint and await owner review. No
  invariant, failure mode or check is removed: must and bust are
  blocking gates, and dropping checks would weaken them.
- all six: the signed trident provenance (signed_by.context, 2026-04-18)
  is restored to "canonical template in rsr-template-repo"; the rename
  had rewritten that historical record.
- docs/onboarding/QUICKSTART-DEV.adoc: the last UNASSIGNED token
  (MUST_INVARIANTS) points at the deed as the authority until must is
  authored, quoting its fail-closed rule verbatim; the retired
  .machine_readable/MUST.contractile path is corrected.
- coaptation receipt regenerated with `just coapt` (drift: exactly the
  removed intent/wish rows and the six contractile hashes).

Checked: nickel export of all six contractiles, just validate,
validate-coapt, validate-claude-md, validate-repo-map, validate-state,
check-lock-sync, action pinning, AsciiDoc render, session contracts,
estate-rules replay.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01J4QvDjJMgMQkerYkRoTr2V
…build command

Two findings from review (Codex, on the mint PR):

- build/just/container.just: repo-init renders the template's
  {{project}} as PROJECT_LOWER (zig_dnssec), while ct-build.sh tags the
  image from SERVICE_NAME (ghcr.io/hyperpolymath/zig-dnssec:latest). So
  `just container-build && just container-run` built one name and ran
  another, and the plain-OCI push fallback would push an unqualified
  zig_dnssec:latest. A single `_image` reference now expands the same
  CT_REGISTRY / CT_TAG overrides and defaults as ct-build.sh and is used
  by the build fallbacks, the push fallback and container-run; the
  container-init service-name default is zig-dnssec to match. Checked
  with a stand-in engine: container-run resolves to
  ghcr.io/hyperpolymath/zig-dnssec:latest (ct-build.sh's FULL_IMAGE)
  and follows CT_REGISTRY/CT_TAG overrides.
- docs/onboarding/QUICKSTART-MAINTAINER.adoc: `just build-release` is
  not wired (it prints FAIL and exits 1). The guide now says
  `just build`, which works on this tree and, once the library lands,
  writes zig-out/.

Checked: the Justfile parses, just validate, validate-coapt,
validate-claude-md, validate-repo-map, validate-state, check-lock-sync,
action pinning, AsciiDoc render, estate-rules replay.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01J4QvDjJMgMQkerYkRoTr2V
claude added 13 commits October 27, 2026 10:48
…al drift

The (variant (paths …)) lists were empty, so
scripts/check-variant-drift.sh reported every mint change as drift (120
lines) and could not separate the mint from later upstream drift
(Codex review). By owner decision they are populated here, and the
source fix (repo-init writing these lists at mint, since it knows what
it removed and rendered) goes upstream.

Generated from the gate's own report against the parent pin. 3100d46
is this repo's Initial commit, which carries the template tree
(2c01b6f) at mint, so a worktree of it is the parent checkout:
  added     5   rendered docs seeded from build/docs-seed/
  removed   6   archetypes/, build/docs-seed/, build/templates/ (whole
                directories, as prefixes), rust-ci.yml,
                PLACEHOLDERS.adoc, rsr-template-repo_chora.deed
  diverged 97   every file the mint rendered, plus the deed and ROADMAP
:last-updated moves to 2026-10-27; the clause comment says how the
lists were made.

Checked: check-variant-drift.sh passes (was 120 drift lines); a control
that edits one undeclared file (scripts/check-adoc-renders.sh) is
caught. just validate, validate-coapt, validate-claude-md,
validate-repo-map, validate-state, check-lock-sync, action pinning,
AsciiDoc render, estate-rules replay, Canon lockstep comparison.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01J4QvDjJMgMQkerYkRoTr2V
- Name: validated uncompressed names, presentation format, RFC 4034
  canonical ordering, compression-pointer decoding that only accepts
  strictly backward pointers (guaranteed termination)
- RDATA layouts: decompression only where RFC 3597 permits, canonical
  lowercasing per RFC 4034 §6.2 / RFC 6840 §5.1, typed views for SOA,
  DNSKEY, DS, RRSIG, NSEC, NSEC3, NSEC3PARAM, type bitmaps
- Message: bounds-checked parse, OPT/EDNS handling, trailing-data and
  meta-type rejection
- Builder: compression for owner/question names and RFC 1035 RDATA

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01F6k6Z173AKT78qpe65xR7n
- crypto: RSASHA1/RSASHA1-NSEC3-SHA1/RSASHA256/RSASHA512 via
  std.crypto.Certificate.rsa (PKCS#1 v1.5), ECDSA P-256/P-384 and
  Ed25519 (cofactorless) via std.crypto.sign; Ed448, GOST, SM2 reported
  as unsupported. RFC 3110 key parsing with leading-zero rejection.
- keys: RFC 4034 App. B key tags, DS digests (SHA-1/256/384)
- rrset: grouping, canonical signed data with wildcard owners, RFC 4035
  §5.3.1 checks (signer, labels, serial-arithmetic validity window, key
  owner/tag/algorithm/protocol/zone/revoke flags), effective TTL
- text: presentation-format parser for fixtures and trust anchors
- tests/vectors.zig: RFC 4034, 4509, 5702, 6605, 8080 examples and every
  signature in the RFC 4035 and RFC 5155 appendix zones, plus negative
  cases. Finding: the RFC 8080 Ed25519 example signatures only reproduce
  with RRSIG Labels=3 on a 2-label owner, which RFC 4035 requires a
  validator to reject; the tests check both facts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01F6k6Z173AKT78qpe65xR7n
- nsec: cover/match with wrap-around, NXDOMAIN (incl. empty non-terminal
  detection and wildcard denial), NODATA (incl. ENT and wildcard
  NODATA), wildcard-answer closest-encloser check, insecure-delegation
  proof; RFC 6840 §4.1 ancestor-delegation and DNAME restrictions, §4.3
  CNAME bit, §4.4 NS bit; child-side NSEC refused for DS denial
- nsec3: RFC 5155 hashing, owner/flag/algorithm filtering, parameter
  consistency, RFC 9276 iteration ceiling, hash budget, closest
  (provable) encloser, §8.4-§8.9 proofs, Opt-Out reported distinctly
- tests/denial.zig: every RFC 4035 and RFC 5155 Appendix B example,
  with each NSEC/NSEC3 authenticated first; RFC 5155 hash vectors

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01F6k6Z173AKT78qpe65xR7n
- Verdict is a tagged union (secure | insecure | bogus | indeterminate);
  answer data is only reachable from the secure arm, or from the
  insecure arm together with the reason and the zone where insecurity
  was proven. Every failure path is bogus or indeterminate.
- Bottom-up chain walk from the RRSIG signer through DS/DNSKEY to the
  closest static trust anchor (DS or DNSKEY anchors; IANA root DS for
  KSK-2017 and KSK-2024 built in, cross-checked against the signed
  root-anchors.xml and Ubuntu dns-root-data).
- Insecurity must be proven: NSEC/NSEC3 insecure-delegation proofs or
  NSEC3 Opt-Out; unsigned data in a provably signed zone is bogus.
- CNAME and DNAME chains (DNAME before the synthesised CNAME), wildcard
  expansion proofs, NXDOMAIN/NODATA proofs, RFC 4509 SHA-1 DS
  suppression, RFC 9905 SHA-1 switch.
- Policies default to fail: unsupported algorithms and NSEC3 iterations
  above 150 are bogus unless the caller opts into the RFC's insecure
  treatment.
- Budgets on fetches, signature checks (incl. per-RRset failures, a
  KeyTrap-class defence), NSEC3 hashes and chain length.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01F6k6Z173AKT78qpe65xR7n
- DoH (RFC 8484) over HTTP/1.1 using std.crypto.tls.Client and
  std.http's head parser, optionally via an HTTP CONNECT proxy with TLS
  end to end. std.http.Client is not used: in Zig 0.17.0 its
  HTTPS-through-CONNECT path sends the request in cleartext inside the
  tunnel (observed with a local CONNECT proxy).
- Queries carry RD, CD, EDNS DO and RFC 8467 block padding; responses
  are matched on ID, QR, opcode and question; bodies capped at 65535.
- DoQ is not implemented (no QUIC in std); documented as a gap.
- Replay transport and trace format; tests/replay.zig replays 263
  responses recorded from NSD + Unbound and asserts agreement with
  Unbound except the documented policy cases, plus 13 mutation
  attacks (tampering, stripped signatures, missing DNSKEY, forged
  denial, wildcard without proof, ...), time travel, wrong and absent
  trust anchors, budgets and fetch failure.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01F6k6Z173AKT78qpe65xR7n
…idator

- tests/fuzz_targets.zig: shared targets: raw decoder with re-encode
  round trip; decoder on recorded responses under a small mutation
  language; NSEC3 RDATA, owner decoding and every proof on arbitrary
  records and names; presentation parser; a differential validator
  target that fails if any mutation of a recorded response yields a
  secure answer different from the unmutated one.
- tests/fuzz.zig and tests/fuzz_validator.zig: std.testing.fuzz
  wrappers (zig build fuzz / fuzz-validator --fuzz=N).
- tests/fuzz/dnssec-fuzz.zig: reproducible standalone mutation fuzzer.
- Finding fixed: the coverage-guided fuzzer hit an integer overflow in
  Name.readFromMessage/readUncompressed (u8 length arithmetic when the
  labels reach exactly 255 octets without a root label). Lengths are
  now computed in usize and a non-root label must leave room for the
  root. The crashing input is kept as corpus and a unit regression test
  covers the boundary.
- The CLI moved to src/cli/ to fit the repository layout.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01F6k6Z173AKT78qpe65xR7n
…inate

Budget exhaustion is an attack signal (resource_limit), so it now maps
to bogus wherever a chain fetch fails, matching the signature and NSEC3
budgets. Network-level failures (fetch_failed, upstream RCODE,
truncation) stay indeterminate. Malformed fetched responses (question
mismatch) are bogus.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01F6k6Z173AKT78qpe65xR7n
- tests/crosscheck/make-zones.sh: fake root (RSASHA256 KSK+ZSK), test.
  (ECDSA P-256, NSEC3) and 19 leaf zones covering algorithms 5/7/8/10/
  13/14/15/16, NSEC and NSEC3 (salted, Opt-Out, 200 iterations), DNAME,
  an unsigned delegation, a signed island, a SHA-1-only DS, and broken
  chains: expired and not-yet-valid signatures, DS for a key not in the
  zone, DNSKEY RRset removed, data changed after signing, a corrupted
  signature. Signed zones and the trust anchor are committed; test keys
  are generated locally and ignored.
- servers.sh: NSD (authoritative), Unbound (validating, plain + DoH)
  and an haproxy HTTP/1.1 front end for Unbound's HTTP/2-only DoH.
- run.sh: 263 queries; our verdict over DoH with CD=1 (default and
  RFC-permissive policies), Unbound's (AD/SERVFAIL) and ldns's
  (drill -S); writes REPORT.adoc listing every disagreement.
- Result: vs Unbound, 17 disagreements (12 Ed448, 5 NSEC3 iterations
  > 150), all documented policy/gap cases; 12 under the permissive
  policy (Ed448 only). vs ldns, 33, each an Ed448/iterations case or a
  case where drill -S's chase is coarser and Unbound agrees with us.
  The first run also caught a DNAME bug, fixed in M4.
- export-fixtures.sh bundles the recorded traces for tests/replay.zig.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01F6k6Z173AKT78qpe65xR7n
- README: experimental status, what it is and is not, usage, building and
  testing, the AI-assisted installation section the template validates.
- docs/reports/VERIFICATION.adoc: every claim tagged PROVEN / TESTED /
  ASSUMED / DESIGNED / OPEN with its artefact; FUZZ-RESULTS.adoc holds
  the campaign table (coverage-guided validator run: 31,237 runs, 0
  findings).
- docs/architecture/THREAT-MODEL.adoc: what the validator promises, the
  trust-anchor assumptions, unimplemented algorithms and every known gap.
- docs/developer/ZIG-STD-SURVEY.adoc: which DNSSEC primitives Zig 0.17.0
  provides, and the std.http.Client CONNECT defect found on the way.
- docs/status/ROADMAP.adoc: milestone 1 done; next is independent review,
  upstream reports, and specialising the template's ABI/FFI seam, which
  as minted is a generic example that does not build on Zig 0.17.0.
- docs/AI_INSTALLATION_GUIDE.adoc rewritten for this repository.
- .github/workflows/zig-ci.yml: checksum-verified Zig 0.17.0, zig fmt
  check, zig build test, ReleaseSafe build, standalone fuzzer smoke run;
  actions pinned and recorded in actions.lock.
- build/container/Containerfile: toolchain, test, crosscheck and runtime
  targets on Wolfi.
- mise.lock: Zig 0.16.0 -> 0.17.0. root-allow.txt: build.zig,
  build.zig.zon; REPOSITORY-MAP.adoc regenerated (`just repo-map`).

Checked: zig build test (88/88), zig fmt --check, just validate,
scripts/check-adoc-renders.sh, check-root-shape, check-no-placeholders,
check-lock-sync, check-invisible-characters, check-action-pinning, the
validate-* drift recipes, and a local replay of the estate-rules workflow.
`just test` and `just build` also run the Idris2 seam and need idris2.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01F6k6Z173AKT78qpe65xR7n
A negative response whose authenticated NSEC/NSEC3 records are absent was,
in one path, handled by reading the Signer's Name off the SOA's RRSIG and
calling `zoneStatus` on it directly — with no signature check and no test
that the signer was an ancestor of the queried name.

That name is attacker-controlled. A forged response could name an
unrelated but genuinely insecure zone as the SOA signer and have a secure
name's tampered or unsigned answer returned as `insecure` (a usable
answer) instead of `bogus`. This breaks the module's core promise that a
validation failure is never reported as insecure (RFC 4035 §5; the
`secure | insecure | bogus | indeterminate` contract in this file's
header).

Fix: drop that path. A missing denial now always returns `.none` with the
SOA *owner*, and the caller decides legitimacy by walking the
authenticated chain from the trust anchor down to that owner, with its
existing `isSubdomainOf` / `isStrictSubdomainOf` ancestry checks. The
owner is only a hint for which zone to authenticate; a lie about it fails
the ancestry check, and the zone's real security is established from the
anchor, not from the response.

The other five uses of an RRSIG signer name in the validator were
re-audited: each either verifies the signature against that zone's keys
afterwards or applies an ancestry check, so this was the only unsound one.

Regression tests (tests/replay.zig): a forged NXDOMAIN, a tampered answer
with a forged "no DS", and a signature-stripped answer with a forged
"no DS", each naming an insecure zone as signer, must all be bogus.
Verified with the differential validator fuzzer (49,729 runs, 0 findings).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01F6k6Z173AKT78qpe65xR7n
The mint PR declared the capabilities its tree carries; this PR adds the
dnssec-stub command-line client (src/cli/), so the profile gains cli.
No gate row keys on cli, so check-rsr-profile.sh output is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01J4QvDjJMgMQkerYkRoTr2V
The mint PR populated the (variant (paths …)) lists so
scripts/check-variant-drift.sh separates the mint from real upstream
drift. This PR adds the library, so it declares its own changes the same
way, generated from the gate's report (73 drift lines before):
  added: build.zig, build.zig.zon, zig-ci.yml, the new reports and
         survey, and the new source and test trees as directory
         prefixes (src/wire/, src/dnssec/, src/stub/, src/cli/,
         tests/crosscheck/, tests/testdata/, tests/fuzz/corpus/, ...)
  diverged: the inherited files this PR edits (CHANGELOG, mise.lock,
         .gitignore, root-allow.txt, AI_INSTALLATION_GUIDE, src/README,
         tests/fuzz/README, ...)
check-variant-drift.sh now passes on this tip.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01J4QvDjJMgMQkerYkRoTr2V
@hyperpolymath
hyperpolymath marked this pull request as ready for review October 27, 2026 10:54
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-27T14:38:31.355045Z 4025364 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@hyperpolymath
hyperpolymath enabled auto-merge (squash) October 27, 2026 11:05

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6d6a2b11d8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/dnssec/validator.zig Resolved
Comment thread src/dnssec/validator.zig Resolved
Comment thread src/dnssec/validator.zig Resolved
Comment thread src/stub/doh.zig Resolved
Comment thread src/dnssec/rrset.zig Resolved
Comment thread build/container/Containerfile Resolved
Comment thread src/dnssec/rrset.zig Resolved
Comment thread src/dnssec/validator.zig Resolved
## Summary

**Stacked on #4
(`feat/dnssec-library`). Review only the last two commits:

- `be345a3`: the seam itself
- `19faf6a`: the seam's variant-contract paths

Once the library PR merges, this branch will be restacked onto `main`
and retargeted.

This replaces the template's example ABI/FFI seam in `src/interface/`.
That seam was not wired to the library and did not compile on Zig
0.17.0. Its Idris2 and Zig sides also disagreed on result codes and
symbol names.

## Changes

- **`zig_dnssec.h`** is the contract (ABI v1) and states the fail-closed
rules:
  - `security` stays NONE unless the call returned OK.
  - Answer text is written only for SECURE and INSECURE.
  - Unknown policy bits are rejected, not ignored.
- **`libzig_dnssec`** is pure Zig with no libc, built by `zig build
ffi`. Every export is checked at compile time against the header's type.
- **The Idris2 model** (`src/interface/Abi/`) has these proofs:
  - status, security and reason codes round-trip;
  - the verdict layout is aligned, in order and non-overlapping;
  - struct offsets must be read by the right field name;
- an `Outcome` whose answer type is `()` for Bogus and Indeterminate, so
no answer can be returned with those verdicts.

  The model is `%default total` with no `believe_me`.
- **`seam_test.zig`** compares the Idris model with the header as the C
compiler sees it. Eleven deliberate mismatches, one of each kind, were
each caught.
- **`abi_test.zig`** covers the C behaviour:
  - all 51 recorded bogus scenarios yield no answer text;
  - every bad-argument path;
  - buffer sizing and the callback transport;
  - no leaks, including under allocation failure at every point.
- **Idris2 → C ABI → Zig end-to-end test** (`just abi-e2e`). A new
`abi-seam` CI job builds Idris2 0.7.0 from its pinned release commit and
runs it. Expect that job to take 10–20 minutes (the first run took about
10).

## RSR Quality Checklist

### Required

- [x] Tests pass (`just test`, `zig build test`)
- [x] Code is formatted (`zig fmt --check`)
- [x] No banned language patterns
- [x] No banned functions (`believe_me` etc.): the Idris model is
`%default total` with none
- [x] No secrets, credentials, or `.env` files included

### As Applicable

- [x] ABI/FFI changes validated (`src/interface/Abi/` and
`src/interface/ffi/` consistent: `seam_test.zig` and `just abi-e2e`)
- [x] Documentation updated (`src/interface/README.adoc`)

## Testing

Run on this tip (`19faf6a`):

- by the author: `zig build test` also run inside the Wolfi container
- re-run locally for this PR, with Zig 0.17.0 and Idris2 0.7.0 built
from `27780073`:
  - `zig fmt --check …`: clean
- `zig build test --summary all` (cold cache): 18/18 steps, **111/111
tests** (89 library + 22 ABI)
  - `idris2 --typecheck` (via `just test`): pass
  - `just test && just quality`: pass
  - `just abi-e2e`: 9 checks, 0 failed
- `just validate`, `validate-coapt`, `validate-claude-md`,
`validate-repo-map`, `validate-state`, lock-sync, action pinning,
AsciiDoc render: pass
  - `estate-rules.yml` replay: pass
  - `scripts/check-variant-drift.sh` against the parent pin: pass
- CI on earlier tips of the same tree: Zig CI `test` and `abi-seam`
passed

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_01J4QvDjJMgMQkerYkRoTr2V

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

<!-- coderabbit-ai-generated:v1 -->

## Summary by CodeRabbit

* **New Features**
* Added a DNSSEC C interface for validating recorded traces or
caller-provided exchanges, with structured verdicts and answer text only
for usable results.
* Added Idris2 interface modeling and proof checks, plus end-to-end
coverage of representative validation scenarios.
* **Bug Fixes**
* Validation failures now return explicit statuses and avoid exposing
answer data for unusable verdicts.
* **Documentation**
* Added guidance for building, using, and testing the interface,
including toolchain requirements and verification limits.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Signed-off-by: Jonathan D.A. Jewell <6759885+hyperpolymath@users.noreply.github.com>
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
C Security Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

hyperpolymath added a commit that referenced this pull request Oct 27, 2026
## Summary

Mints this repository from `rsr-template-repo` with `just repo-init`
(project `zig-dnssec`, owner `hyperpolymath`, type library). This is the
base of a stack. The next PR adds the library on top of this one.

## Changes

- **Deed:** purpose, IS-NOT, kind, domain, pipeline position and unique
strength. Clade `pt`, secondary `sc`, as the owner chose. Registration
in `gv-clade-index` is left to the owner.
- **Generated files:** `CLAUDE.md`, `REPOSITORY-MAP.adoc` and the
coaptation receipt regenerated. All three had gone stale at mint, and CI
diffs the map.
- **Template references:** 24 references to the template's own issues
(#53, #119, #209) put back. The name substitution had renamed them to
zig-dnssec issue numbers. One of them was inside a commit message that
`scripts/sweep-wellknown.sh` writes.
- **Repairs:** a table cell restored, which the placeholder deletion had
removed. The deed's `(manifest)` purpose now describes this repository
rather than the template.

**Added after the first push** (CI and Codex review):

- **Canon re-pin** (`30a69c8`): the deed's `(canon …)` clause moves from
2.1.2 to **2.1.3**, which matches `rsr-template-repo` and fixes `Canon
lockstep`. The `(provenance)` block keeps 2.1.2 as history.
- **Mint defects, round 1** (`a6311dc`):
- The container service name was rendered as `y`; it is re-rendered from
the template as `zig-dnssec`. Every line was verified before
replacement: 51 lines in 12 files.
  - The `mint_cleanup_test.sh` fixture is restored.
  - `security.txt` `Canonical:` now names a URL that is actually served.
- **RSR profile** (`53e9601`): the deed declares the capabilities this
tree carries, and the vestigial `rust-ci.yml` is removed.
- **Mint defects, round 2** (`e1c7f45`):
- Two detectors that the global rename had turned against this repo's
own name are restored and anchored.
  - `.mailmap` is restored.
  - UNASSIGNED quick-start tokens are filled with real commands.
- The template's inherited test record in `TEST-NEEDS.adoc` is reset to
"not assessed".
- **Contractiles** (`88c6393`, by owner decision: neutralised here,
source fix upstream):
- The template's north star is removed from `intend`, and its
declaration is marked pending owner authorship.
- The `must`, `bust` and `dust` abstracts now say their entries were
inherited, and no check was removed.
  - The signed trident provenance is restored.
- **Containers and build** (`21ca1b5`):
- One image reference is shared by `container-build`, `container-push`
and `container-run`, mirroring `ct-build.sh`.
  - The maintainer guide's build command is `just build`.
- **Variant contract** (`2722846`, by owner decision):
- The `(variant (paths …))` lists are populated from
`check-variant-drift.sh`'s own report against the parent pin, so the
gate passes and catches undeclared drift. It previously reported 120
lines. #4 and #5 declare their own paths.

**Template issues met:** worked around here and listed in the commit
messages, to be reported upstream.

## RSR Quality Checklist

### Required

- [ ] Tests pass (`just test` or equivalent): **not at this commit,
expected.** `just test` fails here because the template's own example
FFI (`src/interface/ffi/src/main.zig`, `allocator.dupeZ`) does not
compile on Zig 0.17.0. No CI workflow on this PR runs it. The stacked
ABI-seam PR replaces that code, and `just test` passes there.
- [x] No banned language patterns
- [x] No secrets, credentials, or `.env` files included

### As Applicable

- [x] Repo deed (`*_chora.deed`) updated (purpose, IS-NOT, clade, canon
pin, rsr-profile, variant paths)

## Testing

Run locally on this tip (`2722846`) with just 1.59.0, nickel 1.17.0 and
asciidoctor 2.0.26:

- `just validate`, `validate-coapt`, `validate-claude-md`,
`validate-repo-map`, `validate-state`: pass
- `./scripts/check-lock-sync.sh`, `bun scripts/check-action-pinning.js`,
`bash scripts/check-adoc-renders.sh .`,
`scripts/validate-session-contracts.sh`: pass
- every `run:` step of `estate-rules.yml`, replayed (17 scripts plus the
repository-map staleness diff): pass
- `Canon lockstep` comparison step replayed against the fetched
`canon.lock`: fails on the old pin, passes on the new one
- `scripts/check-variant-drift.sh` against the parent pin: pass; a
control with one undeclared edit is caught
- `nickel export` of all six contractiles: pass
- `tests/workflows/mint_cleanup_test.sh`: strips the restored fixture,
then is idempotent
- standards `check-rsr-profile.sh`: only two canon/template-mismatch
rows (`abi.ipkg` location; no `0-AI-MANIFEST` baseline), listed for
upstream

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_01J4QvDjJMgMQkerYkRoTr2V

---------

Co-authored-by: Claude <noreply@anthropic.com>
Base automatically changed from init/repo-init to main October 27, 2026 14:31

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4025364b0a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/wire/name.zig Resolved
Comment thread src/wire/rdata.zig Resolved
Comment thread src/dnssec/validator.zig Resolved
Comment thread src/dnssec/validator.zig Resolved
@hyperpolymath
hyperpolymath enabled auto-merge (squash) October 27, 2026 14:42
hyperpolymath added a commit that referenced this pull request Oct 28, 2026
…sedes #4) (#6)

## What this is

Milestone 1 of the zig-dnssec library, plus the response to everything
raised on #4.

`main` already contains the minted repository (squash-merged in #3). #4
sat on the
un-squashed `init/repo-init` history and has **no common ancestor with
`main`**, so it is
permanently `CONFLICTING` and cannot be merged; a rebase would replay
eight mint commits
into conflicts. This branch is `main` + the thirteen library commits
cherry-picked clean
(`git merge-base --is-ancestor origin/main HEAD` holds), so it merges.
**It supersedes #4.**

98 files, +16014/-1265 against `main`. Nine commits on top of the
cherry-picks are the
review response: 16 files, +1176/-129.

## Review findings: 12 of 12 fixed, each with a negative control

Two automated reviews (`5666053823` over `6d6a2b11`, `5668921486` over
`4025364b`) raised
2 P1 security and 10 P2 findings. All twelve are fixed. Test count went
**111 → 123**;
`zig build test --summary all` is 18/18 steps, 123/123 tests.

The two P1s are the same defect in two places, and it is the one this
library exists to
prevent:

* **Insecurity inferred from an unauthenticated `Signer` name.** On the
answer path the
validator took `zoneStatus` of the RRSIG's signer and, on `insecure`,
returned the data
without checking whether a configured anchor sat closer to the owner. On
the denial path
it returned `insecure` *before verifying a single signature* over the
NSEC/NSEC3/SOA
records supposed to prove it. `Signer` is attacker-chosen until a
signature over it
verifies, so a responder could hand back a tampered answer as usable
`insecure` data from
inside a configured secure island. Now: authenticate first, gather every
candidate signer
deepest-first, and refuse a signer at or above an anchor (RFC 4035
§5.2).
* **Unsigned fields treated as evidence.** Three findings, one error:
the *minimum* `Labels`
over all same-signer RRSIGs instead of the one that verified (a forged
sibling moved the
wildcard proof depth); the *first* DS signature's signer instead of any
that authenticates
(one extraneous RRSIG broke a valid chain); and the *received* TTL of
unsigned data as the
answer's cache lifetime, so an `insecure` answer outlived the proof that
made it
  acceptable.

Also fixed: `QTYPE=RRSIG` reported as `bogus` for a correctly signed
response;
`QTYPE=CNAME` below a DNAME redirected past the synthesised answer (RFC
6672 §5.3.1);
`effectiveTtl` wrapping for skew-accepted signatures; a missing
SVCB/HTTPS RDATA layout so
the TargetName was hashed in its received case (RFC 4034 §6.2, RFC 9460
§2.2); a `u8`
overflow joining a relative name to its `$ORIGIN`; a dropped query
component in a DoH URI
template (RFC 8484 §3.1); and the container `crosscheck` target's
`;`-chained teardown
masking the cross-check's exit status.

**The tests were verified to fail on the code they guard.** Reverting
`src/dnssec/validator.zig` and `src/dnssec/rrset.zig` to their pre-fix
state fails all seven
new replay tests, each with its finding's exact symptom — a tampered
answer accepted as
`insecure` under an island anchor; a forged NXDOMAIN accepted as
`insecure_delegation`; a
valid chain broken by one extraneous DS RRSIG; a valid wildcard answer
rejected over a forged
`Labels`; an `insecure` answer cached for the attacker-chosen 86400 s;
`QTYPE=CNAME` below a
DNAME returning `indeterminate`; `QTYPE=RRSIG` not refused. The positive
control (an
anchored island validating as `secure`) passed in both states, as it
should. The `name.zig`
test aborts the pre-fix build outright: the overflow is a
checked-arithmetic panic in
Debug/ReleaseSafe and an out-of-bounds copy otherwise.

The replay tests mutate only what an RRSIG does not cover — the question
section, received
TTLs, and the presence and content of additional RRSIGs. That is
precisely an on-path
responder's budget.

No new `Reason` variant was added for `QTYPE=RRSIG`: `zig_dnssec.h`
fixes the reason codes
densely and `main.zig` `@compileError`s on a non-dense or duplicate
value, so a new code is
an ABI break and an Idris2 model change. `.malformed_response` is
reused, and the C boundary
returns `ZIG_DNSSEC_ERR_INVALID_ARGUMENT` before the library is reached.

## k9-deed conformance

* **Fixed a real defect:** `(variant (paths …))` closed with `))))`
where
`build/just/repo-init.just` emits `)))`. The extra parenthesis ended
`(repo-deed …)` early
and left `(provenance)` a *sibling* of it rather than a clause of it, so
no reader walking
clauses below `(repo-deed …)` could reach it. `deed-field.sh --has …
provenance` reported
the clause absent; `check-template-conformance.sh` failed T1 and
short-circuited T2–T4, and
`template-commit`, `template-tree`, `canon-version`, `criteria-sha256`
and `gates-sha256`
were unreadable by every gate. **T1/T2/T3 now pass.** This is inherited
from the mint —
  `main` carries the same defect — so `rsr-template-repo` needs it too.
* `scripts/validate-template.sh` now honours the deed's `(paths :removed
…)` and builds the
root `build.zig` when the contract has removed
`src/interface/ffi/build.zig`. It previously
required paths this variant deliberately deleted and, because
`check_file_exists` returns 1
under `set -euo pipefail`, aborted on the first one and never reported
the rest. Now
  **0 errors, 3 warnings**. The script is declared `:diverged`.
* **Not fixed, and it cannot be from here:** the deed's `:parent-pin` /
`:template-commit` (`3100d46b9cfe…`) and `:template-branch`
(`init/repo-init`) **do not
exist** in `hyperpolymath/rsr-template-repo` — the commit is HTTP 422
from the commits API
and reachable from no branch, and the branch is gone.
`check-variant-drift.sh` takes a
parent checkout at that pin, so the gate is *unrunnable*, not failing.
Against the parent's
current `main` it reports 137 lines of drift, mixing fourteen days of
parent evolution
since the 2026-10-13 mint with this repo's real divergence. Re-pointing
the pin and
rewriting the path lists to make it green would certify convergence
nobody has
demonstrated, so it is recorded in `docs/reports/VERIFICATION.adoc` for
the estate owner
instead. `check-template-conformance.sh` T3 asserts the same unfetchable
commit.
* T4 fails locally on this working branch only — it enumerates
`refs/heads/`, so it is an
  artifact of the checkout, not of the repository.

## SonarCloud

The one red check at #4's tip was **Quality Gate failed: "C Security
Rating on New Code"
(required ≥ A)**, from SonarCloud's automatic GitHub-App analysis
(`sonarqube.yml` self-skips
without `SONAR_TOKEN`). `sonar-project.properties` excludes all `*.zig`
and `*.idr`, so the
analysed new code is the container build, the workflows and the shell.

What I changed, on the merits:

* `build/container/Containerfile` and `.github/workflows/zig-ci.yml` now
pass
`--proto '=https' --tlsv1.2` to every `curl` that fetches the toolchain.
Each already
verifies a pinned SHA-256, but a checksum only proves that what arrived
matches the pin if
  the transfer cannot be silently downgraded.
* The container `CMD` fix above also removes a masked exit status.

What I deliberately did **not** do: widen `sonar.exclusions`, edit the
gate, or change
`sonar-project.properties`. I also did not digest-pin the two
`FROM cgr.dev/chainguard/wolfi-base:latest` lines or change the build
stages' user model,
because neither is verifiable from here — `ziglang.org`, `cgr.dev` and
`sonarcloud.io` are
all unreachable in this environment, there is no container engine to
build with, and an
invented digest or a `USER` directive that breaks `apk add` would be
worse than the thing it
replaces. Base-image pinning is the same estate-wide decision the owner
already deferred for
action pinning; it should be made once, with the digests resolved
against the real registry.
**Whether the gate goes green is therefore not something I can claim** —
the rating is
computed by SonarCloud from findings I cannot read.

## Hypatia and the deposit job

Both were red at `0e785cc` (the CLI segfaulted, exit 139, so the
`hypatia-findings` artifact
was never produced and "Deposit findings for gitbot-fleet" failed
downstream) and both are
**SUCCESS** at `4025364b`. The maintainer's triage already placed the
crash upstream in
`hyperpolymath/hypatia`, since the reusable `standards@da2c748` workflow
scans #5 and #3
cleanly.

I could not retrieve a single finding from either run: `gh run view
--job … --log`,
`gh api …/actions/jobs/<id>/logs` and the check-runs'
`output.summary`/`output.text` all come
back empty or null. So I am **not** claiming Hypatia found nothing — I
am reporting that its
result is unreadable from the API and that nothing here was changed in
response to it. If
Hypatia raises findings on this branch they need triaging on their own
merits.

## CodeRabbit

Review was skipped on #4: 227 files over the 100-file limit, and no
usage credits. The 227
count came from #4's un-squashed mint history — those files are already
in `main`. This
branch is **98 files** against `main`, under the limit, so the skip's
stated cause does not
apply here. The credit problem is an account matter and is not something
a PR can fix;
`.coderabbit.yaml` was left alone rather than relaxed.

## Community health

`/community/profile` reports **100%**. The real gaps were repository
metadata: the
description still reads `***holding repo - only template for now***`,
and `homepage` and
`topics` are empty. `gh repo edit` returns **HTTP 403 "Resource not
accessible by
integration"** — the installation token can read repo metadata but has
no
`administration:write`. This needs the owner (or a token with that
permission). Suggested
description: *"Validating DNSSEC stub resolver in Zig: wire codec,
chain-of-trust validator,
NSEC/NSEC3 denial proofs, DNS-over-HTTPS transport, and a C ABI with an
Idris2 model.
Pre-alpha (CRG X)."* `homepage` should stay empty until Pages is enabled
— `has_pages` is
false, so a Pages URL would 404.

## Known-failing, by design

* `just readiness` fails, and `just test-all` depends on it.
`docs/status/READINESS.adoc`
grades this component **X (Untested)**. Wiring the recipe to the unit or
replay suite would
report a grade the evidence does not support and let `test-all` print
"safe to merge" on
the strength of it, which CRG v2.0 Principle 4 ("grade as-is today, not
aspirationally")
forbids. The recipe's comment now says so. `just crg-grade` /
`crg-badge` were reading
`READINESS.md`, which this repo does not have — they returned the
fallback grade for the
  wrong reason; they now read the file that exists.
* Not runnable in this environment, and therefore unverified here: `just
*` (no `just`),
  `idris2 --typecheck` and the `abi-seam` job (no Idris2), `ncl`, `bun
scripts/check-action-pinning.js`, Hypatia, `trivy`,
`scripts/check-adoc-renders.sh` (no
`asciidoctor`; it fails closed by design), and `tests/crosscheck/` (no
`ldns-signzone`,
`kskgen`, `nsd`, `unbound`). **No new signed zone was generated**, so
every fixture is a
recorded or minimally rewritten Unbound response. Verified here: `zig
fmt --check`,
`zig build test`, `shellcheck`, `yamllint`, `check-no-placeholders.sh`,
`check-root-shape.sh`, `validate-template.sh`,
`check-template-conformance.sh`,
  `deed-field.sh`.
* The library's own gaps are unchanged and documented: no
Ed448/GOST/SM2, no DNS-over-QUIC,
  DoH is HTTP/1.1 only, no RFC 5011 rollover.

## Honest limits on the new evidence

The tests use the recorded cross-check fixtures, so they cover the 22
zones in
`tests/testdata/crosscheck.traces` and synthetic mutations of them. No
fixture has a signed
zone strictly below an unsigned delegation, and building one needs key
material this
environment cannot generate, so the island tests place the trust anchor
below the insecure
delegation instead — same closest-anchor code path, different key
provenance. None of this
replaces the independent review `docs/architecture/THREAT-MODEL.adoc`
asks for before anyone
relies on this validator.


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

<!-- coderabbit-ai-generated:v1 -->

## Summary by CodeRabbit

* **New Features**
* Added DNS message parsing and encoding, DNSSEC validation with
trust-anchor support, and a validating DNS-over-HTTPS client and
command-line tool.
* Added C interface and Idris2 bindings for validating live queries and
recorded traces.
* Added container support and automated checks for formatting, tests,
builds, ABI consistency, and fuzzing.

* **Bug Fixes**
* Improved handling of DNS decoding, denial proofs, signature and TTL
validation, response checks, and DoH requests.

* **Documentation**
* Added project usage, installation, architecture, threat-model, and
verification guides, along with cross-check and fuzzing reports.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Signed-off-by: Jonathan D.A. Jewell <6759885+hyperpolymath@users.noreply.github.com>
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
@coderabbitai

coderabbitai Bot commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

Add Carrot credits or activate Agent usage billing to use Autofix

Copy link
Copy Markdown
Owner Author

Closing: this pull request's content is on main, and this PR itself can never become mergeable.

Why it cannot be fixed in place. This branch sits on the un-squashed init/repo-init history and has no common ancestor with main — git merge-base origin/main feat/dnssec-library exits 1. PR #3 was squash-merged, so the eight mint commits this branch also carries are present in main as a single unrelated commit. Rebasing would replay those eight into conflicts against their own squashed content; that is why this PR has shown CONFLICTING since before the review cycle started, and it is a property of the history, not of the diff.

Where the work went. main + the thirteen library commits cherry-picked clean (e347949..4025364, zero conflicts), plus the review response, was merged as #6 (squashed to 6b0fb29). A second review cycle over that merged tree raised twelve more findings; eleven are fixed in #7.

All twelve review conversations on this PR are now resolved, each with a reply naming the fix, the commit, and the regression test that guards it. Both P1 findings — insecurity inferred from an unauthenticated RRSIG Signer on the answer path and on the denial path — were fixed, and every one of the seven validator regression tests was confirmed to fail against the pre-fix code before being accepted as a fix.

Two things this PR raised that are still open, and are not fixed by closing it:

  • scripts/check-variant-drift.sh cannot be run at all. The deed's :parent-pin / :template-commit (3100d46b9cfee83317018f1e8244b2fafa9da660) does not exist in hyperpolymath/rsr-template-repo — HTTP 422 from the commits API, reachable from no branch — and :template-branch init/repo-init is gone. Re-pointing the pin and rewriting the path lists to make the gate green would certify convergence nobody has demonstrated, so it is recorded in docs/reports/VERIFICATION.adoc for the estate owner instead.
  • Repository metadata is still wrong: the description reads ***holding repo - only template for now***, and homepage and topics are empty. gh repo edit returns HTTP 403 "Resource not accessible by integration" — the available token has no administration:write. This needs the owner.

Also worth carrying upstream: the deed's (variant (paths …)) clause closed with one parenthesis too many, which ended (repo-deed …) early and left (provenance) a sibling of it rather than a clause of it, so no reader could reach the provenance facts and check-template-conformance.sh failed T1 and short-circuited T2–T4. That is fixed here, but it came from the mint — main carried the same defect — so rsr-template-repo and build/just/repo-init.just's callers should be checked.

Copy link
Copy Markdown
Owner Author

Superseded by #6 (merged) and #7; this branch has no common ancestor with main and cannot be made mergeable. All twelve review conversations are resolved with the fix, commit and guarding test named in each.

auto-merge was automatically disabled October 28, 2026 13:58

Pull request was closed

hyperpolymath added a commit that referenced this pull request Oct 28, 2026
… decoder amplification, CLI exit contract) (#7)

## What this is

The second review cycle. #6 merged the milestone-1 library plus the
twelve findings from #4's reviews; that merge then attracted **twelve
more findings** (seven from Codex, six from CodeRabbit, on `main` at
`6b0fb29`). Each was verified against the code as merged before being
touched — one was already fixed, eleven are fixed here.

`zig build test --summary all`: **18/18 steps, 127/127 tests** (was
123). `zig fmt --check` clean.

## Security

* **A forged SOA owner could reach over a closer trust anchor.** The SOA
owner of an unsigned negative response is attacker-controlled, and three
paths used it to choose which zone got the insecurity check, guarded
only by an ancestry test (`computeZoneStatus`, `nameStatus`,
`proveDenial`). Ancestry is not sufficient: with an anchor between the
hinted zone and the target, an ancestor's insecurity says nothing about
the anchored subtree below it. All three now apply the same
closest-anchor refusal the RRSIG signer check already used.
Regression test *"negative: a forged SOA owner cannot reach over a
closer island anchor"* builds exactly CodeRabbit's trigger — anchors =
root plus a DNSKEY anchor at `www.island.test.`, query
`x.www.island.test. A`, unsigned NXDOMAIN whose SOA names
`island.test.`, all signatures and NSEC records stripped — and asserts
the answer is not `insecure`. **Confirmed to fail against `main`'s
validator**, where it returned `insecure`.
* **DS digest downgrade.** `usableDs` dropped SHA-1 when anything
stronger was present but left SHA-256 and SHA-384 both usable, so
`keysFromDs` accepted whichever matched first: if the SHA-384 DS failed
and a SHA-256 DS matched, the child was accepted through the weaker
digest. That is the downgrade RFC 4509 §3 forbids, extended to SHA-384
by RFC 6605 §5. Only the strongest supported digest class present is
kept now.
* **Work amplification in the decoder.** `readRr` sized every record's
expansion buffer at `rdlen + 4*255`, opaque types included. ~5,950
minimal 11-octet RRs fit in one 65535-octet message, so an untrusted
upstream turned each message into ~6 MB of arena; `Session.fetch` caches
every fetched message, so one validation at the default budget could
hold hundreds of MB. Headroom now comes from the layout's actual name
count (no supported layout has more than two) and is zero for opaque
types. Same class as the KeyTrap amplification the threat model puts in
scope.
* **The CLI reported configuration errors as "insecure".** An error
escaping `main` becomes exit status 1, which `dnssec-stub` documents as
*insecure*. A missing `--anchors` file, an unparseable trust anchor, a
refused `http://` `--doh` URL, a bad `--ca`, or an unwritable `--record`
file each reported a proven-insecure verdict to any script or harness
reading the status. Those are now mapped to the documented 4.

## Correctness

* `. DS` NODATA was always `bogus`/`denial_missing`: `strict_parent`
asks for a signer that is a *proper* ancestor of the target, and the
root has none, so the root's own authenticated NSEC/SOA proof was
discarded. At the root the signer can only be the root itself.
* Negative answers below a proven-insecure delegation were bounded only
by the denial proof's lifetime, ignoring the SOA negative TTL, so a
forged NXDOMAIN could be cached for the much longer DS/NSEC lifetime.
Now also bounded by `min(SOA record TTL, SOA MINIMUM)` per RFC 2308 §5,
and by zero when the response supplies no cacheable SOA.
* `formatRr` emitted `(256-octet key)` for a DNSKEY and `(types)` for
the NSEC/NSEC3 bitmaps. Neither is RDATA, and both the CLI and the C ABI
promise presentation-format answer records. DNSKEY now emits base64 (RFC
4034 §2.2); the bitmaps are enumerated as mnemonics through a new
allocator-free `TypeBitmap.fill`; an oversized key falls back to RFC
3597 generic form for the *whole* RDATA. My first attempt wrote the
flags before that decision and produced `256 3 8 \# 2048 …`, which is
neither form — the new test caught it, which is the point of having it.
* `parseTtl` accumulated compound TTLs in plain `u64` and overflowed
before its final range check: a panic in Debug/ReleaseSafe and a
wrapped, wrongly small TTL otherwise, from the public zone parser.
Accumulation is checked and bails as soon as `u32` cannot hold the sum.
* `parseRrsigTime` accepted impossible calendar dates (every month ran
to day 31) and `daysFromCivil` normalises rather than fails, so
`20230231000000` was silently encoded as a March timestamp. The day is
validated against the month and both century leap-year rules.
* `build.zig.zon` shipped only `build.zig`, `build.zig.zon` and `src`,
so `zig build test` in a package fetched through the Zig package manager
failed on missing sources while the step was still advertised. `tests`
is now in `.paths`.
* `just crg-grade` and `just crg-badge` **could never run**. `just` does
not treat `$$` as an escape — it passes both octets to the shell, where
`$$` is the PID — so `grade=$$(grep …)` was a bash syntax error and both
recipes exited 2. Verified with `just` 1.59.0 on a minimal repro before
changing anything. They use `$` now, and read
`docs/status/READINESS.adoc`, which is where this repo keeps its
assessment; they previously read `READINESS.md`, which does not exist
here, so they returned the fallback grade for the wrong reason. Both now
run: grade `X`, badge emitted. The upstream contractile copy carries the
same `$$` defect.

## Not fixed, with reasons rather than silence

* **The negative-cache-TTL bound has no test.** No recorded fixture has
an SOA `MINIMUM` below its own denial proof's TTL, so the bound never
binds in the corpus and a test would pass with or without the fix. It is
inspection-only; generating a fixture needs signing material unavailable
here.
* **The DS digest-preference change is also inspection-only**, for the
same reason: no fixture publishes a DS RRset with two supported digest
types.
* **`check-variant-drift.sh` still cannot run.** The deed's
`:parent-pin` / `:template-commit` (`3100d46b…`) does not exist in
`hyperpolymath/rsr-template-repo` — HTTP 422, reachable from no branch —
and `:template-branch` `init/repo-init` is gone. Re-pointing the pin and
rewriting the path lists to make the gate green would certify
convergence nobody has demonstrated. Recorded in
`docs/reports/VERIFICATION.adoc` for the estate owner.
* **Base-image digest pinning and the container stages' user model** are
left to the estate-wide pinning decision the owner already deferred for
action pins: no registry and no container engine are reachable from
here, so an invented digest or a `USER` directive that breaks `apk add`
would be worse than what it replaces.
* **Repository metadata is still wrong.** The description reads
`***holding repo - only template for now***`; `homepage` and `topics`
are empty. `gh repo edit` returns HTTP 403 "Resource not accessible by
integration" — the token has no `administration:write`. This needs the
owner.
* `just readiness` still fails by design (CRG is X, Untested), so `just
test-all` fails by design. Wiring it to the unit or replay suite would
report a grade the evidence does not support.

## Also corrected

`docs/reports/VERIFICATION.adoc` claimed the container run covered "all
110 tests" without saying it predates the review cycles, and graded
DNSKEY/below-root anchors DESIGNED with "only `TrustAnchors.closest` is
unit-tested" although three replay tests now exercise `anchoredKeys`
with an island anchor. Both rows now say what is actually true,
including that anchors *above* an untrusted chain and RFC 5011 rollover
remain untested.


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

<!-- coderabbit-ai-generated:v1 -->

## Summary by CodeRabbit

* **Bug Fixes**
* Improved DNSSEC validation for unsigned negative answers, root-level
denial proofs, and DNS record sets containing multiple digest types.
* Bound negative-answer cache lifetimes to the relevant SOA TTL values.
  * Corrected DNS record formatting for DNSKEY, NSEC, and NSEC3 records.
* Rejected overflowing TTLs and invalid RRSIG calendar dates during
parsing.
  * Improved DNS record expansion sizing for supported record types.
* **CLI**
* Setup and I/O failures now print an error and return a nonzero exit
status.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Signed-off-by: Jonathan D.A. Jewell <6759885+hyperpolymath@users.noreply.github.com>
Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
hyperpolymath added a commit that referenced this pull request Nov 5, 2026
…ft-gate record (#8)

## Summary

#6 and #7 closed every finding from #4's reviews. Codex's review of the
C ABI seam (#5) raised four findings, and #6
fixed the P1 (lossy presentation text). This PR closes the rest:

- Two of them are fixed here.
- The third (`validate-template.sh` and the deleted FFI files) is
already handled on `main`: the validator honours the variant contract,
and `just e2e` passes.

It also fixes:

- two more presentation-format defects;
- the template residue the mint left in the user and maintainer guides;
- a record in `VERIFICATION.adoc` that called the variant-drift gate
unrunnable, although it runs and passes.

It also addresses the review findings raised on this PR itself.

## Changes

- **`925681d` fix(abi): empty the text buffer before any argument is
checked.**
- **Defect:** `zig_dnssec.h` says text is "set to the empty string
first". But four early rejects returned before that happened: a NULL
exchange function, a NULL trace, a NULL verdict pointer and an
unparseable trace. A caller reusing its buffer could still read the
previous answer after a non-OK status.
  - **Fix:** one `reset()` now runs first in every entry point.
- **Test:** the bad-argument test used to *accept* a stale buffer
(`text[0] == 'X'`). It now requires the empty string for every case,
including a NULL verdict pointer and a NULL exchange function.
- **`1c3df7e` fix(abi): refuse a linked library of another ABI
version.**
- **Defect:** `Abi.Foreign.validateTrace` handed an ABI-v1 verdict
buffer to whatever `libzig_dnssec` was loaded.
- **Fix:** it now compares `linkedAbiVersion` with `abiVersion` first,
and returns `BrokenContract` on a mismatch without calling the library.
- **`046c710` fix(wire): write an empty NSEC3 salt as `-`.**
- **Defect:** `formatRr` printed an empty field, so NSEC3 answers with
the salt RFC 9276 recommends were not parseable presentation format (RFC
5155 §3.3).
- **`54b63a2` and `3d6bbed` docs(onboarding): describe only what the
repository actually wires.**
- **Both quick starts:** they now describe the library, the
`dnssec-stub` CLI (how to run it, its output, its exit contract 0–4) and
the C ABI from `zig build ffi`.
- Idris2 0.7.0 is listed for `just build` and `just test`, with the
Zig-only commands given separately.
- The template's non-existent or unwired flows are gone: `stapeln-*`,
`just install`, a `config.toml`, multi-instance deployment and "Rsr
Template Repo".
- **`build/guix.scm`:** the synopsis and description now describe this
library.
  - **Deed:** the variant contract declares the newly diverged files.
- **`f4b5525` fix(wire): stream NSEC/NSEC3 type bitmaps instead of
truncating them.**
- **Defect:** `TypeBitmap.fill` dropped every type past a 128-entry
buffer without saying so.
- **Fix:** it is replaced by a buffer-free `TypeBitmap.iterator`, which
both formatters stream.
- **Docs:** the drift-gate instructions add `git fetch --unshallow` for
shallow clones.
- **`7088945` docs: CHANGELOG and VERIFICATION.**
  - **CHANGELOG:** each fix above, with its test.
- **Drift-gate correction:** the deed's parent pin `3100d46` is this
repository's own root commit, and its tree `2c01b6f` is exactly the
deed's `(provenance :template-tree)`, so a worktree of it is the parent
at the pin. The finding now says how to run the gate against it.
- **Still for the owner:** the template repository no longer serves that
commit or branch.

## RSR Quality Checklist

### Required

- [x] Tests pass: `just test` and `zig build test` (18/18 steps, 130/130
tests on f4b5525)
- [x] Code is formatted (`zig fmt --check build.zig src tests`)
- [x] Linter is clean (`just quality`: "All quality checks passed!")
- [x] No banned language patterns
- [x] No `unsafe` blocks without `// SAFETY:` comments (none added)
- [x] No banned functions: the Idris module stays `%default total` with
no `believe_me`
- [x] SPDX license headers present on all modified source files
- [x] No secrets, credentials, or `.env` files included

### As Applicable

- [x] `CHANGELOG` updated
- [x] Documentation updated for user-facing changes (quick starts,
`VERIFICATION.adoc`)
- [x] ABI/FFI changes validated: `seam_test.zig`, `abi_test.zig` and
`just abi-e2e` all run

## Testing

Run locally with Zig 0.17.0 and Idris2 0.7.0 (built from `27780073`).
Each new or tightened test was first run against the code it guards:

- **Text-buffer test**, against the old `main.zig`: fails with `expected
0, found 88` (the stale `'X'`).
- **ABI-version check:**
- `idris2 --typecheck src/interface/abi.ipkg` passes, and `just abi-e2e`
gives 9 checks, 0 failed.
- **Negative control:** with the binding temporarily set to expect ABI
2, all 9 checks fail, because the calls are refused before they reach
the library. Reverted afterwards.
- **NSEC3 empty salt:** the new test fails on the old formatter and
passes now.
- **Type bitmaps:**
- A bitmap setting all 256 types of window 0 fails on the old code at
the 128th type and passes now.
  - An iterator test covers windows 0, 1 and 255.
- **CLI and C ABI install layout:** checked with a fresh `--prefix`
each. `zig build` installs `bin/dnssec-stub`; `zig build ffi` installs
`lib/libzig_dnssec.{a,so}` and `include/zig_dnssec.h`.
- **Repo gates, all pass:**
- `just validate`, `validate-coapt`, `validate-claude-md`,
`validate-repo-map` and `validate-state`
  - AsciiDoc render, lock-sync and action pinning
  - `just test && just quality`
- **Variant-drift gate:** `scripts/check-variant-drift.sh <worktree of
3100d46> .` passes. A control that edits one undeclared file fails it.
- **CI and review on f4b5525:** CI green, SonarCloud quality gate
passed, Codex reports no findings.

Not verified here: the container build (no container engine in this
environment); the Containerfile is not touched.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_01J4QvDjJMgMQkerYkRoTr2V

---------

Co-authored-by: Claude <noreply@anthropic.com>
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.

2 participants