All pagesPolicy - the formation contract

Contracts

Policy - the formation contract

Policy is what the rest of Octopus depends on. Every rule on this page is relied on elsewhere.

The design goal

This document serves one goal:

Support a thousand execution environments at once - nested and parallel - and have every worker inside every environment still able to answer its two questions (what can I do, what do I need to do) and act on anything the framework permits, without the whole thing collapsing into conflict or unbounded context.

If a thousand EEs cannot each hand their workers a correct, minimal, non-conflicting grant, the framework does not work. Judge every formation decision by one test: does it still hold at a thousand environments?

1. What policy is, and is not

Everything that is not execution code is policy. Which runs depend on which, which runs are persistent, who may initiate whom, which run holds the widest authority in a given environment - none of that is hardcoded and none of it is a function name. It is decided and edited as data.

Policy is not an artifact.

  • Artifacts arrive from interfaces. Policy does not. It is generated by the runtime, per consumer, at the moment it is needed.
  • It does not travel as an independently emitted artifact. A projection of the formed grant accompanies the invocation and is retained as movement evidence; it is not the authority from which the next grant is read.
  • Materializing a policy artifact per consumer would be pointless churn.

Replayability rests on determinism. Re-forming the grant depends on formation being pure - no hidden state, no clock, no randomness. Its inputs are primitives that are on disk and pinned by hash: EE templates and instances, worker pins, interface descriptors, the run record. The formation path also retains the normalized descriptor bytes in the blob store; a hash of a mutable file alone is not enough for replay. Same inputs at replay, identical grant. If formation ever needs a non-deterministic input, that input must become a logged artifact first.

Policy has two consumers.

  • The runtime and the room consume it as enforcement - the boundary a run cannot cross, applied from outside.
  • The model consumes it as context - the surface it is told it has, and reasons over.

Why policy exists at all

Policy gives every run a universal context that answers exactly two questions:

  1. What can I do?
  2. What do I need to do?

Those two answers are what let a run create a sub-goal, and that sub-goal create another - each receiving a different, narrower grant. The initial root is existence. If it decides it needs a self-improvement environment and none exists, it creates one with narrower policy; that one can create narrower still.

Policy is what keeps this from collapsing. Without it, the alternative is to hand every run “you can do everything”, which produces conflict and unbounded context. Patching that with “you can do everything, but here is what is happening around you, do not conflict” is worse. The minimal, per-run, composed grant is what makes emergent goal-nesting hold together instead of degenerating.

2. The formation principle

Policy is composed by an algorithm, not stored as a flat list. This is the reason the architecture reduces everything to primitives: so policy can be assembled from them.

If Octopus had no workers and no worker environments - just “sessions” - then forming an environment’s policy would mean summing a flat list of everything that exists. Because there are primitives, forming policy is a deterministic script that composes over the EE and its nesting, the worker pin, interfaces, bindings, artifact access, and current state.

The deliverable of policy work is therefore the formation script, not a set of fields. Fields are inputs.

3. Two classes of worker policy

A worker’s policy divides into two kinds that are modeled separately. The split is static ceiling versus dynamic grant - not “enforced versus in-prompt”.

Boundary - static, in the descriptor

What this worker can do at most, written in the worker pin’s policy.json and independent of any execution context. It does not form dynamically. It is the hard frame.

  • which interfaces a worker may reach at all, including which other workers;
  • which worker-environment kinds it may use;
  • which tools it may ever hold;
  • which mark outcomes its checkpoints may close.

These do not depend on the run’s situation. They answer “is this even possible?” before any dynamic grant is computed. A run that authors other runs reads boundary so it knows what it is able to hand out.

Boundary is also the frame a self-modifying worker writes inside. When a coder authors a new worker pin, boundary tells it what it may reference: a new pin may only name room kinds that already exist. If it needs one that does not, the order is explicit - create the kind first, then reference it. Self-modification extends the system in legal steps instead of referencing phantoms.

Context - formed per run

The concrete grant for this run, composed by formation inside its execution context.

  • this web run → this specific browser room, not “browsers” in general;
  • this run → these specific workers it may reach right now;
  • the tool subset granted for this episode, always inside the ceiling;
  • access to these specific artifacts.

The formed grant is not what the model sees. It is parsed into what the model sees. The grant is handed to the bound interface inside the invocation envelope - recomputed at every arrival and attested by the kernel like the caller’s identity. The interface renders it into the prompt and the tool list. An interface with no use for it, like a text-to-speech transform, ignores it. Policy is not a prompt; the prompt is policy’s projection through whatever delivers it.

The same axis has both faces. May reach other workers is boundary; whom it may emit to right now is context. May use browser tools is boundary; this browser.click for this episode is context. Boundary answers “possible at all?”; context answers “granted now?”.

Grants pull artifacts

