Skip to content

chore(roles): follow-ups from the PR #1862 whole-branch review — Checker forwarding direction, byte-axis backstop, record-header projection and probes #1863

Closed

Description

@dekobon

Status (2026-11-11): landed on main at 68b70b08 through #1877 on 2026-11-12, as a fast-forward of the 21 signed commits. Evidence and per-item detail: #1863 (comment)

  • 1. Required with-code predicates (also is_call_with_code / is_string_with_code)
  • 2. Byte-less is_func deleted; byte-less is_func_space / get_space_kind required and pinned
  • 3. Byte-axis backstop; three gates re-declared. Remaining blind spot: refactor(roles): make the gated_by keyword exact on the byte axis #1874
  • 4. record_header for Java and Groovy. C# declined
  • 5. Header types read once; two probes. Per-record memo and arity pre-pass declined
  • 6. Probe added. The FoldLane suggested below regresses another shape; a per-level memoised climb ships instead, with a second probe
  • 7. Four of five done. count_args in the Groovy header arm declined: not equivalent on recovery input

Follow-ups filed from the reviews: #1872, #1873, #1874, #1875.

Follow-ups the whole-branch review of PR #1862 (batch of #1857 #1859 #1858 #1830 #1842) identified as out of that PR's scope. Each is small on its own; none blocks the merge.

1. Checker default forwarding runs with-code → byte-less, the reverse of the documented contract

big-code-analysis-ast/src/checker.rs defaults is_func_with_code to is_func(node, ancestors) and is_func_space_with_code to is_func_space(node). roles/mod.rs ("Reading a row") and docs/development/grammar_dispatch.md §7 say the opposite: the _with_code spelling is what the walk calls and the byte-less defaults forward to it. Only Elixir, Groovy and Java override is_func_with_code; for the other 23 languages a with-code consumer silently gets is_callable(node, &[], ancestors). This is how 80c737e7 on #1862 happened: Java's record-header gate read type bytes, is_func dropped them, and every same-arity constructor read as canonical until is_func_with_code was overridden.

Plan: make is_func_with_code the required Checker method and derive the byte-less is_func from it as the kind table (&[], Ancestors::known(&[])) for every language. The AST crate is outside STABILITY.md; Checker is not re-exported from the root crate. Mechanical across 26 languages.

2. Byte-less is_func has three contracts

Ruby/C#/Kotlin honour the caller's chain and drop bytes; Java/Groovy discard the chain and force a known-empty one (checker/java.rs, checker/groovy.rs, #1842); Elixir returns false. roles/mod.rs was edited to document the Java/Groovy carve-out. The derived parity suite never compares byte-less is_func (derived_parity_tests.rs forwards_on lists is_closure, is_else_if, is_func_space, get_space_kind, is_func_with_code), so the forward is pinned only by *_byte_less_spellings_omit_the_record_header. KNOWN_DISAGREEMENTS grew 6 → 10 entries. Resolve with item 1: one definition of the byte-less spelling, with the chain-honouring variants becoming the exceptions to argue about.

3. No byte-axis backstop for a gate declared under the wrong keyword

roles/mod.rs documents that TEXT_GATED is the author's word and "a gate named under the wrong keyword is the author's error". The chain axis has a behavioural backstop (no_chain_rows_answer_alike_under_the_empty_chain); the byte axis has none. A symmetric derived test — for every !TEXT_GATED owner on corpus candidates, owns(node, code, chain) == owns(node, &[], chain) — would have failed on the #1842 doc fixture as soon as a same-arity alternative constructor was added.

4. Record-header structural projection is restated per consumer

"The header is the record's parameters / components field" is spelled in the gate (roles/java.rs, roles/groovy.rs), the getter's naming closure (kind pair only), nargs params_owner, and npm's stringly field: &str argument to record_header_is_a_method. roles/mod.rs prescribes a named fn beside the table for a structural projection one consumer needs (is_switch_body_kind is the precedent). A record_header(record) -> Option<Node> per language would hold the field name once; C#'s #1828 code has the same shape.

5. Per-record memo for the header gate, and a record width probe

opens_record_header is evaluated 6× per record in bca metrics (walk promotion, get_space_kind_with_code, nargs, nom, cognitive owns_kind, npm) and 2× in bca ops, each re-scanning the body and allocating a Vec<u8> per parameter per constructor. Linear in the file (doubling ratios 1.86–2.1 measured at M=4000 members, C=200 constructors, P=10), ≈1 ms per evaluation at that shape, ≈10 µs on realistic records; 25 % of walk time only on an absurd 2 MB file of 4000 constructors. Optional: NodeQuestion::RecordHeaderOpens memo keyed on the record; build the header's Vec<ParameterType> once per evaluation; compare arity before types. Add nargs/java-record-alternative-ctors (Axis::Width, one record with width alternative constructors whose first 9 types match) and a Groovy twin so the gate's class is pinned; no probe renders a Java/Groovy record today.

6. Python depth × width paren probe

python_code_before_node's climb over extras at every level above a parenthesis is Σ_j Σ_{i<j} k_i, bounded by CPython's 200-level cap (measured exponent ≈1.3–1.4 up to the cap, dropping at d=400). Pre-existing, not introduced by #1830; every Python paren probe is depth-only or width-only. A loc/python-deep-paren-extra-prefix probe (Axis::Depth, depth × 50 \+# c pairs per level, ladder below 200) would pin it; a FoldLane for "code precedes this level's node on its logical line" would make it O(Σk).

