Develop kslip
Requirements
Section titled “Requirements”- Go, at the version named in
go.mod. - Git, to run the Change tests and Git merges outside the image.
- Docker, to build the image.
kubectland a cluster that runs kagent, to run the controller manager.
Every other tool installs into bin/ at a version pinned in the Makefile.
Layout
Section titled “Layout”| Path | Holds |
|---|---|
api/v1alpha1 |
The kslip.dev/v1alpha1 API types. |
cmd/controller |
Entry point of the controller manager. |
cmd/controller/app |
The controller manager’s options and assembly. |
internal/controller |
The AgentClaim, AgentSet, and PathLease reconcilers. |
internal/backlog |
The WorkflowBacklog reconciler and recipe expansion. |
internal/dispatch |
The WorkflowDispatch reconciler and backlog fan-out. |
internal/schedule |
The WorkflowSchedule reconciler and loop state machine. |
internal/gitlimit |
Shared per-repository and global Git concurrency limiter. |
internal/pathset |
Path patterns and whether two of them can describe a common path. |
internal/kagent |
kslip’s clients for kagent Sessions and A2A tasks. |
internal/kagent/fake |
In-memory kagent APIs for tests. |
internal/seat |
The Assignment reconciler and the kagent notification receiver. |
internal/change |
The Change reconciler, lease operations and Git updates. |
internal/workflow |
The WorkflowRun reconciler, step contracts and handoffs. |
internal/testenv |
The Kubernetes control plane that runs during integration tests. |
config/crd/bases |
Generated CustomResourceDefinitions. |
config/rbac |
Generated RBAC rules of the controller manager. |
config/samples |
Example resources. |
charts/kslip |
The Helm chart. Its crds/ and files/ directories hold copies of the generated manifests. |
test/chart |
Tests that render the chart and check the result against an API server. |
test/e2e |
End-to-end tests and the configuration of the cluster they run in. |
hack |
Scripts used by the Makefile. |
docs |
Documentation. |
Common tasks
Section titled “Common tasks”make help lists every target. The ones used most:
| Target | Does |
|---|---|
make build |
Builds the controller into bin/. |
make run |
Runs the controller manager against the cluster in the current kubeconfig. |
make generate |
Generates DeepCopy implementations for the API types. |
make manifests |
Generates the CustomResourceDefinitions and RBAC rules, and copies them into the chart. |
make fmt |
Formats Go code. |
make lint |
Runs the linters, including formatting checks. |
make test |
Runs unit and integration tests. |
make verify |
Runs every check a change must pass. |
make docker-build |
Builds the image. |
make test-image |
Builds the image and checks the kslip controller and Git. |
make install |
Installs the chart into the cluster in the current kubeconfig. |
make e2e-up, make test-e2e |
Create the end-to-end cluster, and run the end-to-end tests in it. |
Changing the API
Section titled “Changing the API”The API types in api/v1alpha1 are the source of the CustomResourceDefinitions,
and the +kubebuilder:rbac markers on the reconcilers are the source of the
controller manager’s RBAC rules.
After changing either, run:
make generate manifestsCommit the generated files with the change. Never edit them by hand:
api/v1alpha1/zz_generated.deepcopy.goconfig/crd/bases/config/rbac/role.yamlcharts/kslip/crds/charts/kslip/files/controller-role.yaml
When a kind is removed, delete its file from config/crd/bases and
charts/kslip/crds. The generator does not remove files.
To add a kind, add its types to api/v1alpha1, register them with
SchemeBuilder, write its reconciler under internal/, and register
the reconciler in cmd/controller/app.
make test runs every test in the module. Integration tests start a local
Kubernetes API server and etcd through
envtest, which make test
downloads into bin/, so they need no cluster. make test also generates the
kagent CustomResourceDefinitions into bin/crds/kagent, from the kagent
version in go.mod, and installs them into that API server.
internal/controllerruns the reconcilers against that API server and an in-memory kagent Session API. The fake follows kagent’s lifecycle rules and is reached over gRPC with kslip’s real client.internal/kagentchecks the client against the same fake.cmd/controller/appstarts the controller manager and checks its probes, metrics endpoint and leader election.internal/seatchecks Assignment admission, dispatch, recovery and notification verification.internal/changechecks planning, lease handling, and fast-forward updates against a Git HTTP server.internal/workflowchecks graph and contract validation, step handoffs, seat selection, and cancellation and landing recovery.test/chartrenders the chart with several sets of values and submits every object to the API server as a dry run.
Run a subset through make to provide the API server binaries, the kagent
CustomResourceDefinitions and the pinned Helm binary.
make test TEST_PACKAGES=./internal/controller TEST_ARGS='-run TestClaimBindsToASession -v'The queue benchmarks use envtest to measure seat selection with queued work on every candidate and PathLease reconciliation with disjoint claims on one repository. The seat benchmark compares live-only reads with indexed discovery backed by a populated test index. They report live Assignment lists and lease pairs per operation.
make test TEST_PACKAGES=./internal/controller TEST_ARGS='-run NoTests -bench QueueScans -benchtime=10x'A verbose run of internal/controller also prints the controller’s logs.
The Git slot benchmark measures acquisition wait and busy attempts for batches of four real HTTP Git merges, each on a separate local repository.
make test TEST_PACKAGES=./internal/change TEST_ARGS='-run NoTests -bench BenchmarkGitSlot -benchtime=5x'The steady workload spaces merge arrivals 150 ms apart. The burst workload makes all four eligible together. Each waiting benchmark worker polls every 10 ms. The benchmark reports the 95th percentile acquisition wait and busy attempts per merge. Controller requeues have their own cadence, and real Git remotes add network and repository work.
The WorkflowRun dispatch benchmark starts the controller manager against envtest and a fake kagent gateway. It submits batches to four seats at 16, 64, and 128 runs per second, with paced arrivals and waves of four at each rate. It reports the 95th percentile time from step readiness to seeing a recorded task ID, the controller’s API requests per submitted run, and dispatch throughput. The benchmark settles each task as soon as it observes the task ID and excludes model execution.
make test TEST_PACKAGES=./cmd/controller/app TEST_ARGS='-run NoTests -bench BenchmarkWorkflowDispatch -benchtime=3x'End-to-end tests
Section titled “End-to-end tests”The end-to-end tests run kslip against a kagent control plane on Agent
Substrate, in a kind cluster. They need Docker and
kubectl.
make e2e-up # create the cluster and install its componentsmake test-e2e # run the testsmake e2e-down # delete the clustermake e2e-up:
- Creates a kind cluster named
kslip-e2e, with the certificate APIs Agent Substrate uses, and writes its kubeconfig tobin/e2e.kubeconfig. - Builds the kagent CLI from the kagent version in
go.modand runs its installer. The installer installs the kagent and Agent Substrate charts published for that version, so the cluster runs the kagent release kslip is compiled against. - Deploys a test Git server.
- Builds the kslip image, loads it into the cluster and installs the chart
with the values in
test/e2e/kslip-values.yaml, with kagent callbacks enabled.
The Change end-to-end test runs an in-cluster Git server and uses scripted model replies and tool calls. It checks that overlapping work merges in lease order and that the second builder rebases its branch.
The WorkflowRun test uses the same Git server. It passes retrieved excerpts to a backend seat, hands off the candidate revision to frontend and QA, and uses the same ConfigMap contracts for kagent and WorkflowRun. It checks that landing publishes the SHA QA reports. False QA and an attestation for a different SHA leave the target branch unchanged.
Run it again after a change to apply the new image and chart to the same cluster.
The tests serve a deterministic model from the test process, so they need no
model provider key. Agent runtimes reach it at the address under which the
cluster sees the machine that runs the tests: 172.17.0.1, the Docker bridge
on Linux, unless KSLIP_E2E_HOST_ADDRESS names another.
The tests act under kslip’s own identity in kagent, because kagent accepts work for a Session only from the identity that created it.
make e2e-diagnose prints the state of the cluster, including its Pods,
kslip and kagent resources, component logs and events.
Checks
Section titled “Checks”Continuous integration runs make verify and, in a workflow of its own, the
end-to-end tests. make verify fails when:
- a linter or the formatter reports a problem;
go.modorgo.sumis not tidy;- a generated file differs from what
make generate manifestsproduces; - a Go source file or shell script is missing the Apache 2.0 header;
- a compiled Go dependency uses an unapproved license;
- the documentation breaks the documentation standards;
- the chart fails
helm lint --strict; - a test fails.
Run the controller manager locally
Section titled “Run the controller manager locally”make run ARGS='--kagent-api-url=http://127.0.0.1:8083 --kagent-user-id=kslip@example.com'The manager uses the current kubeconfig context and needs the address of the
kagent API, which kubectl port-forward can expose on the local machine.
Leader election is off unless --leader-elect is passed; outside a cluster it
also needs --leader-election-namespace.