patchy

module
v0.1.0 Latest Latest
Warning

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

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

README

patchy

An end-to-end workflow for triaging and remediating security findings from multiple sources, using GitHub issues as the state machine.

Findings (GitHub Advanced Security / CodeQL first) arrive via webhook and accumulate into GitHub issues for an hour. Issues are enhanced with ownership context, then a sandboxed coding agent classifies each one — false positives are dismissed, low-confidence or human-only work is assigned to the repository owner, and high-confidence remediations are attempted automatically and opened as pull requests for human review.

Components

Binary Concern
source-controller Receive findings via webhooks, open + accumulate issues (1-hour window)
context-controller Enhance new issues with CMDB ownership / infrastructure context
remediation-controller Run agent Jobs in Kubernetes and apply all GitHub side effects
agent-runner In-pod coding-agent runtime: classify, then remediate via claude -p

See DESIGN.md for the full requirements and label taxonomy, and AGENTS.md for a map of the repository. Full documentation — getting started, the label state machine, 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 four 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     # 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 to create, and how the agent's isolation actually works.

kubectl apply -k deploy/kustomize/overlays/dev

A Helm chart rendering the same stack is published to OCI on every release — see helm/chart:

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

Status

All four 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
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.
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.
internal
agentrun
Package agentrun orchestrates the coding-agent stages inside the Job pod: render the prompts, drive the classification harness, decide whether to continue, drive the remediation harness under a token-budget kill switch, verify and package the resulting changeset, and report every stage as an envelope event on stdout.
Package agentrun orchestrates the coding-agent stages inside the Job pod: render the prompts, drive the classification harness, decide whether to continue, drive the remediation harness under a token-budget kill switch, verify and package the resulting changeset, and report every stage as an envelope event on stdout.
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.
contextctrl
Package contextctrl is the context-controller's engine: it reacts to newly opened security-finding issues, runs the enhancer chain (CMDB ownership, infrastructure context — pkg/enhance plugins), posts each contribution as an attributed comment carrying a machine-readable enrichment block, and advances the issue to context-enhanced.
Package contextctrl is the context-controller's engine: it reacts to newly opened security-finding issues, runs the enhancer chain (CMDB ownership, infrastructure context — pkg/enhance plugins), posts each contribution as an attributed comment carrying a machine-readable enrichment block, and advances the issue to context-enhanced.
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 remediation-controller: 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 remediation-controller: one JSON event per line on the runner's stdout, prefixed so it survives interleaving with any other output.
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.
ghfake
Package ghfake is an in-memory implementation of the ghclient store interfaces for controller tests: deterministic, mutation-recording, and just faithful enough (label filters, search-by-label queries) to exercise the controllers' GitHub interactions without a server.
Package ghfake is an in-memory implementation of the ghclient store interfaces for controller tests: deterministic, mutation-recording, and just faithful enough (label filters, search-by-label queries) to exercise the controllers' GitHub interactions without a server.
gitpush
Package gitpush applies an agent's changeset to GitHub.
Package gitpush applies an agent's changeset to GitHub.
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 issue attempt, deterministically named, labelled so orphans can be reaped, 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 issue attempt, deterministically named, labelled so orphans can be reaped, and garbage collected via TTL plus an owner-referenced per-Job Secret.
labels
Package labels encodes patchy's state machine: the security-* GitHub issue labels that carry every finding's state, and the legal transitions between states.
Package labels encodes patchy's state machine: the security-* GitHub issue labels that carry every finding's state, and the legal transitions between states.
reconcile
Package reconcile provides the periodic reconciliation loop every controller pairs with its webhook receiver.
Package reconcile provides the periodic reconciliation loop every controller pairs with its webhook receiver.
remedctrl
Package remedctrl is the remediation-controller's engine: it picks up context-enhanced findings past the accumulation window, runs the coding agent in an ephemeral Kubernetes Job, and performs every GitHub side effect on the agent's behalf — the agent pod has no GitHub credentials.
Package remedctrl is the remediation-controller's engine: it picks up context-enhanced findings past the accumulation window, runs the coding agent in an ephemeral Kubernetes Job, and performs every GitHub side effect on the agent's behalf — the agent pod has no GitHub credentials.
report
Package report defines the two agent-written report contracts — the classification report and the remediation report — as YAML frontmatter schemas with strict, validated parsing.
Package report defines the two agent-written report contracts — the classification report and the remediation report — as YAML frontmatter schemas with strict, validated parsing.
runner
Package runner executes CommandSpecs.
Package runner executes CommandSpecs.
sourcectrl
Package sourcectrl is the source-controller's engine: it turns normalized findings from source plugins into GitHub issues, accumulating alerts of the same finding type (repository + source + primary advisory) into one issue for the accumulation window, and flipping aged issues to accumulation-complete so the remediation pipeline may pick them up.
Package sourcectrl is the source-controller's engine: it turns normalized findings from source plugins into GitHub issues, accumulating alerts of the same finding type (repository + source + primary advisory) into one issue for the accumulation window, and flipping aged issues to accumulation-complete so the remediation pipeline may pick them up.
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.
webhook
Package webhook is the shared GitHub-webhook HTTP server every controller embeds: HMAC-SHA256 signature validation on the raw body, immediate 202 acknowledgement into a bounded worker pool, delivery-ID deduplication, and health/readiness endpoints with graceful drain.
Package webhook is the shared GitHub-webhook HTTP server every controller embeds: HMAC-SHA256 signature validation on the raw body, 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