Class: InMemoryLearningStore
Defined in: packages/agentos/src/cognition/learning/store/InMemoryLearningStore.ts:342
The learning store in the process, for tests and short-lived processes (see the module's description).
Extends
TransactionalLearningStore
Constructors
Constructor
new InMemoryLearningStore():
InMemoryLearningStore
Returns
InMemoryLearningStore
Inherited from
TransactionalLearningStore.constructor
Properties
kind
readonlykind:"memory"
Defined in: packages/agentos/src/cognition/learning/store/InMemoryLearningStore.ts:343
Overrides
TransactionalLearningStore.kind
Methods
advanceHead()
advanceHead(
chainKey,expectedSeq,next):Promise<boolean>
Defined in: packages/agentos/src/cognition/learning/store/LearningStore.ts:232
Moves a head from expectedSeq to next, whose lastId, lastHash and seq alone it writes; false when the
chain has no head, the head moved on, or it is marked forgotten.
Parameters
chainKey
string
expectedSeq
number
next
lastHash
string
lastId
string
seq
number
Returns
Promise<boolean>
Inherited from
TransactionalLearningStore.advanceHead
agentPendingRows()
agentPendingRows(
namespace,agentKey,createdBefore):Promise<StoredLedgerRow[]>
Defined in: packages/agentos/src/cognition/learning/store/LearningStore.ts:229
The candidates that have no verdict row on one agent's chains with no learner in one namespace (the agent's own
chain and each second user's), created at or before createdBefore (an ISO time), ordered by chain key and
sequence: what a crash left pending there.
Parameters
namespace
string
agentKey
string
createdBefore
string
Returns
Promise<StoredLedgerRow[]>
Inherited from
TransactionalLearningStore.agentPendingRows
candidateRows()
candidateRows(
candidateId):Promise<StoredLedgerRow[]>
Defined in: packages/agentos/src/cognition/learning/store/LearningStore.ts:227
A candidate and its verdicts, in sequence order.
Parameters
candidateId
string
Returns
Promise<StoredLedgerRow[]>
Inherited from
TransactionalLearningStore.candidateRows
chainRows()
chainRows(
chainKey):Promise<StoredLedgerRow[]>
Defined in: packages/agentos/src/cognition/learning/store/LearningStore.ts:225
A chain's rows in sequence order.
Parameters
chainKey
string
Returns
Promise<StoredLedgerRow[]>
Inherited from
TransactionalLearningStore.chainRows
chainWithHead()
chainWithHead(
chainKey):Promise<{head:ChainHead|undefined;rows:StoredLedgerRow[]; }>
Defined in: packages/agentos/src/cognition/learning/store/LearningStore.ts:226
A chain's rows in sequence order and its head, read at one moment: an append that commits meanwhile is in both or in neither, also on a database that gives each statement of a transaction its own snapshot (Postgres at Read Committed), where the SQL store reads both in one statement.
Parameters
chainKey
string
Returns
Promise<{ head: ChainHead | undefined; rows: StoredLedgerRow[]; }>
Inherited from
TransactionalLearningStore.chainWithHead
close()
close():
Promise<void>
Defined in: packages/agentos/src/cognition/learning/store/InMemoryLearningStore.ts:369
Releases nothing: the rows stay with the store until the process ends.
Returns
Promise<void>
Overrides
TransactionalLearningStore.close
deleteFreeze()
deleteFreeze(
scopeKey,mode):Promise<boolean>
Defined in: packages/agentos/src/cognition/learning/store/LearningStore.ts:239
Parameters
scopeKey
string
mode
"frozen" | "off"
Returns
Promise<boolean>
Inherited from
TransactionalLearningStore.deleteFreeze
deleteUserRows()
deleteUserRows(
namespace,userId):Promise<Record<string,number>>
Defined in: packages/agentos/src/cognition/learning/store/LearningStore.ts:246
Deletes every row of one user in one namespace: ledger rows whose userId or turnUserId is the user, the
user's heads, trait rows, outcomes, lessons, skills, session rows of both kinds, and freezes keyed to the user's
learners. Never the tombstone, which every later write for the user checks.
Parameters
namespace
string
userId
string
Returns
Promise<Record<string, number>>
The rows deleted, per table: ledger, heads, traits, outcomes, lessons, skills, sessions
and freezes.
Inherited from
TransactionalLearningStore.deleteUserRows
freezeRows()
freezeRows():
Promise<FreezeRow[]>
Defined in: packages/agentos/src/cognition/learning/store/LearningStore.ts:237
Every freeze and suspension, ordered by scope key and mode.
Returns
Promise<FreezeRow[]>
Inherited from
TransactionalLearningStore.freezeRows
head()
head(
chainKey):Promise<ChainHead|undefined>
Defined in: packages/agentos/src/cognition/learning/store/LearningStore.ts:230
Parameters
chainKey
string
Returns
Promise<ChainHead | undefined>
Inherited from
TransactionalLearningStore.head
insertForgotten()
insertForgotten(
hash,forgottenAt):Promise<void>
Defined in: packages/agentos/src/cognition/learning/store/LearningStore.ts:244
Idempotent.
Parameters
hash
string
forgottenAt
string
Returns
Promise<void>
Inherited from
TransactionalLearningStore.insertForgotten
insertFreeze()
insertFreeze(
row):Promise<void>
Defined in: packages/agentos/src/cognition/learning/store/LearningStore.ts:238
Idempotent: a scope frozen twice holds one row, the first.
Parameters
row
FreezeRow
Returns
Promise<void>
Inherited from
TransactionalLearningStore.insertFreeze
insertHead()
insertHead(
head):Promise<boolean>
Defined in: packages/agentos/src/cognition/learning/store/LearningStore.ts:231
Starts a chain's head; false when the chain has one.
Parameters
head
ChainHead
Returns
Promise<boolean>
Inherited from
TransactionalLearningStore.insertHead
insertLedgerRow()
insertLedgerRow(
row):Promise<void>
Defined in: packages/agentos/src/cognition/learning/store/LearningStore.ts:223
Appends a row; throws when a row has its id, or its chain has a row at its seq.
Parameters
row
StoredLedgerRow
Returns
Promise<void>
Inherited from
TransactionalLearningStore.insertLedgerRow
insertTraitRow()
insertTraitRow(
row):Promise<boolean>
Defined in: packages/agentos/src/cognition/learning/store/LearningStore.ts:235
false when the learner has a row.
Parameters
row
StoredTraitRow
Returns
Promise<boolean>
Inherited from
TransactionalLearningStore.insertTraitRow
isForgotten()
isForgotten(
hash):Promise<boolean>
Defined in: packages/agentos/src/cognition/learning/store/LearningStore.ts:243
Parameters
hash
string
Returns
Promise<boolean>
Inherited from
TransactionalLearningStore.isForgotten
learnerDocs()
learnerDocs(
table,namespace,agentKey,userId):Promise<LearnerDocRow[]>
Defined in: packages/agentos/src/cognition/learning/store/LearningStore.ts:245
One learner's rows of a learner document table, ordered by createdAt and id.
Parameters
table
LearnerDocTable
namespace
string
agentKey
string
userId
string
Returns
Promise<LearnerDocRow[]>
Inherited from
TransactionalLearningStore.learnerDocs
learnerLedgerRows()
learnerLedgerRows(
namespace,agentKey,userId):Promise<StoredLedgerRow[]>
Defined in: packages/agentos/src/cognition/learning/store/LearningStore.ts:228
The rows keyed to one learner (by namespace, agent and userId), ordered by chain key and sequence.
Parameters
namespace
string
agentKey
string
userId
string
Returns
Promise<StoredLedgerRow[]>
Inherited from
TransactionalLearningStore.learnerLedgerRows
ledgerRow()
ledgerRow(
id):Promise<StoredLedgerRow|undefined>
Defined in: packages/agentos/src/cognition/learning/store/LearningStore.ts:224
Parameters
id
string
Returns
Promise<StoredLedgerRow | undefined>
Inherited from
TransactionalLearningStore.ledgerRow
markHeadsForgotten()
markHeadsForgotten(
namespace,userId):Promise<number>
Defined in: packages/agentos/src/cognition/learning/store/LearningStore.ts:233
Marks every head of one user in one namespace forgotten; returns how many.
Parameters
namespace
string
userId
string
Returns
Promise<number>
Inherited from
TransactionalLearningStore.markHeadsForgotten
putSessionRow()
putSessionRow(
row,expectedVersion?):Promise<void>
Defined in: packages/agentos/src/cognition/learning/store/LearningStore.ts:241
Inserts the row, or writes it over the row of the same learner, session and kind, keeping that row's startedAt.
With expectedVersion, the version its writer read, it writes over the row only at that version, and inserts it
only where there is none for 0: a row another writer moved on since is left as it is, which a read of the row
shows, so two writers that read one row never drop each other's ids.
Parameters
row
SessionRow
expectedVersion?
number
Returns
Promise<void>
Inherited from
TransactionalLearningStore.putSessionRow
sessionRow()
sessionRow(
namespace,agentKey,sessionId,userId,kind):Promise<SessionRow|undefined>
Defined in: packages/agentos/src/cognition/learning/store/LearningStore.ts:240
Parameters
namespace
string
agentKey
string
sessionId
string
userId
string
kind
"learner" | "visitor"
Returns
Promise<SessionRow | undefined>
Inherited from
TransactionalLearningStore.sessionRow
sessionRowsIn()
sessionRowsIn(
namespace,agentKey,sessionId):Promise<SessionRow[]>
Defined in: packages/agentos/src/cognition/learning/store/InMemoryLearningStore.ts:364
Parameters
namespace
string
agentKey
string
sessionId
string
Returns
Promise<SessionRow[]>
sessionRowsOf()
sessionRowsOf(
namespace,userId):Promise<SessionRow[]>
Defined in: packages/agentos/src/cognition/learning/store/LearningStore.ts:242
One user's session rows of both kinds in one namespace, every agent's, ordered by session id and kind.
Parameters
namespace
string
userId
string
Returns
Promise<SessionRow[]>
Inherited from
TransactionalLearningStore.sessionRowsOf
traitRow()
traitRow(
namespace,agentKey,userId):Promise<StoredTraitRow|undefined>
Defined in: packages/agentos/src/cognition/learning/store/LearningStore.ts:234
Parameters
namespace
string
agentKey
string
userId
string
Returns
Promise<StoredTraitRow | undefined>
Inherited from
TransactionalLearningStore.traitRow
transaction()
transaction<
T>(fn):Promise<T>
Defined in: packages/agentos/src/cognition/learning/store/InMemoryLearningStore.ts:348
Type Parameters
T
T
Parameters
fn
(tx) => Promise<T>
Returns
Promise<T>
Overrides
TransactionalLearningStore.transaction
updateTraitRow()
updateTraitRow(
row,expectedVersion):Promise<boolean>
Defined in: packages/agentos/src/cognition/learning/store/LearningStore.ts:236
Writes row over the row at expectedVersion; false when another write moved it on, or there is none.
Parameters
row
StoredTraitRow
expectedVersion
number
Returns
Promise<boolean>
Inherited from
TransactionalLearningStore.updateTraitRow