Repository navigation
Expand file tree
/
Copy patherror-code-ledger.zod.ts
More file actions
2525 lines (2506 loc) · 158 KB
/
Copy patherror-code-ledger.zod.ts
File metadata and controls
2525 lines (2506 loc) · 158 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.
/**
* Error-Code Ledger (ADR-0112 D3).
*
* The top-level `error.code` vocabulary is two-tier:
*
* 1. **Standard catalog** — `StandardErrorCode` (`errors.zod.ts`): a small,
* closed set with platform-wide HTTP semantics. It does NOT grow when a
* service invents a code.
* 2. **Registered extension codes** — THIS ledger: every service-specific code
* a route may put in `error.code`, registered under its owning package.
*
* `ErrorCode` (exported below) is the union, and is what `ApiErrorSchema.code`
* validates against. An unregistered code fails schema parse — which fails the
* envelope conformance suites — which fails CI. That friction is the point
* (ADR-0112: "no silent fourth state" for error codes, per ADR-0049/0078).
*
* ## Scope: THIS ledger registers framework packages only (#4805)
*
* Every owner key below is a package published from this repository, and that
* is a RULE — not an accident of the current list, and not something a reader
* should have to infer by scanning the package names. A downstream product
* repo (`objectstack-ai/cloud`, or any product built on the platform) does
* **not** register its codes here. It maintains its OWN ledger, in its own
* repo, and composes the validation itself:
*
* 1. **shape** — `envelopeViolations(body)` (`contract.zod.ts`), and
* 2. **vocabulary** — `code ∈ StandardErrorCode ∪ <its own ledger>`, which
* `makeApiErrorSchema(<its own ledger>)` (`contract.zod.ts`) gives as a
* single parse instead of the two-step assertion.
*
* The deployed wire vocabulary stays closed and checkable either way — which
* is what ADR-0112's "no silent fourth state" asks for. It never asked for
* every entry to live physically in one file.
*
* Why federated rather than admitting downstream entries (maintainer ruling on
* #4805, 2026-08-03, re-confirmed 2026-08-09; raised from cloud#930/#944):
*
* - **A commercial vocabulary does not belong in an Apache-2.0 spec.** The
* codes worth registering are precisely the product-specific ones (billing
* and plan-gating states, control-plane provisioning refusals), and
* registering them here would have the OSS spec enumerate a closed-source
* product's states under package names absent from this distribution.
* - **Cadence mismatch breeds bypass.** A downstream code arrives with a
* downstream feature; making each one cost a cross-repo PR plus a pin bump
* pushes authors toward reusing a semantically wrong existing code, which is
* less visible than inventing one.
*
* The corollary for THIS file: a PR adding an owner key for a package that is
* not published from this repository is out of scope by construction — the
* fix for that need is a ledger in the owning repo, composed as above. The
* one thing a downstream repo must NOT do is emit a code registered nowhere:
* that is the silent fourth state, wherever the ledger lives.
*
* ## Registering a new code
*
* Add it to your package's entry (create the entry if your package has none —
* a framework package; see the scope rule above if yours ships from another
* repo), SCREAMING_SNAKE (`^[A-Z][A-Z0-9_]*$` — lint-enforced by
* `error-code-ledger.test.ts`), with a trailing `//` comment when the name
* alone doesn't carry the meaning. Prefer a domain prefix for anything not
* self-evidently global (`ATTACHMENT_*`, `APPROVAL_*`, `SETTINGS_*`). If the
* condition is generic (not found / permission / validation / rate limit),
* use the standard catalog instead of registering a synonym.
*
* Since #8211 (adjudicated 2026-08-12, option C) that last sentence is
* MECHANICAL, not prose: the admission gate (`error-code-ledger.test.ts`)
* refuses a new code that {@link standardSynonymOf} maps to a standard-catalog
* member, unless the code carries a {@link STANDARD_SYNONYM_WAIVERS} entry
* recording why it stays and which member it shadows. Four synonyms had
* accumulated by the time the rule got teeth precisely because nothing was
* checking; they (plus a fifth the detector surfaced on landing) are
* grandfathered via waivers below — their wire values are unchanged, and
* consolidating any of them onto its standard member is a deliberate wire
* change DEFERRED by the #8211 adjudication (option B) until a specific code
* has a measured victim.
*
* One rule, two doors (#8087, completed by #9106): registration here is the
* ADMISSION door — what the vocabulary may contain. The DISPATCHER door is
* gated (#8087, option B-as-a-gate, maintainer 2026-08-12:
* `check:dispatcher-error-vocabulary` sweeps its producers) and, since the
* #9106 ruling (maintainer 2026-08-16), NARROWS exactly as the REST door
* always has: `resolveThrownHttpError` (`@objectstack/types`) answers `code`
* (a member of this union) for `error.code` at BOTH doors, and a producer's
* unregistered spelling is demoted to the wire's `declaredCode` — the open,
* author-authored channel `ApiErrorSchema` declares for it. Both doors state
* the same rule: a code either IS the standard member for its condition, or it
* is registered here — and if it merely re-spells a standard member, that
* registration is a recorded waiver, never drift. A code registered NOWHERE
* (a tenant app's own spelling) still reaches the wire, in `declaredCode`.
*
* ## Door or no door — every code that ships in `dist` is registered (#16404)
*
* Ruled by the director seat (decision batch #62, 2026-09-07, option D;
* maintainer 「同意」): **the published contract face for error codes is THIS
* ledger together with `StandardErrorCode`.** Any `code` that ships in a
* package's `dist` is registered here whether or not an HTTP door can ever
* answer with it — a thrown value's `code` is what a consumer's
* `catch (e) { switch (e.code) }` pins, and once shipped it cannot be renamed
* without breaking that consumer. Registering a code widens this face and is
* therefore a Clause-② change, door or no door; a code present in `dist` and
* absent here is a protocol gap, not a tier question.
*
* ONE shape, no second list: a `door: 'none'` code is a row like any other —
* the string under the package that stamps it, and a comment that states its
* `status` and the reachability reading ("no HTTP door on this tree; the
* thrown value is the boundary"). Until commit 44c917a47 the dispatcher vocabulary
* (`packages/runtime/src/dispatcher-error-vocabulary.ts`) carried a
* `boot-refusal` verdict that recorded that same reachability for the codes
* NOT yet registered; it is RETIRED, because the gate below now refuses it —
* and every verdict like it — under any published package's `src/`. The one
* verdict that still parks a site there is `pending-registration`, and only
* outside `packages/spec/src/**`, under the dated allowance spelled out below.
* So a `door: 'none'` code has no resting place short of a row here, and the
* ratchet is the one `pending-registration` already had: a row here makes the
* site vanish from that scan. What registration changes
* for such a code is the face,
* not the wire: nothing demotes today, and if a door ever does answer with
* it, `error.code` carries the specific code instead of the status-derived
* member plus `declaredCode`. The `declaredCode` demotion (#9106) stays for
* genuinely unknown / third-party spellings only.
*
* EVERY published package's `src/**` is held to this mechanically — commit 44c917a47
* widened the rule from `packages/spec/src/**` alone, which is all #16449
* could afford to measure. `check:dispatcher-error-vocabulary` refuses to
* classify a stamp site under one as anything but `foreign-vocabulary` (a
* different vocabulary that merely spells itself `code`) or `runtime-pinned`,
* and the only way out is the row here. Under `packages/spec/src/**` that is
* the whole rule, so a `pending-registration` row for a spec site is a finding
* (`spec-face-unregistered`); outside it, a `pending-registration` row keeps a
* named, dated allowance owed to #8846 and any OTHER verdict is a finding
* (`published-face-unregistered`).
*
* A code emitted by several packages is listed once per emitting package —
* the union dedupes; the per-package rows are provenance, not identity.
*
* Since #13353 that sentence has a mechanical half: the provenance gate
* (`check:error-code-provenance`, `packages/spec/scripts/`) sweeps every
* stamp site of a REGISTERED code in `packages/**` non-test source and fails
* when the stamping package's own owner key does not list it. The admission
* rules below never ask WHO emits, so before that gate an unlisted emitter was
* invisible to every gate the repo has (three hand sweeps found the same class
* three times: #7504, #13254, #13353). Two deliberate shapes are NOT rows and
* are recorded in {@link PROVENANCE_WAIVERS} instead: a DOOR in another
* package that names the wire vocabulary itself (`FLOW_DISABLED`,
* `UPDATE_ID_MISMATCH` — see their rows' comments), and a shared constructor
* package whose throw is served under another package's registration.
*
* ## Retiring a code
*
* A row whose last EMITTER is deleted comes out with it. The admission rules
* below check casing, duplication and shadowing — never whether anyone still
* throws the code — so a registered-but-unemittable row stays green forever
* while promising a client a code no response can carry. That is ADR-0112's
* "no silent fourth state" read backwards, and it is not hypothetical:
* `OVERLAY_PERSISTENCE_FAILED` outlived its only producer by one PR (#5264
* deleted `saveMetaItem`'s legacy raw-engine branch; #5783 unregistered the
* code). Nor does a row need to LOSE its producer to be in this class — a
* throw site whose error can never reach a response envelope was unemittable
* from birth: `MONGODB_MULTI_TENANT_UNSUPPORTED` (registered by #3724,
* unregistered by #8035) is a BOOT refusal — the CLI rethrows it pre-HTTP and
* aborts, and the one request-reachable trigger sits inside a documented
* best-effort catch that logs and continues. Its throw site and constant
* (`MULTI_TENANT_UNSUPPORTED_CODE`, `@objectstack/driver-mongodb`) live on:
* host boot matching is not wire vocabulary.
* ⚠️ That SECOND ground is superseded by #16404 ("Door or no door" above): a
* boot refusal that ships in `dist` is owed a row, so the codes left out or
* retired on the "not wire vocabulary" reasoning were registrations owed
* under the ruling, not re-argued per card — #16449 registered the nine
* measured on its tree, and commit 613bfbd3d the fourteen `boot-refusal` rows
* `dispatcher-error-vocabulary.ts` still carried, among them
* `MONGODB_MULTI_TENANT_UNSUPPORTED` itself, back under
* `@objectstack/driver-mongodb` with the #8035 removal reversed on the
* record. What still retires a row is the FIRST ground only: no producer
* left anywhere in `packages/**` source.
* Before deleting a row, check that no producer remains repo-wide AND
* that no consumer — including `objectui` and `cloud` — reads the literal;
* tests that merely CONSTRUCT the code are not producers, and a test pinned to
* a producerless code is pinning nothing (#4984's phantom-check family).
*
* Field-level codes (`FieldErrorSchema.code`, the `fields[]` array) are a
* SEPARATE vocabulary and do not belong here — see #3977 (ADR-0112 D6).
*/
import { z } from 'zod';
import { StandardErrorCode, HttpStatusErrorCodeMap } from './errors.zod';
import { retiredStandardErrorCodeMessage } from './retired-error-codes';
export const ERROR_CODE_LEDGER = {
'@objectstack/rest': [
'ALREADY_REVERTED',
'ANALYTICS_QUERY_FAILED',
'APPROVAL_ACTIONS_FAILED',
// [commit 30b1c636a] The eight rows below are the TEMPLATE-GENERATED members of the
// family whose literal-spelled siblings (`APPROVAL_RECALL_FAILED`,
// `APPROVAL_ACTIONS_FAILED`, `APPROVAL_REQUEST_GET_FAILED`,
// `APPROVAL_REQUEST_LIST_FAILED`) were already registered: the approvals
// route factories in `rest-server.ts` spell the terminal 500 catch's code
// as `` `APPROVAL_${action.toUpperCase()}_FAILED` `` (`decisionRoute`,
// `flowMoveRoute`, `threadRoute`), so a literal sweep could not see them
// and they were skipped when the family landed. Emitted whenever the
// approvals service throws an error `handleApprovalError`'s message-prefix
// table does not map.
'APPROVAL_APPROVE_FAILED',
'APPROVAL_COMMENT_FAILED',
'APPROVAL_REASSIGN_FAILED',
'APPROVAL_RECALL_FAILED',
'APPROVAL_REJECT_FAILED',
'APPROVAL_REMIND_FAILED',
'APPROVAL_REQUEST_GET_FAILED',
'APPROVAL_REQUEST_INFO_FAILED',
'APPROVAL_REQUEST_LIST_FAILED',
'APPROVAL_RESUBMIT_FAILED',
'APPROVAL_REVISE_FAILED',
'BATCH_NOT_ATOMIC',
'BATCH_TOO_LARGE',
'BATCH_UNRESOLVED_REF',
// [#8111] `respondSharingError`'s 409 arm — `revoke` on a rule-materialised
// share (`source != 'manual'`), thrown by plugin-sharing's `sharing-service`
// and documented at `content/docs/kernel/runtime-services/sharing-service.mdx`.
// REGISTERED, not renamed: this is the value the arm has always put on the
// wire, and #8111 converged its POSITION only. Consolidating it onto the
// standard catalog's `RESOURCE_CONFLICT` would change what clients read, so
// it is a deliberate wire change for the maintainer, filed separately —
// exactly the shape this block's existing generic synonyms (`NOT_FOUND`,
// `FORBIDDEN`, `INTERNAL`) already carry.
'CONFLICT',
'CONFLICTING_MAPPING',
'DATASET_INVALID',
'DELEGABLE_SCOPE_FAILED',
'DUPLICATE_REQUEST',
'EMAIL_SEND_FAILED',
'ERR_BULK_RESULT_MISMATCH',
'EXPLAIN_FAILED',
'EXPORT_NOT_PERMITTED',
'EXTERNAL_DATASOURCE_ERROR', // introspection/connection-test refusal from the external-datasource service
'EXTERNAL_IMPORT_ERROR', // federated import refused (read-only store, missing remote table)
// [#8846] ADR-0106 D6 tier 3: field-visibility grants for an object could
// not be evaluated, so the schema is not served — `sendFieldVisibilityFault`
// (`error-response.ts`) answers 503 with this code (503, not 500: the
// condition is an unhealthy dependency and a retry is right). Reported by
// the #8087 dispatcher-vocabulary gate; it reaches the REST door, and the
// ledger is door-agnostic.
'FIELD_VISIBILITY_UNRESOLVED',
'FORBIDDEN',
// [ADR-0159 ruled question 3 = A] The public address clash: a `form` write
// that would leave the form open on a `/forms/SLUG` another form holds
// (`formAddressClashRefusal`, `@objectstack/metadata-protocol`), 409.
'FORM_ADDRESS_TAKEN',
'FORM_NOT_FOUND',
'FORM_RESOLVE_FAILED',
'IMPORT_JOB_CREATE_FAILED',
'IMPORT_ROW_FAILED',
'INTERNAL',
'INVALID_REQUEST',
'INVALID_STATE',
'MAPPING_FORMAT_MISMATCH',
'MAPPING_FORMAT_UNSUPPORTED',
'MAPPING_NOT_FOUND',
'MAPPING_TARGET_MISMATCH',
'NOT_FOUND',
'NOT_UNDOABLE',
'OBJECT_API_DISABLED',
'OBJECT_API_METHOD_NOT_ALLOWED',
'OPENAPI_UNAVAILABLE', // no OpenAPI spec bundled with this runtime
'PACKAGE_DELETE_FAILED',
'PACKAGE_DELETE_PARTIAL', // uninstall left per-item failures behind; see error.details
'PACKAGE_MANIFEST_INVALID',
'PACKAGE_PUBLISH_FAILED',
'PAYLOAD_TOO_LARGE',
'PROJECT_NOT_FOUND',
'PROJECT_PROVISIONING', // project exists but is still provisioning
'PROJECT_PROVISIONING_FAILED',
'READ_BACK_FAILED', // approval write recorded, but its read-back is filtered by the caller's org scope — the result envelope cannot be built; the write is NOT rolled back
// Seven `REPORT*` rows here and two schedule rows further down
// (`SCHEDULES_LIST_FAILED`, `SCHEDULE_DELETE_FAILED`) came out with their
// only emitter, the saved-report `/reports` route family (#20102).
'REQUEST_NOT_FOUND',
'RESUME_FAILED', // decision recorded but its flow run could not be resumed
'RESUME_TARGET_LOST', // the flow run behind the request no longer exists
'RULE_DEFINE_FAILED',
'RULE_DELETE_FAILED',
'RULE_EVALUATE_FAILED',
'RULE_GET_FAILED',
'RULE_LIST_FAILED',
'RULE_NOT_FOUND',
'SHARES_LIST_FAILED',
'SHARE_GRANT_FAILED',
'SHARE_REVOKE_FAILED',
'SUGGESTION_CONFIRM_FAILED',
'SUGGESTION_DISMISS_FAILED',
'SUGGESTION_LIST_FAILED',
// [commit 30b1c636a] `POST /approvals/requests/:id/remind` inside the reminder
// cool-down window — `handleApprovalError` (`rest-server.ts`) maps
// plugin-approvals' `THROTTLED: …` throw (`approval-service.ts`,
// `remind()`) to 429 with this code on the wire. The spec contract
// (`contracts/approval-service.ts`) documents the rejection under this
// name, so the value is contract vocabulary, not an incidental spelling.
// Not a detector-flagged synonym of `RATE_LIMIT_EXCEEDED`, and kept
// deliberately: the condition is a per-action business cool-down, not an
// API quota.
'THROTTLED',
'UNAUTHORIZED',
'UNSUPPORTED_TRANSFORM',
'VALIDATION_FAILED', // record-level validation; carries `fields[]` (#3977)
],
'@objectstack/runtime': [
// [#23367, ruling A] 400 on `POST /keys` (`domains/keys.ts`): the signing
// asked for an `expires_at` further away than the API-key lifecycle
// policy's ceiling (`api_key_max_expiry_days`, one year by default). Not a
// VALIDATION_ERROR synonym: the body is well formed and the date is valid;
// the policy refuses its distance, and the remedy (ask for a nearer date,
// rotate before it) is the policy's own.
'API_KEY_EXPIRY_TOO_LONG',
// [#16041] `POST /analytics/query` / `/analytics/sql` refused a
// `timeDimensions[].dateRange` string outside the closed date-range
// vocabulary (`AnalyticsDateRangeSchema` in `data/analytics.zod.ts`,
// derived from `DATE_RANGE_PRESETS`), or a value that is neither a
// preset name nor a `[start, end]` array. Answered 400 by the runtime
// door (`domains/analytics.ts` lifts the schema's own `invalid_union`
// issue via `isAnalyticsDateRangeRefusalIssue`). Maintainer ruling,
// decision batch #57 (option A, contract first): the arm used to be a
// bare `z.string()` and an unparseable spelling silently matched EVERY
// `Date`-typed row in driver-memory while reading as a single day on SQL.
//
// Not a VALIDATION_ERROR synonym, for the FLOW_* reason: the code names
// the CONDITION — a window spelled outside the platform's one date-range
// vocabulary — which is reported at two moments: here, at the schema
// door, and by the drivers (#16322) when a host calls
// `AnalyticsService.query` in-process past the schema. One condition,
// one code, one wording (`analyticsDateRangeRefusalMessage`, the #5240
// convention); `VALIDATION_FAILED` would say "malformed body" at one
// moment and nothing a driver could speak at the other. Registered under
// the door that names the wire vocabulary. #16322 landed that second
// moment as ONE shared constructor in `@objectstack/core` rather than a
// refusal per driver — so it carries a single PROVENANCE_WAIVERS entry for
// that package below, not a row under each backend.
'ANALYTICS_DATE_RANGE_UNRECOGNIZED',
// [#16293] The AI-facing action doors refuse a call against an action
// whose AUTHOR declared `ai.requiresConfirmation: true` when the request
// does not carry the confirmation member as `true` — 428, the standard
// catalog's "request is missing a required precondition" status, because
// the request is VALID and merely incomplete: for a caller acting for a
// person the identical call with the member set succeeds, and nothing about
// server state changed. An AI service account is refused the same way
// whatever it sends (ADR-0151 D3 rule 3): no retry of its own succeeds. Never
// carries `status: 'failed'`: nothing dispatched, no action body ran, no
// record was read or written.
// Contract, including which request member and what `error.details` carries:
// `AIActionConfirmation` / `ActionConfirmationRequiredDetails` in
// `contracts/ai-service.ts`.
//
// ⛔ NOT a re-spelling of the standard catalog's `PRECONDITION_REQUIRED`,
// and the distinction is why it is registered: that member says SOME
// precondition is missing, which leaves a client unable to tell a
// confirmation gate from a missing conditional header, and unable to build
// the retry. This code says WHICH precondition — the human attestation on
// this named action — which is the thing the caller acts on, exactly the
// discrimination its `*_DISABLED` and `FLOW_*` neighbours make. The
// platform's other confirmation gate,
// `UNIQUE_SCOPE_CONFIRMATION_REQUIRED` (`@objectstack/cloud-connection`),
// is a sibling in KIND only — it answers 409 and therefore sits beside
// `RESOURCE_CONFLICT`, not beside this row's standard member, so it is no
// precedent for choosing 428 over 409 here; that choice rests on the
// condition described above and on nothing it did.
//
// Registered AHEAD of its producer by design — the `FLOW_INPUT_SCHEMA_INVALID`
// split shape. The emitting half is the runtime's pre-dispatch check in
// `action-execution.ts` (`invokeBusinessAction`), which decision batch #54
// split into its own card, #15942; this row is the contract half landed by
// #16293, and the door will assert this exact string by value. Those two
// numbers are the point: a producerless row with no card behind it is the
// "registered but unemittable" retirement class, and this one is a split,
// not a residue. Registered HERE and not under a producing service for the
// same reason as its `FLOW_*` neighbours: the action door, not the
// predicate, is where the wire vocabulary is named.
// Second emitter: the MCP `delete_record` and `delete_records` tools' gate
// (`deleteConfirmationRefusal`, `packages/mcp/src/mcp-http-tools.ts`)
// answers this code, 428, with the same `details` shape for every record
// delete without the member; listed under `@objectstack/mcp` too.
'ACTION_CONFIRMATION_REQUIRED',
// [ADR-0126 §8 item 2] a packaged ACTION this installation switched off,
// refused at dispatch — the activation-ledger consult in
// `action-execution.ts`, answered 409 by BOTH action doors (the REST
// `/actions/:object/:action` route and the MCP `run_action` bridge, which
// throws it with `status`/`code` declared so `resolveThrownHttpError`
// serves the same envelope). Never carries `status: 'failed'`: nothing
// dispatched.
//
// ⛔ NOT a re-spelling of `FLOW_DISABLED`, and the distinction is the point
// of registering it: a `script` action refused under a code naming a flow
// sends an operator hunting a flow that does not exist. It joins the
// `*_DISABLED` family (`OBJECT_API_DISABLED`, `OBJECT_PACKAGE_DISABLED`,
// `FLOW_DISABLED`) — each names WHICH thing is off, which is what an
// operator acts on, and none of them is a synonym of `RESOURCE_CONFLICT`
// in the detector's sense or in meaning.
'ACTION_DISABLED',
// [#14451] `POST /packages/:id/duplicate` was handed a source that is not a
// BASE — a code-loaded or platform/marketplace package. 422 from the
// `/packages` door (`domains/packages.ts`), refused BEFORE the protocol
// call so the target package record is not minted.
//
// ⛔ NOT a re-spelling of `WRITABLE_PACKAGE_REQUIRED`, and the distinction
// is why it is registered: that code says "this package may not be WRITTEN
// to", and its remedy is to use a writable package. Duplicate writes
// nothing to its source, so a caller reading that code here hunts for a way
// to make a code package writable — there is none, and it is not the point.
// This code says the GESTURE does not apply to this source: ADR-0070 D4
// duplicates a base's stored rows, a code package's metadata is delivered
// as code, and the remedy is a base or an ADR-0005 overlay. Same predicate
// (`isWritablePackage`), different consequence.
'DUPLICATE_SOURCE_NOT_A_BASE',
'EXPIRED_OR_REVOKED', // share link
// [#9415] the trigger door refused to dispatch a flow that is switched off
// — `respondToFlowTrigger` (`domains/automation.ts`) reads the engine's
// own `AutomationResult.code` and answers 409. Registered HERE and not
// under the engine's package for the same reason FLOW_FAILED is: this
// door, not the producer, is where the wire vocabulary is named. NOT a
// synonym of `CONFLICT` in the detector's sense and not one in meaning
// either — it names WHICH state conflicts, which is what an operator acts
// on. Never carries `status`: nothing dispatched (#9378 row 3).
// [#9446] Second EMITTER of the code: `POST /api/v1/actions/:object/:action`
// answers the same 409 through `dispatchFlowAction`
// (`packages/runtime/src/action-execution.ts`), reading the same
// engine `AutomationResult.code` via the shared `classifyFlowRefusal`
// table (`flow-dispatch-status.ts`) and serving the throw through
// `errorFromThrown` — the two doors now state the same refusal the same
// way. Provenance, not identity (see above).
'FLOW_DISABLED',
// [#8846] a flow that RAN and rejected — a deliberate business rejection,
// served as a 400 (#3962) with the semantic code kept on the wire so
// callers can branch on it; `/actions` serves the throw through
// `errorFromThrown` (`action-execution.ts`). Reported by the #8087
// dispatcher-vocabulary gate.
'FLOW_FAILED',
// [commit f90e82024] the definition-level input-schema refusal: a node's static
// `config` violates the `inputSchema` its own flow definition declares, so
// the engine refused to dispatch — nothing ran, nothing was written, and
// the result carries NO `status` (the #9378 never-dispatched class, beside
// FLOW_DISABLED / FLOW_NO_START_NODE). The guard's verdict is a pure
// function of the flow definition (`validateNodeInputSchemas` reads
// `node.inputSchema` against the static `node.config`; its variables
// parameter is deliberately unused), so re-running it cannot change the
// answer — ruled NON-RETRYABLE by #10025 (maintainer, 2026-08-20, Option B
// taken whole): ONE refusal row carrying this code instead of
// 1 + maxRetries identical `status: 'failed'` rows re-deriving a
// certainty. Answered 422 like FLOW_NO_START_NODE — understood request,
// existing flow, unexecutable definition — and deliberately distinct from
// it: that one says the definition has nothing to dispatch, this one says
// a node's config contradicts the schema the definition itself declares.
// Not a VALIDATION_ERROR synonym: the REQUEST is well-formed — what fails
// is the stored definition. Registered ahead of its producer by design
// (the #10413 → #10576 split shape, applied to #10025 → commit f90e82024): the
// emitting half — `execute()`'s catch short-circuiting before
// `retryExecution` in `@objectstack/service-automation` — is #10025's,
// blocked on this row, and asserts this exact string by value. Registered
// HERE and not under the engine's package for the same reason as its
// three FLOW_* siblings: the trigger door, not the producer, is where the
// wire vocabulary is named.
'FLOW_INPUT_SCHEMA_INVALID',
// [#9415] the trigger door refused a flow whose stored definition has no
// `start` node — there is nothing to dispatch, so the run never began.
// Answered 422 by `respondToFlowTrigger`: understood request, existing
// flow, unexecutable definition. Deliberately distinct from
// FLOW_DISABLED — one is reversible operational state, the other an
// authoring defect — and from FLOW_FAILED, which means the flow ran
// (#9378 row 4).
// [#9446] Second EMITTER of the code: `POST /api/v1/actions/:object/:action`
// answers the same 422 through `dispatchFlowAction`
// (`packages/runtime/src/action-execution.ts`), reading the same
// engine classification via the shared `classifyFlowRefusal` table
// (`flow-dispatch-status.ts`) and serving the throw through
// `errorFromThrown` — the two doors now state the same refusal the same
// way. Provenance, not identity (see above).
'FLOW_NO_START_NODE',
'INVALID_OR_EXPIRED', // share-link token
'NEEDS_PASSWORD', // share link requires a password
// [#22823] The data door's two exposure codes, stamped by `callData`'s
// nested-relation walk (`refuseUnservedRelationTargets`,
// `action-execution.ts`) when a condition's related object does not serve
// `list`: 404 for `apiEnabled: false`, 405 with `allowed` for a whitelist.
// Reached on the `query` fallback (no protocol service resolved) and on the
// `aggregate` arm. The protocol path's answer for the same condition is
// `@objectstack/metadata-protocol`'s row; `@objectstack/rest` keeps its own
// rows for the addressed object. Provenance, not identity (see above).
'OBJECT_API_DISABLED',
'OBJECT_API_METHOD_NOT_ALLOWED',
// [cloud#3814 D1] the runtime package doors refuse a package change, 409,
// right after the caller's authorization and the walled-catalog refusal
// (both still answer first) and before anything is written,
// when the deployment declares several replicas on the Redis cluster
// driver (`declaresMultiReplicaOnRedis`, `@objectstack/service-cluster`):
// `POST /packages`, `PATCH /packages/:id/enable` and `/disable`,
// `POST /packages/:id/duplicate` and `/ensure-customization`,
// `PATCH /packages/:id` and `DELETE /packages/:id`
// (`multi-replica-package-refusal.ts`), plus the flow and permission-set
// clone doors when the copy would CREATE the source's paired
// customization package (its App's pair, `pairOf`). Each change would reach only the serving
// replica: the registry is read at boot and the enable/disable choice is
// kept per replica. The string is the shared constant one package over
// (see the `@objectstack/cloud-connection` row and PROVENANCE_WAIVERS);
// this row records runtime's own doors.
'MULTI_REPLICA_PACKAGE_CHANGE_REFUSED',
// [ADR-0131 D10 item 5, ruling 6163114098 Q3 A] The v18 boot refusal
// (`OrganizationOwnershipBootGuardPlugin`, `organization-ownership-boot-
// guard.ts`): `os serve` refuses to start against a database still in the
// v17 shape — a table whose object declares no organization column still
// carries a physical `organization_id` — while the organization-ownership
// ceremony's `sys_migration` marker is not verified. Thrown from the
// plugin's `kernel:ready` hook, before `kernel:listening` opens the socket,
// so no request is ever served (`door: 'none'`, the
// WALLED_MEMBERSHIP_POLICY_UNDECLARED precedent); the `code` lets a host
// discriminate the refusal structurally. No escape hatch exists (D10).
'ORGANIZATION_OWNERSHIP_MIGRATION_REQUIRED',
// [#7557] `DELETE /packages/:id` on the DISPATCHER door — per-item failures
// used to ride inside a 200 with a hardcoded `success: true`. Second
// EMITTER of the code `@objectstack/rest` already registers for the
// direct-mount door of the same route; the two doors now state the same
// failure the same way. Provenance, not identity (see above).
'PACKAGE_DELETE_PARTIAL',
// [ADR-0141 Open item 4, ruling A on #30379] 409 from the package disable
// door (`PATCH /packages/:id/disable`, `domains/packages.ts`): the disable
// is refused because a validation rule of a package that stays enabled
// (any severity; an app's `.custom` pair, where tenant-written rules live,
// included) reads a field this package adds through `objectExtensions`.
// Disabling it would withhold that field, and every write to the object
// would then fail that rule. The refusal names each package · object ·
// rule triple it found, one or several. The remedy: disable or change the
// reading rule first, or keep this package enabled. A formula over the
// field is no reason to refuse: it answers `null`. Registered AHEAD of its
// producer (the `ACTION_CONFIRMATION_REQUIRED` split shape): the door's
// scan is #30379's and asserts this string by value. ⛔ NOT a `*_DISABLED`
// re-spelling: those name WHICH thing is off, and this names WHY a disable
// is refused, and the rule it names is what the operator acts on. Nor a
// mirror of `DEPENDENCY_MISSING`: no `manifest.dependencies` entry is
// read, so "RESTRICTED" (the standard `DELETE_RESTRICTED` word for a 409
// refused over a dependent) carries `BY_VALIDATION_RULE` to say which
// dependent. PACKAGE and DISABLE are tokens no standard member carries, so
// it needs no waiver.
'PACKAGE_DISABLE_RESTRICTED_BY_VALIDATION_RULE',
'PROJECT_MEMBERSHIP_REQUIRED',
'RECORD_GONE', // share link resolves but the record was deleted
'ROUTE_NOT_FOUND',
// [#25820] The `/automation/:name/runs/:runId` resume and run-read doors
// answer a run that another flow owns as an unknown one, before the engine
// is asked (`runIsOutsideFlow`, `domains/automation.ts`), so the door
// stamps the code itself; the engine's own resume refusal is the
// `@objectstack/service-automation` row.
'RUN_NOT_FOUND',
'SIGN_IN_REQUIRED',
'UNSUPPORTED',
'VALIDATION_FAILED',
// [#7560] ADR-0070: the `/packages` LIFECYCLE routes (`PATCH /:id/disable`,
// `DELETE /:id`) refuse a read-only — code- or platform-provided — package.
// Second EMITTER of the code `@objectstack/metadata-protocol` already
// registers for the authoring half (`saveMetaItem`); one condition, one
// vocabulary. Per this file's header, a code emitted by several packages is
// listed once per emitting package — provenance, not identity.
'WRITABLE_PACKAGE_REQUIRED',
'WRONG_PASSWORD',
// [commit 613bfbd3d] ADR-0130 D4 — `resolveArtifactCollections`
// (`artifact-collections.ts`) refuses one collection key declared in the
// ARRAY form by one source and the RECORD form by another inside the same
// artifact; `refuse()` there stamps `code` + `status: 422`. Registered
// under the #16404 ruling (door or no door; see the header): the code
// ships in this package's `dist/index.js` (measured), so its spelling is
// the face a consumer's `catch (e) { switch (e.code) }` pins.
// `door: 'none'` on this tree — the reading its `boot-refusal` row in
// `dispatcher-error-vocabulary.ts` recorded and this row ratchets out,
// re-checked here: the function is not exported from `src/index.ts`, and
// its call sites all ship in this package on the artifact load path
// (`app-plugin.ts`, `load-artifact-bundle.ts`, `standalone-stack.ts`,
// `resolve-project-database.ts`), so no package outside this one can
// reach it. The `status: 422` is the ADR-0112 envelope shape this repo's
// rejection tests assert on, not evidence of a door. Not a synonym of any
// standard member (`ARTIFACT`, `COLLECTION`, `SHAPE` are tokens none
// carries).
'MIXED_ARTIFACT_COLLECTION_SHAPE',
// [ADR-0106 D6 tier 3] The MCP object-schema reads over HTTP
// (`domains/mcp.ts`: `describe_object`, `list_objects`, option-field reads)
// answer 503 with this code when the caller's field visibility cannot be
// evaluated or the masked projection would leave no field, the same code
// and status the REST `/meta` object read answers. Rendered by the MCP
// tools' coded result. Second EMITTER of the code `@objectstack/rest`
// registers: provenance, not identity.
'FIELD_VISIBILITY_UNRESOLVED',
],
'@objectstack/service-storage': [
'ATTACHMENT_DELETE_DENIED',
'ATTACHMENT_DOWNLOAD_DENIED',
'ATTACHMENT_PARENT_ACCESS', // no access to the record the file is attached to
'AUTH_REQUIRED',
'ERR_FILE_CONSTRAINT',
'ERR_FILE_REFERENCE_COPY',
// [#32754] 403 from the storage service's own per-object attachment opt-in
// gate (`attachment-files-opt-in.ts`): a `sys_attachment` insert, or an
// update that re-points one, onto an object that does not declare
// `enable.files: true`, thrown from its engine hook and answered by every
// attach door as it was thrown. Second EMITTER of the code
// `@objectstack/plugin-audit` registers for its own gate on the same
// declaration. Provenance, not identity (see above).
'FILES_DISABLED',
'FILE_DOWNLOAD_DENIED',
'FILE_FIELD_BULK_WRITE_REFUSED', // a multi/predicate update wrote a file id into a file-class field (#7102)
'FILE_NOT_FOUND',
'INTERNAL',
'INVALID_REQUEST',
'INVALID_RESUME_TOKEN',
// [#22314] 413 from every upload door over the resolved `max_upload_mb`
// (#22283): the presigned door's declared `size`, the chunked start's
// declared `totalSize`, the local raw PUT body and each chunk's running
// total, by `content-length` before the body is read and by the bytes read
// — `storage-routes.ts`, refused before a row is written or a byte stored.
// Second EMITTER of the code `@objectstack/rest` already registers for its
// import row ceilings (both import routes); one condition — the request
// carries more than the door accepts — one code a client branches on
// without reading the status. Provenance, not identity (see above).
'PAYLOAD_TOO_LARGE',
// [#32734] 409 from `create_upload_link` for a file field of a record a
// pending approval locks (`record-file-access.ts`, asked of
// `IApprovalService.getRecordLock` before a link is minted), so no link is
// issued that the record-lock hook would refuse on use. Second EMITTER of
// the code `@objectstack/plugin-approvals` registers for that hook's own
// refusal, which the upload-link door relays as it was thrown. Provenance,
// not identity (see above).
'RECORD_LOCKED',
'UPLOAD_SESSION_EXPIRED', // chunk/complete against a session past its own expires_at (#7667)
'UPLOAD_SESSION_NOT_FOUND',
],
'@objectstack/service-i18n': [
'INTERNAL',
'INVALID_REQUEST',
],
'@objectstack/plugin-auth': [
'ACCOUNT_LOCKED',
'ASYNC_NOT_SUPPORTED',
'AUTH_CONFIG_ERROR',
'BANNED_USER', // 403 on a sign-in by a banned account: better-auth's admin-plugin code, passed through for an administrator's ban and stamped by plugin-auth (`banned-user-refusal-cause.ts`) on `/sign-in/email` with `details.cause: 'scim_deactivated'` when the identity provider deactivated the account through SCIM; a client tells the two apart by that field, never by the message
'CREATE_FAILED',
'CREDENTIALS_NAME_DIFFERENT_ACCOUNTS', // 401, before every gate and the endpoint: the request's session cookie and its bearer token name two different signed-in accounts, so it is refused and nothing runs for either; an auth request is judged and executed as one account (one credential, one account, or a credential naming no live account is unaffected)
'DOMAIN_VERIFICATION_DISABLED', // domain verification is off on this deployment
'DOMAIN_VERIFICATION_FAILED', // pass-through from better-auth
'EMAIL_DOMAIN_NOT_ALLOWED', // [#11739] audience posture email_domain: the address's domain is off the allowlist
'EMAIL_SERVICE_REQUIRED',
'SMS_SERVICE_REQUIRED', // [#21793] 400 on /phone-number/send-otp: phone OTP needs a deliverable SMS service and none is configured (none wired, or a log-only transport in production)
'ENV_ACCESS_DENIED',
'INVALID_EMAIL',
'INVALID_PHONE',
'INVITE_EMAIL_FAILED',
// [#24082] The invitation role cap's three refusals (`invitation-role-cap.ts`),
// each thrown 403 from `beforeCreateInvitation` with its code (#23945).
'INVITE_ISSUER_MEMBER_ONLY', // [#24082] 403: an issuer below admin grade may invite only as a plain `member`; the requested role does not outrank theirs but may carry capability of its own
'INVITE_ISSUER_UNVERIFIED', // [#24082] 403, fail-closed: the issuer's `sys_member` role was not established (the read answered with no usable row, or the composition has no data engine to read), so the invitation may confer nothing beyond `member`; a read that throws answers `SERVICE_UNAVAILABLE` (503) instead
// [#24254] The invitation placement gate's two refusals (ADR-0105 D8), thrown
// 403 from `beforeCreateInvitation` after the role cap, registered AHEAD of
// their producer: today both are a bare `FORBIDDEN`, and #24243 stamps these.
'INVITE_PLACEMENT_OUTSIDE_ISSUER_SCOPE', // [#24254] 403: the delegated-administration gate refused the invitation's placement intent (its business unit, or a position's permission sets, lies outside the issuer's `adminScope`, ADR-0090 D12), so no invitation is created; the gate's own verdict, not a failure to reach one
'INVITE_PLACEMENT_UNSUPPORTED', // [#24254] 403, fail-closed: the invitation carries placement intent (a business unit and positions) and this deployment has no delegated-administration runtime (plugin-security's `invitation-placement` service) to authorize it, so no invitation is created; the same invitation without placement is unaffected
'INVITE_REQUIRES_EMAIL',
'INVITE_ROLE_ABOVE_ISSUER', // [#24082] 403: the requested role grades above the issuer's own (an invitation never confers authority above its issuer)
'INVALID_REQUEST',
'INVITE_SMS_FAILED',
'IP_NOT_ALLOWED',
'LAST_LOCAL_CREDENTIAL', // refusing to remove the user's only local credential
'NO_IDENTITY', // import row has neither email nor phone
'NO_PENDING_VERIFICATION', // pass-through from better-auth
// [#24254] The organization hooks' two refusals no standard member names
// (`beforeCreateOrganization`, `beforeUpdateOrganization`), registered AHEAD
// of their producer: today both are a bare `FORBIDDEN`, and #24243 stamps these.
'ORGANIZATION_CREATION_DISABLED', // [#24254] 403: the deployment's effective tenancy posture enforces no organization wall (ADR-0105), so creating an organization is refused for every caller; the same derivation `/auth/config` publishes as `features.multiOrgEnabled: false`, a deployment setting and not a grant the caller lacks
'ORGANIZATION_SLUG_LOCKED_BY_ACTIVE_ENVIRONMENTS', // [#24254] 403: a change to a new slug is refused while the organization has an active environment, meaning a `sys_environment` row with its `organization_id` whose `status` is neither `archived` nor `failed` (a row with no status counts), and no hostname is read; a guard read that could not answer is `SERVICE_UNAVAILABLE` (503) instead
'PASSWORD_ALREADY_SET', // pass-through from better-auth
'PASSWORD_EXPIRED',
'PASSWORD_POLICY_VIOLATION',
// [#23287, ruling C′ item 2] 403 from every ADR-0069 gate seam while an
// administrator's forced password change (`sys_user.must_change_password`)
// is outstanding. It used to reuse `PASSWORD_EXPIRED`; the forced act now
// has its own code (scope `credential`, `AUTH_GATE_SCOPES`), so a client
// can tell an expiry from a reset an administrator asked for.
'PASSWORD_RESET_REQUIRED',
'PASSWORD_REUSE',
// ADR-0093 D3 amendment — 400 on /admin/create-user under a walled posture:
// the calling administrator has no current organization for the new user
// to join, so no account is created. better-auth's own code for the same
// condition on Add Member, so both doors answer it alike.
'NO_ACTIVE_ORGANIZATION',
'OAUTH_REGISTER_FAILED', // better-auth rejected the client registration
'PHONE_NOT_ENABLED',
'ROLE_NOT_FOUND', // [#24750] 400 on /organization/invite-member and /organization/update-member-role: the requested membership role is outside the closed vocabulary, refused before any invitation or membership row is written; better-auth's code, stamped by plugin-auth on the invite door (`invite-role-not-found-code.ts`), pass-through from better-auth on update-member-role
'SAML_REGISTER_FAILED',
'SELF_REGISTRATION_CLOSED', // [#11739] audience posture invite_only: self-registration is closed (no pending invitation for this address)
'SSO_REGISTER_FAILED',
'SSO_REGISTER_FORBIDDEN',
'USER_ALREADY_EXISTS', // pass-through from better-auth
// [#15587] Raised by US on `/sign-up/email` for an address that already
// carries a `sys_user` row, using better-auth's own BASE_ERROR_CODES entry
// so the refusal is byte-identical whichever lane produces it. Registered
// here because the platform now EMITS it rather than only passing it
// through: an emitted-but-unregistered code is the silent fourth state.
'USER_ALREADY_EXISTS_USE_ANOTHER_EMAIL',
'VALIDATION_FAILED',
],
'@objectstack/plugin-sharing': [
'AUDIENCE_NOT_ALLOWED',
'ELIGIBILITY_UNEVALUABLE', // [#7861] publicSharing.eligibility would not compile / faulted on the record — refused, never issued past an unanswered policy
'EXPIRED_OR_REVOKED',
'EXPIRY_IN_PAST',
'EXPIRY_TOO_LONG',
'FORBIDDEN',
'INTERNAL',
'INVALID_EXPIRY',
'INVALID_OR_EXPIRED',
'NEEDS_PASSWORD',
'NOT_FOUND',
'PERMISSION_NOT_ALLOWED', // share level would grant a verb the sharer lacks
'RECORD_GONE',
'RECORD_NOT_ELIGIBLE', // [#7861] publicSharing.eligibility returned false for this record
'SHARING_NOT_ENABLED',
'SIGN_IN_REQUIRED',
'UNSUPPORTED',
'VALIDATION_FAILED',
'WRONG_PASSWORD',
],
'@objectstack/metadata-protocol': [
'AUDIT_TYPE_NOT_CANONICAL', // [#8908] an ADR-0010 audit row was offered a non-canonical metadata `type` — the writer asserts, the caller folds
'BATCH_ABORTED', // sibling item in an all-or-nothing publish; it never ran
'CLONE_DISABLED',
'COMMIT_NOT_FOUND',
'CONCURRENT_UPDATE',
'DESTRUCTIVE_CHANGE', // change would drop data; needs an explicit opt-in
// [#23015] The save door's half of "one default record page per object per
// deployment" (maintainer ruling A, record 6134056653): `saveMetaItem`
// refuses a `page` body that is the default record page of an object a
// stored page or a packaged page already holds, naming both, 422 — the
// same code and status `@objectstack/objectql`'s registration refusal
// stamps for the same condition (that package depends on this one, so the
// string is spelled in each). Served by the `/meta` write doors through
// `errorFromThrown`.
'DEFAULT_RECORD_PAGE_CONFLICT',
// [ADR-0159 ruled question 3 = A] The public address clash: the `form`
// save, draft promotion and restore doors refuse a `form` write that would
// leave the form open on a `/forms/SLUG` another form holds, naming both,
// 409 (`formAddressClashRefusal`, protocol-form-writes.ts). Served by the
// `/meta` write doors through `errorFromThrown`.
'FORM_ADDRESS_TAKEN',
// [#24001] The flow save door's 409 for a refused conversion rename came
// out with its last producer (this header's "Retiring a code"): protocol
// 18 reserved the old HTTP-callout node types, so no live owner can
// collide with a rename and no conversion reports a conflict.
'INVALID_METADATA',
'INVALID_REQUEST',
'ITEM_LOCKED', // _lock refuses the write/delete (ADR-0010 §3.3)
'METADATA_CONFLICT',
// The metadata doors' half of "one name, one holder" for a permission set
// (maintainer rulings Q4 = A, record 6050490870, and A, record
// 6063176077): the save door, the draft promotion and the restore doors
// refuse a permission-set write whose name another holder already holds,
// naming both, 422 — the same code and status `@objectstack/objectql`'s
// registration and cold-boot refusals stamp for the same condition (that
// package depends on this one, so the string is spelled in each). Served
// by the `/meta` write doors through `errorFromThrown`.
'NAMESPACE_CONFLICT',
'NAMESPACE_PREFIX', // name violates the package namespace-prefix rule
'NO_DRAFT',
'NOT_ATTEMPTED', // data-batch row never ran — an earlier row's failure stopped the batch, to roll back (atomic, #4793) or because continueOnError was unset (#7539)
'NOT_CREATABLE',
'NOT_OVERRIDABLE',
// [#22737] The data door's two exposure codes, stamped by `findData`'s
// nested-relation walk (`refuseUnservedRelationTarget`) when a condition's
// related object does not serve `list`: 404 for `apiEnabled: false`, 405
// with `allowed` for a whitelist. Served on the list and query routes.
// `@objectstack/rest` keeps its own rows for the addressed object.
'OBJECT_API_DISABLED',
'OBJECT_API_METHOD_NOT_ALLOWED',
'OBJECT_OVERLAY_PACKAGE_MISMATCH', // [ADR-0029 D9.9] object overlay row bound to a package that does not own the object
'OBJECT_PACKAGE_DISABLED', // [#7557] object is registered but its owning package is disabled — data plane refuses rather than serving rows
// [#8846] the query body's convenience `object` key names a different
// object than the route addresses — refused 400 (`protocol.ts`); `/meta`
// and `/packages` serve protocol throws through `errorFromThrown`.
// Reported by the #8087 dispatcher-vocabulary gate.
'QUERY_OBJECT_MISMATCH',
'REGISTRY_TYPE_NOT_CANONICAL', // [#9111] a SchemaRegistry overlay entry was offered a non-canonical metadata `type` — the mint door asserts, the caller folds
'ROLLED_BACK', // atomic data-batch row was written, then undone by the batch rollback (#4793)
'STORED_TYPE_NOT_CANONICAL', // [#8908] a package draft is stored under a non-canonical metadata type (pre-#7894 second-namespace residue) — refused at the publish pre-flight, batch-atomic; [#9174] also refused on `revertCommit`'s restore limb, per-item on `failed[]`, NOT batch-atomic
// [ADR-0131 D6] The `unmanaged` install mode's two refusals, both stamped
// by `importUnmanagedPackage` (`protocol.ts`) before the new base exists,
// so nothing is written. Each gives a consumer a branch no existing code
// gives: the package installs MANAGED instead, and neither the
// `OS_METADATA_WRITABLE` hatch (`NOT_CREATABLE`'s remedy) nor a retry
// helps. Doored: `POST /api/v1/marketplace/install-local` with
// `installMode: 'unmanaged'` (`@objectstack/cloud-connection`) answers
// both with their own code and status; the install door also raises the
// WALLED_POSTURE refusal itself, through the same function, before it
// judges anything else about the package.
// - UNCOPYABLE, 422: the body carries what the copy cannot write as
// environment rows — a runtime-uncreatable type, code, an extension of
// another package's items, or an artifact envelope.
// - WALLED_POSTURE, 409: the deployment's REQUESTED tenancy posture
// (`group` / `isolated`, or an unrecognised value, read fail-closed)
// walls organizations, and one shared editable copy cannot sit behind it.
'UNMANAGED_INSTALL_UNCOPYABLE',
'UNMANAGED_INSTALL_WALLED_POSTURE',
'UNSUPPORTED_QUERY_PARAM',
'VALIDATION_FAILED',
'VERSION_NOT_FOUND',
'VERSION_NOT_RESTORABLE',
'WRITABLE_PACKAGE_REQUIRED',
],
'@objectstack/metadata-core': [
// [ADR-0141 D2] The pre-install dependency check refused an install whose
// delivered package declares a `manifest.dependencies` entry the
// environment does not satisfy: not installed (nor delivered by the same
// act), installed outside the declared range, or a range or installed
// version outside the stated grammar (`DependencyMissingError`,
// `protocol-handshake.ts`). Answered 422, the status the sibling refusals
// at the same gate answer for a delivered manifest judged against the
// environment ahead of registration (`NAMESPACE_CONFLICT`). The three
// install doors — the protocol install primitive, the no-protocol fallback
// of `POST /api/v1/packages` and `POST /api/v1/marketplace/install-local`
// — answer it through the shared `dependencyMissingAnswer`, carrying one
// `dependency_missing` `AppCompatibilityCheck` issue and one fact row per
// unmet entry in `error.details`.
'DEPENDENCY_MISSING',
// [ADR-0131 D6/D7, #23429] `readLegacyOrganizationRows`
// (`legacy-organization-row.ts`, `LegacyOrganizationRowsUnreadable`) could
// not tell a `sys_metadata`-family table's legacy organization rows from
// the environment's: the driver's raw seam returned no result set, its SQL
// dialect resolved to none, or the column list came back empty for a table
// that exists. Refused, never read as "none" — that answer would serve,
// list or delete one organization's rows as the environment's. It reaches a
// door only on a database the organization-ownership ceremony has not
// migrated (which `os serve` refuses), so the remedy it names is the
// ceremony.
'LEGACY_ORGANIZATION_ROWS_UNREADABLE',
'METADATA_BRANCH',
'METADATA_CONFLICT',
'METADATA_NOT_FOUND',
'METADATA_SCHEMA_INVALID',
// [#21727] ADR-0087 D1's protocol handshake refused a package whose
// declared `engines.protocol` range excludes this runtime's major
// (`ProtocolIncompatibleError`, `protocol-handshake.ts`). Answered 422:
// the manifest is well-formed, but it declares a range this runtime can
// never satisfy, so the same body never succeeds on this runtime. The
// remedy is a different body (migrated metadata, or a build for this
// runtime's protocol), or, for a package ahead of the runtime, a runtime
// upgrade, which is a deployment change, not environment state. It
// matches this package's own METADATA_SCHEMA_INVALID. It is not 409,
// which this ledger keeps for refusals from environment state
// (CONCURRENT_UPDATE). The two HTTP doors that reach the throw,
// `POST /api/v1/packages` and (since #21805)
// `POST /api/v1/marketplace/install-local`, answer the same bytes through
// the shared `protocolIncompatibleAnswer`, carrying `requiredRange`,
// `rangeSource`, `protocolVersion` and `targetMajor` in `error.details`
// on every refusal. `migrateCommand` is present only when the chain can
// replay the package's metadata: `objectstack migrate meta --from N` for
// a `targetMajor` from the migrate-meta support floor
// (`MIGRATION_SUPPORT_FLOOR`, 16, ADR-0087 D3) up to the runtime's major,
// and the bare `objectstack migrate meta` when `targetMajor` is null. It
// is absent when `targetMajor` is AHEAD of the runtime (#26480), where
// the message names upgrading the runtime or installing a build for this
// runtime's protocol, and absent BELOW the floor (#33466), where
// `--from N` refuses and the message names installing a build for this
// runtime's protocol, or bringing the metadata to the floor by another
// path and then running `--from 16`.
'OS_PROTOCOL_INCOMPATIBLE',
],
'@objectstack/objectql': [
// [ADR-0142 D4] A by-id write carrying the engine-internal precondition
// (`expect`) matched no row: another writer moved the row first. 409 —
// the claim race's loser ("the record was taken") and the assignment
// cursor's lost advance, raised in `engine.ts`'s by-id update branch.
// Second EMITTER of the code `@objectstack/types` registers for the data
// door's optimistic-lock refusal; one condition, one vocabulary.
'CONCURRENT_UPDATE',
// [#8846] single-row insert: the autonumber counter was re-seeded and the
// value re-issued, and the driver still refused the write (`engine.ts`;
// carries the driver's failure as `cause`). One of four unswept members of
// this package's ERR_* family reported by the #8087 dispatcher-vocabulary
// gate.
'ERR_AUTONUMBER_COLLISION',
'ERR_BULK_RESULT_MISMATCH',
// [#8846] a transaction wrote to an object on a different datasource than
// the one the transaction was opened on (`CrossDatasourceTransactionWriteError`,
// `transaction-errors.ts`). Same #8087-gate family as above.
'ERR_CROSS_DATASOURCE_TRANSACTION_WRITE',
// [ADR-0144 D8 rule 4, Open item 9] A write would store a `record`-mode
// currency amount beside a blank currency code — a number in no currency.
// 400; the driver is never asked to write the row (`RecordCurrencyCodeRequiredError`,
// `validation/record-currency-code.ts`); `field` names the code field to
// fill. The server never fills a currency in.
'ERR_CURRENCY_CODE_REQUIRED',
'ERR_DATASOURCE_UNAVAILABLE',
'ERR_DRIVER_CONNECT',
// [ADR-0144 D5, Open items 2 and 9] A write would store a `record`-mode
// amount declaring `homeAmount` in a foreign currency, and no exchange rate
// for that currency is in force on the record's document date (the latest
// `effective_date` on or before it). 400; the driver is never asked to write
// the row (`ExchangeRateMissingError`, `home-amount-projection.ts`); the
// message names the currency and the date. No 1:1 rate, later rate or empty
// home amount is stored in its place. Fixed by adding a rate row.
'ERR_EXCHANGE_RATE_MISSING',
// [#8846] a `before*` hook moved or cleared the id the engine resolved a
// by-id (or per-row predicate) write against — refused rather than
// silently writing a different record (`HOOK_TARGET_REBIND_ERROR_CODE`,
// `hook-target-rebind-errors.ts`), during a write the dispatcher is
// serving. Same #8087-gate family.
'ERR_HOOK_TARGET_REBIND',
// [ADR-0144 Open item 4] A write would store a `record`-mode amount
// declaring `homeAmount`, and the organization has no usable home currency:
// `localization.currency` is unset (or holds no ISO 4217 code). 400; the
// driver is never asked to write the row (`HomeCurrencyUnsetError`,
// `home-amount-projection.ts`). The platform never assumes a home currency.
// Fixed by setting `localization.currency` — a different remedy from
// `ERR_EXCHANGE_RATE_MISSING`, hence its own code.
'ERR_HOME_CURRENCY_UNSET',
// [ADR-0158 U5, Open items 3 and 9] The unit-of-measure write check
// (`validation/unit-code-membership.ts`). Each is 400 and the driver is
// never asked to write the row; `field` names the unit code field and,
// for a quantity, `quantityField` the quantity. One code per remedy, the
// way `ERR_HOME_CURRENCY_UNSET` stands beside `ERR_EXCHANGE_RATE_MISSING`.
//
// A quantity would be stored beside a blank unit code (Open item 9 case 3,
// mirroring `ERR_CURRENCY_CODE_REQUIRED`). Fixed by writing the code in the
// same write, or leaving the quantity empty. The server never fills one in.
'ERR_UNIT_CODE_REQUIRED',
// The unit code is neither a standard code (U1) nor one of the
// organization's own units (`sys_unit`), in exact uppercase (cases 1 and 2).
// Fixed by writing a standard code, or adding the unit in Setup first.
'ERR_UNIT_CODE_UNKNOWN',
// The unit code names one of the organization's units that is retired
// (L1's delete, Open item 11). A retired code is never created again, so
// the remedy is moving the record to an existing unit.
'ERR_UNIT_CODE_RETIRED',
// The unit code is a member, of another dimension than the
// `unitConfig.unitDimension` the field declares (Open item 9, point 5).
// Fixed by writing a code of that dimension.
'ERR_UNIT_DIMENSION_MISMATCH',
// [ADR-0158 Open item 11; #35488's carried requirement] A delete of a
// `sys_unit` row, refused in every context — user, system and automation —
// before any middleware or hook runs (`delete()`, `engine-delete-and-aggregate.ts`).
// Retiring is the delete: a removed row would free its code to be created
// again with another dimension. 405, the status the data door answers the
// same verb on this object with (`apiMethods` serves no `delete`).
'ERR_UNIT_DELETE_REFUSED',
// [#5320] Third EMITTER of the code (metadata-protocol and plugin-security
// already register it) — the registration loop's `views:` tighten refuses a
// non-container entry, and the `viewItems:` channel refuses an entry the
// assembled vocabulary rejects, both 422/INVALID_METADATA. Provenance, not
// identity, per this file's header.
'INVALID_METADATA',
'ERR_READONLY_FIELD_REJECTED', // strictReadonlyWrites: the write would strip caller-supplied fields, so it was refused (#5126; since #6437 that covers the primary_key strip too — one code, `drops` carries the per-reason breakdown)
'ERR_SUMMARY_RECOMPUTE',
// [#8844] A system-context insert on a tenant-scoped application object
// carried no organization on a MULTI-organization install (a walled
// posture, or a `single` posture whose data holds several organizations).
// The ruled alternative to silently filing the row under the `__global__`
// pseudo-tenant, which forks the autonumber counter and the partitioned
// unique index and mints duplicate business identifiers. Not a synonym of
// any standard member: it is neither the client's bad input (the caller is
// server-side automation) nor a missing precondition on a request.
'ERR_SYSTEM_WRITE_ORGANIZATION_REQUIRED',
// [ADR-0153 D4] A write named a `_sync_` provenance column and is not the
// sync-in pull's, or a `before*` hook of any write (the pull's included)
// assigned, changed or removed one. 400, judged on the caller's payload
// before the middleware, the defaults or a hook run, and on the hooks'
// writes before the driver, so nothing is written
// (`SyncProvenanceWriteRefusedError`, `sync-provenance-write.ts`). Refused
// whatever the caller's context, `isSystem` included: the pull is the
// columns' only writer.
'ERR_SYNC_PROVENANCE_WRITE_REFUSED',
// [#8846] `transaction({ require: true })` on a driver with no
// `beginTransaction` — thrown BEFORE the callback runs, so nothing has
// been written (`TransactionUnsupportedError`, `transaction-errors.ts`;
// ADR-0119 D1/D4 fail-closed posture). Same #8087-gate family.
'ERR_TRANSACTION_UNSUPPORTED',
// [#27277] The engine's floor over a plugin driver on an external
// datasource (epic #27261 Tier A, ruling 6487532394 on #27277;
// `external-driver-floor.ts`). Both are 422
// with their status declared on the thrown error (the
// `driver-connect-errors.ts` pattern), and neither is an ADR-0015 gate
// refusal: `EXTERNAL_WRITE_FORBIDDEN` (403, `@objectstack/spec/shared`)
// is the platform's own write switch being off; these are fixed by
// changing the payload or the filter.
//
// The remote system refused a write with a 4xx (its validation, a lock,
// a missing record). The message is the remote's own; `details` carries
// `remoteStatus`. A remote that failed or did not answer is
// ERR_DATASOURCE_UNAVAILABLE / 503 above, not this.
'EXTERNAL_WRITE_REFUSED',
// A read matched more rows than the engine reads from a plugin driver
// for one request (1000). The engine applies the query to the rows the
// driver returns, so it refuses rather than answer over a set it only
// partly holds. The message prescribes narrowing the filter or mirroring
// the data with DataSync.
//
// Deliberately NOT the standard `MAX_RECORDS_EXCEEDED` (400, `errors.zod.ts`:
// a caller-side limit, the request asked for more than a request may
// carry). This is a 422 on a VALID query that the remote's size makes
// unservable: the request is well-formed and its limit is fine, the