Skip to content

feat(ast): resolve C-family Doxygen documentation owners #1671

In review

Description

@dekobon

Objective

Turn existing C-family Doxygen recognition into useful owner associations without overstating macro, conditional or named-target resolution.

Umbrella: #1654 · Planning ID: D14
Completion prerequisites: D25: #1662, D26: #1663

LANG coverage: C, Cpp, Mozcpp, Objc.

Development can start after D05/D06 interfaces exist. Completion is blocked by D25/D26 infrastructure and requires this adapter's own conformance cases, scaling probes for new work and fuzz seeds.

Shared architecture and constraints

Follow the umbrella's shared contracts. AST recognition serves two consumers: exact legacy convention/coverage streaming for root LOC, and richer source documentation for owner lookup and local text. Source attachment, profile eligibility and physical metric ownership are separate. Preserve the current legacy candidate view before run selection, coverage ordering and metrics-only early exits, including existing logical-line precomputation where required.

Documentation fragments, logical documents and convention-qualified owner edges have separate identities. Source offsets refer to the actual parsed buffer and included ranges. The index is caller-owned, immutable and source-bound; lookup validates tree/index identity. Complete text means local decoded/cleaned content with forward source mapping, not inherited or generator-expanded documentation.

Implementation touchpoints

  • src/metrics/npa/{cpp_declarators,cpp_first_word,cpp_annotations}.rs: current recovered-declaration evidence to inspect, not metric policy to import into AST.
  • src/metrics/loc/continuation.rs, loc/python.rs and src/spaces/compute.rs: current logical-line indexes/memos and metric coverage ordering; reuse structural facts without introducing an AST-to-metrics dependency.
  • big-code-analysis-ast/src/node/ancestors/{chain,siblings,folds}.rs: current derived-chain, sibling-record and memo implementations.
  • big-code-analysis-ast/src/roles/c.rs, big-code-analysis-ast/src/roles/cpp.rs, big-code-analysis-ast/src/roles/mozcpp.rs, big-code-analysis-ast/src/roles/objc.rs: current shared role recognition; read the contributor reference in roles/mod.rs.
  • big-code-analysis-ast/src/roles/doc_tests/: existing per-language recognition fixtures; add independent owner/text expectations.
  • big-code-analysis-ast/src/lang_helpers/doxygen.rs
  • big-code-analysis-ast/src/checker/doxygen_doc_binding.rs
  • big-code-analysis-ast/src/checker/{c,cpp,mozcpp,objc}.rs
  • big-code-analysis-ast/src/documentation C-family adapter
  • big-code-analysis-ast/src/c_macro.rs

Implementation steps

  • Resolve C-family documentation using current id projections and source evidence for recovered multi-piece members, preserving existing logical-line metric precomputation.
  • Build owner resolution on DoxygenRow/id-keyed candidate fragments with explicit context requirements and existing no-reentry memo protocol.
  • Support leading/all-kept blocks, trailing member docs, in-body descriptions, declaration-signature docs, standalone file/page/group/explicit-target blocks and gathering.
  • Resolve previous-member and individual declarator/slot owners, preserving wrapper evidence and shared-document edges.
  • Record conditional/recovery targets as candidates until source proves a concrete owner; current contains-any-declaration boolean is insufficient to select a branch.
  • Extract only structural naming metadata needed for association. Queue forward names and finalize with adapter-defined same-file scope/kind/signature keys; unresolved overloads/missing/ambiguous targets remain explicit.
  • Unify gathered and unbound evidence without losing the gatherer or duplicating text/coverage; keep legacy emissions in their physical spaces.
  • Resolve parsed-source names after masking; comments retain raw text. Do not infer name_masked from dollar bytes or invent original names. Retain positional records even when a named link cannot resolve.
  • Preserve per-question memoization for nested preprocessor checks and separate source/legacy view answers. Recheck relevant fix(loc): tool-vs-bca doc-comment attachment divergences left by #1613 #1646 cases, keeping any changed policy explicit.

