Help us shape the future of Go! Take the 2026 Go Developer Survey

link

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 18, 2026 License: AGPL-3.0 Imports: 1 Imported by: 0

Documentation

Overview

Package link — http_match.go implements W2 of schema 1.9 (cross-language HTTP client → server matching).

The per-language parsers (Go: internal/parse/golang/distributed.go, TS: internal/parse/typescript/http_client.go) detect client-side call sites (fetch/axios in TS, http.Get / http.Client.Get / http.NewRequest in Go) and emit:

  • An AMBIGUOUS placeholder Endpoint with Language="external", qname "http:METHOD /path" (or "http:* /path" when the verb is unknown).
  • An http_calls edge from the caller Function/Method to that placeholder.

MatchHTTPClients runs ONCE after graph.Build and all per-language parsers have produced their nodes/edges. It walks every placeholder Endpoint and either:

  1. Rewires the http_calls edge to a matching real Endpoint (Language="go" or "ts" — emitted by W1 server-side detection) using the 2-stage cascade specified in schema-1.9-spec §6.9:

    a) Specific-verb lookup: `http:METHOD /path` exact match. b) Miss → wildcard fallback: `http:* /path` exact match.

    The matcher uses EXACT path matching (§3.3 decision: V0 chooses exact-match over suffix-match because false-positives across distinct services sharing path suffixes — e.g. two microservices each exposing /api/users — are far worse than the false-negatives exact-match incurs in well-curated monorepos).

  2. Leaves the placeholder + edge alone (§6.3 (B)) when no match is found — surfacing the call as an external-API dependency for audit.

Rewired placeholders are deleted from the graph (they have no remaining inbound edges that matter — the `defines` edge from the parser-emitting file is also deleted since the placeholder no longer represents a node in the file). This keeps the final graph tidy: a successful match leaves no AMBIGUOUS Endpoint residue.

Package link runs cross-language linking after per-language Pass 2 (spec §4.7). V0 implements only Sol -> TS bindings via name match. Cross-lang Go links are V1+.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SolToTS

func SolToTS(nodes []types.Node, abi map[string][]ABISig) []types.Edge

SolToTS emits binds_to edges from each Solidity Contract node to a matching TypeScript Class node sharing the same Name. The ABI map is retained to support future signature-aware matching.

Types

type ABISig

type ABISig struct {
	ContractName string
	FunctionName string
	ParamTypes   []string
}

ABISig mirrors solidity.ABISig to avoid coupling link → parse/solidity.

type HTTPMatchResult

type HTTPMatchResult struct {
	// Rewired counts http_calls edges whose Dst was successfully redirected
	// from a placeholder to a real Endpoint.
	Rewired int
	// SpecificHits counts rewires that matched on the specific verb (stage 1).
	SpecificHits int
	// WildcardHits counts rewires that matched on the wildcard fallback (stage 2).
	WildcardHits int
	// AmbiguousRetained counts placeholder Endpoints that remained in the
	// graph because no server-side Endpoint matched (external-API calls).
	AmbiguousRetained int
	// PlaceholdersDropped counts placeholder Endpoint nodes (and their
	// inbound `defines` edges) removed because every http_calls edge using
	// them got rewired.
	PlaceholdersDropped int
}

HTTPMatchResult captures aggregate counts so callers can log the matching outcome without re-walking the graph.

func MatchHTTPClients

func MatchHTTPClients(nodes []types.Node, edges []types.Edge) ([]types.Node, []types.Edge, HTTPMatchResult)

MatchHTTPClients applies the §6.9 cascade matching pass to nodes/edges, returning the new node/edge slices plus a result summary. The function is pure (no side effects beyond constructing the return values) so the caller can apply the result atomically.

Behaviour:

  • Real Endpoint = NodeEndpoint with SubKind="http" and Language != "external".
  • Placeholder Endpoint = NodeEndpoint with SubKind="http" and Language="external".
  • For each http_calls edge whose Dst is a placeholder: try cascade match. On hit: rewrite Dst; mark placeholder for removal IF no other http_calls edge still points at it. On miss: leave alone.
  • Placeholder Endpoint with NO inbound http_calls edges after matching: dropped (shouldn't normally occur — every placeholder is created alongside its http_calls edge).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL