@anuma/sdk 9.1.1 → 9.1.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.
- package/dist/expo/index.cjs +40 -11
- package/dist/expo/index.d.mts +1 -14
- package/dist/expo/index.d.ts +1 -14
- package/dist/expo/index.mjs +40 -11
- package/dist/react/index.cjs +40 -11
- package/dist/react/index.d.mts +1 -14
- package/dist/react/index.d.ts +1 -14
- package/dist/react/index.mjs +40 -11
- package/dist/server/index.cjs +40 -11
- package/dist/server/index.d.mts +1 -14
- package/dist/server/index.d.ts +1 -14
- package/dist/server/index.mjs +40 -11
- package/package.json +1 -1
package/dist/expo/index.cjs
CHANGED
|
@@ -14817,9 +14817,10 @@ async function getVaultRankingProjectionsOp(ctx, options) {
|
|
|
14817
14817
|
}
|
|
14818
14818
|
function baseVaultSql(ctx, options) {
|
|
14819
14819
|
const clauses = [
|
|
14820
|
+
`"_status" is not 'deleted'`,
|
|
14820
14821
|
'"is_deleted" = 0',
|
|
14821
14822
|
...options?.includeArchived ? [] : ['"archived_at" is null'],
|
|
14822
|
-
`"trust_tier" is not 'quarantined'
|
|
14823
|
+
...options?.includeQuarantined ? [] : [`"trust_tier" is not 'quarantined'`],
|
|
14823
14824
|
'"superseded_by" is null'
|
|
14824
14825
|
];
|
|
14825
14826
|
const args = [];
|
|
@@ -15305,8 +15306,17 @@ async function getMemoriesNeedingTopicExtractionOp(ctx, options) {
|
|
|
15305
15306
|
if (!entityCtx) {
|
|
15306
15307
|
throw new Error("getMemoriesNeedingTopicExtractionOp requires ctx.entityCtx");
|
|
15307
15308
|
}
|
|
15308
|
-
|
|
15309
|
-
|
|
15309
|
+
let rows;
|
|
15310
|
+
try {
|
|
15311
|
+
const base = baseVaultSql(ctx);
|
|
15312
|
+
const sql = `select "id", "topics", "topics_user_managed", "topics_extracted_at", "topics_extracted_version", "updated_at" from "memory_vault" where ${base.sql} order by "created_at" desc`;
|
|
15313
|
+
rows = await ctx.vaultMemoryCollection.query(import_watermelondb21.Q.unsafeSqlQuery(sql, base.args)).unsafeFetchRaw();
|
|
15314
|
+
} catch (err) {
|
|
15315
|
+
getLogger().debug(
|
|
15316
|
+
"memoryVault: topic sweep SQL unavailable; use the adapter query: " + (err instanceof Error ? err.message : String(err))
|
|
15317
|
+
);
|
|
15318
|
+
rows = await ctx.vaultMemoryCollection.query(...baseVaultConditions(ctx), import_watermelondb21.Q.sortBy("created_at", import_watermelondb21.Q.desc)).unsafeFetchRaw();
|
|
15319
|
+
}
|
|
15310
15320
|
const linkedNames = await linkedEntityNamesByMemory(
|
|
15311
15321
|
entityCtx,
|
|
15312
15322
|
rows.map((r) => r.id)
|
|
@@ -15365,10 +15375,19 @@ async function getMemoriesNeedingTopicExtractionOp(ctx, options) {
|
|
|
15365
15375
|
}
|
|
15366
15376
|
const orderedPendingRaw = [...stampedPendingRaw, ...pendingRaw];
|
|
15367
15377
|
const limitedPendingRaw = cap !== void 0 ? orderedPendingRaw.slice(0, cap) : orderedPendingRaw;
|
|
15368
|
-
const pending =
|
|
15369
|
-
|
|
15370
|
-
|
|
15371
|
-
|
|
15378
|
+
const pending = [];
|
|
15379
|
+
for (let i = 0; i < limitedPendingRaw.length; i += 500) {
|
|
15380
|
+
const chunk = limitedPendingRaw.slice(i, i + 500);
|
|
15381
|
+
const memories = await getVaultMemoriesByIdsOp(
|
|
15382
|
+
ctx,
|
|
15383
|
+
chunk.map((raw) => raw.id)
|
|
15384
|
+
);
|
|
15385
|
+
const byId = new Map(memories.map((memory) => [memory.uniqueId, memory]));
|
|
15386
|
+
for (const raw of chunk) {
|
|
15387
|
+
const memory = byId.get(raw.id);
|
|
15388
|
+
if (memory) pending.push(memory);
|
|
15389
|
+
}
|
|
15390
|
+
}
|
|
15372
15391
|
const applyCap = (ids) => cap !== void 0 ? ids.slice(0, cap) : ids;
|
|
15373
15392
|
return {
|
|
15374
15393
|
pending,
|
|
@@ -15515,10 +15534,20 @@ function assertVaultScopeForSweep(ctx) {
|
|
|
15515
15534
|
}
|
|
15516
15535
|
async function getDecayCandidatesRawOp(ctx) {
|
|
15517
15536
|
assertVaultScopeForSweep(ctx);
|
|
15518
|
-
|
|
15519
|
-
|
|
15520
|
-
|
|
15521
|
-
|
|
15537
|
+
let results;
|
|
15538
|
+
try {
|
|
15539
|
+
const base = baseVaultSql(ctx, { includeArchived: true, includeQuarantined: true });
|
|
15540
|
+
const sql = `select "id", "fact_type", "event_time_end", "event_time_kind", "updated_at", "last_observed_at", "archived_at", "source", "trust_tier" from "memory_vault" where ${base.sql} and "kind" is null`;
|
|
15541
|
+
results = await ctx.vaultMemoryCollection.query(import_watermelondb21.Q.unsafeSqlQuery(sql, base.args)).unsafeFetchRaw();
|
|
15542
|
+
} catch (err) {
|
|
15543
|
+
getLogger().debug(
|
|
15544
|
+
"memoryVault: decay sweep SQL unavailable; use the adapter query: " + (err instanceof Error ? err.message : String(err))
|
|
15545
|
+
);
|
|
15546
|
+
results = await ctx.vaultMemoryCollection.query(
|
|
15547
|
+
...baseVaultConditions(ctx, { includeArchived: true, includeQuarantined: true }),
|
|
15548
|
+
import_watermelondb21.Q.where("kind", null)
|
|
15549
|
+
).unsafeFetchRaw();
|
|
15550
|
+
}
|
|
15522
15551
|
return results.map((raw) => ({
|
|
15523
15552
|
uniqueId: raw.id,
|
|
15524
15553
|
factType: raw.fact_type ?? null,
|
package/dist/expo/index.d.mts
CHANGED
|
@@ -6090,20 +6090,7 @@ interface DecayCandidateRaw {
|
|
|
6090
6090
|
* not egress poison content — see the decay sweeper's `isBorderline`). */
|
|
6091
6091
|
trustTier: string | null;
|
|
6092
6092
|
}
|
|
6093
|
-
/**
|
|
6094
|
-
* Decay sweep candidate scan (PR2). Selects the plaintext columns
|
|
6095
|
-
* `classifyDecay` (in `memory/decay`) needs via
|
|
6096
|
-
* `unsafeFetchRaw` — NO Model per row (dodges the never-evicted RecordCache /
|
|
6097
|
-
* web Pile-2 OOM history) and NO `content` read / decrypt (zero-knowledge).
|
|
6098
|
-
*
|
|
6099
|
-
* Includes archived AND quarantined rows (so archived→delete transitions and
|
|
6100
|
-
* aged quarantined rows are seen) but excludes hard-deleted rows — the
|
|
6101
|
-
* `baseVaultConditions` default keeps `is_deleted = false`. Excludes kinded
|
|
6102
|
-
* (profile) memories, which never decay.
|
|
6103
|
-
*
|
|
6104
|
-
* Refuses to run on an unscoped multi-tenant context (see
|
|
6105
|
-
* {@link assertVaultScopeForSweep}).
|
|
6106
|
-
*/
|
|
6093
|
+
/** Return the projected plaintext fields for the decay sweep within the required vault scope. */
|
|
6107
6094
|
declare function getDecayCandidatesRawOp(ctx: VaultMemoryOperationsContext): Promise<DecayCandidateRaw[]>;
|
|
6108
6095
|
/**
|
|
6109
6096
|
* Archive a memory (decay soft state, PR2) — set `archived_at`. An archived row
|
package/dist/expo/index.d.ts
CHANGED
|
@@ -6090,20 +6090,7 @@ interface DecayCandidateRaw {
|
|
|
6090
6090
|
* not egress poison content — see the decay sweeper's `isBorderline`). */
|
|
6091
6091
|
trustTier: string | null;
|
|
6092
6092
|
}
|
|
6093
|
-
/**
|
|
6094
|
-
* Decay sweep candidate scan (PR2). Selects the plaintext columns
|
|
6095
|
-
* `classifyDecay` (in `memory/decay`) needs via
|
|
6096
|
-
* `unsafeFetchRaw` — NO Model per row (dodges the never-evicted RecordCache /
|
|
6097
|
-
* web Pile-2 OOM history) and NO `content` read / decrypt (zero-knowledge).
|
|
6098
|
-
*
|
|
6099
|
-
* Includes archived AND quarantined rows (so archived→delete transitions and
|
|
6100
|
-
* aged quarantined rows are seen) but excludes hard-deleted rows — the
|
|
6101
|
-
* `baseVaultConditions` default keeps `is_deleted = false`. Excludes kinded
|
|
6102
|
-
* (profile) memories, which never decay.
|
|
6103
|
-
*
|
|
6104
|
-
* Refuses to run on an unscoped multi-tenant context (see
|
|
6105
|
-
* {@link assertVaultScopeForSweep}).
|
|
6106
|
-
*/
|
|
6093
|
+
/** Return the projected plaintext fields for the decay sweep within the required vault scope. */
|
|
6107
6094
|
declare function getDecayCandidatesRawOp(ctx: VaultMemoryOperationsContext): Promise<DecayCandidateRaw[]>;
|
|
6108
6095
|
/**
|
|
6109
6096
|
* Archive a memory (decay soft state, PR2) — set `archived_at`. An archived row
|
package/dist/expo/index.mjs
CHANGED
|
@@ -13191,9 +13191,10 @@ async function getVaultRankingProjectionsOp(ctx, options) {
|
|
|
13191
13191
|
}
|
|
13192
13192
|
function baseVaultSql(ctx, options) {
|
|
13193
13193
|
const clauses = [
|
|
13194
|
+
`"_status" is not 'deleted'`,
|
|
13194
13195
|
'"is_deleted" = 0',
|
|
13195
13196
|
...options?.includeArchived ? [] : ['"archived_at" is null'],
|
|
13196
|
-
`"trust_tier" is not 'quarantined'
|
|
13197
|
+
...options?.includeQuarantined ? [] : [`"trust_tier" is not 'quarantined'`],
|
|
13197
13198
|
'"superseded_by" is null'
|
|
13198
13199
|
];
|
|
13199
13200
|
const args = [];
|
|
@@ -13679,8 +13680,17 @@ async function getMemoriesNeedingTopicExtractionOp(ctx, options) {
|
|
|
13679
13680
|
if (!entityCtx) {
|
|
13680
13681
|
throw new Error("getMemoriesNeedingTopicExtractionOp requires ctx.entityCtx");
|
|
13681
13682
|
}
|
|
13682
|
-
|
|
13683
|
-
|
|
13683
|
+
let rows;
|
|
13684
|
+
try {
|
|
13685
|
+
const base = baseVaultSql(ctx);
|
|
13686
|
+
const sql = `select "id", "topics", "topics_user_managed", "topics_extracted_at", "topics_extracted_version", "updated_at" from "memory_vault" where ${base.sql} order by "created_at" desc`;
|
|
13687
|
+
rows = await ctx.vaultMemoryCollection.query(Q6.unsafeSqlQuery(sql, base.args)).unsafeFetchRaw();
|
|
13688
|
+
} catch (err) {
|
|
13689
|
+
getLogger().debug(
|
|
13690
|
+
"memoryVault: topic sweep SQL unavailable; use the adapter query: " + (err instanceof Error ? err.message : String(err))
|
|
13691
|
+
);
|
|
13692
|
+
rows = await ctx.vaultMemoryCollection.query(...baseVaultConditions(ctx), Q6.sortBy("created_at", Q6.desc)).unsafeFetchRaw();
|
|
13693
|
+
}
|
|
13684
13694
|
const linkedNames = await linkedEntityNamesByMemory(
|
|
13685
13695
|
entityCtx,
|
|
13686
13696
|
rows.map((r) => r.id)
|
|
@@ -13739,10 +13749,19 @@ async function getMemoriesNeedingTopicExtractionOp(ctx, options) {
|
|
|
13739
13749
|
}
|
|
13740
13750
|
const orderedPendingRaw = [...stampedPendingRaw, ...pendingRaw];
|
|
13741
13751
|
const limitedPendingRaw = cap !== void 0 ? orderedPendingRaw.slice(0, cap) : orderedPendingRaw;
|
|
13742
|
-
const pending =
|
|
13743
|
-
|
|
13744
|
-
|
|
13745
|
-
|
|
13752
|
+
const pending = [];
|
|
13753
|
+
for (let i = 0; i < limitedPendingRaw.length; i += 500) {
|
|
13754
|
+
const chunk = limitedPendingRaw.slice(i, i + 500);
|
|
13755
|
+
const memories = await getVaultMemoriesByIdsOp(
|
|
13756
|
+
ctx,
|
|
13757
|
+
chunk.map((raw) => raw.id)
|
|
13758
|
+
);
|
|
13759
|
+
const byId = new Map(memories.map((memory) => [memory.uniqueId, memory]));
|
|
13760
|
+
for (const raw of chunk) {
|
|
13761
|
+
const memory = byId.get(raw.id);
|
|
13762
|
+
if (memory) pending.push(memory);
|
|
13763
|
+
}
|
|
13764
|
+
}
|
|
13746
13765
|
const applyCap = (ids) => cap !== void 0 ? ids.slice(0, cap) : ids;
|
|
13747
13766
|
return {
|
|
13748
13767
|
pending,
|
|
@@ -13889,10 +13908,20 @@ function assertVaultScopeForSweep(ctx) {
|
|
|
13889
13908
|
}
|
|
13890
13909
|
async function getDecayCandidatesRawOp(ctx) {
|
|
13891
13910
|
assertVaultScopeForSweep(ctx);
|
|
13892
|
-
|
|
13893
|
-
|
|
13894
|
-
|
|
13895
|
-
|
|
13911
|
+
let results;
|
|
13912
|
+
try {
|
|
13913
|
+
const base = baseVaultSql(ctx, { includeArchived: true, includeQuarantined: true });
|
|
13914
|
+
const sql = `select "id", "fact_type", "event_time_end", "event_time_kind", "updated_at", "last_observed_at", "archived_at", "source", "trust_tier" from "memory_vault" where ${base.sql} and "kind" is null`;
|
|
13915
|
+
results = await ctx.vaultMemoryCollection.query(Q6.unsafeSqlQuery(sql, base.args)).unsafeFetchRaw();
|
|
13916
|
+
} catch (err) {
|
|
13917
|
+
getLogger().debug(
|
|
13918
|
+
"memoryVault: decay sweep SQL unavailable; use the adapter query: " + (err instanceof Error ? err.message : String(err))
|
|
13919
|
+
);
|
|
13920
|
+
results = await ctx.vaultMemoryCollection.query(
|
|
13921
|
+
...baseVaultConditions(ctx, { includeArchived: true, includeQuarantined: true }),
|
|
13922
|
+
Q6.where("kind", null)
|
|
13923
|
+
).unsafeFetchRaw();
|
|
13924
|
+
}
|
|
13896
13925
|
return results.map((raw) => ({
|
|
13897
13926
|
uniqueId: raw.id,
|
|
13898
13927
|
factType: raw.fact_type ?? null,
|
package/dist/react/index.cjs
CHANGED
|
@@ -16634,9 +16634,10 @@ async function getVaultRankingProjectionsOp(ctx, options) {
|
|
|
16634
16634
|
}
|
|
16635
16635
|
function baseVaultSql(ctx, options) {
|
|
16636
16636
|
const clauses = [
|
|
16637
|
+
`"_status" is not 'deleted'`,
|
|
16637
16638
|
'"is_deleted" = 0',
|
|
16638
16639
|
...options?.includeArchived ? [] : ['"archived_at" is null'],
|
|
16639
|
-
`"trust_tier" is not 'quarantined'
|
|
16640
|
+
...options?.includeQuarantined ? [] : [`"trust_tier" is not 'quarantined'`],
|
|
16640
16641
|
'"superseded_by" is null'
|
|
16641
16642
|
];
|
|
16642
16643
|
const args = [];
|
|
@@ -17122,8 +17123,17 @@ async function getMemoriesNeedingTopicExtractionOp(ctx, options) {
|
|
|
17122
17123
|
if (!entityCtx) {
|
|
17123
17124
|
throw new Error("getMemoriesNeedingTopicExtractionOp requires ctx.entityCtx");
|
|
17124
17125
|
}
|
|
17125
|
-
|
|
17126
|
-
|
|
17126
|
+
let rows;
|
|
17127
|
+
try {
|
|
17128
|
+
const base = baseVaultSql(ctx);
|
|
17129
|
+
const sql = `select "id", "topics", "topics_user_managed", "topics_extracted_at", "topics_extracted_version", "updated_at" from "memory_vault" where ${base.sql} order by "created_at" desc`;
|
|
17130
|
+
rows = await ctx.vaultMemoryCollection.query(import_watermelondb24.Q.unsafeSqlQuery(sql, base.args)).unsafeFetchRaw();
|
|
17131
|
+
} catch (err) {
|
|
17132
|
+
getLogger().debug(
|
|
17133
|
+
"memoryVault: topic sweep SQL unavailable; use the adapter query: " + (err instanceof Error ? err.message : String(err))
|
|
17134
|
+
);
|
|
17135
|
+
rows = await ctx.vaultMemoryCollection.query(...baseVaultConditions(ctx), import_watermelondb24.Q.sortBy("created_at", import_watermelondb24.Q.desc)).unsafeFetchRaw();
|
|
17136
|
+
}
|
|
17127
17137
|
const linkedNames = await linkedEntityNamesByMemory(
|
|
17128
17138
|
entityCtx,
|
|
17129
17139
|
rows.map((r) => r.id)
|
|
@@ -17182,10 +17192,19 @@ async function getMemoriesNeedingTopicExtractionOp(ctx, options) {
|
|
|
17182
17192
|
}
|
|
17183
17193
|
const orderedPendingRaw = [...stampedPendingRaw, ...pendingRaw];
|
|
17184
17194
|
const limitedPendingRaw = cap !== void 0 ? orderedPendingRaw.slice(0, cap) : orderedPendingRaw;
|
|
17185
|
-
const pending =
|
|
17186
|
-
|
|
17187
|
-
|
|
17188
|
-
|
|
17195
|
+
const pending = [];
|
|
17196
|
+
for (let i = 0; i < limitedPendingRaw.length; i += 500) {
|
|
17197
|
+
const chunk = limitedPendingRaw.slice(i, i + 500);
|
|
17198
|
+
const memories = await getVaultMemoriesByIdsOp(
|
|
17199
|
+
ctx,
|
|
17200
|
+
chunk.map((raw) => raw.id)
|
|
17201
|
+
);
|
|
17202
|
+
const byId = new Map(memories.map((memory) => [memory.uniqueId, memory]));
|
|
17203
|
+
for (const raw of chunk) {
|
|
17204
|
+
const memory = byId.get(raw.id);
|
|
17205
|
+
if (memory) pending.push(memory);
|
|
17206
|
+
}
|
|
17207
|
+
}
|
|
17189
17208
|
const applyCap = (ids) => cap !== void 0 ? ids.slice(0, cap) : ids;
|
|
17190
17209
|
return {
|
|
17191
17210
|
pending,
|
|
@@ -17332,10 +17351,20 @@ function assertVaultScopeForSweep(ctx) {
|
|
|
17332
17351
|
}
|
|
17333
17352
|
async function getDecayCandidatesRawOp(ctx) {
|
|
17334
17353
|
assertVaultScopeForSweep(ctx);
|
|
17335
|
-
|
|
17336
|
-
|
|
17337
|
-
|
|
17338
|
-
|
|
17354
|
+
let results;
|
|
17355
|
+
try {
|
|
17356
|
+
const base = baseVaultSql(ctx, { includeArchived: true, includeQuarantined: true });
|
|
17357
|
+
const sql = `select "id", "fact_type", "event_time_end", "event_time_kind", "updated_at", "last_observed_at", "archived_at", "source", "trust_tier" from "memory_vault" where ${base.sql} and "kind" is null`;
|
|
17358
|
+
results = await ctx.vaultMemoryCollection.query(import_watermelondb24.Q.unsafeSqlQuery(sql, base.args)).unsafeFetchRaw();
|
|
17359
|
+
} catch (err) {
|
|
17360
|
+
getLogger().debug(
|
|
17361
|
+
"memoryVault: decay sweep SQL unavailable; use the adapter query: " + (err instanceof Error ? err.message : String(err))
|
|
17362
|
+
);
|
|
17363
|
+
results = await ctx.vaultMemoryCollection.query(
|
|
17364
|
+
...baseVaultConditions(ctx, { includeArchived: true, includeQuarantined: true }),
|
|
17365
|
+
import_watermelondb24.Q.where("kind", null)
|
|
17366
|
+
).unsafeFetchRaw();
|
|
17367
|
+
}
|
|
17339
17368
|
return results.map((raw) => ({
|
|
17340
17369
|
uniqueId: raw.id,
|
|
17341
17370
|
factType: raw.fact_type ?? null,
|
package/dist/react/index.d.mts
CHANGED
|
@@ -6695,20 +6695,7 @@ interface DecayCandidateRaw {
|
|
|
6695
6695
|
* not egress poison content — see the decay sweeper's `isBorderline`). */
|
|
6696
6696
|
trustTier: string | null;
|
|
6697
6697
|
}
|
|
6698
|
-
/**
|
|
6699
|
-
* Decay sweep candidate scan (PR2). Selects the plaintext columns
|
|
6700
|
-
* `classifyDecay` (in `memory/decay`) needs via
|
|
6701
|
-
* `unsafeFetchRaw` — NO Model per row (dodges the never-evicted RecordCache /
|
|
6702
|
-
* web Pile-2 OOM history) and NO `content` read / decrypt (zero-knowledge).
|
|
6703
|
-
*
|
|
6704
|
-
* Includes archived AND quarantined rows (so archived→delete transitions and
|
|
6705
|
-
* aged quarantined rows are seen) but excludes hard-deleted rows — the
|
|
6706
|
-
* `baseVaultConditions` default keeps `is_deleted = false`. Excludes kinded
|
|
6707
|
-
* (profile) memories, which never decay.
|
|
6708
|
-
*
|
|
6709
|
-
* Refuses to run on an unscoped multi-tenant context (see
|
|
6710
|
-
* {@link assertVaultScopeForSweep}).
|
|
6711
|
-
*/
|
|
6698
|
+
/** Return the projected plaintext fields for the decay sweep within the required vault scope. */
|
|
6712
6699
|
declare function getDecayCandidatesRawOp(ctx: VaultMemoryOperationsContext): Promise<DecayCandidateRaw[]>;
|
|
6713
6700
|
/**
|
|
6714
6701
|
* Archive a memory (decay soft state, PR2) — set `archived_at`. An archived row
|
package/dist/react/index.d.ts
CHANGED
|
@@ -6695,20 +6695,7 @@ interface DecayCandidateRaw {
|
|
|
6695
6695
|
* not egress poison content — see the decay sweeper's `isBorderline`). */
|
|
6696
6696
|
trustTier: string | null;
|
|
6697
6697
|
}
|
|
6698
|
-
/**
|
|
6699
|
-
* Decay sweep candidate scan (PR2). Selects the plaintext columns
|
|
6700
|
-
* `classifyDecay` (in `memory/decay`) needs via
|
|
6701
|
-
* `unsafeFetchRaw` — NO Model per row (dodges the never-evicted RecordCache /
|
|
6702
|
-
* web Pile-2 OOM history) and NO `content` read / decrypt (zero-knowledge).
|
|
6703
|
-
*
|
|
6704
|
-
* Includes archived AND quarantined rows (so archived→delete transitions and
|
|
6705
|
-
* aged quarantined rows are seen) but excludes hard-deleted rows — the
|
|
6706
|
-
* `baseVaultConditions` default keeps `is_deleted = false`. Excludes kinded
|
|
6707
|
-
* (profile) memories, which never decay.
|
|
6708
|
-
*
|
|
6709
|
-
* Refuses to run on an unscoped multi-tenant context (see
|
|
6710
|
-
* {@link assertVaultScopeForSweep}).
|
|
6711
|
-
*/
|
|
6698
|
+
/** Return the projected plaintext fields for the decay sweep within the required vault scope. */
|
|
6712
6699
|
declare function getDecayCandidatesRawOp(ctx: VaultMemoryOperationsContext): Promise<DecayCandidateRaw[]>;
|
|
6713
6700
|
/**
|
|
6714
6701
|
* Archive a memory (decay soft state, PR2) — set `archived_at`. An archived row
|
package/dist/react/index.mjs
CHANGED
|
@@ -14803,9 +14803,10 @@ async function getVaultRankingProjectionsOp(ctx, options) {
|
|
|
14803
14803
|
}
|
|
14804
14804
|
function baseVaultSql(ctx, options) {
|
|
14805
14805
|
const clauses = [
|
|
14806
|
+
`"_status" is not 'deleted'`,
|
|
14806
14807
|
'"is_deleted" = 0',
|
|
14807
14808
|
...options?.includeArchived ? [] : ['"archived_at" is null'],
|
|
14808
|
-
`"trust_tier" is not 'quarantined'
|
|
14809
|
+
...options?.includeQuarantined ? [] : [`"trust_tier" is not 'quarantined'`],
|
|
14809
14810
|
'"superseded_by" is null'
|
|
14810
14811
|
];
|
|
14811
14812
|
const args = [];
|
|
@@ -15291,8 +15292,17 @@ async function getMemoriesNeedingTopicExtractionOp(ctx, options) {
|
|
|
15291
15292
|
if (!entityCtx) {
|
|
15292
15293
|
throw new Error("getMemoriesNeedingTopicExtractionOp requires ctx.entityCtx");
|
|
15293
15294
|
}
|
|
15294
|
-
|
|
15295
|
-
|
|
15295
|
+
let rows;
|
|
15296
|
+
try {
|
|
15297
|
+
const base = baseVaultSql(ctx);
|
|
15298
|
+
const sql = `select "id", "topics", "topics_user_managed", "topics_extracted_at", "topics_extracted_version", "updated_at" from "memory_vault" where ${base.sql} order by "created_at" desc`;
|
|
15299
|
+
rows = await ctx.vaultMemoryCollection.query(Q9.unsafeSqlQuery(sql, base.args)).unsafeFetchRaw();
|
|
15300
|
+
} catch (err) {
|
|
15301
|
+
getLogger().debug(
|
|
15302
|
+
"memoryVault: topic sweep SQL unavailable; use the adapter query: " + (err instanceof Error ? err.message : String(err))
|
|
15303
|
+
);
|
|
15304
|
+
rows = await ctx.vaultMemoryCollection.query(...baseVaultConditions(ctx), Q9.sortBy("created_at", Q9.desc)).unsafeFetchRaw();
|
|
15305
|
+
}
|
|
15296
15306
|
const linkedNames = await linkedEntityNamesByMemory(
|
|
15297
15307
|
entityCtx,
|
|
15298
15308
|
rows.map((r) => r.id)
|
|
@@ -15351,10 +15361,19 @@ async function getMemoriesNeedingTopicExtractionOp(ctx, options) {
|
|
|
15351
15361
|
}
|
|
15352
15362
|
const orderedPendingRaw = [...stampedPendingRaw, ...pendingRaw];
|
|
15353
15363
|
const limitedPendingRaw = cap !== void 0 ? orderedPendingRaw.slice(0, cap) : orderedPendingRaw;
|
|
15354
|
-
const pending =
|
|
15355
|
-
|
|
15356
|
-
|
|
15357
|
-
|
|
15364
|
+
const pending = [];
|
|
15365
|
+
for (let i = 0; i < limitedPendingRaw.length; i += 500) {
|
|
15366
|
+
const chunk = limitedPendingRaw.slice(i, i + 500);
|
|
15367
|
+
const memories = await getVaultMemoriesByIdsOp(
|
|
15368
|
+
ctx,
|
|
15369
|
+
chunk.map((raw) => raw.id)
|
|
15370
|
+
);
|
|
15371
|
+
const byId = new Map(memories.map((memory) => [memory.uniqueId, memory]));
|
|
15372
|
+
for (const raw of chunk) {
|
|
15373
|
+
const memory = byId.get(raw.id);
|
|
15374
|
+
if (memory) pending.push(memory);
|
|
15375
|
+
}
|
|
15376
|
+
}
|
|
15358
15377
|
const applyCap = (ids) => cap !== void 0 ? ids.slice(0, cap) : ids;
|
|
15359
15378
|
return {
|
|
15360
15379
|
pending,
|
|
@@ -15501,10 +15520,20 @@ function assertVaultScopeForSweep(ctx) {
|
|
|
15501
15520
|
}
|
|
15502
15521
|
async function getDecayCandidatesRawOp(ctx) {
|
|
15503
15522
|
assertVaultScopeForSweep(ctx);
|
|
15504
|
-
|
|
15505
|
-
|
|
15506
|
-
|
|
15507
|
-
|
|
15523
|
+
let results;
|
|
15524
|
+
try {
|
|
15525
|
+
const base = baseVaultSql(ctx, { includeArchived: true, includeQuarantined: true });
|
|
15526
|
+
const sql = `select "id", "fact_type", "event_time_end", "event_time_kind", "updated_at", "last_observed_at", "archived_at", "source", "trust_tier" from "memory_vault" where ${base.sql} and "kind" is null`;
|
|
15527
|
+
results = await ctx.vaultMemoryCollection.query(Q9.unsafeSqlQuery(sql, base.args)).unsafeFetchRaw();
|
|
15528
|
+
} catch (err) {
|
|
15529
|
+
getLogger().debug(
|
|
15530
|
+
"memoryVault: decay sweep SQL unavailable; use the adapter query: " + (err instanceof Error ? err.message : String(err))
|
|
15531
|
+
);
|
|
15532
|
+
results = await ctx.vaultMemoryCollection.query(
|
|
15533
|
+
...baseVaultConditions(ctx, { includeArchived: true, includeQuarantined: true }),
|
|
15534
|
+
Q9.where("kind", null)
|
|
15535
|
+
).unsafeFetchRaw();
|
|
15536
|
+
}
|
|
15508
15537
|
return results.map((raw) => ({
|
|
15509
15538
|
uniqueId: raw.id,
|
|
15510
15539
|
factType: raw.fact_type ?? null,
|
package/dist/server/index.cjs
CHANGED
|
@@ -28918,9 +28918,10 @@ async function getVaultRankingProjectionsOp(ctx, options) {
|
|
|
28918
28918
|
}
|
|
28919
28919
|
function baseVaultSql(ctx, options) {
|
|
28920
28920
|
const clauses = [
|
|
28921
|
+
`"_status" is not 'deleted'`,
|
|
28921
28922
|
'"is_deleted" = 0',
|
|
28922
28923
|
...options?.includeArchived ? [] : ['"archived_at" is null'],
|
|
28923
|
-
`"trust_tier" is not 'quarantined'
|
|
28924
|
+
...options?.includeQuarantined ? [] : [`"trust_tier" is not 'quarantined'`],
|
|
28924
28925
|
'"superseded_by" is null'
|
|
28925
28926
|
];
|
|
28926
28927
|
const args = [];
|
|
@@ -29406,8 +29407,17 @@ async function getMemoriesNeedingTopicExtractionOp(ctx, options) {
|
|
|
29406
29407
|
if (!entityCtx) {
|
|
29407
29408
|
throw new Error("getMemoriesNeedingTopicExtractionOp requires ctx.entityCtx");
|
|
29408
29409
|
}
|
|
29409
|
-
|
|
29410
|
-
|
|
29410
|
+
let rows;
|
|
29411
|
+
try {
|
|
29412
|
+
const base = baseVaultSql(ctx);
|
|
29413
|
+
const sql = `select "id", "topics", "topics_user_managed", "topics_extracted_at", "topics_extracted_version", "updated_at" from "memory_vault" where ${base.sql} order by "created_at" desc`;
|
|
29414
|
+
rows = await ctx.vaultMemoryCollection.query(import_watermelondb19.Q.unsafeSqlQuery(sql, base.args)).unsafeFetchRaw();
|
|
29415
|
+
} catch (err) {
|
|
29416
|
+
getLogger().debug(
|
|
29417
|
+
"memoryVault: topic sweep SQL unavailable; use the adapter query: " + (err instanceof Error ? err.message : String(err))
|
|
29418
|
+
);
|
|
29419
|
+
rows = await ctx.vaultMemoryCollection.query(...baseVaultConditions(ctx), import_watermelondb19.Q.sortBy("created_at", import_watermelondb19.Q.desc)).unsafeFetchRaw();
|
|
29420
|
+
}
|
|
29411
29421
|
const linkedNames = await linkedEntityNamesByMemory(
|
|
29412
29422
|
entityCtx,
|
|
29413
29423
|
rows.map((r) => r.id)
|
|
@@ -29466,10 +29476,19 @@ async function getMemoriesNeedingTopicExtractionOp(ctx, options) {
|
|
|
29466
29476
|
}
|
|
29467
29477
|
const orderedPendingRaw = [...stampedPendingRaw, ...pendingRaw];
|
|
29468
29478
|
const limitedPendingRaw = cap !== void 0 ? orderedPendingRaw.slice(0, cap) : orderedPendingRaw;
|
|
29469
|
-
const pending =
|
|
29470
|
-
|
|
29471
|
-
|
|
29472
|
-
|
|
29479
|
+
const pending = [];
|
|
29480
|
+
for (let i = 0; i < limitedPendingRaw.length; i += 500) {
|
|
29481
|
+
const chunk = limitedPendingRaw.slice(i, i + 500);
|
|
29482
|
+
const memories = await getVaultMemoriesByIdsOp(
|
|
29483
|
+
ctx,
|
|
29484
|
+
chunk.map((raw) => raw.id)
|
|
29485
|
+
);
|
|
29486
|
+
const byId = new Map(memories.map((memory) => [memory.uniqueId, memory]));
|
|
29487
|
+
for (const raw of chunk) {
|
|
29488
|
+
const memory = byId.get(raw.id);
|
|
29489
|
+
if (memory) pending.push(memory);
|
|
29490
|
+
}
|
|
29491
|
+
}
|
|
29473
29492
|
const applyCap = (ids) => cap !== void 0 ? ids.slice(0, cap) : ids;
|
|
29474
29493
|
return {
|
|
29475
29494
|
pending,
|
|
@@ -29616,10 +29635,20 @@ function assertVaultScopeForSweep(ctx) {
|
|
|
29616
29635
|
}
|
|
29617
29636
|
async function getDecayCandidatesRawOp(ctx) {
|
|
29618
29637
|
assertVaultScopeForSweep(ctx);
|
|
29619
|
-
|
|
29620
|
-
|
|
29621
|
-
|
|
29622
|
-
|
|
29638
|
+
let results;
|
|
29639
|
+
try {
|
|
29640
|
+
const base = baseVaultSql(ctx, { includeArchived: true, includeQuarantined: true });
|
|
29641
|
+
const sql = `select "id", "fact_type", "event_time_end", "event_time_kind", "updated_at", "last_observed_at", "archived_at", "source", "trust_tier" from "memory_vault" where ${base.sql} and "kind" is null`;
|
|
29642
|
+
results = await ctx.vaultMemoryCollection.query(import_watermelondb19.Q.unsafeSqlQuery(sql, base.args)).unsafeFetchRaw();
|
|
29643
|
+
} catch (err) {
|
|
29644
|
+
getLogger().debug(
|
|
29645
|
+
"memoryVault: decay sweep SQL unavailable; use the adapter query: " + (err instanceof Error ? err.message : String(err))
|
|
29646
|
+
);
|
|
29647
|
+
results = await ctx.vaultMemoryCollection.query(
|
|
29648
|
+
...baseVaultConditions(ctx, { includeArchived: true, includeQuarantined: true }),
|
|
29649
|
+
import_watermelondb19.Q.where("kind", null)
|
|
29650
|
+
).unsafeFetchRaw();
|
|
29651
|
+
}
|
|
29623
29652
|
return results.map((raw) => ({
|
|
29624
29653
|
uniqueId: raw.id,
|
|
29625
29654
|
factType: raw.fact_type ?? null,
|
package/dist/server/index.d.mts
CHANGED
|
@@ -5666,20 +5666,7 @@ interface DecayCandidateRaw {
|
|
|
5666
5666
|
* not egress poison content — see the decay sweeper's `isBorderline`). */
|
|
5667
5667
|
trustTier: string | null;
|
|
5668
5668
|
}
|
|
5669
|
-
/**
|
|
5670
|
-
* Decay sweep candidate scan (PR2). Selects the plaintext columns
|
|
5671
|
-
* `classifyDecay` (in `memory/decay`) needs via
|
|
5672
|
-
* `unsafeFetchRaw` — NO Model per row (dodges the never-evicted RecordCache /
|
|
5673
|
-
* web Pile-2 OOM history) and NO `content` read / decrypt (zero-knowledge).
|
|
5674
|
-
*
|
|
5675
|
-
* Includes archived AND quarantined rows (so archived→delete transitions and
|
|
5676
|
-
* aged quarantined rows are seen) but excludes hard-deleted rows — the
|
|
5677
|
-
* `baseVaultConditions` default keeps `is_deleted = false`. Excludes kinded
|
|
5678
|
-
* (profile) memories, which never decay.
|
|
5679
|
-
*
|
|
5680
|
-
* Refuses to run on an unscoped multi-tenant context (see
|
|
5681
|
-
* {@link assertVaultScopeForSweep}).
|
|
5682
|
-
*/
|
|
5669
|
+
/** Return the projected plaintext fields for the decay sweep within the required vault scope. */
|
|
5683
5670
|
declare function getDecayCandidatesRawOp(ctx: VaultMemoryOperationsContext): Promise<DecayCandidateRaw[]>;
|
|
5684
5671
|
/**
|
|
5685
5672
|
* Archive a memory (decay soft state, PR2) — set `archived_at`. An archived row
|
package/dist/server/index.d.ts
CHANGED
|
@@ -5666,20 +5666,7 @@ interface DecayCandidateRaw {
|
|
|
5666
5666
|
* not egress poison content — see the decay sweeper's `isBorderline`). */
|
|
5667
5667
|
trustTier: string | null;
|
|
5668
5668
|
}
|
|
5669
|
-
/**
|
|
5670
|
-
* Decay sweep candidate scan (PR2). Selects the plaintext columns
|
|
5671
|
-
* `classifyDecay` (in `memory/decay`) needs via
|
|
5672
|
-
* `unsafeFetchRaw` — NO Model per row (dodges the never-evicted RecordCache /
|
|
5673
|
-
* web Pile-2 OOM history) and NO `content` read / decrypt (zero-knowledge).
|
|
5674
|
-
*
|
|
5675
|
-
* Includes archived AND quarantined rows (so archived→delete transitions and
|
|
5676
|
-
* aged quarantined rows are seen) but excludes hard-deleted rows — the
|
|
5677
|
-
* `baseVaultConditions` default keeps `is_deleted = false`. Excludes kinded
|
|
5678
|
-
* (profile) memories, which never decay.
|
|
5679
|
-
*
|
|
5680
|
-
* Refuses to run on an unscoped multi-tenant context (see
|
|
5681
|
-
* {@link assertVaultScopeForSweep}).
|
|
5682
|
-
*/
|
|
5669
|
+
/** Return the projected plaintext fields for the decay sweep within the required vault scope. */
|
|
5683
5670
|
declare function getDecayCandidatesRawOp(ctx: VaultMemoryOperationsContext): Promise<DecayCandidateRaw[]>;
|
|
5684
5671
|
/**
|
|
5685
5672
|
* Archive a memory (decay soft state, PR2) — set `archived_at`. An archived row
|
package/dist/server/index.mjs
CHANGED
|
@@ -27209,9 +27209,10 @@ async function getVaultRankingProjectionsOp(ctx, options) {
|
|
|
27209
27209
|
}
|
|
27210
27210
|
function baseVaultSql(ctx, options) {
|
|
27211
27211
|
const clauses = [
|
|
27212
|
+
`"_status" is not 'deleted'`,
|
|
27212
27213
|
'"is_deleted" = 0',
|
|
27213
27214
|
...options?.includeArchived ? [] : ['"archived_at" is null'],
|
|
27214
|
-
`"trust_tier" is not 'quarantined'
|
|
27215
|
+
...options?.includeQuarantined ? [] : [`"trust_tier" is not 'quarantined'`],
|
|
27215
27216
|
'"superseded_by" is null'
|
|
27216
27217
|
];
|
|
27217
27218
|
const args = [];
|
|
@@ -27697,8 +27698,17 @@ async function getMemoriesNeedingTopicExtractionOp(ctx, options) {
|
|
|
27697
27698
|
if (!entityCtx) {
|
|
27698
27699
|
throw new Error("getMemoriesNeedingTopicExtractionOp requires ctx.entityCtx");
|
|
27699
27700
|
}
|
|
27700
|
-
|
|
27701
|
-
|
|
27701
|
+
let rows;
|
|
27702
|
+
try {
|
|
27703
|
+
const base = baseVaultSql(ctx);
|
|
27704
|
+
const sql = `select "id", "topics", "topics_user_managed", "topics_extracted_at", "topics_extracted_version", "updated_at" from "memory_vault" where ${base.sql} order by "created_at" desc`;
|
|
27705
|
+
rows = await ctx.vaultMemoryCollection.query(import_watermelondb19.Q.unsafeSqlQuery(sql, base.args)).unsafeFetchRaw();
|
|
27706
|
+
} catch (err) {
|
|
27707
|
+
getLogger().debug(
|
|
27708
|
+
"memoryVault: topic sweep SQL unavailable; use the adapter query: " + (err instanceof Error ? err.message : String(err))
|
|
27709
|
+
);
|
|
27710
|
+
rows = await ctx.vaultMemoryCollection.query(...baseVaultConditions(ctx), import_watermelondb19.Q.sortBy("created_at", import_watermelondb19.Q.desc)).unsafeFetchRaw();
|
|
27711
|
+
}
|
|
27702
27712
|
const linkedNames = await linkedEntityNamesByMemory(
|
|
27703
27713
|
entityCtx,
|
|
27704
27714
|
rows.map((r) => r.id)
|
|
@@ -27757,10 +27767,19 @@ async function getMemoriesNeedingTopicExtractionOp(ctx, options) {
|
|
|
27757
27767
|
}
|
|
27758
27768
|
const orderedPendingRaw = [...stampedPendingRaw, ...pendingRaw];
|
|
27759
27769
|
const limitedPendingRaw = cap !== void 0 ? orderedPendingRaw.slice(0, cap) : orderedPendingRaw;
|
|
27760
|
-
const pending =
|
|
27761
|
-
|
|
27762
|
-
|
|
27763
|
-
|
|
27770
|
+
const pending = [];
|
|
27771
|
+
for (let i = 0; i < limitedPendingRaw.length; i += 500) {
|
|
27772
|
+
const chunk = limitedPendingRaw.slice(i, i + 500);
|
|
27773
|
+
const memories = await getVaultMemoriesByIdsOp(
|
|
27774
|
+
ctx,
|
|
27775
|
+
chunk.map((raw) => raw.id)
|
|
27776
|
+
);
|
|
27777
|
+
const byId = new Map(memories.map((memory) => [memory.uniqueId, memory]));
|
|
27778
|
+
for (const raw of chunk) {
|
|
27779
|
+
const memory = byId.get(raw.id);
|
|
27780
|
+
if (memory) pending.push(memory);
|
|
27781
|
+
}
|
|
27782
|
+
}
|
|
27764
27783
|
const applyCap = (ids) => cap !== void 0 ? ids.slice(0, cap) : ids;
|
|
27765
27784
|
return {
|
|
27766
27785
|
pending,
|
|
@@ -27907,10 +27926,20 @@ function assertVaultScopeForSweep(ctx) {
|
|
|
27907
27926
|
}
|
|
27908
27927
|
async function getDecayCandidatesRawOp(ctx) {
|
|
27909
27928
|
assertVaultScopeForSweep(ctx);
|
|
27910
|
-
|
|
27911
|
-
|
|
27912
|
-
|
|
27913
|
-
|
|
27929
|
+
let results;
|
|
27930
|
+
try {
|
|
27931
|
+
const base = baseVaultSql(ctx, { includeArchived: true, includeQuarantined: true });
|
|
27932
|
+
const sql = `select "id", "fact_type", "event_time_end", "event_time_kind", "updated_at", "last_observed_at", "archived_at", "source", "trust_tier" from "memory_vault" where ${base.sql} and "kind" is null`;
|
|
27933
|
+
results = await ctx.vaultMemoryCollection.query(import_watermelondb19.Q.unsafeSqlQuery(sql, base.args)).unsafeFetchRaw();
|
|
27934
|
+
} catch (err) {
|
|
27935
|
+
getLogger().debug(
|
|
27936
|
+
"memoryVault: decay sweep SQL unavailable; use the adapter query: " + (err instanceof Error ? err.message : String(err))
|
|
27937
|
+
);
|
|
27938
|
+
results = await ctx.vaultMemoryCollection.query(
|
|
27939
|
+
...baseVaultConditions(ctx, { includeArchived: true, includeQuarantined: true }),
|
|
27940
|
+
import_watermelondb19.Q.where("kind", null)
|
|
27941
|
+
).unsafeFetchRaw();
|
|
27942
|
+
}
|
|
27914
27943
|
return results.map((raw) => ({
|
|
27915
27944
|
uniqueId: raw.id,
|
|
27916
27945
|
factType: raw.fact_type ?? null,
|