Skip to content

Commit 2e76c1b

Browse files
committed
docs(plugin-approvals): describe the organisation-less envelope by its effect
Claude-Session: https://claude.ai/code/session_01LR1cD9JqgkeqY7k9rrZH8s Co-authored-by: Claude <noreply@anthropic.com>
1 parent 8f78b06 commit 2e76c1b

3 files changed

Lines changed: 4 additions & 4 deletions

File tree

‎.changeset/24519-approvals-context-identity.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ fix(plugin-approvals): an approval's status write-back runs its automation as th
77
Clause-②: no
88

99
- **What changes.** The write that mirrors a request's status onto the record's `approvalStatusField` (submit, approve, reject, recall, send back, the action link) now names the organisation of the record it writes, and no longer carries an empty set of positions and permission sets. A `runAs: 'user'` hook on that object, and a `runAs: 'user'` record-change flow fired by that write, now run with the acting person's own request envelope in the record's organisation: their positions, their permission sets and their organisation's members, resolved exactly as their own request in that organisation resolves them.
10-
- **Before.** Such a hook ran on the member baseline and saw only the acting person in `sys_user`. Such a flow resolved the person's grants with no organisation: it saw only the person as a peer, and its positions came from every organisation the person belongs to rather than from the record's.
10+
- **Before.** Such a hook ran on the member baseline and saw only the acting person in `sys_user`. Such a flow resolved the person's grants with no organisation, so it saw only the person as a peer and did not run with what the record's organisation grants them.
1111
- **Every acting person, one organisation.** An approver drawn from another organisation's directory also acts in the record's organisation. The organisation is read from the record when the status is written, so a record moved to another organisation while its approval was pending is written, and cascades, in its new organisation.
1212
- **Unchanged.** The write stays elevated (`isSystem`), so it still lands on a locked record and on a read-only status field. A status written by a sweep with no person behind it (the dead-run release) stays user-less, so a `runAs: 'user'` automation it fires is still refused. `ctx.session.organizationId` in a hook on the write now carries the organisation, and `ctx.session.positions` is absent instead of an empty list.
1313

‎packages/plugins/plugin-approvals/src/approval-service.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3186,8 +3186,8 @@ export class ApprovalService implements IApprovalService {
31863186
* Nothing downstream supplies a missing organisation: the automation
31873187
* engine's grants bridge answers a `tenantId` only when it was handed one,
31883188
* and an organisation-less resolution is not the actor's request in the
3189-
* record's organisation — its peers are the actor alone, and its positions
3190-
* come from every organisation the actor belongs to.
3189+
* record's organisation — its peers are the actor alone, and its grants
3190+
* are not the ones that organisation gives them.
31913191
* The write itself is authorized by `isSystem` alone — the security
31923192
* middleware short-circuits before it reads any grant — so leaving the arrays
31933193
* off changes nothing about what this write may do.

‎packages/plugins/plugin-approvals/src/status-mirror-envelope.integration.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
* Two producer facts make that true, and each has its own pins here:
1717
* - the write names the organisation (`tenantId`), read live off the record.
1818
* Without it every consumer resolves organisation-less: the person alone as
19-
* peer, and positions from every organisation they belong to;
19+
* peer, and grants that are not the ones the record's organisation gives;
2020
* - the write carries NO `positions` / `permissions` of its own. A consumer
2121
* keeps carried arrays verbatim, so empty ones stood in for the person's
2222
* grants and left the hook on the member baseline.

0 commit comments

Comments
 (0)