Skip to content

The forge

The forge is a Gitea that holds the team’s pipelines, one file for each pipeline, and a small sample repo. Agents and pipelines open pull requests on it, and its webhooks tell the API when a pipeline file changes. It holds the organization team, where ops/forge-setup.ts makes a pipelines repo and a sample repo.

Docker Compose runs the forge on the server host, from compose.yaml with ops/aws-deploy/compose.aws.yaml over it. It runs Gitea 1.27.3 with an SQLite database, listens on the host’s loopback at port 3001, and keeps its data in /data/forge on the data volume. Registration is off, so its users are the ones the deploy makes and any that a restored archive brings.

The forge’s webhooks post to http://host.docker.internal:7700/v1/hooks/forge, the API’s machine port at the Docker host’s gateway. The forge signs each delivery with the webhook secret, and the API checks the signature.

ops/aws-deploy/forge.ts runs on every deploy, once the forge’s container is up and before the API starts.

  • It makes two forge users when they are missing. agents-admin is an admin that sets up repos. factory is the user that pipelines act as.
  • It makes the organization team.
  • It writes the forge file, /data/agents-app/forge.json, mode 600, owned by the API’s user, which AGENTS_FORGE_FILE names. The file holds the forge’s address, the webhook address, the organization’s name, the factory token, the admin token and the webhook secret.
  • It keeps a copy of the file in the SSM SecureString /agents/forge/config, written when it differs.

A forge file whose tokens work and whose addresses match is left as it is. When the file is gone and the copy’s tokens still work, as after the forge’s archive is restored onto a new data volume, the deploy writes the copy back. Otherwise it mints new tokens and keeps the webhook secret the repos’ webhooks sign with. The deploy makes no repos and adds none to a team.

The tokens leave the server only in that SSM copy. Machines reach repos through the API’s git proxy with their own tokens.

ops/forge-setup.ts <team> makes team/shop, a small app with a known bug from ops/seed/shop, and team/pipelines, which holds shared/pipeline.ts and each .ts file at the top of pipelines/. It protects main on each, gives factory write access, adds the webhook and adds both repos to the team. Merging a change to a file in team/pipelines makes that file its pipeline’s head version. The head becomes the current version once it loads, has been replayed against recorded runs, and a team admin or the pipeline’s shepherd approves it, or once a person approved the proposal that merged it.

The script runs docker compose exec to make the forge users, so it runs where the forge’s container is. On gomoe.dev that is the server host, and no laptop tool runs it there. ops/aws-deploy/move-in.ts brings a forge’s repos from another stack’s archive.

ops/publish-pipelines.ts proposes shared/pipeline.ts and each .ts file at the top of the repo’s pipelines/ folder that differs from the forge’s copy, as one pull request on team/pipelines, on a branch named publish-<time>. With --merge it merges the pull request too, and the forge’s webhook records the new versions as heads, which wait for approval. It reaches the forge at the address in the forge file, the host’s loopback, so on gomoe.dev it runs only on the host, and no laptop tool wraps it. See Pipelines for how a team approves a change.

The built-in pipelines run as agents with fixed names. bug-fix uses an agent named fixer. app-change and research-plan-implement use an agent named builder. improve and coach use an agent named improver. Make all three on the team, with a home machine.

Terminal window
node ops/aws-deploy/admin.ts add-agent <team> fixer <home instance>
node ops/aws-deploy/admin.ts add-agent <team> builder <home instance>
node ops/aws-deploy/admin.ts add-agent <team> improver <home instance>

bug-fix, app-change and research-plan-implement run on a computer. Until the server holds a team Claude token, a run of any of them fails at once with Boxes have no Claude login yet, on every team. See Save the team’s Claude token.

forge-login records which forge user a person is. A command that protects a repo’s default branch for that person as its owner needs it.

Terminal window
node ops/aws-deploy/admin.ts forge-login <email> <forge user>

The nightly backup pauses the forge’s container, archives /data/forge to the objects bucket as backups/<date>/forge.tar.gz, and starts it again. The archive holds the forge’s data but not the forge file, which is why SSM keeps a copy. See What keeps gomoe.dev running.