Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Writeprint CI: unit tests + end-to-end CLI smoke test on every push/PR.
# HonorCode CI: unit tests + end-to-end CLI smoke test on every push/PR.
name: ci

on:
Expand Down Expand Up @@ -31,30 +31,30 @@ jobs:
- name: CLI smoke test (build, check, calibrate, batch, serve)
run: |
set -euo pipefail
python -m writeprint.cli build \
python -m honorcode.cli build \
samples/student_a_baseline1.txt \
samples/student_a_baseline2.txt \
samples/student_a_baseline3.txt \
-o /tmp/base.json --student student_a
python -m writeprint.cli check /tmp/base.json \
python -m honorcode.cli check /tmp/base.json \
samples/student_a_homework_genuine.txt | grep -q CONSISTENT
python -m writeprint.cli check /tmp/base.json \
python -m honorcode.cli check /tmp/base.json \
samples/student_a_homework_suspect.txt | grep -q CONVERSATION
python -m writeprint.cli calibrate \
python -m honorcode.cli calibrate \
--samples samples/student_a_baseline1.txt \
samples/student_a_baseline2.txt \
samples/student_a_baseline3.txt \
--suspect samples/student_a_homework_suspect.txt \
--student student_a -o /tmp/thresholds.json
python -m writeprint.cli batch /tmp/base.json \
python -m honorcode.cli batch /tmp/base.json \
samples/student_a_homework_genuine.txt \
samples/student_a_homework_suspect.txt \
-o /tmp/results.csv --thresholds /tmp/thresholds.json
test "$(wc -l < /tmp/results.csv)" = "3"
(python -m writeprint.cli serve --port 8765 &>/tmp/serve.log & echo $! > /tmp/serve.pid)
(python -m honorcode.cli serve --port 8765 &>/tmp/serve.log & echo $! > /tmp/serve.pid)
for i in $(seq 1 20); do
curl -sf http://127.0.0.1:8765/ -o /dev/null && break
sleep 1
done
curl -sf http://127.0.0.1:8765/ | grep -q Writeprint
curl -sf http://127.0.0.1:8765/ | grep -q HonorCode
kill "$(cat /tmp/serve.pid)"
40 changes: 20 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Writeprint
# HonorCode

**Authorship verification for the classroom — not an AI detector.**

Writeprint compares a student's submission against that student's *own*
HonorCode compares a student's submission against that student's *own*
known-genuine writing and reports how far their writing habits diverge.
The output is a reading — *consistent*, *mild divergence*, or
*worth a conversation* — never a verdict. A human teacher always decides
Expand All @@ -16,27 +16,27 @@ evasion via paraphrasing. Accusing a student on that basis is unjust.

Asking "was this written by *this student*?" is a far more tractable
question. Individual writing habits — sentence length, favorite transitions,
punctuation, contractions, function-word rates — form a *writeprint* that is
stable per author and hard to fake wholesale. Writeprint measures divergence
punctuation, contractions, function-word rates — form a writing
fingerprint that is stable per author and hard to fake wholesale. HonorCode measures divergence
from that baseline.

## Quickstart (no dependencies, Python 3.8+)

```bash
# 1. Build a baseline from 2+ samples of known-genuine writing
python -m writeprint.cli build samples/student_a_baseline1.txt \
python -m honorcode.cli build samples/student_a_baseline1.txt \
samples/student_a_baseline2.txt \
-o baselines/student_a.json --student student_a

# 2. Check a submission
python -m writeprint.cli check baselines/student_a.json \
python -m honorcode.cli check baselines/student_a.json \
samples/student_a_homework_genuine.txt
```

## Browser UI (no dependencies, runs offline)

```bash
python -m writeprint.cli serve
python -m honorcode.cli serve
# → open http://127.0.0.1:8765
```

Expand All @@ -49,7 +49,7 @@ calls: student text never leaves the machine.
## Batch scoring to CSV

```bash
python -m writeprint.cli batch baselines/student_a.json \
python -m honorcode.cli batch baselines/student_a.json \
homework1.txt homework2.txt homework3.txt \
-o results.csv [--thresholds baselines/student_a.thresholds.json]
```
Expand All @@ -64,10 +64,10 @@ weigh the habits in prose. Offline-first: it does nothing unless you
configure it.

```bash
export WRITEPRINT_JUDGE_URL=https://your-endpoint/v1/chat/completions
export WRITEPRINT_JUDGE_MODEL=your-model
export WRITEPRINT_JUDGE_KEY=... # omit for local servers like Ollama
python -m writeprint.cli judge baselines/student_a.json submission.txt
export HONORCODE_JUDGE_URL=https://your-endpoint/v1/chat/completions
export HONORCODE_JUDGE_MODEL=your-model
export HONORCODE_JUDGE_KEY=... # omit for local servers like Ollama
python -m honorcode.cli judge baselines/student_a.json submission.txt
```

