Documentation
¶
Overview ¶
This file implements the GitHub ready-for-review webhook (issue #567, ported from dsh's GitHub review sessions): an opt-in, isolated HTTP endpoint that turns a PR's draft→ready transition into a read-only review session.
Design, mirroring dsh's isolation contract:
- The endpoint mounts exactly one route (POST /github); every other path and method is a bare 404, so the listener exposes nothing else even when a TLS reverse proxy forwards a public URL to it.
- Authenticity: the payload body is verified against the shared webhook secret via X-Hub-Signature-256 (HMAC-SHA256, constant-time compare). The secret is supplied indirectly (an env-var name resolved by the CLI), never inline in config.
- Replay protection: deliveries are deduplicated by the X-GitHub-Delivery id (a bounded, TTL-pruned cache); duplicates answer 202 and re-run nothing.
- Event filter: only pull_request events with action ready_for_review are acted on; everything else answers 202 and is ignored. An optional repo filter ("owner/name") restricts which repository triggers review.
- Delivery: on a match the server creates a persisted session carrying the review prompt, then hands the request to the injected Runner in its own goroutine, answering 200 immediately (GitHub expects a fast response).
The review run is read-only by construction: its tool set is the read/grep/ find subset, so the model can inspect the diff but cannot modify the workspace or execute commands.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ReadOnlyTools ¶
ReadOnlyTools returns the read-only subset of golder's built-in tools, the tool set a review session runs with.
func ReviewPrompt ¶
func ReviewPrompt(req ReviewRequest) string
ReviewPrompt builds the read-only review prompt for one PR event.
Types ¶
type ReviewRequest ¶
type ReviewRequest struct {
Repo string // "owner/name"
PRNumber int
PRTitle string
PRURL string
Branch string
SessionID string // the persisted review session the prompt was written to
Prompt string // the read-only review prompt (already the session's first turn)
}
ReviewRequest is one accepted ready-for-review event, handed to Runner after the review session has been created and persisted.
type Runner ¶
type Runner func(ctx context.Context, req ReviewRequest) error
Runner executes one review request. It runs on its own goroutine, off the HTTP request path. The default runner (Server.DefaultRunner) drives a real read-only agent run; tests inject fakes.
type Server ¶
type Server struct {
// Secret is the shared GitHub webhook secret (high-entropy); required.
Secret string
// Repo, when non-empty, restricts review to "owner/name"; empty accepts
// every repository's events.
Repo string
// Store persists review sessions.
Store *session.Store
// Workspace is the directory the review runs in (and sessions attribute).
Workspace string
// Model / ProviderName / SysPrompt stamp the created session's header and
// feed the default runner.
Model string
ProviderName string
SysPrompt string
// Provider is the resolved provider the default runner streams from.
Provider provider.Provider
// Runner is called (in its own goroutine) for each accepted event. Required.
Runner Runner
// Now is the clock for delivery-cache pruning and session stamps; tests pin it.
Now func() time.Time
// contains filtered or unexported fields
}
Server is the isolated GitHub review webhook endpoint.
func (*Server) DefaultRunner ¶
DefaultRunner drives a real read-only agent run for one review request: the session (already persisted with the prompt) is resumed into context, the run streams against the server's provider with only the read-only tools, and the produced messages are appended back to the same session.