Skip to content

viewer(#972 defense-in-depth): strip OOC authoring-preamble leaks in sanitizeNarration - #979

Merged
100yenadmin merged 1 commit into
mainfrom
viewer/sanitize-ooc-authoring-preamble
Jun 17, 2026
Merged

viewer(#972 defense-in-depth): strip OOC authoring-preamble leaks in sanitizeNarration#979
100yenadmin merged 1 commit into
mainfrom
viewer/sanitize-ooc-authoring-preamble

Conversation

@100yenadmin

@100yenadmin 100yenadmin commented Jun 17, 2026

Copy link
Copy Markdown
Member

What

Defense-in-depth viewer arm for the 2026-06-17 craft audit's OOC authoring-preamble leak. Adds a high-confidence, OOC-only whole-sentence-drop (_AUTHORING_PREAMBLE) to sanitizeNarration in viewer/openworlds/screen-table.jsx, so the first-person DM "thinking out loud" lines the audit found shipping to players verbatim are stripped before the chronicle renders them:

  • "Now let me seat <X> as the player character"
  • "Continuity check — … let me correct that"
  • "Let me set the order of it"
  • "Here's how round one actually went:"
  • "let me set their advancement through the engine"

Why this, given #972 already shipped

The primary fix landed in #972: the DM SKILL.md FICTION-ONLY rule + the deterministic narration_no_ooc_leak gate in qa/assert_behavioral.py::_NARRATION_LEAK — that stops the leak at the source (the DM prompt). This PR is the viewer backstop for anything that still reaches the viewer (old transcripts, edge cases): the engine stays the sole writer; this is a read/projection filter only.

How

Tests

3 new cases in viewer/tests/test_sanitize_narration.py (which transpile + run the real shipped .jsx via the bundled Babel):

  • all 5 verbatim leaks → stripped to "";
  • inline trailing-clause + multiline-beat → surgical strip (real prose survives);
  • legit-fiction / dialogue FP guards → pass through verbatim.

13/13 sanitize tests pass. Full viewer/tests/ suite: 749 passed, 6 skipped, 1 pre-existing env failure unrelated to this change (test_portrait_gen subprocess: ModuleNotFoundError: No module named 'pydantic').

Lane: macOS/OpenWorlds (viewer). No engine/content changes.

Summary by CodeRabbit

  • Bug Fixes

    • Fixed narration sanitization to remove out-of-character authoring preambles that were leaking into visible narrative text. Enhanced detection with additional sentence-level filtering rules.
  • Tests

    • Added comprehensive test coverage verifying that authoring preambles are stripped correctly, including inline and multiline cases, while preserving legitimate narrative content.

…sanitizeNarration

The 2026-06-17 craft audit found the first-person OOC AUTHORING-PREAMBLE family
shipping to players verbatim ("Now let me seat <X> as the player character",
"Continuity check — let me correct that", "Let me set the order of it", "Here's
how round one actually went:", "let me set their advancement through the engine").

PR #972 fixed the leak AT THE SOURCE (DM SKILL.md FICTION-ONLY rule + the
deterministic narration_no_ooc_leak gate in qa/assert_behavioral.py::_NARRATION_LEAK).
This adds the viewer-arm backstop: a new high-confidence, OOC-only _AUTHORING_PREAMBLE
whole-sentence-drop wired into sanitizeNarration's existing _isScaffoldingSentence /
_hasScaffolding pass, so any leak that still reaches the chronicle (old transcripts,
edge cases) is stripped before the player sees it.

Patterns MIRROR _NARRATION_LEAK byte-for-byte (the 5 authoring-preamble arms; the
6th, "inciting incident", is already covered by _CRAFT_JARGON), carrying over its
machine-checked FP-hardening: "through the engine" is engine-sense-anchored (literal
machinery survives), the seat arm is full-word "as the player character" only, and
the round-replay arm is "here's how round <n> … went"-anchored. Additive; legitimate
fiction/dialogue is never stripped.

Tests: 3 new cases in test_sanitize_narration.py (5 verbatim leaks stripped;
inline + multiline surgical strip; legit-fiction FP guards). 13/13 sanitize tests
pass; full viewer suite 749 passed (1 pre-existing env failure: pydantic missing in
the portrait-gen subprocess, unrelated).
@coderabbitai

coderabbitai Bot commented Jun 17, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 496a094b-b5d9-40e3-ac24-c042495e1024

📥 Commits

Reviewing files that changed from the base of the PR and between 1c18d90 and 6c01af0.

📒 Files selected for processing (2)
  • viewer/openworlds/screen-table.jsx
  • viewer/tests/test_sanitize_narration.py

📝 Walkthrough

Walkthrough

Adds a _AUTHORING_PREAMBLE regex to the viewer-side narration sanitizer in screen-table.jsx, hooking it into _isScaffoldingSentence and _hasScaffolding so first-person OOC authoring-preamble sentences are dropped by _stripScaffoldingSentences. Three new test methods cover full removal, inline/multiline surgical removal, and false-positive preservation.

Changes

Authoring Preamble Sentence Stripping

Layer / File(s) Summary
Regex and scaffolding hook implementation
viewer/openworlds/screen-table.jsx
Introduces _AUTHORING_PREAMBLE sentence-match regex for specific first-person OOC preamble phrases. Extends _isScaffoldingSentence and _hasScaffolding to treat matched sentences as scaffolding, causing _stripScaffoldingSentences to drop them. Updates the in-file doc comment to name the new family.
New tests: strip, inline/multiline, and false-positive hardening
viewer/tests/test_sanitize_narration.py
Adds test_strips_ooc_authoring_preamble_leaks (full removal of five OOC phrases), test_authoring_preamble_stripped_inline_and_in_multiline_beat (surgical removal while preserving surrounding prose), and test_authoring_preamble_guard_preserves_legitimate_fiction (no false positives on similar-looking legitimate fiction).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • electricsheephq/WorldOS#338: Earlier modification to the same screen-table.jsx narration sanitizer to strip DM-internal leak text, directly in the same scaffolding-stripping code path extended here.
  • electricsheephq/WorldOS#349: Extends the same _isScaffoldingSentence/_stripScaffoldingSentences logic and test_sanitize_narration.py coverage with broader DM story-craft and tally sentence removal.
  • electricsheephq/WorldOS#972: Addresses the same OOC authoring-preamble leak family via QA-side regex detection and gating; this PR adds the corresponding viewer-side backstop.

Poem

🐇 Hop hop, the preambles must go,
"Now let me set the stage" — out the door, whoa!
The regex sniffs OOC lines with care,
Strips author whispers from the fiction's air.
Legitimate prose stays, the bunny swears — 🌿

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

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

@100yenadmin
100yenadmin merged commit 0bead9d into main Jun 17, 2026
15 of 18 checks passed
@100yenadmin
100yenadmin deleted the viewer/sanitize-ooc-authoring-preamble branch June 17, 2026 06:51
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.

1 participant