@alma-harness/postgres-execution 0.6.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/LICENSE +202 -0
- package/README.md +133 -0
- package/dist/index.d.ts +187 -0
- package/dist/index.js +1177 -0
- package/dist/index.js.map +1 -0
- package/package.json +51 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
# @alma-harness/postgres-execution
|
|
2
|
+
|
|
3
|
+
PostgreSQL operation lineage (spec: durable-operation-lineage). This additive
|
|
4
|
+
package depends on the matching `core`, `execution` and `postgres` release; it
|
|
5
|
+
reuses the shared scoped transaction, role and statement-timeout helpers.
|
|
6
|
+
|
|
7
|
+
`migrateOperationTreeStore(pool)` installs the current execution shape helper and
|
|
8
|
+
`alma_operation_roots`/`alma_operation_calls`. `PostgresOperationTreeStore(pool,
|
|
9
|
+
ScopedStoreOptions?)` implements the neutral `OperationTreeStore` from execution.
|
|
10
|
+
Default transactions SET LOCAL ROLE alma_app and bind org/uid with a 30s timeout.
|
|
11
|
+
An explicit null role retains the existing host opt-out from role switching.
|
|
12
|
+
Migration needs the same privileged migration connection as postgres; runtime
|
|
13
|
+
connections use limited login membership via grantRole.
|
|
14
|
+
|
|
15
|
+
Claim a root once; only its first claimant receives an opaque fence. Reserve stable
|
|
16
|
+
main/direct/delegate/summary slots before dispatch. Root/child scope, session,
|
|
17
|
+
policy, caps, sensitivity and deadline must agree. Parent links stay within a
|
|
18
|
+
root. SQL locks serialize ordinals; a trigger validates root admission and updates
|
|
19
|
+
membership count atomically. Lost acknowledgements are resolved by scoped reads
|
|
20
|
+
or equal reservation replay, never a new root execution authority.
|
|
21
|
+
|
|
22
|
+
Expired roots cannot reserve even before `reconcileExpired(scope)` marks them for
|
|
23
|
+
reconciliation. The bounded sweep skips locked roots. `close` stops admission;
|
|
24
|
+
it does not mean accounting or delivery completed. `listCalls` pages by ordinal,
|
|
25
|
+
default50/max100, with at most512 members per root. Reads never return the fence
|
|
26
|
+
token. Metadata is content-free and retained; no deletion or takeover API exists.
|
|
27
|
+
|
|
28
|
+
Governed conversation and step runners bind these reservations before egress.
|
|
29
|
+
Lineage itself creates no billable cost rows.
|
|
30
|
+
|
|
31
|
+
## Root financial accounting
|
|
32
|
+
|
|
33
|
+
`migrateOperationAccountingStore` composes lineage and governed-cost migrations.
|
|
34
|
+
`PostgresOperationAccountingStore` reads actual governed receipts by registered
|
|
35
|
+
call identity and writes only `alma_operation_financial_calls` and
|
|
36
|
+
`alma_operation_warnings`. A root lock serializes accounting ordinals and totals;
|
|
37
|
+
SQL verifies financial associations and exact decision metadata, and inserts
|
|
38
|
+
warning evidence atomically. Source cost rows/counters are never incremented.
|
|
39
|
+
|
|
40
|
+
The source settlement and aggregate are separate transactions. Lost aggregate
|
|
41
|
+
acknowledgements replay the stored receipt; missing aggregates can be repaired
|
|
42
|
+
without root dispatch authority, including after closure/expiry. Scoped FKs retain
|
|
43
|
+
the source governed rows; ordinary cost retention already preserves those rows.
|
|
44
|
+
Summary counts do not certify completion or external delivery. Out-of-order root
|
|
45
|
+
accounting uses original session/day amounts; root warnings are immutable evidence,
|
|
46
|
+
not a notification outbox (spec: root-financial-receipts).
|
|
47
|
+
|
|
48
|
+
`migrateOperationSessionStore(pool)` installs scoped session lock rows and immutable
|
|
49
|
+
admissions. `PostgresOperationSessionStore` serializes claims across connections;
|
|
50
|
+
a partial unique index permits only one unfinished admission per scoped session.
|
|
51
|
+
Deadlines mark uncertainty without granting takeover. Finish requires the original
|
|
52
|
+
fence before expiry; its replay remains stable. Operator resolution has a separate
|
|
53
|
+
receipt and cannot be replayed as an owner finish.
|
|
54
|
+
|
|
55
|
+
Normal operations assume `alma_app`; explicit `resolve` assumes the separately
|
|
56
|
+
configured `operatorRole` (default `alma_retention`) with membership required and
|
|
57
|
+
FORCE RLS still active. Grant that membership only to the trusted reconciliation
|
|
58
|
+
host. Migration accepts matching `role`/`operatorRole`. Do not invoke resolution
|
|
59
|
+
from a runner, sweeper or timeout handler. Admit before root creation; a crash
|
|
60
|
+
between those transactions intentionally leaves the session occupied. Deploy
|
|
61
|
+
matching readers and roles before adoption; admission itself includes no automatic retention. See the governed-session-admission spec.
|
|
62
|
+
|
|
63
|
+
Operation-tree migration also upgrades the legacy parent-kind CHECK to permit
|
|
64
|
+
parentless prelude summaries. Scoped parent FKs and lower-ordinal checks remain.
|
|
65
|
+
Reapplying old migration SQL preserves the upgrade; old TypeScript readers may
|
|
66
|
+
still reject this new representation and must be replaced before adoption.
|
|
67
|
+
|
|
68
|
+
Conversation request descriptors roundtrip through both admission input and the
|
|
69
|
+
nullable root `request` column. New SQL checks validate closed bounded metadata;
|
|
70
|
+
a root UPDATE trigger protects original binding fields while allowing existing
|
|
71
|
+
status/count changes. Migration retains legacy descriptor absence and survives
|
|
72
|
+
frozen old SQL replay. Install migrations before current adapters (which select the
|
|
73
|
+
new column), then replace old readers before enabling descriptors. No fabricated
|
|
74
|
+
revisions, content rows or charges are created (spec: conversation-root-binding).
|
|
75
|
+
|
|
76
|
+
## Batch submission ownership
|
|
77
|
+
|
|
78
|
+
`migrateBatchSubmissionStore` adds `alma_batch_submissions` and `alma_batch_items`;
|
|
79
|
+
`PostgresBatchSubmissionStore` implements the execution package's neutral contract.
|
|
80
|
+
The parent insert creates the complete membership through a SQL trigger in the
|
|
81
|
+
same transaction. Scoped operation/call/settlement uniqueness and immutable JSON
|
|
82
|
+
bindings prevent reassociation. FORCE RLS covers both org and uid; use the ordinary
|
|
83
|
+
limited login with alma_app membership and statement-timeout settings. Runtime
|
|
84
|
+
gets no delete grants or ownership reset API.
|
|
85
|
+
|
|
86
|
+
SQL guards reject expired new dispatch, reverse transitions and acceptance without
|
|
87
|
+
a prior dispatch marker. The clock is sampled after row locks. A late handle stays
|
|
88
|
+
available under reconciliation; acceptance is not batch completion, accounting or
|
|
89
|
+
permission to submit again. Scoped reads never expose the original fence token.
|
|
90
|
+
SQL access remains a trusted host capability, as with existing fenced stores.
|
|
91
|
+
|
|
92
|
+
Install the additive migration before constructing the adapter; populated replay
|
|
93
|
+
is supported and old execution migrations leave the new tables intact. Input
|
|
94
|
+
normalization caps manifests at 2 MiB; SQL additionally bounds JSONB text to 4 MiB
|
|
95
|
+
because its numeric/whitespace encoding differs. All recursive metadata shapes
|
|
96
|
+
are closed; content must use a separate result store. No automatic retention,
|
|
97
|
+
provider access, collection, settlement or routine integration is included.
|
|
98
|
+
|
|
99
|
+
`migrateBatchUsageStore` composes batch and governed settlement migrations and
|
|
100
|
+
adds `alma_batch_usage`. `PostgresBatchUsageStore` uses the normal scoped limited
|
|
101
|
+
login and timeout options. SQL binds observations to the accepted handle/member,
|
|
102
|
+
checks closed evidence, and permits only a one-way association to an existing
|
|
103
|
+
matching governed cost. FORCE RLS and scoped FKs protect observations and source
|
|
104
|
+
receipt retention; app receives no delete grant. Readers validate complete saved
|
|
105
|
+
pricing and receipt consistency, failing on corrupt metadata.
|
|
106
|
+
|
|
107
|
+
Receipt adoption locks the observation first, then reads its joined receipt in a
|
|
108
|
+
fresh SQL statement: a statement snapshot taken before a competing adoption must
|
|
109
|
+
not mix the new association with old joined data. Lost append, settlement and
|
|
110
|
+
adoption acknowledgements replay the same identities. The adapter never increments
|
|
111
|
+
spend or invokes a provider. Install the additive migration before new readers;
|
|
112
|
+
populated repeated upgrades preserve records. See execution's batch usage journal
|
|
113
|
+
contract; content, valid EOF, collection completion and delivery remain separate.
|
|
114
|
+
The SQL association guard also computes the frozen batch price, including highest
|
|
115
|
+
applicable prompt band, cache fallback/one-hour rates and provider search charges.
|
|
116
|
+
Parity tests compare its amount with core pricing; a matching identity/usage receipt
|
|
117
|
+
with a different monetary amount cannot make an observation unreadable or resolved.
|
|
118
|
+
|
|
119
|
+
`migrateBatchAccountingStore` adds `alma_batch_financial_items` and
|
|
120
|
+
`alma_batch_warnings` on top of the batch usage migrations.
|
|
121
|
+
`PostgresBatchAccountingStore` uses the same limited scoped connection options.
|
|
122
|
+
A batch row lock serializes accounting ordinals and inclusive totals; item and
|
|
123
|
+
warning inserts commit atomically. Unique scoped item keys prevent two observations
|
|
124
|
+
from contributing twice. SQL checks the adopted observation, source amount,
|
|
125
|
+
manifest position and exact decisions/warning set. App grants are SELECT/INSERT
|
|
126
|
+
only; scoped FKs protect source observations. Populated upgrade replay is supported.
|
|
127
|
+
The adapter never writes monetary counters or cost rows and grants no execution
|
|
128
|
+
or channel-delivery authority.
|
|
129
|
+
|
|
130
|
+
SQL validators and triggers that depend on Alma objects pin their invoker path to
|
|
131
|
+
`pg_catalog, installation_schema, pg_temp`. Install in a trusted schema and rerun
|
|
132
|
+
current migrations before backup; old startup SQL may replace function settings.
|
|
133
|
+
This preserves CHECK evaluation during pg_restore and prevents caller-path shadows.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
import { Scope, JobHandle } from '@alma-harness/core';
|
|
2
|
+
import * as _alma_harness_execution from '@alma-harness/execution';
|
|
3
|
+
import { OperationAccountingStore, RootCallReceipt, RootFinancialSummary, OperationSessionStore, OperationRootInput, OperationSessionClaim, OperationSessionRecord, OperationSessionFence, BatchSubmissionStore, BatchSubmissionInput, BatchSubmissionRecord, BatchSubmissionFence, BatchUsageStore, BatchUsageInput, BatchUsageRecord, BatchUsageQuery, BatchAccountingStore, BatchFinancialReceipt, BatchFinancialSummary, OperationTreeStore, OperationRootRecord, OperationFence, OperationCallInput, OperationCallRecord } from '@alma-harness/execution';
|
|
4
|
+
import { ScopedStoreOptions } from '@alma-harness/postgres';
|
|
5
|
+
import { Pool } from 'pg';
|
|
6
|
+
|
|
7
|
+
declare function operationTreeMigrationSql(role?: string): string;
|
|
8
|
+
declare function migrateOperationTreeStore(pool: Pool, opts?: {
|
|
9
|
+
role?: string;
|
|
10
|
+
}): Promise<void>;
|
|
11
|
+
|
|
12
|
+
declare class PostgresOperationAccountingStore implements OperationAccountingStore {
|
|
13
|
+
#private;
|
|
14
|
+
readonly pool: Pool;
|
|
15
|
+
constructor(pool: Pool, opts?: ScopedStoreOptions);
|
|
16
|
+
record(scope: Scope, rootKey: string, callId: string): Promise<{
|
|
17
|
+
status: "replayed";
|
|
18
|
+
receipt: RootCallReceipt;
|
|
19
|
+
} | {
|
|
20
|
+
status: "pending";
|
|
21
|
+
receipt?: never;
|
|
22
|
+
} | {
|
|
23
|
+
status: "applied";
|
|
24
|
+
receipt: RootCallReceipt;
|
|
25
|
+
}>;
|
|
26
|
+
get(scope: Scope, rootKey: string): Promise<RootFinancialSummary | null>;
|
|
27
|
+
list(scope: Scope, rootKey: string, query?: {
|
|
28
|
+
afterOrdinal?: number;
|
|
29
|
+
limit?: number;
|
|
30
|
+
}): Promise<RootCallReceipt[]>;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
declare function operationAccountingMigrationSql(role?: string): string;
|
|
34
|
+
declare function migrateOperationAccountingStore(pool: Pool, opts?: {
|
|
35
|
+
role?: string;
|
|
36
|
+
}): Promise<void>;
|
|
37
|
+
|
|
38
|
+
declare class PostgresOperationSessionStore implements OperationSessionStore {
|
|
39
|
+
#private;
|
|
40
|
+
readonly pool: Pool;
|
|
41
|
+
constructor(pool: Pool, opts?: ScopedStoreOptions & {
|
|
42
|
+
operatorRole?: string;
|
|
43
|
+
});
|
|
44
|
+
claim(value: OperationRootInput): Promise<OperationSessionClaim>;
|
|
45
|
+
get(scope: Scope, rootKey: string): Promise<OperationSessionRecord | null>;
|
|
46
|
+
list(scope: Scope, sessionId: string, query?: {
|
|
47
|
+
afterOrdinal?: number;
|
|
48
|
+
limit?: number;
|
|
49
|
+
}): Promise<OperationSessionRecord[]>;
|
|
50
|
+
finish(fence: OperationSessionFence): Promise<OperationSessionRecord>;
|
|
51
|
+
markUncertain(fence: OperationSessionFence): Promise<OperationSessionRecord>;
|
|
52
|
+
reconcileExpired(scope: Scope, opts?: {
|
|
53
|
+
limit?: number;
|
|
54
|
+
}): Promise<OperationSessionRecord[]>;
|
|
55
|
+
resolve(scope: Scope, rootKey: string, opts: {
|
|
56
|
+
resolutionId: string;
|
|
57
|
+
}): Promise<OperationSessionRecord>;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
declare function operationSessionMigrationSql(role?: string, operatorRole?: string): string;
|
|
61
|
+
declare function migrateOperationSessionStore(pool: Pool, opts?: {
|
|
62
|
+
role?: string;
|
|
63
|
+
operatorRole?: string;
|
|
64
|
+
}): Promise<void>;
|
|
65
|
+
|
|
66
|
+
declare class PostgresBatchSubmissionStore implements BatchSubmissionStore {
|
|
67
|
+
#private;
|
|
68
|
+
readonly pool: Pool;
|
|
69
|
+
constructor(pool: Pool, opts?: ScopedStoreOptions);
|
|
70
|
+
claim(value: BatchSubmissionInput): Promise<{
|
|
71
|
+
status: "claimed";
|
|
72
|
+
record: BatchSubmissionRecord;
|
|
73
|
+
fence: {
|
|
74
|
+
scope: {
|
|
75
|
+
org: string;
|
|
76
|
+
uid: string;
|
|
77
|
+
};
|
|
78
|
+
key: string;
|
|
79
|
+
id: string;
|
|
80
|
+
token: string;
|
|
81
|
+
};
|
|
82
|
+
} | {
|
|
83
|
+
status: "existing";
|
|
84
|
+
record: BatchSubmissionRecord;
|
|
85
|
+
fence?: never;
|
|
86
|
+
}>;
|
|
87
|
+
beginDispatch(fence: BatchSubmissionFence): Promise<{
|
|
88
|
+
dispatch: boolean;
|
|
89
|
+
record: BatchSubmissionRecord;
|
|
90
|
+
}>;
|
|
91
|
+
accept(value: BatchSubmissionFence, raw: JobHandle): Promise<BatchSubmissionRecord>;
|
|
92
|
+
markUncertain(fence: BatchSubmissionFence): Promise<BatchSubmissionRecord>;
|
|
93
|
+
get(scope: Scope, identity: string): Promise<BatchSubmissionRecord | null>;
|
|
94
|
+
list(scope: Scope, query?: {
|
|
95
|
+
afterKey?: string;
|
|
96
|
+
limit?: number;
|
|
97
|
+
}): Promise<_alma_harness_execution.BatchSubmissionSummary[]>;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
declare function batchSubmissionMigrationSql(role?: string): string;
|
|
101
|
+
declare function migrateBatchSubmissionStore(pool: Pool, opts?: {
|
|
102
|
+
role?: string;
|
|
103
|
+
}): Promise<void>;
|
|
104
|
+
|
|
105
|
+
declare class PostgresBatchUsageStore implements BatchUsageStore {
|
|
106
|
+
#private;
|
|
107
|
+
readonly pool: Pool;
|
|
108
|
+
constructor(pool: Pool, opts?: ScopedStoreOptions);
|
|
109
|
+
append(scope: Scope, batchKey: string, value: BatchUsageInput): Promise<BatchUsageRecord>;
|
|
110
|
+
get(scope: Scope, batchKey: string, identity: string): Promise<BatchUsageRecord | null>;
|
|
111
|
+
list(scope: Scope, batchKey: string, query?: BatchUsageQuery): Promise<BatchUsageRecord[]>;
|
|
112
|
+
recordSettlement(scope: Scope, batchKey: string, identity: string): Promise<{
|
|
113
|
+
status: "replayed";
|
|
114
|
+
record: BatchUsageRecord;
|
|
115
|
+
} | {
|
|
116
|
+
status: "pending";
|
|
117
|
+
record?: never;
|
|
118
|
+
} | {
|
|
119
|
+
status: "applied";
|
|
120
|
+
record: BatchUsageRecord;
|
|
121
|
+
}>;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
declare function batchUsageMigrationSql(role?: string): string;
|
|
125
|
+
declare function migrateBatchUsageStore(pool: Pool, opts?: {
|
|
126
|
+
role?: string;
|
|
127
|
+
}): Promise<void>;
|
|
128
|
+
|
|
129
|
+
declare class PostgresBatchAccountingStore implements BatchAccountingStore {
|
|
130
|
+
#private;
|
|
131
|
+
readonly pool: Pool;
|
|
132
|
+
constructor(pool: Pool, opts?: ScopedStoreOptions);
|
|
133
|
+
record(scope: Scope, batchKey: string, observationId: string): Promise<{
|
|
134
|
+
status: "replayed";
|
|
135
|
+
receipt: BatchFinancialReceipt;
|
|
136
|
+
} | {
|
|
137
|
+
status: "applied";
|
|
138
|
+
receipt: BatchFinancialReceipt;
|
|
139
|
+
} | {
|
|
140
|
+
status: "pending";
|
|
141
|
+
}>;
|
|
142
|
+
get(scope: Scope, batchKey: string): Promise<BatchFinancialSummary | null>;
|
|
143
|
+
list(scope: Scope, batchKey: string, query?: {
|
|
144
|
+
afterOrdinal?: number;
|
|
145
|
+
limit?: number;
|
|
146
|
+
}): Promise<BatchFinancialReceipt[]>;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
declare function batchAccountingMigrationSql(role?: string): string;
|
|
150
|
+
declare function migrateBatchAccountingStore(pool: Pool, opts?: {
|
|
151
|
+
role?: string;
|
|
152
|
+
}): Promise<void>;
|
|
153
|
+
|
|
154
|
+
declare class PostgresOperationTreeStore implements OperationTreeStore {
|
|
155
|
+
#private;
|
|
156
|
+
readonly pool: Pool;
|
|
157
|
+
constructor(pool: Pool, opts?: ScopedStoreOptions);
|
|
158
|
+
claim(value: OperationRootInput): Promise<{
|
|
159
|
+
status: "claimed";
|
|
160
|
+
record: OperationRootRecord;
|
|
161
|
+
fence: {
|
|
162
|
+
scope: {
|
|
163
|
+
org: string;
|
|
164
|
+
uid: string;
|
|
165
|
+
};
|
|
166
|
+
key: string;
|
|
167
|
+
id: string;
|
|
168
|
+
token: string;
|
|
169
|
+
};
|
|
170
|
+
} | {
|
|
171
|
+
status: "existing";
|
|
172
|
+
record: OperationRootRecord;
|
|
173
|
+
fence?: never;
|
|
174
|
+
}>;
|
|
175
|
+
reserve(value: OperationFence, request: OperationCallInput): Promise<OperationCallRecord>;
|
|
176
|
+
close(value: OperationFence): Promise<OperationRootRecord>;
|
|
177
|
+
get(scope: Scope, identity: string): Promise<OperationRootRecord | null>;
|
|
178
|
+
listCalls(scope: Scope, identity: string, query?: {
|
|
179
|
+
afterOrdinal?: number;
|
|
180
|
+
limit?: number;
|
|
181
|
+
}): Promise<OperationCallRecord[]>;
|
|
182
|
+
reconcileExpired(scope: Scope, opts?: {
|
|
183
|
+
limit?: number;
|
|
184
|
+
}): Promise<OperationRootRecord[]>;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
export { PostgresBatchAccountingStore, PostgresBatchSubmissionStore, PostgresBatchUsageStore, PostgresOperationAccountingStore, PostgresOperationSessionStore, PostgresOperationTreeStore, batchAccountingMigrationSql, batchSubmissionMigrationSql, batchUsageMigrationSql, migrateBatchAccountingStore, migrateBatchSubmissionStore, migrateBatchUsageStore, migrateOperationAccountingStore, migrateOperationSessionStore, migrateOperationTreeStore, operationAccountingMigrationSql, operationSessionMigrationSql, operationTreeMigrationSql };
|