@ultimat3/core 31.53.1 → 31.55.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/CLAUDE.md CHANGED
@@ -20,7 +20,7 @@ change to every package. A row or rule marked `†` has its full text in
20
20
  | Time | take a `Clock` (a `SleepClock` to wait); `Date.now()` / `new Date()` only in `clock.ts`; a waiting timer only in `sleep-clock.ts` |
21
21
  | Context | never thread `ctx` as a parameter — `useContext()` |
22
22
  | A value ambient across an `await` | `asyncContext<T>(subject)` from `async-context.ts`, in **every** package — never `new AsyncLocalStorage` |
23
- | Exports | explicit in `src/index.ts`; no `export *`. Six public subpaths (`./adapter`, `./page`, `./outbound`, `./redis`, `./render-node`, `./render-nodes`), two internal (`./internal/error-status`, `./internal/sse-frames`: the one SSE frame reader); nothing that loads a titles table joins `./page` (`page-bundle.test.ts`); an app imports `defineError` there (`define-error-bytes.test.ts`) † |
23
+ | Exports | explicit in `src/index.ts`; no `export *`. Seven public subpaths (`./adapter`, `./page`, `./outbound`, `./redis`, `./render-node`, `./render-nodes`, `./test-pace`), two internal (`./internal/error-status`, `./internal/sse-frames`: the one SSE frame reader); nothing that loads a titles table joins `./page` (`page-bundle.test.ts`); apps import `defineError` there (`define-error-bytes.test.ts`) † |
24
24
  | Files | < 200 LOC, 500 hard ceiling, one responsibility, `kebab-case.ts`, test beside source |
25
25
  | Type claims | `type-pins.ts`, never a `.test.ts` — `tsconfig.json` excludes tests |
26
26
 
