Skip to content

fix(swift): preserve declaration identity and compatible call edges - #2436

Open
DavidHLP wants to merge 67 commits into
DeusData:mainfrom
DavidHLP:feat/issue-2061-swift-identity
Open

DavidHLP wants to merge 67 commits into
DeusData:mainfrom
DavidHLP:feat/issue-2061-swift-identity

Conversation

@DavidHLP

@DavidHLP DavidHLP commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Refs #2061. Builds on merged #2342 and enables signature-qualified callable identities for Swift only. Bare node names are preserved.

  • Distinguishes labels, parameter types, generic and extension requirements, static/class dispatch, async declarations, qualified type paths, and explicit return types.
  • Resolves compatible calls by labels, arity, defaults, and trailing closures. Ambiguous compatible overloads are retained with candidate counts; this does not add type inference.
  • Persists an uncapped Swift selector separately from the bounded identity so a hashed signature remains callable after serial, parallel, and incremental indexing.
  • Filters Swift candidates before applying the output limit; unrelated definitions sharing a bare name cannot discard a unique compatible call.
  • Uses index format 6 to rebuild older indexes once and replace collided nodes and stale call edges. This also rebuilds pre-merge format-5 indexes that still carry invented image registry hosts.
  • Removes the unrelated Windows Cypher stress adjustment and redundant opt-in validation material. MCP presentation assertions now run in the default test suite.

This remains a large change (26 files, +2969/-77 against the current base), above CONTRIBUTING.md's recommended PR size. The remaining changes implement and test this single Swift identity boundary, its call resolution, and persisted migration.

AI assistance: This update was prepared with an AI agent acting on behalf of DavidHLP.

Validation

Current source head: 4ab447f8dcc75059e562c7d9afdc603d054eae33, including upstream main a7158ac2f48ca646b4527341b76f930f2aeff87e.

Latest main integration validation in Linux x86_64 Docker:

  • UBSAN_OPTIONS=halt_on_error=1 scripts/test.sh --suites index_format: all 6 tests passed with ASan/UBSan, including the retained Swift migration cases and image migration from formats 2 and 5.
  • scripts/lint.sh --ci CLANG_FORMAT=clang-format-20 "CPPCHECK=cppcheck -j4": passed.
  • git diff --check: passed.

The implementation validation below was performed before this latest merge, at source head a9e56d92fd36190598cffbbddf1e6ef47cb98fac (Docker product-code snapshot 5142a753433e89edcfbffbcd7a4c6169b6f64c68). It is not a fresh full test run of the current head.

Independent Linux x86_64 Docker checks use the repository's canonical build/test/lint scripts. Official Swift 6.0.3 typechecks all four independent input groups. The original main, previous PR head, and revised implementation are compared for the reported fake caller, static/instance identity, constrained extensions, capped signatures, and a large same-name bucket. The new regression cases were observed failing before the correction.

Before the latest main integration:

  • Production build and assertions over all four independent CLI fixture groups passed.
  • scripts/test.sh --suites callable_sig,registry,index_format,extraction: 577 tests passed.
  • Focused Swift extraction/pipeline and MCP cases: 44 tests passed with UBSAN_OPTIONS=halt_on_error=1. These overlap the suite run and are not 44 additional distinct tests.
  • scripts/test.sh --contracts-only: all contracts passed in a Docker container with --init.
  • scripts/lint.sh --ci CLANG_FORMAT=clang-format-20 "CPPCHECK=cppcheck -j4": passed, including no-skips, formatting, cppcheck, NOLINT, and memory-core checks.
  • Local DCO check of the pushed commit range passed.

The broader extraction run emits ObjectScript/Perl UBSan diagnostics and is not sanitizer-clean. Those paths are outside this change. Full local cross-platform tests and TSan were not rerun.

GitHub checks for the current source head have not completed; no completed current-head matrix is claimed.

Maintainer review is pending. Passing checks are not maintainer approval.

Review focus

  • Swift declaration spelling and separation from call compatibility metadata.
  • Selector ownership through compact/spill and serial/parallel/incremental persistence.
  • Conservative candidate handling and the format-6 rebuild boundary.

