@aldus-runtime/release 0.1.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 ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "{}"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/NOTICE ADDED
@@ -0,0 +1,21 @@
1
+ Aldus
2
+ Copyright 2026 Jam Chen
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use
5
+ this software except in compliance with the License. You may obtain a copy of
6
+ the License in the LICENSE file distributed with this software, or at:
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Aldus is currently owned as personal work and has not been assigned to a
11
+ separate legal entity. If ownership is transferred, this file and the related
12
+ copyright statements will be updated at that time.
13
+
14
+ No third-party code is bundled, inlined, or vendored into any published Aldus
15
+ package. Dependencies are resolved at install time and reach the consumer under
16
+ their own licenses, from their own publishers. The dependency audit is recorded
17
+ in THIRD-PARTY-NOTICES.md.
18
+
19
+ This NOTICE file exists by the project's choice rather than by obligation:
20
+ Apache-2.0 section 4(d) governs the preservation of a NOTICE file when the work
21
+ already carries one, and does not itself require that one be created.
@@ -0,0 +1,140 @@
1
+ /**
2
+ * The release adapter contract (architecture contract §17, §4.3).
3
+ *
4
+ * This package contains **no platform client, and names no platform.** Contract §4.2 keeps
5
+ * publishing platforms out of the runtime and §1.2 explicitly rules out prescribing particular
6
+ * release targets; §4.3 places provider and release configuration in Integration. Contract §22's
7
+ * own wording for this work package names two platforms, and following that wording literally
8
+ * would have put an adopter's channel semantics inside the runtime — the dependency direction
9
+ * §4.3 forbids.
10
+ *
11
+ * So what lives here is the shape an adopter implements, plus the resumable machinery that shape
12
+ * plugs into. The only implementation in this package is {@link RecordingReleaseAdapter}, a test
13
+ * double.
14
+ */
15
+ import type { ReleaseOperation } from "./operation.js";
16
+ /** What an adapter is asked to do. */
17
+ export interface ReleaseRequest {
18
+ /** The operation being performed. */
19
+ operation: ReleaseOperation;
20
+ /**
21
+ * The key that makes this request safe to repeat (contract §17, §19.1).
22
+ *
23
+ * An adapter whose platform supports client-supplied idempotency keys SHOULD pass this
24
+ * through, so that a repeat caused by a lost response is deduplicated remotely as well as
25
+ * locally.
26
+ */
27
+ idempotencyKey: string;
28
+ /** Run the release belongs to. */
29
+ runId: string;
30
+ }
31
+ /** What an adapter reports back. */
32
+ export type AdapterOutcome = {
33
+ status: "succeeded";
34
+ /** Identifier assigned by the destination, where one is returned. */
35
+ remoteId?: string;
36
+ /** Address of the released item, where one is meaningful. */
37
+ remoteUrl?: string;
38
+ } | {
39
+ status: "failed";
40
+ /** Operator-facing reason, already redacted by the adapter (contract §19.2). */
41
+ message: string;
42
+ /** Whether repeating the identical request could plausibly succeed (contract §19.1). */
43
+ retryable?: boolean;
44
+ } | {
45
+ /**
46
+ * The outcome is genuinely unknown — a timeout, a lost connection after the request was
47
+ * accepted, a platform that acknowledges asynchronously.
48
+ *
49
+ * Distinct from `failed` and the reason `ReleaseReceipt` has a `pending` status: an
50
+ * unknown outcome MUST be reconciled against the destination rather than retried, because
51
+ * retrying something that already succeeded is how a double publish happens.
52
+ */
53
+ status: "pending";
54
+ message?: string;
55
+ };
56
+ /** What reconciliation found at the destination. */
57
+ export interface RemoteState {
58
+ /** Whether the destination holds the result of this operation. */
59
+ exists: boolean;
60
+ remoteId?: string;
61
+ remoteUrl?: string;
62
+ }
63
+ /**
64
+ * An adopter's implementation for one destination.
65
+ *
66
+ * Implementations live in an adopter integration, never here (§4.3).
67
+ */
68
+ export interface ReleaseAdapter {
69
+ /** The destination this adapter serves, matching `ReleaseOperation.destination`. */
70
+ readonly destination: string;
71
+ /** Perform one operation. */
72
+ execute(request: ReleaseRequest): Promise<AdapterOutcome>;
73
+ /**
74
+ * Ask the destination whether an operation already happened (contract §17).
75
+ *
76
+ * Optional because §17 qualifies resumability with "where the platform allows it" — a
77
+ * destination with no way to query prior state genuinely cannot support this. An adapter that
78
+ * omits it makes reconciliation impossible for its operations, and the executor reports that
79
+ * rather than guessing; see {@link ReleaseErrorCodes.RECONCILIATION_UNAVAILABLE}.
80
+ */
81
+ lookup?(request: ReleaseRequest): Promise<RemoteState>;
82
+ }
83
+ /** Adapters by destination. */
84
+ export declare class AdapterRegistry {
85
+ #private;
86
+ constructor(adapters?: readonly ReleaseAdapter[]);
87
+ /** Register an adapter, replacing any previous one for its destination. */
88
+ register(adapter: ReleaseAdapter): void;
89
+ /** The adapter for a destination, or `undefined`. */
90
+ find(destination: string): ReleaseAdapter | undefined;
91
+ /**
92
+ * The adapter for a destination.
93
+ *
94
+ * @throws {AldusError} `ALDUS_RELEASE_ADAPTER_NOT_REGISTERED` when none is registered. Refusing
95
+ * is deliberate: a missing adapter means an operator declared work nothing can perform, and
96
+ * skipping it would report a complete release that never touched the destination.
97
+ */
98
+ require(destination: string): ReleaseAdapter;
99
+ }
100
+ /** Scripted behaviour for {@link RecordingReleaseAdapter}. */
101
+ export interface RecordingAdapterOptions {
102
+ /** Outcome per `operationId`. Anything unlisted succeeds. */
103
+ outcomes?: Readonly<Record<string, AdapterOutcome>>;
104
+ /** Remote state per idempotency key, as reconciliation would find it. */
105
+ remote?: Readonly<Record<string, RemoteState>>;
106
+ /** Omit `lookup` entirely, modelling a destination that cannot be queried. */
107
+ withoutLookup?: boolean;
108
+ }
109
+ /**
110
+ * A test double that records what it was asked to do.
111
+ *
112
+ * Counting executions is the point: the double-publish tests assert that a *real* second
113
+ * execution never happened, which a spy on the executor could not establish.
114
+ */
115
+ export declare class RecordingReleaseAdapter implements ReleaseAdapter {
116
+ #private;
117
+ readonly destination: string;
118
+ /** Every request passed to {@link execute}, in order. */
119
+ readonly executed: ReleaseRequest[];
120
+ /** Every request passed to {@link lookup}, in order. */
121
+ readonly lookedUp: ReleaseRequest[];
122
+ /** Remote state, mutable so a test can simulate a destination that already holds a result. */
123
+ readonly remote: Map<string, RemoteState>;
124
+ /**
125
+ * Present only when the destination can be queried.
126
+ *
127
+ * An own property assigned in the constructor rather than a prototype method, because
128
+ * `withoutLookup` has to make `lookup` genuinely **absent**. A method that returns "not found"
129
+ * would be indistinguishable from a destination that was queried and had nothing — and those
130
+ * are opposite situations: one means the operation still needs to run, the other means nobody
131
+ * can say. Deleting a prototype method does not remove it from the instance, which is the bug
132
+ * this shape avoids.
133
+ */
134
+ readonly lookup?: (request: ReleaseRequest) => Promise<RemoteState>;
135
+ constructor(destination: string, options?: RecordingAdapterOptions);
136
+ execute(request: ReleaseRequest): Promise<AdapterOutcome>;
137
+ /** How many times an operation was actually sent to the destination. */
138
+ executionCount(operationId: string): number;
139
+ }
140
+ //# sourceMappingURL=adapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAGvD,sCAAsC;AACtC,MAAM,WAAW,cAAc;IAC7B,qCAAqC;IACrC,SAAS,EAAE,gBAAgB,CAAC;IAC5B;;;;;;OAMG;IACH,cAAc,EAAE,MAAM,CAAC;IACvB,kCAAkC;IAClC,KAAK,EAAE,MAAM,CAAC;CACf;AAED,oCAAoC;AACpC,MAAM,MAAM,cAAc,GACtB;IACE,MAAM,EAAE,WAAW,CAAC;IACpB,qEAAqE;IACrE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,6DAA6D;IAC7D,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,GACD;IACE,MAAM,EAAE,QAAQ,CAAC;IACjB,gFAAgF;IAChF,OAAO,EAAE,MAAM,CAAC;IAChB,wFAAwF;IACxF,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,GACD;IACE;;;;;;;OAOG;IACH,MAAM,EAAE,SAAS,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEN,oDAAoD;AACpD,MAAM,WAAW,WAAW;IAC1B,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Ac,EAAE,CAAM;IAEzC,8FAA8F;IAC9F,QAAQ,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IAE1C;;;;;;;;;OASG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,cAAc,KAAK,OAAO,CAAC,WAAW,CAAC,CAAC;IAEpE,YAAY,WAAW,EAAE,MAAM,EAAE,OAAO,GAAE,uBAA4B,EAUrE;IAED,OAAO,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,cAAc,CAAC,CAexD;IAED,wEAAwE;IACxE,cAAc,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAE1C;CACF"}
@@ -0,0 +1,104 @@
1
+ /**
2
+ * The release adapter contract (architecture contract §17, §4.3).
3
+ *
4
+ * This package contains **no platform client, and names no platform.** Contract §4.2 keeps
5
+ * publishing platforms out of the runtime and §1.2 explicitly rules out prescribing particular
6
+ * release targets; §4.3 places provider and release configuration in Integration. Contract §22's
7
+ * own wording for this work package names two platforms, and following that wording literally
8
+ * would have put an adopter's channel semantics inside the runtime — the dependency direction
9
+ * §4.3 forbids.
10
+ *
11
+ * So what lives here is the shape an adopter implements, plus the resumable machinery that shape
12
+ * plugs into. The only implementation in this package is {@link RecordingReleaseAdapter}, a test
13
+ * double.
14
+ */
15
+ import { ReleaseErrorCodes, releaseError } from "./errors.js";
16
+ /** Adapters by destination. */
17
+ export class AdapterRegistry {
18
+ #byDestination = new Map();
19
+ constructor(adapters = []) {
20
+ for (const adapter of adapters)
21
+ this.register(adapter);
22
+ }
23
+ /** Register an adapter, replacing any previous one for its destination. */
24
+ register(adapter) {
25
+ this.#byDestination.set(adapter.destination, adapter);
26
+ }
27
+ /** The adapter for a destination, or `undefined`. */
28
+ find(destination) {
29
+ return this.#byDestination.get(destination);
30
+ }
31
+ /**
32
+ * The adapter for a destination.
33
+ *
34
+ * @throws {AldusError} `ALDUS_RELEASE_ADAPTER_NOT_REGISTERED` when none is registered. Refusing
35
+ * is deliberate: a missing adapter means an operator declared work nothing can perform, and
36
+ * skipping it would report a complete release that never touched the destination.
37
+ */
38
+ require(destination) {
39
+ const adapter = this.#byDestination.get(destination);
40
+ if (adapter === undefined) {
41
+ throw releaseError(ReleaseErrorCodes.ADAPTER_NOT_REGISTERED, `No release adapter is registered for destination "${destination}".`, { category: "validation", retryable: false, details: { destination } });
42
+ }
43
+ return adapter;
44
+ }
45
+ }
46
+ /**
47
+ * A test double that records what it was asked to do.
48
+ *
49
+ * Counting executions is the point: the double-publish tests assert that a *real* second
50
+ * execution never happened, which a spy on the executor could not establish.
51
+ */
52
+ export class RecordingReleaseAdapter {
53
+ destination;
54
+ /** Every request passed to {@link execute}, in order. */
55
+ executed = [];
56
+ /** Every request passed to {@link lookup}, in order. */
57
+ lookedUp = [];
58
+ #options;
59
+ /** Remote state, mutable so a test can simulate a destination that already holds a result. */
60
+ remote;
61
+ /**
62
+ * Present only when the destination can be queried.
63
+ *
64
+ * An own property assigned in the constructor rather than a prototype method, because
65
+ * `withoutLookup` has to make `lookup` genuinely **absent**. A method that returns "not found"
66
+ * would be indistinguishable from a destination that was queried and had nothing — and those
67
+ * are opposite situations: one means the operation still needs to run, the other means nobody
68
+ * can say. Deleting a prototype method does not remove it from the instance, which is the bug
69
+ * this shape avoids.
70
+ */
71
+ lookup;
72
+ constructor(destination, options = {}) {
73
+ this.destination = destination;
74
+ this.#options = options;
75
+ this.remote = new Map(Object.entries(options.remote ?? {}));
76
+ if (options.withoutLookup !== true) {
77
+ this.lookup = (request) => {
78
+ this.lookedUp.push(request);
79
+ return Promise.resolve(this.remote.get(request.idempotencyKey) ?? { exists: false });
80
+ };
81
+ }
82
+ }
83
+ execute(request) {
84
+ this.executed.push(request);
85
+ const scripted = this.#options.outcomes?.[request.operation.operationId];
86
+ const outcome = scripted ?? {
87
+ status: "succeeded",
88
+ remoteId: `remote-${request.operation.operationId}`,
89
+ };
90
+ if (outcome.status === "succeeded") {
91
+ this.remote.set(request.idempotencyKey, {
92
+ exists: true,
93
+ ...(outcome.remoteId === undefined ? {} : { remoteId: outcome.remoteId }),
94
+ ...(outcome.remoteUrl === undefined ? {} : { remoteUrl: outcome.remoteUrl }),
95
+ });
96
+ }
97
+ return Promise.resolve(outcome);
98
+ }
99
+ /** How many times an operation was actually sent to the destination. */
100
+ executionCount(operationId) {
101
+ return this.executed.filter((request) => request.operation.operationId === operationId).length;
102
+ }
103
+ }
104
+ //# sourceMappingURL=adapter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adapter.js","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAGH,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AA4E9D,+BAA+B;AAC/B,MAAM,OAAO,eAAe;IACjB,cAAc,GAAG,IAAI,GAAG,EAA0B,CAAC;IAE5D,YAAY,QAAQ,GAA8B,EAAE;QAClD,KAAK,MAAM,OAAO,IAAI,QAAQ;YAAE,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IACzD,CAAC;IAED,2EAA2E;IAC3E,QAAQ,CAAC,OAAuB;QAC9B,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,OAAO,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;IACxD,CAAC;IAED,qDAAqD;IACrD,IAAI,CAAC,WAAmB;QACtB,OAAO,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IAC9C,CAAC;IAED;;;;;;OAMG;IACH,OAAO,CAAC,WAAmB;QACzB,MAAM,OAAO,GAAG,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;QACrD,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;YAC1B,MAAM,YAAY,CAChB,iBAAiB,CAAC,sBAAsB,EACxC,qDAAqD,WAAW,IAAI,EACpE,EAAE,QAAQ,EAAE,YAAY,EAAE,SAAS,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AAM,EAAE,WAAW;YACnB,QAAQ,EAAE,UAAU,OAAO,CAAC,SAAS,CAAC,WAAW,EAAE;SACpD,CAAC;QACF,IAAI,OAAO,CAAC,MAAM,KAAK,WAAW,EAAE,CAAC;YACnC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,cAAc,EAAE;gBACtC,MAAM,EAAE,IAAI;gBACZ,GAAG,CAAC,OAAO,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAAE,CAAC;gBACzE,GAAG,CAAC,OAAO,CAAC,SAAS,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,OAAO,CAAC,SAAS,EAAE,CAAC;aAC7E,CAAC,CAAC;QACL,CAAC;QACD,OAAO,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IAClC,CAAC;IAED,wEAAwE;IACxE,cAAc,CAAC,WAAmB;QAChC,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,SAAS,CAAC,WAAW,KAAK,WAAW,CAAC,CAAC,MAAM,CAAC;IACjG,CAAC;CACF"}
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Release authorization (architecture contract §13.4, §17, §18.1).
3
+ *
4
+ * This package does **not** decide whether a release is approved. `@aldus-runtime/gate-engine` already
5
+ * models §13.4's separation of uploading from making public as two gates granting two
6
+ * operations, and derives staleness from bound digests (ADR-0009). Re-deciding any of that here
7
+ * would produce a second approval path — and §3.6 exists because a second path is how an
8
+ * approval that nobody recorded ends up authorizing something.
9
+ *
10
+ * So the executor consumes a verdict through a narrow port, and {@link gateEngineAuthorizer}
11
+ * wires that port to the real engine.
12
+ */
13
+ import type { GateEngine, SubjectsByGate } from "@aldus-runtime/gate-engine";
14
+ /** A verdict on one operation's authority. */
15
+ export interface AuthorityVerdict {
16
+ authorized: boolean;
17
+ /** Why not, when refused. Shown to an operator, so it must name the gate. */
18
+ explanation?: string;
19
+ /** The gate that granted it, when authorized — recorded for trace (contract §20). */
20
+ gateId?: string;
21
+ }
22
+ /**
23
+ * Whatever decides if a release operation may proceed.
24
+ *
25
+ * A port rather than a direct dependency so that the executor can be tested against a refusal
26
+ * without constructing a gate graph, and so an adopter with its own authority model can supply
27
+ * one. The shipped implementation is {@link gateEngineAuthorizer}.
28
+ */
29
+ export interface ReleaseAuthorizer {
30
+ /**
31
+ * Whether `authority` is currently held for this Run.
32
+ *
33
+ * `authority` is the operation string a gate grants, e.g. the separate upload and publication
34
+ * authorities of §13.4.
35
+ */
36
+ check(runId: string, authority: string): Promise<AuthorityVerdict>;
37
+ }
38
+ /**
39
+ * A {@link ReleaseAuthorizer} backed by the gate engine (contract §13).
40
+ *
41
+ * `subjects` are the current digests of everything the gates bind — the final render, captions,
42
+ * metadata, destination, and visibility policy of §13.4. They are supplied by the caller and
43
+ * read afresh on every check, so an approval that was valid when the bundle was assembled and
44
+ * has since drifted is refused at the moment of release rather than at the moment of planning.
45
+ */
46
+ export declare function gateEngineAuthorizer(engine: GateEngine, subjects: SubjectsByGate | (() => SubjectsByGate | Promise<SubjectsByGate>)): ReleaseAuthorizer;
47
+ /**
48
+ * An authorizer that permits everything.
49
+ *
50
+ * For operations that genuinely need no approval, and for tests exercising execution mechanics
51
+ * rather than authority. Deliberately named for what it does: a default called
52
+ * `defaultAuthorizer` would be reached for without the reader noticing it approves everything.
53
+ */
54
+ export declare function permitAllAuthorizer(): ReleaseAuthorizer;
55
+ //# sourceMappingURL=authorization.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authorization.d.ts","sourceRoot":"","sources":["../src/authorization.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAE7E,8CAA8C;AAC9C,MAAM,WAAW,gBAAgB;IAC/B,UAAU,EAAE,OAAO,CAAC;IACpB,6EAA6E;IAC7E,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,qFAAqF;IACrF,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,iBAAiB;IAChC;;;;;OAKG;IACH,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;CACpE;AAED;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,UAAU,EAClB,QAAQ,EAAE,cAAc,GAAG,CAAC,MAAM,cAAc,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC,GAC1E,iBAAiB,CAUnB;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,IAAI,iBAAiB,CAEvD"}
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Release authorization (architecture contract §13.4, §17, §18.1).
3
+ *
4
+ * This package does **not** decide whether a release is approved. `@aldus-runtime/gate-engine` already
5
+ * models §13.4's separation of uploading from making public as two gates granting two
6
+ * operations, and derives staleness from bound digests (ADR-0009). Re-deciding any of that here
7
+ * would produce a second approval path — and §3.6 exists because a second path is how an
8
+ * approval that nobody recorded ends up authorizing something.
9
+ *
10
+ * So the executor consumes a verdict through a narrow port, and {@link gateEngineAuthorizer}
11
+ * wires that port to the real engine.
12
+ */
13
+ /**
14
+ * A {@link ReleaseAuthorizer} backed by the gate engine (contract §13).
15
+ *
16
+ * `subjects` are the current digests of everything the gates bind — the final render, captions,
17
+ * metadata, destination, and visibility policy of §13.4. They are supplied by the caller and
18
+ * read afresh on every check, so an approval that was valid when the bundle was assembled and
19
+ * has since drifted is refused at the moment of release rather than at the moment of planning.
20
+ */
21
+ export function gateEngineAuthorizer(engine, subjects) {
22
+ return {
23
+ async check(runId, authority) {
24
+ const current = typeof subjects === "function" ? await subjects() : subjects;
25
+ const result = await engine.authorize(runId, authority, current);
26
+ return result.authorized
27
+ ? { authorized: true, gateId: result.gateId }
28
+ : { authorized: false, explanation: result.explanation };
29
+ },
30
+ };
31
+ }
32
+ /**
33
+ * An authorizer that permits everything.
34
+ *
35
+ * For operations that genuinely need no approval, and for tests exercising execution mechanics
36
+ * rather than authority. Deliberately named for what it does: a default called
37
+ * `defaultAuthorizer` would be reached for without the reader noticing it approves everything.
38
+ */
39
+ export function permitAllAuthorizer() {
40
+ return { check: () => Promise.resolve({ authorized: true }) };
41
+ }
42
+ //# sourceMappingURL=authorization.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authorization.js","sourceRoot":"","sources":["../src/authorization.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AA8BH;;;;;;;GAOG;AACH,MAAM,UAAU,oBAAoB,CAClC,MAAkB,EAClB,QAA2E;IAE3E,OAAO;QACL,KAAK,CAAC,KAAK,CAAC,KAAa,EAAE,SAAiB;YAC1C,MAAM,OAAO,GAAG,OAAO,QAAQ,KAAK,UAAU,CAAC,CAAC,CAAC,MAAM,QAAQ,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC;YAC7E,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,SAAS,CAAC,KAAK,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;YACjE,OAAO,MAAM,CAAC,UAAU;gBACtB,CAAC,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE;gBAC7C,CAAC,CAAC,EAAE,UAAU,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,CAAC,WAAW,EAAE,CAAC;QAC7D,CAAC;KACF,CAAC;AACJ,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,mBAAmB;IACjC,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;AAChE,CAAC"}
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Release bundles (architecture contract §17).
3
+ *
4
+ * A bundle is a **declaration**, not a record of what happened: contract §17 states that
5
+ * "publishing is a domain, not a single command", and the bundle is the domain's unit of intent.
6
+ * What happened lives in `ReleaseReceipt`s, one per operation, in the Run's `release.json`
7
+ * (§7).
8
+ *
9
+ * There is deliberately no persisted bundle state. Execution state is derived from the receipts
10
+ * on every inspection, for the same reason ADR-0009 derives gate state rather than storing it: a
11
+ * stored "in progress" flag survives a crash that the operation it describes did not, and an
12
+ * operator then reads a status that was true once and is not true now.
13
+ */
14
+ import type { BestEffortOperation, ReleaseOperation, RequiredOperation } from "./operation.js";
15
+ /**
16
+ * A set of release operations for one Run.
17
+ *
18
+ * The two lists are the §17 distinction between pre-release hard gates and post-upload
19
+ * best-effort work. Required operations run first, in order; best-effort operations run only
20
+ * once every required one has succeeded, because §17 calls them "post-upload".
21
+ */
22
+ export interface ReleaseBundle {
23
+ /** Identity of this bundle. Part of every operation's idempotency key. */
24
+ bundleId: string;
25
+ /** Run this release belongs to (contract §6). */
26
+ runId: string;
27
+ /** Canonical Episode identity, for the emitted events (contract §6.4). */
28
+ episodeId: string;
29
+ /** Operations whose failure fails the release, in execution order. */
30
+ required: readonly RequiredOperation[];
31
+ /** Operations attempted after the required ones, whose failure is recorded but tolerated. */
32
+ bestEffort: readonly BestEffortOperation[];
33
+ }
34
+ /** Every operation in a bundle, required first, in execution order. */
35
+ export declare function operationsOf(bundle: ReleaseBundle): readonly ReleaseOperation[];
36
+ /**
37
+ * Check a bundle's internal consistency.
38
+ *
39
+ * @throws {AldusError} `ALDUS_RELEASE_EMPTY_BUNDLE` if it declares no operations.
40
+ * @throws {AldusError} `ALDUS_RELEASE_DUPLICATE_OPERATION` if an `operationId` repeats.
41
+ */
42
+ export declare function assertBundleValid(bundle: ReleaseBundle): void;
43
+ /**
44
+ * Derive the idempotency key for one operation (contract §17, §19.1).
45
+ *
46
+ * §17 requires each operation to be "independently idempotent and resumable where the platform
47
+ * allows it", and `ReleaseReceipt.idempotencyKey` is the mechanism. The key is **derived, not
48
+ * supplied**, from the bundle, the operation, its destination, and the digests of what it
49
+ * releases — so a resumed execution computes the identical key without having to remember one,
50
+ * and a changed input produces a different key rather than silently reusing an old outcome.
51
+ *
52
+ * Input hashes are sorted before digesting: the set of things released is what matters, not the
53
+ * order a caller happened to list them in.
54
+ */
55
+ export declare function deriveIdempotencyKey(bundleId: string, operation: ReleaseOperation): string;
56
+ //# sourceMappingURL=bundle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bundle.d.ts","sourceRoot":"","sources":["../src/bundle.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAKH,OAAO,KAAK,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAE/F;;;;;;GAMG;AACH,MAAM,WAAW,aAAa;IAC5B,0EAA0E;IAC1E,QAAQ,EAAE,MAAM,CAAC;IACjB,iDAAiD;IACjD,KAAK,EAAE,MAAM,CAAC;IACd,0EAA0E;IAC1E,SAAS,EAAE,MAAM,CAAC;IAClB,sEAAsE;IACtE,QAAQ,EAAE,SAAS,iBAAiB,EAAE,CAAC;IACvC,6FAA6F;IAC7F,UAAU,EAAE,SAAS,mBAAmB,EAAE,CAAC;CAC5C;AAED,uEAAuE;AACvE,wBAAgB,YAAY,CAAC,MAAM,EAAE,aAAa,GAAG,SAAS,gBAAgB,EAAE,CAE/E;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,aAAa,GAAG,IAAI,CA2B7D;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,gBAAgB,GAAG,MAAM,CAS1F"}