Skip to content

docs(dynamic-kind): clarify Track A resolved calls never surface via roles --dynamic - #2448

Merged
carlos-alm merged 1 commit into
mainfrom
fix/issue-2270-dynamic-kind-scope-docs
Aug 10, 2026
Merged

carlos-alm merged 1 commit into
mainfrom
fix/issue-2270-dynamic-kind-scope-docs

Conversation

@carlos-alm

Copy link
Copy Markdown
Contributor

Summary

Issue #2270 found (empirically, across every language, including JS's own reference implementation) that Track A resolved dynamic calls (computed-literal, value-ref, dispatch-table, resolved reflection) never persist dynamic_kind on their edge row — only flag-only Track B sink edges do. This traces back to an assumption in issue #2042 that extractor-level dynamicKind tagging implies visibility via codegraph roles --dynamic. The issue asked to decide between two directions: thread dynamicKind through resolved edges too, or explicitly document the current scope.

Investigation

Re-read ADR-002 (docs/architecture/decisions/002-dynamic-call-resolution.md) closely. Its own text already scopes codegraph roles --dynamic to flagged (Track B) calls specifically: "visible in the graph, queryable via codegraph roles --dynamic, but never polluting normal precision metrics" — describing Track B, not Track A. The CLI help text (--dynamic', 'Show flagged dynamic call sites...') and dynamicCallsData's pre-existing doc comment ("flagged dynamic call sink edges") already say the same. The ADR, CLI help, and function-level docs were all already accurate — the confusion originated in issue #2042's own framing, not in the codebase's documentation.

Checked whether threading dynamicKind through resolved edges (the other option) would be safe: it is not, without further changes. incremental.ts and native-orchestrator.ts both already use dynamic_kind IS NULL (alongside technique IS NULL) as the signal for "plain edge not yet backfilled with a technique value." Making Track A resolved edges also carry dynamic_kind would silently exclude them from that backfill — a real, wide-blast-radius side effect for what is fundamentally a diagnostic nice-to-have, not a bug fix.

Verified on both engines (fresh builds, direct DB inspection) that obj["foo"]() resolving successfully produces dynamic=1, dynamic_kind=NULL, confidence=1 identically on WASM and native — confirming this is a consistent, intentional, dual-engine-agreed design, not a parity gap.

Fix

No functional code change (diff-impact confirms zero function-level changes). This closes the issue by:

  • Adding an explicit, discoverable statement of the contract to DynamicKind's doc comment (src/types.ts) and dynamicCallsData's doc comment (src/domain/analysis/roles.ts), including the technique-backfill risk that makes the "just thread it through" alternative unsafe.
  • Adding a dual-engine regression test (tests/integration/issue-2270-track-a-dynamic-kind-scope.test.ts) that locks in the current behavior as an explicit, tested contract — so a future well-intentioned attempt to "fix" this can't silently reintroduce the technique-backfill regression without a test forcing a conscious decision.

Testing

  • New test: 6 assertions across WASM + native, verifying the computed-literal call resolves to a real high-confidence edge, that edge has dynamic_kind=NULL, and it's correctly excluded from the dynamic_kind IS NOT NULL query codegraph roles --dynamic uses.
  • Full suite: 5037 tests passing (WASM + native) — one full-suite run showed 86 unrelated failures (0% precision/recall on julia/objc/groovy) that did not reproduce when rerun, or when run in isolation; root-caused to resource contention from this session's heavy concurrent build/test load, not a real regression — confirmed via a clean rerun.
  • node scripts/parity-compare.mjs: 42/42 fixtures identical across engines.
  • npm run lint / cargo fmt --check: clean.

Closes #2270

…roles --dynamic (#2270)

Investigated whether resolved Track A dynamic calls (computed-literal,
value-ref, dispatch-table) should persist dynamic_kind on their edge
row so codegraph roles --dynamic can surface them, per an assumption
in issue #2042 that extractor-level dynamicKind tagging implies that
visibility.

Confirmed empirically (both engines agree) that the current behavior —
Track A calls resolve into ordinary edges with dynamic_kind=NULL, only
flag-only Track B sink edges ever persist dynamic_kind — is the
correct, intended architecture per ADR-002's own text: roles --dynamic
exists to surface calls that would otherwise be silently dropped, and
a resolved Track A call was never at risk of that. It is also not safe
to change by threading dynamicKind through resolved edges too:
incremental.ts/native-orchestrator.ts already use dynamic_kind IS NULL
(alongside technique IS NULL) to find edges due a technique backfill —
repurposing the column for Track A would silently exclude those edges
from it.

Documents this explicitly (DynamicKind's doc comment in types.ts,
dynamicCallsData's in roles.ts) and adds a dual-engine regression test
locking in the contract, so a future well-intentioned "fix" can't
silently reintroduce the technique-backfill regression this avoids.

docs check acknowledged: doc-comment clarification only, no CLI,
language support, or architecture-table changes.
@greptile-apps

greptile-apps Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR documents that resolved Track A dynamic calls do not persist dynamic_kind and therefore do not appear in roles --dynamic.

  • Clarifies the persisted-edge contract in DynamicKind and dynamicCallsData documentation.
  • Adds isolated WASM and native regression coverage for resolved computed-literal calls.
  • Verifies resolved edges retain positive confidence while dynamic_kind remains null.

Confidence Score: 5/5

The PR appears safe to merge because it changes only documentation and focused regression coverage, with no actionable defects identified.

The documented Track A and Track B persistence behavior matches the current full, incremental, WASM, and native paths, and the new tests use established isolated integration-test conventions.

Important Files Changed

Filename Overview
src/domain/analysis/roles.ts Clarifies that the existing query reports only flagged Track B sink edges; no runtime behavior changes.
src/types.ts Documents the distinction between extractor-level dynamic kinds and persisted edge metadata, consistent with current producer and backfill paths.
tests/integration/issue-2270-track-a-dynamic-kind-scope.test.ts Adds isolated dual-engine regression tests that directly verify resolved-edge confidence, null dynamic_kind, and exclusion from the dynamic query.

Reviews (1): Last reviewed commit: "docs(dynamic-kind): clarify Track A reso..." | Re-trigger Greptile

@carlos-alm
carlos-alm merged commit 2fd4cba into main Aug 10, 2026
27 checks passed
@carlos-alm
carlos-alm deleted the fix/issue-2270-dynamic-kind-scope-docs branch August 10, 2026 20:54
@github-actions github-actions Bot locked and limited conversation to collaborators Aug 10, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

1 participant