[EPIC] Add first-class Project / SPEC / source-knowledge APIs #93
Labels
No labels
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
nsaspy/prolog-rlm#93
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?
Goal
Add the reusable Prolog-native foundation for representing a project, observing its source/code structure, defining a domain-neutral specification, freezing that specification, and verifying it against explicit evidence.
Planning and execution are optional consumers. A Project may be indexed without a SPEC. A SPEC may be created/frozen without a Project. VERIFY may evaluate a frozen SPEC against existing evidence without planning or execution.
Architectural boundary
This epic owns epistemic project/source/specification concepts, not trusted project policy or coding-agent UX.
It is distinct from:
Where #75 provides a canonical
ProjectIdentity, this API should be able to reference/reuse it rather than inventing a competing security-sensitive identity. Source-observation identity, parser generations, file hashes, and syntax-node identities remain separate epistemic/versioning concepts.Required Project model
Establish small normalized entities/relations equivalent in semantics to:
Do not encode all metadata into a single
file(Language, Path, ...)mega-term. Files, languages, parser backends, parse generations, symbols, and evidence need stable independent identities and relations.The model must support multiple projects, changed/moved files, unknown/ambiguous languages, generated/vendor/excluded metadata, embedded language regions, non-code artifacts, and versioned observations.
Parser/analyzer architecture
Use a pluggable source-analysis boundary.
Tree-sitter integration is a direct SWI-Prolog <-> Tree-sitter C API binding. Do not add Python, Node, Nim, or another runtime merely as glue.
Tree-sitter owns concrete/incremental polyglot syntax parsing. Prolog owns normalized facts, language adapters, semantics, inference, SPEC, and VERIFY.
For Prolog source, prefer SWI-native source/xref analysis for authoritative semantic facts where it is stronger than a generic Tree-sitter grammar.
Source observation model
The persistent/inspectable project KB must not depend on raw native pointer identity.
Provide normalized versioned observations equivalent to:
Preserve the distinction between low-level CST observations, normalized cross-language facts, richer language-specific facts, and derived Prolog relations/inferences. Do not flatten every language into one impoverished universal AST.
Provenance and freshness
Every material source-derived fact must be traceable to project, file, content hash/generation, parser backend/grammar identity, query/extractor identity where applicable, and source range.
A changed file must not leave old facts silently looking current. Stale observations may remain inspectable, but current queries and VERIFY need deterministic freshness semantics.
First-class SPEC contract
A SPEC is domain-neutral declarative data. Coding/project requirements are one useful specialization, not the definition of SPEC.
Required semantics:
Public API direction:
Exact naming/arity should follow repository conventions.
First-class VERIFY contract
VERIFY evaluates a frozen specification against observations/evidence and does not require PLAN or EXECUTE.
Outcomes should distinguish:
Verifier results preserve evidence/provenance and integrate with #56 without collapsing
proof existsintopremises are trustworthy. Worker/model self-report is not source evidence when a requirement asks for observable source/runtime state.Tree-sitter child issues
Dependency shape:
The SPEC and VERIFY contracts remain tracked by this epic and should be decomposed into focused implementation issues when their concrete API design is ready. Tree-sitter is an evidence source for them, not a mandatory dependency for domain-neutral SPEC use.
Security / authority invariants
consultarbitrary project Prolog as trusted executable policy.Integration acceptance
Non-goals
References
library(prolog_source)/library(prolog_xref)for native Prolog analysisOperator clarification: on-disk project-local KB under
$PROJECT_ROOT/.kb/(first recorded 2026-09-02)The epic's "persistent/inspectable project KB" language was never given a concrete persistence design. A repository/issue-wide check on 2026-09-02 found no doc, issue, or research record specifying where project KB state lives on disk. Recording the operator-clarified intent here so future RAGE slices consume it from the epic instead of rediscovering it:
Requirement (operator, 2026-09-02)
$PROJECT_ROOT/.kb/<kb tree>— project-local, the writable workspace being observed.RLM_TREE_SITTER_GRAMMAR_DIR) is inputs, read-only by nature; it is never KB state. A read-only project root (e.g. store-built tree) must fail with a structured persistence error, never silently degrade to memory-only.library(persistency)as the initial/local adapter only (per TODO.md anddocs/artifact-runtime.md), journal/snapshot under the.kbtree, reload on registry open, deterministic replay..kbpersistence (crash/restart semantics are observable behavior, not implementation detail).Where this lands
research/tree-sitter-query-capture.org(RLM-RESEARCH-012, branchrage/97-query-capture-apis, base156bfe9b2caffa1b967e77bee51263ee9e85fb50, currentlyPENDINGresearch approval in the ADADR control plane)..kblayer for its query-extraction facts (ownrlm_project_querysibling module, not inside the #96 CST module) and defines the reusable layout..kbreload as the freshness substrate for post-restart evidence.Downstream proving consumer: Zara Android projects
lost-rob0t/zara#653is now the concrete product proving ground for persistent project contexts and project-scoped chat under the frozen Android design (lost-rob0t/zara#648, design PRlost-rob0t/zara#649).Direction is intentionally Zara-first for product behavior: Zara implements the end-to-end UX/adapter/tests first and should reuse this epic's existing project/source semantics where they already fit. If Zara #653 exposes a genuinely missing domain-neutral seam, the Prolog-RLM follow-up must point to the concrete Zara implementation and RED-first fixtures before generalizing it here.
Do not move Android navigation/product policy upstream and do not make #93 a speculative blocker for the Zara implementation.