@happyvertical/smrt-core 0.51.31 → 0.51.33

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 (187) hide show
  1. package/agents/build-knowledge.md +13 -0
  2. package/dist/__tests__/fixtures/collection-coverage-fixtures.d.ts +8 -0
  3. package/dist/__tests__/fixtures/inheritance-resolver-fixtures.d.ts +9 -0
  4. package/dist/__tests__/fixtures/inheritance-test-classes.d.ts +5 -0
  5. package/dist/__tests__/fixtures/object-ai-memory-fixtures.d.ts +10 -0
  6. package/dist/__typechecks__/collection-read-plan.d.ts +2 -2
  7. package/dist/adapters/ai-usage.d.ts +5 -2
  8. package/dist/adapters/cost-rates.d.ts +1 -1
  9. package/dist/adapters/metrics.d.ts +7 -1
  10. package/dist/adapters/pubsub.d.ts +7 -1
  11. package/dist/browser.d.ts +1 -0
  12. package/dist/browser.d.ts.map +1 -1
  13. package/dist/browser.js +2 -1
  14. package/dist/cascade.d.ts +69 -3
  15. package/dist/change-feed-authz.d.ts +85 -2
  16. package/dist/change-feed.d.ts +133 -2
  17. package/dist/change-signals.d.ts +66 -1
  18. package/dist/child-accessors.d.ts +39 -1
  19. package/dist/class.d.ts +17 -8
  20. package/dist/class.d.ts.map +1 -1
  21. package/dist/class.js +22 -0
  22. package/dist/class.js.map +1 -1
  23. package/dist/collection-cache.d.ts +47 -1
  24. package/dist/collection-read-plan.d.ts +3 -3
  25. package/dist/collection.d.ts +4 -3
  26. package/dist/config.d.ts +15 -6
  27. package/dist/consumer-plugin/index.d.ts +7 -3
  28. package/dist/consumer-plugin/index.d.ts.map +1 -1
  29. package/dist/consumer-plugin/index.js +2 -0
  30. package/dist/consumer-plugin/index.js.map +1 -1
  31. package/dist/data-query.d.ts +12 -1
  32. package/dist/database.d.ts +10 -2
  33. package/dist/decisions.d.ts +24 -2
  34. package/dist/decisions.d.ts.map +1 -1
  35. package/dist/decisions.js +71 -1
  36. package/dist/decisions.js.map +1 -1
  37. package/dist/decorators/index.d.ts +11 -5
  38. package/dist/dispatch/bus.d.ts +27 -2
  39. package/dist/dispatch/collections/DispatchSubscriptions.d.ts +7 -2
  40. package/dist/dispatch/collections/Dispatches.d.ts +8 -3
  41. package/dist/dispatch/models/Dispatch.d.ts +7 -1
  42. package/dist/dispatch/types.d.ts +7 -2
  43. package/dist/embedded-write-queue.d.ts +1 -1
  44. package/dist/embeddings/provider.d.ts +8 -1
  45. package/dist/embeddings/storage.d.ts +8 -2
  46. package/dist/filesystem-loader.d.ts +16 -1
  47. package/dist/generators/changes-route.d.ts +34 -1
  48. package/dist/generators/custom-action.d.ts +10 -2
  49. package/dist/generators/events-route.d.ts +41 -4
  50. package/dist/generators/mcp-runtime-template.d.ts +13 -2
  51. package/dist/generators/mcp.d.ts +6 -1
  52. package/dist/generators/rest.d.ts +10 -5
  53. package/dist/generators/tool-schema.d.ts +1 -1
  54. package/dist/hierarchical.d.ts +37 -1
  55. package/dist/index.d.ts +2 -1
  56. package/dist/index.d.ts.map +1 -1
  57. package/dist/index.js +2 -1
  58. package/dist/interceptors.d.ts +45 -1
  59. package/dist/junction.d.ts +24 -0
  60. package/dist/knowledge-config.d.ts +1 -1
  61. package/dist/knowledge-discovery.d.ts +2 -25
  62. package/dist/knowledge-discovery.d.ts.map +1 -1
  63. package/dist/knowledge-discovery.js +1 -53
  64. package/dist/knowledge-graph.d.ts +2 -94
  65. package/dist/knowledge-graph.d.ts.map +1 -1
  66. package/dist/knowledge-graph.js +1 -267
  67. package/dist/knowledge.d.ts +4 -23
  68. package/dist/knowledge.d.ts.map +1 -1
  69. package/dist/knowledge.js +3 -52
  70. package/dist/knowledge.js.map +1 -1
  71. package/dist/learning/memory.d.ts +21 -1
  72. package/dist/manifest/generator.d.ts +5 -1
  73. package/dist/manifest/index.d.ts +5 -1
  74. package/dist/manifest/manager.d.ts +1 -1
  75. package/dist/manifest/manifest-loader.d.ts +24 -2
  76. package/dist/manifest/sources/composite.d.ts +17 -1
  77. package/dist/manifest/sources/embedded.d.ts +10 -1
  78. package/dist/manifest/sources/explicit-paths.d.ts +13 -1
  79. package/dist/manifest/sources/fallback.d.ts +15 -1
  80. package/dist/manifest/sources/local-test.d.ts +10 -1
  81. package/dist/manifest/sources/static.d.ts +12 -1
  82. package/dist/manifest/sources/test.d.ts +9 -1
  83. package/dist/manifest/sources/types.d.ts +7 -1
  84. package/dist/manifest/static-manifest.d.ts +6 -1
  85. package/dist/manifest/static-manifest.js +1 -1
  86. package/dist/manifest/static-manifest.js.map +1 -1
  87. package/dist/manifest/store.d.ts +22 -3
  88. package/dist/manifest/store.js +1 -1
  89. package/dist/manifest.json +1 -1
  90. package/dist/migrations/backfill-tracker.d.ts +15 -1
  91. package/dist/migrations/differ.d.ts +8 -2
  92. package/dist/migrations/framework-base-tables.d.ts +57 -2
  93. package/dist/migrations/generator.d.ts +8 -2
  94. package/dist/migrations/integer-width.d.ts +10 -2
  95. package/dist/migrations/minor-units.d.ts +40 -1
  96. package/dist/migrations/null-equal-indexes.d.ts +3 -2
  97. package/dist/migrations/orchestrate.d.ts +15 -3
  98. package/dist/migrations/sqlite-rebuild.d.ts +67 -2
  99. package/dist/migrations/tracker.d.ts +9 -3
  100. package/dist/migrations/types.d.ts +7 -2
  101. package/dist/object.d.ts +7 -6
  102. package/dist/object.d.ts.map +1 -1
  103. package/dist/object.js +6 -17
  104. package/dist/object.js.map +1 -1
  105. package/dist/polymorphic-association.d.ts +44 -1
  106. package/dist/postgres-permissions.d.ts +1 -1
  107. package/dist/prebuild/index.d.ts +5 -1
  108. package/dist/query-bounds.d.ts +26 -0
  109. package/dist/registry/cache-config.d.ts +10 -1
  110. package/dist/registry/class-registration.d.ts +10 -2
  111. package/dist/registry/collection-resolution.d.ts +1 -1
  112. package/dist/registry/embedding-manager.d.ts +9 -1
  113. package/dist/registry/inheritance-resolver.d.ts +8 -3
  114. package/dist/registry/manifest-field-merge.d.ts +2 -2
  115. package/dist/registry/name-resolver.d.ts +22 -2
  116. package/dist/registry/relationship-graph.d.ts +9 -1
  117. package/dist/registry/schema-builder.d.ts +8 -3
  118. package/dist/registry/shared-state.d.ts +12 -2
  119. package/dist/registry/types.d.ts +15 -7
  120. package/dist/registry/validator.d.ts +10 -2
  121. package/dist/registry.d.ts +40 -11
  122. package/dist/relationship-loader.d.ts +1 -1
  123. package/dist/run-once.d.ts +110 -1
  124. package/dist/runtime/client.d.ts +4 -1
  125. package/dist/runtime/server.d.ts +5 -2
  126. package/dist/scanner/import-scanner.d.ts +1 -1
  127. package/dist/scanner/manifest-generator.d.ts +4 -1
  128. package/dist/scanner/types.d.ts +4 -1
  129. package/dist/schema/code-generator.d.ts +6 -2
  130. package/dist/schema/column-data-probes.d.ts +27 -2
  131. package/dist/schema/ddl/base-strategy.d.ts +8 -2
  132. package/dist/schema/ddl/duckdb-strategy.d.ts +14 -2
  133. package/dist/schema/ddl/index.d.ts +2 -2
  134. package/dist/schema/ddl/json-duckdb-strategy.d.ts +10 -2
  135. package/dist/schema/ddl/materialize-manifest.d.ts +1 -1
  136. package/dist/schema/ddl/null-equal-index.d.ts +1 -1
  137. package/dist/schema/ddl/postgres-strategy.d.ts +12 -2
  138. package/dist/schema/ddl/sqlite-strategy.d.ts +12 -2
  139. package/dist/schema/ddl/types.d.ts +10 -1
  140. package/dist/schema/foreign-key-ddl.d.ts +2 -2
  141. package/dist/schema/foreign-key-orphan-report.d.ts +25 -3
  142. package/dist/schema/foreign-key-planner.d.ts +2 -2
  143. package/dist/schema/foreign-key-policy.d.ts +1 -1
  144. package/dist/schema/generator.d.ts +7 -3
  145. package/dist/schema/index-utils.d.ts +11 -2
  146. package/dist/schema/live-parity.d.ts +27 -3
  147. package/dist/schema/manifest-schema.d.ts +21 -2
  148. package/dist/schema/schema-aggregator.d.ts +35 -2
  149. package/dist/schema/schema-manager.d.ts +13 -4
  150. package/dist/schema/system-table-shapes.d.ts +20 -1
  151. package/dist/schema/table-verifier.d.ts +1 -1
  152. package/dist/schema/text-cast-probe.d.ts +24 -1
  153. package/dist/schema/utils.d.ts +13 -4
  154. package/dist/schema/uuid-convergence.d.ts +32 -1
  155. package/dist/signals/bus.d.ts +8 -2
  156. package/dist/signals/sanitizer.d.ts +7 -1
  157. package/dist/smrt-knowledge.json +8 -9
  158. package/dist/system/bootstrap.d.ts +2 -1
  159. package/dist/system/compatibility.d.ts +1 -1
  160. package/dist/system/diagnostics.d.ts +17 -2
  161. package/dist/system/retention.d.ts +46 -1
  162. package/dist/system/schema.d.ts +7 -1
  163. package/dist/system-fields.d.ts +9 -1
  164. package/dist/test-utils.d.ts +7 -1
  165. package/dist/testing/database.d.ts +18 -1
  166. package/dist/testing/notifications-stub.d.ts +15 -1
  167. package/dist/tools/tool-executor.d.ts +6 -1
  168. package/dist/tools/tool-generator.d.ts +8 -2
  169. package/dist/utils/json.d.ts +9 -1
  170. package/dist/utils/qualified-names.d.ts +10 -1
  171. package/dist/utils/scanner-module.d.ts +2 -2
  172. package/dist/utils.d.ts +1 -1
  173. package/dist/vite-plugin/api-client-entries.d.ts +9 -1
  174. package/dist/vite-plugin/changes-route.d.ts +33 -2
  175. package/dist/vite-plugin/dev-plane-route.d.ts +12 -1
  176. package/dist/vite-plugin/events-route.d.ts +37 -2
  177. package/dist/vite-plugin/generated-client.d.ts +9 -1
  178. package/dist/vite-plugin/index.d.ts +9 -5
  179. package/dist/vite-plugin/resources-route.d.ts +82 -1
  180. package/dist/vite-plugin/sveltekit-generator.d.ts +8 -4
  181. package/dist/vite-plugin/sveltekit-route-coordinator.d.ts +3 -3
  182. package/dist/vite-plugin/sync-apply-route.d.ts +19 -2
  183. package/dist/vite-plugin/web-collections.d.ts +25 -2
  184. package/dist/vite-plugin/worker-registration.d.ts +21 -1
  185. package/package.json +7 -8
  186. package/dist/knowledge-discovery.js.map +0 -1
  187. package/dist/knowledge-graph.js.map +0 -1
