A cognitive-manipulation x-ray — on-device
The brain map is a worse detector than the text.
That one finding — proven by the project's own experiment — is why this system looks the way it does. Highlight text, press ⌘B, and a local LLM names the persuasion technique. A brain model shows only where in cortex the words land. This manual walks the whole arc: the premise, the experiments that overturned it, the two algorithms, the engineering, and what's still open.
One idea holds the whole system up
Every file's docstring repeats the same sentence, so start here: detection and interpretation are done by two different models, because each is only good at one job.
The two are decoupled behind a Swift Classifier protocol talking to a local FastAPI server: POST /classify (fast, ~2–3s) and POST /brainmap (slow, opt-in, ~15s–2min). Two OS processes cooperate — the 🧠 menu-bar app you press ⌘B in, and a headless server that holds the models, kept alive 24/7 by a launchd agent on port 8765.
Almost every design decision downstream — which model runs when, what the UI is allowed to claim, why the brain map is opt-in — falls out of this split. Hold onto it.
curl -s -X POST http://127.0.0.1:8765/classify \
-H 'Content-Type: application/json' \
-d '{"text":"Act now or lose everything forever."}'
{"vector":"false-urgency","confidence":99,
"rationale":"imposes a deadline or time pressure...",
"alternatives":[{"vector":"fear-mongering","p":0.0044}, ...]}
Check yourself — why two processes instead of one app?
127.0.0.1:8765.The thesis that died
The project (2026-06-28) began with a bolder, cleaner idea than the one that shipped. The plan: highlight text → feed it to TRIBE v2 as the classifier → read which brain region "lit up" → map that region to a persuasion tactic through a hand-authored table:
It was seductive because it sounded like real neuroscience and it used TRIBE's headline capability directly — "no LLM needed for the core." The overlay would announce not just the tactic but the brain structure it targets.
Two assumptions were load-bearing and both were untested: (1) that emotions map to distinct brain regions, and (2) that a brain model derived from text could detect better than the text itself. Module 2 tests both — and demolishes them.
Sources/…/Taxonomy/Taxonomy.swift — what replaced it
// NOTE: this deliberately makes NO per-vector brain-region claim. // An earlier version asserted fear→amygdala, dopamine→NAcc, etc., // but experiments (A3) showed those vectors do NOT separate by // region, and the model is cortex-only and can't see the amygdala. struct TaxonomyEntry { let vector: PersuasionVector let displayName: String let mechanism: String // a psychological claim, NOT anatomy }
The experiments that reshaped everything
This is the intellectual center. Ten experiments (labelled A1–A7 for feasibility/detection, I1/I1b for interpretation) were run once during research and kept for provenance in server/experiments/. Each asks one falsifiable question. Read the table as a story, top to bottom — the verdict column is where the design turned.
| Exp | Question | Effect / metric | Result | Verdict |
|---|---|---|---|---|
| A1 | Does TRIBE v2 even run on Apple Silicon? | (5, 20484) fsaverage5 predictions on the Metal GPU. |
FEASIBLE | |
| A2 | Does a single decontextualised sentence carry any systematic brain signal? | 34 of 75 regions separate fear vs neutral at p<0.05 — vs ~3.8 expected by chance. | SIGNAL | |
| A2·t | True cold latency per sentence? | ~76s cold (16s events + 60s predict), ~7s warm. | → OPT-IN | |
| A3 | Do fear / outrage / reward hit distinct regions? | No. Effect maps correlate r=0.83–0.90 → the same fronto-orbital regions. (A decoder still reads them apart at 75%.) | KILLED ANATOMY | |
| A4 | Does bag-of-words text beat the brain map? | TF-IDF 43% vs brain 75% — but TF-IDF can't generalise to unseen words. A strawman. | UNINFORMATIVE | |
| A5 | Does the raw Llama embedding beat the brain map? | Yes — 100% vs 75%. The brain projection adds zero detection power; it can only lose information. | THE PIVOT | |
| A6 | Is the gTTS→Google privacy leak gone? | Offline macOS say path taken; (4, 20484) still produced. |
SEALED | |
| I1 | Does dropping audio remove the auditory confound? | No — auditory dominance is model-intrinsic (still d=1.72). But text-only is faster and keeps semantics (d=0.99). | → TEXT-ONLY | |
| A7 | Do curated semantic ROIs separate emotion per-sentence? | Yes — d=0.95, p=0.02 on inferior-frontal/orbital ROIs. The impact profile is honest. | HONEST MAP | |
| I1b | After shipping text-only, does the real pipeline still separate? | Held-out d=+0.77 (large), carried by the Language/inferior-frontal system (Δ+0.85). | RE-VALIDATED |
A5 is the hinge — and it's a theorem, not a fluke
The brain map is computed as text → Llama embedding → brain projection. So the predicted brain response is a function of the text: brain = f(text). The data-processing inequality says a transformation can never add information — so a classifier reading the brain map can never beat one reading the text it was derived from. A5 confirmed it empirically: 100% vs 75%. That killed "TRIBE-as-detector" and forced the hybrid split from Module 0.
Detection is the LLM's job. The brain map's only legitimate value is visceral interpretation — "here is where it lands in your cortex" — never accuracy. Everything the UI says obeys this.
Why these test cases are trustworthy
- Length-matched sentences so sentence length can't fake a difference.
- Per-vertex z-scoring across sentences removes each vertex's baseline, so a region can't look "active" just because it's always active.
- Held-out sentences in I1b (none from the 30 baseline sentences) — no leakage.
- A neutral baseline to z-score against (Module 4) — an emotional baseline would cancel the very signal you want.
- Cohen's d, not just p — effect size, so "significant but tiny" can't masquerade as a real signal.
cat server/experiments/README.md # the results table, verbatim
cd server && .venv/bin/python experiments/a1_smoketest.py
# prints: predictions shape (5, 20484) on mps
Check yourself — why was A4 (TF-IDF) called "uninformative" even though it lost?
How the LLM actually names the technique
The obvious approach — ask the model "which technique is this, and how confident are you?" — was tried and rejected. Free-form generation did two bad things: it collapsed distinct techniques (dopamine-bait and social-proof both got written as false-urgency), and it emitted a constant "80" for confidence every time — a verbal tic, not a probability.
Instead of letting the model write a label, the server scores how likely each candidate label is under the frozen model, then turns those scores into a probability distribution. Concretely, for every one of 12 labels:
- Build a chat prompt that lists all techniques + definitions and ends "answer with the technique name only."
- Append the candidate label and run one forward pass to get the model's log-probability of the label's tokens (teacher-forced next-token log-probs).
- Length-normalise — divide by the number of label tokens so a long name like
critical-thinking-suppressionisn't penalised for being long. - Softmax over the 12 scores → argmax is the verdict; the winner's share is the confidence.
With 12 candidates, a raw softmax spreads probability thin — an obvious false-urgency landed at only ~20%, which reads as "unsure" even when the model isn't. So each score is divided by CONFIDENCE_TEMP = 0.25 before exponentiating. Temperature below 1 exaggerates the gaps, pushing a clear winner toward an assertive number. Same urgency example: 20% → 97%. Genuine ties stay honest (hype / awe / urgency can still land ~34% three-way). Foreshadow: this "assertive" 97% turned out to be over-confident — the honest benchmark (Module 8) found it was right only ~60% of the time, and the shown % is now Platt-calibrated so it means P(correct). Assertive felt good; honest is better.
Eight original negative-valence techniques, three positive-valence ones added later (excitement/hype can manipulate too), plus none for neutral text.
Going from 8 to 12 labels dilutes per-label confidence — the small 3B model separates the positive-valence trio only weakly. The temperature sharpening mitigates it; genuine model ties are left honest rather than faked.
for t in \
'Act now or lose everything forever.' \
'The meeting is at 3pm on Tuesday in room 214.' \
'This will completely change your life and the entire world forever.'
do curl -s -X POST http://127.0.0.1:8765/classify \
-H 'Content-Type: application/json' -d "{\"text\":\"$t\"}"; echo; done
false-urgency 99% (deadline pressure) none 100% (purely factual) hype-hope-mongering 93% (utopian upside)
server/server.py — the softmax sharpening
m = max(scores) exps = [math.exp((s - m) / CONFIDENCE_TEMP) for s in scores] # T<1 => assertive z = sum(exps) probs = [e / z for e in exps] best = max(range(len(VECTORS)), key=lambda i: probs[i])
Check yourself — why score labels instead of generating one?
Scoring 14 labels naively meant 12 forward passes, each re-reading the whole ~350-token prompt — about 4 seconds per ⌘B. The fix: process the shared prompt once into a KV cache, then let each label continue from that cached state. Same verdicts, ~450ms — a 9× speedup that's what makes ⌘B feel instant.
Highlighting a Google AI Overview's friendly "Hello! How can I help you today?" reported "Hype 84%". The reason is structural: a single 14-way classifier must pick a label, so it forces benign, upbeat, or helpful text toward its nearest tactic. Worse, every prompt tweak just slid the whole none/manipulation boundary — fix greetings and you start missing real manipulation.
The fix is to split the decision. Stage 1 is a clean yes/no gate — "is this actually trying to persuade or manipulate?" — where benign text (greetings, questions, requests, plain facts, reviews) answers no and becomes none. Stage 2, the unchanged 14-way technique classifier, runs only if the gate says yes. The line is drawn by intent: "the sale ends Friday" is ordinary; "hurry, the sale ends Friday, don't miss out!" is manipulation.
A binary gate is a far easier, cleaner decision than diluting "none" across a 14-way softmax. Tuned against a realistic mix (60% benign — how people actually highlight), it now catches 20/20 manipulation while correctly ignoring 27/30 benign lines. The one honest cost: a second short model pass (~450ms → ~650ms).
curl ... -d '{"text":"Hello! How can I help you today?"}'
curl ... -d '{"text":"Hurry, this deal disappears at midnight!"}'
"none" 99% # gate says: not manipulation "false-urgency" 100% # gate says yes → technique
The brain map, honestly rendered
Deep-scan is opt-in (the 🧠 menu) because it's slow. When you trigger it, the server turns your sentence into a predicted fMRI cortical response and reduces it to something a human can read. Five moves:
TRIBE v2 predicts activation on 20,484 fsaverage5 cortical vertices. In the default text-only mode there's no speech synthesis at all: the sentence is split into synthetic Word events at 0.35s each and fed straight in. Because word events already exist, TRIBE's transcription step early-returns — "that early-return is the whole trick." No TTS, no WhisperX, no audio dependencies.
Raw activation is dominated by "there is language here" (auditory cortex — model-intrinsic, per I1). To find what's content-driven, each vertex is z-scored against a neutral baseline: z = (activation − mean) / std, where mean/std come from 30 deliberately neutral, factual sentences.
The baseline must be neutral text. If it contained emotional sentences, z-scoring would subtract the emotional signal too — leaving only sensorimotor noise. The baseline is also tagged with its mode; the server refuses to serve if a text baseline is paired with an audio pipeline.
Ranking all regions of a single sentence surfaces low-level acoustic/sensorimotor cortex — an artifact, not meaning. So the profile reports only a curated set of value- and language-evaluation ROIs (inferior-frontal, orbital, vmPFC), the ones A7 proved separate emotional from neutral at d=0.95. Those group into three readable systems:
TRIBE is cortex-only — it cannot see the amygdala or nucleus accumbens. So the UI never says "fires your fear center." It says "engages your value / language-evaluation cortex." The response even carries a caveat field restating this. This is Module 1's dead thesis, buried properly.
TRIBE carries its own ~7 GB text encoder; co-loaded with the detector that's ~13 GB on a 24 GB Mac — swap-thrash territory. So TRIBE is loaded and freed on every call, leaving only the light 4-bit detector resident. And if swap is already >90% full, /brainmap refuses rather than thrashing the disk.
curl -s --max-time 320 -X POST http://127.0.0.1:8765/brainmap \
-H 'Content-Type: application/json' \
-d '{"text":"You must act now or lose everything forever."}'
{"impact_profile":[
{"system":"Language processing (inferior frontal)","z":..,"level":"high"},
{"system":"Value / evaluation (orbitofrontal)", "z":..,"level":"elevated"},
{"system":"Executive / cognitive-load (dlPFC)", "z":..,"level":"elevated"}],
"mode":"text", "caveat":"predicted cortical BOLD, cortex-only ..."}
Check yourself — why z-score against neutral instead of showing raw activation?
Making it real, and invisible
The science is half the work. The other half is a background macOS agent that reads any app's selection, never steals focus, survives its own rebuilds, and doesn't melt a 24 GB laptop. The hard-won lessons:
Capture: the Accessibility → pasteboard pivot
The first build read selected text via the Accessibility API — which returns empty for Chrome/Safari article bodies and PDFs. The fix: synthesize a ⌘C, read the clipboard, then restore the previous clipboard so the user never notices. That reads text everywhere. ⌘B is a deliberately non-consuming global hotkey, so it still bolds in editors while also triggering a scan.
The signing saga (why ⌘B kept dying)
macOS ties the Accessibility permission to the app's code signature. With ad-hoc signing, every rebuild produced a new signature — silently revoking the grant and breaking ⌘B. The fix was a persistent self-signed identity ("CPD Local Signing") so the signature — and therefore the permission — is stable across rebuilds. A one-time re-grant, then it sticks.
The four-hour freeze
The baseline build froze at 2/30 sentences, 0% CPU, for hours. Cause: TRIBE's checkpoint resets its DataLoader to ~20 forked worker processes at load time, and forked workers deadlock on macOS. Patching the source wasn't enough — "the checkpoint wins." The fix, harden_tribe(model), forces num_workers = 0 after every load, plus per-sentence checkpointing so a hang costs one sentence, not the whole run.
Two Metal workloads, one GPU
MLX's GPU streams are thread-local, so all detector work is pinned to one dedicated server thread. And an isBusy mutex in the app serialises classify vs. deep-scan, so an MLX detection and a PyTorch brain-map never fight over Metal at once.
codesign -dv --verbose=2 build/Debug/CorticalPersuasionDecoder.app \ 2>&1 | grep -E 'Identifier|Authority' launchctl print gui/$(id -u)/ai.zeonsystems.cpd.server \ | grep -E 'state|pid'
Identifier=ai.zeonsystems.corticalpersuasiondecoder Authority=CPD Local Signing # stable, not ad-hoc state = running pid = 41750 # respawns on crash (KeepAlive)
A tool that defends your mind can't spy on it
Everything runs on-device — no cloud, no API keys, no telemetry. Two guardrails enforce it:
- The gTTS leak, closed. An early TTS step used Google's
gTTS, which uploaded every highlighted snippet to Google's servers. It was replaced with offline macOSsay+ ffmpeg (and the default text-only path skips TTS entirely). Bonus: 75s → 22s per sentence. - Secrets never get classified. Before any text is sent,
SensitiveTextscreens it for passwords, API-key prefixes (sk-,ghp_,hf_…), JWT shapes, and card-number patterns — and skips them. Analysing a secret is pointless and a liability, even locally.
Sources/…/Support/SensitiveText.swift — the shape heuristics
// API-key-shaped: one long token, letters + digits, no spaces if t.count >= 20 && hasLetter && hasDigit { return true } // Card / account #: mostly digits once spaces & dashes stripped if compactDigits >= 13 && digitRatio > 0.9 { return true }
What's unresolved
Two threads are deliberately left open, and it's worth knowing why.
Capture Region (OCR) — broken, being chipped at
The 🧠 menu's "Capture Region" — drag-select a screen area → screenshot → Vision OCR → classify — doesn't yet produce a verdict. The silent no-op was fixed (every branch now shows an on-screen notice and jumps to the Screen-Recording settings pane), but whether the full OCR→verdict path works once permission is granted is still unconfirmed. Suspects: the Screen-Recording grant or the ScreenCaptureKit / Vision step.
Subcortical "Track B" — deferred on purpose
Training TRIBE to see the amygdala + nucleus accumbens is scientifically motivated but blocked by cost: no auto-download, fMRIPrep derivatives not shipped (GPU-weeks of preprocessing), a cortex-only released checkpoint, Slurm-based training — and decisively, it would improve interpretation only, which A5 already showed is not where accuracy comes from.
Also open, undecided: a confidence-calibration study, a browser extension, and a vision-LLM for images. The positive-valence confidence dilution from Module 3 remains a known, honestly-surfaced limitation.
How we actually know it works
This is the honest accounting the manual was started for. There were two different questions inside "does it work" — and the second one now has a much better answer than it used to.
This is the most important lesson in the manual. The self-authored benchmarks (the ones that drove the manufactured-awe fix and the two-stage gate) were real progress, but they flattered the system — because the same person wrote the examples and tuned the prompts. Only an external, never-tuned-on test set tells the truth, and it's humbling.
The first honest run exposed a gate blind spot. The gate could rank manipulation vs benign (PR-AUC 0.89) but at the shipped threshold it missed ~44% of real manipulation (recall 0.56) — concentrated in e-commerce dark patterns it read as plain facts. The confidence % is assertive, not honest. Calibration error is 0.26: on the cases where it says "99%", it's right ~85% of the time — over-confident on purpose, because the % ships un-calibrated so it reads assertively (turn calibration on and it drops into the 40–60s). Tactic labels blur in the urgency/fomo cluster and on the loose clickbait↔dopamine mapping.
The right response isn't to hide these numbers — it's to measure them properly: macro-F1 and per-class scores (not accuracy) under class imbalance, Wilson/bootstrap confidence intervals (N is small, so ±6–14 points), PR-AUC for the gate, and ECE for the confidence. That's what bench_full.py now does, and what docs/BENCHMARKING.md lays out as the roadmap.
The honest metrics pointed at concrete fixes, each validated on a held-out external half: (1) the gate's probability had been saturated by the assertiveness temperature, so un-sharpening it made the ranking usable (PR-AUC 0.89) and the threshold tunable; (2) the confidence is over-confident, so Platt calibration is available to map the shown % to P(correct) — ECE 0.37 → 0.10 — though it ships off by product choice (the assertive % tested better with the user); (3) when a technique label is genuinely unclear, the card now abstains ("treat the label as a guess") instead of asserting it; and (4) the biggest technique blur — scarcity read as time-urgency — was fixed by splitting fomo (scarcity/miss-out) from false-urgency (the clock), lifting fomo recall 0.05 → 0.70. The point isn't that it's fixed — it's that honest measurement is what tells you what to fix.
Stress-testing turned up a blind spot the marketing-oriented taxonomy couldn't see: "if you really cared you would…", "you made me do this", "no one will ever love you like I do" — one-on-one emotional manipulation — all landed on the nearest broadcast label (guilt read as critical-thinking-suppression, love-bombing as hype). The taxonomy was built for propaganda and ads, not for a text from someone in your life. So it grew a second interpersonal family — guilt-tripping, love-bombing, blame-shifting/DARVO, plus gaslighting and minimization folded into critical-thinking-suppression — taking it to 14 vectors. The subtlety is keeping them separable: possessiveness ("no one else", "can't live without you") distinguishes love-bombing from an ordinary compliment; fault-reversal distinguishes blame-shifting from guilt. With no external labeled corpus for these tactics, they're validated on a curated behavioral set — 88%, with ordinary praise correctly staying none.
The honest run said the gate missed ~44% of manipulation, but not which. A diagnostic (gate_diag.py) recorded the gate's manipulation-probability on every example, then broke the misses down by class — and the answer was stark: the gate was blind to e-commerce dark patterns that read like plain facts. Fake social-proof activity nudges ("24 people have purchased this today", "someone in [city] just bought this") were missed 22 of 31 times; manufactured scarcity ("items in high demand, we reserved yours"), bare countdown timers ("04 HOURS 17 MINUTES 18 SECONDS"), and curiosity-gap clickbait leaked through too. These are manipulation — engineered purchase pressure — but they wear the costume of a neutral statistic. The fix taught the gate each family, keyed on the nudge intent, and — crucially — guarded each one so its benign twin stays none: "the study surveyed 24 people", "the library had 111 visitors", "the meeting is at 4:30", a straight news headline. The payoff, on the same 300 external examples: gate recall 0.56 → 0.77, precision 0.84 → 0.87, PR-AUC 0.89 → 0.93 — +21 recall points with no precision cost. The lesson repeats: you can't fix what you can't localize, so build the diagnostic before the fix.
Fixing the gate exposed the next bottleneck. The gate now caught manipulation (recall 0.78), but the confusion matrix showed stage-2 dumping almost everything into one bucket: false-urgency. Scarcity ("only 2 left") read as a clock; fake social-proof and clickbait landed there too; dopamine-bait scored 0.00 recall. The classifier had definitions but no decision rule for which technique wins when several apply — and "hurry / act now" language is everywhere, so false-urgency became a magnet. The fix was a tie-break keyed on the primary lever the text pulls: limited supply → FOMO; an explicit deadline clock → false-urgency; other people's activity → social-proof; a reward or curiosity hook → dopamine-bait; a named person's fame or credential → authority-appeal (which also had to grow beyond "experts/officials" to cover celebrity and anecdotal authority — "Michael Jordan wears X so you should too"). Crucially this is stage-2 only — the gate never changed — so there was zero risk to the recall just won. The payoff, same 300 examples: accuracy 44 → 61%, macro-F1 0.18 → 0.37, with per-class recall jumping (dopamine 0.00 → 0.70, FOMO 0.28 → 0.53, authority 0.15 → 0.35). Detection and classification are different jobs with different failure modes; separating them let each be fixed without disturbing the other.
With the obvious wins banked, the next question was: can we push past ~61%? Two textbook levers got a fair, measured trial. Few-shot exemplars — worked demonstrations riding the prompt — nudged accuracy to 62.7% but quietly hurt balance (macro-F1 0.37 → 0.34) and re-blurred scarcity vs the clock, so it's used sparingly. Then a real LoRA fine-tune: 3.5M adapter params on the frozen 4-bit base, trained only on a leakage-free split (self-authored + the external dev half) and reported on the untouched holdout, watching the validation loss so we shipped the iter-100 checkpoint rather than the over-fit iter-200. The result was the honest kind of anticlimactic: on the holdout, few-shot 62.7% · zero-shot 62.0% · LoRA 60.7% — statistically tied (the confidence intervals overlap almost completely). LoRA bought better balance (macro-F1 0.49) but not accuracy; 267 imbalanced examples over-fit some classes and starved others. The lesson worth keeping: when three reasonable configs land inside each other's error bars, you're not looking at a tuning problem anymore — you're at the ceiling of a 3B, 4-bit model on this task. The next real lever isn't a cleverer prompt or a longer fine-tune; it's a bigger detector — and this time it got run. Same 300 examples, one env var: 3B 62% → 8B 69% → 14B 79%, and the 14B with few-shot examples reaches 82.3%. Capacity was the ceiling, not the method; the fast 3B stays the instant default and the 14B is an opt-in high-accuracy mode. Past even that, the honest move is to stop forcing one label — manipulation is usually two techniques at once, so scored as top-2 ("did we name it") the number is ~73% on the 3B and near 90% on the 14B. Reporting every number, including the ones that didn't improve — a self-consistency vote that turned out to be a confound, a fine-tune that never beat prompting, a reasoning model too slow to ship — was the point.
The takeaway for anyone learning this system: be suspicious of any benchmark whose author also tuned the model on it. The idea is proven by experiment; the detector works in the "is this manipulation at all?" sense; but the precise accuracy is lower and the confidence less trustworthy than a demo suggests — and saying so plainly is the point.
Litmus · field manual · detection = local MLX Llama-3.2-3B · interpretation = TRIBE v2 · on-device, zero telemetry.
Sources: server/experiments/README.md, server/server.py, the Swift app under Sources/, and docs/BENCHMARKING.md. All quantitative claims trace to the committed experiment record.