Skip to content

Building 70 Projects ranging from beginner to advanced so anyone can — learn from, build upon, use as a reference, or even copy directly. Owned by my cybersecurity company 👇

feat(not-sandboxed): the arena becomes an instrument, and a build inlined a font the CSP forbids

CarterPerez-dev45b8e3781817
diff --git a/PROJECTS/beginner/prompt-injection-firewall/frontend/.gitignore b/PROJECTS/beginner/prompt-injection-firewall/frontend/.gitignore
index 61cb0c2e..fe24ba6d 100644
--- a/PROJECTS/beginner/prompt-injection-firewall/frontend/.gitignore
+++ b/PROJECTS/beginner/prompt-injection-firewall/frontend/.gitignore
@@ -8,6 +8,7 @@ pnpm-debug.log*
lerna-debug.log*
node_modules
+.pnpm-store
dist
dist-ssr
*.local
diff --git a/PROJECTS/beginner/prompt-injection-firewall/frontend/package.json b/PROJECTS/beginner/prompt-injection-firewall/frontend/package.json
index a72fa91b..fc0ec5dd 100644
--- a/PROJECTS/beginner/prompt-injection-firewall/frontend/package.json
+++ b/PROJECTS/beginner/prompt-injection-firewall/frontend/package.json
@@ -15,6 +15,9 @@
"lint:scss:fix": "stylelint '**/*.scss' --fix"
},
"dependencies": {
+ "@fontsource-variable/martian-mono": "^5.3.0",
+ "@fontsource-variable/space-grotesk": "^5.3.0",
+ "@fontsource/ibm-plex-mono": "^5.3.0",
"@tanstack/react-query": "^5.90.12",
"axios": "^1.13.0",
"react": "^19.2.1",
diff --git a/PROJECTS/beginner/prompt-injection-firewall/frontend/pnpm-lock.yaml b/PROJECTS/beginner/prompt-injection-firewall/frontend/pnpm-lock.yaml
index d04a7163..af14f6c9 100644
--- a/PROJECTS/beginner/prompt-injection-firewall/frontend/pnpm-lock.yaml
+++ b/PROJECTS/beginner/prompt-injection-firewall/frontend/pnpm-lock.yaml
@@ -11,6 +11,15 @@ importers:
.:
dependencies:
+ '@fontsource-variable/martian-mono':
+ specifier: ^5.3.0
+ version: 5.3.0
+ '@fontsource-variable/space-grotesk':
+ specifier: ^5.3.0
+ version: 5.3.0
+ '@fontsource/ibm-plex-mono':
+ specifier: ^5.3.0
+ version: 5.3.0
'@tanstack/react-query':
specifier: ^5.90.12
version: 5.90.12([email protected])
@@ -196,24 +205,28 @@ packages:
engines: {node: '>=14.21.3'}
cpu: [arm64]
os: [linux]
+ libc: [musl]
'@biomejs/[email protected]':
resolution: {integrity: sha512-Uo1OJnIkJgSgF+USx970fsM/drtPcQ39I+JO+Fjsaa9ZdCN1oysQmy6oAGbyESlouz+rzEckLTF6DS7cWse95g==}
engines: {node: '>=14.21.3'}
cpu: [arm64]
os: [linux]
+ libc: [glibc]
'@biomejs/[email protected]':
resolution: {integrity: sha512-YGLkqU91r1276uwSjiUD/xaVikdxgV1QpsicT0bIA1TaieM6E5ibMZeSyjQ/izBn4tKQthUSsVZacmoJfa3pDA==}
engines: {node: '>=14.21.3'}
cpu: [x64]
os: [linux]
+ libc: [musl]
'@biomejs/[email protected]':
resolution: {integrity: sha512-QDPMD5bQz6qOVb3kiBui0zKZXASLo0NIQ9JVJio5RveBEFgDgsvJFUvZIbMbUZT3T00M/1wdzwWXk4GIh0KaAw==}
engines: {node: '>=14.21.3'}
cpu: [x64]
os: [linux]
+ libc: [glibc]
'@biomejs/[email protected]':
resolution: {integrity: sha512-H4IoCHvL1fXKDrTALeTKMiE7GGWFAraDwBYFquE/L/5r1927Te0mYIGseXi4F+lrrwhSWbSGt5qPFswNoBaCxg==}
@@ -272,6 +285,15 @@ packages:
'@emnapi/[email protected]':
resolution: {integrity: sha512-WI0DdZ8xFSbgMjR1sFsKABJ/C5OnRrjT06JXbZKexJGrDuPTzZdDYfFlsgcCXCyf+suG5QU2e/y1Wo2V/OapLQ==}
+ '@fontsource-variable/[email protected]':
+ resolution: {integrity: sha512-0wVODx9ILwNnaYC4XCuSaFRYtj1Prd89MRVaSuv2ng6zLiQkS4SepaWEPefs7vqCZS8sbEOA8jb/4F5KNMnGdg==}
+
+ '@fontsource-variable/[email protected]':
+ resolution: {integrity: sha512-2IxmvfB08i9vnGB3Ym/AXvhRE+8XOjWMXIyDum03c+tPwH0FUoMNQfGpU8NXPxjbws0Vvss3AH0Zqt4oJBBAdw==}
+
+ '@fontsource/[email protected]':
+ resolution: {integrity: sha512-eTgnZjZEGk1QtD3ZstF+Vclo2HLAni8YMy34/DxllwZvyz1lR/1RF/xTiAquOBO7MvqBx8D2Ig2WCPMVfdZu7Q==}
+
'@jridgewell/[email protected]':
resolution: {integrity: sha512-2kkt/7niJ6MgEPxF0bYdQ6etZaA+fQvDcLKckhy1yIQOzaoKjBBjSj63/aLVjYE3qhRt5dvM+uUyfCg6UKCBbA==}
@@ -348,36 +370,42 @@ packages:
engines: {node: '>= 10.0.0'}
cpu: [arm]
os: [linux]
+ libc: [glibc]
'@parcel/[email protected]':
resolution: {integrity: sha512-6E+m/Mm1t1yhB8X412stiKFG3XykmgdIOqhjWj+VL8oHkKABfu/gjFj8DvLrYVHSBNC+/u5PeNrujiSQ1zwd1Q==}
engines: {node: '>= 10.0.0'}
cpu: [arm]
os: [linux]
+ libc: [musl]
'@parcel/[email protected]':
resolution: {integrity: sha512-LrGp+f02yU3BN9A+DGuY3v3bmnFUggAITBGriZHUREfNEzZh/GO06FF5u2kx8x+GBEUYfyTGamol4j3m9ANe8w==}
engines: {node: '>= 10.0.0'}
cpu: [arm64]
os: [linux]
+ libc: [glibc]
'@parcel/[email protected]':
resolution: {integrity: sha512-cFOjABi92pMYRXS7AcQv9/M1YuKRw8SZniCDw0ssQb/noPkRzA+HBDkwmyOJYp5wXcsTrhxO0zq1U11cK9jsFg==}
engines: {node: '>= 10.0.0'}
cpu: [arm64]
os: [linux]
+ libc: [musl]
'@parcel/[email protected]':
resolution: {integrity: sha512-GcESn8NZySmfwlTsIur+49yDqSny2IhPeZfXunQi48DMugKeZ7uy1FX83pO0X22sHntJ4Ub+9k34XQCX+oHt2A==}
engines: {node: '>= 10.0.0'}
cpu: [x64]
os: [linux]
+ libc: [glibc]
'@parcel/[email protected]':
resolution: {integrity: sha512-n0E2EQbatQ3bXhcH2D1XIAANAcTZkQICBPVaxMeaCVBtOpBZpWJuf7LwyWPSBDITb7In8mqQgJ7gH8CILCURXg==}
engines: {node: '>= 10.0.0'}
cpu: [x64]
os: [linux]
+ libc: [musl]
'@parcel/[email protected]':
resolution: {integrity: sha512-RFzklRvmc3PkjKjry3hLF9wD7ppR4AKcWNzH7kXR7GUe0Igb3Nz8fyPwtZCSquGrhU5HhUNDr/mKBqj7tqA2Vw==}
@@ -436,24 +464,28 @@ packages:
engines: {node: ^20.19.0 || >=22.12.0}
cpu: [arm64]
os: [linux]
+ libc: [glibc]
'@rolldown/[email protected]':
resolution: {integrity: sha512-L0zRdH2oDPkmB+wvuTl+dJbXCsx62SkqcEqdM+79LOcB+PxbAxxjzHU14BuZIQdXcAVDzfpMfaHWzZuwhhBTcw==}
engines: {node: ^20.19.0 || >=22.12.0}
cpu: [arm64]
os: [linux]
+ libc: [musl]
'@rolldown/[email protected]':
resolution: {integrity: sha512-gyoI8o/TGpQd3OzkJnh1M2kxy1Bisg8qJ5Gci0sXm9yLFzEXIFdtc4EAzepxGvrT2ri99ar5rdsmNG0zP0SbIg==}
engines: {node: ^20.19.0 || >=22.12.0}
cpu: [x64]
os: [linux]
+ libc: [glibc]
'@rolldown/[email protected]':
resolution: {integrity: sha512-zti8A7M+xFDpKlghpcCAzyOi+e5nfUl3QhU023ce5NCgUxRG5zGP2GR9LTydQ1rnIPwZUVBWd4o7NjZDaQxaXA==}
engines: {node: ^20.19.0 || >=22.12.0}
cpu: [x64]
os: [linux]
+ libc: [musl]
'@rolldown/[email protected]':
resolution: {integrity: sha512-eZUssog7qljrrRU9Mi0eqYEPm3Ch0UwB+qlWPMKSUXHNqhm3TvDZarJQdTevGEfu3EHAXJvBIe0YFYr0TPVaMA==}
@@ -958,24 +990,28 @@ packages:
engines: {node: '>= 12.0.0'}
cpu: [arm64]
os: [linux]
+ libc: [glibc]
resolution: {integrity: sha512-5Vh9dGeblpTxWHpOx8iauV02popZDsCYMPIgiuw97OJ5uaDsL86cnqSFs5LZkG3ghHoX5isLgWzMs+eD1YzrnA==}
engines: {node: '>= 12.0.0'}
cpu: [arm64]
os: [linux]
+ libc: [musl]
resolution: {integrity: sha512-Cfd46gdmj1vQ+lR6VRTTadNHu6ALuw2pKR9lYq4FnhvgBc4zWY1EtZcAc6EffShbb1MFrIPfLDXD6Xprbnni4w==}
engines: {node: '>= 12.0.0'}
cpu: [x64]
os: [linux]
+ libc: [glibc]
resolution: {integrity: sha512-XJaLUUFXb6/QG2lGIW6aIk6jKdtjtcffUT0NKvIqhSBY3hh9Ch+1LCeH80dR9q9LBjG3ewbDjnumefsLsP6aiA==}
engines: {node: '>= 12.0.0'}
cpu: [x64]
os: [linux]
+ libc: [musl]
resolution: {integrity: sha512-FZn+vaj7zLv//D/192WFFVA0RgHawIcHqLX9xuWiQt7P0PtdFEVaxgF9rjM/IRYHQXNnk61/H/gb2Ei+kUQ4xQ==}
@@ -1615,6 +1651,12 @@ snapshots:
tslib: 2.8.1
optional: true
+ '@fontsource-variable/[email protected]': {}
+
+ '@fontsource-variable/[email protected]': {}
+
+ '@fontsource/[email protected]': {}
+
'@jridgewell/[email protected]':
dependencies:
'@jridgewell/sourcemap-codec': 1.5.5
diff --git a/PROJECTS/beginner/prompt-injection-firewall/frontend/src/App.tsx b/PROJECTS/beginner/prompt-injection-firewall/frontend/src/App.tsx
index a7d82d6a..ec9c7993 100644
--- a/PROJECTS/beginner/prompt-injection-firewall/frontend/src/App.tsx
+++ b/PROJECTS/beginner/prompt-injection-firewall/frontend/src/App.tsx
@@ -8,9 +8,10 @@ import { ReactQueryDevtools } from '@tanstack/react-query-devtools'
import { RouterProvider } from 'react-router-dom'
import { Toaster } from 'sonner'
+import { TOAST } from '@/config'
import { queryClient } from '@/core/api'
import { router } from '@/core/app/routers'
-import '@/core/app/toast.module.scss'
+import toastStyles from '@/core/app/toast.module.scss'
export default function App(): React.ReactElement {
return (
@@ -18,14 +19,13 @@ export default function App(): React.ReactElement {
<div className="app">
<RouterProvider router={router} />
<Toaster
- position="top-right"
- duration={2000}
- theme="dark"
+ position={TOAST.POSITION}
+ duration={TOAST.DURATION}
toastOptions={{
- style: {
- background: 'hsl(0, 0%, 12.2%)',
- border: '1px solid hsl(0, 0%, 18%)',
- color: 'hsl(0, 0%, 98%)',
+ unstyled: true,
+ classNames: {
+ toast: toastStyles.toast,
+ title: toastStyles.toastTitle,
},
}}
/>
diff --git a/PROJECTS/beginner/prompt-injection-firewall/frontend/src/config.ts b/PROJECTS/beginner/prompt-injection-firewall/frontend/src/config.ts
index e3e9616b..39bd5181 100644
--- a/PROJECTS/beginner/prompt-injection-firewall/frontend/src/config.ts
+++ b/PROJECTS/beginner/prompt-injection-firewall/frontend/src/config.ts
@@ -50,6 +50,11 @@ export const HTTP_STATUS = {
INTERNAL_SERVER: 500,
} as const
+export const TOAST = {
+ POSITION: 'top-right',
+ DURATION: 2000,
+} as const
+
export const ARENA = {
FIRST_LEVEL: 1,
LAST_LEVEL: 6,
@@ -73,19 +78,98 @@ export const DECISION = {
export const RULE_LAYER_DISABLED = 'layer-disabled'
+export const SEVERITY_WEIGHT = {
+ INFO: 0,
+ LOW: 1,
+ MEDIUM: 2,
+ HIGH: 3,
+ CRITICAL: 4,
+} as const
+
+export const SEVERITY_MAX_WEIGHT = 4
+
+export const SEVERITY_SCALE_OFFSET = 1
+
+export const NUMERAL_PAD = 2
+
+export const SESSION_ID_HEAD = 8
+
+export const CODEPOINT_CLASSES = {
+ TAG: { LOW: 0xe0000, HIGH: 0xe007f },
+ BIDI: [
+ { LOW: 0x202a, HIGH: 0x202e },
+ { LOW: 0x2066, HIGH: 0x2069 },
+ { LOW: 0x200e, HIGH: 0x200f },
+ ],
+ ZERO_WIDTH: [
+ { LOW: 0x200b, HIGH: 0x200d },
+ { LOW: 0xfeff, HIGH: 0xfeff },
+ ],
+ ASCII_HIGH: 0x7f,
+} as const
+
+export const CENSUS_MARKS = {
+ TAG: 'TAG',
+ BIDI: 'BIDI',
+ ZERO_WIDTH: 'ZW',
+} as const
+
+export type CensusMark = (typeof CENSUS_MARKS)[keyof typeof CENSUS_MARKS]
+
export const COPY = {
TITLE: 'not-sandboxed',
TAGLINE: 'the model is not sandboxed, so the effects are',
+ UNIT_ID: 'unit id / ns-06',
+ UNIT_ROLE: 'prompt injection firewall',
+ NODE: 'support desk agent',
+ NODE_STATE: 'untrusted input accepted',
+ ORIGIN: 'local instance',
+ ORIGIN_DETAIL: 'no model keys, no network',
+ FOOTER_SPEC: 'five layers / four hard invariants / one scored best-effort',
+ FOOTER_BUILD: 'ingress is incomplete by design',
+ FOOTER_MARK: 'angelamos — 2026',
+ SESSION_LABEL: 'session',
+ SESSION_PENDING: 'opening',
+ SECRET_LABEL_SHORT: 'secret held',
+ SECRET_UNIT: 'chars',
+ CONFIG_LABEL: 'configurations',
+ LEVEL_HEADING: 'Select firewall configuration',
+ LEVEL_LEGEND: 'level',
+ TEACHES_LABEL: 'what this level teaches',
TICKET_LABEL: 'Submit a support ticket',
TICKET_HINT: 'You control this text. It reaches the agent as untrusted DATA.',
+ SPECIMEN_HEADING: 'Specimen',
+ SPECIMEN_EMPTY: 'Nothing submitted yet. The field reads what you type.',
+ REVEAL_ON: 'Reveal invisibles',
+ REVEAL_OFF: 'Hide invisibles',
+ CENSUS: {
+ GLYPHS: 'glyphs',
+ BYTES: 'utf-8 bytes',
+ NON_ASCII: 'non-ascii',
+ TAG: 'tag block',
+ BIDI: 'bidi controls',
+ ZERO_WIDTH: 'zero width',
+ },
+ CENSUS_CLEAN: 'Nothing hidden in this text.',
+ CENSUS_DIRTY:
+ 'This text carries characters your eye cannot see. The tokenizer ' +
+ 'still reads every one of them.',
SUBMIT: 'Send ticket',
SUBMITTING: 'Running…',
AGENT_HEADING: 'What the agent produced',
AGENT_EMPTY: 'The firewall blocked this before the agent replied.',
VERDICT_HEADING: 'Verdict',
+ REQUEST_LABEL: 'request',
+ EGRESS_LABEL: 'egress',
+ EGRESS_UNREACHED: 'not reached',
+ ATTEMPTS_LABEL: 'attempt',
+ FINDINGS_HEADING: 'Rules fired',
+ INVARIANT_MARK: 'invariant',
NO_RULES: 'Nothing fired.',
SECRET_ESCAPED: 'The secret escaped.',
SECRET_CONTAINED: 'The secret stayed in.',
+ SECRET_LABEL: 'containment',
+ AWAITING: 'awaiting ticket',
DISABLED_NOTICE:
'These layers are switched off at this level. Getting through ' +
'here is not a bypass, it is a gift.',
diff --git a/PROJECTS/beginner/prompt-injection-firewall/frontend/src/core/app/shell.module.scss b/PROJECTS/beginner/prompt-injection-firewall/frontend/src/core/app/shell.module.scss
index d8bd6282..ec6e22f3 100644
--- a/PROJECTS/beginner/prompt-injection-firewall/frontend/src/core/app/shell.module.scss
+++ b/PROJECTS/beginner/prompt-injection-firewall/frontend/src/core/app/shell.module.scss
@@ -2,12 +2,74 @@
// © AngelaMos | 2026
// shell.module.scss
// ===================
-// Layout only. The visual language is decided later.
+
+@use '../../styles/tokens' as *;
+@use '../../styles/fonts' as *;
+@use '../../styles/mixins' as *;
.shell {
display: flex;
flex-direction: column;
min-height: 100vh;
+ padding: $space-4;
+
+ @include breakpoint-up('md') {
+ padding: $space-8;
+ }
+}
+
+.sheet {
+ display: flex;
+ flex: 1;
+ flex-direction: column;
+ width: 100%;
+ max-width: $measure-page;
+ margin: 0 auto;
+ border: $hairline;
+ background-color: $color-paper-lit;
+
+ @include corner-ticks(-1px, $space-4);
+}
+
+.strip {
+ display: grid;
+ grid-template-columns: 1fr;
+ gap: $space-3;
+ padding: $space-3 $space-4;
+ border-bottom: $hairline;
+
+ @include breakpoint-up('sm') {
+ grid-template-columns: repeat(3, 1fr);
+ }
+
+ &:last-child {
+ border-top: $hairline;
+ border-bottom: 0;
+ }
+}
+
+.strip-cell {
+ display: flex;
+ flex-direction: column;
+ gap: $space-1;
+}
+
+.strip-cell-end {
+ @include breakpoint-up('sm') {
+ text-align: right;
+ }
+}
+
+.strip-key {
+ @include plate-type;
+
+ color: $color-ink;
+}
+
+.strip-value {
+ @include label-type($font-size-2xs);
+
+ color: $color-ink-faint;
}
.content {
@@ -18,14 +80,26 @@
.error {
display: flex;
flex-direction: column;
- gap: 0.5rem;
+ gap: $space-3;
+ padding: $space-8 $space-4;
+ border-left: 3px solid $color-signal;
+}
- pre {
- white-space: pre-wrap;
- overflow-x: auto;
- }
+.error-heading {
+ @include display-type($font-size-2xl);
+}
+
+.error-body {
+ font-family: $font-mono;
+ font-size: $font-size-sm;
+ color: $color-ink-soft;
+ white-space: pre-wrap;
+ overflow-x: auto;
}
.loading {
- display: block;
+ @include plate-type($font-size-xs);
+
+ padding: $space-12 $space-4;
+ color: $color-ink-faint;
}
diff --git a/PROJECTS/beginner/prompt-injection-firewall/frontend/src/core/app/shell.tsx b/PROJECTS/beginner/prompt-injection-firewall/frontend/src/core/app/shell.tsx
index e82d0b78..b004c8e8 100644
--- a/PROJECTS/beginner/prompt-injection-firewall/frontend/src/core/app/shell.tsx
+++ b/PROJECTS/beginner/prompt-injection-firewall/frontend/src/core/app/shell.tsx
@@ -12,8 +12,8 @@ import styles from './shell.module.scss'
function ShellErrorFallback({ error }: { error: Error }): React.ReactElement {
return (
<div className={styles.error}>
- <h2>{COPY.ERRORS.DEFAULT}</h2>
- <pre>{error.message}</pre>
+ <h2 className={styles.errorHeading}>{COPY.ERRORS.DEFAULT}</h2>
+ <pre className={styles.errorBody}>{error.message}</pre>
</div>
)
}
@@ -25,13 +25,38 @@ function ShellLoading(): React.ReactElement {
export function Shell(): React.ReactElement {
return (
<div className={styles.shell}>
- <main className={styles.content}>
- <ErrorBoundary FallbackComponent={ShellErrorFallback}>
- <Suspense fallback={<ShellLoading />}>
- <Outlet />
- </Suspense>
- </ErrorBoundary>
- </main>
+ <div className={styles.sheet}>
+ <header className={styles.strip}>
+ <div className={styles.stripCell}>
+ <span className={styles.stripKey}>{COPY.UNIT_ID}</span>
+ <span className={styles.stripValue}>{COPY.UNIT_ROLE}</span>
+ </div>
+ <div className={styles.stripCell}>
+ <span className={styles.stripKey}>{COPY.NODE}</span>
+ <span className={styles.stripValue}>{COPY.NODE_STATE}</span>
+ </div>
+ <div className={`${styles.stripCell} ${styles.stripCellEnd}`}>
+ <span className={styles.stripKey}>{COPY.ORIGIN}</span>
+ <span className={styles.stripValue}>{COPY.ORIGIN_DETAIL}</span>
+ </div>
+ </header>
+
+ <main className={styles.content}>
+ <ErrorBoundary FallbackComponent={ShellErrorFallback}>
+ <Suspense fallback={<ShellLoading />}>
+ <Outlet />
+ </Suspense>
+ </ErrorBoundary>
+ </main>
+
+ <footer className={styles.strip}>
+ <span className={styles.stripValue}>{COPY.FOOTER_SPEC}</span>
+ <span className={styles.stripValue}>{COPY.FOOTER_BUILD}</span>
+ <span className={`${styles.stripValue} ${styles.stripCellEnd}`}>
+ {COPY.FOOTER_MARK}
+ </span>
+ </footer>
+ </div>
</div>
)
}
diff --git a/PROJECTS/beginner/prompt-injection-firewall/frontend/src/core/app/toast.module.scss b/PROJECTS/beginner/prompt-injection-firewall/frontend/src/core/app/toast.module.scss
index 62a8ee32..909401c8 100644
--- a/PROJECTS/beginner/prompt-injection-firewall/frontend/src/core/app/toast.module.scss
+++ b/PROJECTS/beginner/prompt-injection-firewall/frontend/src/core/app/toast.module.scss
@@ -2,3 +2,22 @@
// © AngelaMos | 2026
// toast.module.scss
// ===================
+
+@use '../../styles/tokens' as *;
+@use '../../styles/fonts' as *;
+@use '../../styles/mixins' as *;
+
+.toast {
+ display: flex;
+ align-items: center;
+ width: 100%;
+ padding: $space-3 $space-4;
+ color: $color-ink;
+ background-color: $color-paper-lit;
+ border: $rule-ink;
+ border-left: 4px solid $color-signal;
+}
+
+.toast-title {
+ @include plate-type($font-size-2xs);
+}
diff --git a/PROJECTS/beginner/prompt-injection-firewall/frontend/src/core/lib/census.ts b/PROJECTS/beginner/prompt-injection-firewall/frontend/src/core/lib/census.ts
new file mode 100644
index 00000000..fb3aee70
--- /dev/null
+++ b/PROJECTS/beginner/prompt-injection-firewall/frontend/src/core/lib/census.ts
@@ -0,0 +1,104 @@
+// ===================
+// © AngelaMos | 2026
+// census.ts
+// ===================
+
+import { CENSUS_MARKS, type CensusMark, CODEPOINT_CLASSES } from '@/config'
+
+export interface Census {
+ glyphs: number
+ bytes: number
+ nonAscii: number
+ tag: number
+ bidi: number
+ zeroWidth: number
+}
+
+export interface Segment {
+ start: number
+ text: string
+ mark: CensusMark | null
+}
+
+interface Range {
+ LOW: number
+ HIGH: number
+}
+
+const encoder = new TextEncoder()
+
+function inRange(code: number, range: Range): boolean {
+ return code >= range.LOW && code <= range.HIGH
+}
+
+function inAnyRange(code: number, ranges: readonly Range[]): boolean {
+ return ranges.some((range) => inRange(code, range))
+}
+
+export function markOf(code: number): CensusMark | null {
+ if (inRange(code, CODEPOINT_CLASSES.TAG)) {
+ return CENSUS_MARKS.TAG
+ }
+ if (inAnyRange(code, CODEPOINT_CLASSES.BIDI)) {
+ return CENSUS_MARKS.BIDI
+ }
+ if (inAnyRange(code, CODEPOINT_CLASSES.ZERO_WIDTH)) {
+ return CENSUS_MARKS.ZERO_WIDTH
+ }
+ return null
+}
+
+export function census(text: string): Census {
+ const counts: Census = {
+ glyphs: 0,
+ bytes: encoder.encode(text).length,
+ nonAscii: 0,
+ tag: 0,
+ bidi: 0,
+ zeroWidth: 0,
+ }
+
+ for (const character of text) {
+ const code = character.codePointAt(0) ?? 0
+ counts.glyphs += 1
+
+ if (code > CODEPOINT_CLASSES.ASCII_HIGH) {
+ counts.nonAscii += 1
+ }
+
+ const mark = markOf(code)
+ if (mark === CENSUS_MARKS.TAG) {
+ counts.tag += 1
+ } else if (mark === CENSUS_MARKS.BIDI) {
+ counts.bidi += 1
+ } else if (mark === CENSUS_MARKS.ZERO_WIDTH) {
+ counts.zeroWidth += 1
+ }
+ }
+
+ return counts
+}
+
+export function hiddenTotal(counts: Census): number {
+ return counts.tag + counts.bidi + counts.zeroWidth
+}
+
+export function segments(text: string): Segment[] {
+ const output: Segment[] = []
+ let offset = 0
+
+ for (const character of text) {
+ const mark = markOf(character.codePointAt(0) ?? 0)
+ const previous = output.at(-1)
+
+ if (previous !== undefined && previous.mark === null && mark === null) {
+ previous.text += character
+ } else {
+ output.push({ start: offset, text: character, mark })
+ }
+
+ offset += character.length
+ }
+
+ return output
+}
diff --git a/PROJECTS/beginner/prompt-injection-firewall/frontend/src/core/lib/index.ts b/PROJECTS/beginner/prompt-injection-firewall/frontend/src/core/lib/index.ts
index cdee46e2..0231f1c4 100644
--- a/PROJECTS/beginner/prompt-injection-firewall/frontend/src/core/lib/index.ts
+++ b/PROJECTS/beginner/prompt-injection-firewall/frontend/src/core/lib/index.ts
@@ -3,4 +3,5 @@
// index.ts
// ===================
+export * from './census'
export * from './shell.ui.store'
diff --git a/PROJECTS/beginner/prompt-injection-firewall/frontend/src/main.tsx b/PROJECTS/beginner/prompt-injection-firewall/frontend/src/main.tsx
index 1b1f2c8a..8a1e6acd 100644
--- a/PROJECTS/beginner/prompt-injection-firewall/frontend/src/main.tsx
+++ b/PROJECTS/beginner/prompt-injection-firewall/frontend/src/main.tsx
@@ -3,6 +3,11 @@
// main.tsx
// ===========================
+import '@fontsource-variable/martian-mono'
+import '@fontsource-variable/space-grotesk'
+import '@fontsource/ibm-plex-mono/400.css'
+import '@fontsource/ibm-plex-mono/500.css'
+
import { StrictMode } from 'react'
import { createRoot } from 'react-dom/client'
import App from './App'
diff --git a/PROJECTS/beginner/prompt-injection-firewall/frontend/src/pages/arena/arena.module.scss b/PROJECTS/beginner/prompt-injection-firewall/frontend/src/pages/arena/arena.module.scss
index 4568b90a..0ce73de7 100644
--- a/PROJECTS/beginner/prompt-injection-firewall/frontend/src/pages/arena/arena.module.scss
+++ b/PROJECTS/beginner/prompt-injection-firewall/frontend/src/pages/arena/arena.module.scss
@@ -2,176 +2,678 @@
// © AngelaMos | 2026
// arena.module.scss
// ===================
-// Layout only. No colour, no type scale, no aesthetic decisions.
-// The visual language is Carter's call; every class below is a hook
-// waiting for it.
+
+@use '../../styles/tokens' as *;
+@use '../../styles/fonts' as *;
+@use '../../styles/mixins' as *;
.page {
display: flex;
flex-direction: column;
- gap: 1.5rem;
}
-.header {
+.masthead {
+ position: relative;
+ display: grid;
+ grid-template-columns: 1fr;
+ gap: $space-6;
+ padding: $space-8 $space-4 $space-6;
+ overflow: hidden;
+
+ @include breakpoint-up('md') {
+ padding: $space-12 $space-8 $space-8;
+ }
+
+ @include breakpoint-up('lg') {
+ grid-template-columns: minmax(0, 1fr) 16rem;
+ align-items: end;
+ }
+}
+
+.masthead-main {
+ display: flex;
+ flex-direction: column;
+ min-width: 0;
+}
+
+.masthead-meta {
display: flex;
flex-direction: column;
- gap: 0.25rem;
+ border-top: $rule-ink;
+}
+
+.meta-row {
+ display: flex;
+ align-items: baseline;
+ justify-content: space-between;
+ gap: $space-3;
+ padding: $space-2 0;
+ border-bottom: $hairline;
+}
+
+.meta-key {
+ @include plate-type($font-size-2xs);
+
+ color: $color-ink-faint;
+}
+
+.meta-value {
+ @include label-type($font-size-2xs);
+
+ color: $color-ink;
+ font-variant-numeric: tabular-nums;
}
.title {
- margin: 0;
+ @include display-type;
+
+ margin-left: -0.06em;
+ color: $color-ink;
+ text-transform: lowercase;
+ overflow-wrap: anywhere;
}
.tagline {
- margin: 0;
+ @include label-type($font-size-sm);
+
+ max-width: 46ch;
+ margin-top: $space-4;
+ color: $color-ink-soft;
+ text-transform: none;
}
-.levels {
+.masthead-rule {
+ height: $space-6;
+
+ @include ruled-field($color-rule, 5px);
+
+ @include breakpoint-up('lg') {
+ grid-column: 1 / -1;
+ }
+}
+
+.plate-heading {
+ @include plate-type($font-size-2xs);
+
+ padding-bottom: $space-3;
+ color: $color-ink;
+ border-bottom: $rule-ink;
+}
+
+.sub-heading {
+ @include plate-type($font-size-2xs);
+
+ color: $color-ink-faint;
+}
+
+.config {
display: flex;
- flex-wrap: wrap;
- gap: 0.5rem;
+ flex-direction: column;
+ gap: $space-5;
+ padding: $space-6 $space-4;
+ border-top: $hairline;
+
+ @include breakpoint-up('md') {
+ padding: $space-8;
+ }
}
-.level-button {
+.levels {
+ display: grid;
+ grid-template-columns: repeat(auto-fit, minmax(9.5rem, 1fr));
+ gap: 0;
+ border: $hairline;
+}
+
+.level-plate {
display: flex;
flex-direction: column;
- align-items: flex-start;
- gap: 0.125rem;
- cursor: pointer;
+ gap: $space-2;
+ min-height: 7.5rem;
+ padding: $space-3;
+ color: $color-ink;
+ text-align: left;
+ background-color: transparent;
+ border-right: $hairline;
+ border-bottom: $hairline;
+ transition: background-color $duration-fast $ease,
+ color $duration-fast $ease;
+
+ @include focus-plate;
+
+ &:hover {
+ background-color: $color-paper-sunk;
+ }
+
+ &[data-selected='true'] {
+ @include inverted;
+
+ &:hover {
+ background-color: $color-ink;
+ }
+ }
}
.level-number {
- display: block;
+ @include display-type($font-size-3xl);
+
+ line-height: 1;
}
.level-title {
- display: block;
+ @include label-type($font-size-2xs);
+
+ margin-top: auto;
+ color: inherit;
+ opacity: 0.75;
+}
+
+.level-bars {
+ display: flex;
+ gap: 2px;
+ height: 4px;
+}
+
+.level-bar {
+ flex: 1;
+ background-color: currentColor;
+ opacity: 0.18;
+
+ &[data-on='true'] {
+ opacity: 1;
+ }
+}
+
+.detail {
+ display: grid;
+ grid-template-columns: 1fr;
+ gap: $space-6;
+
+ @include breakpoint-up('lg') {
+ grid-template-columns: 1.15fr 1fr;
+ }
}
.teaches {
- margin: 0;
+ display: flex;
+ flex-direction: column;
+ gap: $space-3;
}
-.layers {
+.teaches-label {
+ @include plate-type($font-size-2xs);
+
+ color: $color-ink-faint;
+}
+
+.teaches-text {
+ font-family: $font-display;
+ font-size: $font-size-xl;
+ line-height: $line-height-tight;
+ letter-spacing: $tracking-display;
+ color: $color-ink;
+
+ @include breakpoint-up('md') {
+ font-size: $font-size-2xl;
+ }
+}
+
+.rail {
display: flex;
flex-direction: column;
- gap: 0.5rem;
+ gap: $space-3;
}
-.layers-heading {
- margin: 0;
+.rail-heading {
+ @include plate-type($font-size-2xs);
+
+ color: $color-ink-faint;
}
-.layer-list {
+.rail-list {
display: flex;
- flex-wrap: wrap;
- gap: 0.5rem;
- margin: 0;
- padding: 0;
- list-style: none;
+ flex-direction: column;
+ border-top: $hairline;
+}
+
+.rail-item {
+ display: grid;
+ grid-template-columns: 3rem 1fr;
+ align-items: center;
+ gap: $space-3;
+ padding: $space-2 $space-1;
+ border-bottom: $hairline;
+ color: $color-ink-ghost;
+
+ &[data-active='true'] {
+ color: $color-ink;
+ background-color: $color-paper-sunk;
+ }
}
-.layer {
- display: inline-block;
+.rail-index {
+ @include label-type($font-size-2xs);
+}
+
+.rail-name {
+ @include plate-type($font-size-xs);
+
+ letter-spacing: $tracking-label;
+
+ [data-active='false'] & {
+ text-decoration: line-through;
+ }
}
.note {
- margin: 0;
+ font-family: $font-mono;
+ font-size: $font-size-xs;
+ line-height: $line-height-relaxed;
+ color: $color-ink-faint;
+ max-width: 62ch;
+
+ &[data-tone='loud'] {
+ padding-left: $space-3;
+ color: $color-ink;
+ border-left: 2px solid $color-signal;
+ }
}
.form {
display: flex;
flex-direction: column;
- gap: 0.5rem;
+ gap: $space-3;
+ padding: $space-6 $space-4;
+ border-top: $hairline;
+ background-color: $color-paper;
+
+ @include breakpoint-up('md') {
+ padding: $space-8;
+ }
+}
+
+.form-head {
+ display: flex;
+ align-items: baseline;
+ justify-content: space-between;
+ gap: $space-4;
+ padding-bottom: $space-3;
+ border-bottom: $rule-ink;
}
.label {
- display: block;
+ @include plate-type($font-size-2xs);
+}
+
+.counter {
+ @include label-type($font-size-2xs);
+
+ color: $color-ink-faint;
}
.hint {
- margin: 0;
+ font-family: $font-mono;
+ font-size: $font-size-xs;
+ color: $color-ink-soft;
}
.textarea {
width: 100%;
- min-height: 8rem;
+ min-height: 11rem;
+ padding: $space-4;
+ font-family: $font-mono;
+ font-size: $font-size-sm;
+ line-height: $line-height-relaxed;
+ color: $color-ink;
resize: vertical;
- font-family: inherit;
-}
+ background-color: $color-paper-lit;
+ border: $rule-ink;
+ border-radius: $radius-none;
-.counter {
- align-self: flex-end;
+ @include focus-plate;
}
.submit {
align-self: flex-start;
- cursor: pointer;
+ padding: $space-3 $space-8;
+ color: $color-paper-lit;
+ background-color: $color-ink;
+ border: $plate-border;
+ transition: background-color $duration-fast $ease,
+ color $duration-fast $ease;
+
+ @include plate-type($font-size-2xs);
+ @include focus-plate;
+
+ &:hover:not(:disabled) {
+ color: $color-ink;
+ background-color: $color-signal;
+ border-color: $color-signal;
+ }
+
+ &:disabled {
+ color: $color-ink-ghost;
+ cursor: not-allowed;
+ background-color: transparent;
+ border-color: $color-rule;
+ }
+}
+
+.specimen {
+ display: flex;
+ flex-direction: column;
+ gap: $space-4;
+ padding: $space-6 $space-4;
+ border-top: $hairline;
+
+ @include breakpoint-up('md') {
+ padding: $space-8;
+ }
+}
+
+.specimen-head {
+ display: flex;
+ align-items: baseline;
+ justify-content: space-between;
+ gap: $space-4;
+}
+
+.ghost-button {
+ padding: $space-2 $space-3;
+ color: $color-ink-soft;
+ border: $hairline;
+ transition: color $duration-fast $ease,
+ border-color $duration-fast $ease;
+
+ @include plate-type($font-size-2xs);
+ @include focus-plate;
+
+ &:hover,
+ &[data-on='true'] {
+ color: $color-ink;
+ border-color: $color-ink;
+ }
+}
+
+.census-grid {
+ display: grid;
+ grid-template-columns: repeat(2, 1fr);
+ border-top: $hairline;
+ border-left: $hairline;
+
+ @include breakpoint-up('sm') {
+ grid-template-columns: repeat(3, 1fr);
+ }
+
+ @include breakpoint-up('lg') {
+ grid-template-columns: repeat(6, 1fr);
+ }
+}
+
+.census-cell {
+ display: flex;
+ flex-direction: column;
+ gap: $space-1;
+ padding: $space-3;
+ border-right: $hairline;
+ border-bottom: $hairline;
+
+ &[data-hot='true'] {
+ background-color: $color-caution;
+ }
+}
+
+.census-value {
+ @include display-type($font-size-2xl);
+
+ font-variant-numeric: tabular-nums;
+}
+
+.census-label {
+ @include label-type($font-size-2xs);
+
+ color: $color-ink-faint;
+
+ [data-hot='true'] & {
+ color: $color-ink;
+ }
+}
+
+.reveal {
+ padding: $space-4;
+ font-family: $font-mono;
+ font-size: $font-size-sm;
+ line-height: 2;
+ color: $color-ink-soft;
+ white-space: pre-wrap;
+ overflow-wrap: anywhere;
+ background-color: $color-paper-lit;
+ border: $hairline;
+
+ @include dotted-field($color-rule-faint, 5px);
+}
+
+.reveal-mark {
+ padding: 0 $space-1;
+ margin: 0 1px;
+ font-size: $font-size-2xs;
+ letter-spacing: $tracking-label;
+ color: $color-paper-lit;
+ text-transform: uppercase;
+ background-color: $color-ink;
+
+ &[data-mark='TAG'] {
+ color: $color-ink;
+ background-color: $color-caution;
+ }
+
+ &[data-mark='BIDI'] {
+ background-color: $color-signal;
+ }
}
.error {
- margin: 0;
+ padding: $space-3 $space-4;
+ margin: 0 $space-4;
+ color: $color-paper-lit;
+ background-color: $color-signal;
+
+ @include plate-type($font-size-2xs);
+}
+
+.awaiting {
+ padding: $space-12 $space-4;
+ color: $color-ink-ghost;
+ text-align: center;
+ border-top: $hairline;
+
+ @include plate-type($font-size-2xs);
}
.verdict {
display: flex;
flex-direction: column;
- gap: 0.5rem;
+ gap: $space-5;
+ padding: $space-6 $space-4 $space-10;
+ border-top: $rule-ink;
+
+ @include breakpoint-up('md') {
+ padding: $space-8 $space-8 $space-12;
+ }
+}
+
+.verdict-head {
+ display: flex;
+ align-items: baseline;
+ justify-content: space-between;
+ gap: $space-4;
}
-.verdict-heading {
- margin: 0;
+.attempts {
+ @include label-type($font-size-2xs);
+
+ color: $color-ink-faint;
}
.decisions {
display: grid;
- grid-template-columns: auto 1fr;
- gap: 0.25rem 0.75rem;
- margin: 0;
+ grid-template-columns: 1fr;
+ gap: 0;
+ border-top: $hairline;
+ border-left: $hairline;
- dd {
- margin: 0;
+ @include breakpoint-up('sm') {
+ grid-template-columns: repeat(2, 1fr);
+ }
+}
+
+.decision {
+ display: flex;
+ flex-direction: column;
+ gap: $space-2;
+ padding: $space-4;
+ border-right: $hairline;
+ border-bottom: $hairline;
+}
+
+.decision-key {
+ @include plate-type($font-size-2xs);
+
+ color: $color-ink-faint;
+}
+
+.decision-value {
+ @include display-type($font-size-3xl);
+
+ text-transform: lowercase;
+
+ &[data-decision='block'] {
+ color: $color-signal;
+ }
+
+ &[data-decision='sanitize'] {
+ color: $color-ink;
+ text-decoration: underline;
+ text-decoration-thickness: 3px;
+ text-underline-offset: 0.14em;
+ text-decoration-color: $color-caution;
+ }
+
+ &[data-unreached='true'] {
+ font-size: $font-size-lg;
+ color: $color-ink-ghost;
}
}
.findings {
display: flex;
flex-direction: column;
- gap: 0.25rem;
- margin: 0;
- padding: 0;
- list-style: none;
+ border-top: $hairline;
}
.finding {
- display: flex;
- flex-wrap: wrap;
- gap: 0.5rem;
+ display: grid;
+ grid-template-columns: 1fr;
+ gap: $space-1 $space-3;
+ align-items: center;
+ padding: $space-3 $space-1;
+ border-bottom: $hairline;
+
+ @include breakpoint-up('md') {
+ grid-template-columns: 7rem 1fr 8rem 5rem 5rem;
+ }
+}
+
+.finding-layer {
+ @include plate-type($font-size-2xs);
+}
+
+.finding-rule {
+ font-family: $font-mono;
+ font-size: $font-size-sm;
+ color: $color-ink-soft;
+ overflow-wrap: anywhere;
+}
+
+.finding-track {
+ display: block;
+ height: 0.75rem;
+ background-color: $color-paper-sunk;
+}
+
+.finding-fill {
+ display: block;
+ height: 100%;
+ background-color: $color-ink;
+
+ [data-invariant='true'] & {
+ background-color: $color-signal;
+ }
}
-.finding-layer,
-.finding-rule,
.finding-severity {
- display: inline-block;
+ @include label-type($font-size-2xs);
+
+ color: $color-ink-faint;
}
-.outcome {
- margin: 0;
+.finding-flag {
+ @include label-type($font-size-2xs);
+
+ color: $color-signal;
}
-.agent {
+.seal {
display: flex;
flex-direction: column;
- gap: 0.5rem;
+ gap: $space-3;
+ padding: $space-6 $space-4;
+ border: $plate-border;
+
+ @include breakpoint-up('md') {
+ padding: $space-8;
+ }
+
+ &[data-escaped='true'] {
+ @include inverted;
+
+ border-color: $color-ink;
+ }
}
-.agent-heading {
- margin: 0;
+.seal-label {
+ @include plate-type($font-size-2xs);
+
+ color: $color-ink-faint;
+
+ [data-escaped='true'] & {
+ color: $color-signal;
+ }
+}
+
+.seal-text {
+ @include display-type($font-size-numeral);
+
+ [data-escaped='true'] & {
+ color: $color-paper-lit;
+ }
+}
+
+.agent {
+ display: flex;
+ flex-direction: column;
+ gap: $space-3;
}
.agent-text {
- margin: 0;
+ padding: $space-4;
+ font-family: $font-mono;
+ font-size: $font-size-sm;
+ line-height: $line-height-relaxed;
+ color: $color-ink;
white-space: pre-wrap;
overflow-x: auto;
- font-family: inherit;
+ background-color: $color-paper;
+ border-top: $rule-ink;
+ border-bottom: $hairline;
}
diff --git a/PROJECTS/beginner/prompt-injection-firewall/frontend/src/pages/arena/index.tsx b/PROJECTS/beginner/prompt-injection-firewall/frontend/src/pages/arena/index.tsx
index 241e59c7..6d58d388 100644
--- a/PROJECTS/beginner/prompt-injection-firewall/frontend/src/pages/arena/index.tsx
+++ b/PROJECTS/beginner/prompt-injection-firewall/frontend/src/pages/arena/index.tsx
@@ -7,85 +7,284 @@ import { useMemo, useState } from 'react'
import { useAttempt, useLevels, useSession } from '@/api/hooks'
import type { AttemptResponse, Finding, Level } from '@/api/types'
-import { ARENA, COPY, DECISION, LAYER_ORDER, RULE_LAYER_DISABLED } from '@/config'
+import {
+ ARENA,
+ CENSUS_MARKS,
+ COPY,
+ DECISION,
+ LAYER_ORDER,
+ NUMERAL_PAD,
+ RULE_LAYER_DISABLED,
+ SESSION_ID_HEAD,
+ SEVERITY_MAX_WEIGHT,
+ SEVERITY_SCALE_OFFSET,
+ SEVERITY_WEIGHT,
+} from '@/config'
+import { census, hiddenTotal, segments } from '@/core/lib'
import styles from './arena.module.scss'
+function numeral(value: number): string {
+ return String(value).padStart(NUMERAL_PAD, '0')
+}
+
+function severityWidth(severity: string): string {
+ const weight = SEVERITY_WEIGHT[severity as keyof typeof SEVERITY_WEIGHT] ?? 0
+ const span = SEVERITY_MAX_WEIGHT + SEVERITY_SCALE_OFFSET
+ return `${((weight + SEVERITY_SCALE_OFFSET) / span) * 100}%`
+}
+
function firedFindings(result: AttemptResponse): Finding[] {
return result.findings.filter((finding) => finding.rule !== RULE_LAYER_DISABLED)
}
-function disabledLayers(level: Level): string[] {
- return LAYER_ORDER.filter((layer) => !level.active_layers.includes(layer))
+function LevelPlate({
+ level,
+ selected,
+ onSelect,
+}: {
+ level: Level
+ selected: boolean
+ onSelect: (value: number) => void
+}): React.ReactElement {
+ return (
+ <button
+ type="button"
+ className={styles.levelPlate}
+ data-selected={selected}
+ onClick={() => onSelect(level.number)}
+ >
+ <span className={styles.levelNumber}>{numeral(level.number)}</span>
+ <span className={styles.levelTitle}>{level.title}</span>
+ <span className={styles.levelBars} aria-hidden="true">
+ {LAYER_ORDER.map((layer) => (
+ <span
+ key={layer}
+ className={styles.levelBar}
+ data-on={level.active_layers.includes(layer)}
+ />
+ ))}
+ </span>
+ </button>
+ )
}
-function LayerList({ level }: { level: Level }): React.ReactElement {
- const off = disabledLayers(level)
+function LayerRail({ level }: { level: Level }): React.ReactElement {
+ const off = LAYER_ORDER.filter((layer) => !level.active_layers.includes(layer))
return (
- <section className={styles.layers}>
- <h2 className={styles.layersHeading}>{COPY.ACTIVE_LAYERS}</h2>
- <ul className={styles.layerList}>
- {LAYER_ORDER.map((layer) => (
+ <section className={styles.rail}>
+ <h2 className={styles.railHeading}>{COPY.ACTIVE_LAYERS}</h2>
+ <ul className={styles.railList}>
+ {LAYER_ORDER.map((layer, index) => (
<li
key={layer}
- className={styles.layer}
+ className={styles.railItem}
data-active={level.active_layers.includes(layer)}
>
- {layer}
+ <span className={styles.railIndex}>{numeral(index + 1)}</span>
+ <span className={styles.railName}>{layer}</span>
</li>
))}
</ul>
{level.active_layers.length === 0 && (
- <p className={styles.note}>{COPY.NO_ACTIVE_LAYERS}</p>
+ <p className={styles.note} data-tone="loud">
+ {COPY.NO_ACTIVE_LAYERS}
+ </p>
)}
{off.length > 0 && level.active_layers.length > 0 && (
<p className={styles.note}>{COPY.DISABLED_NOTICE}</p>
)}
{level.number === ARENA.BOUNTY_LEVEL && (
- <p className={styles.note}>{COPY.BOUNTY_NOTE}</p>
+ <p className={styles.note} data-tone="loud">
+ {COPY.BOUNTY_NOTE}
+ </p>
+ )}
+ </section>
+ )
+}
+
+function CensusCell({
+ label,
+ value,
+ hot,
+}: {
+ label: string
+ value: number
+ hot: boolean
+}): React.ReactElement {
+ return (
+ <div className={styles.censusCell} data-hot={hot}>
+ <span className={styles.censusValue}>{value}</span>
+ <span className={styles.censusLabel}>{label}</span>
+ </div>
+ )
+}
+
+function Specimen({ ticket }: { ticket: string }): React.ReactElement {
+ const [revealed, setRevealed] = useState<boolean>(false)
+ const counts = useMemo(() => census(ticket), [ticket])
+ const hidden = hiddenTotal(counts)
+ const parts = useMemo(
+ () => (revealed ? segments(ticket) : []),
+ [revealed, ticket]
+ )
+
+ return (
+ <section className={styles.specimen}>
+ <div className={styles.specimenHead}>
+ <h2 className={styles.plateHeading}>{COPY.SPECIMEN_HEADING}</h2>
+ <button
+ type="button"
+ className={styles.ghostButton}
+ data-on={revealed}
+ onClick={() => setRevealed((value) => !value)}
+ >
+ {revealed ? COPY.REVEAL_OFF : COPY.REVEAL_ON}
+ </button>
+ </div>
+
+ <div className={styles.censusGrid}>
+ <CensusCell
+ label={COPY.CENSUS.GLYPHS}
+ value={counts.glyphs}
+ hot={false}
+ />
+ <CensusCell label={COPY.CENSUS.BYTES} value={counts.bytes} hot={false} />
+ <CensusCell
+ label={COPY.CENSUS.NON_ASCII}
+ value={counts.nonAscii}
+ hot={false}
+ />
+ <CensusCell
+ label={COPY.CENSUS.TAG}
+ value={counts.tag}
+ hot={counts.tag > 0}
+ />
+ <CensusCell
+ label={COPY.CENSUS.BIDI}
+ value={counts.bidi}
+ hot={counts.bidi > 0}
+ />
+ <CensusCell
+ label={COPY.CENSUS.ZERO_WIDTH}
+ value={counts.zeroWidth}
+ hot={counts.zeroWidth > 0}
+ />
+ </div>
+
+ {ticket.length === 0 ? (
+ <p className={styles.note}>{COPY.SPECIMEN_EMPTY}</p>
+ ) : (
+ <p className={styles.note} data-tone={hidden > 0 ? 'loud' : 'calm'}>
+ {hidden > 0 ? COPY.CENSUS_DIRTY : COPY.CENSUS_CLEAN}
+ </p>
+ )}
+
+ {revealed && ticket.length > 0 && (
+ <pre className={styles.reveal}>
+ {parts.map((part) =>
+ part.mark === null ? (
+ <span key={part.start}>{part.text}</span>
+ ) : (
+ <mark
+ key={part.start}
+ className={styles.revealMark}
+ data-mark={part.mark}
+ >
+ {part.mark === CENSUS_MARKS.TAG
+ ? part.text.codePointAt(0)?.toString(16)
+ : part.mark}
+ </mark>
+ )
+ )}
+ </pre>
)}
</section>
)
}
+function Findings({ findings }: { findings: Finding[] }): React.ReactElement {
+ if (findings.length === 0) {
+ return <p className={styles.note}>{COPY.NO_RULES}</p>
+ }
+
+ return (
+ <ul className={styles.findings}>
+ {findings.map((finding) => (
+ <li
+ key={`${finding.layer}-${finding.rule}`}
+ className={styles.finding}
+ data-invariant={finding.invariant}
+ >
+ <span className={styles.findingLayer}>{finding.layer}</span>
+ <span className={styles.findingRule}>{finding.rule}</span>
+ <span className={styles.findingTrack}>
+ <span
+ className={styles.findingFill}
+ style={{ width: severityWidth(finding.severity) }}
+ />
+ </span>
+ <span className={styles.findingSeverity}>{finding.severity}</span>
+ <span className={styles.findingFlag}>
+ {finding.invariant ? COPY.INVARIANT_MARK : ''}
+ </span>
+ </li>
+ ))}
+ </ul>
+ )
+}
+
function Verdict({ result }: { result: AttemptResponse }): React.ReactElement {
const fired = firedFindings(result)
return (
<section className={styles.verdict}>
- <h2 className={styles.verdictHeading}>{COPY.VERDICT_HEADING}</h2>
+ <div className={styles.verdictHead}>
+ <h2 className={styles.plateHeading}>{COPY.VERDICT_HEADING}</h2>
+ <span className={styles.attempts}>
+ {COPY.ATTEMPTS_LABEL} {numeral(result.attempts)}
+ </span>
+ </div>
<dl className={styles.decisions}>
- <dt>request</dt>
- <dd data-decision={result.request_decision}>{result.request_decision}</dd>
- <dt>egress</dt>
- <dd data-decision={result.egress_decision ?? DECISION.ALLOW}>
- {result.egress_decision ?? '—'}
- </dd>
+ <div className={styles.decision}>
+ <dt className={styles.decisionKey}>{COPY.REQUEST_LABEL}</dt>
+ <dd
+ className={styles.decisionValue}
+ data-decision={result.request_decision}
+ >
+ {result.request_decision}
+ </dd>
+ </div>
+ <div className={styles.decision}>
+ <dt className={styles.decisionKey}>{COPY.EGRESS_LABEL}</dt>
+ <dd
+ className={styles.decisionValue}
+ data-decision={result.egress_decision ?? DECISION.ALLOW}
+ data-unreached={result.egress_decision === null}
+ >
+ {result.egress_decision ?? COPY.EGRESS_UNREACHED}
+ </dd>
+ </div>
</dl>
- {fired.length === 0 ? (
- <p className={styles.note}>{COPY.NO_RULES}</p>
- ) : (
- <ul className={styles.findings}>
- {fired.map((finding) => (
- <li
- key={`${finding.layer}-${finding.rule}`}
- className={styles.finding}
- data-invariant={finding.invariant}
- >
- <span className={styles.findingLayer}>{finding.layer}</span>
- <span className={styles.findingRule}>{finding.rule}</span>
- <span className={styles.findingSeverity}>{finding.severity}</span>
- </li>
- ))}
- </ul>
- )}
+ <h3 className={styles.subHeading}>{COPY.FINDINGS_HEADING}</h3>
+ <Findings findings={fired} />
- <p className={styles.outcome} data-escaped={result.secret_escaped}>
- {result.secret_escaped ? COPY.SECRET_ESCAPED : COPY.SECRET_CONTAINED}
- </p>
+ <div className={styles.seal} data-escaped={result.secret_escaped}>
+ <span className={styles.sealLabel}>{COPY.SECRET_LABEL}</span>
+ <span className={styles.sealText}>
+ {result.secret_escaped ? COPY.SECRET_ESCAPED : COPY.SECRET_CONTAINED}
+ </span>
+ </div>
+
+ <section className={styles.agent}>
+ <h3 className={styles.subHeading}>{COPY.AGENT_HEADING}</h3>
+ <pre className={styles.agentText}>
+ {result.agent_text || COPY.AGENT_EMPTY}
+ </pre>
+ </section>
</section>
)
}
@@ -122,68 +321,95 @@ export function Component(): React.ReactElement {
}
return (
- <main className={styles.page}>
- <header className={styles.header}>
- <h1 className={styles.title}>{COPY.TITLE}</h1>
- <p className={styles.tagline}>{COPY.TAGLINE}</p>
+ <div className={styles.page}>
+ <header className={styles.masthead}>
+ <div className={styles.mastheadMain}>
+ <h1 className={styles.title}>{COPY.TITLE}</h1>
+ <p className={styles.tagline}>{COPY.TAGLINE}</p>
+ </div>
+ <dl className={styles.mastheadMeta}>
+ <div className={styles.metaRow}>
+ <dt className={styles.metaKey}>{COPY.SESSION_LABEL}</dt>
+ <dd className={styles.metaValue}>
+ {session.data?.session_id.slice(0, SESSION_ID_HEAD) ??
+ COPY.SESSION_PENDING}
+ </dd>
+ </div>
+ <div className={styles.metaRow}>
+ <dt className={styles.metaKey}>{COPY.SECRET_LABEL_SHORT}</dt>
+ <dd className={styles.metaValue}>
+ {session.data === undefined
+ ? COPY.SESSION_PENDING
+ : `${session.data.secret_length} ${COPY.SECRET_UNIT}`}
+ </dd>
+ </div>
+ <div className={styles.metaRow}>
+ <dt className={styles.metaKey}>{COPY.CONFIG_LABEL}</dt>
+ <dd className={styles.metaValue}>
+ {numeral(levels.data?.levels.length ?? 0)}
+ </dd>
+ </div>
+ </dl>
+ <div className={styles.mastheadRule} />
</header>
- <nav className={styles.levels}>
- {levels.data?.levels.map((entry) => (
- <button
- key={entry.number}
- type="button"
- className={styles.levelButton}
- data-selected={entry.number === level}
- onClick={() => setLevel(entry.number)}
- >
- <span className={styles.levelNumber}>{entry.number}</span>
- <span className={styles.levelTitle}>{entry.title}</span>
- </button>
- ))}
- </nav>
+ <section className={styles.config}>
+ <h2 className={styles.plateHeading}>{COPY.LEVEL_HEADING}</h2>
+ <nav className={styles.levels}>
+ {levels.data?.levels.map((entry) => (
+ <LevelPlate
+ key={entry.number}
+ level={entry}
+ selected={entry.number === level}
+ onSelect={setLevel}
+ />
+ ))}
+ </nav>
- {current && (
- <>
- <p className={styles.teaches}>{current.teaches}</p>
- <LayerList level={current} />
- </>
- )}
+ {current && (
+ <div className={styles.detail}>
+ <div className={styles.teaches}>
+ <span className={styles.teachesLabel}>{COPY.TEACHES_LABEL}</span>
+ <p className={styles.teachesText}>{current.teaches}</p>
+ </div>
+ <LayerRail level={current} />
+ </div>
+ )}
+ </section>
<form className={styles.form} onSubmit={submit}>
- <label className={styles.label} htmlFor="ticket">
- {COPY.TICKET_LABEL}
- </label>
+ <div className={styles.formHead}>
+ <label className={styles.label} htmlFor="ticket">
+ {COPY.TICKET_LABEL}
+ </label>
+ <span className={styles.counter}>
+ {ticket.length} / {ARENA.MAX_TICKET_CHARS}
+ </span>
+ </div>
<p className={styles.hint}>{COPY.TICKET_HINT}</p>
<textarea
id="ticket"
className={styles.textarea}
value={ticket}
maxLength={ARENA.MAX_TICKET_CHARS}
+ spellCheck={false}
onChange={(event) => setTicket(event.target.value)}
/>
- <div className={styles.counter}>
- {ticket.length} / {ARENA.MAX_TICKET_CHARS}
- </div>
<button type="submit" className={styles.submit} disabled={!canSubmit}>
{attempt.isPending ? COPY.SUBMITTING : COPY.SUBMIT}
</button>
</form>
+ <Specimen ticket={ticket} />
+
{attempt.isError && <p className={styles.error}>{COPY.ERRORS.DEFAULT}</p>}
- {attempt.data && (
- <>
- <Verdict result={attempt.data} />
- <section className={styles.agent}>
- <h2 className={styles.agentHeading}>{COPY.AGENT_HEADING}</h2>
- <pre className={styles.agentText}>
- {attempt.data.agent_text || COPY.AGENT_EMPTY}
- </pre>
- </section>
- </>
+ {attempt.data ? (
+ <Verdict result={attempt.data} />
+ ) : (
+ <p className={styles.awaiting}>{COPY.AWAITING}</p>
)}
- </main>
+ </div>
)
}
diff --git a/PROJECTS/beginner/prompt-injection-firewall/frontend/src/styles.scss b/PROJECTS/beginner/prompt-injection-firewall/frontend/src/styles.scss
index d3afe02d..003738fc 100644
--- a/PROJECTS/beginner/prompt-injection-firewall/frontend/src/styles.scss
+++ b/PROJECTS/beginner/prompt-injection-firewall/frontend/src/styles.scss
@@ -10,14 +10,36 @@
@use 'styles/reset';
@use 'styles/tokens' as *;
@use 'styles/fonts' as *;
+@use 'styles/mixins' as *;
+
+$grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23g)' opacity='0.34'/%3E%3C/svg%3E");
body {
- font-family: $font-sans;
+ font-family: $font-display;
+ font-size: $font-size-base;
color: $color-text;
background-color: $color-bg;
}
+body::before {
+ position: fixed;
+ inset: 0;
+ z-index: $z-base;
+ background-image: $grain;
+ opacity: 0.5;
+ mix-blend-mode: multiply;
+ pointer-events: none;
+ content: '';
+}
+
+::selection {
+ color: $color-paper-lit;
+ background-color: $color-ink;
+}
+
#root {
+ position: relative;
+ z-index: $z-base;
min-height: 100vh;
min-height: 100dvh;
display: flex;
diff --git a/PROJECTS/beginner/prompt-injection-firewall/frontend/src/styles/_fonts.scss b/PROJECTS/beginner/prompt-injection-firewall/frontend/src/styles/_fonts.scss
index 049e125a..1c916697 100644
--- a/PROJECTS/beginner/prompt-injection-firewall/frontend/src/styles/_fonts.scss
+++ b/PROJECTS/beginner/prompt-injection-firewall/frontend/src/styles/_fonts.scss
@@ -3,7 +3,10 @@
// _fonts.scss
// ===================
-$font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica,
- Arial, sans-serif;
-$font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, 'Liberation Mono',
- monospace;
+$font-display: 'Space Grotesk Variable', 'Helvetica Neue', Helvetica, Arial,
+ sans-serif;
+$font-plate: 'Martian Mono Variable', ui-monospace, SFMono-Regular, Menlo,
+ Consolas, monospace;
+$font-mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, Consolas,
+ 'Liberation Mono', monospace;
+$font-sans: $font-display;
diff --git a/PROJECTS/beginner/prompt-injection-firewall/frontend/src/styles/_mixins.scss b/PROJECTS/beginner/prompt-injection-firewall/frontend/src/styles/_mixins.scss
index aef18b11..b6093e1d 100644
--- a/PROJECTS/beginner/prompt-injection-firewall/frontend/src/styles/_mixins.scss
+++ b/PROJECTS/beginner/prompt-injection-firewall/frontend/src/styles/_mixins.scss
@@ -5,6 +5,7 @@
@use 'sass:map';
@use 'tokens' as *;
+@use 'fonts' as *;
$breakpoints: (
'xs': $breakpoint-xs,
@@ -36,7 +37,86 @@ $breakpoints: (
padding: 0;
margin: -1px;
overflow: hidden;
- clip: rect(0 0 0 0);
+ clip-path: inset(50%);
white-space: nowrap;
border: 0;
}
+
+@mixin plate-type($size: $font-size-2xs) {
+ font-family: $font-plate;
+ font-size: $size;
+ font-weight: $font-weight-normal;
+ letter-spacing: $tracking-plate;
+ text-transform: uppercase;
+ line-height: $line-height-tight;
+}
+
+@mixin label-type($size: $font-size-xs) {
+ font-family: $font-mono;
+ font-size: $size;
+ letter-spacing: $tracking-label;
+ text-transform: uppercase;
+ line-height: $line-height-tight;
+}
+
+@mixin display-type($size: $font-size-display) {
+ font-family: $font-display;
+ font-size: $size;
+ font-weight: $font-weight-bold;
+ letter-spacing: $tracking-display;
+ line-height: $line-height-flat;
+}
+
+@mixin inverted {
+ color: $color-paper-lit;
+ background-color: $color-ink;
+}
+
+@mixin corner-ticks($inset: 0, $length: $tick-size, $color: $color-ink) {
+ position: relative;
+
+ &::before,
+ &::after {
+ position: absolute;
+ width: $length;
+ height: $length;
+ content: '';
+ pointer-events: none;
+ }
+
+ &::before {
+ top: $inset;
+ left: $inset;
+ border-top: 1px solid $color;
+ border-left: 1px solid $color;
+ }
+
+ &::after {
+ right: $inset;
+ bottom: $inset;
+ border-right: 1px solid $color;
+ border-bottom: 1px solid $color;
+ }
+}
+
+@mixin dotted-field($color: $color-ink-ghost, $step: 6px) {
+ background-image: radial-gradient($color 0.5px, transparent 0.5px);
+ background-size: $step $step;
+}
+
+@mixin ruled-field($color: $color-rule-faint, $step: 4px) {
+ background-image: repeating-linear-gradient(
+ 90deg,
+ $color 0,
+ $color 1px,
+ transparent 1px,
+ transparent $step
+ );
+}
+
+@mixin focus-plate {
+ &:focus-visible {
+ outline: 2px solid $color-signal;
+ outline-offset: 2px;
+ }
+}
diff --git a/PROJECTS/beginner/prompt-injection-firewall/frontend/src/styles/_tokens.scss b/PROJECTS/beginner/prompt-injection-firewall/frontend/src/styles/_tokens.scss
index 4f86f733..157bf40f 100644
--- a/PROJECTS/beginner/prompt-injection-firewall/frontend/src/styles/_tokens.scss
+++ b/PROJECTS/beginner/prompt-injection-firewall/frontend/src/styles/_tokens.scss
@@ -2,10 +2,7 @@
// © AngelaMos | 2026
// _tokens.scss
// ===================
-// Neutral baseline. No brand identity -- grayscale palette, system type, plain
-// spacing scale. Design on top of these; nothing here implies a look.
-// Spacing (8px base)
$space-0: 0;
$space-1: 0.25rem;
$space-2: 0.5rem;
@@ -20,7 +17,7 @@ $space-16: 4rem;
$space-20: 5rem;
$space-24: 6rem;
-// Font sizes
+$font-size-2xs: 0.6875rem;
$font-size-xs: 0.75rem;
$font-size-sm: 0.875rem;
$font-size-base: 1rem;
@@ -29,42 +26,54 @@ $font-size-xl: 1.25rem;
$font-size-2xl: 1.5rem;
$font-size-3xl: 1.875rem;
$font-size-4xl: 2.25rem;
+$font-size-5xl: 3rem;
+$font-size-display: clamp(3.25rem, 11vw, 9.5rem);
+$font-size-numeral: clamp(2.5rem, 7vw, 5.5rem);
-// Weights / line-height / radius
$font-weight-normal: 400;
$font-weight-medium: 500;
$font-weight-semibold: 600;
$font-weight-bold: 700;
-$line-height-tight: 1.25;
+
+$line-height-flat: 0.86;
+$line-height-tight: 1.15;
$line-height-normal: 1.5;
-$line-height-relaxed: 1.75;
-$radius-sm: 0.25rem;
-$radius-md: 0.5rem;
-$radius-lg: 0.75rem;
+$line-height-relaxed: 1.7;
+
+$tracking-plate: 0.14em;
+$tracking-label: 0.08em;
+$tracking-display: -0.035em;
+
+$radius-none: 0;
+$radius-sm: 0.125rem;
$radius-full: 9999px;
-// Neutral grayscale
-$color-white: #fff;
-$color-black: #000;
-$color-gray-50: #fafafa;
-$color-gray-100: #f4f4f5;
-$color-gray-200: #e4e4e7;
-$color-gray-300: #d4d4d8;
-$color-gray-400: #a1a1aa;
-$color-gray-500: #71717a;
-$color-gray-600: #52525b;
-$color-gray-700: #3f3f46;
-$color-gray-800: #27272a;
-$color-gray-900: #18181b;
+$color-paper: #e8e5db;
+$color-paper-lit: #f0eee6;
+$color-paper-sunk: #dedbd0;
+$color-ink: #16150f;
+$color-ink-soft: #3d3b31;
+$color-ink-faint: #7c7869;
+$color-ink-ghost: #b3ae9d;
+$color-rule: #c3bfb0;
+$color-rule-faint: #d5d1c4;
-// Neutral semantic aliases
-$color-bg: $color-white;
-$color-surface: $color-gray-50;
-$color-border: $color-gray-200;
-$color-text: $color-gray-900;
-$color-text-muted: $color-gray-500;
+$color-signal: #f04a23;
+$color-signal-sunk: #c93b17;
+$color-caution: #e9e70e;
+$color-live: #35c46a;
+
+$color-bg: $color-paper;
+$color-surface: $color-paper-lit;
+$color-border: $color-rule;
+$color-text: $color-ink;
+$color-text-muted: $color-ink-faint;
+
+$hairline: 1px solid $color-rule;
+$hairline-faint: 1px solid $color-rule-faint;
+$rule-ink: 1px solid $color-ink;
+$plate-border: 2px solid $color-ink;
-// Breakpoints
$breakpoint-xs: 480px;
$breakpoint-sm: 640px;
$breakpoint-md: 768px;
@@ -72,13 +81,17 @@ $breakpoint-lg: 1024px;
$breakpoint-xl: 1280px;
$breakpoint-2xl: 1536px;
-// Z-index
+$measure-page: 1420px;
+$tick-size: 0.5rem;
+
$z-base: 1;
$z-dropdown: 1000;
$z-modal: 1300;
$z-toast: 1400;
-// Motion
+$duration-instant: 80ms;
$duration-fast: 150ms;
$duration-normal: 250ms;
-$ease: cubic-bezier(0.4, 0, 0.2, 1);
+$duration-slow: 600ms;
+$ease: cubic-bezier(0.2, 0, 0, 1);
+$ease-mechanical: steps(6, end);
diff --git a/PROJECTS/beginner/prompt-injection-firewall/frontend/vite.config.ts b/PROJECTS/beginner/prompt-injection-firewall/frontend/vite.config.ts
index a8d5d478..7d7d7c23 100644
--- a/PROJECTS/beginner/prompt-injection-firewall/frontend/vite.config.ts
+++ b/PROJECTS/beginner/prompt-injection-firewall/frontend/vite.config.ts
@@ -8,6 +8,8 @@ import react from '@vitejs/plugin-react'
import { defineConfig, loadEnv } from 'vite'
import tsconfigPaths from 'vite-tsconfig-paths'
+const FONT_ASSET = /\.(woff2?|ttf|otf|eot)$/
+
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, path.resolve(__dirname, '..'), '')
const isDev = mode === 'development'
@@ -42,6 +44,8 @@ export default defineConfig(({ mode }) => {
build: {
target: 'esnext',
cssTarget: 'chrome100',
+ assetsInlineLimit: (filePath: string) =>
+ FONT_ASSET.test(filePath) ? false : undefined,
sourcemap: isDev ? true : 'hidden',
minify: 'oxc',
rollupOptions: {