Skip to content

deterministic ingestion of structured data files #2214

Closed

Description

@dchavezf

Context
We're using graphify to index YAML contracts from a data pipeline (business entities with stable IDs like BP_001, FC_002, cross-references, and evidence citations back to source transcripts). Determinism is a hard requirement: the same input must always produce the same graph, with no re-labeling of entities between runs.

While integrating graphify for this, we hit two limitations:

  1. Structured data files (YAML/JSON) are forced through LLM extraction
    code_exts (in the file-classification logic used during update/build) only covers programming-language source files:

{'.py','.ts','.js','.go','.rs','.java','.cpp','.c','.rb','.swift','.kt','.cs','.scala','.php','.cc','.cxx','.hpp','.h','.kts','.lua','.toc','.f','.F','.f90','.F90','.f95','.F95','.f03','.F03','.f08','.F08'}
Any .yaml/.yml/.json file falls outside this list and gets classified as document, which routes it through semantic (LLM-based) extraction rather than structural parsing — even when the file already contains explicit, stable identifiers and cross-references (i.e., no entity extraction/inference is actually needed).

Problem this causes: LLM-based extraction over the same structured file can label the same entity differently across runs, breaking determinism for use cases where the source is already structured data, not prose to be interpreted.

Request: Support a deterministic/structural extraction path for structured data files — either by:

extending code_exts to include .yaml/.yml/.json and adding a structural parser for them (key-based entity/relationship extraction, similar to how code files are parsed for symbols), or exposing the existing internal build_from_json/build_merge construction API as a documented, first-class CLI entry point, so callers who already have structured data (and want to skip extraction entirely) have a supported path instead of reaching into internal Python functions.
We worked around this today by calling build_from_json/to_json directly from a custom script, bypassing extraction — which works, but relies on undocumented internals rather than a public contract.

  1. to_json shrink-guard has no override for intentional shrinkage
    graphify.export.to_json refuses to write a graph if it has fewer nodes than the existing file on disk (tracked as issue Prevent partial-chunk overwrite in --update: pre-build node-count assertion + build_merge() helper #479). This guard is reasonable as a default (catches accidental partial extraction), but there's no explicit way to say "this shrinkage is intentional, write anyway" — the only workaround is manually deleting/backing up the old graph.json before running.

Request: Add an explicit override, e.g. to_json(..., allow_shrink=True) or a --force/--allow-shrink CLI flag, so callers with a legitimate reduction (entities removed upstream, corrected data, etc.) can proceed without bypassing the guard by deleting state out-of-band.

Activity

  1. wrightbuilt commented on Aug 3, 2026

    @wrightbuilt

    Second reporter for part 2, from a different angle than yours — CI rather than a library caller.

    We run graphify as a post-merge job on protected main in several repos: clean checkout, pinned version, AST-only (no API key, so extraction is deterministic and free), regenerate, commit graphify-out/ back. Two repos wedged on the shrink guard within three days of each other, both from an ordinary .graphifyignore edit:

    committed nodes fresh extraction cause
    9368 8522 added archive/ to .graphifyignore, moved five docs under it
    1889 1246 excluded docs/superpowers/ and CHANGELOG.md

    40+ consecutive failed runs on the first with zero successes, until we pushed a --force regeneration directly to main through the branch-protection bypass. The second had no bypass available and abandoned the exclusion instead.

    The argument I would add to your part 2: on a CI path the guard has no true positives available to it. Its stated premise is "you may be missing chunk files from a previous session" — a stateful local condition. A job that checks out clean, installs a pinned graphify, and extracts from scratch cannot be in that state, so there it can only produce false positives.

    What makes it a wedge rather than an annoyance is that recovery is out of reach from inside the repo: the graph is a protected-branch artifact, so a corrected graph cannot land through a pull request, and a graph-only push does not retrigger the job. The only exit is a privileged direct push — break-glass, for a foreseeable configuration change.

    One correction to part 2 worth having on the record: graphify update --force does exist and does resolve it — that is what we used. But --force on update is overloaded: it also disables the incremental gate and skips semantic-cache reads (#1894). A caller who only wants "accept this shrink" has to take the full re-scan as well. Your --allow-shrink framing separates those two meanings, which is the part I would most like to see.

    One datum in favour of a narrower gate rather than a blanket override: the codebase already computes the distinction. A source gone from disk folds into the deleted set and passes the accounting check, while a source that still exists but left the corpus is tracked separately and reported as

    [graphify watch] fail-closed: kept N node(s) from M file(s) that left the scan corpus
    but still exist on disk (ignore rules or filters changed?).
    

    so at the point the write is refused, graphify already knows which nodes it is dropping and why. Whether that set is reachable from the refusing path is your call, but the information needed to gate this narrowly appears to exist already.

    Happy to supply full run logs, or to test a patch against either corpus.

  2. rywjin-hub commented on Oct 13, 2026

    @rywjin-hub

    Second reporter for part 1, from the skill side: a corpus whose relationships already exist as typed nodes and edges (seed data files, curriculum JSON, lesson documents), so neither AST nor semantic extraction fits.

    What worked on graphifyy 0.9.73 is the same workaround described above: a small deterministic exporter that writes the extraction JSON directly, every edge confidence: "EXTRACTED" with confidence_score: 1.0, then build_from_json, clustering, the report and graphify export html. The exporter wrote 843 nodes and 1,038 edges, and diagnose_extraction reported 0 dangling and 0 collapsed edges.

    What a documented entry point, or a skill section for it, would need to say, since none of it is written for a caller who supplies its own extraction:

    A short "bring your own extraction" section in the skill (tools/skillgen/fragments/core/core.md, plus the aider.md and devin.md monolith fragments) that skips Steps 2 and 3 and starts at Step 4 with a minimal detection dict would cover the documentation half of this request with no new API.

  3. safishamsi commented on Oct 23, 2026

    @safishamsi
    Member
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions