physgate
Use when explicitly invoked via /physgate or $physgate for a rigorous scientific computing or physics modeling micro-task that requires aligning physical assumptions and units against literature, freezing a sanitized SPEC.md contract with fresh non-circular physics tests, and running user-approved OS-jailed cross-family adversarial bug hunting plus human code review. Do not use for quick exploratory plots or general non-scientific software tasks.
Why it scored this
named +4 · described +6 · substantial +6 · right length +4 · subagents +5 · references +5 · evals +5 · numbered-steps +5 · active +5 · unseen-before +8 · specific-vocabulary +8
The file
---
name: physgate
description: "Use when explicitly invoked via /physgate or $physgate for a rigorous scientific computing or physics modeling micro-task that requires aligning physical assumptions and units against literature, freezing a sanitized SPEC.md contract with fresh non-circular physics tests, and running user-approved OS-jailed cross-family adversarial bug hunting plus human code review. Do not use for quick exploratory plots or general non-scientific software tasks."
disable-model-invocation: true
argument-hint: "[scientific micro-task + reference literature / data paths]"
---
# PhysGate — Turn AI into a Physicist
> **Iron Rule (Zero Exceptions)**: Violating the letter of this protocol violates its spirit. Implicit auto-invocation is locked off via `disable-model-invocation: true` (Claude Code) and `allow_implicit_invocation: false` in `agents/openai.yaml` (Codex CLI). At every human sign-off checkpoint marked `🛑 STAGE GATE`, **never advance to the next stage, never write production scientific code early, and never invoke external CLIs before explicit user approval of exact hashed files, named providers, and OS read-jail boundaries**.
## Scope, Privacy Boundary & Human Ownership
- **Readable Scientific Micro-Tasks & Human Code Ownership**: Keep the core solver concise enough for one researcher to read in one sitting (one module, no gratuitous framework split). Automated physics tests and cross-family AI reviews are an **adversarial bug hunt**, never a proof of correctness and **never a substitute for reading your own code and verifying library semantics**.
- **Private Local Evidence & Host-Provider Honesty**: Immediately gitignore `.physgate_local/` (including `.physgate_local/QA_RAW.md`, `.physgate_local/withheld.md`, `.physgate_local/holdout/`, `.physgate_local/logs/`), `.physgate_reviews/`, `REVIEW_BOARD.md`, and any user-declared restricted paths in **Stage 1** before writing `Round 0`. On a cloud-hosted Main AI, **never open workspace PDFs, datasets, or logs before the user classifies disclosure**; "off-provider" means never sent to external providers, and files restricted even from the host provider remain unopened.
- **OS Read-Jail Confinement & Progressive Disclosure**: `cd`, `-C`, and `--cwd` do **not** stop absolute paths or `..`. External reviewer and Clerk CLIs MUST run inside a deny-default OS read-jail (macOS `sandbox-exec`, Linux `bwrap`, or Windows WSL2+`bwrap` / Windows Sandbox / read-only container) allowlisting only `$STAGE_DIR` (`mktemp -d` outside `<project_root>` and `$HOME`, `cp -L` with zero symlinks) plus CLI runtime paths—**whenever any private directory (`.physgate_local/`, `.physgate_reviews/`) OR any Restricted path exists on the machine**, if that OS jail cannot be built, **stop remote CLI dispatch immediately** (use an offline local model with outbound networking disabled, or abort). **Only `Read` the `references/` and `templates/` files for the exact stage you are entering** (Gate map: `GATE 1` → `GATE 2` → `GATE 3a/3b` → `GATE 4` → `GATE 5`).
---
## Stage Overview & Hard Gates
| Stage | Core Actions | On-Demand Reference | Hard Stage Gate & Completion Criteria |
| :--- | :--- | :--- | :--- |
| **Stage 1**<br>Disclosure Triage & Dual-Register Socratic Questioning | Before reading any workspace PDF/dataset/log, ask the researcher to classify file disclosure (`Public / Sanitized / Restricted`); ignore `.physgate_local/`, `REVIEW_BOARD.md`, and restricted paths first; ask open-ended **Technical + Plain-Language** questions (**no recommended answers or `(a)/(b)` menus**); log locally in `.physgate_local/QA_RAW.md` (verbatim or redacted) | [`./references/01-socratic-questioning.md`](./references/01-socratic-questioning.md) | `🛑 GATE 1`: **Stop immediately after each round of questions** and wait for the user to answer item by item.<br>**Done when**: Disclosure boundaries, task scope, literature conflicts, and hidden assumptions are decided by the user and logged locally. |
| **Stage 2**<br>Initial Research Design Review | Present the complete initial research design in **both Technical and Concise Plain-Language** registers, plus **rejected alternatives and why** (logged locally) | Same (`01`, Section 4) | `🛑 GATE 2`: **Stop immediately after presenting** and wait for user approval or revisions.<br>**Done when**: The user explicitly approves the research design direction (or revisions have been re-reviewed and approved). |
| **Stage 3**<br>Physics Constraints & Sanitized Contract Freeze | **3a** Propose candidate first-principles physics constraints (`PC-01..N`, grounded in known-answer & extreme-regime falsification) and invite the researcher to keep 1–2 private holdout tests off-AI under `.physgate_local/holdout/`;<br>**3b** Present the **final design + sanitized constraints table** for sign-off;<br>**3c** Freeze sanitized `SPEC.md` (`Public`/`Sanitized` rows only; restricted inputs recorded anonymously without paths/titles), seal `.physgate_local/QA_RAW.md`, and echo paths | [`./references/02-constraints-spec-tickets.md`](./references/02-constraints-spec-tickets.md)<br>[`./templates/SPEC.template.md`](./templates/SPEC.template.md) | `🛑 GATE 3a`: **Stop after presenting candidate constraints**.<br>`🛑 GATE 3b`: **Stop after presenting final design + constraints**.<br>**Done when**: Sanitized `SPEC.md` is frozen on disk, local log is sealed under `.physgate_local/`, and paths are echoed. |
| **Stage 4**<br>Lightweight Slicing, Worktree Implementation & Self-Check | Generate `TICKETS.md` (**2–4 vertical slices**); commit `SPEC.md` and `TICKETS.md` only; keep core solver in one readable module; whenever any private directory (`.physgate_local/`, `.physgate_reviews/`) or Restricted path exists, spawn no slice sub-agent unless confined inside a deny-default OS read-jail allowlisting only its assigned worktree (and require named-provider + exact-file approval before granting any external path); implement slices in `git worktree` using `git add -- <paths>` and pre-merge file audits; codify `PC-XX` into fresh-execution non-circular tests (synthetic/public fixtures mandatory when inputs are restricted) *(Stage 4 performs no external review dispatch; next human stop is Stage 5 `GATE 4`)* | Same (`02`, Sections 3–5)<br>[`./templates/TICKETS.template.md`](./templates/TICKETS.template.md) | **Internal Verification Gate**:<br>**Done when**: All `TICKETS.md` slices pass pre-merge checks and merge, public interface matches `SPEC.md`, and **all automated physics tests execute the current solver freshly and empirically PASS**. |
| **Stage 5**<br>Pre-Dispatch Approval, OS-Jailed Adversarial Bug Hunt & Clerk Synthesis | **5a** Present **named reviewer & Clerk providers**, **exact per-seat sanitized files + SHA-256 hashes** (sanitized `SPEC.md` and sanitized `PC-XX` tests are required for any completed remote audit—if either cannot be sanitized, **stop remote dispatch** rather than dropping them or marking review complete), OS read-jail status, and exact **Audit Scope** (**`Full Literature/Data Audit`** vs. **`Limited Contract+Code Audit`** vs. **`Limited Contract+Tests Audit (No Solver Code)`**);<br>**5b** Copy (`cp -L`, zero symlinks) approved files into `$STAGE_DIR` (`mktemp -d` outside repo & `$HOME`), run **no-repo preflight** (`--version`/`models`) and OS-jailed parallel blind bug hunts across `>= 2` **pairwise distinct foundation model families** (anti-yes-man rubric: unproven findings tagged `unproven`, uncited dimensions tagged `not examined`); run the approved jailed non-voting **Clerk** (never a host sub-agent) to synthesize verbatim action items and surface **Residual Limitations** | [`./references/03-independent-review.md`](./references/03-independent-review.md)<br>[`./templates/REVIEW_BOARD.template.md`](./templates/REVIEW_BOARD.template.md) | `🛑 GATE 4` (**Pre-Dispatch Approval**): **Stop before invoking ANY external CLI** until the user explicitly approves named reviewers, jailed Clerk seat, exact hashed files, OS jail status, and exact Audit Scope.<br>**Fail-Closed Breaker**: Whenever any private directory (`.physgate_local/`, `.physgate_reviews/`) or Restricted path exists and an OS jail cannot be built—or if a core file cannot be sanitized, or any approved seat fails/times out/has duplicate or unknown base family—**abort remote dispatch immediately (zero roleplay)**.<br>**Done when**: Raw audits, Clerk synthesis, and **Residual Limitations** are surfaced to the researcher. |
| **Stage 6**<br>Remediation, Hash-Gated Re-Audit & Human Code Review | Fix tests and solver per proven joint action items (never relax `SPEC.md` tolerances); any byte change in approved files, new path, or provider change **re-triggers `GATE 4`** (including diff SHA-256; never send diffs of paths that ever held restricted bytes) and re-runs inside fresh OS-jailed `$STAGE_DIR`s; re-run all physics tests freshly; present **Equation-to-`file:line` Map + 6-Column External Library Behavior Table** in chat and invite the researcher to run private `.physgate_local/holdout/` tests (reporting failed invariants in words only—never pasting hidden cases/tracebacks) | Same (`03`, Section 5) | `🛑 GATE 5`: **Stop immediately after submitting** fixes, re-audit receipts, residual limitations, fresh test logs, and code/library walkthrough; wait for user review.<br>**Done when**: The researcher explicitly confirms they read the solver and library table, verified any private holdout tests, and provides revisions or sign-off. |
| **Stage 7**<br>Human Amendments & Final Human-Signed Closure | Append Stage 6–7 amendments locally in `.physgate_local/QA_RAW.md` (gitignored, off-provider); update sanitized `SPEC.md` and fresh tests; apply fixes, re-confirm `GATE 4` for changed file hashes, pass OS-jailed read-only re-audit, re-run the entire physics test suite freshly, and obtain the researcher's explicit code-reading sign-off | Same (`03`, Section 6) | **Final Closure Criteria**: All user-added conditions pass fresh tests, changed bytes pass OS-jailed re-audit, exact `Full`/`Limited` scope is stated, and **the researcher explicitly confirms reading the final solver and library table** ("tests passed" alone does not close). |
---
## Execution Protocol (Mandatory for Main AI)
1. **On Invocation (`/physgate` or `$physgate`)**: **`Read` ONLY** [`./references/01-socratic-questioning.md`](./references/01-socratic-questioning.md); ensure `.physgate_local/`, `.physgate_reviews/`, `.worktrees/`, and `REVIEW_BOARD.md` are gitignored (via `.gitignore` or `.git/info/exclude`) before writing `Round 0`; **do not open workspace PDFs, datasets, or logs before the user classifies disclosure**; post **Stage 1** Round 1 dual-register open questions (starting with disclosure classification + initial scientific questions from user-pasted text), then **stop immediately and wait for the user**.
2. **On Every Subsequent User Reply**: Update `.physgate_local/QA_RAW.md` first (immediately ignoring any user-declared restricted paths); check the current stage's **Done when** criteria—if unmet, stay in the current stage; if met, announce the transition, `Read` only that stage's referenced files, and stop immediately at every `🛑 STAGE GATE`.
---
## High-Risk Red Flags & Anti-Rationalization Checklist
| Common Rationalization | PhysGate Iron Rule (Reality) |
| :--- | :--- |
| "Adding a recommended default or `(a)/(b)` binary choice saves the user time." | **Never offer recommended answers or any option menu.** Ask dual-register open-ended questions so the researcher decides in their own words. |
| "Let me open the user's PDFs/datasets first to save a round of questions." | **Never open workspace papers, datasets, or logs before the user classifies their disclosure class** (a cloud Main AI read is already host-provider egress). |
| "`cd $STAGE_DIR` or `-C $STAGE_DIR` + `--read-only` already blocks reading other files." | **`cd`, `-C`, and `--cwd` do NOT stop absolute paths or `..`!** Whenever AN