Forming policy is not a flat intersection of lists. Some grants pull the descriptive artifacts that make them meaningful to a model. A worker pin lists role_artifacts; formation closes that dependency graph over the worker and the exact worker interfaces that survive narrowing, keeps declared order, and pins every descriptor hash. It never auto-grants a binding: the grant fails closed unless each dependency was authored as a readable artifact binding on the checkpoint.

4. Where policy is declared

Two primitive domains anchor everything: interfaces and artifacts. The rest hangs off them.

EE template

registry/ee_template/<id>/ee_template.json - the nesting scope.

{
  "id": "project",
  "goal_class": "Carry one named project outcome inside the operator space under its narrowed policy.",
  "allowed_interfaces": null,
  "allowed_worker_environment_kinds": null,
  "allowed_child_ee_templates": ["project"],
  "bootstrap_root": false
}
  • allowed_interfaces - the interface allowance. This carries worker allowance too, since a worker is a system_worker_* interface. null leaves the axis to the enclosing layers and the ceiling.
  • allowed_worker_environment_kinds - which room kinds runs here may use.
  • allowed_tools, hard_blocked_tools - optional tool narrowing and hard denials.
  • allowed_child_ee_templates - what may be created beneath it.
  • allowed_root_slots - which host paths rooms here may be given.
  • bootstrap_root - selects the single initial seed template. Other authored parentless EEs form independent chains from their own policy.

An EE instance (state/ee_instances/<ee_id>.json) records its template, its parent, its goal text, and any further policy_narrowing.

Memory access is not part of an EE template. Memory is an artifact; access to it is an artifact binding.

Worker pin

registry/interface/system_worker_<name>/policy.json - the ceiling. A template, not a live grant; the live grant can only narrow it. See Workers.

A model is an interface, so a worker’s model access is declared through interface grants.

Run record

A run names the pin it wears and authors its bindings on its checkpoints: which interface each checkpoint awaits, where its output goes, which artifacts it reads. The record carries bindings, not policy. Hand-written fields never become rights, because the grant is recomputed by formation.

Interface

Every boundary is a declared interface descriptor, including the internal ones. The link between one worker and another is an interface. So is the door of a room. An interface’s own descriptor and code own what it accepts, what operations it supports, its transport, its auth, and its rate limits.

An interface binding may carry an artifact_policy that narrows which artifact names cross it. That is binding data enforced at the boundary; a denied name is refused as policy.interface_binding_denied.

Artifact access

Distinct from binding. Rights on the object itself: who may read, change, create, or delete it. A binding is the default flow - an artifact arrives here, leaves there. Artifact access is rights on the thing. Different axes, no overlap.

5. Composition

Policy is hierarchical and strictly narrowing inward, and the narrowing is a property of where the run lives in the EE tree - not of who created it.

A goal inside another goal has less policy than the one around it. That is the only source of “child ⊆ parent”: it follows from nesting and from nothing else.

grant = worker-interface ceiling  ∩  the EE chain the run lives in  ∩  the run's authored bindings

The ceiling is the policy.json of the pin named in run.worker. One cheap gate runs before any grant exists: that pin must be inside the interface allowance of every EE layer in the run’s chain. A run cannot lift itself above its place by claiming a pin its environment does not permit.

Most interfaces and tools a task uses are private copies. A copy declares the descriptor it was copied from (copy_of), and an allowance admits a copy by its own id or by that original; a hard block on an original reaches every declared copy. A copy admitted by its original is never wider than it: the original must exist, a worker copy’s ceiling is intersected with the original’s, and an interface copy keeps every original policy variable and its reducer. Its defaults and values may narrow the original; dropping a variable or changing its reduction rule refuses formation. Worker and EE overrides for both identities apply together. A tool copy counts as its original only while its executable, handler and schema match and its authority stays within the original’s. A copy with a contract incompatible with its original is refused; no automatic adoption rewrites it. Research-preview contract changes require a fresh Home.

Who initiated the run is not an input. A narrow initiator may legitimately create a run more capable than itself - a run with few tools can open a coding environment, and a capable coder runs inside it. There is no clamp-under-the-creator, and capability is not inherited.

The rules:

  • R1 - A run may do strictly less than its EE chain and its ceiling permit. Narrowing is by place, never by the initiator’s grant.
  • R2 - A run reads its own grant from the metadata that rides with its artifact. Formation projects the composed grant onto the invocation envelope delivered with every artifact. Nothing is precomputed for a subtree, and a wider holder does not need to know the policy of everyone beneath it.
  • Capability is granted by place and policy, not inherited. A created run neither inherits its creator’s powers nor is capped to them.
  • The narrower wins. If the EE allows X and the ceiling forbids it, X is forbidden. There is no conflict to resolve; the ceiling is a hard frame.
  • Hard-block beats subset. A hard-blocked tool is stripped even where a subset would have allowed it. An EE may hard-deny regardless of the ceiling.

The projected grant carries the goal, the surviving interfaces, tools, room kinds, and mark outcomes, the hard-blocked tools, the role artifacts, artifact access, the attached interface bindings, and a formation pin - the hashes of the worker pin and EE templates it was formed against. That pin is the exact boundary a replay re-forms from.

