@hraness/oh 0.3.1 → 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -147,7 +147,11 @@ function document(
147
147
  async function bootstrapped(): Promise<SqliteCompatibleLibSqlClient> {
148
148
  const client = new SqliteCompatibleLibSqlClient();
149
149
  expect(await bootstrapOhLibSqlSemanticCacheV1(client, { appliedAt: instant1 }))
150
- .toMatchObject({ schemaVersion: 1, v: 1 });
150
+ .toEqual({
151
+ schemaSha256: "d9903735e900e08a8c49c9ad36ea8f277b1689117ef88b9a2c6b906456dfbace" as Sha256Hex,
152
+ schemaVersion: 1,
153
+ v: 1,
154
+ });
151
155
  return client;
152
156
  }
153
157
 
@@ -167,6 +171,51 @@ function authority(
167
171
  }
168
172
 
169
173
  describe("libSQL derived semantic cache", () => {
174
+ test("reproduces the fixed released V1 digest fixture", async () => {
175
+ const fixture = await Bun.file(new URL(
176
+ "../spec/v1/libsql-semantic-digest-fixture-v1.json",
177
+ import.meta.url,
178
+ )).json() as Readonly<{
179
+ authorityId: string;
180
+ authoritySha256: Sha256Hex;
181
+ content: string;
182
+ generation: number;
183
+ generationSha256: Sha256Hex;
184
+ inputSha256: Sha256Hex;
185
+ membershipSha256: Sha256Hex;
186
+ recordKey: string;
187
+ recordSha256: Sha256Hex;
188
+ title: string;
189
+ v: 1;
190
+ }>;
191
+ const client = await bootstrapped();
192
+ const cache = await openOhLibSqlSemanticCacheV1(client);
193
+ const calls: string[][] = [];
194
+ const staged = await cache.stage({
195
+ authorityId: fixture.authorityId,
196
+ authoritySha256: fixture.authoritySha256,
197
+ createdAt: instant1,
198
+ documents: [{
199
+ content: fixture.content,
200
+ key: fixture.recordKey,
201
+ recordSha256: fixture.recordSha256,
202
+ title: fixture.title,
203
+ v: fixture.v,
204
+ }],
205
+ embeddingClient: embeddingClient(calls),
206
+ generation: fixture.generation,
207
+ });
208
+ expect(staged).toMatchObject({
209
+ generationSha256: fixture.generationSha256,
210
+ membershipSha256: fixture.membershipSha256,
211
+ v: 1,
212
+ });
213
+ expect(calls).toHaveLength(1);
214
+ expect(sha256Hex(calls[0]?.[0] ?? "")).toBe(fixture.inputSha256);
215
+ await cache.close();
216
+ client.close();
217
+ });
218
+
170
219
  test("requires explicit bootstrap and refuses a partial or drifted schema", async () => {
171
220
  const empty = new SqliteCompatibleLibSqlClient();
172
221
  await expect(openOhLibSqlSemanticCacheV1(empty)).rejects.toMatchObject({
@@ -1,2 +1,3 @@
1
1
  export * from "./cloudflare-embedding";
2
2
  export * from "./libsql-semantic";
3
+ export * from "./libsql-semantic-v2";