Skip to content

feat(syntropy-mcp): B5 ChannelRenderingPolicy (R7 PHI-egress boundary) — fully fail-closed, inert - #61

Merged
supmo668 merged 4 commits into
mainfrom
mangyinm/syntropy-mcp-b5
Jul 11, 2026
Merged

supmo668 merged 4 commits into
mainfrom
mangyinm/syntropy-mcp-b5

Conversation

@supmo668

@supmo668 supmo668 commented Jul 11, 2026 •

Copy link
Copy Markdown

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

    • Added configurable outbound rendering rules for health-related component content.
    • Health details are minimized on unapproved or unknown channels, with optional deep links.
    • Media and malformed component content are removed when health information is minimized.
    • Approved channels can display full health summaries, while third-party channels remain restricted.
  • Bug Fixes

    • Ensured hooks and observers receive the sanitized content rather than the original message.

supmo668 and others added 4 commits July 11, 2026 00:53
…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]>
@supmo668 supmo668 added the enhancement New feature or request label Jul 11, 2026
@coderabbitai

coderabbitai Bot commented Jul 11, 2026 •

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Gateway 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.

Changes

R7 outbound rendering

Layer / File(s) Summary
Rendering configuration contract
src/config/types.gateway.ts, src/config/zod-schema.ts
Gateway configuration and validation add optional approved channels and deep-link settings.
Channel rendering policy
src/infra/outbound/render-policy.ts
Health-aware component carriers are passed through only for approved non-denylisted channels; other channels receive minimized text, optional deep links, and scrub decisions for malformed carriers.
Outbound delivery enforcement
src/infra/outbound/deliver.ts, src/infra/outbound/deliver.test.ts
Delivery applies rendering decisions before hooks, clears minimized media and component data, warns once for ignored third-party approvals, and uses hook replacements from the modified payload.
Rendering and delivery validation
src/infra/outbound/render-policy.test.ts, src/infra/outbound/deliver.test.ts
Tests cover channel policy, malformed data, denylisting, deep links, media removal, hook ordering, and unchanged non-component payloads.
Change receipt
workstreams/openclaw/qgr/...md
A QGR receipt records metadata, hashes, attestation stages, and the final rendering-policy summary.

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
Loading

Poem

A rabbit guards the message trail,
With health clues tucked beneath a veil.
Safe channels keep the fuller tune,
Unknown paths get a safer moon.
Links hop lightly, media stays—
Hooray for fail-closed ways! 🐇

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description summarizes the change, but it does not follow the required template and omits many mandated sections. Reformat it to the repository template and add the missing Summary, Change Type, Scope, Linked Issue, Verification, Impact, and Risks sections.
Docstring Coverage ⚠️ Warning Docstring coverage is 71.43% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly names the ChannelRenderingPolicy and fail-closed PHI-egress boundary change.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch mangyinm/syntropy-mcp-b5

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown

⚠️ Formal models conformance drift detected

The formal models extracted constants (generated/*) do not match this openclaw PR.

This check is informational (not blocking merges yet).
See the formal-models-conformance-drift artifact for the diff.

If this change is intentional, follow up by updating the formal models repo or regenerating the extracted artifacts there.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between e6f5294 and 2a050a2.

📒 Files selected for processing (7)
  • src/config/types.gateway.ts
  • src/config/zod-schema.ts
  • src/infra/outbound/deliver.test.ts
  • src/infra/outbound/deliver.ts
  • src/infra/outbound/render-policy.test.ts
  • src/infra/outbound/render-policy.ts
  • workstreams/openclaw/qgr/SyntropyHealth-Applications-mo-openclaw-openclaw-SyntropyHealth-Applications-qgr-pr-prep-20260711-0127-3b2df03.md

Comment on lines +121 to +136
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 };
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 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/outbound

Repository: 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.ts

Repository: 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.ts

Repository: 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.

@supmo668
supmo668 merged commit 0e72f76 into main Jul 11, 2026
9 of 14 checks passed
@supmo668
supmo668 deleted the mangyinm/syntropy-mcp-b5 branch July 11, 2026 08:35
supmo668 added a commit that referenced this pull request Jul 11, 2026
…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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant