Access from other computers
By default the Foundry answers only on the Mac it runs on. Colleagues can reach it from their own
computers when you set three things in the Network section of the Settings page (Administration → Settings), or in config.yaml:

server:
listen: 127.0.0.1 # 127.0.0.1 (default), ::1, 0.0.0.0 or ::
allowed_hosts: [mymac.local] # names people type; a port is optional
allow_insecure_http: false # true: also accept plain HTTP from other computers
public_url: https://mymac.example.com # optional; links in notifications and issue comments
memory_limit_mb: 2048 # restart at a safe moment when memory stays above this; 0 turns it off
listenis the address the server binds.0.0.0.0and::answer on every network; the other two only on this Mac. Only these four values are allowed. A change needs a restart.allowed_hostsreplaces the old fixed localhost check.localhost,127.0.0.1and[::1](with the server port) always work. Any otherHostheader must be listed, else the answer is403 forbidden host. A change applies at once.allow_insecure_httpis off by default. A change applies at once.memory_limit_mb(default 2048, 0 turns it off) is the server's memory limit in MB. The server samples its own memory every minute and keeps the last 60 samples. When three samples in a row are above the limit, it saves the newest 12 tomemory-growth.jsonin the data folder, asks for a restart at a safe moment, and the monitor files one bug story with the samples (thememory-growthfinding). The same growth files no second story. When the memory crosses the limit, the server log also writes onehealth:line with the heap, the memory outside the heap and the buffers, so you can tell which part grows. A change applies at once.public_urlis the https address people use to reach the Foundry, for example the one of your HTTPS proxy. It is optional and empty by default. The Foundry uses it for the links in macOS and Slack notifications and in its comments on issues (the Where: line of the status comment and the Run: line of a failure comment), so they open from another device. Only a plain address is accepted:https://with a host name, no user, password,?or#; anything else is refused when you save. The field is in the Network section as Public address. A change applies at the next check or notification. A comment that was already posted keeps its link until the status comment is next edited.
The safe way: HTTPS through Caddy on the Mac. The Foundry has no TLS of its own. A proxy on the
same Mac does the HTTPS and talks to the Foundry on 127.0.0.1.
- Keep
listen: 127.0.0.1. Add the Mac's name to the allowed host names. Use the local host name from System Settings → General → Sharing, for examplemymac.local. Colleagues must be able to resolve that name (macOS does it on the same network; other systems may need a DNS or hosts entry). - Install Caddy:
brew install caddy. - Write the Caddyfile. Homebrew's service reads
$(brew --prefix)/etc/Caddyfile:mymac.local { tls internal reverse_proxy 127.0.0.1:4777 } - Start it:
brew services start caddy(it starts again at login). After a change:brew services restart caddy. To try it once in a terminal:caddy run --config <file>. - Trust the certificate on the Mac itself:
caddy trust. - Give your colleagues Caddy's root certificate,
root.crt. Caddy keeps it in its data folder, by default~/Library/Application Support/Caddy/pki/authorities/local/root.crtwhen it runs as your user. Check that the file exists on your Mac. On macOS, open it with Keychain Access, add it to System, then set it to Always Trust. On Windows, import it into Trusted Root Certification Authorities. Firefox has its own certificate store. - Check it:
curl --cacert root.crt -sI https://mymac.local/shows200andstrict-transport-security.curl -s -H 'Host: mymac.local' http://127.0.0.1:4777/answersHTTPS required.
What any proxy must do.
- Run on the same Mac and connect to
127.0.0.1:<port>. The Foundry believes forwarded headers only from a connection that comes from this Mac. - Pass the
Hostheader unchanged, with its port. - Set
X-Forwarded-Protoitself from the real connection (overwrite what the client sent, never pass it on) and sendX-Forwarded-For. - Not buffer responses (the run log is a stream).
Caddy does all of this by default. For nginx use proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_buffering off; ($host drops the port, so use $http_host). A proxy that rewrites Host to
127.0.0.1:4777 and sends no forwarded headers makes remote requests look local; do not use one.
Plain HTTP on a trusted network. Set listen: 0.0.0.0, add the Mac's name or address to the
allowed host names and switch on allow_insecure_http. Warning: passwords and session cookies
then cross the network unencrypted. Use it only on a network you trust.
What the server does.
- Over HTTPS (through the proxy) the session cookie is
Secureand responses carryStrict-Transport-Security(one year). - Every response carries a strict
Content-Security-Policy(only this server's own scripts and styles) andX-Content-Type-Options: nosniff. - A change (POST, PUT, DELETE) with an
Originheader must come from exactly the address you used: same scheme, name and port. - Requests from other computers are refused with
HTTPS requiredunless they come through the proxy over HTTPS, orallow_insecure_httpis on. - The server does not start on
0.0.0.0or::until an admin account exists. - The first admin can only be created on the Mac itself, not through the proxy.
- Settings cannot be saved if the change would lock out the browser that saves it (its host name
removed, or a
listenvalue that does not cover the address it is connected to). - Sign-in and set-password also wait per client address (from the 5th wrong try, up to 60 seconds; see "Wrong passwords" in Settings and safety) and run at most 16 password checks at the same time; an e-mail longer than 254 characters is a wrong sign-in.
Restart after changing the address: stop and start scf ui, or run scf service install again.
Do not mix HTTPS and plain HTTP on one host name: HSTS makes browsers refuse HTTP for that name for a year.
A user account can only do what "Roles and permissions" above allows, but a run can
still run commands on this Mac, so only give accounts to people you trust. Links
in Slack and notifications still point at http://localhost:<port>.
Claude token in the Keychain. Claude steps sign in by a token. To keep it across a restart or a logout, without launchctl setenv, store it once in the macOS Keychain:
scf auth set-token # asks for the token on a terminal, or reads its first line from stdin
scf auth status # prints source: environment, keychain or none, and set: <time> (never the value)
scf auth clear-token # removes the item
set-token takes no operand or option; anything else is refused before it reads the token. The item is a generic password, service spaghetti-code-foundry, account claude-oauth-token. The token must be 8 to 4096 characters with no spaces or control characters. The server reads it at start and at each Claude step on anthropic, which gets it as CLAUDE_CODE_OAUTH_TOKEN. If CLAUDE_CODE_OAUTH_TOKEN, ANTHROPIC_API_KEY or ANTHROPIC_AUTH_TOKEN is set, that one wins and nothing changes. Codex and other providers never get this token. Each set and clear writes one audit line without the value. Steps of your runs can read the token through the agent's shell tool, so keep it for accounts you trust.
When the AI sign-in is missing. Claude steps need a token, or Claude Code's own login on this Mac (claude /login). When neither works, the Foundry does not fail the runs. AI jobs wait in the queue, shell-only flows still run, and Your turn shows one item for admins, AI sign-in: "The Foundry has no AI sign-in", with the two steps claude setup-token, then scf auth set-token. Every run that stopped on the sign-in is listed under that one item. A user's own waiting run says "waiting for the sign-in" and shows no steps; an admin must set the token. The sign-in is treated as missing only when no token and no key variable is set, and Claude Code's start check says it is signed out, or a step stopped on a sign-in error (Failed to refresh OAuth token, can't save to the Keychain, OAuth token has expired). An install that works with Claude Code's own login is not held. A sign-in error from a user's run stops only that run and does not hold the queue for everyone.
Once a token is set, in this process or another (for example scf auth set-token in a terminal), the held jobs start by themselves within about 30 seconds, and runs that stopped on the sign-in resume: runs of an issues watcher at its next check, runs started by hand within about a minute. You do not restart the server.
Stored credentials. A token or an ssh key can be stored through the API
(POST /api/credentials); you cannot add one in the web interface, and runs do not use them yet.
An admin can see them on the Credentials page (Administration → Credentials under People and access):
owner, provider, identity, scope, fingerprint, created and last used, never the secret. They are kept in
credentials.json in the data folder (mode 0600), encrypted with AES-256-GCM. The key is not in
the data folder: it is in the macOS Keychain, as an item of the service
claude-factory-credential-key. Only macOS is supported. The token or deploy key of a repository is stored here
too, as repo:<repository id>; your own names must not start with repo:. The public key of a deploy key
is not a secret: /api/repos always shows it in full, even when a stored secret is part of it (the rest of
the answer is hidden as before).
- What the API shows. Only type, name, created, last used and the fingerprint, never the
secret. A token must be 8 to 4096 printable ASCII characters on one line. To check a fingerprint:
printf %s "$TOKEN" | shasum -a 256, the first 16 digits. - Redaction. A stored secret is replaced by
[redacted]in step output, logs, transcripts, errors and API answers. Limits: text written before a credential was saved stays on disk (the API hides it), the task text and other encodings (such as base64 ofuser:token) are not matched. If credentials exist and the Keychain is locked or the key is gone, runs fail before they start and the API shows nothing until that is fixed. - Deleting. Deleting a credential or a user (
scf user delete) replaces the key, so older copies ofcredentials.jsonare useless.scf credential rotate-keydoes the same on demand. - Who can read the key. Anyone who runs commands as your macOS user, flow steps included. The encryption protects copies of the data folder: backups, sync, another user.
Global settings are stored in ~/.spaghetti-code-foundry/config.yaml; runs in ~/.spaghetti-code-foundry/runs/, and old runs that housekeeping has moved in ~/.spaghetti-code-foundry/runs-archive/ (see "Old runs move to runs-archive/" in chapter 4).
Workspaces#
A workspace is a team. Each repository, each watcher's runs and each run is recorded as belonging to exactly
one workspace. There is always a default workspace, so an install without any workspace works and stores
its data as before. List the teams in config.yaml:
workspaces:
- id: team-api # lowercase letters, digits and "-"; "default" is reserved
name: API team
members: # account ids
- "6f1c2a3e-0000-4000-8000-000000000001"
limits: # all optional
max_concurrent: 2
test_slots: 1
monthly_budget_usd: 150
hosts: # optional: extra hosts a team's shell steps may reach
- "api.example.com"
- Team runs are held. A run of any workspace but
defaultis held apart from the rest of the machine:- its steps always run in the operating-system sandbox;
sandbox.user_runsandsandbox.user_readdo not apply to it. If the computer cannot sandbox a step, the run is refused before any step starts; - its agents reach only their model host; its shell steps reach GitHub, the package registries and the
hostsbelow. A host that is not allowed is refused, and the step log names it; - it never uses the machine's GitHub login, and it needs a commit identity;
inplaceandworktreeflows are refused, because they work in the server's own folder.- Known gap: a team's agent does not yet get a key from its workspace, so set its agent key in the usual way for now.
- its steps always run in the operating-system sandbox;
hosts. Each entry is a host name (api.example.com), a host name with a port (api.example.com:8443) or*.example.comfor subdomains. Up to 100 entries. IP addresses are refused. Port 443 is used when no port is given.- Limits. Each limit holds for the workspace only:
max_concurrent: no new job of the workspace starts while it has that many running. The account limits still apply on top.monthly_budget_usd: no new run of the workspace starts once the cost of its runs this calendar month (UTC) reaches the limit. The run waits with "waiting — the workspace's monthly budget" and starts again in the next month. This limit is not checked whencost_limitsis off.test_slots: the test runs of the workspace never use more test slots at once than this. The machine-wide total still applies.- A workspace without limits, and the
defaultworkspace, work as before.
- Fair turns. When two or more workspaces have stories waiting, a free slot goes to the workspace that started a story least recently. Inside a workspace the order is unchanged: bugs first, then priority, then account fairness.
- An account that is in no workspace is in
default. An account may be in several workspaces. - An admin sets the workspace of a repository with
PUT /api/admin/repos/:id/workspace({ "workspace": "team-api" }, ornullfordefault). A transfer to another account keeps it. A repository without one is indefault. - A run takes the workspace of its repository; a run without a repository (a local run) is in
default. Usage events carry the workspace. - A user sees only the repositories, watchers' runs, runs and refinement sessions of their own workspaces. A
team member does not see
default, and an account in no team seesdefaultonly. An object of another workspace answers404, as an unknown id does; lists, search, the board and the usage view leave it out. An admin sees all workspaces. A user cannot start a change on a repository outside their workspaces. - An invalid entry, or a second entry with the same id, stops the config from being read. A plugin can supply
the list instead (
api.workspaces, see PLUGIN_API.md). - The Settings page does not show the list; edit it in
config.yaml.
Where the files go. The default workspace keeps its runs in runs/ and its area locks in locks/ under
the data folder, as before. Each other workspace keeps its runs in workspaces/<id>/runs/ and its locks in
workspaces/<id>/locks/. Nothing is moved when you add a workspace; the Foundry finds runs in runs/ first,
then in each workspace folder. A run's steps can only write to their own workspace's lock folder, and the
sandbox denies every runs folder.
Skills of a workspace. Each workspace other than default has its own administrator skills folder, <data folder>/workspaces/<id>/skills/, with the same layout as <data folder>/skills/. A run of the workspace takes its administrator skills only from that folder, so a team's skills are used only by its runs. The default workspace uses <data folder>/skills/, and a team workspace does not see it. The other skill sources (approved releases, skills.roots, the built-in skills and the repository) are the same for every workspace, and so are the pins and the skill lifecycle. The Skills section of a run (under Details) shows the skills of that run's workspace. To list a team's skills, use scf skills --workspace <id>; scf skills pin <id@version> <digest> --workspace <id> takes the package from that folder. --workspace with an id that is not valid is refused.
A workspace removed from config.yaml. Its runs stay listed and readable, but it becomes read-only: a new
run or a resume in it fails with WORKSPACE_REMOVED, and answers, parking and archiving are refused. Cancelling
a run still works, and scf clean can still remove its old runs. Put the workspace back in the list to use it again.
Plugins#
A plugin adds behaviour to the Foundry without a change to its code. List them in config.yaml:
plugins:
- module: "@your-org/scf-plugin-slack" # a package name, or an absolute path
options: { channel: "#factory" } # any map; the plugin gets it as api.options
- module: /opt/scf/plugins/audit.mjs
- When they load. Once, when the server starts, in the order listed, before the queue and the
watchers start. A plugin that cannot be found or imported, has no
register, throws, or does not finishregisterwithin 30 seconds stops the start. The message names the plugin. Nothing runs half-started. A change needs a restart. - What
registergets.register(api)(sync or async) receivesapi.version(the plugin API version,0.2) andapi.options. A plugin can also get the usage events withapi.onUsage. A plugin that does not support this version can throw with a message; that stops the start like any other failure. See PLUGIN_API.md. - What is refused. A relative path, a URL, a built-in Node module, and a module inside a runs folder or a repository the Foundry works on. At most 20 plugins; no name twice.
- Where they are set. In
config.yamlonly. The Plugins card on the Settings page shows them read-only.PUT /api/configrefuses apluginskey, and a save from the Settings page keeps the stored list. - Checking.
scf pluginslists the loaded plugins in order, with their version, their module and what each registered. It needs a running, signed-in server (admin);GET /api/pluginsis the same list. The health line shows a plugin problem whenconfig.yamllists other plugins than the ones loaded (restart the server), or when the file cannot be read. - Without
pluginsnothing changes: no plugin loads and the health line has no plugin entry.
Plugin pages, menu items and settings#
A plugin can also add to the web interface. In register(api) it calls api.ui(spec) once (see
PLUGIN_API.md):
- Pages. Each page is an ES module in the plugin's folder. It is served at
/plugins/<name>/<file>and opens at#/plugins/<name>/<page>inside the normal layout. The<name>is the plugin's label in lower case (@,/,.and_become-). A page can name more files of its folder (.js,.css,.svg). - Menu items. A link under a Plugins heading in the sidebar. It names a page and the roles that see it; a role can see the item only when it can see the page.
- Who may see what. A plugin file is served only when a rule of that plugin lists your role. Without a rule the answer is 404; without a session, 401; with a role the rule does not list, 403. Admins pass every rule. Pages and menu items you may not see are not listed for you.
- Settings. A settings section adds a card on the Settings page. Its fields are number, yes-no,
text, list or choice, each with a label, an optional help text and a default. Saved values go to
plugin_settings.<name>inconfig.yamlthrough the normal settings save. A key the plugin does not declare, or a value that does not fit its field, is refused. So is a change to the values of a plugin that is not loaded. - Limits. At most 20 pages, 20 menu items, 20 files per page and 50 fields. A file is at most 1 MB and must lie inside the plugin's folder (not a symbolic link out of it, not a folder where runs write).
- Checking.
GET /api/plugins/ui(any signed-in role) lists the pages and menu items you may see. It never shows a folder, a file path or a plugin option. - Without plugins the interface is unchanged: no plugin link, no plugin card, no plugin address.
Managed services#
A managed service is a companion program (for example an integration) that the Foundry starts, watches
and restarts, so you do not need a second process manager. List it in config.yaml:
services:
- name: echo-bot # a-z, 0-9 and -; 1 to 40 characters
command: /opt/scf-services/echo-bot # an absolute path to the program file
args: ["--quiet"] # optional, at most 50
env: { BOT_CHANNEL: "factory" } # optional; names starting SCF_ or FACTORY_ are reserved
public_key: "<base64 of a 32-byte Ed25519 key>" # optional: checks <command>.sig before each start
scope: ["GET health", "GET runs"] # the routes of the service account the Foundry keeps for it
acts_for: "ann@example.com" # optional: the name or e-mail of one person; see section 7
When they start. After the server listens and the watchers have started. Up to 10 services.
Changes while the server runs. The server reads
config.yamlonce a second. When theservices:list has changed in two reads in a row, the change is applied within about 2 seconds, with no restart:- a new entry starts;
- a removed entry stops (its token is revoked), and
services: []removes every service; - an entry whose
command,args,env,public_key,scopeoracts_forchanged is stopped and started again. Other services keep running untouched.
Before a running entry is replaced, the same checks as a start run: the program, the signature (with
public_key), the scope and theacts_forperson. If one fails, the change is refused for that entry only, the running program keeps running, and the Health page saysthe change in config.yaml is not applied:with the reason. The change is tried again with the usual backoff, so fix the cause and it applies by itself. A file that is half-written, empty, not valid settings or unreadable changes nothing: the last valid list stays in force, and the problem is logged once for that version of the file. Each start, stop and refusal caused by a change is a line in the service log and in the audit log (service-start,service-stop,service-refuse).What they get. Their environment holds a few system variables (
PATH,HOME,USER,LANG,TMPDIRand others), yourenvvalues,SCF_URL(the server's address on this computer) andSCF_SERVICE_TOKEN. The token is a new token of the service's own account on every start, and the token of the run before is revoked. It is never on the command line. The account has only the routes inscope; see the service accounts in section 7 above.What is refused. A relative path, a web address, a path with
.or..parts, and a program inside the runs or workspaces folders are refused when the config loads. At start the program must exist, be a file and be executable. Nothing runs through a shell.Signed programs. With
public_key, the Foundry checks<command>.sig(a detached Ed25519 signature of the program file) before every start. A program that does not match is not started, and the Health page says why: the signature file is missing or is not a valid signature, or the signature does not match the program. Fix the file or the signature; the check runs again before each start and each retry, so the program starts by itself.Restarts. A program that exits is started again after 1 second, then 2, 4, 8 and so on, at most 5 minutes apart. A run that lasted 5 minutes or more starts the count again at 1 second.
Stopping. On shutdown, and before a self-update restart, each program gets a stop signal and is killed after 5 seconds if it has not gone. Its token is revoked.
Output. Stdout and stderr go to
<data folder>/services/<name>.log. When the file reaches 5 MB it is moved to<name>.log.1(one older file is kept). The token and yourenvvalues are replaced in the log. Each start and exit is a line of its own.Checking. The Health page shows one line per service, for example "Service echo-bot: running, 1 restart, last exit code 1". A refused or waiting service counts as a problem on the health line.
scf services(orscf services list) prints the same: state, restarts, last exit and the problem. It needs a running, signed-in server (admin).Where they are set. In
config.yamlonly; a change applies while the server runs (see above).PUT /api/configrefuses aserviceskey, and a save from the Settings page keeps the stored list. There is no control on the Settings page, by choice: a program started with the Foundry's rights should be changed by the owner of the file, not from a browser.Without services nothing changes: no program starts, and the health line has no service entry.