feat(resolve): add opt-in Godot idFields DSL indexing via godot:id sentinels#84
Merged
Conversation
…ntinels Capture bare/compound IDs in .tres [resource] bodies as godot:id:<kind>:<value> sentinel references, gated behind an opt-in godot.dsl.idFields config. Golden-neutral by two mechanisms: opt-in gating (fires only when .codegraph/codegraph.json declares idFields) and sentinel unresolvability (a colon-delimited godot:id:* literal can never name-match a node, so it stays in the non-golden-compared unresolved_refs). - godot_dsl_config.rs: IdFieldSpec + id_fields BTreeMap on GodotDslConfig, plus an independent mtime-cached dsl_id_fields reader mirroring the resourceFields reader. - godot_resource.rs: dsl_id_targets emits godot:id sentinels (bare/no-separator -> 1; separator+idSegments -> N, 0-based, out-of-range silently skipped), source-line order. - godot_dsl.rs: +6 cases (bare int; compound split; no-config zero; absent field; out-of-range skip; determinism). - docs/godot.md: idFields opt-in block documentation. - godot_idfields_determinism.rs: sync==index-force + parallel run-to-run determinism.
The opt-in Godot `idFields` AND `resourceFields` DSL hooks did nothing under the real `codegraph index` CLI unless it happened to run with its CWD equal to the project root. `extract_and_persist_frameworks` hands the framework resolver a repo-RELATIVE `.tres` path, and the DSL config reader resolved that relative path against `std::env::current_dir()`, so `$PROJECT/.codegraph/codegraph.json` was only discovered when CWD == project root. The unit tests masked this by passing absolute `.tres` paths. Thread the indexing project root into the framework-resolver extraction seam so the config lookup walks up from the file's real on-disk location, while the path stored as node/reference attribution stays relative (golden byte-stable). - framework.rs: add an additive `project_root: &str` arg to `FrameworkResolver::extract`; document that `file_path` stays relative for attribution and `project_root` is only for per-project config lookup. - godot_resource.rs: new `config_lookup_path` joins a relative `.tres` path onto `project_root` (absolute paths and empty root pass through unchanged); both `dsl_resource_fields` and `dsl_id_fields` now receive it. Attribution is unchanged — only the config lookup sees the absolute path. - godot.rs / resolver.rs: thread `self.project_root` to `parse_tres`. - react/vue/nestjs + tests: updated to the new `extract` arity (non-godot resolvers ignore `project_root`). - godot_idfields_cwd.rs: NEW e2e CLI regression — drives the real binary from a foreign cwd against the project's absolute path and asserts the `godot:id:buff:7005` sentinel and the `resourceFields` literal land in `unresolved_refs`, plus an off-by-default-from-foreign-cwd guard.
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.
Summary
godot.dsl.idFieldsblock to.codegraph/codegraph.jsonthat captures bare/compound IDs in.tres[resource]bodies asgodot:id:<kind>:<value>sentinel references — making project-specific IDs (e.g.buff_id = 7005,skill_effect = "a:b:9015:c:7005:1000") searchable.separator, select 0-basedidSegments(out-of-range silently skipped). All field names / kinds / separators are project-supplied — no domain hardcoding.FrameworkResolver::extracttrait gains an additiveproject_rootparam). This also fixes the pre-existingresourceFieldsreader, which had the same latent CWD bug.Golden-neutrality (two-part mechanism)
idFieldsis configured; golden corpora have no such config.godot:id:*literal can never name-match a node (match_fuzzymatches callable/type kinds only), so it stays inunresolved_refsand never becomes a goldenedgesrow.This is a downstream-only feature — no analogue in upstream colby (verified against v1.1.1 HEAD).
Verification
make cigreen locally (fmt + clippy + test + guardrail)git diff --stat reference/empty (golden-neutral);cargo test -p codegraph-bench4/4idFieldscases ingodot_dsl.rs; determinism testgodot_idfields_determinism.rs(sync == index --force, parallel == sequential); e2e CLI testgodot_idfields_cwd.rsdriving the real binary from a foreign cwd (the regression lock for the config-root fix) + off-by-default twin