@smthrs/journal 0.0.0-stage → 1.0.0-rc.3
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/CHANGELOG.md +149 -0
- package/LICENSE +21 -0
- package/README.md +206 -2
- package/dist/cjs/CallFact.d.ts +129 -0
- package/dist/cjs/CallFact.d.ts.map +1 -0
- package/dist/cjs/CallFact.js +106 -0
- package/dist/cjs/CallFact.js.map +7 -0
- package/dist/cjs/Consensus.d.ts +440 -0
- package/dist/cjs/Consensus.d.ts.map +1 -0
- package/dist/cjs/Consensus.js +251 -0
- package/dist/cjs/Consensus.js.map +7 -0
- package/dist/cjs/EngineEvent.d.ts +890 -0
- package/dist/cjs/EngineEvent.d.ts.map +1 -0
- package/dist/cjs/EngineEvent.js +383 -0
- package/dist/cjs/EngineEvent.js.map +7 -0
- package/dist/cjs/ExecutionFact.d.ts +216 -0
- package/dist/cjs/ExecutionFact.d.ts.map +1 -0
- package/dist/cjs/ExecutionFact.js +303 -0
- package/dist/cjs/ExecutionFact.js.map +7 -0
- package/dist/cjs/Journal.d.ts +617 -0
- package/dist/cjs/Journal.d.ts.map +1 -0
- package/dist/cjs/Journal.js +190 -0
- package/dist/cjs/Journal.js.map +7 -0
- package/dist/cjs/JournalEvent.d.ts +421 -0
- package/dist/cjs/JournalEvent.d.ts.map +1 -0
- package/dist/cjs/JournalEvent.js +281 -0
- package/dist/cjs/JournalEvent.js.map +7 -0
- package/dist/cjs/JournalGeneration.d.ts +34 -0
- package/dist/cjs/JournalGeneration.d.ts.map +1 -0
- package/dist/cjs/JournalGeneration.js +72 -0
- package/dist/cjs/JournalGeneration.js.map +7 -0
- package/dist/cjs/JournalMetrics.d.ts +72 -0
- package/dist/cjs/JournalMetrics.d.ts.map +1 -0
- package/dist/cjs/JournalMetrics.js +55 -0
- package/dist/cjs/JournalMetrics.js.map +7 -0
- package/dist/cjs/Migrations.d.ts +42 -0
- package/dist/cjs/Migrations.d.ts.map +1 -0
- package/dist/cjs/Migrations.js +58 -0
- package/dist/cjs/Migrations.js.map +7 -0
- package/dist/cjs/OwnerId.d.ts +40 -0
- package/dist/cjs/OwnerId.d.ts.map +1 -0
- package/dist/cjs/OwnerId.js +40 -0
- package/dist/cjs/OwnerId.js.map +7 -0
- package/dist/cjs/Projection.d.ts +29 -0
- package/dist/cjs/Projection.d.ts.map +1 -0
- package/dist/cjs/Projection.js +25 -0
- package/dist/cjs/Projection.js.map +7 -0
- package/dist/cjs/RedactedLogger.d.ts +121 -0
- package/dist/cjs/RedactedLogger.d.ts.map +1 -0
- package/dist/cjs/RedactedLogger.js +235 -0
- package/dist/cjs/RedactedLogger.js.map +7 -0
- package/dist/cjs/Redaction.d.ts +350 -0
- package/dist/cjs/Redaction.d.ts.map +1 -0
- package/dist/cjs/Redaction.js +928 -0
- package/dist/cjs/Redaction.js.map +7 -0
- package/dist/cjs/SqlConsensus.d.ts +44 -0
- package/dist/cjs/SqlConsensus.d.ts.map +1 -0
- package/dist/cjs/SqlConsensus.js +243 -0
- package/dist/cjs/SqlConsensus.js.map +7 -0
- package/dist/cjs/SqlJournal.d.ts +173 -0
- package/dist/cjs/SqlJournal.d.ts.map +1 -0
- package/dist/cjs/SqlJournal.js +1568 -0
- package/dist/cjs/SqlJournal.js.map +7 -0
- package/dist/cjs/StepFact.d.ts +66 -0
- package/dist/cjs/StepFact.d.ts.map +1 -0
- package/dist/cjs/StepFact.js +68 -0
- package/dist/cjs/StepFact.js.map +7 -0
- package/dist/cjs/index.d.ts +95 -0
- package/dist/cjs/index.d.ts.map +1 -0
- package/dist/cjs/index.js +63 -0
- package/dist/cjs/index.js.map +7 -0
- package/dist/cjs/internal/JournalInternalFault.d.ts +37 -0
- package/dist/cjs/internal/JournalInternalFault.d.ts.map +1 -0
- package/dist/cjs/internal/JournalInternalFault.js +43 -0
- package/dist/cjs/internal/JournalInternalFault.js.map +7 -0
- package/dist/cjs/migrations/0001_initial.d.ts +15 -0
- package/dist/cjs/migrations/0001_initial.d.ts.map +1 -0
- package/dist/cjs/migrations/0001_initial.js +54 -0
- package/dist/cjs/migrations/0001_initial.js.map +7 -0
- package/dist/cjs/migrations/0002_checkpoints.d.ts +27 -0
- package/dist/cjs/migrations/0002_checkpoints.d.ts.map +1 -0
- package/dist/cjs/migrations/0002_checkpoints.js +48 -0
- package/dist/cjs/migrations/0002_checkpoints.js.map +7 -0
- package/dist/cjs/migrations/0003_startup_index.d.ts +15 -0
- package/dist/cjs/migrations/0003_startup_index.d.ts.map +1 -0
- package/dist/cjs/migrations/0003_startup_index.js +40 -0
- package/dist/cjs/migrations/0003_startup_index.js.map +7 -0
- package/dist/cjs/migrations/0004_dedup.d.ts +15 -0
- package/dist/cjs/migrations/0004_dedup.d.ts.map +1 -0
- package/dist/cjs/migrations/0004_dedup.js +57 -0
- package/dist/cjs/migrations/0004_dedup.js.map +7 -0
- package/dist/cjs/migrations/0005_run_event_type.d.ts +15 -0
- package/dist/cjs/migrations/0005_run_event_type.d.ts.map +1 -0
- package/dist/cjs/migrations/0005_run_event_type.js +40 -0
- package/dist/cjs/migrations/0005_run_event_type.js.map +7 -0
- package/dist/cjs/migrations/0006_consensus.d.ts +22 -0
- package/dist/cjs/migrations/0006_consensus.d.ts.map +1 -0
- package/dist/cjs/migrations/0006_consensus.js +84 -0
- package/dist/cjs/migrations/0006_consensus.js.map +7 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/test/Notifying.d.ts +65 -0
- package/dist/cjs/test/Notifying.d.ts.map +1 -0
- package/dist/cjs/test/Notifying.js +62 -0
- package/dist/cjs/test/Notifying.js.map +7 -0
- package/dist/cjs/test/TestJournal.d.ts +43 -0
- package/dist/cjs/test/TestJournal.d.ts.map +1 -0
- package/dist/cjs/test/TestJournal.js +43 -0
- package/dist/cjs/test/TestJournal.js.map +7 -0
- package/dist/esm/CallFact.d.ts +129 -0
- package/dist/esm/CallFact.d.ts.map +1 -0
- package/dist/esm/CallFact.js +96 -0
- package/dist/esm/CallFact.js.map +1 -0
- package/dist/esm/Consensus.d.ts +440 -0
- package/dist/esm/Consensus.d.ts.map +1 -0
- package/dist/esm/Consensus.js +454 -0
- package/dist/esm/Consensus.js.map +1 -0
- package/dist/esm/EngineEvent.d.ts +890 -0
- package/dist/esm/EngineEvent.d.ts.map +1 -0
- package/dist/esm/EngineEvent.js +614 -0
- package/dist/esm/EngineEvent.js.map +1 -0
- package/dist/esm/ExecutionFact.d.ts +216 -0
- package/dist/esm/ExecutionFact.d.ts.map +1 -0
- package/dist/esm/ExecutionFact.js +374 -0
- package/dist/esm/ExecutionFact.js.map +1 -0
- package/dist/esm/Journal.d.ts +617 -0
- package/dist/esm/Journal.d.ts.map +1 -0
- package/dist/esm/Journal.js +323 -0
- package/dist/esm/Journal.js.map +1 -0
- package/dist/esm/JournalEvent.d.ts +421 -0
- package/dist/esm/JournalEvent.d.ts.map +1 -0
- package/dist/esm/JournalEvent.js +517 -0
- package/dist/esm/JournalEvent.js.map +1 -0
- package/dist/esm/JournalGeneration.d.ts +34 -0
- package/dist/esm/JournalGeneration.d.ts.map +1 -0
- package/dist/esm/JournalGeneration.js +65 -0
- package/dist/esm/JournalGeneration.js.map +1 -0
- package/dist/esm/JournalMetrics.d.ts +72 -0
- package/dist/esm/JournalMetrics.d.ts.map +1 -0
- package/dist/esm/JournalMetrics.js +79 -0
- package/dist/esm/JournalMetrics.js.map +1 -0
- package/dist/esm/Migrations.d.ts +42 -0
- package/dist/esm/Migrations.d.ts.map +1 -0
- package/dist/esm/Migrations.js +59 -0
- package/dist/esm/Migrations.js.map +1 -0
- package/dist/esm/OwnerId.d.ts +40 -0
- package/dist/esm/OwnerId.d.ts.map +1 -0
- package/dist/esm/OwnerId.js +33 -0
- package/dist/esm/OwnerId.js.map +1 -0
- package/dist/esm/Projection.d.ts +29 -0
- package/dist/esm/Projection.d.ts.map +1 -0
- package/dist/esm/Projection.js +13 -0
- package/dist/esm/Projection.js.map +1 -0
- package/dist/esm/RedactedLogger.d.ts +121 -0
- package/dist/esm/RedactedLogger.d.ts.map +1 -0
- package/dist/esm/RedactedLogger.js +445 -0
- package/dist/esm/RedactedLogger.js.map +1 -0
- package/dist/esm/Redaction.d.ts +350 -0
- package/dist/esm/Redaction.d.ts.map +1 -0
- package/dist/esm/Redaction.js +1584 -0
- package/dist/esm/Redaction.js.map +1 -0
- package/dist/esm/SqlConsensus.d.ts +44 -0
- package/dist/esm/SqlConsensus.d.ts.map +1 -0
- package/dist/esm/SqlConsensus.js +252 -0
- package/dist/esm/SqlConsensus.js.map +1 -0
- package/dist/esm/SqlJournal.d.ts +173 -0
- package/dist/esm/SqlJournal.d.ts.map +1 -0
- package/dist/esm/SqlJournal.js +1858 -0
- package/dist/esm/SqlJournal.js.map +1 -0
- package/dist/esm/StepFact.d.ts +66 -0
- package/dist/esm/StepFact.d.ts.map +1 -0
- package/dist/esm/StepFact.js +50 -0
- package/dist/esm/StepFact.js.map +1 -0
- package/dist/esm/index.d.ts +95 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +95 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/internal/JournalInternalFault.d.ts +37 -0
- package/dist/esm/internal/JournalInternalFault.d.ts.map +1 -0
- package/dist/esm/internal/JournalInternalFault.js +28 -0
- package/dist/esm/internal/JournalInternalFault.js.map +1 -0
- package/dist/esm/migrations/0001_initial.d.ts +15 -0
- package/dist/esm/migrations/0001_initial.d.ts.map +1 -0
- package/dist/esm/migrations/0001_initial.js +32 -0
- package/dist/esm/migrations/0001_initial.js.map +1 -0
- package/dist/esm/migrations/0002_checkpoints.d.ts +27 -0
- package/dist/esm/migrations/0002_checkpoints.d.ts.map +1 -0
- package/dist/esm/migrations/0002_checkpoints.js +38 -0
- package/dist/esm/migrations/0002_checkpoints.js.map +1 -0
- package/dist/esm/migrations/0003_startup_index.d.ts +15 -0
- package/dist/esm/migrations/0003_startup_index.d.ts.map +1 -0
- package/dist/esm/migrations/0003_startup_index.js +18 -0
- package/dist/esm/migrations/0003_startup_index.js.map +1 -0
- package/dist/esm/migrations/0004_dedup.d.ts +15 -0
- package/dist/esm/migrations/0004_dedup.d.ts.map +1 -0
- package/dist/esm/migrations/0004_dedup.js +38 -0
- package/dist/esm/migrations/0004_dedup.js.map +1 -0
- package/dist/esm/migrations/0005_run_event_type.d.ts +15 -0
- package/dist/esm/migrations/0005_run_event_type.d.ts.map +1 -0
- package/dist/esm/migrations/0005_run_event_type.js +18 -0
- package/dist/esm/migrations/0005_run_event_type.js.map +1 -0
- package/dist/esm/migrations/0006_consensus.d.ts +22 -0
- package/dist/esm/migrations/0006_consensus.d.ts.map +1 -0
- package/dist/esm/migrations/0006_consensus.js +69 -0
- package/dist/esm/migrations/0006_consensus.js.map +1 -0
- package/dist/esm/test/Notifying.d.ts +65 -0
- package/dist/esm/test/Notifying.d.ts.map +1 -0
- package/dist/esm/test/Notifying.js +62 -0
- package/dist/esm/test/Notifying.js.map +1 -0
- package/dist/esm/test/TestJournal.d.ts +43 -0
- package/dist/esm/test/TestJournal.d.ts.map +1 -0
- package/dist/esm/test/TestJournal.js +27 -0
- package/dist/esm/test/TestJournal.js.map +1 -0
- package/docs/README.md +164 -0
- package/docs/api.md +639 -0
- package/docs/concepts/compaction.md +157 -0
- package/docs/concepts/idempotency.md +127 -0
- package/docs/concepts/owner-fence.md +124 -0
- package/docs/concepts/redaction.md +218 -0
- package/docs/concepts/state-event-authority.md +159 -0
- package/docs/concepts/two-channels.md +167 -0
- package/docs/guides/commit-state-and-entry.md +114 -0
- package/docs/guides/compact-a-run.md +134 -0
- package/docs/guides/fold-a-projection.md +106 -0
- package/docs/guides/read-a-run.md +139 -0
- package/docs/guides/redact-log-output.md +94 -0
- package/docs/guides/testing.md +124 -0
- package/docs/guides/write-lifecycle-events.md +110 -0
- package/docs/installation.md +133 -0
- package/docs/quickstart.md +143 -0
- package/docs/troubleshooting.md +214 -0
- package/package.json +263 -3
- package/src/CallFact.ts +117 -0
- package/src/Consensus.ts +683 -0
- package/src/EngineEvent.ts +823 -0
- package/src/ExecutionFact.ts +433 -0
- package/src/Journal.ts +688 -0
- package/src/JournalEvent.ts +654 -0
- package/src/JournalGeneration.ts +77 -0
- package/src/JournalMetrics.ts +89 -0
- package/src/Migrations.ts +62 -0
- package/src/OwnerId.ts +42 -0
- package/src/Projection.ts +31 -0
- package/src/RedactedLogger.ts +483 -0
- package/src/Redaction.ts +1784 -0
- package/src/SqlConsensus.ts +344 -0
- package/src/SqlJournal.ts +2732 -0
- package/src/StepFact.ts +69 -0
- package/src/index.ts +109 -0
- package/src/internal/JournalInternalFault.ts +40 -0
- package/src/migrations/0001_initial.ts +41 -0
- package/src/migrations/0002_checkpoints.ts +46 -0
- package/src/migrations/0003_startup_index.ts +19 -0
- package/src/migrations/0004_dedup.ts +43 -0
- package/src/migrations/0005_run_event_type.ts +19 -0
- package/src/migrations/0006_consensus.ts +83 -0
- package/src/test/Notifying.ts +101 -0
- package/src/test/TestJournal.ts +52 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var run_event_type_exports = {};
|
|
30
|
+
__export(run_event_type_exports, {
|
|
31
|
+
runEventType: () => runEventType
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(run_event_type_exports);
|
|
34
|
+
var Effect = __toESM(require("effect/Effect"), 1);
|
|
35
|
+
var SqlClient = __toESM(require("effect/unstable/sql/SqlClient"), 1);
|
|
36
|
+
const runEventType = Effect.gen(function* () {
|
|
37
|
+
const sql = yield* SqlClient.SqlClient;
|
|
38
|
+
yield* sql`CREATE INDEX flows_journal_events_run_event_type_idx ON flows_journal_events (run_id, event_type, seq)`;
|
|
39
|
+
});
|
|
40
|
+
//# sourceMappingURL=0005_run_event_type.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/migrations/0005_run_event_type.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Indexed exact event-type reads within a run.\n *\n * @since 1.0.0\n */\n\nimport * as Effect from \"effect/Effect\"\nimport * as SqlClient from \"effect/unstable/sql/SqlClient\"\n\n/**\n * Keeps filtered cursor reads proportional to the matching entries.\n *\n * @category migrations\n * @since 1.0.0\n */\nexport const runEventType: Effect.Effect<void, unknown, SqlClient.SqlClient> = Effect.gen(function*() {\n const sql = yield* SqlClient.SqlClient\n yield* sql`CREATE INDEX flows_journal_events_run_event_type_idx ON flows_journal_events (run_id, event_type, seq)`\n})\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,aAAwB;AACxB,gBAA2B;AAQpB,MAAM,eAAkE,OAAO,IAAI,aAAY;AACpG,QAAM,MAAM,OAAO,UAAU;AAC7B,SAAO;AACT,CAAC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `SqlConsensus` lease table.
|
|
3
|
+
*
|
|
4
|
+
* This is the private schema of the default consensus strategy: the owner
|
|
5
|
+
* tuple, the two-phase claim columns, and the grant timestamp relocated from
|
|
6
|
+
* `flows_runs`. Lease rows are strategy evidence, never history: heartbeats
|
|
7
|
+
* and lease state never enter the journal.
|
|
8
|
+
*
|
|
9
|
+
* @since 1.0.0
|
|
10
|
+
*/
|
|
11
|
+
import * as Effect from "effect/Effect";
|
|
12
|
+
import * as SqlClient from "effect/unstable/sql/SqlClient";
|
|
13
|
+
/**
|
|
14
|
+
* Creates the `flows_consensus_leases` table and backfills a lease for every
|
|
15
|
+
* running or claimed run when `flows_runs` is already present, so an owner
|
|
16
|
+
* that was driving a run before this migration keeps its fence afterwards.
|
|
17
|
+
*
|
|
18
|
+
* @category migrations
|
|
19
|
+
* @since 1.0.0
|
|
20
|
+
*/
|
|
21
|
+
export declare const consensus: Effect.Effect<void, unknown, SqlClient.SqlClient>;
|
|
22
|
+
//# sourceMappingURL=0006_consensus.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"0006_consensus.d.ts","sourceRoot":"","sources":["../../../src/migrations/0006_consensus.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,SAAS,MAAM,+BAA+B,CAAA;AAE1D;;;;;;;GAOG;AACH,eAAO,MAAM,SAAS,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,OAAO,EAAE,SAAS,CAAC,SAAS,CA2DtE,CAAA"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var consensus_exports = {};
|
|
30
|
+
__export(consensus_exports, {
|
|
31
|
+
consensus: () => consensus
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(consensus_exports);
|
|
34
|
+
var Dialect = __toESM(require("@smthrs/database/Dialect"), 1);
|
|
35
|
+
var Effect = __toESM(require("effect/Effect"), 1);
|
|
36
|
+
var SqlClient = __toESM(require("effect/unstable/sql/SqlClient"), 1);
|
|
37
|
+
const consensus = Effect.gen(function* () {
|
|
38
|
+
const sql = yield* SqlClient.SqlClient;
|
|
39
|
+
yield* sql`CREATE TABLE flows_consensus_leases (
|
|
40
|
+
run_id TEXT PRIMARY KEY CHECK (length(run_id) > 0),
|
|
41
|
+
owner_host_id TEXT,
|
|
42
|
+
owner_pid ${Dialect.integer(sql)} CHECK (owner_pid IS NULL OR (${Dialect.isInteger(sql, sql`owner_pid`)} AND owner_pid >= 0)),
|
|
43
|
+
owner_nonce TEXT,
|
|
44
|
+
granted_at_ms ${Dialect.integer(sql)} CHECK (granted_at_ms IS NULL OR (${Dialect.isInteger(sql, sql`granted_at_ms`)} AND granted_at_ms >= 0)),
|
|
45
|
+
heartbeat_at_ms ${Dialect.integer(sql)} CHECK (heartbeat_at_ms IS NULL OR (${Dialect.isInteger(sql, sql`heartbeat_at_ms`)} AND heartbeat_at_ms >= 0)),
|
|
46
|
+
claim_host_id TEXT,
|
|
47
|
+
claim_pid ${Dialect.integer(sql)} CHECK (claim_pid IS NULL OR (${Dialect.isInteger(sql, sql`claim_pid`)} AND claim_pid >= 0)),
|
|
48
|
+
claim_nonce TEXT,
|
|
49
|
+
claimed_at_ms ${Dialect.integer(sql)} CHECK (claimed_at_ms IS NULL OR (${Dialect.isInteger(sql, sql`claimed_at_ms`)} AND claimed_at_ms >= 0))
|
|
50
|
+
)`;
|
|
51
|
+
const tables = yield* Dialect.tables(sql);
|
|
52
|
+
if (!tables.some((table) => table.name === "flows_runs")) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
yield* sql`
|
|
56
|
+
INSERT INTO flows_consensus_leases (
|
|
57
|
+
run_id,
|
|
58
|
+
owner_host_id,
|
|
59
|
+
owner_pid,
|
|
60
|
+
owner_nonce,
|
|
61
|
+
granted_at_ms,
|
|
62
|
+
heartbeat_at_ms,
|
|
63
|
+
claim_host_id,
|
|
64
|
+
claim_pid,
|
|
65
|
+
claim_nonce,
|
|
66
|
+
claimed_at_ms
|
|
67
|
+
)
|
|
68
|
+
SELECT
|
|
69
|
+
run_id,
|
|
70
|
+
owner_host_id,
|
|
71
|
+
owner_pid,
|
|
72
|
+
owner_nonce,
|
|
73
|
+
CASE WHEN status = 'running' THEN heartbeat_at_ms ELSE NULL END,
|
|
74
|
+
CASE WHEN status = 'running' THEN heartbeat_at_ms ELSE NULL END,
|
|
75
|
+
claim_host_id,
|
|
76
|
+
claim_pid,
|
|
77
|
+
claim_nonce,
|
|
78
|
+
claimed_at_ms
|
|
79
|
+
FROM flows_runs
|
|
80
|
+
WHERE status = 'running' OR claim_host_id IS NOT NULL
|
|
81
|
+
ON CONFLICT (run_id) DO NOTHING
|
|
82
|
+
`;
|
|
83
|
+
});
|
|
84
|
+
//# sourceMappingURL=0006_consensus.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/migrations/0006_consensus.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * The `SqlConsensus` lease table.\n *\n * This is the private schema of the default consensus strategy: the owner\n * tuple, the two-phase claim columns, and the grant timestamp relocated from\n * `flows_runs`. Lease rows are strategy evidence, never history: heartbeats\n * and lease state never enter the journal.\n *\n * @since 1.0.0\n */\n\nimport * as Dialect from \"@smthrs/database/Dialect\"\nimport * as Effect from \"effect/Effect\"\nimport * as SqlClient from \"effect/unstable/sql/SqlClient\"\n\n/**\n * Creates the `flows_consensus_leases` table and backfills a lease for every\n * running or claimed run when `flows_runs` is already present, so an owner\n * that was driving a run before this migration keeps its fence afterwards.\n *\n * @category migrations\n * @since 1.0.0\n */\nexport const consensus: Effect.Effect<void, unknown, SqlClient.SqlClient> = Effect.gen(function*() {\n const sql = yield* SqlClient.SqlClient\n\n yield* sql`CREATE TABLE flows_consensus_leases (\n run_id TEXT PRIMARY KEY CHECK (length(run_id) > 0),\n owner_host_id TEXT,\n owner_pid ${Dialect.integer(sql)} CHECK (owner_pid IS NULL OR (${\n Dialect.isInteger(sql, sql`owner_pid`)\n } AND owner_pid >= 0)),\n owner_nonce TEXT,\n granted_at_ms ${Dialect.integer(sql)} CHECK (granted_at_ms IS NULL OR (${\n Dialect.isInteger(sql, sql`granted_at_ms`)\n } AND granted_at_ms >= 0)),\n heartbeat_at_ms ${Dialect.integer(sql)} CHECK (heartbeat_at_ms IS NULL OR (${\n Dialect.isInteger(sql, sql`heartbeat_at_ms`)\n } AND heartbeat_at_ms >= 0)),\n claim_host_id TEXT,\n claim_pid ${Dialect.integer(sql)} CHECK (claim_pid IS NULL OR (${\n Dialect.isInteger(sql, sql`claim_pid`)\n } AND claim_pid >= 0)),\n claim_nonce TEXT,\n claimed_at_ms ${Dialect.integer(sql)} CHECK (claimed_at_ms IS NULL OR (${\n Dialect.isInteger(sql, sql`claimed_at_ms`)\n } AND claimed_at_ms >= 0))\n )`\n\n const tables = yield* Dialect.tables(sql)\n if (!tables.some((table) => table.name === \"flows_runs\")) {\n return\n }\n\n yield* sql`\n INSERT INTO flows_consensus_leases (\n run_id,\n owner_host_id,\n owner_pid,\n owner_nonce,\n granted_at_ms,\n heartbeat_at_ms,\n claim_host_id,\n claim_pid,\n claim_nonce,\n claimed_at_ms\n )\n SELECT\n run_id,\n owner_host_id,\n owner_pid,\n owner_nonce,\n CASE WHEN status = 'running' THEN heartbeat_at_ms ELSE NULL END,\n CASE WHEN status = 'running' THEN heartbeat_at_ms ELSE NULL END,\n claim_host_id,\n claim_pid,\n claim_nonce,\n claimed_at_ms\n FROM flows_runs\n WHERE status = 'running' OR claim_host_id IS NOT NULL\n ON CONFLICT (run_id) DO NOTHING\n `\n})\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAWA,cAAyB;AACzB,aAAwB;AACxB,gBAA2B;AAUpB,MAAM,YAA+D,OAAO,IAAI,aAAY;AACjG,QAAM,MAAM,OAAO,UAAU;AAE7B,SAAO;AAAA;AAAA;AAAA,gBAGO,QAAQ,QAAQ,GAAG,CAAC,iCAChC,QAAQ,UAAU,KAAK,cAAc,CACvC;AAAA;AAAA,oBAEkB,QAAQ,QAAQ,GAAG,CAAC,qCACpC,QAAQ,UAAU,KAAK,kBAAkB,CAC3C;AAAA,sBACoB,QAAQ,QAAQ,GAAG,CAAC,uCACtC,QAAQ,UAAU,KAAK,oBAAoB,CAC7C;AAAA;AAAA,gBAEc,QAAQ,QAAQ,GAAG,CAAC,iCAChC,QAAQ,UAAU,KAAK,cAAc,CACvC;AAAA;AAAA,oBAEkB,QAAQ,QAAQ,GAAG,CAAC,qCACpC,QAAQ,UAAU,KAAK,kBAAkB,CAC3C;AAAA;AAGA,QAAM,SAAS,OAAO,QAAQ,OAAO,GAAG;AACxC,MAAI,CAAC,OAAO,KAAK,CAAC,UAAU,MAAM,SAAS,YAAY,GAAG;AACxD;AAAA,EACF;AAEA,SAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA4BT,CAAC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"commonjs"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Effect-native analogue of Bazel Skyframe's `NotifyingHelper` and
|
|
3
|
+
* `NotifyingInMemoryGraph`: wrap a record-of-Effect-methods service so a listener hook fires around
|
|
4
|
+
* every operation. The hook runs in the calling fiber, so a hook that dies,
|
|
5
|
+
* interrupts, or awaits a `Latch` injects crashes, fence loss, and exact
|
|
6
|
+
* sequencing at any durable transition point, the mechanism that makes
|
|
7
|
+
* interstitial interleaving bugs testable at all.
|
|
8
|
+
*
|
|
9
|
+
* Deliberately NOT ported from Skyframe: `DeterministicHelper`'s
|
|
10
|
+
* deterministic-scheduler machinery, `ChainedFunction`, and `TrackingAwaiter`.
|
|
11
|
+
* Effect already gives us deterministic fibers, `TestClock`, `Latch`, and
|
|
12
|
+
* failure propagation across fiber joins, so those helpers have no residue
|
|
13
|
+
* here.
|
|
14
|
+
*
|
|
15
|
+
* @since 0.1.0
|
|
16
|
+
*/
|
|
17
|
+
import type * as Context from "effect/Context";
|
|
18
|
+
import * as Effect from "effect/Effect";
|
|
19
|
+
import * as Layer from "effect/Layer";
|
|
20
|
+
/**
|
|
21
|
+
* Whether the hook is firing before or after the delegated operation.
|
|
22
|
+
* Skyframe's `NotifyingHelper.Order`, minus its `BEFORE_AND_AFTER` (pass the
|
|
23
|
+
* same hook body for both firings instead).
|
|
24
|
+
*
|
|
25
|
+
* @category models
|
|
26
|
+
* @since 0.1.0
|
|
27
|
+
*/
|
|
28
|
+
export type Order = "before" | "after";
|
|
29
|
+
/**
|
|
30
|
+
* Listener invoked around every delegated operation. `op` is the service
|
|
31
|
+
* method name (Skyframe's `EventType`, but open-world), `args` the call
|
|
32
|
+
* arguments. Express crash injection as `Effect.die` or `Effect.interrupt`
|
|
33
|
+
* inside the hook, the hook's type stays `Effect<void>` so the wrapped
|
|
34
|
+
* service is structurally identical to the real one.
|
|
35
|
+
*
|
|
36
|
+
* The `after` firing only happens when the operation succeeds; a failed
|
|
37
|
+
* operation already is the interesting event.
|
|
38
|
+
*
|
|
39
|
+
* @category models
|
|
40
|
+
* @since 0.1.0
|
|
41
|
+
*/
|
|
42
|
+
export type Hook = (op: string, order: Order, args: ReadonlyArray<unknown>) => Effect.Effect<void>;
|
|
43
|
+
/**
|
|
44
|
+
* Wraps a service so `hook(op, "before" | "after", args)` fires around every
|
|
45
|
+
* Effect-valued operation, delegating to the real implementation in between.
|
|
46
|
+
*
|
|
47
|
+
* Generic over any record-of-Effect-methods service (`Journal`, `CacheStore`,
|
|
48
|
+
* `AttemptStore`, `RunStore`, ...): Effect-returning methods and plain Effect
|
|
49
|
+
* properties are hooked; non-Effect members (e.g. `Stream`-returning methods)
|
|
50
|
+
* delegate untouched.
|
|
51
|
+
*
|
|
52
|
+
* @category constructors
|
|
53
|
+
* @since 0.1.0
|
|
54
|
+
*/
|
|
55
|
+
export declare const wrap: <S extends object>(service: S, hook: Hook) => S;
|
|
56
|
+
/**
|
|
57
|
+
* Layer form of {@link wrap}: reads the real service from the environment and
|
|
58
|
+
* re-provides the notifying wrapper under the same key, so an existing stack
|
|
59
|
+
* gains a listener without touching its construction.
|
|
60
|
+
*
|
|
61
|
+
* @category layers
|
|
62
|
+
* @since 0.1.0
|
|
63
|
+
*/
|
|
64
|
+
export declare const layer: <Id, S extends object>(tag: Context.Key<Id, S>, hook: Hook) => Layer.Layer<Id, never, Id>;
|
|
65
|
+
//# sourceMappingURL=Notifying.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Notifying.d.ts","sourceRoot":"","sources":["../../../src/test/Notifying.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,KAAK,OAAO,MAAM,gBAAgB,CAAA;AAC9C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AAErC;;;;;;;GAOG;AACH,MAAM,MAAM,KAAK,GAAG,QAAQ,GAAG,OAAO,CAAA;AAEtC;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,IAAI,GAAG,CACjB,EAAE,EAAE,MAAM,EACV,KAAK,EAAE,KAAK,EACZ,IAAI,EAAE,aAAa,CAAC,OAAO,CAAC,KACzB,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;AAExB;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,IAAI,GAAI,CAAC,SAAS,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,IAAI,KAAG,CAyB/D,CAAA;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,KAAK,GAAI,EAAE,EAAE,CAAC,SAAS,MAAM,EACxC,KAAK,OAAO,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC,EACvB,MAAM,IAAI,KACT,KAAK,CAAC,KAAK,CAAC,EAAE,EAAE,KAAK,EAAE,EAAE,CAAyE,CAAA"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var Notifying_exports = {};
|
|
30
|
+
__export(Notifying_exports, {
|
|
31
|
+
layer: () => layer,
|
|
32
|
+
wrap: () => wrap
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(Notifying_exports);
|
|
35
|
+
var Effect = __toESM(require("effect/Effect"), 1);
|
|
36
|
+
var Layer = __toESM(require("effect/Layer"), 1);
|
|
37
|
+
const wrap = (service, hook) => {
|
|
38
|
+
const wrapped = {};
|
|
39
|
+
for (const key of Object.keys(service)) {
|
|
40
|
+
const value = service[key];
|
|
41
|
+
if (Effect.isEffect(value)) {
|
|
42
|
+
wrapped[key] = hook(key, "before", []).pipe(
|
|
43
|
+
Effect.andThen(value),
|
|
44
|
+
Effect.tap(() => hook(key, "after", []))
|
|
45
|
+
);
|
|
46
|
+
} else if (typeof value === "function") {
|
|
47
|
+
const method = value;
|
|
48
|
+
wrapped[key] = (...args) => {
|
|
49
|
+
const result = method.apply(service, args);
|
|
50
|
+
return Effect.isEffect(result) ? hook(key, "before", args).pipe(
|
|
51
|
+
Effect.andThen(result),
|
|
52
|
+
Effect.tap(() => hook(key, "after", args))
|
|
53
|
+
) : result;
|
|
54
|
+
};
|
|
55
|
+
} else {
|
|
56
|
+
wrapped[key] = value;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return wrapped;
|
|
60
|
+
};
|
|
61
|
+
const layer = (tag, hook) => Layer.effect(tag)(Effect.map(tag, (service) => wrap(service, hook)));
|
|
62
|
+
//# sourceMappingURL=Notifying.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/test/Notifying.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Effect-native analogue of Bazel Skyframe's `NotifyingHelper` and\n * `NotifyingInMemoryGraph`: wrap a record-of-Effect-methods service so a listener hook fires around\n * every operation. The hook runs in the calling fiber, so a hook that dies,\n * interrupts, or awaits a `Latch` injects crashes, fence loss, and exact\n * sequencing at any durable transition point, the mechanism that makes\n * interstitial interleaving bugs testable at all.\n *\n * Deliberately NOT ported from Skyframe: `DeterministicHelper`'s\n * deterministic-scheduler machinery, `ChainedFunction`, and `TrackingAwaiter`.\n * Effect already gives us deterministic fibers, `TestClock`, `Latch`, and\n * failure propagation across fiber joins, so those helpers have no residue\n * here.\n *\n * @since 0.1.0\n */\n\nimport type * as Context from \"effect/Context\"\nimport * as Effect from \"effect/Effect\"\nimport * as Layer from \"effect/Layer\"\n\n/**\n * Whether the hook is firing before or after the delegated operation.\n * Skyframe's `NotifyingHelper.Order`, minus its `BEFORE_AND_AFTER` (pass the\n * same hook body for both firings instead).\n *\n * @category models\n * @since 0.1.0\n */\nexport type Order = \"before\" | \"after\"\n\n/**\n * Listener invoked around every delegated operation. `op` is the service\n * method name (Skyframe's `EventType`, but open-world), `args` the call\n * arguments. Express crash injection as `Effect.die` or `Effect.interrupt`\n * inside the hook, the hook's type stays `Effect<void>` so the wrapped\n * service is structurally identical to the real one.\n *\n * The `after` firing only happens when the operation succeeds; a failed\n * operation already is the interesting event.\n *\n * @category models\n * @since 0.1.0\n */\nexport type Hook = (\n op: string,\n order: Order,\n args: ReadonlyArray<unknown>\n) => Effect.Effect<void>\n\n/**\n * Wraps a service so `hook(op, \"before\" | \"after\", args)` fires around every\n * Effect-valued operation, delegating to the real implementation in between.\n *\n * Generic over any record-of-Effect-methods service (`Journal`, `CacheStore`,\n * `AttemptStore`, `RunStore`, ...): Effect-returning methods and plain Effect\n * properties are hooked; non-Effect members (e.g. `Stream`-returning methods)\n * delegate untouched.\n *\n * @category constructors\n * @since 0.1.0\n */\nexport const wrap = <S extends object>(service: S, hook: Hook): S => {\n const wrapped: Record<string, unknown> = {}\n for (const key of Object.keys(service)) {\n const value = (service as Record<string, unknown>)[key]\n if (Effect.isEffect(value)) {\n wrapped[key] = hook(key, \"before\", []).pipe(\n Effect.andThen(value as Effect.Effect<unknown, unknown, unknown>),\n Effect.tap(() => hook(key, \"after\", []))\n )\n } else if (typeof value === \"function\") {\n const method = value as (...args: Array<unknown>) => unknown\n wrapped[key] = (...args: Array<unknown>) => {\n const result = method.apply(service, args)\n return Effect.isEffect(result)\n ? hook(key, \"before\", args).pipe(\n Effect.andThen(result as Effect.Effect<unknown, unknown, unknown>),\n Effect.tap(() => hook(key, \"after\", args))\n )\n : result\n }\n } else {\n wrapped[key] = value\n }\n }\n return wrapped as S\n}\n\n/**\n * Layer form of {@link wrap}: reads the real service from the environment and\n * re-provides the notifying wrapper under the same key, so an existing stack\n * gains a listener without touching its construction.\n *\n * @category layers\n * @since 0.1.0\n */\nexport const layer = <Id, S extends object>(\n tag: Context.Key<Id, S>,\n hook: Hook\n): Layer.Layer<Id, never, Id> => Layer.effect(tag)(Effect.map(tag, (service) => wrap(service, hook)))\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAkBA,aAAwB;AACxB,YAAuB;AA2ChB,MAAM,OAAO,CAAmB,SAAY,SAAkB;AACnE,QAAM,UAAmC,CAAC;AAC1C,aAAW,OAAO,OAAO,KAAK,OAAO,GAAG;AACtC,UAAM,QAAS,QAAoC,GAAG;AACtD,QAAI,OAAO,SAAS,KAAK,GAAG;AAC1B,cAAQ,GAAG,IAAI,KAAK,KAAK,UAAU,CAAC,CAAC,EAAE;AAAA,QACrC,OAAO,QAAQ,KAAiD;AAAA,QAChE,OAAO,IAAI,MAAM,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC;AAAA,MACzC;AAAA,IACF,WAAW,OAAO,UAAU,YAAY;AACtC,YAAM,SAAS;AACf,cAAQ,GAAG,IAAI,IAAI,SAAyB;AAC1C,cAAM,SAAS,OAAO,MAAM,SAAS,IAAI;AACzC,eAAO,OAAO,SAAS,MAAM,IACzB,KAAK,KAAK,UAAU,IAAI,EAAE;AAAA,UAC1B,OAAO,QAAQ,MAAkD;AAAA,UACjE,OAAO,IAAI,MAAM,KAAK,KAAK,SAAS,IAAI,CAAC;AAAA,QAC3C,IACE;AAAA,MACN;AAAA,IACF,OAAO;AACL,cAAQ,GAAG,IAAI;AAAA,IACjB;AAAA,EACF;AACA,SAAO;AACT;AAUO,MAAM,QAAQ,CACnB,KACA,SAC+B,MAAM,OAAO,GAAG,EAAE,OAAO,IAAI,KAAK,CAAC,YAAY,KAAK,SAAS,IAAI,CAAC,CAAC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Deterministic bundle of the production journal service.
|
|
3
|
+
*
|
|
4
|
+
* This provides the journal and nothing else. A consumer that also needs run
|
|
5
|
+
* state or the step cache composes `@smthrs/run-store/test/TestRunStore` and
|
|
6
|
+
* `@smthrs/step-cache/test/TestCacheStore` over the same database, or takes
|
|
7
|
+
* the whole engine bundle from `@smthrs/engine-store/test/TestStores`.
|
|
8
|
+
*
|
|
9
|
+
* @since 0.1.0
|
|
10
|
+
*/
|
|
11
|
+
import * as Layer from "effect/Layer";
|
|
12
|
+
import * as SqlJournal from "../SqlJournal.ts";
|
|
13
|
+
/**
|
|
14
|
+
* Options for the deterministic journal bundle.
|
|
15
|
+
*
|
|
16
|
+
* The production options with `capacity` and `overflow` made optional. Every
|
|
17
|
+
* field forwards to {@link SqlJournal.layer} unchanged, so a suite can exercise
|
|
18
|
+
* index-bound eviction, the entry byte bound, a custom or noop redactor, and
|
|
19
|
+
* the compaction policy through the bundle instead of hand-assembling the layer
|
|
20
|
+
* stack the bundle exists to hide.
|
|
21
|
+
*
|
|
22
|
+
* The type is derived rather than mirrored because a mirror silently falls
|
|
23
|
+
* behind: the hand-copied list had already lost `maxEntryBytes`, so the one
|
|
24
|
+
* production bound a hostile-payload suite needs was unreachable here.
|
|
25
|
+
*
|
|
26
|
+
* @category models
|
|
27
|
+
* @since 0.1.0
|
|
28
|
+
*/
|
|
29
|
+
export interface TestJournalOptions extends Omit<SqlJournal.SqlJournalOptions, "capacity" | "overflow"> {
|
|
30
|
+
/** Admission-queue bound and `changes` buffer size. Defaults to 1024. */
|
|
31
|
+
readonly capacity?: number | undefined;
|
|
32
|
+
/** Policy applied when the admission queue is full. Defaults to `reject`. */
|
|
33
|
+
readonly overflow?: SqlJournal.SqlJournalOptions["overflow"] | undefined;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Provides the production SQLite journal over an in-memory database.
|
|
37
|
+
* Migrations run before the journal is exposed.
|
|
38
|
+
*
|
|
39
|
+
* @category layers
|
|
40
|
+
* @since 0.1.0
|
|
41
|
+
*/
|
|
42
|
+
export declare const layer: (options?: TestJournalOptions) => Layer.Layer<import("../Journal.ts").Journal, import("effect/unstable/sql/SqlError").SqlError | import("../Journal.ts").JournalError | import("effect/unstable/sql/Migrator").MigrationError, never>;
|
|
43
|
+
//# sourceMappingURL=TestJournal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TestJournal.d.ts","sourceRoot":"","sources":["../../../src/test/TestJournal.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AAErC,OAAO,KAAK,UAAU,MAAM,kBAAkB,CAAA;AAE9C;;;;;;;;;;;;;;;GAeG;AACH,MAAM,WAAW,kBAAmB,SAAQ,IAAI,CAAC,UAAU,CAAC,iBAAiB,EAAE,UAAU,GAAG,UAAU,CAAC;IACrG,yEAAyE;IACzE,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IACtC,6EAA6E;IAC7E,QAAQ,CAAC,QAAQ,CAAC,EAAE,UAAU,CAAC,iBAAiB,CAAC,UAAU,CAAC,GAAG,SAAS,CAAA;CACzE;AAED;;;;;;GAMG;AACH,eAAO,MAAM,KAAK,GAAI,UAAU,kBAAkB,wMAKgC,CAAA"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var TestJournal_exports = {};
|
|
30
|
+
__export(TestJournal_exports, {
|
|
31
|
+
layer: () => layer
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(TestJournal_exports);
|
|
34
|
+
var TestDatabase = __toESM(require("@smthrs/database/test/TestDatabase"), 1);
|
|
35
|
+
var Layer = __toESM(require("effect/Layer"), 1);
|
|
36
|
+
var Migrations = __toESM(require("../Migrations.js"), 1);
|
|
37
|
+
var SqlJournal = __toESM(require("../SqlJournal.js"), 1);
|
|
38
|
+
const layer = (options) => SqlJournal.layer({
|
|
39
|
+
...options,
|
|
40
|
+
capacity: options?.capacity ?? 1024,
|
|
41
|
+
overflow: options?.overflow ?? "reject"
|
|
42
|
+
}).pipe(Layer.provide(Layer.provideMerge(Migrations.layer, TestDatabase.layer)));
|
|
43
|
+
//# sourceMappingURL=TestJournal.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/test/TestJournal.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Deterministic bundle of the production journal service.\n *\n * This provides the journal and nothing else. A consumer that also needs run\n * state or the step cache composes `@smthrs/run-store/test/TestRunStore` and\n * `@smthrs/step-cache/test/TestCacheStore` over the same database, or takes\n * the whole engine bundle from `@smthrs/engine-store/test/TestStores`.\n *\n * @since 0.1.0\n */\n\nimport * as TestDatabase from \"@smthrs/database/test/TestDatabase\"\nimport * as Layer from \"effect/Layer\"\nimport * as Migrations from \"../Migrations.ts\"\nimport * as SqlJournal from \"../SqlJournal.ts\"\n\n/**\n * Options for the deterministic journal bundle.\n *\n * The production options with `capacity` and `overflow` made optional. Every\n * field forwards to {@link SqlJournal.layer} unchanged, so a suite can exercise\n * index-bound eviction, the entry byte bound, a custom or noop redactor, and\n * the compaction policy through the bundle instead of hand-assembling the layer\n * stack the bundle exists to hide.\n *\n * The type is derived rather than mirrored because a mirror silently falls\n * behind: the hand-copied list had already lost `maxEntryBytes`, so the one\n * production bound a hostile-payload suite needs was unreachable here.\n *\n * @category models\n * @since 0.1.0\n */\nexport interface TestJournalOptions extends Omit<SqlJournal.SqlJournalOptions, \"capacity\" | \"overflow\"> {\n /** Admission-queue bound and `changes` buffer size. Defaults to 1024. */\n readonly capacity?: number | undefined\n /** Policy applied when the admission queue is full. Defaults to `reject`. */\n readonly overflow?: SqlJournal.SqlJournalOptions[\"overflow\"] | undefined\n}\n\n/**\n * Provides the production SQLite journal over an in-memory database.\n * Migrations run before the journal is exposed.\n *\n * @category layers\n * @since 0.1.0\n */\nexport const layer = (options?: TestJournalOptions) =>\n SqlJournal.layer({\n ...options,\n capacity: options?.capacity ?? 1024,\n overflow: options?.overflow ?? \"reject\"\n }).pipe(Layer.provide(Layer.provideMerge(Migrations.layer, TestDatabase.layer)))\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAWA,mBAA8B;AAC9B,YAAuB;AACvB,iBAA4B;AAC5B,iBAA4B;AAgCrB,MAAM,QAAQ,CAAC,YACpB,WAAW,MAAM;AAAA,EACf,GAAG;AAAA,EACH,UAAU,SAAS,YAAY;AAAA,EAC/B,UAAU,SAAS,YAAY;AACjC,CAAC,EAAE,KAAK,MAAM,QAAQ,MAAM,aAAa,WAAW,OAAO,aAAa,KAAK,CAAC,CAAC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Versioned facts for an authorized native cell invocation and its delivered result.
|
|
3
|
+
* @since 1.0.0
|
|
4
|
+
*/
|
|
5
|
+
import * as Context from "effect/Context";
|
|
6
|
+
import * as Schema from "effect/Schema";
|
|
7
|
+
/** Stable harness coordinates, independent of physical attempt or publication order.
|
|
8
|
+
* @category schemas
|
|
9
|
+
* @since 1.0.0
|
|
10
|
+
*/
|
|
11
|
+
export declare const Identity: Schema.Struct<{
|
|
12
|
+
/** Public logical run identity, not an authentication session credential. */
|
|
13
|
+
readonly runId: Schema.String;
|
|
14
|
+
readonly frame: Schema.Int;
|
|
15
|
+
readonly cell: Schema.String;
|
|
16
|
+
readonly ordinal: Schema.Int;
|
|
17
|
+
readonly declaration: Schema.String;
|
|
18
|
+
readonly layers: Schema.$Array<Schema.String>;
|
|
19
|
+
}>;
|
|
20
|
+
/** A call annotation contains data only and never changes an action key.
|
|
21
|
+
* @category schemas
|
|
22
|
+
* @since 1.0.0
|
|
23
|
+
*/
|
|
24
|
+
export declare const Call: Schema.Struct<{
|
|
25
|
+
readonly callId: Schema.String;
|
|
26
|
+
readonly identity: Schema.Struct<{
|
|
27
|
+
/** Public logical run identity, not an authentication session credential. */
|
|
28
|
+
readonly runId: Schema.String;
|
|
29
|
+
readonly frame: Schema.Int;
|
|
30
|
+
readonly cell: Schema.String;
|
|
31
|
+
readonly ordinal: Schema.Int;
|
|
32
|
+
readonly declaration: Schema.String;
|
|
33
|
+
readonly layers: Schema.$Array<Schema.String>;
|
|
34
|
+
}>;
|
|
35
|
+
readonly flowName: Schema.String;
|
|
36
|
+
readonly input: Schema.Codec<Schema.Json, Schema.Json, never, never>;
|
|
37
|
+
/**
|
|
38
|
+
* The resolved declaration's display projection, as its owner encoded it.
|
|
39
|
+
*
|
|
40
|
+
* JSON rather than a struct because the vocabulary belongs to
|
|
41
|
+
* `@smthrs/registry` (`Descriptor.FlowActivity`, `Descriptor.CallPresentation`),
|
|
42
|
+
* which sits above this package: `@smthrs/harness` `Cell.displayDescriptor`
|
|
43
|
+
* encodes it from a typed call and the reading card validates each field
|
|
44
|
+
* before it is displayed, so the journal carries it and claims nothing about
|
|
45
|
+
* it. Absent means the declaration claimed nothing.
|
|
46
|
+
*/
|
|
47
|
+
readonly descriptor: Schema.optional<Schema.Codec<Schema.Json, Schema.Json, never, never>>;
|
|
48
|
+
}>;
|
|
49
|
+
/** Decoded authorized call coordinates.
|
|
50
|
+
* @category models
|
|
51
|
+
* @since 1.0.0
|
|
52
|
+
*/
|
|
53
|
+
export type Call = typeof Call.Type;
|
|
54
|
+
declare const Annotation_base: Context.ServiceClass<Annotation, "@smthrs/journal/CallFact/Annotation", {
|
|
55
|
+
readonly phase: "invoked" | "settled";
|
|
56
|
+
readonly call: Call;
|
|
57
|
+
}>;
|
|
58
|
+
/** Native action annotation; only the existing controller record settles a call.
|
|
59
|
+
* @category services
|
|
60
|
+
* @since 1.0.0
|
|
61
|
+
*/
|
|
62
|
+
export declare class Annotation extends Annotation_base {
|
|
63
|
+
}
|
|
64
|
+
/** Public result vocabulary. Executable outcomes remain in the protected attempt row.
|
|
65
|
+
* @category schemas
|
|
66
|
+
* @since 1.0.0
|
|
67
|
+
*/
|
|
68
|
+
export declare const Result: Schema.Union<readonly [Schema.Struct<{
|
|
69
|
+
readonly outcome: Schema.Literal<"success">;
|
|
70
|
+
readonly value: Schema.Codec<Schema.Json, Schema.Json, never, never>;
|
|
71
|
+
readonly message: Schema.optional<Schema.String>;
|
|
72
|
+
readonly code: Schema.optionalKey<Schema.Never>;
|
|
73
|
+
}>, Schema.Struct<{
|
|
74
|
+
readonly outcome: Schema.Literal<"failure">;
|
|
75
|
+
readonly value: Schema.Codec<Schema.Json, Schema.Json, never, never>;
|
|
76
|
+
readonly message: Schema.optional<Schema.String>;
|
|
77
|
+
readonly code: Schema.optional<Schema.String>;
|
|
78
|
+
}>]>;
|
|
79
|
+
/** Bounded, redacted event projection; a truncation marker is still JSON.
|
|
80
|
+
* @category schemas
|
|
81
|
+
* @since 1.0.0
|
|
82
|
+
*/
|
|
83
|
+
export declare const Fact: Schema.Union<readonly [Schema.Struct<{
|
|
84
|
+
readonly phase: Schema.Literal<"invoked">;
|
|
85
|
+
readonly input: Schema.Codec<Schema.Json, Schema.Json, never, never>;
|
|
86
|
+
readonly descriptor: Schema.optional<Schema.Codec<Schema.Json, Schema.Json, never, never>>;
|
|
87
|
+
readonly version: Schema.Literal<1>;
|
|
88
|
+
readonly callId: Schema.String;
|
|
89
|
+
readonly identity: Schema.Struct<{
|
|
90
|
+
/** Public logical run identity, not an authentication session credential. */
|
|
91
|
+
readonly runId: Schema.String;
|
|
92
|
+
readonly frame: Schema.Int;
|
|
93
|
+
readonly cell: Schema.String;
|
|
94
|
+
readonly ordinal: Schema.Int;
|
|
95
|
+
readonly declaration: Schema.String;
|
|
96
|
+
readonly layers: Schema.$Array<Schema.String>;
|
|
97
|
+
}>;
|
|
98
|
+
readonly flowName: Schema.String;
|
|
99
|
+
}>, Schema.Struct<{
|
|
100
|
+
readonly phase: Schema.Literal<"settled">;
|
|
101
|
+
readonly outcome: Schema.Literals<readonly ["success", "failure"]>;
|
|
102
|
+
readonly value: Schema.Codec<Schema.Json, Schema.Json, never, never>;
|
|
103
|
+
readonly message: Schema.optional<Schema.Codec<Schema.Json, Schema.Json, never, never>>;
|
|
104
|
+
readonly code: Schema.optional<Schema.String>;
|
|
105
|
+
readonly version: Schema.Literal<1>;
|
|
106
|
+
readonly callId: Schema.String;
|
|
107
|
+
readonly identity: Schema.Struct<{
|
|
108
|
+
/** Public logical run identity, not an authentication session credential. */
|
|
109
|
+
readonly runId: Schema.String;
|
|
110
|
+
readonly frame: Schema.Int;
|
|
111
|
+
readonly cell: Schema.String;
|
|
112
|
+
readonly ordinal: Schema.Int;
|
|
113
|
+
readonly declaration: Schema.String;
|
|
114
|
+
readonly layers: Schema.$Array<Schema.String>;
|
|
115
|
+
}>;
|
|
116
|
+
readonly flowName: Schema.String;
|
|
117
|
+
}>]>;
|
|
118
|
+
/** Decoded public native call fact.
|
|
119
|
+
* @category models
|
|
120
|
+
* @since 1.0.0
|
|
121
|
+
*/
|
|
122
|
+
export type Fact = typeof Fact.Type;
|
|
123
|
+
/** The immutable native journal is the durable outbox consumed by the native bridge.
|
|
124
|
+
* @category events
|
|
125
|
+
* @since 1.0.0
|
|
126
|
+
*/
|
|
127
|
+
export declare const eventType = "flows.harness.call-fact.v1";
|
|
128
|
+
export {};
|
|
129
|
+
//# sourceMappingURL=CallFact.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CallFact.d.ts","sourceRoot":"","sources":["../../src/CallFact.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAA;AACzC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAEvC;;;GAGG;AACH,eAAO,MAAM,QAAQ;IACnB,6EAA6E;;;;;;;EAO7E,CAAA;AAEF;;;GAGG;AACH,eAAO,MAAM,IAAI;;;QAbf,6EAA6E;;;;;;;;;;IAkB7E;;;;;;;;;OASG;;EAEH,CAAA;AAEF;;;GAGG;AACH,MAAM,MAAM,IAAI,GAAG,OAAO,IAAI,CAAC,IAAI,CAAA;;oBAOjB,SAAS,GAAG,SAAS;mBACtB,IAAI;;AANrB;;;GAGG;AACH,qBAAa,UAAW,SAAQ,eAGW;CAAG;AAE9C;;;GAGG;AACH,eAAO,MAAM,MAAM;;;;;;;;;;IAajB,CAAA;AASF;;;GAGG;AACH,eAAO,MAAM,IAAI;;;;;;;QA5Ef,6EAA6E;;;;;;;;;;;;;;;;;;QAA7E,6EAA6E;;;;;;;;;IA2F7E,CAAA;AAEF;;;GAGG;AACH,MAAM,MAAM,IAAI,GAAG,OAAO,IAAI,CAAC,IAAI,CAAA;AAEnC;;;GAGG;AACH,eAAO,MAAM,SAAS,+BAA+B,CAAA"}
|