[P1] Add incremental Tree-sitter reparsing, changed-range invalidation, and source freshness #99
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#99
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: #94, #95, #96, #97, #98
Goal
Use Tree-sitter's incremental parsing model to update Project source observations efficiently and, more importantly, make freshness/invalidation semantics explicit so stale AST/symbol/reference facts never silently satisfy current queries or SPEC verification.
Required update flow
Model the update path semantically as:
Do not make raw Tree-sitter node identity the freshness mechanism.
Edit model
Expose a Prolog representation equivalent to Tree-sitter input edits, including:
Provide semantics equivalent to:
Exact API may differ, but sync operations should remain ordinary local predicates unless implementation evidence shows meaningful latency requiring the existing async contract.
Current / stale observation semantics
Define explicit generation state for:
A public "current" Project/source query must never merge facts from incompatible generations.
Historical observations may remain queryable through explicit generation/provenance APIs.
States must distinguish at least:
where useful. Do not silently delete the evidence trail merely because a new parse exists.
Invalidation
Use changed ranges to identify observations that may require recomputation, but do not overclaim semantic locality.
Some changes can affect facts outside the textual changed range, for example imports, scope/binding relationships, grammar/extractor behavior, or language-specific semantics. Language adapters must be able to declare conservative invalidation scope such as:
Correctness wins over incremental cleverness.
Query/extractor versions
A grammar upgrade or query-pack/extractor change must also invalidate/recompute the corresponding current observations even if source bytes did not change.
Currentness therefore depends on more than file mtime:
Atomic publication
Do not expose a half-reindexed generation as the complete current Project state.
Prefer staging the new parse/extraction generation and publishing it as current only after required indexing phases complete or publishing an explicit
partial(...)state that VERIFY cannot mistake for complete evidence.Document the linearization/publication semantics for concurrent readers and file updates.
Resource lifecycle
Old native trees must be released when no current operation/reference needs them. Historical KB provenance must not require retaining every native
TSTreeforever.Persisted historical observations should use normalized Prolog evidence, not native pointer lifetime.
Acceptance criteria
changed_rangesis exposed as structured Prolog data.Non-goals
Refs #93 #94 #95 #96 #97 #98