Skip to content

Strip narration comments and close the doc-coverage gaps #41

Closed

Description

@FAZuH

Part of the whole-repo quality audit (2026-09-30). Comment hygiene per @antislop-code, doc coverage per docs/dev/standards.md §5.1-§5.4. No code behaviour changes.

What to build

Comments that only earn their line by explaining why; every .rs file carrying its mandated //! module doc; every real pub item documented.

Deletions (narration, dividers above the name they repeat, decision-log, stale history)

  • 48 test-module // ── fn_name ── dividers, each sitting directly above the fn it names, across iptables.rs, policy_route.rs, dns_parser.rs, models.rs, auto-discover/daemon.rs, forwarding.rs, lab-lib/docker.rs, api.rs, natmap/docker.rs, tests/auto_discover/mod.rs. Keep the two that carry a reason (iptables.rs:94 explains the pure-builder split, iptables.rs:1113 explains why the manager is not tested) and the §5.3-mandated top-level dividers.
  • 22 line-by-line narrations of shell arrays in tests/natmap_docker.rs, plus a parenthetical change-history aside.
  • 19 narrations in crates/natmap/src/iptables.rs, including one stale reference: // cmd_success logs on fail names a function that does not exist (it is run_success), and one wrong comment: // Delete by line number from bottom up describes behaviour the code does not have.
  • 14 narrations of match arms and asserts in crates/auto-discover/src/daemon.rs.
  • Over-explained blocks in crates/lab-lib/src/port.rs (a 7-line load-check preamble, a 5-line retry explanation) and three decorative box banners.
  • 9 narrations in crates/natmap/src/api.rs, including a 4-line block duplicated verbatim at two sites.
  • 7 in crates/natmap/src/daemon.rs, 6 in crates/lab-lib/src/docker.rs, 4 in src/main.rs, 8 of history in protocol.rs and docs/dev/modules.md.
  • Seven /// doc comments that only restate the signature or the field name.

Additions (the standards the code currently misses)

  • 23 files missing the //! module doc §5.1 mandates: natmap/src/{completions,api,consts,policy_route}.rs, auto-discover/src/{daemon,config,cli}.rs, src/{consts,cli}.rs, natmap/tests/{model,cli}.rs, tests/natmap_docker.rs, tests/cf2ansible.rs, and all eight tests/auto_discover/*.rs.
  • 19 real pub items missing /// per §5.2, concentrated in auto-discover/src/config.rs (17), natmap/src/{daemon,api,policy_route,models}.rs, auto-discover/src/daemon.rs, lab-lib/src/{lib,consts,port,protocol}.rs, src/{lib,cmd/mod}.rs, natmap/src/{cli,completions,consts}.rs, and the tests/auto_discover/mod.rs helpers.
  • crates/natmap/src/command.rs is named explicitly in §5.3 and exceeds 200 lines, but has zero section dividers. Add them at the natural boundaries.

Corrections to stale docs

  • docs/dev/modules.md:42 cites natmap/src/port.rs and auto-discover/src/port.rs; neither file exists.
  • docs/dev/modules.md:82,245 carry change-history parentheticals.
  • docs/dev/testing.md:53 claims 88 inline unit tests. The real count is 421 tests and roughly 9761 test lines. Fix the number.

Acceptance criteria

  • Every remaining comment explains why, verified against §5.4
  • Every .rs file starts with //!
  • Every pub item outside a lib.rs module list has a ///; the pub mod lines in the four lib.rs files are documented too
  • docs/dev/modules.md cites only files that exist
  • No production code changed

Blocked by

None (can start immediately).

Estimated: -132 comment lines, +docs.

Activity

  1. added 2 commits that reference this issue on Oct 1, 2026
    745fa3a
    e2b6c07
  2. FAZuH commented on Oct 1, 2026

    @FAZuH
    OwnerAuthor

    Landed on v0.2 as 745fa3a, merged e2b6c07. Closed by hand: a closing keyword only fires from commits reaching the default branch.

    No executable code changed, and that is verified rather than asserted

    Stripping //, /// and //! from every touched file and comparing the whitespace-normalised remainder against HEAD leaves 39 of 40 .rs files byte-identical. The one that differs does so only by a # shell comment inside a raw string in tests/auto_discover/preserve_src_ip.rs, which is not Rust.

    Line count, measured

    comment lines removed 216
    comment lines added 169
    net −47
    repo total, before 1404
    repo total, after 1357

    The additions are not optional. standards.md §5.1 and §5.2 mandate 21 //! module docs and 43 /// on real pub items, so they were not trimmed to flatter the net number. Each is one line; the eight that run to two carry a second fact.

    Two opposite actions on the same pattern, and why

    • Added four // --- Section --- dividers to crates/natmap/src/command.rs, which §5.3 names explicitly and which is 434 lines with none. They name a section, so they navigate the file.
    • Deleted 48 dividers that sat directly above the exact fn they named. A name above the thing it names repeats the next line.

    Three survive, all earning their line: iptables.rs:94 and policy_route.rs:14 name the pure-builder split and why it exists, and lab-lib/src/docker.rs:298 names a fixtures group. Zero box-drawn ==== banners remain in the tree.

    Kept against the ticket's instruction

    • iptables.rs rule_exists: the ticket called // cmd_success logs on fail stale, which is correct. It was replaced, not deleted, with the reason the helper uses run over exec: -C exits non-zero when the rule is absent, and that is the answer rather than a failure.
    • flush_chain: a two-line note added on the let _ = swallow, which is deliberate and reads as an oversight without it.
    • lab-lib/src/port.rs: retry preamble 5 lines to 3, load-check note 7 to 4. The "load check, not reproduction" distinction is the reason that test can never be red.
    • natmap_docker.rs loopback-MASQUERADE header: left intact. It is the packet-level explanation of why the rule exists and the bug it reproduces.

    Stale items from earlier tickets, folded in

    Seven, all the same class of defect: models.rs:154 (claimed preserve_src_ip skips a MASQUERADE on a DNAT mapping, which has none — that is the hairpin path, and HairpinConfig::lan_cidr at :196 already said it correctly); four policy_route.rs dividers naming functions that no longer exist; docs/dev/testing.md:179 ("& sleep 2" has been false since #47); docs/dev/testing.md:178 ("--test-threads=1" is enforced by nothing — now says so and cites #54); preserve_src_ip.rs:206; and docs/dev/modules.md:42.

    Verification

    ./dev.sh format, ./dev.sh lint, ./dev.sh test all exit 0. 463 passed, 0 failed, 10 targets, at loadavg 1.41/2.67 before and 3.02/2.92 after.

    The 462 figure I quoted in the brief was wrong. It was arithmetic on per-ticket deltas rather than a measured run, and the honest total is 463. It was caught by stashing the diff and measuring the base at the same 463, which also confirms this change did not move the count. Recording it because a number I asserted without measuring is exactly the error this batch has been correcting.

    Skipped, with a ticket

    The per-file test counts in docs/dev/testing.md now claim 45 integration, 94 Docker and 5 doc tests, and are further out of date than they were. Restating them needs a measured run per target, not a comment pass, and a wrong number is worse than a stale one. Filed separately.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    ready-for-agentFully specified, ready for an AFK agent

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions