Skip to content

feat(swift): resolve type references across files through a Swift type index - #4758

Open
idachev wants to merge 11 commits into
Graphify-Labs:v8from
idachev:swift-xfile-types-pr
Open

idachev wants to merge 11 commits into
Graphify-Labs:v8from
idachev:swift-xfile-types-pr

Conversation

@idachev

@idachev idachev commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do?

Fixes #4574
Fixes #4575
Fixes #4754

Problem. In a Swift corpus many type references never reach the declaration of the type they name. Swift has no per-type imports inside a module, so every cross-file type name starts as a sourceless stub that the label-based passes have to repair, and several ordinary patterns defeat them:

The root causes (RC1-RC5), the design and the decisions are in docs/swift-cross-file-type-resolution-rfc.md, added by this PR.

Approach. Deterministic, fail-closed Swift name lookup, in the RFC's phases. Phases 1-4 depend on each other (the RFC explains why Phase 3 cannot ship without Phases 2 and 4), so they are one PR.

Wrong bindings fixed on the way, each with a regression test:

  • A dotted label such as Item.ID resolves only through the Swift lookup; it no longer binds a concatenated ItemID through the member-call fallback or the stub rewire.
  • An extension of the sugar forms [T], [K: V], T? extends Swift.Array / Swift.Dictionary / Swift.Optional instead of folding onto T.
  • A member call whose receiver type is an extension-only node emits no type-only references edge to it when the method is not defined in the extension.
  • The Swift member-call pass handles only Swift callers (by effective suffix, so a .graphifyrc override counts) and binds only .swift / .m / .mm / .h targets.

Fixed after review (the first three in commits fix(swift): dotted refs to nested types, ObjC-owned callers, extension-only ctor targets and fix(swift): resolve same-file dotted type names by lexical lookup; the others name their commit), each with a regression test:

  • A dotted reference such as Action.Delegate slugged to the id of a same-file case delegate (ids are caseless; the case keeps the plain id and the nested type is salted), so it pointed at the enum case; and a same-file shortcut by absolute path ignored lexical scope, so Model.Item written inside Outer could bind a top-level Model.Item instead of Outer.Model.Item. A dotted Swift name no longer takes the same-file id shortcut: it stays a stub and the Phase 2 lookup binds it with the reference's scope (test_dotted_reference_reaches_nested_type_not_same_slug_enum_case, test_dotted_reference_uses_lexical_scope_over_same_named_top_level, both declaration orders).
  • A Swift extension of an Objective-C class folds onto the Objective-C node, which has no Swift path, so Item() inside that extension lost the constructor edge v8 has. A non-Swift owner now gives file scope (test_constructor_call_in_extension_of_objc_class_binds).
  • The generic constructor fallback still accepted an extension-only node, so External() of a library type bound to extension External (as on v8). Swift calls now drop such candidates (test_constructor_call_does_not_bind_extension_only_node).
  • fix(swift): do not bind Swift calls to C/C++ declarations in .h headers: the member-call target gate admitted every .h target, so Inner.go() could bind a C++ Inner::go declared in a header, and a missing method fell back to a type-only references edge to the C++ class. A .h target now binds only when it is an Objective-C method (its label carries the - / + sigil) or a type that owns one (test_swift_type_call_does_not_bind_cpp_class_method_in_h, test_swift_call_to_cpp_class_emits_no_reference_in_h, test_swift_instance_call_still_binds_objc_instance_method_in_h).
  • fix(swift): honour language overrides in Swift suffix checks: six checks (the constructor branch, its extension-only candidate filter, the dotted-stub guard, the Swift type index, the type-reference source set and the type-reference file selection) tested the raw file name, so a file remapped to Swift in .graphifyrc lost or gained edges, and a corpus of .SWIFT files skipped the type-reference pass. One helper now decides by the effective suffix, ignoring case (test_constructor_in_language_override_file_binds_lexical_type, test_uppercase_swift_suffix_corpus_binds_type_reference).
  • fix(swift): keep nested type ids distinct from same-file top-level declarations: a nested type's id joins its parent's id and its name, so Outer.State and a file-level Outer_State or outer_state() minted one id and the second node was dropped. A nested type now yields that id to any member or function and to any type of the same or a shallower depth, and is salted, independent of declaration order (test_nested_type_does_not_swallow_toplevel_underscore_type, test_nested_type_does_not_swallow_toplevel_function).
  • fix(swift): bind nothing for receivers whose written type is unproven: a receiver typed with a name that something else in the file shadows (a typealias, an associatedtype, a generic parameter or pack, a type declared inside a function body, a Self.-qualified path, a generic-constrained prefix or a generic argument) bound the call to a same-named type elsewhere. Such a write now makes the name bind nothing in that file, for properties (every name of a multi-binding declaration), parameters, typed locals, typed closure parameters, file-scope bindings and initializers or factories called through such a type, also when the binding is annotated; nothing is parked, and var x: A; x.go() still binds A.go (tests/test_swift_receiver_fail_closed.py).

Three commits change no behaviour. refactor(swift): tidy the new Swift resolution helpers removes duplication in the new helpers (one shared navigation-path walk, one shared relation set, one redundant check dropped), and docs(swift): use generic examples in the RFC and fixtures only renames examples in the RFC, test fixtures and comments. The third, refactor(swift): split Swift call binding out of walk() for pyright, only moves the new Swift branches of _extract_generic's walk() into small nested helpers, with no behaviour change: they had pushed walk() past pyright's complexity limit, so pyright stopped checking the whole function.

