# Factory SPEC

> Source: <https://gist.github.com/saeedvaziry/71180cae1084ebeb9d2fb5081a481946>
> Published: 2026-11-27 18:30:17+00:00

**Key takeaway:** Factory isolates each agent harness in its own VM with root and open network access, and gates only actions that leave the machine—git remotes, config and plugins—through user-defined policy.

|  | # Factory | 
|  | Factory is a desktop app for running all of one person's projects through AI agents. It does no agentic work itself: agent harnesses such as Claude Code do the work inside isolated machines, and Factory is the interface, the organiser and the gatekeeper around them. | 
|  | "Factory" is a working name. | 
|  | ## Principles | 
|  | - The core is small. Every feature outside the core is a plugin, including the ones that ship with the app. | 
|  | - Agents never run on the host by default. They run in machines. | 
|  | - A machine is the agent's own. Factory does not restrict what an agent does inside it. | 
|  | - Gates sit only where work leaves a machine: the user's git remotes, the app's configuration, plugins. | 
|  | - Everything the app can do is an action. The user, flows and agents all call the same actions. | 
|  | - The user decides which actions need their approval and which agents may perform alone. | 
|  | - Configuration is plain files that the user and agents can read. Agents change them through actions. | 
|  | - Version 1 is built for one user on macOS. It stays clean enough to open source later. | 
|  | ## Trust model | 
|  | Factory trusts agents to do their work. It guards against accidents, not against a hostile agent. | 
|  | \| Inside a machine, an agent has \| Outside a machine, an agent has \| | 
|  | \|---\|---\| | 
|  | \| Root \| No access to the host's files or processes \| | 
|  | \| Open outbound network \| Only actions, each decided by policy \| | 
|  | \| The harness without permission prompts \| \| | 
|  | \| The project code, the workspace's secrets and the harness credential \| \| | 
|  | - Roles separate duties. Two sessions in one machine are not walled off from each other. | 
|  | - Nothing stops an agent from sending what is in its machine over the network. | 
|  | ## Stack | 
|  | \| Part \| Choice \| | 
|  | \|---\|---\| | 
|  | \| Shell \| Tauri: Rust core, web UI \| | 
|  | \| Plugin logic \| JavaScript in an engine embedded in the core (QuickJS) \| | 
|  | \| Plugin UI \| Web views in frames that cannot reach the core directly \| | 
|  | \| Runtime state \| SQLite \| | 
|  | \| Configuration \| Files under `~/Factory` \| | 
|  | \| Local VMs \| Bundled `svm`, with its own `SVM_HOME`, `SVM_CACHE` and `SVM_RUNTIME` \| | 
|  | \| In each machine \| The guest agent, one Linux binary \| | 
|  | \| Process model \| One process that stays in the menu bar \| | 
|  | \| Outside control \| A local socket and a `factory` CLI on the host \| | 
|  | ## Model | 
|  | ``` | 
|  | Workspace | 
|  | ├─ Projects git repos or plain folders | 
|  | ├─ Image base machine for this workspace | 
|  | ├─ Flows | 
|  | ├─ Policy | 
|  | ├─ Secrets | 
|  | └─ Tasks | 
|  | └─ Task one run of a task flow, in one machine | 
|  | └─ Sessions | 
|  | ``` | 
|  | \| Thing \| Meaning \| | 
|  | \|---\|---\| | 
|  | \| Workspace \| What the user maintains: a product, a client, an initiative. Workspaces do not know about each other. \| | 
|  | \| Project \| One source inside a workspace: a git repo, a subpath of a repo, or a plain folder. A workspace has zero or more. \| | 
|  | \| Image \| The prepared base machine of a workspace: tools, dependencies and harness binaries. \| | 
|  | \| Task \| One unit of work. It is one run of a task flow. It sees all projects of its workspace unless narrowed. \| | 
|  | \| Session \| One harness run inside a machine. \| | 
|  | \| Machine \| Where sessions run. \| | 
|  | \| Flow \| A file of steps. \| | 
|  | \| Action \| A named operation, such as `task.create` or `git.push`. \| | 
|  | \| Policy \| Rules that decide whether a caller may perform an action. \| | 
|  | \| Secret \| A named value of a workspace, given to its machines as an environment variable. Agents in those machines can read it. \| | 
|  | \| Plugin \| A folder that adds actions, adapters, providers, views, triggers or themes. \| | 
|  | - The same repo can be added to several workspaces. Each workspace treats it as its own project. | 
|  | - A subpath sets where the agent starts. It is not a boundary: the whole repo is in the machine. | 
|  | - A workspace with one project shows as a single level in the UI. | 
|  | ### Task states | 
|  | \| State \| Meaning \| | 
|  | \|---\|---\| | 
|  | \| `open` \| Created, not started \| | 
|  | \| `queued` \| Ready to start, waiting for a free machine \| | 
|  | \| `working` \| At least one session is running \| | 
|  | \| `waiting` \| No session is running and a session or an action waits for the user \| | 
|  | \| `review` \| The work is fetched to the host and not yet approved \| | 
|  | \| `done` \| The task flow finished \| | 
|  | \| `failed` \| A step failed and the user has not retried or discarded \| | 
|  | \| `discarded` \| Closed without delivery \| | 
|  | - On `svm`, a task's machine is deleted at `done` and `discarded`. | 
|  | - On `svm`, a task's machine is stopped in `review`, and in `waiting` after an idle timeout. Sessions resume when the machine starts again. | 
|  | - A closed task can be reopened: a new machine from the image, the task branch from the mirror, and the saved harness state. | 
|  | - Each task has an `out` folder on the host for results that are not code. It is kept after the machine is deleted. | 
|  | ## Machines | 
|  | \| Provider \| Machine \| Per task \| Agent can reach the user's Mac \| | 
|  | \|---\|---\|---\|---\| | 
|  | \| `svm` \| Local Linux VM \| A fresh machine from the workspace image \| No \| | 
|  | \| `ssh` \| A remote host the user provides \| A directory on that host \| No \| | 
|  | \| `host` \| The user's Mac \| A git worktree \| Yes \| | 
|  | - `svm` guests are Linux only. Work that needs macOS, such as Xcode builds, uses the `host` provider or a remote Mac over `ssh`. | 
|  | - An `ssh` machine is long-lived and shared by its tasks. Factory creates and deletes nothing on it except task directories. Images do not apply. | 
|  | - On the `host` provider policy is not enforced: an agent on the Mac can act as the user. | 
|  | - A workspace uses the `host` provider only when its `workspace.toml` says so. | 
|  | - CPU, memory and disk per `svm` machine are set in `workspace.toml`. `config.toml` caps how many machines run at once. | 
|  | ### Images | 
|  | - A workspace image is built from a setup script in the workspace folder and saved with `svm image save`. | 
|  | - An image is named by the hash of its setup script. A changed script builds a new image. | 
|  | - A task keeps the image it started with. Images that no task uses are deleted. | 
|  | - A task machine is created with `svm create <image>`, then `svm start` and `svm wait`. | 
|  | ### Guest agent | 
|  | Every machine runs the guest agent. It has three jobs: | 
|  | \| Job \| Detail \| | 
|  | \|---\|---\| | 
|  | \| Supervise sessions \| It starts the harness and records its events to a log. Sessions keep running when the app quits. The app replays the log when it reconnects. \| | 
|  | \| Carry the action channel \| It listens inside the machine only. The host connects to it with `svm tunnel`, or an SSH port forward on `ssh` machines. \| | 
|  | \| Serve agents \| It provides the `factory` CLI and an MCP server inside the machine. \| | 
|  | ## Code in and out | 
|  | - Inside Factory every project is a git repo. A folder project gets a repo that Factory manages. | 
|  | - Factory keeps a bare mirror of each project under `~/Factory/mirrors`. The mirror fetches from the project's source when a task starts. | 
|  | - The host pushes the base branch from the mirror into the machine. The agent commits to a task branch. | 
|  | - Before review, the guest agent commits any uncommitted changes. The host then fetches the task branch into the mirror. | 
|  | - Machines hold no credentials for git remotes unless the user adds one as a secret. Pushing to a remote and opening or merging a pull request are host actions that go through policy. | 
|  | - An approval covers one commit. A newer commit on the task branch needs a new approval. | 
|  | - Delivery for a folder project copies the approved commit's files into the folder. | 
|  | - A `host` task works in a git worktree under `~/Factory/work`. | 
|  | ## Harnesses | 
|  | A harness adapter is a plugin. Each adapter can: | 
|  | \| Capability \| Meaning \| | 
|  | \|---\|---\| | 
|  | \| Detect and install \| Find or install the harness binary inside a machine \| | 
|  | \| Start, resume, stop \| Control a session \| | 
|  | \| Send \| Deliver a prompt or an answer to a session \| | 
|  | \| Stream events \| Report messages, tool calls, waiting for input, finished, failed \| | 
|  | \| Terminal \| Run the harness's own TUI \| | 
|  | Rules for every adapter: | 
|  | - It drives the unmodified harness binary. | 
|  | - The harness uses the user's own login. Factory does not bundle harness binaries. | 
|  | - A session runs in one mode, structured or terminal. Switching mode stops the session and resumes it in the other mode. | 
|  | - In terminal mode the adapter learns the session's state from the harness's hooks. | 
|  | - Inside an `svm` or `ssh` machine the harness runs without its own permission prompts. The machine is the sandbox. | 
|  | - The user keeps one template folder per harness in `~/Factory/harness`: settings, skills, plugins, instructions. | 
|  | - Each machine gets its own harness config directory, copied from the template and kept on the host. A task machine's directory is kept with the task. No two machines write to the same one. | 
|  | The user logs in to a harness once. How that credential reaches each machine is decided by the first build spike. | 
|  | \| Harness \| Structured mode \| Version 1 \| | 
|  | \|---\|---\|---\| | 
|  | \| Codex \| `codex app-server` \| Yes, built first \| | 
|  | \| Claude Code \| `claude -p` with stream-json input and output \| Yes \| | 
|  | ## Actions, policy, inbox and activity | 
|  | ### Actions | 
|  | - Every operation is an action in one registry. Plugins register their own. | 
|  | - Buttons, the CLI, flow steps and agents call the same actions. | 
|  | - An action that must wait for the user returns a pending ID at once. Its result reaches the calling session later as a new message, and a calling flow run pauses until then. | 
|  | ### Callers | 
|  | \| Caller \| Who \| | 
|  | \|---\|---\| | 
|  | \| `user` \| The person at the app or the host CLI \| | 
|  | \| `flow` \| A flow started by the user, a schedule or an event \| | 
|  | \| `operator` \| The agent behind the chat \| | 
|  | \| `worker` \| An agent doing a task \| | 
|  | \| `reviewer` \| An agent reviewing a task \| | 
|  | - Custom agent roles are allowed. | 
|  | - The host gives each session a token that fixes its role and workspace. The token names the caller of every action the session calls. | 
|  | - A role is assigned by the user or by a flow step. | 
|  | - A flow started by an agent runs its steps as that agent, not as `flow`. | 
|  | ### Outcomes | 
|  | \| Outcome \| Effect \| | 
|  | \|---\|---\| | 
|  | \| `allow` \| The action runs \| | 
|  | \| `notify` \| The action runs and is flagged in the inbox for the user to look at afterwards \| | 
|  | \| `ask` \| The action waits in the inbox until the user approves or rejects \| | 
|  | \| `deny` \| The action fails \| | 
|  | ### Rules | 
|  | ``` toml | 
|  | [[rule]] | 
|  | action = "git.push" | 
|  | caller = "flow" | 
|  | when = "approved && !protected_branch" | 
|  | outcome = "allow" | 
|  | ``` | 
|  | - A rule matches on action, caller and an optional `when` condition. | 
|  | - `when` reads facts the host works out itself. It never reads what the caller claims. A fact that cannot be worked out makes the rule not match. | 
|  | \| Fact \| Meaning \| | 
|  | \|---\|---\| | 
|  | \| `branch` \| The resolved branch the action touches \| | 
|  | \| `commit` \| The commit the action touches \| | 
|  | \| `changed_paths` \| Paths the commit changes against the base \| | 
|  | \| `protected_branch` \| Whether the branch is protected \| | 
|  | \| `approved` \| Whether the commit is approved \| | 
|  | \| `verdict` \| The reviewer's verdict on the task \| | 
|  | \| `external_text` \| Whether the input contains text from outside, such as a GitHub issue \| | 
|  | \| `unfetched_work` \| Whether the machine has work not yet fetched to the host \| | 
|  | \| `workspace`, `task` \| Where the call applies \| | 
|  | - Rules exist in four layers: global, workspace, flow, task. A `deny` in any layer wins. Otherwise the nearest layer with a matching rule wins. | 
|  | - An action with no matching rule gets `ask`. | 
|  | - A `policy.toml` that cannot be read makes every action its layer covers `ask`, and adds an inbox item naming the file and the error. A broken file never widens rights. | 
|  | - Policy decides calls by flows and agents. A call by `user` always runs; the UI confirms the ones that cannot be undone, such as a merge. | 
|  | - Rules are stored in `policy.toml` files. The user rarely edits them by hand: | 
|  | - Answering an inbox item offers a scope: once, this task, this flow, this workspace. Any scope other than once shows the exact rule, then writes it. | 
|  | - A task or flow can use a preset, a named rule set. Factory ships `supervised` (the default) and `autonomous`. | 
|  | - The user can ask the operator to propose a policy change. | 
|  | ### Protected actions | 
|  | Two actions are always `ask` for every caller other than `user`. No rule, preset or scoped answer loosens them: | 
|  | - `policy.set`, which includes choosing a preset. An agent cannot widen its own rights. | 
|  | - `plugin.install`. Plugin code runs on the host. | 
|  | Answering an inbox item is possible only for `user`, from the core window. | 
|  | Every other action can be set to `allow` by the user. | 
|  | ### Default policy (`supervised`) | 
|  | \| Action \| Outcome for flows and agents \| | 
|  | \|---\|---\| | 
|  | \| Anything inside a machine \| `allow` \| | 
|  | \| `task.create` \| `allow`; `notify` when the prompt contains text from outside, such as a GitHub issue \| | 
|  | \| `task.approve` \| `ask` \| | 
|  | \| `git.push` of an approved commit to an unprotected branch \| `allow` \| | 
|  | \| `github.pr.open` for an approved commit \| `allow` \| | 
|  | \| `github.pr.merge`, and any push to a protected branch \| `ask` \| | 
|  | \| `machine.delete` on a machine with unfetched work \| `ask` \| | 
|  | \| Writing a flow file, a `workspace.toml`, an image setup script or a secret \| `ask` \| | 
|  | ### Inbox and activity | 
|  | - Every action call is recorded as an event: time, caller, action, parameters, outcome, result. Parameters marked secret are not stored. | 
|  | - Activity shows all events, filtered by workspace, task or caller. | 
|  | - The inbox shows events that wait for the user (`ask`), events flagged for a later look (` notify`), sessions that wait for input, and problems that stop work until the user acts, such as a harness logged out, `svm` not responding or a plugin that failed to load. | 
|  | - The inbox is the only place the app waits on the user. | 
|  | ## Operator | 
|  | - The operator is the agent behind the chat. It is a normal harness session. | 
|  | - It runs in one operator machine that starts on first use and stops when idle. | 
|  | - The operator machine holds no project code. | 
|  | - The operator's only power is calling actions. Its calls go through policy as caller `operator`. | 
|  | - The operator can call actions on all workspaces. A chat opened inside a workspace starts with that workspace as context; it is not a boundary. | 
|  | - Work that needs code becomes a task. | 
|  | ## Flows | 
|  | A flow is a YAML file in `~/Factory/flows` or in a workspace's `flows` folder. | 
|  | ``` yaml | 
|  | # flows/task.yaml: the default task flow | 
|  | steps: | 
|  | - machine.create | 
|  | - code.push_in | 
|  | - session.run: { role: worker } | 
|  | - code.fetch | 
|  | - task.review: { harness: codex, max_rounds: 3 } | 
|  | - task.approve | 
|  | - git.push | 
|  | - github.pr.open | 
|  | - machine.delete | 
|  | ``` | 
|  | ``` yaml | 
|  | # flows/fix-issue.yaml | 
|  | on: github.issue.labeled | 
|  | steps: | 
|  | - task.create: { projects: [cli], harness: claude-code, prompt: "Fix issue {{issue.number}}" } | 
|  | ``` | 
|  | - A step is an action call. | 
|  | - A run has a context: its workspace, and its task when it is a task flow. A step takes any parameter it is not given from the context and from the results of earlier steps. | 
|  | - `task.create` starts a task flow and returns the task ID at once. `flow:` names the task flow; the default is `task`. Another flow waits for a task with `task.wait`. | 
|  | - The run's state is saved after every step. A run continues after the app restarts. | 
|  | - A failed step sets the task to `failed` and adds an inbox item with three choices: retry, skip, discard. A step that covers several projects retries only the projects that failed. | 
|  | - Triggers are manual, a schedule, or an event. Events from outside services are polled. Each event has an ID and starts a flow once. | 
|  | - Schedules and polling run only while Factory is running. | 
|  | ### Review | 
|  | - `task.review` runs a second session in the task's machine with the role `reviewer`. | 
|  | - The reviewer reports a verdict, approved or rejected, with comments. | 
|  | - A rejection sends the comments to the worker, and the review repeats on the new commit. After `max_rounds` rejections the task goes to the inbox. | 
|  | - `task.approve` is the gate. With the default policy it waits for the user in Diff review. | 
|  | - A rule lets an approved verdict pass the gate without the user: | 
|  | ``` toml | 
|  | [[rule]] | 
|  | action = "task.approve" | 
|  | caller = "flow" | 
|  | when = "verdict == 'approved'" | 
|  | outcome = "allow" | 
|  | ``` | 
|  | ## Plugins | 
|  | A plugin is a folder: | 
|  | ``` | 
|  | my-plugin/ | 
|  | plugin.toml name, version, what it contributes | 
|  | main.js optional logic, runs in the core's JS engine | 
|  | ui/ optional web views | 
|  | themes/ optional theme files | 
|  | ``` | 
|  | \| A plugin can add \| Example \| | 
|  | \|---\|---\| | 
|  | \| Actions \| `github.pr.open` \| | 
|  | \| Flow triggers \| `github.issue.labeled` \| | 
|  | \| Harness adapters \| Claude Code \| | 
|  | \| Machine providers \| `svm` \| | 
|  | \| Views \| A sidebar panel, a task tab, a workspace tab \| | 
|  | \| Settings \| A GitHub token \| | 
|  | \| Themes \| Nord, in a light and a dark mode \| | 
|  | - Plugin logic uses a host API for processes on a machine or the host, files, HTTP, storage, events and actions. | 
|  | - Factory loads plugins only from `~/Factory/plugins`. Only `plugin.install` writes there. | 
|  | - `plugin.install` installs one commit of a plugin's source repo. An update to an installed plugin is another `plugin.install`. | 
|  | - Installing loads or reloads the plugin without restarting the app. | 
|  | - Plugin logic is not sandboxed in version 1. | 
|  | - Plugin views, and all content written by agents (notes, messages, diffs), render in frames that have no access to the core. A plugin view reaches its own plugin's actions only. | 
|  | - Built-in plugins ship inside the app and use the same API. | 
|  | ### Themes | 
|  | - A theme is a file of colours with a table per mode, light and dark. A theme with one mode uses it in both. | 
|  | - Its keys are the colour tokens of the design (`design/tokens.css`). Its values are colours only. A theme cannot change sizes, fonts or layout, and cannot hide anything. | 
|  | - The core checks a theme's contrast before applying it: text on buttons, state text on its tinted background, and muted text must reach 4.5:1. A theme that fails is refused, naming the pair. | 
|  | - A token a theme does not set takes the value of Ink, the default theme, which is part of the core. | 
|  | - A theme can give the sidebar and the status bar colours of their own. | 
|  | - The core turns the chosen theme into CSS variables for its window and sends the same values to every plugin view. Changing the theme or the mode applies at once. | 
|  | - The theme and the mode (light, dark or the system's) are settings. When a theme's plugin is removed, the app uses Ink. | 
|  | ### Built-in plugins in version 1 | 
|  | \| Plugin \| Purpose \| | 
|  | \|---\|---\| | 
|  | \| `svm`, `ssh`, `host` \| Machine providers \| | 
|  | \| `claude-code`, `codex` \| Harness adapters \| | 
|  | \| Terminal \| A terminal on any machine \| | 
|  | \| Chat \| The operator chat and session views \| | 
|  | \| Diff review \| What a task changed per project, comments back to the worker, approve or discard \| | 
|  | \| Task board \| Tasks per workspace with their state \| | 
|  | \| GitHub \| Issues to tasks, pull requests from tasks, pull request and CI status \| | 
|  | \| Notes \| Markdown notes per workspace that agents read and write through actions \| | 
|  | \| Themes \| macOS, Paper, Nord, Midnight, Plum and Graphite \| | 
|  | ### Extending Factory with itself | 
|  | - Factory ships a workspace named `factory-plugins`. Its project is `~/Factory/plugin-src`, a git repo of plugin sources. | 
|  | - Its image holds the plugin API types and documentation. | 
|  | - An agent writes or changes a plugin as a normal task in a machine. | 
|  | - The user reviews the diff. `plugin.install` then installs the approved commit. | 
|  | ## Files | 
|  | ``` | 
|  | ~/Factory/ | 
|  | config.toml | 
|  | policy.toml | 
|  | flows/ | 
|  | plugins/ installed plugins, written only by plugin.install | 
|  | plugin-src/ plugin sources, a git repo | 
|  | harness/<name>/ the user's template per harness | 
|  | operator.md the operator's instructions | 
|  | machines/<name>/harness/ harness config directory of a machine that is not a task's | 
|  | mirrors/ bare git mirrors | 
|  | work/ worktrees of host tasks | 
|  | tasks/<id>/ | 
|  | out/ results that are not code | 
|  | harness/ the task's harness config directory | 
|  | svm/ svm home, cache and runtime | 
|  | state.db tasks, sessions, flow runs, events | 
|  | workspaces/<name>/ | 
|  | workspace.toml projects, machine provider and size, image setup | 
|  | policy.toml | 
|  | flows/ | 
|  | notes/ | 
|  | ``` | 
|  | ## Build order | 
|  | \| Step \| Contents \| | 
|  | \|---\|---\| | 
|  | \| 0. Design \| Every screen and state of the app, settled in `design/` before any code \| | 
|  | \| 1. One slice, hard-coded \| `svm`, the guest agent, Codex, actions, the operator chat, one task, Diff review, a push that asks \| | 
|  | \| 2. The core mechanisms \| Policy, inbox, flows, with the slice rebuilt on them \| | 
|  | \| 3. The plugin API \| Extracted from what steps 1 and 2 needed; the slice's parts become built-in plugins \| | 
|  | \| 4. The rest of version 1 \| Claude Code, GitHub, Task board, Notes, `ssh` and `host` providers, `factory-plugins` \| | 
|  | ## Not in version 1 | 
|  | - Restricting what a machine can do: network allowlists, limits on root | 
|  | - Plugin sandboxing and a plugin registry | 
|  | - Linux and Windows builds of the app | 
|  | - A headless daemon, remote clients and mobile clients | 
|  | - Accounts, teams and sharing | 
|  | - Harness adapters other than Claude Code and Codex |