6. Checkpoints are the central capability

A checkpoint is an artifact crossing an interface - the arrival or the departure. Strictly that, as a general rule, not “get a response from the model” in the ordinary-agent sense. The artifact may be a model reply, an API response, or something from another run. Every such event is one kind of thing: a movement.

An artifact arrives from an API; the model must respond to it. “The model must return something” is itself a checkpoint, because it is an artifact crossing the model’s interface.

An interface binding is a checkpoint. A run wakes exactly when an artifact lands on a binding. Three faces of one primitive:

  • a run awaiting a model or API artifact - an inbound binding;
  • a run awaiting an artifact from another run - a System-interface binding;
  • one run reaching another - emitting an artifact to a System interface bound to it.

There is no separate right to create checkpoints. Spawning a worker, dispatching to an idle one, escalating to whoever created your environment, and looping to call another tool are all the same thing: a run emitting an artifact to an interface under ordinary policy. What a run may do is governed by which interfaces it may use and which artifacts it may emit or receive.

No worker is hardcoded to route to another. A run can be persistent, awaiting an artifact from any run that has policy to emit to it. Any worker may reach another, or author a run for it, if its policy grants it: authority comes from policy, not from code.

The function-calling loop follows from artifacts. One model turn is not a single synchronous step. A request artifact departs to the provider; the reply arrives as artifacts; the run enacts exactly one further movement for each, derived from the binding the interface emitted it into - a tool call through the gate, or a reply through the outbound binding. Never from a payload type. A tool call continues the turn; an outbound reply ends it. A step budget caps runaway depth as a resource limit, not as the terminal condition.

Asking for more is contained by formation and the gate.

  • Formation strips dead bindings. A binding to an interface the EE does not permit is dropped when the grant is composed. A binding cannot outlive its allowance. A binding to an interface whose folder is missing from the registry is dropped the same way: the run keeps living, and only the route through that interface is refused, as unknown_interface.
  • Emission is refused at the gate. An attempt to emit through a binding that is not in the formed grant is turned back as a typed movement - DeliveryRefused with reason policy or no_binding - not a silent drop. The refusal is itself in the ledger and replayable.

Together these make “ask for more than your place allows” a fail-closed, observable event, with no reach graph and no pre-clamped subtree.

Run-state changes follow the same shape. A run’s record is a file, and a room is a path scope: the path is the permission. To let a run re-arm, policy grants a room whose path covers that run’s own record, and the checkpoint is authored by an ordinary file-write tool call - appended by the interface’s code or, under policy, emitted by the model. The runtime is agnostic to the author. A one-shot run is one whose EE does not grant that room.

7. Run lifecycle

  • A run is continuous. Abstractly it does not start or end; it idles, parks on a checkpoint, and wakes when the awaited artifact lands.
  • For a person it is sliced by checkpoints, so a run appears to begin and end. Different clients may slice differently.
  • status is not a process-liveness flag. New operator input moves a run to running; the provider’s terminal output moves it to idle, still continuable through a checkpoint.
  • A run may be deleted when it is no longer needed for its goal. Persistence versus removal is an EE-policy decision.

8. Reaching anything is a binding

Reaching a parent for more policy, a memory worker, or any other worker is the same thing: a System-interface binding plus an artifact.

  • When an initiator creates an environment beneath it, it leaves a backward binding to itself. That is how the lower worker sends an artifact back up and asks to be widened. The creator, which already holds the wider right, decides. Widening is always done by whoever already holds the right; nothing widens itself.
  • Memory is identical. A worker that can use memory holds a binding to the artifact or to the worker that maintains it.

Everything that felt like a distinct grant - may escalate, may use memory, may dispatch worker X - reduces to one question: does this run hold a binding to that interface, and does policy permit emitting that artifact through it?

How does a creator know to leave the backward binding? Its role artifact tells it. This is role-driven foresight, not a code-level default.

9. Changing bindings

A run may edit its own bindings only through a granted file tool whose room covers its run record. The next arrival re-forms the grant: writing a binding cannot widen the worker ceiling or the EE chain. Reaching an interface still requires an authored binding that survives formation.

A run’s place is the one field ee in its record. Another run whose formed grant covers the record moves it with an ordinary file write that changes only that field; the ledger proves the edit, the run’s provider adopts it, and each arrival forms its grant in the place the record names at that moment. A run never changes its own place. The provider proves the place on every input; an edit made outside Octopus, or by the run itself, is unproven, so each turn fails with a clear error while it stands, and restoring the proven place heals the run; the failed turns leave nothing that outlives the restore. A room over run records already lets its holder create runs in any EE, so moving runs adds no new way to lift oneself; an EE’s root slots decide which runs may hold such a room.

Supported operations belong to the interface’s descriptor and code, not a kernel method vocabulary. Return and escalation paths are authored bindings; role artifacts guide their creation rather than a hidden backward route.

esc