@@ -1,4 +1,18 @@
1
- import { DatabaseInterface } from '@happyvertical/sql';
1
+ /**
2
+ * Tracks application-specific data backfills (not schema migrations).
3
+ *
4
+ * Sits next to `MigrationTracker` but is intentionally minimal — backfills
5
+ * have no checksum, no rollback semantics, no DDL. They're "this data
6
+ * correction has run, don't run it again" markers, keyed by a stable
7
+ * backfill name the app chooses.
8
+ *
9
+ * Backed by the `_smrt_backfills` system table (see
10
+ * `../system/schema.ts`). The table is created lazily on first use —
11
+ * every public method (`isApplied`, `recordApplied`, `runIfPending`,
12
+ * `listApplied`) awaits `initialize()` itself, so consumers never need
13
+ * to call `initialize()` explicitly.
14
+ */
15
+ import type { DatabaseInterface } from '@happyvertical/sql';
2
16
  export interface BackfillTrackerOptions {
3
17
  db: DatabaseInterface;
4
18
  }
@@ -1,5 +1,11 @@
1
- import { ColumnDefinition, SchemaChange, SchemaDefinition, SchemaDiff, SQLDataType } from '../schema/types.js';
2
- import { DatabaseInterface, SqlTableSchemaInfo } from './types.js';
1
+ /**
2
+ * Schema Differ
3
+ *
4
+ * Compares manifest schemas to database schemas and generates
5
+ * a SchemaDiff with the differences.
6
+ */
7
+ import type { ColumnDefinition, SchemaChange, SchemaDefinition, SchemaDiff, SQLDataType } from '../schema/types.js';
8
+ import type { DatabaseInterface, SqlTableSchemaInfo } from './types.js';
3
9
  /**
4
10
  * `mismatch.actual` of the manual change reported when a required column
5
11
  * could not be added to a populated table (#3008): the column is absent.
@@ -1,5 +1,60 @@
1
- import { DatabaseInterface } from '@happyvertical/sql';
2
- import { DatabaseEngine } from '../schema/ddl/types.js';
1
+ /**
2
+ * One-time remediation for the five orphaned framework-base tables (#2647).
3
+ *
4
+ * #2644 stopped `getAllSchemasAsDefinitions()` from planning a table for
5
+ * SMRT's abstract framework-base classes (`SmrtObject`, `SmrtClass`,
6
+ * `SmrtCollection`, `SmrtHierarchical`, `SmrtPolymorphicAssociation`), but it
7
+ * does not remove the ones a pre-fix `db:migrate` already created. Any
8
+ * deployment that ran `db:migrate` before that fix has all five tables, and
9
+ * the differ now reports them as permanent orphans (#2369's
10
+ * `includeDroppedTables` stays `false` on purpose — see below).
11
+ *
12
+ * This module is a narrow, named remediation, deliberately **not** a change
13
+ * to the general differ: `SchemaDiff.orphan_tables` already reports orphan
14
+ * tables, and `includeDroppedTables` (default `false`, both call sites pass
15
+ * it explicitly) is the opt-in for the executable `DROP TABLE`. That default
16
+ * must stay `false` — flipping it globally would make `db:migrate` drop *any*
17
+ * table absent from the manifest, which for a consumer with hand-managed or
18
+ * legacy tables is unacceptable data loss. Dropping only these five specific,
19
+ * hand-typed names is safe *because* nothing but the retired base-class
20
+ * planning path could ever have created them; a general orphan drop is not.
21
+ *
22
+ * Safety model, in order:
23
+ * 1. {@link FRAMEWORK_BASE_TABLE_NAMES} is a literal, hand-typed list. It is
24
+ * never derived from a differ orphan report or any other dynamic source —
25
+ * doing so would recreate the dangerous global-drop path by another route.
26
+ * 2. {@link planFrameworkBaseTableDrop} is read-only. For every name in the
27
+ * list that exists live, it verifies the table has *only* that table's
28
+ * expected columns — the universal `id`/`slug`/`context`/`created_at`/
29
+ * `updated_at` base for three of the five, extended with the real fields
30
+ * `SmrtHierarchical`/`SmrtPolymorphicAssociation` themselves declare for
31
+ * `smrt_hierarchicals`/`smrt_polymorphic_associations` (see
32
+ * {@link EXPECTED_COLUMN_BUCKETS_BY_TABLE}) — with a plausible type for
33
+ * each, is referenced by no foreign key anywhere in the live database,
34
+ * and is empty. Any live table missing that shape — e.g. a consumer's
35
+ * own, unrelated table that happens to share one of these five names —
36
+ * is reported as unsafe and dropped nothing.
37
+ * 3. {@link dropFrameworkBaseTables} refuses to run against a plan that is
38
+ * not `safe`, locks every PostgreSQL target `IN ACCESS EXCLUSIVE MODE`
39
+ * (a plain `SELECT COUNT(*)` alone would not block a concurrent writer),
40
+ * and then re-verifies shape, type, and emptiness — not just the row
41
+ * count — inside that same bounded transaction immediately before
42
+ * dropping anything. A table rewritten or replaced between planning and
43
+ * execution therefore still stops the whole batch, not just a row-count
44
+ * race. Foreign keys are checked at planning time only. On PostgreSQL, a
45
+ * foreign key added afterward is still caught — its FK enforcement is
46
+ * dependency-based, so `DROP TABLE` refuses when a real dependent
47
+ * exists. This does **not** hold on SQLite/DuckDB: SQLite's `DROP TABLE`
48
+ * only enforces against the rows actually being removed, so an empty
49
+ * parent (exactly this function's precondition) drops cleanly past a
50
+ * real foreign key, and DuckDB's adapter cannot even see the reference
51
+ * at plan time (see {@link qualifyIdentifier}'s doc comment). No data is
52
+ * lost either way — the residual risk on those two engines is a
53
+ * dangling reference, not data loss, confined to a narrow window a
54
+ * one-time operator-run command makes unlikely in practice.
55
+ */
56
+ import type { DatabaseInterface } from '@happyvertical/sql';
57
+ import type { DatabaseEngine } from '../schema/ddl/types.js';
3
58
  /**
4
59
  * The exact five orphaned framework-base tables #2644 stopped planning.
5
60
  *
@@ -1,5 +1,11 @@
1
- import { MigrationDefinition, SchemaDiff } from '../schema/types.js';
2
- import { DatabaseEngine } from './types.js';
1
+ /**
2
+ * Migration Generator
3
+ *
4
+ * Generates migration files from schema diffs.
5
+ * Supports both SQL and TypeScript formats.
6
+ */
7
+ import type { MigrationDefinition, SchemaDiff } from '../schema/types.js';
8
+ import type { DatabaseEngine } from './types.js';
3
9
  /**
4
10
  * Options for migration generation
5
11
  */
