loop

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2026 License: MIT Imports: 21 Imported by: 0

Documentation

Overview

Package loop implements the work loop of §6.4 and its instrumentation (adenda A.2): cada intento escribe una línea en .devclean/runs/<id>/attempts.jsonl. Ese archivo es la única fuente de las métricas y del parte de datos (§6.7); nada se recalcula leyendo el repo después.

Index

Constants

View Source
const DefaultTimeout = 5 * time.Minute

DefaultTimeout is the fallback when Options no fija un timeout.

Variables

This section is empty.

Functions

func RunsDir

func RunsDir(root string) string

RunsDir returns the runs directory of the repository at root.

Types

type Agent

type Agent interface {
	Name() string
	Run(ctx context.Context, req Request) (Result, error)
}

Agent es lo mínimo que el bucle pide al ejecutor: una invocación por intento y el gasto de tokens que produjo. La interfaz se declara aquí, del lado del consumidor; los adaptadores de internal/executor la satisfacen con un shim en cmd/run, sin que el bucle dependa de un paquete en obra.

type Attempt

type Attempt struct {
	Intento                  int       `json:"intento"`
	Inicio                   time.Time `json:"inicio"`
	Fin                      time.Time `json:"fin"`
	SalidaCodigo             *int      `json:"salida_codigo"`
	TestsPasaron             *int      `json:"tests_pasaron"`
	TestsFallaron            *int      `json:"tests_fallaron"`
	ArchivosTocados          []string  `json:"archivos_tocados"`
	SimbolosExportados       *[]string `json:"simbolos_exportados"`
	LineasMas                int       `json:"lineas_mas"`
	LineasMenos              int       `json:"lineas_menos"`
	RevertidosFueraDeAlcance []string  `json:"revertidos_fuera_de_alcance"`
	Tokens                   Tokens    `json:"tokens"`
	Modelo                   string    `json:"modelo"`
}

Attempt is one line of attempts.jsonl. Los campos que el bucle no puede derivar con certeza van en nil, que en JSON es null: un número que no se pudo medir nunca se inventa (adenda A.2).

func ReadAttempts

func ReadAttempts(root, id string) ([]Attempt, error)

ReadAttempts returns every recorded attempt of a task, oldest first. A task that never ran has no attempts (not an error).

type Options

type Options struct {
	Agent          Agent
	Root           string
	Room           room.Room
	Task           task.Task
	Model          string
	Base           string        // rama base para el diff de símbolos
	PatronesPrueba []string      // rutas de prueba que nunca se editan
	AgentTimeout   time.Duration // timeout de cada invocación del agente
	PruebaTimeout  time.Duration // timeout de cada listo_cuando
	Env            []string      // variables propias del cuarto (PORT, ...)
}

Options lleva las dependencias del bucle.

type Outcome

type Outcome struct {
	Verde       bool   `json:"verde"`
	Intentos    int    `json:"intentos"`
	UltimoError string `json:"ultimo_error,omitempty"`
	Pregunta    string `json:"pregunta,omitempty"`
}

Outcome es el resultado de correr el bucle sobre una tarea.

func Run

func Run(ctx context.Context, o Options) (Outcome, error)

Run dirige el bucle de §6.4 e instrumenta cada intento (adenda A.2). Devuelve el Outcome; solo error si el mecanismo falla (no si la tarea se agotó: detenerse es un resultado válido, no un fallo).

type Request

type Request struct {
	RoomPath     string
	Prompt       string
	AllowedGlobs []string
	Model        string
	Timeout      time.Duration
	Env          []string
}

Request es una invocación del agente dentro de su cuarto.

type Result

type Result struct {
	Stdout   string
	ExitCode int
	Tokens   Tokens
}

Result es lo que devolvió una invocación.

type Tokens

type Tokens struct {
	Entrada int `json:"entrada"`
	Salida  int `json:"salida"`
}

Tokens is the token spend of one attempt.

Jump to

Keyboard shortcuts

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