Class: InMemoryRunRepository
Defined in: adapters/in-memory/InMemoryRunRepository.ts:28
InMemoryRunRepository -- the run repository in a Map, for tests and the sandbox
About
Behaves like a database without one: copies in and out, lists in insertion order.
Implements IRunRepository so the RunStore runs with no infrastructure. transition is atomic by construction: one
synchronous read and write with no await between them, which is what a real adapter gets from a conditional update.
Who needs it
The gateway tests (gatewayConfigBase), the dev sandbox and the cookbook's first run; a host app uses its own adapter.
Pitfalls
Production: nothing survives the process, nothing is shared between processes.
Implements
Constructors
Constructor
new InMemoryRunRepository():
InMemoryRunRepository
Returns
InMemoryRunRepository
Methods
anonymizeByUser()
anonymizeByUser(
__namedParameters):Promise<number>
Defined in: adapters/in-memory/InMemoryRunRepository.ts:195
anonymizeByUser -- keeps a user's runs as skeletons
About
GDPR pseudonymisation: the words go, the record stays.
userId becomes the pseudonym; messages, request.system, request.outputSchema, skills, pending and answer are
emptied; a RUNNING or PAUSED run becomes CANCELLED; id, status, steps and dates stay. Returns how many.
Who needs it
RunStore.anonymizeByUser, for the gateway's anonymizeUserData.
Parameters
__namedParameters
pseudonym
string
tenantId
string
userId
string
Returns
Promise<number>
Implementation of
IRunRepository.anonymizeByUser
delete()
delete(
__namedParameters):Promise<number>
Defined in: adapters/in-memory/InMemoryRunRepository.ts:160
delete -- hard-deletes the runs of threads
About
The listed ids, or every run of the tenant for
"all".
Narrowed to one user when userId is given. Returns how many went.
Who needs it
RunStore.delete, for the gateway's delete and deleteUserData.
Parameters
__namedParameters
tenantId
string
threadIds
userId?
string
Returns
Promise<number>
Implementation of
listByStatus()
listByStatus(
__namedParameters):Promise<IRun[]>
Defined in: adapters/in-memory/InMemoryRunRepository.ts:89
listByStatus -- the tenant's runs in one status
About
Narrowed to one user when
userIdis given; any order.
Every run of the tenant whose status matches.
Who needs it
RunStore.listPaused and listRunning.
Parameters
__namedParameters
status
tenantId
string
userId?
string
Returns
Promise<IRun[]>
Implementation of
load()
load(
__namedParameters):Promise<IRun|null>
Defined in: adapters/in-memory/InMemoryRunRepository.ts:63
load -- the run of a tenant by id
About
Null when missing or of another tenant.
The run as stored, whole.
Who needs it
RunStore.load.
Parameters
__namedParameters
runId
string
tenantId
string
Returns
Promise<IRun | null>
Implementation of
save()
save(
__namedParameters):Promise<void>
Defined in: adapters/in-memory/InMemoryRunRepository.ts:44
save -- creates or replaces the run
About
Whole, by
idwithin the tenant.
The run as the gateway holds it: request, messages, status, pending calls, answer.
Who needs it
RunStore.save and setStatus.
Parameters
__namedParameters
run
Returns
Promise<void>
Implementation of
transition()
transition(
__namedParameters):Promise<IRun|null>
Defined in: adapters/in-memory/InMemoryRunRepository.ts:121
transition -- moves a run from one status to another atomically
About
Compare-and-set (D69): two callers racing for the same run, exactly one gets it.
Returns the updated run, or null when the run is missing or not in from; pending is cleared when to is not PAUSED.
One database operation with the condition in the filter, never a load followed by a save.
Who needs it
RunStore.transition, for every status change that must be taken once: a resume, a cancel, an expiry.
Parameters
__namedParameters
from
runId
string
tenantId
string
to
Returns
Promise<IRun | null>