← Back to Pull requests

fix(presentation): scan every static-site text asset and fail closed on unreviewable text #9406

Closed
unknown closed this pull request without merging on Nov 26, 2026 06:56 UTC
View on GitHub
unknown unknown commented on Nov 24, 2026 14:26 UTC
Author

Goal And Delivered Outcome

loopx presentation package certifies a whole static-site bundle as public-safe while inspecting only eight filename suffixes and decoding only UTF-8, so ordinary text assets such as .csv chart data, .log captures, .yaml config, .env, Dockerfile, .map/.tsbuildinfo JSON and BOM-marked or BOM-less UTF-16 captures are copied into the publish artifact under ok: true without being scanned. This PR makes every text asset in a copied bundle reach the existing public boundary patterns regardless of its filename, decodes the encoding the asset declares, and fails closed when the bytes cannot be reviewed as text. It also keeps the publisher's own media support boundary, so a browser-decodable container such as AVIF or APNG is copied verbatim instead of being decoded as text (review follow-up on both P2 rounds below).

  • Outcome basis / optional anchor: the linked issue recorded below; its number is inserted once at publication.

  • Goal/source and gap: _scan_public_text in loopx/presentation/static_site.py returned before reading unless the asset's suffix was one of .css, .html, .js, .json, .md, .svg, .txt, .xml, and always read bytes as UTF-8. The repository's outbound public-safe scanner already documents why an allow-list fails for this task (loopx/capabilities/public_safe_outbound/scan_cli.py, _iter_text_files: it "silently skipped .env, Dockerfile, Makefile, id_rsa") and decodes the BOM-declared encoding; the static-site publisher never received that correction. Follow-up to #9370, which removed the separate 2 MB exemption and recorded this gap as out of scope.

  • Observable before → after, with the validation row that proves it: at base a7d72a1cf, a site with data.csv carrying a synthetic GitHub token returns {"ok": true, ... "write_performed": true} and the token is present in publish/data.csv; at head, the same site returns {"ok": false, "error": "public boundary scan failed for data.csv: provider token"}, exits 2 and creates no publish directory. The same before/after holds for .log, .yaml, .env, Dockerfile (including nested paths), .map, .tsbuildinfo, a BOM-marked UTF-16 .txt, and BOM-less UTF-16 (the last reports content is not reviewable text). For media, the first reviewed head ebac4eb9b rejected a valid 16×16 AVIF with public boundary scan failed for assets/hero.avif: content is not decodable as utf-8 and created no publish directory; the second reviewed head 204fd145e rejected a valid 16×16 two-frame APNG the same way while accepting the identical bytes renamed .png, while base a7d72a1cf published both. This head copies the AVIF (331 bytes), the APNG (239 bytes) and the renamed .png byte for byte with matching manifest digests, and each still rejects a .csv credential placed in the same bundle. The regression_parity and real_entrypoint rows below record the raw comparison.

  • Issue/task and intended base: Fixes #9405; PR base is loopx-project/loopx main, and the branch was cut from main at a7d72a1cf (the merge base), not from the fork.
  • Author Declaration

  • Written by: model_agent (Doubao, ByteDance), at the operator's request; no human reviewed this change before publication.
  • Implemented against

  • Specification and revision: the linked issue plus the repository's stated text contract at a7d72a1cf: loopx/capabilities/public_safe_outbound/README.md and scan_cli.py (candidate selection is a binary deny-list, and a candidate is decoded with the BOM-declared Unicode encoding) and docs/public-private-boundary.md (a raw credential token with no label is rejected by both tiers).

  • Criteria:
  • | Criterion (spec clause) | Disposition | Symbol / path | Test or command |
    | --- | --- | --- | --- |
    | Every text asset the bundle copies reaches the existing boundary patterns, regardless of filename suffix | implemented | loopx/presentation/static_site.py::_scan_public_text | tests/test_static_site_presentation.py::test_package_scans_text_assets_outside_the_former_suffix_allow_list (8 cases, including a nested assets/export.csv, extensionless .env / Dockerfile, and .map / .tsbuildinfo); real CLI before/after |
    | A BOM-marked UTF-16 capture is decoded before the patterns run | implemented | _scan_public_text (_BOM_CODECS) | tests/test_static_site_presentation.py::test_package_scans_a_bom_marked_utf16_capture_before_publication; real CLI |
    | A text asset that cannot be decoded in full, or whose decoded text contains NUL, fails publication instead of receiving a receipt | implemented | _scan_public_text (strict content.decode) | test_package_fails_closed_on_bomless_utf16_text, test_package_fails_closed_on_nul_bearing_text, test_package_fails_closed_on_undecodable_text; real CLI |
    | Known binary assets stay outside the text scan and remain publishable; .map / .tsbuildinfo are reviewed as JSON text | implemented | _scan_public_text (_BINARY_ASSET_SUFFIXES = outbound BINARY_SUFFIXES minus the two JSON text formats, unioned with the publisher's own _STATIC_MEDIA_SUFFIXES) | tests/test_static_site_presentation.py::test_package_still_copies_binary_assets_without_text_scanning; .map / .tsbuildinfo cases above |
    | A browser-decodable media container the outbound deny-list does not name is copied verbatim instead of being strict-decoded as text | implemented | _STATIC_MEDIA_SUFFIXES (.apng, .avif, .avifs, .heic, .heif, .jxl, .m4v, .ogv, .opus — the publisher's own support boundary) | test_package_copies_a_real_media_asset_byte_for_byte[avif\|apng], test_package_rejects_a_text_asset_next_to_real_media[avif\|apng], test_cli_package_copies_real_media_and_rejects_text_beside_it[avif\|apng]; real CLI |
    | Text-shaped assets are not swept into the media boundary: subtitle and playlist formats stay reviewable | implemented | _STATIC_MEDIA_SUFFIXES (no .vtt / .m3u8 / .mpd) | the parametrized text cases above; no exemption added for those suffixes |
    | The failure contract is unchanged: ok: false, exit 2, no publish directory, filename and rule in the error | implemented | loopx/cli_commands/presentation.py::handle_presentation_command, _collect_site_files | real CLI probes below; existing focused suite |
    | Reserved paths, symlinks, manifest/revision receipt and idempotent packaging behave as before | implemented | _collect_site_files, _replace_output, package_static_site | existing focused suite (one Windows-only symlink fixture remains blocked by host privilege; see Validation) |
    | Canonical boundary patterns are not restated or narrowed | implemented | loopx/public_safe_text.py (unchanged) | loopx check --scan-path over the two changed files |
    | Credentials embedded in binary media remain undetected by the text scan | out_of_scope | _scan_public_text | separate binary-content decision, not expanded here |
    | Retained-revision rollback does not re-scan | out_of_scope | rollback_static_site | pre-existing property of the rollback path, not a regression from this change |

  • Self-check before submission: I ran the final test file against three revisions — base a7d72a1cf (16 failed, 18 passed: the 8 suffix cases, BOM UTF-16, BOM-less UTF-16, NUL, undecodable UTF-8, both text-next-to-media cases and both CLI parity cases), the second reviewed head 204fd145e (2 failed, 32 passed: the APNG copy and the APNG CLI case, both reporting content is not decodable as utf-8), and this head (34 passed). The first reviewed head ebac4eb9b reported the same two failures for AVIF before that format was added. I also ran the real loopx presentation package CLI on base, 204fd145e and this head for 11 token shapes plus PNG, AVIF and APNG controls, Ruff, git diff --check, the repository loopx check boundary scan, the two static-site examples, the architecture import-boundary test and both UTF-8 guards. I did not run the full repository Python suite; CI's pytest job covers it, and one unrelated required test is already red at the base commit (see Validation). On this Windows host python -m pytest cannot create the symlink fixture (WinError 1314), which also fails before and after this change.
  • Scope And Continuation

  • Completed scope and remaining work: complete within this scope. The change replaces the local text allow-list with the outbound scanner's BINARY_SUFFIXES exclusion minus .map/.tsbuildinfo, decodes the declared encoding strictly, fails closed on undecodable or NUL-bearing content, and reuses the caller's single digest read. Review follow-up: the publisher keeps its own media boundary (_STATIC_MEDIA_SUFFIXES) instead of inheriting the repo-tree deny-list, so a browser-decodable container is copied verbatim while every other asset still has to be reviewable text. The set covers the browser containers the deny-list omits in one place rather than one suffix per review round, and it excludes text-shaped formats (.vtt, .m3u8, .mpd) so they stay scanned. No new pattern, consumer branch, receipt field, dependency or abstraction is introduced.

  • Security classification: the linked issue records why this is a public boundary-correctness report — no attacker-controlled path, no live credential, same class as the public #7727/#7799 precedent (fixed by merged #7732/#7814) — rather than a private vulnerability report. The PR body and tests use synthetic token shapes only.

  • Slice boundary / successor: N/A. The predecessor (#9370) removed the size exemption and left this selection gap; binary-embedded content remains a separate decision, not a successor of this slice. The change is independently testable and reversible by restoring the suffix filter and the permissive UTF-8 read. The media boundary is additive: removing a suffix from _STATIC_MEDIA_SUFFIXES restores the stricter rejection the review measured.
  • Validation

  • Tested revision: a603af13167f5214083d759b27b9de736050381d

  • Exact-head refresh: merged latest main (af946a5c1385e3a566386e69cfefcf512802af3f); focused static-site suite 35 passed, architecture import-boundary suite 34 passed, real CLI byte-for-byte media controls and adjacent text rejection passed, and standard premerge passed 6 direct checks plus 2 catalog canaries with 0 failures.

  • Run state: finished

  • Input classes: synthetic text plus two real encoder-produced media assets
  • | Check kind | Result | Public-safe evidence / limitation |
    | --- | --- | --- |
    | regression_parity | passed | Base a7d72a1cf with the final test file: 16 failed, 18 passed, 1 deselected — the 8 suffix cases (.csv ×2, .log, .yaml, .env, Dockerfile, .map, .tsbuildinfo), BOM UTF-16, BOM-less UTF-16, NUL-bearing UTF-8, undecodable UTF-8, both text-next-to-media cases and both CLI parity cases. Second reviewed head 204fd145e: 2 failed, 32 passed — the APNG copy and the APNG CLI case, both with content is not decodable as utf-8; the AVIF cases pass there. This head: 34 passed, 1 deselected. Counterfactuals are the removed suffix filter (base), the permissive UTF-8 read (base) and the one-suffix media set (first reviewed head). |
    | real_entrypoint | passed | Real loopx presentation package --execute. Text: 11 token shapes at base publish with ok: true, exit 0 and the synthetic token in publish/ for 9 of them; at this head all 11 return ok: false, exit 2 and create no publish directory, with content is not reviewable text for the BOM-less/NUL shapes and provider token for the rest. Media: a 16×16 AVIF and a 16×16 two-frame APNG are published byte-identically (331 and 239 bytes, manifest sha256 matches) with exit 0; at ebac4eb9b the AVIF was rejected and at 204fd145e the APNG was rejected, both with exit 2 and no publish directory, while the identical APNG bytes renamed .png published at both heads. Adding a .csv credential to each media bundle returns ok: false, exit 2 and creates no publish directory. |
    | unit | passed | uv run --extra test python -m pytest tests/test_static_site_presentation.py -q -k "not test_package_rejects_reserved_paths_symlinks_and_public_boundary_leaks" -> 34 passed, 1 deselected. The deselected fixture fails at base and head on this Windows host (WinError 1314, symlink creation privilege), so it is not a regression. |
    | unit | failed | tests/test_runtime_subprocess_utf8.py::test_shipped_runtime_pins_utf8_for_every_text_mode_subprocess_call fails on loopx/control_plane/goals/planning_batch.py:704, a file this PR does not touch (2 changed files), from #9263 at the base commit. An in-flight contributor fix owns that lane; it is disclosed here rather than claimed as passing. |
    | static | passed | uv run --extra test python -m ruff check loopx/presentation/static_site.py tests/test_static_site_presentation.py -> All checks passed. git diff --check -> clean. |
    | integration | passed | uv run --extra test loopx canary premerge --from-git-diff --git-diff-base a7d72a1cf -> status passed, changed_files 2, surfaces python, 0 failures, 0 advisory failures, 0 manual holds; 6 direct checks and both selected canaries passed. Root npm ci --ignore-scripts was required for the semantic-vocabulary canary. |
    | manual | passed | uv run --extra test loopx --format json check --scan-path loopx/presentation/static_site.py --scan-path tests/test_static_site_presentation.py -> public boundary scan clean: 2 files. The wrapper also reports one pre-existing local registry diagnostic that the diff does not touch. examples/static-site-presentation-smoke.py -> ok; examples/session-dash-panel-smoke.py -> OK. |

  • Coverage and gaps: the parametrized regression exercises the full package_static_site entrypoint (not only the helper), includes a nested directory, an extensionless .env, an extensionless Dockerfile, .map, .tsbuildinfo, a BOM-marked UTF-16 capture, BOM-less UTF-16, NUL-bearing UTF-8, undecodable UTF-8, and two real fixtures — a 16×16 AVIF from Pillow's libavif encoder and a 16×16 two-frame APNG — each beside a .csv credential, so a consumer that bypassed the scan, certified unreviewable bytes or rejected a browser-decodable container would fail it. The CLI case covers both halves through the shipped command for both fixtures. The real CLI covers the shipped entrypoint and records the base, previous-head and current over-reject sets, including the same APNG bytes renamed .png as the control that isolates the suffix boundary. The media exemption is by suffix: a text payload appended to a listed container (.avif, .apng, and .png at base) is copied without review, which is the declared binary-content boundary and unchanged by this slice. The full Python suite was not run locally; the unchanged planning_batch.py UTF-8 lane is red at the base commit and is owned by another in-flight fix. Credentials embedded in binary media remain explicitly out of scope.
  • Frontend / Visual Evidence

  • UI impact: none

  • Before: N/A

  • After: N/A

  • First viewport and preview: N/A

  • States and viewports shown: N/A

  • Source data: none

  • Attention review: N/A (no user-visible UI change)

  • Craft review: N/A (no user-visible UI change)
  • Type of Change

  • Bug fix

  • New feature

  • Breaking change

  • Refactoring (no functional changes)

  • Documentation update

  • Test update
  • LoopX Area

  • Control plane (goals, todos, quota, scheduler, registry, runtime)

  • Benchmark boundary (adapters, runners, verifiers, scoring, evidence)

  • Capability or extension (providers, adapters, skills)

  • Public docs or presentation surface (README, protocols, dashboard)

  • Build, packaging, installer, or CI

  • Host or runtime integration
  • Technical Direction

  • Direction / acceptance reference, when applicable: N/A
  • Shared-authority RFC fixture impact

  • Production-scale fixture schema: N/A

  • Semantic dimensions changed, or reviewed no-impact rationale: N/A

  • Provider conformance arms run: N/A

  • Read-only legacy/file/PostgreSQL three-arm rehearsal (required for promotion, runtime-routing, or compatibility-projection changes): N/A
  • Boundary Checklist

  • Neither the diff nor this PR body/comments/attachments disclose private state, credentials, raw traces or verifier output, internal links, or local machine paths (including .loopx/, .codex/goals/, and live ACTIVE_GOAL_STATE.md). Only a synthetic token shape and <tmp> placeholders are used.

  • I did not duplicate maintainer-owned benchmark work unless a maintainer split out a public issue for it.

  • I kept the change scoped to the linked issue/task.

  • Existing English/Chinese RFC pairs (including ledger entries) both have a diff, and the local premerge check python3 scripts/check_rfc_bilingual.py --base origin/main --head HEAD passes, or no paired RFC changed.

  • I completed the visual evidence section for UI changes, or marked UI impact none.

  • Every commit includes a DCO Signed-off-by trailer (git commit -s).
  • Diff: 650 lines (+487 / -163) across 8 files Reviewer: JasonBuildAI Review duration: 2429m
    All Vouch review confidence checks passed
    Residual risk 0.21 = Change Risk (0.52) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.52 · 650 lines diff across 8 files
    0.52
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.388
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #9406"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 52% (MEDIUM) · Higher = larger blast radius
    52%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 20.5% · Safe to merge
    20.5%