patchy

module
v0.5.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 22, 2026 License: MIT

README

patchy

An end-to-end workflow for triaging and remediating security findings from multiple sources, using Kubernetes custom resources as the state machine and GitHub issues as a human-facing projection.

Findings (GitHub Advanced Security / CodeQL first) arrive via webhook and accumulate into Finding resources for an hour, each projected to a GitHub tracking issue. Findings are enhanced with ownership context, then a sandboxed coding agent investigates each one — false positives are dismissed, low-confidence or human-only work is handed to the repository owner, and high-confidence remediations are queued in priority order, attempted automatically, and opened as pull requests for human review. Completed findings expire on a TTL while FindingRollup resources keep the all-time statistics.

Components

Binary Concern
integration-controller The one internet-facing entry point: validate provider webhooks, ingest alerts into Findings, project tracking issues, apply human signals
source-controller Forge/Repository reconcilers: resolve credentials, pin the head SHA, serve the repository tarball agents fetch credential-lessly
context-controller Enhance freshly opened Findings with CMDB ownership / infrastructure context
investigation-controller Gate eligible findings, run analysis agent Jobs, route the verdicts
remediation-controller Queue admission, priority-ordered remediation Jobs, changeset push + pull requests, rollup statistics and the finding TTL
agent-runner In-pod coding-agent runtime: investigate or remediate via claude -p

See DESIGN.md for the full requirements and the state machine, and AGENTS.md for a map of the repository. Full documentation — getting started, configuration and deployment references — lives at oss.bitwisemedia.uk/patchy (source under docs/; build locally with mise run serve).

Building

The toolchain comes from the .mise/ submodule (mise provisions the pinned tools):

git submodule update --init
make build   # all six binaries into bin/
make test    # unit tests with race + coverage
make lint    # golangci-lint, govulncheck, license headers, prose linters
make pr      # the full local gate before a pull request

Testing

make test    # unit tests (race + coverage)
make e2e     # envtest + the real binaries, driven by recorded webhooks against an in-memory GitHub

Deploying

Container images and kustomize manifests live in deploy/; deploy/README.md covers the GitHub App setup, the secrets and custom resources to create, and how the agent's isolation actually works.

kubectl apply -k deploy/kustomize/overlays/dev

Helm charts rendering the same stack are published to OCI on every release — charts/patchy is the stack; charts/patchy-config carries the Integration/Forge custom resources, installed as a second release once the CRDs exist:

helm install patchy oci://ghcr.io/bitwise-media-group/patchy/charts/patchy --namespace patchy --create-namespace

Status

All components are implemented and tested end to end. The context enhancer is a deliberate placeholder — the plugin seam (pkg/enhance) and a YAML-backed static enhancer ship, and a real CMDB integration implements the same interface.

Directories