7. Smaller

  • tests/parity/ops_metrics_space_parity.rs: the Java/Groovy record fixture cannot see a two-sided drop of the header space (space.spaces is non-empty from other members); a contains("Function Some(\"R\")") on the rendered tree would make it self-checking.
  • Groovy nargs header arm counts record_component children by kind filter; count_args::<Self> gives the same answer today and is the one definition of "a parameter".
  • check_gated in space_tree_tests.rs uses "" as the no-gated-kind sentinel; Option<&str> says the same. The Java row test in roles/java.rs hand-rolls the same gated-kind pattern.
  • impl_npm_java_like!'s has_public_modifier swapped child(0) for a cursor scan: one TreeCursor allocation per method; the direction docs/development/benchmarking.md warns about, measurably nothing today.
  • not_extra (lang_helpers/python.rs) states the tree-sitter-python extra pair once; loc/python.rs python_code_among restates it in a skip_while. Export as python_is_extra when LOC is next touched.

Activity

  1. dekobon commented on Nov 12, 2026

    @dekobon
    OwnerAuthor

    Implemented on the local branch chore/1863-roles-followups, 19 commits on main a62077d5, tip 51bd1ad6. Not pushed and no PR yet, so this stays open.

    Full record (commands, revisions, numbers, per-item detail): https://gist.github.com/dekobon/4dd5e8ab3d67b87c444f1df0dc2a4613

    No metric value, space name or snapshot moves (git diff a62077d5..51bd1ad6 -- '*.snap' tests/repositories man '.role-coverage*' is empty). At the tip: make pre-commit ends BCA_GATE: pass (7242 tests), make bench-scaling passes all 132 probes, make chain-audit passes.

    Item Outcome
    1 Done. Five with-code predicates are required (is_call_with_code and is_string_with_code had the same default and are included).
    2 Done. Byte-less is_func is deleted, not derived: the JS family and C# need the real chain in the doc-body test. The byte-less is_func_space / get_space_kind are required and pinned at build time.
    3 Done. The backstop found three mis-declared gates: Tcl family is_braced_literal, Bash comparison_operator and short_circuit_operator. Six gates re-declared gated_by each fail it. Its blind spot is #1874.
    4 Done for Java and Groovy. C# declined: its list sits in no field and the grammar admits more than one per type.
    5 Header types read once per evaluation; two probes added. Per-record memo and arity pre-pass declined (reasons in the record).
    6 Done, but not with the FoldLane this issue suggests: that fold made another shape quadratic (2.02, where main reads 1.08). A per-level memoised climb ships instead, with a second probe for that shape.
    7 Four of five done. count_args in the Groovy header arm declined: it is not equivalent on recovery input (record R(int a,) {} reads 1 by kind and 2 through count_args), so the swap would move nargs. A test pins both.

    Scaling exponents for item 6 (--no-gate, one run each, busy host):

    Probe climb (main) fold memoised climb
    loc/python-deep-paren-extra-prefix 1.96 1.06 0.99
    loc/python-block-comments-paren-strings (new) 1.08 2.02 1.00

    Follow-ups filed from the reviews: #1872, #1873, #1874, #1875.

  2. dekobon commented on Nov 12, 2026

    @dekobon
    OwnerAuthor

    One more local commit, 530da1b0: the Japanese po/ja.po entry for the book line this work changed (the Getter bullet of the new-language page) is translated. It was already fuzzy against an older English sentence, so the item rendered in English on /ja/. Only that entry changes (fuzzy entries 991 -> 990). msgfmt --check passes, the msgid matches a freshly generated messages.pot, and make book && make book-ja renders it. The record gist is updated. The gates above were taken at 51bd1ad6; this commit touches no code.

  3. dekobon commented on Nov 12, 2026

    @dekobon
    OwnerAuthor

    The branch is pushed and in review as #1877 (Fixes #1863), tip 530da1b0.

  4. 3 remaining items

  5. dekobon commented on Nov 12, 2026

    @dekobon
    OwnerAuthor

    The branch was rebased onto main 389d879f (#1876) and force-pushed; #1877 is now at 68b70b08. The hashes in the comments above and in the record gist are the pre-rebase ones. Old to new:

    c935311d -> 4aed88bc
    78689de0 -> a359774b
    520d000d -> e93b3777
    8dfc50a3 -> 4bf33be8
    6bdf488c -> ee68d23f
    582b5331 -> 4c1f5717
    798ee09c -> 54589594
    0b4703da -> bacf760c
    48e7b77a -> 678be303
    29d6a888 -> 1642a963
    b8388cca -> 6e9ab714
    8e6a7fb5 -> 9e098807
    3080a342 -> 8061e967
    04dbe042 -> c799efd9
    a9bb20b6 -> 601a0742
    b4e70ebf -> 6198f3fe
    19b637fc -> f0774c39
    0e4bc24c -> e3d0cca8
    51bd1ad6 -> 6dd823a9
    530da1b0 -> 8f7bbe66
    9d2f893c -> 68b70b08
    

    Each replayed commit passed cargo check --workspace --all-features --all-targets, and .bca-baseline.toml was regenerated per commit, not merged. At 68b70b08: make pre-commit ends BCA_GATE: pass (7249 tests), the chain-audit leg's command passes, and make bench-scaling passes all 132 probes. The measurements in the record were taken before the rebase.

  6. dekobon commented on Nov 12, 2026

    @dekobon
    OwnerAuthor

    Landed: main was fast-forwarded to 68b70b08 (#1877) after CI passed on that commit (52 checks passed; the two Pages jobs do not run on pull requests). GitHub's rebase merge was not available because main requires signed commits, so the 21 signed commits were pushed as they are. Every item above is done or declined with its reason recorded; follow-ups are #1872, #1873, #1874 and #1875.

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

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions