advisers 0.2.2 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +0 -0
- package/NOTICE +0 -0
- package/README-zh.md +11 -7
- package/README.md +16 -8
- package/THIRD-PARTY-NOTICES.md +1 -1
- package/bin/advisers.js +6347 -542
- package/index.js +1 -1
- package/lib/agent.js +529 -80
- package/lib/attachments.js +0 -0
- package/lib/audit-anchor.js +683 -0
- package/lib/backup.js +1345 -0
- package/lib/capture.js +0 -0
- package/lib/context-window.js +0 -0
- package/lib/digest.js +0 -0
- package/lib/doc-review.js +0 -0
- package/lib/egress.js +0 -0
- package/lib/error-codes.js +1373 -0
- package/lib/evidence.js +352 -43
- package/lib/fs-safe.js +347 -0
- package/lib/ical.js +0 -0
- package/lib/imap.js +6 -2
- package/lib/importers.js +0 -0
- package/lib/learning.js +0 -0
- package/lib/ledger-read.js +608 -0
- package/lib/mcp-server.js +331 -50
- package/lib/model.js +73 -1
- package/lib/node-warning-filter.js +15 -0
- package/lib/notify.js +13 -3
- package/lib/nudge.js +0 -0
- package/lib/ocr.js +29 -9
- package/lib/pdf.js +0 -0
- package/lib/pet-brief-store.js +0 -0
- package/lib/pet-brief.js +126 -64
- package/lib/receipt-verify.js +213 -15
- package/lib/relative-date.js +0 -0
- package/lib/remind.js +91 -36
- package/lib/research.js +0 -0
- package/lib/review.js +0 -0
- package/lib/routine.js +0 -0
- package/lib/safety/classifier.js +55 -2
- package/lib/safety/explain.js +0 -0
- package/lib/safety/index.js +0 -0
- package/lib/safety/redact.js +0 -0
- package/lib/safety/rules.js +28 -0
- package/lib/scheduler.js +0 -0
- package/lib/source.js +0 -0
- package/lib/sqlite.js +2302 -55
- package/lib/sync.js +398 -71
- package/lib/text-safe.js +229 -0
- package/lib/timestamp.js +29 -9
- package/lib/tos/index.js +1 -1
- package/lib/tos/manifest.json +6 -6
- package/lib/tos/privacy.zh-CN.md +12 -9
- package/lib/tos/safety.zh-CN.md +4 -3
- package/lib/tos/summary.zh-CN.md +3 -3
- package/lib/tos/terms.zh-CN.md +8 -6
- package/lib/tui/color.js +164 -0
- package/lib/tui/index.js +33 -0
- package/lib/tui/json.js +124 -0
- package/lib/tui/labels.js +50 -0
- package/lib/tui/policy.js +108 -0
- package/lib/tui/render.js +371 -0
- package/lib/tui/sanitize.js +142 -0
- package/lib/tui/text-file.js +116 -0
- package/lib/tui/width.js +577 -0
- package/lib/ui.js +0 -0
- package/lib/undo.js +0 -0
- package/lib/untrusted.js +186 -0
- package/lib/vault.js +0 -0
- package/package.json +6 -5
|
@@ -0,0 +1,1373 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Advisers error-code registry (single source of truth for the 0.3.0 contract).
|
|
3
|
+
*
|
|
4
|
+
* Two layers:
|
|
5
|
+
* - the frozen 0.2.4 baseline: 50 `E_*` literals in committed
|
|
6
|
+
* `packages/advisers/{bin,lib}` source at `35a51c3`;
|
|
7
|
+
* - 65 additive 0.3.0 codes (`since: "0.3.0"`) extracted from the 0.3.0
|
|
8
|
+
* modules landing in the same release (audit anchor, backup/restore, read-only
|
|
9
|
+
* ledger facade, TUI JSON guards, receipt limits). They are provisional until
|
|
10
|
+
* their modules are committed; `check-contracts --errors` accepts a 0.3.0 code
|
|
11
|
+
* that exists in the worktree but not yet in git HEAD, and fails only when a
|
|
12
|
+
* registered code exists nowhere (stale).
|
|
13
|
+
*
|
|
14
|
+
* This module is data + pure helpers only: importing it never changes CLI/MCP/DSH
|
|
15
|
+
* behaviour. `bin/` may start using the helpers in a later integration wave; for
|
|
16
|
+
* 0.3.0 the consumers are `scripts/check-contracts.mjs` (registry <-> source
|
|
17
|
+
* <-> docs sync gate) and `packages/advisers/test/contracts.test.js`.
|
|
18
|
+
*
|
|
19
|
+
* Rules:
|
|
20
|
+
* - a code is registered once with its category, documented exit code, observed
|
|
21
|
+
* surfaces, freeze baseline (`since`) and a one-line actionable remedy;
|
|
22
|
+
* - a new `E_*` literal in committed source must be registered or
|
|
23
|
+
* `check-contracts --errors` fails (new codes are additive; v1 is frozen);
|
|
24
|
+
* - `contracts/errors/codes.v1.json` and `docs/ERROR-CODES.md` are generated from
|
|
25
|
+
* this file with `node scripts/check-contracts.mjs --update`; never edit them;
|
|
26
|
+
* - do not silently rename or change the meaning of an existing code: scripts may
|
|
27
|
+
* branch on it. Add a new code and keep the old one as an alias instead.
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
export const ERROR_CODE_VERSION = 1
|
|
31
|
+
export const ERROR_CODES_FROZEN_AT = '2026-11-20'
|
|
32
|
+
export const ERROR_CODES_SOURCE_COMMIT = '35a51c3'
|
|
33
|
+
export const ERROR_CODES_SOURCE_VERSION = '0.2.4'
|
|
34
|
+
export const ERROR_CODES_RELEASE = '0.3.0'
|
|
35
|
+
export const ERROR_CODES_BASELINE_COUNT = 50
|
|
36
|
+
|
|
37
|
+
/** Category vocabulary used by the registry, docs and contracts. */
|
|
38
|
+
export const ERROR_CATEGORIES = Object.freeze([
|
|
39
|
+
'usage', 'config', 'store', 'schema', 'state', 'tos', 'policy',
|
|
40
|
+
'content', 'evidence', 'fs', 'template', 'verify', 'internal',
|
|
41
|
+
])
|
|
42
|
+
|
|
43
|
+
/** Where a code can be observed. MCP transport errors are JSON-RPC numbers, not E_* codes. */
|
|
44
|
+
export const ERROR_SURFACES = Object.freeze(['cli', 'lib', 'dsh'])
|
|
45
|
+
|
|
46
|
+
const REGISTRY = [
|
|
47
|
+
{
|
|
48
|
+
code: 'E_AMOUNT',
|
|
49
|
+
category: 'template',
|
|
50
|
+
exit: 1,
|
|
51
|
+
surfaces: Object.freeze(['cli']),
|
|
52
|
+
since: '0.2.x',
|
|
53
|
+
stable: true,
|
|
54
|
+
remedy: "Fix the quote/proposal money fields: quantities, unit prices and tax/discount rates are decimal strings within the template limits.",
|
|
55
|
+
doc: 'docs/CLI-JSON.md',
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
code: 'E_AUDIT_ANCHOR_ABSENT',
|
|
59
|
+
category: 'state',
|
|
60
|
+
exit: 1,
|
|
61
|
+
surfaces: Object.freeze(['lib']),
|
|
62
|
+
since: '0.3.0',
|
|
63
|
+
stable: true,
|
|
64
|
+
remedy: "no audit anchor has been recorded yet; run `advisers audit --write-anchor` to create a baseline",
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
code: 'E_AUDIT_ANCHOR_BEHIND',
|
|
68
|
+
category: 'state',
|
|
69
|
+
exit: 1,
|
|
70
|
+
surfaces: Object.freeze(['lib']),
|
|
71
|
+
since: '0.3.0',
|
|
72
|
+
stable: true,
|
|
73
|
+
remedy: "the backup is older than the audit anchor; pass --allow-anchor-behind only if this time-travel is intended",
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
code: 'E_AUDIT_ANCHOR_DB_MISMATCH',
|
|
77
|
+
category: 'state',
|
|
78
|
+
exit: 1,
|
|
79
|
+
surfaces: Object.freeze(['lib']),
|
|
80
|
+
since: '0.3.0',
|
|
81
|
+
stable: true,
|
|
82
|
+
remedy: "the audit anchor belongs to a different database; do not use it to certify this ledger",
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
code: 'E_AUDIT_ANCHOR_HEAD_INVALID',
|
|
86
|
+
category: 'state',
|
|
87
|
+
exit: 1,
|
|
88
|
+
surfaces: Object.freeze(['lib']),
|
|
89
|
+
since: '0.3.0',
|
|
90
|
+
stable: false,
|
|
91
|
+
remedy: "Audit anchor/chain integrity check failed; do not repair the chain automatically — investigate and restore from a trusted backup.",
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
code: 'E_AUDIT_ANCHOR_HMAC_MISMATCH',
|
|
95
|
+
category: 'state',
|
|
96
|
+
exit: 1,
|
|
97
|
+
surfaces: Object.freeze(['lib']),
|
|
98
|
+
since: '0.3.0',
|
|
99
|
+
stable: true,
|
|
100
|
+
remedy: "the audit anchor HMAC does not match; treat this as tampering or a changed audit key and restore from a trusted backup",
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
code: 'E_AUDIT_ANCHOR_INVALID',
|
|
104
|
+
category: 'state',
|
|
105
|
+
exit: 1,
|
|
106
|
+
surfaces: Object.freeze(['lib']),
|
|
107
|
+
since: '0.3.0',
|
|
108
|
+
stable: true,
|
|
109
|
+
remedy: "the audit anchor file is malformed; inspect it and write a fresh anchor (never delete audit rows to make it match)",
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
code: 'E_AUDIT_ANCHOR_KEY_MISSING',
|
|
113
|
+
category: 'state',
|
|
114
|
+
exit: 1,
|
|
115
|
+
surfaces: Object.freeze(['lib']),
|
|
116
|
+
since: '0.3.0',
|
|
117
|
+
stable: true,
|
|
118
|
+
remedy: "the audit anchor is HMAC-keyed but the audit key is unavailable; restore $ADVISERS_HOME/audit.key (do not regenerate it, the existing chain would verify as BROKEN)",
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
code: 'E_AUDIT_ANCHOR_PATH',
|
|
122
|
+
category: 'state',
|
|
123
|
+
exit: 1,
|
|
124
|
+
surfaces: Object.freeze(['lib']),
|
|
125
|
+
since: '0.3.0',
|
|
126
|
+
stable: false,
|
|
127
|
+
remedy: "Audit anchor/chain integrity check failed; do not repair the chain automatically — investigate and restore from a trusted backup.",
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
code: 'E_AUDIT_ANCHOR_STORE',
|
|
131
|
+
category: 'state',
|
|
132
|
+
exit: 1,
|
|
133
|
+
surfaces: Object.freeze(['lib']),
|
|
134
|
+
since: '0.3.0',
|
|
135
|
+
stable: false,
|
|
136
|
+
remedy: "Audit anchor/chain integrity check failed; do not repair the chain automatically — investigate and restore from a trusted backup.",
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
code: 'E_AUDIT_ANCHOR_TOO_LARGE',
|
|
140
|
+
category: 'state',
|
|
141
|
+
exit: 1,
|
|
142
|
+
surfaces: Object.freeze(['lib']),
|
|
143
|
+
since: '0.3.0',
|
|
144
|
+
stable: true,
|
|
145
|
+
remedy: "the audit anchor file is unexpectedly large; inspect it before trusting it",
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
code: 'E_AUDIT_ANCHOR_UNREADABLE',
|
|
149
|
+
category: 'state',
|
|
150
|
+
exit: 1,
|
|
151
|
+
surfaces: Object.freeze(['lib']),
|
|
152
|
+
since: '0.3.0',
|
|
153
|
+
stable: true,
|
|
154
|
+
remedy: "the audit anchor file cannot be read; check permissions and the path",
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
code: 'E_AUDIT_ANCHOR_WRITE_FAILED',
|
|
158
|
+
category: 'state',
|
|
159
|
+
exit: 1,
|
|
160
|
+
surfaces: Object.freeze(['lib']),
|
|
161
|
+
since: '0.3.0',
|
|
162
|
+
stable: false,
|
|
163
|
+
remedy: "Audit anchor/chain integrity check failed; do not repair the chain automatically — investigate and restore from a trusted backup.",
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
code: 'E_AUDIT_CHAIN_BROKEN',
|
|
167
|
+
category: 'state',
|
|
168
|
+
exit: 1,
|
|
169
|
+
surfaces: Object.freeze(['lib']),
|
|
170
|
+
since: '0.3.0',
|
|
171
|
+
stable: true,
|
|
172
|
+
remedy: "the audit chain is broken (a middle row was edited or deleted); nothing will repair it automatically — export evidence and restore from a trusted backup",
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
code: 'E_AUDIT_EXPECT_MISMATCH',
|
|
176
|
+
category: 'state',
|
|
177
|
+
exit: 1,
|
|
178
|
+
surfaces: Object.freeze(['lib']),
|
|
179
|
+
since: '0.3.0',
|
|
180
|
+
stable: true,
|
|
181
|
+
remedy: "the audit does not match the expected count/head; the tail may have been deleted or rolled back",
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
code: 'E_AUDIT_HEAD_INVALID',
|
|
185
|
+
category: 'state',
|
|
186
|
+
exit: 1,
|
|
187
|
+
surfaces: Object.freeze(['lib']),
|
|
188
|
+
since: '0.3.0',
|
|
189
|
+
stable: false,
|
|
190
|
+
remedy: "Audit anchor/chain integrity check failed; do not repair the chain automatically — investigate and restore from a trusted backup.",
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
code: 'E_AUDIT_HEAD_MISMATCH',
|
|
194
|
+
category: 'state',
|
|
195
|
+
exit: 1,
|
|
196
|
+
surfaces: Object.freeze(['lib']),
|
|
197
|
+
since: '0.3.0',
|
|
198
|
+
stable: true,
|
|
199
|
+
remedy: "the audit last row was rewritten or rolled back; restore from a trusted backup and investigate",
|
|
200
|
+
},
|
|
201
|
+
{
|
|
202
|
+
code: 'E_AUDIT_TAIL_TRUNCATED',
|
|
203
|
+
category: 'state',
|
|
204
|
+
exit: 1,
|
|
205
|
+
surfaces: Object.freeze(['lib']),
|
|
206
|
+
since: '0.3.0',
|
|
207
|
+
stable: true,
|
|
208
|
+
remedy: "the audit tail was deleted or the database was rolled back; do not delete or rebuild audit rows — restore from a trusted backup and investigate",
|
|
209
|
+
},
|
|
210
|
+
{
|
|
211
|
+
code: 'E_BACKUP_ANCHOR_HEAD_MISSING',
|
|
212
|
+
category: 'store',
|
|
213
|
+
exit: 1,
|
|
214
|
+
surfaces: Object.freeze(['lib']),
|
|
215
|
+
since: '0.3.0',
|
|
216
|
+
stable: false,
|
|
217
|
+
remedy: "Backup operation failed; the live database is unchanged. Check the path/permissions and retry, and keep the diagnostic output.",
|
|
218
|
+
},
|
|
219
|
+
{
|
|
220
|
+
code: 'E_BACKUP_ANCHOR_MISMATCH',
|
|
221
|
+
category: 'store',
|
|
222
|
+
exit: 1,
|
|
223
|
+
surfaces: Object.freeze(['lib']),
|
|
224
|
+
since: '0.3.0',
|
|
225
|
+
stable: true,
|
|
226
|
+
remedy: "the backup's own .anchor.json sidecar does not match the backup audit head; the backup or its sidecar was modified",
|
|
227
|
+
},
|
|
228
|
+
{
|
|
229
|
+
code: 'E_BACKUP_AUDIT_CHAIN_BROKEN',
|
|
230
|
+
category: 'store',
|
|
231
|
+
exit: 1,
|
|
232
|
+
surfaces: Object.freeze(['lib']),
|
|
233
|
+
since: '0.3.0',
|
|
234
|
+
stable: true,
|
|
235
|
+
remedy: "the backup audit chain is broken; restore only with explicit allowBrokenAuditChain after exporting evidence",
|
|
236
|
+
},
|
|
237
|
+
{
|
|
238
|
+
code: 'E_BACKUP_AUDIT_UNREADABLE',
|
|
239
|
+
category: 'store',
|
|
240
|
+
exit: 1,
|
|
241
|
+
surfaces: Object.freeze(['lib']),
|
|
242
|
+
since: '0.3.0',
|
|
243
|
+
stable: true,
|
|
244
|
+
remedy: "the backup audit head cannot be read; the file may be corrupt",
|
|
245
|
+
},
|
|
246
|
+
{
|
|
247
|
+
code: 'E_BACKUP_BUSY',
|
|
248
|
+
category: 'store',
|
|
249
|
+
exit: 1,
|
|
250
|
+
surfaces: Object.freeze(['lib']),
|
|
251
|
+
since: '0.3.0',
|
|
252
|
+
stable: true,
|
|
253
|
+
remedy: "another connection blocked the WAL checkpoint; close other advisers processes (ui/mcp/bridge) and retry",
|
|
254
|
+
},
|
|
255
|
+
{
|
|
256
|
+
code: 'E_BACKUP_CHECKPOINT_FAILED',
|
|
257
|
+
category: 'store',
|
|
258
|
+
exit: 1,
|
|
259
|
+
surfaces: Object.freeze(['lib']),
|
|
260
|
+
since: '0.3.0',
|
|
261
|
+
stable: false,
|
|
262
|
+
remedy: "Backup operation failed; the live database is unchanged. Check the path/permissions and retry, and keep the diagnostic output.",
|
|
263
|
+
},
|
|
264
|
+
{
|
|
265
|
+
code: 'E_BACKUP_CORRUPT',
|
|
266
|
+
category: 'store',
|
|
267
|
+
exit: 1,
|
|
268
|
+
surfaces: Object.freeze(['lib']),
|
|
269
|
+
since: '0.3.0',
|
|
270
|
+
stable: true,
|
|
271
|
+
remedy: "the backup fails SQLite quick_check; do not restore it — try an older backup and keep this file for forensics",
|
|
272
|
+
},
|
|
273
|
+
{
|
|
274
|
+
code: 'E_BACKUP_DIR_FAILED',
|
|
275
|
+
category: 'store',
|
|
276
|
+
exit: 1,
|
|
277
|
+
surfaces: Object.freeze(['lib']),
|
|
278
|
+
since: '0.3.0',
|
|
279
|
+
stable: false,
|
|
280
|
+
remedy: "Backup operation failed; the live database is unchanged. Check the path/permissions and retry, and keep the diagnostic output.",
|
|
281
|
+
},
|
|
282
|
+
{
|
|
283
|
+
code: 'E_BACKUP_DIR_REQUIRED',
|
|
284
|
+
category: 'store',
|
|
285
|
+
exit: 1,
|
|
286
|
+
surfaces: Object.freeze(['lib']),
|
|
287
|
+
since: '0.3.0',
|
|
288
|
+
stable: false,
|
|
289
|
+
remedy: "Backup operation failed; the live database is unchanged. Check the path/permissions and retry, and keep the diagnostic output.",
|
|
290
|
+
},
|
|
291
|
+
{
|
|
292
|
+
code: 'E_BACKUP_EMPTY',
|
|
293
|
+
category: 'store',
|
|
294
|
+
exit: 1,
|
|
295
|
+
surfaces: Object.freeze(['lib']),
|
|
296
|
+
since: '0.3.0',
|
|
297
|
+
stable: true,
|
|
298
|
+
remedy: "the backup file is empty; it cannot be restored — take a fresh backup after recovering the ledger",
|
|
299
|
+
},
|
|
300
|
+
{
|
|
301
|
+
code: 'E_BACKUP_EXISTS',
|
|
302
|
+
category: 'store',
|
|
303
|
+
exit: 1,
|
|
304
|
+
surfaces: Object.freeze(['lib']),
|
|
305
|
+
since: '0.3.0',
|
|
306
|
+
stable: true,
|
|
307
|
+
remedy: "the target backup file already exists; choose another name or pass overwrite explicitly",
|
|
308
|
+
},
|
|
309
|
+
{
|
|
310
|
+
code: 'E_BACKUP_FAILED',
|
|
311
|
+
category: 'store',
|
|
312
|
+
exit: 1,
|
|
313
|
+
surfaces: Object.freeze(['lib']),
|
|
314
|
+
since: '0.3.0',
|
|
315
|
+
stable: false,
|
|
316
|
+
remedy: "Backup operation failed; the live database is unchanged. Check the path/permissions and retry, and keep the diagnostic output.",
|
|
317
|
+
},
|
|
318
|
+
{
|
|
319
|
+
code: 'E_BACKUP_HAS_WAL',
|
|
320
|
+
category: 'store',
|
|
321
|
+
exit: 1,
|
|
322
|
+
surfaces: Object.freeze(['lib']),
|
|
323
|
+
since: '0.3.0',
|
|
324
|
+
stable: true,
|
|
325
|
+
remedy: "the backup was copied without a WAL checkpoint; take a fresh backup with `advisers backup` (it checkpoints first)",
|
|
326
|
+
},
|
|
327
|
+
{
|
|
328
|
+
code: 'E_BACKUP_INSTALL_FAILED',
|
|
329
|
+
category: 'store',
|
|
330
|
+
exit: 1,
|
|
331
|
+
surfaces: Object.freeze(['lib']),
|
|
332
|
+
since: '0.3.0',
|
|
333
|
+
stable: false,
|
|
334
|
+
remedy: "Backup operation failed; the live database is unchanged. Check the path/permissions and retry, and keep the diagnostic output.",
|
|
335
|
+
},
|
|
336
|
+
{
|
|
337
|
+
code: 'E_BACKUP_INVALID',
|
|
338
|
+
category: 'store',
|
|
339
|
+
exit: 1,
|
|
340
|
+
surfaces: Object.freeze(['lib']),
|
|
341
|
+
since: '0.3.0',
|
|
342
|
+
stable: false,
|
|
343
|
+
remedy: "Backup operation failed; the live database is unchanged. Check the path/permissions and retry, and keep the diagnostic output.",
|
|
344
|
+
},
|
|
345
|
+
{
|
|
346
|
+
code: 'E_BACKUP_KEEP_INVALID',
|
|
347
|
+
category: 'store',
|
|
348
|
+
exit: 1,
|
|
349
|
+
surfaces: Object.freeze(['lib']),
|
|
350
|
+
since: '0.3.0',
|
|
351
|
+
stable: true,
|
|
352
|
+
remedy: "invalid keep policy; use a count or daily=7,weekly=4,monthly=3",
|
|
353
|
+
},
|
|
354
|
+
{
|
|
355
|
+
code: 'E_BACKUP_LIST_FAILED',
|
|
356
|
+
category: 'store',
|
|
357
|
+
exit: 1,
|
|
358
|
+
surfaces: Object.freeze(['lib']),
|
|
359
|
+
since: '0.3.0',
|
|
360
|
+
stable: false,
|
|
361
|
+
remedy: "Backup operation failed; the live database is unchanged. Check the path/permissions and retry, and keep the diagnostic output.",
|
|
362
|
+
},
|
|
363
|
+
{
|
|
364
|
+
code: 'E_BACKUP_MISSING',
|
|
365
|
+
category: 'store',
|
|
366
|
+
exit: 1,
|
|
367
|
+
surfaces: Object.freeze(['lib']),
|
|
368
|
+
since: '0.3.0',
|
|
369
|
+
stable: true,
|
|
370
|
+
remedy: "the backup file does not exist; check the path or list <home>/backups",
|
|
371
|
+
},
|
|
372
|
+
{
|
|
373
|
+
code: 'E_BACKUP_NOT_ADVISERS_DB',
|
|
374
|
+
category: 'store',
|
|
375
|
+
exit: 1,
|
|
376
|
+
surfaces: Object.freeze(['lib']),
|
|
377
|
+
since: '0.3.0',
|
|
378
|
+
stable: true,
|
|
379
|
+
remedy: "the file is not an Advisers ledger database; check the path",
|
|
380
|
+
},
|
|
381
|
+
{
|
|
382
|
+
code: 'E_BACKUP_OPEN_FAILED',
|
|
383
|
+
category: 'store',
|
|
384
|
+
exit: 1,
|
|
385
|
+
surfaces: Object.freeze(['lib']),
|
|
386
|
+
since: '0.3.0',
|
|
387
|
+
stable: false,
|
|
388
|
+
remedy: "Backup operation failed; the live database is unchanged. Check the path/permissions and retry, and keep the diagnostic output.",
|
|
389
|
+
},
|
|
390
|
+
{
|
|
391
|
+
code: 'E_BACKUP_PATH_UNSAFE',
|
|
392
|
+
category: 'store',
|
|
393
|
+
exit: 1,
|
|
394
|
+
surfaces: Object.freeze(['lib']),
|
|
395
|
+
since: '0.3.0',
|
|
396
|
+
stable: true,
|
|
397
|
+
remedy: "refusing to delete a path outside the managed backup directory",
|
|
398
|
+
},
|
|
399
|
+
{
|
|
400
|
+
code: 'E_BACKUP_SCHEMA_NEWER',
|
|
401
|
+
category: 'store',
|
|
402
|
+
exit: 1,
|
|
403
|
+
surfaces: Object.freeze(['lib']),
|
|
404
|
+
since: '0.3.0',
|
|
405
|
+
stable: true,
|
|
406
|
+
remedy: "the backup is from a newer Advisers; upgrade the CLI instead of restoring it",
|
|
407
|
+
},
|
|
408
|
+
{
|
|
409
|
+
code: 'E_BACKUP_SIDECAR_FAILED',
|
|
410
|
+
category: 'store',
|
|
411
|
+
exit: 1,
|
|
412
|
+
surfaces: Object.freeze(['lib']),
|
|
413
|
+
since: '0.3.0',
|
|
414
|
+
stable: true,
|
|
415
|
+
remedy: "the .sha256 sidecar could not be written; the backup exists but its checksum file is missing",
|
|
416
|
+
},
|
|
417
|
+
{
|
|
418
|
+
code: 'E_BACKUP_SOURCE_MISSING',
|
|
419
|
+
category: 'store',
|
|
420
|
+
exit: 1,
|
|
421
|
+
surfaces: Object.freeze(['lib']),
|
|
422
|
+
since: '0.3.0',
|
|
423
|
+
stable: false,
|
|
424
|
+
remedy: "Backup operation failed; the live database is unchanged. Check the path/permissions and retry, and keep the diagnostic output.",
|
|
425
|
+
},
|
|
426
|
+
{
|
|
427
|
+
code: 'E_BACKUP_STORE_INVALID',
|
|
428
|
+
category: 'store',
|
|
429
|
+
exit: 1,
|
|
430
|
+
surfaces: Object.freeze(['lib']),
|
|
431
|
+
since: '0.3.0',
|
|
432
|
+
stable: false,
|
|
433
|
+
remedy: "Backup operation failed; the live database is unchanged. Check the path/permissions and retry, and keep the diagnostic output.",
|
|
434
|
+
},
|
|
435
|
+
{
|
|
436
|
+
code: 'E_BACKUP_TAG_INVALID',
|
|
437
|
+
category: 'store',
|
|
438
|
+
exit: 1,
|
|
439
|
+
surfaces: Object.freeze(['lib']),
|
|
440
|
+
since: '0.3.0',
|
|
441
|
+
stable: false,
|
|
442
|
+
remedy: "Backup operation failed; the live database is unchanged. Check the path/permissions and retry, and keep the diagnostic output.",
|
|
443
|
+
},
|
|
444
|
+
{
|
|
445
|
+
code: 'E_BACKUP_TARGET_MISSING',
|
|
446
|
+
category: 'store',
|
|
447
|
+
exit: 1,
|
|
448
|
+
surfaces: Object.freeze(['lib']),
|
|
449
|
+
since: '0.3.0',
|
|
450
|
+
stable: false,
|
|
451
|
+
remedy: "Backup operation failed; the live database is unchanged. Check the path/permissions and retry, and keep the diagnostic output.",
|
|
452
|
+
},
|
|
453
|
+
{
|
|
454
|
+
code: 'E_BACKUP_UNREADABLE',
|
|
455
|
+
category: 'store',
|
|
456
|
+
exit: 1,
|
|
457
|
+
surfaces: Object.freeze(['lib']),
|
|
458
|
+
since: '0.3.0',
|
|
459
|
+
stable: false,
|
|
460
|
+
remedy: "Backup operation failed; the live database is unchanged. Check the path/permissions and retry, and keep the diagnostic output.",
|
|
461
|
+
},
|
|
462
|
+
{
|
|
463
|
+
code: 'E_BACKUP_VERIFY_FAILED',
|
|
464
|
+
category: 'store',
|
|
465
|
+
exit: 1,
|
|
466
|
+
surfaces: Object.freeze(['lib']),
|
|
467
|
+
since: '0.3.0',
|
|
468
|
+
stable: true,
|
|
469
|
+
remedy: "the copied backup did not verify, so it was removed and no backup was installed; the live database is unchanged",
|
|
470
|
+
},
|
|
471
|
+
{
|
|
472
|
+
code: 'E_BRIEF',
|
|
473
|
+
category: 'internal',
|
|
474
|
+
exit: 1,
|
|
475
|
+
surfaces: Object.freeze(['cli']),
|
|
476
|
+
since: '0.2.x',
|
|
477
|
+
stable: false,
|
|
478
|
+
remedy: "The pet-brief command failed unexpectedly. Re-run with --check to see structural errors and report the message if it persists.",
|
|
479
|
+
doc: 'docs/PET-BRIEF-PRODUCER.md',
|
|
480
|
+
},
|
|
481
|
+
{
|
|
482
|
+
code: 'E_CALENDAR_SKIP',
|
|
483
|
+
category: 'state',
|
|
484
|
+
exit: 1,
|
|
485
|
+
surfaces: Object.freeze(['cli']),
|
|
486
|
+
since: '0.2.x',
|
|
487
|
+
stable: false,
|
|
488
|
+
remedy: "A calendar entry was skipped (unsupported TZID or invalid time). It is listed in agenda().degraded[]; the rest of the window is still valid.",
|
|
489
|
+
},
|
|
490
|
+
{
|
|
491
|
+
code: 'E_CONFIDENCE',
|
|
492
|
+
category: 'schema',
|
|
493
|
+
exit: 1,
|
|
494
|
+
surfaces: Object.freeze(['lib']),
|
|
495
|
+
since: '0.2.x',
|
|
496
|
+
stable: true,
|
|
497
|
+
remedy: "Pet Brief confidence must be a number between 0 and 1.",
|
|
498
|
+
doc: 'docs/PET-BRIEF-PRODUCER.md',
|
|
499
|
+
},
|
|
500
|
+
{
|
|
501
|
+
code: 'E_COUNTS',
|
|
502
|
+
category: 'schema',
|
|
503
|
+
exit: 1,
|
|
504
|
+
surfaces: Object.freeze(['lib']),
|
|
505
|
+
since: '0.2.x',
|
|
506
|
+
stable: true,
|
|
507
|
+
remedy: "Pet Brief counts must be integers and match the array lengths.",
|
|
508
|
+
doc: 'docs/PET-BRIEF-PRODUCER.md',
|
|
509
|
+
},
|
|
510
|
+
{
|
|
511
|
+
code: 'E_DB_CORRUPT',
|
|
512
|
+
category: 'store',
|
|
513
|
+
exit: 1,
|
|
514
|
+
surfaces: Object.freeze(['cli', 'lib']),
|
|
515
|
+
since: '0.2.x',
|
|
516
|
+
stable: true,
|
|
517
|
+
remedy: "Back up the database file and restore from a backup; never delete it. Run `advisers doctor --check-db` for a diagnosis.",
|
|
518
|
+
},
|
|
519
|
+
{
|
|
520
|
+
code: 'E_DB_LOCKED',
|
|
521
|
+
category: 'store',
|
|
522
|
+
exit: 1,
|
|
523
|
+
surfaces: Object.freeze(['cli', 'lib']),
|
|
524
|
+
since: '0.2.x',
|
|
525
|
+
stable: true,
|
|
526
|
+
remedy: "Another advisers writer holds the instance lock. Close it or wait and retry; ADVISERS_LOCK_TIMEOUT_MS controls the wait.",
|
|
527
|
+
},
|
|
528
|
+
{
|
|
529
|
+
code: 'E_DISPLAY_POLICY',
|
|
530
|
+
category: 'schema',
|
|
531
|
+
exit: 1,
|
|
532
|
+
surfaces: Object.freeze(['lib']),
|
|
533
|
+
since: '0.2.x',
|
|
534
|
+
stable: true,
|
|
535
|
+
remedy: "Pet Brief requires an explicit displayPolicy (public|private|none) when --strict is used.",
|
|
536
|
+
doc: 'docs/PET-BRIEF-PRODUCER.md',
|
|
537
|
+
},
|
|
538
|
+
{
|
|
539
|
+
code: 'E_DUP_ID',
|
|
540
|
+
category: 'schema',
|
|
541
|
+
exit: 1,
|
|
542
|
+
surfaces: Object.freeze(['lib']),
|
|
543
|
+
since: '0.2.x',
|
|
544
|
+
stable: true,
|
|
545
|
+
remedy: "Pet Brief ids must be unique within each array.",
|
|
546
|
+
doc: 'docs/PET-BRIEF-PRODUCER.md',
|
|
547
|
+
},
|
|
548
|
+
{
|
|
549
|
+
code: 'E_ENUM',
|
|
550
|
+
category: 'schema',
|
|
551
|
+
exit: 1,
|
|
552
|
+
surfaces: Object.freeze(['lib']),
|
|
553
|
+
since: '0.2.x',
|
|
554
|
+
stable: true,
|
|
555
|
+
remedy: "A contract field has a value outside its allowed set; see docs/PET-BRIEF-PRODUCER.md for the allowed values.",
|
|
556
|
+
doc: 'docs/PET-BRIEF-PRODUCER.md',
|
|
557
|
+
},
|
|
558
|
+
{
|
|
559
|
+
code: 'E_EXPIRED',
|
|
560
|
+
category: 'state',
|
|
561
|
+
exit: 1,
|
|
562
|
+
surfaces: Object.freeze(['lib']),
|
|
563
|
+
since: '0.2.x',
|
|
564
|
+
stable: true,
|
|
565
|
+
remedy: "The Pet Brief is older than its expiresAt; regenerate it.",
|
|
566
|
+
doc: 'docs/PET-BRIEF-PRODUCER.md',
|
|
567
|
+
},
|
|
568
|
+
{
|
|
569
|
+
code: 'E_FORBIDDEN_FIELD',
|
|
570
|
+
category: 'schema',
|
|
571
|
+
exit: 1,
|
|
572
|
+
surfaces: Object.freeze(['lib']),
|
|
573
|
+
since: '0.2.x',
|
|
574
|
+
stable: true,
|
|
575
|
+
remedy: "The payload contains a field forbidden by the closed Pet Brief contract; remove it.",
|
|
576
|
+
doc: 'docs/PET-BRIEF-PRODUCER.md',
|
|
577
|
+
},
|
|
578
|
+
{
|
|
579
|
+
code: 'E_FS_PERMISSION',
|
|
580
|
+
category: 'fs',
|
|
581
|
+
exit: 1,
|
|
582
|
+
surfaces: Object.freeze(['lib']),
|
|
583
|
+
since: '0.2.x',
|
|
584
|
+
stable: false,
|
|
585
|
+
remedy: "A file/directory permission was denied. Close any program holding the file (antivirus/OneDrive/sync client) and retry, or pick a writable path.",
|
|
586
|
+
},
|
|
587
|
+
{
|
|
588
|
+
code: 'E_ID',
|
|
589
|
+
category: 'schema',
|
|
590
|
+
exit: 1,
|
|
591
|
+
surfaces: Object.freeze(['lib']),
|
|
592
|
+
since: '0.2.x',
|
|
593
|
+
stable: false,
|
|
594
|
+
remedy: "Pet Brief items must carry a non-empty string id.",
|
|
595
|
+
},
|
|
596
|
+
{
|
|
597
|
+
code: 'E_IO',
|
|
598
|
+
category: 'fs',
|
|
599
|
+
exit: 1,
|
|
600
|
+
surfaces: Object.freeze(['lib']),
|
|
601
|
+
since: '0.2.x',
|
|
602
|
+
stable: false,
|
|
603
|
+
remedy: "The filesystem reported an I/O error; the write was aborted and the temp file removed. Retry on a healthy disk.",
|
|
604
|
+
},
|
|
605
|
+
{
|
|
606
|
+
code: 'E_JSON_IMPURE',
|
|
607
|
+
category: 'internal',
|
|
608
|
+
exit: 1,
|
|
609
|
+
surfaces: Object.freeze(['lib']),
|
|
610
|
+
since: '0.3.0',
|
|
611
|
+
stable: false,
|
|
612
|
+
remedy: "Internal output guard: non-JSON bytes (ANSI/OSC/control characters) were detected on a --json stream. Fix the writer; do not strip bytes at the consumer.",
|
|
613
|
+
},
|
|
614
|
+
{
|
|
615
|
+
code: 'E_JSON_INVALID',
|
|
616
|
+
category: 'schema',
|
|
617
|
+
exit: 1,
|
|
618
|
+
surfaces: Object.freeze(['lib']),
|
|
619
|
+
since: '0.3.0',
|
|
620
|
+
stable: false,
|
|
621
|
+
remedy: "A JSON input file is malformed; fix the file (or regenerate it) before retrying.",
|
|
622
|
+
},
|
|
623
|
+
{
|
|
624
|
+
code: 'E_LEDGER_ABSENT',
|
|
625
|
+
category: 'store',
|
|
626
|
+
exit: 1,
|
|
627
|
+
surfaces: Object.freeze(['lib']),
|
|
628
|
+
since: '0.3.0',
|
|
629
|
+
stable: true,
|
|
630
|
+
remedy: "Run `advisers init` to create the local ledger; the read-only facade never creates it.",
|
|
631
|
+
},
|
|
632
|
+
{
|
|
633
|
+
code: 'E_LEDGER_BUSY',
|
|
634
|
+
category: 'store',
|
|
635
|
+
exit: 1,
|
|
636
|
+
surfaces: Object.freeze(['lib']),
|
|
637
|
+
since: '0.3.0',
|
|
638
|
+
stable: true,
|
|
639
|
+
remedy: "Retry in a moment; a long-running writer may be checkpointing the ledger.",
|
|
640
|
+
},
|
|
641
|
+
{
|
|
642
|
+
code: 'E_LEDGER_CORRUPT',
|
|
643
|
+
category: 'store',
|
|
644
|
+
exit: 1,
|
|
645
|
+
surfaces: Object.freeze(['lib']),
|
|
646
|
+
since: '0.3.0',
|
|
647
|
+
stable: true,
|
|
648
|
+
remedy: "Back up state.db (do not delete it), then run `advisers doctor`; do not rebuild or replace the file.",
|
|
649
|
+
},
|
|
650
|
+
{
|
|
651
|
+
code: 'E_LEDGER_UNAVAILABLE',
|
|
652
|
+
category: 'store',
|
|
653
|
+
exit: 1,
|
|
654
|
+
surfaces: Object.freeze(['lib']),
|
|
655
|
+
since: '0.3.0',
|
|
656
|
+
stable: true,
|
|
657
|
+
remedy: "Use a local writable directory for ADVISERS_HOME and make sure this process may read state.db; network/synced volumes and read-only mounts are not supported.",
|
|
658
|
+
},
|
|
659
|
+
{
|
|
660
|
+
code: 'E_LENGTH',
|
|
661
|
+
category: 'schema',
|
|
662
|
+
exit: 1,
|
|
663
|
+
surfaces: Object.freeze(['lib']),
|
|
664
|
+
since: '0.2.x',
|
|
665
|
+
stable: false,
|
|
666
|
+
remedy: "A contract string field is outside its min/max length; truncate or split it.",
|
|
667
|
+
},
|
|
668
|
+
{
|
|
669
|
+
code: 'E_MALFORMED_JSON',
|
|
670
|
+
category: 'schema',
|
|
671
|
+
exit: 1,
|
|
672
|
+
surfaces: Object.freeze(['lib']),
|
|
673
|
+
since: '0.2.x',
|
|
674
|
+
stable: false,
|
|
675
|
+
remedy: "The input is not valid JSON; fix the payload before validation.",
|
|
676
|
+
},
|
|
677
|
+
{
|
|
678
|
+
code: 'E_MATTER_ARCHIVED',
|
|
679
|
+
category: 'state',
|
|
680
|
+
exit: 1,
|
|
681
|
+
surfaces: Object.freeze(['cli']),
|
|
682
|
+
since: '0.2.x',
|
|
683
|
+
stable: true,
|
|
684
|
+
remedy: "The matter is archived. Re-activate it with the matter commands or choose an active matter.",
|
|
685
|
+
doc: 'docs/CLI-JSON.md',
|
|
686
|
+
},
|
|
687
|
+
{
|
|
688
|
+
code: 'E_MATTER_NOT_FOUND',
|
|
689
|
+
category: 'usage',
|
|
690
|
+
exit: 1,
|
|
691
|
+
surfaces: Object.freeze(['cli']),
|
|
692
|
+
since: '0.2.x',
|
|
693
|
+
stable: true,
|
|
694
|
+
remedy: "Unknown matter id. Run `advisers matter ls` and use an existing id.",
|
|
695
|
+
doc: 'docs/CLI-JSON.md',
|
|
696
|
+
},
|
|
697
|
+
{
|
|
698
|
+
code: 'E_MAX_ITEMS',
|
|
699
|
+
category: 'schema',
|
|
700
|
+
exit: 1,
|
|
701
|
+
surfaces: Object.freeze(['lib']),
|
|
702
|
+
since: '0.2.x',
|
|
703
|
+
stable: true,
|
|
704
|
+
remedy: "A contract array exceeds the item limit; trim it.",
|
|
705
|
+
doc: 'docs/PET-BRIEF-PRODUCER.md',
|
|
706
|
+
},
|
|
707
|
+
{
|
|
708
|
+
code: 'E_MAX_LINES',
|
|
709
|
+
category: 'schema',
|
|
710
|
+
exit: 1,
|
|
711
|
+
surfaces: Object.freeze(['lib']),
|
|
712
|
+
since: '0.2.x',
|
|
713
|
+
stable: false,
|
|
714
|
+
remedy: "Pet Brief suggestedLines exceeds the contract limit; reduce the lines.",
|
|
715
|
+
},
|
|
716
|
+
{
|
|
717
|
+
code: 'E_MIGRATE_BUSY',
|
|
718
|
+
category: 'store',
|
|
719
|
+
exit: 1,
|
|
720
|
+
surfaces: Object.freeze(['cli', 'lib']),
|
|
721
|
+
since: '0.2.x',
|
|
722
|
+
stable: false,
|
|
723
|
+
remedy: "A migration is already running or the database is busy; close other writers and retry.",
|
|
724
|
+
},
|
|
725
|
+
{
|
|
726
|
+
code: 'E_MIGRATION_BACKUP',
|
|
727
|
+
category: 'store',
|
|
728
|
+
exit: 1,
|
|
729
|
+
surfaces: Object.freeze(['cli', 'lib']),
|
|
730
|
+
since: '0.2.x',
|
|
731
|
+
stable: false,
|
|
732
|
+
remedy: "The pre-migration backup failed validation, so the database was not migrated. Keep the backup and run `advisers doctor`.",
|
|
733
|
+
},
|
|
734
|
+
{
|
|
735
|
+
code: 'E_NO_SPACE',
|
|
736
|
+
category: 'fs',
|
|
737
|
+
exit: 1,
|
|
738
|
+
surfaces: Object.freeze(['lib']),
|
|
739
|
+
since: '0.2.x',
|
|
740
|
+
stable: true,
|
|
741
|
+
remedy: "Not enough disk space. Free space and retry; the temp file was removed and no truncated file was installed.",
|
|
742
|
+
doc: 'docs/FAULT-INJECTION.md',
|
|
743
|
+
},
|
|
744
|
+
{
|
|
745
|
+
code: 'E_READ',
|
|
746
|
+
category: 'fs',
|
|
747
|
+
exit: 1,
|
|
748
|
+
surfaces: Object.freeze(['cli']),
|
|
749
|
+
since: '0.2.x',
|
|
750
|
+
stable: false,
|
|
751
|
+
remedy: "Cannot read the input file; check the path and permissions.",
|
|
752
|
+
},
|
|
753
|
+
{
|
|
754
|
+
code: 'E_READ_ONLY',
|
|
755
|
+
category: 'internal',
|
|
756
|
+
exit: 1,
|
|
757
|
+
surfaces: Object.freeze(['cli', 'lib']),
|
|
758
|
+
since: '0.2.x',
|
|
759
|
+
stable: false,
|
|
760
|
+
remedy: "Internal guard: a write was attempted on a read-only store. Open a writable store instead of bypassing it.",
|
|
761
|
+
},
|
|
762
|
+
{
|
|
763
|
+
code: 'E_RECEIPT_LIMIT',
|
|
764
|
+
category: 'verify',
|
|
765
|
+
exit: 1,
|
|
766
|
+
surfaces: Object.freeze(['lib']),
|
|
767
|
+
since: '0.3.0',
|
|
768
|
+
stable: true,
|
|
769
|
+
remedy: "The receipt/evidence pack exceeds a verification resource limit (entries, depth, file size or total bytes); ask the sender for a normal pack or verify it manually — the pack was not trusted.",
|
|
770
|
+
},
|
|
771
|
+
{
|
|
772
|
+
code: 'E_RESTORE_BUSY',
|
|
773
|
+
category: 'store',
|
|
774
|
+
exit: 1,
|
|
775
|
+
surfaces: Object.freeze(['lib']),
|
|
776
|
+
since: '0.3.0',
|
|
777
|
+
stable: true,
|
|
778
|
+
remedy: "another connection blocked the pre-restore checkpoint; close other advisers processes and retry",
|
|
779
|
+
},
|
|
780
|
+
{
|
|
781
|
+
code: 'E_RESTORE_CHECKPOINT_FAILED',
|
|
782
|
+
category: 'store',
|
|
783
|
+
exit: 1,
|
|
784
|
+
surfaces: Object.freeze(['lib']),
|
|
785
|
+
since: '0.3.0',
|
|
786
|
+
stable: false,
|
|
787
|
+
remedy: "Restore operation failed; follow the documented recovery path and keep the pre-restore safety backup.",
|
|
788
|
+
},
|
|
789
|
+
{
|
|
790
|
+
code: 'E_RESTORE_CLOSE_FAILED',
|
|
791
|
+
category: 'store',
|
|
792
|
+
exit: 1,
|
|
793
|
+
surfaces: Object.freeze(['lib']),
|
|
794
|
+
since: '0.3.0',
|
|
795
|
+
stable: false,
|
|
796
|
+
remedy: "Restore operation failed; follow the documented recovery path and keep the pre-restore safety backup.",
|
|
797
|
+
},
|
|
798
|
+
{
|
|
799
|
+
code: 'E_RESTORE_COPY_FAILED',
|
|
800
|
+
category: 'store',
|
|
801
|
+
exit: 1,
|
|
802
|
+
surfaces: Object.freeze(['lib']),
|
|
803
|
+
since: '0.3.0',
|
|
804
|
+
stable: false,
|
|
805
|
+
remedy: "Restore operation failed; follow the documented recovery path and keep the pre-restore safety backup.",
|
|
806
|
+
},
|
|
807
|
+
{
|
|
808
|
+
code: 'E_RESTORE_INSTALL_FAILED',
|
|
809
|
+
category: 'store',
|
|
810
|
+
exit: 1,
|
|
811
|
+
surfaces: Object.freeze(['lib']),
|
|
812
|
+
since: '0.3.0',
|
|
813
|
+
stable: true,
|
|
814
|
+
remedy: "the atomic install failed, so the live database is unchanged; retry after closing programs that hold the file (antivirus/OneDrive)",
|
|
815
|
+
},
|
|
816
|
+
{
|
|
817
|
+
code: 'E_RESTORE_PRERESTORE_FAILED',
|
|
818
|
+
category: 'store',
|
|
819
|
+
exit: 1,
|
|
820
|
+
surfaces: Object.freeze(['lib']),
|
|
821
|
+
since: '0.3.0',
|
|
822
|
+
stable: true,
|
|
823
|
+
remedy: "the pre-restore safety backup failed, so nothing was replaced; free disk space/permissions and retry",
|
|
824
|
+
},
|
|
825
|
+
{
|
|
826
|
+
code: 'E_RESTORE_ROLLBACK_FAILED',
|
|
827
|
+
category: 'store',
|
|
828
|
+
exit: 1,
|
|
829
|
+
surfaces: Object.freeze(['lib']),
|
|
830
|
+
since: '0.3.0',
|
|
831
|
+
stable: true,
|
|
832
|
+
remedy: "the installed database did not verify AND rollback failed: stop, keep the pre-restore backup, and recover manually",
|
|
833
|
+
},
|
|
834
|
+
{
|
|
835
|
+
code: 'E_RESTORE_TARGET_MISSING',
|
|
836
|
+
category: 'store',
|
|
837
|
+
exit: 1,
|
|
838
|
+
surfaces: Object.freeze(['lib']),
|
|
839
|
+
since: '0.3.0',
|
|
840
|
+
stable: false,
|
|
841
|
+
remedy: "Restore operation failed; follow the documented recovery path and keep the pre-restore safety backup.",
|
|
842
|
+
},
|
|
843
|
+
{
|
|
844
|
+
code: 'E_RESTORE_TARGET_UNSAFE',
|
|
845
|
+
category: 'store',
|
|
846
|
+
exit: 1,
|
|
847
|
+
surfaces: Object.freeze(['lib']),
|
|
848
|
+
since: '0.3.0',
|
|
849
|
+
stable: true,
|
|
850
|
+
remedy: "the restore target path is not a regular .db path; refusing to replace it",
|
|
851
|
+
},
|
|
852
|
+
{
|
|
853
|
+
code: 'E_RESTORE_VERIFY_FAILED',
|
|
854
|
+
category: 'store',
|
|
855
|
+
exit: 1,
|
|
856
|
+
surfaces: Object.freeze(['lib']),
|
|
857
|
+
since: '0.3.0',
|
|
858
|
+
stable: true,
|
|
859
|
+
remedy: "the installed database did not verify; the pre-restore backup was used to roll back",
|
|
860
|
+
},
|
|
861
|
+
{
|
|
862
|
+
code: 'E_RESTORE_WAL_OPEN',
|
|
863
|
+
category: 'store',
|
|
864
|
+
exit: 1,
|
|
865
|
+
surfaces: Object.freeze(['lib']),
|
|
866
|
+
since: '0.3.0',
|
|
867
|
+
stable: true,
|
|
868
|
+
remedy: "the database still has a non-empty WAL; checkpoint and close every connection before restoring",
|
|
869
|
+
},
|
|
870
|
+
{
|
|
871
|
+
code: 'E_SCHEMA_NEWER',
|
|
872
|
+
category: 'schema',
|
|
873
|
+
exit: 1,
|
|
874
|
+
surfaces: Object.freeze(['cli', 'lib']),
|
|
875
|
+
since: '0.2.x',
|
|
876
|
+
stable: true,
|
|
877
|
+
remedy: "The database was written by a newer advisers version. Upgrade the package; do not downgrade the schema.",
|
|
878
|
+
doc: 'docs/ARCHITECTURE.md',
|
|
879
|
+
},
|
|
880
|
+
{
|
|
881
|
+
code: 'E_SCHEMA_STALE',
|
|
882
|
+
category: 'schema',
|
|
883
|
+
exit: 1,
|
|
884
|
+
surfaces: Object.freeze(['cli', 'lib']),
|
|
885
|
+
since: '0.2.x',
|
|
886
|
+
stable: true,
|
|
887
|
+
remedy: "The database is older than this CLI. Run a writable command (for example `advisers doctor`) to migrate it, or retry if another process is upgrading it.",
|
|
888
|
+
doc: 'docs/ARCHITECTURE.md',
|
|
889
|
+
},
|
|
890
|
+
{
|
|
891
|
+
code: 'E_SCHEMA_VERSION',
|
|
892
|
+
category: 'schema',
|
|
893
|
+
exit: 1,
|
|
894
|
+
surfaces: Object.freeze(['lib']),
|
|
895
|
+
since: '0.2.x',
|
|
896
|
+
stable: true,
|
|
897
|
+
remedy: "Pet Brief schemaVersion is unsupported; use schemaVersion 2 (or explicitly allow the v0.1 legacy when supported).",
|
|
898
|
+
doc: 'docs/PET-BRIEF-PRODUCER.md',
|
|
899
|
+
},
|
|
900
|
+
{
|
|
901
|
+
code: 'E_SECRECY_BLOCKED',
|
|
902
|
+
category: 'policy',
|
|
903
|
+
exit: 1,
|
|
904
|
+
surfaces: Object.freeze(['cli', 'lib']),
|
|
905
|
+
since: '0.2.x',
|
|
906
|
+
stable: true,
|
|
907
|
+
remedy: "Some selected evidence belongs to protected matters. Remove those ids or lower the matter secrecy locally; packs exclude protected matters by default.",
|
|
908
|
+
},
|
|
909
|
+
{
|
|
910
|
+
code: 'E_SHORT_WRITE',
|
|
911
|
+
category: 'internal',
|
|
912
|
+
exit: 1,
|
|
913
|
+
surfaces: Object.freeze(['lib']),
|
|
914
|
+
since: '0.2.x',
|
|
915
|
+
stable: false,
|
|
916
|
+
remedy: "Internal guard: a short write was detected and rejected. Retry on a healthy disk; never accept a truncated file.",
|
|
917
|
+
},
|
|
918
|
+
{
|
|
919
|
+
code: 'E_SOURCE',
|
|
920
|
+
category: 'schema',
|
|
921
|
+
exit: 1,
|
|
922
|
+
surfaces: Object.freeze(['lib']),
|
|
923
|
+
since: '0.2.x',
|
|
924
|
+
stable: false,
|
|
925
|
+
remedy: "Pet Brief field \"source\" must be \"advisers\".",
|
|
926
|
+
},
|
|
927
|
+
{
|
|
928
|
+
code: 'E_STORE',
|
|
929
|
+
category: 'store',
|
|
930
|
+
exit: 1,
|
|
931
|
+
surfaces: Object.freeze(['cli', 'lib']),
|
|
932
|
+
since: '0.2.x',
|
|
933
|
+
stable: true,
|
|
934
|
+
remedy: "The ledger store is missing or unreadable. Run `advisers init` or point ADVISERS_HOME at the right home.",
|
|
935
|
+
doc: 'docs/PET-BRIEF-PRODUCER.md',
|
|
936
|
+
},
|
|
937
|
+
{
|
|
938
|
+
code: 'E_TEMPLATE_INVALID',
|
|
939
|
+
category: 'template',
|
|
940
|
+
exit: 1,
|
|
941
|
+
surfaces: Object.freeze(['cli']),
|
|
942
|
+
since: '0.2.x',
|
|
943
|
+
stable: true,
|
|
944
|
+
remedy: "The template data is invalid; fix the field named in error.details.path and retry.",
|
|
945
|
+
doc: 'docs/CLI-JSON.md',
|
|
946
|
+
},
|
|
947
|
+
{
|
|
948
|
+
code: 'E_TEMPLATE_OUTPUT',
|
|
949
|
+
category: 'template',
|
|
950
|
+
exit: 1,
|
|
951
|
+
surfaces: Object.freeze(['cli']),
|
|
952
|
+
since: '0.2.x',
|
|
953
|
+
stable: true,
|
|
954
|
+
remedy: "Could not write the generated document; check the output path and disk.",
|
|
955
|
+
doc: 'docs/CLI-JSON.md',
|
|
956
|
+
},
|
|
957
|
+
{
|
|
958
|
+
code: 'E_TEMPLATE_UNKNOWN',
|
|
959
|
+
category: 'usage',
|
|
960
|
+
exit: 1,
|
|
961
|
+
surfaces: Object.freeze(['cli']),
|
|
962
|
+
since: '0.2.x',
|
|
963
|
+
stable: false,
|
|
964
|
+
remedy: "Unknown template. Use `quote` or `proposal`.",
|
|
965
|
+
},
|
|
966
|
+
{
|
|
967
|
+
code: 'E_TIME_FORMAT',
|
|
968
|
+
category: 'schema',
|
|
969
|
+
exit: 1,
|
|
970
|
+
surfaces: Object.freeze(['lib']),
|
|
971
|
+
since: '0.2.x',
|
|
972
|
+
stable: true,
|
|
973
|
+
remedy: "A contract timestamp must be ISO 8601 with a timezone.",
|
|
974
|
+
doc: 'docs/PET-BRIEF-PRODUCER.md',
|
|
975
|
+
},
|
|
976
|
+
{
|
|
977
|
+
code: 'E_TIME_INVALID',
|
|
978
|
+
category: 'state',
|
|
979
|
+
exit: 1,
|
|
980
|
+
surfaces: Object.freeze(['cli']),
|
|
981
|
+
since: '0.2.x',
|
|
982
|
+
stable: false,
|
|
983
|
+
remedy: "A commitment dueAt could not be parsed; it is reported in degraded[] and left unchanged. Fix the date on the commitment.",
|
|
984
|
+
},
|
|
985
|
+
{
|
|
986
|
+
code: 'E_TIME_ORDER',
|
|
987
|
+
category: 'schema',
|
|
988
|
+
exit: 1,
|
|
989
|
+
surfaces: Object.freeze(['lib']),
|
|
990
|
+
since: '0.2.x',
|
|
991
|
+
stable: true,
|
|
992
|
+
remedy: "Pet Brief expiresAt must be after generatedAt.",
|
|
993
|
+
doc: 'docs/PET-BRIEF-PRODUCER.md',
|
|
994
|
+
},
|
|
995
|
+
{
|
|
996
|
+
code: 'E_TOS_REQUIRED',
|
|
997
|
+
category: 'tos',
|
|
998
|
+
exit: 3,
|
|
999
|
+
surfaces: Object.freeze(['cli']),
|
|
1000
|
+
since: '0.2.x',
|
|
1001
|
+
stable: true,
|
|
1002
|
+
remedy: "Accept the current Terms with `advisers tos accept` (TTY), or pass --accept-tos / set ADVISERS_ACCEPT_TOS=1 for non-interactive use.",
|
|
1003
|
+
doc: 'docs/QUICKSTART.md',
|
|
1004
|
+
},
|
|
1005
|
+
{
|
|
1006
|
+
code: 'E_TX_REQUIRED',
|
|
1007
|
+
category: 'internal',
|
|
1008
|
+
exit: 1,
|
|
1009
|
+
surfaces: Object.freeze(['cli', 'lib']),
|
|
1010
|
+
since: '0.2.x',
|
|
1011
|
+
stable: false,
|
|
1012
|
+
remedy: "Internal guard: a ledger write escaped its transaction. Do not bypass it; this indicates a programming error.",
|
|
1013
|
+
},
|
|
1014
|
+
{
|
|
1015
|
+
code: 'E_TYPE',
|
|
1016
|
+
category: 'schema',
|
|
1017
|
+
exit: 1,
|
|
1018
|
+
surfaces: Object.freeze(['lib']),
|
|
1019
|
+
since: '0.2.x',
|
|
1020
|
+
stable: false,
|
|
1021
|
+
remedy: "A contract value has the wrong JSON type; see docs/PET-BRIEF-PRODUCER.md.",
|
|
1022
|
+
},
|
|
1023
|
+
{
|
|
1024
|
+
code: 'E_UNKNOWN',
|
|
1025
|
+
category: 'internal',
|
|
1026
|
+
exit: 1,
|
|
1027
|
+
surfaces: Object.freeze(['lib']),
|
|
1028
|
+
since: '0.3.0',
|
|
1029
|
+
stable: false,
|
|
1030
|
+
remedy: "An error was reported without a specific code. Read the message; this is a fallback label, not a stable contract.",
|
|
1031
|
+
},
|
|
1032
|
+
{
|
|
1033
|
+
code: 'E_UNKNOWN_FIELD',
|
|
1034
|
+
category: 'schema',
|
|
1035
|
+
exit: 1,
|
|
1036
|
+
surfaces: Object.freeze(['lib']),
|
|
1037
|
+
since: '0.2.x',
|
|
1038
|
+
stable: true,
|
|
1039
|
+
remedy: "The payload carries a field outside the closed Pet Brief contract; consumers must upgrade before the producer adds fields.",
|
|
1040
|
+
doc: 'docs/PET-BRIEF-PRODUCER.md',
|
|
1041
|
+
},
|
|
1042
|
+
{
|
|
1043
|
+
code: 'E_USAGE',
|
|
1044
|
+
category: 'usage',
|
|
1045
|
+
exit: 1,
|
|
1046
|
+
surfaces: Object.freeze(['cli']),
|
|
1047
|
+
since: '0.2.x',
|
|
1048
|
+
stable: true,
|
|
1049
|
+
remedy: "Invalid arguments. Run the command with --help for usage.",
|
|
1050
|
+
doc: 'docs/CLI-JSON.md',
|
|
1051
|
+
},
|
|
1052
|
+
{
|
|
1053
|
+
code: 'E_VAULT_SEALED',
|
|
1054
|
+
category: 'store',
|
|
1055
|
+
exit: 1,
|
|
1056
|
+
surfaces: Object.freeze(['cli']),
|
|
1057
|
+
since: '0.2.x',
|
|
1058
|
+
stable: true,
|
|
1059
|
+
remedy: "The database is sealed. Unseal it with `advisers vault unseal` (or use the sealed-home workflow) before running ledger commands.",
|
|
1060
|
+
},
|
|
1061
|
+
{
|
|
1062
|
+
code: 'E_VERIFY_FAILED',
|
|
1063
|
+
category: 'verify',
|
|
1064
|
+
exit: 1,
|
|
1065
|
+
surfaces: Object.freeze(['cli']),
|
|
1066
|
+
since: '0.2.x',
|
|
1067
|
+
stable: false,
|
|
1068
|
+
remedy: "Verification failed; inspect the failed check ids/detail in the JSON output and fix the input.",
|
|
1069
|
+
},
|
|
1070
|
+
{
|
|
1071
|
+
code: 'E_WAL_CORRUPT',
|
|
1072
|
+
category: 'store',
|
|
1073
|
+
exit: 1,
|
|
1074
|
+
surfaces: Object.freeze(['lib']),
|
|
1075
|
+
since: '0.2.x',
|
|
1076
|
+
stable: true,
|
|
1077
|
+
remedy: "SQLite could not use the WAL file and left it untouched. Run `advisers doctor --check-db`; transactions after the last checkpoint may be lost.",
|
|
1078
|
+
doc: 'docs/ARCHITECTURE.md',
|
|
1079
|
+
},
|
|
1080
|
+
{
|
|
1081
|
+
code: 'E_WAL_TRUNCATED',
|
|
1082
|
+
category: 'store',
|
|
1083
|
+
exit: 1,
|
|
1084
|
+
surfaces: Object.freeze(['lib']),
|
|
1085
|
+
since: '0.2.x',
|
|
1086
|
+
stable: false,
|
|
1087
|
+
remedy: "The WAL ends with a torn frame. SQLite recovered the valid prefix; the most recent transactions may be lost. Take a backup.",
|
|
1088
|
+
doc: 'docs/ARCHITECTURE.md',
|
|
1089
|
+
},
|
|
1090
|
+
{
|
|
1091
|
+
code: 'E_WAL_UNREADABLE',
|
|
1092
|
+
category: 'store',
|
|
1093
|
+
exit: 1,
|
|
1094
|
+
surfaces: Object.freeze(['lib']),
|
|
1095
|
+
since: '0.2.x',
|
|
1096
|
+
stable: false,
|
|
1097
|
+
remedy: "Could not inspect the WAL file. Close other processes using the database and retry.",
|
|
1098
|
+
},
|
|
1099
|
+
{
|
|
1100
|
+
code: 'E_WRITE',
|
|
1101
|
+
category: 'fs',
|
|
1102
|
+
exit: 1,
|
|
1103
|
+
surfaces: Object.freeze(['cli']),
|
|
1104
|
+
since: '0.2.x',
|
|
1105
|
+
stable: true,
|
|
1106
|
+
remedy: "Could not write the output file; check the path, permissions and disk.",
|
|
1107
|
+
doc: 'docs/PET-BRIEF-PRODUCER.md',
|
|
1108
|
+
},
|
|
1109
|
+
{
|
|
1110
|
+
code: 'E_CLIENT_ALIAS_CONFLICT',
|
|
1111
|
+
category: 'state',
|
|
1112
|
+
exit: 1,
|
|
1113
|
+
surfaces: Object.freeze(['cli', 'lib']),
|
|
1114
|
+
since: '0.3.0',
|
|
1115
|
+
stable: true,
|
|
1116
|
+
remedy: "Client alias already belongs to another client; choose a unique alias or merge the clients.",
|
|
1117
|
+
doc: 'docs/CLIENTS.md',
|
|
1118
|
+
},
|
|
1119
|
+
{
|
|
1120
|
+
code: 'E_CLIENT_ALIAS_NOT_FOUND',
|
|
1121
|
+
category: 'state',
|
|
1122
|
+
exit: 1,
|
|
1123
|
+
surfaces: Object.freeze(['cli', 'lib']),
|
|
1124
|
+
since: '0.3.0',
|
|
1125
|
+
stable: true,
|
|
1126
|
+
remedy: "The requested client alias does not exist; run `advisers client show <id>` to inspect aliases.",
|
|
1127
|
+
doc: 'docs/CLIENTS.md',
|
|
1128
|
+
},
|
|
1129
|
+
{
|
|
1130
|
+
code: 'E_CLIENT_ARCHIVED',
|
|
1131
|
+
category: 'state',
|
|
1132
|
+
exit: 1,
|
|
1133
|
+
surfaces: Object.freeze(['cli', 'lib']),
|
|
1134
|
+
since: '0.3.0',
|
|
1135
|
+
stable: true,
|
|
1136
|
+
remedy: "The client is archived; restore it first or choose an active client.",
|
|
1137
|
+
doc: 'docs/CLIENTS.md',
|
|
1138
|
+
},
|
|
1139
|
+
{
|
|
1140
|
+
code: 'E_CLIENT_DUPLICATE',
|
|
1141
|
+
category: 'state',
|
|
1142
|
+
exit: 1,
|
|
1143
|
+
surfaces: Object.freeze(['cli', 'lib']),
|
|
1144
|
+
since: '0.3.0',
|
|
1145
|
+
stable: true,
|
|
1146
|
+
remedy: "An active client with the same normalized name exists; use `client show` or merge explicitly.",
|
|
1147
|
+
doc: 'docs/CLIENTS.md',
|
|
1148
|
+
},
|
|
1149
|
+
{
|
|
1150
|
+
code: 'E_CLIENT_HAS_ACTIVE_PROJECTS',
|
|
1151
|
+
category: 'state',
|
|
1152
|
+
exit: 1,
|
|
1153
|
+
surfaces: Object.freeze(['cli', 'lib']),
|
|
1154
|
+
since: '0.3.0',
|
|
1155
|
+
stable: true,
|
|
1156
|
+
remedy: "The client still has active projects; archive/close them first (or use --dry-run to list them).",
|
|
1157
|
+
doc: 'docs/CLIENTS.md',
|
|
1158
|
+
},
|
|
1159
|
+
{
|
|
1160
|
+
code: 'E_CLIENT_INVALID',
|
|
1161
|
+
category: 'usage',
|
|
1162
|
+
exit: 1,
|
|
1163
|
+
surfaces: Object.freeze(['cli', 'lib']),
|
|
1164
|
+
since: '0.3.0',
|
|
1165
|
+
stable: true,
|
|
1166
|
+
remedy: "Invalid client fields; check --name, --alias, --secrecy and --note.",
|
|
1167
|
+
doc: 'docs/CLIENTS.md',
|
|
1168
|
+
},
|
|
1169
|
+
{
|
|
1170
|
+
code: 'E_CLIENT_MERGE_SELF',
|
|
1171
|
+
category: 'usage',
|
|
1172
|
+
exit: 1,
|
|
1173
|
+
surfaces: Object.freeze(['cli', 'lib']),
|
|
1174
|
+
since: '0.3.0',
|
|
1175
|
+
stable: true,
|
|
1176
|
+
remedy: "Cannot merge a client into itself; pass a different source/target id.",
|
|
1177
|
+
doc: 'docs/CLIENTS.md',
|
|
1178
|
+
},
|
|
1179
|
+
{
|
|
1180
|
+
code: 'E_CLIENT_NOTE_INVALID',
|
|
1181
|
+
category: 'usage',
|
|
1182
|
+
exit: 1,
|
|
1183
|
+
surfaces: Object.freeze(['cli', 'lib']),
|
|
1184
|
+
since: '0.3.0',
|
|
1185
|
+
stable: true,
|
|
1186
|
+
remedy: "Invalid client note; check --summary, --kind and the optional project/matter ids.",
|
|
1187
|
+
doc: 'docs/CLIENTS.md',
|
|
1188
|
+
},
|
|
1189
|
+
{
|
|
1190
|
+
code: 'E_CLIENT_NOTE_NOT_FOUND',
|
|
1191
|
+
category: 'state',
|
|
1192
|
+
exit: 1,
|
|
1193
|
+
surfaces: Object.freeze(['cli', 'lib']),
|
|
1194
|
+
since: '0.3.0',
|
|
1195
|
+
stable: true,
|
|
1196
|
+
remedy: "The client note id does not exist or was deleted.",
|
|
1197
|
+
doc: 'docs/CLIENTS.md',
|
|
1198
|
+
},
|
|
1199
|
+
{
|
|
1200
|
+
code: 'E_CLIENT_NOT_FOUND',
|
|
1201
|
+
category: 'state',
|
|
1202
|
+
exit: 1,
|
|
1203
|
+
surfaces: Object.freeze(['cli', 'lib']),
|
|
1204
|
+
since: '0.3.0',
|
|
1205
|
+
stable: true,
|
|
1206
|
+
remedy: "The client id does not exist; use `advisers client list`.",
|
|
1207
|
+
doc: 'docs/CLIENTS.md',
|
|
1208
|
+
},
|
|
1209
|
+
{
|
|
1210
|
+
code: 'E_DELIVERY_INVALID',
|
|
1211
|
+
category: 'usage',
|
|
1212
|
+
exit: 1,
|
|
1213
|
+
surfaces: Object.freeze(['cli', 'lib']),
|
|
1214
|
+
since: '0.3.0',
|
|
1215
|
+
stable: true,
|
|
1216
|
+
remedy: "Invalid delivery lineage or template metadata; check the client/project and template fields.",
|
|
1217
|
+
doc: 'docs/CLIENTS.md',
|
|
1218
|
+
},
|
|
1219
|
+
{
|
|
1220
|
+
code: 'E_MATTER_CLIENT_MISMATCH',
|
|
1221
|
+
category: 'usage',
|
|
1222
|
+
exit: 1,
|
|
1223
|
+
surfaces: Object.freeze(['cli', 'lib']),
|
|
1224
|
+
since: '0.3.0',
|
|
1225
|
+
stable: true,
|
|
1226
|
+
remedy: "The matter belongs to a different client; pick a matter owned by the target client.",
|
|
1227
|
+
doc: 'docs/CLIENTS.md',
|
|
1228
|
+
},
|
|
1229
|
+
{
|
|
1230
|
+
code: 'E_PROJECT_ARCHIVED',
|
|
1231
|
+
category: 'state',
|
|
1232
|
+
exit: 1,
|
|
1233
|
+
surfaces: Object.freeze(['cli', 'lib']),
|
|
1234
|
+
since: '0.3.0',
|
|
1235
|
+
stable: true,
|
|
1236
|
+
remedy: "The project is archived; restore it or choose an active project.",
|
|
1237
|
+
doc: 'docs/CLIENTS.md',
|
|
1238
|
+
},
|
|
1239
|
+
{
|
|
1240
|
+
code: 'E_PROJECT_CLIENT_MISMATCH',
|
|
1241
|
+
category: 'usage',
|
|
1242
|
+
exit: 1,
|
|
1243
|
+
surfaces: Object.freeze(['cli', 'lib']),
|
|
1244
|
+
since: '0.3.0',
|
|
1245
|
+
stable: true,
|
|
1246
|
+
remedy: "The project belongs to a different client; use the project's client.",
|
|
1247
|
+
doc: 'docs/CLIENTS.md',
|
|
1248
|
+
},
|
|
1249
|
+
{
|
|
1250
|
+
code: 'E_PROJECT_DUPLICATE',
|
|
1251
|
+
category: 'state',
|
|
1252
|
+
exit: 1,
|
|
1253
|
+
surfaces: Object.freeze(['cli', 'lib']),
|
|
1254
|
+
since: '0.3.0',
|
|
1255
|
+
stable: true,
|
|
1256
|
+
remedy: "An active project with the same normalized name exists for this client.",
|
|
1257
|
+
doc: 'docs/CLIENTS.md',
|
|
1258
|
+
},
|
|
1259
|
+
{
|
|
1260
|
+
code: 'E_PROJECT_INVALID',
|
|
1261
|
+
category: 'usage',
|
|
1262
|
+
exit: 1,
|
|
1263
|
+
surfaces: Object.freeze(['cli', 'lib']),
|
|
1264
|
+
since: '0.3.0',
|
|
1265
|
+
stable: true,
|
|
1266
|
+
remedy: "Invalid project fields; check --name, --client and dates.",
|
|
1267
|
+
doc: 'docs/CLIENTS.md',
|
|
1268
|
+
},
|
|
1269
|
+
{
|
|
1270
|
+
code: 'E_PROJECT_NOT_FOUND',
|
|
1271
|
+
category: 'state',
|
|
1272
|
+
exit: 1,
|
|
1273
|
+
surfaces: Object.freeze(['cli', 'lib']),
|
|
1274
|
+
since: '0.3.0',
|
|
1275
|
+
stable: true,
|
|
1276
|
+
remedy: "The project id does not exist; use `advisers project list`.",
|
|
1277
|
+
doc: 'docs/CLIENTS.md',
|
|
1278
|
+
},
|
|
1279
|
+
]
|
|
1280
|
+
|
|
1281
|
+
/** code -> frozen entry (alphabetical insertion order). */
|
|
1282
|
+
export const ERROR_CODES = Object.freeze(Object.fromEntries(
|
|
1283
|
+
REGISTRY.map((entry) => [entry.code, Object.freeze({ ...entry })]),
|
|
1284
|
+
))
|
|
1285
|
+
|
|
1286
|
+
/** Sorted code list (stable snapshot for docs/tests). */
|
|
1287
|
+
export const ERROR_CODE_LIST = Object.freeze(Object.keys(ERROR_CODES).sort())
|
|
1288
|
+
|
|
1289
|
+
/**
|
|
1290
|
+
* DSH adapter error codes. They are part of the DSH tool contract and are kept
|
|
1291
|
+
* verbatim (additive-only); 0.3.0 does not rename them.
|
|
1292
|
+
*/
|
|
1293
|
+
const DSH_REGISTRY = [
|
|
1294
|
+
{
|
|
1295
|
+
code: 'INVALID_ARGUMENT',
|
|
1296
|
+
category: 'usage',
|
|
1297
|
+
exit: 1,
|
|
1298
|
+
surfaces: Object.freeze(['dsh']),
|
|
1299
|
+
since: '0.2.x',
|
|
1300
|
+
stable: true,
|
|
1301
|
+
remedy: "Pass every required argument with the documented type; see the tool description in the DSH bundle.",
|
|
1302
|
+
source: 'packages/dsh-advisers/index.js',
|
|
1303
|
+
},
|
|
1304
|
+
{
|
|
1305
|
+
code: 'UNKNOWN_ID_PREFIX',
|
|
1306
|
+
category: 'usage',
|
|
1307
|
+
exit: 1,
|
|
1308
|
+
surfaces: Object.freeze(['dsh']),
|
|
1309
|
+
since: '0.2.x',
|
|
1310
|
+
stable: true,
|
|
1311
|
+
remedy: "Ids must start with cm_ (commitment), fact_ (fact) or pref_ (preference).",
|
|
1312
|
+
source: 'packages/dsh-advisers/index.js',
|
|
1313
|
+
},
|
|
1314
|
+
{
|
|
1315
|
+
code: 'EVIDENCE_NOT_FOUND',
|
|
1316
|
+
category: 'evidence',
|
|
1317
|
+
exit: 1,
|
|
1318
|
+
surfaces: Object.freeze(['dsh']),
|
|
1319
|
+
since: '0.2.x',
|
|
1320
|
+
stable: true,
|
|
1321
|
+
remedy: "No record matched in the preview ledger. Use the CLI (`advisers evidence show <id> --json`) for real-ledger evidence in 0.3.0.",
|
|
1322
|
+
source: 'packages/dsh-advisers/index.js',
|
|
1323
|
+
},
|
|
1324
|
+
{
|
|
1325
|
+
code: 'INTERNAL_ERROR',
|
|
1326
|
+
category: 'internal',
|
|
1327
|
+
exit: 1,
|
|
1328
|
+
surfaces: Object.freeze(['dsh']),
|
|
1329
|
+
since: '0.2.x',
|
|
1330
|
+
stable: true,
|
|
1331
|
+
remedy: "Unexpected adapter failure; retry once and report the message without customer data.",
|
|
1332
|
+
source: 'packages/dsh-advisers/index.js',
|
|
1333
|
+
},
|
|
1334
|
+
{
|
|
1335
|
+
code: 'CONTENT_BLOCKED',
|
|
1336
|
+
category: 'content',
|
|
1337
|
+
exit: 1,
|
|
1338
|
+
surfaces: Object.freeze(['dsh']),
|
|
1339
|
+
since: '0.2.x',
|
|
1340
|
+
stable: true,
|
|
1341
|
+
remedy: "The local content-safety layer blocked the call. Do not retry the same content; review it first.",
|
|
1342
|
+
source: 'packages/dsh-advisers/index.js',
|
|
1343
|
+
},
|
|
1344
|
+
]
|
|
1345
|
+
|
|
1346
|
+
export const DSH_ERROR_CODES = Object.freeze(Object.fromEntries(
|
|
1347
|
+
DSH_REGISTRY.map((entry) => [entry.code, Object.freeze({ ...entry })]),
|
|
1348
|
+
))
|
|
1349
|
+
|
|
1350
|
+
/** Exit code for a registered code; 1 (generic user/config/runtime error) otherwise. */
|
|
1351
|
+
export function exitCodeFor(code) {
|
|
1352
|
+
return ERROR_CODES[code]?.exit ?? 1
|
|
1353
|
+
}
|
|
1354
|
+
|
|
1355
|
+
/** True when the code is registered (CLI vocabulary or DSH external vocabulary). */
|
|
1356
|
+
export function isKnownErrorCode(code) {
|
|
1357
|
+
return typeof code === 'string' && (Object.hasOwn(ERROR_CODES, code) || Object.hasOwn(DSH_ERROR_CODES, code))
|
|
1358
|
+
}
|
|
1359
|
+
|
|
1360
|
+
/**
|
|
1361
|
+
* Build the v1 CLI error envelope `{error:{code,message,hint?,details?}}`.
|
|
1362
|
+
* Pure helper: it never writes and never sets an exit code by itself.
|
|
1363
|
+
* @param {string} code
|
|
1364
|
+
* @param {string} message
|
|
1365
|
+
* @param {{hint?: string, details?: object}} [extra]
|
|
1366
|
+
* @returns {{error: {code: string, message: string, hint?: string, details?: object}}}
|
|
1367
|
+
*/
|
|
1368
|
+
export function errorEnvelope(code, message, extra = {}) {
|
|
1369
|
+
const error = { code: String(code), message: String(message) }
|
|
1370
|
+
if (extra && typeof extra.hint === 'string' && extra.hint) error.hint = extra.hint
|
|
1371
|
+
if (extra && extra.details && typeof extra.details === 'object') error.details = extra.details
|
|
1372
|
+
return { error }
|
|
1373
|
+
}
|