Skip to content

fix(skill): pin extraction source_file + root the full build so --update stops duplicating - #1366

Merged
safishamsi merged 1 commit into
Graphify-Labs:v8from
RelywOo:fix/skill-source-file-convention
Jun 18, 2026
Merged

safishamsi merged 1 commit into
Graphify-Labs:v8from
RelywOo:fix/skill-source-file-convention

Conversation

@RelywOo

@RelywOo RelywOo commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Problem

After #1344 (build_merge replace-on-re-extract) and #1361 (pass root= to build_merge in the --update runbook), the full build and an incremental /graphify --update could still emit different source_file bases for the same file (e.g. docs/wiki/overview.md from one run vs basename overview.md from another). Because build_merge's replace keys on the source_file string, the mismatch made it miss the stored node, so re-extraction accumulated duplicates instead of replacing. Two gaps remained:

  1. extraction-spec(.md/-compact.md) — the subagent's source_file slot was an unpinned "relative/path", so it invented a base per run. The node id (derived from the same path) drifted too.
  2. core.md — the full build called build_from_json without root=, so /graphify --update: build_merge called without root= → prune_sources never matches, graph inflates on every update #1361's update-side root= had no matching base on the full-build side; the two halves never agreed.

Fix (engine build.py unchanged)

All skill artifacts regenerated via python tools/skillgen/gen.py.

Test

Adds test_build_merge_root_collapses_convention_drift: a drifted relative base with no root leaves 3 nodes (stale + duplicate); the verbatim path + root= collapses to 1 canonical node and drops the stale node. tests/test_build.py — 35 passed.

Builds on #1344 and #1361 (same bug family).

…eleted-only

Completes the source_file convention fix begun in Graphify-Labs#1344 (build_merge
replace-on-re-extract) and Graphify-Labs#1361 (pass root= to build_merge in the --update
runbook). Two gaps still let the full build and incremental --update emit
different source_file bases for the same file, so the source_file-keyed replace
missed and duplicates accumulated:

1. extraction-spec(.md/-compact.md): the subagent's source_file slot was an
   unpinned "relative/path", so it invented a base per run (and the node id,
   derived from the same path, drifted too). Pin it to the verbatim FILE_LIST
   path so _norm_source_file(root) canonicalizes every run identically.

2. core.md: the full build called build_from_json WITHOUT root=, so Graphify-Labs#1361's
   update-side root= had no matching base on the full-build side. Pass
   root='INPUT_PATH' at both sites (Step 4 export, Step 5 report) so the full
   build and --update relativize to the same base.

update.md prune_sources = deleted only. Changed files are replaced by build_merge
(Graphify-Labs#1344); once root= aligns the bases, leaving `changed` in prune_sources would
delete the freshly re-extracted nodes.

Engine (build.py) unchanged. Regenerated all skill artifacts via
tools/skillgen/gen.py. Adds test_build_merge_root_collapses_convention_drift.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@safishamsi
safishamsi merged commit 897483f into Graphify-Labs:v8 Jun 18, 2026
1 of 4 checks passed
@safishamsi

Copy link
Copy Markdown
Member

Merged to v8 in 897483f — thank you @RelywOo, this is an excellent catch and a genuinely important fix.

Your diagnosis is exactly right, and it's more consequential than the PR framing suggests: I verified that after #1361 added root= to the --update build_merge call (shipped in 0.8.41), build_merge's prune — which runs after the merge — began matching the freshly re-extracted nodes of changed files (still in prune_sources) and deleting them. Direct repro:

0.8.41 (prune = deleted + changed, root passed):  changed file's fresh node -> DELETED
this PR (prune = deleted only):                   changed file's fresh node -> preserved

So --update on a changed file was wiping that file's nodes in 0.8.41. Dropping changed from prune_sources (since #1344's replace-on-re-extract already reconciles changed files), passing root= to the full build's build_from_json at both sites, and pinning the extraction-spec source_file to the verbatim path all compose correctly.

