Skip to content

feat(mesh): require child-safety guards for image generation - #2979

Draft
matbalez wants to merge 4 commits into
Mesh-LLM:mainfrom
matbalez:codex/image-safety-guards
Draft

matbalez wants to merge 4 commits into
Mesh-LLM:mainfrom
matbalez:codex/image-safety-guards

Conversation

@matbalez

@matbalez matbalez commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Image-generation routes now require local child-safety guards. Requesters screen effective input text before sending it, providers screen both input text and generated images, and clients can opt into independently checking received images.

Depends on #2873. This draft includes the generic multimodal work from #2873 until that PR lands and the branch is restacked. It is updated to Mesh main after the Skippy cutover in #3193. The guard binaries use Mesh’s pinned standalone Skippy crates. Guard-only comparison.

Architecture

Role Provided plugin Input text Images
Requester, default get-images YuFeng XGuard Reason 0.6B Relies on provider checks
Requester, screen_received_images = true get-images Nemotron 3.5 Content Safety Same Nemotron instance independently checks received images
Provider serve-images Nemotron before generation Same Nemotron instance checks generated images before release

The host requires the corresponding local guard capabilities. The supplied plugins use private embedded Skippy inference, pinned model/projector hashes, fixed policy/templates, actual readiness self-tests, bounded execution and no disk prompt cache. Strict requesters replace YuFeng with Nemotron; they do not load both. Weights are installed alongside the plugins, not embedded in Mesh. The generation backend remains separate.

Mandatory admission runs before optional exchange hooks on every selected candidate, preserving peer fallback without allowing safety rejection to become optional. Explicit blocks return 403; missing/not-ready guards, errors, timeouts, malformed results and resource-limit failures return 503. Guarded HTTP/SSE responses are held until verification completes; core raw request/response captures are suppressed. Structured-image deltas, mixed error/choices frames, framing ambiguity, duplicate keys and invalid raster payloads fail closed.

Build with just build-image-guards and install the separately packaged plugins through the existing archive installer. Setup, GPU configuration, pinned checkpoints and licenses.

Protocol and scope

  • Uses feat(mesh): discover model outputs and display generated images #2873's output-modality metadata; no additional gossip or mesh wire-format change. Local guard operations/capabilities are additive.
  • Text input and concrete gateway routes for Chat, Completions, Responses and Messages. Image-output virtual models are rejected. Direct transport SDK applications need their own requester checks.
  • Bounded opaque, static inline PNG/JPEG/WebP only: 4 MiB per data URL, classifier images up to 4096 pixels per side, 16 MiB complete response. Remote artifact URLs and unsupported structured-image representations are rejected. Guarded replies are fully buffered, including SSE.
  • Strict requesters check generation responses even when a concrete peer advertises text-only output. Default requesters rely on honest, updated providers. Older hosts do not enforce these requirements; discovery is not proof of guard execution.

Limits

This is an honest-node mitigation, not remote attestation or guaranteed CSAM detection. Classifiers can produce false positives and false negatives; YuFeng's blocked labels also cover some broader harms. The checks cover effective input text and image artifacts, not assistant output text.

Operators must keep generation backends private and withhold unapproved artifacts from files, public URLs, caches and raw logs. Mesh's quarantine cannot undo upstream backend side effects. GPU placement must be verified operationally; readiness does not guarantee GPU-only execution.

Validation

Post-cutover validation on 614c3ebb5:

  • Workspace formatting and warning-denying all-target Clippy for the host runtime and image guards passed.
  • All host runtime and image guard unit, integration and doc-test targets passed locally. The host unit suite reported 4,788 passed and 32 skipped. The guard library reported 9 passed.
  • just test-ui passed lint, typechecking, Vitest (2,026 passed, 3 skipped) and the production build.
  • The draft still needs hosted CI, the feat(mesh): discover model outputs and display generated images #2873 restack, and final GPU qualification.
