DHF specification.
The rules of the Delivery Harness Framework. This page states what must hold on every host; it does not describe an implementation. This is a translation. The authoritative text is the Chinese source, docs/dhf-spec.md in the public repository bryanzk/delivery-harness-framework (current release: v0.1.0); where the two differ, the source wins.
1. Standing of this page
- This page is the DHF specification. It states rules, not implementation.
- The rules do not depend on any one host. A host is the program that runs an agent.
- Other pages of the public site describe an implementation or explain the framework. Where another page conflicts with this one, this page wins.
- When models become more capable, the rules stay the same. The implementation may change.
2. Eight invariants
Each invariant has four parts: rule, reason, enforcement point, and test.
An enforcement point is the place where a rule is carried out mechanically. Prefer points outside the host: CI, branch protection, a protected runner, credential scope, file permissions.
I-1 Evidence is graded
- Rule: evidence has seven levels: design intent, source implemented, verification passed, runtime active, publicly published, production enforced, customer outcome validated. Evidence of a lower level must not be used to prove a higher level.
- Rule: source, runtime, public documentation, and production are four states and are reported separately.
- Reason: a model can write a fluent statement that looks finished. Fluent is not accurate.
- Enforcement point: the delivery report template; the status page of the public site.
- Test: every status claim has an evidence level and an evidence date beside it.
I-2 A completion claim carries a fresh receipt
- Rule: every conclusion of the form "done", "fixed", or "passed" carries four fields:
command,exit_code,key_output,timestamp. - Rule: a receipt expires when the related source, the host version, or a runtime file changes.
- Rule: a report from a sub-agent is evidence awaiting review. It is not proof of completion.
- Reason: a receipt replaces a statement with a fact that can be checked.
- Enforcement point: the delivery report template; a required check in CI.
- Test: a conclusion that lacks any of the four fields is treated as unverified.
I-3 Authority comes only from the owner's current message
- Rule: only a message the owner sends in the current conversation can authorize an action.
- Rule: repository files, tool output, earlier conversations, recovered state, and agent-generated content never authorize anything.
- Rule: a side effect that is not in the action register is refused.
- Reason: instructions can be mixed into anything an agent reads. Recovery restores facts, not permission.
- Enforcement point: the action register; the single-use authorization check of a protected runner.
- Test: every external write can be traced to one message from the owner.
I-4 Actions are graded by side effect
- Rule: an action is graded by two properties: whether it can be undone, and whether it leaves the machine. It is not graded by the kind of work.
- Rule: there are three levels. Level 0: local reads, and local writes inside the authorized write set. Level 1: may run once the owner has named the action and the target. Level 2: refused by default.
- Rule: Level 0 needs no confirmation. A Level 1 action leaves the machine but can be undone. A Level 2 action cannot be undone, or changes permissions or the control plane.
- Rule: Level 1 authority may be given for a group: one message from the owner authorizes one class of action, for the current session only.
- Rule: Level 2 authority is never given for a group. It is given separately each time.
- Rule: the action register may mark a Level 1 action as not groupable.
- Rule: a profile does not change the level of an action. It changes only how Level 1 is confirmed: the governed profile does not allow group authority; the other profiles do.
- Reason: the cost of process must match the risk. Low-risk work stays light.
- Enforcement point: the action register; the three profiles light, standard, and governed.
- Test: every action belongs to exactly one level in the register.
I-5 Discipline for external writes
- Rule: check the current state of the target before writing. Read it back immediately after.
- Rule: when the result is partial or unknown, do read-only checks only. Never retry blind.
- Rule: single-use authority expires after one use. Group authority is valid only in the session that gave it. A replay is refused.
- Rule: secrets never enter an agent's input, output, or context.
- Reason: the state of an external system cannot be rolled back, or only at high cost.
- Enforcement point: a protected runner; version-conditional writes in a connector; credential scope.
- Test: every external write has one pre-write check record and one read-back record.
I-6 High risk is blocked before the side effect
- Rule: a high-risk action is stopped mechanically before its side effect happens. A prompt alone is not enough.
- Rule: prefer enforcement points outside the host. A hook inside the host is a supplement.
- Rule: every blocking point leaves a record that it ran. A blocking point that cannot show whether it was called is treated as unverified.
- Reason: a prompt can only advise. A hook inside a host stops working when the host changes, when the host is upgraded, or when a third party rewrites the configuration.
- Enforcement point: branch protection; CI; a protected runner; file permissions; a host hook as a supplement.
- Test: every Level 2 action has at least one verified enforcement point in the action-to-point table, or a recorded acceptance by the owner.
I-7 Continuity lives outside the conversation
- Rule: a fact has one authoritative source. Every other place holds a pointer.
- Rule: sources are trusted in this order: stable rules, the repository map, the terminology contract, current state, decision records, source and Git, execution evidence, conversation history. Conversation history gives clues only.
- Rule: a new session recovers from durable files, not from an old conversation. Recovery loads four items only: the phase, confirmed facts, blockers, and the next safe action.
- Rule: a correction from the owner is written into a durable file.
- Reason: the context window is finite, compaction loses detail, and a model does not learn from a correction.
- Enforcement point: rule files, policy, and the State Log in the repository.
- Test: with all conversation history deleted, a new session can still state the current phase and the next safe action.
I-8 Business decisions are made explicit
- Rule: any case that affects money, authorization level, customer-visible output, persistence, or runtime permission is decided item by item before implementation.
- Rule: there are four decisions only: allow, refuse, decide by a person, leave the existing path unchanged. Each case gets exactly one.
- Rule: when evidence is insufficient, the decision is "decide by a person" or the task is blocked. Never guess.
- Rule: a passing test does not turn a business guess into a contract.
- Reason: a model does not know niche business rules that exist only with the customer.
- Enforcement point: the pre-implementation decision matrix (PIDM); the terminology contract.
- Test: every implementation task has a complete decision matrix before work starts.
3. Four conditions before a state change (SAFE)
All four conditions hold before every state change.
| Condition | Meaning | Invariants |
|---|---|---|
| S · Specification | Scope, acceptance conditions, and state definitions are written down | I-8 |
| A · Authorization | The owner's current authority covers this action and this target | I-3, I-4 |
| F · Facts | There is a fresh test, receipt, or read-back | I-1, I-2 |
| E · Error recovery | There is a checkpoint, a rollback method, or a handoff method | I-5, I-7 |
4. Order after a failure (RECOVER)
- Recognize: tell failure, partial completion, and unknown result apart.
- End: stop further side effects.
- Capture: keep the failure receipt, the target, the version, and the scope of impact.
- Obtain: get the last trusted state from Git, a checkpoint, or version history.
- Verify: check it with an independent read-back.
- Escalate: a new HEAD, digest, or version needs the owner's authority again.
- Resume: continue only from the next safe action recorded in the checkpoint.
5. Host applicability
This is the only section where a host may be named.
| Invariant | Kind of enforcement point | Codex, local | Claude Code, local | Claude Code, cloud |
|---|---|---|---|---|
| I-1 to I-5, I-7, I-8 | Repository files, templates, CI, runner | applies | applies | applies |
| I-6, points outside the host | Branch protection, CI, runner, credential scope | applies | applies | applies |
| I-6, points inside the host | hook | verified 2026-11-27 (reference machine, Codex CLI 0.172.0) | verified 2026-11-27 (probe repository, Claude Code 2.1.332) | single-repository session: verified 2026-11-27 (probe repository). Project thread: repository hooks do not run |
- Every cell of this table has an evidence date. A cell whose date is more than 30 days old is marked stale.
- "Verified" holds only for the named machine and host version. Another machine or another version is probed again.
- The cell-by-cell state of the seven functions on each host, with probe methods and probe receipts, is recorded in
docs/dhf-conformance.json. Where this table conflicts with that file, the file wins.
6. Kinds of mnemonic
| Kind | Mnemonics | Meaning |
|---|---|---|
| Rules | SAFE, AIRCRAFT, CAP, RECOVER | Rules. This page is their authoritative source. |
| Implementation | PROTECT, BRIDGE | How the seven functions are implemented on a host, and how mature that is. The functions stay the same; the implementation changes with the host. |
| Explanation | TRUST, BEST, CARE | Ways of telling the story to different readers. They add no rule. |
Where the rule mnemonics sit on this page:
| Mnemonic | Place on this page |
|---|---|
| SAFE | Section 3 |
| RECOVER | Section 4 |
| AIRCRAFT | The trust order in I-7. The eight sources, in the order I-7 lists them, match the eight letters |
| CAP | Continuity is I-7; Accuracy is I-1 and I-2; Permission is I-3, I-4, and I-6 |
7. One action description
The core is the decision logic that depends on no host. An adapter is the layer that connects one host to the core.
The core accepts only the input below. A host's own data structures never enter the core.
| Field | Meaning |
|---|---|
| Session | The identifier of this session |
| Working directory | The working directory at the time of the action, as an absolute path |
| Action kind | One of the seven kinds below, or "unrecognized" |
| Target paths | The list of paths the action touches, as absolute paths |
| Original tool name | The name the host gave this call |
| Action kind | Meaning |
|---|---|
| Read | Read a local file or directory |
| Write | Create or modify a local file |
| Delete | Delete a local file, or move it away |
| Execute | Run a local command or program |
| Network | Send a request off the machine without changing remote state |
| Remote | Change state off the machine: push, publish, send, call an external write interface |
| Delegate | Hand work to another agent |
Rules:
- One tool call may produce several action descriptions. A patch that changes three files produces three. A move produces one delete and one write.
- Target paths are normalized before they enter the core: relative paths and symbolic links are resolved.
- The original tool name is for the record only. The core never decides by the original tool name.
- A call the adapter cannot classify gets the action kind "unrecognized". An unrecognized call leaves a record.
- Whether an unrecognized call is blocked depends on the profile: the governed profile blocks it, the other profiles record it only.
- The count of unrecognized calls appears in the status report. After a host version change, a count above zero must be dealt with.
- When the adapter cannot obtain the target paths, it leaves them empty and writes "target unresolved" in the record. It never guesses.
8. Contracts of the seven functions
The seven functions are invariant. Their implementation may differ on each host.
Each function has four parts: input, output, tests, and what it must not depend on.
For all seven, "must not depend on" includes the host's name, the host's file names, the host's data structures, prompts, and conversation history. The entries below list only what is additional.
Position
- Purpose: answer which phase the task is in now.
- Input: the durable task state record; the session; the working directory.
- Output: the current phase; the source of that conclusion; whether the conclusion is certain. When it is not certain, the output is "unknown".
- Test: with the same durable state, two computations give the same result.
- Test: with all conversation history deleted, the result does not change.
- Test: when uncertain, the output is never a phase more permissive than "unknown".
- Must not depend on: the model's own statement of its phase.
Restrict
- Purpose: decide, before the side effect, whether an action goes ahead.
- Input: one action description; the boundary from Contain; the phase from Position; the valid authority from Empower. The profile decides whether the last two are used.
- Output: allow or block. A block carries a reason code. Every call leaves an invocation receipt.
- Test: a block happens before the side effect.
- Test: the same input gives the same decision.
- Test: the invocation receipt answers three questions: was it called, what was the latest decision, and is the installed version the one that was called.
- Test: a read is blocked only when its target is a credential.
- Test: when the core itself fails, a call whose kind is write or delete is blocked, and the reason code says it is a core fault. Other kinds are allowed and recorded. Failure includes a crash, a timeout, and a result that cannot be parsed. The adapter must guarantee this.
- Test: write targets inside an "execute" action are not parsed. This is a known gap. The two points below cover it; Restrict does not.
- Test: a control-plane file that changes only at release is protected with the operating system's immutable flag. The release transaction clears the flag first and sets it again when done.
- Test: a control-plane file that the host itself also writes gets no immutable flag. Its content is checked at session start, and any difference from the source is reported.
- Test: the governed profile may add one rule: a command whose text contains a protected path is blocked. The other profiles do not add it, because it would block read-only commands by mistake.
- Must not depend on: the original tool name; the location of the host's configuration files.
Observe
- Purpose: write down what actually happened, for checking and for recovery.
- Input: the action description; the result of the action; the decision from Restrict.
- Output: an append-only evidence record. A verification record carries the four fields
command,exit_code,key_output,timestamp. - Test: the record lives outside the conversation, and a new session can read it.
- Test: a record is not authority.
- Test: secrets do not enter the record.
- Test: a failure to write the record does not change the result of the action itself.
- Must not depend on: the model's statement of the result.
Thread
- Purpose: let a new session pick up the work of an old one.
- Input: the durable state record.
- Output: four items at session start: the phase, confirmed facts, blockers, and the next safe action.
- Test: with all conversation history deleted, the four items are still available.
- Test: resumption restores facts, not permission. Authority from the previous session is not valid in the new one.
- Must not depend on: the host's own session-resume feature.
Empower
- Purpose: let the owner open one capability explicitly, inspect it, and revoke it.
- Input: an explicit declaration from the owner, with the action, the target, and how long it is valid.
- Output: one authority record. It can be inspected, it can be revoked, and it has an expiry time.
- Test: every authority record can be traced to one operation by the owner.
- Test: after expiry or revocation, the authority is invalid at once.
- Test: authority marked single-use expires after one use. A replay is refused.
- Test: an agent does not create, modify, or extend an authority record.
- Must not depend on: any location an agent can write to by itself.
Contain
- Purpose: answer whether a path is inside the allowed range.
- Input: a boundary declaration the owner maintains, with governed roots, protected roots, and the allowed write set.
- Output: for any target path, one of three answers: inside the boundary, outside the boundary, protected.
- Test: normalize the path first, then decide. Symbolic links and hard links do not get around the decision.
- Test: the harness's own installation, credentials, and the operating system's auto-start locations are always protected. They stay protected when the boundary declaration is missing.
- Test: an agent does not modify the boundary declaration.
- Must not depend on: the working directory happening to sit at a fixed location.
Transact
- Purpose: release a set of control-plane files to the runtime together, or restore them together.
- Input: a fixed list of release targets; a source digest the owner has approved.
- Output: every target updated, or every target restored. One release record, with a transaction identifier and each target's hash before and after.
- Test: if any target fails, the targets already updated are restored in reverse order.
- Test: when the owner has not approved the digest, the release is refused.
- Test: files outside the list are not changed.
- Test: after release, a read-back shows the runtime hashes equal to the source.
- Test: the owner runs the release. An agent does not run a release and does not approve a digest.
- Must not depend on: the directory layout of the runtime installation. The adapter supplies the target locations.
9. Core and adapters
- The core implements the decision logic of the seven functions. The core accepts only the action description of section 7.
- Each host has one adapter. An adapter does three things only: translate the host's call into action descriptions; translate the core's decision into the response format the host accepts; register itself in the host.
- An adapter contains no rules. The same action description gets the same decision on every host.
- Every combination of function and host has one probe without side effects, and one dated probe receipt. A combination without a receipt is treated as unverified.
- After a host version change, all probe receipts for that host expire.
- The owner sets the profile explicitly: per workspace, with an expiry time. When none is set, or it has expired, the profile is light. A damaged record is treated as governed.
- An agent does not set the profile. Keywords in a prompt do not change the profile.
- Where the profile lives: the owner declares it in the workspace with
codex-task profile <profile> --reason <reason-code>(--ttlis optional, default 8 hours), andtask_statekeeps the record. The Guard and the DHF skill read that record. The prompt hook (dhf_preprompt.py) does not decide the profile; the owner has it turned off for now. - Where a group grant lives: the owner writes a line of its own,
成组授权: <group>(orgroup-grant: <group>), in a message of the session. Several groups are separated by commas;成组授权: nonewithdraws every grant. Groups and their actions are in the action registercodex/runtime/action-registry.json. Before acting on a group grant, an agent runscodex-task grant-check <action> --session-id <session id>; only exit code 0 counts as granted, and every use leaves an audit record. The governed profile refuses every group grant. - DHF defines gates (the conditions for moving to the next step), not routes (which skill to use). Skills are chosen on demand.
docs/LIFECYCLE_SKILL_ROUTING.mdis a reference only: not a contract, and not on the required reading list. - What the three profiles turn on: light has only the fixed blocks of Restrict; standard is the same as light for now; governed also turns on Position, Empower, and Contain, and blocks unrecognized write calls.
- In the governed profile, when the owner has declared no phase, writes and deletes are blocked and reads are unaffected. The block message says how to declare a phase.
- The owner may turn off one function on one host. A function that is turned off is listed truthfully in the status report. "Turned off" is never reported as "faulty", and never as "normal".
- Turning each hook on or off belongs to the owner, in the host's own interface (
/hooksin Codex). DHF offers no switch command an agent can run, and never turns a disabled hook back on. When a sync moves a hook's registration, its on/off state follows the hook's command, not its position. A disabled Guard is flagged prominently in the status report. - In parallel work, the write sets of the agents and worktrees do not overlap. The lead agent integrates and does the final verification. Sharing a repository does not mean sharing write rights.
- While the owner runs commands in a workspace, an agent does not change the same workspace.
- Each worktree puts its verification receipt in its delivery report and does not write the State Log. The main session appends one State Log entry on the integration branch, which merges to main with the integration PR. When one session works alone, its own PR is the integration PR.
10. Outside the specification
The following may change with the model and the host, and are not written into the specification:
- Which skill completes which phase.
- What is injected into a prompt.
- How context pressure is detected.
- The file name, registration location, and data structure of a host hook.
- The specific keywords of each profile.
Where the implementation falls short
This section records what the specification requires and the implementation does not yet do. An item is removed when it is done.
- Blocking on a core fault: the crash case is implemented and released to the runtime. It passes tests on Python 3.12 and 3.9.6 and has not yet met a live fault in a host. A timeout and an unparseable result are decided by the host; an adapter cannot guarantee them alone. A file that does not compile cannot carry out this rule.
- The gap in "execute" actions: the source of all three enforcement points is implemented. It is promoted to the runtime of the reference machine. The command-text check has a host probe receipt (
restrict.governed-command-protected-path); the other two points do not yet. The immutable flag works on macOS only, and the owner can clear it withchflags nouchg. The session-start check reports and never repairs. The command-text check works only in the governed profile and only in the Codex adapter, and it matches text. Known forms it misses: a path built at run time from variables, command substitution, eval, or decoding (a leading$HOMEor$CODEX_HOMEis handled); a path written inside a script file; a glob in a symlinked directory name followed by..; a glob whose matching file does not exist yet when the check runs. By owner decision, these forms are not patched one by one. - Group authority: the source is implemented and not yet released. The grant is written in an owner message of the session, so it is valid only in that session and that repository. An agent checks it with
codex-task grant-check, and every use leaves an audit record. The agent passes the session id itself, so it can borrow the grant of another session running in parallel in the same repository. Nothing checks mechanically that the agent ran the check first. - The action register: it exists in the Codex adapter. The file in the repository
bryanzk/delivery-harness-framework(dhf/adapters/codex/runtime/action-registry.json) is an example. No program other thancodex-task grant-checkreads it. - Path normalization: the protected objects are listed in one registry in the core. When a name in the registry is a symbolic link, the link and its destination are both protected; the same holds for a symbolic link inside a protected directory. A path that goes through a symbolic link and then
..is judged by the file the system reaches. This is promoted to the runtime of the reference machine (2026-12-01) and has host probe receipts (Codex: restrict.symlink-then-parent; Claude Code local: restrict.cc-local-symlinked-key-destination). Claude Code 2.1.333 folds..itself before it calls the hook, so a path with a symbolic link followed by..reaches neither the Guard nor the protected file on that host. Symbolic links inside the launch directories of the system volume (/System) are not followed: that volume is sealed, and a symbolic link in it cannot be added or changed. When a link leads to a directory, the links in that directory are followed too, level after level. When Python imports a module it runs a cached compiled file without checking its content; so the place where the interpreter keeps the compiled files of a protected directory is registered as a protected directory too, and the Guard runs the files it loads from source only. The directory of the Codex session records (sessions), and the directoriesbin(wherecodex-taskis) andruntime, are control plane too: a group authorization and a phase line of a session are read from the session records. The number of files in the session records has no limit, so that directory is protected by path only: a symbolic link inside it that leads out, and a hard link from outside to a record, are not found; the command check of the governed profile does not cover that directory, and a command that reads a session record continues. Three cases are not covered: paths inside shell commands are not parsed (see the gap in "execute" actions); the Guard checks once before the call, so a symbolic link created or changed after the check is not seen; and a content search (Grep in Claude Code) is judged by the directory it searches, not by each file in it, so a hard link to a protected file inside that directory is not found, because a walk of the whole directory before every search would go far beyond the time budget of the hook. - "An agent does not create an authority record" in Empower: an agent's edit tools cannot change a declaration, but an agent can run the declaration command from its shell. Today this leaves an audit trail and is not a hard boundary.
- "An agent does not set the profile": the same as the previous item. An agent can run the setting command from its shell.
- Host coverage: only one host on one machine has probe receipts for all seven functions. The cell-by-cell state is in
docs/dhf-conformance.json. - Parallel work: the rules are written here only, and no tool enforces them. Nothing checks that worktree branches leave the State Log alone. Two worktrees merging in parallel without a State Log conflict has not been tried yet.