@smthrs/journal 1.0.0-rc.16 → 1.0.0-rc.18
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 +20 -0
- package/README.md +26 -8
- package/dist/cjs/CallFact.d.ts +8 -8
- package/dist/cjs/Consensus.d.ts +26 -6
- package/dist/cjs/Consensus.d.ts.map +1 -1
- package/dist/cjs/Consensus.js +63 -22
- package/dist/cjs/Consensus.js.map +2 -2
- package/dist/cjs/EngineEvent.d.ts +23 -23
- package/dist/cjs/EngineEvent.d.ts.map +1 -1
- package/dist/cjs/EngineEvent.js +3 -2
- package/dist/cjs/EngineEvent.js.map +2 -2
- package/dist/cjs/ExecutionFact.d.ts +5 -5
- package/dist/cjs/Journal.d.ts +77 -2
- package/dist/cjs/Journal.d.ts.map +1 -1
- package/dist/cjs/Journal.js +1 -0
- package/dist/cjs/Journal.js.map +2 -2
- package/dist/cjs/JournalGeneration.d.ts +1 -1
- package/dist/cjs/JournalGeneration.d.ts.map +1 -1
- package/dist/cjs/JournalGeneration.js +10 -1
- package/dist/cjs/JournalGeneration.js.map +2 -2
- package/dist/cjs/JournalMetrics.d.ts +41 -5
- package/dist/cjs/JournalMetrics.d.ts.map +1 -1
- package/dist/cjs/JournalMetrics.js +10 -1
- package/dist/cjs/JournalMetrics.js.map +2 -2
- package/dist/cjs/RedactedLogger.d.ts.map +1 -1
- package/dist/cjs/RedactedLogger.js +5 -3
- package/dist/cjs/RedactedLogger.js.map +2 -2
- package/dist/cjs/Redaction.d.ts +18 -1
- package/dist/cjs/Redaction.d.ts.map +1 -1
- package/dist/cjs/Redaction.js +142 -12
- package/dist/cjs/Redaction.js.map +3 -3
- package/dist/cjs/SqlConsensus.d.ts +4 -3
- package/dist/cjs/SqlConsensus.d.ts.map +1 -1
- package/dist/cjs/SqlConsensus.js +92 -59
- package/dist/cjs/SqlConsensus.js.map +2 -2
- package/dist/cjs/SqlJournal.d.ts.map +1 -1
- package/dist/cjs/SqlJournal.js +370 -131
- package/dist/cjs/SqlJournal.js.map +3 -3
- package/dist/cjs/StepFact.d.ts +1 -1
- package/dist/cjs/TelemetryLog.d.ts +241 -0
- package/dist/cjs/TelemetryLog.d.ts.map +1 -0
- package/dist/cjs/TelemetryLog.js +349 -0
- package/dist/cjs/TelemetryLog.js.map +7 -0
- package/dist/cjs/index.d.ts +5 -0
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +3 -1
- package/dist/cjs/index.js.map +2 -2
- package/dist/cjs/internal/EventTally.d.ts +31 -0
- package/dist/cjs/internal/EventTally.d.ts.map +1 -0
- package/dist/cjs/internal/EventTally.js +32 -0
- package/dist/cjs/internal/EventTally.js.map +7 -0
- package/dist/cjs/internal/JournalDigest.d.ts +24 -0
- package/dist/cjs/internal/JournalDigest.d.ts.map +1 -0
- package/dist/cjs/internal/JournalDigest.js +44 -0
- package/dist/cjs/internal/JournalDigest.js.map +7 -0
- package/dist/cjs/internal/JournalTestObserver.d.ts +41 -0
- package/dist/cjs/internal/JournalTestObserver.d.ts.map +1 -0
- package/dist/cjs/internal/JournalTestObserver.js +38 -0
- package/dist/cjs/internal/JournalTestObserver.js.map +7 -0
- package/dist/cjs/internal/TelemetryText.d.ts +28 -0
- package/dist/cjs/internal/TelemetryText.d.ts.map +1 -0
- package/dist/cjs/internal/TelemetryText.js +44 -0
- package/dist/cjs/internal/TelemetryText.js.map +7 -0
- package/dist/esm/CallFact.d.ts +8 -8
- package/dist/esm/Consensus.d.ts +26 -6
- package/dist/esm/Consensus.d.ts.map +1 -1
- package/dist/esm/Consensus.js +102 -21
- package/dist/esm/Consensus.js.map +1 -1
- package/dist/esm/EngineEvent.d.ts +23 -23
- package/dist/esm/EngineEvent.d.ts.map +1 -1
- package/dist/esm/EngineEvent.js +4 -2
- package/dist/esm/EngineEvent.js.map +1 -1
- package/dist/esm/ExecutionFact.d.ts +5 -5
- package/dist/esm/Journal.d.ts +77 -2
- package/dist/esm/Journal.d.ts.map +1 -1
- package/dist/esm/Journal.js +4 -1
- package/dist/esm/Journal.js.map +1 -1
- package/dist/esm/JournalGeneration.d.ts +1 -1
- package/dist/esm/JournalGeneration.d.ts.map +1 -1
- package/dist/esm/JournalGeneration.js +9 -1
- package/dist/esm/JournalGeneration.js.map +1 -1
- package/dist/esm/JournalMetrics.d.ts +41 -5
- package/dist/esm/JournalMetrics.d.ts.map +1 -1
- package/dist/esm/JournalMetrics.js +38 -6
- package/dist/esm/JournalMetrics.js.map +1 -1
- package/dist/esm/RedactedLogger.d.ts.map +1 -1
- package/dist/esm/RedactedLogger.js +9 -5
- package/dist/esm/RedactedLogger.js.map +1 -1
- package/dist/esm/Redaction.d.ts +18 -1
- package/dist/esm/Redaction.d.ts.map +1 -1
- package/dist/esm/Redaction.js +199 -16
- package/dist/esm/Redaction.js.map +1 -1
- package/dist/esm/SqlConsensus.d.ts +4 -3
- package/dist/esm/SqlConsensus.d.ts.map +1 -1
- package/dist/esm/SqlConsensus.js +34 -22
- package/dist/esm/SqlConsensus.js.map +1 -1
- package/dist/esm/SqlJournal.d.ts.map +1 -1
- package/dist/esm/SqlJournal.js +410 -108
- package/dist/esm/SqlJournal.js.map +1 -1
- package/dist/esm/StepFact.d.ts +1 -1
- package/dist/esm/TelemetryLog.d.ts +241 -0
- package/dist/esm/TelemetryLog.d.ts.map +1 -0
- package/dist/esm/TelemetryLog.js +519 -0
- package/dist/esm/TelemetryLog.js.map +1 -0
- package/dist/esm/index.d.ts +5 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +5 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/internal/EventTally.d.ts +31 -0
- package/dist/esm/internal/EventTally.d.ts.map +1 -0
- package/dist/esm/internal/EventTally.js +27 -0
- package/dist/esm/internal/EventTally.js.map +1 -0
- package/dist/esm/internal/JournalDigest.d.ts +24 -0
- package/dist/esm/internal/JournalDigest.d.ts.map +1 -0
- package/dist/esm/internal/JournalDigest.js +27 -0
- package/dist/esm/internal/JournalDigest.js.map +1 -0
- package/dist/esm/internal/JournalTestObserver.d.ts +41 -0
- package/dist/esm/internal/JournalTestObserver.d.ts.map +1 -0
- package/dist/esm/internal/JournalTestObserver.js +17 -0
- package/dist/esm/internal/JournalTestObserver.js.map +1 -0
- package/dist/esm/internal/TelemetryText.d.ts +28 -0
- package/dist/esm/internal/TelemetryText.d.ts.map +1 -0
- package/dist/esm/internal/TelemetryText.js +28 -0
- package/dist/esm/internal/TelemetryText.js.map +1 -0
- package/docs/README.md +6 -5
- package/docs/api.md +244 -49
- package/docs/concepts/owner-fence.md +4 -1
- package/docs/concepts/redaction.md +45 -2
- package/docs/concepts/state-event-authority.md +5 -4
- package/docs/concepts/two-channels.md +3 -2
- package/docs/guides/read-a-run.md +8 -6
- package/docs/guides/redact-log-output.md +4 -2
- package/docs/guides/testing.md +4 -2
- package/docs/installation.md +23 -9
- package/docs/quickstart.md +58 -3
- package/docs/troubleshooting.md +4 -2
- package/package.json +21 -9
- package/src/Consensus.ts +118 -28
- package/src/EngineEvent.ts +6 -2
- package/src/Journal.ts +85 -2
- package/src/JournalGeneration.ts +13 -1
- package/src/JournalMetrics.ts +53 -6
- package/src/RedactedLogger.ts +10 -4
- package/src/Redaction.ts +252 -16
- package/src/SqlConsensus.ts +135 -83
- package/src/SqlJournal.ts +604 -179
- package/src/TelemetryLog.ts +597 -0
- package/src/index.ts +6 -0
- package/src/internal/EventTally.ts +39 -0
- package/src/internal/JournalDigest.ts +30 -0
- package/src/internal/JournalTestObserver.ts +48 -0
- package/src/internal/TelemetryText.ts +31 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/JournalGeneration.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Durable generations distinguish histories that reuse journal sequences.\n *\n * @since 1.0.0-rc.0\n */\n\nimport * as Dialect from \"@smthrs/database/Dialect\"\nimport * as Effect from \"effect/Effect\"\nimport * as SqlClient from \"effect/sql/SqlClient\"\n\n/**\n * Installs the generation table idempotently. Both the SQL journal and time\n * travel initialize it, including databases whose migration ladder already\n * passed the journal's reserved block. A read-only client installs nothing.\n *\n * @category migrations\n * @since 1.0.0-rc.0\n */\nexport const initialize = Effect.gen(function*() {\n const sql = yield* SqlClient.SqlClient\n // A read-only observer reads the schema it finds and installs nothing.\n if (Dialect.isReadOnly(sql)) return\n const create = sql`\n CREATE TABLE IF NOT EXISTS flows_journal_generations (\n run_id TEXT PRIMARY KEY NOT NULL CHECK (length(run_id) > 0),\n generation ${Dialect.integer(sql)} NOT NULL CHECK (${\n Dialect.isInteger(sql, sql`generation`)\n } AND generation > 0 AND generation <= 9007199254740991),\n after_seq ${Dialect.integer(sql)} NOT NULL CHECK (${\n Dialect.isInteger(sql, sql`after_seq`)\n } AND after_seq >= -1 AND after_seq <= 9007199254740991)\n )\n `\n // The journal layer and time travel's migration both run this, side by side\n // on a host that builds them together. PostgreSQL serializes only what opens\n // a transaction, which takes the schema's writer lock first: two bare\n // CREATE TABLE IF NOT EXISTS statements race in the catalog, and the loser\n // fails on `pg_type_typname_nsp_index`.\n yield* sql.onDialectOrElse({
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,cAAyB;AACzB,aAAwB;AACxB,gBAA2B;AAUpB,MAAM,aAAa,OAAO,IAAI,aAAY;AAC/C,QAAM,MAAM,OAAO,UAAU;AAE7B,MAAI,QAAQ,WAAW,GAAG,EAAG;AAC7B,QAAM,SAAS;AAAA;AAAA;AAAA,mBAGE,QAAQ,QAAQ,GAAG,CAAC,oBACnC,QAAQ,UAAU,KAAK,eAAe,CACxC;AAAA,kBACgB,QAAQ,QAAQ,GAAG,CAAC,oBAClC,QAAQ,UAAU,KAAK,cAAc,CACvC;AAAA;AAAA;
|
|
4
|
+
"sourcesContent": ["/**\n * Durable generations distinguish histories that reuse journal sequences.\n *\n * @since 1.0.0-rc.0\n */\n\nimport * as Dialect from \"@smthrs/database/Dialect\"\nimport * as Effect from \"effect/Effect\"\nimport * as SqlClient from \"effect/sql/SqlClient\"\n\n/**\n * Installs the generation table idempotently. Both the SQL journal and time\n * travel initialize it, including databases whose migration ladder already\n * passed the journal's reserved block. A read-only client installs nothing.\n *\n * @category migrations\n * @since 1.0.0-rc.0\n */\nexport const initialize = Effect.gen(function*() {\n const sql = yield* SqlClient.SqlClient\n // A read-only observer reads the schema it finds and installs nothing.\n if (Dialect.isReadOnly(sql)) return\n const create = sql`\n CREATE TABLE IF NOT EXISTS flows_journal_generations (\n run_id TEXT PRIMARY KEY NOT NULL CHECK (length(run_id) > 0),\n generation ${Dialect.integer(sql)} NOT NULL CHECK (${\n Dialect.isInteger(sql, sql`generation`)\n } AND generation > 0 AND generation <= 9007199254740991),\n after_seq ${Dialect.integer(sql)} NOT NULL CHECK (${\n Dialect.isInteger(sql, sql`after_seq`)\n } AND after_seq >= -1 AND after_seq <= 9007199254740991)\n )\n `\n // The journal layer and time travel's migration both run this, side by side\n // on a host that builds them together. PostgreSQL serializes only what opens\n // a transaction, which takes the schema's writer lock first: two bare\n // CREATE TABLE IF NOT EXISTS statements race in the catalog, and the loser\n // fails on `pg_type_typname_nsp_index`.\n // An installed table costs no writer lock: every Durable Object alarm builds\n // the journal, and the schema's lock would hold up every other writer.\n const installed = sql<{ readonly found: boolean }>`\n SELECT to_regclass('flows_journal_generations') IS NOT NULL AS found\n `\n yield* sql.onDialectOrElse({\n pg: () =>\n Effect.flatMap(\n installed,\n ([row]) => row?.found === true ? Effect.void : Effect.asVoid(sql.withTransaction(create))\n ),\n orElse: () => Effect.asVoid(create)\n })\n})\n\nconst journals = new WeakMap<SqlClient.SqlClient, Set<(runIds: ReadonlyArray<string>) => void>>()\n\n/**\n * Registers a live journal's cache invalidation until its scope closes.\n * Multiple journals over the same SQL client must observe the same rewind.\n *\n * @category lifecycle\n * @since 1.0.0-rc.0\n */\nexport const onTruncate = (forget: (runIds: ReadonlyArray<string>) => void) =>\n Effect.gen(function*() {\n const sql = yield* SqlClient.SqlClient\n let listeners = journals.get(sql)\n if (listeners === undefined) {\n listeners = new Set()\n journals.set(sql, listeners)\n }\n const registered = listeners\n yield* Effect.acquireRelease(\n Effect.sync(() => registered.add(forget)),\n () =>\n Effect.sync(() => {\n registered.delete(forget)\n })\n )\n })\n\n/**\n * Forgets cached identities and allocation floors after a committed truncation.\n * The rewinder must quiesce producers and flush pending admissions first.\n * Database rows remain authoritative; this operation changes no durable data.\n *\n * @category lifecycle\n * @since 1.0.0-rc.0\n */\nexport const forget = (runIds: ReadonlyArray<string>) =>\n Effect.gen(function*() {\n const sql = yield* SqlClient.SqlClient\n yield* Effect.sync(() => {\n for (const invalidate of journals.get(sql) ?? []) invalidate(runIds)\n })\n })\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,cAAyB;AACzB,aAAwB;AACxB,gBAA2B;AAUpB,MAAM,aAAa,OAAO,IAAI,aAAY;AAC/C,QAAM,MAAM,OAAO,UAAU;AAE7B,MAAI,QAAQ,WAAW,GAAG,EAAG;AAC7B,QAAM,SAAS;AAAA;AAAA;AAAA,mBAGE,QAAQ,QAAQ,GAAG,CAAC,oBACnC,QAAQ,UAAU,KAAK,eAAe,CACxC;AAAA,kBACgB,QAAQ,QAAQ,GAAG,CAAC,oBAClC,QAAQ,UAAU,KAAK,cAAc,CACvC;AAAA;AAAA;AAUA,QAAM,YAAY;AAAA;AAAA;AAGlB,SAAO,IAAI,gBAAgB;AAAA,IACzB,IAAI,MACF,OAAO;AAAA,MACL;AAAA,MACA,CAAC,CAAC,GAAG,MAAM,KAAK,UAAU,OAAO,OAAO,OAAO,OAAO,OAAO,IAAI,gBAAgB,MAAM,CAAC;AAAA,IAC1F;AAAA,IACF,QAAQ,MAAM,OAAO,OAAO,MAAM;AAAA,EACpC,CAAC;AACH,CAAC;AAED,MAAM,WAAW,oBAAI,QAA2E;AASzF,MAAM,aAAa,CAACA,YACzB,OAAO,IAAI,aAAY;AACrB,QAAM,MAAM,OAAO,UAAU;AAC7B,MAAI,YAAY,SAAS,IAAI,GAAG;AAChC,MAAI,cAAc,QAAW;AAC3B,gBAAY,oBAAI,IAAI;AACpB,aAAS,IAAI,KAAK,SAAS;AAAA,EAC7B;AACA,QAAM,aAAa;AACnB,SAAO,OAAO;AAAA,IACZ,OAAO,KAAK,MAAM,WAAW,IAAIA,OAAM,CAAC;AAAA,IACxC,MACE,OAAO,KAAK,MAAM;AAChB,iBAAW,OAAOA,OAAM;AAAA,IAC1B,CAAC;AAAA,EACL;AACF,CAAC;AAUI,MAAM,SAAS,CAAC,WACrB,OAAO,IAAI,aAAY;AACrB,QAAM,MAAM,OAAO,UAAU;AAC7B,SAAO,OAAO,KAAK,MAAM;AACvB,eAAW,cAAc,SAAS,IAAI,GAAG,KAAK,CAAC,EAAG,YAAW,MAAM;AAAA,EACrE,CAAC;AACH,CAAC;",
|
|
6
6
|
"names": ["forget"]
|
|
7
7
|
}
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Standard metric definitions for the journal write path.
|
|
3
3
|
*
|
|
4
|
-
* This module
|
|
4
|
+
* This module defines the metric handles, following the shape of Effect's
|
|
5
5
|
* `ClusterMetrics`. `SqlJournal` updates them as emission receipts are
|
|
6
6
|
* produced, so the counters measure admissions on the hot path rather than
|
|
7
7
|
* rows read back. No exporter ships in this package; provide one, for
|
|
8
|
-
* example `@smthrs/observability`, and these counters appear in it.
|
|
8
|
+
* example `@smthrs/observability`, and these counters appear in it. The
|
|
9
|
+
* counters sum over the whole process; {@link tally} counts the entries one
|
|
10
|
+
* effect, such as one request or alarm, committed.
|
|
9
11
|
*
|
|
10
12
|
* @since 0.1.0
|
|
11
13
|
*/
|
|
14
|
+
import * as Effect from "effect/Effect";
|
|
12
15
|
import * as Metric from "effect/Metric";
|
|
13
16
|
/**
|
|
14
17
|
* Counter over journal emissions, dimensioned by `channel` (`durable` or
|
|
@@ -47,8 +50,8 @@ export declare const lossy: {
|
|
|
47
50
|
readonly [Tag in "Accepted" | "Duplicate" | "Dropped"]: Metric.Metric<number, Metric.CounterState<number>>;
|
|
48
51
|
};
|
|
49
52
|
/**
|
|
50
|
-
* Counter over
|
|
51
|
-
* dimensioned by `channel` (
|
|
53
|
+
* Counter over queued entries the writer admitted and then failed to commit,
|
|
54
|
+
* dimensioned by `channel` (`lossy` or `deferred`) and the `code` of the
|
|
52
55
|
* `JournalError` that lost them.
|
|
53
56
|
*
|
|
54
57
|
* **Details**
|
|
@@ -63,10 +66,43 @@ export declare const lossy: {
|
|
|
63
66
|
*/
|
|
64
67
|
export declare const lostEntries: Metric.Counter<number>;
|
|
65
68
|
/**
|
|
66
|
-
* The {@link lostEntries} view for one `JournalError` code.
|
|
69
|
+
* The lossy-channel {@link lostEntries} view for one `JournalError` code.
|
|
67
70
|
*
|
|
68
71
|
* @category metrics
|
|
69
72
|
* @since 1.0.0-rc.1
|
|
70
73
|
*/
|
|
71
74
|
export declare const lost: (code: string) => Metric.Metric<number, Metric.CounterState<number>>;
|
|
75
|
+
/**
|
|
76
|
+
* What one {@link tally} wrote to the journal.
|
|
77
|
+
*
|
|
78
|
+
* @category models
|
|
79
|
+
* @since 1.0.0
|
|
80
|
+
*/
|
|
81
|
+
export interface JournalTally {
|
|
82
|
+
/** New entries committed, counted after their transaction commits; a duplicate is not new. */
|
|
83
|
+
readonly events: number;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Runs `effect` and answers how many new journal entries it committed. An
|
|
87
|
+
* entry counts once its transaction commits, when the journal publishes it,
|
|
88
|
+
* so one rolled back with an enclosing transaction never counts. It counts
|
|
89
|
+
* the entries committed by `effect`'s fiber or by fibers it forks, in
|
|
90
|
+
* tallies nested to any depth. Lossy entries commit on the journal's own
|
|
91
|
+
* writer fiber and are not counted. When `effect` fails, so does `tally`.
|
|
92
|
+
*
|
|
93
|
+
* @example
|
|
94
|
+
* ```ts
|
|
95
|
+
* import { Effect } from "effect"
|
|
96
|
+
* import { JournalMetrics } from "@smthrs/journal"
|
|
97
|
+
*
|
|
98
|
+
* declare const drive: Effect.Effect<void>
|
|
99
|
+
*
|
|
100
|
+
* const logged = Effect.flatMap(JournalMetrics.tally(drive), ([written]) =>
|
|
101
|
+
* Effect.logInfo("drive").pipe(Effect.annotateLogs({ events: written.events })))
|
|
102
|
+
* ```
|
|
103
|
+
*
|
|
104
|
+
* @category metrics
|
|
105
|
+
* @since 1.0.0
|
|
106
|
+
*/
|
|
107
|
+
export declare const tally: <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<[tally: JournalTally, result: A], E, R>;
|
|
72
108
|
//# sourceMappingURL=JournalMetrics.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"JournalMetrics.d.ts","sourceRoot":"","sources":["../../src/JournalMetrics.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"JournalMetrics.d.ts","sourceRoot":"","sources":["../../src/JournalMetrics.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAGvC;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,MAAM,wBAEjB,CAAA;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,OAAO,EAAE;IACpB,QAAQ,EAAE,GAAG,IAAI,UAAU,GAAG,WAAW,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;CAI/F,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,KAAK,EAAE;IAClB,QAAQ,EAAE,GAAG,IAAI,UAAU,GAAG,WAAW,GAAG,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;CAK3G,CAAA;AAED;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,WAAW,wBAEtB,CAAA;AAEF;;;;;GAKG;AACH,eAAO,MAAM,IAAI,GAAI,MAAM,MAAM,KAAG,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,CACrB,CAAA;AAEhE;;;;;GAKG;AACH,MAAM,WAAW,YAAY;IAC3B,8FAA8F;IAC9F,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CACxB;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,KAAK,GAAI,CAAC,EAAE,CAAC,EAAE,CAAC,EAC3B,QAAQ,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,KAC7B,MAAM,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,YAAY,EAAE,MAAM,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAMnD,CAAA"}
|
|
@@ -32,10 +32,13 @@ __export(JournalMetrics_exports, {
|
|
|
32
32
|
lossy: () => lossy,
|
|
33
33
|
lost: () => lost,
|
|
34
34
|
lostEntries: () => lostEntries,
|
|
35
|
+
tally: () => tally,
|
|
35
36
|
writes: () => writes
|
|
36
37
|
});
|
|
37
38
|
module.exports = __toCommonJS(JournalMetrics_exports);
|
|
39
|
+
var Effect = __toESM(require("effect/Effect"), 1);
|
|
38
40
|
var Metric = __toESM(require("effect/Metric"), 1);
|
|
41
|
+
var EventTally = __toESM(require("./internal/EventTally.js"), 1);
|
|
39
42
|
const writes = Metric.counter("flows_journal_writes", {
|
|
40
43
|
description: "Journal emissions by channel and receipt"
|
|
41
44
|
});
|
|
@@ -49,7 +52,13 @@ const lossy = {
|
|
|
49
52
|
Dropped: Metric.withAttributes(writes, { channel: "lossy", receipt: "dropped" })
|
|
50
53
|
};
|
|
51
54
|
const lostEntries = Metric.counter("flows_journal_lost", {
|
|
52
|
-
description: "Admitted
|
|
55
|
+
description: "Admitted journal entries the writer failed to commit"
|
|
53
56
|
});
|
|
54
57
|
const lost = (code) => Metric.withAttributes(lostEntries, { channel: "lossy", code });
|
|
58
|
+
const tally = (effect) => Effect.gen(function* () {
|
|
59
|
+
const accumulator = { events: 0 };
|
|
60
|
+
const open = yield* EventTally.Current;
|
|
61
|
+
const result = yield* Effect.provideService(effect, EventTally.Current, [...open, accumulator]);
|
|
62
|
+
return [{ events: accumulator.events }, result];
|
|
63
|
+
});
|
|
55
64
|
//# sourceMappingURL=JournalMetrics.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/JournalMetrics.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Standard metric definitions for the journal write path.\n *\n * This module
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
4
|
+
"sourcesContent": ["/**\n * Standard metric definitions for the journal write path.\n *\n * This module defines the metric handles, following the shape of Effect's\n * `ClusterMetrics`. `SqlJournal` updates them as emission receipts are\n * produced, so the counters measure admissions on the hot path rather than\n * rows read back. No exporter ships in this package; provide one, for\n * example `@smthrs/observability`, and these counters appear in it. The\n * counters sum over the whole process; {@link tally} counts the entries one\n * effect, such as one request or alarm, committed.\n *\n * @since 0.1.0\n */\n\nimport * as Effect from \"effect/Effect\"\nimport * as Metric from \"effect/Metric\"\nimport * as EventTally from \"./internal/EventTally.ts\"\n\n/**\n * Counter over journal emissions, dimensioned by `channel` (`durable` or\n * `lossy`) and `receipt` (`accepted`, `duplicate`, or `dropped`).\n *\n * **Details**\n *\n * A `durable` emission counts when its receipt is produced, which is after the\n * write transaction returned; under `Journal.transact` that is still inside\n * the caller's transaction, so a receipt that later rolls back with the\n * enclosing transaction has already counted. The counter is throughput\n * evidence, not commit evidence: the journal rows themselves are the latter.\n *\n * @category metrics\n * @since 0.1.0\n */\nexport const writes = Metric.counter(\"flows_journal_writes\", {\n description: \"Journal emissions by channel and receipt\"\n})\n\n/**\n * `writes` views for the durable channel, keyed by the receipt tag\n * `Journal.emitDurable` resolves to.\n *\n * @category metrics\n * @since 0.1.0\n */\nexport const durable: {\n readonly [Tag in \"Accepted\" | \"Duplicate\"]: Metric.Metric<number, Metric.CounterState<number>>\n} = {\n Accepted: Metric.withAttributes(writes, { channel: \"durable\", receipt: \"accepted\" }),\n Duplicate: Metric.withAttributes(writes, { channel: \"durable\", receipt: \"duplicate\" })\n}\n\n/**\n * `writes` views for the lossy channel, keyed by the receipt tag\n * `Journal.emitLossy` resolves to.\n *\n * @category metrics\n * @since 0.1.0\n */\nexport const lossy: {\n readonly [Tag in \"Accepted\" | \"Duplicate\" | \"Dropped\"]: Metric.Metric<number, Metric.CounterState<number>>\n} = {\n Accepted: Metric.withAttributes(writes, { channel: \"lossy\", receipt: \"accepted\" }),\n Duplicate: Metric.withAttributes(writes, { channel: \"lossy\", receipt: \"duplicate\" }),\n Dropped: Metric.withAttributes(writes, { channel: \"lossy\", receipt: \"dropped\" })\n}\n\n/**\n * Counter over queued entries the writer admitted and then failed to commit,\n * dimensioned by `channel` (`lossy` or `deferred`) and the `code` of the\n * `JournalError` that lost them.\n *\n * **Details**\n *\n * A lossy producer rarely calls `flush`, so the failure `flush` reports is not\n * where an operator learns about a lost batch. This counter moves by the number\n * of entries lost the moment the writer gives them up, whether or not anyone\n * is waiting on them.\n *\n * @category metrics\n * @since 1.0.0-rc.1\n */\nexport const lostEntries = Metric.counter(\"flows_journal_lost\", {\n description: \"Admitted journal entries the writer failed to commit\"\n})\n\n/**\n * The lossy-channel {@link lostEntries} view for one `JournalError` code.\n *\n * @category metrics\n * @since 1.0.0-rc.1\n */\nexport const lost = (code: string): Metric.Metric<number, Metric.CounterState<number>> =>\n Metric.withAttributes(lostEntries, { channel: \"lossy\", code })\n\n/**\n * What one {@link tally} wrote to the journal.\n *\n * @category models\n * @since 1.0.0\n */\nexport interface JournalTally {\n /** New entries committed, counted after their transaction commits; a duplicate is not new. */\n readonly events: number\n}\n\n/**\n * Runs `effect` and answers how many new journal entries it committed. An\n * entry counts once its transaction commits, when the journal publishes it,\n * so one rolled back with an enclosing transaction never counts. It counts\n * the entries committed by `effect`'s fiber or by fibers it forks, in\n * tallies nested to any depth. Lossy entries commit on the journal's own\n * writer fiber and are not counted. When `effect` fails, so does `tally`.\n *\n * @example\n * ```ts\n * import { Effect } from \"effect\"\n * import { JournalMetrics } from \"@smthrs/journal\"\n *\n * declare const drive: Effect.Effect<void>\n *\n * const logged = Effect.flatMap(JournalMetrics.tally(drive), ([written]) =>\n * Effect.logInfo(\"drive\").pipe(Effect.annotateLogs({ events: written.events })))\n * ```\n *\n * @category metrics\n * @since 1.0.0\n */\nexport const tally = <A, E, R>(\n effect: Effect.Effect<A, E, R>\n): Effect.Effect<[tally: JournalTally, result: A], E, R> =>\n Effect.gen(function*() {\n const accumulator: EventTally.Accumulator = { events: 0 }\n const open = yield* EventTally.Current\n const result = yield* Effect.provideService(effect, EventTally.Current, [...open, accumulator])\n return [{ events: accumulator.events }, result]\n })\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAcA,aAAwB;AACxB,aAAwB;AACxB,iBAA4B;AAiBrB,MAAM,SAAS,OAAO,QAAQ,wBAAwB;AAAA,EAC3D,aAAa;AACf,CAAC;AASM,MAAM,UAET;AAAA,EACF,UAAU,OAAO,eAAe,QAAQ,EAAE,SAAS,WAAW,SAAS,WAAW,CAAC;AAAA,EACnF,WAAW,OAAO,eAAe,QAAQ,EAAE,SAAS,WAAW,SAAS,YAAY,CAAC;AACvF;AASO,MAAM,QAET;AAAA,EACF,UAAU,OAAO,eAAe,QAAQ,EAA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Root":"","sources":["../../src/RedactedLogger.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AAGH,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAA;AAIzC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AACrC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAEvC,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAA;AAE3C;;;;;;;;;GASG;AACH,eAAO,MAAM,MAAM,EAAE,OAAO,MAAqD,CAAA;AAEjF;;;;;GAKG;AACH,eAAO,MAAM,UAAU,GAAI,QAAQ,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,KAAG,OAA2B,CAAA;AA0LxF;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,cAAc,GAAI,OAAO,OAAO,EAAE,UAAU,SAAS,CAAC,QAAQ,KAAG,OAkB7E,CAAA;AAKD;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,GAAI,QAAQ,OAAO,CAAC,OAAO,EAAE,UAAU,SAAS,CAAC,QAAQ,KAAG,OAAO,CAAC,OA0BhG,CAAA;AAkFD;;;;;;GAMG;AACH,eAAO,MAAM,IAAI,GAAI,OAAO,EAAE,MAAM,EAClC,QAAQ,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,EACtC,UAAU,SAAS,CAAC,OAAO,KAC1B,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAiC/B,CAAA;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,KAAK,GAAI,UAAU,SAAS,CAAC,OAAO,KAAG,KAAK,CAAC,KAAK,CAAC,KAAK,CAUlE,CAAA"}
|
|
@@ -98,7 +98,7 @@ const renderHooks = /* @__PURE__ */ new Set([
|
|
|
98
98
|
"toString",
|
|
99
99
|
"valueOf"
|
|
100
100
|
]);
|
|
101
|
-
const redactError = (error, redactor, seen, depth = 0) => {
|
|
101
|
+
const redactError = (error, redactor, seen, walk, depth = 0) => {
|
|
102
102
|
const memoized = seen.get(error);
|
|
103
103
|
if (memoized !== void 0) return memoized;
|
|
104
104
|
const clone = new Error();
|
|
@@ -117,7 +117,7 @@ const redactError = (error, redactor, seen, depth = 0) => {
|
|
|
117
117
|
redactedName(key, redactor),
|
|
118
118
|
// A credential-named member is replaced wholesale, the way the journal's
|
|
119
119
|
// own walk replaces one, so both halves of the one rule set answer alike.
|
|
120
|
-
Redaction.isSensitiveKey(key) ? Redaction.placeholder : depth + 1 >= renderDepthLimit ? renderDepthMarker :
|
|
120
|
+
Redaction.isSensitiveKey(key) ? Redaction.placeholder : depth + 1 >= renderDepthLimit ? renderDepthMarker : walk(value),
|
|
121
121
|
descriptor.enumerable === true
|
|
122
122
|
);
|
|
123
123
|
}
|
|
@@ -125,7 +125,9 @@ const redactError = (error, redactor, seen, depth = 0) => {
|
|
|
125
125
|
};
|
|
126
126
|
const redactArgument = (value, redactor) => {
|
|
127
127
|
try {
|
|
128
|
-
|
|
128
|
+
const seen = /* @__PURE__ */ new WeakMap();
|
|
129
|
+
const walk = (node, depth = 0) => node instanceof Error ? redactError(node, redactor, seen, (member) => walk(member, depth + 1), depth) : redactor(node);
|
|
130
|
+
return redactor.withErrors === void 0 ? walk(value) : redactor.withErrors(value, (error, member, depth) => redactError(error, redactor, seen, member, depth));
|
|
129
131
|
} catch {
|
|
130
132
|
return unrenderableMarker;
|
|
131
133
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/RedactedLogger.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * The redacting logger: the journal's redaction rules applied to log output.\n *\n * The journal redacts on the write path, so a credential a cell logs or\n * returns never reaches a committed row (`./Redaction.ts`). The operator's\n * terminal was the other place the same credential surfaces: every built-in\n * Effect logger renders through the fiber's `Console`, so an action that hands\n * a token to `Effect.logInfo` wrote it to stderr in full and it reached\n * whatever collected that stream.\n *\n * This module closes that half with the SAME rules rather than a second rule\n * set. {@link wrap} does not re-implement redaction and does not re-format a\n * log line. It redacts the log event itself \u2014 the message, the cause, and the\n * log annotations \u2014 before the wrapped logger is handed it, and it hands that\n * logger a view of the fiber whose `Console` is a redacting console, so\n * whatever the logger renders for itself \u2014 a pretty line, a JSON document \u2014\n * passes through `Redaction.redact` on its way to the stream as well.\n *\n * Both halves carry load. Most built-in loggers write through the fiber's\n * `Console`, which is what covers the pretty line, the `--json` document, and\n * the `.flows/logs/<runId>.log` stream. But a logger is free to read the event\n * instead of rendering it, and one in Effect's own default logger set does:\n * `Logger.tracerLogger` publishes the message as a span event name and\n * `Cause.pretty` of the cause as the span's `effect.cause` attribute, and\n * never reads `Console` at all. Redacting only the console would hide a\n * credential on stderr and export it in clear to whatever OTLP collector is\n * configured.\n *\n * Cost is bounded by the rules themselves: every alternation inside a\n * repetition in `Redaction.diagnosticRules` starts its branches with disjoint\n * characters, so each rule is linear in the length of the line and no input\n * backtracks catastrophically.\n *\n * One deliberate difference from the journal write path. `Redaction.redact`\n * rebuilds an object from its own enumerable entries, which is right for a row\n * that is about to be JSON-encoded and wrong for a terminal: an `Error` keeps\n * `message` and `stack` on non-enumerable properties, so rebuilding one prints\n * `{}` where the operator expected a failure. An `Error` is rebuilt as a plain\n * `Error` instead, carrying its name, message, stack and own members with the\n * rules applied. Its class is NOT preserved. A copy built on the original's\n * prototype inherits everything the prototype defines, an own-key walk sees\n * none of it, and each of `name`, `cause`, `toJSON`, `Symbol.toStringTag` and\n * `nodejs.util.inspect.custom` carried a credential out that way.\n *\n * @since 0.1.0\n */\n\nimport * as Cause from \"effect/Cause\"\nimport * as Console from \"effect/Console\"\nimport * as Context from \"effect/Context\"\nimport * as Effect from \"effect/Effect\"\nimport type * as Fiber from \"effect/Fiber\"\nimport * as Layer from \"effect/Layer\"\nimport * as Logger from \"effect/Logger\"\nimport * as References from \"effect/References\"\nimport * as Redaction from \"./Redaction.ts\"\n\n/**\n * Marks a logger this module already wrapped.\n *\n * Both the CLI and the durable runtime install {@link layer}, and a detached\n * `smithers run` is both at once. Wrapping twice would be correct but pay the\n * rules twice per line, so a wrapped logger is returned unchanged.\n *\n * @since 0.1.0\n * @category type ids\n */\nexport const TypeId: unique symbol = Symbol.for(\"@smthrs/journal/RedactedLogger\")\n\n/**\n * Whether {@link wrap} already wrapped this logger.\n *\n * @since 0.1.0\n * @category predicates\n */\nexport const isRedacted = (logger: Logger.Logger<any, any>): boolean => TypeId in logger\n\n/**\n * Console methods that write caller-supplied values, mapped to whether their\n * arguments carry log output.\n *\n * Only `clear` and `groupEnd` are marked `false`, because those two take no\n * arguments at all: there is nothing for the rules to read and binding them\n * straight through saves a copy per call. Every other method here, `count`,\n * `countReset`, `time`, and `timeEnd` included, accepts a caller-supplied\n * LABEL and prints it, so a label of `api_key=sk-\u2026` reached the terminal\n * through all four of them. `timeLog` already redacted its label, so the pair\n * `time` / `timeLog` also disagreed about what a timer is called; redacting all\n * of them is what makes a label match itself again.\n */\nconst consoleMethods = {\n assert: true,\n clear: false,\n count: true,\n countReset: true,\n debug: true,\n dir: true,\n dirxml: true,\n error: true,\n group: true,\n groupCollapsed: true,\n groupEnd: false,\n info: true,\n log: true,\n table: true,\n time: true,\n timeEnd: true,\n timeLog: true,\n trace: true,\n warn: true\n} as const\n\n/** How deep the logger walks a value before it names it instead. */\nconst renderDepthLimit = 200\n\n/** What the logger renders in place of a value nested past the depth limit. */\nconst renderDepthMarker = \"[Deep]\"\n\n/**\n * The parts of a log message.\n *\n * Effect's logging API passes an array, one entry per argument, including for\n * a single argument. A caller that builds `LogOptions` by hand may pass the\n * message itself, so it is wrapped rather than walked.\n *\n * @since 0.1.0\n * @category redaction\n */\nconst toArray = (message: unknown): ReadonlyArray<unknown> => Array.isArray(message) ? message : [message]\n\n/**\n * Reads one piece of text off `error` and runs it through the rules.\n *\n * Everything a renderer prints about an error is read here, once, and only the\n * redacted result crosses to the copy. A caller's error can define any of these\n * as an accessor that throws, and reading one happens while a log line is\n * rendering, so a refusal costs that piece of text and nothing else.\n */\nconst redactedText = (read: () => unknown, redactor: Redaction.Redactor, fallback: string): string => {\n try {\n return String(redactor(String(read())))\n } catch {\n return fallback\n }\n}\n\n/** `error.stack` through the rules, or `undefined` when it has none to give. */\nconst redactedStack = (error: Error, redactor: Redaction.Redactor): string | undefined => {\n try {\n const stack = error.stack\n // An `Error.stack` is optional. Under `exactOptionalPropertyTypes` an\n // assignment cannot carry the `undefined` a stackless error has, so the\n // copy defines the property instead of assigning it.\n return typeof stack === \"string\" ? String(redactor(stack)) : undefined\n } catch {\n return undefined\n }\n}\n\n/**\n * A member NAME with the rules applied, replaced outright when one fires.\n *\n * The treatment `Redaction.redact` gives an object key, for the same reason: a\n * name is text a renderer prints. Rewriting one in place would change what it\n * reads as and redaction would stop being a fixed point, so a name that matches\n * becomes the placeholder whole.\n */\nconst redactedName = (key: string, redactor: Redaction.Redactor): string => {\n const redacted = String(redactor(key))\n return redacted === key ? key : Redaction.placeholder\n}\n\n/**\n * Own names the copy never carries, because a renderer CALLS them.\n *\n * `name`, `message` and `stack` are defined from the rules above instead. The\n * rest are hooks: a redacted `toString` or `valueOf` would leave a string under\n * a name the language calls, and `String(error)` would then throw from inside\n * the renderer, which is the failure mode this module exists to avoid.\n */\nconst renderHooks: ReadonlySet<string> = new Set([\n \"constructor\",\n \"message\",\n \"name\",\n \"stack\",\n \"toJSON\",\n \"toString\",\n \"valueOf\"\n])\n\n/**\n * A copy of `error` carrying the same information with the rules applied.\n *\n * A PLAIN `Error`, never a copy built on the original's prototype. A prototype\n * is an unbounded leak surface and an own-key walk never looks at one: an\n * inherited `name`, `cause`, `toJSON`, `Symbol.toStringTag` or\n * `nodejs.util.inspect.custom` each carried a credential straight to an OTLP\n * span attribute or to the operator's terminal, one per review round, and a\n * getter anywhere on the chain is the same hole with a different name. So\n * nothing inherited crosses. Only redacted text does: the name, the message,\n * the stack, and the error's own members, each read once here and stored as\n * data, since a getter carried across unchanged would hand the unredacted\n * value to whatever reads it next.\n *\n * The copy is not an instance of the original's class, so a renderer that\n * special-cases `instanceof MyError` sees a plain `Error`. That is the fidelity\n * trade the release policy already records for every other value, and it is\n * the trade the same problem's earlier, crashing form was settled with: a copy\n * on a host prototype, such as the `DOMException` an `AbortSignal` carries as\n * its reason, is an impostor whose brand check throws from inside `Cause.pretty`\n * and kills the run the line was describing.\n */\nconst redactError = (\n error: Error,\n redactor: Redaction.Redactor,\n seen: WeakMap<Error, Error>,\n depth = 0\n): Error => {\n // The memo holds the COPY, not a visited mark: returning the original on a\n // repeat reference put the unredacted error back into the output, so a\n // diamond (two fields naming one error) leaked on its second field. The copy\n // is registered before its own members are walked, so a cycle terminates on\n // it and every reference to one error is the same redacted object.\n const memoized = seen.get(error)\n if (memoized !== undefined) return memoized\n const clone = new Error()\n seen.set(error, clone)\n const define = (key: string, value: unknown, enumerable: boolean): void => {\n Object.defineProperty(clone, key, { value, writable: true, enumerable, configurable: true })\n }\n define(\"name\", redactedText(() => error.name, redactor, \"Error\"), false)\n define(\"message\", redactedText(() => error.message, redactor, \"\"), false)\n define(\"stack\", redactedStack(error, redactor), false)\n // Own NAMES, not `Reflect.ownKeys`. A symbol key never crosses: its\n // description is text no walk can rewrite in place, and the three hooks with\n // no name to skip are symbols too, `Symbol.toPrimitive`,\n // `Symbol.toStringTag`, and `nodejs.util.inspect.custom`.\n for (const key of Object.getOwnPropertyNames(error)) {\n if (renderHooks.has(key)) continue\n const descriptor = Object.getOwnPropertyDescriptor(error, key)!\n const value = \"value\" in descriptor\n ? descriptor.value\n : (error as unknown as Record<PropertyKey, unknown>)[key]\n define(\n redactedName(key, redactor),\n // A credential-named member is replaced wholesale, the way the journal's\n // own walk replaces one, so both halves of the one rule set answer alike.\n Redaction.isSensitiveKey(key)\n ? Redaction.placeholder\n // The depth cap binds under an Error exactly as it does beside one: a\n // deep value carried on a cause can exhaust the stack just as easily.\n : depth + 1 >= renderDepthLimit\n ? renderDepthMarker\n : value instanceof Error\n ? redactError(value, redactor, seen, depth + 1)\n : redactor(value),\n descriptor.enumerable === true\n )\n }\n return clone\n}\n\n/**\n * Redacts one value on its way out of the logger.\n *\n * An `Error` is rebuilt as a plain `Error` whose name, message, stack and own\n * members are redacted, so a renderer that special-cases an `Error` still gets\n * one. Everything else goes through the journal's own rules, which rebuild a\n * value from its plain data: a `Date`, a `Map`, a class instance or a host\n * object therefore reaches the operator in that plain form rather than as\n * itself.\n *\n * That collapse is deliberate, and it now covers the `Error` too. An earlier\n * version rebuilt each value on its own prototype to keep the rendering\n * faithful. Three rounds of review found three ways that could kill the run it\n * was logging, because a host class keeps state a property walk cannot see and\n * a copy of one throws the moment a brand check reads it, and four more found\n * that the prototype an `Error` copy kept was itself the leak: everything it\n * defines is read by a renderer and seen by no own-key walk. A log line is not\n * worth a run, and the rendering it buys is cosmetic.\n *\n * @since 0.1.0\n * @category redaction\n */\nexport const redactArgument = (value: unknown, redactor: Redaction.Redactor): unknown => {\n try {\n return value instanceof Error ? redactError(value, redactor, new WeakMap()) : redactor(value)\n } catch {\n // A logged value is arbitrary and a throw here happens while the line is\n // rendering, which would kill the run the line describes. The marker is\n // deliberately NOT derived from the value: an earlier fallback rendered\n // the value to text and printed it, and that text had never been through\n // the rules, so a credential reached the terminal in clear.\n return unrenderableMarker\n }\n}\n\n/** What the logger renders in place of a value that cannot be rendered. */\nconst unrenderableMarker = \"[Unrenderable]\"\n\n/**\n * A console that runs every value it is handed through `redactor` and then\n * delegates to `target`.\n *\n * @since 0.1.0\n * @category constructors\n */\nexport const redactingConsole = (target: Console.Console, redactor: Redaction.Redactor): Console.Console => {\n const methods = target as unknown as Record<string, (...args: ReadonlyArray<any>) => unknown>\n const view: Record<string, unknown> = {}\n for (const [name, redacts] of Object.entries(consoleMethods)) {\n const method = methods[name]!.bind(target)\n view[name] = redacts\n ? (...args: ReadonlyArray<unknown>) => {\n const redacted = args.map((value) => redactArgument(value, redactor))\n try {\n return method(...redacted)\n } catch {\n // The delegate refused what we handed it. Retry with markers, never\n // with a rendering of the values: a rendering has not been through\n // the rules, and printing one is how a credential reached the\n // terminal before. A delegate that refuses the markers too is out of\n // options, and a log line is not worth the run.\n try {\n return method(...redacted.map(() => unrenderableMarker))\n } catch {\n return undefined\n }\n }\n }\n : method\n }\n return view as unknown as Console.Console\n}\n\n/**\n * A view of `fiber` whose console redacts and whose log annotations are\n * already redacted.\n *\n * The view inherits from the fiber itself, so `id`, `currentSpan`, and every\n * other member a logger reads answer exactly as before; only the two\n * references a logger renders from are substituted.\n */\nconst redactedFiber = (\n fiber: Fiber.Fiber<unknown, unknown>,\n redactor: Redaction.Redactor\n): Fiber.Fiber<unknown, unknown> => {\n const view = Object.create(fiber) as Fiber.Fiber<unknown, unknown>\n Object.defineProperty(view, \"getRef\", {\n value: <X>(reference: Context.Reference<X>): X => {\n const current = fiber.getRef(reference)\n if (reference === (Console.Console as unknown as Context.Reference<X>)) {\n return redactingConsole(current as Console.Console, redactor) as X\n }\n if (reference === (References.CurrentLogAnnotations as unknown as Context.Reference<X>)) {\n // The same treatment a message part gets, so one log event obeys one\n // rule and an annotated Error is redacted like a logged one.\n return redactArgument(current, redactor) as X\n }\n return current\n }\n })\n return view\n}\n\n/**\n * Rebuilds the frame chain as redacted data. Evaluate the lazy stack here:\n * carrying its original function would defer the credential past the boundary.\n * The same depth cap as logged values also bounds cyclic parent chains.\n */\nconst redactedFrame = (\n frame: References.StackFrame | undefined,\n redactor: Redaction.Redactor,\n depth = 0\n): References.StackFrame | undefined => {\n if (frame === undefined) return undefined\n if (depth >= renderDepthLimit) {\n return { name: renderDepthMarker, stack: () => undefined, parent: undefined }\n }\n const stack = redactedText(() => frame.stack() ?? \"\", redactor, unrenderableMarker)\n return {\n name: redactedText(() => frame.name, redactor, unrenderableMarker),\n stack: () => stack,\n parent: redactedFrame(frame.parent, redactor, depth + 1)\n }\n}\n\n/**\n * The log event's cause with the rules applied to failures, defects and stack\n * annotations. `Cause.pretty` renders these frames after rendering the error;\n * the tracer exports that text without passing through the redacting console.\n * Interruptions also carry both their own and the interruptor's frame chains.\n * Rebuild reasons and annotation maps so the original cause stays untouched.\n */\nconst redactedCause = (\n cause: Cause.Cause<unknown>,\n redactor: Redaction.Redactor\n): Cause.Cause<unknown> => {\n if (cause.reasons.length === 0) return cause\n return Cause.fromReasons(cause.reasons.map((reason) => {\n const annotations = new Map(reason.annotations)\n for (const key of [Cause.StackTrace.key, Cause.InterruptorStackTrace.key]) {\n if (annotations.has(key)) {\n annotations.set(key, redactedFrame(annotations.get(key) as References.StackFrame | undefined, redactor))\n }\n }\n const copy = reason._tag === \"Fail\"\n ? Cause.makeFailReason(redactArgument(reason.error, redactor))\n : reason._tag === \"Die\"\n ? Cause.makeDieReason(redactArgument(reason.defect, redactor))\n : Cause.makeInterruptReason(reason.fiberId)\n return copy.annotate(Context.makeUnsafe(annotations))\n }))\n}\n\n/**\n * Returns `logger` with the journal's redaction rules over everything it\n * renders. A logger this module already wrapped is returned unchanged.\n *\n * @since 0.1.0\n * @category combinators\n */\nexport const wrap = <Message, Output>(\n logger: Logger.Logger<Message, Output>,\n options?: Redaction.Options\n): Logger.Logger<Message, Output> => {\n if (isRedacted(logger)) return logger\n // A logger NAMES a too-deep value rather than throwing: a throw is caught one\n // frame up and costs the operator every argument on the line, not just the\n // deep one. A log line is a diagnostic, so it takes the diagnostic rules. A\n // caller passing its own `onTooDeep` or `rules` still wins.\n const redactor = Redaction.make({ onTooDeep: \"name\", rules: Redaction.diagnosticRules, ...options })\n const wrapped = Logger.make<Message, Output>((logOptions) =>\n logger.log({\n ...logOptions,\n // The message is redacted here, not only behind the fiber's Console,\n // because a logger is free to read it directly: `Logger.tracerLogger`\n // ships in Effect's default set and publishes the message as a span\n // event name, so a Console-only substitution would export a credential\n // in clear to whatever collector is configured.\n //\n // Effect delivers the message as an array of parts, one per argument,\n // including the single-argument case; a non-array reaches here only from\n // a caller that builds `LogOptions` by hand, and `toArray` covers it\n // without a branch no test could reach through the logging API.\n message: (toArray(logOptions.message).map((part) => redactArgument(part, redactor))) as Message,\n // The cause travels the same way and for the same reason. A failure is\n // logged as a `Cause`, not as message parts (`Effect.logError(cause)`\n // moves it out of the arguments), and `Logger.tracerLogger` renders it\n // itself into the span's `effect.cause` attribute without going near the\n // console, so an error message carrying a token would leave the process\n // in clear.\n cause: redactedCause(logOptions.cause, redactor),\n fiber: redactedFiber(logOptions.fiber, redactor)\n })\n )\n Object.defineProperty(wrapped, TypeId, { value: true })\n return wrapped\n}\n\n/**\n * Replaces the active logger set with redacting wrappers of the same loggers.\n *\n * It composes over whatever loggers are already installed rather than\n * choosing one, so an operator keeps the FORMAT they had, meaning their own\n * logger and its layout, though a value inside a line is rendered from its\n * redacted plain data rather than as its own class, and a host that\n * installed its own logger keeps it too.\n *\n * @since 0.1.0\n * @category layers\n */\nexport const layer = (options?: Redaction.Options): Layer.Layer<never> =>\n Layer.effect(\n Logger.CurrentLoggers,\n Effect.withFiber((fiber) =>\n Effect.sync(() => {\n const wrapped = new Set<Logger.Logger<unknown, any>>()\n for (const logger of fiber.getRef(Logger.CurrentLoggers)) wrapped.add(wrap(logger, options))\n return wrapped\n })\n )\n )\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA+CA,YAAuB;AACvB,cAAyB;AACzB,cAAyB;AACzB,aAAwB;AAExB,YAAuB;AACvB,aAAwB;AACxB,iBAA4B;AAC5B,gBAA2B;AAYpB,MAAM,SAAwB,uBAAO,IAAI,gCAAgC;AAQzE,MAAM,aAAa,CAAC,WAA6C,UAAU;AAelF,MAAM,iBAAiB;AAAA,EACrB,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,OAAO;AAAA,EACP,YAAY;AAAA,EACZ,OAAO;AAAA,EACP,KAAK;AAAA,EACL,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,OAAO;AAAA,E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,UAAU,OAAO,GAAG,KAAK;AACvE,SAAO,WAAW,aAAa,MAAM,MAAM,SAAS,UAAU,EAAE,GAAG,KAAK;AACxE,SAAO,SAAS,cAAc,OAAO,QAAQ,GAAG,KAAK;AAKrD,aAAW,OAAO,OAAO,oBAAoB,KAAK,GAAG;AACnD,QAAI,YAAY,IAAI,GAAG,EAAG;AAC1B,UAAM,aAAa,OAAO,yBAAyB,OAAO,GAAG;AAC7D,UAAM,QAAQ,WAAW,aACrB,WAAW,QACV,MAAkD,GAAG;AAC1D;AAAA,MACE,aAAa,KAAK,QAAQ;AAAA;AAAA;AAAA,MAG1B,UAAU,eAAe,GAAG,IACxB,UAAU,cAGV,QAAQ,KAAK,mBACb,oBACA,
|
|
4
|
+
"sourcesContent": ["/**\n * The redacting logger: the journal's redaction rules applied to log output.\n *\n * The journal redacts on the write path, so a credential a cell logs or\n * returns never reaches a committed row (`./Redaction.ts`). The operator's\n * terminal was the other place the same credential surfaces: every built-in\n * Effect logger renders through the fiber's `Console`, so an action that hands\n * a token to `Effect.logInfo` wrote it to stderr in full and it reached\n * whatever collected that stream.\n *\n * This module closes that half with the SAME rules rather than a second rule\n * set. {@link wrap} does not re-implement redaction and does not re-format a\n * log line. It redacts the log event itself \u2014 the message, the cause, and the\n * log annotations \u2014 before the wrapped logger is handed it, and it hands that\n * logger a view of the fiber whose `Console` is a redacting console, so\n * whatever the logger renders for itself \u2014 a pretty line, a JSON document \u2014\n * passes through `Redaction.redact` on its way to the stream as well.\n *\n * Both halves carry load. Most built-in loggers write through the fiber's\n * `Console`, which is what covers the pretty line, the `--json` document, and\n * the `.flows/logs/<runId>.log` stream. But a logger is free to read the event\n * instead of rendering it, and one in Effect's own default logger set does:\n * `Logger.tracerLogger` publishes the message as a span event name and\n * `Cause.pretty` of the cause as the span's `effect.cause` attribute, and\n * never reads `Console` at all. Redacting only the console would hide a\n * credential on stderr and export it in clear to whatever OTLP collector is\n * configured.\n *\n * Cost is bounded by the rules themselves: every alternation inside a\n * repetition in `Redaction.diagnosticRules` starts its branches with disjoint\n * characters, so each rule is linear in the length of the line and no input\n * backtracks catastrophically.\n *\n * One deliberate difference from the journal write path. `Redaction.redact`\n * rebuilds an object from its own enumerable entries, which is right for a row\n * that is about to be JSON-encoded and wrong for a terminal: an `Error` keeps\n * `message` and `stack` on non-enumerable properties, so rebuilding one prints\n * `{}` where the operator expected a failure. An `Error` is rebuilt as a plain\n * `Error` instead, carrying its name, message, stack and own members with the\n * rules applied. Its class is NOT preserved. A copy built on the original's\n * prototype inherits everything the prototype defines, an own-key walk sees\n * none of it, and each of `name`, `cause`, `toJSON`, `Symbol.toStringTag` and\n * `nodejs.util.inspect.custom` carried a credential out that way.\n *\n * @since 0.1.0\n */\n\nimport * as Cause from \"effect/Cause\"\nimport * as Console from \"effect/Console\"\nimport * as Context from \"effect/Context\"\nimport * as Effect from \"effect/Effect\"\nimport type * as Fiber from \"effect/Fiber\"\nimport * as Layer from \"effect/Layer\"\nimport * as Logger from \"effect/Logger\"\nimport * as References from \"effect/References\"\nimport * as Redaction from \"./Redaction.ts\"\n\n/**\n * Marks a logger this module already wrapped.\n *\n * Both the CLI and the durable runtime install {@link layer}, and a detached\n * `smithers run` is both at once. Wrapping twice would be correct but pay the\n * rules twice per line, so a wrapped logger is returned unchanged.\n *\n * @since 0.1.0\n * @category type ids\n */\nexport const TypeId: unique symbol = Symbol.for(\"@smthrs/journal/RedactedLogger\")\n\n/**\n * Whether {@link wrap} already wrapped this logger.\n *\n * @since 0.1.0\n * @category predicates\n */\nexport const isRedacted = (logger: Logger.Logger<any, any>): boolean => TypeId in logger\n\n/**\n * Console methods that write caller-supplied values, mapped to whether their\n * arguments carry log output.\n *\n * Only `clear` and `groupEnd` are marked `false`, because those two take no\n * arguments at all: there is nothing for the rules to read and binding them\n * straight through saves a copy per call. Every other method here, `count`,\n * `countReset`, `time`, and `timeEnd` included, accepts a caller-supplied\n * LABEL and prints it, so a label of `api_key=sk-\u2026` reached the terminal\n * through all four of them. `timeLog` already redacted its label, so the pair\n * `time` / `timeLog` also disagreed about what a timer is called; redacting all\n * of them is what makes a label match itself again.\n */\nconst consoleMethods = {\n assert: true,\n clear: false,\n count: true,\n countReset: true,\n debug: true,\n dir: true,\n dirxml: true,\n error: true,\n group: true,\n groupCollapsed: true,\n groupEnd: false,\n info: true,\n log: true,\n table: true,\n time: true,\n timeEnd: true,\n timeLog: true,\n trace: true,\n warn: true\n} as const\n\n/** How deep the logger walks a value before it names it instead. */\nconst renderDepthLimit = 200\n\n/** What the logger renders in place of a value nested past the depth limit. */\nconst renderDepthMarker = \"[Deep]\"\n\n/**\n * The parts of a log message.\n *\n * Effect's logging API passes an array, one entry per argument, including for\n * a single argument. A caller that builds `LogOptions` by hand may pass the\n * message itself, so it is wrapped rather than walked.\n *\n * @since 0.1.0\n * @category redaction\n */\nconst toArray = (message: unknown): ReadonlyArray<unknown> => Array.isArray(message) ? message : [message]\n\n/**\n * Reads one piece of text off `error` and runs it through the rules.\n *\n * Everything a renderer prints about an error is read here, once, and only the\n * redacted result crosses to the copy. A caller's error can define any of these\n * as an accessor that throws, and reading one happens while a log line is\n * rendering, so a refusal costs that piece of text and nothing else.\n */\nconst redactedText = (read: () => unknown, redactor: Redaction.Redactor, fallback: string): string => {\n try {\n return String(redactor(String(read())))\n } catch {\n return fallback\n }\n}\n\n/** `error.stack` through the rules, or `undefined` when it has none to give. */\nconst redactedStack = (error: Error, redactor: Redaction.Redactor): string | undefined => {\n try {\n const stack = error.stack\n // An `Error.stack` is optional. Under `exactOptionalPropertyTypes` an\n // assignment cannot carry the `undefined` a stackless error has, so the\n // copy defines the property instead of assigning it.\n return typeof stack === \"string\" ? String(redactor(stack)) : undefined\n } catch {\n return undefined\n }\n}\n\n/**\n * A member NAME with the rules applied, replaced outright when one fires.\n *\n * The treatment `Redaction.redact` gives an object key, for the same reason: a\n * name is text a renderer prints. Rewriting one in place would change what it\n * reads as and redaction would stop being a fixed point, so a name that matches\n * becomes the placeholder whole.\n */\nconst redactedName = (key: string, redactor: Redaction.Redactor): string => {\n const redacted = String(redactor(key))\n return redacted === key ? key : Redaction.placeholder\n}\n\n/**\n * Own names the copy never carries, because a renderer CALLS them.\n *\n * `name`, `message` and `stack` are defined from the rules above instead. The\n * rest are hooks: a redacted `toString` or `valueOf` would leave a string under\n * a name the language calls, and `String(error)` would then throw from inside\n * the renderer, which is the failure mode this module exists to avoid.\n */\nconst renderHooks: ReadonlySet<string> = new Set([\n \"constructor\",\n \"message\",\n \"name\",\n \"stack\",\n \"toJSON\",\n \"toString\",\n \"valueOf\"\n])\n\n/**\n * A copy of `error` carrying the same information with the rules applied.\n *\n * A PLAIN `Error`, never a copy built on the original's prototype. A prototype\n * is an unbounded leak surface and an own-key walk never looks at one: an\n * inherited `name`, `cause`, `toJSON`, `Symbol.toStringTag` or\n * `nodejs.util.inspect.custom` each carried a credential straight to an OTLP\n * span attribute or to the operator's terminal, one per review round, and a\n * getter anywhere on the chain is the same hole with a different name. So\n * nothing inherited crosses. Only redacted text does: the name, the message,\n * the stack, and the error's own members, each read once here and stored as\n * data, since a getter carried across unchanged would hand the unredacted\n * value to whatever reads it next.\n *\n * The copy is not an instance of the original's class, so a renderer that\n * special-cases `instanceof MyError` sees a plain `Error`. That is the fidelity\n * trade the release policy already records for every other value, and it is\n * the trade the same problem's earlier, crashing form was settled with: a copy\n * on a host prototype, such as the `DOMException` an `AbortSignal` carries as\n * its reason, is an impostor whose brand check throws from inside `Cause.pretty`\n * and kills the run the line was describing.\n */\nconst redactError = (\n error: Error,\n redactor: Redaction.Redactor,\n seen: WeakMap<Error, Error>,\n walk: (value: unknown) => unknown,\n depth = 0\n): Error => {\n // The memo holds the COPY, not a visited mark: returning the original on a\n // repeat reference put the unredacted error back into the output, so a\n // diamond (two fields naming one error) leaked on its second field. The copy\n // is registered before its own members are walked, so a cycle terminates on\n // it and every reference to one error is the same redacted object.\n const memoized = seen.get(error)\n if (memoized !== undefined) return memoized\n const clone = new Error()\n seen.set(error, clone)\n const define = (key: string, value: unknown, enumerable: boolean): void => {\n Object.defineProperty(clone, key, { value, writable: true, enumerable, configurable: true })\n }\n define(\"name\", redactedText(() => error.name, redactor, \"Error\"), false)\n define(\"message\", redactedText(() => error.message, redactor, \"\"), false)\n define(\"stack\", redactedStack(error, redactor), false)\n // Own NAMES, not `Reflect.ownKeys`. A symbol key never crosses: its\n // description is text no walk can rewrite in place, and the three hooks with\n // no name to skip are symbols too, `Symbol.toPrimitive`,\n // `Symbol.toStringTag`, and `nodejs.util.inspect.custom`.\n for (const key of Object.getOwnPropertyNames(error)) {\n if (renderHooks.has(key)) continue\n const descriptor = Object.getOwnPropertyDescriptor(error, key)!\n const value = \"value\" in descriptor\n ? descriptor.value\n : (error as unknown as Record<PropertyKey, unknown>)[key]\n define(\n redactedName(key, redactor),\n // A credential-named member is replaced wholesale, the way the journal's\n // own walk replaces one, so both halves of the one rule set answer alike.\n Redaction.isSensitiveKey(key)\n ? Redaction.placeholder\n // The depth cap binds under an Error exactly as it does beside one: a\n // deep value carried on a cause can exhaust the stack just as easily.\n : depth + 1 >= renderDepthLimit\n ? renderDepthMarker\n : walk(value),\n descriptor.enumerable === true\n )\n }\n return clone\n}\n\n/**\n * Redacts one value on its way out of the logger.\n *\n * An `Error` is rebuilt as a plain `Error` whose name, message, stack and own\n * members are redacted, so a renderer that special-cases an `Error` still gets\n * one. Everything else goes through the journal's own rules, which rebuild a\n * value from its plain data: a `Date`, a `Map`, a class instance or a host\n * object therefore reaches the operator in that plain form rather than as\n * itself.\n *\n * That collapse is deliberate, and it now covers the `Error` too. An earlier\n * version rebuilt each value on its own prototype to keep the rendering\n * faithful. Three rounds of review found three ways that could kill the run it\n * was logging, because a host class keeps state a property walk cannot see and\n * a copy of one throws the moment a brand check reads it, and four more found\n * that the prototype an `Error` copy kept was itself the leak: everything it\n * defines is read by a renderer and seen by no own-key walk. A log line is not\n * worth a run, and the rendering it buys is cosmetic.\n *\n * @since 0.1.0\n * @category redaction\n */\nexport const redactArgument = (value: unknown, redactor: Redaction.Redactor): unknown => {\n try {\n const seen = new WeakMap<Error, Error>()\n const walk = (node: unknown, depth = 0): unknown =>\n node instanceof Error\n ? redactError(node, redactor, seen, (member) => walk(member, depth + 1), depth)\n : redactor(node)\n return redactor.withErrors === undefined\n ? walk(value)\n : redactor.withErrors(value, (error, member, depth) => redactError(error, redactor, seen, member, depth))\n } catch {\n // A logged value is arbitrary and a throw here happens while the line is\n // rendering, which would kill the run the line describes. The marker is\n // deliberately NOT derived from the value: an earlier fallback rendered\n // the value to text and printed it, and that text had never been through\n // the rules, so a credential reached the terminal in clear.\n return unrenderableMarker\n }\n}\n\n/** What the logger renders in place of a value that cannot be rendered. */\nconst unrenderableMarker = \"[Unrenderable]\"\n\n/**\n * A console that runs every value it is handed through `redactor` and then\n * delegates to `target`.\n *\n * @since 0.1.0\n * @category constructors\n */\nexport const redactingConsole = (target: Console.Console, redactor: Redaction.Redactor): Console.Console => {\n const methods = target as unknown as Record<string, (...args: ReadonlyArray<any>) => unknown>\n const view: Record<string, unknown> = {}\n for (const [name, redacts] of Object.entries(consoleMethods)) {\n const method = methods[name]!.bind(target)\n view[name] = redacts\n ? (...args: ReadonlyArray<unknown>) => {\n const redacted = args.map((value) => redactArgument(value, redactor))\n try {\n return method(...redacted)\n } catch {\n // The delegate refused what we handed it. Retry with markers, never\n // with a rendering of the values: a rendering has not been through\n // the rules, and printing one is how a credential reached the\n // terminal before. A delegate that refuses the markers too is out of\n // options, and a log line is not worth the run.\n try {\n return method(...redacted.map(() => unrenderableMarker))\n } catch {\n return undefined\n }\n }\n }\n : method\n }\n return view as unknown as Console.Console\n}\n\n/**\n * A view of `fiber` whose console redacts and whose log annotations are\n * already redacted.\n *\n * The view inherits from the fiber itself, so `id`, `currentSpan`, and every\n * other member a logger reads answer exactly as before; only the two\n * references a logger renders from are substituted.\n */\nconst redactedFiber = (\n fiber: Fiber.Fiber<unknown, unknown>,\n redactor: Redaction.Redactor\n): Fiber.Fiber<unknown, unknown> => {\n const view = Object.create(fiber) as Fiber.Fiber<unknown, unknown>\n Object.defineProperty(view, \"getRef\", {\n value: <X>(reference: Context.Reference<X>): X => {\n const current = fiber.getRef(reference)\n if (reference === (Console.Console as unknown as Context.Reference<X>)) {\n return redactingConsole(current as Console.Console, redactor) as X\n }\n if (reference === (References.CurrentLogAnnotations as unknown as Context.Reference<X>)) {\n // The same treatment a message part gets, so one log event obeys one\n // rule and an annotated Error is redacted like a logged one.\n return redactArgument(current, redactor) as X\n }\n return current\n }\n })\n return view\n}\n\n/**\n * Rebuilds the frame chain as redacted data. Evaluate the lazy stack here:\n * carrying its original function would defer the credential past the boundary.\n * The same depth cap as logged values also bounds cyclic parent chains.\n */\nconst redactedFrame = (\n frame: References.StackFrame | undefined,\n redactor: Redaction.Redactor,\n depth = 0\n): References.StackFrame | undefined => {\n if (frame === undefined) return undefined\n if (depth >= renderDepthLimit) {\n return { name: renderDepthMarker, stack: () => undefined, parent: undefined }\n }\n const stack = redactedText(() => frame.stack() ?? \"\", redactor, unrenderableMarker)\n return {\n name: redactedText(() => frame.name, redactor, unrenderableMarker),\n stack: () => stack,\n parent: redactedFrame(frame.parent, redactor, depth + 1)\n }\n}\n\n/**\n * The log event's cause with the rules applied to failures, defects and stack\n * annotations. `Cause.pretty` renders these frames after rendering the error;\n * the tracer exports that text without passing through the redacting console.\n * Interruptions also carry both their own and the interruptor's frame chains.\n * Rebuild reasons and annotation maps so the original cause stays untouched.\n */\nconst redactedCause = (\n cause: Cause.Cause<unknown>,\n redactor: Redaction.Redactor\n): Cause.Cause<unknown> => {\n if (cause.reasons.length === 0) return cause\n return Cause.fromReasons(cause.reasons.map((reason) => {\n const annotations = new Map(reason.annotations)\n for (const key of [Cause.StackTrace.key, Cause.InterruptorStackTrace.key]) {\n if (annotations.has(key)) {\n annotations.set(key, redactedFrame(annotations.get(key) as References.StackFrame | undefined, redactor))\n }\n }\n const copy = reason._tag === \"Fail\"\n ? Cause.makeFailReason(redactArgument(reason.error, redactor))\n : reason._tag === \"Die\"\n ? Cause.makeDieReason(redactArgument(reason.defect, redactor))\n : Cause.makeInterruptReason(reason.fiberId)\n return copy.annotate(Context.makeUnsafe(annotations))\n }))\n}\n\n/**\n * Returns `logger` with the journal's redaction rules over everything it\n * renders. A logger this module already wrapped is returned unchanged.\n *\n * @since 0.1.0\n * @category combinators\n */\nexport const wrap = <Message, Output>(\n logger: Logger.Logger<Message, Output>,\n options?: Redaction.Options\n): Logger.Logger<Message, Output> => {\n if (isRedacted(logger)) return logger\n // A logger NAMES a too-deep value rather than throwing: a throw is caught one\n // frame up and costs the operator every argument on the line, not just the\n // deep one. A log line is a diagnostic, so it takes the diagnostic rules. A\n // caller passing its own `onTooDeep` or `rules` still wins.\n const redactor = Redaction.make({ onTooDeep: \"name\", rules: Redaction.diagnosticRules, ...options })\n const wrapped = Logger.make<Message, Output>((logOptions) =>\n logger.log({\n ...logOptions,\n // The message is redacted here, not only behind the fiber's Console,\n // because a logger is free to read it directly: `Logger.tracerLogger`\n // ships in Effect's default set and publishes the message as a span\n // event name, so a Console-only substitution would export a credential\n // in clear to whatever collector is configured.\n //\n // Effect delivers the message as an array of parts, one per argument,\n // including the single-argument case; a non-array reaches here only from\n // a caller that builds `LogOptions` by hand, and `toArray` covers it\n // without a branch no test could reach through the logging API.\n message: (toArray(logOptions.message).map((part) => redactArgument(part, redactor))) as Message,\n // The cause travels the same way and for the same reason. A failure is\n // logged as a `Cause`, not as message parts (`Effect.logError(cause)`\n // moves it out of the arguments), and `Logger.tracerLogger` renders it\n // itself into the span's `effect.cause` attribute without going near the\n // console, so an error message carrying a token would leave the process\n // in clear.\n cause: redactedCause(logOptions.cause, redactor),\n fiber: redactedFiber(logOptions.fiber, redactor)\n })\n )\n Object.defineProperty(wrapped, TypeId, { value: true })\n return wrapped\n}\n\n/**\n * Replaces the active logger set with redacting wrappers of the same loggers.\n *\n * It composes over whatever loggers are already installed rather than\n * choosing one, so an operator keeps the FORMAT they had, meaning their own\n * logger and its layout, though a value inside a line is rendered from its\n * redacted plain data rather than as its own class, and a host that\n * installed its own logger keeps it too.\n *\n * @since 0.1.0\n * @category layers\n */\nexport const layer = (options?: Redaction.Options): Layer.Layer<never> =>\n Layer.effect(\n Logger.CurrentLoggers,\n Effect.withFiber((fiber) =>\n Effect.sync(() => {\n const wrapped = new Set<Logger.Logger<unknown, any>>()\n for (const logger of fiber.getRef(Logger.CurrentLoggers)) wrapped.add(wrap(logger, options))\n return wrapped\n })\n )\n )\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA+CA,YAAuB;AACvB,cAAyB;AACzB,cAAyB;AACzB,aAAwB;AAExB,YAAuB;AACvB,aAAwB;AACxB,iBAA4B;AAC5B,gBAA2B;AAYpB,MAAM,SAAwB,uBAAO,IAAI,gCAAgC;AAQzE,MAAM,aAAa,CAAC,WAA6C,UAAU;AAelF,MAAM,iBAAiB;AAAA,EACrB,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,OAAO;AAAA,EACP,YAAY;AAAA,EACZ,OAAO;AAAA,EACP,KAAK;AAAA,EACL,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,OAAO;AAAA,EACP,gBAAgB;AAAA,EAChB,UAAU;AAAA,EACV,MAAM;AAAA,EACN,KAAK;AAAA,EACL,OAAO;AAAA,EACP,MAAM;AAAA,EACN,SAAS;AAAA,EACT,SAAS;AAAA,EACT,OAAO;AAAA,EACP,MAAM;AACR;AAGA,MAAM,mBAAmB;AAGzB,MAAM,oBAAoB;AAY1B,MAAM,UAAU,CAAC,YAA6C,MAAM,QAAQ,OAAO,IAAI,UAAU,CAAC,OAAO;AAUzG,MAAM,eAAe,CAAC,MAAqB,UAA8B,aAA6B;AACpG,MAAI;AACF,WAAO,OAAO,SAAS,OAAO,KAAK,CAAC,CAAC,CAAC;AAAA,EACxC,QAAQ;AACN,WAAO;AAAA,EACT;AACF;A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AAA,EACtD,CAAC,CAAC;AACJ;AASO,MAAM,OAAO,CAClB,QACA,YACmC;AACnC,MAAI,WAAW,MAAM,EAAG,QAAO;AAK/B,QAAM,WAAW,UAAU,KAAK,EAAE,WAAW,QAAQ,OAAO,UAAU,iBAAiB,GAAG,QAAQ,CAAC;AACnG,QAAM,UAAU,OAAO;AAAA,IAAsB,CAAC,eAC5C,OAAO,IAAI;AAAA,MACT,GAAG;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAWH,SAAU,QAAQ,WAAW,OAAO,EAAE,IAAI,CAAC,SAAS,eAAe,MAAM,QAAQ,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAOlF,OAAO,cAAc,WAAW,OAAO,QAAQ;AAAA,MAC/C,OAAO,cAAc,WAAW,OAAO,QAAQ;AAAA,IACjD,CAAC;AAAA,EACH;AACA,SAAO,eAAe,SAAS,QAAQ,EAAE,OAAO,KAAK,CAAC;AACtD,SAAO;AACT;AAcO,MAAM,QAAQ,CAAC,YACpB,MAAM;AAAA,EACJ,OAAO;AAAA,EACP,OAAO;AAAA,IAAU,CAAC,UAChB,OAAO,KAAK,MAAM;AAChB,YAAM,UAAU,oBAAI,IAAiC;AACrD,iBAAW,UAAU,MAAM,OAAO,OAAO,cAAc,EAAG,SAAQ,IAAI,KAAK,QAAQ,OAAO,CAAC;AAC3F,aAAO;AAAA,IACT,CAAC;AAAA,EACH;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/cjs/Redaction.d.ts
CHANGED
|
@@ -205,6 +205,17 @@ export declare const symbolMarker = "[Symbol]";
|
|
|
205
205
|
* @category redaction
|
|
206
206
|
*/
|
|
207
207
|
export declare const depthMarker = "[Deep]";
|
|
208
|
+
/**
|
|
209
|
+
* Rebuilds an Error reached during redaction for a diagnostic renderer.
|
|
210
|
+
*
|
|
211
|
+
* The callback walks an own member using the same ancestors and depth budget.
|
|
212
|
+
* A handler must memoize its copies before walking members to terminate error
|
|
213
|
+
* cycles. The journal leaves this hook unset and keeps JSON's enumerable data.
|
|
214
|
+
*
|
|
215
|
+
* @since 1.0.0
|
|
216
|
+
* @category models
|
|
217
|
+
*/
|
|
218
|
+
export type ErrorHandler = (error: Error, walk: (value: unknown) => unknown, depth: number) => unknown;
|
|
208
219
|
/**
|
|
209
220
|
* Returns `value` with credentials removed.
|
|
210
221
|
*
|
|
@@ -230,10 +241,16 @@ export declare const redact: (value: unknown, options?: Options) => unknown;
|
|
|
230
241
|
/**
|
|
231
242
|
* A redaction function, as the journal consumes it.
|
|
232
243
|
*
|
|
244
|
+
* Built-in redactors also expose `withErrors`, the optional diagnostic walk.
|
|
245
|
+
* Plain one-argument redactors remain valid.
|
|
246
|
+
*
|
|
233
247
|
* @since 0.1.0
|
|
234
248
|
* @category models
|
|
235
249
|
*/
|
|
236
|
-
export type Redactor = (value: unknown) => unknown
|
|
250
|
+
export type Redactor = ((value: unknown) => unknown) & {
|
|
251
|
+
/** An optional diagnostic walk that preserves Error nodes. */
|
|
252
|
+
readonly withErrors?: (value: unknown, onError: ErrorHandler) => unknown;
|
|
253
|
+
};
|
|
237
254
|
/**
|
|
238
255
|
* Builds a redactor over a rule set.
|
|
239
256
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Redaction.d.ts","sourceRoot":"","sources":["../../src/Redaction.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAGH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAKvC;;;;;;;;;;;;;;GAcG;AACH,MAAM,WAAW,IAAI;IACnB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;IACnB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IACrC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,IAAI,EAAE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