@fuzdev/fuz_app 0.132.0 → 0.133.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.
Files changed (55) hide show
  1. package/dist/actions/action_dispatcher.js +1 -0
  2. package/dist/actions/action_event_data.d.ts +2 -2
  3. package/dist/actions/action_event_types.d.ts +2 -2
  4. package/dist/actions/action_rpc.js +1 -0
  5. package/dist/actions/action_spec.d.ts +19 -19
  6. package/dist/actions/perform_action.js +1 -0
  7. package/dist/actions/register_action_ws.js +1 -0
  8. package/dist/auth/account_routes.js +1 -1
  9. package/dist/auth/audit_log_schema.d.ts +5 -5
  10. package/dist/auth/cell_action_specs.d.ts +3 -3
  11. package/dist/auth/credential_type_schema.d.ts +1 -1
  12. package/dist/cli/daemon.js +1 -0
  13. package/dist/cli/logger.js +1 -0
  14. package/dist/db/CLAUDE.md +1 -1
  15. package/dist/db/fact_disk_storage.d.ts +3 -3
  16. package/dist/db/fact_disk_storage.d.ts.map +1 -1
  17. package/dist/db/fact_disk_storage.js +11 -11
  18. package/dist/db/fact_store.d.ts +4 -4
  19. package/dist/db/fact_store.js +3 -3
  20. package/dist/db/fact_store_errors.d.ts +3 -3
  21. package/dist/db/fact_store_errors.d.ts.map +1 -1
  22. package/dist/db/fact_store_errors.js +5 -5
  23. package/dist/env/load.js +1 -0
  24. package/dist/hono_context.d.ts +1 -1
  25. package/dist/http/CLAUDE.md +2 -2
  26. package/dist/http/auth_shape.d.ts +6 -6
  27. package/dist/http/error_schemas.d.ts +7 -2
  28. package/dist/http/error_schemas.d.ts.map +1 -1
  29. package/dist/http/error_schemas.js +5 -1
  30. package/dist/http/surface.js +1 -0
  31. package/dist/realtime/sse.js +1 -0
  32. package/dist/server/app_server.js +1 -0
  33. package/dist/testing/CLAUDE.md +1 -0
  34. package/dist/testing/admin_integration.d.ts.map +1 -1
  35. package/dist/testing/admin_integration.js +2 -1
  36. package/dist/testing/adversarial_404.d.ts.map +1 -1
  37. package/dist/testing/adversarial_404.js +5 -3
  38. package/dist/testing/adversarial_input.d.ts.map +1 -1
  39. package/dist/testing/adversarial_input.js +9 -3
  40. package/dist/testing/attack_surface.js +4 -4
  41. package/dist/testing/cross_backend/action_manifest.d.ts +10 -10
  42. package/dist/testing/cross_backend/standard.d.ts +6 -0
  43. package/dist/testing/cross_backend/standard.d.ts.map +1 -1
  44. package/dist/testing/cross_backend/standard.js +2 -1
  45. package/dist/testing/cross_backend/testing_reset_actions.d.ts +5 -5
  46. package/dist/testing/data_exposure.d.ts.map +1 -1
  47. package/dist/testing/data_exposure.js +11 -8
  48. package/dist/testing/round_trip.d.ts.map +1 -1
  49. package/dist/testing/round_trip.js +3 -9
  50. package/dist/testing/rpc_helpers.js +1 -0
  51. package/dist/testing/schema_generators.d.ts +12 -0
  52. package/dist/testing/schema_generators.d.ts.map +1 -1
  53. package/dist/testing/schema_generators.js +10 -0
  54. package/dist/testing/transports/ws_client.js +1 -0
  55. package/package.json +4 -4
@@ -6,6 +6,7 @@
6
6
  *
7
7
  * @module
8
8
  */
9
+ import { JsonrpcMessageFromClientToServer, JsonrpcMessageFromServerToClient, JsonrpcNotification, JsonrpcRequest, JsonrpcResponseOrError, JsonrpcErrorResponse } from '../http/jsonrpc.js';
9
10
  import { create_jsonrpc_error_response, create_jsonrpc_error_response_from_thrown, to_jsonrpc_message_id, is_jsonrpc_request, is_jsonrpc_notification } from '../http/jsonrpc_helpers.js';
10
11
  import { jsonrpc_error_messages } from '../http/jsonrpc_errors.js';
11
12
  import { to_input_params } from '../http/schema_helpers.js';
@@ -28,11 +28,11 @@ export declare const ActionEventData: z.ZodObject<{
28
28
  execute: "execute";
29
29
  }>;
30
30
  step: z.ZodEnum<{
31
- failed: "failed";
32
- parsed: "parsed";
33
31
  initial: "initial";
32
+ parsed: "parsed";
34
33
  handling: "handling";
35
34
  handled: "handled";
35
+ failed: "failed";
36
36
  }>;
37
37
  method: z.ZodString;
