@mnmal-ai/substrate 1.0.0-alpha.11 → 1.0.0-alpha.13

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.
Files changed (38) hide show
  1. package/README.md +12 -5
  2. package/dist/{boot-store-C5vNZJ3i.js → boot-store-0BPtJ8ne.js} +167 -71
  3. package/dist/{bridge-COu0Tg_h.d.ts → bridge-DQyQ6Qhn.d.ts} +1 -1
  4. package/dist/{cli-BrwW4tjO.js → cli-BvQqNFVn.js} +14 -11
  5. package/dist/client.d.ts +3 -3
  6. package/dist/client.js +3 -3
  7. package/dist/{errors-BOllGhVx.d.ts → errors-xP9Mo7Q1.d.ts} +25 -4
  8. package/dist/{index-Cp74OcmS.d.ts → index-baF5A5jU.d.ts} +1 -1
  9. package/dist/pack.d.ts +2 -2
  10. package/dist/pack.js +1 -1
  11. package/dist/{pg-edges-store-BLsbcXkk.js → pg-edges-store-B4FSN9yp.js} +72 -9
  12. package/dist/{plugin-DIYm2cZE.js → plugin-BLm5IRdX.js} +2 -2
  13. package/dist/proposals-bootstrap.js +2 -2
  14. package/dist/proposals.d.ts +2 -2
  15. package/dist/proposals.js +1 -1
  16. package/dist/recall-bootstrap.js +2 -2
  17. package/dist/recall.d.ts +10 -10
  18. package/dist/recall.js +2 -2
  19. package/dist/{repl-B8gy0YM7.js → repl-Dw2Fb7C1.js} +25 -25
  20. package/dist/{row-DwaDU4b-.d.ts → row-Dtj3KrPH.d.ts} +9 -2
  21. package/dist/{run-B18qtGKc.js → run-CgDw2c3X.js} +520 -141
  22. package/dist/{schema-CijHRfuk.d.ts → schema-oXfQyo0s.d.ts} +272 -27
  23. package/dist/sdk.d.ts +93 -29
  24. package/dist/sdk.js +4 -4
  25. package/dist/{src-D041j6GS.js → src-Bew_JvTo.js} +32 -16
  26. package/dist/{src-DpPdw2oL.js → src-Bi3NhEsT.js} +1 -1
  27. package/dist/{src-DptNGNYQ.js → src-BjWVYYoo.js} +175 -91
  28. package/dist/{src-DK7VEQT6.js → src-C4t1Gy-m.js} +2477 -830
  29. package/dist/{src-Br6aDUti.js → src-CHND7-Pm.js} +2 -2
  30. package/dist/src-CSe2tJDf.js +6940 -0
  31. package/dist/{src-Dbvuel6w.js → src-DWqzrm3O.js} +18 -1
  32. package/dist/substrate-admin.js +1 -1
  33. package/dist/substrate.js +1 -1
  34. package/dist/testing.d.ts +233 -92
  35. package/dist/testing.js +6 -23
  36. package/dist/{ws-DC8OhMaV.d.ts → ws-Dx3A2B4U.d.ts} +2 -2
  37. package/package.json +19 -20
  38. package/dist/src-gz4I1F29.js +0 -5097
@@ -1,13 +1,13 @@
1
1
  import { createRequire as __binCreateRequire } from 'node:module'; const require = __binCreateRequire(import.meta.url);
2
- import { Ut as validateHardDeleteEnv, X as runSweep, Y as loadSweepState, Z as saveSweepState, g as INVITE_TYPE, h as AUDIT_EVENT_TYPE, m as buildAuditRow, p as runInviteSweep, u as isStoreProfileName } from "./src-DK7VEQT6.js";
2
+ import { Qt as validateHardDeleteEnv, _ as AUDIT_EVENT_TYPE, et as loadSweepState, g as buildAuditRow, m as runInviteSweep, nt as saveSweepState, tt as runSweep, u as isStoreProfileName, v as INVITE_TYPE } from "./src-C4t1Gy-m.js";
3
3
  import { n as trimTrailingSlashes, s as makeAuthorizationProvider } from "./env-utils-CGNazUNt.js";
4
- import { L as encodeList, T as SYSTEM_NAMESPACE, f as coversNamespace, m as grantedIn, p as grantOf } from "./src-DpPdw2oL.js";
5
- import "./src-Dbvuel6w.js";
6
- import { a as parseBridgeCreds, d as reportUnguardedIndexBuilds, f as runDeferredIndexBuilds, g as openPgDataset, h as version, i as MS_PER_DAY, n as resolvePluginDir, o as parseBridges, p as startSentinelClient, q as AdminCliError, s as parseEnv, t as bootStore, u as redactStoreSpec } from "./boot-store-C5vNZJ3i.js";
7
- import { a as SubstrateClient, d as NetworkError, i as tokenAudience, n as resolveAgentCapabilities, p as AdminBackfillError, r as noRedirectFetch, t as createClientFromEnv, u as AuthError } from "./src-Br6aDUti.js";
4
+ import { L as encodeList, T as SYSTEM_NAMESPACE, f as coversNamespace, m as grantedIn, p as grantOf } from "./src-Bi3NhEsT.js";
5
+ import "./src-DWqzrm3O.js";
6
+ import { Y as AdminCliError, _ as openPgDataset, a as parseBridgeCreds, f as reportUnguardedIndexBuilds, g as version, i as MS_PER_DAY, m as startSentinelClient, n as resolvePluginDir, o as parseBridges, p as runDeferredIndexBuilds, s as parseEnv, t as bootStore, u as redactStoreSpec } from "./boot-store-0BPtJ8ne.js";
7
+ import { a as SubstrateClient, d as NetworkError, i as tokenAudience, n as resolveAgentCapabilities, p as AdminBackfillError, r as noRedirectFetch, t as createClientFromEnv, u as AuthError } from "./src-CHND7-Pm.js";
8
8
  import { n as runScript, t as DEFAULT_MAX_WRITES } from "./script-C6DSa_Na.js";
