@ultimat3/cli 31.46.0 → 31.47.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 +1 -1
- package/README.md +1 -1
- package/package.json +29 -29
- package/src/affected.ts +3 -2
- package/src/app-config-load.ts +8 -5
- package/src/app-mcp.ts +2 -5
- package/src/app-runtime.ts +4 -4
- package/src/cmd-cache.ts +8 -4
- package/src/cmd-deploy-compose.ts +11 -12
- package/src/cmd-deploy-helm.ts +5 -8
- package/src/cmd-exercise-spec.ts +2 -2
- package/src/cmd-exercise.ts +7 -19
- package/src/cmd-new.ts +4 -3
- package/src/cmd-planned.ts +11 -76
- package/src/cmd-shot-matrix.ts +3 -2
- package/src/cmd-token.ts +11 -3
- package/src/codemods/ci-weekly-schedule.ts +61 -0
- package/src/codemods/index.ts +2 -0
- package/src/codemods/vendored-guards.ts +3 -5
- package/src/codemods/verify-floor-skips.ts +4 -6
- package/src/codemods/verify-floor-steps.ts +4 -3
- package/src/db-seed.ts +3 -2
- package/src/dispatch.ts +2 -11
- package/src/duplicate-packages.ts +4 -4
- package/src/exercise-findings.ts +4 -3
- package/src/exercise-floor.ts +1 -1
- package/src/exercise-seed.ts +34 -0
- package/src/fix-command.ts +2 -3
- package/src/flag-reads.ts +6 -3
- package/src/generate-files.ts +10 -6
- package/src/gitignore.ts +4 -3
- package/src/guards-built-in.ts +3 -6
- package/src/guards.ts +5 -8
- package/src/island-bundle.ts +3 -2
- package/src/island-sources.ts +4 -3
- package/src/island-states-load.ts +4 -3
- package/src/island-store.ts +3 -2
- package/src/json-merge.ts +8 -6
- package/src/lint-findings.ts +4 -7
- package/src/mcp-errors.ts +1 -1
- package/src/messages.ts +1 -0
- package/src/prerender-out.ts +4 -3
- package/src/publish-closure.ts +4 -6
- package/src/pwa-manifest-locales.ts +5 -8
- package/src/registry.ts +0 -7
- package/src/root-env.ts +3 -2
- package/src/runtime-admin.ts +2 -4
- package/src/runtime-keys.ts +5 -2
- package/src/static-report.ts +5 -8
- package/src/templates/github/ci-schedule.ts +86 -0
- package/src/templates/github/ci.yml.ts +6 -8
- package/src/templates/github/dependabot.yml.ts +6 -1
- package/src/templates/scaffold-docs.ts +1 -0
- package/src/templates/shapes/overlay.ts +4 -7
- package/src/upgrade-guards-baseline.ts +3 -5
- package/src/verify-merge-skips.ts +2 -4
- package/src/verify-merge.ts +13 -8
- package/src/verify-part-step.ts +5 -7
- package/src/worker-bundle.ts +4 -2
- package/wiki/Actions.md +69 -5
- package/wiki/Agents.md +13 -0
- package/wiki/Auth.md +4 -0
- package/wiki/Batching-And-Preloading.md +77 -3
- package/wiki/CLI-Reference.md +18 -5
- package/wiki/Caching-And-Invalidation.md +76 -23
- package/wiki/Client-Navigation.md +2 -0
- package/wiki/Configuration.md +17 -4
- package/wiki/Entities-And-Migrations.md +168 -6
- package/wiki/FAQ.md +1 -1
- package/wiki/Feature-Flags.md +3 -0
- package/wiki/Getting-Started.md +27 -1
- package/wiki/Jobs-And-Workflows.md +70 -13
- package/wiki/Known-Gaps.md +58 -49
- package/wiki/MCP-And-AI.md +43 -3
- package/wiki/Mail.md +6 -0
- package/wiki/Migrations-And-Backfills.md +13 -0
- package/wiki/Money.md +20 -1
- package/wiki/N-Plus-One-Detection.md +31 -1
- package/wiki/Notify.md +13 -2
- package/wiki/PWA-And-Offline.md +34 -4
- package/wiki/Policies-And-Authz.md +27 -5
- package/wiki/Queries-And-Live-Queries.md +41 -4
- package/wiki/Realtime.md +22 -0
- package/wiki/Resource-Management.md +6 -1
- package/wiki/Routes-And-Render-Modes.md +54 -6
- package/wiki/SEO.md +24 -2
- package/wiki/Scheduled-Tasks.md +29 -11
- package/wiki/Scraping.md +33 -2
- package/wiki/Static-Assets.md +1 -0
- package/wiki/Storage-And-Uploads.md +8 -1
- package/wiki/Testing.md +120 -13
- package/wiki/The-Eight-Primitives.md +125 -6
- package/wiki/Timezones-And-Dates.md +13 -5
- package/wiki/Troubleshooting.md +1 -1
- package/wiki/Tutorial-02-First-Feature.md +6 -0
- package/wiki/Tutorial-03-Auth-And-Admin.md +8 -0
- package/wiki/Tutorial-04-Jobs-And-Realtime.md +40 -2
- package/wiki/Tutorial-06-Growing-Up.md +1 -2
- package/wiki/UI-Components.md +14 -5
- package/wiki/Upgrading.md +41 -4
package/src/verify-merge.ts
CHANGED
|
@@ -16,7 +16,13 @@
|
|
|
16
16
|
import { existsSync } from 'node:fs';
|
|
17
17
|
// why: Bun ships no path-join primitive.
|
|
18
18
|
import { join } from 'node:path';
|
|
19
|
-
import {
|
|
19
|
+
import {
|
|
20
|
+
APP_CONFIG_FILE,
|
|
21
|
+
ERROR_DOCS_URL,
|
|
22
|
+
isJsonObject,
|
|
23
|
+
renderThrowable,
|
|
24
|
+
UltimateError,
|
|
25
|
+
} from '@ultimat3/core';
|
|
20
26
|
import { judgeCoverage } from './coverage-floor';
|
|
21
27
|
import type { CoverageMap } from './coverage-lcov';
|
|
22
28
|
import { decodeCoverage, mergeCoverage } from './coverage-lcov';
|
|
@@ -74,9 +80,6 @@ export interface MergeOptions {
|
|
|
74
80
|
readonly riders?: MergeRiders;
|
|
75
81
|
}
|
|
76
82
|
|
|
77
|
-
const isRecord = (value: unknown): value is Record<string, unknown> =>
|
|
78
|
-
typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
79
|
-
|
|
80
83
|
/**
|
|
81
84
|
* The LAST non-empty line, and only it: an app's own wrapper script (an older scaffold's
|
|
82
85
|
* `bin/check --json`) prints the build's document and then the gate's. Never "the last line that parses" — a part whose tail is not the gate's document is
|
|
@@ -99,14 +102,14 @@ export function parsePart(file: string, text: string, command: string = GATE_COM
|
|
|
99
102
|
command,
|
|
100
103
|
});
|
|
101
104
|
}
|
|
102
|
-
if (!
|
|
105
|
+
if (!isJsonObject(doc) || doc['command'] !== 'verify' || !Array.isArray(doc['steps'])) {
|
|
103
106
|
throw new VerifyMergeInputError({
|
|
104
107
|
file,
|
|
105
108
|
reason: 'is not an x verify --json document (no "command": "verify" with "steps")',
|
|
106
109
|
command,
|
|
107
110
|
});
|
|
108
111
|
}
|
|
109
|
-
const data =
|
|
112
|
+
const data = isJsonObject(doc['data']) ? doc['data'] : {};
|
|
110
113
|
const steps: PartStep[] = [];
|
|
111
114
|
for (const raw of doc['steps'] as unknown[]) {
|
|
112
115
|
const step = readPartStep(raw);
|
|
@@ -114,9 +117,11 @@ export function parsePart(file: string, text: string, command: string = GATE_COM
|
|
|
114
117
|
steps.push(step);
|
|
115
118
|
}
|
|
116
119
|
const coverage = new Map<string, CoverageMap>();
|
|
117
|
-
for (const [step, entry] of Object.entries(
|
|
120
|
+
for (const [step, entry] of Object.entries(
|
|
121
|
+
isJsonObject(data['coverage']) ? data['coverage'] : {},
|
|
122
|
+
)) {
|
|
118
123
|
// A part that judged its own floor carries numbers, not facts: nothing here to fold.
|
|
119
|
-
if (!
|
|
124
|
+
if (!isJsonObject(entry) || !('facts' in entry)) continue;
|
|
120
125
|
const map = decodeCoverage(entry['facts']);
|
|
121
126
|
if (map === undefined) {
|
|
122
127
|
throw new VerifyMergeInputError({
|
package/src/verify-part-step.ts
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// cast past `name` and `ok`: `findings: [null]` merged green, and a step with no `durationMs`
|
|
3
3
|
// reached `Math.max` as `undefined` — a part a CI job hand-edited, or truncated, was believed.
|
|
4
4
|
|
|
5
|
+
import { isJsonObject } from '@ultimat3/core';
|
|
5
6
|
import type { Finding, TestServicesState } from './output';
|
|
6
7
|
import type { TestCounts } from './test-counts';
|
|
7
8
|
|
|
@@ -24,21 +25,18 @@ export interface PartStep {
|
|
|
24
25
|
};
|
|
25
26
|
}
|
|
26
27
|
|
|
27
|
-
const isRecord = (value: unknown): value is Record<string, unknown> =>
|
|
28
|
-
typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
29
|
-
|
|
30
28
|
const isCount = (value: unknown): value is number =>
|
|
31
29
|
typeof value === 'number' && Number.isInteger(value) && value >= 0;
|
|
32
30
|
|
|
33
31
|
/** What every finding is: code, cause and fix as strings. Optional fields ride along as written. */
|
|
34
32
|
export const isFinding = (value: unknown): value is Finding =>
|
|
35
|
-
|
|
33
|
+
isJsonObject(value) &&
|
|
36
34
|
typeof value['code'] === 'string' &&
|
|
37
35
|
typeof value['cause'] === 'string' &&
|
|
38
36
|
typeof value['fix'] === 'string';
|
|
39
37
|
|
|
40
38
|
const isTests = (value: unknown): value is TestCounts =>
|
|
41
|
-
|
|
39
|
+
isJsonObject(value) &&
|
|
42
40
|
isCount(value['ran']) &&
|
|
43
41
|
isCount(value['skipped']) &&
|
|
44
42
|
(value['errors'] === undefined || isCount(value['errors']));
|
|
@@ -47,7 +45,7 @@ const isTextList = (value: unknown): value is readonly string[] =>
|
|
|
47
45
|
Array.isArray(value) && value.every((line) => typeof line === 'string');
|
|
48
46
|
|
|
49
47
|
const isShard = (value: unknown): value is NonNullable<PartStep['shard']> =>
|
|
50
|
-
|
|
48
|
+
isJsonObject(value) &&
|
|
51
49
|
isCount(value['index']) &&
|
|
52
50
|
isCount(value['total']) &&
|
|
53
51
|
typeof value['corpusHash'] === 'string' &&
|
|
@@ -56,7 +54,7 @@ const isShard = (value: unknown): value is NonNullable<PartStep['shard']> =>
|
|
|
56
54
|
|
|
57
55
|
/** The step, or the reason it is not one — phrased to follow "holds a step …". */
|
|
58
56
|
export function readPartStep(raw: unknown): PartStep | string {
|
|
59
|
-
if (!
|
|
57
|
+
if (!isJsonObject(raw) || typeof raw['name'] !== 'string' || typeof raw['ok'] !== 'boolean') {
|
|
60
58
|
return 'holds a step without a name and ok';
|
|
61
59
|
}
|
|
62
60
|
const name = raw['name'];
|
package/src/worker-bundle.ts
CHANGED
|
@@ -7,13 +7,15 @@
|
|
|
7
7
|
// so an old tab keeps what it started with.
|
|
8
8
|
|
|
9
9
|
// why: Bun ships no path API; the entry is resolved to a file and named in the cause.
|
|
10
|
-
|
|
10
|
+
|
|
11
|
+
import { dirname, join } from 'node:path';
|
|
11
12
|
import type { Route, UltimateRequest } from '@ultimat3/http';
|
|
12
13
|
import { applyCacheHeaders, jsonResponse, NO_STORE, textResponse } from '@ultimat3/http';
|
|
13
14
|
import { contentHash } from '@ultimat3/render/server';
|
|
14
15
|
import { assetRouteMeta } from './asset-route-meta';
|
|
15
16
|
import { FrameworkScriptBuildFailedError, type FrameworkScriptKind } from './errors';
|
|
16
17
|
import { describeBuildError } from './island-identity';
|
|
18
|
+
import { posixRelative } from './posix-path';
|
|
17
19
|
|
|
18
20
|
/**
|
|
19
21
|
* The ONE prefix every framework-served, content-addressed script lives under — the sync worker,
|
|
@@ -120,7 +122,7 @@ async function buildFrameworkScript(
|
|
|
120
122
|
): Promise<FrameworkScript | undefined> {
|
|
121
123
|
const entry = explicit ?? resolveEntry(root, specifier);
|
|
122
124
|
if (entry === undefined) return undefined;
|
|
123
|
-
const label =
|
|
125
|
+
const label = posixRelative(root, entry);
|
|
124
126
|
let built: Awaited<ReturnType<typeof Bun.build>>;
|
|
125
127
|
try {
|
|
126
128
|
built = await Bun.build({
|
package/wiki/Actions.md
CHANGED
|
@@ -3,10 +3,36 @@
|
|
|
3
3
|
The load-bearing primitive. A mutation or command, server-authoritative, declared once.
|
|
4
4
|
|
|
5
5
|
```ts
|
|
6
|
+
import { action, t } from '@ultimat3/action';
|
|
7
|
+
import { tag } from '@ultimat3/cache';
|
|
8
|
+
import type { Actor } from '@ultimat3/core';
|
|
9
|
+
import type { JobHandle } from '@ultimat3/jobs';
|
|
10
|
+
import { can } from '@ultimat3/policy';
|
|
11
|
+
|
|
12
|
+
declare module '@ultimat3/cache' {
|
|
13
|
+
interface CacheTagRegistry {
|
|
14
|
+
post: true;
|
|
15
|
+
feed: true;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
declare module '@ultimat3/core' {
|
|
19
|
+
interface CtxServices {
|
|
20
|
+
readonly posts: {
|
|
21
|
+
publish(id: string): Promise<{ id: string; orgId: string; title: string }>;
|
|
22
|
+
like(id: string): Promise<{ likeCount: number; likedByMe: boolean }>;
|
|
23
|
+
body(id: string): Promise<string>;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
declare const notifySubscribers: JobHandle<{ postId: string; orgId: string }>;
|
|
29
|
+
declare function ownsPost(actor: Actor | null, postId: string): boolean;
|
|
30
|
+
const PostView = t.object({ id: t.uuid, orgId: t.uuid, title: t.string });
|
|
31
|
+
|
|
6
32
|
export const publishPost = action({
|
|
7
33
|
input: t.object({ postId: t.uuid, notify: t.boolean.default(true) }),
|
|
8
34
|
output: PostView,
|
|
9
|
-
policy: can('post:publish', ({ input, actor }) => ownsPost(actor, input.postId)),
|
|
35
|
+
policy: can<{ postId: string }>('post:publish', ({ input, actor }) => ownsPost(actor, input.postId)),
|
|
10
36
|
cache: { invalidates: [tag.post, tag.feed] },
|
|
11
37
|
mcp: { expose: true, description: 'Publish a draft post' },
|
|
12
38
|
async handle({ input, ctx }) {
|
|
@@ -250,7 +276,28 @@ Logic lives in `service.ts`; `actions/` holds declarations. An action whose `han
|
|
|
250
276
|
Same declaration surface as `action`, plus a local half that runs client-side against the local store while the server call is in flight.
|
|
251
277
|
|
|
252
278
|
```ts
|
|
279
|
+
import { mutator, t } from '@ultimat3/action';
|
|
280
|
+
import { can } from '@ultimat3/policy';
|
|
281
|
+
|
|
282
|
+
declare module '@ultimat3/core' {
|
|
283
|
+
interface CtxServices {
|
|
284
|
+
readonly posts: {
|
|
285
|
+
publish(id: string): Promise<{ id: string; orgId: string; title: string }>;
|
|
286
|
+
like(id: string): Promise<{ likeCount: number; likedByMe: boolean }>;
|
|
287
|
+
body(id: string): Promise<string>;
|
|
288
|
+
};
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
declare module '@ultimat3/action' {
|
|
292
|
+
interface LocalTables {
|
|
293
|
+
posts: { likedByMe: boolean; likeCount: number };
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
|
|
253
297
|
export const likePost = mutator({
|
|
298
|
+
input: t.object({ postId: t.uuid }),
|
|
299
|
+
output: t.object({ likeCount: t.number, likedByMe: t.boolean }),
|
|
300
|
+
policy: can('post:like'),
|
|
254
301
|
// REQUIRED (`X_MUTATOR_NOT_IDEMPOTENT`): a replay under the same Idempotency-Key answers the
|
|
255
302
|
// first result instead of running `server` again.
|
|
256
303
|
idempotent: true,
|
|
@@ -388,10 +435,27 @@ Emitted with the action, and green on the first run: it pins the invariant the a
|
|
|
388
435
|
|
|
389
436
|
```ts
|
|
390
437
|
// contract test — generated with the action
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
438
|
+
import { type Action, t } from '@ultimat3/action';
|
|
439
|
+
import { testActor } from '@ultimat3/policy';
|
|
440
|
+
import { contractTest, expect } from '@ultimat3/testing';
|
|
441
|
+
|
|
442
|
+
const PostView = t.object({ id: t.uuid, orgId: t.uuid, title: t.string });
|
|
443
|
+
const PublishPostInput = t.object({ postId: t.uuid });
|
|
444
|
+
declare const publishPost: Action<typeof PublishPostInput, typeof PostView>;
|
|
445
|
+
declare const postId: string;
|
|
446
|
+
|
|
447
|
+
// Named here because this file does not boot the app; at boot `defineApi` stamps the same name.
|
|
448
|
+
const target = publishPost.named('publishPost');
|
|
449
|
+
|
|
450
|
+
// Holds the grant, wrong org: a denial here is the policy deciding, not the permission check.
|
|
451
|
+
const outsider = testActor('outsider', {
|
|
452
|
+
orgId: '00000000-0000-4000-8000-000000000009',
|
|
453
|
+
permissions: ['post:publish'],
|
|
454
|
+
}).actor;
|
|
455
|
+
|
|
456
|
+
contractTest('publishPost denies a foreign org', async () => {
|
|
457
|
+
const denied = await target.as(outsider, { postId }).catch((error: unknown) => error);
|
|
458
|
+
expect(denied).toBeUltimateError('X_FORBIDDEN');
|
|
395
459
|
});
|
|
396
460
|
```
|
|
397
461
|
|
package/wiki/Agents.md
CHANGED
|
@@ -734,6 +734,19 @@ export const triageBacklog = hive({
|
|
|
734
734
|
### Three member outcomes, never two
|
|
735
735
|
|
|
736
736
|
```ts
|
|
737
|
+
import { type Action, t } from '@ultimat3/action';
|
|
738
|
+
import type { HiveOutput } from '@ultimat3/ai';
|
|
739
|
+
import type { Ctx } from '@ultimat3/core';
|
|
740
|
+
|
|
741
|
+
const TriageInput = t.object({ orderIds: t.array(t.uuid) });
|
|
742
|
+
const Verdict = t.object({ verdict: t.string });
|
|
743
|
+
declare const triageBacklog: Action<typeof TriageInput, HiveOutput<typeof Verdict>>;
|
|
744
|
+
declare const orderIds: string[];
|
|
745
|
+
declare const ctx: Ctx;
|
|
746
|
+
declare function use(index: number, value: { verdict: string }): void;
|
|
747
|
+
declare function log(index: number, code: string, reason: string): void;
|
|
748
|
+
declare function retryLater(index: number, reason: string): void;
|
|
749
|
+
|
|
737
750
|
const result = await triageBacklog({ orderIds }, { ctx });
|
|
738
751
|
|
|
739
752
|
for (const member of result.members) {
|
package/wiki/Auth.md
CHANGED
|
@@ -10,6 +10,10 @@ the walk-through is [Tutorial 3](Tutorial-03-Auth-And-Admin).
|
|
|
10
10
|
```ts
|
|
11
11
|
import { defineAuth, login, oauthLogin, postgresAuthAdapter } from '@ultimat3/auth';
|
|
12
12
|
|
|
13
|
+
declare const email: string;
|
|
14
|
+
declare const password: string;
|
|
15
|
+
declare const ip: string;
|
|
16
|
+
|
|
13
17
|
export const auth = defineAuth({
|
|
14
18
|
adapter: postgresAuthAdapter(), // or memoryAuthAdapter()
|
|
15
19
|
session: { absoluteTtlMs: 30 * 864e5, idleTtlMs: 7 * 864e5 },
|
|
@@ -29,11 +29,27 @@ The first two are automatic — nothing to opt into, no `dataloader()`, no `batc
|
|
|
29
29
|
`findMany` tags the rows it returns with their own foreign key **values** (never the rows) under a per-request store. The first `findById` whose id matches one of those values then resolves that key for **every** row of the page in one statement, and the rest of a `for … of` loop is served from memory:
|
|
30
30
|
|
|
31
31
|
```ts
|
|
32
|
-
|
|
32
|
+
import { entity, postgresRepo, uuid } from '@ultimat3/entity';
|
|
33
|
+
|
|
34
|
+
const members = entity('members', {
|
|
35
|
+
tenant: 'orgId',
|
|
36
|
+
columns: { id: uuid().primaryKey(), orgId: uuid() },
|
|
37
|
+
});
|
|
38
|
+
const posts = entity('posts', {
|
|
39
|
+
tenant: 'orgId',
|
|
40
|
+
columns: {
|
|
41
|
+
id: uuid().primaryKey(),
|
|
42
|
+
orgId: uuid(),
|
|
43
|
+
authorId: uuid().references(() => members.id),
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
declare const orgId: string;
|
|
47
|
+
|
|
48
|
+
const page = await postgresRepo(posts).findMany({ orgId });
|
|
33
49
|
for (const post of page.rows) {
|
|
34
50
|
// Two statements for the whole loop: the page, then one `where "id" in (…)` over every
|
|
35
51
|
// author on it. Every lookup after the first is memory.
|
|
36
|
-
const author = await
|
|
52
|
+
const author = await postgresRepo(members).findById(post.authorId, { orgId });
|
|
37
53
|
}
|
|
38
54
|
```
|
|
39
55
|
|
|
@@ -42,11 +58,28 @@ Controlled by the `jitPreload` option, default `true`, on `postgresDriver({ jitP
|
|
|
42
58
|
### `.preload('relation')` — named on the chain
|
|
43
59
|
|
|
44
60
|
```ts
|
|
61
|
+
import { database, entity, text, uuid } from '@ultimat3/entity';
|
|
62
|
+
|
|
63
|
+
const orgs = entity('orgs', { columns: { id: uuid().primaryKey(), name: text() } });
|
|
64
|
+
const members = entity('members', {
|
|
65
|
+
tenant: 'orgId',
|
|
66
|
+
columns: { id: uuid().primaryKey(), orgId: uuid(), name: text() },
|
|
67
|
+
});
|
|
68
|
+
const posts = entity('posts', {
|
|
69
|
+
tenant: 'orgId',
|
|
70
|
+
columns: {
|
|
71
|
+
id: uuid().primaryKey(),
|
|
72
|
+
orgId: uuid(),
|
|
73
|
+
authorId: uuid().references(() => members.id),
|
|
74
|
+
},
|
|
75
|
+
});
|
|
76
|
+
declare const orgId: string;
|
|
77
|
+
|
|
45
78
|
export const db = database({ orgs, posts, members });
|
|
46
79
|
|
|
47
80
|
// Two statements: the page, then one `select … where "id" in (…)` over its authors.
|
|
48
81
|
const page = await db.posts.where({ orgId }).preload('author').page();
|
|
49
|
-
page.rows[0]
|
|
82
|
+
page.rows[0]?.author; // the member row, or null — always present
|
|
50
83
|
```
|
|
51
84
|
|
|
52
85
|
A `belongsTo` attaches the row or `null`; a `hasMany` attaches an array, always present so "no author" and "nobody preloaded the author" cannot read the same. `preload()` is resolved on the chain (`relationNamed`), so an unknown relation fails there and not a page later. Attachment happens after the projection — `select()` is widened internally with every preloaded relation's own key, so a projection can never drop what a preload needs; `plan().select` reports the widened list that actually ran. Only the terminals that read a row resolve it: `page()`, `all()`, `one()` — never `count()`, `countBy()` or `plan()`, since none of those has a row to attach one to.
|
|
@@ -70,6 +103,28 @@ Reach for `.preload()` when the relation is part of what the page *is* — a lis
|
|
|
70
103
|
A loop of `insert()` calls is the same defect a per-row read loop is, on the other side of the statement:
|
|
71
104
|
|
|
72
105
|
```ts
|
|
106
|
+
import { database, entity, text, uuid } from '@ultimat3/entity';
|
|
107
|
+
|
|
108
|
+
const posts = entity('posts', {
|
|
109
|
+
tenant: 'orgId',
|
|
110
|
+
columns: { id: uuid().primaryKey(), orgId: uuid(), status: text().default('draft') },
|
|
111
|
+
});
|
|
112
|
+
const likes = entity('likes', {
|
|
113
|
+
tenant: 'orgId',
|
|
114
|
+
columns: { id: uuid().primaryKey(), orgId: uuid(), postId: uuid(), memberId: uuid() },
|
|
115
|
+
indexes: [{ on: ['postId', 'memberId'], unique: true }],
|
|
116
|
+
});
|
|
117
|
+
const tags = entity('tags', {
|
|
118
|
+
tenant: 'orgId',
|
|
119
|
+
columns: { id: uuid().primaryKey(), orgId: uuid(), name: text() },
|
|
120
|
+
});
|
|
121
|
+
const db = database({ likes, posts, tags });
|
|
122
|
+
declare const names: readonly string[];
|
|
123
|
+
declare const rows: readonly { orgId: string; postId: string; memberId: string }[];
|
|
124
|
+
declare const orgId: string;
|
|
125
|
+
declare const postId: string;
|
|
126
|
+
declare const memberId: string;
|
|
127
|
+
|
|
73
128
|
await db.tags.insertAll(names.map((name) => ({ orgId, name }))); // one statement, n rows
|
|
74
129
|
|
|
75
130
|
await db.likes.upsertAll(rows, { // insert, or leave what's there
|
|
@@ -98,6 +153,25 @@ const removed = await db.likes.deleteWhere({ orgId, postId, memberId });
|
|
|
98
153
|
The chain's own terminal for "every row, not one page":
|
|
99
154
|
|
|
100
155
|
```ts
|
|
156
|
+
import { database, entity, uuid } from '@ultimat3/entity';
|
|
157
|
+
|
|
158
|
+
declare const search: { index(rows: readonly object[]): Promise<void> };
|
|
159
|
+
|
|
160
|
+
const members = entity('members', {
|
|
161
|
+
tenant: 'orgId',
|
|
162
|
+
columns: { id: uuid().primaryKey(), orgId: uuid() },
|
|
163
|
+
});
|
|
164
|
+
const posts = entity('posts', {
|
|
165
|
+
tenant: 'orgId',
|
|
166
|
+
columns: {
|
|
167
|
+
id: uuid().primaryKey(),
|
|
168
|
+
orgId: uuid(),
|
|
169
|
+
authorId: uuid().references(() => members.id),
|
|
170
|
+
},
|
|
171
|
+
});
|
|
172
|
+
const db = database({ members, posts });
|
|
173
|
+
declare const orgId: string;
|
|
174
|
+
|
|
101
175
|
await using batches = db.posts.where({ orgId }).preload('author').inBatches(500);
|
|
102
176
|
for await (const batch of batches) {
|
|
103
177
|
await search.index(batch);
|
package/wiki/CLI-Reference.md
CHANGED
|
@@ -50,7 +50,7 @@ x version # CLI version
|
|
|
50
50
|
| `x jobs` | list, show, retry, cancel, remove and promote jobs; pause and resume a queue · `drain` was removed from the registry `As of 2026-11-15` ([Known gaps](Known-Gaps#open-by-decision)) | shipped |
|
|
51
51
|
| `x tasks` | cron tasks, their timezone and their next run | shipped |
|
|
52
52
|
| `x policy` | which clause decided a permission, and why | shipped |
|
|
53
|
-
| `x exercise [<name>] [--seed n] [--shard i/n]` | run every action, query, job and route `load` once on generated rows, with no test written; the gate's `exercise` step | shipped |
|
|
53
|
+
| `x exercise [<name>] [--seed n\|random] [--shard i/n]` | run every action, query, job and route `load` once on generated rows, with no test written; the gate's `exercise` step | shipped |
|
|
54
54
|
| `x drill [<name>] [--list] [--budget-ms n]` | the app's roles as real processes on real Postgres, Redis and NATS, each dependency faulted through a proxy, each role signalled, or every role started before `ROLE=migrate`, red on any framework contract that does not hold. Not a gate step: it needs the services | shipped |
|
|
55
55
|
| `x i18n` | add, sync, check catalogs | shipped |
|
|
56
56
|
| `x mail preview <id>` | render a mail's declared `preview` in every locale, nothing sent | shipped |
|
|
@@ -69,7 +69,7 @@ x version # CLI version
|
|
|
69
69
|
| `x token create\|list\|revoke` | MCP and API tokens in the app's `x_api_keys`: issue one with exact scopes (plaintext shown once), list an owner's, revoke one · `grant` was removed from the registry `As of 2026-11-15` ([Known gaps](Known-Gaps#open-by-decision)) | shipped |
|
|
70
70
|
| `x config show [--section <key>]` | the resolved `app.config.ts`, defaults merged, credentials redacted | shipped |
|
|
71
71
|
| `x logs tail [--lines n] [--role <role>]` | the last lines of `.x/dev.log`, or one role's (its `.x/logs/<role>.log`, else its lines of the dev log) — the `logs.tail` MCP tool's reader | shipped |
|
|
72
|
-
| `x cache graph\|bust <tag>\|clear` | the tag graph off the manifest (what each write evicts), a bust of one tag or every declared tag through the app's own tiers and bus · `stats` was removed `As of 2026-11-15` ([Known gaps](Known-Gaps#
|
|
72
|
+
| `x cache graph\|bust <tag>\|clear` | the tag graph off the manifest (what each write evicts), a bust of one tag or every declared tag through the app's own tiers and bus · `stats` was removed `As of 2026-11-15` ([Known gaps](Known-Gaps#open-by-decision)) | shipped |
|
|
73
73
|
| `x explain <query> [--input <json>] [--org <id>]` | one declared query run once on the dev database, every statement it sent planned by the `exercise` step's oracle | shipped |
|
|
74
74
|
| `x profile <route> [--runs 20] [--top 10]` | a CPU profile of rendering one route in this process: the hottest functions, file and line | shipped |
|
|
75
75
|
| `x status [--url <origin>] [--samples n]` | the build each live worker runs (`x_job_workers`), and the build, status and role each sampled origin's `/readyz` answers | shipped |
|
|
@@ -1067,6 +1067,8 @@ Two files, one committed and one never:
|
|
|
1067
1067
|
|
|
1068
1068
|
```ts
|
|
1069
1069
|
// app.config.ts
|
|
1070
|
+
import { defineEnv, type EnvSchema, installSecrets } from '@ultimat3/core';
|
|
1071
|
+
|
|
1070
1072
|
await installSecrets();
|
|
1071
1073
|
export const envSchema = {
|
|
1072
1074
|
SESSION_SECRET: { type: 'string', secret: true, description: 'Cookie signing key' },
|
|
@@ -1442,7 +1444,7 @@ Errors: `X_DECLARATION_UNKNOWN` (with the nearest name as its fix), `X_CLI_BAD_F
|
|
|
1442
1444
|
## x exercise
|
|
1443
1445
|
|
|
1444
1446
|
```bash
|
|
1445
|
-
x exercise [<name>] [--seed n] [--shard i/n] [--json]
|
|
1447
|
+
x exercise [<name>] [--seed n|random] [--shard i/n] [--json]
|
|
1446
1448
|
```
|
|
1447
1449
|
|
|
1448
1450
|
Every action, query and job the app registers, run **once** against generated rows, with no test
|
|
@@ -1482,6 +1484,17 @@ export const exercise = defineExercise({
|
|
|
1482
1484
|
});
|
|
1483
1485
|
```
|
|
1484
1486
|
|
|
1487
|
+
**The seed** (`As of 31.47.0`). Row ids and tenants are drawn from it, so it is part of the verdict.
|
|
1488
|
+
|
|
1489
|
+
| Run | Seed | For |
|
|
1490
|
+
|---|---|---|
|
|
1491
|
+
| `x exercise`, and the gate's `exercise` step | one constant, `DEFAULT_SEED` from `@ultimat3/testing` | one tree, one verdict |
|
|
1492
|
+
| `x exercise --seed <n>` | `n`, 0 to 2147483647 | replaying a run |
|
|
1493
|
+
| `x exercise --seed random` | a fresh one | looking for a seed-dependent helper; never the gate |
|
|
1494
|
+
|
|
1495
|
+
The first output line and `seed` in `.x/exercise.json` and `--json` name the seed used. Each pass
|
|
1496
|
+
has its own scratch database, so repeating a seed collides with nothing.
|
|
1497
|
+
|
|
1485
1498
|
A blank `off` reason is `X_CONTRACT_EXERCISE_UNDECLARED`; so is an `exercise.ts` with no single
|
|
1486
1499
|
`defineExercise()` export. The gate's `exercise` step runs this command as a child and is red on
|
|
1487
1500
|
exactly its findings, plus the static half of the tenant proof: an entity with no tenant column
|
|
@@ -2159,7 +2172,7 @@ Every flag is read before the database opens: a refusal costs no boot.
|
|
|
2159
2172
|
|---|---|---|
|
|
2160
2173
|
| workers | every live row of `x_job_workers`, through the queue `x jobs list` opens (`DATABASE_URL`, else the embedded database) | `data.workers`: `count`, `draining`, `byBuild` (a row from before the build column is `unknown`), `rows[]` |
|
|
2161
2174
|
| origins | `--url`: `--samples` (default 5, 1–50) `GET /readyz` per origin, each on its own connection, so a load balancer chooses again | `data.origins[]`: `origin`, `samples`, `byBuild` (`x-ultimate-build`), `byStatus` (`unreachable` when nothing answered), `unstamped` (a 2xx with no build), `roles` (named by a role's health port) |
|
|
2162
|
-
| unrecorded | — | `data.unrecorded`: `web`, `sync`, `scheduler`, `replicator` — no fleet-wide record holds their build; name each one's health origin in `--url` ([Known gaps](Known-Gaps#
|
|
2175
|
+
| unrecorded | — | `data.unrecorded`: `web`, `sync`, `scheduler`, `replicator` — no fleet-wide record holds their build; name each one's health origin in `--url` ([Known gaps](Known-Gaps#open-by-decision)) |
|
|
2163
2176
|
|
|
2164
2177
|
`--url` takes bare http(s) origins only — a path, query or credentials is `X_CLI_BAD_FLAG`, as is a `--samples` outside 1–50. Both are refused before any request or connection.
|
|
2165
2178
|
|
|
@@ -2204,7 +2217,7 @@ A route answering `>= 400` is profiled and reported red, `X_PROFILE_ROUTE_FAILED
|
|
|
2204
2217
|
|
|
2205
2218
|
## Planned commands
|
|
2206
2219
|
|
|
2207
|
-
None, `As of 2026-11-16`. The table is `PLANNED_COMMANDS` in `packages/cli/src/cmd-planned.ts`, and it is empty
|
|
2220
|
+
None, `As of 2026-11-16`. The table is `PLANNED_COMMANDS` in `packages/cli/src/cmd-planned.ts`, and it is empty, and the registry builds no command from it: the last three left with plan 101b slice 13. `x branch`, `x ai` and `x money` are each a row in [Known gaps](Known-Gaps) with the decision ("not planned") and the extension point that does the job today, and the parser refuses each with `X_CLI_UNKNOWN_COMMAND`. `PLANNED_SUBCOMMANDS`, the one-level-down version, has been empty since `As of 2026-11-15` (`x db studio`, `x jobs drain`, `x token grant` and `x cache stats` went the same way). `cmd-planned.test.ts` holds both tables empty.
|
|
2208
2221
|
|
|
2209
2222
|
`x token`, `x config`, `x logs` and `x cache` left this table `As of 2026-11` (plan 101-full-stack-efficiency-sweeps U5), `x status` `As of 2026-11-15`; each has its section above.
|
|
2210
2223
|
|
|
@@ -32,38 +32,72 @@ Read order is **1 → 2 → 3 → origin**. A tier is never consulted for a requ
|
|
|
32
32
|
|
|
33
33
|
## Entity tags are the invalidation graph
|
|
34
34
|
|
|
35
|
-
A tag is a typed handle
|
|
35
|
+
A tag is a typed handle the app declares once: `CacheTagRegistry` types `tag.post`, `declareTags` is the runtime list `X_CACHE_TAG_UNKNOWN` checks. No cache key is written by hand.
|
|
36
36
|
|
|
37
37
|
```ts
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
38
|
+
// packages/db/src/tags.ts — the type registry and the runtime list name the same strings
|
|
39
|
+
import { declareTags, tag } from '@ultimat3/cache';
|
|
40
|
+
|
|
41
|
+
declare module '@ultimat3/cache' {
|
|
42
|
+
interface CacheTagRegistry {
|
|
43
|
+
post: true;
|
|
44
|
+
feed: true;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
declareTags(['post', 'feed']);
|
|
49
|
+
|
|
50
|
+
export { tag }; // tag.post — the collection · tag('post', postId) — one row
|
|
42
51
|
```
|
|
43
52
|
|
|
44
53
|
| Tag form | Scope | Example |
|
|
45
54
|
|---|---|---|
|
|
46
55
|
| `tag.post` | all posts | a schema-level change |
|
|
47
|
-
| `tag
|
|
48
|
-
| `tag.feed` |
|
|
56
|
+
| `tag('post', postId)` | one row | the common case; narrowest eviction |
|
|
57
|
+
| `tag.feed` | a name of its own. Tags do not cascade: a write that stales it lists it | list views that a post membership affects |
|
|
49
58
|
|
|
50
59
|
| Declared where | By |
|
|
51
60
|
|---|---|
|
|
52
|
-
| Queries |
|
|
61
|
+
| Queries | `cache: { tags: [...] }`. Nothing derives them from the `sql`; undeclared is `[]` |
|
|
53
62
|
| Routes | `revalidate: { tags: [...] }` |
|
|
54
63
|
| Actions / mutators | `cache: { invalidates: [...] }` |
|
|
55
|
-
| LLM calls | `cache: { invalidates: [...] }` |
|
|
56
64
|
|
|
57
|
-
The graph is a build-time artifact in `x.manifest.json`, so it records exactly what a write will evict — before you run it. `x cache graph --json` reads it (since 31.17.0), as does `x dev` → the `/_x` cache panel. Tag typing comes from
|
|
65
|
+
The graph is a build-time artifact in `x.manifest.json`, so it records exactly what a write will evict — before you run it. `x cache graph --json` reads it (since 31.17.0), as does `x dev` → the `/_x` cache panel. Tag typing comes from the app's own `CacheTagRegistry` augmentation, written by hand beside `declareTags` (`examples/dummy/packages/db/src/tags.ts`); nothing generates it, `As of 2026-11`.
|
|
58
66
|
|
|
59
67
|
## One hop, all tiers
|
|
60
68
|
|
|
61
69
|
```ts
|
|
62
70
|
// action
|
|
71
|
+
import { action, t } from '@ultimat3/action';
|
|
72
|
+
import { tag } from '@ultimat3/cache';
|
|
73
|
+
import type { Actor } from '@ultimat3/core';
|
|
74
|
+
import type { JobHandle } from '@ultimat3/jobs';
|
|
75
|
+
import { can } from '@ultimat3/policy';
|
|
76
|
+
|
|
77
|
+
declare module '@ultimat3/cache' {
|
|
78
|
+
interface CacheTagRegistry {
|
|
79
|
+
post: true;
|
|
80
|
+
feed: true;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
declare module '@ultimat3/core' {
|
|
84
|
+
interface CtxServices {
|
|
85
|
+
readonly posts: {
|
|
86
|
+
publish(id: string): Promise<{ id: string; orgId: string; title: string }>;
|
|
87
|
+
like(id: string): Promise<{ likeCount: number; likedByMe: boolean }>;
|
|
88
|
+
body(id: string): Promise<string>;
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
declare const notifySubscribers: JobHandle<{ postId: string; orgId: string }>;
|
|
94
|
+
declare function ownsPost(actor: Actor | null, postId: string): boolean;
|
|
95
|
+
const PostView = t.object({ id: t.uuid, orgId: t.uuid, title: t.string });
|
|
96
|
+
|
|
63
97
|
export const publishPost = action({
|
|
64
98
|
input: t.object({ postId: t.uuid, notify: t.boolean.default(true) }),
|
|
65
99
|
output: PostView,
|
|
66
|
-
policy: can('post:publish', ({ input, actor }) => ownsPost(actor, input.postId)),
|
|
100
|
+
policy: can<{ postId: string }>('post:publish', ({ input, actor }) => ownsPost(actor, input.postId)),
|
|
67
101
|
cache: { invalidates: [tag.post, tag.feed] },
|
|
68
102
|
mcp: { expose: true, description: 'Publish a draft post' },
|
|
69
103
|
async handle({ input, ctx }) {
|
|
@@ -144,11 +178,11 @@ The bug is never "the cache is wrong". The bug is that invalidation is a *decisi
|
|
|
144
178
|
| Failure mode | Cause | Removed by |
|
|
145
179
|
|---|---|---|
|
|
146
180
|
| Stale page after publish | forgot one `revalidate` call | tags are declared on the route, resolved from the graph |
|
|
147
|
-
| Purging too much | uncertainty → `flushAll` | narrow `tag
|
|
181
|
+
| Purging too much | uncertainty → `flushAll` | narrow `tag('post', x)` is the ergonomic default |
|
|
148
182
|
| Tier drift | Redis purged, CDN not | one fanout, all tiers |
|
|
149
183
|
| Leak across tenants | hand-built cache key missing the tenant | keys are framework-generated from the query name, the read's authority (`cache: { scope }`, default `actor`), its parsed input and its tags |
|
|
150
184
|
| Stale forever | a query whose tables no tag covers | the tag rule — **not yet a gate**: `X_CACHE_UNTAGGED_QUERY` is reserved `As of 2026-08` and nothing raises it, so a cached query no tag covers is cached and never invalidated ([Error codes → Reserved codes](Error-Codes#reserved-codes)) |
|
|
151
|
-
| Silent typo | `invalidates: [tag.pots]` | a compile error against
|
|
185
|
+
| Silent typo | `invalidates: [tag.pots]` | a compile error against `CacheTagRegistry`; at runtime `X_CACHE_TAG_UNKNOWN`, which a write logs as `action.invalidate.failed` rather than failing the commit it followed |
|
|
152
186
|
|
|
153
187
|
Agents are measurably bad at *distant* invariants — "edit here, remember to also edit there" is where LLM-written code regresses most. Declaring `invalidates` at the write site is local, checkable, and typed.
|
|
154
188
|
|
|
@@ -203,24 +237,43 @@ CDN never fails the write that triggered the bust, and the entry expires by TTL
|
|
|
203
237
|
Model calls are slow and metered; exact-match caching almost never hits because prompts differ by a word.
|
|
204
238
|
|
|
205
239
|
```ts
|
|
240
|
+
import { t } from '@ultimat3/action';
|
|
241
|
+
import { llm, type Prompt } from '@ultimat3/ai';
|
|
242
|
+
import { can } from '@ultimat3/policy';
|
|
243
|
+
|
|
244
|
+
declare module '@ultimat3/core' {
|
|
245
|
+
interface CtxServices {
|
|
246
|
+
readonly posts: {
|
|
247
|
+
publish(id: string): Promise<{ id: string; orgId: string; title: string }>;
|
|
248
|
+
like(id: string): Promise<{ likeCount: number; likedByMe: boolean }>;
|
|
249
|
+
body(id: string): Promise<string>;
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
declare const summarizePrompt: Prompt<{ body: string }>;
|
|
255
|
+
|
|
206
256
|
export const summarize = llm({
|
|
207
257
|
model: 'claude-sonnet-5-5',
|
|
258
|
+
input: t.object({ postId: t.uuid }),
|
|
259
|
+
output: t.object({ summary: t.string }),
|
|
260
|
+
policy: can('post:read'),
|
|
261
|
+
prompt: summarizePrompt, // versioned artifact, see 09-ai-first.md
|
|
262
|
+
vars: async ({ input, ctx }) => ({ body: await ctx.posts.body(input.postId) }),
|
|
208
263
|
cache: {
|
|
209
264
|
semantic: { threshold: 0.97, ttl: '7d' }, // partitions on the ACTOR by default
|
|
210
|
-
invalidates: [tag.post],
|
|
211
265
|
},
|
|
212
|
-
prompt: summarizePrompt, // versioned artifact, see 09-ai-first.md
|
|
213
266
|
});
|
|
214
267
|
```
|
|
215
268
|
|
|
216
269
|
| Aspect | Rule |
|
|
217
270
|
|---|---|
|
|
218
|
-
| Store |
|
|
219
|
-
| Key |
|
|
220
|
-
| Hit | cosine similarity >= `threshold
|
|
271
|
+
| Store | one `SemanticCache` per prompt version, locale and scope. Default `memorySemanticCache()`, per process; the `semanticCache` port replaces it |
|
|
272
|
+
| Key | store: prompt ref + **prompt hash** + **request locale** + scope. Entry: matched by the embedding of the rendered prompt. The model id is in neither |
|
|
273
|
+
| Hit | cosine similarity >= `threshold`, any value from 0 to 1. Undeclared: the store's default, 0.92 in `memorySemanticCache()`. Below ~0.9 unrelated prompts collide; nothing enforces that floor |
|
|
221
274
|
| Scope | optional — the calling **actor** by default, so one org never reads another's completion. Widening is written down: `scope: () => 'global'` |
|
|
222
|
-
| Bypass |
|
|
223
|
-
| Invalidation |
|
|
275
|
+
| Bypass | omit `cache`. There is no `cache: false`, and `temperature` is not consulted |
|
|
276
|
+
| Invalidation | no tag reaches it, `As of 2026-11`: `LlmCache` has no `invalidates` (`packages/ai/src/llm-cache.ts`). Bumping the prompt version moves to a different store; `ttl` ends the rest |
|
|
224
277
|
| Metrics | every `llm()` call emits `ai.llm` on the instrumentation bus with `cacheHit`, `inputTokens` and `outputTokens`; hit rate and tokens saved are a subscriber's sum, and `gen_ai_client_token_usage` is on `/metrics` → [Observability](Observability) |
|
|
225
278
|
|
|
226
279
|
**The locale is part of the key, and not part of the scope** — `As of 2026-08-24`. A prompt that takes `locale` as a var differs by one token between languages while carrying a whole document, so the two rendered prompts are near-identical to an embedder: measured over the reference app's summarize template, **0.9986**, against the `threshold: 0.97` in the snippet above. Before this, whichever language asked first was served to everyone — an English reader got the Spanish summary, and the model had done nothing wrong.
|
|
@@ -239,7 +292,7 @@ Ships since **31.17.0** (`graph`, `bust`, `clear`); `stats` is still **planned**
|
|
|
239
292
|
| `x cache graph --tag post --json` | the blast radius of one tag |
|
|
240
293
|
| `x cache bust <tag> --json` | the real fanout for one tag — the app's own tiers booted as a role boots them, then `invalidateTags`: shared tiers dropped, the edge purged, the bus told — and the invalidation report |
|
|
241
294
|
| `x cache clear --json` | the same bust over every tag the app's modules declare |
|
|
242
|
-
| hit rates | not a command: `stats` left `x cache` `As of 2026-11-15` — each serving process emits `cache.hit` / `cache.miss` on its own bus and nothing aggregates them ([Known gaps](Known-Gaps#
|
|
295
|
+
| hit rates | not a command: `stats` left `x cache` `As of 2026-11-15` — each serving process emits `cache.hit` / `cache.miss` on its own bus and nothing aggregates them ([Known gaps](Known-Gaps#open-by-decision)) |
|
|
243
296
|
|
|
244
297
|
From code: `invalidateTags([...])` from `@ultimat3/cache`, the call `x cache bust` makes.
|
|
245
298
|
|
|
@@ -248,7 +301,7 @@ From code: `invalidateTags([...])` from `@ultimat3/cache`, the call `x cache bus
|
|
|
248
301
|
| Code | Cause | Fix |
|
|
249
302
|
|---|---|---|
|
|
250
303
|
| `X_CACHE_UNTAGGED_QUERY` | **reserved, nothing raises it** `As of 2026-08` — a query's tables are covered by no tag, so it could never be invalidated ([Error codes → Reserved codes](Error-Codes#reserved-codes)) | declare the entity tag, then `x manifest` |
|
|
251
|
-
| `X_CACHE_TAG_UNKNOWN` | `tag "<name>" is not declared by any entity` | `
|
|
304
|
+
| `X_CACHE_TAG_UNKNOWN` | `tag "<name>" is not declared by any entity` | `declareTags(['<name>'])` beside the app's other declared tags, plus the name in its `CacheTagRegistry`; for a typo, correct the tag |
|
|
252
305
|
| `X_CACHE_TOO_LARGE` | `entry "<key>" is <n>B, over the <tier> budget of <m>B` | `lruTier({ maxBytes: <n> })` / `redisTier({ maxValueBytes: <n> })` where the tier is built, or cache a projection instead of the row |
|
|
253
306
|
| `X_CACHE_DRIVER_UNAVAILABLE` | `cache tier "<driver>" is unavailable` — a Redis command missed its deadline, or the tier is parked after one; or a purge driver built without its token | the error carries the exact config or command to fix |
|
|
254
307
|
| `X_CACHE_PURGE_FAILED` | `<driver> refused the purge (HTTP <status>)` — a wrong token, a zone without tag purge, a throttle, or a key a CDN would split | `meta.retryable === true` → the identical purge can land again; otherwise set the env key the `fix` names |
|
|
@@ -262,6 +315,6 @@ Verbatim shapes: [`packages/cache/src/errors.ts`](https://github.com/developerz-
|
|
|
262
315
|
- Never cache a value whose policy scope is not in its key.
|
|
263
316
|
- `flushAll` has no shipped caller: `x cache clear` busts every declared tag through `invalidateTags`, never a flush, and there is no runtime API for it.
|
|
264
317
|
- Cache misses must be correct and merely slower — no code path may depend on a hit.
|
|
265
|
-
- Prefer `tag
|
|
318
|
+
- Prefer `tag('post', x)` over `tag.post`. Narrow eviction is the default, not an optimization.
|
|
266
319
|
- A cache tier may never fail a business read or write. Tier errors land in the invalidation report, or in a `cache.tier_failure` event on the read ladder.
|
|
267
320
|
- Realtime is not a cache tier. Live queries flow from logical replication on their own path ([Realtime](Realtime)).
|