Path Synopsis
api
v1alpha1
Package v1alpha1 defines the patchy.bitwisemedia.uk/v1alpha1 API: the custom resources that carry finding state through the pipeline.
Package v1alpha1 defines the patchy.bitwisemedia.uk/v1alpha1 API: the custom resources that carry finding state through the pipeline.
cmd
agent-runner command
Command agent-runner is the coding-agent runtime that executes inside the ephemeral Job pod: it drives the classification and remediation harness stages against a pre-cloned repository and reports results as an event stream on stdout.
Command agent-runner is the coding-agent runtime that executes inside the ephemeral Job pod: it drives the classification and remediation harness stages against a pre-cloned repository and reports results as an event stream on stdout.
context-controller command
Command context-controller reacts to newly opened security-finding issues and enhances their context from first/third parties (CMDB ownership, associated infrastructure) before remediation picks them up.
Command context-controller reacts to newly opened security-finding issues and enhances their context from first/third parties (CMDB ownership, associated infrastructure) before remediation picks them up.
integration-controller command
Command integration-controller is the edge between patchy and its external systems: it terminates the provider webhook paths (the cluster's single internet-facing entry point), turns scanner deliveries into Finding resources, projects Findings as tracking issues, and applies human signals (approvals, closures, merges) back onto Findings.
Command integration-controller is the edge between patchy and its external systems: it terminates the provider webhook paths (the cluster's single internet-facing entry point), turns scanner deliveries into Finding resources, projects Findings as tracking issues, and applies human signals (approvals, closures, merges) back onto Findings.
investigation-controller command
Command investigation-controller turns enhanced Findings into analysis agent runs: it gates on the accumulation window and minimum age, resolves forge coverage, materializes the SHA-pinned repository artifact, runs the investigation agent Job (bounded concurrency, severity-priority order), and routes each verdict — queue for remediation, hold for approval, dismiss, or hand to humans.
Command investigation-controller turns enhanced Findings into analysis agent runs: it gates on the accumulation window and minimum age, resolves forge coverage, materializes the SHA-pinned repository artifact, runs the investigation agent Job (bounded concurrency, severity-priority order), and routes each verdict — queue for remediation, hold for approval, dismiss, or hand to humans.
remediation-controller command
Command remediation-controller picks up context-enhanced security-finding issues, runs the classification/remediation coding agent in an ephemeral Kubernetes Job, and performs every GitHub side effect on its behalf — issue updates, alert dismissal, branch pushes, and pull requests.
Command remediation-controller picks up context-enhanced security-finding issues, runs the classification/remediation coding agent in an ephemeral Kubernetes Job, and performs every GitHub side effect on its behalf — issue updates, alert dismissal, branch pushes, and pull requests.
source-controller command
Command source-controller receives security findings from external sources (GitHub Advanced Security first) via GitHub webhooks and accumulates them into GitHub issues — the pipeline's state machine.
Command source-controller receives security findings from external sources (GitHub Advanced Security first) via GitHub webhooks and accumulates them into GitHub issues — the pipeline's state machine.
status-server command
Command status-server serves the patchy status page: a web dashboard over the Finding state machine and the FindingRollup statistics, with SSO sign-in and RBAC-gated approve/suspend/resume actions.
Command status-server serves the patchy status page: a web dashboard over the Finding state machine and the FindingRollup statistics, with SSO sign-in and RBAC-gated approve/suspend/resume actions.
internal
agentresult
Package agentresult converts agent envelope payloads into the CRD status shapes — the one place the float-bearing wire format meets the no-float structural schemas.
Package agentresult converts agent envelope payloads into the CRD status shapes — the one place the float-bearing wire format meets the no-float structural schemas.
agentrun
Package agentrun orchestrates the coding-agent stage inside the Job pod: render the prompt, drive the harness under a token-budget kill switch, and report the stage as an envelope event on stdout.
Package agentrun orchestrates the coding-agent stage inside the Job pod: render the prompt, drive the harness under a token-budget kill switch, and report the stage as an envelope event on stdout.
artifact
Package artifact stores and serves the SHA-pinned repository tarballs that source-controller produces and agent jobs fetch.
Package artifact stores and serves the SHA-pinned repository tarballs that source-controller produces and agent jobs fetch.
cli
Package cli holds the command plumbing shared by every patchy binary: the conventional cobra root command and the signal-aware execution wrapper.
Package cli holds the command plumbing shared by every patchy binary: the conventional cobra root command and the signal-aware execution wrapper.
controller/context
Package context is the context-controller's engine: it reacts to freshly opened Findings, runs the enhancer chain (CMDB ownership, infrastructure context — pkg/enhance plugins), records each contribution as an enrichment on the Finding's status, and advances Opened → Enhanced.
Package context is the context-controller's engine: it reacts to freshly opened Findings, runs the enhancer chain (CMDB ownership, infrastructure context — pkg/enhance plugins), records each contribution as an enrichment on the Finding's status, and advances Opened → Enhanced.
controller/integration
Package integration is the integration-controller's engine: the edge between patchy and its external systems, driven by Integration resources.
Package integration is the integration-controller's engine: the edge between patchy and its external systems, driven by Integration resources.
controller/investigation
Package investigation is the investigation-controller's engine: it turns Enhanced findings into analysis agent runs and routes their verdicts.
Package investigation is the investigation-controller's engine: it turns Enhanced findings into analysis agent runs and routes their verdicts.
controller/remediation
Package remediation is the remediation-controller's engine — three reconcilers over the Finding/Remediation kinds:
Package remediation is the remediation-controller's engine — three reconcilers over the Finding/Remediation kinds:
controller/rollup
Package rollup maintains the all-time FindingRollup statistics and the TTL deletion of completed findings — causally ordered: nothing is deleted before its spend is aggregated into every scope.
Package rollup maintains the all-time FindingRollup statistics and the TTL deletion of completed findings — causally ordered: nothing is deleted before its spend is aggregated into every scope.
controller/source
Package source is the source-controller's engine: the reconcilers for the Forge and Repository kinds.
Package source is the source-controller's engine: the reconcilers for the Forge and Repository kinds.
enhancers
Package enhancers holds the built-in pkg/enhance implementations: noop (the explicit "nothing configured" placeholder) and staticfile (a YAML-backed repo→ownership map that doubles as the fake CMDB for development and e2e).
Package enhancers holds the built-in pkg/enhance implementations: noop (the explicit "nothing configured" placeholder) and staticfile (a YAML-backed repo→ownership map that doubles as the fake CMDB for development and e2e).
envelope
Package envelope is the versioned event contract between agent-runner and the job controllers: one JSON event per line on the runner's stdout, prefixed so it survives interleaving with any other output.
Package envelope is the versioned event contract between agent-runner and the job controllers: one JSON event per line on the runner's stdout, prefixed so it survives interleaving with any other output.
forge
Package forge resolves a finding's repository URL to the Forge custom resource whose credentials may act on it, and mints per-operation scoped tokens from that Forge's secret.
Package forge resolves a finding's repository URL to the Forge custom resource whose credentials may act on it, and mints per-operation scoped tokens from that Forge's secret.
ghas
Package ghas implements the pkg/source plugin for GitHub Advanced Security code-scanning alerts (CodeQL first): it consumes code_scanning_alert webhook deliveries, fetches the full alert for rule help and location detail, and normalizes it into a source.Finding — extracting CWE identifiers from CodeQL rule tags as the advisory categorization.
Package ghas implements the pkg/source plugin for GitHub Advanced Security code-scanning alerts (CodeQL first): it consumes code_scanning_alert webhook deliveries, fetches the full alert for rule help and location detail, and normalizes it into a source.Finding — extracting CWE identifiers from CodeQL rule tags as the advisory categorization.
ghclient
Package ghclient is patchy's GitHub REST client: GitHub App and personal-access-token authentication, installation-scoped clients and short-lived scoped tokens, and a narrow, fake-able surface (IssueStore, AlertStore, RepoStore) over the handful of endpoints the controllers use.
Package ghclient is patchy's GitHub REST client: GitHub App and personal-access-token authentication, installation-scoped clients and short-lived scoped tokens, and a narrow, fake-able surface (IssueStore, AlertStore, RepoStore) over the handful of endpoints the controllers use.
ghpush
Package ghpush applies an agent's changeset to GitHub through the Git Data API.
Package ghpush applies an agent's changeset to GitHub through the Git Data API.
ghsecret
Package ghsecret turns credential Secrets referenced by Forge and Integration resources into GitHub clients.
Package ghsecret turns credential Secrets referenced by Forge and Integration resources into GitHub clients.
harness
Package harness abstracts the coding-agent CLIs patchy drives.
Package harness abstracts the coding-agent CLIs patchy drives.
jobs
Package jobs creates and observes the ephemeral Kubernetes Jobs that run agent-runner: one Job per Investigation/Remediation attempt, deterministically named, labelled by kind/owner/finding (the two job controllers share the agents namespace and filter on the kind label), and garbage collected via TTL plus an owner-referenced per-Job Secret.
Package jobs creates and observes the ephemeral Kubernetes Jobs that run agent-runner: one Job per Investigation/Remediation attempt, deterministically named, labelled by kind/owner/finding (the two job controllers share the agents namespace and filter on the kind label), and garbage collected via TTL plus an owner-referenced per-Job Secret.
kube
Package kube is the shared controller-runtime scaffolding: the scheme with every API group the controllers touch, manager construction honoring the --kubeconfig flag, leader election, and the logr→slog bridge.
Package kube is the shared controller-runtime scaffolding: the scheme with every API group the controllers touch, manager construction honoring the --kubeconfig flag, leader election, and the logr→slog bridge.
labels
Package labels renders the human-facing security-* label vocabulary the issue projection stamps on tracking issues: source, advisories, the finding's phase, severity, priority, and the investigation's verdict.
Package labels renders the human-facing security-* label vocabulary the issue projection stamps on tracking issues: source, advisories, the finding's phase, severity, priority, and the investigation's verdict.
priority
Package priority maps investigation results onto the 0–100 scheduling priority remediation runs compete with.
Package priority maps investigation results onto the 0–100 scheduling priority remediation runs compete with.
report
Package report defines the two agent-written report contracts — the investigation report and the remediation report — as YAML frontmatter schemas with strict, validated parsing.
Package report defines the two agent-written report contracts — the investigation report and the remediation report — as YAML frontmatter schemas with strict, validated parsing.
runner
Package runner executes CommandSpecs.
Package runner executes CommandSpecs.
schedule
Package schedule ranks pending agent runs for bounded-concurrency slot grants.
Package schedule ranks pending agent runs for bounded-concurrency slot grants.
stats
Package stats is the pure arithmetic behind the all-time FindingRollup objects: micro-USD cost parsing, per-scope delta computation, and exactly-once ledger application.
Package stats is the pure arithmetic behind the all-time FindingRollup objects: micro-USD cost parsing, per-scope delta computation, and exactly-once ledger application.
telemetry
Package telemetry wires OpenTelemetry tracing, metrics, and structured logging into the patchy binaries and owns their lifecycle.
Package telemetry wires OpenTelemetry tracing, metrics, and structured logging into the patchy binaries and owns their lifecycle.
templates
Package templates renders every piece of markdown patchy writes — issue bodies, comments, pull-request bodies, and the agent-facing handoff files — from embedded text/templates, so the artifacts stay consistent across the estate.
Package templates renders every piece of markdown patchy writes — issue bodies, comments, pull-request bodies, and the agent-facing handoff files — from embedded text/templates, so the artifacts stay consistent across the estate.
version
Package version exposes build metadata stamped in via -ldflags.
Package version exposes build metadata stamped in via -ldflags.
web
Package web is the status-server backend: the embedded status page SPA, a JSON projection of Findings and FindingRollups, the three human actions (approve, suspend, resume), and an SSE change signal that tells open browsers to refetch.
Package web is the status-server backend: the embedded status page SPA, a JSON projection of Findings and FindingRollups, the three human actions (approve, suspend, resume), and an SSE change signal that tells open browsers to refetch.
web/auth
Package auth resolves who is making a status-server request.
Package auth resolves who is making a status-server request.
web/authz
Package authz resolves what an identity may do to findings.
Package authz resolves what an identity may do to findings.
webhook
Package webhook is the GitHub-webhook HTTP server the integration-controller embeds: HMAC-SHA256 signature validation on the raw body (against a static secret or the per-Integration candidate set), immediate 202 acknowledgement into a bounded worker pool, delivery-ID deduplication, and health/readiness endpoints with graceful drain.
Package webhook is the GitHub-webhook HTTP server the integration-controller embeds: HMAC-SHA256 signature validation on the raw body (against a static secret or the per-Integration candidate set), immediate 202 acknowledgement into a bounded worker pool, delivery-ID deduplication, and health/readiness endpoints with graceful drain.
pkg
enhance
Package enhance is patchy's public plugin seam for context enhancement.
Package enhance is patchy's public plugin seam for context enhancement.
source
Package source is patchy's public plugin seam for security-finding sources.
Package source is patchy's public plugin seam for security-finding sources.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL