Skip to content

Class: SqliteLessonStore ​

Defined in: sqlite/src/stores/sqlite-lesson-store.ts:23

WAL-mode SQLite implementation of the @paraharness/core LessonStore runtime port.

Persists distilled empirical lessons, computes normalized candidate relevance $R(L, Q) \in [0, 1]$, tracks 4-state execution outcomes, synchronizes creation epochs, and enforces signal cooldowns.

Implements ​

Constructors ​

Constructor ​

ts
new SqliteLessonStore(uriOrDb): SqliteLessonStore;

Defined in: sqlite/src/stores/sqlite-lesson-store.ts:36

Initializes a SqliteLessonStore against a SQLite file path, :memory:, or existing Database handle.

Applies WAL-mode PRAGMAs and idempotent lesson store DDL statements on initialization.

Parameters ​

ParameterTypeDescription
uriOrDbstring | DatabaseSQLite database URI or open better-sqlite3 handle.

Returns ​

SqliteLessonStore

Methods ​

admit() ​

ts
admit(lesson): Promise<string>;

Defined in: sqlite/src/stores/sqlite-lesson-store.ts:62

Persists a newly distilled lesson into the store and returns its assigned lessonId.

Deduplicates identical (partition, directive) entries and records epochAtCreation and createdByRunId.

Parameters ​

ParameterTypeDescription
lessonAdmitLessonParamsLesson definition to admit.

Returns ​

Promise<string>

Newly assigned or content-addressed lessonId.

Implementation of ​

LessonStore.admit


close() ​

ts
close(): void;

Defined in: sqlite/src/stores/sqlite-lesson-store.ts:143

Closes the underlying better-sqlite3 database connection.

Releases file descriptors and WAL shared-memory locks held by this store instance.

Returns ​

void

Returns nothing once the connection is closed.


markSignalEmitted() ​

ts
markSignalEmitted(
   lessonId, 
   signalId, 
   emittedAt
): Promise<void>;

Defined in: sqlite/src/stores/sqlite-lesson-store.ts:111

Records the ISO-8601 timestamp when a promotion signal was emitted for lessonId.

Persists the timestamp in signalLastEmittedAt[signalId] to enforce cooldownHours across restarts.

Parameters ​

ParameterTypeDescription
lessonIdstringIdentifier of the lesson that triggered the signal.
signalIdstringIdentifier of the emitted signal.
emittedAtstringISO-8601 timestamp string of the emission.

Returns ​

Promise<void>

Resolves when the cooldown timestamp is persisted.

Implementation of ​

LessonStore.markSignalEmitted


queryCandidates() ​

ts
queryCandidates(req): Promise<readonly LessonRecord[]>;

Defined in: sqlite/src/stores/sqlite-lesson-store.ts:49

Queries non-retired candidate lessons relevant to req.queryText and req.partitions.

Populates relevanceScore in [0, 1] on each returned LessonRecord.

Parameters ​

ParameterTypeDescription
reqQueryLessonCandidatesParamsSearch query and active partitions.

Returns ​

Promise<readonly LessonRecord[]>

Candidate lesson records with relevanceScore populated.

Implementation of ​

LessonStore.queryCandidates


recordOutcomes() ​

ts
recordOutcomes(outcomes): Promise<readonly LessonRecord[]>;

Defined in: sqlite/src/stores/sqlite-lesson-store.ts:75

Appends deduplicated step execution outcomes to the specified lessons and returns their updated records.

Increments totalCleanPasses or totalViolated and updates each lesson's recentOutcomes window.

Parameters ​

ParameterTypeDescription
outcomesreadonly LessonOutcomeEntryParams[]Batch of (lessonId, outcome) pairs.

Returns ​

Promise<readonly LessonRecord[]>

Updated lesson records reflecting the recorded outcomes.

Implementation of ​

LessonStore.recordOutcomes


retire() ​

ts
retire(lessonIds): Promise<void>;

Defined in: sqlite/src/stores/sqlite-lesson-store.ts:128

Permanently retires lessons that breached violation or low clean-pass-rate thresholds.

Excludes retired lessons from all subsequent queryCandidates() recalls.

Parameters ​

ParameterTypeDescription
lessonIdsreadonly string[]Identifiers of lessons to retire.

Returns ​

Promise<void>

Resolves when all specified lessons are retired.

Implementation of ​

LessonStore.retire


syncCreationEpochsForRuns() ​

ts
syncCreationEpochsForRuns(runIds, updatedEpochs): Promise<void>;

Defined in: sqlite/src/stores/sqlite-lesson-store.ts:91

Aligns epochAtCreation for lessons created by runIds when their topology overlays commit to the base store.

Prevents lessons authored in a run that also updated a partition's contract from being falsely penalized for epoch drift.

Parameters ​

ParameterTypeDescription
runIdsreadonly string[]Run IDs whose topology overlays were committed.
updatedEpochsReadonlyMap<string, number>Map of partitionId to newly committed base epoch.

Returns ​

Promise<void>

Resolves when creation epochs are synchronized.

Implementation of ​

LessonStore.syncCreationEpochsForRuns

Released under the MIT License.