@volter/world-core 2.0.18 → 2.0.19

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.
@@ -25,7 +25,7 @@ export type TwinRequestJournalEntry = {
25
25
  /** credential-looking headers/query params that arrived, named + fingerprinted, never quoted. */
26
26
  credentials?: TwinCredentialShape[];
27
27
  };
28
- /** The journal read back: every entry kept for a service, oldest first (an empty list when the journal is off or empty). */
28
+ /** The journal read back: every entry kept for a service, oldest first (an empty list when the journal is switched off or empty). */
29
29
  export declare function readTwinRequestJournal(service: string, root?: string): TwinRequestJournalEntry[];
30
30
  /** Non-reversible, stable fingerprint. 64 bits of sha256 — enough that two distinct credentials
31
31
  * never collide in a journal, far too little to walk back to a real key. */
@@ -35,12 +35,14 @@ export declare function credentialFingerprint(value: string): string;
35
35
  * fingerprinted, sorted for stable diffing. Values never leave this function.
36
36
  */
37
37
  export declare function twinRequestCredentials(headers: Headers | Record<string, string>, url?: string | URL): TwinCredentialShape[];
38
+ /** The audit is kept unless it is switched off (VOLTER_TWIN_REQUEST_JOURNAL=0): no audit is the
39
+ * setting someone chooses, never the default. */
38
40
  export declare function twinRequestJournalEnabled(env?: Record<string, string | undefined>): boolean;
39
41
  /** Where a service's request journal lives: beside its `actions.jsonl`. */
40
42
  export declare function twinRequestJournalPath(service: string, root?: string): string;
41
43
  /**
42
- * Append one served request to the journal — a no-op unless VOLTER_TWIN_REQUEST_JOURNAL=1, so
43
- * the default path does zero I/O. Never throws: an observability append must not fail a serve.
44
+ * Append one served request to the journal — a no-op only when VOLTER_TWIN_REQUEST_JOURNAL=0.
45
+ * Never throws: an append must not fail a serve.
44
46
  */
45
47
  export declare function journalTwinRequest(service: string, entry: TwinRequestJournalEntry, root?: string): void;
46
48
  export declare const TWIN_JOURNAL_IDENTITY: unique symbol;
