Skip to content

FE-1415: Generate import edges for Python packages - #9252

Draft
kube wants to merge 1 commit into
cf/fe-1447-arch-docs-emit-layer-facts-and-relations-as-structured-datafrom
cf/fe-1415-arch-docs-generate-import-edges-for-python-packages
Draft

FE-1415: Generate import edges for Python packages#9252
kube wants to merge 1 commit into
cf/fe-1447-arch-docs-emit-layer-facts-and-relations-as-structured-datafrom
cf/fe-1415-arch-docs-generate-import-edges-for-python-packages

Conversation

@kube

@kube kube commented Aug 19, 2026

Copy link
Copy Markdown
Collaborator

🌟 What is the purpose of this PR?

Implements FE-1415: Python packages had layers but no edges, because the import graph came from dependency-cruiser (TypeScript only). The optimizer's real dependency on the Python bindings was invisible, and its diagram suggested dead code.

The bundle now derives Python import edges the same way as TypeScript ones. The visible result:

{ "from": "optimizer", "to": "python-bindings", "provenance": "imports", "fileDependencies": 2, "crossesPackage": true }

Top of stack #9226, on FE-1447.

🔗 Related links

  • FE-1415 (internal): this PR
  • FE-1443 (internal): complementary. No Python import crosses the subprocess boundary, so the declared python-bindings → cli edge stays declared, and the duplicate check confirms the two never overlap.

🔍 What does this change?

libs/@local/petrinaut-arch-docs:

  • Provider split (graph.ts): buildGraph splits covered packages by language. TypeScript goes through dependency-cruiser as before; Python goes through a new collector. Both produce the same file-level dependency records, so aggregation, intra-layer dropping, example pairs, crossesPackage, rules, and the declared-edge duplicate check apply to Python unchanged.
  • python-imports.ts (new, no dependencies): a line-based parser for import a.b and from a.b import c (aliases, comma lists, parenthesised continuations, relative imports), a module index over the covered Python packages, and a resolver. Imports that resolve to nothing covered (stdlib, third-party) drop silently, matching the TypeScript behaviour. A false negative beats a false positive: strings and comments are skipped conservatively.
  • Stale captions retired: the relations-card note and content/index.mdx no longer say Python contributes no edges.

Edge count: 198 → 199. The one new edge is the optimizer's import of the bindings; intra-package Python imports aggregate away as intra-layer, as they should.

Pre-Merge Checklist 🚀

🚢 Has this modified a publishable library?

This PR:

  • modifies a workspace but not a publishable library

📜 Does this require a change to the docs?

The changes in this PR:

  • require changes to docs which are made as part of this PR

🕸️ Does this require a change to the Turbo Graph?

The changes in this PR:

  • do not affect the execution graph

🛡 What tests cover this?

  • python-imports.test.ts (new): parsing (absolute, from-import, aliases, relative, continuations, comment/string non-matches), module indexing, resolution.
  • graph.test.ts: a full-chain assertion that a Python cross-package import aggregates into an edge.
  • lint:arch-docs exercises the real repo: 199 edges, zero diagnostics.

❓ How to test this?

  1. yarn workspace @local/petrinaut-arch-docs lint:arch-docs — 199 edges.
  2. turbo run dev --filter @apps/petrinaut-docs — the optimizer page shows python-bindings under "Depends on" with an import count, and the overview diagram draws the solid edge next to the dashed declared one.

🤖 Generated with Claude Code

@kube kube self-assigned this Aug 19, 2026
@vercel

vercel Bot commented Aug 19, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
hash Ready Ready Preview Aug 20, 2026 10:54am
petrinaut Ready Ready Preview Aug 20, 2026 10:54am
petrinaut-docs Ready Ready Preview Aug 20, 2026 10:54am
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
hashdotdesign-tokens Ignored Ignored Preview Aug 20, 2026 10:54am

@vercel
vercel Bot temporarily deployed to Preview – petrinaut August 19, 2026 15:59 Inactive
@github-actions github-actions Bot added area/libs Relates to first-party libraries/crates/packages (area) type/eng > backend Owned by the @backend team labels Aug 19, 2026
@kube
kube force-pushed the cf/fe-1415-arch-docs-generate-import-edges-for-python-packages branch from 3ef4667 to 58ce62d Compare August 19, 2026 16:06
@vercel
vercel Bot temporarily deployed to Preview – petrinaut August 19, 2026 16:06 Inactive
@kube
kube force-pushed the cf/fe-1415-arch-docs-generate-import-edges-for-python-packages branch from 58ce62d to 5ad8d7e Compare August 19, 2026 16:15
@vercel
vercel Bot temporarily deployed to Preview – petrinaut August 19, 2026 16:16 Inactive
@kube
kube force-pushed the cf/fe-1415-arch-docs-generate-import-edges-for-python-packages branch from 5ad8d7e to 3fe1939 Compare August 19, 2026 16:22
@vercel
vercel Bot temporarily deployed to Preview – petrinaut August 19, 2026 16:23 Inactive
@kube
kube force-pushed the cf/fe-1415-arch-docs-generate-import-edges-for-python-packages branch from 3fe1939 to dad50f8 Compare August 19, 2026 16:47
@vercel
vercel Bot temporarily deployed to Preview – petrinaut August 19, 2026 16:47 Inactive
@kube
kube force-pushed the cf/fe-1415-arch-docs-generate-import-edges-for-python-packages branch from dad50f8 to 41682c6 Compare August 19, 2026 17:32
@kube
kube force-pushed the cf/fe-1415-arch-docs-generate-import-edges-for-python-packages branch from 5323c1d to 3dd9e5b Compare August 19, 2026 22:16
@kube
kube force-pushed the cf/fe-1415-arch-docs-generate-import-edges-for-python-packages branch from 3dd9e5b to d705288 Compare August 19, 2026 22:54
@kube
kube force-pushed the cf/fe-1415-arch-docs-generate-import-edges-for-python-packages branch from d705288 to 6ab77ad Compare August 19, 2026 22:56
@kube
kube force-pushed the cf/fe-1415-arch-docs-generate-import-edges-for-python-packages branch from 6ab77ad to a1241c6 Compare August 19, 2026 23:45
@kube
kube force-pushed the cf/fe-1415-arch-docs-generate-import-edges-for-python-packages branch from a1241c6 to 5ffe338 Compare August 20, 2026 00:26
@kube
kube force-pushed the cf/fe-1415-arch-docs-generate-import-edges-for-python-packages branch from 5ffe338 to 3eacd7f Compare August 20, 2026 00:29
@kube
kube force-pushed the cf/fe-1415-arch-docs-generate-import-edges-for-python-packages branch from 3eacd7f to 12dab88 Compare August 20, 2026 00:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/libs Relates to first-party libraries/crates/packages (area) type/eng > backend Owned by the @backend team

Development

Successfully merging this pull request may close these issues.

1 participant