@spine-event-engine/storage-postgres 2.0.0-snapshot.23 → 2.0.0-snapshot.25
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/README.md +34 -16
- package/REFERENCE.md +66 -26
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/postgres/agent-history.d.ts +60 -18
- package/dist/postgres/agent-history.d.ts.map +1 -1
- package/dist/postgres/agent-history.js +114 -37
- package/dist/postgres/agent-history.js.map +1 -1
- package/dist/postgres/column-mapping.d.ts.map +1 -1
- package/dist/postgres/column-mapping.js +6 -3
- package/dist/postgres/column-mapping.js.map +1 -1
- package/dist/postgres/entity-commit.d.ts +90 -56
- package/dist/postgres/entity-commit.d.ts.map +1 -1
- package/dist/postgres/entity-commit.js +439 -188
- package/dist/postgres/entity-commit.js.map +1 -1
- package/dist/postgres/entity-history.d.ts +4 -2
- package/dist/postgres/entity-history.d.ts.map +1 -1
- package/dist/postgres/entity-history.js +163 -262
- package/dist/postgres/entity-history.js.map +1 -1
- package/dist/postgres/errors.d.ts +1 -1
- package/dist/postgres/errors.d.ts.map +1 -1
- package/dist/postgres/errors.js +5 -3
- package/dist/postgres/errors.js.map +1 -1
- package/dist/postgres/id-column.d.ts.map +1 -1
- package/dist/postgres/id-column.js +6 -3
- package/dist/postgres/id-column.js.map +1 -1
- package/dist/postgres/record-storage.d.ts +228 -117
- package/dist/postgres/record-storage.d.ts.map +1 -1
- package/dist/postgres/record-storage.js +350 -204
- package/dist/postgres/record-storage.js.map +1 -1
- package/dist/postgres/storage-factory.d.ts +267 -30
- package/dist/postgres/storage-factory.d.ts.map +1 -1
- package/dist/postgres/storage-factory.js +786 -145
- package/dist/postgres/storage-factory.js.map +1 -1
- package/dist/postgres/table-initializer.d.ts +7 -4
- package/dist/postgres/table-initializer.d.ts.map +1 -1
- package/dist/postgres/table-initializer.js +21 -15
- package/dist/postgres/table-initializer.js.map +1 -1
- package/dist/postgres/table-resolver.d.ts +15 -1
- package/dist/postgres/table-resolver.d.ts.map +1 -1
- package/dist/postgres/table-resolver.js +36 -7
- package/dist/postgres/table-resolver.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -5
- package/dist/postgres/agent-execution.d.ts +0 -284
- package/dist/postgres/agent-execution.d.ts.map +0 -1
- package/dist/postgres/agent-execution.js +0 -648
- package/dist/postgres/agent-execution.js.map +0 -1
- package/dist/postgres/delivery-cleanup.d.ts +0 -76
- package/dist/postgres/delivery-cleanup.d.ts.map +0 -1
- package/dist/postgres/delivery-cleanup.js +0 -224
- package/dist/postgres/delivery-cleanup.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
# PostgreSQL storage for Spine TS
|
|
2
2
|
|
|
3
|
+
See [storage layout and database preparation](https://github.com/SpineEventEngine/spine-ts/blob/master/docs/STORAGE_LAYOUT.md) for
|
|
4
|
+
physical structures, tenant placement, prerequisites, and customization.
|
|
5
|
+
|
|
3
6
|
`@spine-event-engine/storage-postgres` stores Spine TS records in PostgreSQL.
|
|
4
7
|
It is a separate provider package; the existing `storage-mysql` package remains
|
|
5
8
|
the MySQL provider. PostgreSQL support currently targets PostgreSQL 16 or newer,
|
|
@@ -8,9 +11,10 @@ with live acceptance recorded against PostgreSQL 16.15 and 18.6.
|
|
|
8
11
|
This is an experimental snapshot package. Use Node 24 or newer. For the precise
|
|
9
12
|
public API and operational rules, see the [coding-agent reference](REFERENCE.md).
|
|
10
13
|
|
|
11
|
-
Agent repositories can use this factory to retain
|
|
12
|
-
history across restarts.
|
|
13
|
-
|
|
14
|
+
Agent repositories can use this factory to retain state, typed admission receipts,
|
|
15
|
+
and conversation history across restarts. An interrupted Agent handler does not
|
|
16
|
+
restart from those records. Atomic live Agent commits save accepted state and
|
|
17
|
+
audit together; a model call does not keep a database transaction open.
|
|
14
18
|
|
|
15
19
|
## Install
|
|
16
20
|
|
|
@@ -47,31 +51,45 @@ try {
|
|
|
47
51
|
if (stored?.value !== "task-42") throw new Error("The record was not stored.");
|
|
48
52
|
} finally {
|
|
49
53
|
records.close();
|
|
50
|
-
factory.close();
|
|
54
|
+
await factory.close();
|
|
51
55
|
}
|
|
52
56
|
```
|
|
53
57
|
|
|
54
58
|
The URL must include a database name. Use `postgres:` or `postgresql:` URLs;
|
|
55
59
|
credentials should come from the deployment environment. TLS options, pool
|
|
56
60
|
limits, connection timeout, and an explicit schema are configured through the
|
|
57
|
-
factory options.
|
|
58
|
-
`
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
61
|
+
factory options. Building the factory and creating a record handle do not open
|
|
62
|
+
a connection. Call `await factory.checkConnection()` for a read-only check of
|
|
63
|
+
the shared database; it opens and closes a temporary pool unless normal storage
|
|
64
|
+
use already opened one. When no schema is supplied, the first awaited use
|
|
65
|
+
resolves the server's `current_schema()` and retains that schema for later use.
|
|
66
|
+
|
|
67
|
+
For multitenancy, set the shared database with `setOptions()` and select tenant
|
|
68
|
+
databases with `setTenantOptions()` or `setTenantResolver()`. The resolver may be
|
|
69
|
+
asynchronous and is called only on first use of a tenant. Distinct tenants must
|
|
70
|
+
resolve to distinct databases; a schema is not a substitute for that boundary.
|
|
71
|
+
The shared database may coincide with a tenant database only when their record
|
|
72
|
+
families do not map to the same physical table.
|
|
63
73
|
|
|
64
74
|
## Lifecycle and operations
|
|
65
75
|
|
|
66
76
|
Tables are initialized lazily and checked against the expected PostgreSQL
|
|
67
|
-
layout.
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
77
|
+
layout. Provider integrations can prepare declared record, Entity current and
|
|
78
|
+
enabled history, and Agent audit families through
|
|
79
|
+
`StoragePreparations.for(factory)`. Creation verifies the resulting layout;
|
|
80
|
+
check mode only inspects existing tables and audit indexes, and a compatible
|
|
81
|
+
check avoids later creation SQL for the same family. Explicit preparation uses
|
|
82
|
+
and releases a temporary pool when no runtime pool exists; otherwise it reuses
|
|
83
|
+
the retained runtime pool. Each acquired
|
|
84
|
+
client is released; history maintenance applies deletion
|
|
85
|
+
pages independently. Await `factory.close()` when the application stops; it is
|
|
86
|
+
idempotent, drains admitted work and pools, and reports cleanup failures. A
|
|
87
|
+
closed factory cannot create new handles or check a connection.
|
|
71
88
|
|
|
72
89
|
The provider supports record CRUD, compare-and-set, immutable append, Entity
|
|
73
|
-
state and event history,
|
|
74
|
-
|
|
90
|
+
state and event history, declared-column filtering, sorting, limits, offsets,
|
|
91
|
+
and continuations through the common storage API. Eligible Inbox cleanup deletes
|
|
92
|
+
the message ID directly through record storage. It uses
|
|
75
93
|
PostgreSQL `BYTEA`, parameterized `$1`-style values, and PostgreSQL's configured
|
|
76
94
|
text collation. Collation ordering can differ from JavaScript ordering, so
|
|
77
95
|
applications should choose and document their database collation deliberately.
|
package/REFERENCE.md
CHANGED
|
@@ -6,7 +6,7 @@ agents.
|
|
|
6
6
|
## Public entry point
|
|
7
7
|
|
|
8
8
|
Import `PostgresStorageFactory`, `PostgresStorageFactoryBuilder`,
|
|
9
|
-
`PostgresStorageFactoryOptions`, `PostgresTenantStorageOptions`,
|
|
9
|
+
`PostgresStorageFactoryOptions`, `PostgresTenantStorageOptions`, `PostgresTenantResolver`,
|
|
10
10
|
`PostgresEntityStorageHandle`, `PostgresTableSpec`,
|
|
11
11
|
`PostgresCreateOperation`, `PostgresCreateOperationFactory`, and
|
|
12
12
|
`PostgresColumnSpec` from the package root. Provider errors are
|
|
@@ -16,19 +16,37 @@ Import `PostgresStorageFactory`, `PostgresStorageFactoryBuilder`,
|
|
|
16
16
|
|
|
17
17
|
## Configuration
|
|
18
18
|
|
|
19
|
-
`PostgresStorageFactory.newBuilder().setOptions(options).build()`
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
`PostgresStorageFactory.newBuilder().setOptions(options).build()` assembles a
|
|
20
|
+
logical factory without connecting. Shared `setOptions()` is required;
|
|
21
|
+
`setTenantOptions(entries)` or `setTenantResolver(resolver)` additionally selects
|
|
22
|
+
one database per complete generated `TenantId`. The two tenant selection modes
|
|
23
|
+
cannot be combined. A resolver may return options asynchronously; concurrent
|
|
24
|
+
first uses of one tenant share resolution, failed attempts may retry, and a
|
|
25
|
+
successful binding stays fixed for this factory. Options include a
|
|
23
26
|
PostgreSQL URL, pool maximum, connection timeout, TLS CA/certificate/key,
|
|
24
27
|
server-certificate verification, and optional schema name. URLs must include a
|
|
25
28
|
database and cannot bypass the explicit options model with fragments or driver
|
|
26
|
-
parameters.
|
|
27
|
-
|
|
29
|
+
parameters. `checkConnection()` checks only the shared destination using
|
|
30
|
+
read-only SQL; it does not resolve tenants, create tables, or check a model.
|
|
31
|
+
Provider integrations can use `StoragePreparations.for(factory)` to create or
|
|
32
|
+
check a declared Record, Entity current/enabled history, or surviving Agent
|
|
33
|
+
audit family. Check mode inspects the selected tenant's actual schema, table,
|
|
34
|
+
and required audit indexes without DDL or custom creation SQL. A successful
|
|
35
|
+
compatible preparation is reused by later handles and operations in this
|
|
36
|
+
factory. Explicit preparation uses and releases a temporary pool when no runtime
|
|
37
|
+
pool exists; otherwise it reuses the retained runtime pool. Failed requirements
|
|
38
|
+
can be retried without discarding
|
|
39
|
+
earlier compatible families.
|
|
40
|
+
|
|
41
|
+
The default shared registry converts message-valued IDs and columns using
|
|
42
|
+
generated descriptors registered on module import. A registry supplied with
|
|
43
|
+
`setStringifierRegistry(registry)` is snapshotted at factory construction.
|
|
44
|
+
`setEventStoreTable(contextName, table, role?)` selects one physical Event Store
|
|
45
|
+
table for the exact bounded-context name and domain or system role.
|
|
28
46
|
|
|
29
47
|
PostgreSQL creates tables but not databases or schemas. A missing schema is a
|
|
30
|
-
configuration error. Without an explicit schema, `current_schema()`
|
|
31
|
-
|
|
48
|
+
configuration error on `checkConnection()` or first use. Without an explicit schema, `current_schema()`
|
|
49
|
+
is resolved from the server on first use and the validated result qualifies every
|
|
32
50
|
table and metadata statement.
|
|
33
51
|
|
|
34
52
|
## Physical layout and queries
|
|
@@ -42,7 +60,7 @@ altered. Missing, extra, or incompatible columns, defaults, nullability,
|
|
|
42
60
|
primary keys, or unique constraints reject with `PostgresStorageSchemaError`.
|
|
43
61
|
|
|
44
62
|
The adapter uses `$1` parameters, `IS NOT DISTINCT FROM`, PostgreSQL upsert,
|
|
45
|
-
|
|
63
|
+
independent bounded history maintenance pages, and a normalized query plan. It preserves
|
|
46
64
|
the common 1,000-bind plan budget and 10,000-row default with one
|
|
47
65
|
overflow lookahead row. The database collation controls text ordering; the
|
|
48
66
|
provider does not invent a JavaScript-compatible collation.
|
|
@@ -60,6 +78,26 @@ plain, non-reserved ASCII identifiers only. Reserved and quoted-required names
|
|
|
60
78
|
preserve their spelling; all names reject NUL, unsafe values, 63-byte overflow,
|
|
61
79
|
and collisions before DDL, DML, or catalog inspection.
|
|
62
80
|
|
|
81
|
+
## Entity commit behavior
|
|
82
|
+
|
|
83
|
+
The provider captures and validates one Entity commit input before database I/O,
|
|
84
|
+
then prepares its record families. It writes state history, diagnostic Events,
|
|
85
|
+
canonical delivery Events, and finally the current state as ordered independent
|
|
86
|
+
records. A later failure leaves the completed prefix in place; an Event row
|
|
87
|
+
alone does not prove that the current state was written. Concurrent commits can
|
|
88
|
+
interleave, including their current-state writes. This is not one SQL
|
|
89
|
+
transaction across the four families.
|
|
90
|
+
|
|
91
|
+
After preparation succeeds, a PostgreSQL deadlock (`40P01`) or serialization
|
|
92
|
+
failure (`40001`) during the ordered record writes triggers one replay of the
|
|
93
|
+
captured input. A failure during preparation is not retried. Commit does not
|
|
94
|
+
rerun the handler or create new
|
|
95
|
+
versions or Event IDs. An immutable retry accepts an existing row only when its
|
|
96
|
+
wire bytes match; the same ID with different bytes is a collision. A caller
|
|
97
|
+
retry must likewise reuse the original versions and Event IDs. See the
|
|
98
|
+
[shared storage contract](../storage/REFERENCE.md) for the provider SPI and
|
|
99
|
+
cross-provider limits.
|
|
100
|
+
|
|
63
101
|
## Agent history
|
|
64
102
|
|
|
65
103
|
The provider-only Agent history handle stores `AgentHistoryRecord` in one
|
|
@@ -76,26 +114,28 @@ B-tree entry limits still apply to exceptionally long record IDs. Pages use
|
|
|
76
114
|
bounded SQL chunks and sum serialized entry bytes; a fetched chunk can be
|
|
77
115
|
larger than the returned byte budget.
|
|
78
116
|
|
|
79
|
-
## Agent
|
|
80
|
-
|
|
81
|
-
Agent execution records and per-instance pending entries are stored in separate
|
|
82
|
-
tenant database tables. Indexed queries select the next eligible instance and
|
|
83
|
-
the first unresolved signal within it. Required B-tree indexes use complete
|
|
84
|
-
binary-comparable ordering keys and are checked before admission.
|
|
117
|
+
## Agent live persistence
|
|
85
118
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
119
|
+
Agent audit entries use the indexed tenant-scoped `agent_history` family above.
|
|
120
|
+
`appendAll()` writes the complete immutable group in one PostgreSQL transaction.
|
|
121
|
+
Live Agent completion uses `EntityCommitStorage.commitAgent()` to compare the
|
|
122
|
+
exact Entity state image and model preferences, and to commit state, preference,
|
|
123
|
+
and history changes atomically. A no-op or preference-only turn does not need a
|
|
124
|
+
new Entity Version. The typed admission receipt is a separate record family;
|
|
125
|
+
it is not a replayable execution record. No database transaction remains open
|
|
126
|
+
while a model request runs. Factory shutdown drains admitted operations before
|
|
127
|
+
closing their retained connections.
|
|
91
128
|
|
|
92
129
|
## Lifecycle and errors
|
|
93
130
|
|
|
94
|
-
`factory.close()`
|
|
95
|
-
creation,
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
131
|
+
Await `factory.close()` to observe cleanup failures. It synchronously prevents new handle
|
|
132
|
+
creation, waits for admitted Entity commits, then closes registered handles and pools.
|
|
133
|
+
Repeated calls return the same completion. Record and Entity handles can close independently.
|
|
134
|
+
Acquired clients are released in `finally` blocks. History maintenance applies
|
|
135
|
+
each deletion page independently. Top-level provider error messages and public
|
|
136
|
+
responses omit URLs, credentials, SQL text, and driver details. The original
|
|
137
|
+
driver failure remains available as the internal `cause`; do not expose it in
|
|
138
|
+
public responses or unfiltered logs.
|
|
99
139
|
|
|
100
140
|
Custom table creation may use `useOperationFactory(factory)` with the exported
|
|
101
141
|
`PostgresTableSpec`, `PostgresCreateOperation`, and
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { PostgresStorageFactory, type PostgresCreateOperation, type PostgresCreateOperationFactory, type PostgresColumnSpec, type PostgresStorageFactoryBuilder, type PostgresStorageFactoryOptions, type PostgresTableSpec, type PostgresTenantStorageOptions, } from "./postgres/storage-factory.js";
|
|
1
|
+
export { PostgresStorageFactory, type PostgresCreateOperation, type PostgresCreateOperationFactory, type PostgresColumnSpec, type PostgresStorageFactoryBuilder, type PostgresStorageFactoryOptions, type PostgresTableSpec, type PostgresTenantStorageOptions, type PostgresTenantResolver, } from "./postgres/storage-factory.js";
|
|
2
2
|
export type { PostgresDdlType } from "./postgres/data-type.js";
|
|
3
3
|
export { PostgresStorageConfigurationError, PostgresStorageConnectionError, PostgresStorageDataError, PostgresStorageOperationError, PostgresStorageSchemaError, } from "./postgres/errors.js";
|
|
4
4
|
export type { PostgresEntityStorageHandle } from "./postgres/entity-history.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAcA,OAAO,EACL,sBAAsB,EACtB,KAAK,uBAAuB,EAC5B,KAAK,8BAA8B,EACnC,KAAK,kBAAkB,EACvB,KAAK,6BAA6B,EAClC,KAAK,6BAA6B,EAClC,KAAK,iBAAiB,EACtB,KAAK,4BAA4B,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAcA,OAAO,EACL,sBAAsB,EACtB,KAAK,uBAAuB,EAC5B,KAAK,8BAA8B,EACnC,KAAK,kBAAkB,EACvB,KAAK,6BAA6B,EAClC,KAAK,6BAA6B,EAClC,KAAK,iBAAiB,EACtB,KAAK,4BAA4B,EACjC,KAAK,sBAAsB,GAC5B,MAAM,+BAA+B,CAAC;AAEvC,YAAY,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE/D,OAAO,EACL,iCAAiC,EACjC,8BAA8B,EAC9B,wBAAwB,EACxB,6BAA6B,EAC7B,0BAA0B,GAC3B,MAAM,sBAAsB,CAAC;AAE9B,YAAY,EAAE,2BAA2B,EAAE,MAAM,8BAA8B,CAAC"}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EACL,sBAAsB,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EACL,sBAAsB,GASvB,MAAM,+BAA+B,CAAC;AAIvC,OAAO,EACL,iCAAiC,EACjC,8BAA8B,EAC9B,wBAAwB,EACxB,6BAA6B,EAC7B,0BAA0B,GAC3B,MAAM,sBAAsB,CAAC"}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import type { AgentHistoryEntry } from "@spine-event-engine/proto/agent";
|
|
2
|
-
import type
|
|
3
|
-
import { type AgentHistoryPage, type AgentHistoryRead, type AgentHistoryStorage, type AgentHistoryStorageInput } from "@spine-event-engine/storage/provider";
|
|
4
|
-
import {
|
|
2
|
+
import { type AgentHistoryRecord } from "@spine-event-engine/proto/generated/spine/server/agent/history_record_pb.js";
|
|
3
|
+
import { type AgentHistoryPage, type AgentHistoryCapacity, type AgentHistoryRead, type AgentHistoryStorage, type AgentHistoryStorageInput } from "@spine-event-engine/storage/provider";
|
|
4
|
+
import type { StoragePreparationMode } from "@spine-event-engine/storage/provider";
|
|
5
|
+
import type { PoolClient } from "pg";
|
|
6
|
+
import { PostgresRecordStorage, type OnPublicOperation } from "./record-storage.js";
|
|
5
7
|
/**
|
|
6
8
|
* Hashes complete identities into bounded physical IDs and indexed scope keys.
|
|
7
9
|
*/
|
|
@@ -23,13 +25,21 @@ export declare class PostgresAgentHistory<Id> implements AgentHistoryStorage<Id>
|
|
|
23
25
|
#private;
|
|
24
26
|
private readonly input;
|
|
25
27
|
private readonly records;
|
|
28
|
+
private readonly onAdmit;
|
|
29
|
+
private readonly onPrepare?;
|
|
30
|
+
/**
|
|
31
|
+
* Native PostgreSQL Agent history capacity declaration.
|
|
32
|
+
*/
|
|
33
|
+
readonly capacity: AgentHistoryCapacity;
|
|
26
34
|
/**
|
|
27
35
|
* Binds one typed Agent repository to the provider record handle.
|
|
28
36
|
*
|
|
29
37
|
* @param input Repository and complete tenant scope.
|
|
30
38
|
* @param records Native record-family storage.
|
|
39
|
+
* @param onAdmit Admits complete public Agent-history operations.
|
|
40
|
+
* @param onPrepare Optionally uses factory-shared index readiness.
|
|
31
41
|
*/
|
|
32
|
-
constructor(input: AgentHistoryStorageInput<Id>, records: PostgresRecordStorage<string, AgentHistoryRecord>);
|
|
42
|
+
constructor(input: AgentHistoryStorageInput<Id>, records: PostgresRecordStorage<string, AgentHistoryRecord>, onAdmit: OnPublicOperation, onPrepare?: ((mode: StoragePreparationMode) => Promise<void>) | undefined);
|
|
33
43
|
/**
|
|
34
44
|
* Writes one original entry or confirms byte-identical content.
|
|
35
45
|
*
|
|
@@ -38,6 +48,21 @@ export declare class PostgresAgentHistory<Id> implements AgentHistoryStorage<Id>
|
|
|
38
48
|
* @returns Completion after immutable storage confirms the entry.
|
|
39
49
|
*/
|
|
40
50
|
append(entityId: Id, entry: AgentHistoryEntry): Promise<void>;
|
|
51
|
+
/**
|
|
52
|
+
* Writes atomically writes one captured immutable Agent audit group.
|
|
53
|
+
* @param entityId Typed Agent identifier.
|
|
54
|
+
* @param entries Complete history rows.
|
|
55
|
+
* @returns Completion after the group commits.
|
|
56
|
+
*/
|
|
57
|
+
appendAll(entityId: Id, entries: readonly AgentHistoryEntry[]): Promise<void>;
|
|
58
|
+
/**
|
|
59
|
+
* Writes an admitted immutable group on one rollback-capable transaction.
|
|
60
|
+
*
|
|
61
|
+
* @param entityId Typed Entity identifier.
|
|
62
|
+
* @param entries Complete immutable history group.
|
|
63
|
+
* @returns Completion after the complete immutable audit group commits atomically.
|
|
64
|
+
*/
|
|
65
|
+
private appendAllAdmitted;
|
|
41
66
|
/**
|
|
42
67
|
* Reads a bounded indexed page in full Timestamp/category/UTF-8 order.
|
|
43
68
|
*
|
|
@@ -46,9 +71,13 @@ export declare class PostgresAgentHistory<Id> implements AgentHistoryStorage<Id>
|
|
|
46
71
|
*/
|
|
47
72
|
read(request: AgentHistoryRead<Id>): Promise<AgentHistoryPage>;
|
|
48
73
|
/**
|
|
49
|
-
|
|
74
|
+
* Reads an admitted Agent-history page.
|
|
75
|
+
* @param request Typed Agent view and continuation limits.
|
|
76
|
+
* @returns Original entries and continuation status.
|
|
77
|
+
*/
|
|
78
|
+
private readAdmitted;
|
|
79
|
+
/**
|
|
50
80
|
* Closes this handle without deleting stored records.
|
|
51
|
-
|
|
52
81
|
*/
|
|
53
82
|
close(): void;
|
|
54
83
|
/**
|
|
@@ -63,16 +92,6 @@ export declare class PostgresAgentHistory<Id> implements AgentHistoryStorage<Id>
|
|
|
63
92
|
* @returns Completion after all three definitions are validated.
|
|
64
93
|
*/
|
|
65
94
|
private initialize;
|
|
66
|
-
/**
|
|
67
|
-
* Rejects an existing same-name index with incomplete columns or collation.
|
|
68
|
-
*
|
|
69
|
-
* @param client Acquired PostgreSQL client.
|
|
70
|
-
* @param table Validated physical table name.
|
|
71
|
-
* @param name Fixed required index name.
|
|
72
|
-
* @param columns Required complete binary-order columns.
|
|
73
|
-
* @returns Completion after the index definition is checked.
|
|
74
|
-
*/
|
|
75
|
-
private ensureIndex;
|
|
76
95
|
/**
|
|
77
96
|
* Reads a bounded native page with complete scope and view predicates.
|
|
78
97
|
*
|
|
@@ -105,10 +124,33 @@ export declare class PostgresAgentHistory<Id> implements AgentHistoryStorage<Id>
|
|
|
105
124
|
*/
|
|
106
125
|
private key;
|
|
107
126
|
/**
|
|
108
|
-
|
|
109
127
|
* Rejects calls after this handle closes.
|
|
110
|
-
|
|
111
128
|
*/
|
|
112
129
|
private requireOpen;
|
|
113
130
|
}
|
|
131
|
+
/**
|
|
132
|
+
* Verifies the fixed Agent audit indexes without changing a checked database.
|
|
133
|
+
*/
|
|
134
|
+
export declare const PostgresAgentIndexes: {
|
|
135
|
+
/**
|
|
136
|
+
* Prepares each required Agent audit index.
|
|
137
|
+
*
|
|
138
|
+
* @param client Acquired client.
|
|
139
|
+
* @param table Qualified audit table.
|
|
140
|
+
* @param mode Preparation mode.
|
|
141
|
+
* @returns Completion after all three indexes match.
|
|
142
|
+
*/
|
|
143
|
+
prepare(client: PoolClient, table: string, mode: StoragePreparationMode): Promise<void>;
|
|
144
|
+
/**
|
|
145
|
+
* Validates one fixed index and creates it only in create mode.
|
|
146
|
+
*
|
|
147
|
+
* @param client Acquired client.
|
|
148
|
+
* @param table Qualified audit table.
|
|
149
|
+
* @param name Fixed index name.
|
|
150
|
+
* @param columns Required columns.
|
|
151
|
+
* @param mode Preparation mode.
|
|
152
|
+
* @returns Completion after exact index validation.
|
|
153
|
+
*/
|
|
154
|
+
ensure(client: PoolClient, table: string, name: string, columns: string, mode: StoragePreparationMode): Promise<void>;
|
|
155
|
+
};
|
|
114
156
|
//# sourceMappingURL=agent-history.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-history.d.ts","sourceRoot":"","sources":["../../src/postgres/agent-history.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"agent-history.d.ts","sourceRoot":"","sources":["../../src/postgres/agent-history.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACzE,OAAO,EAEL,KAAK,kBAAkB,EACxB,MAAM,6EAA6E,C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;YACW,iBAAiB;IAiB/B;;;;;OAKG;IACH,IAAI,CAAC,OAAO,EAAE,gBAAgB,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAI9D;;;;OAIG;YACW,YAAY;IAY1B;;OAEG;IACH,KAAK,IAAI,IAAI;IAMb;;;;OAIG;IACH,OAAO,CAAC,KAAK;IAOb;;;;OAIG;YACW,UAAU;IAmBxB;;;;;;;;OAQG;YACW,KAAK;IAyBnB;;;;;;OAMG;IACH,OAAO,CAAC,aAAa;IAkBrB;;;;OAIG;IACH,OAAO,CAAC,YAAY;IAQpB;;;;;OAKG;IACH,OAAO,CAAC,GAAG;IAMX;;OAEG;IACH,OAAO,CAAC,WAAW;CAGpB;AAED;;GAEG;AACH,eAAO,MAAM,oBAAoB;IAC/B;;;;;;;OAOG;oBACmB,UAAU,SAAS,MAAM,QAAQ,sBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC;IAS7F;;;;;;;;;OASG;mBAEO,UAAU,SACX,MAAM,QACP,MAAM,WACH,MAAM,QACT,sBAAsB,GAC3B,OAAO,CAAC,IAAI,CAAC;CAwBjB,CAAC"}
|
|
@@ -12,9 +12,12 @@
|
|
|
12
12
|
* the License.
|
|
13
13
|
*/
|
|
14
14
|
import { createHash } from "node:crypto";
|
|
15
|
+
import { clone } from "@bufbuild/protobuf";
|
|
16
|
+
import { AgentHistoryRecordSchema, } from "@spine-event-engine/proto/generated/spine/server/agent/history_record_pb.js";
|
|
15
17
|
import { AgentHistoryKeys, AgentHistoryPages, } from "@spine-event-engine/storage/provider";
|
|
16
18
|
import { AgentHistoryRecords } from "@spine-event-engine/storage/provider";
|
|
17
19
|
import { PostgresRecordStorage } from "./record-storage.js";
|
|
20
|
+
import { PostgresStorageOperationError } from "./errors.js";
|
|
18
21
|
/**
|
|
19
22
|
* Hashes complete identities into bounded physical IDs and indexed scope keys.
|
|
20
23
|
*/
|
|
@@ -37,14 +40,18 @@ export const AgentHistoryHash = {
|
|
|
37
40
|
export class PostgresAgentHistory {
|
|
38
41
|
input;
|
|
39
42
|
records;
|
|
43
|
+
onAdmit;
|
|
44
|
+
onPrepare;
|
|
45
|
+
/**
|
|
46
|
+
* Native PostgreSQL Agent history capacity declaration.
|
|
47
|
+
*/
|
|
48
|
+
capacity = Object.freeze({});
|
|
40
49
|
/**
|
|
41
50
|
* Records whether this handle accepts calls.
|
|
42
51
|
*/
|
|
43
52
|
#open = true;
|
|
44
53
|
/**
|
|
45
|
-
|
|
46
54
|
* Reuses one table and index preparation promise.
|
|
47
|
-
|
|
48
55
|
*/
|
|
49
56
|
#ready;
|
|
50
57
|
/**
|
|
@@ -52,10 +59,14 @@ export class PostgresAgentHistory {
|
|
|
52
59
|
*
|
|
53
60
|
* @param input Repository and complete tenant scope.
|
|
54
61
|
* @param records Native record-family storage.
|
|
62
|
+
* @param onAdmit Admits complete public Agent-history operations.
|
|
63
|
+
* @param onPrepare Optionally uses factory-shared index readiness.
|
|
55
64
|
*/
|
|
56
|
-
constructor(input, records) {
|
|
65
|
+
constructor(input, records, onAdmit, onPrepare) {
|
|
57
66
|
this.input = input;
|
|
58
67
|
this.records = records;
|
|
68
|
+
this.onAdmit = onAdmit;
|
|
69
|
+
this.onPrepare = onPrepare;
|
|
59
70
|
}
|
|
60
71
|
/**
|
|
61
72
|
* Writes one original entry or confirms byte-identical content.
|
|
@@ -64,10 +75,37 @@ export class PostgresAgentHistory {
|
|
|
64
75
|
* @param entry Complete history entry.
|
|
65
76
|
* @returns Completion after immutable storage confirms the entry.
|
|
66
77
|
*/
|
|
67
|
-
|
|
78
|
+
append(entityId, entry) {
|
|
79
|
+
return this.appendAll(entityId, [entry]);
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Writes atomically writes one captured immutable Agent audit group.
|
|
83
|
+
* @param entityId Typed Agent identifier.
|
|
84
|
+
* @param entries Complete history rows.
|
|
85
|
+
* @returns Completion after the group commits.
|
|
86
|
+
*/
|
|
87
|
+
appendAll(entityId, entries) {
|
|
88
|
+
return this.onAdmit(() => this.appendAllAdmitted(entityId, entries));
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Writes an admitted immutable group on one rollback-capable transaction.
|
|
92
|
+
*
|
|
93
|
+
* @param entityId Typed Entity identifier.
|
|
94
|
+
* @param entries Complete immutable history group.
|
|
95
|
+
* @returns Completion after the complete immutable audit group commits atomically.
|
|
96
|
+
*/
|
|
97
|
+
async appendAllAdmitted(entityId, entries) {
|
|
68
98
|
this.requireOpen();
|
|
99
|
+
const key = this.key(entityId);
|
|
100
|
+
const records = entries.map((entry) => clone(AgentHistoryRecordSchema, AgentHistoryRecords.record(this.input.stateType, key, entry)));
|
|
101
|
+
if (records.length === 0)
|
|
102
|
+
return;
|
|
69
103
|
await this.ready();
|
|
70
|
-
|
|
104
|
+
const executor = this.records.historyExecutor();
|
|
105
|
+
await executor.transaction(async (client) => {
|
|
106
|
+
for (const record of records)
|
|
107
|
+
await executor.appendImmutable(client, record);
|
|
108
|
+
});
|
|
71
109
|
}
|
|
72
110
|
/**
|
|
73
111
|
* Reads a bounded indexed page in full Timestamp/category/UTF-8 order.
|
|
@@ -75,7 +113,15 @@ export class PostgresAgentHistory {
|
|
|
75
113
|
* @param request Typed Agent, view, continuation, and response limits.
|
|
76
114
|
* @returns Original entries and continuation status.
|
|
77
115
|
*/
|
|
78
|
-
|
|
116
|
+
read(request) {
|
|
117
|
+
return this.onAdmit(() => this.readAdmitted(request));
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Reads an admitted Agent-history page.
|
|
121
|
+
* @param request Typed Agent view and continuation limits.
|
|
122
|
+
* @returns Original entries and continuation status.
|
|
123
|
+
*/
|
|
124
|
+
async readAdmitted(request) {
|
|
79
125
|
this.requireOpen();
|
|
80
126
|
await this.ready();
|
|
81
127
|
const agentKey = this.key(request.entityId);
|
|
@@ -84,9 +130,7 @@ export class PostgresAgentHistory {
|
|
|
84
130
|
return AgentHistoryPages.read(request, after, (cursor, limit) => this.fetch(agentKey, request, cursor, limit));
|
|
85
131
|
}
|
|
86
132
|
/**
|
|
87
|
-
|
|
88
133
|
* Closes this handle without deleting stored records.
|
|
89
|
-
|
|
90
134
|
*/
|
|
91
135
|
close() {
|
|
92
136
|
if (!this.#open)
|
|
@@ -100,7 +144,10 @@ export class PostgresAgentHistory {
|
|
|
100
144
|
* @returns Shared preparation promise for this handle.
|
|
101
145
|
*/
|
|
102
146
|
ready() {
|
|
103
|
-
return (this.#ready ??= this.initialize())
|
|
147
|
+
return (this.#ready ??= this.initialize().catch((error) => {
|
|
148
|
+
this.#ready = undefined;
|
|
149
|
+
throw error;
|
|
150
|
+
}));
|
|
104
151
|
}
|
|
105
152
|
/**
|
|
106
153
|
* Creates each native index idempotently on the shared record family.
|
|
@@ -110,36 +157,22 @@ export class PostgresAgentHistory {
|
|
|
110
157
|
async initialize() {
|
|
111
158
|
const executor = this.records.historyExecutor();
|
|
112
159
|
await executor.prepare();
|
|
160
|
+
if (this.onPrepare !== undefined) {
|
|
161
|
+
try {
|
|
162
|
+
await this.onPrepare("create");
|
|
163
|
+
}
|
|
164
|
+
catch (error) {
|
|
165
|
+
throw new PostgresStorageOperationError("PostgreSQL record operation failed.", {
|
|
166
|
+
cause: error,
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
113
171
|
await executor.using(async (client) => {
|
|
114
172
|
const table = executor.table();
|
|
115
|
-
await
|
|
116
|
-
await this.ensureIndex(client, table, "agent_history_category", 'scope_digest, category, order_key COLLATE "C"');
|
|
117
|
-
await this.ensureIndex(client, table, "agent_history_conversation", 'scope_digest, conversation_digest, order_key COLLATE "C"');
|
|
173
|
+
await PostgresAgentIndexes.prepare(client, table, "create");
|
|
118
174
|
});
|
|
119
175
|
}
|
|
120
|
-
/**
|
|
121
|
-
* Rejects an existing same-name index with incomplete columns or collation.
|
|
122
|
-
*
|
|
123
|
-
* @param client Acquired PostgreSQL client.
|
|
124
|
-
* @param table Validated physical table name.
|
|
125
|
-
* @param name Fixed required index name.
|
|
126
|
-
* @param columns Required complete binary-order columns.
|
|
127
|
-
* @returns Completion after the index definition is checked.
|
|
128
|
-
*/
|
|
129
|
-
async ensureIndex(client, table, name, columns) {
|
|
130
|
-
await client.query(`CREATE INDEX IF NOT EXISTS "${name}" ON ${table} (${columns})`);
|
|
131
|
-
const result = await client.query("SELECT pg_get_indexdef(i.indexrelid) AS definition, i.indisvalid, i.indisready " +
|
|
132
|
-
"FROM pg_index i " +
|
|
133
|
-
"JOIN pg_class c ON c.oid=i.indexrelid WHERE i.indrelid=to_regclass($1) AND c.relname=$2", [table, name]);
|
|
134
|
-
const index = result.rows[0];
|
|
135
|
-
const definition = index?.definition ?? "";
|
|
136
|
-
if (!index?.indisvalid ||
|
|
137
|
-
!index.indisready ||
|
|
138
|
-
!definition.includes(" USING btree ") ||
|
|
139
|
-
!definition.includes(`(${columns})`) ||
|
|
140
|
-
definition.includes(" WHERE "))
|
|
141
|
-
throw new Error("PostgreSQL Agent history index is incompatible.");
|
|
142
|
-
}
|
|
143
176
|
/**
|
|
144
177
|
* Reads a bounded native page with complete scope and view predicates.
|
|
145
178
|
*
|
|
@@ -213,13 +246,57 @@ export class PostgresAgentHistory {
|
|
|
213
246
|
return key;
|
|
214
247
|
}
|
|
215
248
|
/**
|
|
216
|
-
|
|
217
249
|
* Rejects calls after this handle closes.
|
|
218
|
-
|
|
219
250
|
*/
|
|
220
251
|
requireOpen() {
|
|
221
252
|
if (!this.#open)
|
|
222
253
|
throw new Error("Agent history storage handle is closed.");
|
|
223
254
|
}
|
|
224
255
|
}
|
|
256
|
+
/**
|
|
257
|
+
* Verifies the fixed Agent audit indexes without changing a checked database.
|
|
258
|
+
*/
|
|
259
|
+
export const PostgresAgentIndexes = {
|
|
260
|
+
/**
|
|
261
|
+
* Prepares each required Agent audit index.
|
|
262
|
+
*
|
|
263
|
+
* @param client Acquired client.
|
|
264
|
+
* @param table Qualified audit table.
|
|
265
|
+
* @param mode Preparation mode.
|
|
266
|
+
* @returns Completion after all three indexes match.
|
|
267
|
+
*/
|
|
268
|
+
async prepare(client, table, mode) {
|
|
269
|
+
for (const [name, columns] of [
|
|
270
|
+
["agent_history_full", 'scope_digest, order_key COLLATE "C"'],
|
|
271
|
+
["agent_history_category", 'scope_digest, category, order_key COLLATE "C"'],
|
|
272
|
+
["agent_history_conversation", 'scope_digest, conversation_digest, order_key COLLATE "C"'],
|
|
273
|
+
])
|
|
274
|
+
await this.ensure(client, table, name, columns, mode);
|
|
275
|
+
},
|
|
276
|
+
/**
|
|
277
|
+
* Validates one fixed index and creates it only in create mode.
|
|
278
|
+
*
|
|
279
|
+
* @param client Acquired client.
|
|
280
|
+
* @param table Qualified audit table.
|
|
281
|
+
* @param name Fixed index name.
|
|
282
|
+
* @param columns Required columns.
|
|
283
|
+
* @param mode Preparation mode.
|
|
284
|
+
* @returns Completion after exact index validation.
|
|
285
|
+
*/
|
|
286
|
+
async ensure(client, table, name, columns, mode) {
|
|
287
|
+
if (mode === "create")
|
|
288
|
+
await client.query(`CREATE INDEX IF NOT EXISTS "${name}" ON ${table} (${columns})`);
|
|
289
|
+
const result = await client.query("SELECT pg_get_indexdef(i.indexrelid) AS definition, i.indisvalid, i.indisready " +
|
|
290
|
+
"FROM pg_index i " +
|
|
291
|
+
"JOIN pg_class c ON c.oid=i.indexrelid WHERE i.indrelid=to_regclass($1) AND c.relname=$2", [table, name]);
|
|
292
|
+
const index = result.rows[0];
|
|
293
|
+
const definition = index?.definition ?? "";
|
|
294
|
+
if (!index?.indisvalid ||
|
|
295
|
+
!index.indisready ||
|
|
296
|
+
!definition.includes(" USING btree ") ||
|
|
297
|
+
!definition.includes(`(${columns})`) ||
|
|
298
|
+
definition.includes(" WHERE "))
|
|
299
|
+
throw new Error("PostgreSQL Agent history index is incompatible.");
|
|
300
|
+
},
|
|
301
|
+
};
|
|
225
302
|
//# sourceMappingURL=agent-history.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-history.js","sourceRoot":"","sources":["../../src/postgres/agent-history.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"agent-history.js","sourceRoot":"","sources":["../../src/postgres/agent-history.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAE3C,OAAO,EACL,wBAAwB,GAEzB,MAAM,6EAA6E,CAAC;AACrF,OAAO,EACL,gBAAgB,EAChB,iBAAiB,GAMlB,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,mBAAmB,EAAE,MAAM,sCAAsC,CAAC;AAI3E,OAAO,EAAE,qBAAqB,EAA0B,MAAM,qBAAqB,CAAC;AACpF,OAAO,EAAE,6BAA6B,EAAE,MAAM,aAAa,CAAC;AAE5D;;GAEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B;;;;;OAKG;IACH,KAAK,CAAC,KAAa;QACjB,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAClE,CAAC;CACF,CAAC;AAEF;;;;GAIG;AACH,MAAM,OAAO,oBAAoB;IAyBZ;IACA;IACA;IACA;IA3BnB;;OAEG;IACM,QAAQ,GAAyB,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IAE5D;;OAEG;IACH,KAAK,GAAG,IAAI,CAAC;IAEb;;OAEG;IACH,MAAM,CAA4B;IAElC;;;;;;;OAOG;IACH,YACmB,KAAmC,EACnC,OAA0D,EAC1D,OAA0B,EAC1B,SAA2D;QAH3D,UAAK,GAAL,KAAK,CAA8B;QACnC,YAAO,GAAP,OAAO,CAAmD;QAC1D,YAA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