Checklist

  • Original fake-caller behavior and additional boundary failures reproduced independently.
  • Necessary regressions included in default suites.
  • Unrelated Cypher adjustment and duplicate opt-in drivers removed.
  • Final targeted Docker integration validation complete.
  • Current-head GitHub checks complete.
  • Maintainer review complete.

DeusData and others added 8 commits September 25, 2026 18:49
…Data#2061)

Overloads that share a base QN (Java/C#/C++/Kotlin/Swift/Scala/ObjC) merge
into one graph node today, and that node collects the CALLS of every
overload. The agreed cure is one signature-qualified callable identity for
all overloading languages:

    callable_qn := base_qn [<tparams>] (params) [cvref]

This change lands the plumbing with every language still at
CBM_CALLABLE_ID_NONE, so the graph is byte-identical; each language is
switched on later in its own change (with its index-format bump).

- internal/cbm/callable_sig.{c,h}: the per-language mode side table
  (NONE|TYPED|LABELED_TYPED|LABELED|ARITY; kept out of CBMLangSpec like
  cbm_string_dispatch_suffixes, since ~160 positional rows would otherwise
  all need the member under -Wmissing-field-initializers), the shared
  builder cbm_callable_sig[_mode] for the def and the call-scope QN, and
  the inverse cbm_qn_callable_base_len[_named]. Suffix contract: no '.',
  '::' or '->'; whitespace-normalized; comments/annotations/attributes
  dropped; qualified types keep their last segment; '->' spelled '=>';
  variadic '[]' (Java) / '~'; C++ top-level cv dropped, arrays decay,
  cvref kept; <= 200 bytes, longer ones keep whole leading entries and end
  in '#<fnv1a64 of the full suffix>)'. The builder is iterative (cursor
  walk, bounded declarator loop) and self-checks against the inverse.
- The inverse is anchored to the node's bare name wherever the name is
  known: real QNs already end in ')' without being callables (a Java field
  whose name is its declarator `X = f()`, make `$(VAR)` targets), and only
  the anchor makes the inverse exact on them.
- Leaf splitters strip a suffix first (no-op today): registry by-name key
  (indexed by the bare name for a suffixed callable), cbm_lsp_bare_segment,
  cbm_pipeline_qn_class_method_tail, pxc_last_component, pxc_qn_leaf,
  go_index_visit_node, collect_prod_defs, sg_qn_prefix_len.
- New unused fields: CBMDefinition.qn_sig_off, CBMResolvedCall.callee_sig
  (relocated by result compaction), CBMRegisteredFunc.sig, CBMLSPDef.sig.
  The lsp_surface codec is unchanged (no format bump in this change).
- get_code_snippet and trace_path gain base-QN tiers
  (cbm_store_find_nodes_by_qn_base) that find nothing until suffixes exist.
- store: cbm_store_find_nodes_by_qn_suffix built its LIKE pattern in a
  512-byte buffer (a long suffix was truncated into a pattern that matched
  nothing) and did not escape '_'/'%' (`my_func` also matched `myXfunc`).
  The pattern is now heap-built, escaped, and matched with ESCAPE '\'.

Proof: full sorted node+edge+lsp_surface dumps are byte-identical before
and after on 7 corpora (this repo, elasticsearch libs, Exposed, dotnet
System.Linq, System.Collections, coreclr/gc, a C corpus).

Refs DeusData#2061

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
Enable typed, labeled Swift callable identities on the shared DeusData#2061 plumbing. Resolve calls by compatible labels, defaulted parameters, and trailing closures; retain all compatible overload edges with candidate counts. Cover registry, pipeline, and signature behavior.

Refs DeusData#2061

Signed-off-by: DavidHLP <lysf15520112973@163.com>
Signed-off-by: DavidHLP <lysf15520112973@163.com>
Force the parallel call pass on a Swift fixture and assert both label-compatible type overloads retain CALLS edges with the ambiguity count.

Refs DeusData#2061

Signed-off-by: DavidHLP <lysf15520112973@163.com>
Signed-off-by: DavidHLP <lysf15520112973@163.com>
A Swift call that shares its bare name with project symbols but matches
none of their overloads was handled differently by the two resolvers:
the parallel path cleared the bare-name match and fell through as
unresolved (keeping each resolver's empty-resolution service
fallbacks), while the sequential path dropped the call outright. Skip
the bare-name registry bind on the sequential path too — it would bind
a wrong overload — and continue as unresolved, so count < 0 behaves
exactly like any other unresolved call on each resolver.

Pipeline regressions pin the global-fetch fallback (DeusData#856) on both
paths: the incompatible local overload gets no wrong CALLS edge, and
the URL call keeps its HTTP_CALLS edge. The route-registration fallback
differs between the paths on main (sequential additionally requires a
'/'-leading first argument); that pre-existing divergence is out of
scope here.

Refs DeusData#2061

Signed-off-by: DavidHLP <lysf15520112973@163.com>
Signed-off-by: DavidHLP <lysf15520112973@163.com>
@github-actions

Copy link
Copy Markdown

Thanks for opening this — it has been seen, and it is queued.

This note is automated, but it is not a brush-off: it exists so you know where your PR stands instead of having to guess from silence.

Current review status: working through a backlog. 0.9.1-rc.1 is out, so the release freeze that held reviews is over — but it left a large queue of open pull requests behind it, and we are reading through them oldest-first. The background is in discussion #1144.

What that means for this PR, concretely:

  • It will not be closed for inactivity. No stale bot touches pull requests here.
  • It may still sit a while before a human reads it. That is on us, not on you.
  • Older PRs are read first, so a recent one is not being skipped — it is behind a queue.

Things that will genuinely speed it up whenever review does happen:

  • Keep it rebased on main — the tree is moving quickly right now, and a conflicting branch cannot be reviewed as the diff you intended.
  • Get CI green, or say which failures you believe are pre-existing.
  • Keep the change to one claim. Bundled features and refactors get split before they get merged, which costs you a round trip.
  • Every commit needs a sign-off (git commit -s) — CI enforces DCO.

If this fixes a bug, a reproduction we can run is worth more than a description of the symptom.

Thanks for contributing, and sorry in advance for the wait.

Signed-off-by: DavidHLP <lysf15520112973@163.com>
Signed-off-by: DavidHLP <lysf15520112973@163.com>
@DeusData
DeusData force-pushed the feat/callable-identity-plumbing branch 2 times, most recently from 3441da4 to 5538355 Compare September 30, 2026 22:34
Signed-off-by: DavidHLP <lysf15520112973@163.com>
@DeusData DeusData added enhancement New feature or request parsing/quality Graph extraction bugs, false positives, missing edges priority/normal Standard review queue; useful PR with ordinary maintainer urgency. labels Oct 1, 2026
@DeusData

DeusData commented Oct 1, 2026

Copy link
Copy Markdown
Owner

Thank you for the detailed status update and for clearly distinguishing the actual PR head from unpublished work and unverified results. The changed-file scope includes callable identity, resolution and persisted metadata, so we need more time for a complete review together with the parent change. This remains queued for deeper review; this comment is not an approval or a request for another routine rebase. The queue is full, and we appreciate your patience and the care taken to document the remaining work.

Swift-scope checkpoint for DeusData#2061: capture bounded trailing-closure labels, match Swift overload candidates conservatively, and cover extraction, registry, compact/spill, serial, parallel, and incremental behavior.

Validation: ASan passed on the combined WIP source only; this A-only checkpoint has not been independently verified. GCC TSan, smoke, and memory gates remain failed/open. This commit is a scope checkpoint, not acceptance.

Signed-off-by: David HLP <lysf15520112973@163.com>
Signed-off-by: David HLP <lysf15520112973@163.com>
Signed-off-by: David HLP <lysf15520112973@163.com>
Signed-off-by: David HLP <lysf15520112973@163.com>
Signed-off-by: David HLP <lysf15520112973@163.com>
Signed-off-by: David HLP <lysf15520112973@163.com>
Signed-off-by: David HLP <lysf15520112973@163.com>
@DavidHLP
DavidHLP force-pushed the feat/issue-2061-swift-identity branch from 4dbfd27 to eea3143 Compare October 3, 2026 09:49
Signed-off-by: DavidHLP <lysf15520112973@163.com>
Signed-off-by: DavidHLP <lysf15520112973@163.com>
Signed-off-by: DavidHLP <lysf15520112973@163.com>
@DavidHLP
DavidHLP marked this pull request as draft October 5, 2026 08:08
Signed-off-by: DavidHLP <lysf15520112973@163.com>
Signed-off-by: DavidHLP <lysf15520112973@163.com>
Signed-off-by: DavidHLP <lysf15520112973@163.com>
Signed-off-by: DavidHLP <lysf15520112973@163.com>
Signed-off-by: DavidHLP <lysf15520112973@163.com>
Signed-off-by: DavidHLP <lysf15520112973@163.com>
Signed-off-by: DavidHLP <lysf15520112973@163.com>
Signed-off-by: DavidHLP <lysf15520112973@163.com>
Signed-off-by: DavidHLP <lysf15520112973@163.com>
@DavidHLP DavidHLP changed the title fix(swift): preserve overload identity and compatible call edges fix(swift): preserve declaration identity and compatible call edges Oct 5, 2026
@DavidHLP
DavidHLP marked this pull request as ready for review October 5, 2026 09:35
@DavidHLP

DavidHLP commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor Author

I've finished the Swift fixes on top of #2342. The current head is 35533b2674a09e2e6e9a066faf52e3fb8ccdaada; the code was tested at 10f47697, and the last commit only updates the validation notes.

The two remaining collisions now have separate identities: A.Item versus B.Item, and functions that differ only in their declared return type. The tests reproduce each collision before the fix, then check separate nodes, source locations and outgoing calls, including parallel indexing and reopening the index. Call resolution still keeps all compatible candidates rather than guessing from types.

The main thing I'd like feedback on is the identity spelling: qualified types use /, explicit returns use =>Type, and format4 rebuilds older indexes once. The implementation and migration tests are in callable_sig.c, registry.c and test_index_format.c.

On remote-dev, 909 focused tests and 328 pipeline TSan tests passed, along with the separate graph and MCP checks, production build and CI lint. There are still two ObjectScript UBSan reports, so the focused run isn't sanitizer-clean. The full C run stops at the Scoop metadata precheck, full clang-tidy still reports errors, and the native CLI crashes at startup with the same stack seen in the earlier main comparison. Current macOS, Windows and Ubuntu CLI checks haven't been run.

Test commands and full logs are available here. I removed the duplicate progress comments; their original text is archived. This is ready for review, with the remaining checks and approval still pending.

Signed-off-by: DavidHLP <lysf15520112973@163.com>
Signed-off-by: DavidHLP <lysf15520112973@163.com>
Signed-off-by: DavidHLP <lysf15520112973@163.com>
Signed-off-by: DavidHLP <lysf15520112973@163.com>
Signed-off-by: DavidHLP <lysf15520112973@163.com>
Signed-off-by: DavidHLP <lysf15520112973@163.com>
Signed-off-by: DavidHLP <lysf15520112973@163.com>
@DavidHLP
DavidHLP force-pushed the feat/issue-2061-swift-identity branch from 1a94454 to caa4d0c Compare October 13, 2026 07:25
Signed-off-by: DavidHLP <lysf15520112973@163.com>
Signed-off-by: DavidHLP <lysf15520112973@163.com>
Signed-off-by: DavidHLP <lysf15520112973@163.com>
Signed-off-by: DavidHLP <lysf15520112973@163.com>
Signed-off-by: DavidHLP <lysf15520112973@163.com>
Preserve Swift identity and upstream image migration coverage. Advance the combined index format to 6 so pre-merge format-5 indexes also rebuild invented image hosts. Refs DeusData#2061.

Signed-off-by: DavidHLP <lysf15520112973@163.com>

This branch has not been deployed

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

Labels

enhancement New feature or request parsing/quality Graph extraction bugs, false positives, missing edges priority/normal Standard review queue; useful PR with ordinary maintainer urgency.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants