Repository navigation
feat(resolve): bind Tauri commands to their invoke call sites - #217
Merged
Merged
Conversation
A `#[tauri::command]` read as dead code: nothing connected the Rust function to
the `invoke('name')` that calls it, so `callers get_mcp_port` answered "No
callers found" for a command the frontend used on every launch. The IPC boundary
was simply absent from the graph.
A TauriResolver now spans it. It emits one namespaced reference per
literal-argument `invoke` call site and binds it to the command whose wire name
matches, accepting both the snake_case attribute name and the camelCase spelling
`tauri-specta` generates. An edge is built only when exactly one command claims
the name; a name claimed twice is poisoned permanently, so an ambiguous roster
yields no edge rather than a guess. That rule is the only protection available
here, because Rust has no language family and `Calls` bypasses the cross-family
gates regardless.
Both text scans are lexically masked, and each mask carries a different burden of
proof. On the TypeScript side the extractor already discriminates every shape, so
the mask is held to agreeing with it: a comment, a string, a template literal, a
regex literal and a `client.invoke(...)` member call each contribute nothing,
while the one real call contributes one edge. On the Rust side nothing else
discriminates, so the mask is the only defense — without it a commented-out or
raw-string copy of the attribute promotes the real unattributed function of the
same name, which turns a plain helper into a command and fabricates an edge to
it. The same mask keeps this repository from detecting itself as a Tauri project
off the literal in the resolver's own source.
References are file-granular, so `callers` names the calling file rather than the
enclosing function: reconstructing that id is unsafe when a call site may sit in
an arrow function, a class method, or an object literal that mints no node at
all. `invoke(cmdName)`, template-literal names, `generate_handler!` registration
and the typed `commands.*` binding path are deliberately out of scope.
EXTRACTION_VERSION 7 -> 8: the references are persisted, so a v7 index would
otherwise keep skipping unchanged files and never gain them.
Codecov Report❌ Patch coverage is
❌ Your patch check has failed because the patch coverage (93.17%) is below the target coverage (95.00%). You can increase the patch coverage or adjust the target coverage. @@ Coverage Diff @@
## main #217 +/- ##
==========================================
- Coverage 95.30% 95.28% -0.03%
==========================================
Files 139 140 +1
Lines 76041 77287 +1246
==========================================
+ Hits 72472 73642 +1170
- Misses 3569 3645 +76
... and 6 files with indirect coverage changes 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Tier 4 item 10 of the post-
v1.5.0upstream sync (#1543). A#[tauri::command]read as dead code — the IPC boundary was absent from the graph:What it does
TauriResolveremits one namespaced reference per literal-argumentinvokecall site and binds it to the command claiming that wire name, accepting both the snake_case attribute name and the camelCase spellingtauri-spectagenerates.An edge is built only when exactly one command claims the name; a name claimed by a second, different target is poisoned permanently. That rule is the only protection available here —
Language::RustreturnsNonefromlanguage_family, socrosses_known_familynever fires for a Rust target, andCallsbypasses those gates regardless.Both text scans are masked, with different burdens of proof
On the TypeScript side the extractor already discriminates every shape, so the mask is held to agreeing with it. Measured on one
.tsxfixture carrying all six shapes:// invoke('fake')"invoke('fake')"`invoke('fake')`/invoke\('fake'\)/client.invoke('fake')await invoke('get_mcp_port')On the Rust side nothing else discriminates, so the mask is the sole defense. Without it, a commented-out or raw-string copy of the attribute promotes the real unattributed function of the same name — those copies mint no node, so the same-file/same-name join has exactly one candidate and it is the wrong one:
Pre-fix that adversarial fixture produced 6 fabricated edges where the correct answer is one. The same mask also keeps this repository from detecting itself as a Tauri project off the literal in the resolver's own source — the raw scan finds 2 files, the masked scan finds 0.
Negatives cover nested block comments,
r##/br##, byte strings, char-versus-lifetime, and thetauri::commandanttoken-boundary collision, each with a roster key-set test and an end-to-end edge-count test.Deliberately out of scope
References are file-granular, so
callersnames the calling file rather than the enclosing function: reconstructing that id is unsafe when a call site may sit in an arrow function, a class method, or an object literal that mints no node at all.invoke(cmdName), template-literal names,generate_handler!registration (so an attributed-but-unregistered command still gets an edge, asserted deliberately), and the typedcommands.*path are not handled.Verification
make cigreen: 133 suites / 3371 passed / 0 failed (baseline 132 / 3304).EXTRACTION_VERSION7 → 8, three edits as the plan required;CURRENT_STORAGE_PROTOCOLstays 2; no newEdgeKind, no schema change.reference/untouched; erlang's 2 legitimate recursivecallsself-edges intact;tests/frameworks.rszero diff (itsMockContextsupplies no.rsfile, so all four probes miss and its React-only assertion stays true).tauri.conf.jsonapart — diff empty,framework=0,tauri_ns=0, on a 582-file snapshot taken withgit ls-files --cached --others --exclude-standardso the new untracked files are actually in it.2 reindexed, 0 skipped→ 2 edges at version 8; without it,0 reindexed, 2 skipped→ 0 edges, version 7. A v7 index would have kept skipping unchanged files forever.Three deviations from the plan, each measured
resolve_and_persistcallsdelete_resolved_rows(resolver.rs:1416), sotauri:invoke:%inunresolved_refsreads 0 post-pipeline and those assertions passed vacuously on an empty set. Re-expressed on edges, with anindex_without_resolveharness for the in-suite lexical comparison.*/, so onlystill comment */leaked. Strengthened to/* outer /* inner */ #[tauri::command]….]/(requirement already rejectscommandant, so the original probe broke nothing.The plan cleared four review rounds and ten blockers. One of those blockers was mine and wrong: I demanded the design anchor on the extractor's stored refs, which is impossible at this tier —
FrameworkExtractionContextis{ project_root, godot_dsl }andResolutionContexthas zero ref-facing methods.