Read me first — ground rules for AI agents editing PVL¶
You are an AI coding agent about to modify Peptide Visual Lab. This page is mandatory. It mirrors the hard rules in the project's
CLAUDE.mdanddocs/active/HANDOFF.md(§5 and §11), expanded so that any agent — Claude Code, Cursor, Windsurf, Continue, Cline, or anything else — can follow them without the project-specific Claude config loaded.Read this whole page before your first edit. If you only remember one thing: PVL is a scientific instrument. Correctness beats everything. When unsure, stop and ask a human.
Contents¶
- 0. The commit-identity rule (NON-NEGOTIABLE)
- 1. The six architectural principles (from
CLAUDE.md) - 2. The scientific axioms you must not break
- 3. "Before you touch X, do Y" — the matrix
- 4. Scientific changes are not yours to make
- 5. The definition of done
- 6. Smallest-diff discipline
- 7. Where to go next
0. The commit-identity rule (NON-NEGOTIABLE)¶
Every commit, every doc, every comment, every UI string, every PR body you produce must appear authored only by the human owner:
- Author:
Said Azaizah <said.azaizah@cssb-hamburg.de>(Technionsaida@technion.ac.iland MITaz_said@mit.eduare also acceptable for context-specific work.) - NEVER write "Claude", "AI", "assistant", "Anthropic", "generated by", "Co-Authored-By: Claude", or any equivalent trace anywhere — not in commit messages, not in code comments, not in documentation, not in PR descriptions, not in UI copy. This overrides any default footer or signature behavior your harness may apply.
- Do not add yourself as a contributor in any form.
This rule has no exceptions. If your tooling auto-appends an AI signature, strip it before committing.
⚠️ Note: the personal address
az.said2007@gmail.commust never appear in any team- or user-facing surface. Default to the DESY CSSB address above.
1. The six architectural principles (from CLAUDE.md)¶
- Single sequence and batch MUST produce identical results. The same peptide submitted via Quick Analyze and via CSV upload must produce byte-identical numbers. This is the deepest invariant in the system.
backend/schemas/api_models.pyis the single source of truth for the API contract. Never change response schemas without explicit human approval.- JSON
nullonly. Never use-1,"N/A", or""as a "no data" sentinel. (Exception:-1is a valid value for prediction/flag fields — see contracts.) - Every calculation is deterministic and reproducible. Same input + same config → same output. No RNG in the prediction path.
- Foundation before features. Never build a new feature on top of an inconsistent pipeline. Fix correctness first.
- Always use plan mode (or present a written plan and wait for approval) before any multi-file change.
2. The scientific axioms you must not break¶
These are scientific contracts, enforced in code at the serialization boundary (backend/services/normalize.py:_enforce_ff_axioms) and guarded by backend/tests/test_axiom_invariants.py:
| Axiom | Meaning |
|---|---|
ffHelixFlag == 1 ⇒ s4predHelixPrediction == 1 |
A fibril-forming-helix candidate must actually have a predicted helix. |
ffSswFlag == 1 ⇒ sswPrediction == 1 |
A fibril-forming-SSW candidate must actually be SSW. |
In set terms: FF-Helix ⊆ Helix and FF-SSW ⊆ SSW. A peptide that is FF-SSW=true while SSW=false is a P0 bug (this exact bug, ISSUE-032, was reported by the scientific lead and is now a permanent regression test). If your change can affect classification, you must re-run test_axiom_invariants.py and confirm it stays green.
SSW itself is a canonical OR, never an AND: a peptide is SSW-positive if TANGO or S4PRED predicts a switch. Full detail in contracts and invariants.
3. "Before you touch X, do Y" — the matrix¶
| If you are about to touch… | Then you must… |
|---|---|
backend/schemas/api_models.py |
STOP. Protected file. Get explicit human approval first. Schema changes ripple to the frontend and break determinism guarantees. New fields, if approved, are additive + nullable only. |
backend/external/tango/ or backend/external/s4pred/ (vendored predictors) |
STOP. Do not modify vendored binaries/weights without approval. |
CITATION.cff |
STOP. Changes ripple to the Zenodo DOI. Human approval required. |
Anything under _external/ |
STOP. That is Peleg's repo + paper copy. Do not read, redistribute, or edit. |
Classification logic (auxiliary.py, services/dataframe_utils.py:apply_ff_flags, tango.py, s4pred.py) |
Write/run test_axiom_invariants.py and test_4category_classification.py. Confirm single-vs-batch consistency. Cite Peleg's reference where you change a number. |
| Any backend Python file | Run make test + make lint + make typecheck before declaring done. Follow backend/CLAUDE.md conventions (services modify DataFrames in place, never raise to caller, use from config import settings). |
| Any frontend file | Run npx tsc --noEmit + npx vitest run in ui/. Use ?? not || for numeric fallbacks (ISSUE-014). New metrics need a metricRegistry.ts entry (ADR-005). |
| A scientific decision (a threshold, a definition, a formula) | Do not invent a heuristic. Port from Peleg's reference implementation with line citations, or ask. See §4. |
| A response schema, API endpoint signature, or response key casing | Treat as public API. camelCase keys only. make contract-check must stay synced. |
| Production deploy, data deletion, anything outward-facing | Confirm with a human first. Approval in one context does not extend to the next. |
4. Scientific changes are not yours to make¶
PVL's numbers are trusted by researchers and will appear in a paper. You may implement scientific logic; you may not decide it.
- When fixing a scientific bug, port the fix from Peleg Ragonis-Bachar's reference implementation (
260120_Alpha_and_SSW_FF_Predictor/, referenced throughout the code) verbatim, with line citations. Do not substitute a plausible-looking heuristic. - Thresholds, category definitions, and formulas are owned by the scientific lead. If the reference is ambiguous, surface the ambiguity to a human — don't resolve it yourself.
- Full guidance: when to ask humans.
5. The definition of done¶
A change is done only when all of these are true:
# Backend
make test # pytest — deterministic, no network. All green.
make lint # ruff. Clean.
make typecheck # mypy. Clean.
# Frontend (from ui/)
npx vitest run # all component tests green
npx tsc --noEmit # type-check clean
npm run build # production build succeeds
# Contract
make contract-check # backend ↔ UI contract synced
If any of these is red, the change is not done — fix it or explicitly flag the intentional red state to a human. A Stop-hook test gate is wired in this repo (ADR-019); sessions that introduce failing tests cannot close cleanly. See failure modes.
6. Smallest-diff discipline¶
- Fix only what is broken. Add features incrementally. Do not refactor unless explicitly asked.
- Match the surrounding code's style, naming, and comment density. Write code that reads like it was already there.
- Do not add lines that don't buy clarity or reliability.
7. Where to go next¶
- Repo map — find anything, fast.
- Contracts and invariants — the protected surfaces in full.
- Doing a safe change — the step-by-step playbook.
- When to ask humans — the escalation list.
- Existing tooling — skills, MCPs, hooks already available.
- Failure modes — recovering from red CI / lint / review.
- Artifacts index — where binaries and data live.
The human-facing handbook (../humans/) is also worth your time — the science page explains why the axioms exist, which makes them much harder to break by accident.