Documentation
¶
Index ¶
- func CloneIfMissing(ctx context.Context, repoPath, remote string) error
- func PostCheckpointWithRetry(c *client.Client, ticketID string, phase, sha string, maxAttempts int) error
- func ReconstructState(ticketDir, worktreePath string, claim *client.ClaimResponse) error
- func RecoverTicket(ctx context.Context, claim *client.ClaimResponse, cfg *config.Config, ...) error
- func RecoverTicketForRetry(ctx context.Context, claim *client.ClaimResponse, cfg *config.Config, ...) error
- func RestoreDesignDocuments(ticketDir string, claim *client.ClaimResponse) error
- type Agent
- type Decision
- type Diagnoser
- type Diagnosis
- type Executor
- type GolemExecutor
- type ModelDiagnoser
- type Worker
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CloneIfMissing ¶
CloneIfMissing clones remote into repoPath when there is no git repository there yet. Only http/https/ssh/git URL schemes are permitted, to prevent git ext:: injection.
"Missing" means no git repository, not merely no directory. The earlier os.IsNotExist check was wrong in a way that produced a baffling failure: a directory that exists but is not a repository — an empty volume mount, or one where a previous run's `golem init` had already created .golem — silently skipped the clone, and the first git command to follow died with
creating worktree: git worktree add: exit status 128 fatal: not a git repository (or any of the parent directories): .git
several steps away from the actual cause.
A directory that already contains something other than a git repository is reported rather than cloned into: git clone refuses a non-empty target, and working around that with init-plus-fetch would be operating on a directory whose contents nobody has explained.
func PostCheckpointWithRetry ¶
func PostCheckpointWithRetry(c *client.Client, ticketID string, phase, sha string, maxAttempts int) error
PostCheckpointWithRetry uses the client's built-in exponential-backoff retry logic with a per-call retry budget. The copy shares the HTTP transport without changing the retry settings used by concurrent requests on the original client.
func ReconstructState ¶
func ReconstructState(ticketDir, worktreePath string, claim *client.ClaimResponse) error
ReconstructState writes state.json and log.jsonl into ticketDir from the data carried in the ClaimResponse. The directory is created if absent. worktreePath is the expected worktree path for the ticket (used by ticket.Load).
func RecoverTicket ¶
func RecoverTicket(ctx context.Context, claim *client.ClaimResponse, cfg *config.Config, setup func(string) error) error
RecoverTicket ensures the local repo is in the correct state for resuming a checkpointed ticket, then reconstructs the ticket's local state files. setup is the adapter's WorktreeSetup, run on a newly created worktree. Idempotent: safe to call on an already-present worktree.
func RecoverTicketForRetry ¶ added in v0.1.0
func RecoverTicketForRetry(ctx context.Context, claim *client.ClaimResponse, cfg *config.Config, setup func(string) error) error
RecoverTicketForRetry keeps an existing worktree's uncommitted edits when it is already on this ticket's branch. If the retry lands on another shem with no matching worktree, it falls back to the saved commit checkpoint.
func RestoreDesignDocuments ¶ added in v0.1.0
func RestoreDesignDocuments(ticketDir string, claim *client.ClaimResponse) error
RestoreDesignDocuments makes the design documents a resumed ticket's remaining phases read from disk — spec.md for the plan phase, plan.md and spec.md for implementation — exist on this host. A design phase writes its document only into the ticket directory of the host that ran it, so a checkpoint resume on a fresh shem or container used to skip the design phases and implement from a plan that was not there: the implement prompt cats .golem/tickets/<id>/plan.md, gets nothing, and the reviewer later finds no plan.
The orchestrator keeps a copy of each document: the phase posts it as a SPEC/PLAN log entry before validation runs, and every claim carries the ticket's full log. A missing local file is restored from that copy — in manual-approval mode, exactly the text the human approved. A present local file always wins: it is what validation actually ran against. Restored or present, every required document is re-checked for content, the same floor requireDesignDocument applies after a phase.
A required document that exists in neither place fails the resume for brainstorm and plan checkpoints: the next phase exists only to produce or consume that document, and continuing is the silent plan-free run this function exists to remove. Later checkpoints (a crashed implementation or review) restore what they can and only log a gap — those resumes ran without the documents before, and the tickets are already past the phases that read them.
Types ¶
type Agent ¶ added in v0.1.0
type Agent struct {
Adapter agentrunner.Adapter
ConfigPath string
Catalog models.Catalog
}
Agent is the adapter this shem runs plus the config document its nested golem subcommands read.
type Decision ¶ added in v0.1.0
type Decision struct {
Question string `json:"question"`
Choice string `json:"choice"`
Reason string `json:"reason"`
Basis string `json:"basis"`
}
Decision is what the diagnoser decided instead of asking a human.
type Diagnoser ¶ added in v0.1.0
type Diagnoser interface {
Diagnose(context.Context, *client.ClaimResponse, string, string) (Diagnosis, error)
}
Diagnoser returns a second opinion. Routing and dispatch remain worker-owned; a diagnosis cannot override the host policy or the server state guards.
type Diagnosis ¶ added in v0.1.0
type Diagnosis struct {
Route string `json:"route"`
Reason string `json:"reason"`
Feedback string `json:"feedback"`
// Decision is set only on route "decide".
Decision *Decision `json:"decision,omitempty"`
}
Diagnosis is the sole structured output the routing policy accepts.
type Executor ¶
type Executor interface {
RunTicket(ctx context.Context, cfg *config.Config, c *client.Client, claim *client.ClaimResponse) error
}
Executor is the interface for running a ticket.
type GolemExecutor ¶
type GolemExecutor struct {
Agent *Agent
// Forge merges a finished epic child into its run's target ref (plain
// git in the push mirror). Nil means forge.Git{}; tests substitute a
// fake. The worker depends on the operation, not on the git CLI.
Forge forge.Forge
// contains filtered or unexported fields
}
GolemExecutor runs tickets phase by phase. Per ticket, the spec and the plan are either gated by a human (manual approval) or by automatic validation.
func (*GolemExecutor) IntegrateAssigned ¶ added in v0.1.0
func (e *GolemExecutor) IntegrateAssigned(ctx context.Context, cfg *config.Config, c *client.Client, claim *client.ClaimResponse, repoPath, branch string)
IntegrateAssigned re-runs the integration lane for one assigned epic child. It is the Worker-facing entry to integrateEpicChild, for the startup sweep, periodic reconciliation and the resume push.
func (*GolemExecutor) RunTicket ¶
func (e *GolemExecutor) RunTicket(ctx context.Context, cfg *config.Config, c *client.Client, claim *client.ClaimResponse) error
RunTicket executes a claimed ticket:
- Pre-creates the local ticket with `golem ticket new` (scaffolding only, no agent).
- Ensures the repo is initialized and the code graph is current.
- Runs three separate agent sessions — brainstorm, plan, implement — pausing between brainstorm→plan and plan→implement for human approval via the orchestrator UI. Tickets are NOT closed automatically; humans close via the UI.
type ModelDiagnoser ¶ added in v0.1.0
type ModelDiagnoser struct {
Runner agentrunner.Runner
Model string
}
func (ModelDiagnoser) Diagnose ¶ added in v0.1.0
func (d ModelDiagnoser) Diagnose(ctx context.Context, claim *client.ClaimResponse, reason, ticketDir string) (Diagnosis, error)
type Worker ¶
type Worker struct {
// contains filtered or unexported fields
}
Worker polls for available tickets, claims them, and runs them via Executor.
func (*Worker) HandleMessage ¶
HandleMessage processes a WebSocket push message from the orchestrator.
func (*Worker) SetWSClient ¶
SetWSClient attaches a WebSocket client for heartbeat pings.