Skip to content

feat(extract): bridge frontend/backend HTTP boundaries with shared http_endpoint nodes - #5232

Open
armbrusl wants to merge 1 commit into
Graphify-Labs:v8from
armbrusl:feat/http-endpoint-linking
Open

armbrusl wants to merge 1 commit into
Graphify-Labs:v8from
armbrusl:feat/http-endpoint-linking

Conversation

@armbrusl

Copy link
Copy Markdown

What does this PR do?

Implements the first client/server adapter pair proposed in #1595: the frontend island and the backend island of a full-stack repo share no code edge — the frontend calls fetch('/api/devices'), the backend binds path("devices", views.devices), and the wire between them has no node in the graph. graphify affected <a backend view> therefore cannot see the client call sites that break when a response shape changes.

Two suffix-gated language resolvers mint one deterministic http_endpoint node per normalized URL pattern, and each side binds to it:

  • django_routes (.py): a urls.py tree walk stamps path()/re_path()/include() calls — module-level route declarations never reach the generic raw_call walk — then composes include() prefixes and binds views through import evidence: one serves edge per unambiguously resolved route.
  • http_fetch_calls (JS/TS/Svelte/Vue/Astro): fetch()/axios call sites get their first string argument stamped onto raw_calls (config-gated via http_callees): one calls_endpoint edge per caller.

Placeholder syntaxes converge on one node: fetch(\/api/runs/${id}`)and Django'sapi/+runs/int:run_id` normalize identically (endpoint ids are hash-addressed, terraform-scope style, so both derivations meet by construction).

Two deliberate deviations from #1595, offered for discussion:

  1. EXTRACTED rather than INFERRED. Each edge is explicit text in source — the call site names the URL it fetches, the route names the view it serves — and the cross-boundary meeting is node identity, not a matched guess. Nothing is inferred, so nothing should be discounted.
  2. v1 matches path only. Django's path() declares no HTTP method, so method agreement (this issue's guard) is impossible to honor for this server framework; observed methods are recorded in the endpoint node's metadata instead. A verb-declaring server adapter (Express, @GetMapping) can raise the bar later.

Client paths with no server route (and vice versa) mint an orphan node with origin metadata — the dangling-contract drift in #1595 is visible without emitting any edge.

Design lives in graphify/http_endpoints.py (shared contract: normalization, id, node/edge builders, guards); graphify/django_routes.py and graphify/http_fetch.py are the adapters; stamping sits in the python extractor and the generic engine's raw_call emission, gated by http_callees on the language config.

Real-world check (Svelte + Django repo, 232 files; before → after: 1780 → 1802 nodes, 5349 → 5387 edges):

graphify path frontend/src/main.js backend/api/views.py
  main.js --contains--> boot() --calls_endpoint--> /api/devices --serves--> devices() <--contains-- views.py
  Path confidence: EXTRACTED (4 hops)

Type of change

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

Verification & Invariants

  • Read the CONTRIBUTING.md guide.
  • Reproduced the gap and identified the invariant: path between a frontend file and a backend file exits with "no route" on 0.9.110; the invariant this protects is extraction determinism — endpoint ids derive from pattern text alone (no fs order, no env, no timestamps), so both derivations meet and re-extraction is stable.
  • Regression tests fail pre-change: the engine stamp tests fail with the engine.py hunk stashed (verified via git stash), and the resolver gate test fails before registration wiring.
  • AST cache: schema bumped 47 → 48 so existing urls.py cache blobs (which carry no route stamps) are retired, not silently misread.
  • Fail-closed guards: include() module strings and view references resolve only on exactly one candidate (zero or many → park name-only, never a guessed edge); duplicate (source, target, relation) keys are skipped; re-drive idempotence asserted by node identity.
  • Documented limitations: regex re_path routes are parked (unresolved_route), not bound; module-level fetch() calls are outside the JS function-body walk; axios capture keys on the literal receiver name; matching is path-only (see deviation 2).

How was this tested

