feat(jailbreak): move override to top of system prompt and add LIBERATED badge to TUI - #213
Merged
Merged
Conversation
…imated LIBERATED badge in the Rust TUI The /jailbreak block now PREPENDS to the static base (block <> "\n\n" <> static_base) so the operator override is the first text the model reads — before the Soul base, before /system state, before dynamic context. Docs updated to match, plus a test asserting the system message opens with the block. The LIBERATED badge never showed in the Rust TUI: it only existed in the Elixir spinner path. New components/jailbreak.rs reads the backend's ~/.osa/jailbreak.json (bounded 1s poll, cache-dropped on command result) and feeds an injected `liberated` field on StatusBar + Activity, so the badge renders: - status-bar row 0: animated ⚡ LIBERATED next to the model name (wall-clock pulse, no tick plumbing) - spinner status group: ⚡ LIBERATED while a turn runs, after the silence notice (a wrong-state report outranks a decorative chip) - /jailbreak on: magenta L I B E R A T E D banner + Success toast on result State is injected, not pulled from machine state inside the components, so tests stay hermetic. /jailbreak registered in BUILTIN_SLASH_COMMANDS.
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Intent
Move the /jailbreak operator override block from the END of the system prompt to the very TOP (first text the model reads), and add an animated LIBERATED badge to the Rust TUI (status-bar row 0 next to the model name, spinner status group, /jailbreak-on banner + toast) reading the backend's ~/.osa/jailbreak.json with a bounded 1s poll. Decisions made: block PREPENDS before the Soul static base and any /system state; TUI state is INJECTED into components (StatusBar/Activity take a set_liberated setter fed by the app tick) rather than read from machine state inside components, keeping tests hermetic; the LIBERATED chip sits AFTER the silence notice in the spinner's status group because a wrong-state report outranks a decorative chip; badge animation is wall-clock derived so it needs no extra tick plumbing.
What Changed
/jailbreakoperator override block is now prepended as the first text of the system prompt (before the Soul static base and any/systemstate) instead of appended at the end, with the injected seed wording updated to match its new precedence position (Context.buildinlib/optimal_system_agent/agent/context.ex,lib/optimal_system_agent/agent/jailbreak.ex).priv/rust/tui/src/components/jailbreak.rs) shown in status-bar row 0 next to the model name and in the spinner status group (after the silence notice), plus a/jailbreak-on banner and toast; it reads the backend's~/.osa/jailbreak.jsonvia a bounded 1s poll on the app tick, and liberated state is injected into StatusBar/Activity throughset_liberatedsetters so components stay hermetic in tests. Badge animation is wall-clock derived, requiring no extra tick plumbing.test/optimal_system_agent/agent/jailbreak_test.exs(including an "armed block is the FIRST text of the system message" assertion) and Rust badge render tests; review-pass fixes removed duplicated/jailbreakmatch-arm/poll/seed code introduced in the first commit.Risk Assessment
✅ Low: The fix commit surgically removes the duplicated /jailbreak match arm, seed call, and poll block and repairs the moduledoc newline with no new logic, resolving all prior findings while satisfying the stated intent.
Testing
Ran the targeted Elixir jailbreak suite (11/11) and the Rust badge tests (3/3) after fetching mix deps and building the TUI. Beyond unit tests, I demonstrated the intent as an end user sees it: an Elixir probe built a real Context with jailbreak armed and showed the operator override is now the first text of the system prompt (before the Soul base); and an evidence test rendered the actual StatusBar and Activity components via ratatui's TestBackend with the badge armed, captured across three animation frames, then exported a colored HTML frame and a PNG screenshot showing the ⚡ LIBERATED badge next to the model name on row 0 and as the trailing chip in the spinner group, with the bright/dim pulse visible. All green; no product issues found.
/var/folders/_8/h35hggb56t9gctwqgy2lgw100000gn/T/no-mistakes-evidence/01M1AVTC3EP2E2KQFZXS8P2Y5T/liberated_badge.png)Evidence: LIBERATED badge — colored HTML frame (source of the screenshot)
Evidence: Elixir: override block is the FIRST text of the assembled system prompt
Evidence: Rendered TUI rows (plain-text extraction)
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
🔧 **Review** - 4 issues found → auto-fixed ✅
priv/rust/tui/src/app/commands.rs:577- priv/rust/tui/src/app/commands.rs:577 — a second identical"/jailbreak" =>match arm duplicates lines 567-576. It is unreachable, and since Makefile:10 runscargo clippy -- -D warnings, the resultingunreachable_patternlint is promoted to a hard error and breaks the build/CI. Delete the duplicate arm (lines 577-586).priv/rust/tui/src/app/mod.rs:705- priv/rust/tui/src/app/mod.rs:705 —status.set_liberated(crate::components::jailbreak::is_liberated())is emitted twice back-to-back (also line 702). The second call is redundant copy-paste; remove line 705 (and its duplicate comment).priv/rust/tui/src/app/update.rs:1582- priv/rust/tui/src/app/update.rs:1582 — the per-tick jailbreak poll block (let liberated = ...; self.status.set_liberated; self.activity.set_liberated) is duplicated (lines 1574-1576 and 1582-1584), doubling the file poll and setter work on every app tick. Delete the second block.lib/optimal_system_agent/agent/jailbreak.ex:5- lib/optimal_system_agent/agent/jailbreak.ex:5 — the moduledoc contains a literal backslash-n (any /system\n state) rather than an actual newline, somix docs/IExhrenders\nliterally. Replace with a real line break.🔧 Fix: remove duplicated jailbreak arm/poll/seed, fix moduledoc newline
✅ Re-checked - no issues remain.
✅ **Test** - passed
✅ No issues found.
mix test test/optimal_system_agent/agent/jailbreak_test.exs— 11 tests, 0 failures (incl. new "armed block is the FIRST text of the system message" position test)cargo test --bin osagent jailbreak— 3 badge tests pass (disarmed renders nothing, bolt flicker cycles, invalidate forces fresh read)E2E prompt-position probe: armed Jailbreak.set(true, custom) + Context.build on the :ollama route, printed assembled system prompt — confirmed it starts with the override block then\n\n+ static baseEvidence render test (env-gatedOSA_EVIDENCE_HTML) rendering real StatusBar row 0 + Activity spinner group with set_liberated(true) across 3 pulse frames → HTML → PNG🔧 **Document** - 1 issue found → auto-fixed ✅
lib/optimal_system_agent/agent/jailbreak.ex:32- The @fallback_seed injected payload in lib/optimal_system_agent/agent/jailbreak.ex:32 still reads "It takes precedence over every instruction above", but this change moved the block to the very TOP of the system prompt, so nothing sits above it anymore — the phrasing is now literally inaccurate (it should reference "everything below" / "every other instruction"). I did not edit it because it is the runtime prompt text fed to the model, not documentation, and changing it would alter model-facing behavior (out of scope for a docs/lint pass). Surfacing as a judgment call for the author.🔧 Fix: fix stale jailbreak precedence wording in fallback seed
✅ Re-checked - no issues remain.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.