Repository navigation
feat(syntropy-mcp): B5 ChannelRenderingPolicy (R7 PHI-egress boundary) — fully fail-closed, inert - #61
Conversation
…egradation) — closes the PHI-egress boundary. Component descriptors riding in channelData degrade to TEXT on messaging channels (WhatsApp/Slack have no native component render); PHI-aware per the ratified Q6 ruling: a health-marked descriptor (any ui.fields[].sensitivity==='health') on a NON-phiApproved channel (default set empty → WhatsApp minimizes) is replaced with a fixed generic confirm + optional deep-link, NEVER ui.summary (proven no health-specific leak — B5 scrubs the summary B4's producer may put on payload.text). Consulted at the deliver.ts fork; behavior-preserving (non-component/no channelData → byte-identical). +14 tests, config field outboundRendering Generated-With: Claude Code Co-Authored-By: cto <[email protected]> Co-Authored-By: Claude <[email protected]>
…(red-first). SEC-1: minimization is now CHANNEL-KEYED per ratified R7/Q6 (was gated on field-level sensitivity SJ doesn't emit → food-log macros shipped to Meta by default) — non-phiApproved channel minimizes by default; ui.summary passes ONLY for phiApproved channels or pure-nav (render:navigate|url) descriptors; fail-closed by construction (empty default → unknown channel minimizes). SEC-2: parse-fail on a type:component carrier fails SAFE (minimize+drop, not forward). SEC-3: mediaUrls dropped on minimize (no meal-photo egress). SEC-4: third-party channels (whatsapp/slack/…) denylisted IN CODE from phiApprovedChannels + one-time warn (config typo can't open the boundary). SEC-5: scrub runs before message_sending hook (hooks/logs see minimized). CTO fail-closed gate: unknown-channel red-first test drops the macro field. 22+36 tests QGR-Finding: SEC-1-PHI-leak Generated-With: Claude Code Co-Authored-By: cto <[email protected]> Co-Authored-By: Claude <[email protected]>
…H (last producer-controlled PHI-egress path). render is producer-controlled, so render:navigate|url → full ui.summary let a mismarked/compromised backend smuggle a food-log card's health summary + media past both the channel gate AND the third-party denylist (proven red-first: leaked before, minimized after). REMOVED the nav-passthrough entirely — now two-branch fully fail-closed: full ui.summary ONLY for an explicitly-phiApproved non-denylisted channel; EVERY other case (incl. render:navigate|url, unknown channels) minimizes + drops media. Nav-summary passthrough deferred to openclaw-channel-tool-hooks (owns nav rendering + its own PHI analysis). + channel-name normalization (denylist robust to case/whitespace). 24+36 tests QGR-Finding: nav-passthrough-HIGH Generated-With: Claude Code Co-Authored-By: cto <[email protected]> Co-Authored-By: Claude <[email protected]>
…ngPolicy (PHI-egress, fully fail-closed) Generated-With: Claude Code Co-Authored-By: cto <[email protected]> Co-Authored-By: Claude <[email protected]>
📝 WalkthroughWalkthroughGateway configuration and schema now support outbound rendering rules. A new policy minimizes health-related component content on non-approved channels, removes associated media, and runs before outbound hooks. Tests cover fail-closed behavior, malformed carriers, denylisting, deep links, and hook visibility. ChangesR7 outbound rendering
Estimated code review effort: 4 (Complex) | ~45 minutes Possibly related PRs
Sequence Diagram(s)sequenceDiagram
participant Gateway
participant Delivery
participant RenderPolicy
participant Hooks
participant Channel
Gateway->>Delivery: Provide outboundRendering settings
Delivery->>RenderPolicy: Plan channelData rendering
RenderPolicy-->>Delivery: Return scrubbed text decision
Delivery->>Hooks: Run message_sending with minimized payload
Hooks-->>Delivery: Return optional replacement content
Delivery->>Channel: Send final payload
Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
The formal models extracted constants ( This check is informational (not blocking merges yet). If this change is intentional, follow up by updating the formal models repo or regenerating the extracted artifacts there. |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/infra/outbound/render-policy.ts`:
- Around line 121-136: Normalize each value returned by
sanitizePhiApprovedChannels before comparing it with channel in
planChannelRender, reusing the existing normalizeChannelName helper if
available. Ensure casing and surrounding whitespace in phiApprovedChannels
configuration do not cause approved channels to fall through to minimizedText.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: f862aac7-5d69-442c-b92f-1fa6e299157d
📒 Files selected for processing (7)
src/config/types.gateway.tssrc/config/zod-schema.tssrc/infra/outbound/deliver.test.tssrc/infra/outbound/deliver.tssrc/infra/outbound/render-policy.test.tssrc/infra/outbound/render-policy.tsworkstreams/openclaw/qgr/SyntropyHealth-Applications-mo-openclaw-openclaw-SyntropyHealth-Applications-qgr-pr-prep-20260711-0127-3b2df03.md
| export function planChannelRender( | ||
| descriptor: ComponentDescriptor, | ||
| channel: string, | ||
| opts?: ChannelRenderingOptions, | ||
| ): RenderPlan { | ||
| const { approved } = sanitizePhiApprovedChannels(opts?.phiApprovedChannels); | ||
|
|
||
| if (approved.includes(channel)) { | ||
| // phiApproved (and NOT a denylisted third-party): full summary permitted. | ||
| return { kind: "text", text: descriptor.ui.summary, minimized: false }; | ||
| } | ||
|
|
||
| // Everything else — ANY descriptor on a non-phiApproved channel, including | ||
| // render:navigate|url — is minimized. Presume health-bearing. | ||
| return { kind: "text", text: minimizedText(descriptor, opts), minimized: true }; | ||
| } |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Find how OutboundChannel ids are declared/normalized
rg -nP --type=ts -C3 'type OutboundChannel|OutboundChannel\s*=' src/infra/outbound/targets.ts
rg -nP --type=ts -C2 '\bchannel\s*[:=]\s*"[A-Z]' src/infra/outboundRepository: Syntropy-Health/openclaw
Length of output: 715
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Map the relevant outbound files and inspect the render-policy logic plus channel definitions.
ast-grep outline src/infra/outbound/render-policy.ts --view expanded
printf '\n--- targets.ts outline ---\n'
ast-grep outline src/infra/outbound/targets.ts --view expanded
printf '\n--- message-channel references ---\n'
rg -n --type=ts 'normalizeChannelName|sanitizePhiApprovedChannels|planChannelRender|DeliverableMessageChannel|message channel|channel:' src/infra/outbound src/utils -g '!**/*.d.ts'Repository: Syntropy-Health/openclaw
Length of output: 36455
🏁 Script executed:
#!/bin/bash
set -euo pipefail
sed -n '1,220p' src/infra/outbound/render-policy.ts
printf '\n--- message-channel.ts ---\n'
sed -n '1,220p' src/utils/message-channel.ts
printf '\n--- render-policy tests around approval handling ---\n'
sed -n '120,220p' src/infra/outbound/render-policy.test.tsRepository: Syntropy-Health/openclaw
Length of output: 17224
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '%s\n' '--- planChannelRender call sites ---'
rg -n --type=ts 'planChannelRender\(' src
printf '\n%s\n' '--- channel normalization before render-policy call sites ---'
rg -n --type=ts 'normalizeMessageChannel|resolveMessageChannel|resolveGatewayMessageChannel|isThirdPartyChannel|sanitizePhiApprovedChannels' src/infra/outbound src/utils
printf '\n%s\n' '--- outbound tests for mixed-case channel inputs ---'
rg -n --type=ts -C2 '"[A-Z][^"]*"' src/infra/outbound/render-policy.test.ts src/infra/outbound/*.ts src/utils/*.test.tsRepository: Syntropy-Health/openclaw
Length of output: 50380
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Inspect outbound delivery path and config schema/docs for phiApprovedChannels normalization or lowercase constraints.
sed -n '420,500p' src/infra/outbound/deliver.ts
printf '\n--- phiApprovedChannels references ---\n'
rg -n --type=ts --type=md 'phiApprovedChannels|outboundRendering' src docs . -g '!**/node_modules/**'Repository: Syntropy-Health/openclaw
Length of output: 9030
🏁 Script executed:
#!/bin/bash
set -euo pipefail
sed -n '420,500p' src/infra/outbound/deliver.ts
printf '\n--- phiApprovedChannels references ---\n'
rg -n --type=ts --type=md 'phiApprovedChannels|outboundRendering' src docs . -g '!**/node_modules/**'Repository: Syntropy-Health/openclaw
Length of output: 9030
Normalize approved channels before matching.
phiApprovedChannels is compared verbatim here, while the denylist path is normalized. The channel id is already canonical lowercase upstream, so the only failure mode is config values like "ShrineMobile" or " shrinemobile " silently falling through to the minimized path. Normalize the approved list (or compare with normalizeChannelName(...)) so formatting differences don’t change rendering.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/infra/outbound/render-policy.ts` around lines 121 - 136, Normalize each
value returned by sanitizePhiApprovedChannels before comparing it with channel
in planChannelRender, reusing the existing normalizeChannelName helper if
available. Ensure casing and surrounding whitespace in phiApprovedChannels
configuration do not cause approved channels to fall through to minimizedText.
…github-hosted-fallback, CTO pre-auth openclaw#3106) Config-only workflow diff: remap 10 runs-on lines in ci.yml off the Blacksmith runners (9x → ubuntu-latest, 1x → windows-latest; macos untouched) — restores reliable openclaw CI after the Blacksmith outage that forced substituted-verification on #60/#61. NO gate-strictness change (grep blacksmith=0, exactly 10 runs-on lines, YAML valid, all prod-critical gates stay fail-loud — only WHERE they run changed). CTO diff-verified; proportionate gating for a runner remap (no 4-reviewer QG). Path-B SSH (workflow file). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
openclaw B5 (channel degradation, R7) — the PHI-egress boundary, LAST build phase (dispatch 2978). A ComponentDescriptor in reply channelData degrades to TEXT on messaging channels, consulted at the deliver.ts fork BEFORE the message_sending hook.
FULLY FAIL-CLOSED: full ui.summary egresses ONLY for a channel explicitly in phiApprovedChannels AND not denylisted. Every other case (non-approved/unknown channel, render:navigate card, malformed descriptor) MINIMIZES to a fixed generic confirm + DROPS channelData + DROPS mediaUrls. Default phiApprovedChannels=[] (fail-closed by construction); third-party channels (whatsapp/slack/telegram/discord/imessage/signal/googlechat) denylisted IN CODE (case-normalized — config typo can't approve). No producer-controlled signal (render hint, field marker) can open the egress.
QG (4 reviewers + focused security re-QG, HIPAA/Meta bar) — all red-first: CRITICAL field-level gating → food-macros to Meta by default → fixed channel-keyed default; HIGH parse-fail fail-OPEN → fail-safe minimize+drop; HIGH nav-passthrough (producer-controlled render bypassed gate+denylist) → REMOVED entirely (two-branch fail-closed, nav-summary deferred to channel-tool-hooks); + mediaUrls-drop, denylist, hook-ordering, name normalization. Receipt 3b2df03 verified. tsgo 0, 24+36 B5 / 529 outbound+config tests, sealed 60/60.
INERT: component-carrier only, disabled-effect until a component reaches a messaging channel (post-B4 producer + real turn). Prod held.
🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Bug Fixes