@ai-matrx/records 0.58.4 → 0.58.7

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/CHANGELOG.md CHANGED
@@ -1,5 +1,79 @@
1
1
  # Changelog — @ai-matrx/records
2
2
 
3
+ ## 0.58.7
4
+
5
+ Automatic changed-only republish (docs/metadata drift since the last tag — see
6
+ `git diff npm/records/v0.58.6..npm/records/v0.58.7 -- apps/shared/records`).
7
+ No source changes intended and no consumer action required.
8
+
9
+ ## Unreleased — lane SOURCE-KEY (2026-09-25)
10
+
11
+ * **A record-store table's event-source key is `record:<table id>`** (was `custom_record:<table id>`,
12
+ the retired tier-2 table's word). `recordChangeTrigger(tableId)` now writes it; new
13
+ `recordSourceKey(tableId)` is the one builder, and `recordSourceTable(key)` reads the table back
14
+ from either key (rows saved before the move). The store moved first (lane SOURCE-KEY, applied to
15
+ production 2026-09-25 03:29 UTC): `custom.record_change_actions`, `custom.table_webhook_declare`
16
+ and the row-change producer write `record:<table id>`, read both, and turn an older client's
17
+ `custom_record:` key into the new one on the way in, so a schedule saved by an older release
18
+ still fires until the store refuses the old key (the next step, once this release is installed).
19
+ **Consumer action:** anything that compares a trigger's or webhook's key to the literal
20
+ `custom_record:` must use `recordSourceTable(key)`.
21
+
22
+ ## 0.58.6 (2026-09-24 — published by PUBLISH-SWEEP-5)
23
+
24
+ 0.58.5 (the release run's automatic tag, run 36082256533) never reached npm: the live census found
25
+ the store raising `XX000`, which STORE-TAILS-3 removed at the source (below). This release carries
26
+ S5-PRIME's and S5-PRIME-2's inbox doors, which records-ui 0.85.7 needs, so it publishes first.
27
+
28
+ ### Lane STORE-TAILS-3 (2026-09-25)
29
+
30
+ * **`42P17` is mapped to `refused_by_rule`**: the store refuses, by name, a formula / lookup /
31
+ rollup that would read itself round a circle (on declare and edit), and refuses a circle stored
32
+ before that rule when it is worked out (applied to production 2026-09-25 02:51 UTC).
33
+ * **No door raises `XX000` any more**: `custom._view_key_value` judges `filters` and refuses a
34
+ store-written or unknown view setting as a named `22023` (applied 03:02 UTC). The live census
35
+ clause "maps every refusal class the store actually raises" is green again.
36
+ * **The live suite's no-standing clause reads its stranger organization from the write target**:
37
+ a typed production id that the rehearsal branch does not hold made the FIXTURE answer 23503
38
+ (`knob_override_organization_id_fkey`) before the door ever ran; the door itself answers 42501
39
+ on every target (measured on the branch and read-only on production).
40
+ * `src/store.generated.ts` regenerated against the live store (686 doors; new server-only helpers
41
+ `archive_event_of`, `far_value`, `record_value_one`, `field_cycle`,
42
+ `field_context_policy_floor`, `context_policy_rank`). No consumer action.
43
+
44
+ ### Lane S5-PRIME-2 (2026-09-24)
45
+
46
+ * **Snooze and clear, as one person's own inbox state** (uichamp_s5b + uichamp_s5b2, applied to
47
+ production 2026-09-25 02:13 UTC): `inboxSnooze({ item_id, until })`, `inboxUnsnooze`,
48
+ `inboxClear` (a decision still owed is refused, SQLSTATE 55000, "This one needs a decision"),
49
+ `inboxUnclear`, and `inboxCounts({ everyOrganization })` — waiting / snoozed / cleared / overdue
50
+ per organization, counted by the same predicate the inbox lists with (the shell badge's number).
51
+ Types `WorkInboxView`, `InboxStateChange`, `InboxCounts`.
52
+ * **`workInbox({ view })`**: `"inbox"` (default) hides what this person snoozed or cleared,
53
+ `"snoozed"` lists what they put off (soonest back first), `"done"` what they cleared.
54
+ `WorkInboxItem` gains `snoozed_until`, `cleared_at`, `snoozed_count`, `cleared_count`.
55
+ * **`P0002` is mapped to `not_found`**: the inbox doors answer it for an id that is not in this
56
+ person's inbox (an invented id, somebody else's item and another organization's alike).
57
+ * `src/store.generated.ts` regenerated against the live store (679 doors, knob
58
+ `inbox_reminder_after_days`).
59
+
60
+ ### Lane S5-PRIME (2026-09-24)
61
+
62
+ * **`WorkInboxItem` carries the table and, when closed, who decided it and when**: `table_id`,
63
+ `table_name`, `decided_by`, `decided_by_name`, `decided_at`, `outcome` — the six columns
64
+ `custom.work_inbox` now answers (uichamp_s5, applied to production 2026-09-25 01:07 UTC).
65
+ * **`WorkApprovalState`** = `pending | approved | declined | withdrawn`. `withdrawn` is the store's
66
+ own close: archiving a record or table withdraws the approvals waiting on it, with the reason.
67
+ * **`WorkDecideVerdict` gains `archived`**: `work_decide_many` answers it when the thing an approval
68
+ would change is archived (SQLSTATE 55000 from `work_approval_decide`, sentence names it).
69
+ * `src/store.generated.ts` regenerated against the live store (669 doors).
70
+
71
+ ## 0.58.5
72
+
73
+ Automatic changed-only republish (docs/metadata drift since the last tag — see
74
+ `git diff npm/records/v0.58.4..npm/records/v0.58.5 -- apps/shared/records`).
75
+ No source changes intended and no consumer action required.
76
+
3
77
  ## 0.58.4 (2026-09-24 — published by PUBLISH-SWEEP-5)
4
78
 
5
79
  **`src/store.generated.ts` is the live main database's catalogue after the 2026-09-24 production
@@ -2332,6 +2332,8 @@ __export(core_exports, {
2332
2332
  predictWriteRefusals: () => predictWriteRefusals,
2333
2333
  publicFormPath: () => publicFormPath,
2334
2334
  recordChangeTrigger: () => recordChangeTrigger,
2335
+ recordSourceKey: () => recordSourceKey,
2336
+ recordSourceTable: () => recordSourceTable,
2335
2337
  rememberedOpCount: () => rememberedOpCount,
2336
2338
  sameDocument: () => sameDocument,
2337
2339
  scopeChip: () => scopeChip,
@@ -2902,10 +2904,18 @@ async function exportPageXlsx(page, labels = {}, sheetLabel = "Records") {
2902
2904
  }
2903
2905
  return XLSX.write(workbook, { type: "array", bookType: "xlsx", compression: true });
2904
2906
  }
2907
+ function recordSourceKey(tableId) {
2908
+ return `record:${tableId}`;
2909
+ }
2910
+ var SOURCE_KEY = /^(record|custom_record):([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/;
2911
+ function recordSourceTable(key) {
2912
+ const m = key ? SOURCE_KEY.exec(key) : null;
2913
+ return m ? m[2] : null;
2914
+ }
2905
2915
  function recordChangeTrigger(tableId, options = {}) {
2906
2916
  return {
2907
2917
  type: "event",
2908
- entity_type: `custom_record:${tableId}`,
2918
+ entity_type: recordSourceKey(tableId),
2909
2919
  table_id: tableId,
2910
2920
  ...options.actions && options.actions.length > 0 ? { actions: options.actions } : {},
2911
2921
  ...options.changedFields && options.changedFields.length > 0 ? { changed_fields: options.changedFields } : {}
@@ -3393,6 +3403,10 @@ var BY_SQLSTATE = {
3393
3403
  // refusal class rather than a person guessing one.
3394
3404
  "22003": "invalid_argument",
3395
3405
  "02000": "not_found",
3406
+ // P0002 — `custom.inbox_snooze` / `custom.inbox_clear` (lane S5-PRIME-2, 2026-09-24): "There is
3407
+ // nothing in your inbox with that id". An invented id, another person's item and another
3408
+ // organization's all answer it alike, so it reads exactly as 02000 does: not found.
3409
+ "P0002": "not_found",
3396
3410
  "23503": "missing_reference",
3397
3411
  "23505": "already_exists",
3398
3412
  "0A000": "not_supported",
@@ -3421,6 +3435,12 @@ var BY_SQLSTATE = {
3421
3435
  // moves, so it reads as a refusal on the merits. Caught by the live-door census on records
3422
3436
  // 0.58.3's tag, the seventh time the census found a class before a person did.
3423
3437
  "55000": "refused_by_rule",
3438
+ // 42P17 — a worked-out column that would read itself round a circle (STORE-TAILS-3,
3439
+ // 2026-09-25): `custom._field_reads_what_it_reads` refuses the declaration or edit that would
3440
+ // close the circle, naming every column in it, and `custom.far_value` refuses a circle stored
3441
+ // before that rule when a lookup or rollup is worked out. Refused on its merits, in the store's
3442
+ // own sentence, nothing written — so it reads as 55000 does.
3443
+ "42P17": "refused_by_rule",
3424
3444
  "40001": "stale_read",
3425
3445
  // 57014 — the store cancelled the statement at its own timeout. Like
3426
3446
  // `stale_read` and unlike every other refusal here, the call was never
@@ -3773,6 +3793,7 @@ var STORE_DOORS = [
3773
3793
  { name: "anon_token_verify", args: "p_secret text, p_origin text, p_required_mode text", returns: "TABLE(token_id uuid, organization_id uuid, form_id uuid, saved_view_id uuid, record_id uuid, mode text)", security: "definer" },
3774
3794
  { name: "anon_write", args: "p_secret text, p_origin text, p_payload jsonb, p_client_key text DEFAULT NULL::text, p_raw_payload jsonb DEFAULT '{}'::jsonb", returns: "uuid", security: "definer" },
3775
3795
  { name: "applicable_fields", args: "p_organization_id uuid, p_table_id uuid, p_record_type text DEFAULT NULL::text", returns: "SETOF custom.record", security: "definer" },
3796
+ { name: "archive_event_of", args: "p_organization_id uuid, p_record_id uuid", returns: "history.migration_log", security: "definer" },
3776
3797
  { name: "assert_client_may_change", args: "p_organization_id uuid, p_subject_id uuid, p_door text, p_required permission_level DEFAULT 'editor'::permission_level, p_subject_word text DEFAULT 'record'::text", returns: "void", security: "invoker" },
3777
3798
  { name: "assert_client_may_open", args: "p_organization_id uuid, p_subject_id uuid, p_door text, p_required permission_level DEFAULT 'viewer'::permission_level, p_subject_word text DEFAULT 'record'::text", returns: "void", security: "invoker" },
3778
3799
  { name: "assert_client_may_reach", args: "p_organization_id uuid, p_door text", returns: "void", security: "invoker" },
@@ -3839,8 +3860,10 @@ var STORE_DOORS = [
3839
3860
  { name: "containment_edges", args: "p_organization_id uuid", returns: "TABLE(parent_id uuid, child_id uuid, via text)", security: "invoker" },
3840
3861
  { name: "containment_parent", args: "p_data jsonb", returns: "uuid", security: "invoker" },
3841
3862
  { name: "context_compare_facts", args: "p_user_id uuid, p_record_ids uuid[], p_item_ids uuid[] DEFAULT NULL::uuid[], p_cells jsonb DEFAULT NULL::jsonb", returns: "jsonb", security: "definer" },
3863
+ { name: "context_policy_rank", args: "p_policy text", returns: "integer", security: "invoker" },
3842
3864
  { name: "context_resolve", args: "p_bindings jsonb", returns: "jsonb", security: "definer" },
3843
3865
  { name: "context_resolve", args: "p_organization_id uuid, p_bindings jsonb, p_scope_slug text DEFAULT 'scopes'::text", returns: "jsonb", security: "definer" },
3866
+ { name: "context_tag_copy", args: "p_organization_id uuid", returns: "jsonb", security: "definer" },
3844
3867
  { name: "conversation_scope", args: "p_organization_id uuid, p_conversation_id uuid", returns: "jsonb", security: "definer" },
3845
3868
  { name: "conversation_scope_bind", args: "p_organization_id uuid, p_conversation_id uuid, p_record_id uuid", returns: "jsonb", security: "definer" },
3846
3869
  { name: "conversation_scope_context", args: "p_organization_id uuid, p_conversation_id uuid, p_relations integer DEFAULT 12, p_history integer DEFAULT 15, p_siblings integer DEFAULT 8", returns: "jsonb", security: "definer" },
@@ -3934,15 +3957,21 @@ var STORE_DOORS = [
3934
3957
  { name: "external_tier_contract", args: "", returns: "jsonb", security: "definer" },
3935
3958
  { name: "external_write_through", args: "p_organization_id uuid, p_record_id uuid, p_patch jsonb", returns: "void", security: "definer" },
3936
3959
  { name: "external_writes_set", args: "p_organization_id uuid, p_source_id uuid, p_enabled boolean", returns: "boolean", security: "definer" },
3960
+ { name: "far_value", args: "p_organization_id uuid, p_record_id uuid, p_key text, p_reader jsonb", returns: "jsonb", security: "invoker" },
3937
3961
  { name: "field_behaviour", args: "p_field_data jsonb", returns: "text", security: "invoker" },
3962
+ { name: "field_context_policy_floor", args: "p_organization_id uuid, p_field_data jsonb, p_self uuid DEFAULT NULL::uuid", returns: "TABLE(context_policy text, reads jsonb)", security: "definer" },
3963
+ { name: "field_cycle", args: "p_organization_id uuid, p_field_data jsonb, p_self uuid", returns: "text[]", security: "definer" },
3938
3964
  { name: "field_declare", args: "p_organization_id uuid, p_table_id uuid, p_spec jsonb", returns: "uuid", security: "definer" },
3939
3965
  { name: "field_dependants", args: "p_organization_id uuid, p_field_id uuid", returns: "TABLE(kind text, dependant_id uuid, label text, how text)", security: "definer" },
3940
3966
  { name: "field_history", args: "p_organization_id uuid, p_table_id uuid, p_field_key text, p_limit integer DEFAULT 100, p_offset integer DEFAULT 0, p_record_id uuid DEFAULT NULL::uuid", returns: "TABLE(record_id uuid, record_title text, version integer, occurred_at timestamp with time zone, operation_label text, actor jsonb, before jsonb, after jsonb)", security: "definer" },
3967
+ { name: "field_input_closure", args: "p_organization_id uuid, p_field_data jsonb, p_self uuid DEFAULT NULL::uuid", returns: "TABLE(input_id uuid, input_key text, input_label text, input_table uuid, sensitivity text, retired boolean, depth integer)", security: "definer" },
3968
+ { name: "field_inputs_of", args: "p_organization_id uuid, p_field_data jsonb", returns: "TABLE(input_id uuid, input_key text, input_label text, input_table uuid, sensitivity text, retired boolean, how text)", security: "definer" },
3941
3969
  { name: "field_kernel_id", args: "", returns: "uuid", security: "invoker" },
3942
3970
  { name: "field_kinds", args: "", returns: "TABLE(kind text, behavior text, parity boolean, made_of text)", security: "invoker" },
3943
3971
  { name: "field_options", args: "p_organization_id uuid, p_field_id uuid", returns: "SETOF custom.record", security: "definer" },
3944
3972
  { name: "field_retire", args: "p_organization_id uuid, p_field_id uuid", returns: "boolean", security: "definer" },
3945
3973
  { name: "field_rules", args: "p_field_data jsonb", returns: "TABLE(kind text, spec jsonb)", security: "invoker" },
3974
+ { name: "field_sensitivity_floor", args: "p_organization_id uuid, p_field_data jsonb, p_self uuid DEFAULT NULL::uuid", returns: "TABLE(sensitivity text, reads jsonb)", security: "definer" },
3946
3975
  { name: "field_update", args: "p_organization_id uuid, p_field_id uuid, p_patch jsonb", returns: "uuid", security: "definer" },
3947
3976
  { name: "field_value_convert", args: "p_to jsonb, p_value jsonb", returns: "jsonb", security: "invoker" },
3948
3977
  { name: "field_words", args: "p_organization_id uuid, p_field_id uuid, p_value jsonb", returns: "text", security: "invoker" },
@@ -3989,6 +4018,12 @@ var STORE_DOORS = [
3989
4018
  { name: "inbound_mail_land", args: "p_address text, p_mail jsonb, p_secret text DEFAULT NULL::text", returns: "jsonb", security: "definer" },
3990
4019
  { name: "inbound_mail_map", args: "p_organization_id uuid, p_table_id uuid, p_mail jsonb", returns: "jsonb", security: "invoker" },
3991
4020
  { name: "inbound_set", args: "p_organization_id uuid, p_inbound_id uuid, p_enabled boolean", returns: "jsonb", security: "definer" },
4021
+ { name: "inbox_clear", args: "p_organization_id uuid, p_item_id uuid", returns: "jsonb", security: "definer" },
4022
+ { name: "inbox_counts", args: "p_organization_id uuid DEFAULT NULL::uuid", returns: "TABLE(organization_id uuid, organization_name text, waiting integer, snoozed integer, cleared integer, overdue integer, oldest_waiting_at timestamp with time zone)", security: "definer" },
4023
+ { name: "inbox_remind_tick", args: "", returns: "jsonb", security: "invoker" },
4024
+ { name: "inbox_snooze", args: "p_organization_id uuid, p_item_id uuid, p_until timestamp with time zone", returns: "jsonb", security: "definer" },
4025
+ { name: "inbox_unclear", args: "p_organization_id uuid, p_item_id uuid", returns: "jsonb", security: "definer" },
4026
+ { name: "inbox_unsnooze", args: "p_organization_id uuid, p_item_id uuid", returns: "jsonb", security: "definer" },
3992
4027
  { name: "index_payload", args: "p_organization_id uuid, p_table_id uuid, p_limit integer DEFAULT 1000", returns: "TABLE(id uuid, searchable text)", security: "invoker" },
3993
4028
  { name: "intern_provenance", args: "p_data jsonb", returns: "jsonb", security: "invoker" },
3994
4029
  { name: "io_cell", args: "p_organization_id uuid, p_field jsonb, p_word text, p_date_order text DEFAULT 'mdy'::text", returns: "jsonb", security: "invoker" },
@@ -4187,6 +4222,7 @@ var STORE_DOORS = [
4187
4222
  { name: "record_state_as_of", args: "p_record_id uuid, p_at timestamp with time zone", returns: "TABLE(state jsonb, replayed boolean)", security: "definer" },
4188
4223
  { name: "record_table", args: "p_organization_id uuid, p_record_id uuid", returns: "uuid", security: "definer" },
4189
4224
  { name: "record_update", args: "p_organization_id uuid, p_record_id uuid, p_patch jsonb, p_expected_version integer DEFAULT NULL::integer", returns: "integer", security: "definer" },
4225
+ { name: "record_value_one", args: "p_organization_id uuid, p_record_id uuid, p_key text", returns: "jsonb", security: "invoker" },
4190
4226
  { name: "record_values", args: "p_organization_id uuid, p_record_id uuid", returns: "jsonb", security: "invoker" },
4191
4227
  { name: "record_values_of", args: "p_row custom.record", returns: "jsonb", security: "invoker" },
4192
4228
  { name: "record_values_versioned", args: "p_organization_id uuid, p_record_id uuid", returns: "TABLE(field_key text, field_id uuid, value jsonb, value_version integer, source jsonb, absent_reason text, actor text, on_behalf_of text, written_at timestamp with time zone, alternates jsonb)", security: "definer" },
@@ -4238,6 +4274,7 @@ var STORE_DOORS = [
4238
4274
  { name: "said", args: "p_value text, p_when_there_is_none text", returns: "text", security: "invoker" },
4239
4275
  { name: "scope_member_reaches", args: "p_user_id uuid, p_record_id uuid, p_required permission_level DEFAULT 'viewer'::permission_level", returns: "boolean", security: "invoker" },
4240
4276
  { name: "scope_table_provision", args: "p_organization_id uuid, p_item_id uuid, p_scope_id uuid, p_home_id uuid DEFAULT NULL::uuid", returns: "uuid", security: "definer" },
4277
+ { name: "sensitivity_rank", args: "p_sensitivity text", returns: "integer", security: "invoker" },
4241
4278
  { name: "share_access", args: "p_organization_id uuid, p_subject_id uuid", returns: "TABLE(principal_kind text, principal_id uuid, principal_label text, level permission_level, reason text, reason_detail text, via_type text, via_id uuid, revocable boolean)", security: "definer" },
4242
4279
  { name: "share_grant", args: "p_organization_id uuid, p_subject_id uuid, p_principal_kind text, p_principal_id uuid, p_level permission_level DEFAULT 'viewer'::permission_level", returns: "jsonb", security: "definer" },
4243
4280
  { name: "share_lane_set", args: "p_organization_id uuid, p_subject_id uuid, p_choice text, p_level permission_level DEFAULT NULL::permission_level", returns: "jsonb", security: "definer" },
@@ -4333,6 +4370,8 @@ var STORE_DOORS = [
4333
4370
  { name: "value_restore", args: "p_organization_id uuid, p_record_id uuid, p_field_key text, p_version integer, p_author jsonb", returns: "jsonb", security: "definer" },
4334
4371
  { name: "value_versions", args: "p_old jsonb, p_new jsonb", returns: "jsonb", security: "invoker" },
4335
4372
  { name: "view_declare", args: "p_organization_id uuid, p_table_id uuid, p_spec jsonb", returns: "uuid", security: "definer" },
4373
+ { name: "view_keys", args: "", returns: "TABLE(path text, shape text, layouts text[], writer text, sentence text)", security: "invoker" },
4374
+ { name: "view_keys_check", args: "p_organization_id uuid, p_table_id uuid, p_set jsonb, p_old jsonb DEFAULT '{}'::jsonb", returns: "jsonb", security: "invoker" },
4336
4375
  { name: "view_record_order_set", args: "p_organization_id uuid, p_view_id uuid, p_record_ids uuid[]", returns: "jsonb", security: "definer" },
4337
4376
  { name: "views", args: "p_organization_id uuid, p_table_id uuid DEFAULT NULL::uuid", returns: "TABLE(view_id uuid, name text, table_id uuid, filters jsonb, definition jsonb, created_at timestamp with time zone)", security: "definer" },
4338
4377
  { name: "visibility_ancestors", args: "p_item_type text, p_item_id uuid", returns: "TABLE(container_type text, container_id uuid, depth integer, max_level permission_level)", security: "definer" },
@@ -4358,7 +4397,7 @@ var STORE_DOORS = [
4358
4397
  { name: "work_assignment_fields", args: "p_options_table_id uuid DEFAULT NULL::uuid", returns: "TABLE(key text, label text, spec jsonb)", security: "invoker" },
4359
4398
  { name: "work_decide_many", args: "p_organization_id uuid, p_decisions jsonb", returns: "jsonb", security: "definer" },
4360
4399
  { name: "work_has_assignment", args: "p_organization_id uuid, p_table_id uuid", returns: "boolean", security: "definer" },
4361
- { name: "work_inbox", args: "p_organization_id uuid, p_limit integer DEFAULT 50, p_offset integer DEFAULT 0, p_include_decided boolean DEFAULT false", returns: "TABLE(item_id uuid, kind text, origin text, title text, subject_id uuid, subject_kind text, summary text, state text, due_on timestamp with time zone, due_state text, actionable boolean, requested_by uuid, requested_by_name text, at timestamp with time zone, table_id uuid, table_name text, decided_by uuid, decided_by_name text, decided_at timestamp with time zone, outcome text)", security: "definer" },
4400
+ { name: "work_inbox", args: "p_organization_id uuid, p_limit integer DEFAULT 50, p_offset integer DEFAULT 0, p_include_decided boolean DEFAULT false, p_view text DEFAULT 'inbox'::text", returns: "TABLE(item_id uuid, kind text, origin text, title text, subject_id uuid, subject_kind text, summary text, state text, due_on timestamp with time zone, due_state text, actionable boolean, requested_by uuid, requested_by_name text, at timestamp with time zone, table_id uuid, table_name text, decided_by uuid, decided_by_name text, decided_at timestamp with time zone, outcome text, snoozed_until timestamp with time zone, cleared_at timestamp with time zone, snoozed_count integer, cleared_count integer)", security: "definer" },
4362
4401
  { name: "work_instantiation_shape", args: "p_organization_id uuid, p_instantiation_id uuid", returns: "jsonb", security: "definer" },
4363
4402
  { name: "work_list", args: "p_organization_id uuid, p_flavour text DEFAULT 'mine'::text, p_include_finished boolean DEFAULT false, p_limit integer DEFAULT 100, p_offset integer DEFAULT 0", returns: "TABLE(record_id uuid, table_id uuid, table_name text, title text, assignee_id uuid, assignee_name text, assignee_user_id uuid, due_on timestamp with time zone, due_state text, status text, terminal boolean, assigned_by uuid, updated_at timestamp with time zone)", security: "definer" },
4364
4403
  { name: "work_person", args: "p_organization_id uuid, p_user_id uuid, p_create boolean DEFAULT true", returns: "uuid", security: "definer" },
@@ -4385,6 +4424,7 @@ var STORE_DOORS = [
4385
4424
  var STORE_KNOBS = [
4386
4425
  { key: "accessible_entity_ids_guard", value: "true", type: "boolean" },
4387
4426
  { key: "action_run_records_max", value: "5000", type: "integer" },
4427
+ { key: "agent_context_reads_the_copy", value: "false", type: "boolean" },
4388
4428
  { key: "agent_schema_changes", value: '"ask"', type: "string" },
4389
4429
  { key: "associations_guard", value: "true", type: "boolean" },
4390
4430
  { key: "batch_items_max", value: "500", type: "integer" },
@@ -4425,6 +4465,7 @@ var STORE_KNOBS = [
4425
4465
  { key: "form_redirect_domains", value: "[]", type: "json" },
4426
4466
  { key: "grid_layout", value: '{"mode": "auto", "wrap": false, "row_height": "normal", "fit_max_columns": 8, "freeze_first_column": false}', type: "json" },
4427
4467
  { key: "inbound_domain", value: '"inbound.matrxserver.com"', type: "string" },
4468
+ { key: "inbox_reminder_after_days", value: "3", type: "integer" },
4428
4469
  { key: "member_default_level", value: '"viewer"', type: "enum" },
4429
4470
  { key: "member_default_visibility", value: '"all_records"', type: "enum" },
4430
4471
  { key: "outside_invite_who", value: '"org_admins_and_table_owners"', type: "string" },
@@ -4455,21 +4496,23 @@ var STORE_REFUSAL_CODES = [
4455
4496
  { code: "02000", raised_by: "_checklist_instantiate,_portal_config_judge,_portal_invite_payload,_share_write_person,_table_share_invite_payload,checklist_declare,checklist_run,checklist_step_complete,checklist_step_refusal,checklist_template_shape,conversation_scope_bind,dashboard_delete,dashboard_run,doc_letterhead,doc_render_body,doc_render_document,doc_render_read,doc_sign,doc_signature_intact,doc_signature_read,doc_template_delete,doc_template_read,doc_template_save,enrich_pin,entity_field_retire,entity_field_update,entity_record_read,entity_value_write,external_history_event,external_rows,external_stub_upsert,external_writes_set,io_restore,migrate_delete,migrate_extract_parent,migrate_merge,migrate_reclass,migrate_rename,migrate_reparent,migrate_retype,migrate_split,migrate_undo,organization_clear,portal_archive,portal_card,portal_declare,portal_form,portal_form_submit,portal_invite,portal_invite_accept,portal_preview,portal_principal_bind,portal_restore,portal_revoke,read_record,record_delete,record_restore,record_restore_preview,record_table,record_update,relation_halves_repair,relation_uncarry,share_access,share_grant,share_lane_set,share_people,share_revoke,sign_request_cancel,sign_request_create,sign_request_remind,sign_request_unchanged,table_archive,table_share_outside_accept,table_share_outside_grant,table_share_outside_invite,table_share_outside_resend,table_share_outside_revoke,visibility_as_of,work_approval_decide,work_approval_read,work_approval_request,work_assign,work_record_states,work_set_state" },
4456
4497
  { code: "0A000", raised_by: "checklist_step_complete,external_rows,external_source_declare,external_write_through,promote_field,promoted_index_expr,promoted_query_sql,promoted_read,rule_eval,rule_filter_node_sql,work_assign" },
4457
4498
  { code: "22003", raised_by: "context_resolve" },
4458
- { code: "22004", raised_by: "_entity_custom_fields_guard,_portal_config_judge,_share_write_person,_value_envelope,actor_word,agg_assert_key,agg_compare_windows,agg_sql,anon_capture,anon_token_issue,anon_write,assert_client_may_reach,booking_declare,capture_submit,checklist_declare,context_resolve,dashboard_block_normalize,dashboard_declare,dashboard_window_sql,doc_render_write,doc_sign,doc_signature_write,doc_template_save,enrich_land,enrich_normalize,external_history_event,external_rows,external_source_declare,external_stub_upsert,external_write_through,external_writes_set,field_history,form_declare,form_submit,home_add,io_comment_write,io_import_begin,io_infer_column,io_outbox_drain,io_restore,migrate_choice_keys,migrate_purge,migrate_purge_hard,migrate_reclass,migrate_split,migrate_undo,organization_clear,organization_contents,pipeline_declare,pipeline_gate_preview,portal_declare,portal_form_submit,portal_invite,portal_principal_bind,provenance_retention_days,provenance_write,query_across_homes,query_by_coordinates,query_rollup,record_delete,record_reparent,record_resolve,record_restore,record_update,record_write,record_write_graph,record_write_many,relation_carry,relation_halves_repair,relation_own,rule_declare,share_grant,sign_request_create,sign_request_sign,subscription_declare,table_archive,table_declare,table_move,table_share_outside_grant,table_share_outside_invite,value_restore,view_declare,work_approval_decide,work_approval_request,work_template_declare" },
4499
+ { code: "22004", raised_by: "_entity_custom_fields_guard,_portal_config_judge,_share_write_person,_value_envelope,actor_word,agg_assert_key,agg_compare_windows,agg_sql,anon_capture,anon_token_issue,anon_write,assert_client_may_reach,booking_declare,capture_submit,checklist_declare,context_resolve,context_tag_copy,dashboard_block_normalize,dashboard_declare,dashboard_window_sql,doc_render_write,doc_sign,doc_signature_write,doc_template_save,enrich_land,enrich_normalize,external_history_event,external_rows,external_source_declare,external_stub_upsert,external_write_through,external_writes_set,field_history,form_declare,form_submit,home_add,inbox_snooze,io_comment_write,io_import_begin,io_infer_column,io_outbox_drain,io_restore,migrate_choice_keys,migrate_purge,migrate_purge_hard,migrate_reclass,migrate_split,migrate_undo,organization_clear,organization_contents,pipeline_declare,pipeline_gate_preview,portal_declare,portal_form_submit,portal_invite,portal_principal_bind,provenance_retention_days,provenance_write,query_across_homes,query_by_coordinates,query_rollup,record_delete,record_reparent,record_resolve,record_restore,record_update,record_write,record_write_graph,record_write_many,relation_carry,relation_halves_repair,relation_own,rule_declare,share_grant,sign_request_create,sign_request_sign,subscription_declare,table_archive,table_declare,table_move,table_share_outside_grant,table_share_outside_invite,value_restore,view_declare,work_approval_decide,work_approval_request,work_template_declare" },
4459
4500
  { code: "22007", raised_by: "agg_parse_moment,dashboard_window_sql" },
4460
4501
  { code: "22012", raised_by: "formula_eval,rule_eval,rule_sql_op" },
4461
- { code: "22023", raised_by: "_action_check,_booking_availability,_decorations_check,_entity_custom_fields_guard,_fx_date,_fx_num,_fx_unit,_fxp_level,_fxp_resolve,_fxp_tokens,_portal_config_judge,_take_op_id,_value_envelope,_work_shape_guard,action_run,actor_word,agg_assert_key,agg_calendar,agg_compare_windows,agg_sql,anon_token_issue,booking_declare,containment_parent,dashboard_block_normalize,dashboard_run,dashboard_target_field_assert,dashboard_window_sql,doc_render_body,doc_render_write,doc_signature_write,enrich_declare,enrich_land,enrich_normalize,enrich_pin,entity_reference_words,entity_value_write,external_history_event,external_source_declare,external_stub_upsert,external_write_through,field_history,field_update,form_declare,form_draft_save,formula_eval,formula_parse,grid_layout_check,hub_changed_by,io_export,io_import_begin,io_import_finish,io_import_plan,io_import_report,io_proposal_accept,list_portals,migrate_merge,migrate_reclass,my_levels,organization_clear,page_size,pin_agent_cells,pipeline_move,pipeline_move_many,portal_declare,portal_form_submit,provenance_write,query_by_coordinates,query_rollup,read_records_archived,read_records_in_view_order,record_filter_sql,record_update,record_write_graph,record_write_many,relation_carry,rule_eval,rule_filter_node_sql,rule_members,rule_members_visible,rule_sql_op,scope_table_provision,share_grant,share_lane_set,sign_request_create,sign_request_sign,subscription_declare,table_from_example,table_move,table_rules,table_share_outside_grant,table_sync,table_webhook_declare,view_record_order_set,visibility_as_of,work_approval_request,work_decide_many,work_list,work_slot_hold" },
4502
+ { code: "22023", raised_by: "_action_check,_booking_availability,_decorations_check,_entity_custom_fields_guard,_fx_date,_fx_num,_fx_unit,_fxp_level,_fxp_resolve,_fxp_tokens,_portal_config_judge,_take_op_id,_value_envelope,_view_field_key,_view_key_value,_work_shape_guard,action_run,actor_word,agg_assert_key,agg_calendar,agg_compare_windows,agg_sql,anon_token_issue,booking_declare,containment_parent,dashboard_block_normalize,dashboard_run,dashboard_target_field_assert,dashboard_window_sql,doc_render_body,doc_render_write,doc_signature_write,enrich_declare,enrich_land,enrich_normalize,enrich_pin,entity_reference_words,entity_value_write,external_history_event,external_source_declare,external_stub_upsert,external_write_through,field_history,field_update,form_declare,form_draft_save,formula_eval,formula_parse,grid_layout_check,hub_changed_by,inbox_snooze,io_export,io_import_begin,io_import_finish,io_import_plan,io_import_report,io_proposal_accept,list_portals,migrate_merge,migrate_reclass,my_levels,organization_clear,page_size,pin_agent_cells,pipeline_move,pipeline_move_many,portal_declare,portal_form_submit,provenance_write,query_by_coordinates,query_rollup,read_records_archived,read_records_in_view_order,record_filter_sql,record_update,record_write_graph,record_write_many,relation_carry,rule_eval,rule_filter_node_sql,rule_members,rule_members_visible,rule_sql_op,scope_table_provision,share_grant,share_lane_set,sign_request_create,sign_request_sign,subscription_declare,table_from_example,table_move,table_rules,table_share_outside_grant,table_sync,table_webhook_declare,view_declare,view_keys_check,view_record_order_set,visibility_as_of,work_approval_request,work_decide_many,work_inbox,work_list,work_slot_hold" },
4462
4503
  { code: "23503", raised_by: "_action_check,_booking_availability,_checklist_instantiate,_containment_guard,_decorations_check,_display_spec_for,_field_document_for,_field_type_parity_guard,_pipeline_stage_key,_record_rule_uses,action_declare,action_run,agg_digest_assemble,anon_publish,anon_rate_take,anon_token_issue,anon_write,assert_organization_wall,autonumber_backfill,booking_cancel,booking_confirm,booking_declare,booking_hold,booking_reschedule,capture_publish,checklist_declare,checklist_steps_table,comment_write,dashboard_declare,delete_rule,doc_sign,doc_template_save,enrich_declare,enrich_due,enrich_land,form_declare,form_draft_save,form_submit,grid_layout,home_add,inbound_declare,inbound_mail_land,inbound_set,io_comment_write,io_import_begin,io_import_finish,io_import_report,io_import_rows,io_proposal_accept,migrate_demote,migrate_promote,pipeline_board,pipeline_declare,pipeline_move,pipeline_read,pipeline_transition_refusal,promote_field,promote_table,read_records_in_view_order,record_applicability,record_reparent,relation_carry,relation_own,resolve_first_match,rule_applies,rule_declare,rule_eval,rule_filter_node_sql,rule_members,rule_members_visible,rule_run,sign_request_create,subscription_mute,subscription_preview,table_decorate,table_from_example,table_webhook_archive,table_webhook_declare,view_declare,view_record_order_set,work_set_state,work_take_assignment,work_template_instantiate" },
4463
4504
  { code: "23505", raised_by: "_portal_config_judge,_share_write_person,_unique_rule_holds,doc_sign,doc_signature_write,entity_field_declare,field_declare,home_add,inbound_declare,io_proposal_accept,relation_carry,relation_own,sign_request_cancel,sign_request_create,table_share_outside_resend,work_approval_decide,work_slot_hold" },
4464
- { code: "23514", raised_by: "_checklist_instantiate,_checklist_step_guard,_containment_guard,_dated_values_guard,_derived_fields,_display_format_check,_display_spec_for,_entity_custom_fields_guard,_field_class_guard,_field_document_for,_field_shape_guard,_field_type_parity_guard,_merge_field_shape_guard,_merge_field_temporal_guard,_promoted_field_cap_guard,_record_rule_uses,_relation_halves_agree,_relation_kernel_targets,_resolve_choice_words,_rule_shape_guard,_rule_topology_guard,_store_relation_edge_names_its_field,_table_columns_word_guard,_table_shape_guard,_undeclared_key_guard,_value_envelope,_with_display,_work_shape_guard,_workdoors_approval_guard,action_run,assert_columns_are_defined,assert_entity_is_organization_scoped,booking_declare,capture_publish,capture_sheet_declare,checklist_declare,checklist_step_complete,doc_sign,doc_signature_write,doc_template_save,entity_field_declare,entity_field_retire,entity_field_update,entity_records_find,entity_table,field_declare,field_retire,field_update,home_add,io_comment_write,io_import_rows,migrate_merge,migrate_purge_hard,portal_archive,portal_restore,record_write_graph,relation_carry,relation_halves_repair,relation_own,sign_request_create,sign_request_sign,table_declare,table_from_example,validate_value_envelope,validate_values,work_set_state,work_slots_declare,work_take_assignment,work_template_instantiate" },
4505
+ { code: "23514", raised_by: "_checklist_instantiate,_checklist_step_guard,_containment_guard,_dated_values_guard,_derived_fields,_display_format_check,_display_spec_for,_entity_custom_fields_guard,_field_class_guard,_field_document_for,_field_shape_guard,_field_type_parity_guard,_merge_field_shape_guard,_merge_field_temporal_guard,_promoted_field_cap_guard,_record_rule_uses,_relation_halves_agree,_relation_kernel_targets,_resolve_choice_words,_rule_shape_guard,_rule_topology_guard,_store_relation_edge_names_its_field,_table_columns_word_guard,_table_shape_guard,_undeclared_key_guard,_value_envelope,_with_display,_work_shape_guard,_workdoors_approval_guard,action_run,assert_columns_are_defined,assert_entity_is_organization_scoped,booking_declare,capture_publish,capture_sheet_declare,checklist_declare,checklist_step_complete,doc_sign,doc_signature_write,doc_template_save,entity_field_declare,entity_field_retire,entity_field_update,entity_records_find,entity_table,field_declare,field_retire,field_update,home_add,io_comment_write,io_import_rows,migrate_merge,migrate_purge_hard,portal_archive,portal_restore,record_restore,record_write_graph,relation_carry,relation_halves_repair,relation_own,sign_request_create,sign_request_sign,table_declare,table_from_example,validate_value_envelope,validate_values,work_set_state,work_slots_declare,work_take_assignment,work_template_instantiate" },
4465
4506
  { code: "40001", raised_by: "has_visibility_at,table_move" },
4466
- { code: "42501", raised_by: "_context_copy_fence,_doc_render_immutable,_doc_signature_immutable,_field_definition_write,_field_write_door,_portal_config_judge,_portal_principal_here,_rule_definition_write,_store_door,agent_table_claim,agg_fields_readable_assert,anon_capture,anon_inbound_land,anon_publish,anon_token_issue,anon_token_verify,anon_write,assert_client_may_change,assert_client_may_open,assert_client_may_reach,assert_may_know_table,assert_organization_admin,assert_store_door,booking_confirm,booking_declare,booking_hold,capture_submit,checklist_run,comment_write,context_resolve,conversation_scope_bind,conversation_scope_unbind,dashboard_target_field_assert,doc_sign,enrich_declare,enrich_due,enrich_land,enrich_normalize,entity_field_declare,entity_field_retire,entity_field_update,entity_value_write,external_write_through,form_declare,form_draft_save,form_public_asks,form_submit,inbound_mail_land,io_comment_resolve,io_comment_write,io_import_begin,io_import_finish,io_restore,migrate_purge,migrate_purge_hard,migrate_purge_hard_request,migrate_reclass,my_levels,organization_clear,organization_contents,portal_declare,portal_form,portal_form_submit,portal_invitation,portal_invite,portal_invite_accept,portal_principal_bind,promote_table,query_visibility_parity,read_record,read_records,read_records_archived,read_records_by_ids,read_records_matching,record_table,record_write_graph,relation_halves_disagreements,relation_halves_repair,resolve_context,scope_table_provision,share_grant,subscription_mute,subscription_preview,table_move,table_share_outside_accept,table_share_outside_grant,table_share_outside_invite,table_share_outside_resend,table_webhook_declare,visibility_as_of,work_approval_decide,work_approval_read,work_approval_request,work_person" },
4507
+ { code: "42501", raised_by: "_context_copy_fence,_doc_render_immutable,_doc_signature_immutable,_field_definition_write,_field_write_door,_portal_config_judge,_portal_principal_here,_rule_definition_write,_store_door,agent_table_claim,agg_fields_readable_assert,anon_capture,anon_inbound_land,anon_publish,anon_token_issue,anon_token_verify,anon_write,assert_client_may_change,assert_client_may_open,assert_client_may_reach,assert_may_know_table,assert_organization_admin,assert_store_door,booking_confirm,booking_declare,booking_hold,capture_submit,checklist_run,comment_write,context_resolve,conversation_scope_bind,conversation_scope_unbind,dashboard_target_field_assert,doc_sign,enrich_declare,enrich_due,enrich_land,enrich_normalize,entity_field_declare,entity_field_retire,entity_field_update,entity_value_write,external_write_through,form_declare,form_draft_save,form_public_asks,form_submit,inbound_mail_land,inbox_clear,inbox_snooze,inbox_unclear,inbox_unsnooze,io_comment_resolve,io_comment_write,io_import_begin,io_import_finish,io_restore,migrate_purge,migrate_purge_hard,migrate_purge_hard_request,migrate_reclass,my_levels,organization_clear,organization_contents,portal_declare,portal_form,portal_form_submit,portal_invitation,portal_invite,portal_invite_accept,portal_principal_bind,promote_table,query_visibility_parity,read_record,read_records,read_records_archived,read_records_by_ids,read_records_matching,record_table,record_write_graph,relation_halves_disagreements,relation_halves_repair,resolve_context,scope_table_provision,share_grant,subscription_mute,subscription_preview,table_move,table_share_outside_accept,table_share_outside_grant,table_share_outside_invite,table_share_outside_resend,table_webhook_declare,visibility_as_of,work_approval_decide,work_approval_read,work_approval_request,work_person" },
4467
4508
  { code: "42703", raised_by: "entity_table,portal_declare" },
4509
+ { code: "42P17", raised_by: "_field_reads_what_it_reads,far_value" },
4468
4510
  { code: "53400", raised_by: "anon_rate_take,delete_cascade_closure,enrich_due,enrich_land,promote_field" },
4469
4511
  { code: "54000", raised_by: "action_run,form_draft_save,hub_changed_by,pipeline_move_many,record_headers,table_decorate,table_from_example,table_row_counts,table_sync,table_webhook_declare,view_record_order_set,work_decide_many" },
4470
4512
  { code: "54001", raised_by: "record_delete" },
4471
- { code: "55000", raised_by: "table_move,work_approval_decide,work_approval_request" },
4513
+ { code: "55000", raised_by: "inbox_clear,inbox_snooze,table_move,work_approval_decide,work_approval_request" },
4472
4514
  { code: "P0001", raised_by: "action_run" },
4515
+ { code: "P0002", raised_by: "inbox_clear,inbox_snooze" },
4473
4516
  { code: "PT409", raised_by: "record_update" },
4474
4517
  { code: "PT428", raised_by: "_record_rule_uses" }
4475
4518
  ];
@@ -6054,6 +6097,12 @@ var DOORS = {
6054
6097
  workApprovalDecide: "work_approval_decide",
6055
6098
  /** Lane S4: many inbox decisions, one call, a verdict per item. */
6056
6099
  workDecideMany: "work_decide_many",
6100
+ /** Lane S5-PRIME-2: one person's own inbox state — snooze, clear, and the counts. */
6101
+ inboxSnooze: "inbox_snooze",
6102
+ inboxUnsnooze: "inbox_unsnooze",
6103
+ inboxClear: "inbox_clear",
6104
+ inboxUnclear: "inbox_unclear",
6105
+ inboxCounts: "inbox_counts",
6057
6106
  workApprovalRead: "work_approval_read",
6058
6107
  // PRODUCTS row 13 — checklists and SOP runs.
6059
6108
  checklistRefusal: "checklist_refusal",
@@ -8001,11 +8050,47 @@ function createRecordsClient(config) {
8001
8050
  p_organization_id: org,
8002
8051
  p_limit: args?.limit ?? 50,
8003
8052
  p_offset: args?.offset ?? 0,
8004
- p_include_decided: args?.includeDecided ?? false
8053
+ p_include_decided: args?.includeDecided ?? false,
8054
+ p_view: args?.view ?? "inbox"
8005
8055
  },
8006
8056
  "workInbox"
8007
8057
  );
8008
8058
  },
8059
+ async inboxSnooze({ item_id, until }) {
8060
+ return callDoor(
8061
+ DOORS.inboxSnooze,
8062
+ { p_organization_id: org, p_item_id: item_id, p_until: until },
8063
+ "inboxSnooze"
8064
+ );
8065
+ },
8066
+ async inboxUnsnooze({ item_id }) {
8067
+ return callDoor(
8068
+ DOORS.inboxUnsnooze,
8069
+ { p_organization_id: org, p_item_id: item_id },
8070
+ "inboxUnsnooze"
8071
+ );
8072
+ },
8073
+ async inboxClear({ item_id }) {
8074
+ return callDoor(
8075
+ DOORS.inboxClear,
8076
+ { p_organization_id: org, p_item_id: item_id },
8077
+ "inboxClear"
8078
+ );
8079
+ },
8080
+ async inboxUnclear({ item_id }) {
8081
+ return callDoor(
8082
+ DOORS.inboxUnclear,
8083
+ { p_organization_id: org, p_item_id: item_id },
8084
+ "inboxUnclear"
8085
+ );
8086
+ },
8087
+ async inboxCounts(args) {
8088
+ return callDoor(
8089
+ DOORS.inboxCounts,
8090
+ { p_organization_id: args?.everyOrganization ? null : org },
8091
+ "inboxCounts"
8092
+ );
8093
+ },
8009
8094
  async workList(args) {
8010
8095
  return callDoor(
8011
8096
  DOORS.workList,