@@ -52,8 +54,7 @@ export declare function vendorFromStack(stack: string | undefined): string | und
52
54
  /**
53
55
  * Wrap `Bun.serve` so EVERY twin's HTTP surface journals, with no per-pack line. Idempotent
54
56
  * (a `Symbol.for` marker survives a second copy of this module) and a strict pass-through when
55
- * VOLTER_TWIN_REQUEST_JOURNAL is not `1` — the default path adds one function call per request
56
- * and does zero I/O. Called once at module load, below; exported so a test can assert it.
57
+ * VOLTER_TWIN_REQUEST_JOURNAL=0. Called once at module load, below; exported so a test can assert it.
57
58
  *
58
59
  * A pack that knows its own identity may declare it by putting `{service, root}` on the serve
59
60
  * options under `TWIN_JOURNAL_IDENTITY` (a symbol key Bun's option reader ignores). Nothing in
package/dist/src/serve.js CHANGED
@@ -18,7 +18,7 @@ import { hashFieldValue } from "./hash.js";
18
18
  import { appendActionIfAbsent, appendActionOccurrence, decideAndAppendAction, projectResources } from "./actions.js";
19
19
  import { observeWorldPaths, worldPaths } from "./storage.js";
20
20
  import { getActiveWorldStore } from "./world-store.js";
21
- /** The journal read back: every entry kept for a service, oldest first (an empty list when the journal is off or empty). */
21
+ /** The journal read back: every entry kept for a service, oldest first (an empty list when the journal is switched off or empty). */
22
22
  export function readTwinRequestJournal(service, root) {
23
23
  const path = twinRequestJournalPath(service, root);
24
24
  const out = [];
@@ -102,16 +102,18 @@ export function twinRequestCredentials(headers, url) {
102
102
  catch { /* an unparseable URL must not fail a serve */ }
103
103
  return shapes.sort((a, b) => (a.in === b.in ? a.name.localeCompare(b.name) : a.in.localeCompare(b.in)));
104
104
  }
105
+ /** The audit is kept unless it is switched off (VOLTER_TWIN_REQUEST_JOURNAL=0): no audit is the
106
+ * setting someone chooses, never the default. */
105
107
  export function twinRequestJournalEnabled(env = process.env) {
106
- return env.VOLTER_TWIN_REQUEST_JOURNAL === '1';
108
+ return env.VOLTER_TWIN_REQUEST_JOURNAL !== '0';
107
109
  }
108
110
  /** Where a service's request journal lives: beside its `actions.jsonl`. */
109
111
  export function twinRequestJournalPath(service, root) {
110
112
  return join(dirname(worldPaths(service, root).events), 'requests.jsonl');
111
113
  }
112
114
  /**
113
- * Append one served request to the journal — a no-op unless VOLTER_TWIN_REQUEST_JOURNAL=1, so
114
- * the default path does zero I/O. Never throws: an observability append must not fail a serve.
115
+ * Append one served request to the journal — a no-op only when VOLTER_TWIN_REQUEST_JOURNAL=0.
116
+ * Never throws: an append must not fail a serve.
115
117
  */
116
118
  export function journalTwinRequest(service, entry, root) {
117
119
  if (!twinRequestJournalEnabled())
@@ -137,7 +139,7 @@ export function journalTwinRequest(service, entry, root) {
137
139
  store.append(path, `${line}\n`);
138
140
  }
139
141
  catch {
140
- // journaling is best-effort observability; the serve path must not care
142
+ // the append must not fail the serve it records
141
143
  }
142
144
  }
143
145
  // ── how a wrapped `Bun.serve` learns which twin it is ──────────────────────────────────────────
@@ -196,8 +198,7 @@ export function vendorFromStack(stack) {
196
198
  /**
197
199
  * Wrap `Bun.serve` so EVERY twin's HTTP surface journals, with no per-pack line. Idempotent
198
200
  * (a `Symbol.for` marker survives a second copy of this module) and a strict pass-through when
199
- * VOLTER_TWIN_REQUEST_JOURNAL is not `1` — the default path adds one function call per request
200
- * and does zero I/O. Called once at module load, below; exported so a test can assert it.
201
+ * VOLTER_TWIN_REQUEST_JOURNAL=0. Called once at module load, below; exported so a test can assert it.
201
202
  *
202
203
  * A pack that knows its own identity may declare it by putting `{service, root}` on the serve
203
204
  * options under `TWIN_JOURNAL_IDENTITY` (a symbol key Bun's option reader ignores). Nothing in
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@volter/world-core",
3
- "version": "2.0.18",
3
+ "version": "2.0.19",
4
4
  "description": "The kernel of Volter World: one log per twin, branches as pointers, checkpoints, the fold that keeps a twin current, the head that performs a write against the vendor, references, and the git plane. A twin package builds on it; the runtime serves it.",
5
5
  "keywords": [
6
6
  "twin",
package/src/serve.ts CHANGED
@@ -24,9 +24,9 @@ import { getActiveWorldStore } from './world-store.ts';
24
24
  // ── the request journal: the INSPECT half of the read path ─────────────────────────────────────
25
25
  // `actions.jsonl` records MUTATIONS only, so a twin's READS are invisible to `volter-world tail`
26
26
  // — an empty-catalog GET that 404s leaves no trace, and "did the app even ask?" is unanswerable.
27
- // The journal is the minimal honest answer: an OPT-IN (VOLTER_TWIN_REQUEST_JOURNAL=1) per-twin
28
- // `requests.jsonl` beside `actions.jsonl`, one line per served HTTP request. Size-capped: at ~1 MB
29
- // the file rotates once to `requests.jsonl.1` (previous rotation overwritten), so an enabled
27
+ // The journal is the minimal honest answer: a per-twin `requests.jsonl` beside `actions.jsonl`, one
28
+ // line per served HTTP request, kept unless switched off (VOLTER_TWIN_REQUEST_JOURNAL=0). Size-capped:
29
+ // at ~1 MB the file rotates once to `requests.jsonl.1` (previous rotation overwritten), so the
30
30
  // journal can never grow unbounded. `volter-world tail --requests` merges these lines live.
31
31
  //
32
32
  // WHAT A LINE CARRIES. `{at, method, path, status}` — the shape — plus, when the request presented
@@ -84,7 +84,7 @@ export type TwinRequestJournalEntry = {
84
84
  credentials?: TwinCredentialShape[];
85
85
  };
86
86
 
87
- /** The journal read back: every entry kept for a service, oldest first (an empty list when the journal is off or empty). */
87
+ /** The journal read back: every entry kept for a service, oldest first (an empty list when the journal is switched off or empty). */
88
88
  export function readTwinRequestJournal(service: string, root?: string): TwinRequestJournalEntry[] {
89
89
  const path = twinRequestJournalPath(service, root);
90
90
  const out: TwinRequestJournalEntry[] = [];
@@ -156,8 +156,10 @@ export function twinRequestCredentials(headers: Headers | Record<string, string>
156
156
  return shapes.sort((a, b) => (a.in === b.in ? a.name.localeCompare(b.name) : a.in.localeCompare(b.in)));
157
157
  }
158
158
 
159
+ /** The audit is kept unless it is switched off (VOLTER_TWIN_REQUEST_JOURNAL=0): no audit is the
160
+ * setting someone chooses, never the default. */
159
161
  export function twinRequestJournalEnabled(env: Record<string, string | undefined> = process.env): boolean {
160
- return env.VOLTER_TWIN_REQUEST_JOURNAL === '1';
162
+ return env.VOLTER_TWIN_REQUEST_JOURNAL !== '0';
161
163
  }
162
164
 
163
165
  /** Where a service's request journal lives: beside its `actions.jsonl`. */
@@ -166,8 +168,8 @@ export function twinRequestJournalPath(service: string, root?: string): string {
166
168
  }
167
169
 
168
170
  /**
169
- * Append one served request to the journal — a no-op unless VOLTER_TWIN_REQUEST_JOURNAL=1, so
170
- * the default path does zero I/O. Never throws: an observability append must not fail a serve.
171
+ * Append one served request to the journal — a no-op only when VOLTER_TWIN_REQUEST_JOURNAL=0.
172
+ * Never throws: an append must not fail a serve.
171
173
  */
172
174
  export function journalTwinRequest(service: string, entry: TwinRequestJournalEntry, root?: string): void {
173
175
  if (!twinRequestJournalEnabled()) return;
@@ -191,7 +193,7 @@ export function journalTwinRequest(service: string, entry: TwinRequestJournalEnt
191
193
  });
192
194
  store.append(path, `${line}\n`);
193
195
  } catch {
194
- // journaling is best-effort observability; the serve path must not care
196
+ // the append must not fail the serve it records
195
197
  }
196
198
  }
197
199
 
@@ -260,8 +262,7 @@ export function vendorFromStack(stack: string | undefined): string | undefined {
260
262
  /**
261
263
  * Wrap `Bun.serve` so EVERY twin's HTTP surface journals, with no per-pack line. Idempotent
262
264
  * (a `Symbol.for` marker survives a second copy of this module) and a strict pass-through when
263
- * VOLTER_TWIN_REQUEST_JOURNAL is not `1` — the default path adds one function call per request
264
- * and does zero I/O. Called once at module load, below; exported so a test can assert it.
265
+ * VOLTER_TWIN_REQUEST_JOURNAL=0. Called once at module load, below; exported so a test can assert it.
265
266
  *
266
267
  * A pack that knows its own identity may declare it by putting `{service, root}` on the serve
267
268
  * options under `TWIN_JOURNAL_IDENTITY` (a symbol key Bun's option reader ignores). Nothing in