Cache and upgrade. _AST_CACHE_SCHEMA goes from 25 to 26, once for all phases, because per-file Swift output changes. The first build after the upgrade re-extracts every file. Nested Swift types get new ids, so saved queries and --seed ids that name a nested Swift type have to be updated. On a large Swift corpus the dedup shrink guard may refuse the first graph if it is smaller than the old one; --allow-dedup-shrink lets it through.

Related PRs and issues.

Split out. Two small fixes found during this work are separate PRs and do not depend on this one or on each other: #4756 (no dedup collision warning for shared module nodes, RFC Phase 5) and #4757 (the Python member-call pass binds only Python callers and targets).

Notes for maintainers

  • This PR bumps _AST_CACHE_SCHEMA 25 -> 26 because it changes per-file Swift output; feel free to adjust the number or fold it into your release bump.

Type of change

  • Bug fix
  • New feature
  • Documentation
  • Tests or CI
  • Refactor
  • Security fix

Verification & Invariants

Invariants: extraction stays deterministic (no ambient state, no file reads in the resolvers); ambiguity binds nothing instead of guessing (fail-closed); no binding across language families; a sourceless stub never wins over a sourced declaration; an extension of a type outside the corpus is never treated as its declaration. Persisted state this invalidates: the AST cache (schema bump) and any saved id of a nested Swift type.

  • Read the CONTRIBUTING.md guide.
  • Reproduced the issue and identified the invariant.
  • Made the smallest fix necessary (Phases 1-4 depend on each other; see the RFC).
  • Added a regression test (if bug fix) or isolated boundary test.
  • Kept the PR description synchronized with the final implementation.
  • Documented any limitations / unsupported cases explicitly.

How was this tested?

New test files: tests/test_swift_type_index.py, test_swift_type_resolution.py, test_swift_nested_constructor_calls.py, test_swift_member_call_scopes.py, test_swift_member_call_target_gate.py, test_swift_extension_only_member_calls.py, test_swift_sugar_extensions.py, test_swift_dotted_label_key.py, test_swift_language_override.py, test_swift_nested_id_collision.py; additions to test_swift_cross_file_calls.py and test_serve.py.

On this branch at its current head (rebased on v8 92741d16):

uv sync --all-extras
uv run pytest tests                  # 8885 passed, 16 skipped, 1 xfailed
uv run ruff check .                  # All checks passed!   (v8: All checks passed!)
uv run pyright                       # 656 errors   (v8: 657)

Pyright: the error sets compared by file and message (line stripped) show 0 new errors.

