section9d

Agentic Software Factory

curl -fsSL https://raw.githubusercontent.com/Dyallab/factory/main/install.sh | bash

Stages

14

Plan, setup, work, validate, judge, ship. Every stage writes to the ledger.

Gates

07

Local checks, security, review, prove, adversarial, remote CI, budget.

Approvals

00

No human approval on the happy path. Only blocked tasks page a human.

[ DANGER ]

Red gates fail fast. The task escalates, the worktree is kept, Discord is paged.

STACK //
  • BUN
  • TYPESCRIPT
  • SQLITE
  • OPENCODE
  • GH
  • DOCKER
  • CLOUDFLARE
SYS.NOMINAL
[ MISSION BRIEF ]

section9d is a software factory that runs on your own box. Label an issue factory, or let a cron fire, and a daemon plans, implements, tests, reviews and merges the change inside an isolated git worktree. Automated gates decide. A human is only paged when the pipeline gets stuck.

Read the pipeline
SEC.01 // PIPELINE

Fourteen stages. One work order.

The daemon claims a task with a single atomic UPDATE ... RETURNING, opens a worktree on a Conventional Commits branch (feat/143-add-dark-mode) and walks the ladder. Every stage writes a row to the runs ledger, so cost, verdicts and evidence survive a restart.

Fiber optic cables glowing in a rack CH-02 STILL
Fiber spine BACKBONE / 0x1F

Phase 01 // Ingress

01 / 03
  • S-01
    plan

    Reads the issue, writes PLAN.md with acceptance criteria, comments it on the issue.

    read-only
  • S-02
    setup

    Prepares the worktree with the repo's setup commands.

    shell
  • S-03
    work

    Implements the plan and commits with Conventional Commits. Never pushes.

    agent

Phase 02 // Validation

04 / 06
  • S-04
    qa

    Runs the repo's own check commands, the same ones CI runs.

    gate
  • S-05
    quality

    Runs quality commands: linters, scanners, coverage drift.

    gate
  • S-06
    security

    TruffleHog over the diff blocks on any finding. Semgrep findings go back to the agent for a bounded fix.

    blocking

Phase 03 // Judgement

07 / 10
  • S-07
    review

    A different model reviews the diff and must end with VERDICT: APPROVE.

    read-only
  • S-08
    fix

    Injects the findings into the same session. At most maxFixRounds rounds.

    bounded
  • S-09
    prove

    Executes every acceptance criterion in the plan. Needs PROOF: PASS.

    evidence
  • S-10
    adversarial

    Hostile second review. Only confirmed findings survive.

    attack

Phase 04 // Delivery

11 / 14
  • S-11
    wrapup

    Pushes the branch, opens the PR with Closes #N, comments on the issue.

    git + gh
  • S-12
    sync

    Merges origin/base into the branch. Conflicts go to the agent with the parent epic as context, then gates re-run.

    git + gh
  • S-13
    ci

    Watches the real GitHub checks with gh pr checks --watch.

    ci
  • S-14
    merge

    Squash merges and deletes the branch once every gate is green.

    gated

The qa, review and fix loop is bounded. When the rounds run out or a gate stays red, the task fails and escalates. There is no path from a red gate to merge.

SEC.02 // VALIDATION

Nothing merges on trust.

Every layer answers a different question. The happy path has no approval button, so the gates have to be enough. They are checked in the final round and again on the real GitHub runners.

Shibuya crossing at night under neon screens CH-01 STILL
Shibuya grid 35.6595N / 139.7005E
Validation ladder
ID Layer Catches Instrument
G-01 Local gates Build breaks, lint, tests, portability qa and quality commands from SECTION9.json
G-02 Security Credentials, injection, unsafe patterns TruffleHog diff blocking, semgrep on new code with bounded fix
G-03 Independent review Missed requirements, conventions, bugs, dead code Different model, read-only agent, verdict enforced
G-04 Fix loop Review findings ignored Up to maxFixRounds with the findings injected, same session
G-05 Prove it works Acceptance criteria that were never executed Runs every criterion from the plan, requires PROOF: PASS
G-06 Adversarial Subtle bugs, scope creep, blast radius Hostile review, each finding verified before it counts
G-07 Remote CI Anything the local gates missed, environment drift gh pr checks --watch on the actual GitHub runners
G-08 Budget cap Runaway token spend maxUsdPerTask checked before every opencode stage
G-09 Escalation Blocked, ambiguous or failing tasks Discord mention, factory:blocked label, worktree kept

