Repository navigation
Commit 568dc0b
fix(data): record-change payloads apply the write-response credential mask and internal-field omission (#21866)
Fixes #21830
Clause-②: yes (widening)
Record-change payloads apply the same credential mask and internal-field
omission as write responses.
## What changed
One rule, one helper: `omitInternalFieldsFromWriteResponse`
(`@objectstack/core`, the helper PR #21816 landed for write responses).
No second copy of the rule anywhere.
- **Engine record-change publish** (`packages/objectql/src/engine.ts`,
`publishDataEvent`). The `after` and `changes` bodies of
`data.record.created` / `data.record.updated` are projected through the
helper on a fresh shallow copy: credential-class fields carry
`SECRET_MASK` (or `null` when unset), `internal: true` fields are
omitted. The engine's own write result is untouched, so privileged
in-process callers are unchanged.
- **Defence in depth** at the downstream producers that store or forward
a record body, each through the same helper or its collectors:
- approval request snapshot (`plugin-approvals`, `payload_json` when the
request is opened);
- outbound webhook body and its stored delivery row (`plugin-webhooks`
auto-enqueuer, `after` and `changes`);
- knowledge index documents (`service-knowledge` `recordToDocument`
takes the object definition as an optional fourth argument and skips
credential-class and `internal` fields, under `'*'` and when named
explicitly).
- The audit trail already masked these fields and is unchanged. No
accept set changes; the one public-surface change is additive (see
Review round 1).
- Changeset: `.changeset/record-change-payload-credential-mask.md`
(minor for `@objectstack/service-knowledge`, patch for the other three).
## Verification (head d6e0eae, after merging origin/main)
- Dependency closure build of the four touched packages: `VERDICT
command-exit 0`.
- `@objectstack/objectql` full suite: `Test Files 376 passed (376)`,
`Tests 7486 passed (7486)`.
- `@objectstack/plugin-approvals`: 60 files / 895 tests passed.
`@objectstack/plugin-webhooks`: 14 / 163 passed.
`@objectstack/service-knowledge`: 4 / 49 passed.
- `typecheck` for objectql, plugin-approvals, plugin-webhooks: green
(`check:test-typecheck: OK`). service-knowledge has no typecheck script.
- Dogfood, real boot:
`test/approval-snapshot-credential-field.dogfood.test.ts` 1 passed,
after a build of the dogfood dependency closure.
- Gates: `node scripts/pm/dispatch-gates.mjs --commands` derived 75
families; all 75 run, all exit 0 (plus `check-nul-bytes`); `--ran`
reconciliation: 75 run, 0 NOT-MEASURED, a derived zero with exit codes
recorded.
- Ablation (one-shot, via `scripts/ablation-replace.mjs`, from the
committed state): removing the helper call in the engine's event-body
projection turns `src/engine-realtime-credential-mask.test.ts` red (3
failed, 1 passed); restore proven by blob hash equal to HEAD
(48b8210) and an empty `git diff HEAD`.
- Not run locally, declared to CI: repo-wide lint and the
wide-population gate families.
## Acceptance notes
- Payload projections are idempotent over an already-projected body, so
the engine projection and the downstream defence-in-depth layers
compose.
- A producer whose engine exposes no `getSchema` (or an unregistered
object) projects nothing, matching the helper's own posture; the
engine-side projection still applies upstream.
---
_Generated by [Claude
Code](https://claude.ai/code/session_018zT8d8NpiQ1ExhuNd5TxY6)_
## Review round 1 (PM seat)
- `@objectstack/service-knowledge` is now `minor`: `recordToDocument`, a
published export, gains an optional fourth argument (the object
definition); three-argument calls behave as before.
- The outbound webhook projection also covers `before` (no producer
fills it today).
- The changeset now says receivers see masked values, and that rows
written before this change are not rewritten (reindexing a knowledge
source refreshes its documents).
- Head `c87404e8c4`: `@objectstack/plugin-webhooks` 163/163; the
changeset gates green against `origin/main`.
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 149153c commit 568dc0b
10 files changed
Lines changed: 779 additions & 12 deletions
File tree
- .changeset
- packages
- objectql/src
- plugins
- plugin-approvals/src
- plugin-webhooks/src
- qa/dogfood/test
- services/service-knowledge/src
- __tests__
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
Lines changed: 144 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
119 | 119 | | |
120 | 120 | | |
121 | 121 | | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
122 | 127 | | |
123 | 128 | | |
124 | 129 | | |
| |||
3365 | 3370 | | |
3366 | 3371 | | |
3367 | 3372 | | |
| 3373 | + | |
| 3374 | + | |
| 3375 | + | |
| 3376 | + | |
| 3377 | + | |
| 3378 | + | |
| 3379 | + | |
| 3380 | + | |
| 3381 | + | |
| 3382 | + | |
| 3383 | + | |
| 3384 | + | |
| 3385 | + | |
| 3386 | + | |
| 3387 | + | |
| 3388 | + | |
| 3389 | + | |
| 3390 | + | |
| 3391 | + | |
| 3392 | + | |
| 3393 | + | |
| 3394 | + | |
| 3395 | + | |
| 3396 | + | |
| 3397 | + | |
| 3398 | + | |
| 3399 | + | |
3368 | 3400 | | |
3369 | 3401 | | |
3370 | 3402 | | |
| |||
7572 | 7604 | | |
7573 | 7605 | | |
7574 | 7606 | | |
7575 | | - | |
7576 | | - | |
| 7607 | + | |
| 7608 | + | |
| 7609 | + | |
| 7610 | + | |
| 7611 | + | |
| 7612 | + | |
| 7613 | + | |
| 7614 | + | |
| 7615 | + | |
| 7616 | + | |
| 7617 | + | |
7577 | 7618 | | |
7578 | 7619 | | |
7579 | 7620 | | |
7580 | 7621 | | |
7581 | 7622 | | |
7582 | | - | |
7583 | | - | |
7584 | | - | |
7585 | | - | |
| 7623 | + | |
7586 | 7624 | | |
7587 | 7625 | | |
7588 | 7626 | | |
| |||
Lines changed: 33 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
66 | | - | |
| 66 | + | |
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
| |||
3038 | 3038 | | |
3039 | 3039 | | |
3040 | 3040 | | |
3041 | | - | |
| 3041 | + | |
3042 | 3042 | | |
3043 | 3043 | | |
3044 | 3044 | | |
| |||
5915 | 5915 | | |
5916 | 5916 | | |
5917 | 5917 | | |
| 5918 | + | |
| 5919 | + | |
| 5920 | + | |
| 5921 | + | |
| 5922 | + | |
| 5923 | + | |
| 5924 | + | |
| 5925 | + | |
| 5926 | + | |
| 5927 | + | |
| 5928 | + | |
| 5929 | + | |
| 5930 | + | |
| 5931 | + | |
| 5932 | + | |
| 5933 | + | |
| 5934 | + | |
| 5935 | + | |
| 5936 | + | |
| 5937 | + | |
| 5938 | + | |
| 5939 | + | |
| 5940 | + | |
| 5941 | + | |
| 5942 | + | |
| 5943 | + | |
| 5944 | + | |
| 5945 | + | |
| 5946 | + | |
| 5947 | + | |
| 5948 | + | |
5918 | 5949 | | |
5919 | 5950 | | |
5920 | 5951 | | |
| |||
0 commit comments