Tests and edge cases

  • Quoted/CDATA structural tags, valid versus unresolved explicit targets, typed macros and member pointers, split virtual methods with intervening preprocessor lines, thread-safety annotation tails, and chained comment continuation origins.
  • Conditional per struct depth and nested conditional chains, ERROR wrappers, aliases, member-pointer data versus method templates, and current continuation/preprocessor masking distinctions in all four grammars.
  • All four grammars: leading docs on functions/types, trailing docs on members/parameters, in-body description and signature placements.
  • Multi-declarator ownership, anonymous/slot forms and Objective-C methods/properties/protocols.
  • @file gathers older blocks, line gatherer joins, multiple structural blocks and EOF gatherer.
  • Forward explicit name, duplicate/overloaded names, missing symbol and conditional alternatives; no first-wins or all-candidates-as-resolved behavior.
  • Source with preproc masking versus caller-written dollar spelling: positional association survives; unavailable original-name link stays unresolved.
  • Deep nested #ifdef with source/legacy queries in both orders, plus included-range gaps and local recovery.
  • Exact selected source spans and physical DLOC row identities; Cpp/Mozcpp parity for constructs their grammars share.

Use independently specified expected owners, fragment counts/order, byte ranges, text and availability. Pair them with separate legacy metric assertions where relevant. Do not sort/trim observed results, rely only on facade/delegate equality, or accept generated snapshots without an expected-value anchor. Use verbatim source for EOF/CRLF cases. Perturb the decision-bearing expression and confirm the intended assertion fails; use the maintained utils/perturb.py only on tracked, clean targets, recording or stashing real work first. Multi-target cargo runs require --no-fail-fast; include the mutated crate and dependent crates before claiming a unique guard. Keep irreproducible fixtures/manifests in tests, maintained utils or an issue attachment, following the “Temporary files” and “Evidence for a claim” rules in AGENTS.md.

Acceptance criteria

  • C/Cpp/Mozcpp/Objc all provide useful declaration/text results with honest uncertainty.
  • No new symbol-table or macro-expansion promise; no metric owner reassignment.
  • Gathering, trailing resolution, many-owner output and conditional depth have discriminating tests/probes/seeds.

Verification and completion evidence

  • Follow current docs/development/testing.md and docs/development/grammar_dispatch.md. Assert deterministic work counters exactly and measure both cached-state computations and slot searches where relevant.
  • Use the current pre-implementation base and grammar pins; completed fixes and documented retained limitations have different expected outcomes. Do not restore an obsolete baseline to make a migration pass.
  • Follow current role-census/role-coverage/role-bypass requirements and applicable role-parity-corpus checks. Preserve independent semantic fixtures; refresh .role-coverage-observed.txt when any sampled corpus gitlink changes.
  • Put revisions, exact commands, tool versions and durable input links beside parity/coverage claims; host-local evidence paths are not citations.
  • Recheck current source and the prerequisite contracts/baseline applicable to this issue; record intentional changes to the premises.
  • Run focused production-path tests and affected language siblings. Use package-isolated -p big-code-analysis-ast / -p big-code-analysis feature builds; workspace feature unification is not isolation.
  • Run the repository's required checks for the touched surfaces. For implementation changes: make worktree-setup, make pre-commit read from its BCA_GATE: verdict, and relevant test-language membership comparison. Add scaling and chain-audit checks for traversal changes; run make fuzz-check and seed replay for fuzz changes.
  • Record exact test/perturbation/probe evidence in a completion comment and update this body. Review unexpected metric drift before snapshot acceptance; follow baseline and integration-submodule discipline if behavior deliberately changes.
  • Land public API documentation, re-export/stability review and changelog entries with the originating API change. Keep unrelated CLI/web/Python surfaces outside this issue unless explicitly listed.

Current implementation notes (2026-11-17)

