[P1] Normalize Tree-sitter captures into symbols, references, and source relations #438
Labels
No labels
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
nsaspy/prolog-rlm#438
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Parent: #93
Depends on: #95, #96, #97
Goal
Build the first semantic source-knowledge layer above raw Tree-sitter syntax/captures: definitions, symbols, references, containment, calls, imports, exports, and selected language-specific relations represented as ordinary Prolog facts with provenance.
This is where Tree-sitter syntax becomes useful to SPEC/VERIFY and project reasoning.
Layering rule
Keep three levels distinct:
Do not infer semantics directly in the C FFI and do not pretend every language has one identical AST.
Common fact vocabulary
Define a deliberately small common model equivalent in semantics to:
Exact terms may change after fixture-driven design. Add common concepts only when they have defensible cross-language meaning.
Allow language-specific facts alongside the common model, for example predicate arity, macro definitions, implementation/interface relations, decorators/attributes, module forms, or language-native binding details.
Identity and unresolved references
A definition may yield a stable source symbol identity within a project/source generation. A reference may initially resolve only to a textual/structural target.
Do not fabricate successful symbol resolution when static information is insufficient.
Represent at least the semantic distinction between:
Later language servers/type checkers/indexes may enrich these facts without invalidating the basic Tree-sitter observation.
Language adapters
Implement initial query+normalization adapters for at least three languages with meaningfully different syntax families, including Python and JavaScript/TypeScript plus one additional language selected from current project priorities.
Adapters live in Prolog/query-pack code, not language-specific C wrappers.
Each adapter should declare supported extraction capabilities, e.g.:
Unsupported extraction must be distinguishable from an analyzed file containing zero matches.
Provenance
Every semantic fact must be traceable to its source observations:
Derived Prolog relations must remain distinguishable from directly extracted observations.
Cross-file/project resolution
Provide a bounded initial resolver where semantics are defensible, but keep extraction separate from global resolution.
For example:
Project-level symbol/reference resolution can use file/language/module facts and return ambiguous/unknown explicitly.
Do not require a full compiler/typechecker for the first slice.
Acceptance criteria
Non-goals
Refs #93 #95 #96 #97
Duplicate of #98 (pre-existing Forgejo mirror with GitHub number parity). Closing this accidental duplicate created by today's open-state sync; #98 stays canonical on Forgejo.