Repository navigation
Conversation
The extraction prompt told the model "Node ID format: lowercase, only
`[a-z0-9_]`", but `ids.normalize_id` keeps every word character after
casefolding, so a non-ASCII path keeps its letters:
docs/tz/ЛЗ4_обоснование.md -> docs_tz_лз4_обоснование
文档/中文名.md -> 文档_中文名
Nothing can satisfy both halves of that instruction. For a non-ASCII path the
model improvised a stem — differently per chunk and per run — and
`_semantic_id_remap` had no canonical id to remap onto, so the AST node and the
semantic nodes for one file landed under different ids. Graphify-Labs#3103 reported this and
was closed without a fix; the wording is unchanged on v8 and lives in three
places, not one.
All three now state the rule the code implements: word characters only, which
is `[a-z0-9_]` for ASCII input while non-ASCII letters and digits are kept.
The ASCII half is unchanged, so no ASCII corpus produces different ids.
The rule text is in two skillgen fragments, so the committed skill artifacts are
regenerated with `python -m tools.skillgen` rather than edited by hand, per the
contributing guide. `tools/skillgen/expected/` is refreshed with `--bless`.
`--check` reports all 134 artifacts in sync.
Tests: tests/test_prompt_id_rule_matches_ids.py (5 tests) asserts that no prompt
surface claims ASCII-only ids, that `make_id` keeps Cyrillic and CJK, and that
ASCII input is still lowercased ASCII (the rule was not relaxed). The three
"no ASCII-only claim" assertions fail on unmodified v8; the two behaviour
assertions pass both ways, since `ids.py` was already correct — only the prompt
lied about it.
Fixes Graphify-Labs#4432
Co-Authored-By: Claude <[email protected]>
|
Thanks for the pull request, @dupeisen. 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. |
There was a problem hiding this comment.
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.
Graphify review — findings
Updates the node ID format instruction in the LLM extraction prompt and the shared extraction spec so it no longer claims IDs are ASCII-only. The rule now says IDs use word characters after casefolding: [a-z0-9_] for ASCII input, with non-ASCII letters and digits kept as-is. The same wording is regenerated across every per-platform skill copy (agents, amp, claude, claw, kilo, pi, trae, windows), so the in-code prompt and the skill docs stay in sync. A test now checks that the prompt's ID rule matches the IDs and no longer claims ASCII-only.
Review partial — this diff was larger than one review pass covers, so later files were not reviewed; some findings may be missing.
Analysis details — impact, health, verification
Impact & health
Graphify review
Impact — 1139 functions depend on the 269 functions this change touches.
Health — grade B; 10 existing hotspot(s) in the area this change touches (pre-existing, not introduced here):
deduplicate_entities()— 110 callers, 31 callees (high)build_merge()— 101 callers, 16 callees (high)dispatch_command()— 5 callers, 135 callees (high)build()— 83 callers, 6 callees (high)_call_openai_compat()— 34 callers, 12 callees (high)extract_files_direct()— 19 callers, 21 callees (high)_call_llm()— 18 callers, 22 callees (high)extract_corpus_parallel()— 28 callers, 12 callees (high)- …and 2 more
Verification — 1139 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: 671 function(s) in the blast radius were not formally verified this run
Test selection
Test selection
466 of 466 test file(s) selected (100%) via static blast radius.
Escalated to a full run for safety — the selection is not trustworthy on its own (see below). CI should run the whole suite.
tests/pi.test.ts— full-run-safetytests/test_affected_cli.py— full-run-safetytests/test_affected_defines.py— full-run-safetytests/test_affected_member_seed.py— full-run-safetytests/test_affected_overrides.py— full-run-safetytests/test_affected_path_file_node.py— full-run-safetytests/test_agents_platform.py— full-run-safetytests/test_alias_folding.py— full-run-safetytests/test_analyze.py— full-run-safetytests/test_anthropic_custom_endpoint.py— full-run-safetytests/test_antigravity_install.py— full-run-safetytests/test_apm_fallback_version.py— full-run-safetytests/test_architecture_doc.py— full-run-safetytests/test_astro_extraction.py— full-run-safetytests/test_astro_import_ids.py— full-run-safetytests/test_atomic_canvas_export.py— full-run-safetytests/test_atomic_version_stamp.py— full-run-safetytests/test_atomic_writes.py— full-run-safetytests/test_backend_env_isolation.py— impact, full-run-safetytests/test_backend_extras.py— impact, full-run-safetytests/test_backend_opt_in.py— impact, full-run-safetytests/test_benchmark.py— full-run-safetytests/test_benchmark_raw_graph.py— full-run-safetytests/test_benchmark_real_query.py— full-run-safetytests/test_binary_media_words.py— full-run-safetytests/test_blade_extractor.py— full-run-safetytests/test_build.py— impact, full-run-safetytests/test_build_located_semantic_identity.py— impact, full-run-safetytests/test_build_merge_dedup_scope.py— impact, full-run-safetytests/test_build_merge_hyperedges_and_prune.py— impact, full-run-safetytests/test_build_merge_shrink_guard.py— impact, full-run-safetytests/test_builtin_global_type_refs.py— full-run-safetytests/test_c_include_resolution.py— impact, full-run-safetytests/test_cache.py— full-run-safetytests/test_cache_long_paths.py— full-run-safetytests/test_cache_stale_import_target.py— full-run-safetytests/test_callflow_html.py— full-run-safetytests/test_cargo_introspect.py— full-run-safetytests/test_cargo_missing_manifest.py— full-run-safetytests/test_carried_hyperedge_remap.py— impact, full-run-safetytests/test_case_sensitive_resolution.py— full-run-safetytests/test_charmap_encoding.py— impact, full-run-safetytests/test_chunking.py— impact, full-run-safetytests/test_cjs_module_extension.py— full-run-safetytests/test_claude_cli_backend.py— impact, full-run-safetytests/test_claude_md.py— full-run-safetytests/test_cli_broken_pipe.py— full-run-safetytests/test_cli_export.py— full-run-safetytests/test_cli_help.py— full-run-safetytests/test_cloud_cta.py— full-run-safety- … and 416 more
non-code file(s) changed (
graphify/skills/agents/references/extraction-spec.md,graphify/skills/amp/references/extraction-spec.md,graphify/skills/claude/references/extraction-spec.md,graphify/skills/claw/references/extraction-spec.md,graphify/skills/codex/references/extraction-spec.md…) → running the full suite for safety (a code graph can't see config/fixture/data deps)
changed code file(s) with no mapped test (
graphify/skills/agents/references/extraction-spec.md,graphify/skills/amp/references/extraction-spec.md,graphify/skills/claude/references/extraction-spec.md,graphify/skills/claw/references/extraction-spec.md,graphify/skills/codex/references/extraction-spec.md…) — a coverage gap or a missing link — running the full suite rather than only the selected tests
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.
#4799's new wording put `[^\W]` in the non-raw _EXTRACTION_SYSTEM string, which raises SyntaxWarning: invalid escape sequence '\W' (a SyntaxError in a future Python). Escape it to `[^\\W]`; the rendered runtime prompt is byte-identical (`[^\W]`) and the markdown fragments are unaffected. Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
Landed in v0.9.100, now on PyPI (pip install graphifyy==0.9.100). The extraction prompt's node-id description matches what ids.py actually produces. Thanks for the fix, @dupeisen. |
What this fixes
The extraction prompt tells the model:
But
ids.normalize_idkeeps every word character after casefolding, so a non-ASCII path keeps its letters:Nothing satisfies both halves of that instruction. For a non-ASCII path the model improvises a stem — and per the issue, differently per chunk and per run — while
_semantic_id_remaphas no canonical id to remap onto. The AST node and the semantic nodes for one file then land under different ids, which is the ghost-duplicate failure mode this module exists to prevent (its own docstring lists #811, #550, #1033, #1104).#3103 reported this and was closed without a fix. The wording is unchanged on v8, and it is in three places, not one:
graphify/llm.py_EXTRACTION_SYSTEMtools/skillgen/fragments/references/shared/extraction-spec.md(rendered into 14 host skills)tools/skillgen/fragments/references/shared/extraction-spec-compact.mdThe change
All three now state the rule the code implements:
The ASCII half is unchanged.
src/auth/session.py+ValidateTokenstill yieldssrc_auth_session_validatetoken, so no ASCII corpus produces different ids and no rebuild is needed. Only the false "ASCII-only" claim is gone, plus the concrete examples a model needs for the non-ASCII case.I edited the two fragments rather than the committed skill files, per the contributing guide, then ran:
That is why the diff touches 32 files: 2 fragments,
llm.py, 1 test, and 28 regenerated artifacts. Every regenerated file differs by that one line only — I checked the diff ongraphify/skills/codex/references/extraction-spec.mdand--checkpassing is the proof the tree is self-consistent.Verification
New
tests/test_prompt_id_rule_matches_ids.py(5 tests) pins the invariant rather than the exact wording:llm.pyand both fragments);make_idkeeps Cyrillic and CJK as documented;normalize_idoutput is all word characters for those inputs;_— the guard that this was a wording fix, not a relaxation.Those 11 failures are pre-existing on this Windows checkout: unmodified v8 gives the same
11 failedwith87 passed, so this change adds 5 passes and no failures. I did not touch them.Limitations
_semantic_id_remaphalf of [Bug]: node-ID rule 'only [a-z0-9_]' still contradicts ids.py for non-ASCII paths in 0.9.89, in both llm.py and extraction-spec.md (#3103 closed without a fix) #4432 (reconciling a near-miss id onto the canonical one) is a separate change and is not in this PR.[a-z0-9_]phrasing present, qualified as the ASCII case, rather than removing it — several hosts cache the rendered skill, and keeping a recognisable ASCII statement seemed less disruptive than deleting it.Fixes #4432
Disclosure: I used an AI coding assistant for this change, as the contributing guide asks. I verified the ids.py behaviour directly, regenerated the artifacts with the project's own generator, and confirmed the new assertions fail without the fix.