Five layers, six stages, one contract.
The detail behind the map: what each layer owns, what happens between a paste and a verdict, the exact shape the answer must take, and the rules that decide who reads it afterwards.
Who owns what.
Interface
React 19 · Tailwind
Renders the drill, the inspector and the reference pages as one responsive app, from a single codebase that also ships to phones.
Routing
TanStack Start · Cloudflare Workers
Each screen is its own file-based route, server-rendered first and hydrated in the browser. Gated routes resolve the session before rendering a single record.
Server functions
Typed RPC · zod validation
The only way in or out of the engine. Every call is named, validated against fixed limits, and checked for a signed-in caller before any work happens.
Analysis engine
Python 3 reference · schema-bound model
The A–Z codes are specified as readable Python predicates. The live analyser applies the same rubric and must answer in the same fixed shape.
Storage
Entity store · row-level security
Two tables record what happened. Access is decided by rule, not by query, so a record is only ever visible to the person it belongs to and to an admin.
From paste to verdict.
The browser never talks to the engine or the store directly. One named call does all four jobs in order, and each step can stop the request without leaving anything half-written.
browser server function engine · store │ paste + submit │ │ ├────────────────────────▶│ │ │ │ 1 resolve the session │ │ │ 2 validate · trim · cap │ │ │ 3 frame as evidence ──────▶│ │ │◀──── verdict, schema-bound │ │◀── verdict + flags ─────┤ │ │ │ 4 write Inspection ───────▶│ │◀── saved to history ────┤ │ │ │ │
Steps 1 and 2 are deterministic. Step 3 is the only judgement call in the system.
Six stages, in order.
- 01
Accept and bound
Sender 320 characters, subject 320, links 1 000, body 8 000 — with the body trimmed and a 20-character minimum. Nothing longer or emptier reaches the engine.
- 02
Authenticate
A server-side middleware resolves the caller before the handler runs. Anonymous calls get a 401 and the analysis never starts.
- 03
Frame the evidence
From, Subject, Links and Body are labelled and triple-fenced. The frame states that the message is evidence and that nothing inside it is an instruction.
- 04
Constrain the answer
The response is a JSON schema: a verdict from three values, an integer score 0–100, at most six flags, at most five tactics.
- 05
Score and classify
Bands are fixed: safe 0–25, suspicious 26–64, phishing 65–100. The score has to sit inside the verdict it was given with.
- 06
Persist
Verdict, score, flags and next step are written as an Inspection record under the asker's own access rules — saved, not silently shared.
Codes decide the thinking. The schema decides the shape.
Each letter in the code list is a predicate that takes a message and returns true or false. The reference implementation reads them as a plain list of checks, weights what fired, and maps the total onto a band — which is exactly what the live analyser is told to do, in the same vocabulary.
MESSAGE = Message(sender, subject, links, body)
findings = [rule for rule in RULES if rule(MESSAGE)]
score = min(sum(SEVERITY[rule.__name__] for rule in findings), 100)
report(
verdict=band(score), # safe · suspicious · phishing
score=score,
flags=[explain(rule, MESSAGE) for rule in findings],
)Read top to bottom: extract once, run every code, weight the hits, return one report. The live engine produces the same six fields.
- Input caps and trimming
- Caller identity
- Output shape and value ranges
- Score stays inside its band
- Who may read the record
- Which lines are the flags
- How serious each flag is
- The wording of the summary
- The single next step to give
Everything in this column is bounded by the schema, quoted from the message, and checked against the verdict.
What comes back, every time.
safe
No meaningful signs of deception.
suspicious
Some signs, inconclusive. Verify before acting.
phishing
A clear attempt to deceive.
verdictone of safe · suspicious · phishingrisk_scoreinteger 0–100, inside its verdict's bandsummaryat most two sentences, plain languagered_flags0–6 items, most serious first, each with a verbatim quotetacticsup to five short labelsrecommended_actionone or two sentencesTwo records, no sharing.
History exists so a learner can see their own improvement. Access is written as a rule on each record rather than as a query in the interface, which means a wrong filter cannot widen it.
DrillAttemptScenario, category, difficulty, your call, whether it was right, seconds taken.
Owner reads and writes; an admin can review.
InspectionThe message you pasted, its verdict, score, flags, tactics and next step.
Owner reads and writes; an admin can review.
How it behaves when it breaks.
- Short input never submits — the form needs twenty characters and the schema enforces the ceiling.
- A signed-out caller gets a 401, never a half-finished analysis.
- An analysis error is shown inline while the message stays in the form, so nothing typed is lost.
- If saving history fails, the verdict still stays on screen — the read is never thrown away for a storage error.
- An answer that breaks the schema is a failed call, not a free-form paragraph the interface has to guess at.
See the codes behind the verdict.
Every flag the engine returns is one of twenty-six letters, each with the tell, an example and its Python predicate.