Repository navigation
fix(media): honor sender policy for host media reads - #64459
Conversation
Greptile SummaryThis PR threads sender and group context into outbound host-media read capability resolution, so that a group member explicitly denied the Confidence Score: 5/5Safe to merge — the sender-policy gate is correctly implemented and all production call sites consistently propagate sender context. No P0 or P1 findings. The core logic in src/media/read-capability.test.ts — minor test-shape inconsistency with production call sites (P2 only). Prompt To Fix All With AIThis is a comment left during a code review.
Path: src/media/read-capability.test.ts
Line: 52-53
Comment:
**Test passes `messageProvider` alongside `sessionKey`**
Every production call site sets `messageProvider: undefined` when `sessionKey` is present (e.g. `deliver.ts`, `outbound-send-service.ts`, and `message-action-runner.ts` all gate on `params.session?.key ? undefined : channel`). Functionally the tests are correct — `resolveGroupToolPolicy` uses `messageProvider ?? sessionContext.channel` and both paths resolve to `"whatsapp"` — but the tests don't precisely mirror the real call shape, which could hide a future regression if that precedence order ever changes. Consider omitting `messageProvider` from tests that supply a `sessionKey` to keep them aligned with the production call sites.
How can I resolve this? If you propose a fix, please make it concise.Reviews (1): Last reviewed commit: "fix(media): preserve account policy fall..." | Re-trigger Greptile |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 100fca7681
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
…or e164/username/name policy matching
100fca7 to
6efc7a4
Compare
…der when sessionKey is set Addresses P2 review: production call sites pass messageProvider: undefined when sessionKey is present; tests should mirror that so regressions in the precedence order are caught.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6348e1f64d
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| sessionKey: params.session?.key, | ||
| messageProvider: params.session?.key ? undefined : channel, | ||
| accountId: params.session?.requesterAccountId ?? accountId, |
There was a problem hiding this comment.
Persist requester policy context for queued retries
Fresh evidence in this commit is that outbound media access now depends on params.session requester metadata (sessionKey/sender/account), but recovery replay still rebuilds deliveries from QueuedDeliveryPayload without any session/requester fields (delivery-queue-storage.ts + delivery-queue-recovery.ts). After a crash/restart, retries reach this branch with params.session unset and evaluate host-media read policy against destination-only context, so sender-scoped denies (for example toolsBySender on read) can be bypassed on replay; queue entries need to persist and replay requester session metadata so retry behavior matches the initial attempt.
Useful? React with 👍 / 👎.
* fix(media): honor sender policy for host media reads * fix(media): clarify host read group policy gating * fix(media): forward sender identity for outbound reads * fix(media): propagate non-id sender fields through outbound session for e164/username/name policy matching * fix(media): preserve requester provider for host read policy * fix(media): forward full sender identity through followup and core send paths * fix(media): forward requester session/account context through core send fallback * fix(media): preserve account policy fallback for requester-scoped host reads * chore(changelog): add outbound media sender-policy entry * fix(media): align test call shape with production — omit messageProvider when sessionKey is set Addresses P2 review: production call sites pass messageProvider: undefined when sessionKey is present; tests should mirror that so regressions in the precedence order are caught. --------- Co-authored-by: Devin Robison <[email protected]>
* fix(media): honor sender policy for host media reads * fix(media): clarify host read group policy gating * fix(media): forward sender identity for outbound reads * fix(media): propagate non-id sender fields through outbound session for e164/username/name policy matching * fix(media): preserve requester provider for host read policy * fix(media): forward full sender identity through followup and core send paths * fix(media): forward requester session/account context through core send fallback * fix(media): preserve account policy fallback for requester-scoped host reads * chore(changelog): add outbound media sender-policy entry * fix(media): align test call shape with production — omit messageProvider when sessionKey is set Addresses P2 review: production call sites pass messageProvider: undefined when sessionKey is present; tests should mirror that so regressions in the precedence order are caught. --------- Co-authored-by: Devin Robison <[email protected]>
* fix(media): honor sender policy for host media reads * fix(media): clarify host read group policy gating * fix(media): forward sender identity for outbound reads * fix(media): propagate non-id sender fields through outbound session for e164/username/name policy matching * fix(media): preserve requester provider for host read policy * fix(media): forward full sender identity through followup and core send paths * fix(media): forward requester session/account context through core send fallback * fix(media): preserve account policy fallback for requester-scoped host reads * chore(changelog): add outbound media sender-policy entry * fix(media): align test call shape with production — omit messageProvider when sessionKey is set Addresses P2 review: production call sites pass messageProvider: undefined when sessionKey is present; tests should mirror that so regressions in the precedence order are caught. --------- Co-authored-by: Devin Robison <[email protected]>
* fix(media): honor sender policy for host media reads * fix(media): clarify host read group policy gating * fix(media): forward sender identity for outbound reads * fix(media): propagate non-id sender fields through outbound session for e164/username/name policy matching * fix(media): preserve requester provider for host read policy * fix(media): forward full sender identity through followup and core send paths * fix(media): forward requester session/account context through core send fallback * fix(media): preserve account policy fallback for requester-scoped host reads * chore(changelog): add outbound media sender-policy entry * fix(media): align test call shape with production — omit messageProvider when sessionKey is set Addresses P2 review: production call sites pass messageProvider: undefined when sessionKey is present; tests should mirror that so regressions in the precedence order are caught. --------- Co-authored-by: Devin Robison <[email protected]>
* fix(media): honor sender policy for host media reads * fix(media): clarify host read group policy gating * fix(media): forward sender identity for outbound reads * fix(media): propagate non-id sender fields through outbound session for e164/username/name policy matching * fix(media): preserve requester provider for host read policy * fix(media): forward full sender identity through followup and core send paths * fix(media): forward requester session/account context through core send fallback * fix(media): preserve account policy fallback for requester-scoped host reads * chore(changelog): add outbound media sender-policy entry * fix(media): align test call shape with production — omit messageProvider when sessionKey is set Addresses P2 review: production call sites pass messageProvider: undefined when sessionKey is present; tests should mirror that so regressions in the precedence order are caught. --------- Co-authored-by: Devin Robison <[email protected]>
Summary
readtool policy checksChanges
src/media/read-capability.tsso hostreadFilesupport now intersects the existing group tool policy forreadsessionKey, channel/account context, and requester sender id from outbound message paths into media access resolutionValidation
corepack pnpm test src/media/read-capability.test.tscorepack pnpm test src/infra/outbound/message-action-runner.plugin-dispatch.test.tscorepack pnpm buildclaude -p "/review"; the command returned a PR-list approval prompt instead of a local diff review, so I completed manual diff review after the local test/build gatespnpm checkduringscripts/committerNotes