Any OpenAI-compatible endpoint works, including a fully local Ollama
Expand Down Expand Up @@ -122,7 +122,7 @@ Two findings:
(Twain/Doyle quote heavily, Austen doesn't) proved scene-dependent
rather than author-stable, so it was left out.

Honest scope: Writeprint distinguishes voices with strong personal
Honest scope: HonorCode distinguishes voices with strong personal
habit markers. Telling apart polished authors in a shared register —
or a student paraphrasing *well* — is beyond v1's features. Corpus:
`samples/gutenberg_*` (Huck Finn, Pride & Prejudice, The Adventures
Expand Down Expand Up @@ -175,13 +175,13 @@ on your own labeled set — genuine pieces plus known-suspect ones:
# Leave-one-out scores each genuine sample against the others,
# sweeps candidate thresholds, and recommends one (max F1,
# ties break toward fewer false flags).
python -m writeprint.cli calibrate \
python -m honorcode.cli calibrate \
--samples genuine1.txt genuine2.txt genuine3.txt \
--suspect suspect1.txt \
--student student_a -o baselines/student_a.thresholds.json

# Use the calibrated threshold when checking
python -m writeprint.cli check baselines/student_a.json submission.txt \
python -m honorcode.cli check baselines/student_a.json submission.txt \
--thresholds baselines/student_a.thresholds.json
```

Expand All @@ -198,11 +198,11 @@ Two warnings, both serious:

## How it works

1. **Extract** (`writeprint/features.py`) — 33 stylometric features per text:
1. **Extract** (`honorcode/features.py`) — 33 stylometric features per text:
sentence/word length, type-token ratio, long-word ratio, first-person and
contraction rates, punctuation rates, and 20 function-word rates.
All rates are per-100-words so texts of different lengths compare fairly.
2. **Baseline** (`writeprint/compare.py`) — per-feature mean/std across the
2. **Baseline** (`honorcode/compare.py`) — per-feature mean/std across the
student's samples, with a variance floor so rare habits can't produce
explosive z-scores from sparse data.
3. **Compare** — mean absolute z-score across features, with per-feature
Expand All @@ -223,9 +223,9 @@ Two warnings, both serious:

## Roadmap

- [x] Per-classroom calibration helper (`writeprint calibrate`, v1.1)
- [x] Local browser UI + print-friendly report (`writeprint serve`, v1.2)
- [x] Two-student validation corpus + CSV batch export (`writeprint batch`, v1.3)
- [x] Per-classroom calibration helper (`honorcode calibrate`, v1.1)
- [x] Local browser UI + print-friendly report (`honorcode serve`, v1.2)
- [x] Two-student validation corpus + CSV batch export (`honorcode batch`, v1.3)
- [x] Real-prose validation: Gutenberg corpus, honest negative result (v1.4)
- [x] Real student writing: ASAP false-flag study, published rates (v1.5)
- [x] Opt-in LLM judge for nuanced cases, offline by default (v1.6)
Expand Down
1 change: 1 addition & 0 deletions honorcode/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""HonorCode: authorship verification for the classroom."""
File renamed without changes.
12 changes: 6 additions & 6 deletions writeprint/cli.py → honorcode/cli.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Writeprint command line: build baselines, check submissions."""
"""HonorCode command line: build baselines, check submissions."""

import argparse
import json
Expand Down Expand Up @@ -63,7 +63,7 @@ def cmd_judge(args):
baseline, text, baseline.get("student", "?"))
assessment = call_judge(system, user, endpoint, api_key, model)
except JudgeError as exc:
print("writeprint judge: %s" % exc)
print("honorcode judge: %s" % exc)
raise SystemExit(2)
print(render_assessment(baseline.get("student", "?"),
args.submission, assessment))
Expand Down Expand Up @@ -119,7 +119,7 @@ def read_many(paths):


def main(argv=None):
parser = argparse.ArgumentParser(prog="writeprint", description="Authorship verification for the classroom.")
parser = argparse.ArgumentParser(prog="honorcode", description="Authorship verification for the classroom.")
sub = parser.add_subparsers(dest="cmd", required=True)

p_build = sub.add_parser("build", help="Build a baseline from known-genuine samples.")
Expand Down Expand Up @@ -162,11 +162,11 @@ def main(argv=None):
p_judge.add_argument("baseline", help="Baseline JSON from 'build'.")
p_judge.add_argument("submission", help="Submission text file to assess.")
p_judge.add_argument("--endpoint", default=None,
help="Chat-completions URL (or WRITEPRINT_JUDGE_URL).")
help="Chat-completions URL (or HONORCODE_JUDGE_URL).")
p_judge.add_argument("--key", default=None,
help="Bearer token (or WRITEPRINT_JUDGE_KEY).")
help="Bearer token (or HONORCODE_JUDGE_KEY).")
p_judge.add_argument("--model", default=None,
help="Model name (or WRITEPRINT_JUDGE_MODEL).")
help="Model name (or HONORCODE_JUDGE_MODEL).")
p_judge.set_defaults(func=cmd_judge)

args = parser.parse_args(argv)
Expand Down
4 changes: 2 additions & 2 deletions writeprint/compare.py → honorcode/compare.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def compare(features, baseline, bands=None, eps=1e-9):
"""Compare a submission against a baseline profile.

bands overrides (BAND_CONSISTENT, BAND_REVIEW), e.g. with values
from `writeprint calibrate --out`. Returns {"score": mean |z| (full precision — round only for display),
from `honorcode calibrate --out`. Returns {"score": mean |z| (full precision — round only for display),
"band": ..., "flags": [...]} where flags are per-feature
divergences with |z| >= 2, sorted worst first.
"""
Expand Down Expand Up @@ -69,7 +69,7 @@ def compare(features, baseline, bands=None, eps=1e-9):
def render_report(student, filename, result):
"""Render a teacher-readable report (advisory, never a verdict)."""
lines = [
"Writeprint report",
"HonorCode report",
" Student: %s" % student,
" Submission: %s" % filename,
" Score: %.3f (mean |z| vs. baseline)" % result["score"],
Expand Down
File renamed without changes.
File renamed without changes.
18 changes: 9 additions & 9 deletions writeprint/judge.py → honorcode/judge.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
endpoint, and never use it as the sole basis for an accusation.

Config (flags override env):
WRITEPRINT_JUDGE_URL chat-completions endpoint URL
WRITEPRINT_JUDGE_KEY bearer token (may be empty for local servers)
WRITEPRINT_JUDGE_MODEL model name
HONORCODE_JUDGE_URL chat-completions endpoint URL
HONORCODE_JUDGE_KEY bearer token (may be empty for local servers)
HONORCODE_JUDGE_MODEL model name
"""

import json
Expand Down Expand Up @@ -100,14 +100,14 @@ def parse_response(text):

def judge_config(endpoint=None, api_key=None, model=None):
"""Resolve config from flags-or-env. Raises JudgeError if unusable."""
url = endpoint or os.environ.get("WRITEPRINT_JUDGE_URL", "")
key = api_key if api_key is not None else os.environ.get("WRITEPRINT_JUDGE_KEY", "")
name = model or os.environ.get("WRITEPRINT_JUDGE_MODEL", "")
url = endpoint or os.environ.get("HONORCODE_JUDGE_URL", "")
key = api_key if api_key is not None else os.environ.get("HONORCODE_JUDGE_KEY", "")
name = model or os.environ.get("HONORCODE_JUDGE_MODEL", "")
missing = [n for n, v in (("endpoint URL", url), ("model", name)) if not v]
if missing:
raise JudgeError(
"LLM judge not configured (missing %s). Set WRITEPRINT_JUDGE_URL "
"and WRITEPRINT_JUDGE_MODEL (plus WRITEPRINT_JUDGE_KEY unless "
"LLM judge not configured (missing %s). Set HONORCODE_JUDGE_URL "
"and HONORCODE_JUDGE_MODEL (plus HONORCODE_JUDGE_KEY unless "
"your endpoint needs none), or pass --endpoint/--model. "
"Any OpenAI-compatible /chat/completions endpoint works, "
"including a local Ollama server." % " and ".join(missing))
Expand Down Expand Up @@ -144,7 +144,7 @@ def call_judge(system, user, endpoint, api_key, model, timeout=60):
def render_assessment(student, filename, assessment):
"""Render the assessment for the terminal."""
lines = [
"Writeprint LLM assessment (second opinion — advisory only)",
"HonorCode LLM assessment (second opinion — advisory only)",
" Student: %s" % student,
" Submission: %s" % filename,
" Reading: %s (confidence %.2f)" % (
Expand Down
12 changes: 6 additions & 6 deletions writeprint/web.py → honorcode/web.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Local browser UI for Writeprint. Standard library only.
"""Local browser UI for HonorCode. Standard library only.

Serves a single page on 127.0.0.1: paste baseline samples and a
submission, get the report rendered with band coloring and a
Expand All @@ -20,7 +20,7 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Writeprint — authorship check</title>
<title>HonorCode — authorship check</title>
<style>
:root { --green: #1a7f37; --amber: #9a6700; --red: #b42318;
--ink: #1f2328; --muted: #59636e; --line: #d0d7de; --bg: #f6f8fa; }
Expand Down Expand Up @@ -73,7 +73,7 @@
</head>
<body>
<header>
<h1>✒️ Writeprint</h1>
<h1>✒️ HonorCode</h1>
<p>Authorship verification for the classroom — advisory only, never a verdict.</p>
</header>
<main>
Expand Down Expand Up @@ -128,7 +128,7 @@
if (!rows) rows = '<tr><td colspan="4">No strongly divergent habits.</td></tr>';
const today = new Date().toLocaleDateString();
rep.innerHTML =
"<div><strong>Writeprint report</strong> — " + escapeHtml(student) + " — " + today + "</div>" +
"<div><strong>HonorCode report</strong> — " + escapeHtml(student) + " — " + today + "</div>" +
'<div class="score">' + data.score.toFixed(3) + "</div>" +
'<span class="band ' + cls + '">' + data.band.toUpperCase() + "</span>" +
"<table><tr><th>Habit</th><th>Submission</th><th>Baseline avg</th><th>z</th></tr>" +
Expand Down Expand Up @@ -171,7 +171,7 @@ def check_payload(payload):


class Handler(BaseHTTPRequestHandler):
server_version = "Writeprint/1"
server_version = "HonorCode/1"

def log_message(self, *args): # keep the console to startup/errors only
pass
Expand Down Expand Up @@ -225,7 +225,7 @@ def do_POST(self):
def serve(port=DEFAULT_PORT):
"""Serve the UI on 127.0.0.1 only — student text never leaves the machine."""
server = ThreadingHTTPServer(("127.0.0.1", port), Handler)
print("Writeprint UI at http://127.0.0.1:%d (local only — Ctrl+C to stop)" % port)
print("HonorCode UI at http://127.0.0.1:%d (local only — Ctrl+C to stop)" % port)
try:
server.serve_forever()
except KeyboardInterrupt:
Expand Down
12 changes: 6 additions & 6 deletions tests/test_judge.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@

sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))

from writeprint.compare import build_baseline
from writeprint.features import extract
from writeprint.judge import (JudgeError, build_prompt, call_judge,
from honorcode.compare import build_baseline
from honorcode.features import extract
from honorcode.judge import (JudgeError, build_prompt, call_judge,
judge_config, parse_response)

SAMPLES = os.path.join(os.path.dirname(__file__), "..", "samples")
Expand Down Expand Up @@ -79,14 +79,14 @@ def test_confidence_clamped(self):

class TestConfig(unittest.TestCase):
def test_missing_config_raises_helpfully(self):
env = {"WRITEPRINT_JUDGE_URL": "", "WRITEPRINT_JUDGE_MODEL": ""}
env = {"HONORCODE_JUDGE_URL": "", "HONORCODE_JUDGE_MODEL": ""}
old = {k: os.environ.get(k) for k in env}
try:
os.environ.update(env)
os.environ.pop("WRITEPRINT_JUDGE_KEY", None)
os.environ.pop("HONORCODE_JUDGE_KEY", None)
with self.assertRaises(JudgeError) as ctx:
judge_config()
self.assertIn("WRITEPRINT_JUDGE_URL", str(ctx.exception))
self.assertIn("HONORCODE_JUDGE_URL", str(ctx.exception))
finally:
for k, v in old.items():
if v is None:
Expand Down
6 changes: 3 additions & 3 deletions tests/test_web.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Tests for the Writeprint browser UI (stdlib only)."""
"""Tests for the HonorCode browser UI (stdlib only)."""

import json
import os
Expand All @@ -10,7 +10,7 @@

sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))

from writeprint.web import Handler, check_payload
from honorcode.web import Handler, check_payload

SAMPLES = os.path.join(os.path.dirname(__file__), "..", "samples")

Expand Down Expand Up @@ -92,7 +92,7 @@ def test_root_serves_html(self):
status, ctype, raw = self.request("GET", "/")
self.assertEqual(status, 200)
self.assertIn("text/html", ctype)
self.assertIn(b"Writeprint", raw)
self.assertIn(b"HonorCode", raw)
self.assertIn(b"/api/check", raw)

def test_api_check_roundtrip(self):
Expand Down
10 changes: 5 additions & 5 deletions tests/test_writeprint.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Smoke tests for Writeprint v1 (stdlib unittest)."""
"""Smoke tests for HonorCode v1 (stdlib unittest)."""

import csv
import os
Expand All @@ -8,15 +8,15 @@

sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))

from writeprint.features import extract, feature_names
from writeprint.compare import build_baseline, compare
from writeprint.calibrate import (
from honorcode.features import extract, feature_names
from honorcode.compare import build_baseline, compare
from honorcode.calibrate import (
loo_genuine_scores,
suspect_scores,
sweep,
recommend,
)
from writeprint.export import COLUMNS, rows_for, write_csv
from honorcode.export import COLUMNS, rows_for, write_csv

SAMPLES = os.path.join(os.path.dirname(__file__), "..", "samples")

Expand Down
1 change: 0 additions & 1 deletion writeprint/__init__.py

This file was deleted.

Loading