advisers 0.3.2 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/README-zh.md +13 -14
  2. package/README.md +32 -23
  3. package/THIRD-PARTY-NOTICES.md +1 -1
  4. package/bin/advisers.js +2180 -92
  5. package/index.js +1 -1
  6. package/lib/brief-archive.js +267 -0
  7. package/lib/client-pack.js +1016 -0
  8. package/lib/consent.js +390 -0
  9. package/lib/credentials.js +195 -0
  10. package/lib/error-codes.js +516 -7
  11. package/lib/evidence.js +697 -113
  12. package/lib/kb-extract.js +626 -0
  13. package/lib/kb-facts.js +429 -0
  14. package/lib/kb-pages.js +1084 -0
  15. package/lib/kb.js +1036 -0
  16. package/lib/mail-errors.js +46 -0
  17. package/lib/mail-extract.js +351 -0
  18. package/lib/mail-imap.js +446 -0
  19. package/lib/mail-import.js +176 -0
  20. package/lib/mail-parse.js +223 -0
  21. package/lib/mail-store.js +731 -0
  22. package/lib/mail.js +506 -0
  23. package/lib/mcp-server.js +196 -10
  24. package/lib/notify.js +265 -7
  25. package/lib/policy/decision.js +315 -0
  26. package/lib/policy/egress.js +268 -0
  27. package/lib/policy/errors.js +71 -0
  28. package/lib/policy/index.js +99 -0
  29. package/lib/policy/rules.js +468 -0
  30. package/lib/policy/surfaces.js +141 -0
  31. package/lib/receipt-verify.js +199 -19
  32. package/lib/receivables.js +1653 -0
  33. package/lib/scheduler.js +453 -9
  34. package/lib/shell.js +1406 -0
  35. package/lib/source.js +98 -3
  36. package/lib/sqlite.js +366 -49
  37. package/lib/tos/index.js +2 -2
  38. package/lib/tos/manifest.json +6 -6
  39. package/lib/tos/privacy.zh-CN.md +33 -20
  40. package/lib/tos/safety.zh-CN.md +7 -6
  41. package/lib/tos/summary.zh-CN.md +3 -2
  42. package/lib/tos/terms.zh-CN.md +31 -16
  43. package/lib/urgency.js +467 -0
  44. package/package.json +4 -4
@@ -4,12 +4,15 @@
4
4
  * Two layers:
5
5
  * - the frozen 0.2.4 baseline: 50 `E_*` literals in committed
6
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).
7
+ * - 82 additive 0.3.0 codes (`since: "0.3.0"`) extracted from the 0.3.0
8
+ * modules landing in that release (audit anchor, backup/restore, read-only
9
+ * ledger facade, TUI JSON guards, receipt limits);
10
+ * - 51 additive 0.4.0 codes (`since: "0.4.0"`) extracted from the 0.4.0
11
+ * modules landing in this release (KB, mail/IMAP, policy/consent, receivables
12
+ * and the offline client status pack).
13
+ * Additive codes are provisional until their modules are committed;
14
+ * `check-contracts --errors` accepts a code that exists in the worktree but not
15
+ * yet in git HEAD, and fails only when a registered code exists nowhere (stale).
13
16
  *
14
17
  * This module is data + pure helpers only: importing it never changes CLI/MCP/DSH
15
18
  * behaviour. `bin/` may start using the helpers in a later integration wave; for
@@ -31,8 +34,10 @@ export const ERROR_CODE_VERSION = 1
31
34
  export const ERROR_CODES_FROZEN_AT = '2026-11-20'
32
35
  export const ERROR_CODES_SOURCE_COMMIT = '35a51c3'
33
36
  export const ERROR_CODES_SOURCE_VERSION = '0.2.4'
34
- export const ERROR_CODES_RELEASE = '0.3.0'
37
+ export const ERROR_CODES_RELEASE = '0.4.0'
35
38
  export const ERROR_CODES_BASELINE_COUNT = 50
39
+ /** Additive layers after the frozen baseline, oldest first (a code's `since`). */
40
+ export const ERROR_CODES_ADDITIVE_RELEASES = Object.freeze(['0.3.0', '0.4.0'])
36
41
 
37
42
  /** Category vocabulary used by the registry, docs and contracts. */
