InMemoryPropositionRunLinkStore

class InMemoryPropositionRunLinkStore constructor(runStore: ExtractionRunStore, propositionStore: PropositionStore, maxRuns: Int) : PropositionRunLinkStore

Reference PropositionRunLinkStore that keeps the relation in a map.

It is the executable statement of what the contract means, so a durable backend can be held to the same suite, and it lets a host record run lineage before it has a database.

It needs both endpoint stores, and that is the honest shape. The tenant guard is a question about existence — is there a run under this key, is there a proposition under this id in this tenant — and only the stores that hold them can answer. A durable backend asks the same two questions in its own statements inside one transaction. A reference implementation that skipped the check would accept cross-tenant links every durable backend rejects, and the suite that holds the two together would be asserting nothing.

Every write and read runs inside one monitor, so a check and the write that depends on it cannot interleave with another thread's. A durable store gets the same from its transaction.

There is no unscoped read here, for the same reason InMemoryExtractionRunStore has none: one instance holds every tenant's links.

This is the reference implementation, and it forgets. A link whose proposition is gone altogether is dropped the next time a read resolves it, and a run with no links left is dropped with it, but nothing reads on a host's behalf, so the store also holds links for at most maxRuns runs. When a link for a new run would push it past that cap it evicts the runs it linked earliest, oldest first, as long as the run store says the run has ended. A run still RUNNING keeps its links, so a store where every linked run is running can grow past the cap; that logs once at warn, not on every link. A host running this store in production is accepting that the lineage of a run older than the cap is gone for good. Retention is a real, durable policy on the graph-backed store; this one exists so a host can record lineage before it has one of those.

Nothing here survives the JVM, and two instances know nothing about each other.

EXPERIMENTAL. The shape may still change while extraction runs (DICE #67) land.

Parameters

runStore

Where the run end of a link is resolved.

propositionStore

Where the proposition end is resolved.

maxRuns

The most runs this store keeps links for before it starts forgetting the ones it linked earliest. Must be positive. The default, 10,000, matches InMemoryExtractionRunStore.

Constructors

Link copied to clipboard
constructor(runStore: ExtractionRunStore, propositionStore: PropositionStore, maxRuns: Int)

Functions

Link copied to clipboard
open override fun link(key: ExtractionRunKey, propositionIds: Collection<String>): Int

Records that key's run produced each of propositionIds, in that run's tenant.

open fun link(key: ExtractionRunKey, propositionId: String): Int

link for a single proposition.

Link copied to clipboard
open override fun propositionsOf(key: ExtractionRunKey, limit: Int): List<String>

The propositions this run produced that this tenant still holds.

Link copied to clipboard
open override fun runsOf(contextIdValue: String, propositionId: String, limit: Int): List<ExtractionRunRef>

The runs that produced the proposition, in one tenant, by run id ascending.