skillgen: tell extraction subagents not to emit JSON-Schema keyword nodes - #2256
Open
harshslr wants to merge 1 commit into
Open
skillgen: tell extraction subagents not to emit JSON-Schema keyword nodes#2256harshslr wants to merge 1 commit into
harshslr wants to merge 1 commit into
Conversation
…odes A JSON-Schema contract file (top-level $schema/$defs) has no named entities at the keyword level, but the extraction prompt never says so. Subagents reading one emit a node per `description` / `type` / `$ref` / `required` / `properties` occurrence — once per definition — and those collapse into communities whose entire membership is `description ~ $ref ~ type`, polluting clustering, the god-node analysis and GRAPH_REPORT.md. Adds one rule to the shared extraction-spec fragment (and its compact variant): extract the domain the schema describes — event types, payload names, enum values, field semantics — and link a definition straight to its fields and values rather than through the keyword that nested them. Fragment edit + `python -m tools.skillgen` + `--bless`; the other 28 files are generated. Related to Graphify-Labs#2255, which reports the same node explosion arriving via the AST path (json_config treats any JSON with a top-level $schema as a config manifest) — that one is a code fix, this is the prompt half. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds one rule to the extraction subagent prompt: don't emit nodes whose label is a bare JSON-Schema keyword.
Why
A JSON-Schema contract file has no named entities at the keyword level, but nothing in the prompt says so. A subagent handed one emits a node per
description/type/$ref/required/properties/enumoccurrence — and those recur once per definition, so they arrive in bulk.On a real corpus (92 files, 669k words) a single 160 KB event-contract schema contributed 362 such nodes and 726 edges — 13% of the graph — which Louvain then grouped into ~12 communities whose entire membership is
description ~ $ref ~ type. They swamped the community list and skewed the god-node ranking.What changed
One rule in
tools/skillgen/fragments/references/shared/extraction-spec.mdand its compact variant:The other 28 files are generated:
python -m tools.skillgenthenpython -m tools.skillgen --bless. 30 files, 30 insertions, no deletions.Relationship to #2255
Same node explosion, other half of the problem. #2255 is the AST path —
json_config._is_config_json()treats any JSON with a top-level$schemaas a config manifest and walks the whole keyword tree, so the nodes appear even with semantic extraction switched off. That needs a code fix. This PR only hardens the semantic pass, and is useful independently: a subagent can produce these nodes from a schema file the AST extractor correctly skipped.Testing
tests/test_skillgen.py,tests/test_skill_version_warning.py,tests/test_claude_md.py— 81 passed. The--blessstep was required;test_check_passescatches an un-blessed snapshot, which is how I found it.Note for maintainers
mainis ~730 files behindv8(the default branch) — it has nographify/extractors/ortools/skillgen/. Anyone reading the repo tree frommainsees a skeleton. Might be worth deleting or clearly marking it; I lost a few minutes to it while researching #2255.