Engine Reference // Deterministic by Construction.

How the 8 mechanical rules and the offline audit card work

Engine state verified against shipped code: 2026-12-02 · grai.page v3.3.0.

Direct Answer. grai is a deterministic harness, not a model wrapper. The browser engine inside grai.html (and the seal worker at grai.page) audits a draft against eight mechanical rules with fixed penalties, a sentence-rhythm floor at CV ≥ 0.32 and a Unicode integrity gate. The CLI/MCP engine (grai-gate on PyPI) checks the same habit families under snake_case names and adds four flags of its own. No model scores your text. Regular expressions and arithmetic do, and two runs on the same draft return the same number.

1. Architecture: Deterministic by Construction

Three engines enforce one contract: paste a draft, get a binary verdict and the exact spans that broke it.

EngineWhere it runsStackModel in the loop
Browser enginegrai.html, local file, CSP connect-src 'none'Vanilla JS, zero dependenciesNone
Seal enginegrai.page/seal worker, audited modeSame rule table server-side, volatile RAMNone
CLI/MCP gategrai-gate (PyPI) local and grai.page/api/mcpPython stdlib, gate.pyNone

The scored path never calls an LLM. Drafting and repair are separate actions you run with your own model. The audit is the part that stays boring on purpose, because boring is verifiable.

2. The Eight Mechanical Rules (Browser and Seal Engine)

The rule table ships inside grai.html as GRAI_RULES. Each rule carries a first-occurrence penalty and a smaller repeat penalty, so one slip costs more than a habit. The score starts at 100 and stops at 4.

Internal codeWhat it catchesFirst hitRepeat
CONTRASTIVE_NEGATIONThe forced opposition formula: “It's not X, it's Y.”-14-8
LESS_MORE_SYMMETRYCorporate symmetry: “Less X, more Y.” “Stop doing X, start doing Y.”-10-6
EPIPHANY_OPENERThe formulaic reveal beat: “Here is why...” “Let that sink in.”-10-7
ARROW_BULLET_SLOPArrow cascades and emoji bullet templates.-12-4
TRIADIC_PADDINGThe empty slogan triplet: “No X. No Y. Just Z.”-12-8
LEXICAL_SLOPGeneric synthetic vocabulary: state-of-the-art, best-in-class, actionable.-6-5
VERDICT_COLONThe pompous verdict colon: “The reality is:” “The takeaway:”-8-4
PROSE_TRIADRhetorical triplets and parallel question cascades.-10-5

The audit names the rule and quotes the span that fired it. You fix the span yourself or send it to your model with the rule label attached. The gate never rewrites text you did not ask it to.

SMOOTH_BRIDGE, reported separately

