8000 GitHub - flok-ai/flok: Architecture and design for running autonomous coding agents - on my local machine and in the cloud · GitHub
[go: up one dir, main page]

Skip to content
flok-aiPublic

About

Architecture and design for running autonomous coding agents - on my local machine and in the cloud

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

flok

Unsupervised coding agents in the cloud. flok takes a scoped GitHub issue to a reviewed pull request — with real isolation boundaries, agents with their own identity, and an enforced multi-agent workflow. Built in public; this repo is its design and context layer.

Two modes: an interactive session on my laptop writes scoped issues to GitHub; unsupervised agents in the cloud pull issues and open pull requests

Pair & delegate. Architecture and scoping stay interactive — me and a coding agent, on my laptop. Implementation runs headless in the cloud, one pod per agent step. GitHub issues are the handoff.

100% open source. Most open source agent tools run on a developer's laptop as wrappers around Codex or Claude Code, and the scalable ones keep key parts closed. flok is cloud-native and fully open: every component, from the infrastructure to the token broker, is in the open.

What's here

This repo is where I design the platform and scope work. The components are built in their own repositories, where agents pick up the scoped tickets — without context from here, so a badly scoped ticket shows up as a failure.

  • Architecture — how the platform works: use case, architecture, requirements, workflow
  • Decisions — ADRs, one decision per file, target design vs. what the POC builds

Components

Each component is built, versioned and deployed on its own.

Repository What it does
agent-images agent-base image: goose, runtime entrypoint, credential and signing setup
github-broker Just-in-time GitHub tokens, scoped to an agent's role and one repository
infrastructure Terraform for Azure: AKS, workload identities, Key Vault, storage, PostgreSQL
platform-services Runs, pod authentication with ServiceAccount tokens, and the artifact API
workflows Argo workflow templates and agent recipes

Important

This is not a reference architecture. It's a portfolio piece and proof of concept I'm building out in public to share my learnings – and to put my money where my mouth is. Although a POC, I'm still applying 10+ years of cloud engineering experience to set up enough guardrails and enforced security boundaries that I will let agents work unsupervised for me.

For most individuals this setup is overkill. For most organizations, however, as a former enterprise architect, I consider this to be minimum due diligence.

Project Status

  • Design — ADR-001 – 017 accepted
  • Dev container agent — working: own GitHub account, GPG-signed commits, unattended runs after a confirmed read-back (ADR-001)
  • goose in a container — working with docker run: issue in, PR out
  • Cloud platform on AKS — cluster deployed, Argo Workflows installed, agent secrets from Key Vault through workload identity
  • Platform services — deployed in the cluster: create a run, pod authentication with ServiceAccount tokens (one credential per pod), artifact API with SAS URLs, Entra authentication to PostgreSQL
  • Workflow — foreman → planner → coder → reviewer runs end to end with argo submit (or make submit-workflow): issue in, signed and reviewed PR out. If the reviewer requests changes, one coder-fix round runs.
  • Run data — each step reports its timing, token usage, cost and transcript to platform services; an exit handler reports the run's status, duration, PR and failures.
  • Evals — first eval run by hand (2026-12-02): one task on a frozen copy of a real repository, graded by hidden tests.
  • GitHub token broker — in use by the workflow: each agent pod gets a just-in-time GitHub token scoped to its role and one repository. PRs are opened by the GitHub App; commits stay signed by the agent. No shared GitHub token is in use.