9
- import { _ as tryWithPgAdvisoryLock } from "./src-gz4I1F29.js";
10
- import { n as PgLexicalStore, r as PgEmbeddingsStore } from "./src-DptNGNYQ.js";
9
+ import { w as tryWithPgAdvisoryLock } from "./src-CSe2tJDf.js";
10
+ import { n as PgLexicalStore, r as PgEmbeddingsStore } from "./src-BjWVYYoo.js";
11
11
  import { chmodSync, existsSync, mkdirSync, readFileSync, readdirSync, writeFileSync } from "node:fs";
12
12
  import { homedir, hostname } from "node:os";
13
13
  import { basename, dirname, join, resolve } from "node:path";
@@ -848,6 +848,8 @@ function installShutdown(args) {
848
848
  * SUBSTRATE_BODY_LIMIT_BYTES max request body size in bytes (optional). Unset =
849
849
  * Fastify's 1 MiB default. Raise for bulk batched
850
850
  * mutation frames that exceed 1 MiB.
851
+ * SUBSTRATE_STATEMENT_TIMEOUT_MS statement timeout for walk reads in ms (default 30000);
852
+ * a cancelled read is refused `query_timeout`
851
853
  * SUBSTRATE_SWEEP_INTERVAL_MS sweep cadence in ms (default 300000)
852
854
  * SUBSTRATE_INVITE_SWEEP_INTERVAL_MS invite reaper cadence in ms (default 3600000 = 1h)
853
855
  * SUBSTRATE_TOMBSTONE_RETENTION_DAYS retention window for tombstoned rows /
@@ -2157,7 +2159,7 @@ async function runInit(argv) {
2157
2159
  return 1;
2158
2160
  }
2159
2161
  if (!config.yes) try {
2160
- const { runRepl } = await import("./repl-B8gy0YM7.js");
2162
+ const { runRepl } = await import("./repl-Dw2Fb7C1.js");
2161
2163
  config = await runRepl(config);
2162
2164
  } catch (err) {
2163
2165
  if (err.message?.includes("User force closed")) return 130;
@@ -2832,19 +2834,20 @@ function createMcpServer(endpoint, options = {}) {
2832
2834
  name: "mutate",
2833
2835
  config: {
2834
2836
  description: "Run one or more mutations. payload is a single frame object mapping qualified keys (<ns>/<mutationName>) to { params, fields } (single-frame) or to an array of frames (batched atomic). ONE op-key can accept a single frame or an array. An ARRAY op-key is its own transaction: it commits or rolls back as a unit, independently of every other op-key in the call. The SINGLE-FRAME op-keys share one transaction when they sit on one tx scope (every namespace on one pg handle); across two tx scopes they are refused rather than split. So a single-frame op-key beside an array is NOT rolled back when the array fails — to make writes atomic together, put them in one array under one op-key. The memory dataset mints a fresh tx scope per namespace, so single-frame op-keys in two namespaces are refused there.",
2835
- inputSchema: { payload: payloadSchema("Mutation frame. Single: { \"default/createTodo\": { \"params\": { \"title\": \"...\" }, \"fields\": { \"id\": true } } }. Batched atomic: { \"default/updateTodo\": [ { \"params\": { \"id\": \"1\", \"done\": true }, \"fields\": { \"id\": true } }, { \"params\": { \"id\": \"2\", \"done\": true }, \"fields\": { \"id\": true } } ] }.") }
2837
+ inputSchema: { payload: payloadSchema("Mutation frame. Single: { \"default/createTodo\": { \"params\": { \"title\": \"...\" }, \"fields\": { \"id\": true } } }. Batched atomic: { \"default/updateTodo\": [ { \"params\": { \"id\": \"1\", \"done\": true }, \"fields\": { \"id\": true } }, { \"params\": { \"id\": \"2\", \"done\": true }, \"fields\": { \"id\": true } } ] }. By filter: { \"default/updateManyTodo\": { \"params\": { \"where\": { \"done\": { \"eq\": false } }, \"set\": { \"done\": true } }, \"fields\": { \"count\": true, \"ids\": true, \"idsTruncated\": true } } }; deleteMany<Type> takes only \"where\".") }
2836
2838
  },
2837
2839
  handler: createMutateHandler(endpoint)
2838
2840
  },
2839
2841
  {
2840
2842
  name: "ask",
2841
2843
  config: {
2842
- description: "Ask a natural-language question of one namespace. The parser answers first; a constrained judge handles what it escalates; a judge outage hands off honestly. Returns { outcome, trail }, where outcome.kind is rows | recall | clarify | refuse | unknown. unknown means part of the question was dropped and the answer would change which rows count; it carries dropped and the plan, and nothing ran. rows also carries dropped (what it does not reflect) and plan. Read-only. Requires the @mnmal-ai/substrate-nl plugin (404 otherwise).",
2844
+ description: "Ask a natural-language question of one namespace. The parser answers first; a constrained judge handles what it escalates; a judge outage hands off honestly. Returns { outcome, trail }, where outcome.kind is rows | recall | clarify | refuse | unknown. unknown means part of the question was dropped and the answer would change which rows count; it carries dropped and the plan, and nothing ran. rows also carries dropped (what it does not reflect) and plan. Relative dates are read against asOf when given, else the server clock; the parsed trail event says which. Read-only. Requires the @mnmal-ai/substrate-nl plugin (404 otherwise).",
2843
2845
  inputSchema: {
2844
2846
  namespace: z.string().min(1).describe("Namespace to ask, e.g. \"notes\"."),
2845
2847
  question: z.string().min(1).describe("The question, e.g. \"open todos in billing\"."),
2846
2848
  project: z.string().min(1).optional().describe("Asking project; scopes project-bearing types."),
2847
- type: z.string().min(1).optional().describe("force the reading to this type (resubmit a clarify option)")
2849
+ type: z.string().min(1).optional().describe("force the reading to this type (resubmit a clarify option)"),
2850
+ asOf: z.string().min(1).optional().describe("\"now\" for relative dates (\"yesterday\", \"last week\") and month-day year inference: ISO-8601 date-time with an offset, e.g. 2026-10-02T12:00:00-05:00. Default: the server clock.")
2848
2851
  }
2849
2852
  },
2850
2853
  handler: createNlHandler(endpoint)
package/dist/client.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { B as QualifiedFrame, Cn as Row, an as RuntimeErrors, f as PackEnvelope, in as RuntimeErrorEntry, m as Schema, on as RuntimeMetrics, rn as ResolverStat, sn as SlowRequest, tn as ProcessStat } from "./schema-CijHRfuk.js";
2
- import { A as and, B as SYSTEM_NAMESPACE, C as flattenGrant, D as parseGrantEntries, E as intersectGrants, F as TokenProviderOpts, G as resolveAdminCredential, H as isActiveAdminKeyRow, I as adminClaimCapabilities, J as NlAskRequest, K as resolveDefaultKeyPath, L as isEncryptedKey, M as or, N as ADMIN_CAPABILITIES, O as decodeList, P as DEFAULT_CAPABILITIES, R as makeAuthorizationProvider, S as expandFlat, T as grantIsUniform, U as AdminCredential, V as describeGrant, W as AdminEnv, Y as NlAskResult, _ as newlyGrantedPairs, a as denyAll, b as capabilitiesFor, c as requireIdentity, d as KeyUpdateRefusal, dt as NlTrailEvent, f as checkRevocable, g as newlyGranted, h as grantEntriesConfer, i as allowVerbs, it as NlOutcome, j as not, k as encodeList, l as requireNamespace, m as grantCovers, n as row, o as denyVerbs, p as checkUpdatable, pt as NlWireEvent, q as resolveDefaultKidPath, r as allowAll, s as requireCapability, t as applyRowFilters, u as KeyMutationRefusal, ut as NlServedPack, v as revokedAtIso, w as grantEntryError, x as encodeGrant, y as Grant, z as makeTokenProvider } from "./row-DwaDU4b-.js";
3
- import { s as SchemaDriftError } from "./index-Cp74OcmS.js";
1
+ import { Mn as Row, W as QualifiedFrame, f as PackEnvelope, fn as ResolverStat, gn as SlowRequest, hn as RuntimeMetrics, m as Schema, mn as RuntimeErrors, pn as RuntimeErrorEntry, un as ProcessStat } from "./schema-oXfQyo0s.js";
2
+ import { A as and, B as SYSTEM_NAMESPACE, C as flattenGrant, D as parseGrantEntries, E as intersectGrants, F as TokenProviderOpts, G as resolveAdminCredential, H as isActiveAdminKeyRow, I as adminClaimCapabilities, J as NlAskRequest, K as resolveDefaultKeyPath, L as isEncryptedKey, M as or, N as ADMIN_CAPABILITIES, O as decodeList, P as DEFAULT_CAPABILITIES, R as makeAuthorizationProvider, S as expandFlat, T as grantIsUniform, U as AdminCredential, V as describeGrant, W as AdminEnv, Y as NlAskResult, _ as newlyGrantedPairs, a as denyAll, b as capabilitiesFor, c as requireIdentity, d as KeyUpdateRefusal, dt as NlTrailEvent, f as checkRevocable, g as newlyGranted, h as grantEntriesConfer, i as allowVerbs, it as NlOutcome, j as not, k as encodeList, l as requireNamespace, m as grantCovers, n as row, o as denyVerbs, p as checkUpdatable, pt as NlWireEvent, q as resolveDefaultKidPath, r as allowAll, s as requireCapability, t as applyRowFilters, u as KeyMutationRefusal, ut as NlServedPack, v as revokedAtIso, w as grantEntryError, x as encodeGrant, y as Grant, z as makeTokenProvider } from "./row-Dtj3KrPH.js";
3
+ import { s as SchemaDriftError } from "./index-baF5A5jU.js";
4
4
  import { Signal } from "@preact/signals-core";
5
5
  //#region ../../packages/substrate-client/src/admin/surgery.d.ts
6
6
  type AdminDropCascade = 'refuse' | 'delete';
package/dist/client.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import { createRequire as __binCreateRequire } from 'node:module'; const require = __binCreateRequire(import.meta.url);
2
2
  import { a as adminClaimCapabilities, c as makeTokenProvider, d as resolveDefaultKidPath, i as DEFAULT_CAPABILITIES, l as resolveAdminCredential, o as isEncryptedKey, r as ADMIN_CAPABILITIES, s as makeAuthorizationProvider, u as resolveDefaultKeyPath } from "./env-utils-CGNazUNt.js";
3
- import { A as expandFlat, C as not, D as isActiveAdminKeyRow, E as describeGrant, F as parseGrantEntries, I as decodeList, L as encodeList, M as grantEntryError, N as grantIsUniform, O as capabilitiesFor, P as intersectGrants, S as and, T as SYSTEM_NAMESPACE, _ as grantCovers, a as denyAll, b as newlyGrantedPairs, c as requireIdentity, g as checkUpdatable, h as checkRevocable, i as allowVerbs, j as flattenGrant, k as encodeGrant, l as requireNamespace, n as row, o as denyVerbs, r as allowAll, s as requireCapability, t as applyRowFilters, v as grantEntriesConfer, w as or, x as revokedAtIso, y as newlyGranted } from "./src-DpPdw2oL.js";
4
- import { f as SchemaDriftError } from "./src-Dbvuel6w.js";
5
- import { C as diagnose, S as DIAGNOSE_CHECKS, _ as SKIPPABLE_STEPS, a as SubstrateClient, b as planOnboarding, c as reduceSubscribeRows, d as NetworkError, f as SubscribeError, g as ONBOARD_STEPS, h as CURRENT_MARK, i as tokenAudience, l as watchRows, m as BACKFILL_CHUNK, n as resolveAgentCapabilities, o as collectDiagnostics, p as AdminBackfillError, r as noRedirectFetch, s as createDefaultDiagnosticsSink, t as createClientFromEnv, u as AuthError, v as STEP_MARKS, w as reconcileIdentities, x as requiredOutstanding, y as currentStep } from "./src-Br6aDUti.js";
3
+ import { A as expandFlat, C as not, D as isActiveAdminKeyRow, E as describeGrant, F as parseGrantEntries, I as decodeList, L as encodeList, M as grantEntryError, N as grantIsUniform, O as capabilitiesFor, P as intersectGrants, S as and, T as SYSTEM_NAMESPACE, _ as grantCovers, a as denyAll, b as newlyGrantedPairs, c as requireIdentity, g as checkUpdatable, h as checkRevocable, i as allowVerbs, j as flattenGrant, k as encodeGrant, l as requireNamespace, n as row, o as denyVerbs, r as allowAll, s as requireCapability, t as applyRowFilters, v as grantEntriesConfer, w as or, x as revokedAtIso, y as newlyGranted } from "./src-Bi3NhEsT.js";
4
+ import { f as SchemaDriftError } from "./src-DWqzrm3O.js";
5
+ import { C as diagnose, S as DIAGNOSE_CHECKS, _ as SKIPPABLE_STEPS, a as SubstrateClient, b as planOnboarding, c as reduceSubscribeRows, d as NetworkError, f as SubscribeError, g as ONBOARD_STEPS, h as CURRENT_MARK, i as tokenAudience, l as watchRows, m as BACKFILL_CHUNK, n as resolveAgentCapabilities, o as collectDiagnostics, p as AdminBackfillError, r as noRedirectFetch, s as createDefaultDiagnosticsSink, t as createClientFromEnv, u as AuthError, v as STEP_MARKS, w as reconcileIdentities, x as requiredOutstanding, y as currentStep } from "./src-CHND7-Pm.js";
6
6
  import { n as runScript, t as DEFAULT_MAX_WRITES } from "./script-C6DSa_Na.js";
7
7
 
8
8
  export { ADMIN_CAPABILITIES, AdminBackfillError, AuthError, BACKFILL_CHUNK, CURRENT_MARK, DEFAULT_CAPABILITIES, DEFAULT_MAX_WRITES, DIAGNOSE_CHECKS, NetworkError, ONBOARD_STEPS, SKIPPABLE_STEPS, STEP_MARKS, SYSTEM_NAMESPACE, SchemaDriftError, SubscribeError, SubstrateClient, adminClaimCapabilities, allowAll, allowVerbs, and, applyRowFilters, capabilitiesFor, checkRevocable, checkUpdatable, collectDiagnostics, createClientFromEnv, createDefaultDiagnosticsSink, currentStep, decodeList, denyAll, denyVerbs, describeGrant, diagnose, encodeGrant, encodeList, expandFlat, flattenGrant, grantCovers, grantEntriesConfer, grantEntryError, grantIsUniform, intersectGrants, isActiveAdminKeyRow, isEncryptedKey, makeAuthorizationProvider, makeTokenProvider, newlyGranted, newlyGrantedPairs, noRedirectFetch, not, or, parseGrantEntries, planOnboarding, reconcileIdentities, reduceSubscribeRows, requireCapability, requireIdentity, requireNamespace, requiredOutstanding, resolveAdminCredential, resolveAgentCapabilities, resolveDefaultKeyPath, resolveDefaultKidPath, revokedAtIso, row, runScript, tokenAudience, watchRows };
@@ -1,5 +1,7 @@
1
- import { fn as EdgeRef, un as Edge } from "./schema-CijHRfuk.js";
1
+ import { xn as EdgeRef, yn as Edge } from "./schema-oXfQyo0s.js";
2
2
  //#region ../../packages/substrate-types/src/errors.d.ts
3
+ /** A by-filter write matched more rows than `SUBSTRATE_FILTER_WRITE_MAX_MATCH`; nothing changed. */
4
+ declare const FILTER_TOO_BROAD = "filter_too_broad";
3
5
  /** Refusal codes for the typed-edge-walk grammar. */
4
6
  declare const WALKS_NEED_PARTITIONED = "walks_need_partitioned";
5
7
  declare const WALKS_IN_SUBSCRIPTION = "walks_in_subscription";
@@ -7,6 +9,8 @@ declare const WALKS_IN_MUTATION = "walks_in_mutation";
7
9
  declare const ROW_POLICY_BLOCKS_WALK = "row_policy_blocks_walk";
8
10
  declare const WALK_BUDGET_EXCEEDED = "walk_budget_exceeded";
9
11
  declare const WALKS_UNSUPPORTED_STORE = "walks_unsupported_store";
12
+ /** A read cancelled by the store's statement timeout; `details: { timeoutMs }`. */
13
+ declare const QUERY_TIMEOUT = "query_timeout";
10
14
  /**
11
15
  * A walk construct refused where it cannot be answered: inside a struct, over
12
16
  * a list or struct-nested crossRef, under a reused field name, on a virtual
@@ -42,6 +46,8 @@ declare class ResolverFrameError extends Error {
42
46
  readonly details?: Record<string, unknown>;
43
47
  constructor(code: string, message: string, details?: Record<string, unknown>);
44
48
  }
49
+ /** `filter_too_broad`: a by-filter write on `<namespace>/<type>` matched more than `maxMatch` rows. */
50
+ declare function filterTooBroad(namespace: string, type: string, maxMatch: number): ResolverFrameError;
45
51
  /**
46
52
  * Thrown by a write-path resolver when a crossRef declaring `onMissing: 'reject'`
47
53
  * references a target that does not exist (or has been tombstoned). Extends
@@ -91,11 +97,12 @@ declare class NamespaceMismatch extends Error {
91
97
  }
92
98
  /**
93
99
  * Thrown by `Dataset.updateField` when the caller targets a reserved
94
- * field name (e.g. `_deletedAt`). Spec §4.5.
100
+ * field name (e.g. `_deletedAt`), and by any other write path that refuses
101
+ * one; `how` names that path in the message. Spec §4.5.
95
102
  */
96
103
  declare class ReservedField extends Error {
97
104
  readonly name = "ReservedField";
98
- constructor(field: string);
105
+ constructor(field: string, how?: string);
99
106
  }
100
107
  /**
101
108
  * The `(auth)` tag `HttpBridgeClient` appends to a 401/403 cause. Single
@@ -118,6 +125,20 @@ declare class BridgeUnreachableError extends Error {
118
125
  readonly cause: unknown;
119
126
  constructor(bridgeName: string, baseUrl: string, cause: unknown);
120
127
  }
128
+ /**
129
+ * Thrown by a `BatchResolver` to refuse element `index` of its args list. The
130
+ * engine rolls back the whole array and reports `cause` as the per-element
131
+ * resolver would have: a `ResolverFrameError` or `RestrictViolation` keeps
132
+ * its code at `[key]`, and `batched_frame_rolled_back` names the element.
133
+ */
134
+ declare class BatchElementError extends Error {
135
+ readonly index: number;
136
+ readonly cause: unknown;
137
+ readonly name = "BatchElementError";
138
+ constructor(index: number, cause: unknown);
139
+ }
140
+ /** Recognise a {@link BatchElementError} across module-realm boundaries. */
141
+ declare function isBatchElementError(err: unknown): err is BatchElementError;
121
142
  /**
122
143
  * Recognise a {@link ResolverFrameError} across module-realm boundaries.
123
144
  *
@@ -140,4 +161,4 @@ declare function isResolverFrameError(err: unknown): err is ResolverFrameError;
140
161
  */
141
162
  declare function isRestrictViolation(err: unknown): err is RestrictViolation;
142
163
  //#endregion
143
- export { isRestrictViolation as _, ReservedField as a, UnsupportedFilterError as c, WALKS_NEED_PARTITIONED as d, WALKS_UNSUPPORTED_STORE as f, isResolverFrameError as g, isAuthCause as h, ROW_POLICY_BLOCKS_WALK as i, WALKS_IN_MUTATION as l, WALK_UNSUPPORTED_REF as m, MissingReferentError as n, ResolverFrameError as o, WALK_BUDGET_EXCEEDED as p, NamespaceMismatch as r, RestrictViolation as s, BridgeUnreachableError as t, WALKS_IN_SUBSCRIPTION as u };
164
+ export { isRestrictViolation as S, WALK_UNSUPPORTED_REF as _, NamespaceMismatch as a, isBatchElementError as b, ReservedField as c, UnsupportedFilterError as d, WALKS_IN_MUTATION as f, WALK_BUDGET_EXCEEDED as g, WALKS_UNSUPPORTED_STORE as h, MissingReferentError as i, ResolverFrameError as l, WALKS_NEED_PARTITIONED as m, BridgeUnreachableError as n, QUERY_TIMEOUT as o, WALKS_IN_SUBSCRIPTION as p, FILTER_TOO_BROAD as r, ROW_POLICY_BLOCKS_WALK as s, BatchElementError as t, RestrictViolation as u, filterTooBroad as v, isResolverFrameError as x, isAuthCause as y };
@@ -1,4 +1,4 @@
1
- import { f as PackEnvelope, i as FieldDef, l as FieldInput, m as Schema } from "./schema-CijHRfuk.js";
1
+ import { f as PackEnvelope, i as FieldDef, l as FieldInput, m as Schema } from "./schema-oXfQyo0s.js";
2
2
  import { pack as packFrame, unpack as unpackFrame } from "msgpackr";
3
3
  //#region ../../packages/substrate-pack/src/decoder.d.ts
4
4
  interface DecodeContext {
package/dist/pack.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { f as PackEnvelope, i as FieldDef, l as FieldInput, m as Schema } from "./schema-CijHRfuk.js";
2
- import { a as DecodeEnvelopeCtx, c as decodeEnvelope, i as DecodeContext, l as decodePositional, n as packFrame, o as PackDecodeError, r as unpackFrame, s as SchemaDriftError, t as WS_SUBPROTOCOL_SUBSTRATE_PACK, u as decodePositionalFromFieldDef } from "./index-Cp74OcmS.js";
1
+ import { f as PackEnvelope, i as FieldDef, l as FieldInput, m as Schema } from "./schema-oXfQyo0s.js";
2
+ import { a as DecodeEnvelopeCtx, c as decodeEnvelope, i as DecodeContext, l as decodePositional, n as packFrame, o as PackDecodeError, r as unpackFrame, s as SchemaDriftError, t as WS_SUBPROTOCOL_SUBSTRATE_PACK, u as decodePositionalFromFieldDef } from "./index-baF5A5jU.js";
3
3
  //#region ../../packages/substrate-pack/src/content-type.d.ts
4
4
  /**
5
5
  * Content-type negotiation. Spec: §7.0.
package/dist/pack.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { createRequire as __binCreateRequire } from 'node:module'; const require = __binCreateRequire(import.meta.url);
2
- import { _ as encodeEnvelope, a as buildDecodePlan, c as isPlainRequestData, d as PackDecodeError, f as SchemaDriftError, g as PackEncodeError, h as decodePositionalFromFieldDef, i as applyDecodePlanInPlace, l as decodeStreamChunk, m as decodePositional, n as packFrame, o as decodeWsEnvelope, p as decodeEnvelope, r as unpackFrame, s as encodeWsFrame, t as WS_SUBPROTOCOL_SUBSTRATE_PACK, u as encodeStreamChunk, v as encodePositional, y as encodePositionalFromFieldDef } from "./src-Dbvuel6w.js";
2
+ import { _ as encodeEnvelope, a as buildDecodePlan, c as isPlainRequestData, d as PackDecodeError, f as SchemaDriftError, g as PackEncodeError, h as decodePositionalFromFieldDef, i as applyDecodePlanInPlace, l as decodeStreamChunk, m as decodePositional, n as packFrame, o as decodeWsEnvelope, p as decodeEnvelope, r as unpackFrame, s as encodeWsFrame, t as WS_SUBPROTOCOL_SUBSTRATE_PACK, u as encodeStreamChunk, v as encodePositional, y as encodePositionalFromFieldDef } from "./src-DWqzrm3O.js";
3
3
  import { n as acceptsPack, t as PACK_MIME } from "./content-type-C7T28xNb.js";
4
4
 
5
5
  export { PACK_MIME, PackDecodeError, PackEncodeError, SchemaDriftError, WS_SUBPROTOCOL_SUBSTRATE_PACK, acceptsPack, applyDecodePlanInPlace, buildDecodePlan, decodeEnvelope, decodePositional, decodePositionalFromFieldDef, decodeStreamChunk, decodeWsEnvelope, encodeEnvelope, encodePositional, encodePositionalFromFieldDef, encodeStreamChunk, encodeWsFrame, isPlainRequestData, packFrame, unpackFrame };
@@ -1,5 +1,5 @@
1
1
  import { createRequire as __binCreateRequire } from 'node:module'; const require = __binCreateRequire(import.meta.url);
2
- import { n as txScopeIdFor } from "./src-gz4I1F29.js";
2
+ import { n as txScopeIdFor } from "./src-CSe2tJDf.js";
3
3
  import { randomUUID } from "node:crypto";
4
4
 
5
5
  //#region ../../packages/substrate-dataset-pg/src/pg-edges-store.ts
@@ -85,6 +85,54 @@ var PgEdgesStore = class PgEdgesStore {
85
85
  createdAt
86
86
  };
87
87
  }
88
+ async writeMany(inputs) {
89
+ if (inputs.length === 0) return [];
90
+ const edges = inputs.map((input) => {
91
+ return {
92
+ id: randomUUID(),
93
+ from: buildRef(input.from.ns, input.from.type, refToId(input.from.id), input.from.bridged === true),
94
+ to: buildRef(input.to.ns, input.to.type, refToId(input.to.id), input.to.bridged === true),
95
+ fieldName: input.fieldName,
96
+ policy: input.policy,
97
+ createdAt: this.#now()
98
+ };
99
+ });
100
+ await this.#sql`
101
+ INSERT INTO edges (
102
+ id, from_ns, from_type, from_id, from_bridged,
103
+ to_ns, to_type, to_id, to_bridged,
104
+ field_name, policy, created_at, deleted_at, last_swept_at, blocked
105
+ )
106
+ SELECT t.id, t.from_ns, t.from_type, t.from_id, t.from_bridged::boolean,
107
+ t.to_ns, t.to_type, t.to_id, t.to_bridged::boolean,
108
+ t.field_name, t.policy, t.created_at::timestamptz, NULL, NULL, false
109
+ FROM unnest(
110
+ ${edges.map((e) => e.id)}::uuid[],
111
+ ${edges.map((e) => e.from.ns)}::text[],
112
+ ${edges.map((e) => e.from.type)}::text[],
113
+ ${edges.map((e) => String(e.from.id))}::text[],
114
+ ${edges.map((e) => String(e.from.bridged === true))}::text[],
115
+ ${edges.map((e) => e.to.ns)}::text[],
116
+ ${edges.map((e) => e.to.type)}::text[],
117
+ ${edges.map((e) => String(e.to.id))}::text[],
118
+ ${edges.map((e) => String(e.to.bridged === true))}::text[],
119
+ ${edges.map((e) => e.fieldName)}::text[],
120
+ ${edges.map((e) => e.policy)}::text[],
121
+ ${edges.map((e) => e.createdAt.toISOString())}::text[]
122
+ ) AS t(id, from_ns, from_type, from_id, from_bridged,
123
+ to_ns, to_type, to_id, to_bridged, field_name, policy, created_at)
124
+ `;
125
+ return edges;
126
+ }
127
+ async tombstoneMany(ids, at) {
128
+ if (ids.length === 0) return;
129
+ await this.#sql`
130
+ UPDATE edges
131
+ SET deleted_at = ${at ?? this.#now()}
132
+ WHERE id = ANY(${ids}::uuid[])
133
+ AND deleted_at IS NULL
134
+ `;
135
+ }
88
136
  async tombstone(id, at) {
89
137
  const stamp = at ?? this.#now();
90
138
  await this.#sql`
@@ -164,27 +212,42 @@ var PgEdgesStore = class PgEdgesStore {
164
212
  `).map(rowToEdge);
165
213
  }
166
214
  async findEdgesToMany(refs) {
215
+ return this.#findMany("to", refs);
216
+ }
217
+ async findEdgesFromMany(refs) {
218
+ return this.#findMany("from", refs);
219
+ }
220
+ async #findMany(side, refs) {
167
221
  if (refs.length === 0) return [];
168
222
  const sql = this.#sql;
169
223
  const seenRef = /* @__PURE__ */ new Set();
170
- const toNs = [];
171
- const toType = [];
172
- const toId = [];
224
+ const seekNs = [];
225
+ const seekType = [];
226
+ const seekId = [];
173
227
  for (const r of refs) {
174
228
  const id = refToId(r.id);
175
229
  const k = `${r.ns}\u0000${r.type}\u0000${id}`;
176
230
  if (seenRef.has(k)) continue;
177
231
  seenRef.add(k);
178
- toNs.push(r.ns);
179
- toType.push(r.type);
180
- toId.push(id);
232
+ seekNs.push(r.ns);
233
+ seekType.push(r.type);
234
+ seekId.push(id);
181
235
  }
236
+ const [colNs, colType, colId] = side === "to" ? [
237
+ sql("to_ns"),
238
+ sql("to_type"),
239
+ sql("to_id")
240
+ ] : [
241
+ sql("from_ns"),
242
+ sql("from_type"),
243
+ sql("from_id")
244
+ ];
182
245
  return (await sql`
183
246
  SELECT ${this.#edgeCols}
184
247
  FROM edges
185
- JOIN unnest(${toNs}::text[], ${toType}::text[], ${toId}::text[])
248
+ JOIN unnest(${seekNs}::text[], ${seekType}::text[], ${seekId}::text[])
186
249
  AS seek(seek_ns, seek_type, seek_id)
187
- ON to_ns = seek.seek_ns AND to_type = seek.seek_type AND to_id = seek.seek_id
250
+ ON ${colNs} = seek.seek_ns AND ${colType} = seek.seek_type AND ${colId} = seek.seek_id
188
251
  WHERE deleted_at IS NULL
189
252
  `).map(rowToEdge);
190
253
  }
@@ -1,6 +1,6 @@
1
1
  import { createRequire as __binCreateRequire } from 'node:module'; const require = __binCreateRequire(import.meta.url);
2
- import { J as applyObligations, Yt as ResolverFrameError, bt as jsonResponse, vt as buildContext } from "./src-DK7VEQT6.js";
3
- import "./src-Dbvuel6w.js";
2
+ import { $ as applyObligations, Dt as buildContext, kt as jsonResponse, sn as ResolverFrameError } from "./src-C4t1Gy-m.js";
3
+ import "./src-DWqzrm3O.js";
4
4
  import { Worker } from "node:worker_threads";
5
5
 
6
6
  //#region ../../plugins/substrate-recall/src/candidate-selection.ts
@@ -1,6 +1,6 @@
1
1
  import { createRequire as __binCreateRequire } from 'node:module'; const require = __binCreateRequire(import.meta.url);
2
- import { fn as defineBootstrap } from "./src-DK7VEQT6.js";
3
- import { n as createNoopPubSub, t as createProposalsPlugin } from "./src-D041j6GS.js";
2
+ import { En as defineBootstrap } from "./src-C4t1Gy-m.js";
3
+ import { n as createNoopPubSub, t as createProposalsPlugin } from "./src-Bew_JvTo.js";
4
4
  import { z } from "zod";
5
5
 
6
6
  //#region ../../plugins/substrate-proposals/src/bootstrap.ts
@@ -1,5 +1,5 @@
1
- import { Dt as Dataset, _ as CoordinatorPlugin, hn as OnDelete } from "./schema-CijHRfuk.js";
2
- import { o as ResolverFrameError } from "./errors-BOllGhVx.js";
1
+ import { Mt as Dataset, wn as OnDelete, x as CoordinatorPlugin } from "./schema-oXfQyo0s.js";
2
+ import { l as ResolverFrameError } from "./errors-xP9Mo7Q1.js";
3
3
  //#region ../../plugins/substrate-proposals/src/config.d.ts
4
4
  /**
5
5
  * Multi-instance invalidation transport used by the plugin to broadcast
package/dist/proposals.js CHANGED
@@ -1,4 +1,4 @@
1
1
  import { createRequire as __binCreateRequire } from 'node:module'; const require = __binCreateRequire(import.meta.url);
2
- import { i as ProposalError, n as createNoopPubSub, r as storageSettled, t as createProposalsPlugin } from "./src-D041j6GS.js";
2
+ import { i as ProposalError, n as createNoopPubSub, r as storageSettled, t as createProposalsPlugin } from "./src-Bew_JvTo.js";
3
3
 
4
4
  export { ProposalError, createNoopPubSub, createProposalsPlugin, storageSettled };
@@ -1,7 +1,7 @@
1
1
  import { createRequire as __binCreateRequire } from 'node:module'; const require = __binCreateRequire(import.meta.url);
2
- import { fn as defineBootstrap } from "./src-DK7VEQT6.js";
2
+ import { En as defineBootstrap } from "./src-C4t1Gy-m.js";
3
3
  import { t as FakeEmbedder } from "./fake-DUVtKVSE.js";
4
- import { t as createRecallPlugin } from "./plugin-DIYm2cZE.js";
4
+ import { t as createRecallPlugin } from "./plugin-BLm5IRdX.js";
5
5
  import { z } from "zod";
6
6
 
7
7
  //#region ../../packages/substrate-embedder/src/types.ts
package/dist/recall.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { A as KernelPlugin, C as FilterOperatorDef, Cn as Row, D as KernelMigration, Dt as Dataset, M as McpToolRegistration, Z as HttpHandler, _t as RequestContext, ft as Identity, gt as PolicyProbeContext, ht as PolicyDecision, i as FieldDef, mn as EdgesStore, y as EmbedSourceContext, yt as ResolverArgs, z as PostWriteHook } from "./schema-CijHRfuk.js";
1
+ import { C as EmbedSourceContext, Cn as EdgesStore, Ct as ResolverArgs, D as FilterOperatorDef, I as McpToolRegistration, Mn as Row, Mt as Dataset, P as KernelPlugin, U as PostWriteHook, bt as PolicyProbeContext, gt as Identity, i as FieldDef, j as KernelMigration, tt as HttpHandler, xt as RequestContext, yt as PolicyDecision } from "./schema-oXfQyo0s.js";
2
2
  import { t as Embedder } from "./types-8c0gtnd2.js";
3
3
  import postgres, { Sql } from "postgres";
4
4
  //#region ../../plugins/substrate-recall/src/candidate-selection.d.ts
@@ -1516,7 +1516,7 @@ export declare class InMemoryEmbeddingsStore implements EmbeddingsStore {
1516
1516
  //#endregion
1517
1517
  //#region ../../plugins/substrate-recall/src/in-memory-lexical-store.d.ts
1518
1518
  /**
1519
- * Resolves a row body, mirroring pg's join against `rows`.
1519
+ * Resolves a row body, mirroring pg's join against the type's table.
1520
1520
  *
1521
1521
  * Signature matches `InMemoryEmbeddingsStoreOptions.datasetFor` deliberately:
1522
1522
  * a host wires both from the same registry lookup.
@@ -1706,20 +1706,20 @@ export declare class PgEmbeddingsStore implements EmbeddingsStore {
1706
1706
  id: string;
1707
1707
  }>, model: string): Promise<ReadonlyArray<EmbeddingsStoreFetchResult>>;
1708
1708
  selectCandidates(selector: CandidateSelector, model: string): Promise<Candidate[]>;
1709
+ staleRowIds(input: {
1710
+ namespace: string;
1711
+ type: string;
1712
+ afterId: string;
1713
+ limit: number;
1714
+ }): Promise<string[]>;
1709
1715
  /**
1710
1716
  * Deletes every embedding whose backing row is missing or soft-deleted.
1711
- * Needed because `embeddings` has no FK to `rows` and no
1717
+ * Needed because `embeddings` has no FK to the type tables and no
1712
1718
  * dataset delete path touches it; tombstones are terminal, so soft-deleted
1713
1719
  * rows are safe to collect immediately. Run as a sweep stage by the binary.
1714
1720
  *
1715
1721
  * @returns number of orphaned embeddings deleted.
1716
1722
  */
1717
- staleRowIds(input: {
1718
- namespace: string;
1719
- type: string;
1720
- afterId: string;
1721
- limit: number;
1722
- }): Promise<string[]>;
1723
1723
  purgeOrphans(): Promise<number>;
1724
1724
  }
1725
1725
  //#endregion
@@ -1740,7 +1740,7 @@ export declare class PgLexicalStore implements LexicalStore {
1740
1740
  /**
1741
1741
  * Deletes every lexical row whose backing row is missing or soft-deleted,
1742
1742
  * as `PgEmbeddingsStore.purgeOrphans` does for vectors: `lexical` has no FK
1743
- * to `rows`, so a drop, purge or tombstone would otherwise leave the text.
1743
+ * to the type tables, so a drop, purge or tombstone would otherwise leave the text.
1744
1744
  *
1745
1745
  * @returns number of orphaned lexical rows deleted.
1746
1746
  */
package/dist/recall.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { createRequire as __binCreateRequire } from 'node:module'; const require = __binCreateRequire(import.meta.url);
2
- import { a as InMemoryLexicalStore, i as PgClusterStore, n as PgLexicalStore, o as InMemoryEmbeddingsStore, r as PgEmbeddingsStore, s as InMemoryClusterStore, t as RECALL_VERSION } from "./src-DptNGNYQ.js";
3
- import { $ as CLUSTERER_BACKEND_VERSION, A as CLUSTER_MEMBER_FIELDS, C as EmbedSourceRegistry, D as makeReembed, E as makeEmbedPostWrite, F as unknownParams, G as DEFAULT_CRYSTALLISE_CONFIG, H as CRYSTALLISE_IN_FLIGHT_CODE, I as handleRecallRequest, J as runClusterer, K as handleCrystallise, L as RRF_K, M as recallRouteHandler, N as checkParams, O as crystalliseRouteHandler, P as unknownParamMessage, Q as CLUSTERER_BACKEND, R as armRanks, S as createEmbedStats, T as embedRowReporting, U as createCrystalliseGuard, X as l2normalize, _ as EMBEDDINGS_FETCH_MAX_REFS, a as REINDEX_MAX_LIMIT, b as handleLexicalCoverage, c as SALIENCE_BOOST_MAX_TARGETS, d as embeddingsMigration, et as memberKey, f as recallMcpTool, g as embeddingsFetchRouteHandler, h as embeddingSimilarOperator, i as REINDEX_DEFAULT_LIMIT, j as buildClusterSurface, k as CLUSTER_FIELDS, l as lexicalMigration, m as makeLexicalPostWrite, n as salienceBoostRouteHandler, nt as validateSelector, o as handleReindex, p as makeLexicalClassify, q as validateCrystalliseInput, r as reindexRouteHandler, s as validateReindexInput, t as createRecallPlugin, tt as SELECT_CANDIDATES_MAX_LIMIT, u as recallClustersMigration, v as embedStatsRouteHandler, w as embedAndStore, x as validateLexicalCoverageInput, y as handleEmbedStatsRequest, z as fuseByRank } from "./plugin-DIYm2cZE.js";
2
+ import { a as InMemoryLexicalStore, i as PgClusterStore, n as PgLexicalStore, o as InMemoryEmbeddingsStore, r as PgEmbeddingsStore, s as InMemoryClusterStore, t as RECALL_VERSION } from "./src-BjWVYYoo.js";
3
+ import { $ as CLUSTERER_BACKEND_VERSION, A as CLUSTER_MEMBER_FIELDS, C as EmbedSourceRegistry, D as makeReembed, E as makeEmbedPostWrite, F as unknownParams, G as DEFAULT_CRYSTALLISE_CONFIG, H as CRYSTALLISE_IN_FLIGHT_CODE, I as handleRecallRequest, J as runClusterer, K as handleCrystallise, L as RRF_K, M as recallRouteHandler, N as checkParams, O as crystalliseRouteHandler, P as unknownParamMessage, Q as CLUSTERER_BACKEND, R as armRanks, S as createEmbedStats, T as embedRowReporting, U as createCrystalliseGuard, X as l2normalize, _ as EMBEDDINGS_FETCH_MAX_REFS, a as REINDEX_MAX_LIMIT, b as handleLexicalCoverage, c as SALIENCE_BOOST_MAX_TARGETS, d as embeddingsMigration, et as memberKey, f as recallMcpTool, g as embeddingsFetchRouteHandler, h as embeddingSimilarOperator, i as REINDEX_DEFAULT_LIMIT, j as buildClusterSurface, k as CLUSTER_FIELDS, l as lexicalMigration, m as makeLexicalPostWrite, n as salienceBoostRouteHandler, nt as validateSelector, o as handleReindex, p as makeLexicalClassify, q as validateCrystalliseInput, r as reindexRouteHandler, s as validateReindexInput, t as createRecallPlugin, tt as SELECT_CANDIDATES_MAX_LIMIT, u as recallClustersMigration, v as embedStatsRouteHandler, w as embedAndStore, x as validateLexicalCoverageInput, y as handleEmbedStatsRequest, z as fuseByRank } from "./plugin-BLm5IRdX.js";
4
4
 
5
5
  export { CLUSTERER_BACKEND, CLUSTERER_BACKEND_VERSION, CLUSTER_FIELDS, CLUSTER_MEMBER_FIELDS, CRYSTALLISE_IN_FLIGHT_CODE, DEFAULT_CRYSTALLISE_CONFIG, EMBEDDINGS_FETCH_MAX_REFS, EmbedSourceRegistry, InMemoryClusterStore, InMemoryEmbeddingsStore, InMemoryLexicalStore, PgClusterStore, PgEmbeddingsStore, PgLexicalStore, RECALL_VERSION, REINDEX_DEFAULT_LIMIT, REINDEX_MAX_LIMIT, RRF_K, SALIENCE_BOOST_MAX_TARGETS, SELECT_CANDIDATES_MAX_LIMIT, armRanks, buildClusterSurface, checkParams, createCrystalliseGuard, createEmbedStats, createRecallPlugin, crystalliseRouteHandler, embedAndStore, embedRowReporting, embedStatsRouteHandler, embeddingSimilarOperator, embeddingsFetchRouteHandler, embeddingsMigration, fuseByRank, handleCrystallise, handleEmbedStatsRequest, handleLexicalCoverage, handleRecallRequest, handleReindex, l2normalize, lexicalMigration, makeEmbedPostWrite, makeLexicalClassify, makeLexicalPostWrite, makeReembed, memberKey, recallClustersMigration, recallMcpTool, recallRouteHandler, reindexRouteHandler, runClusterer, salienceBoostRouteHandler, unknownParamMessage, unknownParams, validateCrystalliseInput, validateLexicalCoverageInput, validateReindexInput, validateSelector };