@happyvertical/smrt-core 0.47.0 → 0.47.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.
Files changed (84) hide show
  1. package/AGENTS.md +2 -0
  2. package/agents/generators.md +19 -5
  3. package/agents/registry-snapshot.md +28 -0
  4. package/agents/schema-paths.md +12 -0
  5. package/agents/system-diagnostics.md +43 -0
  6. package/dist/browser.js +4 -2
  7. package/dist/change-feed.d.ts +8 -0
  8. package/dist/change-feed.d.ts.map +1 -1
  9. package/dist/change-feed.js +1 -1
  10. package/dist/change-feed.js.map +1 -1
  11. package/dist/index.d.ts +1 -0
  12. package/dist/index.d.ts.map +1 -1
  13. package/dist/index.js +5 -2
  14. package/dist/manifest/static-manifest.js +1 -1
  15. package/dist/manifest/static-manifest.js.map +1 -1
  16. package/dist/manifest/store.js +1 -1
  17. package/dist/manifest.json +1 -1
  18. package/dist/migrations/differ.d.ts +78 -0
  19. package/dist/migrations/differ.d.ts.map +1 -1
  20. package/dist/migrations/differ.js +191 -1
  21. package/dist/migrations/differ.js.map +1 -1
  22. package/dist/migrations/generator.d.ts.map +1 -1
  23. package/dist/migrations/generator.js +2 -1
  24. package/dist/migrations/generator.js.map +1 -1
  25. package/dist/postgres-permissions.d.ts +3 -0
  26. package/dist/postgres-permissions.d.ts.map +1 -1
  27. package/dist/postgres-permissions.js +49 -6
  28. package/dist/postgres-permissions.js.map +1 -1
  29. package/dist/prebuild/index.d.ts.map +1 -1
  30. package/dist/prebuild/index.js +4 -3
  31. package/dist/prebuild/index.js.map +1 -1
  32. package/dist/registry/class-registration.d.ts.map +1 -1
  33. package/dist/registry/class-registration.js +3 -1
  34. package/dist/registry/class-registration.js.map +1 -1
  35. package/dist/registry/schema-builder.js +1 -1
  36. package/dist/registry.js +1 -1
  37. package/dist/scanner/manifest-generator.d.ts.map +1 -1
  38. package/dist/scanner/manifest-generator.js +22 -1
  39. package/dist/scanner/manifest-generator.js.map +1 -1
  40. package/dist/schema/foreign-key-ddl.d.ts +18 -0
  41. package/dist/schema/foreign-key-ddl.d.ts.map +1 -1
  42. package/dist/schema/foreign-key-ddl.js +15 -2
  43. package/dist/schema/foreign-key-ddl.js.map +1 -1
  44. package/dist/schema/foreign-key-orphan-report.d.ts +57 -0
  45. package/dist/schema/foreign-key-orphan-report.d.ts.map +1 -0
  46. package/dist/schema/foreign-key-orphan-report.js +142 -0
  47. package/dist/schema/foreign-key-orphan-report.js.map +1 -0
  48. package/dist/schema/index.d.ts +1 -0
  49. package/dist/schema/index.d.ts.map +1 -1
  50. package/dist/schema/index.js +2 -1
  51. package/dist/schema/live-parity.d.ts +8 -1
  52. package/dist/schema/live-parity.d.ts.map +1 -1
  53. package/dist/schema/live-parity.js +98 -2
  54. package/dist/schema/live-parity.js.map +1 -1
  55. package/dist/schema/types.d.ts +11 -1
  56. package/dist/schema/types.d.ts.map +1 -1
  57. package/dist/schema.js +2 -1
  58. package/dist/smrt-knowledge.json +22 -10
  59. package/dist/system/diagnostics.d.ts +299 -0
  60. package/dist/system/diagnostics.d.ts.map +1 -0
  61. package/dist/system/diagnostics.js +530 -0
  62. package/dist/system/diagnostics.js.map +1 -0
  63. package/dist/system/index.d.ts +2 -0
  64. package/dist/system/index.d.ts.map +1 -1
  65. package/dist/system/index.js +3 -1
  66. package/dist/system/registry-snapshot.d.ts +112 -0
  67. package/dist/system/registry-snapshot.d.ts.map +1 -0
  68. package/dist/system/registry-snapshot.js +171 -0
  69. package/dist/system/registry-snapshot.js.map +1 -0
  70. package/dist/testing/database.d.ts.map +1 -1
  71. package/dist/testing/database.js +10 -2
  72. package/dist/testing/database.js.map +1 -1
  73. package/dist/utils/scanner-module.d.ts +16 -0
  74. package/dist/utils/scanner-module.d.ts.map +1 -1
  75. package/dist/vite-plugin/index.d.ts +34 -1
  76. package/dist/vite-plugin/index.d.ts.map +1 -1
  77. package/dist/vite-plugin/index.js +85 -5
  78. package/dist/vite-plugin/index.js.map +1 -1
  79. package/dist/vite-plugin/web-collections.d.ts +6 -0
  80. package/dist/vite-plugin/web-collections.d.ts.map +1 -1
  81. package/dist/vite-plugin/web-collections.js +9 -4
  82. package/dist/vite-plugin/web-collections.js.map +1 -1
  83. package/dist/vite-plugin.js +2 -2
  84. package/package.json +10 -10