Regression tests fail on v8: the new and changed test files copied into a v8 92741d16 checkout and run against v8 code give 55 failed and 1 collection error in the Swift and serve files (the same run also held the test files of the two split-out PRs, which account for its other 6 failures; 216 tests passed in total). The failures include test_extension_of_outside_type_does_not_absorb_references (#4574), test_same_file_nested_types_get_distinct_ids (#4575), test_declaration_with_same_file_extension_absorbs_cross_file_extension (#4754 case 1), test_cross_file_constructor_call_emits_inferred_call (#4754 case 3) and test_callers_question_keeps_constructor_call_edges (serve). test_swift_type_index.py cannot be collected on v8 because it imports _swift_type_index / _swift_lookup. The 216 that pass are the controls.

Real-project check: a SwiftUI app with several hundred Swift files, built with graphify extract <app> --code-only, GRAPHIFY_BACKEND=none, no API keys set. These numbers were measured on an earlier revision of this change set, before the rebase onto 92741d16, against v8 c588b72d (0.9.94). Since that measurement the branch changed only by the rebase, the walk() refactor above (no behaviour change), the removal of the Python-pass change that now ships as #4757, and the review fixes above; the real-app check was not rerun after those fixes.

metric before (c588b72d) after
one struct referenced from many other files: affected <declaration id>, depth 1, other files / uses 0 / 0 30 / 127
the same struct: affected "<name>" (label) No unique node match 427 hits in 36 files
references left on a stub although the corpus has exactly one declaration of that name 600 66
INFERRED constructor calls 0 3705 (0 to a stub)
dotted label collapsed onto a concatenated name (Item.ID -> ItemID) 0 0
cross-language calls / references 0 0
EXTRACTED calls 10065 9859

The total of Swift references that end on a stub rises (4836 -> 7040). That is by design: references to an extension-only type (View, NSEvent) no longer bind to the extension (#4574), and dotted names stay dotted stubs instead of binding a lookalike.

The drop in EXTRACTED calls was checked per call site (caller, file, line, callee name), not by node id, since nested types now get parent-qualified ids. Of the 370 call sites that lost an EXTRACTED calls edge, 314 still have an edge to the same target: 248 are in-file constructor calls of nested types that are now recorded as INFERRED, and 66 collapsed into an existing references edge on the same node pair, since the graph keeps one edge per pair. Another 26 were wrong bindings that are now gone (self-recursion through a receiver of a different type, a receiver of an external type bound to a same-named local method, and one call bound to an extension-only node that now binds to the real type). The remaining 30 are real losses, listed under limitations: 21 member calls whose receiver is written several times in the same file, 6 qualified nested-type constructors Outer.Inner(...), and 3 self-loops from a type's static property calling its own initializer. On the other side, 164 EXTRACTED calls were added, 142 of them cross-file Type.member(...) calls whose receiver type was checked to match the target's owner.

Known limitations / unsupported cases

  • A receiver name written more than once in one file with a different type or in a different scope binds nothing (fail-closed), even when both writes name the same type in two enclosing types or spell it Outer.T and T. 21 correct same-file member calls on the app above are lost this way. A narrower rule is follow-up work.
  • A qualified nested-type constructor call Outer.Inner(...) reaches only Outer (a references edge) or nothing; the calls edge to Inner is not emitted (6 calls on the app above, plus 3 self-loop initializer calls).
  • An Objective-C class in a .h header that owns no Objective-C method (for example an @interface that declares only properties) is no longer a target of a Swift type-only references edge, since the gate cannot tell it from a C or C++ type (accepted loss of the .h fix above).
  • A method declared only on a superclass or protocol is not found by the member-call resolver (no inheritance walk); the call gets a type-only references edge.
  • The receiver table is flat per file: a name written once binds by that write's type label, without flow analysis.
  • The receiver check does not yet see if let / guard let / for bindings with a type annotation or tuple patterns (let (x, y): (State, Int)), and a local bound by a resolvable factory can still shadow a typed parameter of the same name, so such a receiver can bind to a same-named type elsewhere, as on v8 (follow-up).
  • The same receiver check does not yet follow generic constructors (let x = Box<Int>() through typealias Box<T> = Other<T>), wrapped initializers (try Box.make(), (Box.make())) or nested factory paths, and sees only shadowing declarations in the current file (a typealias declared in a type in another file, used from an extension of that type), so these receivers can still bind to a same-named type, as before this change (follow-up).
  • The fail-closed receiver rule is file-wide: one unproven write of a name drops that name's member calls in the whole file, including correct ones in other functions.
  • A dotted receiver path is shortened to its first segment when the corpus has any type table, so Outer.Inner.go() binds Outer.go, as on v8 (follow-up).
  • An extension written before its declaration in the same file (extension Outer.State above struct Outer) creates the node with the dotted label, so State() binds a top-level State, as on v8 (follow-up).
  • A static factory is chosen by bare label, so a nested factory that shadows a same-named top-level one binds make() but not the member call on its result (fail-closed; follow-up: choose the factory by lexical lookup).
  • In one file, a typed member call can still bind by bare label in the extractor before the scoped resolver runs, as on v8 (follow-up).
  • A same-file dotted reference to a type that exists only as an extension (no declaration in the corpus) stays on its stub (fail-closed).
  • tree-sitter-swift parse errors that swallow a declaration (fix(swift): parse an if let binding whose await operand is not a call #3542) are not addressed.
  • An incremental re-extraction (the watch and post-commit hook paths) does not re-resolve references in unchanged files when a declaration changes elsewhere (pre-existing, all languages).
  • The corpus is treated as one Swift module; per-target scoping (SwiftPM / Xcode targets) is an open question in the RFC.
  • Out of scope: nested receivers (a.b.go()), protocol-extension default implementations and conditional conformances.

Graphify-specific checklist

  • I updated generated skill artifacts (uv run python -m tools.skillgen --bless) when changing their source fragments. Not applicable: no skillgen fragments changed.
  • I confirmed that AST/structural extraction remains deterministic (no ambient state dependencies like ENV variables).
  • I reviewed changes for security implications (no unsafe interpolation into shell/Python).
  • I confirmed no API keys or local-only graph data are included.
  • (If applicable) I disclosed AI authorship in my commit messages.

🤖 Generated with Claude Code

idachev and others added 5 commits October 25, 2026 09:21
…e index

Swift has no per-type imports inside a module, so every cross-file type
name becomes a sourceless stub that the generic label-based passes must
repair. Several ordinary patterns defeated them:

- A declaration next to its own same-file `extension` shares the
  extension's id and was skipped as a merge candidate, so an extension
  of it in another file stayed a second sourced node and every
  reference from other files stayed on per-file stubs.
- An extension of a type declared outside the corpus (`extension View`,
  `private extension String`) acted as the declaration and absorbed
  same-named references (Graphify-Labs#4574).
- Nested type names were cut to their first segment (`Layout.Pane` ->
  `Layout`), and same-named nested types under different outers
  collapsed into one node (Graphify-Labs#4575).
- Cross-file constructor calls `Foo(...)` were always dropped, since a
  Swift file never imports a type from its own module.

What changes:

- Phase 1: `swift_extensions[]` records carry `declared`, and a node
  built only from `extension` blocks carries `_swift_extension_only`.
  Such a node is never a canonical merge or rewire target; the real
  declaration is, even with a same-file extension. `graphify update`
  keeps the marker on context nodes (cli.py, watch.py).
- Phase 2: Swift type nodes carry `_swift_qualified` paths, reference
  edges `_swift_scope`, and `swift_type_table` gains `scopes`. A new
  `_resolve_swift_type_references` pass binds references by Swift name
  lookup (innermost scope first) through `_swift_type_index` /
  `_swift_lookup` before the bare-label rewire, and fails closed on
  ambiguity. Extension targets resolve through the same lookup.
- Phase 3: nested types get their enclosing type's id, salted only on a
  collision with a member of the same slug.
- Phase 4: `Foo(...)` binds as an INFERRED `calls` edge with
  `context="constructor"` when the lexical lookup finds one type; the
  `callers` filter in serve.py keeps those edges.
- Member calls: receiver types resolve through per-file scopes; a
  receiver whose same-file writes disagree binds nothing and is not
  parked; dotted names never fall back to the label key; an extension of
  `[T]`, `[K: V]` or `T?` extends `Swift.Array` / `Swift.Dictionary` /
  `Swift.Optional`; only Swift callers are handled and only Swift or
  Objective-C targets are bound.

`_AST_CACHE_SCHEMA` goes to 26 because per-file Swift output changes.
Nested Swift type ids change, so saved queries naming one stop matching.

Fixes Graphify-Labs#4574
Fixes Graphify-Labs#4575

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Records the root causes (RC1-RC5), the phase design, the fixed
contracts and decisions, and the implementation notes behind the Swift
type index, so a reviewer can check the code against the intended
lookup rules and their fail-closed cases.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The Swift branches added to _extract_generic's walk() pushed it past
pyright's code-flow complexity limit ("Code is too complex to
analyze"), so pyright stopped checking the whole function and hid its
existing errors. The Swift class id, qualified-path bookkeeping,
sugar-extension label, scope stack push/pop and body-scope notes now
live in small nested helpers next to the other Swift helpers. No
behaviour change; upstream's own code in walk() is untouched.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…n-only ctor targets

Three defects found in review of the Swift type index:

- `Action.Delegate` slugged to the id of a same-file `case delegate`
  (ids are caseless; the case keeps the plain id and the nested type is
  salted), so the same-file shortcut in ensure_named_node pointed the
  reference at the enum case. A dotted Swift name declared in the file
  now maps to its nested type's real id first.
- A Swift extension of an Objective-C class folds onto the ObjC node,
  which has no `_swift_qualified`; _swift_caller_scope returned None and
  `Item()` inside that extension lost the constructor edge v8 had. A
  non-Swift owner now gives file scope "".
- The generic constructor fallback still accepted an
  `_swift_extension_only` node, so `External()` of a library type bound
  to `extension External`. Swift calls now drop such candidates.

The RFC D25 note now says which writes the same-file agreement check
sees; factory bindings and annotated locals are not covered yet.

Accepted risks:
- F2 `Outer.Inner.go()` binds `Outer.go`: the extractor keeps only the receiver head; same on v8 whenever any type table exists (follow-up).
- F3 a typealias and an upper-cased static factory with one name in one type let the factory retry treat an annotation as a call (artificial; needs per-entry provenance).
- F4 a same-file `extension Outer.State` before the declaration keeps the dotted label, so `State()` binds the top-level `State`, as on v8 (follow-up).
- F6 a nested factory shadowing a same-named top-level factory binds `make()` but not the member call on its result (fail-closed; follow-up: choose the factory by lexical lookup).
- F7 a same-file typed member call can still bind by bare label before the scoped resolver, as on v8 (follow-up).
- F8 factory bindings and annotated locals are outside the D25 agreement check, so one local name in two functions can bind to the first write, as on v8 (follow-up).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The round-1 fix mapped a dotted Swift name declared in the file to the
nested type at that absolute path. Inside `Outer`, `Model.Item` then
bound the top-level `Model.Item` instead of `Outer.Model.Item`, which
hides it. The older same-file id shortcut had the same flaw whenever
the top-level type came first in the file, and it is what let
`Action.Delegate` reach a `case delegate`.

A dotted Swift name now never takes the same-file id shortcut: it stays
a sourceless stub, and the existing Swift type pass binds it through
`_swift_lookup` from the edge's `_swift_scope`, as it already does for
cross-file dotted references.

Accepted risks:
- A same-file dotted reference to an extension-only node with no declaration anywhere (`extension A.B {}` plus `var x: A.B`) stays on a stub instead of the file-local extension node, like any undeclared type.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@idachev
idachev requested a review from safishamsi as a code owner October 25, 2026 08:33
@github-actions

Copy link
Copy Markdown

Thanks for the pull request, @idachev. A maintainer will review it soon.

Want to talk it through while it is in review? Come join us on our Discord server. For longer-form discussion there is also GitHub Discussions.

A couple of things that speed up review: make sure the test suite passes on Python 3.10 and 3.13, and that the change keeps extraction deterministic.

@graphify-labs graphify-labs Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Graphify reviewed this change.

No issues found by static checks — no coupling regressions or blocking issues in the code graph. That is not the same as safe to merge: see what was not checked.

Not checked: tests were not run; formal verification proved 0 of 14 changed function(s) (1 sampled, not proven, 12 not verified).

Formal verification. 1 change(s) alter behavior, breaking input(s) attached. PR-changed functions: 2/14 verified (0 proven, 1 may-equivalent, 1 distinguished) · 12 not verified (7 vacuous, 5 unsupported).

Behavior changes: \_swift\_classify\_base changes behavior, here is the input that shows it.

The verifier found a concrete input on which \_swift\_classify\_base behaves differently before and after the change. If that change is intended, ship it; if not, this is your bug.

Guarantee: This difference was REPRODUCED, the verifier actually ran both versions on that input and saw them disagree. It is real, not an artifact.

Evidence: On input \{"name":"'\.'","kind":"None","is\_first":"False","protocols":"set\(\)","classes":"\{''\}"\}, the old code produced 'implements' but the new code produces 'inherits' (outputs first differ at character 2). Paste that input straight into a regression test.

Not verified on this run: dispatch\_command (vacuous: never exercised), \_merge\_swift\_extensions (vacuous: never exercised), \_node\_label\_key (unsupported), \_resolve\_swift\_member\_calls (unsupported), \_rewire\_unique\_stub\_nodes (unsupported), \_extract\_generic (unsupported), \_swift\_collect\_type\_refs (vacuous: never exercised), \_swift\_constructor\_type (vacuous: never exercised), \_swift\_local\_var\_types (vacuous: never exercised), \_swift\_user\_type\_name (vacuous: never exercised), and 2 more.


Graphify review — findings

Fixes Swift cross-file type resolution so references to a type that has a same-file extension plus an extension in another file land on the real declaration instead of per-file sourceless stubs. Extensions of types declared outside the corpus (View, String) no longer pose as declarations and fail closed, nested types such as Layout.Pane keep their qualified identity, and cross-file constructor calls like Layout(panes: []) now bind to the declaration. It also stops the spurious "node 'foundation' is minted by two different files" warning for repeated import statements, and the AST cache schema bumps from 25 to 26, so existing caches rebuild once. Adds the RFC that traces the problem to five root causes and documents the phased plan, and the diff includes the Swift tests covering these cases.

Review partial — this diff was larger than one review pass covers, so later files were not reviewed; some findings may be missing.

Analysis details — impact, health, verification

Impact & health

Graphify review

Impact — 5376 functions depend on the 1822 functions this change touches.

Health — this change adds coupling hotspots:

  • worse: extract() — 1044 callers, 66 callees
  • worse: _rebuild_code() — 192 callers, 60 callees
  • worse: _extract_generic() — 20 callers, 47 callees
  • worse: _rewire_unique_stub_nodes() — 14 callers, 12 callees
  • worse: walk() — 1 callers, 88 callees
  • new: _assert_struct_untouched() — 7 callers, 4 callees
  • new: _assert_declaration() — 8 callers, 3 callees
  • new: _assert_external_extension() — 6 callers, 3 callees
  • …and 22 more — each is listed as a finding

Verification — 5376 functions in the blast radius were not formally verified this run (proofs are advisory here).

Gate & verification

graphify gate

PASS — objectively clean (no health regressions, tests not run — proofs not run this pass (advisory)). Grounded, not self-assessed.

Advisory (not blocking):

  • verification_scope: 5324 function(s) in the blast radius were not formally verified this run

Test selection

Test selection

461 of 461 test file(s) selected (100%) via static blast radius.

Escalated to a full run for safety — the selection is not trustworthy on its own (see below). CI should run the whole suite.

  • tests/pi.test.ts — full-run-safety
  • tests/test_affected_cli.py — impact, full-run-safety
  • tests/test_affected_defines.py — full-run-safety
  • tests/test_affected_member_seed.py — full-run-safety
  • tests/test_affected_overrides.py — impact, full-run-safety
  • tests/test_affected_path_file_node.py — full-run-safety
  • tests/test_agents_platform.py — impact, full-run-safety
  • tests/test_alias_folding.py — full-run-safety
  • tests/test_analyze.py — full-run-safety
  • tests/test_anthropic_custom_endpoint.py — full-run-safety
  • tests/test_antigravity_install.py — full-run-safety
  • tests/test_apm_fallback_version.py — full-run-safety
  • tests/test_architecture_doc.py — full-run-safety
  • tests/test_astro_extraction.py — impact, full-run-safety
  • tests/test_astro_import_ids.py — impact, full-run-safety
  • tests/test_atomic_canvas_export.py — full-run-safety
  • tests/test_atomic_version_stamp.py — full-run-safety
  • tests/test_atomic_writes.py — full-run-safety
  • tests/test_backend_env_isolation.py — full-run-safety
  • tests/test_backend_extras.py — full-run-safety
  • tests/test_backend_opt_in.py — full-run-safety
  • tests/test_benchmark.py — impact, full-run-safety
  • tests/test_benchmark_raw_graph.py — impact, full-run-safety
  • tests/test_benchmark_real_query.py — impact, full-run-safety
  • tests/test_binary_media_words.py — impact, full-run-safety
  • tests/test_blade_extractor.py — impact, full-run-safety
  • tests/test_build.py — impact, full-run-safety
  • tests/test_build_located_semantic_identity.py — full-run-safety
  • tests/test_build_merge_dedup_scope.py — full-run-safety
  • tests/test_build_merge_hyperedges_and_prune.py — full-run-safety
  • tests/test_build_merge_shrink_guard.py — full-run-safety
  • tests/test_builtin_global_type_refs.py — impact, full-run-safety
  • tests/test_c_include_resolution.py — impact, full-run-safety
  • tests/test_cache.py — impact, full-run-safety
  • tests/test_cache_long_paths.py — impact, full-run-safety
  • tests/test_cache_stale_import_target.py — impact, full-run-safety
  • tests/test_callflow_html.py — full-run-safety
  • tests/test_cargo_introspect.py — full-run-safety
  • tests/test_cargo_missing_manifest.py — full-run-safety
  • tests/test_carried_hyperedge_remap.py — full-run-safety
  • tests/test_case_sensitive_resolution.py — impact, full-run-safety
  • tests/test_charmap_encoding.py — impact, full-run-safety
  • tests/test_chunking.py — impact, full-run-safety
  • tests/test_cjs_module_extension.py — impact, full-run-safety
  • tests/test_claude_cli_backend.py — full-run-safety
  • tests/test_claude_md.py — full-run-safety
  • tests/test_cli_broken_pipe.py — full-run-safety
  • tests/test_cli_export.py — impact, full-run-safety
  • tests/test_cli_help.py — full-run-safety
  • tests/test_cloud_cta.py — impact, full-run-safety
  • … and 411 more

non-code file(s) changed (docs/swift-cross-file-type-resolution-rfc.md) → running the full suite for safety (a code graph can't see config/fixture/data deps)

changed code file(s) with no mapped test (docs/swift-cross-file-type-resolution-rfc.md) — a coverage gap or a missing link — running the full suite rather than only the selected tests

Selection is safe under the controlled-regression assumption; always-run tests + a periodic full run are the backstops. Advisory — it never changes the check verdict.

Docs that may be stale (advisory)

…and 10 more.

Formal verification

Behavior changes: \_swift\_classify\_base changes behavior, here is the input that shows it.

The verifier found a concrete input on which \_swift\_classify\_base behaves differently before and after the change. If that change is intended, ship it; if not, this is your bug.

Guarantee: This difference was REPRODUCED, the verifier actually ran both versions on that input and saw them disagree. It is real, not an artifact.

Evidence: On input \{"name":"'\.'","kind":"None","is\_first":"False","protocols":"set\(\)","classes":"\{''\}"\}, the old code produced 'implements' but the new code produces 'inherits' (outputs first differ at character 2). Paste that input straight into a regression test.

Could not verify: Could not verify dispatch\_command.

The verifier did not have enough to check dispatch\_command, so it is saying so rather than guessing. No false assurance is the whole point.

Guarantee: No guarantee either way, this is an honest abstention, not a pass.

Note: Reason: no capturable inputs from the test suite; property tier: not verifiable: all 40 sampled inputs raised on both versions — the function never executed, so 'no divergence' would be vacuous (mostly SystemExit — names the real obstacle, not a sampling gap)

Could not verify: Could not verify \_merge\_swift\_extensions.

The verifier did not have enough to check \_merge\_swift\_extensions, so it is saying so rather than guessing. No false assurance is the whole point.

Guarantee: No guarantee either way, this is an honest abstention, not a pass.

Note: Reason: no capturable inputs from the test suite; property tier: non-vacuity: domain too small (only 1 distinct inputs exercised, need 3) — 'no divergence' would be near-vacuous

Could not verify: Could not verify \_node\_label\_key.

The verifier did not have enough to check \_node\_label\_key, so it is saying so rather than guessing. No false assurance is the whole point.

Guarantee: No guarantee either way, this is an honest abstention, not a pass.

Note: Reason: no capturable inputs from the test suite; property tier: not verifiable: the input domain has 17 values but only 12 distinct were tested — a small finite domain must be EXHAUSTED, not sampled (an untested input could invert the result)

Could not verify: Could not verify \_resolve\_swift\_member\_calls.

The verifier did not have enough to check \_resolve\_swift\_member\_calls, so it is saying so rather than guessing. No false assurance is the whole point.

Guarantee: No guarantee either way, this is an honest abstention, not a pass.

Note: Reason: no capturable inputs from the test suite; property tier: not verified: a runtime divergence was observed, but the two versions' package snapshots loaded differently in the sandbox (old: {'fallback': {'graphify.extractors.julia': 'ModuleNotFoundError', 'graphify.extractors.objc': 'ModuleNotFoundError'}, 'missing': ['graphify.extractors.engine']}, new: {'fallback': {'graphify.build': 'ModuleNotFoundError', 'graphify.detect': 'ModuleNotFoundError', 'graphify.extractors.julia': 'ModuleNotFoundError', 'graphify.extractors.objc': 'ModuleNotFoundError'}, 'missing': ['graphify.extractors.engine', 'graphify.google_workspace', 'graphify.validate']}), so it may be an environment artifact rather than the edit

Could not verify: Could not verify \_rewire\_unique\_stub\_nodes.

The verifier did not have enough to check \_rewire\_unique\_stub\_nodes, so it is saying so rather than guessing. No false assurance is the whole point.

Guarantee: No guarantee either way, this is an honest abstention, not a pass.

Note: Reason: no capturable inputs from the test suite; property tier: not verifiable: the input domain has 81 values but only 11 distinct were tested — a small finite domain must be EXHAUSTED, not sampled (an untested input could invert the result)

No difference found (not proven): No behavior difference found in extract (not a proof).

The verifier ran both versions of extract on many inputs and saw identical behavior every time. Strong evidence the change is safe, but evidence, not a proof.

Guarantee: Empirical: differential testing (both versions run on many generated inputs). A divergence on an untested input remains possible, so this is 'no counterexample found', not 'proven equivalent'.

Note: An input the sampler did not try could still differ.

Could not verify: Could not verify \_extract\_generic.

The verifier did not have enough to check \_extract\_generic, so it is saying so rather than guessing. No false assurance is the whole point.

Guarantee: No guarantee either way, this is an honest abstention, not a pass.

Note: Reason: no capturable inputs from the test suite; property tier: parameter `config` is annotated `LanguageConfig` — outside the synthesizable primitive/collection set

Could not verify: Could not verify \_swift\_collect\_type\_refs.

The verifier did not have enough to check \_swift\_collect\_type\_refs, so it is saying so rather than guessing. No false assurance is the whole point.

Guarantee: No guarantee either way, this is an honest abstention, not a pass.

Note: Reason: no capturable inputs from the test suite; property tier: not verifiable: all 235 sampled inputs raised on both versions — the function never executed, so 'no divergence' would be vacuous (mostly AttributeError — names the real obstacle, not a sampling gap)

Could not verify: Could not verify \_swift\_constructor\_type.

The verifier did not have enough to check \_swift\_constructor\_type, so it is saying so rather than guessing. No false assurance is the whole point.

Guarantee: No guarantee either way, this is an honest abstention, not a pass.

Note: Reason: no capturable inputs from the test suite; property tier: not verifiable: all 228 sampled inputs raised on both versions — the function never executed, so 'no divergence' would be vacuous (mostly AttributeError — names the real obstacle, not a sampling gap)

Could not verify: Could not verify \_swift\_local\_var\_types.

The verifier did not have enough to check \_swift\_local\_var\_types, so it is saying so rather than guessing. No false assurance is the whole point.

Guarantee: No guarantee either way, this is an honest abstention, not a pass.

Note: Reason: no capturable inputs from the test suite; property tier: not verifiable: all 235 sampled inputs raised on both versions — the function never executed, so 'no divergence' would be vacuous (mostly AttributeError — names the real obstacle, not a sampling gap)

Could not verify: Could not verify \_swift\_user\_type\_name.

The verifier did not have enough to check \_swift\_user\_type\_name, so it is saying so rather than guessing. No false assurance is the whole point.

Guarantee: No guarantee either way, this is an honest abstention, not a pass.

Note: Reason: no capturable inputs from the test suite; property tier: not verifiable: all 228 sampled inputs raised on both versions — the function never executed, so 'no divergence' would be vacuous (mostly AttributeError — names the real obstacle, not a sampling gap)

Could not verify: Could not verify \_filter\_graph\_by\_context.

The verifier did not have enough to check \_filter\_graph\_by\_context, so it is saying so rather than guessing. No false assurance is the whole point.

Guarantee: No guarantee either way, this is an honest abstention, not a pass.

Note: Reason: no capturable inputs from the test suite; property tier: not verifiable: all 12 sampled inputs raised on both versions — the function never executed, so 'no divergence' would be vacuous

Could not verify: Could not verify \_rebuild\_code.

The verifier did not have enough to check \_rebuild\_code, so it is saying so rather than guessing. No false assurance is the whole point.

Guarantee: No guarantee either way, this is an honest abstention, not a pass.

Note: Reason: no capturable inputs from the test suite; property tier: nondeterministic output (both versions disagreed with themselves on the witness) — not a behaviour change; a function whose output is not a function of its inputs (random / time / uuid / os.urandom, or state carried across calls) cannot be soundly distinguished by execution, so this tier abstains for the whole function

· 20 grounded finding(s) anchored inline below; 5 more finding(s) on lines outside this diff (see the check run); 5 additional anchorable finding(s) not shown (cap).

return next((c for c in decl.children if c.type in _SWIFT_TYPE_BODY_TYPES), None)


def _swift_body_members(body_node, source: bytes) -> list[tuple[str, str]]:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Health regression — _swift_body_members()

fans out to 6 callees (efferent coupling).

Grounded coupling-delta finding (deterministic), not an LLM guess.

swift_nested_groups: dict = {}
swift_path_nids: dict[str, str] = {}

def _swift_member_nid(parent_path: str | None, parent_nid: str, name: str,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Health regression — _swift_member_nid()

high coupling complexity (Ca·Ce = 12).

Grounded coupling-delta finding (deterministic), not an LLM guess.

assert _xext_has_edge(result, file_node["id"], nid, "contains"), f"{ext_file} does not contain {nid}"


def test_declaration_with_same_file_extension_absorbs_cross_file_extension(tmp_path: Path):

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Health regression — test_declaration_with_same_file_extension_absorbs_cross_file_extension()

fans out to 6 callees (efferent coupling).

Grounded coupling-delta finding (deterministic), not an LLM guess.

assert expected <= refs, f"references that missed the declaration: {sorted(expected - refs)}"


def test_extension_of_outside_type_does_not_absorb_references(tmp_path: Path):

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Health regression — test_extension_of_outside_type_does_not_absorb_references()

fans out to 7 callees (efferent coupling).

Grounded coupling-delta finding (deterministic), not an LLM guess.

assert (".shout()", "return_type", "StringExt.swift") in _xext_incoming(result, string_ext["id"])


def test_extension_only_type_extended_in_two_files_stays_unresolved(tmp_path: Path):

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Health regression — test_extension_only_type_extended_in_two_files_stays_unresolved()

fans out to 6 callees (efferent coupling).

Grounded coupling-delta finding (deterministic), not an LLM guess.

assert not leftovers, f"the extension must not survive as its own node: {leftovers}"


def test_qualified_conformance_and_generic_args_resolve(tmp_path: Path):

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Health regression — test_qualified_conformance_and_generic_args_resolve()

fans out to 6 callees (efferent coupling).

Grounded coupling-delta finding (deterministic), not an LLM guess.


# ── controls ──────────────────────────────────────────────────────────────────

def test_ambiguous_bare_name_stays_on_stub(tmp_path: Path):

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Health regression — test_ambiguous_bare_name_stays_on_stub()

fans out to 6 callees (efferent coupling).

Grounded coupling-delta finding (deterministic), not an LLM guess.

}, "x.go() must not bind to OuterInner.go()"


def test_same_file_duplicate_nested_names_stay_ambiguous(tmp_path: Path):

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Health regression — test_same_file_duplicate_nested_names_stay_ambiguous()

fans out to 7 callees (efferent coupling).

Grounded coupling-delta finding (deterministic), not an LLM guess.

)


def test_no_cross_language_binding(tmp_path: Path):

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Health regression — test_no_cross_language_binding()

fans out to 6 callees (efferent coupling).

Grounded coupling-delta finding (deterministic), not an LLM guess.

assert ts_store not in targets


def test_swift_reference_to_non_swift_type_keeps_generic_rewire(tmp_path: Path):

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Health regression — test_swift_reference_to_non_swift_type_keeps_generic_rewire()

fans out to 8 callees (efferent coupling).

Grounded coupling-delta finding (deterministic), not an LLM guess.

idachev and others added 6 commits October 26, 2026 07:16
Behaviour is unchanged. Six small clean-ups in code this branch adds:

- Extract _swift_upper_navigation_path() and use it from both
  _swift_constructor_type() and _swift_navigation_type_head(), which
  carried the same upper-cased navigation-chain walk.
- _swift_record_class() calls _swift_is_extension() instead of
  repeating its body inline.
- _resolve_swift_member_calls() drops an is_swift_call check that the
  early Swift-only gate already guarantees.
- _resolve_swift_type_references() builds the node list for the type
  index once and reuses it for the Swift source ids.
- engine.py imports _SWIFT_TYPE_REFERENCE_RELATIONS from resolution.py
  instead of defining an identical _SWIFT_SCOPED_RELATIONS, so the walk
  that stamps the scope and the pass that reads it share one set.
- The RFC names _swift_salted_member_nid without a stale line range.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Replace the example type, file and member names in the RFC, in the
Swift test fixtures and in a few code comments with neutral ones
(Shape, Shape.Point, Canvas.State, Converter, Recipe), renamed
consistently in the asserted labels, paths and ids. The RFC's real-app
section no longer quotes file paths, line numbers, file sizes or exact
corpus counts. Test structure and assertions are unchanged; the code
changes are comment-only.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The Swift member-call target gate admitted every `.h` target, but a header
can be C or C++ as well as Objective-C, so `Inner.go()` bound a C++
`Inner::go`, and a missing method fell back to a type-only `references`
edge to the C++ class. A `.h` target now binds only when it is an ObjC
method (its label carries the `+`/`-` sigil) or a type that owns one.

The label and the method edges are already persisted, so the rule also
holds on incremental rebuilds; per-file output is unchanged, so no cache
schema bump. The change only removes edges. Accepted loss: a type-only
`references` edge to an ObjC class with no ObjC method in the corpus.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The Swift constructor branch, its extension-only candidate filter, the
dotted-stub guard, the Swift type index, the type-reference source set and
the type-reference file selection tested the raw file name, so a file
remapped to Swift in .graphifyrc lost or gained the wrong edges, and a
corpus of .SWIFT files skipped the type-reference pass. One helper,
_is_swift_source, now decides by the effective suffix, case-insensitively.

All six checks run in the cross-file passes; per-file output is
unchanged, so no cache schema bump.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…clarations

A nested Swift type's id joins its parent's id and its name, so
`Outer.State` and a file-level `Outer_State` or `outer_state()`, or
`Outer.A.B` and `Outer.A_B`, minted one id; add_node dropped the second
node and its methods hung under the survivor.

A per-file pre-scan now records the owners of each plain id. A nested
type yields to any member or function and to any type of the same or a
shallower depth, and is salted, so the shallower declaration keeps the
plain id and the outcome does not depend on declaration order. A member
that its sibling collision group already salts does not count as holding
the plain id, so no id is salted needlessly. Written references such as
`Outer.State` stay stubs and the Swift type pass binds them to the salted
node through its qualified path.

This changes per-file ids for affected .swift files; the AST cache schema
bump already in this series covers it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A Swift receiver whose written type goes through a typealias, an
associatedtype, a generic parameter or parameter pack, a type declared
inside a function, closure or accessor body, or a `Self`-qualified path
names a type the corpus type index cannot see. The in-file bare-label
bind and the corpus resolver then bound the call to an unrelated
same-named type.

Such a write now marks the name's scope unknown at once (a sticky
`scopes[name] = None`, the same mark two conflicting writes leave), so
nothing is bound and nothing is parked. The same holds for binding sites
the receiver table does not read: typed locals, typed closure parameters,
every name of a multi-binding property, file-scope bindings, and
initializers or factories through an unproven type, annotated or not. A
scopes-only result is serialized so the mark reaches the AST cache, and
the resolver checks the unknown scope before the upper-case type arm, so
a variable spelled `X` is not the type `X`. The change only removes
edges: `var x: A; x.go()` still binds `A.go`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

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

None yet

Projects

None yet

1 participant