Skip to content

feat(resolve): add opt-in Godot idFields DSL indexing via godot:id sentinels#84

Merged
sunerpy merged 2 commits into
mainfrom
feat/godot-idfields-dsl
Jun 27, 2026
Merged

feat(resolve): add opt-in Godot idFields DSL indexing via godot:id sentinels#84
sunerpy merged 2 commits into
mainfrom
feat/godot-idfields-dsl

Conversation

@sunerpy

@sunerpy sunerpy commented Jun 27, 2026

Copy link
Copy Markdown
Owner

Summary

  • Adds an opt-in godot.dsl.idFields block to .codegraph/codegraph.json that captures bare/compound IDs in .tres [resource] bodies as godot:id:<kind>:<value> sentinel references — making project-specific IDs (e.g. buff_id = 7005, skill_effect = "a:b:9015:c:7005:1000") searchable.
  • Bare scalar → one sentinel; compound → split on a configured separator, select 0-based idSegments (out-of-range silently skipped). All field names / kinds / separators are project-supplied — no domain hardcoding.
  • Bundled fix: resolve the Godot DSL config against the project root, not the process CWD (the FrameworkResolver::extract trait gains an additive project_root param). This also fixes the pre-existing resourceFields reader, which had the same latent CWD bug.

Golden-neutrality (two-part mechanism)

  1. Opt-in gating — fires only when idFields is configured; golden corpora have no such config.
  2. Sentinel-unresolvability — a colon-delimited godot:id:* literal can never name-match a node (match_fuzzy matches callable/type kinds only), so it stays in unresolved_refs and never becomes a golden edges row.

This is a downstream-only feature — no analogue in upstream colby (verified against v1.1.1 HEAD).

Verification

  • make ci green locally (fmt + clippy + test + guardrail)
  • git diff --stat reference/ empty (golden-neutral); cargo test -p codegraph-bench 4/4
  • New tests: 6 idFields cases in godot_dsl.rs; determinism test godot_idfields_determinism.rs (sync == index --force, parallel == sequential); e2e CLI test godot_idfields_cwd.rs driving the real binary from a foreign cwd (the regression lock for the config-root fix) + off-by-default twin
  • react/vue/nestjs resolvers updated for the additive trait param (no behavior change)

sunerpy added 2 commits June 27, 2026 15:48
…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.
@sunerpy sunerpy merged commit 54bf901 into main Jun 27, 2026
4 checks passed
@sunerpy sunerpy deleted the feat/godot-idfields-dsl branch June 27, 2026 07:53
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.

1 participant