Merge authorization

ALL CONDITIONS REQUIRED

One missing check is a failed task, not a warning.

  • At least one commit over origin/base on the task branch
  • qa, quality and security green in the final round
  • Review verdict is APPROVE, or review is disabled
  • Prove it works returned PROOF: PASS
  • Adversarial verdict is APPROVE, or the pass is disabled
  • Sync resolved: branch is in sync with origin/base, conflicts agent-resolved, gates re-run
  • Remote CI is green with gh pr checks --watch
Animation of magenta data glyphs falling CH-08 LIVE
Signal intercept SECURITY / LIVE

Branch protection still wins. If GitHub requires a human review, gh pr merge fails and the task escalates. That is a per-repo safety valve, not a second code path. A missing verdict or proof is parsed as a failure on purpose.

SEC.03 // SYSTEM MAP

One daemon. One worker. One ledger.

A Bun process, a SQLite queue, isolated worktrees and opencode as the engine. Triggers arrive by webhook and cron. The dashboard reads the same database the pipeline writes, so there is nothing else to keep in sync.

Animation of data packets routed between network nodes CH-07 LIVE
Packet routing NET / LIVE

On a narrow screen the map scrolls sideways. The architecture doc has the same flow as text.

Section 9 architecture Issues and cron triggers feed the daemon, which claims tasks from SQLite, runs stages in isolated worktrees through opencode, opens pull requests, waits for CI and merges. Mission control reads the same ledger. Trigger Issue · factory label · Architecture component Trigger Issue factory label Cloudflare Tunnel · public HTTPS Cloudflare Tunnel public HTTPS Ingest · webhook + cron Ingest webhook + cron SQLite · tasks + runs SQLite tasks + runs Pipeline · plan to merge + resume · lights-out Pipeline plan to merge + resume lights-out Opencode v2 · run --format json Opencode v2 run --format json Pull Request · squash + delete · Architecture component Pull Request squash + delete Remote CI · gh pr checks · Architecture component Remote CI gh pr checks Worktree · branch feat/N Worktree branch feat/N runs.jsonl · append-only ledger runs.jsonl append-only ledger Mission Control · live on :3100 · Architecture component Mission Control live on :3100 Discord · success + mention · Architecture component Discord success + mention webhook push https :3101 enqueue claim run push + open PR cwd ledger watch notify reads reads
  • Mission control
  • Daemon logic
  • SQLite and worktrees
  • Remote CI
  • Issue and Discord
M-01

Ingest

HMAC-verified GitHub webhooks through Cloudflare Tunnel, plus local cron. One catch-up poll at boot, then no polling.

M-02

Queue

SQLite. A task is claimed with one atomic UPDATE ... RETURNING. Never read-then-write.

M-03

Workspace

A clone cache and one git worktree per task on a Conventional Commits branch (feat/143-add-dark-mode). A failure keeps the worktree.

M-04

Ledger

Every stage writes to runs and runs.jsonl: status, model, tokens, cost and output tail.

Crash recovery is part of the design. Interrupted tasks go back to ready at boot. Tasks that already opened a PR are adopted instead of re-planned: green stages are skipped from the ledger and the run continues at ci or merge.

SEC.04 // DEPLOYMENT

Point it at a repo. File an issue. Walk away.

Bun, gh and opencode on the host. One config file, one SECTION9.json per target repo, one webhook. Then an issue is a work order.

Soldier holding a tablet with a holographic tactical interface CH-03 STILL
Field ops HOLO / TACTICAL
  1. 01

    Install

    Run the installer: it clones, installs dependencies and writes the daemon config.

  2. 02

    Configure a repo

    Add SECTION9.json at the target repo root and create the factory and factory:blocked labels.

    Register the GitHub webhook once with the shared secret.

  3. 03

    File a task

    An issue with the factory label is a work order. The body is the spec. A [TAG] prefix becomes the commit type.

  4. 04

    Watch, or don't

    Follow the stages in the logs or mission control. Discord gets the merged PR or the escalation. The ledger gets everything.

$ quick start
curl -fsSL https://raw.githubusercontent.com/Dyallab/factory/main/install.sh | bash
opencode auth login   # once
gh auth login         # once
cd "${SECTION9_SRC:-$HOME/.local/share/section9/src}"
bun run dev
$ file a task
gh issue create --repo owner/repo \
  --label factory \
  --title "docs: clarify the service contract" \
  --body "Add a short table of the local services."

Per-repo policy lives in SECTION9.json. Empty model strings mean "whatever opencode is configured with". Set models.review to a different model for a real second opinion.