Validation on merge: clean merge onto v8, skillgen --check passes (re-blessed the expected/ snapshots, which were the only thing missing from the PR), full suite 2129 passed, and your test_build_merge_root_collapses_convention_drift is in. Credited you via Co-Authored-By.

Because this is a regression in the current 0.8.41 release, I'll cut a prompt 0.8.42 with it. Really appreciate the rigorous writeup.

guglxni added a commit to guglxni/graphify that referenced this pull request Jun 18, 2026
Keep Solidity feat in CHANGELOG Unreleased alongside upstream fixes
(Graphify-Labs#1363, Graphify-Labs#1366, Graphify-Labs#1369, Graphify-Labs#1373). In walk_calls, retain both the Solidity
call/instantiate handling and Java object_creation_expression (Graphify-Labs#1373).

Co-authored-by: Cursor <[email protected]>
guglxni added a commit to guglxni/graphify that referenced this pull request Jun 18, 2026
…raphify-Labs#1367)

Upstream released 0.8.42 and moved Graphify-Labs#1363/Graphify-Labs#1366/Graphify-Labs#1369/Graphify-Labs#1373 out of
Unreleased. Keep the Solidity feat under Unreleased only.

Co-authored-by: Cursor <[email protected]>
PerryLin-0420 pushed a commit to PerryLin-0420/graphify-decouple that referenced this pull request Aug 13, 2026
…so --update stops duplicating

After Graphify-Labs#1361 added root= to the --update build_merge call, build_merge's prune
(which runs after the merge) began matching freshly re-extracted changed-file
nodes and deleting them — a regression in 0.8.41 where --update on a changed
file wiped its nodes. This drops `changed` from prune_sources (replace-on-
re-extract from Graphify-Labs#1344 already reconciles changed files), passes root= to the
full build's build_from_json so its node-key base matches the update side, and
pins the extraction-spec source_file to the verbatim path so the two runs never
drift. Re-blessed skillgen expected/ snapshots.

Co-Authored-By: RelywOo <[email protected]>
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
hassaanch23 added a commit to hassaanch23/graphify that referenced this pull request Sep 2, 2026
…ify-Labs#2217)

The skill path has told agents since Graphify-Labs#1366 to copy source_file from the
FILE_LIST "character-for-character". The native/API prompt said nothing: it
showed `"source_file":"relative/path"` in the schema and left provenance to the
model's judgement. That is the upstream half of Graphify-Labs#2217 — a DeepSeek run
reconstructed a plausible repo path out of a node id quoted inside a document,
because nothing told it not to.

Adds the rule to `_EXTRACTION_SYSTEM`: copy from the enclosing
<untrusted_source path="..."> block, never infer from a label, node id,
citation, basename or import, and omit rather than reconstruct.

The test asserts against the RULE PARAGRAPH, not the whole prompt. Matching the
whole prompt proves nothing here: the base prompt already contains
"<untrusted_source>" (the SECURITY paragraph), "node id" ("Node ID format: ...")
and "citation" ("EXTRACTED: relationship explicit in source (import, call,
citation, ...)"), so a rule saying the exact opposite — "pick whatever
source_file seems most plausible (basename is fine)" — passed a whole-prompt
assertion green. Verified by mutation: that inverted rule now fails the test.

Split out because it carries a cost the code fix does not:

  - prompt fingerprint f33081f95084 -> 850648cc0d13, so every existing semantic
    cache entry falls out of its namespace and the next run re-extracts the
    corpus for real money (Graphify-Labs#1939 working as designed — this IS a prompt change —
    but it is a one-time bill for every user on upgrade)
  - +490 chars (~122 tokens) on every extraction request

If that trade is not worth it for a given release, drop this commit and keep the
first; the graph stays correct either way, it just keeps paying to filter
fabrications instead of asking for fewer. Commit 1 passes the suite standalone.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
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