package/README.md CHANGED
@@ -965,6 +965,21 @@ Server-only, on its own subpath: `import { outbound, screenDial } from '@ultimat
965
965
  | `breaker({ name, failures, cooldownMs, classify?, clock? })` → `admit`, `succeeded`, `failed`, `released`, `state`, `failures`, `judge`, `refusal`, `run` | is a dependency down | one state machine, the trigger stays the caller's. One probe in `half-open`, lapsing after `cooldownMs`; `X_BREAKER_OPEN` names `retryAfterSeconds`; `breaker_transitions_total{name,to}`. Per process |
966
966
  | `retryBudgetOf(breaker)` → `called()`, `spend()` | retries as a share of calls, per breaker key | whether one more retry may go out during a partial outage the breaker cannot see: a call earns 1 token, a retry costs 5 (retries ≤ 20% of calls), a quiet key starts with a burst of 10 retries. Keyed by breaker identity, per process; `outbound` consults it, and a refused retry answers the last error |
967
967
 
968
+ ## A test deadline at the gate's pace
969
+
970
+ On its own subpath: `import { paced } from '@ultimat3/core/test-pace'` (the barrel exports none of
971
+ it, `test-pace.test.ts`). `paced(ms)` is `ms` times `ULTIMATE_TEST_PACE`, which `x verify` measures
972
+ and sets on every test run it starts; absent is 1, and a value that is not a number at or above 1 is
973
+ `X_TEST_PACE_INVALID`. Core's so a test in any tier reads the one number: `@ultimat3/testing`
974
+ re-exports `paced` and `TEST_PACE_ENV` from here. `As of 2026-11`.
975
+
976
+ | Export | The one answer |
977
+ |---|---|
978
+ | `paced(ms, env?)` | a declared test or hook deadline at this machine's pace: `test(name, body, paced(90_000))` |
979
+ | `testPace(env?)` | the pace itself, 1 or more |
980
+ | `TEST_PACE_ENV` | `'ULTIMATE_TEST_PACE'` |
981
+ | `TestPaceInvalidError` | `X_TEST_PACE_INVALID` |
982
+
968
983
  ## One Redis client
969
984
 
970
985
  Server-only, on its own subpath: `import { redisClient } from '@ultimat3/core/redis'` (the barrel
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ultimat3/core",
3
- "version": "31.53.1",
3
+ "version": "31.55.0",
4
4
  "description": "Ultimate's foundation: errors, context, env, config, clock, ids, logging, telemetry, lifecycle",
5
5
  "keywords": [
6
6
  "ultimate",
@@ -17,7 +17,8 @@
17
17
  "type": "module",
18
18
  "sideEffects": [
19
19
  "./src/core-error-codes.ts",
20
- "./src/schema-error-codes.ts"
20
+ "./src/schema-error-codes.ts",
21
+ "./src/test-pace.ts"
21
22
  ],
22
23
  "repository": {
23
24
  "type": "git",
@@ -37,7 +38,8 @@
37
38
  "./outbound": "./src/outbound-subpath.ts",
38
39
  "./redis": "./src/redis-client.ts",
39
40
  "./render-node": "./src/render-node.ts",
40
- "./render-nodes": "./src/render-nodes.ts"
41
+ "./render-nodes": "./src/render-nodes.ts",
42
+ "./test-pace": "./src/test-pace.ts"
41
43
  },
42
44
  "files": [
43
45
  "src",
@@ -55,6 +57,6 @@
55
57
  "test": "bun test"
56
58
  },
57
59
  "dependencies": {
58
- "@ultimat3/schema": "31.53.1"
60
+ "@ultimat3/schema": "31.55.0"
59
61
  }
60
62
  }
package/src/index.ts CHANGED
@@ -417,6 +417,7 @@ export {
417
417
  describeErrorCode,
418
418
  describeValue,
419
419
  EnvMissingError,
420
+ /** @deprecated Goes when `next` merges: `errorDocsUrl(code)` links each code's own page. */
420
421
  ERROR_DOCS_URL,
421
422
  ERROR_RETRY_KINDS,
422
423
  errorCodeSnapshot,
@@ -0,0 +1,42 @@
1
+ // How much slower this machine runs than the one a test's deadline was measured on: `x verify`
2
+ // measures it (`packages/cli/src/verify-pace.ts`) and passes it as `ULTIMATE_TEST_PACE`. On core's
3
+ // own subpath so a test in any tier reads one number; `@ultimat3/testing` re-exports it.
4
+
5
+ import { registerErrorCodes } from './error-codes';
6
+ import { UltimateError } from './errors';
7
+
8
+ // Registered HERE, not in `core-error-codes.ts`: that table rides every browser page, and a test's
9
+ // pace is never read there (axiom 6).
10
+ registerErrorCodes({
11
+ X_TEST_PACE_INVALID: { title: 'ULTIMATE_TEST_PACE is not a number at or above 1' },
12
+ });
13
+
14
+ /** Set by `x verify` on each test run it starts. Absent — a hand-run `bun test` — is pace 1. */
15
+ export const TEST_PACE_ENV = 'ULTIMATE_TEST_PACE';
16
+
17
+ /** A pace that does not parse, or one below 1: a machine is never read as faster than the bound. */
18
+ export class TestPaceInvalidError extends UltimateError {
19
+ constructor(value: string) {
20
+ super({
21
+ code: 'X_TEST_PACE_INVALID',
22
+ cause: `${TEST_PACE_ENV}=${JSON.stringify(value)} is not a number at or above 1`,
23
+ fix: `env -u ${TEST_PACE_ENV} bun test <file> # the gate measures the pace and sets it on each test run itself; unset is pace 1`,
24
+ });
25
+ }
26
+ }
27
+
28
+ /** The pace this process was started at. */
29
+ export function testPace(env: Readonly<Record<string, string | undefined>> = Bun.env): number {
30
+ const raw = env[TEST_PACE_ENV];
31
+ if (raw === undefined || raw.trim() === '') return 1;
32
+ const pace = Number(raw);
33
+ if (!Number.isFinite(pace) || pace < 1) throw new TestPaceInvalidError(raw);
34
+ return pace;
35
+ }
36
+
37
+ /**
38
+ * A declared test deadline at this machine's pace: `test(name, body, paced(90_000))`. The number
39
+ * stays the one measured on a fast machine; only a slower one stretches it.
40
+ */
41
+ export const paced = (ms: number, env?: Readonly<Record<string, string | undefined>>): number =>
42
+ Math.round(ms * testPace(env));