@axiom-lattice/pg-stores 3.3.13 → 4.0.0
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/.turbo/turbo-build.log +10 -10
- package/CHANGELOG.md +208 -0
- package/dist/index.d.mts +357 -3
- package/dist/index.d.ts +357 -3
- package/dist/index.js +2337 -77
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2342 -76
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
- package/src/__tests__/AgentRunRetention.migrations.test.ts +41 -0
- package/src/__tests__/PostgreSQLAgentRunLedger.test.ts +305 -0
- package/src/__tests__/PostgreSQLAgentRunRetention.test.ts +126 -0
- package/src/__tests__/PostgreSQLAgentRunTaskQueue.test.ts +1375 -0
- package/src/__tests__/PostgreSQLChannelReplyJobStore.test.ts +335 -0
- package/src/__tests__/PostgreSQLCheckpointStorage.deleteAfter.test.ts +473 -0
- package/src/__tests__/PostgreSQLCheckpointStorage.test.ts +538 -0
- package/src/__tests__/PostgreSQLStore.test.ts +173 -0
- package/src/__tests__/PostgreSQLThreadStore.test.ts +80 -0
- package/src/__tests__/ThreadMessageQueueStore.integration.test.ts +21 -0
- package/src/__tests__/ThreadMessageQueueStore.test.ts +8 -3
- package/src/__tests__/createPgStoreConfig.test.ts +38 -0
- package/src/__tests__/eval-task-id.test.ts +14 -3
- package/src/createPgStoreConfig.ts +35 -2
- package/src/index.ts +7 -0
- package/src/migrations/agent_run_base_checkpoint_captured_migration.ts +34 -0
- package/src/migrations/agent_run_capability_revision_migration.ts +24 -0
- package/src/migrations/agent_run_ledger_migration.ts +51 -0
- package/src/migrations/agent_run_project_task_migration.ts +34 -0
- package/src/migrations/agent_run_project_task_running_index_migration.ts +33 -0
- package/src/migrations/agent_run_retention_migration.ts +25 -0
- package/src/migrations/agent_run_rollback_failure_migration.ts +28 -0
- package/src/migrations/agent_run_running_index_source_migration.ts +31 -0
- package/src/migrations/agent_run_task_queue_migration.ts +65 -0
- package/src/migrations/channel_reply_job_migration.ts +55 -0
- package/src/migrations/eval_migrations.ts +19 -0
- package/src/migrations/store_migrations.ts +50 -0
- package/src/migrations/task_migration.ts +17 -0
- package/src/migrations/thread_migrations.ts +25 -0
- package/src/stores/PostgreSQLAgentRunLedger.ts +1221 -0
- package/src/stores/PostgreSQLChannelReplyJobStore.ts +373 -0
- package/src/stores/PostgreSQLCheckpointStorage.ts +548 -0
- package/src/stores/PostgreSQLEvalStore.ts +17 -4
- package/src/stores/PostgreSQLStore.ts +167 -0
- package/src/stores/PostgreSQLTaskStore.ts +4 -0
- package/src/stores/PostgreSQLThreadStore.ts +49 -10
- package/src/stores/ThreadMessageQueueStore.ts +10 -5
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @axiom-lattice/pg-stores@
|
|
2
|
+
> @axiom-lattice/pg-stores@4.0.0 build /home/runner/work/agentic/agentic/packages/pg-stores
|
|
3
3
|
> tsup src/index.ts --format cjs,esm --dts --sourcemap
|
|
4
4
|
|
|
5
5
|
[34mCLI[39m Building entry: src/index.ts
|
|
@@ -8,13 +8,13 @@
|
|
|
8
8
|
[34mCLI[39m Target: es2020
|
|
9
9
|
[34mCJS[39m Build start
|
|
10
10
|
[34mESM[39m Build start
|
|
11
|
-
[
|
|
12
|
-
[
|
|
13
|
-
[
|
|
14
|
-
[
|
|
15
|
-
[
|
|
16
|
-
[
|
|
11
|
+
[32mCJS[39m [1mdist/index.js [22m[32m528.09 KB[39m
|
|
12
|
+
[32mCJS[39m [1mdist/index.js.map [22m[32m960.67 KB[39m
|
|
13
|
+
[32mCJS[39m ⚡️ Build success in 969ms
|
|
14
|
+
[32mESM[39m [1mdist/index.mjs [22m[32m518.65 KB[39m
|
|
15
|
+
[32mESM[39m [1mdist/index.mjs.map [22m[32m960.39 KB[39m
|
|
16
|
+
[32mESM[39m ⚡️ Build success in 1032ms
|
|
17
17
|
[34mDTS[39m Build start
|
|
18
|
-
[32mDTS[39m ⚡️ Build success in
|
|
19
|
-
[32mDTS[39m [1mdist/index.d.ts [22m[
|
|
20
|
-
[32mDTS[39m [1mdist/index.d.mts [22m[
|
|
18
|
+
[32mDTS[39m ⚡️ Build success in 11614ms
|
|
19
|
+
[32mDTS[39m [1mdist/index.d.ts [22m[32m110.68 KB[39m
|
|
20
|
+
[32mDTS[39m [1mdist/index.d.mts [22m[32m110.68 KB[39m
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,213 @@
|
|
|
1
1
|
# @axiom-lattice/pg-stores
|
|
2
2
|
|
|
3
|
+
## 4.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- 80c8dca: Release the chat, task, store, and sandbox updates together.
|
|
8
|
+
|
|
9
|
+
- Chat: frosted-glass user-message navigator, breathing run status bar, streaming auto-follow that stops when the reader scrolls away, and stop notices routed through the status bar.
|
|
10
|
+
- Crons: workspace/project-scoped crons, tenant-validated scope, Console project selector/card/filter.
|
|
11
|
+
- Store: long-term Store rebuilt as a toolbar + master-detail drawer with namespace editor, JSON validation, and TTL presets.
|
|
12
|
+
- Workspace menu: optional `requiredTenantRoles` gating; Store, Audit Log, API Keys, Observability, and System Info are owner/admin-only.
|
|
13
|
+
- Execution: durable runs re-pin the shared agent to the authoritative scope, absent scheduled scope stays unscoped, subagent breaker state is isolated, first run of a locally-constructed thread is admitted, and `TaskListFilter.threadId` authorizes isolated task threads.
|
|
14
|
+
- Recursion: default budget 500 with `AGENT_RECURSION_LIMIT` override.
|
|
15
|
+
- Uploads: default request body and upload limit raised to 500 MB.
|
|
16
|
+
- Sandbox: default memory aligned to 1024 MiB and service body limit raised to 500 MB.
|
|
17
|
+
- PostgreSQL: run availability defaults to the database clock, so clock drift cannot make fresh runs briefly unclaimable.
|
|
18
|
+
|
|
19
|
+
Breaking: default recursion budget (1000 -> 500), request/upload limit (100 MB -> 500 MB), sandbox memory (512/2048 -> 1024 MiB), and durable-run scope authority change observable behavior without extra configuration.
|
|
20
|
+
|
|
21
|
+
### Minor Changes
|
|
22
|
+
|
|
23
|
+
- ae1535e: Make eval safe on the existing worker pool: a global `eval:execution` lease
|
|
24
|
+
allows any replica to run one eval at a time, cancellation is a durable
|
|
25
|
+
`cancel_requested` flag polled by the executing worker, and aborted runs settle
|
|
26
|
+
as `aborted`. The compatibility progress stream now polls the shared EvalStore
|
|
27
|
+
instead of the owner's process-local EventEmitter.
|
|
28
|
+
|
|
29
|
+
### Patch Changes
|
|
30
|
+
|
|
31
|
+
- Updated dependencies [c5a4a88]
|
|
32
|
+
- Updated dependencies [ae1535e]
|
|
33
|
+
- Updated dependencies [e71979f]
|
|
34
|
+
- Updated dependencies [80c8dca]
|
|
35
|
+
- Updated dependencies [c650a59]
|
|
36
|
+
- Updated dependencies [ae1535e]
|
|
37
|
+
- Updated dependencies [ae1535e]
|
|
38
|
+
- @axiom-lattice/core@10.0.0
|
|
39
|
+
- @axiom-lattice/protocols@6.0.0
|
|
40
|
+
|
|
41
|
+
## 3.4.0
|
|
42
|
+
|
|
43
|
+
### Minor Changes
|
|
44
|
+
|
|
45
|
+
- d5dc506: Agent run history retention
|
|
46
|
+
|
|
47
|
+
- Add `IAgentRunLedger.deleteTerminalBefore(cutoffMs, limit)` for bounded,
|
|
48
|
+
oldest-first deletion of terminal runs; pending and running rows are never
|
|
49
|
+
deleted.
|
|
50
|
+
- Implement the method for the in-memory and PostgreSQL ledgers, including a
|
|
51
|
+
partial terminal-`finished_at` index (migration v201).
|
|
52
|
+
- Add a gateway retention job controlled by `AGENT_RUN_RETENTION_DAYS` (default
|
|
53
|
+
30 days; `0`/invalid disables) and stop it during graceful shutdown.
|
|
54
|
+
|
|
55
|
+
- f1f8840: Durable cross-replica public-channel replies (Phase B)
|
|
56
|
+
|
|
57
|
+
- Add a durable `ChannelReplyJob` protocol, in-memory/PostgreSQL stores, and a
|
|
58
|
+
`lattice_channel_reply_jobs` migration (v200) with lease-based claim, bounded
|
|
59
|
+
reschedule, and terminal delivery state.
|
|
60
|
+
- Route non-Room public ingress for adapters declaring `durableReply: true`
|
|
61
|
+
through a reply job plus a pending `source='run_api'` run (job written first,
|
|
62
|
+
with compensation on run-create failure). Lark opts in; WeCom/WeChat/Room stay
|
|
63
|
+
legacy because their reply transport is connection-bound/process-local.
|
|
64
|
+
- Add `ChannelReplyDispatcher`, which polls due jobs on any replica, waits for
|
|
65
|
+
the run ledger to become terminal, reads the final assistant text from the
|
|
66
|
+
thread checkpoint, sends it through the adapter, and marks the job delivered.
|
|
67
|
+
Empty output and loader/send failures retry with capped exponential backoff;
|
|
68
|
+
sends have a 15s deadline; missing runs converge after a 30s grace window;
|
|
69
|
+
cancelled runs do not send a waiting notice. Terminal jobs are pruned after
|
|
70
|
+
24h.
|
|
71
|
+
- Keep Room/trusted dispatch and `ChannelConnectionLeader` unchanged. Durable
|
|
72
|
+
replies are at-least-once; outbound metadata carries `inputMessageId` for
|
|
73
|
+
channel-side deduplication. Ingress falls back to legacy when the dispatcher
|
|
74
|
+
runtime is not registered. Opt out with `CHANNEL_DURABLE_RUNS=false`.
|
|
75
|
+
|
|
76
|
+
- 8285b9a: Execution substrate: durable agent-run ledger and opt-in fleet worker
|
|
77
|
+
|
|
78
|
+
- Add `IAgentRunLedger` + PostgreSQL implementation (migration v193, one running run per thread).
|
|
79
|
+
- Record agent runs observationally (fire-and-forget begin/heartbeat/settle); lease remains the execution authority.
|
|
80
|
+
- Add opt-in `ThreadExecutionSupervisor` worker discovery with fair rotating scan, cooldowns, orphan recovery via the existing resume path, and readiness guidance.
|
|
81
|
+
- Add `probeThreadRunOwner` (owner/free/unknown) and `hasPending` discovery metadata.
|
|
82
|
+
|
|
83
|
+
- ea90717: `keep_latest` checkpoint pruning (M2-B2b)
|
|
84
|
+
|
|
85
|
+
- Add `CheckpointMaintenance.pruneThread` and transactional per-namespace latest-N checkpoint retention with blob retention derived from `channel_versions`.
|
|
86
|
+
- Add `POST .../prune { strategy: "keep_latest", keep?: 1..100 }`; `delete` is unchanged.
|
|
87
|
+
- Reuse strict ownership, thread-run lease, and empty-inbox guards; keep the thread row and chunk stream.
|
|
88
|
+
|
|
89
|
+
- 1fde314: Pending run task queue (Phase 1)
|
|
90
|
+
|
|
91
|
+
- Make `lattice_agent_runs` the durable task queue for the new single-run API: create writes `pending`, a worker claims/executes through `Agent.executeRun`, and recovery reclaims expired rows in place and completes durable rollback work.
|
|
92
|
+
- Add run lifecycle `join` (bounded terminal wait), `cancel?action=interrupt|rollback`, and HITL command runs; Web App runtime mirrors the same handlers.
|
|
93
|
+
- Add `client.runs.join` / cancel `action` / create `command`, and single-run HITL with `ThreadStream.openRun`. `RunCreateResult` is now `{ runId, messageId?, status: "pending" }`: the old queue-first `status: "queued"` / `queued: true` shape and the required `messageId` are gone (command runs have no user message).
|
|
94
|
+
- Keep the legacy message queue, Room, Project Task, A2A, and legacy HITL on `source='legacy'`; the two executors share the `thread-run` lease.
|
|
95
|
+
|
|
96
|
+
- 1236db0: feat(run-queue): add a per-tenant execution concurrency cap
|
|
97
|
+
|
|
98
|
+
`RUN_TASK_MAX_RUNNING_PER_TENANT` bounds concurrently `running`
|
|
99
|
+
`source='run_api'` rows per tenant, independently of the admission quota
|
|
100
|
+
(`RUN_TASK_MAX_ACTIVE_PER_TENANT`, which counts pending + running and rejects
|
|
101
|
+
creates). Pending rows stay queued; scans skip tenants at their cap so other
|
|
102
|
+
tenants remain listable. InMemory enforces on list/claim, PostgreSQL adds a
|
|
103
|
+
per-candidate count predicate and serializes capped claims with a
|
|
104
|
+
transaction-scoped tenant advisory lock. The global `N_JOBS_PER_WORKER` pool and
|
|
105
|
+
existing claim ordering are unchanged; this is best-effort cross-tenant
|
|
106
|
+
visibility, not strict round-robin fairness.
|
|
107
|
+
|
|
108
|
+
- 5c5550b: Per-tenant run queue admission quota
|
|
109
|
+
|
|
110
|
+
- Add optional `maxActiveRunsForTenant` to `CreatePendingAgentRunInput` and
|
|
111
|
+
`AgentRunTenantQuotaExceededError` (`RUN_TENANT_QUOTA_EXCEEDED`); both stores
|
|
112
|
+
reject before insert when the tenant already has that many active
|
|
113
|
+
(`pending`/`running`) `source='run_api'` runs.
|
|
114
|
+
- PostgreSQL serializes tenant creates with
|
|
115
|
+
`pg_advisory_xact_lock(hashtext($tenantId))` before counting; no migration.
|
|
116
|
+
- Gateway reads `RUN_TASK_MAX_ACTIVE_PER_TENANT` (positive safe integer else
|
|
117
|
+
unlimited) for run-lifecycle, legacy `/api/runs` background/streaming, and A2A
|
|
118
|
+
creation; HTTP creates return 429 before SSE hijack.
|
|
119
|
+
- Admission control only: pending rows count, worker claim order is unchanged,
|
|
120
|
+
and this is not fair scheduling or per-tenant execution concurrency.
|
|
121
|
+
|
|
122
|
+
- e732b92: Execute Project Task on the durable AgentRun queue while preserving TaskItem lifecycle, roster authority, HITL, and Room projection.
|
|
123
|
+
|
|
124
|
+
Project Task now creates `source="project_task"` runs with a canonical `taskId`; the worker rebuilds trusted Project/roster context from persisted rows, and a terminal hook settles error/interrupted/cancelled outcomes. Production composition no longer requires `threadMessageQueue`. Adds the active-run-by-task ledger query and PG migrations v203 (task identity) / v204 (one running row across `run_api` and `project_task`). A2A remains `source="run_api"` with unchanged semantics; run success is not task completion.
|
|
125
|
+
|
|
126
|
+
- da5294d: Tenant-scoped namespaced KV store (M2-C)
|
|
127
|
+
|
|
128
|
+
- Add `StoreProtocol` (put/get/delete/search/listNamespaces/deleteExpired) with deep JSONB filters, substring query, and TTL.
|
|
129
|
+
- Add InMemory, Local SQLite, and PostgreSQL implementations (PG migration v195 with GIN and partial expiry indexes).
|
|
130
|
+
- Add `/api/store/*` routes and a single-flight store TTL sweeper.
|
|
131
|
+
- `index` hints are accepted but vector indexing and semantic search remain deferred.
|
|
132
|
+
|
|
133
|
+
- 2609f3b: Thread copy and prune-delete (M2-B1)
|
|
134
|
+
|
|
135
|
+
- Add `CheckpointMaintenance` and transactional `copyThread` / `deleteThread` to `PostgreSQLCheckpointStorage`, with a typed `CHECKPOINT_TARGET_NOT_EMPTY` conflict and metadata `thread_id` rewrite.
|
|
136
|
+
- Add owner-scoped, busy-guarded copy and prune-delete routes; prune clears the thread's chunk stream best-effort and retains run-ledger rows.
|
|
137
|
+
- Share the thread ownership resolver between read and maintenance controllers.
|
|
138
|
+
|
|
139
|
+
- 12ce057: Thread read model (M2-A)
|
|
140
|
+
|
|
141
|
+
- Add `Agent.getStateHistory` / `Agent.getStateAtCheckpoint` (bounded to 50 checkpoints).
|
|
142
|
+
- Add `CheckpointStorage` / `ThreadCheckpointStorage` protocols and a read-only `PostgreSQLCheckpointStorage` over the built-in `PostgresSaver` tables.
|
|
143
|
+
- Add tenant/assistant-scoped read-only routes for thread status, checkpoint history, checkpoint state, and checkpoint storage usage; missing checkpoints and foreign threads return 404 and unexpected errors are sanitized.
|
|
144
|
+
|
|
145
|
+
- 23902af: Per-thread TTL and expiry sweeper (M2-B2a)
|
|
146
|
+
|
|
147
|
+
- Add optional `expiresAt` to `Thread`/`CreateThreadRequest` and `listExpiredThreads` to `ThreadStore`.
|
|
148
|
+
- Persist `expires_at` in InMemory, Local SQLite, and PostgreSQL stores (PG migration v194 + partial index).
|
|
149
|
+
- Accept `ttlSeconds`/`expiresAt` when creating a thread (invalid values return 400).
|
|
150
|
+
- Add a lease/inbox/maintenance-guarded TTL sweeper with `THREAD_TTL_SWEEP_*` configuration.
|
|
151
|
+
- Copy does not inherit TTL; run-ledger rows are retained on sweep.
|
|
152
|
+
|
|
153
|
+
### Patch Changes
|
|
154
|
+
|
|
155
|
+
- c1f4f54: fix: do not let stale legacy running rows block run_api claims
|
|
156
|
+
|
|
157
|
+
Legacy message-queue ledger rows and durable `run_api` rows share
|
|
158
|
+
`lattice_agent_runs`. A crashed legacy owner could leave a `running` row behind
|
|
159
|
+
and the `(tenant, thread) WHERE status='running'` unique index made every later
|
|
160
|
+
`run_api` pending row unclaimable after the thread-run lease expired.
|
|
161
|
+
|
|
162
|
+
Pending scans/claims now ignore legacy running rows, and migration v202 scopes
|
|
163
|
+
the one-running-row partial unique index to `source='run_api'`. Actual execution
|
|
164
|
+
exclusion remains the shared `thread-run` lease.
|
|
165
|
+
|
|
166
|
+
- 5f0aeff: feat(run-task): interleave pending scans fairly across tenants
|
|
167
|
+
|
|
168
|
+
`ListPendingRunsOptions.fairTenants` (default `false`) returns each tenant's
|
|
169
|
+
oldest claimable pending run first, then each tenant's second-oldest, and so on,
|
|
170
|
+
with `(availableAt, createdAt, runId, tenantId)` tie-breakers. Existing due,
|
|
171
|
+
active-thread, rollback and `maxRunningPerTenant` filters still apply before
|
|
172
|
+
ranking. InMemory and PostgreSQL use the same ordering; PostgreSQL ranks with a
|
|
173
|
+
tenant-partitioned `row_number()` window. Fair mode rejects the global keyset
|
|
174
|
+
`after` cursor with `RangeError`, and the run-task worker now always scans fair
|
|
175
|
+
without a cursor. This is best-effort interleaving at scan time, not strict
|
|
176
|
+
global round-robin scheduling.
|
|
177
|
+
|
|
178
|
+
- Updated dependencies [1fde314]
|
|
179
|
+
- Updated dependencies [9a6579c]
|
|
180
|
+
- Updated dependencies [c1f4f54]
|
|
181
|
+
- Updated dependencies [d5dc506]
|
|
182
|
+
- Updated dependencies [f1f8840]
|
|
183
|
+
- Updated dependencies [8285b9a]
|
|
184
|
+
- Updated dependencies [5f0aeff]
|
|
185
|
+
- Updated dependencies [dcbe47b]
|
|
186
|
+
- Updated dependencies [235b4a4]
|
|
187
|
+
- Updated dependencies [c07db86]
|
|
188
|
+
- Updated dependencies [ea90717]
|
|
189
|
+
- Updated dependencies [e33c7c3]
|
|
190
|
+
- Updated dependencies [2d61ef6]
|
|
191
|
+
- Updated dependencies [351b0e9]
|
|
192
|
+
- Updated dependencies [1fde314]
|
|
193
|
+
- Updated dependencies [1236db0]
|
|
194
|
+
- Updated dependencies [5c5550b]
|
|
195
|
+
- Updated dependencies [e732b92]
|
|
196
|
+
- Updated dependencies [2422cdd]
|
|
197
|
+
- Updated dependencies [bfb7c42]
|
|
198
|
+
- Updated dependencies [ced17aa]
|
|
199
|
+
- Updated dependencies [8f9dd0d]
|
|
200
|
+
- Updated dependencies [da5294d]
|
|
201
|
+
- Updated dependencies [03e9984]
|
|
202
|
+
- Updated dependencies [2609f3b]
|
|
203
|
+
- Updated dependencies [4a74c70]
|
|
204
|
+
- Updated dependencies [12ce057]
|
|
205
|
+
- Updated dependencies [66daf89]
|
|
206
|
+
- Updated dependencies [23902af]
|
|
207
|
+
- Updated dependencies [fad0bd0]
|
|
208
|
+
- @axiom-lattice/core@9.0.0
|
|
209
|
+
- @axiom-lattice/protocols@5.0.0
|
|
210
|
+
|
|
3
211
|
## 3.3.13
|
|
4
212
|
|
|
5
213
|
### Patch Changes
|