Review the prerequisites
Suitable for: Readers able to run Python and inspect a SQLite table.
- Session log and working context
- The session retains governed events and references; context is a lossy view built from cursors, summaries and artifact versions, not an authority grant or business fact.
- Replaceable controller
- A new worker reconstructs work from external records; disposable local memory does not make external actions repeatable or guarantee recovery of workspace bytes.
- Release manifest
- Bind model, harness, tools, policies, context and skill/hook bytes to a traceable behavior release; the manifest alone does not enforce isolation.
How does the mechanism work?
Step-by-step explanation
- State follows authority, not a container
Persist session, artifacts and merchant ledger separately and verify each through its owner.
- Separate discovery, computation and approval
Dynamic loading reduces input and programmatic calls process results; current authorization and approval still gate the actual action.
- Mechanisms evolve with evidence
Version model and harness together, using held-out tasks and counterexamples to keep or remove one orchestration mechanism.
Implementation · Build it
Implement stable identities across controller replacement
Objectives of this level: Run a complete local example, then specify the interfaces still missing for production.
Visual guide · Replace the controller, keep facts
This is the proposed architecture. The local identity demo has no model, network or sandbox; a surviving session does not guarantee surviving workspace files. Select the figure to open it at full size.
Implement event and operation identity before adding a framework
Save the complete program below as harness_architecture_demo.py. Use Python 3.10+ and a fresh architecture-work directory. Run the three commands separately: the first process commits a fictional merchant record but intentionally stops before recording its receipt; the next process reconstructs work from files and reconciles that original operation. No model, network, approval service, sandbox or real commerce is involved.
The two SQLite files persist independent local facts. MerchantFixture is a service fixture within each process, not an independent remote service. SessionLog exposes append semantics but does not enforce database-file permissions. No credential is read. This is an executable identity/recovery example, not an OS security or distributed exactly-once test.
import json
import sqlite3
import sys
from pathlib import Path
def canonical(value):
return json.dumps(value, sort_keys=True, separators=(",", ":"))
class SessionLog:
def __init__(self, path):
self.db = sqlite3.connect(path)
self.db.execute("CREATE TABLE IF NOT EXISTS events("
"seq INTEGER PRIMARY KEY AUTOINCREMENT,"
"event_id TEXT UNIQUE NOT NULL,kind TEXT NOT NULL,"
"operation_id TEXT NOT NULL,payload TEXT NOT NULL)")
self.db.commit()
def append(self, event_id, kind, operation_id, payload):
body = canonical(payload)
with self.db:
self.db.execute("BEGIN IMMEDIATE")
old = self.db.execute(
"SELECT kind,operation_id,payload FROM events WHERE event_id=?",
(event_id,)).fetchone()
if old is not None:
if old != (kind, operation_id, body):
raise ValueError("event_identity_conflict")
return "replayed"
self.db.execute(
"INSERT INTO events(event_id,kind,operation_id,payload) VALUES(?,?,?,?)",
(event_id, kind, operation_id, body))
return "committed"
def intents(self):
return self.db.execute(
"SELECT operation_id,payload FROM events WHERE kind='intent' ORDER BY seq"
).fetchall()
def count(self):
return self.db.execute("SELECT COUNT(*) FROM events").fetchone()[0]
class MerchantFixture:
def __init__(self, path):
self.db = sqlite3.connect(path)
self.db.execute("CREATE TABLE IF NOT EXISTS operations("
"operation_id TEXT PRIMARY KEY,payload TEXT NOT NULL,"
"receipt TEXT UNIQUE NOT NULL)")
self.db.commit()
def create(self, operation_id, payload):
body = canonical(payload)
with self.db:
self.db.execute("BEGIN IMMEDIATE")
old = self.db.execute(
"SELECT payload,receipt FROM operations WHERE operation_id=?",
(operation_id,)).fetchone()
if old is not None:
if old[0] != body:
raise ValueError("operation_identity_conflict")
return old[1]
receipt = "r-" + operation_id
self.db.execute("INSERT INTO operations VALUES(?,?,?)",
(operation_id, body, receipt))
return receipt
def lookup(self, operation_id, payload):
row = self.db.execute(
"SELECT payload,receipt FROM operations WHERE operation_id=?",
(operation_id,)).fetchone()
if row is None:
return None
if row[0] != canonical(payload):
raise ValueError("receipt_binding_conflict")
return row[1]
def count(self):
return self.db.execute("SELECT COUNT(*) FROM operations").fetchone()[0]
phase, directory = sys.argv[1:]
root = Path(directory)
root.mkdir(parents=True, exist_ok=True)
if phase == "prepare" and any(root.iterdir()):
raise FileExistsError("use_empty_directory")
session = SessionLog(root / "session.sqlite")
merchant = MerchantFixture(root / "merchant.sqlite")
try:
if phase == "prepare":
payload = {"tenant": "A", "order": "o-17", "quantity": 1}
session.append("intent-17", "intent", "return-17", payload)
merchant.create("return-17", payload)
result = {"phase": "interrupted", "events": session.count(),
"effects": merchant.count()}
# Stop before recording the receipt. A later command is a new process.
elif phase == "recover":
status = "unknown"
outcome = None
for operation_id, body in session.intents():
receipt = merchant.lookup(operation_id, json.loads(body))
if receipt is None:
continue # An empty query alone does not authorize another write.
outcome = session.append("receipt-" + operation_id, "receipt",
operation_id, {"receipt": receipt})
status = "completed"
result = {"phase": status, "append": outcome, "events": session.count(),
"effects": merchant.count()}
else:
raise ValueError("phase")
print(json.dumps(result, sort_keys=True))
finally:
session.db.close()
merchant.db.close()
python3 harness_architecture_demo.py prepare architecture-work
python3 harness_architecture_demo.py recover architecture-work
python3 harness_architecture_demo.py recover architecture-work
Actual output observed on 2026-10-30, Python 3.14.7:
{"effects": 1, "events": 1, "phase": "interrupted"}
{"append": "committed", "effects": 1, "events": 2, "phase": "completed"}
{"append": "replayed", "effects": 1, "events": 2, "phase": "completed"}
The third command is another process, yet effects remains 1. Recovery calls lookup rather than create. A missing receipt leaves unknown; this program deliberately does not claim that one empty lookup authorizes a new write. The transition to completed is only for this fixture's exact return-creation contract. It says nothing about refunds, language quality or delivery to a user.
Interfaces to add around this example
The proposed production event envelope is {session_id, event_id, sequence, kind, operation_id?, attempt_id?, producer_epoch, release_digest, artifact_ref?, payload_digest}. Validate field ownership at ingestion; don't accept a model-supplied tenant as an authenticated principal. Persist an action intent and its immutable operation binding before dispatch; collect transport observations separately from the business receipt.
A context projector reads a sequence range and records its source cursor, summary version, artifact digests and release digest. On wake, verify current authorization and selected artifact versions, then rebuild a bounded view. Do not replay every historical tool call. A supervisor grants a new worker epoch; the gateway/merchant must enforce the relevant fencing contract. On the sandbox side, keep a rebuild recipe and artifact manifest outside the disposable workspace. A session can survive without preserving an uncommitted file edit.
To explore real process/HTTP behavior, read the existing capstone. Its fictional local merchant and bounded teaching model are separate evidence; importing its filename does not implement this architecture.
code example
The worker changes, the operation does not
The first process records intent-17 and one merchant effect. The second appends receipt-return-17 after lookup; the third replays that event. events progresses 1→2→2 while effects remains 1.
Acceptance task for this level
Run the complete program in a new directory, retain all three outputs and inspect both tables. Add the three documented negative controls without changing the original operation binding.
Reading this browser’s record…
Hide the answer and check your understanding
Why does recover not call create after finding no receipt?
Expand reference derivation
The example has not established that an empty lookup is authoritative terminal absence or that re-dispatch is permitted. It preserves unknown until a stronger service contract is supplied.
Further explanations and practice
When encountering unfamiliar principles, first read the implementation, continuous questioning and migration cases, and then independently explain the premise and boundaries. Answers and notes are saved to the original account record.
All linked explanations and exercises (1 )
Sources and verification scope
The principles are based on public information; the numbers, cases and tasks are the teaching design of this website. Offline experiments verify the range noted on this page, and the learning effect still needs to be judged through independent tasks and feedback.
- Anthropic · Managed Agents architecture · 2026-04-08
- Anthropic · Harness design for long-running apps · 2026-03-24
- OpenAI · Introducing the Agents API · 2026-09-10
- OpenAI Agents API · Architecture · checked 2026-10-30
- OpenAI · Tool search · checked 2026-10-30
- OpenAI · Programmatic tool calling · checked 2026-10-30
- OpenAI Agents API · Vaults · checked 2026-10-30
- OpenAI Agents API · Plugins · checked 2026-10-30
- Codex · AGENTS.md discovery and precedence · checked 2026-10-30
- Codex · Hooks and permission events · checked 2026-10-30