Original author validation before the cutover
  • Current-base workspace/all-target compilation and formatting passed. just build metal rebuilt native ABI 0.1.79, the standalone Skippy CLI, production UI and Mesh host; both guard executables and their schema exports were built separately.
  • Warning-denying all-target product Clippy passed. One equivalent boolean simplification in the existing runtime was needed for Rust 1.95; no draft/model behavior changes.
  • Full host/package tests passed: 4,553 host unit tests (32 existing ignored), 26 host integration tests, 9 guard tests, 91 shared plugin tests, 64 CI-controller tests, and 478 runtime unit plus 7 runtime integration tests (12 existing ignored). All seven production-UI browser parity cases passed against fixture APIs.
  • The broader workspace run exercised 162 targets. An unchanged macOS ACL display assertion failed once and passed its isolated rerun; a native-cache case enabled by the global bundle variable found an incomplete unrelated cache, while the standard host run and focused normal-environment rerun passed. These are not claims of a single green workspace wrapper.
  • The binding group found an unchanged upstream test with stale context-layout literals (168 bytes). Independent C-header and generated-Rust compiler probes agree on the actual 176-byte layout. Its repair is outside this PR; the complete local gate is not green. Broader xtask Rust 1.95 lint debt was also observed on the earlier base.
  • The complete current-base just ci-validate invocation passed, including its automation, integration, legacy, crate-roster, release, console-output and publish-chain consistency checks. publish-crates here is the read-only consistency command, not artifact publication.

The preceding GPU demo used local Metal YuFeng and remote CUDA Nemotron over a private two-node mesh, with seven classifier controls passing and a generated image reaching the console after screening. That evidence used native ABI 0.1.78. Current main requires 0.1.79: its Metal bundle has been rebuilt, but the safety-model deployment must be qualified again on the final build before marking ready. No CPU safety-model inference is used for this preparation.

Keep draft until #2873 lands, this branch is restacked, required hosted checks pass, and final GPU deployment qualification completes.

@coderabbitai

coderabbitai Bot commented Nov 10, 2026

Copy link
Copy Markdown
Contributor

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@github-actions

Copy link
Copy Markdown
Contributor

This pull request is currently a draft. Reviews will not take place until the PR is marked as ready for review.

@matbalez
matbalez force-pushed the codex/image-safety-guards branch from b09d2c8 to 4267118 Compare November 10, 2026 02:40
Signed-off-by: James Dumay <james@generalinference.xyz>

@i386 i386 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Reviewed the guard-only delta (ce260b6ac..614c3ebb54 — the two commits after the #2873 carry) at head 614c3ebb54. No blocking findings. Content is approve-worthy once the remaining process gates close: #2873 lands and the branch restacks, the draft flips ready for review, GPU qualification per the checklist, and the owner's manual pass. Verdict recorded as a comment because the PR is a draft and approval is held for the owner.

Verified fail-closed end to end:

  • Admission runs on every selected candidate, inside the ordered-target loop in transport_route_model.rs, before any optional exchange hook, on both ingress paths (buffered_exchange local+QUIC, passive_exchange idle/passive/bootstrap). ResponseSafetyBuffer::wrap installs the hold before dispatch; arming after the response has started is refused, so nothing can screen too late.
  • Request screening: complete effective input (≤64 KiB, provider extra fields kept, media-bearing parts rejected), duplicate JSON keys at any depth → 503 before screening a parse view that differs from the forwarded bytes. Explicit Block → 403; missing/not-ready guards, protocol/model/policy-status mismatch, 120 s guard timeout, oversized guard output, malformed verdicts (model/policy_revision binding, bounded reason_code charset) → 503. The prompt is marked private before any guard call, so admission failures never persist it; raw captures clear while armed.
  • Response screening: quarantine capped at 16 MiB, released only on an exact content-length match or connection-delimited with successful shutdown; chunked/incomplete/redirect responses → 503 (chunked-SSE upstream covered by tests). Structured image output, mixed error/output frames, conflicting envelopes, HTML media, non-canonical data URIs, animations, alpha transparency and MIME/header mismatches all fail closed; decode runs on a 2-permit blocking pool with 2 s/30 s timeouts; every verified image is screened against every planned guard; denial responses are static — no content echo.
  • Guards: pinned sha256 + byte-count verification of weights and projector at load; exact-shape policy parsing where truncation, unknown labels and non-Stop finishes yield Unavailable — never Allow; readiness self-tests; the guard child process loads its own verified native runtime.

The residual limits (honest-node mitigation, no attestation, GPU placement verified operationally, classifier error rates) are accurately disclosed in the description.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants