Neo4jRagPropositionRepository

class Neo4jRagPropositionRepository(crud: PropositionStore, val entityRepository: <Error class: unknown class>) : PropositionStore, VectorSearchCapable

Reference proposition store that backs persistence through Embabel's NamedEntityDataRepository SPI — which is Neo4j-backed at runtime in a typical deployment, hence the descriptive name — without ever importing a graph driver or emitting Cypher from production code. The store stays hexagonal: it talks to the SPI port, and the consuming application supplies whatever concrete (Neo4j or otherwise) implementation it likes.

Composition

Propositions are not native graph nodes — the entity SPI stores NamedEntityData, not Proposition. This adapter therefore composes two collaborators:

  • crud: a supplementary durable PropositionStore that actually holds the Proposition objects (CRUD, identity, the composable query). All base-port members delegate here.

  • entityRepository: the entity/vector/relationship backend the consumer supplies. It backs the separate entity-axis projection/reconciliation path; it is held here as a real collaborator but is deliberately never exposed in this store's public signatures, so no SPI-only type leaks into the proposition contract.

Declared capabilities (honest fragments only)

The store declares exactly PropositionStore and VectorSearchCapable. Every VectorSearchCapable member — both findSimilarWithScores overloads and findClusters — is forwarded to the supplementary store when that store is itself vector-capable, so any backend-pushed-down filtering or clustering override on the supplementary store is honoured rather than bypassed. When the supplementary store is not vector-capable, every vector member degrades to an empty result. None of these paths is ever wired to the SPI's entity vectorSearch, which operates on a different axis (entities, not propositions) and would be semantically wrong.

Why graph and temporal capabilities are omitted

The proposition capability fragments (GraphTraversalCapable for the abstraction hierarchy, TemporalQueryCapable for time-window/effective-confidence queries) are proposition-scoped, whereas the NamedEntityDataRepository SPI is entity-scoped — the proposition-vs-entity axis mismatch. The SPI exposes only 1-hop entity navigation (findRelated) and no temporal surface, so neither proposition fragment can be served honestly here. Declaring a fragment this store cannot back would make a caller's supportsGraph report true while results came back empty — dishonest. Omission is the honest signal: a caller using PropositionStoreTemplate sees supportsGraph == false and gets empty, typed results from the graph/temporal paths, never an exception. Full multi-hop / path-between traversal is deferred to a future native graph-query adapter.

Parameters

crud

the supplementary durable proposition store backing all CRUD and query operations

entityRepository

the entity/relationship/vector backend supplied by the consumer; held for the entity-axis projection path and never surfaced in this store's public signatures

Constructors

Link copied to clipboard
constructor(crud: PropositionStore, entityRepository: <Error class: unknown class>)

Properties

Link copied to clipboard
val entityRepository: <Error class: unknown class>
Link copied to clipboard

Whether this particular instance can actually run vector search. Implementing the interface is a type-level promise; this is the runtime truth. A store that can be wired without an embedder (so it satisfies the type but has nothing to embed with) should override this to report whether it was given one. Lets a caller — e.g. PropositionStoreTemplate.supportsVector — distinguish "configured for vectors" from "vector search will quietly return empty".

Functions

Link copied to clipboard
open override fun addProvenance(propositionId: String, entries: List<ProvenanceEntry>): Proposition?

Append provenance to a proposition (deduplicated); never removes existing entries.

Link copied to clipboard
open override fun clearProvenance(propositionId: String): Proposition?

Remove all provenance from a proposition.

Link copied to clipboard
open override fun count(): Int

Get the total count of propositions.

open override fun count(query: PropositionQuery): Int

Count the propositions matching query. The default materialises query's results and counts them; a backend that can count server-side (e.g. the graph store) overrides to avoid loading the rows just to size them.

Link copied to clipboard
open override fun delete(id: String): Boolean

Delete a proposition by ID.

Link copied to clipboard
open override fun findAll(): List<Proposition>

Get all propositions.

Link copied to clipboard
open override fun findByContextId(contextId: <Error class: unknown class>): List<Proposition>

Find propositions in the given context.

Link copied to clipboard
open override fun findByContextIdValue(contextIdValue: String): List<Proposition>

Java-friendly variant of findByContextId that accepts a plain string.

Link copied to clipboard
open override fun findByEntity(entityIdentifier: <Error class: unknown class>): List<Proposition>

Find all propositions that mention a specific entity.

Link copied to clipboard
open override fun findByGrounding(chunkId: String): List<Proposition>

Find all propositions grounded by a specific chunk.

Link copied to clipboard
open override fun findById(id: String): Proposition?

Find a proposition by its ID.

Link copied to clipboard
open override fun findByMinLevel(minLevel: Int): List<Proposition>

Find propositions at or above the specified abstraction level. Level 0 = raw observations, 1+ = abstractions.

Link copied to clipboard
open override fun findByStatus(status: PropositionStatus): List<Proposition>

Find all propositions with the given status.

Link copied to clipboard
open override fun findClusters(similarityThreshold: <Error class: unknown class>, topK: Int, query: PropositionQuery): List<<Error class: unknown class><Proposition>>

Proposition clustering. Forwards to the supplementary store so any backend-native clustering override is honoured. Degrades to empty when the supplementary store is not vector-capable.

Link copied to clipboard
open override fun findPinned(contextId: <Error class: unknown class>): List<Proposition>

All pinned propositions in contextId.

Link copied to clipboard
open fun findSimilar(textSimilaritySearchRequest: <Error class: unknown class>): List<Proposition>

Find propositions similar to the given text using vector similarity.

Link copied to clipboard
open override fun findSimilarWithScores(textSimilaritySearchRequest: <Error class: unknown class>): List<<Error class: unknown class><Proposition>>

Proposition vector similarity search. Forwards to the supplementary store when it is vector-capable; degrades gracefully to an empty list otherwise. Never touches the entity-axis SPI vector search, which operates on a different axis.

open override fun findSimilarWithScores(textSimilaritySearchRequest: <Error class: unknown class>, query: PropositionQuery): List<<Error class: unknown class><Proposition>>

Filtered similarity search. Forwards to the supplementary store so any backend that pushes the query filter down to its own index gets credit for it, rather than falling back to the interface default that re-filters generic results. Degrades to empty when the supplementary store is not vector-capable.

Link copied to clipboard
open override fun keywordOverlap(base: PropositionQuery, tokens: List<String>, limit: Int): List<Proposition>

Find propositions in base's scope whose text contains at least one of tokens (case-insensitive), ranked by how many distinct tokens each contains (descending), ties broken by base's ordering. At most limit results; empty tokens or non-positive limit returns nothing.

Link copied to clipboard
open override fun pin(id: String): Proposition?

Pin a proposition so it resists reclamation: pinned propositions are skipped by the decay collector and the sweep policy, are decay-exempt in the default status policy, and are not auto-retired by contradiction resolution.

Link copied to clipboard
open override fun provenanceOf(propositionId: String): List<ProvenanceEntry>

The provenance entries of a proposition, or an empty list if it has none or does not exist.

Link copied to clipboard
open override fun query(query: PropositionQuery): List<Proposition>

Disambiguates the diamond between VectorSearchCapable.query and PropositionStore.query by forwarding to the supplementary store, giving the composed type a single unambiguous query.

Link copied to clipboard
open override fun save(proposition: Proposition): Proposition

Save a proposition. If a proposition with the same ID exists, it will be replaced.

Link copied to clipboard
open override fun saveAll(propositions: Collection<Proposition>)

Save multiple propositions.

Link copied to clipboard

Save multiple propositions and report which stored proposition each one landed on.

Link copied to clipboard
open override fun setProvenance(propositionId: String, entries: List<ProvenanceEntry>): Proposition?

Authoritatively set a proposition's provenance to exactly entries, removing any not listed.

Link copied to clipboard
open override fun touchAccessed(ids: Collection<String>)

Refresh Proposition.lastAccessed to now for ids — the read-side reinforcement that lets a DECAYING proposition's decay anchor (see Proposition.effectiveConfidenceAt) track actual use rather than only content edits. Best-effort and silent about unknown ids (a stale eager id that has since been deleted is not an error).

Link copied to clipboard
open override fun unpin(id: String): Proposition?

Clear a proposition's pin, returning it to normal reclamation.