Skip to main content
Glama
Academic Prose Humanizer MCP Server

Academic Prose Humanizer MCP Server

README.md
<div align="center">

# Academic Prose Humanizer v3.0

**Cross-Platform, Contract-Driven, Event-Driven LLM Add-On Harness for Academic Humanization & Turnitin Remediation**  
*Install alongside **Antigravity, Claude Code, OpenAI Codex, Cursor, or GitHub Copilot** so your active LLM performs controlled, zero-corruption, Walter-surpassing scholarly humanization for any sentence, paragraph, or manuscript — backed by an 18-command CLI, 6-operator air-gapped decompressor & optional `1280×720` Local Web Studio*

[![Release v3.0.0](https://img.shields.io/badge/release-v3.0.0-0969da.svg)](CHANGELOG.md)
[![Runtimes](https://img.shields.io/badge/runtimes-Antigravity%20%7C%20Claude%20Code%20%7C%20Codex%20%7C%20Cursor%20%7C%20Copilot-6f42c1.svg)](docs/MCP_AND_SKILLS.md)
[![TOML Contracts](https://img.shields.io/badge/TOML%20contracts-5%20declarative-1f6feb.svg)](docs/ARCHITECTURE.md#2-declarative-toml-contracts-contracts)
[![Lifecycle Events](https://img.shields.io/badge/event%20harness-9%20lifecycle%20events-0a7ea4.svg)](docs/ARCHITECTURE.md#1-event-driven-controlled-llm-harness-pipeline)
[![Portable Skills](https://img.shields.io/badge/AgentSkills-4%20portable%20skills-2ea44f.svg)](docs/MCP_AND_SKILLS.md#2-portable-skills--5-role-editorial-team-agents)
[![Dual-Format Agents](https://img.shields.io/badge/editorial%20agents-5%20dual--format%20(.md%20%2B%20.toml)-0550ae.svg)](docs/MCP_AND_SKILLS.md#2-portable-skills--5-role-editorial-team-agents)
[![MCP Server](https://img.shields.io/badge/MCP%20server-21%20offline%20tools-6f42c1.svg)](docs/API_REFERENCE.md#4-mcp-server-21-offline-stdio-tools)
[![CLI Commands](https://img.shields.io/badge/CLI-18%20subcommands-0550ae.svg)](docs/API_REFERENCE.md#1-command-line-interface-prose-humanize--python--m-prose_humanizer)
[![Companion Web Studio](https://img.shields.io/badge/companion%20Web%20Studio-22%20HTTP%20routes-0f4c81.svg)](#companion-runtime-cli-offline-decompressor-docker--optional-local-web-studio)
[![Python 3.10+](https://img.shields.io/badge/python-3.10%20%7C%203.11%20%7C%203.12-3776AB?logo=python&logoColor=white)](https://www.python.org/)
[![Core Dependencies: Zero](https://img.shields.io/badge/core%20deps-0%20(pure%20stdlib)-1f6feb.svg)](pyproject.toml)
[![License: MIT](https://img.shields.io/badge/license-MIT-2ea44f.svg)](LICENSE)

[60-Second Add-On Quickstart](#60-second-add-on-quickstart) •
[Repository Architecture](#repository-architecture-map) •
[Companion Runtime](#companion-runtime-cli-offline-decompressor-docker--optional-local-web-studio) •
[Before & After Proof](#before--after-academic-showcase) •
[Multi-Oracle Progression](#multi-oracle-progression-iter-0-to-iter-2b3) •
[Competitive Matrix](#competitive-matrix-verified-2026-12-05) •
[Documentation](#documentation--examples) •
[Academic Integrity](#academic-integrity--offline-proxy-notice)

</div>

---

## Why Academic Prose Humanizer Exists

Both commercial SaaS humanizers and unassisted frontier LLMs fail academic manuscripts in three reproducible ways:

1. **Silent scientific corruption:** In our empirical 90-span forensic audit of a leading commercial humanizer (Walter Writes Pro, `University | Academic | Enhanced`), **`55 / 90` (`61.1%`)** spans suffered critical numeric, inequality, polarity, acronym, or silent-omission defects (`36 -> 48` patients hallucinated, `0.0656 -> 0.0665` digit transposition, `<0.98 -> >.98` inequality flip, `8/8` clinical standards mangled, and **`0 / 90`** spans usable verbatim). In our follow-up 10-passage cross-domain showdown, Commercial Humanizer Pro failed **`10 / 10`** passages (`63` critical defects, including gene-symbol and statistical-test corruptions).
2. **The Turnitin Purple trap:** WordNet spinners, 1:1 synonym swappers, typo injectors, and multi-hop translation chains swap natural prose for artificial lexical cycling — triggering **Turnitin Purple (AI-paraphrased)** flags and failing peer review.
3. **Uncontrolled LLM backfires & collateral re-flagging:** Asking a frontier LLM to "humanize this paragraph" without deterministic guardrails rewrites already-clean (`0%` AI) sentences and frequently **increases** AI risk — in our blind randomized A/B evaluation (`n = 6` academic spans), an unassisted LLM baseline backfired (`Mode B risk 31.62 -> 39.64`, `+8.02` pts; `5/6` spans became *more* flagged).

**Academic Prose Humanizer v3.0** solves all three by wrapping your active coding/research LLM (**Antigravity, Claude Code, OpenAI Codex, Cursor, or GitHub Copilot**) inside a **declarative TOML-contract-driven, event-driven add-on harness** built on **pure Python 3.10+ standard library** (zero mandatory pip dependencies, zero external CDNs, zero telemetry):

- **Declarative TOML Contracts (`contracts/*.toml`):** Five machine-validated contracts (`harness.toml`, `presets.toml`, `invariants.toml`, `routing.toml`, `team.toml`) govern the 8-state harness, **288** exact Walter-parity + Q1-academic 4-axis target bands (`6` readability × `6` purpose × `4` strength × `2` voice policies), `D1`–`D10` zero-corruption gates, `FLU-1`–`FLU-5` fluency guards, `BB-1`–`BB-4` boundary bridges, `7` auto-routes + `5` exclusions, and the 5-role Editorial Team (`zero_self_approval = true`).
- **Event-Driven LLM Harness (`HumanizerHarness` + `21`-Tool Local Stdio MCP):** Drives any active LLM through a persistent, fail-closed `9`-event state machine (`state.json` + append-only `events.jsonl`): `harness_start_session` → `harness_next_span` → active LLM rewrites strictly outside `⟦...⟧` frozen sentinels → `harness_submit_candidate` (fail-closed `D1`–`D10` + Mode B + Purple-Spin gate with surgical retry directives) → `harness_record_audit` (independent non-author auditor) → `harness_apply_and_certify` (pre-write `100%` SHA-256 lock parity + atomic `.tex`/`.md`/`.docx`/`.txt` patch + receipt).
- **Drop-In Cross-Platform Pack + 1-Command Installer (`scripts/install_addon.py`):** Ships `4` portable AgentSkills, `5` dual-format (`.md` + `.toml`) Editorial Team agents, `3` executable fail-closed lifecycle hooks (`hooks/*.py`), and native plugin bundles for **Antigravity, Claude Code, OpenAI Codex, Cursor, and GitHub Copilot** — installed atomically with `.bak` backups and zero destructive config overwrites.
- **Deterministic Companion Runtime Included:** Backed by the standalone **`18`-subcommand CLI**, our **`6`-operator air-gapped Offline Structural Decompressor** (`12/12` Clean Eradication, zero API keys), Mode A **4-format Turnitin PDF ingestion** + SHA-256 clean locks, and the optional **`1280×720` `100vh` Local Web Studio** (`prose-humanize serve`, `22` HTTP routes, zero `.innerHTML`).

---

## 60-Second Add-On Quickstart

### 1. Install Engine & Drop-In Runtime Add-On (1 Command)

```bash
git clone https://github.com/academic-prose-humanizer/academic-prose-humanizer.git
cd academic-prose-humanizer

# 1. Pure Python 3.10+ stdlib install (zero mandatory pip dependencies)
pip install -e .
# Optional: add PyMuPDF for native Turnitin PDF highlight ingestion
pip install -e ".[pdf]"

# 2. Validate all 5 declarative TOML contracts & bundled wheel parity
prose-humanize harness validate-contracts

# 3. Install the add-on pack for your active LLM runtime (atomic, non-destructive, .bak backups)
python scripts/install_addon.py --target claude        # Claude Code (~/.claude/ + 4 slash cmds + hooks + MCP)
python scripts/install_addon.py --target codex         # OpenAI Codex (~/.codex/ skills, agents, config.toml MCP)
python scripts/install_addon.py --target antigravity   # Antigravity (~/.gemini/config/plugins/academic-prose-humanizer/)
python scripts/install_addon.py --target cursor        # Cursor (.cursor/rules/*.mdc + .cursor/mcp.json)
python scripts/install_addon.py --target copilot --project-dir .  # GitHub Copilot (.github/copilot-instructions.md + agents)

# Or install/verify/uninstall across ALL 5 runtimes at once (supports --scope user|project and --dry-run)
python scripts/install_addon.py --target all --dry-run
python scripts/install_addon.py --target all --verify
```

### 2. How Your Active LLM Drives the Event-Driven Harness

Once installed, your active LLM (via the **21-tool local stdio MCP server** `python -B -m prose_humanizer mcp-serve` or the **`prose-humanize harness`** CLI) never blindly overwrites your manuscript. Every single sentence, paragraph, Turnitin-flagged section, or full paper executes through a **deterministic, fail-closed 9-event loop**:

```mermaid
flowchart LR
    A["1. harness_start_session<br>(on_intake + on_lock_and_freeze)"] --> B["2. harness_next_span<br>(on_before_rewrite)"]
    B --> C["Active LLM Rewrites<br>Frozen ⟦...⟧ Packet<br>(4-Axis Presets + OP-1..OP-8)"]
    C --> D["3. harness_submit_candidate<br>(on_candidate_generated)"]
    D -- "D1-D10 / Spin / Band Fail" --> E["on_retry_requested<br>(Surgical Repair Directive)"]
    E --> C
    D -- "PASS (Zero Defects)" --> F["on_candidate_verified<br>(Ranked Drafts + Blue Diff)"]
    F --> G["4. harness_record_audit<br>(on_semantic_audit_recorded;<br>zero_self_approval = true)"]
    G --> H["5. harness_apply_and_certify<br>(on_pre_write_lock_guard +<br>on_apply_and_certify)"]
```

Every Walter-style control axis is resolved deterministically from `contracts/presets.toml` before your LLM writes a word:

| Control Axis | Supported Values | Deterministic Contract Enforcement |
|---|---|---|
| **`readability`** | `high_school`, `university` *(default)*, `masters`, `phd`, `journalist`, `general` | Exact `mean_sl`, `max_sentence_words`, `func_share`, `MTLD`, `CV`, `IQR`, and `passive_pct` target bands |
| **`purpose`** | `academic` *(default)*, `journal_q1`, `thesis`, `technical_report`, `grant`, `general` | Contraction ban (`forbid_contractions`), register passive floor/ceiling, max sentence cap |
| **`strength`** | `light`, `balanced`, `enhanced` *(default)*, `maximum` | Allowed operators (`OP-1`–`OP-8`), `3g-Jaccard` overlap ceiling, word-delta cap, target Mode B risk (`<= 30–42`), retry budget |
| **`voice_policy`** | `third_person_strict` *(default)*, `first_person_allowed` | Enforced under `D8` (blocks 2nd-person `you/your` and unauthorized 1st-person `I/we/our`) |
| **Pinning & Locking** | `freeze_terms` (`--freeze-terms`), `locked_sentences`, `turnitin_path`, `single_sentence_mode` | Custom `⟦TERM_###⟧` sentinels + `100%` dual SHA-256 `LOCKED_WHITE` lock parity (`0.0%` byte drift) |

**CLI equivalent (works in any shell or non-MCP environment):**

```bash
# Start a controlled PhD / Q1-journal session on a LaTeX manuscript with Mode A Turnitin locks
prose-humanize harness start examples/sample_paper.tex --is-file \
  --turnitin examples/sample_turnitin_map.json \
  --readability phd --purpose journal_q1 --strength enhanced \
  --voice-policy third_person_strict --freeze-terms "TRIPOD+AI,DICOM-SR"

# Pull next frozen span directive -> submit LLM candidate(s) -> independent audit -> certify & patch
prose-humanize harness next <session_id>
prose-humanize harness submit <session_id> --span-id SPAN_001 --candidate-file cand.txt
prose-humanize harness audit <session_id> --role semantic-critic --verdict PASS --notes "Verified D1-D10 & polarity"
prose-humanize harness apply <session_id> --out-file sample_humanized.tex --receipt sample_receipt.json
```

### 3. Supported Agent Runtimes & Native Entrypoints

| Runtime | 1-Command Flag | What Gets Installed (Non-Destructively) | Native Entrypoints |
|---|---|---|---|
| **Antigravity** | `--target antigravity` | Standalone plugin bundle (`plugin.json`, `mcp_config.json`, `hooks.json`, `rules/`, `4` skills, `5` `.md`+`.toml` agents, `5` contracts, `3` hooks) | `21` MCP tools, `PreInvocation`/`PreToolUse`/`PostToolUse` hooks, `/academic-prose-humanizer` |
| **Claude Code** | `--target claude` | `.claude-plugin/`, `.mcp.json` / `mcp_servers.json`, `hooks/hooks.json`, `4` skills, `4` slash commands, `5` subagents, delimited `CLAUDE.md` | `/humanize`, `/detect-ai`, `/turnitin-fix`, `/humanize-swarm`, `21` MCP tools |
| **OpenAI Codex** | `--target codex` | `[mcp_servers.academic_prose_humanizer]` in `config.toml`, `4` skills, `5` `.md`+`.toml` agents, `contracts/`, `rules/`, delimited `AGENTS.md` | `21` MCP tools, AgentSkills auto-discovery, TOML subagents |
| **Cursor** | `--target cursor` | Scoped `.cursor/rules/academic-prose-humanizer.mdc` (`.tex/.md/.txt/.docx`) + merged `.cursor/mcp.json` | Contextual editorial rules + `21` MCP tools |
| **GitHub Copilot** | `--target copilot` | Delimited `.github/copilot-instructions.md` block + `5` Editorial Team profiles in `.github/agents/` | Repo-wide Copilot guardrails + 5 role agents + CLI harness |

Step-by-step setup, hook wiring, and worked single-sentence / Mode A Turnitin / full-paper swarm transcripts: **[docs/MCP_AND_SKILLS.md](docs/MCP_AND_SKILLS.md)**.

---

## Repository Architecture Map

```text
academic-prose-humanizer/
├── contracts/                       # 5 authoritative declarative TOML contracts (mirrored in src/.../data/contracts/)
│   ├── harness.toml                 # 8-state machine (INIT..APPLIED), 9 ordered lifecycle events, retry & fail-closed policies
│   ├── presets.toml                 # 4-axis Walter + Q1-academic matrix (6x6x4x2 = 288 target-band contracts)
│   ├── invariants.toml              # D1-D10 defect gates, SHA-256 LOCKED_WHITE <0.15 locks, FLU-1..5, BB-1..4
│   ├── routing.toml                 # 7 cross-platform auto-routes + 5 fail-safe exclusions
│   └── team.toml                    # 5-role disjoint-scope Editorial Team & zero_self_approval topology
├── skills/                          # 4 portable, public-safe AgentSkills-spec packages
│   ├── academic-prose-humanizer/    # Core controlled humanizer skill (+ references/ & evals/)
│   ├── turnitin-report-remediator/  # Mode A Cyan/Purple & Similarity PDF remediation skill
│   ├── ai-prose-auditor/            # Mode B offline risk, Purple-Spin, grammar & similarity auditor skill
│   └── editorial-humanizer-swarm/   # Full-manuscript parallel multi-section swarm orchestrator skill
├── agents/                          # 5 dual-format (.md + .toml) AI Editorial Team role contracts
│   ├── diagnostician.{md,toml}      # Stage 1: Intake, Mode A/B triage, SHA-256 locking & span planning
│   ├── structural-rewriter.{md,toml}# Stage 2: OP-1..OP-8 structural rewriting outside sentinels (no self-approval)
│   ├── semantic-critic.{md,toml}    # Stage 3: Independent factual, numeric, polarity & D1-D10 auditor
│   ├── voice-editor.{md,toml}       # Stage 4: Scholarly register, BB-1..BB-4 seam flow & FLU-1..5 fluency auditor
│   └── blind-auditor.{md,toml}      # Stage 5: Final Mode B delta, zero-spin & 100% SHA-256 lock receipt auditor
├── hooks/                           # Executable cross-platform lifecycle hooks + manifest
│   ├── hooks.json                   # Portable UserPromptSubmit / PreToolUse / PostToolUse hook manifest
│   ├── pre_invocation_route.py      # Routes prompts via contracts/routing.toml (silent on 5 exclusions)
│   ├── post_rewrite_gate.py         # Fail-closed D1-D10 + preset gate (exit 0 PASS / exit 2 REJECT + repair JSON)
│   └── pre_write_lock_guard.py      # Fail-closed SHA-256 LOCKED_WHITE & zero-sentinel guard (exit 0 SAFE / exit 2 BLOCKED)
├── plugins/                         # Ready-to-install drop-in packs for all 5 agent runtimes
│   ├── antigravity/                 # plugin.json, mcp_config.json, hooks.json, README.md
│   ├── claude-code/                 # .claude-plugin/, .mcp.json, hooks/, 4 slash commands/, CLAUDE.md
│   ├── codex/                       # config.toml, AGENTS.md, README.md
│   ├── cursor/                      # .cursor/rules/academic-prose-humanizer.mdc, .cursor/mcp.json
│   └── copilot/                     # copilot-instructions.md, README.md
├── rules/
│   └── HUMANIZER_GUARDRAILS.md      # Portable single-file guardrail summary for any LLM workspace
├── scripts/
│   └── install_addon.py             # Pure-stdlib 1-command installer (--target, --scope, --dry-run, --verify, --uninstall)
├── src/prose_humanizer/             # Pure Python 3.10+ stdlib engine (zero mandatory dependencies)
│   ├── contracts_loader.py          # TOML contract loader, 288-combo preset resolver & bundled wheel parity validator
│   ├── harness.py                   # EventBus + HumanizerHarness (atomic state.json + append-only events.jsonl)
│   ├── mcp_server.py                # 21-tool JSON-RPC 2.0 stdio MCP server (6 harness_* + 15 local_*)
│   ├── cli.py                       # 18-subcommand CLI (`prose-humanize` / `python -m prose_humanizer`)
│   ├── offline_decompressor.py      # 6-operator air-gapped structural decompressor (OP-1..OP-6, FLU-1..FLU-5)
│   ├── locks_and_freeze.py          # Dual SHA-256 clean locks & cross-domain `⟦...⟧` sentinel freezer/restorer
│   ├── invariants.py                # 10-layer D1-D10 cross-domain anti-corruption shield + ranker
│   ├── turnitin_ingest.py           # Mode A: 4-format Turnitin PDF/JSON/MD parser & monotonic alignment
│   ├── detector.py / features.py    # Mode B: LOMO-calibrated 13f Zero-ML + Purple-Spin + optional <=25% Hybrid
│   ├── rewriter.py / providers.py   # Closed-loop eradication, 6 backends, single-sentence & Zero-API Handoff
│   ├── planner_and_patcher.py       # 1-span-per-packet planner (BB-1..BB-4) & atomic multi-format patcher
│   ├── docx_io.py / grammar_and_similarity.py / batch.py / history.py
│   ├── web_server.py + web/*        # Optional 1280×720 100vh Local Web Studio (22 HTTP routes, 0 .innerHTML, 0 CDNs)
│   └── data/{calibrated_weights.json,contracts/*.toml}  # Wheel-bundled weights & TOML contracts
├── docs/                            # Architecture, MCP & Skills, API Reference, Benchmarks, Providers, Turnitin, Integrity
├── examples/                        # Zero-API-key runnable LaTeX, Markdown, Turnitin JSON, Batch & SDK examples
└── tests/                           # 115 stdlib unittest tests (106 portable passing, 9 optional-env skipped)
```

Deep architectural breakdown: **[docs/ARCHITECTURE.md](docs/ARCHITECTURE.md)**.

---

## Companion Runtime: CLI, Offline Decompressor, Docker & Optional Local Web Studio

Even without an external coding agent, the same verified deterministic engine runs completely standalone on your machine:

### 1. Standalone 18-Command CLI & 6-Operator Air-Gapped Decompressor

```bash
# Mode B: Report-free offline risk, Purple-Spin & Most-AI/Human sentence rankings (<10 ms)
prose-humanize detect examples/sample_paper.tex --mode zero_ml

# 6-operator air-gapped humanization (12/12 Clean Eradication, zero API keys) with Mode A Turnitin locks
prose-humanize humanize examples/sample_paper.tex \
  --turnitin examples/sample_turnitin_map.json \
  --provider deterministic_offline \
  --freeze-terms "TRIPOD+AI,DICOM-SR" \
  --out sample_paper_humanized.tex \
  --receipt sample_paper_receipt.json

# Targeted single-sentence rewrite (1-3 verified alternatives) & sentinel-safe grammar auto-fix
prose-humanize rewrite-sentence examples/sample_manuscript.md --sentence-index 0 --n-alternatives 3
prose-humanize grammar examples/sample_manuscript.md --fix --out sample_manuscript_fixed.md

# Full clause-level restructuring via FREE local Ollama (private on your machine)
ollama pull llama3.1:8b
prose-humanize humanize examples/sample_paper.tex \
  --provider ollama --model llama3.1:8b \
  --readability phd --purpose journal_q1 --strength enhanced \
  --out sample_paper_ollama.tex --receipt sample_paper_ollama_receipt.json
```

### 2. Optional `1280×720` Local Web Studio (`22` HTTP Routes, Zero CDNs, Zero `.innerHTML`)

```bash
prose-humanize serve --open-browser
# Opens http://127.0.0.1:8765/ (strictly localhost-only, 200 OK /favicon.ico, zero telemetry)
```

The optional local browser GUI backs all 7 scholarly workspaces on pure Python stdlib `ThreadingHTTPServer` + vanilla JS (`0` `.innerHTML` calls, `0` inline event handlers, `0` external CDNs):

1. **Humanizer Studio** — Above-the-fold `100vh` dual-pane scroll-synced editor with draggable split (`25%–75%`), **Multi-Draft Switcher (`Draft 1 / 2 / 3`)**, interactive **`+ Pin Term`** cobalt freeze chips, per-sentence **Click-to-Rewrite popover** (`1–3` verified alternatives, `Lock SHA-256`, `Restore Orig`), 3-axis controls, **Cobalt-Blue Inline Diff vs. Clean View**, **Zero-API Chat LLM Handoff drawer**, and native **`.docx` Upload & Export**.
2. **AI Detector** — Hero **`% Human-Like`** ring, Mode B score & `confidence_summary`, **Your Most AI / Most Human Sentences** ranked jump cards (`Show in Text`), live Neural Oracle status pill (`/api/neural/status`), and 1-click *Humanize Flagged Spans*.
3. **Turnitin Report Studio** — Drag-and-drop Turnitin AI (`AI_V2_DUAL` / `AI_V3_UNIFIED`), Similarity (`SIM_MODERN`), or JSON map with Cyan / Purple / Similarity / `LOCKED_WHITE` counts.
4. **Grammar & Style Checker** — Offline scholarly linter with 1-click **`Apply Fix`**, **`Apply All Safe Fixes`**, and **`Undo`** stack (sentinel-safe).
5. **Originality / Similarity Guard** — Offline word `k`-shingle Jaccard containment & contiguous overlap highlighter.
6. **Batch Queue** — Parallel multi-item `humanize` / `detect` / `grammar` / `similarity` runner with JSON export.
7. **History & Provider Settings** — Local SQLite history (`~/.prose_humanizer/history.db`) + in-memory-only provider configuration (API keys never persisted).

### 3. Docker (1 Command with Host Ollama Networking)

```bash
docker compose up --build
# Builds academic-prose-humanizer:3.0.0 on http://127.0.0.1:8765 (pre-wired to host.docker.internal:11434 Ollama)
```

### 4. Python SDK (Event-Driven Harness & Direct Engine)

```python
from prose_humanizer import HumanizerHarness, resolve_preset, validate_contracts

assert validate_contracts()["ok"] is True
preset = resolve_preset(readability="phd", purpose="journal_q1", strength="enhanced")

harness = HumanizerHarness(session_dir=".prose_harness")
result = harness.run_controlled_loop(
    "Furthermore, it is worth noting that this study delves into clinical triage using TRIPOD+AI (AUROC = 0.89, p < 0.01).",
    provider="deterministic_offline",
    readability="phd",
    purpose="journal_q1",
    strength="enhanced",
    protected_terms=["TRIPOD+AI"],
)
print(result["before_detect"]["score_0_100"], "->", result["after_detect"]["score_0_100"], "| events:", result["events_log_path"])
```

Run the standalone offline SDK demo anytime: `python examples/sdk_quickstart.py`.

---

## Before & After Academic Showcase

Real three-way comparison from our certified evaluation suite (`case_01` clinical triage governance span):

<table>
<thead>
<tr>
<th>Variant</th>
<th>Rendered Prose Excerpt &amp; Audit Outcome</th>
<th>Mode B Risk<br>(0–100)</th>
<th><code>D1</code>–<code>D10</code><br>Defects</th>
</tr>
</thead>
<tbody>
<tr>
<td><strong>Original Flagged Span</strong><br><em>(Telegraphic AI-like compression)</em></td>
<td>Dense noun stacks, active-only cadence, analytic function-word share <code>18.4%</code>; embeds 8 clinical standards (<code>TRIPOD+AI</code>, <code>CLAIM 2024</code>, <code>MINIMAR</code>, <code>DECIDE-AI</code>, <code>DICOM-SR</code>, <code>HL7 FHIR</code>, <code>CONSORT-AI</code>, <code>zero-PHI</code>) and label set <code>{0, 1}</code>.</td>
<td><strong><code>57.22</code></strong><br><em>(likely_ai)</em></td>
<td>Baseline</td>
</tr>
<tr>
<td><strong>Commercial Black-Box Humanizer</strong><br><em>(Raw Walter Writes Pro control)</em></td>
<td>❌ Mangled <strong>8/8</strong> clinical standards (<code>TriPod + AI</code>, <code>Claim 2024</code>, <code>Dicom-Sr</code>, <code>Hl7-Fhir</code>, <code>Consort-Ai</code>), erupted into <strong>88 spurious Title-Case words</strong>, inverted the clinical safety stance (<em>"For The Roll-Out of Autonomous Clinical Care Rather Than Premature Autonomous Clinical Care"</em>), dropped the hardware parity gate, and leaked unescaped <code>&amp;</code>.</td>
<td><code>53.12</code><br><em>(still likely_ai;<br><code>-4.10</code>)</em></td>
<td><strong>❌ HARD FAIL</strong><br>(<code>4</code> critical +<br><code>2</code> high)</td>
</tr>
<tr>
<td><strong>Unassisted LLM Baseline</strong><br><em>(<code>without_skill</code> control)</em></td>
<td>⚠️ Preserved clinical standards, but retained telegraphic active-only syntax (<code>func_word 20.1%</code>) and <strong>backfired</strong> by making the paragraph statistically <em>more</em> AI-flagged.</td>
<td><code>68.33</code><br><em>(backfire;<br><code>+11.11</code>)</em></td>
<td><code>0</code> critical<br><em>(failed band)</em></td>
</tr>
<tr>
<td><strong>Academic Prose Humanizer</strong><br><em>(Controlled LLM + Harness output)</em></td>
<td>✅ Unpacked dense modifiers into analytic scholarly syntax (<code>func_word 18.4% → 24.8%</code>), preserved <strong>8/8</strong> standards, <code>{0, 1}</code>, and non-autonomous clinical polarity verbatim, stayed at <code>+12.0%</code> word delta (<code>max 34w</code>), and won blind A/B review.</td>
<td><strong><code>28.96</code></strong><br><em>(likely_human;<br><strong><code>-28.26</code></strong>)</em></td>
<td><strong>✅ <code>0 / 10</code></strong><br><em>(100% PASS)</em></td>
</tr>
</tbody>
</table>

> Across all 6 blinded randomized A/B evaluation cases (`4` core + `2` held-out), our methodology won **`6 / 6` (`100%`)** blind comparisons, cut mean Mode B AI risk from **`31.62 → 10.47` (`-21.16` pts; Purple spin `99.7 → 0.0`)** with **`0 / 6` invariant defects**, while the unassisted baseline backfired **`31.62 → 39.64` (`+8.02` pts)**.

---

## Multi-Oracle Progression (Iter 0 to Iter 2b/3)

Head-to-head anonymized progression (`Iter 0 → Iter 1 → Iter 2b/3`) across all **10 real commercial-paired multi-domain passages** (`4` cross-domain manuscripts + `6` biomedical/quantum spans) on a frozen 6-oracle offline evaluator (`Mode B 13f`, independent `fakespot-roberta`, `gpt2`/`distilgpt2` `Hybrid-18`, `LOCKED_WHITE` stylometry, `D1`–`D10` + SHA-256 locks, and academic Grammar):

| Track | Mode B ↓ | RoBERTa AI% ↓ | Hybrid-18 ↓ | `D1`–`D10` Pass | Grammar ↑ | Clean Erad. | Dual Erad. | Composite ↑ | Δ vs Commercial |
|---|---:|---:|---:|---:|---:|---:|---:|---:|---:|
| **Source (`v2.1+` shield)** | 50.73 | 11.65% | 49.34 | 10/10 | 94.7 | 2/10 | 2/10 | 82.58 | +38.13 |
| **Commercial Humanizer Pro** *(Walter Writes Pro)* | 47.17 | 27.03% | 44.20 | **0/10 (`63c`)** | 83.2 | **0/10** | **0/10** | **44.45** | `0.00` |
| **Ours Iter 0 Offline** | 55.67 | 12.11% | 49.09 | 9/10 | 95.7 | 1/10 | 0/10 | 79.61 | +35.16 |
| **Ours Iter 1 Offline** *(6-Op Decompressor)* | 23.99 | 11.27% | 24.04 | 10/10 | 96.4 | 9/10 | 8/10 | 90.43 | +45.98 |
| **Ours Iter 2b Offline** *(Final Air-Gapped)* | **22.31** | 14.07% | **22.23** | **10/10** | **96.2** | **10/10** | **8/10** | **90.67** | **+46.22** |
| **Ours Iter 0 AI-Team** | 28.44 | 11.44% | 21.87 | 10/10 | 99.7 | 8/10 | 6/10 | 93.27 | +48.82 |
| **Ours Iter 1 AI-Team** | 18.59 | 12.95% | 19.16 | 10/10 | 99.3 | 10/10 | 8/10 | 94.94 | +50.49 |
| **Ours Iter 3 AI-Team** *(Controlled LLM + Guarded Hybrid)* | **20.44** | **8.27%** | **20.91** | **10/10** | **99.0** | **10/10** | **9/10** | **95.40** | **+50.95** |

> On the full 12-passage suite (adding SHA-256 lock and Turnitin-Purple spin torture tests), our **Air-Gapped Offline Decompressor** achieves **`12/12` (`100%`) Clean Eradication** (`Mode B 21.91`, `12/12` `D1`–`D10` + SHA-256 locks, `0` fluency regressions across `FLU-1`–`FLU-5`), and the **Controlled AI Editorial Team** reaches **`12/12` Clean Eradication**, **`10/12` Dual Clean Eradication** (`RoBERTa 12.83%`), and **`94.15` Composite**. Complete per-passage and domain-split tables in [docs/BENCHMARKS.md](docs/BENCHMARKS.md#3-multi-oracle-autoresearch-progression-iter-0-to-iter-2b3).

---

## Competitive Matrix (Verified 2026-12-05)

> Verified directly against live GitHub API metadata, licenses, and source trees on **2026-12-05**. Full 15-repository forensic tables (Tables A & B) are published in [docs/BENCHMARKS.md](docs/BENCHMARKS.md#4-competitive-feature-matrices-verified-2026-12-05).  
> Legend: ✅ Native | 🟡 Partial / manual / prompt-only | ❌ Not supported

| Capability | **academic-prose-humanizer v3.0** | **Walter Writes Pro** *(Commercial)* | **blader/humanizer** *(77.2k★)* | **Turnitout-Humanizer** *(12.9k★)*\* | **AIScientists/academic-humanizer** *(7.2k★)* | **sgaofen/humanizer-local-model** *(1.3k★)* | **Moonlit/AIGC-Detector-Rewriter** *(508★)* | **rudra496/StealthHumanizer** *(250★)* |
|---|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|
| **Cross-Platform LLM Add-On Harness (5 Runtimes + Contracts + Hooks)** | ✅ `5` TOML + `9` events + `4` skills + `5` agents + `install_addon.py` | ❌ Closed SaaS | 🟡 Single prompt skill | ❌ None | 🟡 Single prompt skill | 🟡 `AGENTS.md` only | 🟡 Prompt skill | ❌ CLI only |
| **True Open-Source License** | ✅ MIT | ❌ Closed SaaS | ✅ MIT | ❌ **Proprietary**\* | ✅ MIT | ✅ Apache-2.0 | ✅ Apache-2.0 | ✅ MIT |
| **Zero-API Local / Offline Run** | ✅ 6-Op Stdlib (`12/12` ClnEr) + Local LLM | ❌ Cloud only | 🟡 Host LLM | ❌ Hosted mirrors | 🟡 Host LLM | ✅ 12B GGUF (6–14 GB) | 🟡 Host LLM | 🟡 Ollama / VPS |
| **Bring-Your-Own-LLM + Controlled MCP / Handoff** | ✅ `21`-tool MCP + 6 backends + Handoff | 🟡 Paid remote MCP | 🟡 Agent LLM | ❌ None | 🟡 Agent LLM | 🟡 External compat | 🟡 Agent LLM | ✅ 35 providers |
| **Turnitin PDF Cyan/Purple Ingest** | ✅ PyMuPDF (`V2`/`V3`/`SIM`) | ❌ None | ❌ None | ❌ None | ❌ None | ❌ Text import only | 🟡 Manual paste | ❌ Text import only |
| **SHA-256 Clean-Sentence Locks + Pre-Write Hook** | ✅ Automatic + Verified + Hook | ❌ None | ❌ None | ❌ None | ❌ None | 🟡 Manual "Create fact" | ❌ Prompt-only | ❌ None |
| **LaTeX / Bio / Math / Citation Shield** | ✅ `⟦...⟧` + `D1`–`D10` + `+ Pin Term` | ❌ `61.1%` crit. fail† | ❌ Prompt-only | 🟡 Unaudited closed | ❌ Prompt-only | 🟡 Digits stderr (`10.5%` err) | ❌ Prompt-only (245 KB) | ❌ None |
| **Anti-Word-Spin / Purple Guard** | ✅ Calibrated `spin_alert` | ❌ None | ❌ None | ❌ 1:1 synonym swap | ❌ None | ✅ Human-trained | 🟡 Prompt rules | ❌ 500+ synonym swaps |
| **Closed-Loop Event Retry + Independent Audit** | ✅ `D1`–`D10` + Mode B + `zero_self_approval` | 🟡 Manual "Rewrite" | 🟡 Prompt self-check | ❌ None | 🟡 Prompt self-check | ❌ Single-shot | 🟡 External manual | 🟡 Static RoBERTa Bo8 |
| **Atomic `.tex`/`.docx`/`.md` Patch** | ✅ Round-trip + Browser `.docx` | 🟡 Upload/paste | 🟡 Agent file edit | 🟡 Remote upload | 🟡 Agent file edit | 🟡 `.docx` loses runs | 🟡 Manual | 🟡 `.pdf`/`.docx` |
| **Optional Companion Local Web Studio** | ✅ `100vh` Studio (`0` `.innerHTML`, `22` routes) | ✅ SaaS Web UI | ❌ None | 🟡 Remote Streamlit | ❌ None | ✅ Desktop Webview | ❌ None | ✅ Next.js Studio |

*\*`AhmadHassan-BTed/Turnitout-Humanizer` contains zero engine source code in the repository and ships a Proprietary "All Rights Reserved" `LICENSE`.*  
*†Measured across 90 real Turnitin-flagged academic spans in our empirical forensic audit (`55 / 90` critical defects; `0 / 90` usable verbatim) and replicated in our 10-passage cross-domain showdown (`0 / 10` passing `D1`–`D10`, `63` critical defects).*

---

## Reproducible "Proof" Table

Every headline engineering claim in this repository maps to an executable offline command or published audit table:

| Claim | Verification Command / Artifact |
|---|---|
| **All 5 declarative TOML contracts & bundled wheel copies validate (`288` preset bands)** | `prose-humanize harness validate-contracts` |
| **Cross-platform 5-runtime installer plans cleanly (`antigravity`, `claude`, `codex`, `cursor`, `copilot`)** | `python -B scripts/install_addon.py --target all --dry-run` |
| **Zero-dep portable test suite passes offline (`106` portable / `115` total, `0` failures)** | `PROSE_HUMANIZER_PORTABLE_TESTS=1 python -B -m unittest discover -s tests -v` |
| **Fail-closed executable hooks route prompts & block corrupt rewrites / lock drift** | `python -B hooks/pre_invocation_route.py --prompt "Remediate Turnitin Cyan+Purple"` & `hooks/post_rewrite_gate.py` & `hooks/pre_write_lock_guard.py` |
| **Mode A Turnitin locks keep `WHITE` sentences `0.0%` drift** | `prose-humanize humanize examples/sample_paper.tex --turnitin examples/sample_turnitin_map.json --out out.tex --receipt out.receipt.json` |
| **Mode B offline risk, Purple-Spin & sentence rankings (`<10 ms`)** | `prose-humanize detect examples/sample_manuscript.md --mode zero_ml` |
| **Offline grammar linter + sentinel-safe `--fix` auto-repair** | `prose-humanize grammar examples/sample_manuscript.md --fix` |
| **End-to-end Python SDK + SQLite history (zero keys)** | `python examples/sdk_quickstart.py` |
| **6-oracle `Iter 0 → Iter 3` progression & blind A/B (`6/6` wins)** | Full empirical metrics & methodology in [docs/BENCHMARKS.md](docs/BENCHMARKS.md) |

---

## Documentation & Examples

### Technical Guides (`docs/`)
- **[docs/MCP_AND_SKILLS.md](docs/MCP_AND_SKILLS.md)** — **Start here for Agent Runtimes:** 1-command installation, slash commands, hook wiring, 21-tool MCP setup, and sample transcripts for **Antigravity, Claude Code, OpenAI Codex, Cursor, and GitHub Copilot**
- **[docs/ARCHITECTURE.md](docs/ARCHITECTURE.md)** — Event-Driven Controlled LLM Harness (`9` lifecycle events, `8` states), 5 declarative TOML contracts, Mode A + Mode B pipeline, 6-operator `offline_decompressor.py`, cross-domain `⟦...⟧` sentinel freezing, `D1`–`D10` shield, companion Web Studio, and full module map
- **[docs/API_REFERENCE.md](docs/API_REFERENCE.md)** — Complete reference for all **18 CLI commands** (including `harness start|next|submit|audit|status|apply|validate-contracts`), **21 stdio MCP tools** (`6` `harness_*` + `15` `local_*`), `HumanizerHarness` & `contracts_loader` Python SDK, all **3 executable `hooks/*.py` CLIs**, and **22 companion Web Studio HTTP routes**
- **[docs/BENCHMARKS.md](docs/BENCHMARKS.md)** — Empirical 90-span commercial forensics, 6-report validation corpus (`2,840` sentences), blind randomized A/B proof, 12-passage 6-oracle `Iter 0 → Iter 2b/3` progression, and Competitive Matrices A & B
- **[docs/PROVIDERS.md](docs/PROVIDERS.md)** — 60-second setup for Air-Gapped Offline, Ollama, LM Studio / vLLM, Gemini, OpenAI, Anthropic, and Coding-Agent workflows
- **[docs/TURNITIN_MODES.md](docs/TURNITIN_MODES.md)** — Mode A 4-format Turnitin PDF ingestion + SHA-256 locks + `BB-1`–`BB-4` Boundary Bridges vs. Mode B 13-feature / optional Hybrid proxy + Purple-Spin science
- **[docs/ACADEMIC_INTEGRITY.md](docs/ACADEMIC_INTEGRITY.md)** — Responsible research use, authorship transparency, non-guarantee proxy disclaimer, and anti-plagiarism stance

### Runnable Public-Safe Examples (`examples/` — Zero API Keys Required)
- [examples/sample_paper.tex](examples/sample_paper.tex) — Synthetic LaTeX paper with `\cite{}`, `\eqref{}`, inline math (`$<0.98$`, `$\le 10^{-10}$`), acronyms, and clean vs. flagged paragraphs
- [examples/sample_manuscript.md](examples/sample_manuscript.md) — Synthetic Markdown excerpt contrasting a Turnitin-Purple spun paragraph against a clean scholarly paragraph
- [examples/sample_turnitin_map.json](examples/sample_turnitin_map.json) — Mode A Turnitin flag map (`LOCKED_WHITE`, `CYAN`, `PURPLE`) aligned with `sample_paper.tex`
- [examples/sample_batch.json](examples/sample_batch.json) — 3-item batch input for `prose-humanize batch`
- [examples/sdk_quickstart.py](examples/sdk_quickstart.py) — Standalone Python script exercising `detect_document`, `humanize_text`, `check_grammar_and_style`, `check_similarity`, and `HistoryStore` offline

---

## Academic Integrity & Offline-Proxy Notice

> [!IMPORTANT]
> **Editing Aid, Not Ghostwriting:** `academic-prose-humanizer` is designed to remove formulaic, repetitive, or machine-spun phrasing from **author-written scholarly drafts** while strictly preserving citations, equations, empirical numbers, and scientific claims. Always follow your university, publisher (IEEE, Nature, Springer, Elsevier, Frontiers, ACM), and funding-agency AI-editing disclosure policies.
>
> **No Official Turnitin Guarantee:** Local Mode B scores (`Tier1_ZeroML_AntiGoodhart_13f` and optional `Tier3_Hybrid_AntiGoodhart_18f`) are empirically calibrated offline risk estimates — **never official Turnitin clearance**. Submitting your compiled manuscript through your institutional Turnitin workflow remains the sole definitive check.
>
> **Zero Deceptive Tricks:** This software never injects hidden Unicode characters, homoglyphs, intentional typos, or fabricated citations. See [docs/ACADEMIC_INTEGRITY.md](docs/ACADEMIC_INTEGRITY.md) for our complete ethics policy.

---

## Contributing, Security & License

- **Agent & Contributor Onboarding:** Read [AGENTS.md](AGENTS.md) and [CONTRIBUTING.md](CONTRIBUTING.md).
- **Security & Privacy:** See [SECURITY.md](SECURITY.md) (strict `127.0.0.1` localhost binding, zero `.innerHTML`, never-persisted API keys, zero outbound telemetry).
- **License:** Released under the [MIT License](LICENSE).