SECTION9.json
{
  "setup": ["bun install"],
  "models": { "work": "", "plan": "", "review": "" },
  "stages": {
    "plan": { "enabled": true },
    "qa": { "commands": ["bun run check"] },
    "quality": { "commands": [] },
    "security": { "enabled": true, "trufflehog": true, "semgrep": true },
    "review": {
      "enabled": true,
      "maxFixRounds": 2,
      "adversarial": true,
      "adversarialMaxRounds": 1
    },
    "ci": { "enabled": true, "timeoutMinutes": 30 },
    "merge": { "enabled": true, "method": "squash" }
  }
}
SEC.05 // MISSION CONTROL

Mission control, not a control room.

A read-only view of every task and stage, rendered live from section9.db: status KPIs, Trends charts, per-repo costs, a sortable task index and review/adversarial/prove verdicts with per-stage tails. Filter by status, repo or issue and page through results. The only button is requeue, and it only works on failed tasks. Green stages are skipped when the task resumes.

Server room with open racks and cabling CH-06 STILL
Data vault RACK / 0x2A

Illustrative view. The real dashboard adds status KPIs with success rate and tokens, Trends charts (throughput, status, failing stages, cost by repo), a by-repo table, a sortable task index with retry counts, filters with a pager, a read-only JSON API and a health endpoint. Real rows come from section9.db, with the stage output tails and cost per task.

$ live dashboard
bun run dashboard:serve
# http://localhost:3100
$ one-shot report
bun run dashboard
# writes ./mission-control.html
M-05

Every stage, every tail

Status, model, cost, tokens, review/adversarial/prove verdicts and the last 4000 characters of output per run, plus Trends charts, by-repo costs and a sortable task index.

M-06

Requeue is the only write

POST /requeue only accepts failed tasks. It cannot cancel or reset running work. Requeueing an epic also requeues its failed children.

M-07

Static when you want it

One command writes one HTML file, filtered with --status/--repo/--q and paged with --page/--limit. Serve it live for the filter form, guarded refresh, a read-only JSON API and health.

SEC.06 // QUERIES

Questions with teeth.

The parts people ask before trusting an autonomous merge.

Magenta-graded macro photograph of a circuit board CH-05 STILL
Core array PCB / CYBERBRAIN
Q-01 Does it really merge without a human?

On the happy path, yes. The merge decision is the authorization list above: local gates, security, review, proof, adversarial and remote CI. There is no approval button to click. A human is called only when a task fails and escalates.

Q-02 What happens when review says no?

The findings go back into the same opencode session as a fix stage, then qa, quality, security and review run again. The loop is bounded by maxFixRounds (2 by default). When the rounds run out, the task fails and escalates. It never merges on a REQUEST_CHANGES verdict.

Q-03 Can review use a different model than work?

Yes, and it should. models.work, models.plan and models.review are set per repo. Empty strings mean the opencode default. A different reviewer model is the point of the independent review gate.

Q-04 Can it run more than one task at a time?

Today the daemon runs one task at a time. Opt-in concurrency with per-repo locks is tracked in issue #10; the default will stay at one worker.

Q-05 Where do secrets live?

Only in the environment: GH_TOKEN, DISCORD_WEBHOOK_URL, GITHUB_WEBHOOK_SECRET and CLOUDFLARE_TUNNEL_TOKEN. They are never logged and never committed. Inbound webhooks are HMAC-verified, and the daemon refuses to start without the secret.

Q-06 What if remote CI is red?

The ci stage fails and the task escalates. A flaky or red check is never treated as a pass. "No checks reported" is the only special case, and it waits before accepting that answer.

Q-07 Can I try it in PR-only mode?

Set merge.enabled to false in SECTION9.json. The pipeline still plans, implements, tests, reviews and opens the PR, then stops. It is the right setting while you gain trust in a new repo.

Q-08 How isolated is the agent?

Each task gets its own git worktree on its own branch. The work agent is told not to push, not to open PRs and not to touch SECTION9.json or CI config; wrapup owns the push. Review, prove and adversarial run read-only. There are no git hook bypasses anywhere.

Q-09 Does it need a GPU or a cloud account?

No GPU. It needs a Bun runtime, gh and an authenticated opencode account, plus Docker Compose if you want the 24/7 homelab deploy. Models are whatever opencode can reach. Costs land per stage in the ledger and are capped by maxUsdPerTask.

CH-00 // OPTICAL

FEED

↑