[semantic-compiler] Library/tool integration for large documents, chunked compilation, projections, and host adapters #402
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#402
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: #388
Depends on: #392, #393, #394
Related: #395
Goal
Finish the reusable library/tool surface around the general semantic compiler so hosts can compile single strings, documents, streams/logs, or chunked corpora without depending on symbolic-memory.
Public surface
Provide semantics equivalent to:
Exact naming follows repo conventions.
Large-document semantics
Support:
The compiler itself may return a package/stream of accepted semantic records; persistence remains caller-owned.
Tool adapter
Expose semantic compilation as a normal capability-gated tool using the same library semantics.
The tool must not:
Projection
Allow a host to request a bounded projection from an already compiled package for a current goal, selecting relevant entities/rules/events/procedures/constraints plus provenance refs rather than sending the entire compiled document to a model.
This projection may compose with #381 retrieval and the prompt compiler, but must remain usable as a pure library operation for in-memory packages.
Structured input adapters
Support optional deterministic adapters for sources such as:
Adapters preserve source structure/provenance and then feed semantic content through the same compiler.
Acceptance
Refs #388 #392 #393 #394 #395 #381.
MACHINE-SPIRIT #398C/#398D handoff — projections become replayable query modules
Depth-1 research changes the intended meaning of
semantic_projection/4.A projection should not be an untyped bag of top-K semantic records. It should be a bounded query-specific semantic module containing or referencing:
This makes a projection replayable and explainable: downstream Expert/Prompt/Model consumers can see which semantic environment produced it rather than receiving context stripped of theory boundaries.
Large-document / corpus implication
Chunked source compilation may produce many source-local theories/contexts and versioned vocabulary references. Cross-segment linking should create explicit semantic mappings/bridges rather than silently rewriting all identifiers into one document-global ontology.
Query integration implication
Where a query is already symbolic, the compiler/runtime should let deductive demand narrow the projection before embeddings/model relevance ranking are used. A known Horn/procedure/constraint query should be able to derive its relevant theory/rule slice with zero provider calls.
Acceptance additions suggested by #398C/D
Full research is in #398C/#398D and parent #397.
MACHINE-SPIRIT #399C library/tool delta — analyzer/adaptor interoperability surface
The public library surface should gain optional semantics equivalent to:
Requirements:
semantic_compileremains usable with the admitted analyzer subset available;Full rationale and sources are in #399C.
MACHINE-SPIRIT #399D library/tool delta — resumable content-addressed compile execution
Depth 2D adds an execution layer beneath the existing public semantic APIs without making persistence mandatory.
Additional API direction
Semantics equivalent to:
Exact names follow repository style.
Cache/artifact SPI
The compiler should accept an optional host-supplied immutable artifact/cache interface. Implementations may be memory-only, filesystem CAS, Symbolic Memory-backed, remote/shared, or disabled. Correctness must not depend on cache availability.
Cacheable artifacts include deterministic source-adapter output, analyzer/native formalism output, SCL/SCC shards, mapping artifacts, validation/export/loss receipts and retained model candidate artifacts where policy permits.
Hard replay distinction:
A model request fingerprint alone cannot satisfy exact replay.
Partial outcome contract
Compilation should expose typed material gaps rather than one generic failed/succeeded bit. Callers may request completeness profiles such as
no_material_gaps([attribution,negation,quantifier_scope]). Successful completed artifacts remain reusable across retry/cancellation.Parallelism
Segment-local analysis can fan out; ordered/dynamic discourse reconciliation remains dependency-aware. Worker interleaving may not choose semantic winners. Existing runtime concurrency/cancellation machinery executes the plan; do not create another global scheduler.
Full design + D1-D13 fixtures: #399D.
Machine Spirit #403A handoff —
semantic_projectioncontractThe package-local
semantic_projection(+CompiledPackage,+Goal,+Options,-Outcome)should use the same TAPS semantics as world-model-backed projection, while remaining a pure in-memory library operation with no symbolic-memory/vector/model requirement.Required result distinctions:
Projection flow: hard scope/profile/temporal admission → exact/structural seed discovery → mandatory rule/premise/guard/justification/counterevidence closure → optional soft periphery. Top-k/budget packing may drop a candidate, but must not retain a derived candidate while silently omitting its mandatory dependencies.
Return a replayable receipt with package fingerprint, projection options/profile, selected seeds, dependencies, frontier/gaps and deterministic ordering metadata. Embedding/graph/learned retrieval may be pluggable candidate sensors but cannot be required for exact symbolic projection or change truth/authority semantics.
This makes direct package projection and symbolic-memory #7 projection differential-testable under identical semantic fixtures. Refs #403 #381 #394.
Machine Spirit #403B handoff — adversarially robust
semantic_projectionFor pure in-memory compiled packages,
semantic_projectionshould preserve the same OATH-TAPS control boundary established in #403B:mandatory,pinned, trust, identity or authority;The in-memory surface need not implement durable-ledger mechanics, but it should preserve the same semantic receipt shape so hosts do not get weaker safety merely because persistence is absent. Refs #403 #395 #381.
MACHINE-SPIRIT #403C handoff — in-memory projection interoperability
semantic_projectionshould expose the same MOSAIC-TAPS contract as durable/remote retrievers where applicable: typed candidate envelopes, explicit coverage/freshness, QueryIR translation/preservation receipts, and backend-local ordering semantics. A pure compiled package can naturally advertise a strong exact/local fragment; it must not fake vector/remote coverage it does not have.For identical admitted package/query/profile fixtures, #403C requires semantic equivalence between the pure #396 projection path and the symbolic-memory #7 local adapter path, with differences limited to storage/provenance envelope details. Preserve
model_calls = 0for known compiled-semantic projection.Refs #397 #403 #381 #395 and symbolic-memory#7/#9.
Machine Spirit #403D handoff — in-memory projection equivalence
semantic_projection/3for an already-compiled in-memory package should implement the same logical projection/receipt semantics as RACE-TAPS without requiring symbolic-memory or remote federation.For pure in-memory packages, require deterministic QueryIR/obligation planning, hard admission, mandatory dependency closure, explicit support/search/opposition coverage, stable tie-breaking, byte/work bounds and a replayable strategy receipt. Physical optimization may be trivial/local, but the semantic contract must remain equivalent to #403 so callers do not get a weaker meaning model merely because the package is in memory.
Differential fixture: same finite semantic package + goal/profile/budget through
semantic_projectionand an equivalent one-backend #381/RACE projection must normalize to the same selected semantic records, closure state, gaps and coverage classes withmodel_calls = 0.