Field Note 01 · Code Package
FoundryOS Field Note 01 — Dan Merchant

DO NOT STOP!

The complete source for the semantic session-contract gate described in the field note. When you tell a coding agent "don't stop until every test passes," this is the mechanism that holds it to that — a lifecycle hook that classifies the agent's own stop message and refuses an early hand-back.

Free to download. No email required. Start with the portable version — one dependency-free Node.js file.

22/22
Portable tests
54/54
Production suite
0
Dependencies
Downloads

Three packages.

Take the portable one if you just want it working. The others are for reading.

Start here · Recommended

Portable code — dependency-free implementation

The core mechanism compressed into a single Node.js script that handles all three lifecycle events. Copy it to a path, register it in your Claude Code settings, done. Ships with a 22-case executable smoke-test harness so you can verify it before you trust it.

ZIP · 14 KBNode.js 20+Zero dependencies22/22 verified
  • session-contract-minimal.mjs — SessionStart, UserPromptSubmit and Stop in one file
  • session-contract-smoke-test.mjs — 22-case harness, run it with node
  • README.md — install, arm, disarm, kill switch
↓ Download portable code do-not-stop-portable-code.zip · 13 KB
Reference source

FoundryOS production source

The wider implementation this was extracted from — a work-item ledger, a question gate, reasoned waivers, classified escalations, a managed hook installer and the full production unit suite. It integrates with FoundryOS operator infrastructure, so treat it as reference source rather than a drop-in package.

ZIP · 53 KB9 files54/54 verified
  • Shared state model, classifiers and decision procedure
  • Stop-boundary gate and question/decision-handoff gate
  • Work-item tracking, waivers and escalation authorization
  • Operator-visible item board posted to the transcript as work accrues
  • Idempotent managed hook installer + production test suite
Read it

Complete code appendix

The full written appendix from the field note — installation notes, the design rationale behind the classifier, and the complete portable source and smoke-test source inline. Nothing omitted from either file. Read this if you want to understand the mechanism before you run it.

Markdown · 38 KBFull source inline
  • What the version implements, line by line
  • Installation and arming/disarming reference
  • Complete portable source, unabridged
  • Complete smoke-test source, unabridged
54c95f652
Base merge commit
Audit 2
Classifier revision
2026-07-28
Published
Quick start

Running in about a minute.

Requires Claude Code with lifecycle hooks, and Node.js 20 or later.

01 Verify before you trust it

Unzip the portable package, keep both files in the same directory, and run the smoke test.

node session-contract-smoke-test.mjs

# expected:
22/22 smoke tests passed.

02 Register the hook

Copy session-contract-minimal.mjs to a stable absolute path, then register that same path for all three lifecycle events in your Claude Code settings.

{
  "hooks": {
    "SessionStart": [{
      "hooks": [{
        "type": "command",
        "command": "node \"/absolute/path/session-contract-minimal.mjs\""
      }]
    }],
    "UserPromptSubmit": [{
      "hooks": [{
        "type": "command",
        "command": "node \"/absolute/path/session-contract-minimal.mjs\""
      }]
    }],
    "Stop": [{
      "hooks": [{
        "type": "command",
        "command": "node \"/absolute/path/session-contract-minimal.mjs\""
      }]
    }]
  }
}

Use an absolute path that exists in the environment where Claude Code actually runs.

03 Arm it conversationally

No command, no flag. You arm it with the correction you would already have typed.

Don't stop until every migration test passes.

# disarm explicitly:
stop

# emergency bypass:
SESSION_CONTRACT=0

What it does and doesn't do. The gate records the condition you stated and uses it as session context — it does not independently prove that condition is met. It blocks contradictory or avoidable hand-offs and permits ordinary completion messages. Pair it with tests, acceptance criteria, an external verifier or a work ledger when the end state itself needs independent enforcement.

Published as the reference implementation accompanying FoundryOS Field Note 01. Use it, adapt it, ship it in your own setup. If it saves you a morning, tell me what broke — that's the useful feedback.

We build the platforms
your business runs on.

This gate is a byproduct. The day job is custom operational software — engineered around how your business actually works, shipped in 2–4 weeks.

Based in Nova Scotia · Shipping everywhere