beadAnchors function

({List<String> paths, bool pathsTruncated, List<String> symbols, bool symbolsTruncated}) beadAnchors(
  1. Bead bead
)

The PATH + SYMBOL anchors bead names — the round's ONLY tree-intake pass. Pure, deterministic (first-appearance order), bounded (kMaxAnchors), and exposed for unit tests.

A PATH is a known-extension repository-relative token, found either inside backticks OR as a plain path token in the prose (a bead that writes lib/src/x.dart without backticks names the same surface). It may carry the CITED LINE the bead named (lib/src/x.dart:222): the qualifier rides ON the anchor so a resolver can window the file at that site instead of clipping its head (parseCodeAnchor), and two sites in one file are two anchors. A SYMBOL is a BACKTICKED identifier carrying an inner capital (buildSpecifyBrief, kSpecReviewCircuit) or an initial one (Heartbeat) — which is what keeps ordinary backticked prose (bd, main, haiku) out of the set.

pathsTruncated/symbolsTruncated record a hit on kMaxAnchors: the bead names MORE surfaces than this profile carries, and a lens must be told that rather than shown a silently short list.

Implementation

({
  List<String> paths,
  List<String> symbols,
  bool pathsTruncated,
  bool symbolsTruncated,
})
beadAnchors(Bead bead) {
  final text = [
    for (final field in kBeadWorkFields) beadTextOf(bead, field),
  ].join('\n');
  final paths = <String>{};
  final symbols = <String>{};
  for (final match in _anchorSpan.allMatches(text)) {
    final backticked = match.group(1);
    final span = (backticked ?? match.group(2)!).trim();
    if (_isPathAnchor(span)) {
      paths.add(span);
    } else if (backticked != null && _isSymbolAnchor(span)) {
      symbols.add(span);
    }
  }
  return (
    paths: paths.take(kMaxAnchors).toList(),
    symbols: symbols.take(kMaxAnchors).toList(),
    pathsTruncated: paths.length > kMaxAnchors,
    symbolsTruncated: symbols.length > kMaxAnchors,
  );
}