Revalidated against 91087f52f5d4a58e31ae320851351990f1436411. These notes replace the November 4 implementation notes; the earlier review is retained in this issue’s comment/edit history. Relevant work: PR #1824, PR #1835, PR #1838, PR #1856, PR #1909, PR #1928, PR #1931, PR #1933.

  • Doxygen quoted-text/CDATA suppression and id-based conditional/container/skip projections are implemented. Reuse their grammar-id and no-reentry tests; do not recreate the old string membership scans.
  • The C-family bare-row class now settles once per logical line through the root LOC index before physical gap accounting. A parent gap can be visited before the child tokens that determine it. Preserve current legacy timing/precomputation rather than assuming one final verdict per node visit.
  • Recent C++/Mozcpp fixes distinguish parenthesized member pointers, typed macro calls, split virtual methods and trailing thread-safety annotations. The readers live in root npa/cpp_declarators.rs, cpp_first_word.rs and cpp_annotations.rs. They are metric source readings, not authoritative symbol resolution; factor only genuinely shared structural evidence into AST if needed.
  • A source owner may span recovered sibling declarations, possibly with comments or preprocessor lines between the pieces. Keep ordered source pieces and explicit ambiguous candidates, not two invented method owners or an attached annotation-as-member.
  • Preserve Doxygen's shortened parent-only context only for its existing questions; nearest-level/depth-aware owner queries need whole ancestry.

Unit 2 integrated (bf5282d3)

  • Integrated on feat/1654-documentation at bf5282d3 (merging feat/1654/1671-c-family-unit2: 2e28ee2c and 84f3b28a).
  • Separates @file/\file gatherer comments before declarations, attaches trailing enum comments after a comma, and projects single-declaration C++ template_declaration and linkage_specification wrappers under Profile::Doxygen across C, Cpp, Mozcpp, and Objc.
  • make pre-commit (BCA_GATE: pass), make bench-source (0 performance failures), anchor_check.py (manifests=71 cases=1631 problems=0), and all 5 perturbation sweeps (76/76 total caught) passed.