uv run pytest tests/test_http_endpoints_integration.py tests/test_django_routes.py \
              tests/test_http_fetch_calls.py tests/test_language_resolvers.py \
              tests/test_cache.py tests/test_svelte_extraction.py -q
  -> 135 passed, 1 skipped

uv run pytest tests/ -q
  -> 18 failed, 11066 passed, 356 skipped, 1 xfailed in 427.57s
     (the 18 failures pre-exist this change — 12 x tests/test_skillgen.py,
     6 x tests/test_ext_tagged_id_clash.py — byte-identical on the pristine
     v8 checkout at aaafbb4, and with this PR's engine hunk stashed)

uv run ruff check .
  -> All checks passed!

uv run pyright <all eight touched/new files>
  -> 0 errors in every new or touched file; graphify/extract.py reports 150
     pre-existing basic-mode errors, none inside this PR's hunks

@armbrusl
armbrusl requested a review from safishamsi as a code owner November 15, 2026 20:57
@github-actions

Copy link
Copy Markdown

Thanks for the pull request, @armbrusl. 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.

…tp_endpoint nodes

A full-stack repo extracts as two disconnected islands: the frontend calls
fetch('/api/devices') while the backend binds path("devices", views.devices),
and no static edge can cross the gap (the coupling is an API contract, which
the code graph has no node for). First adapter pair proposed in Graphify-Labs#1595.

Two suffix-gated language resolvers mint one deterministic http_endpoint node
per normalized URL pattern, so the contract becomes the meeting point:

- django_routes (.py): a urls.py tree walk stamps path()/re_path()/include()
  calls (module-level route declarations never reach the generic raw_call
  walk), then composes include() prefixes and binds views through import
  evidence: one serves edge per unambiguously resolved route.
- http_fetch_calls (JS/TS/Svelte/Vue/Astro): fetch()/axios call sites get
  their first string argument stamped onto raw_calls (config-gated via
  http_callees): one calls_endpoint edge per caller.

Both edges are EXTRACTED because each is explicit text in source, and the
cross-boundary meeting is node identity, not a matched guess. Placeholder
syntaxes converge on one node: fetch(`/api/runs/${id}`) and Django's
api/ + runs/<int:run_id> normalize identically. Ambiguity fails closed
(unresolved views and regex routes park name-only; duplicate pairs are
skipped), and re-extraction stays idempotent across the AST cache (schema
48), including incremental updates.

Limitations: regex re_path routes are parked, not bound; module-level
fetch() calls are outside the JS walk; axios capture keys on the literal
receiver name; matching is path-only because Django's path() declares no
HTTP method (observed methods land in the endpoint node's metadata).

Co-Authored-By: GLM 5.3 <[email protected]>

@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; no formal proof of the changed code.


No blocking issues. I didn't find anything I'd hold the merge for.

Analysis details — impact, health, verification

Impact & health

Graphify review

Impact — 0 functions depend on the 0 functions this change touches.

Health — grade A; no new coupling hotspots.

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

Diff could not be reliably attributed to this PR: the base/head merge-base was unreachable in the shallow clone, so detailed findings were skipped (rather than emit a two-dot diff, which would misattribute base-branch changes).

Gate & verification

graphify gate

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

Test selection

Test selection

0 of 584 test file(s) selected (0%) via static blast radius.

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.

@LHopitalOne

Copy link
Copy Markdown
Contributor

Nice work, this is the shape I'd hoped for. Two small things I ran into while writing edges in the same shape from a cross-repo tool:

  1. calls_endpoint and serves aren't in DEFAULT_AFFECTED_RELATIONS, so graphify affected "<view>" doesn't reach the frontend caller unless you pass --relation calls_endpoint --relation serves. Worth adding both?
  2. The edges carry context="http", so "who calls <view>" (which infers a call filter) drops them too. Adding calls_endpoint to the relations a call filter matches would fix that. My small PR for cross-repo calls adds that mechanism: fix(serve): keep cross-repo calls edges when a query filters on call #5257.

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

Development

Successfully merging this pull request may close these issues.

2 participants