Gives a Kubernetes pod its own logged-in web browser, over MCP
gofer AGENTS.md
5.9 kB 130 lines
Markdown
at main

gofer AGENTS.md #

You work on gofer's code here. README.md says what gofer is and how to install it, skills/ says how to use it, and plans/00-design.md is the design.

Plans are in plans/. Read plans/README.md before you add, build, or close one. Numbered plans build the design one plan at a time, and code exists only where a plan calls for it. A plan states contracts and leaves the shape of the code to the person or agent who builds it.

Layout #

The operator is one Go module, tangled.org/guid.foo/gofer, with packages named by domain. In place of client-go, it uses the Kubernetes packages of liken: apiclient, informer, events, conditions, and memo. The sidecar is the one part in another language, because Playwright and its MCP server are TypeScript.

  • cmd/gofer has main, which reads the settings, loads the key-encryption key, and starts the parts below. It also has the code that keeps the webhook's CA and decides the CA rollover.
  • api/v1alpha1 has the BrowserProfile as Go types. The CRD in deploy/crds/ is written by hand. The tests in api/v1alpha1 check that the two match field by field, and run examples through the CRD's schema and CEL rules. Change both in one commit.
  • cluster is every read and write to the API server, and cluster/clustertest is the tests' fake of it.
  • profile keeps each profile's finalizer and conditions.
  • inject is the mutating webhook: the sidecar it adds and the rules that refuse a pod.
  • stateapi serves each profile's state and secrets to sidecars, and store and seal keep that state on the operator's volume, sealed.
  • servingcert makes and renews the operator's CA and serving certificate, with no cert-manager.
  • metrics serves the operator's series and /healthz. Each domain declares its own series.
  • sidecar/ is the browser sidecar, in Node: the egress proxy, the browser's launch in chromium.mjs, the MCP tools, and the state's save and merge. Its image builds from sidecar/Dockerfile. The image also contains workload.mjs, an MCP client that the README's example and e2e/ run as the workload.
  • deploy/ is the kustomize base, with no setting of any one cluster. deploy/monitoring is a component that adds a PodMonitor.
  • e2e/ contains the experiments that test a cluster end to end. Each is a script that runs kubectl against the context named by CONTEXT and the namespace named by NS, which defaults to errands. Run setup.sh first to prepare the namespace. The experiments need a cluster with gofer installed, so CI does not run them.
  • transect/ describes the BrowserProfile kind and gofer's programs for liken's transect.
  • skills/ is the usage documentation, as Agent Skills. .claude-plugin/ and plugin.json make the repository a plugin marketplace for them.

Where the parts are #

The parts are the ones that plans/00-design.md names.

  • The operator: cmd/gofer, profile, cluster, metrics, and servingcert.
  • The webhook: inject.
  • The sidecar: sidecar/.
  • The state API: stateapi, with store and seal.

Commands #

make test            # the Go checks, the sidecar's tests, and the kustomize build
make test-go         # gofmt, go mod tidy -diff, go vet, staticcheck, go test -race
make test-sidecar    # npm ci and node --test in sidecar/
make test-deploy     # kustomize build of deploy/
prek run --all-files # goimports, go vet, staticcheck, go test, and file hygiene
claude plugin validate .

go test -race needs cgo and a C compiler. Without a compiler, run make test RACE=. The tests write coverage.out, which git ignores.

STATICCHECK and KUSTOMIZE name the commands that run those tools. KUSTOMIZE defaults to kubectl kustomize, and CI sets it to kustomize build. The sidecar's only check is node --test.

Images and release #

.tangled/workflows/ci.yml runs on a Tangled spindle with the kubernetes engine. CI runs make test without the race detector. It builds and smoke-tests the sidecar image with docker-buildx, on the buildkitd that the workflow pod names in BUILDX_BUILDER. It builds the operator image with ./ko-build.sh.

On a push to main, in the weekly scheduled run, and in a manual run on main, CI then pushes both images and the gofer-deploy artifact under one tag, <UTC yyyymmddHHMMSS>-<short sha>. The images are also tagged latest. The artifact goes last, so no cluster sees a tag whose images are missing. A pull request builds both images and pushes nothing.

The ATCR_DEVICE_SECRET secret is the registry login. It is an atcr.io device secret, which can push and delete images but cannot write the account's other records.

ko builds the operator image from .ko.yaml. The image's entrypoint is the binary at /ko-app/gofer. Nothing sets command, so a pod runs the entrypoint. The sidecar image builds from sidecar/Dockerfile, with Chrome for Testing at Chrome's current stable version:

make sidecar-image   # builds the image and runs its smoke test
./ko-build.sh --push=false   # builds the operator image

How work lands #

Work lands as commits on main, with no merge commits. Rebase a change made on a branch onto main. Each push to main is a release. There are no version numbers, only the tags CI publishes.

Security is the product #

gofer holds logins and card numbers for workloads that read untrusted web pages. Every change keeps the principles and the security premise in plans/00-design.md. A change that weakens one says so in its plan and its commit.