Activity

  1. added
    enhancement
    on Oct 21, 2026
  2. dekobon commented on Nov 4, 2026

    @dekobon
    OwnerAuthor

    Plan refreshed against current main

    Updated this issue body after reviewing changes since #1654 was filed, through 07822c69211fe851c452ac6c0ebbd99cf92589a5. Relevant PRs: PR #1769, PR #1774, PR #1804.

    • Doxygen entry recognition is now id-keyed roles/c_family.rs fragments composed via DoxygenRow. Preserve old_names_are_the_row alias coverage and the ERROR/context logic around the row; do not reconstruct the old kind-name match.
    • conditional_declares uses MemoQuestion::ConditionalDeclares and a one-entry parent context. It is deliberately exact only for gates that inspect at most parent. A new depth-reading source-owner gate needs a separate appropriately scoped context; blindly copying the full chain per conditional was measured quadratic.
    • Preserve the two defenses against reentering conditional analysis and tests on both cached and uncached paths. Add independent conditionals at growing struct depth, not just a single nested #ifdef chain.
    • C++ member templates/member pointers changed in PRs fix(npa,getter,npm): batch fix for #1299, #1706 and #1401 #1721/fix: batch 2026-11-03-2 (8 issues) #1804. Reuse AST c_declarator facts where relevant to owner normalization; do not infer declaration ownership from old NPA/NPM outputs or duplicate metric policy.
    • fix(metrics/loc): C family, Ruby, Elixir lose a bare \ row #1801 continuation-row gap remains open for the C family. Source/legacy baseline and mapping behavior need explicit treatment; positional records must survive unresolved masked-name links.

    The original source-documentation scope remains. New tests and current integration touchpoints are in the body; acceptance checkboxes remain open. This is source/history analysis, not a claim that the feature or new validation has run.

  3. dekobon commented on Nov 18, 2026

    @dekobon
    OwnerAuthor

    Updated this issue body against 91087f52f5d4a58e31ae320851351990f1436411 after the November 4 review. Resolve C-family documentation using current id projections and source evidence for recovered multi-piece members, preserving existing logical-line metric precomputation.

    Added tests: Quoted/CDATA structural tags, valid versus unresolved explicit targets, typed macros and member pointers, split virtual methods with intervening preprocessor lines, thread-safety annotation tails, and chained comment continuation origins.

    Evidence: PR #1824, PR #1835, PR #1838, PR #1856, PR #1909, PR #1928, PR #1931, PR #1933. The dated body section replaces stale implementation notes and records current source paths and prerequisite outcomes. Original extraction acceptance criteria and issue status remain open; this was source/history review, not an implementation or gate run.

  4. dekobon commented on Nov 23, 2026

    @dekobon
    OwnerAuthor

    #1646 evidence/disposition handoff for #1654: cases D1–D8. See the current ledger and reproduction packet for exact fixture bytes, source/tool versions, attachment versus publication, and reopen triggers.

    D1–D8: self-contained NS_ENUM expansion documents ExampleOne in nested XML, but it is not the historical Apple recovery shape; the guarded-extern initial fixture agrees and the after-guard fixture differs; #elifdef is unsupported by the tested Doxygen preprocessor.

    These are version/configuration-qualified observations and retained legacy DLOC readings, not approval to change DLOC or substitute characterization for independent source-owner/text expectations. The adapter should explicitly disposition these cases under its existing contract. No new acceptance item is presumed complete by this comment.

  5. dekobon commented on Nov 23, 2026

    @dekobon
    OwnerAuthor

    #1646 v2 correction/verification, current ledger and reviewed evidence (SHA256 c9fa2a647da033623d333bc7ad9a420a2fe2efd4bb106adfca59f38d04d10518; supersedes the previous gist). Corrected D1–D8 controls: D2 in Mozcpp parses the valid macro terminator as the same missing-; declaration as the invalid case plus a following alone_macro; D3 unexpanded ObjC XML has NS_ENUM:d in inbodydescription, and no standalone fixture shares historical Apple initializer_list recovery; D5 attachment must not be inferred from bare XML member presence, so paired INTERNAL_DOCS NO/YES controls were added; D8 now has #elif defined(X) runs with X defined and undefined (documented f:d versus none). Legacy DLOC is unchanged; this is a disposition handoff, not an approved source fix.

  6. dekobon commented on Nov 23, 2026

    @dekobon
    OwnerAuthor

    #1646 v3 final evidence correction: ledger, packet, SHA256 0373a85f863f1c1334822fccefd59e049392cb58f09de1ce3b69dfc897fa2ed2. Supersedes older evidence links. D7 correction: the trailing doc at the end of extern "C" binds across the linkage body even without #ifdef (bca 0/1, Doxygen g:d); a namespace body is a real barrier, a flat control agrees. Reopen for linkage_specification transparency in Cpp/Mozcpp, not preprocessor support. D2 has a second valid DECL(x) twin (bca 0/1 all dialects vs Doxygen x:d with expansion; C/Objc macro_type_specifier+missing ;, Cpp/Mozcpp call expression+missing ;). D3 unexpanded ObjC NS_ENUM puts d in function in-body XML; none of the standalone controls is the historical Apple initializer_list recovery shape. These are profile-qualified observations, not authorization to change legacy DLOC; keep source-owner/text expectations independent.

  7. dekobon commented on Nov 25, 2026

    @dekobon
    OwnerAuthor

    Unit 1 (test-only) is integrated locally

    Unit 1 pins what the production collector already does for C, C++, Mozcpp and Objective-C under the Doxygen profile and adds a legacy guard. It changes no production code. It is merged into the local integration branch feat/1654-documentation as 31279411b17341bf9004b19f922b00a2c8f4bab1 (not pushed; the issue stays open).

    Commits on feat/1654/1671-c-family-documentation:

    • 557d60b2 test(documentation): pin Doxygen owners and text for the four C-family variants
    • 11f301ab test(loc): guard C-family documentation rows before owner and conditional work
    • 7967cca1 test(documentation): assert the capability and the absent qualifications
    • 049b4e3a merge of the integration head that then held the Go unit (feat(ast): associate Go documentation groups with declarations #1672)

    What it adds: 39 tests in big-code-analysis-ast/src/documentation/collector/c_family_tests.rs (38 cases across the four variants, each through both entry points, expectations written before the collector was observed), one root-crate test with 47 legacy LOC rows, and two perturbation manifests (22 + 2 deliberate defects).

    Evidence at the merged head 049b4e3a

    Check Result
    make pre-commit one verdict line, BCA_GATE: pass (gate=pre-commit); nextest 7,873 run, 7,873 passed, 4 skipped
    python3 -B utils/perturb.py utils/documentation-c-family-unit1-perturb.json 22 of 22 caught; 200 of 200 named tests fail
    python3 -B utils/perturb.py utils/documentation-c-family-unit1-legacy-perturb.json 2 of 2 caught
    make check-test-lang-gates-compare COMPARE_REF=3296fd8d… OK — no test lost a build
    Code review Astra, Fable and Argon: APPROVE in round 1 at 7967cca1, and each confirmed the merge commit 049b4e3a

    The one merge conflict was in src/metrics/loc/documentation_tests.rs, where this unit and the Go unit each append a test. Both tests are kept unchanged, in integration order.

    What an audit found before review

    Every test could fail. The compared view read neither the qualification records nor the capability of the index, while two comments said the tests compare everything the index publishes. A temporary defect that gave every @fn document a wrong Reference record passed 39 of 39 tests. The third commit asserts both values and corrects the comments; the same defect now fails the @fn test of each variant.

    Pinned as today's answer, for later units to change (decision D4)

    • A block before #if: one unresolved association with no owner.
    • A block inside a function body.
    • A trailing block after a declarator's comma.
    • Declarations inside an include guard: Unresolved(Conditional).

    Each is marked in the test as pinned, not as the design.

    Carried to the next C-family unit

    • Both manifests of this unit end without a final line feed.
    • Node queries for slots and for pending conditionals are not asserted for these sources.
    • No case of this unit has a retained candidate, so a leak of retained candidates under default options is not visible here.

    Not delivered by this unit

    Any production change (ledger items D1 to D8), templates, linkage wrappers, macros that wrap declarations, operators, destructors, parameters, recovery shapes, fuzz seeds, bench workloads. No Doxygen or clang run was made for this unit after the evidence was prepared.

  8. dekobon commented on Nov 27, 2026

    @dekobon
    OwnerAuthor

    Unit 2 integrated (bf5282d3)

    • Merge commit: bf5282d3 (tree aa3e74f6) on feat/1654-documentation, merging feat/1654/1671-c-family-unit2 (2e28ee2ce5ea9cbebe6a943660ab42a1d0a36ac7 and 84f3b28ace7639fe76819843d586b1a98c56b234).
    • Specification & design review: UNIT2_SPEC_R3.md (a3c80fa7d3073714f49593274186bc29bc88c6a6442d2ae3f798a6866d141ee3) + ADDENDUM_R3.md (30c939d4daa820a4da9148917c002a3e702bfb1fbbd63d759d5038d8c91527f6), unanimously approved (3 APPROVE / 0 REQUEST_CHANGES from sol-review, fable-review, argon-review) in Implementation Code Review Round 1.
    • Scope delivered:
      • Separates @file / \file gatherer comments in RunSelection::select (streaming/markers.rs) so file-level documentation and the following declaration's leading comment each publish their own document under Profile::Doxygen (LANG::C, LANG::Cpp, LANG::Mozcpp, LANG::Objc).
      • Resolves trailing Doxygen enum comments (/**<, /*!<, ///<, //!<) after an enumerator comma via enum_comma_predecessor (collector.rs), while initializer commas uniformly retain their pending comma document without binding to the enumerator.
      • Projects single-declaration C++ template_declaration and linkage_specification (extern "C") wrappers (projections.rs), keeping braced linkage blocks (extern "C" { … }) pending and preserving all legacy LOC rows unchanged.
    • Verification:
      • make pre-commit on bf5282d3: BCA_GATE: pass (gate=pre-commit) with make self-scan-baseline-fresh exiting 0 (0 added, 0 removed, 0 worsened, 0 improved).
      • make bench-source: combined gate: 0 performance failures.
      • anchor_check.py: manifests=71 cases=1631 problems=0.
      • Perturbation sweeps: C-family Unit 2 29/29 caught, C-family Unit 2 legacy 1/1 caught, C-family Unit 1 22/22 caught, C-family Unit 1 legacy 2/2 caught, and documentation variants 22/22 caught (76/76 total, rc=101, missing_expected=[]).
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

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions