Repository navigation
fix: resolve workspace imports, stylesheet tokens and generic handler bindings; record what a scan excluded - #3605
Freekvdijk12 wants to merge 7 commits into
Conversation
CODE_EXTENSIONS did not include .css, so stylesheets fell through classify_file() as unclassified and never reached an extractor. Co-Authored-By: Claude Sonnet 5 <[email protected]>
A class implementing a known binding interface generically over its subject type (IRequestHandler<TRequest>, AbstractValidator<T>, an IPipelineBehavior, an IEntityTypeConfiguration) only ever produced a references/implements edge to the interface itself, so a query for "what handles this request" or "what validates this model" had no edge to walk. Add _CSHARP_BINDING_GENERICS mapping each interface to its subject type-argument position and the relation to emit, and repoint that edge cross-file the same way inherits/implements/references already are. The handles relation is stored request -> handler (reversed from the English verb) so a lookup that starts at the request type walks straight to its handler; validates/configures/ intercepts keep the type -> subject direction. Extend the context-hint vocabulary in serve.py with a type_binding context so a query naming "handler" or "validator" maps onto it. Co-Authored-By: Claude Sonnet 5 <[email protected]>
.css reached classify_file() as code with no extractor wired to it, so a stylesheet contributed nothing to the graph. Add extract_css, which resolves each @import through the shared JS/TS import resolver (a relative path, tsconfig alias, or workspace package) instead of dropping the reference, and register it in the extension dispatch table. Co-Authored-By: Claude Sonnet 5 <[email protected]>
extract_css already recorded a stylesheet's own --custom-property definitions and its var() references, but a reference from a DIFFERENT file had no definition node in scope, so it stayed pointing at the raw token name instead of the file that declares it — and a Tailwind-preset color/shadow utility used from a .ts/.tsx class name had no token-reference path at all. Add design_tokens.py (read_tailwind_preset, scan_token_refs) and a _resolve_design_token_refs pass that binds both kinds of reference — across every scanned file — to the real --property or preset-utility node, folding a -rgb variant onto its base token. Add uses_token to DEFAULT_AFFECTED_RELATIONS so a token change's blast radius includes the files that consume it. Co-Authored-By: Claude Sonnet 5 <[email protected]>
detect() already computed which paths it ignored, pruned as noise, or left unclassified, and extract() already detected files taken in only partially after a syntax error — both were reported in a scan's return value or a stderr line and then discarded. Write every one of these as a row (kind, path, reason) to graphify-out/EXCLUDED.tsv so the excluded set survives past the run that computed it, anchored at cache_root when one is given so an --out run does not plant the file in the scanned corpus. Co-Authored-By: Claude Sonnet 5 <[email protected]>
…twin _EXPORT_CONDITION_PRIORITY does not query a `development` condition, so an exports map naming only `development` and `default` resolves to the `default` catch-all instead of the intended condition. Add it right after `source`. A workspace-relative candidate under a package's `dist/` can be a real file on disk (the build ran) that still sits outside the scanned corpus, so resolving straight to it produces an edge to a node the graph never extracted. Add _source_twin_of_build_output and try a candidate's extensionless `src/` counterpart first, so the edge lands on the source file the build compiles from instead. Co-Authored-By: Claude Sonnet 5 <[email protected]>
Part A fed extract() only the 'code' category, so a document-classified file with a real structural extractor of its own (Markdown, for instance) never reached it — Part B's semantic pass deliberately skips code and was never meant to be the only path for a document a structural extractor already covers. Walk the document category too in core.md, devin.md and aider.md, keeping only the files _get_extractor recognizes, and regenerate every rendered skill artifact and its expected/ snapshot. Add a monolith-roundtrip predicate sanctioning the change for the two hand-maintained monolith bodies. Co-Authored-By: Claude Sonnet 5 <[email protected]>
There was a problem hiding this comment.
Graphify reviewed this change.
Worth a look — the grounded gate found no coupling regressions or blocking issues, but 5 advisory finding(s) below merit a look before merge.
Formal verification. 1 change(s) tested, no difference found (not proven).
Graphify review — findings
Adds first-class design-token support to extraction: .css files are now scanned (via extract_css) and classified as code, and a new _resolve_design_token_refs pass binds var(--x) and Tailwind-utility references to their defining CSS custom-property or preset node, emitting uses_token edges (dropping any that stay unresolved and logging the count). Extends the semantic relation set with handles, validates, configures, and intercepts so they flow through stub-rewiring and C#-scoped resolution, and adds uses_token to the affected-relation defaults. Writes an EXCLUDED.tsv register into the output dir at the end of detect, recording each ignored/pruned/unclassified/sensitive path with its reason, atomically and routed to cache_root when given so it stays out of the scanned corpus.
Worth a look
- Default affected traversal now includes uses_token edges —
graphify/affected.py:32· Escalate · medium- agreed by 2 of 2 members but NOT verified (no proof, no reproducing execution) — consensus is not a verdict; needs human review
- CSS @import url(...) statements are never extracted —
graphify/extractors/css.py:11· Escalate · medium- agreed by 2 of 2 members but NOT verified (no proof, no reproducing execution) — consensus is not a verdict; needs human review
- CSS extractor treats custom properties inside block comments as real definitions —
graphify/extractors/css.py:31· Escalate · medium- agreed by 2 of 2 members but NOT verified (no proof, no reproducing execution) — consensus is not a verdict; needs human review
- Tailwind preset reader ignores double-quoted token values —
graphify/extractors/design_tokens.py:13· Escalate · medium- agreed by 2 of 2 members but NOT verified (no proof, no reproducing execution) — consensus is not a verdict; needs human review
- Workspace imports now prefer src twins over existing exported dist files —
graphify/extractors/resolution.py:621· Escalate · medium- agreed by 2 of 2 members but NOT verified (no proof, no reproducing execution) — consensus is not a verdict; needs human review
Analysis details — impact, health, verification
Impact & health
Graphify review
Impact — 5180 functions depend on the 3289 functions this change touches.
Health — this change adds coupling hotspots:
- new:
extract()— 641 callers, 46 callees - new:
_rebuild_code()— 123 callers, 53 callees - new:
detect()— 113 callers, 17 callees - new:
_extract_generic()— 18 callers, 29 callees - new:
save_manifest()— 40 callers, 11 callees - new:
extract_files_direct()— 17 callers, 20 callees - new:
extract_js()— 85 callers, 4 callees - new:
extract_xaml()— 19 callers, 17 callees - …and 98 more — each is listed as a finding
Verification — 5180 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: 4921 function(s) in the blast radius were not formally verified this run
Formal verification
Could not verify: Could not verify detect.
The verifier did not have enough to check detect, 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 `root` is annotated `Path` — outside the synthesizable primitive/collection set
Could not verify: Could not verify extract.
The verifier did not have enough to check extract, 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 `cache_root` is annotated `Path | None` — outside the synthesizable primitive/collection set
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 9 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\_csharp\_type\_references.
The verifier did not have enough to check \_resolve\_csharp\_type\_references, 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 \_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 `path` is annotated `Path` — outside the synthesizable primitive/collection set
Could not verify: Could not verify \_resolve\_workspace\_import.
The verifier did not have enough to check \_resolve\_workspace\_import, 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 `start_dir` is annotated `Path` — outside the synthesizable primitive/collection set
No difference found (not proven): No behavior difference found in monolith\_roundtrip (not a proof).
The verifier ran both versions of monolith\_roundtrip 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.
· 3 grounded finding(s) anchored inline below; 103 more finding(s) on lines outside this diff (see the check run).
| pass | ||
|
|
||
|
|
||
| def detect(root: Path, *, follow_symlinks: bool | None = None, google_workspace: bool | None = None, extra_excludes: list[str] | None = None, cache_root: Path | None = None, gitignore: bool = True) -> dict: |
There was a problem hiding this comment.
detect()
fans out to 17 callees (efferent coupling); 113 callers depend on it (afferent coupling).
Grounded coupling-delta finding (deterministic), not an LLM guess.
| logging.getLogger(__name__).info("design-token references left unresolved: %d", unresolved) | ||
|
|
||
|
|
||
| def _rewire_unique_stub_nodes(nodes: list[dict], edges: list[dict]) -> None: |
There was a problem hiding this comment.
_rewire_unique_stub_nodes()
fans out to 7 callees (efferent coupling); 10 callers depend on it (afferent coupling).
Grounded coupling-delta finding (deterministic), not an LLM guess.
| return package_dir / "src" / relative.parent / name[: -len(suffix)] | ||
| return package_dir / "src" / relative.with_suffix("") | ||
|
|
||
| def _resolve_workspace_import(raw: str, start_dir: Path) -> Path | None: |
There was a problem hiding this comment.
_resolve_workspace_import()
fans out to 6 callees (efferent coupling).
Grounded coupling-delta finding (deterministic), not an LLM guess.
|
Closing this — opened without the graph system's owner having agreed to it. The work stays local; if it is offered again it will be after that conversation. |
The problem
Five ordinary questions about a monorepo, and what the graph answered before this change. Ground
truth built with greps over
git ls-files, so it does not move with the tool under measurement;corpus 9 048 files (8 570 code), one npm workspace with three apps and a shared UI package, one .NET
service, one documentation tree.
handlesedges; 3 of 3 spot-checked request→handler paths resolve end to endgraphify-out/EXCLUDED.tsvThe 14-file reproduction from the issue gives the same picture without a monorepo. Before / after,
same script, same fixture:
.cssfiles classified as code@demo/uiimport lands onpackages/ui/dist/index.js(outside the scanned corpus)packages/ui/src/index.ts@importedgesuses_tokenedgeshandlesedgesGetThingQuery -> GetThingQueryHandlergraphify-out/EXCLUDED.tsvThe right-hand column was re-measured on this branch (
uv run --frozen bash repro.sh <dir>atc221e27):2 of 2,index.ts(thesrc/twin, whiledist/index.jsis present on disk),1,6,GetThingQuery -> GetThingQueryHandler,4 rows.What changed, and how to check each part
1 ·
.cssjoinsCODE_EXTENSIONS(graphify/detect.py). One token in one set literal.2 ·
detect()writes the exclusion register it already computes (graphify/detect.py,graphify/extract.py). Three kinds, one row each, tab separated:ignored(ignore rule or noisedir),
unclassified(with the extension that fell through),skipped(sensitive pattern). The"partially extracted after a parse error" notice, which until now existed only as a line on stderr
during the run, becomes a fourth kind,
partial, in the same file.3 · A workspace import resolves to the source, not to the build output
(
graphify/extractors/resolution.py, 20 lines).developmentjoins_EXPORT_CONDITION_PRIORITY— it was in no position in that tuple, so an exports map naming only
developmentanddefaultresolved to the
defaultcatch-all — and_source_twin_of_build_output()maps adist/candidate onto its extensionlesssrc/counterpartand prefers it when that file exists — including when the build output itself is present, which a
fallback that only triggers on a missing file does not cover. In the fixture the
exportsmap names./dist/index.d.tsand./dist/index.js, the second of which exists on disk; the edge lands onpackages/ui/src/index.tsall the same. This is the fix that carries most of0 → 87in the table:dist/is pruned as a noise dir, so before the change every edge into a shared package pointedoutside the corpus. The last two of those 87 files arrive through the stylesheet
@importandpreset import edges from fixes 4 and 5. Check with the fixture — the line
'@demo/ui' import lands on.4 · A CSS extractor (new
graphify/extractors/css.py, 78 lines). It emits the stylesheet's ownnode, a node per custom property it declares, a
uses_tokenedge pervar(--x)reference, and animportsedge per@import, resolved through the existing JS import resolver so a bare packagespecifier in a stylesheet lands on a real file.
5 · Design tokens become nodes, and references bind to them (new
graphify/extractors/design_tokens.py, 112 lines;_resolve_design_token_refs()ingraphify/extract.py;uses_tokenadded toDEFAULT_AFFECTED_RELATIONSingraphify/affected.py).A reference from another file —
var(--brand)in a component, or a Tailwind utility class whosepreset entry resolves to that variable — becomes an edge to the node that declares the token. This
is what turns the blast radius of a token change from 1 file into 62:
6 · A request type binds to the generic handler that handles it
(
graphify/extractors/engine.py,graphify/extractors/csharp.py, plus the relation names ingraphify/extract.pyand query hints ingraphify/serve.py). A small table maps a genericinterface to (type-parameter position, relation name):
IRequestHandler/INotificationHandler→handles,IPipelineBehavior→intercepts,AbstractValidator→validates,IEntityTypeConfiguration→configures. The edge carriescontext="type_binding"alongside theordinary
referencesedge, so the "this class mentions that type" signal is not lost.7 · The runbook feeds documents to the extractor too (
tools/skillgen/fragments/core/*.md, andthe generated skill artefacts). Part A collected only
detect['files']['code'], so a Markdown filenever reached
extract()even though a structural extractor for it exists; the semantic pass wasnever meant to be the only path for those files. Part A now also walks the
documentcategory,filtered to files
_get_extractor()actually covers.graphify/skill*.mdis generated: the three core fragments are the edit,python -m tools.skillgenplus
--blessregenerated the 16 skill files and their snapshots, andgen.pygained one predicateso
--monolith-roundtripcan sanction those lines. All five skillgen gates are green.Cost
Measured on the 9 048-file corpus (8 570 code, 464 document, ~7.7M words), full standard build:
uses_token4 781,validates239,handles44,configures0,intercepts0)referencesedge on the same pair, 14 replaced acontainsedgehandles685 instead of 44 (see "choices" below)graph.jsonon diskgraphify affected, three warm runsSource change: +397 / −7 lines across 9 files in
graphify/(two of them new, 190 linestogether), +230 lines of tests in 8 files, +31 / −4 in
tools/skillgen/. The remaining 32 changedfiles are generated skill artefacts and their snapshots. 53 files, +754 / −43 in total
(
git diff --shortstat v8..HEAD).What this does not do
EXCLUDED.tsvartefact ingraphify-out/.graphify/extractors/__init__.pyis untouched. The CSS extractor is registered in theextension→extractor dispatch table in
extract.pyonly, not inLANGUAGE_EXTRACTORS; thedesign-token module is not a language extractor at all (it exposes no
extract_*). Where you wantthese two registered, and whether the second belongs under
extractors/, is your call — say theword and I will move them and add the
MIGRATION.mdrow.ARCHITECTURE.md,CHANGELOG.md,extractors/MIGRATION.mdanduv.lockare untouched. Thechangelog convention wants an issue number per line, so those lines belong in the same commit as
the issue reference once this has one.
dist/only, mapped tosrc/, for extensionless targets andfor the
.d.ts/.d.mts/.d.ctsfamily.build/,lib/andout/are not handled.@importmust be a quoted string;@import url(...)is not matched.bg-${variant}template is notguessed. On the measured corpus that was 2 files.
Choices locked in, that a reviewer should agree with or reject
handlesedge is stored request → handler: source is the request type, target is thehandler class. That reads backwards against the English verb, and it is deliberate, not a reversed
edge: it makes "what runs when this request is dispatched" a forward traversal from the request,
which is the direction users ask in.
validates,configuresandinterceptskeep the naturaldirection (the validator/configuration/behaviour class is the source). If you want
handlestoread like the verb, it is the swap in
_resolve_csharp_type_referencesand nothing else.handles/validatesedge collides with thereferencesedge the same generic argument alreadyproduced. On the measured corpus, the request→handler naming survived in 5 of 635 pairs until the
graph was built directed; built directed it is 685 edges. The extractor is right either way — the
loss is in the build step — but the value of this fix depends on a directed build, and that is
worth saying out loud rather than discovering later.
uses_tokenwas added toDEFAULT_AFFECTED_RELATIONS. The four C# binding relations arenot in the default traversal, so a default blast radius is unchanged unless
--relationnamesthem.
type-argument position 0 with exactly one resolved reference. An unrelated library that happens to
name an interface the same way will match. There is no configuration surface for it.
tailwind-preset.ts. A design system thatdoes not use that convention still gets the
var(--x)half, and nothing else.--x-rgbcompanion tokens fold onto--xwhen both are declared in the same stylesheet. Onthe measured corpus this merged 7 token nodes, and inside the declaring stylesheet 21 pairs that
used to be
contains("this file declares this token") becameuses_token("this file uses it").That is a behaviour change on existing graphs, not only an addition.
Two known limitations, not fixed here
The two writers of
EXCLUDED.tsvanchor differently.detect()writes tocache_root or root,following the convention the word-count cache already uses, so an
extract --outrun keeps it outof the scanned corpus. The
partialrows inextract()anchor torootinstead, which for the CLIis the scanned project (
cli.pyhandsextract(){"cache_root": out_root, "root": target}). With--outthe two halves land in two different files, and the second one writes into the corpus beinganalysed. Reproduced with
rootandcache_rootdeliberately pulled apart: the register appearsunder the scan root and not under the out dir. The new test does not catch it because it passes only
cache_root=tmp_pathwith paths under it, so the two coincide. I left it as is rather than guesswhich anchor you want — say which, and I will make both writers use it and pin the choice with a
second test case.
The
extract()writer appends. It opens the register in append mode and writes the header onlywhen the file is absent, so two
extract()runs over the same tree list the same partiallyextracted file twice. A full
detect()pass rewrites the file atomically and clears theduplication, but a path that only re-extracts (
graphify watch, repeatedupdate) keeps growing.Same choice as above: it becomes a rewrite the moment you say which anchor and which lifetime the
file should have, and it gets a test in the same round.
Test plan
11 tests, in
tests/, on the layout CI runs (uv run --frozen pytest tests/ -q --tb=short, Python3.10 and 3.12):
Each test fails when its own production change is reverted: one fix at a time, in a throwaway
worktree, with the test files left untouched — 11 of 11 go red, and the worktree was verified clean
between rounds. Two commits carry two independent halves each, and there the tests split the same
way: removing only
developmentfrom_EXPORT_CONDITION_PRIORITYreddens…development_outranks_defaultwhile…falls_back_to_src_twin…stays green, and removing only the_source_twin_of_build_outputcall does the reverse; the same holds for thedetect()andextract()halves of the exclusion register.Suite, same machine, same lockfile, one environment per side
(
uv run --frozen pytest tests/ -q):The six failures are identical by name on both sides and pre-existing. Four in
tests/test_ollama_retry_cap.pyneed an optional extra that a defaultuv syncdoes not install(
ModuleNotFoundError: No module named 'openai'; CI installs with--all-extras, this run didnot).
test_collect_files_skips_hiddenasserts overPath.partsof an absolute path, so it failswhenever the checkout itself sits under a dot-directory.
test_ts_normalizer_scales_linearly_on_large_filesis a wall-clock ratio test (
0.0770s -> 0.2859s, threshold 3x) that fails under machine load.None is touched here. The difference of 11 passing tests is exactly the 11 above — checked by
collecting both sides separately (
pytest tests/ -q --collect-only, 5717 vs 5706 items) anddiffing the node ids: 11 added, none removed, none renamed.
Also green:
ruff check --config pyproject.toml .(both sides),python -m tools.skillgen --check(
134 artifact(s) match committed output and expected/),--audit-coverage,--schema-singleton,--monolith-roundtrip,--always-on-roundtrip, andgraphify --help.bandit -r graphify -llreports the same metrics block as the base commit (Low 102 · Medium 8 · High 3).
pyrightreports583 errors, 4 warningson both sides, and with paths and line numbers normalized away the twodiagnostic sets are identical — this branch adds no new one.
A note on reviewing this
Two of the nine changed files under
graphify/are new (extractors/css.py,extractors/design_tokens.py). If you verify a build by hashing an installed package against itsRECORD, an added file produces no mismatch — only the seven modified ones show up. So the hashdiff is not the full change surface here; the file list above is.
C · Verzendcommando's
Niets hiervan is gedraaid — de tak staat lokaal, er is geen fork, geen push, geen PR, geen release.
D · Vóór je verzendt
Reparatie 3 uitkleden.Gedaan opfeat/head-port:19dd101bevat alleen nogdevelopmentin_EXPORT_CONDITION_PRIORITYplus_source_twin_of_build_outputmet zijnaanroep (samen twintig regels,
git show 19dd101 -- graphify/extractors/resolution.py). De_resolve_export_targets-hunks van de oude tak zijn geschrapt; de kop heeft die zelf.(#<nummer>, thanks @<handle>).Vandaar issue vóór PR (stap 4); daarna de changelogregel in de
(unreleased)-sectie toevoegen.(a) classificatie + CSS-extractor, (b) ontwerptokens, (c) generieke typeparameter,
(d) uitsluitingsregister, (e) werkruimte-imports. De PR-tekst hierboven dekt alle vijf; bij
splitsen knip je per kop.
LANGUAGE_EXTRACTORS,MIGRATION.md-rij) — de PR-tekst laatdie keuze expliciet aan de onderhouder; als je liever meteen levert, doe het vóór verzending.
EXCLUDED.tsvnoemen inREADME.mdbij de uitvoerbestanden, als je het artefact wilt latenstaan.