Over-connected paragraph openers (“That's why...”, “In other words...”) get their own flag instead of sharing the rule table. A draft can pass all eight rules and still read glued together, so the bridge check runs in the same pass.

The Unicode Integrity Gate

The web engine strips invisible characters before it scores anything: zero-width space through zero-width non-joiner (U+200B to U+200D) plus the byte order mark (U+FEFF). The CLI gate goes further and fails the draft on Unicode obfuscation: mixed-script homoglyphs, BiDi overrides and hidden tag characters cost 25 points per critical hit. Copy-pasted model output often carries these marks. They are invisible in every editor and they ship to the client unless something removes them.

3. The Burstiness Floor: CV = sigma / mu

Burstiness is the coefficient of variation of your sentence lengths: the standard deviation divided by the mean. Flat AI drafts cluster around a polite 15-word mean. Human rhythm swings, so the gate enforces a floor on the ratio. This is why a draft with clean vocabulary can still fail: every sentence is fine, and the rhythm between them is a metronome.

The two engine families draw the line differently, and the difference is published rather than hidden.

Browser and seal engine: one binary floor. CV ≥ 0.32 passes, anything below flags FLAT_BURSTINESS. The audit needs at least 4 sentences to compute a CV at all.

CLI/MCP gate (gate.py): four graded bands.

CV rangeVerdictEffect on score
below 0.32flat cadencehard fail, -20
0.32 to 0.35low burstinesshard fail, -14
0.35 to 0.40borderline cadencesoft flag, -3
0.40 and abovehuman bandclean, target reference is 0.45

A draft at CV 0.34 passes the web floor and still fails the CLI gate. Both engines are deterministic about it, so you can argue with an opinion, never with the arithmetic. The corpus behind the floor: grai.page/methodology.

4. The Offline Audit Card vs. the Server Seal

Two proof artifacts exist, and the boundary between them is exact.

The offline audit card (local, zero network)

In grai.html you print the cadence certificate: an A4 card with the measured profile, the rule results and a SHA-256 fingerprint of the payload. The fingerprint is computed in the browser through WebCrypto, with a pure-JS SHA-256 fallback for file:// sessions. The page carries connect-src 'none' in its Content Security Policy, so the browser itself refuses outbound requests. Profiles and drafts stay in localStorage with a one-click .grai export. Nothing is uploaded because the transport is disabled.

The seal payload (hash-only)

The certificate's seal payload contains a salted SHA-256 of the draft (draftHash), plus hashes of the profile and the settings. The draft text never enters the object. You copy the payload to grai.page/seal and the server signs the envelope with ECDSA P-256 (key grai-seal-1, algorithm ES256). The server sees hashes. It never sees the draft.

The audited server seal

Agency mode is the one path where the draft travels: you submit the text once, the worker runs the same eight rules in volatile memory, and the prose is discarded after the hash is computed. What lands in Cloudflare KV is the SHA-256 commitment, the score, the CV, the rule count and the agency reference. The public receipt at grai.page/verify/:hash shows exactly that. A draft that fails the gate gets HTTP 422 and no signature (not_issued_failed_gate). Zero prose is stored. The claim is precise: the audited seal sends the draft once and keeps none of it.

The registry of live receipts is public at grai.page/proof, and the full protocol for agencies is documented there.

5. What the CLI/MCP Gate Adds

gate.py implements the same habit families under snake_case names: heres_why (epiphany opener), contrast (forced opposition), arrows, zombie (lexical slop), verdict_colon, prose_triad, triplet, closing, smooth_bridge. On top of the shared set it adds four checks the web scorer does not run.

FlagWhat it addsEffect
em_dashEm dashes and double-hyphen separators in prosehard fail, -18 per hit, capped at 3
tripletThree consecutive sentences within a narrow length bandhard flag on monotony
closingEngagement-bait closers: “Thoughts?”, “Agree or disagree?”soft penalty
run_onRun-on sentences past the 32-word caphard flag

The CLI runs locally (uvx --from grai-mcp grai-gate-mcp), in CI through grai-gate-action, or over the remote MCP endpoint at grai.page/api/mcp. Install steps: grai.page/mcp.

6. Frequently Asked Questions

Do the browser engine and the CLI gate give the same score?

No, and the difference is documented. Both are deterministic and both check the same habit families, but the web floor is binary at 0.32 while the CLI grades 0.32 to 0.40 into low-burst and borderline bands. A draft at CV 0.36 passes the web scorer and reads borderline on the CLI. Pick the engine that matches your pipeline and stay on it.

Why does my draft fail with zero flagged vocabulary?

Because vocabulary is only the small layer. Rhythm gets scored too, and so does structure: opposition formulas, slogan triplets, glued paragraph bridges. Invisible characters count. A draft can be clean on every word and still read machine-made, because the metronome is the tell. The audit names the span and the rule for each hit. Fix it, rerun, watch the number move.

Can a client verify the signed card without installing anything?

Yes. The receipt at grai.page/verify/:hash is a public URL with no account and no login. It shows the score, the CV against the floor, the rule count and the ECDSA P-256 signature status with the key id. Anyone who wants to check the signature by hand can pull the public keyring from /api/pubkey.

Run the gate on your own machine, then decide.

Solo Offline Edition ($79/yr) or Agency Verification Protocol ($99/mo or $790/yr).

Solo Offline $79/yr Agency Protocol $99/mo