38
38
  executor: z.ZodEnum<{
@@ -12,11 +12,11 @@ export declare const ActionExecutor: z.ZodEnum<{
12
12
  }>;
13
13
  export type ActionExecutor = z.infer<typeof ActionExecutor>;
14
14
  export declare const ActionEventStep: z.ZodEnum<{
15
- failed: "failed";
16
- parsed: "parsed";
17
15
  initial: "initial";
16
+ parsed: "parsed";
18
17
  handling: "handling";
19
18
  handled: "handled";
19
+ failed: "failed";
20
20
  }>;
21
21
  export type ActionEventStep = z.infer<typeof ActionEventStep>;
22
22
  export declare const action_event_step_transitions: Record<ActionEventStep, ReadonlyArray<ActionEventStep>>;
@@ -13,6 +13,7 @@
13
13
  */
14
14
  import { z } from 'zod';
15
15
  import { DEV } from 'esm-env';
16
+ import {} from '../http/route_spec.js';
16
17
  import { get_client_ip } from '../http/client_ip.js';
17
18
  import { get_request_context } from '../auth/request_context.js';
18
19
  import { ACCOUNT_ID_KEY, CREDENTIAL_TYPE_KEY, TOKEN_SCOPE_KEY, TEST_CONTEXT_PRESET_KEY } from '../hono_context.js';
@@ -51,14 +51,14 @@ export declare const ActionSpec: z.ZodObject<{
51
51
  */
52
52
  auth: z.ZodNullable<z.ZodObject<{
53
53
  account: z.ZodEnum<{
54
- required: "required";
55
- none: "none";
56
54
  optional: "optional";
55
+ none: "none";
56
+ required: "required";
57
57
  }>;
58
58
  actor: z.ZodEnum<{
59
- required: "required";
60
- none: "none";
61
59
  optional: "optional";
60
+ none: "none";
61
+ required: "required";
62
62
  }>;
63
63
  roles: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
64
64
  credential_types: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
@@ -108,9 +108,9 @@ export declare const ActionSpec: z.ZodObject<{
108
108
  * dispatchers don't read it.
109
109
  */
110
110
  rate_limit: z.ZodOptional<z.ZodEnum<{
111
- both: "both";
112
111
  account: "account";
113
112
  ip: "ip";
113
+ both: "both";
114
114
  }>>;
115
115
  }, z.core.$strict>;
116
116
  export type ActionSpec = z.infer<typeof ActionSpec>;
@@ -128,21 +128,21 @@ export declare const RequestResponseActionSpec: z.ZodObject<{
128
128
  streams: z.ZodOptional<z.ZodString>;
129
129
  error_reasons: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
130
130
  rate_limit: z.ZodOptional<z.ZodEnum<{
131
- both: "both";
132
131
  account: "account";
133
132
  ip: "ip";
133
+ both: "both";
134
134
  }>>;
135
135
  kind: z.ZodDefault<z.ZodLiteral<"request_response">>;
136
136
  auth: z.ZodObject<{
137
137
  account: z.ZodEnum<{
138
- required: "required";
139
- none: "none";
140
138
  optional: "optional";
139
+ none: "none";
140
+ required: "required";
141
141
  }>;
142
142
  actor: z.ZodEnum<{
143
- required: "required";
144
- none: "none";
145
143
  optional: "optional";
144
+ none: "none";
145
+ required: "required";
146
146
  }>;
147
147
  roles: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
148
148
  credential_types: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
@@ -163,9 +163,9 @@ export declare const RemoteNotificationActionSpec: z.ZodObject<{
163
163
  streams: z.ZodOptional<z.ZodString>;
164
164
  error_reasons: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
165
165
  rate_limit: z.ZodOptional<z.ZodEnum<{
166
- both: "both";
167
166
  account: "account";
168
167
  ip: "ip";
168
+ both: "both";
169
169
  }>>;
170
170
  kind: z.ZodDefault<z.ZodLiteral<"remote_notification">>;
171
171
  auth: z.ZodDefault<z.ZodNull>;
@@ -193,9 +193,9 @@ export declare const LocalCallActionSpec: z.ZodObject<{
193
193
  streams: z.ZodOptional<z.ZodString>;
194
194
  error_reasons: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
195
195
  rate_limit: z.ZodOptional<z.ZodEnum<{
196
- both: "both";
197
196
  account: "account";
198
197
  ip: "ip";
198
+ both: "both";
199
199
  }>>;
200
200
  kind: z.ZodDefault<z.ZodLiteral<"local_call">>;
201
201
  auth: z.ZodDefault<z.ZodNull>;
@@ -215,21 +215,21 @@ export declare const ActionSpecUnion: z.ZodUnion<readonly [z.ZodObject<{
215
215
  streams: z.ZodOptional<z.ZodString>;
216
216
  error_reasons: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
217
217
  rate_limit: z.ZodOptional<z.ZodEnum<{
218
- both: "both";
219
218
  account: "account";
220
219
  ip: "ip";
220
+ both: "both";
221
221
  }>>;
222
222
  kind: z.ZodDefault<z.ZodLiteral<"request_response">>;
223
223
  auth: z.ZodObject<{
224
224
  account: z.ZodEnum<{
225
- required: "required";
226
- none: "none";
227
225
  optional: "optional";
226
+ none: "none";
227
+ required: "required";
228
228
  }>;
229
229
  actor: z.ZodEnum<{
230
- required: "required";
231
- none: "none";
232
230
  optional: "optional";
231
+ none: "none";
232
+ required: "required";
233
233
  }>;
234
234
  roles: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
235
235
  credential_types: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
@@ -248,9 +248,9 @@ export declare const ActionSpecUnion: z.ZodUnion<readonly [z.ZodObject<{
248
248
  streams: z.ZodOptional<z.ZodString>;
249
249
  error_reasons: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
250
250
  rate_limit: z.ZodOptional<z.ZodEnum<{
251
- both: "both";
252
251
  account: "account";
253
252
  ip: "ip";
253
+ both: "both";
254
254
  }>>;
255
255
  kind: z.ZodDefault<z.ZodLiteral<"remote_notification">>;
256
256
  auth: z.ZodDefault<z.ZodNull>;
@@ -272,9 +272,9 @@ export declare const ActionSpecUnion: z.ZodUnion<readonly [z.ZodObject<{
272
272
  streams: z.ZodOptional<z.ZodString>;
273
273
  error_reasons: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
274
274
  rate_limit: z.ZodOptional<z.ZodEnum<{
275
- both: "both";
276
275
  account: "account";
277
276
  ip: "ip";
277
+ both: "both";
278
278
  }>>;
279
279
  kind: z.ZodDefault<z.ZodLiteral<"local_call">>;
280
280
  auth: z.ZodDefault<z.ZodNull>;
@@ -56,6 +56,7 @@
56
56
  */
57
57
  import { DEV } from 'esm-env';
58
58
  import { apply_authorization_phase, has_any_scoped_role } from '../auth/request_context.js';
59
+ import {} from '../hono_context.js';
59
60
  import { to_input_params } from '../http/schema_helpers.js';
60
61
  import { dispatch_with_post_commit_rollback } from '../http/pending_effects.js';
61
62
  import { JSONRPC_VERSION } from '../http/jsonrpc.js';
@@ -104,6 +104,7 @@ import { JsonrpcRequest } from '../http/jsonrpc.js';
104
104
  import { dev_only, jsonrpc_error_messages } from '../http/jsonrpc_errors.js';
105
105
  import { create_jsonrpc_error_response, create_jsonrpc_notification, to_jsonrpc_envelope_id, to_jsonrpc_message_id, to_jsonrpc_params, is_jsonrpc_object, is_jsonrpc_request, is_jsonrpc_request_id } from '../http/jsonrpc_helpers.js';
106
106
  import { TOKEN_SCOPE_KEY, TEST_CONTEXT_PRESET_KEY } from '../hono_context.js';
107
+ import {} from './action_types.js';
107
108
  import { compile_action_registry } from './compile_action_registry.js';
108
109
  import { cancel_action_spec, CancelNotificationParams } from './cancel.js';
109
110
  import { DEFAULT_WS_MAX_MESSAGE_BYTES, WS_CLOSE_INTERNAL_ERROR, WS_CLOSE_MESSAGE_TOO_BIG, WS_CLOSE_POLICY_VIOLATION, WS_CLOSE_SERVER_HEARTBEAT_TIMEOUT, WS_CLOSE_SESSION_REVOKED, WS_CLOSE_SESSION_REVOKED_REASON, utf8_length, utf8_length_over } from './transports.js';
@@ -22,7 +22,7 @@
22
22
  * @module
23
23
  */
24
24
  import { clear_session_cookie, create_session_and_set_cookie } from './session_middleware.js';
25
- import { to_session_account } from './account_schema.js';
25
+ import { RoleGrantSummaryJson, to_session_account } from './account_schema.js';
26
26
  import { account_status_route_shape, create_account_route_shapes, DEFAULT_MAX_SESSIONS } from './account_route_schema.js';
27
27
  import { hash_session_token, query_session_revoke_all_for_account, query_session_revoke_by_hash_unscoped } from './session_queries.js';
28
28
  import { query_account_by_username_or_email, query_update_account_password } from './account_queries.js';
@@ -141,16 +141,16 @@ export declare const audit_metadata_schemas: Readonly<{
141
141
  concurrent_change: "concurrent_change";
142
142
  }>>;
143
143
  credential_type: z.ZodOptional<z.ZodEnum<{
144
- session: "session";
145
144
  daemon_token: "daemon_token";
145
+ session: "session";
146
146
  api_token: "api_token";
147
147
  }>>;
148
148
  }, z.core.$loose>>;
149
149
  session_revoke: z.ZodObject<{
150
150
  session_id: z.core.$ZodBranded<z.ZodString, "SessionId", "out">;
151
151
  credential_type: z.ZodOptional<z.ZodEnum<{
152
- session: "session";
153
152
  daemon_token: "daemon_token";
153
+ session: "session";
154
154
  api_token: "api_token";
155
155
  }>>;
156
156
  }, z.core.$loose>;
@@ -159,8 +159,8 @@ export declare const audit_metadata_schemas: Readonly<{
159
159
  reason: z.ZodOptional<z.ZodString>;
160
160
  attempted_account_id: z.ZodOptional<z.core.$ZodBranded<z.ZodUUID, "Uuid", "out">>;
161
161
  credential_type: z.ZodOptional<z.ZodEnum<{
162
- session: "session";
163
162
  daemon_token: "daemon_token";
163
+ session: "session";
164
164
  api_token: "api_token";
165
165
  }>>;
166
166
  }, z.core.$loose>;
@@ -168,16 +168,16 @@ export declare const audit_metadata_schemas: Readonly<{
168
168
  token_id: z.ZodString;
169
169
  name: z.ZodString;
170
170
  credential_type: z.ZodOptional<z.ZodEnum<{
171
- session: "session";
172
171
  daemon_token: "daemon_token";
172
+ session: "session";
173
173
  api_token: "api_token";
174
174
  }>>;
175
175
  }, z.core.$loose>;
176
176
  token_revoke: z.ZodObject<{
177
177
  token_id: z.ZodString;
178
178
  credential_type: z.ZodOptional<z.ZodEnum<{
179
- session: "session";
180
179
  daemon_token: "daemon_token";
180
+ session: "session";
181
181
  api_token: "api_token";
182
182
  }>>;
183
183
  }, z.core.$loose>;
@@ -385,8 +385,8 @@ export declare const CellListInput: z.ZodDefault<z.ZodObject<{
385
385
  updated_at: "updated_at";
386
386
  }>>;
387
387
  order_direction: z.ZodOptional<z.ZodEnum<{
388
- desc: "desc";
389
388
  asc: "asc";
389
+ desc: "desc";
390
390
  }>>;
391
391
  limit: z.ZodOptional<z.ZodNumber>;
392
392
  offset: z.ZodOptional<z.ZodNumber>;
@@ -737,8 +737,8 @@ export declare const cell_list_action_spec: {
737
737
  updated_at: "updated_at";
738
738
  }>>;
739
739
  order_direction: z.ZodOptional<z.ZodEnum<{
740
- desc: "desc";
741
740
  asc: "asc";
741
+ desc: "desc";
742
742
  }>>;
743
743
  limit: z.ZodOptional<z.ZodNumber>;
744
744
  offset: z.ZodOptional<z.ZodNumber>;
@@ -1090,8 +1090,8 @@ export declare const all_cell_action_specs: readonly [{
1090
1090
  updated_at: "updated_at";
1091
1091
  }>>;
1092
1092
  order_direction: z.ZodOptional<z.ZodEnum<{
1093
- desc: "desc";
1094
1093
  asc: "asc";
1094
+ desc: "desc";
1095
1095
  }>>;
1096
1096
  limit: z.ZodOptional<z.ZodNumber>;
1097
1097
  offset: z.ZodOptional<z.ZodNumber>;
@@ -45,8 +45,8 @@ export declare const CREDENTIAL_TYPE_DAEMON_TOKEN = "daemon_token";
45
45
  export declare const BUILTIN_CREDENTIAL_TYPES: readonly ["session", "api_token", "daemon_token"];
46
46
  /** Zod enum for builtin credential types only. */
47
47
  export declare const BuiltinCredentialType: z.ZodEnum<{
48
- session: "session";
49
48
  daemon_token: "daemon_token";
49
+ session: "session";
50
50
  api_token: "api_token";
51
51
  }>;
52
52
  export type BuiltinCredentialType = z.infer<typeof BuiltinCredentialType>;
@@ -8,6 +8,7 @@
8
8
  * @module
9
9
  */
10
10
  import { z } from 'zod';
11
+ import {} from '../runtime/deps.js';
11
12
  import { write_file_atomic } from '../runtime/fs.js';
12
13
  import { get_app_dir } from './config.js';
13
14
  /**
@@ -11,6 +11,7 @@
11
11
  *
12
12
  * @module
13
13
  */
14
+ import { Logger } from '@fuzdev/fuz_util/log.ts';
14
15
  /**
15
16
  * Creates a CLI logger wrapping a Logger with semantic output methods.
16
17
  *
package/dist/db/CLAUDE.md CHANGED
@@ -178,7 +178,7 @@ DO NOTHING`), `_put_fact_refs`, `_get_fact` / `_get_fact_meta` / `_has_fact`
178
178
  `fsync`ed before the rename publishes it (twins the Rust `fuz_fact` §fsync
179
179
  posture: data-sync before rename, parent-dir fsync waived) — the serve path
180
180
  streams the file without re-hashing, so write-time durability is the guard.
181
- - **`fact_store_errors.ts`** — `PayloadTooLargeError` / `StorageFullError` (+
181
+ - **`fact_store_errors.ts`** — `FactPayloadTooLargeError` / `FactStorageFullError` (+
182
182
  `is_enospc_error`) thrown by `put_stream`, for a consumer route's 413 / 507.
183
183
  - The HTTP serving plumbing lives under `server/` (`serve_fact_route.ts`,
184
184
  `x_accel.ts`).
@@ -78,12 +78,12 @@ export interface StreamFactToDiskResult {
78
78
  * `facts_dir`), the buffer + remaining chunks spill to `<facts_dir>/.tmp/…`,
79
79
  * then `rename` into `<facts_dir>/<shard>/<rest>` once the hash is known —
80
80
  * `{kind: 'disk'}`. A body over the threshold with `facts_dir === undefined`
81
- * throws `PayloadTooLargeError` (matches `PgFactStore.put`).
82
- * - **Cap enforcement.** Aborts with `PayloadTooLargeError` the moment the
81
+ * throws `FactPayloadTooLargeError` (matches `PgFactStore.put`).
82
+ * - **Cap enforcement.** Aborts with `FactPayloadTooLargeError` the moment the
83
83
  * running byte count passes `max_bytes` — the mid-stream backstop for a
84
84
  * chunked or mis-declared `Content-Length`.
85
85
  * - **Disk-full.** An `ENOSPC` from the temp-file write surfaces as
86
- * `StorageFullError`.
86
+ * `FactStorageFullError`.
87
87
  *
88
88
  * @mutates `facts_dir` filesystem
89
89
  */
@@ -1 +1 @@
1
- {"version":3,"file":"fact_disk_storage.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/db/fact_disk_storage.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AASH,OAAO,EAAoB,KAAK,QAAQ,EAAE,MAAM,kCAAkC,CAAC;AACnF,OAAO,K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O,UAAU,KACf,OAAO,CAAC,WAAW,CAgBrB,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,yBAAyB,GACrC,MAAM,IAAI,CAAC,mBAAmB,EAAE,WAAW,CAAC,EAC5C,WAAW,MAAM,EACjB,KAAK,MAAM,KACT,OAAO,CAAC,UAAU,CAIpB,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,kBAAkB,GAC9B,MAAM,IAAI,CAAC,mBAAmB,EAAE,SAAS,GAAG,MAAM,GAAG,QAAQ,CAAC,EAC9D,WAAW,MAAM,EACjB,UAAU;IAAE,UAAU,CAAC,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,KAC3D,OAAO,CAAC,MAAM,CA0BhB,CAAC"}
@@ -36,7 +36,7 @@ import { to_hex } from '@fuzdev/fuz_util/hex.ts';
36
36
  import { FACT_HASH_PREFIX } from '@fuzdev/fuz_util/hash_schemas.ts';
37
37
  import { generate_random_base64url } from '../crypto.js';
38
38
  import { fact_disk_path, mint_file_fact_url, parse_file_fact_url } from './file_fact_url.js';
39
- import { is_enospc_error, PayloadTooLargeError, StorageFullError } from './fact_store_errors.js';
39
+ import { is_enospc_error, FactPayloadTooLargeError, FactStorageFullError } from './fact_store_errors.js';
40
40
  /** Subdirectory under `facts_dir` for in-flight atomic temp files. */
41
41
  export const FACT_TMP_DIRNAME = '.tmp';
42
42
  /** Default age (1 hour) past which a `.tmp/*` file is considered orphaned. */
@@ -54,12 +54,12 @@ export const FACT_TMP_ORPHAN_MAX_AGE_MS = 60 * 60 * 1000;
54
54
  * `facts_dir`), the buffer + remaining chunks spill to `<facts_dir>/.tmp/…`,
55
55
  * then `rename` into `<facts_dir>/<shard>/<rest>` once the hash is known —
56
56
  * `{kind: 'disk'}`. A body over the threshold with `facts_dir === undefined`
57
- * throws `PayloadTooLargeError` (matches `PgFactStore.put`).
58
- * - **Cap enforcement.** Aborts with `PayloadTooLargeError` the moment the
57
+ * throws `FactPayloadTooLargeError` (matches `PgFactStore.put`).
58
+ * - **Cap enforcement.** Aborts with `FactPayloadTooLargeError` the moment the
59
59
  * running byte count passes `max_bytes` — the mid-stream backstop for a
60
60
  * chunked or mis-declared `Content-Length`.
61
61
  * - **Disk-full.** An `ENOSPC` from the temp-file write surfaces as
62
- * `StorageFullError`.
62
+ * `FactStorageFullError`.
63
63
  *
64
64
  * @mutates `facts_dir` filesystem
65
65
  */
@@ -76,7 +76,7 @@ export const stream_fact_to_disk = async (deps, facts_dir, source, max_bytes, em
76
76
  const hash_and_count = (chunk) => {
77
77
  size += chunk.length;
78
78
  if (size > max_bytes)
79
- throw new PayloadTooLargeError(size, max_bytes);
79
+ throw new FactPayloadTooLargeError(size, max_bytes);
80
80
  blake3.update(chunk);
81
81
  sha256.update(chunk);
82
82
  };
@@ -111,7 +111,7 @@ export const stream_fact_to_disk = async (deps, facts_dir, source, max_bytes, em
111
111
  if (facts_dir === undefined) {
112
112
  // Over the embedded threshold with nowhere to spill — same shape as the
113
113
  // `PgFactStore.put` oversize-without-disk_root reject.
114
- throw new PayloadTooLargeError(size, embedded_threshold);
114
+ throw new FactPayloadTooLargeError(size, embedded_threshold);
115
115
  }
116
116
  // Phase 2: spill. A combined stream emits the already-hashed buffered
117
117
  // chunks, then continues pulling from `reader`, hashing each remaining
@@ -154,8 +154,8 @@ export const stream_fact_to_disk = async (deps, facts_dir, source, max_bytes, em
154
154
  catch (err) {
155
155
  await deps.remove(tmp_path).catch(() => undefined);
156
156
  if (is_enospc_error(err))
157
- throw new StorageFullError(err);
158
- throw err; // includes a mid-stream PayloadTooLargeError surfaced via the stream
157
+ throw new FactStorageFullError(err);
158
+ throw err; // includes a mid-stream FactPayloadTooLargeError surfaced via the stream
159
159
  }
160
160
  const hash = (FACT_HASH_PREFIX + to_hex(blake3.finalize()));
161
161
  const { shard, rest } = await commit_temp_to_cas(deps, tmp_path, facts_dir, hash);
@@ -197,7 +197,7 @@ export const write_fact_bytes_to_disk = async (deps, facts_dir, hash, bytes) =>
197
197
  catch (err) {
198
198
  await deps.remove(tmp_path).catch(() => undefined);
199
199
  if (is_enospc_error(err))
200
- throw new StorageFullError(err);
200
+ throw new FactStorageFullError(err);
201
201
  throw err;
202
202
  }
203
203
  const { shard, rest } = await commit_temp_to_cas(deps, tmp_path, facts_dir, hash);
@@ -273,7 +273,7 @@ export const sweep_orphan_temps = async (deps, facts_dir, options) => {
273
273
  * the file without re-hashing, so the bytes must be stable before they become
274
274
  * the canonical body), then either drop the temp (byte-identical content already
275
275
  * present — idempotent dedup) or atomically `rename` it into place. On any
276
- * failure the temp is unlinked and an `ENOSPC` is surfaced as `StorageFullError`.
276
+ * failure the temp is unlinked and an `ENOSPC` is surfaced as `FactStorageFullError`.
277
277
  * The single commit path shared by both writers above — twins the Rust `fuz_fact`
278
278
  * `SpillFile::rename_into_cas` (data-sync before rename; parent-dir fsync waived).
279
279
  *
@@ -295,7 +295,7 @@ const commit_temp_to_cas = async (deps, tmp_path, facts_dir, hash) => {
295
295
  catch (err) {
296
296
  await deps.remove(tmp_path).catch(() => undefined);
297
297
  if (is_enospc_error(err))
298
- throw new StorageFullError(err);
298
+ throw new FactStorageFullError(err);
299
299
  throw err;
300
300
  }
301
301
  return { shard, rest };
@@ -24,7 +24,7 @@
24
24
  * oversize `put` throws. `put_stream` needs `fs` for a body of any size — with
25
25
  * none it throws before reading the stream — and `disk_root` for the
26
26
  * over-threshold spill: with none, a body that passes the threshold throws
27
- * `PayloadTooLargeError`.
27
+ * `FactPayloadTooLargeError`.
28
28
  *
29
29
  * Every `external_url` the store writes is a `file:<shard>/<rest>` URL into its
30
30
  * own disk CAS, and that CAS is the only place `get` reads external bytes from
@@ -58,7 +58,7 @@ export declare const FACT_EMBEDDED_THRESHOLD_DEFAULT: number;
58
58
  * reads disk-backed facts from it. When either is unset the store writes
59
59
  * embedded rows only and `get` returns `null` for an external row: an oversize
60
60
  * `put` throws; `put_stream` throws for a body of any size when `fs` is unset,
61
- * and with `fs` but no `disk_root` throws `PayloadTooLargeError` for a body
61
+ * and with `fs` but no `disk_root` throws `FactPayloadTooLargeError` for a body
62
62
  * that passes the threshold. `log` is optional — its call sites are the
63
63
  * warnings on the paths where `get` returns `null` for an external row.
64
64
  */
@@ -91,8 +91,8 @@ export declare class PgFactStore implements FactStore {
91
91
  * BLAKE3 + SHA-256 in one pass, buffer to the embedded threshold, spill to the
92
92
  * disk CAS), then inserts the `fact` row by placement — embedded bytes go to
93
93
  * the PG `bytes` column, disk-spilled bytes record the `file:` `external_url`.
94
- * The cap is enforced mid-stream (`PayloadTooLargeError`); a disk-full mid-
95
- * stream throws `StorageFullError`.
94
+ * The cap is enforced mid-stream (`FactPayloadTooLargeError`); a disk-full mid-
95
+ * stream throws `FactStorageFullError`.
96
96
  *
97
97
  * Refs: explicit `options.refs` are recorded; JSON auto-extraction is NOT
98
98
  * attempted (it would need a buffered re-read, defeating the bounded-memory
@@ -24,7 +24,7 @@
24
24
  * oversize `put` throws. `put_stream` needs `fs` for a body of any size — with
25
25
  * none it throws before reading the stream — and `disk_root` for the
26
26
  * over-threshold spill: with none, a body that passes the threshold throws
27
- * `PayloadTooLargeError`.
27
+ * `FactPayloadTooLargeError`.
28
28
  *
29
29
  * Every `external_url` the store writes is a `file:<shard>/<rest>` URL into its
30
30
  * own disk CAS, and that CAS is the only place `get` reads external bytes from
@@ -100,8 +100,8 @@ export class PgFactStore {
100
100
  * BLAKE3 + SHA-256 in one pass, buffer to the embedded threshold, spill to the
101
101
  * disk CAS), then inserts the `fact` row by placement — embedded bytes go to
102
102
  * the PG `bytes` column, disk-spilled bytes record the `file:` `external_url`.
103
- * The cap is enforced mid-stream (`PayloadTooLargeError`); a disk-full mid-
104
- * stream throws `StorageFullError`.
103
+ * The cap is enforced mid-stream (`FactPayloadTooLargeError`); a disk-full mid-
104
+ * stream throws `FactStorageFullError`.
105
105
  *
106
106
  * Refs: explicit `options.refs` are recorded; JSON auto-extraction is NOT
107
107
  * attempted (it would need a buffered re-read, defeating the bounded-memory
@@ -14,7 +14,7 @@
14
14
  * mis-declared `Content-Length` that the cheap header pre-check can't catch.
15
15
  * A consumer route maps this to `413`.
16
16
  */
17
- export declare class PayloadTooLargeError extends Error {
17
+ export declare class FactPayloadTooLargeError extends Error {
18
18
  /** Bytes read before the cap tripped (may exceed `max_bytes` by one chunk). */
19
19
  readonly bytes_read: number;
20
20
  readonly max_bytes: number;
@@ -26,13 +26,13 @@ export declare class PayloadTooLargeError extends Error {
26
26
  * a best-effort free-space preflight can't promise (chunked uploads, TOCTOU
27
27
  * races). A consumer route maps this to `507`.
28
28
  */
29
- export declare class StorageFullError extends Error {
29
+ export declare class FactStorageFullError extends Error {
30
30
  constructor(cause?: unknown);
31
31
  }
32
32
  /**
33
33
  * Whether a thrown value is a Node filesystem `ENOSPC` (no space left on
34
34
  * device). Used by the streaming disk write to translate the raw FS error
35
- * into a `StorageFullError`.
35
+ * into a `FactStorageFullError`.
36
36
  */
37
37
  export declare const is_enospc_error: (err: unknown) => boolean;
38
38
  //# sourceMappingURL=fact_store_errors.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"fact_store_errors.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/db/fact_store_errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH;;;;;GAKG;AACH,qBAAa,oBAAqB,SAAQ,KAAK;IAC9C,+EAA+E;IAC/E,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;gBACf,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM;CAMjD;AAED;;;;;GAKG;AACH,qBAAa,gBAAiB,SAAQ,KAAK;gBAC9B,KAAK,CAAC,EAAE,OAAO;CAI3B;AAED;;;;GAIG;AACH,eAAO,MAAM,eAAe,GAAI,KAAK,OAAO,KAAG,OAID,CAAC"}
1
+ {"version":3,"file":"fact_store_errors.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/db/fact_store_errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH;;;;;GAKG;AACH,qBAAa,wBAAyB,SAAQ,KAAK;IAClD,+EAA+E;IAC/E,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;gBACf,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM;CAMjD;AAED;;;;;GAKG;AACH,qBAAa,oBAAqB,SAAQ,KAAK;gBAClC,KAAK,CAAC,EAAE,OAAO;CAI3B;AAED;;;;GAIG;AACH,eAAO,MAAM,eAAe,GAAI,KAAK,OAAO,KAAG,OAID,CAAC"}
@@ -14,13 +14,13 @@
14
14
  * mis-declared `Content-Length` that the cheap header pre-check can't catch.
15
15
  * A consumer route maps this to `413`.
16
16
  */
17
- export class PayloadTooLargeError extends Error {
17
+ export class FactPayloadTooLargeError extends Error {
18
18
  /** Bytes read before the cap tripped (may exceed `max_bytes` by one chunk). */
19
19
  bytes_read;
20
20
  max_bytes;
21
21
  constructor(bytes_read, max_bytes) {
22
22
  super(`payload too large: read ${bytes_read} bytes, exceeds ${max_bytes} byte limit`);
23
- this.name = 'PayloadTooLargeError';
23
+ this.name = 'FactPayloadTooLargeError';
24
24
  this.bytes_read = bytes_read;
25
25
  this.max_bytes = max_bytes;
26
26
  }
@@ -31,16 +31,16 @@ export class PayloadTooLargeError extends Error {
31
31
  * a best-effort free-space preflight can't promise (chunked uploads, TOCTOU
32
32
  * races). A consumer route maps this to `507`.
33
33
  */
34
- export class StorageFullError extends Error {
34
+ export class FactStorageFullError extends Error {
35
35
  constructor(cause) {
36
36
  super('storage_full', cause === undefined ? undefined : { cause });
37
- this.name = 'StorageFullError';
37
+ this.name = 'FactStorageFullError';
38
38
  }
39
39
  }
40
40
  /**
41
41
  * Whether a thrown value is a Node filesystem `ENOSPC` (no space left on
42
42
  * device). Used by the streaming disk write to translate the raw FS error
43
- * into a `StorageFullError`.
43
+ * into a `FactStorageFullError`.
44
44
  */
45
45
  export const is_enospc_error = (err) => typeof err === 'object' &&
46
46
  err !== null &&
package/dist/env/load.js CHANGED
@@ -6,6 +6,7 @@
6
6
  *
7
7
  * @module
8
8
  */
9
+ import { z } from 'zod';
9
10
  /**
10
11
  * Error thrown when environment validation fails.
11
12
  *
@@ -24,8 +24,8 @@ import type { RequestContext } from './auth/request_context.js';
24
24
  export declare const CREDENTIAL_TYPES: readonly ["session", "api_token", "daemon_token"];
25
25
  /** Credential type — how a request was authenticated. */
26
26
  export declare const CredentialType: z.ZodEnum<{
27
- session: "session";
28
27
  daemon_token: "daemon_token";
28
+ session: "session";
29
29
  api_token: "api_token";
30
30
  }>;
31
31
  export type CredentialType = z.infer<typeof CredentialType>;
@@ -151,7 +151,7 @@ WS); see ../../../docs/architecture.md §DEV-only Output Validation.
151
151
  `http/error_schemas.ts` is the **declarative** error surface:
152
152
 
153
153
  - `ERROR_*` `snake_case` string constants — single source of truth; use `.literal(ERROR_*)` in Zod schemas and inline checks in handlers
154
- - `ApiError`, `ValidationError`, `PermissionError`, `CredentialTypeRequiredError`, `RateLimitError`, `PayloadTooLargeError`, `ForeignKeyError` — standard shapes
154
+ - `ApiError`, `ValidationError`, `PermissionError`, `CredentialTypeRequiredError`, `RateLimitError`, `PayloadTooLargeError`, `UnsupportedContentTypeError`, `ForeignKeyError` — standard shapes
155
155
  - `RouteErrorSchemas = Partial<Record<number, z.ZodType>>`
156
156
  - `RateLimitKey = 'ip' | 'account' | 'both'`
157
157
 
@@ -173,7 +173,7 @@ merges three layers, later overrides earlier at the same status code:
173
173
  - `auth.roles?.length` → 403 `PermissionError` (carries `required_roles`)
174
174
  - `auth.credential_types?.length` → 403 `CredentialTypeRequiredError` (carries `required_credential_types`; both gates set yields `z.union([PermissionError, CredentialTypeRequiredError])`)
175
175
  - `rate_limit` → 429 `RateLimitError`
176
- - `checks_content_type` (every `POST`) → 415 `ApiError` (`unsupported_content_type`)
176
+ - `checks_content_type` (every `POST`) → 415 `UnsupportedContentTypeError`
177
177
  - `auth.actor !== 'none'` → widens 400 to a union with `ActorRequiredError` / `ActorNotOnAccountError` and adds 500 union of `NoActorsOnAccountError` / `AccountVanishedError`. Mirrors what the dispatcher's authorization phase actually emits on routes whose input declares `acting?: ActingActor` (per registry-time invariant 2) — so DEV-mode error-schema validation doesn't reject the auth phase's body.
178
178
  2. **Middleware** — from `MiddlewareSpec.errors` that apply to the route's path (via `middleware_applies`)
179
179
  3. **Explicit** — `RouteSpec.errors` — always wins
@@ -91,9 +91,9 @@ export declare const parse_acting: (value: unknown) => string | undefined;
91
91
  * without an actor binding).
92
92
  */
93
93
  export declare const AuthAxisState: z.ZodEnum<{
94
- required: "required";
95
- none: "none";
96
94
  optional: "optional";
95
+ none: "none";
96
+ required: "required";
97
97
  }>;
98
98
  export type AuthAxisState = z.infer<typeof AuthAxisState>;
99
99
  /**
@@ -123,14 +123,14 @@ export type AuthAxisState = z.infer<typeof AuthAxisState>;
123
123
  */
124
124
  export declare const RouteAuth: z.ZodObject<{
125
125
  account: z.ZodEnum<{
126
- required: "required";
127
- none: "none";
128
126
  optional: "optional";
127
+ none: "none";
128
+ required: "required";
129
129
  }>;
130
130
  actor: z.ZodEnum<{
131
- required: "required";
132
- none: "none";
133
131
  optional: "optional";
132
+ none: "none";
133
+ required: "required";
134
134
  }>;
135
135
  roles: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
136
136
  credential_types: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodString>>>;