@@ -1,5 +1,13 @@
1
- import { DatabaseInterface } from '@happyvertical/sql';
2
- import { SchemaDefinition } from '../schema/types.js';
1
+ /**
2
+ * Explicit one-time widening for deployments created before #2373.
3
+ *
4
+ * Fresh PostgreSQL and DuckDB schemas now materialize SMRT's abstract
5
+ * `INTEGER` as `BIGINT`. The migration differ deliberately treats int4 and
6
+ * int8 as equivalent, so existing deployments need this separate, operator
7
+ * initiated maintenance-window migration rather than an automatic repair.
8
+ */
9
+ import type { DatabaseInterface } from '@happyvertical/sql';
10
+ import type { SchemaDefinition } from '../schema/types.js';
3
11
  /** A table and its SMRT-owned integer columns. */
4
12
  export interface IntegerWidthTarget {
5
13
  table: string;
@@ -1,4 +1,43 @@
1
- import { DatabaseInterface } from './types.js';
1
+ /**
2
+ * Money-column rescale: floating-point major units → integer minor units (#2401).
3
+ *
4
+ * SMRT's rule is that money is exact and is stored as **integer minor units**
5
+ * at an application-defined scale — `$19.99` is `1999` at a cents scale.
6
+ * Packages that predate the rule
7
+ * declared their money fields `= 0.0`, which compiles to a floating-point
8
+ * column holding *major* units. Flipping the declaration to `= 0` changes the
9
+ * column type, and REAL→INTEGER is deliberately **not** one of the differ's
10
+ * whitelisted upgrades: an automatic `ALTER … TYPE BIGINT` would truncate
11
+ * `19.99` to `19`, silently destroying minor units on every row.
12
+ *
13
+ * So the conversion is an explicit, opt-in migration with two halves:
14
+ *
15
+ * 1. {@link preflightMinorUnitsRescale} — read-only. Reports, per column,
16
+ * whether it still needs converting, and lists the rows that would lose
17
+ * information: values whose scaled form is not a whole number (a half-cent
18
+ * that has to be rounded away) and values that exceed JavaScript's safe
19
+ * integer range once multiplied by the scale. Run it against a production
20
+ * snapshot and
21
+ * read the summary before converting anything.
22
+ * 2. {@link rescaleMoneyColumnsToMinorUnits} — the conversion itself, guarded
23
+ * by a {@link BackfillTracker} marker so re-running it can never multiply a
24
+ * table by 100 twice.
25
+ *
26
+ * Per-engine behaviour:
27
+ *
28
+ * | Engine | Column type | Values |
29
+ * | --- | --- | --- |
30
+ * | PostgreSQL | `ALTER COLUMN … TYPE BIGINT USING round(col * scale)` | converted by the cast |
31
+ * | DuckDB | `ALTER COLUMN … TYPE BIGINT USING round(col * scale)` | converted by the cast |
32
+ * | SQLite | **not changed here** — SQLite cannot alter a column's declared type in place | rescaled with an `UPDATE`, values become exact integers |
33
+ *
34
+ * SQLite's declared type only sets an affinity, so a rescaled column already
35
+ * behaves as integer minor units; bringing the *declaration* into line needs
36
+ * the table-rebuild path (#2370). The result flags that with
37
+ * {@link MinorUnitsRescaleResult.declaredTypeChangePending} rather than
38
+ * pretending the column type moved.
39
+ */
40
+ import type { DatabaseInterface } from './types.js';
2
41
  /** A table and the money columns on it that must move to minor units. */
3
42
  export interface MoneyColumnTarget {
4
43
  /** Physical table name, e.g. `payments`. */
@@ -1,5 +1,6 @@
1
- import { DatabaseInterface } from '@happyvertical/sql';
2
- import { SchemaDefinition } from '../schema/types.js';
1
+ /** Explicit, atomic maintenance upgrade of framework-owned nullable conflict indexes. */
2
+ import type { DatabaseInterface } from '@happyvertical/sql';
3
+ import type { SchemaDefinition } from '../schema/types.js';
3
4
  export interface NullEqualIndexTarget {
4
5
  table: string;
5
6
  index: string;
@@ -1,6 +1,18 @@
1
- import { DatabaseInterface } from '@happyvertical/sql';
2
- import { DatabaseEngine } from '../schema/ddl/types.js';
3
- import { MigrationResult, SchemaChange } from '../schema/types.js';
1
+ /**
2
+ * High-level "make my SMRT app's schema match its database" orchestration.
3
+ *
4
+ * Wraps `ObjectRegistry.getAllSchemasAsDefinitions()` → `generateSchemaDiff`
5
+ * → `MigrationTracker.applyAll`. Apps that just want to run pending
6
+ * schema changes call `migrateSmrtSchemas({ db, packageName, version })`
7
+ * and don't have to assemble the migration definition by hand.
8
+ *
9
+ * The migration name is timestamped, so re-running on an up-to-date
10
+ * database is a no-op (the diff is empty, no statements are generated,
11
+ * `applied: false` is returned).
12
+ */
13
+ import type { DatabaseInterface } from '@happyvertical/sql';
14
+ import type { DatabaseEngine } from '../schema/ddl/types.js';
15
+ import type { MigrationResult, SchemaChange } from '../schema/types.js';
4
16
  import { generateSchemaDiff } from './differ.js';
5
17
  export interface MigrateSmrtSchemasOptions {
6
18
  db: DatabaseInterface;
@@ -1,5 +1,70 @@
1
- import { SchemaChange, SQLDataType } from '../schema/types.js';
2
- import { DatabaseInterface } from './types.js';
1
+ /**
2
+ * SQLite table-rebuild migrations (issue #2370)
3
+ *
4
+ * SQLite has no `ALTER TABLE ... ALTER COLUMN ... TYPE`. Before this module
5
+ * every type-bucket change on SQLite (the canonical one being a numeric
6
+ * default edited from `0` to `0.0`, i.e. INTEGER → REAL) turned into an
7
+ * advisory differ comment, which `db:migrate` classifies as
8
+ * *manual intervention* and exits 1 for — forever, because nothing in the
9
+ * toolchain could ever perform the change.
10
+ *
11
+ * This module turns that comment into the executable rebuild SQLite's own
12
+ * documentation prescribes ("Making Other Kinds Of Table Schema Changes",
13
+ * lang_altertable.html):
14
+ *
15
+ * 1. `PRAGMA defer_foreign_keys = ON` — defers foreign-key enforcement to
16
+ * COMMIT so the window where the table does not exist cannot raise. It is
17
+ * honored *inside* a transaction (unlike `PRAGMA foreign_keys`, which is a
18
+ * silent no-op there) and resets itself at COMMIT/ROLLBACK.
19
+ * 2. Create a new table under a reserved `_smrt_rebuild_` name carrying the
20
+ * target shape.
21
+ * 3. Copy every row across.
22
+ * 4. Drop the original table.
23
+ * 5. Rename the new table into its place, with `PRAGMA legacy_alter_table`
24
+ * ON for the rename itself (see {@link buildSqliteRebuildStatements}).
25
+ * 6. Recreate the indexes and triggers that died with the original table.
26
+ *
27
+ * The whole plan is a plain statement list, so it is executed by the
28
+ * `MigrationTracker` inside the same transaction as the rest of the batch:
29
+ * a failure anywhere rolls the table back to its original shape and contents.
30
+ *
31
+ * ## The target shape comes from the live DDL, not from the manifest
32
+ *
33
+ * The new table is the *original* `CREATE TABLE` text with only the drifted
34
+ * columns' type tokens replaced. That deliberately preserves everything the
35
+ * manifest does not model or does not own here: columns the manifest has
36
+ * dropped (SMRT is additive — a rebuild must not become an implicit
37
+ * `DROP COLUMN`), table-level constraints, `CHECK`s, collations, and table
38
+ * options such as `WITHOUT ROWID`. The `add_column` changes in the same batch
39
+ * still run their own `ALTER TABLE ... ADD COLUMN`, against the rebuilt table
40
+ * — {@link planSqliteTableRebuilds} hoists the rebuild ahead of them for
41
+ * exactly that reason.
42
+ *
43
+ * ## Why the copy carries no CAST
44
+ *
45
+ * The copy is a plain `INSERT INTO new SELECT ... FROM old`; SQLite applies
46
+ * the destination column's *affinity* on insert, which is exactly the
47
+ * conversion a fresh table would have performed (integer `1` becomes real
48
+ * `1.0` in a REAL column). An explicit `CAST` would be strictly worse: casting
49
+ * a non-numeric TEXT value to REAL/INTEGER silently yields `0`, and casting an
50
+ * ISO timestamp string to SQLite's NUMERIC-affinity `DATETIME` silently yields
51
+ * the leading year. Affinity conversion leaves values it cannot convert
52
+ * untouched instead of destroying them.
53
+ *
54
+ * ## When the rebuild refuses
55
+ *
56
+ * With `PRAGMA foreign_keys` enabled — which the SMRT SQLite adapter is by
57
+ * default — `DROP TABLE` performs an implicit `DELETE FROM` that fires
58
+ * `ON DELETE` actions on children. A child with `ON DELETE CASCADE` therefore
59
+ * loses its rows, and `defer_foreign_keys` does not help: it defers
60
+ * constraint *checks*, not FK *actions*. So when any table declares a foreign
61
+ * key onto the rebuild target and enforcement is on, the plan is refused and
62
+ * the change stays a manual intervention. That includes the target's own
63
+ * self-references, because the staging table copies them and so becomes a
64
+ * child of the table being dropped.
65
+ */
66
+ import type { SchemaChange, SQLDataType } from '../schema/types.js';
67
+ import type { DatabaseInterface } from './types.js';
3
68
  /**
4
69
  * Prefix of the reserved staging table a rebuild creates. `_smrt_`-prefixed
5
70
  * names are SMRT system tables, which the differ's dropped-table sweep skips,
@@ -1,7 +1,13 @@
1
+ /**
2
+ * Migration Tracker
3
+ *
4
+ * Manages migration state, tracking which migrations have been applied,
5
+ * and providing idempotent migration application.
6
+ */
1
7
  import { parsePostgresTimeoutMs } from '../postgres-timeouts.js';
2
- import { DatabaseEngine } from '../schema/ddl/types.js';
3
- import { DriftReport, MigrationDefinition, MigrationResult, MigrationStatus, SchemaMigrationRecord } from '../schema/types.js';
4
- import { ApplyMigrationsOptions, MigrationTrackerOptions, RollbackOptions } from './types.js';
8
+ import type { DatabaseEngine } from '../schema/ddl/types.js';
9
+ import type { DriftReport, MigrationDefinition, MigrationResult, MigrationStatus, SchemaMigrationRecord } from '../schema/types.js';
10
+ import type { ApplyMigrationsOptions, MigrationTrackerOptions, RollbackOptions } from './types.js';
5
11
  /**
6
12
  * Extract the index name from a `CREATE [UNIQUE] INDEX …` statement.
7
13
  *
@@ -1,5 +1,10 @@
1
- import { DatabaseInterface, ColumnDefinitionWithName as SqlColumnDefinitionWithName, IndexDefinition as SqlIndexDefinition, TableSchemaInfo as SqlTableSchemaInfo } from '@happyvertical/sql';
2
- import { MigrationResult } from '../schema/types.js';
1
+ /**
2
+ * Migration Types
3
+ *
4
+ * Re-exports migration types from schema and adds migration-specific types.
5
+ */
6
+ import type { DatabaseInterface, ColumnDefinitionWithName as SqlColumnDefinitionWithName, IndexDefinition as SqlIndexDefinition, TableSchemaInfo as SqlTableSchemaInfo } from '@happyvertical/sql';
7
+ import type { MigrationResult } from '../schema/types.js';
3
8
  export type { DriftReport, MigrationDefinition, MigrationResult, MigrationStatus, SchemaChange, SchemaDiff, SchemaMigrationRecord, } from '../schema/types.js';
4
9
  export type { DatabaseInterface, SqlColumnDefinitionWithName, SqlIndexDefinition, SqlTableSchemaInfo, };
5
10
  /**
package/dist/object.d.ts CHANGED
@@ -1,9 +1,10 @@
1
- import { AITextCompletionOptions, AITool } from '@happyvertical/ai';
2
- import { SmrtClassOptions, SmrtClass } from './class';
3
- import { DatabaseErrorClassification } from './db-errors';
4
- import { EvaluateOptions, EvaluationResult } from './decisions';
5
- import { GenerateEmbeddingsOptions } from './embeddings/types';
6
- import { ToolCall, ToolCallResult } from './tools/tool-executor';
1
+ import type { AITextCompletionOptions, AITool } from '@happyvertical/ai';
2
+ import type { SmrtClassOptions } from './class';
3
+ import { SmrtClass } from './class';
4
+ import { type DatabaseErrorClassification } from './db-errors';
5
+ import { type EvaluateOptions, type EvaluationResult } from './decisions';
6
+ import type { GenerateEmbeddingsOptions } from './embeddings/types';
7
+ import { type ToolCall, type ToolCallResult } from './tools/tool-executor';
7
8
  /** Optional optimistic-concurrency guard for persisted-object saves. */
8
9
  export interface SmrtSaveOptions {
9
10
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"object.d.ts","sourceRoot":"","sources":["../src/object.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAYzE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAChD,OA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ceptors, createInterceptorContext, resolveGetStringFilter } from "./interceptors.js";
8
8
  import { detectEngine } from "./schema/ddl/index.js";
9
9
  import { CHANGE_FEED_WAS_PERSISTED_KEY, recordInstanceChange } from "./change-feed.js";
10
+ import { assertFiniteUnitInterval } from "./decisions.js";
10
11
  import { SmrtClass } from "./class.js";
11
12
  import { EmbeddingProvider } from "./embeddings/provider.js";
12
13
  import { EmbeddingStorage } from "./embeddings/storage.js";
13
- import { assertFiniteUnitInterval } from "./decisions.js";
14
14
  import { ContentHasher } from "./embeddings/hash.js";
15
15
  import { getBoxedPrimitiveKind, isRawJSON } from "./plain-json.js";
16
16
  import { isBatchSafeValidator } from "./registry/validator.js";
@@ -40,9 +40,6 @@ function isDuckDbHugeInt(value) {
40
40
  return Boolean(value && typeof value === "object" && "hugeint" in value && (typeof value.hugeint === "number" || typeof value.hugeint === "bigint"));
41
41
  }
42
42
  var PLAIN_JSON_OMITTED = Symbol("plain-json-omitted");
43
- function asDecisionRecord(value) {
44
- return value && typeof value === "object" && !Array.isArray(value) ? value : void 0;
45
- }
46
43
  /**
47
44
  * Materialize the values JSON.stringify() would emit without first encoding
48
45
  * them into a string. This keeps toPlainObject() suitable for SvelteKit while
@@ -1992,8 +1989,7 @@ var SmrtObject = class SmrtObject extends SmrtClass {
1992
1989
  const configuredFallback = options.uncertaintyFallback === false ? void 0 : options.uncertaintyFallback ?? config?.uncertaintyFallback;
1993
1990
  if (configuredFallback) assertFiniteUnitInterval(configuredFallback.band, "Decision uncertainty fallback band");
1994
1991
  if (!decision) return this.evaluateWithGenerativeClient(criteria, options);
1995
- if ((await decision.getCapabilities?.())?.decisions !== true || typeof decision.decide !== "function") throw new Error("The configured decision client does not support typed decisions.");
1996
- const result = asDecisionRecord(await decision.decide({
1992
+ const result = await this.attemptDecision({
1997
1993
  state: options.includeData === false ? {} : { content: this.serializeForAiPrompt(options.maxDataLength) },
1998
1994
  questions: { result: {
1999
1995
  type: "predicate",
@@ -2007,20 +2003,13 @@ var SmrtObject = class SmrtObject extends SmrtClass {
2007
2003
  operation: "decision",
2008
2004
  className: this._className
2009
2005
  }
2010
- }));
2011
- const answer = asDecisionRecord(asDecisionRecord(result?.answers)?.result);
2006
+ });
2007
+ if (!result) throw new Error("Configured decision client was unavailable.");
2008
+ const provenance = result.provenance;
2009
+ const answer = result.answers.result;
2012
2010
  if (answer?.type !== "predicate") throw new Error("Decision provider returned no predicate result.");
2013
2011
  const probability = answer.probability;
2014
2012
  assertFiniteUnitInterval(probability, "Decision probability");
2015
- const provenance = asDecisionRecord(result?.provenance);
2016
- if (!provenance || typeof provenance.provider !== "string" || typeof provenance.model !== "string") throw new Error("Decision provider returned invalid provenance.");
2017
- await this.recordAiUsageEvent({
2018
- provider: provenance.provider,
2019
- model: provenance.model,
2020
- operation: "decision",
2021
- usage: result?.usage,
2022
- tags: { operation: "decision" }
2023
- }, provenance);
2024
2013
  const lowerUncertaintyBound = configuredFallback === void 0 ? void 0 : Math.max(0, threshold - configuredFallback.band);
2025
2014
  const upperUncertaintyBound = configuredFallback === void 0 ? void 0 : Math.min(1, threshold + configuredFallback.band);
2026
2015
  if (lowerUncertaintyBound !== void 0 && upperUncertaintyBound !== void 0 && probability >= lowerUncertaintyBound && probability <= upperUncertaintyBound) return {