Milestones

  • Initial release (2026-11-11) — one issue end to end in the cluster: a planner writes a plan, a coder implements it and opens a signed PR, I review and merge.
  • Just-in-time credentials (2026-11-20) — every component runs on short-lived, scoped credentials; the shared GitHub token is retired.
  • Demo-able (due 2026-12-18) — reviewer step, run data and a first eval are done; a read-only run viewer is next (#35).

Current priorities

  • Next: a read-only run viewer showing runs, steps, transcripts and cost.
  • Later: webhook trigger, review loops beyond one fix round, role images with skills baked in.

Example workflow run

To save cost, the Kubernetes cluster doesn't run full time, so a webhook trigger isn't practical yet. Runs are submitted by hand instead:

make submit-workflow ACR=aisdlctb1fcr.azurecr.io REPOSITORY=julie-ng/flok-eval-target ISSUE=1

About three minutes later, the agents have planned, implemented and reviewed the change, and the pull request is open: flok-eval-target#2, including the reviewer's comment. Argo shows the run like this:

Name:                initial-release-xd485
Namespace:           agents
ServiceAccount:      planner
Status:              Succeeded
Conditions:
 PodRunning          False
 Completed           True
Created:             Wed Dec 02 14:37:56 +0100 (3 minutes ago)
Started:             Wed Dec 02 14:37:57 +0100 (3 minutes ago)
Finished:            Wed Dec 02 14:41:18 +0100 (now)
Duration:            3 minutes 21 seconds
Progress:            5/5
ResourcesDuration:   23s*(1 cpu),4m22s*(100Mi memory)
Parameters:
  acr:               aisdlctb1fcr.azurecr.io
  repository:        julie-ng/flok-eval-target
  issue:             1
  planner_model:     openai/gpt-5.2-codex
  coder_model:       openai/gpt-5.2-codex
  reviewer_model:    openai/gpt-5.2-codex
  coder_fix_model:   openai/gpt-5.2-codex
Output Parameters:
  pr-url:            https://github.com/julie-ng/flok-eval-target/pull/2

STEP                             TEMPLATE                   PODNAME                                        DURATION  MESSAGE
 ✔ initial-release-xd485         initial-release
 ├───✔ foreman                   foreman/foreman            initial-release-xd485-foreman-3991385265       12s
 ├───✔ planner                   planner                    initial-release-xd485-planner-512095290        49s
 ├───✔ coder                     coder                      initial-release-xd485-coder-4105192104         1m
 ├───✔ reviewer                  reviewer                   initial-release-xd485-reviewer-703279583       25s
 └───○ coder-fix                 coder-fix                                                                           when 'approve == changes_requested' evaluated false

 ✔ initial-release-xd485.onExit  report-run
 └───✔ run-reporter              run-reporter/run-reporter  initial-release-xd485-run-reporter-4148166333  4s

The reviewer approved, so the coder-fix step was skipped. After the last step, the exit handler reports the run's outcome to platform services.

The workflow itself is still early and bare-bones. So far, the work has gone into the foundations: security first, cloud-native and built to scale.

What's New?

2026-12-02

Added

  • Reviewer step (2026-11-29). A reviewer agent reads the plan and the PR and posts a comment review with a verdict. If it requests changes, the coder gets one fix round, without a second review. It can only comment: the GitHub App can't approve a PR it opened itself.
  • Run data (2026-11-30). Each step reports its timing, exit code, token usage and cost, and uploads its session transcript. An exit handler reports the run's status, duration, PR and failures. A failed precondition or a time limit is recorded as its own cause, so a system failure isn't counted against the agent.

Validated

  • First eval, by hand. One task on a frozen copy of a real repository, graded by hidden tests: pass, in about 3 minutes, for $0.15.

Changed

  • Loosened the main rules one step. Agents could neither push nor merge to main; now a pull request with one approval can be merged. The gap this opens is documented in GitHub configuration.

Learned

  • The coder didn't run its tests, and the reviewer approved anyway. The hidden tests confirmed the code was right; the approval alone was no evidence of that.

2026-11-29

Changed

  • No shared credentials between pods. Agent pods authenticate to platform services with their own Kubernetes ServiceAccount token, as they already do with the token broker, instead of HMAC step tokens. Every pod gets its own credential and its own step record, so a second coder pod in a fix round never reuses the first one's. The foreman step only registers the run; it no longer hands out secrets. See ADR-017 and the credential flow.

Learned

  • Argo keeps Workflow labels as flat keys. An expression reading the workflow-template label stayed unresolved, and the first run after the switch failed at foreman. The workflow type is now written into each template.

2026-11-20

Changed

  • Renamed to flok — like a flock of geese: every agent runs goose. The repositories moved to the flok-ai organization, and pull requests are now opened by flok-ai[bot].
  • Open source licenses: components under AGPL-3.0-only, docs and diagrams under CC BY-SA 4.0, with attribution required (see License). Releases v0.1.0 (the POC, MIT) and v0.2.0 (relicensed) pin each component.
  • Submodules removed: each component is built, versioned and deployed on its own; see Components.

Milestone

  • Every component runs with just-in-time credentials. Agent pods get their GitHub token from the broker at startup, scoped to their role and one repository and valid for an hour. The shared GitHub token is revoked and removed from the cluster and its Key Vault grants. The first run without it opened a PR as the GitHub App, with a Verified commit and green CI.

Validated

  • Infrastructure access re-checked, nothing left unverified. Every workload identity holds only the secret-scoped grants it needs, nothing inherited. A pod can't mount another identity's secrets, agent pods still can't reach the cloud metadata endpoint, and logs stay within budget. See the verification log.

Learned

  • A bare registry name pulls from Docker Hub. aisdlc…cr instead of aisdlc…cr.azurecr.io made the planner wait for an image that doesn't exist until its deadline. make submit now rejects it up front.

2026-11-18

Validated

  • GitHub token broker works in the cluster. A pod presents its own Kubernetes token and gets a GitHub token that lasts an hour, limited to its role and one repository. The planner's push was denied, the coder's succeeded, and every wrong caller was refused: missing assignment, wrong role, wrong token audience, or a request trying to choose its own repository. No token reached the logs. See the token broker reference.

Learned

  • A GitHub App has two IDs that are easy to mix up. The App ID comes from the App's own settings page; the installation ID belongs to the App's installation on a repository. With the wrong one, GitHub answers "Integration not found", and because the broker deliberately hides upstream errors, finding it took a direct call to GitHub.

2026-11-11

Milestone

  • Initial release works end to end. One argo submit with a repository and issue number: a trusted foreman step creates the run, a planner writes and uploads a plan, a coder implements it and opens a signed PR. The first agent PR took under 2.5 minutes, showed Verified on GitHub, and I merged it.

Decided

  • Agents transfer artifacts themselves, with curl commands in their instructions, rather than through wrapper code. Accepted trade-off: the model can read its own short-lived step token. The pod already holds stronger credentials, so hiding it would have added code without adding protection.
  • Agent instructions live in the workflows repo next to the templates, for now. A practical choice for this release, not an architecture decision.

Learned

  • goose run exits successfully even when the model call fails. Each step now checks that its result exists: an uploaded plan, an opened PR.
  • Argo copies the agent container's volume mounts, including secrets, into its own helper container. The templates remove those copies.

2026-11-10

Added

  • Platform services deployed on AKS: HMAC step tokens, creating a run, and a workload identity token for PostgreSQL. Migrations run at startup as the service's own identity. Verified from an agent pod: create a run, upload a plan, download it.
  • Agent image entrypoint: loads the secrets mounted from Key Vault and sets up the Git identity and commit signing.

Decided

  • Agents read the long-lived secrets they need through workload identity, one secret-scoped grant each. Replaces the signing-key-only exception. See ADR-003.
  • Step tokens expire after 15 minutes as a cost cap: a slow run fails rather than keeps spending.

2026-11-05

Decided

  • Initial release scope: one issue end to end in the cluster. Start a run with the Argo CLI; a planner writes a plan, a coder implements it and opens a PR, and I review and merge. No reviewer step yet.
  • HMAC tokens for platform services, reusing my Tally Split implementation, so callers work without a cluster. Kubernetes ServiceAccount authentication is deferred. See ADR-016.
  • One exception to "agents have no cloud identity": the coder can read only its commit-signing key from Key Vault. See ADR-003.
  • Shared agent instructions now prefer the smallest implementation that meets the acceptance criteria, after agents kept proposing production-grade machinery for a POC.

Added

  • Argo Workflows installed on AKS with Helm. See Infrastructure.
  • Trusted foreman step: its own identity and RBAC to create a run and hand each agent step a scoped token. Platform services consolidated into one identity.
  • Key Vault secrets created by script: platform-service tokens and the agent's GPG signing key.

2026-11-04

Validated

  • Artifact SAS URLs signed with user delegation keys, no storage account keys. Upload, download and overwrite work against Azure; wrong permissions and other containers return 403. See ADR-015.

2026-11-01

Added

  • Artifact API in Platform services: register, upload and download artifacts through scoped SAS URLs, backed by PostgreSQL. Plus logging, a readiness endpoint and an API docs site.

Changed

  • Removed an unneeded service layer from platform services in favor of explicit guards and plain functions.

2026-10-27

Added

  • Cost control: GitHub workflow stops AKS and PostgreSQL manually and daily at 8pm.

2026-10-25

Decided

  • Commit signing: native Git with GPG, one key per agent role. See ADR-014.

Added

Validated

  • Agent pod restrictions: agent pods can't reach the cloud metadata endpoint (IMDS), and privileged pods such as hostNetwork are rejected.

2026-10-22

Added

  • Azure infrastructure deployed: AKS cluster, networking, shared services and workload identities. See Infrastructure.
  • Agent base image built: Goose on Debian, with Python and Node, running as a non-root user. AMD64 build and offline smoke checks passed. See Agent images.

Decided

  • Use GitHub CLI for GitHub operations and keep Goose a light wrapper around capable models, prioritizing API-token cost efficiency. See Image ADRs.

2026-10-20

Design

  • Established the platform architecture and ADRs covering isolation, Argo orchestration, agent identity, credentials and completion gates. See Architecture.

Validated

  • Dev container agents commit under their own GitHub identity with GPG signatures. See ADR-001

Resources

Inspired by

License

Docs, architecture decision records and diagrams in this repository are licensed under CC BY-SA 4.0; scripts under AGPL-3.0-only (see REUSE.toml). The flok components are AGPL-3.0-only in their own repositories. Reuse requires attribution as described in NOTICE; GitHub's "Cite this repository" uses CITATION.cff.

About

Architecture and design for running autonomous coding agents - on my local machine and in the cloud

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Contributors

Languages

0