@ultimat3/core 31.31.0 → 31.33.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/src/async-context.ts +1 -1
- package/src/bunfs.ts +4 -2
- package/src/client-paths.ts +4 -2
- package/src/client-transport.ts +4 -2
- package/src/client-writes.ts +3 -2
- package/src/cursor.ts +4 -2
- package/src/environment.ts +4 -1
- package/src/error-reporter-sentry.ts +8 -5
- package/src/flight-gate.ts +4 -3
- package/src/host-rules.ts +5 -3
- package/src/image/probe.ts +13 -6
- package/src/index.ts +1 -0
- package/src/intl-cache.ts +5 -4
- package/src/keyed-fingerprint.ts +4 -2
- package/src/locale-direction.ts +5 -4
- package/src/locale-path.ts +6 -4
- package/src/logger.ts +12 -9
- package/src/otlp-log-exporter.ts +11 -8
- package/src/otlp-span-exporter.ts +18 -12
- package/src/otlp.ts +2 -1
- package/src/outbound-headers.ts +5 -3
- package/src/page.ts +7 -4
- package/src/probe-database-sweep.ts +5 -3
- package/src/read-capped.ts +6 -4
- package/src/registrar.ts +3 -2
- package/src/request-budget.ts +5 -4
- package/src/schema-error-codes.ts +1 -0
- package/src/seal-errors.ts +5 -4
- package/src/secrets-errors.ts +1 -1
- package/src/source-mask.ts +6 -4
- package/src/trailing-slashes.ts +10 -0
- package/src/type-pins.ts +6 -5
- package/src/version.ts +2 -1
- package/src/wire-dates.ts +5 -4
- package/src/write-origin.ts +6 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ultimat3/core",
|
|
3
|
-
"version": "31.
|
|
3
|
+
"version": "31.33.0",
|
|
4
4
|
"description": "Ultimate's foundation: errors, context, env, config, clock, ids, logging, telemetry, lifecycle",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ultimate",
|
|
@@ -54,6 +54,6 @@
|
|
|
54
54
|
"test": "bun test"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@ultimat3/schema": "31.
|
|
57
|
+
"@ultimat3/schema": "31.33.0"
|
|
58
58
|
}
|
|
59
59
|
}
|
package/src/async-context.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// opens its scope through this seam, so "what happens where there is no async context" has one
|
|
4
4
|
// answer instead of one per module.
|
|
5
5
|
|
|
6
|
-
// `node:async_hooks` is unavoidable and deliberate: nothing else in Bun makes a value ambient
|
|
6
|
+
// why: `node:async_hooks` is unavoidable and deliberate: nothing else in Bun makes a value ambient
|
|
7
7
|
// across an `await` without threading it through every signature in the framework.
|
|
8
8
|
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
9
9
|
import { UltimateError } from './errors';
|
package/src/bunfs.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
// Whether a directory is inside a `bun build --compile` executable's virtual filesystem. One answer
|
|
2
2
|
// for every platform, because Bun spells its root two ways: `/$bunfs/` on POSIX and `B:\~BUN\`
|
|
3
3
|
// (public form `B:/~BUN/`) on Windows — `BASE_PATH` / `BASE_PUBLIC_PATH` in Bun's
|
|
4
|
-
// `StandaloneModuleGraph`, as of Bun 1.4.2.
|
|
5
|
-
//
|
|
4
|
+
// `StandaloneModuleGraph`, as of Bun 1.4.2.
|
|
5
|
+
//
|
|
6
|
+
// An entry that tested only the first resolved its app root INSIDE the bundle on Windows, where no
|
|
7
|
+
// source exists, and every registry booted empty.
|
|
6
8
|
|
|
7
9
|
/** Each prefix is followed by a separator or nothing, so `/$bunfsx` or `B:\~BUNDLE` never match. */
|
|
8
10
|
const COMPILED_ROOT = /^(?:\/\$bunfs|[Bb]:[\\/]~BUN)(?:[\\/]|$)/;
|
package/src/client-paths.ts
CHANGED
|
@@ -2,8 +2,10 @@
|
|
|
2
2
|
* The ONE URL rule for the two HTTP primitives: an action's export name derives `POST
|
|
3
3
|
* /api/<resource>/<verb>`, a query's derives `GET /_x/query/<kebab>`. Tier 0 and string math, so
|
|
4
4
|
* `action`, `query` and `realtime` (all tier 3) derive the same URL with no sideways import and a
|
|
5
|
-
* browser bundle pays a few hundred bytes for it.
|
|
6
|
-
*
|
|
5
|
+
* browser bundle pays a few hundred bytes for it.
|
|
6
|
+
*
|
|
7
|
+
* The one thing read rather than computed is the style a caller did not name: `actionPath` takes it
|
|
8
|
+
* from the document the server rendered.
|
|
7
9
|
*/
|
|
8
10
|
|
|
9
11
|
import { CLIENT_PATH_STYLE_META } from './page-meta';
|
package/src/client-transport.ts
CHANGED
|
@@ -2,8 +2,10 @@
|
|
|
2
2
|
* The ONE browser HTTP function. Every client surface — `rpc()`, `queryClient()`, a signed upload,
|
|
3
3
|
* the store's refetch — sends through here, so credentials, headers, the error decode, the records
|
|
4
4
|
* envelope and the principal fence are decided once. A GET is a read: abortable on `rescope()`,
|
|
5
|
-
* deduped when a `ClientFlight` is supplied.
|
|
6
|
-
*
|
|
5
|
+
* deduped when a `ClientFlight` is supplied.
|
|
6
|
+
*
|
|
7
|
+
* Anything else is a write: never deduped, never aborted by the fence, and its records never
|
|
8
|
+
* adopted across one.
|
|
7
9
|
*
|
|
8
10
|
* `clientFlight` is NOT imported here at value level — a caller passes one, and only then
|
|
9
11
|
* does its graph enter the bundle. Neither is `traceHeaders()`: the trace and budget headers come
|
package/src/client-writes.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* "A write just went through this tab's client": the one signal a page-side cache of server
|
|
3
|
-
*
|
|
2
|
+
* "A write just went through this tab's client": the one signal a page-side cache of server answers
|
|
3
|
+
* (the client router's prefetched documents) needs to stop trusting them. Emitted by
|
|
4
4
|
* `clientTransport` for every non-GET, landed or failed — a failed write may still have committed.
|
|
5
|
+
*
|
|
5
6
|
* On `globalThis` under one `Symbol.for` key, like the page client: every bundle's copy of core
|
|
6
7
|
* shares one listener set.
|
|
7
8
|
*/
|
package/src/cursor.ts
CHANGED
|
@@ -101,8 +101,10 @@ export function resetCursorSigning(): void {
|
|
|
101
101
|
export function usesDevCursorSecret(options?: {
|
|
102
102
|
readonly env?: Readonly<Record<string, string | undefined>> | undefined;
|
|
103
103
|
}): boolean {
|
|
104
|
-
|
|
105
|
-
|
|
104
|
+
// `timingSafeEqual` though the other side is published: the left side is the live secret.
|
|
105
|
+
if (options?.env === undefined) return timingSafeEqual(currentSecret(), DEV_CURSOR_SECRET);
|
|
106
|
+
const secret = configured || options.env[CURSOR_SECRET_KEY] || DEV_CURSOR_SECRET;
|
|
107
|
+
return timingSafeEqual(secret, DEV_CURSOR_SECRET);
|
|
106
108
|
}
|
|
107
109
|
|
|
108
110
|
/** `base64url(payload).signature`. Opaque by contract: callers must never parse it. */
|
package/src/environment.ts
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// key (`ULTIMATE_ENV`), one spelling per value — the twin of `roles.ts`: `ROLE` says what the
|
|
3
3
|
// process does, `ULTIMATE_ENV` says which deploy it belongs to.
|
|
4
4
|
|
|
5
|
+
import { renderFixShellArg } from './error-render';
|
|
5
6
|
import { type CodedErrorInit, UltimateError } from './errors';
|
|
6
7
|
|
|
7
8
|
export class EnvironmentInvalidError extends UltimateError {
|
|
@@ -63,7 +64,9 @@ export function resolveEnvironment(options?: ResolveEnvironmentOptions): Environ
|
|
|
63
64
|
if (read.ok) return read.environment;
|
|
64
65
|
throw new EnvironmentInvalidError({
|
|
65
66
|
cause: `${ENVIRONMENT_KEY}="${read.declared}" is not one of ${ENVIRONMENTS.join(' | ')}`,
|
|
66
|
-
|
|
67
|
+
// A command that runs, never `KEY=a|b|c`, which a shell reads as two pipes. `production` is
|
|
68
|
+
// the fail-closed pick: it refuses every published dev secret, so a wrong guess stops a boot.
|
|
69
|
+
fix: `export ${renderFixShellArg(ENVIRONMENT_KEY, 'ULTIMATE_ENV')}=production # or whichever of ${ENVIRONMENTS.join(', ')} this deploy is, spelled exactly`,
|
|
67
70
|
meta: { key: ENVIRONMENT_KEY, received: read.declared, allowed: ENVIRONMENTS },
|
|
68
71
|
});
|
|
69
72
|
}
|
|
@@ -78,11 +78,14 @@ export function parseSentryDsn(dsn: string): SentryDsn {
|
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
/** The protocol's own level names. `warning`/`error`/`fatal` happen to be the same three words. */
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
81
|
+
// Null-prototype: a key that arrives untyped never answers an `Object.prototype` member.
|
|
82
|
+
const LEVELS = Object.freeze<Record<ErrorSeverity, string>>(
|
|
83
|
+
Object.assign(Object.create(null), {
|
|
84
|
+
warning: 'warning',
|
|
85
|
+
error: 'error',
|
|
86
|
+
fatal: 'fatal',
|
|
87
|
+
} satisfies Record<ErrorSeverity, string>),
|
|
88
|
+
);
|
|
86
89
|
|
|
87
90
|
export interface SentryEnvelopeOptions {
|
|
88
91
|
readonly dsn: string;
|
package/src/flight-gate.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
// Single responsibility: how many of one kind of work may run at once, and how many callers may
|
|
2
2
|
// wait. THREE bounded pools shipped before this one — `@ultimat3/auth`'s kdf gate, `@ultimat3/ai`'s
|
|
3
|
-
// hive pool, `@ultimat3/http`'s `maxInflight` — and only the first refuses past its queue.
|
|
4
|
-
//
|
|
5
|
-
//
|
|
3
|
+
// hive pool, `@ultimat3/http`'s `maxInflight` — and only the first refuses past its queue.
|
|
4
|
+
//
|
|
5
|
+
// This header counted `@ultimat3/scraping`'s pacer as a fourth until 2026-08-23 and it is not one:
|
|
6
|
+
// a pacer bounds how OFTEN work starts, not how many run at once, so ten concurrent navigations all
|
|
6
7
|
// proceed merely staggered — no `maxConcurrent`, no queue bound, no refusal. Past the bound the
|
|
7
8
|
// answer here is a refusal, never a longer queue: an unbounded queue converts a load spike into a
|
|
8
9
|
// memory fault and answers it minutes late.
|
package/src/host-rules.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
// `allowHosts`, as a decision every browser driver asks before a request leaves — never a note in
|
|
2
|
-
//
|
|
1
|
+
// `allowHosts`, as a decision every browser driver asks before a request leaves — never a note in a
|
|
2
|
+
// README. A headless browser inside your network is the widest SSRF surface an app can own: one
|
|
3
3
|
// injected `<img src="http://169.254.169.254/…">` on a page you do not control is a credential
|
|
4
|
-
// read.
|
|
4
|
+
// read.
|
|
5
|
+
//
|
|
6
|
+
// In core because two tier-5 packages drive a browser (`scraping`, and `cli`'s `x shot`) and
|
|
5
7
|
// neither may import the other; two copies of this rule would be two answers to "may it leave".
|
|
6
8
|
|
|
7
9
|
import { classifyAddress } from './address-class';
|
package/src/image/probe.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
// Single responsibility: identify an image and read its intrinsic pixel size from the header
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
//
|
|
1
|
+
// Single responsibility: identify an image and read its intrinsic pixel size from the header bytes
|
|
2
|
+
// alone — never a decode, never a guess from a file extension. WebP, AVIF, GIF and SVG have no
|
|
3
|
+
// built-in codec here, yet every `<img>` still needs `width`/`height` inlined, and that is the only
|
|
4
|
+
// thing that keeps CLS at 0 for them.
|
|
5
|
+
//
|
|
6
|
+
// SVG declares its box in markup rather than in header bytes, so that reading lives in
|
|
7
|
+
// `probe-svg.ts`.
|
|
6
8
|
|
|
7
9
|
import { imageDecodeFailed, imageUnsupported } from './errors';
|
|
8
10
|
import { exifOrientation, swapsAxes } from './exif-orientation';
|
|
@@ -315,5 +317,10 @@ export function probeImage(bytes: Uint8Array): ImageInfo {
|
|
|
315
317
|
const { width, height } = probeSize(bytes, format);
|
|
316
318
|
// Before any allocation downstream: a hostile header is refused here, not at malloc.
|
|
317
319
|
assertPixelBudget(width, height, format);
|
|
318
|
-
|
|
320
|
+
// `format` is the sniff's own closed answer; the guard keeps the exported, mutable table's
|
|
321
|
+
// prototype from ever answering as a media type.
|
|
322
|
+
const mimeType = Object.hasOwn(IMAGE_MIME_TYPES, format)
|
|
323
|
+
? IMAGE_MIME_TYPES[format]
|
|
324
|
+
: 'application/octet-stream';
|
|
325
|
+
return { format, width, height, mimeType };
|
|
319
326
|
}
|
package/src/index.ts
CHANGED
|
@@ -999,6 +999,7 @@ export { timingSafeEqual } from './timing-safe-equal';
|
|
|
999
999
|
export type { ToolDescriptionSource } from './tool-description';
|
|
1000
1000
|
// A projected tool's description: `@ultimat3/mcp`'s and `@ultimat3/ai`'s, one tier apart from neither.
|
|
1001
1001
|
export { toolDescription } from './tool-description';
|
|
1002
|
+
export { trimTrailingSlashes } from './trailing-slashes';
|
|
1002
1003
|
export {
|
|
1003
1004
|
frameworkVersion,
|
|
1004
1005
|
readPackageVersion,
|
package/src/intl-cache.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
// One bounded cache, on one canonical key, and one screen, for every `Intl` formatter the
|
|
2
|
-
//
|
|
3
|
-
// A locale and a zone both arrive from a request header, so an unbounded `Map` keyed on the
|
|
1
|
+
// One bounded cache, on one canonical key, and one screen, for every `Intl` formatter the framework
|
|
2
|
+
// builds. A locale and a zone both arrive from a request header, so an unbounded `Map` keyed on the
|
|
4
3
|
// caller's spelling is memory the client chooses — 31 MB and 55.1 MB, measured `As of 2026-08` and
|
|
5
|
-
// written up in the README.
|
|
4
|
+
// written up in the README.
|
|
5
|
+
//
|
|
6
|
+
// The bound and the canonical key are two halves of ONE rule.
|
|
6
7
|
|
|
7
8
|
import { UltimateError } from './errors';
|
|
8
9
|
|
package/src/keyed-fingerprint.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
// Single responsibility: a fingerprint of caller input that is safe to PERSIST. `fingerprint()` is
|
|
2
2
|
// an unkeyed SHA-256 prefix — fine as an in-memory sharing key, but stored beside a row it is an
|
|
3
3
|
// offline oracle: a 6–20-digit account number or an ID number in an input, with the other fields
|
|
4
|
-
// known, is brute-forced from a database read.
|
|
5
|
-
//
|
|
4
|
+
// known, is brute-forced from a database read.
|
|
5
|
+
//
|
|
6
|
+
// Keyed with HMAC-SHA-256, the stored value proves nothing to anyone without the app's signing
|
|
7
|
+
// secret.
|
|
6
8
|
|
|
7
9
|
import { canonicalJson } from './canonical-json';
|
|
8
10
|
import { currentSigningSecret } from './cursor';
|
package/src/locale-direction.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
// Text direction of a locale — a fact about the locale's script, and nothing about catalogs or
|
|
2
|
-
// requests
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
//
|
|
2
|
+
// requests. Import it from `@ultimat3/core`: i18n's re-export was deleted in 25.0.0.
|
|
3
|
+
//
|
|
4
|
+
// Tier 0 rather than `@ultimat3/i18n`'s because `@ultimat3/ui`'s provider reflects `dir` onto
|
|
5
|
+
// `<html>` from the locale it was handed, and reaching the i18n barrel for that one function put
|
|
6
|
+
// the whole framework catalog into every browser chunk with a `UiProvider` in it (issue #490).
|
|
6
7
|
|
|
7
8
|
export type Direction = 'ltr' | 'rtl';
|
|
8
9
|
|
package/src/locale-path.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
// A locale in a URL, as pure path arithmetic over an explicit locale list: the default locale is
|
|
2
|
-
// the UNPREFIXED path, every other one is `/<locale>/…`.
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
//
|
|
2
|
+
// the UNPREFIXED path, every other one is `/<locale>/…`.
|
|
3
|
+
//
|
|
4
|
+
// Tier 0 for `locale-direction.ts`' reason: `@ultimat3/ui`'s `LocaleSwitcher` spells its links with
|
|
5
|
+
// it, and reaching the i18n barrel for one function puts the whole framework catalog into every
|
|
6
|
+
// browser chunk (issue #490). i18n wraps these with the app's configured locales (`localizedPath`,
|
|
7
|
+
// `splitLocalePrefix`), so apps call those.
|
|
6
8
|
|
|
7
9
|
/** The segment a locale is written as in a URL: lowercase, so `pt-BR` is `/pt-br/`. */
|
|
8
10
|
export function localeSegment(locale: string): string {
|
package/src/logger.ts
CHANGED
|
@@ -23,15 +23,18 @@ export const LOG_LEVELS = ['trace', 'debug', 'info', 'warn', 'error', 'fatal', '
|
|
|
23
23
|
|
|
24
24
|
export type LogLevel = (typeof LOG_LEVELS)[number];
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
26
|
+
// Null-prototype: a key that arrives untyped never answers an `Object.prototype` member.
|
|
27
|
+
const LEVEL_WEIGHT = Object.freeze<Record<LogLevel, number>>(
|
|
28
|
+
Object.assign(Object.create(null), {
|
|
29
|
+
trace: 10,
|
|
30
|
+
debug: 20,
|
|
31
|
+
info: 30,
|
|
32
|
+
warn: 40,
|
|
33
|
+
error: 50,
|
|
34
|
+
fatal: 60,
|
|
35
|
+
silent: 100,
|
|
36
|
+
} satisfies Record<LogLevel, number>),
|
|
37
|
+
);
|
|
35
38
|
|
|
36
39
|
export interface Logger {
|
|
37
40
|
readonly level: LogLevel;
|
package/src/otlp-log-exporter.ts
CHANGED
|
@@ -28,14 +28,17 @@ import {
|
|
|
28
28
|
} from './telemetry';
|
|
29
29
|
|
|
30
30
|
/** OTLP's `SeverityNumber`: the first number of each band. */
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
31
|
+
// Null-prototype: a key that arrives untyped never answers an `Object.prototype` member.
|
|
32
|
+
const SEVERITY = Object.freeze<Record<LogRecordEvent['level'], number>>(
|
|
33
|
+
Object.assign(Object.create(null), {
|
|
34
|
+
trace: 1,
|
|
35
|
+
debug: 5,
|
|
36
|
+
info: 9,
|
|
37
|
+
warn: 13,
|
|
38
|
+
error: 17,
|
|
39
|
+
fatal: 21,
|
|
40
|
+
} satisfies Record<LogRecordEvent['level'], number>),
|
|
41
|
+
);
|
|
39
42
|
|
|
40
43
|
/** One record as the exporter holds it: the event, and the span it was written under. */
|
|
41
44
|
export interface ExportedLogRecord {
|
|
@@ -28,19 +28,25 @@ import type {
|
|
|
28
28
|
} from './telemetry';
|
|
29
29
|
|
|
30
30
|
/** OTLP's `SpanKind` enum; `UNSPECIFIED` is 0 and Ultimate never emits it. */
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
31
|
+
// Null-prototype: a key that arrives untyped never answers an `Object.prototype` member.
|
|
32
|
+
const SPAN_KIND = Object.freeze<Record<SpanKind, number>>(
|
|
33
|
+
Object.assign(Object.create(null), {
|
|
34
|
+
internal: 1,
|
|
35
|
+
server: 2,
|
|
36
|
+
client: 3,
|
|
37
|
+
producer: 4,
|
|
38
|
+
consumer: 5,
|
|
39
|
+
} satisfies Record<SpanKind, number>),
|
|
40
|
+
);
|
|
38
41
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
// Null-prototype: a key that arrives untyped never answers an `Object.prototype` member.
|
|
43
|
+
const STATUS_CODE = Object.freeze<Record<SpanStatusCode, number>>(
|
|
44
|
+
Object.assign(Object.create(null), {
|
|
45
|
+
unset: 0,
|
|
46
|
+
ok: 1,
|
|
47
|
+
error: 2,
|
|
48
|
+
} satisfies Record<SpanStatusCode, number>),
|
|
49
|
+
);
|
|
44
50
|
|
|
45
51
|
interface OtlpSpanJson {
|
|
46
52
|
readonly traceId: string;
|
package/src/otlp.ts
CHANGED
|
@@ -8,6 +8,7 @@ import { renderFixShellArg } from './error-render';
|
|
|
8
8
|
import { type CodedErrorInit, UltimateError } from './errors';
|
|
9
9
|
import { otlpEndpointLabel } from './otlp-post';
|
|
10
10
|
import type { AttributeValue, SpanResource } from './telemetry';
|
|
11
|
+
import { trimTrailingSlashes } from './trailing-slashes';
|
|
11
12
|
import { frameworkVersion } from './version';
|
|
12
13
|
|
|
13
14
|
export class OtlpEndpointInvalidError extends UltimateError {
|
|
@@ -110,7 +111,7 @@ function parseEndpoint(signal: OtlpSignal, raw: string, perSignal: boolean, env:
|
|
|
110
111
|
if (perSignal) return url.toString();
|
|
111
112
|
// On the PATH, never on the string: `http://collector:4318?tenant=a` concatenated to
|
|
112
113
|
// `…/?tenant=a/v1/traces`, a request to `/` whose query merely ends in the receiver's path.
|
|
113
|
-
url.pathname = `${url.pathname
|
|
114
|
+
url.pathname = `${trimTrailingSlashes(url.pathname)}/v1/${signal}`;
|
|
114
115
|
return url.toString();
|
|
115
116
|
}
|
|
116
117
|
|
package/src/outbound-headers.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The trace and request-budget headers a SERVER-side typed call carries onward, installed into the
|
|
3
3
|
* transport's slot by the code that makes them meaningful — `runWithContext` and `startSpan` — and
|
|
4
|
-
* never at import.
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* never at import.
|
|
5
|
+
*
|
|
6
|
+
* A browser runs neither, so its slot stays empty and `clientTransport` carries zero bytes of
|
|
7
|
+
* telemetry, context or logger: that graph was 12.9 kB of every island that called `rpc()` or
|
|
8
|
+
* `queryClient()`, for a header a browser never has a value for.
|
|
7
9
|
*/
|
|
8
10
|
|
|
9
11
|
import { traceHeaders } from './client-wire';
|
package/src/page.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* `@ultimat3/core/page` — the ONE light entry for browser code: the page handle, the principal
|
|
3
3
|
* fence, the names a document, a service worker and an island agree on, and `UltimateError` with
|
|
4
|
-
* the render helper a refusal's `fix:` needs.
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* `
|
|
4
|
+
* the render helper a refusal's `fix:` needs.
|
|
5
|
+
*
|
|
6
|
+
* What it never carries is a titles TABLE: any barrel import retains the anchored
|
|
7
|
+
* `core-error-codes.ts` and `schema-error-codes.ts`, and a browser that loaded no table titles a
|
|
8
|
+
* code from its name. The barrel re-exports every name here; `page-bundle.test.ts` fails if this
|
|
9
|
+
* entry ever grows a table back.
|
|
8
10
|
*/
|
|
9
11
|
|
|
10
12
|
// The client seam's own functions, for the hooks a browser island calls: the one transport, the
|
|
@@ -89,6 +91,7 @@ export { fillTemplate, templateParams } from './route-path-template';
|
|
|
89
91
|
export { onSessionLost, sessionIsLost } from './session-lost';
|
|
90
92
|
// The key the theme boot script reads and the toggle island writes.
|
|
91
93
|
export { THEME_STORAGE_KEY } from './theme-storage';
|
|
94
|
+
export { trimTrailingSlashes } from './trailing-slashes';
|
|
92
95
|
// A poll a hidden tab and a lost session stop: here, so an island polling reaches no realtime.
|
|
93
96
|
export type { VisibleIntervalOptions } from './visible-interval';
|
|
94
97
|
export { visibleInterval } from './visible-interval';
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
// Test support: drop the probe databases a KILLED run of the same suite left behind. A per-run name
|
|
2
2
|
// (`probe-database.ts`) is never reused, so nothing else would ever drop it — the fixed name it
|
|
3
|
-
// replaced was dropped by the next run.
|
|
4
|
-
//
|
|
5
|
-
//
|
|
3
|
+
// replaced was dropped by the next run.
|
|
4
|
+
//
|
|
5
|
+
// Only a database whose run is provably over goes: its pid dead on this host, no backend connected,
|
|
6
|
+
// AND older than `PROBE_DATABASE_MIN_AGE_MS` — a run on another host that has created its database
|
|
7
|
+
// and not yet connected reads dead and idle here.
|
|
6
8
|
|
|
7
9
|
import { stringField } from './error-render';
|
|
8
10
|
import type { PgExecutor } from './pg-executor';
|
package/src/read-capped.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
// Single responsibility: reading a request body through a COUNTING reader, so a payload past the
|
|
2
|
-
// cap is never held in full.
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
// `
|
|
2
|
+
// cap is never held in full.
|
|
3
|
+
//
|
|
4
|
+
// It lives in core because two transports need the identical guarantee and cannot share it any
|
|
5
|
+
// other way: `@ultimat3/http` (tier 2) owns `bodyLimitBytes`, and `@ultimat3/mcp` (tier 4) serves a
|
|
6
|
+
// bare `Request` that never passes through http's pipeline — `await request.json()` there was
|
|
7
|
+
// governed only by Bun's 128 MiB default.
|
|
6
8
|
|
|
7
9
|
import { assert } from './assert';
|
|
8
10
|
|
package/src/registrar.ts
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
// the same tier, so each owner announces its registrar here at import time and callers ask
|
|
4
4
|
// by kind. Same shape as `defineService` and `registerErrorCodes`.
|
|
5
5
|
|
|
6
|
+
import { renderFixShellArg } from './error-render';
|
|
6
7
|
import { UltimateError } from './errors';
|
|
7
8
|
|
|
8
9
|
/**
|
|
@@ -410,7 +411,7 @@ export function registerPrimitiveRegistrar(kind: PrimitiveKind, registrar: Modul
|
|
|
410
411
|
// One command, because a `fix:` is pasted verbatim: collapsing every range on the package
|
|
411
412
|
// to one resolved version is the repair. `bun pm why <package>` names the dependents when
|
|
412
413
|
// a range genuinely disagrees and the update cannot converge on its own.
|
|
413
|
-
fix: `bun update ${PRIMITIVE_PACKAGES[kind]}`,
|
|
414
|
+
fix: `bun update ${renderFixShellArg(PRIMITIVE_PACKAGES[kind], '<the @ultimat3 package the cause names>')}`,
|
|
414
415
|
meta: { kind },
|
|
415
416
|
});
|
|
416
417
|
}
|
|
@@ -432,7 +433,7 @@ export function primitiveRegistrar(kind: PrimitiveKind): ModuleRegistrar {
|
|
|
432
433
|
throw new UltimateError({
|
|
433
434
|
code: 'X_REGISTRAR_MISSING',
|
|
434
435
|
cause: `no ${kind} registrar is loaded, so ${kind} primitives cannot be registered`,
|
|
435
|
-
fix: `bun add ${PRIMITIVE_PACKAGES[kind]}`,
|
|
436
|
+
fix: `bun add ${renderFixShellArg(PRIMITIVE_PACKAGES[kind], '<the @ultimat3 package the cause names>')}`,
|
|
436
437
|
meta: { kind },
|
|
437
438
|
});
|
|
438
439
|
}
|
package/src/request-budget.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
// How much of THIS request's budget is left, and the one header that carries it to the next hop.
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
// tier
|
|
5
|
-
//
|
|
2
|
+
//
|
|
3
|
+
// The header name lives here rather than in `@ultimat3/http` because both ends need it and only one
|
|
4
|
+
// of them is tier 2: the reader is http's `resolveTimeoutMs`, the writer is a typed client in tier
|
|
5
|
+
// 0, and a second literal in the writer is a propagation that silently stops working the day either
|
|
6
|
+
// string is edited.
|
|
6
7
|
|
|
7
8
|
import type { Ctx } from './context';
|
|
8
9
|
import { tryUseContext } from './context';
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// process that imports `@ultimat3/core` — not just the CLI. `@ultimat3/schema` is tier 0 alongside
|
|
3
3
|
// this package and cannot call `registerErrorCodes()` itself: that would be `schema -> core`, an
|
|
4
4
|
// import this package's own dependency-free promise forbids in that direction and always will.
|
|
5
|
+
//
|
|
5
6
|
// The other direction is DECLARED (`core -> schema`, `scripts/lib/tiers.ts`), so the titles are
|
|
6
7
|
// READ from schema rather than restated here.
|
|
7
8
|
//
|
package/src/seal-errors.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
// Single responsibility: the three X_SEAL_* refusals and the errors that carry them. Three codes
|
|
2
2
|
// rather than one "it will not open" because each names a different fact — no key at all, a key
|
|
3
|
-
// this process was not given, a value that did not authenticate — and a different thing to do
|
|
4
|
-
//
|
|
5
|
-
//
|
|
6
|
-
//
|
|
3
|
+
// this process was not given, a value that did not authenticate — and a different thing to do next.
|
|
4
|
+
// No error here carries a key, a plaintext or the sealed string itself.
|
|
5
|
+
//
|
|
6
|
+
// Titles live in `core-error-codes.ts` and the retry class in `error-retry.ts`, so this module runs
|
|
7
|
+
// nothing at import and stays out of every bundle that does not seal.
|
|
7
8
|
|
|
8
9
|
import { renderCauseValue } from './error-render';
|
|
9
10
|
import { UltimateError } from './errors';
|
package/src/secrets-errors.ts
CHANGED
|
@@ -72,7 +72,7 @@ export class SecretsKeyMissingError extends UltimateError {
|
|
|
72
72
|
input.source !== undefined
|
|
73
73
|
? 'export const runtime = { secretSource } # apps/<app>/runtime.ts — that source must answer a master key (check the KMS key or Vault path it reads); delete it to fall back to ULTIMATE_SECRETS_KEY, then .secrets.key'
|
|
74
74
|
: ENV_VAR_NAME.test(input.envVar)
|
|
75
|
-
? `export ${input.envVar}="$(cat ${renderFixShellArg(input.keyPath, '<the key file the cause names>')})" # in a repo that has no key yet: x secrets init`
|
|
75
|
+
? `export ${renderFixShellArg(input.envVar, 'ULTIMATE_SECRETS_KEY')}="$(cat ${renderFixShellArg(input.keyPath, '<the key file the cause names>')})" # in a repo that has no key yet: x secrets init`
|
|
76
76
|
: "set the variable this error's cause names to the contents of the key file beside it, in whatever way this shell spells an assignment — in a repo that has no key yet: x secrets init",
|
|
77
77
|
meta: {
|
|
78
78
|
keyPath: input.keyPath,
|
package/src/source-mask.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
// Reading TypeScript source without a parser: comments — and optionally string contents — replaced
|
|
2
|
-
// by spaces, newlines kept so line numbers survive.
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
//
|
|
2
|
+
// by spaces, newlines kept so line numbers survive.
|
|
3
|
+
//
|
|
4
|
+
// Moved here from `@ultimat3/cli`'s `ts-scan.ts` on 2026-09-05 because `@ultimat3/i18n`'s key
|
|
5
|
+
// extractor (tier 1) needed exactly this and could not import a tier-5 package: a `// … t('…')` in
|
|
6
|
+
// a comment was a phantom key `x i18n sync` would have written as `"…": "⟦…⟧"`. One masking
|
|
7
|
+
// implementation, at the tier every scanner can reach.
|
|
6
8
|
|
|
7
9
|
// `ReadonlySet`, so a consumer cannot mutate what every scan reads.
|
|
8
10
|
export const QUOTES: ReadonlySet<string> = new Set(["'", '"', '`']);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// `trimTrailingSlashes`: a string without its trailing `/` run, in one linear pass. `/\/+$/` is
|
|
2
|
+
// quadratic on a long run of slashes followed by anything else (CodeQL `js/polynomial-redos`), and
|
|
3
|
+
// a base URL, an issuer or an origin is often operator or caller input.
|
|
4
|
+
|
|
5
|
+
/** `value` with every trailing `/` removed; `'///'` becomes `''`. */
|
|
6
|
+
export function trimTrailingSlashes(value: string): string {
|
|
7
|
+
let end = value.length;
|
|
8
|
+
while (end > 0 && value.charCodeAt(end - 1) === 47) end -= 1;
|
|
9
|
+
return end === value.length ? value : value.slice(0, end);
|
|
10
|
+
}
|
package/src/type-pins.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
// Compile-time pins for the actor-facts seam, the config surface, the request-context patch and
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
//
|
|
1
|
+
// Compile-time pins for the actor-facts seam, the config surface, the request-context patch and the
|
|
2
|
+
// route and cache-tier vocabularies. Source, not a `.test.ts`, on purpose: `tsconfig.json` excludes
|
|
3
|
+
// `src/**/*.test.ts`, so `tsc -b` never reads a test file and a type-level assertion written there
|
|
4
|
+
// can never fail.
|
|
5
|
+
//
|
|
6
|
+
// This module emits nothing and exports nothing anybody imports — a regression is a build error.
|
|
6
7
|
|
|
7
8
|
import type { Actor, ActorFactMap, FactKeysOf, FactMapOf } from './actor';
|
|
8
9
|
import type { CacheTierName } from './cache-vocabulary';
|
package/src/version.ts
CHANGED
|
@@ -3,8 +3,9 @@
|
|
|
3
3
|
// manifest is `private` and carries no `version`, and after `npm install` a walk above the package
|
|
4
4
|
// lands in `node_modules/` where there is no manifest at all. Both mistakes fail silently.
|
|
5
5
|
|
|
6
|
+
// why: `frameworkVersion()` is synchronous and `Bun.file` reads only asynchronously.
|
|
6
7
|
import { existsSync, readFileSync } from 'node:fs';
|
|
7
|
-
// Bun has no path-join primitive; `import.meta.dir` is the module's own directory in both the
|
|
8
|
+
// why: Bun has no path-join primitive; `import.meta.dir` is the module's own directory in both the
|
|
8
9
|
// checked-out `src/` layout and the published `dist/` one, each exactly one level below the
|
|
9
10
|
// package root.
|
|
10
11
|
import { resolve } from 'node:path';
|
package/src/wire-dates.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Which values of an answer were instants. `JSON.stringify` writes a `Date` as its ISO string and
|
|
3
3
|
* nothing on the far side can tell it from text, so a read's row typed `Date` reached its caller as
|
|
4
|
-
* a string — and every app converted at its own edge (`wireDate()`).
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
4
|
+
* a string — and every app converted at its own edge (`wireDate()`).
|
|
5
|
+
*
|
|
6
|
+
* The server knows: it walks the answer once, names each `Date` by its path in `x-ultimate-dates`,
|
|
7
|
+
* and `clientTransport` turns exactly those strings back into `Date`s. The body is unchanged, so a
|
|
8
|
+
* client that ignores the header reads what it always read.
|
|
8
9
|
*
|
|
9
10
|
* A path is a list of segments: a string is an object key, a number an array index, and `null`
|
|
10
11
|
* EVERY element of an array — what a list of rows folds to (`[[null, "publishedAt"]]`), so the
|
package/src/write-origin.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
// The write in flight on the server: the digest of the idempotency key the request that is
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
//
|
|
1
|
+
// The write in flight on the server: the digest of the idempotency key the request that is running
|
|
2
|
+
// arrived with. `@ultimat3/action`'s HTTP projection opens the scope; the layers that turn a
|
|
3
|
+
// committed row into a `records` frame read it — entity's row observer in-process, and the Postgres
|
|
4
|
+
// driver, which writes it into the WAL for the replicator to find.
|
|
5
|
+
//
|
|
6
|
+
// Server-only: it rides core's one `AsyncLocalStorage` seam, which a browser bundle does not have.
|
|
6
7
|
|
|
7
8
|
import { asyncContext } from './async-context';
|
|
8
9
|
import { isWriteDigest } from './write-digest';
|