package/AGENTS.md CHANGED
@@ -20,6 +20,8 @@ and repository rules.
20
20
  | `src/generators/`, `src/vite-plugin/web-collections.ts` | REST/CLI/MCP generation, manifest hashes, ETags | [agents/generators.md](agents/generators.md) |
21
21
  | `src/vite-plugin/`, `src/consumer-plugin/`, `src/knowledge.ts` | Decorator UI hints, knowledge projection, generation snapshots | [agents/build-knowledge.md](agents/build-knowledge.md) |
22
22
  | `src/object.ts`, `src/collection.ts`, `src/learning/memory.ts` | Context memory and semantic search | [agents/memory.md](agents/memory.md) |
23
+ | `src/system/diagnostics.ts` | SELECT-only `_smrt_*` diagnostics reader behind smrt-dev-mcp runtime tools (#1824) | [agents/system-diagnostics.md](agents/system-diagnostics.md) |
24
+ | `src/system/registry-snapshot.ts` | Sanitized plain-JSON projection of the booted `ObjectRegistry` for the smrt-dev-mcp runtime dev-plane (#1831); never constructors, validators, values, or absolute paths | [agents/registry-snapshot.md](agents/registry-snapshot.md) |
23
25
 
24
26
  ## Cross-module invariants
25
27
 
@@ -157,11 +157,25 @@ error nothing could clear.
157
157
  Both `stale-*` codes are warnings by default and errors under `--strict`, which
158
158
  is what CI runs. Alongside them: `agent-surface-missing-identity`,
159
159
  `agent-surface-duplicate-identity`, and `agent-surface-empty-playbook` are
160
- errors, and `agent-surface-not-static` is a warning. A cross-file duplicate
161
- arrives as a *diagnostic* rather than two entries — the scanner's merge already
162
- dropped the loser — so that diagnostic maps to the duplicate error rather than
163
- the not-static warning; otherwise the error would be unreachable for the case it
164
- exists to catch.
160
+ errors, and `agent-surface-not-static` and `agent-surface-tool-name-collision`
161
+ are warnings. A cross-file duplicate arrives as a *diagnostic* rather than two
162
+ entries — the scanner's merge already dropped the loser — so that diagnostic
163
+ maps to the duplicate error rather than the not-static warning; otherwise the
164
+ error would be unreachable for the case it exists to catch.
165
+
166
+ A `tool-name-collision` diagnostic (#2725) is derived from the MANIFEST, not
167
+ from the declaration: the plugin compares each emitted intent against
168
+ `buildWebMcpToolDefinitions` for the same build, which is already filtered by
169
+ the exposure policy, and appends the result to the surface. So it is excluded
170
+ from the drift comparison above — that pass re-derives declarations from source
171
+ alone and has no manifest, so counting one as "declared" would report every
172
+ collision as drift no rebuild could clear. The check is advisory and drops
173
+ nothing: `defineIntent` accepts the id, so the intent is emitted, and the
174
+ document-global tool-name lock (#2613) rejects whichever registers second — the
175
+ build-time notice is the earlier, cheaper form of the same answer. A build
176
+ cannot see the provider's WebMCP `namespace` or `effects` policy, either of
177
+ which separates the pair outright, so the message states that precondition
178
+ rather than asserting the collision.
165
179
 
166
180
  `smrt doctor` prints the whole surface — model tools, intents, playbooks — from
167
181
  these artifacts alone, with no application running.
@@ -0,0 +1,28 @@
1
+ <!-- Module doc for packages/core/AGENTS.md. Linked from the Modules table there. -->
2
+
3
+ # Registry snapshot (#1831)
4
+
5
+ `src/system/registry-snapshot.ts` projects the booted, process-global
6
+ `ObjectRegistry` into `RuntimeRegistrySnapshot`, the only shape in which
7
+ registry state may cross a process or wire boundary. It is a pure read of
8
+ in-process state: no database, no project code, no registry mutation.
9
+
10
+ What leaves: per object the simple/qualified name, package, table, collection,
11
+ `extends`/type argument/inheritance chain, visibility, tenancy `{mode, field}`,
12
+ counts, and (with `detail`) fields — name, type, required, `related`,
13
+ transient, inherited, `sqlType` — and methods — name, async/static/public,
14
+ parameter names and types, return type, inherited. Registry diagnostics keep
15
+ only severity, code, and message.
16
+
17
+ What never leaves: constructors, collection constructors, validators,
18
+ validation rules, `tools` payloads, decorator config, field `value`s or
19
+ descriptions, diagnostic `context`, and absolute paths. `sourceFilePath` is
20
+ relativized to `projectRoot`; a path outside the root (installed package,
21
+ symlinked workspace) is reduced to its basename so `..` walking cannot reveal
22
+ layout. `assertPlainJson()` is exported so callers and tests prove a snapshot
23
+ is plain JSON (no functions, class instances, symbols, or cycles) rather than
24
+ trusting an allow-list.
25
+
26
+ Consumers: `smrt-dev-mcp` `tools/runtime/observation.ts` (`runtime-registry`,
27
+ `runtime-object`) and its Level 2 HTTP host. A new consumer must take the DTO,
28
+ never a `RegisteredClass`.
@@ -530,6 +530,18 @@ SQLite requires a deliberate table rebuild; DuckDB reports the unsupported ALTER
530
530
  path. Neither engine treats an unsupported constraint addition as a successful
531
531
  no-op.
532
532
 
533
+ **Counting orphans is a separate, read-only concern (#2753).**
534
+ `renderForeignKeyOrphanDetector({ limitOne: true })` makes the probe a gate;
535
+ `schema/foreign-key-orphan-report.ts`'s `collectForeignKeyOrphanCounts()` runs
536
+ the identical predicate as `COUNT(*)` (via the same function's `countOnly`
537
+ option, so the FROM/JOIN/WHERE clause is never duplicated) for every
538
+ manifest-declared foreign key, and reports child/parent table and column, the
539
+ live count, and child-column nullability. A relationship whose child or parent
540
+ table does not exist live is skipped and reported separately rather than
541
+ failing the whole run. It never repairs anything — the CLI surface is
542
+ `smrt db:orphans` (`packages/cli/src/commands/db-orphans.ts`), and `db:status`
543
+ prints a compact per-foreign-key summary when any count is nonzero.
544
+
533
545
  ### Pre-R11 `text` ids converge to `uuid` before any FK statement (#2608)
534
546
 
535
547
  PostgreSQL FK columns must have matching physical types. Legacy text IDs may
@@ -0,0 +1,43 @@
1
+ <!-- Module doc for packages/core/AGENTS.md. Linked from the Modules table there. -->
2
+
3
+ # System diagnostics (#1824)
4
+
5
+ `src/system/diagnostics.ts` is the typed, SELECT-only reader over the
6
+ framework-owned `_smrt_*` tables for development tooling (smrt-dev-mcp runtime
7
+ diagnostics). It takes a `DatabaseInterface` and never resolves connections,
8
+ never writes, and never boots the app — connection resolution, redaction, and
9
+ provenance labeling belong to the caller (`packages/smrt-dev-mcp`
10
+ `tools/runtime/`).
11
+
12
+ Categories degrade individually: a missing table or failed read returns a
13
+ `CategoryUnavailable` result (`available: false` with `reason`
14
+ `table-missing`/`retired`/`read-error`) instead of throwing, an empty-but-
15
+ healthy category, or fabricated data. Callers must surface the reason, never
16
+ paper over it. `_smrt_registry` is a retired system table and is reported as
17
+ retired rather than read — only its existence is probed, never its rows.
18
+
19
+ Every read is a bounded `SELECT` with an explicit safe-column projection.
20
+ Sensitive columns are never selected, not selected-then-stripped: job
21
+ `args`/`result_pointer`/task payloads, schedule `agentConfig`/`methodArgs`, and
22
+ dispatch `payload`/`metadata` stay in the database; short error texts
23
+ (`last_error`, `error_message`) and statuses are surfaced for diagnosis, and
24
+ smrt-dev-mcp runs every string in a live result through
25
+ `redactConnectionString` before it reaches a client. Migration
26
+ counts use `MigrationTracker`'s real vocabulary (`completed`, `running`,
27
+ `failed`, `rolled_back`), never an invented `applied`/`pending`. A `running`
28
+ job is stuck only when its `worker_heartbeat` is stale or NULL **and** its
29
+ worker holds no fresh `_smrt_workers.lease_expires_at` — the same rule the
30
+ runner's recovery uses (#1474), so a handler blocking its event loop under a
31
+ live off-loop lease is not reported stuck; without the workers table the
32
+ heartbeat is the only signal. Row lists honor `DIAGNOSTICS_DEFAULT_LIMIT` (50)
33
+ capped at 500; `readRecentChanges()` pages `getChangesSince()` with
34
+ `drain: false` (default 200, same cap) so the PostgreSQL staged-entry drain —
35
+ a write — never runs from a diagnostic.
36
+
37
+ Engine compatibility lives in one place: `placeholders(db)` resolves `$n`
38
+ numbering (PostgreSQL) versus `?` (SQLite/DuckDB) via the shared
39
+ `getDatabaseEngine` convention — explicit `type`/config hint first, then the
40
+ connection URL's scheme — and identifiers are never interpolated from caller
41
+ input, only from the constant `SYSTEM_DIAGNOSTICS_TABLES` map.
42
+ `readSystemDiagnostics()` composes every
43
+ category for one-shot snapshots; per-category readers compose it.
package/dist/browser.js CHANGED
@@ -14,15 +14,17 @@ import { SmrtClass } from "./class.js";
14
14
  import { convertTypeToJsonSchema, generateToolFromMethod, generateToolManifest, shouldIncludeMethod } from "./tools/tool-generator.js";
15
15
  import { executeToolCall, executeToolCalls, formatToolResults, validateToolCall } from "./tools/tool-executor.js";
16
16
  import { SmrtObject } from "./object.js";
17
- import { SMRT_COLLECTION_BASE_NAMES, isSmrtCollectionExtendsName } from "./registry/collection-resolution.js";
18
17
  import { isFrameworkBaseClass } from "./registry/framework-base-classes.js";
18
+ import { SMRT_COLLECTION_BASE_NAMES, isSmrtCollectionExtendsName } from "./registry/collection-resolution.js";
19
19
  import { ObjectRegistry, smrt } from "./registry.js";
20
20
  import { DEFAULT_FACET_LIMIT, MAX_FACET_FIELDS, MAX_FACET_LIMIT, MAX_STI_READ_SCOPE_TYPES, SmrtCollection } from "./collection.js";
21
21
  import { SmrtHierarchical } from "./hierarchical.js";
22
22
  import { SmrtJunction } from "./junction.js";
23
23
  import { SmrtPolymorphicAssociation } from "./polymorphic-association.js";
24
24
  import "./signals/index.js";
25
+ import { DIAGNOSTICS_DEFAULT_LIMIT, SYSTEM_DIAGNOSTICS_TABLES, readDispatchHealth, readJobHealth, readMigrationStatus, readRecentChanges, readRegistryDrift, readScheduleHealth, readSystemDiagnostics } from "./system/diagnostics.js";
26
+ import { BOOTED_PROVENANCE, assertPlainJson, sanitizeMessagePaths, snapshotRegistry } from "./system/registry-snapshot.js";
25
27
  import { DEFAULT_RETENTION_POLICY, clearRetentionTasks, getRetentionTasks, pruneAiUsage, pruneExpiredContexts, registerRetentionTask, runRetentionSweep, unregisterRetentionTask } from "./system/retention.js";
26
28
  import "./system/index.js";
27
29
  import "./tools/index.js";
28
- export { AIError, AiUsageCollector, AiUsagePersistenceHandler, ConfigurationError, DEFAULT_AI_COST_RATES, DEFAULT_FACET_LIMIT, DEFAULT_RETENTION_POLICY, DatabaseError, ErrorUtils, FilesystemError, MAX_FACET_FIELDS, MAX_FACET_LIMIT, MAX_STI_READ_SCOPE_TYPES, MetricsAdapter, NetworkError, ObjectRegistry, PubSubAdapter, RuntimeError, SMRT_COLLECTION_BASE_NAMES, SignalBus, SignalSanitizer, SmrtClass, SmrtCollection, SmrtError, SmrtHierarchical, SmrtJunction, SmrtObject, SmrtPolymorphicAssociation, TenantIsolationError, ValidationError, ValidationReport, ValidationUtils, assertPostgresSystemTimestampsCurrent, classifyDatabaseError, classifyDialectMessage, clearRetentionTasks, config, convertTypeToJsonSchema, ensureBootstrapSystemTableCompatibility, ensureDeferredSystemTableCompatibility, ensureDispatchSubscriptionsSystemTableCompatibility, ensureDispatchSystemTableCompatibility, ensureJobEventsSystemTableCompatibility, ensureJobsSystemTableCompatibility, ensureLegacySystemTableCompatibility, ensureSystemTables, estimateAiUsageCost, executeToolCall, executeToolCalls, formatToolResults, generateToolFromMethod, generateToolManifest, getDatabaseEngine, getRetentionTasks, isAbortedTransactionError, isDeterministicDatabaseError, isFrameworkBaseClass, isNotNullViolationError, isSmrtCollectionExtendsName, isTransientDatabaseError, isUniqueViolationError, migratePostgresSystemTimestamps, planPostgresSystemTimestampMigrations, pruneAiUsage, pruneExpiredContexts, registerRetentionTask, runRetentionSweep, shouldIncludeMethod, smrt, smrt as smrtRegistry, tableExists, unregisterRetentionTask, validateToolCall };
30
+ export { AIError, AiUsageCollector, AiUsagePersistenceHandler, BOOTED_PROVENANCE, ConfigurationError, DEFAULT_AI_COST_RATES, DEFAULT_FACET_LIMIT, DEFAULT_RETENTION_POLICY, DIAGNOSTICS_DEFAULT_LIMIT, DatabaseError, ErrorUtils, FilesystemError, MAX_FACET_FIELDS, MAX_FACET_LIMIT, MAX_STI_READ_SCOPE_TYPES, MetricsAdapter, NetworkError, ObjectRegistry, PubSubAdapter, RuntimeError, SMRT_COLLECTION_BASE_NAMES, SYSTEM_DIAGNOSTICS_TABLES, SignalBus, SignalSanitizer, SmrtClass, SmrtCollection, SmrtError, SmrtHierarchical, SmrtJunction, SmrtObject, SmrtPolymorphicAssociation, TenantIsolationError, ValidationError, ValidationReport, ValidationUtils, assertPlainJson, assertPostgresSystemTimestampsCurrent, classifyDatabaseError, classifyDialectMessage, clearRetentionTasks, config, convertTypeToJsonSchema, ensureBootstrapSystemTableCompatibility, ensureDeferredSystemTableCompatibility, ensureDispatchSubscriptionsSystemTableCompatibility, ensureDispatchSystemTableCompatibility, ensureJobEventsSystemTableCompatibility, ensureJobsSystemTableCompatibility, ensureLegacySystemTableCompatibility, ensureSystemTables, estimateAiUsageCost, executeToolCall, executeToolCalls, formatToolResults, generateToolFromMethod, generateToolManifest, getDatabaseEngine, getRetentionTasks, isAbortedTransactionError, isDeterministicDatabaseError, isFrameworkBaseClass, isNotNullViolationError, isSmrtCollectionExtendsName, isTransientDatabaseError, isUniqueViolationError, migratePostgresSystemTimestamps, planPostgresSystemTimestampMigrations, pruneAiUsage, pruneExpiredContexts, readDispatchHealth, readJobHealth, readMigrationStatus, readRecentChanges, readRegistryDrift, readScheduleHealth, readSystemDiagnostics, registerRetentionTask, runRetentionSweep, sanitizeMessagePaths, shouldIncludeMethod, smrt, smrt as smrtRegistry, snapshotRegistry, tableExists, unregisterRetentionTask, validateToolCall };
@@ -66,6 +66,14 @@ export interface GetChangesOptions {
66
66
  * resync before resuming from {@link ChangeFeedPage.resyncCursor}.
67
67
  */
68
68
  since: number;
69
+ /**
70
+ * Whether to sequence staged entries before reading (default `true`). On
71
+ * PostgreSQL that drain writes through `_smrt_drain_changes()`; a
72
+ * diagnostics reader that must stay SELECT-only passes `false` and
73
+ * accepts that entries still staged by an open caller transaction remain
74
+ * invisible until a writer drains them.
75
+ */
76
+ drain?: boolean;
69
77
  /** Restrict to these physical table names. Empty/omitted → all tables. */
70
78
  tables?: string[];
71
79
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"change-feed.d.ts","sourceRoot":"","sources":["../src/change-feed.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkIG;AAGH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,C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O,CAAC,MAAM,CAAC,CA8CjB;AA4BD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAsB,eAAe,CACnC,EAAE,EAAE,iBAAiB,EACrB,SAAS,EAAE,mBAAmB,GAC7B,OAAO,CAAC;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC,CAyF7B;AA4BD,eAAO,MAAM,6BAA6B,gCAAgC,CAAC;AAW3E;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,wBAAwB,IAAI,IAAI,CAwC/C;AAED,uDAAuD;AACvD,wBAAgB,0BAA0B,IAAI,OAAO,CAEpD;AAiED,gFAAgF;AAChF,wBAAsB,oBAAoB,CACxC,QAAQ,EAAE,UAAU,EACpB,SAAS,GAAE,eAA0B,GACpC,OAAO,CAAC,IAAI,CAAC,CAEf;AA8DD;;GAEG;AACH,wBAAgB,uBAAuB,IAAI,IAAI,CAS9C"}
@@ -779,7 +779,7 @@ async function getChangesSince(db, options) {
779
779
  const { since } = options;
780
780
  if (!Number.isFinite(since) || since < 0) throw new Error(`getChangesSince requires a non-negative numeric cursor, got '${String(since)}'`);
781
781
  const limit = Math.min(Math.max(Math.floor(options.limit ?? 500), 1), MAX_CHANGES_LIMIT);
782
- await drainChangeFeedBestEffort(db);
782
+ if (options.drain !== false) await drainChangeFeedBestEffort(db);
783
783
  const p = placeholders(db);
784
784
  const boundsRows = getQueryRows(await db.query(getEngine(db) === "postgres" ? `SELECT MIN(seq) AS floor, MAX(seq) AS horizon, pg_current_xact_id_if_assigned() IS NOT NULL AS in_transaction FROM ${CHANGE_FEED_TABLE}` : `SELECT MIN(seq) AS floor, MAX(seq) AS horizon FROM ${CHANGE_FEED_TABLE}`));
785
785
  const floor = toSeqNumber(boundsRows[0]?.floor);