38
43
  export const ERROR_CATEGORIES = Object.freeze([
@@ -1276,6 +1281,510 @@ const REGISTRY = [
1276
1281
  remedy: "The project id does not exist; use `advisers project list`.",
1277
1282
  doc: 'docs/CLIENTS.md',
1278
1283
  },
1284
+ {
1285
+ code: 'E_FACT_NOT_FOUND',
1286
+ category: 'state',
1287
+ exit: 1,
1288
+ surfaces: Object.freeze(['lib']),
1289
+ since: '0.4.0',
1290
+ stable: true,
1291
+ remedy: "Unknown or deleted fact at this clearance. Run `advisers fact ls` (or pass --include-deleted to inspect a tombstone) and use an existing fact id.",
1292
+ },
1293
+ {
1294
+ code: 'E_INTERNAL',
1295
+ category: 'internal',
1296
+ exit: 1,
1297
+ surfaces: Object.freeze(['lib']),
1298
+ since: '0.4.0',
1299
+ stable: false,
1300
+ remedy: "A KB batch item failed without a coded error; this is a fallback label, not a stable contract. Retry the file alone and report the message if it persists.",
1301
+ },
1302
+ {
1303
+ code: 'E_KB_DUPLICATE',
1304
+ category: 'state',
1305
+ exit: 1,
1306
+ surfaces: Object.freeze(['lib']),
1307
+ since: '0.4.0',
1308
+ stable: true,
1309
+ remedy: "This document is already indexed. Re-run with --replace to re-index it, or skip the file.",
1310
+ },
1311
+ {
1312
+ code: 'E_KB_EMPTY',
1313
+ category: 'content',
1314
+ exit: 1,
1315
+ surfaces: Object.freeze(['lib']),
1316
+ since: '0.4.0',
1317
+ stable: true,
1318
+ remedy: "No extractable text was found. A scanned/image file is reported as needs-OCR and is not indexed in 0.4.0; store a text-based version or a PDF with a text layer.",
1319
+ },
1320
+ {
1321
+ code: 'E_KB_ENCODING',
1322
+ category: 'content',
1323
+ exit: 1,
1324
+ surfaces: Object.freeze(['lib']),
1325
+ since: '0.4.0',
1326
+ stable: true,
1327
+ remedy: "The file bytes are neither valid UTF-8 nor decodable as GB18030, so nothing was indexed. Convert the file to UTF-8 and retry.",
1328
+ },
1329
+ {
1330
+ code: 'E_KB_INVALID',
1331
+ category: 'usage',
1332
+ exit: 1,
1333
+ surfaces: Object.freeze(['lib']),
1334
+ since: '0.4.0',
1335
+ stable: true,
1336
+ remedy: "Invalid KB input (file path, kind/relation/scope, symlink or page id). Pass an existing regular file and a documented kind/relation/scope; see `advisers kb add --help`.",
1337
+ },
1338
+ {
1339
+ code: 'E_KB_LIMIT',
1340
+ category: 'usage',
1341
+ exit: 1,
1342
+ surfaces: Object.freeze(['lib']),
1343
+ since: '0.4.0',
1344
+ stable: true,
1345
+ remedy: "At most 200 files can be indexed in one KB batch. Split the batch and retry.",
1346
+ },
1347
+ {
1348
+ code: 'E_KB_NOT_FOUND',
1349
+ category: 'state',
1350
+ exit: 1,
1351
+ surfaces: Object.freeze(['lib']),
1352
+ since: '0.4.0',
1353
+ stable: true,
1354
+ remedy: "Unknown, hidden-above-clearance or tombstoned KB document. Run `advisers kb ls` and use an active document id.",
1355
+ },
1356
+ {
1357
+ code: 'E_KB_PAGE_NOT_FOUND',
1358
+ category: 'state',
1359
+ exit: 1,
1360
+ surfaces: Object.freeze(['lib']),
1361
+ since: '0.4.0',
1362
+ stable: true,
1363
+ remedy: "Unknown, hidden-above-clearance or not-yet-built KB page. Rebuild/derive the page (`advisers kb page rebuild`) or use an existing page id.",
1364
+ },
1365
+ {
1366
+ code: 'E_KB_READ',
1367
+ category: 'fs',
1368
+ exit: 1,
1369
+ surfaces: Object.freeze(['lib']),
1370
+ since: '0.4.0',
1371
+ stable: true,
1372
+ remedy: "The KB source file cannot be read (missing, permission or I/O error), so nothing was indexed. Check the path and permissions and retry.",
1373
+ },
1374
+ {
1375
+ code: 'E_KB_TOO_LARGE',
1376
+ category: 'fs',
1377
+ exit: 1,
1378
+ surfaces: Object.freeze(['lib']),
1379
+ since: '0.4.0',
1380
+ stable: true,
1381
+ remedy: "The file or an archive member exceeds the KB ingestion budget (50 MB file, 2 MB text, 500 PDF pages, ZIP entry/expansion caps). Split or shrink the file; limits are reported, never silently dropped.",
1382
+ },
1383
+ {
1384
+ code: 'E_KB_UNSUPPORTED',
1385
+ category: 'usage',
1386
+ exit: 1,
1387
+ surfaces: Object.freeze(['lib']),
1388
+ since: '0.4.0',
1389
+ stable: true,
1390
+ remedy: "Unsupported file type for KB ingest. Index md/txt/docx/xlsx/pptx/ofd/pdf/eml files; scanned images need no OCR in 0.4.0.",
1391
+ },
1392
+ {
1393
+ code: 'E_QUERY_TOO_LONG',
1394
+ category: 'usage',
1395
+ exit: 1,
1396
+ surfaces: Object.freeze(['lib']),
1397
+ since: '0.4.0',
1398
+ stable: true,
1399
+ remedy: "The KB search query is longer than 200 characters. Shorten the query and retry.",
1400
+ },
1401
+ {
1402
+ code: 'E_CREDENTIALS_INSECURE',
1403
+ category: 'policy',
1404
+ exit: 1,
1405
+ surfaces: Object.freeze(['lib']),
1406
+ since: '0.4.0',
1407
+ stable: true,
1408
+ remedy: "The local IMAP credential file is unsafe (group/other-readable, a symlink, corrupt or wrong format). chmod 700 the credentials directory and 600 the file, or delete it and re-add the account; advisers refuses to read it.",
1409
+ },
1410
+ {
1411
+ code: 'E_IMAP_AUTH',
1412
+ category: 'config',
1413
+ exit: 1,
1414
+ surfaces: Object.freeze(['lib']),
1415
+ since: '0.4.0',
1416
+ stable: true,
1417
+ remedy: "IMAP authentication failed. Check the account username and app password; providers may require an app password (OAuth is not supported in 0.4.0).",
1418
+ },
1419
+ {
1420
+ code: 'E_IMAP_PROTOCOL',
1421
+ category: 'config',
1422
+ exit: 1,
1423
+ surfaces: Object.freeze(['lib']),
1424
+ since: '0.4.0',
1425
+ stable: true,
1426
+ remedy: "The IMAP server sent an unparseable/rejected response or a non-read-only command was refused. Check server compatibility and retry; advisers only reads mail.",
1427
+ },
1428
+ {
1429
+ code: 'E_IMAP_TIMEOUT',
1430
+ category: 'state',
1431
+ exit: 1,
1432
+ surfaces: Object.freeze(['lib']),
1433
+ since: '0.4.0',
1434
+ stable: true,
1435
+ remedy: "The IMAP request timed out. Check the network/server and retry; advisers never falls back to cleartext.",
1436
+ },
1437
+ {
1438
+ code: 'E_IMAP_TLS',
1439
+ category: 'config',
1440
+ exit: 1,
1441
+ surfaces: Object.freeze(['lib']),
1442
+ since: '0.4.0',
1443
+ stable: true,
1444
+ remedy: "The IMAP TLS connection or STARTTLS upgrade failed, or the server certificate is not valid for the configured host. Fix the server/certificate or use implicit TLS on 993; advisers never falls back to cleartext.",
1445
+ },
1446
+ {
1447
+ code: 'E_IMAP_UIDVALIDITY',
1448
+ category: 'state',
1449
+ exit: 1,
1450
+ surfaces: Object.freeze(['lib']),
1451
+ since: '0.4.0',
1452
+ stable: true,
1453
+ remedy: "The mailbox UIDVALIDITY changed, so the sync cursor needs a full rescan. Run `advisers mail sync <account> --full`; no local messages are deleted.",
1454
+ },
1455
+ {
1456
+ code: 'E_MAIL_ACCOUNT_NOT_FOUND',
1457
+ category: 'state',
1458
+ exit: 1,
1459
+ surfaces: Object.freeze(['lib']),
1460
+ since: '0.4.0',
1461
+ stable: true,
1462
+ remedy: "Unknown mail account. Run `advisers mail account ls` and use an active account name or id.",
1463
+ },
1464
+ {
1465
+ code: 'E_MAIL_CONFIG',
1466
+ category: 'config',
1467
+ exit: 1,
1468
+ surfaces: Object.freeze(['lib']),
1469
+ since: '0.4.0',
1470
+ stable: true,
1471
+ remedy: "Invalid mail account/import configuration (host, port, TLS mode, retention or dates). Fix the flagged field; cleartext IMAP is refused, use implicit TLS on 993 or STARTTLS.",
1472
+ },
1473
+ {
1474
+ code: 'E_MAIL_CREDENTIALS_MISSING',
1475
+ category: 'config',
1476
+ exit: 1,
1477
+ surfaces: Object.freeze(['lib']),
1478
+ since: '0.4.0',
1479
+ stable: true,
1480
+ remedy: "No stored credential for this mail account. Run `advisers mail account add` again and enter the password through the TTY prompt or --pass-stdin (never argv).",
1481
+ },
1482
+ {
1483
+ code: 'E_MAIL_MESSAGE_NOT_FOUND',
1484
+ category: 'state',
1485
+ exit: 1,
1486
+ surfaces: Object.freeze(['lib']),
1487
+ since: '0.4.0',
1488
+ stable: true,
1489
+ remedy: "Unknown mail message. Run `advisers mail ls` and use an existing message id.",
1490
+ },
1491
+ {
1492
+ code: 'E_MAIL_MODEL_DISABLED',
1493
+ category: 'policy',
1494
+ exit: 1,
1495
+ surfaces: Object.freeze(['lib']),
1496
+ since: '0.4.0',
1497
+ stable: true,
1498
+ remedy: "Model extraction is opt-in and disabled here (needs --model --yes and ADVISERS_API_KEY, and is refused for protected/secrecy>0 matters). Use the default local extraction or grant the model path explicitly.",
1499
+ },
1500
+ {
1501
+ code: 'E_MAIL_NOT_RETAINED',
1502
+ category: 'state',
1503
+ exit: 1,
1504
+ surfaces: Object.freeze(['lib']),
1505
+ since: '0.4.0',
1506
+ stable: true,
1507
+ remedy: "The message body was not retained (metadata-only row or purged by retention). Metadata and body_sha256 are kept; re-sync the mailbox to read the body again.",
1508
+ },
1509
+ {
1510
+ code: 'E_MAIL_TOO_LARGE',
1511
+ category: 'fs',
1512
+ exit: 1,
1513
+ surfaces: Object.freeze(['lib']),
1514
+ since: '0.4.0',
1515
+ stable: true,
1516
+ remedy: "An IMAP message/response exceeded the size limit; oversize messages keep header-only metadata. Raise --max-message-bytes only if the server is trusted and memory allows.",
1517
+ },
1518
+ {
1519
+ code: 'E_CONTENT_SAFETY_BLOCKED',
1520
+ category: 'content',
1521
+ exit: 1,
1522
+ surfaces: Object.freeze(['cli', 'lib']),
1523
+ since: '0.4.0',
1524
+ stable: true,
1525
+ remedy: "The local content-safety classifier blocked this content. Do not retry the same content; review it first.",
1526
+ },
1527
+ {
1528
+ code: 'E_POLICY_AUDIT_UNAVAILABLE',
1529
+ category: 'policy',
1530
+ exit: 1,
1531
+ surfaces: Object.freeze(['cli', 'lib']),
1532
+ since: '0.4.0',
1533
+ stable: true,
1534
+ remedy: "The policy intent/result audit could not be written, so the side effect was refused. Fix the audit sink/ledger and retry; if details.effectCompleted is true the effect already ran unaudited, so reconcile manually.",
1535
+ },
1536
+ {
1537
+ code: 'E_POLICY_CONFIRMATION_UNAVAILABLE',
1538
+ category: 'policy',
1539
+ exit: 1,
1540
+ surfaces: Object.freeze(['cli', 'lib']),
1541
+ since: '0.4.0',
1542
+ stable: true,
1543
+ remedy: "Untrusted content would drive a side effect, but no interactive confirmation channel is available. Re-run interactively (TTY) or use an explicitly authorized non-interactive path; do not bypass confirmation.",
1544
+ },
1545
+ {
1546
+ code: 'E_POLICY_CONSENT_REQUIRED',
1547
+ category: 'policy',
1548
+ exit: 1,
1549
+ surfaces: Object.freeze(['cli', 'lib']),
1550
+ since: '0.4.0',
1551
+ stable: true,
1552
+ remedy: "Explicit consent for this surface + data class + provider is required before model egress. Record a consent grant for those exact fields (and base URL) and retry.",
1553
+ },
1554
+ {
1555
+ code: 'E_POLICY_EFFECT_FAILED',
1556
+ category: 'internal',
1557
+ exit: 1,
1558
+ surfaces: Object.freeze(['lib']),
1559
+ since: '0.4.0',
1560
+ stable: false,
1561
+ remedy: "Internal fallback recorded when an audited effect threw an uncoded error; not a stable contract. Read the original error, retry the action and report it with diagnostics if it persists.",
1562
+ },
1563
+ {
1564
+ code: 'E_POLICY_EGRESS_UNREGISTERED',
1565
+ category: 'policy',
1566
+ exit: 1,
1567
+ surfaces: Object.freeze(['cli', 'lib']),
1568
+ since: '0.4.0',
1569
+ stable: true,
1570
+ remedy: "This egress sink/path is not registered (or is ambiguous), so egress fails closed. Register the path or pass a registered meta.id disambiguator.",
1571
+ },
1572
+ {
1573
+ code: 'E_POLICY_INVALID_FACTS',
1574
+ category: 'policy',
1575
+ exit: 1,
1576
+ surfaces: Object.freeze(['cli', 'lib']),
1577
+ since: '0.4.0',
1578
+ stable: true,
1579
+ remedy: "Policy facts are malformed or incomplete, so the decision fails closed. Pass the documented fact fields with valid types and re-evaluate.",
1580
+ },
1581
+ {
1582
+ code: 'E_POLICY_PROTECTED_PATH',
1583
+ category: 'policy',
1584
+ exit: 1,
1585
+ surfaces: Object.freeze(['cli', 'lib']),
1586
+ since: '0.4.0',
1587
+ stable: true,
1588
+ remedy: "The target path is a protected or persistence location (credentials/config/HOME persistence). Choose a workspace path instead.",
1589
+ },
1590
+ {
1591
+ code: 'E_POLICY_SAFETY_REQUIRED',
1592
+ category: 'policy',
1593
+ exit: 1,
1594
+ surfaces: Object.freeze(['cli', 'lib']),
1595
+ since: '0.4.0',
1596
+ stable: true,
1597
+ remedy: "A content-safety verdict is required before this action but was not supplied. Run the configured content-safety check and pass its verdict.",
1598
+ },
1599
+ {
1600
+ code: 'E_POLICY_SURFACE_NOT_ENABLED',
1601
+ category: 'policy',
1602
+ exit: 1,
1603
+ surfaces: Object.freeze(['cli', 'lib']),
1604
+ since: '0.4.0',
1605
+ stable: true,
1606
+ remedy: "The surface is registered but not wired/enabled in this release, so the action fails closed. Do not bypass the gate; wire/enable the surface first.",
1607
+ },
1608
+ {
1609
+ code: 'E_POLICY_TOKEN_EFFECT_MISMATCH',
1610
+ category: 'policy',
1611
+ exit: 1,
1612
+ surfaces: Object.freeze(['lib']),
1613
+ since: '0.4.0',
1614
+ stable: true,
1615
+ remedy: "The effect does not match the effect digest the decision was issued for. Authorize the actual effect and pass matching effect metadata.",
1616
+ },
1617
+ {
1618
+ code: 'E_POLICY_TOKEN_EXPIRED',
1619
+ category: 'policy',
1620
+ exit: 1,
1621
+ surfaces: Object.freeze(['lib']),
1622
+ since: '0.4.0',
1623
+ stable: true,
1624
+ remedy: "The decision token expired before the effect ran. Authorize again and execute promptly.",
1625
+ },
1626
+ {
1627
+ code: 'E_POLICY_TOKEN_INVALID',
1628
+ category: 'policy',
1629
+ exit: 1,
1630
+ surfaces: Object.freeze(['lib']),
1631
+ since: '0.4.0',
1632
+ stable: true,
1633
+ remedy: "The decision token is malformed or was tampered with. Authorize again and use the returned token unchanged.",
1634
+ },
1635
+ {
1636
+ code: 'E_POLICY_TOKEN_REPLAY',
1637
+ category: 'policy',
1638
+ exit: 1,
1639
+ surfaces: Object.freeze(['lib']),
1640
+ since: '0.4.0',
1641
+ stable: true,
1642
+ remedy: "The one-shot decision token was already consumed. Authorize the action again instead of reusing the token.",
1643
+ },
1644
+ {
1645
+ code: 'E_POLICY_TOKEN_UNKNOWN',
1646
+ category: 'policy',
1647
+ exit: 1,
1648
+ surfaces: Object.freeze(['lib']),
1649
+ since: '0.4.0',
1650
+ stable: true,
1651
+ remedy: "The decision token was not issued by this process (or was cleared). Authorize the action again.",
1652
+ },
1653
+ {
1654
+ code: 'E_POLICY_UNKNOWN_SURFACE',
1655
+ category: 'policy',
1656
+ exit: 1,
1657
+ surfaces: Object.freeze(['cli', 'lib']),
1658
+ since: '0.4.0',
1659
+ stable: true,
1660
+ remedy: "The surface/action is not registered in the policy matrix, so the action fails closed. Use a registered surface/action and register new integration points before use.",
1661
+ },
1662
+ {
1663
+ code: 'E_POLICY_WORKSPACE_ESCAPE',
1664
+ category: 'policy',
1665
+ exit: 1,
1666
+ surfaces: Object.freeze(['cli', 'lib']),
1667
+ since: '0.4.0',
1668
+ stable: true,
1669
+ remedy: "The target path escapes the workspace boundary. Keep the target inside the workspace or widen it explicitly.",
1670
+ },
1671
+ {
1672
+ code: 'E_CLIENT_HAS_OPEN_RECEIVABLES',
1673
+ category: 'state',
1674
+ exit: 1,
1675
+ surfaces: Object.freeze(['lib']),
1676
+ since: '0.4.0',
1677
+ stable: true,
1678
+ remedy: "The client still has open receivables. Settle or void them (or use an explicit supported override) before archiving the client.",
1679
+ },
1680
+ {
1681
+ code: 'E_PAYMENT_INVALID',
1682
+ category: 'usage',
1683
+ exit: 1,
1684
+ surfaces: Object.freeze(['lib']),
1685
+ since: '0.4.0',
1686
+ stable: true,
1687
+ remedy: "Invalid payment input (amount, currency, method or paid date). Fix the flagged field and retry; a payment currency must equal its receivable currency.",
1688
+ },
1689
+ {
1690
+ code: 'E_PAYMENT_NOT_FOUND',
1691
+ category: 'state',
1692
+ exit: 1,
1693
+ surfaces: Object.freeze(['lib']),
1694
+ since: '0.4.0',
1695
+ stable: true,
1696
+ remedy: "Unknown payment id. Run `advisers payment ls` and use an existing id.",
1697
+ },
1698
+ {
1699
+ code: 'E_RECEIVABLE_INVALID',
1700
+ category: 'usage',
1701
+ exit: 1,
1702
+ surfaces: Object.freeze(['lib']),
1703
+ since: '0.4.0',
1704
+ stable: true,
1705
+ remedy: "Invalid receivable input (amount, currency, due date, kind or memo). Fix the flagged field and retry; amounts are decimal strings within the minor-unit cap and one of CNY/USD/EUR/HKD.",
1706
+ },
1707
+ {
1708
+ code: 'E_RECEIVABLE_NOT_FOUND',
1709
+ category: 'state',
1710
+ exit: 1,
1711
+ surfaces: Object.freeze(['lib']),
1712
+ since: '0.4.0',
1713
+ stable: true,
1714
+ remedy: "Unknown or hidden-above-clearance receivable id. Run `advisers receivable ls` and use an active id.",
1715
+ },
1716
+ {
1717
+ code: 'E_CLIENT_PACK_INVALID',
1718
+ category: 'usage',
1719
+ exit: 1,
1720
+ surfaces: Object.freeze(['lib']),
1721
+ since: '0.4.0',
1722
+ stable: true,
1723
+ remedy: "The client status pack input, manifest or checksum file is invalid (schema, missing/extra files or a forbidden money-like field). Fix the flagged field/file; a v1 pack never carries receivable/payment amounts.",
1724
+ },
1725
+ {
1726
+ code: 'E_CLIENT_PACK_LIMIT',
1727
+ category: 'verify',
1728
+ exit: 1,
1729
+ surfaces: Object.freeze(['lib']),
1730
+ since: '0.4.0',
1731
+ stable: true,
1732
+ remedy: "The client status pack exceeds a verification resource limit (entry count, depth, single-file or total size). The pack is not trusted; ask the sender for a normal-size pack or verify it manually.",
1733
+ },
1734
+ {
1735
+ code: 'E_CLIENT_PACK_RECEIVABLES_UNSUPPORTED',
1736
+ category: 'policy',
1737
+ exit: 1,
1738
+ surfaces: Object.freeze(['lib']),
1739
+ since: '0.4.0',
1740
+ stable: true,
1741
+ remedy: "Client status pack v1 must not include receivable/payment amounts (reserved for 0.4.1 pending legal review). Keep money columns local and drop --include-receivables.",
1742
+ },
1743
+ {
1744
+ code: 'E_STORE_REQUIRED',
1745
+ category: 'state',
1746
+ exit: 1,
1747
+ surfaces: Object.freeze(['cli', 'lib']),
1748
+ since: '0.4.0',
1749
+ stable: true,
1750
+ remedy: "This family command needs the SQLite ledger (KB/mail/money tables live there). Unset ADVISERS_STORE=json and run advisers doctor; the JSON fallback keeps only the nine-table wire ledger.",
1751
+ },
1752
+ {
1753
+ code: 'E_TERM_REQUIRED',
1754
+ category: 'usage',
1755
+ exit: 1,
1756
+ surfaces: Object.freeze(['cli']),
1757
+ since: '0.4.0',
1758
+ stable: true,
1759
+ remedy: "A terminal is required for the hidden secret prompt. Run on a TTY, or pipe one line with --pass-stdin; never put a password in argv.",
1760
+ },
1761
+ {
1762
+ code: 'E_POLICY_DENIED',
1763
+ category: 'policy',
1764
+ exit: 1,
1765
+ surfaces: Object.freeze(['cli', 'lib']),
1766
+ since: '0.4.0',
1767
+ stable: true,
1768
+ remedy: "The policy engine denied this side effect (surface/action/data class). Read the decision code/hint, run advisers privacy --matrix, and grant the explicit consent or fix the facts; do not bypass the gate.",
1769
+ },
1770
+ {
1771
+ code: 'E_MAIL_MODEL_OPT_IN',
1772
+ category: 'policy',
1773
+ exit: 1,
1774
+ surfaces: Object.freeze(['cli']),
1775
+ since: '0.4.0',
1776
+ stable: true,
1777
+ remedy: "mail extract --model sends message text to the model provider and needs an explicit --yes. The default local path is offline; pass --model --yes only after consent.",
1778
+ },
1779
+ {
1780
+ code: 'E_CONSENT_CONFIRMATION_UNAVAILABLE',
1781
+ category: 'policy',
1782
+ exit: 1,
1783
+ surfaces: Object.freeze(['cli', 'lib']),
1784
+ since: '0.4.0',
1785
+ stable: true,
1786
+ remedy: "A non-interactive consent grant needs an explicit --yes (or ADVISERS_CONSENT_<SURFACE>=1). Read advisers tos show and docs/PRIVACY.md first; this is a separate model-egress consent, not TOS acceptance.",
1787
+ },
1279
1788
  ]
1280
1789
 
1281
1790
  /** code -> frozen entry (alphabetical insertion order). */