@happyvertical/smrt-core 0.46.0 → 0.47.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +39 -0
- package/agents/generators.md +19 -5
- package/agents/system-diagnostics.md +43 -0
- package/dist/browser.js +2 -1
- package/dist/change-feed.d.ts +8 -0
- package/dist/change-feed.d.ts.map +1 -1
- package/dist/change-feed.js +1 -1
- package/dist/change-feed.js.map +1 -1
- package/dist/decorators/compatibility.d.ts +46 -0
- package/dist/decorators/compatibility.d.ts.map +1 -1
- package/dist/decorators/compatibility.js +48 -5
- package/dist/decorators/compatibility.js.map +1 -1
- package/dist/decorators/index.d.ts +119 -1
- package/dist/decorators/index.d.ts.map +1 -1
- package/dist/decorators/index.js +52 -8
- package/dist/decorators/index.js.map +1 -1
- package/dist/generators/custom-action.d.ts +379 -2
- package/dist/generators/custom-action.d.ts.map +1 -1
- package/dist/generators/custom-action.js +694 -17
- package/dist/generators/custom-action.js.map +1 -1
- package/dist/generators/index.d.ts +1 -1
- package/dist/generators/index.d.ts.map +1 -1
- package/dist/generators/index.js +2 -2
- package/dist/generators/preflight-route.d.ts +12 -10
- package/dist/generators/preflight-route.d.ts.map +1 -1
- package/dist/generators/preflight-route.js +46 -14
- package/dist/generators/preflight-route.js.map +1 -1
- package/dist/generators/rest.d.ts +44 -0
- package/dist/generators/rest.d.ts.map +1 -1
- package/dist/generators/rest.js +84 -9
- package/dist/generators/rest.js.map +1 -1
- package/dist/generators.js +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -4
- package/dist/knowledge.d.ts.map +1 -1
- package/dist/knowledge.js +59 -15
- package/dist/knowledge.js.map +1 -1
- package/dist/manifest/static-manifest.d.ts.map +1 -1
- package/dist/manifest/static-manifest.js +125 -53
- package/dist/manifest/static-manifest.js.map +1 -1
- package/dist/manifest/store.js +1 -1
- package/dist/manifest/store.js.map +1 -1
- package/dist/manifest.json +184 -53
- package/dist/postgres-permissions.d.ts +9 -1
- package/dist/postgres-permissions.d.ts.map +1 -1
- package/dist/postgres-permissions.js +127 -13
- package/dist/postgres-permissions.js.map +1 -1
- package/dist/registry/index.d.ts +1 -1
- package/dist/registry/index.d.ts.map +1 -1
- package/dist/registry/shared-state.d.ts +19 -0
- package/dist/registry/shared-state.d.ts.map +1 -1
- package/dist/registry/shared-state.js +16 -1
- package/dist/registry/shared-state.js.map +1 -1
- package/dist/registry.d.ts +136 -1
- package/dist/registry.d.ts.map +1 -1
- package/dist/registry.js +231 -1
- package/dist/registry.js.map +1 -1
- package/dist/scanner/manifest-generator.d.ts.map +1 -1
- package/dist/scanner/manifest-generator.js +18 -16
- package/dist/scanner/manifest-generator.js.map +1 -1
- package/dist/scanner/types.d.ts +59 -6
- package/dist/scanner/types.d.ts.map +1 -1
- package/dist/scanner/types.js.map +1 -1
- package/dist/smrt-knowledge.json +42 -35
- package/dist/system/diagnostics.d.ts +299 -0
- package/dist/system/diagnostics.d.ts.map +1 -0
- package/dist/system/diagnostics.js +530 -0
- package/dist/system/diagnostics.js.map +1 -0
- package/dist/system/index.d.ts +1 -0
- package/dist/system/index.d.ts.map +1 -1
- package/dist/system/index.js +2 -1
- package/dist/utils/scanner-module.d.ts +16 -0
- package/dist/utils/scanner-module.d.ts.map +1 -1
- package/dist/vite-plugin/api-client-entries.d.ts.map +1 -1
- package/dist/vite-plugin/api-client-entries.js +10 -8
- package/dist/vite-plugin/api-client-entries.js.map +1 -1
- package/dist/vite-plugin/index.d.ts +34 -1
- package/dist/vite-plugin/index.d.ts.map +1 -1
- package/dist/vite-plugin/index.js +82 -3
- package/dist/vite-plugin/index.js.map +1 -1
- package/dist/vite-plugin/sveltekit-generator.d.ts +28 -2
- package/dist/vite-plugin/sveltekit-generator.d.ts.map +1 -1
- package/dist/vite-plugin/sveltekit-generator.js +121 -51
- package/dist/vite-plugin/sveltekit-generator.js.map +1 -1
- package/dist/vite-plugin/web-collections.d.ts.map +1 -1
- package/dist/vite-plugin/web-collections.js +1 -1
- package/dist/vite-plugin/web-collections.js.map +1 -1
- package/dist/vite-plugin.js +2 -2
- package/package.json +16 -11
package/AGENTS.md
CHANGED
|
@@ -20,6 +20,7 @@ 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) |
|
|
23
24
|
|
|
24
25
|
## Cross-module invariants
|
|
25
26
|
|
|
@@ -53,6 +54,44 @@ and repository rules.
|
|
|
53
54
|
constructor, explicit package, and isolated one-object manifest. Never infer
|
|
54
55
|
ownership from paths, simple names, or table names; packages can share names.
|
|
55
56
|
Consumer regression gate: `packages/bundle-gate/src/__tests__/registry-identity.spec.ts`.
|
|
57
|
+
- API custom-action eligibility has ONE resolver, `resolveApiMethodExposure()`
|
|
58
|
+
in `generators/custom-action.ts`: both SvelteKit route emitters,
|
|
59
|
+
`resolveApiActionSet`, and `knowledge.ts` read it, and a new consumer must too
|
|
60
|
+
— a local mirror is how a method gets reported unavailable while its route
|
|
61
|
+
file is still written. A public method routes by default only when every
|
|
62
|
+
parameter is JSON-shaped; `@method({ expose })` overrides in both directions,
|
|
63
|
+
`expose: true` bypasses the heuristic ALONE, and an explicit `api.include` or
|
|
64
|
+
`api.routes` entry keeps its pre-#2686 route. Fail closed on scanner
|
|
65
|
+
uncertainty: read `parameters[].typeUnresolved`, never the `'any'` it
|
|
66
|
+
substitutes. Accepting `Date` as wire-able and hydrating it
|
|
67
|
+
(`toCustomActionDate`) are one decision — changing either breaks the other.
|
|
68
|
+
The runtime `APIGenerator` transport stays declaration-gated: `rest.ts`
|
|
69
|
+
dispatch and `preflight-route.ts` prediction both read
|
|
70
|
+
`declaresRuntimeRestRoute()`, which must accept every `ApiCustomRouteConfig`
|
|
71
|
+
option so a sweep moving one onto its method cannot delete the endpoint. Its
|
|
72
|
+
twin `declaresRuntimeRestRouteShape()` deliberately ignores `expose: false`:
|
|
73
|
+
the dispatcher must still SEE a withheld declaration to answer 404, because
|
|
74
|
+
`POST /<collection>/<segment>` resolves to `create` when nothing claims the
|
|
75
|
+
segment. Split unions and type arguments with `splitTopLevel()` — a naive
|
|
76
|
+
`split('|')` truncates `Record<string, Asset | null>` into fragments that
|
|
77
|
+
match no rule and are then accepted, widening the gate. `extractTypeName`
|
|
78
|
+
returns `null` for a generic with an unresolvable ARGUMENT or a union with an
|
|
79
|
+
unresolvable BRANCH so those reach that fail-closed path instead of arriving
|
|
80
|
+
as a bare `'Array'`. Runtime transports read
|
|
81
|
+
`ObjectRegistry.resolveRuntimeMethod()`, which tries the item class's manifest
|
|
82
|
+
entry, then the COLLECTION class's (where a collection-hosted action's
|
|
83
|
+
parameters live), then the live `@method()` store — keyed by CONSTRUCTOR,
|
|
84
|
+
never by simple name (`Account` exists in two packages), and recording
|
|
85
|
+
`isStatic` because an unscanned runtime has no manifest to recover the
|
|
86
|
+
receiver from. `isRestActionRoutable` ANDs "declared" with that receiver, so
|
|
87
|
+
it never predicts `allow` for an action dispatch refuses. A declared action
|
|
88
|
+
with no receiver is refused (501 collection-scoped, 404 item-scoped), never
|
|
89
|
+
allowed to fall through into `create`. All eight consumers read the resolver,
|
|
90
|
+
including `packages/smrt-workbench/src/discovery.ts`; it imports the
|
|
91
|
+
`./generators/custom-action` LEAF subpath, not `./generators`, because that
|
|
92
|
+
barrel value-re-exports `MCPGenerator` and so drags `@happyvertical/ai` and
|
|
93
|
+
`@happyvertical/sql` into a build-time helper (2 modules vs 109). Keep
|
|
94
|
+
`custom-action.ts` free of value imports outside `tools/tool-generator`.
|
|
56
95
|
|
|
57
96
|
## Gotchas
|
|
58
97
|
|
package/agents/generators.md
CHANGED
|
@@ -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`
|
|
161
|
-
arrives as a *diagnostic* rather than two
|
|
162
|
-
dropped the loser — so that diagnostic
|
|
163
|
-
the not-static warning; otherwise the
|
|
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,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
|
@@ -22,7 +22,8 @@ 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";
|
|
25
26
|
import { DEFAULT_RETENTION_POLICY, clearRetentionTasks, getRetentionTasks, pruneAiUsage, pruneExpiredContexts, registerRetentionTask, runRetentionSweep, unregisterRetentionTask } from "./system/retention.js";
|
|
26
27
|
import "./system/index.js";
|
|
27
28
|
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 };
|
|
29
|
+
export { AIError, AiUsageCollector, AiUsagePersistenceHandler, 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, 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, shouldIncludeMethod, smrt, smrt as smrtRegistry, tableExists, unregisterRetentionTask, validateToolCall };
|
package/dist/change-feed.d.ts
CHANGED
|
@@ -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/om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CAEf;AA8DD;;GAEG;AACH,wBAAgB,uBAAuB,IAAI,IAAI,CAS9C"}
|
package/dist/change-feed.js
CHANGED
|
@@ -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);
|