task

package
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package task implements the task contract of §6.1: one markdown file per task under .devclean/tasks/, with a frontmatter block in the same yaml subset as config.yml and a free notes body.

Index

Constants

View Source
const (
	DefaultLimiteIntentos = 3
	DefaultLimiteLineas   = 200
)

Defaults for the optional contract fields (§6.1).

View Source
const Version = 1

Version is the contract version this binary understands (adenda A.1). A file declaring a higher one is read tolerantly and reported.

Variables

This section is empty.

Functions

func NextID

func NextID(dir string) (string, error)

NextID scans dir and returns the first free correlative ID.

func NombreDeFirma added in v0.2.5

func NombreDeFirma(firma string) string

NombreDeFirma reduce una firma de `expone`/`usa` al identificador que tiene que aparecer sí o sí en el código: "wol.Send(mac string) error" → "Send", "POST /wake" → "/wake".

Deliberadamente no compara la firma completa. El lenguaje reescribe los nombres de parámetros y el orden de los tipos, así que exigir el texto literal rechazaría implementaciones correctas. Lo que sí atrapa es el fallo real: que la tarea no haya implementado la pieza, o la haya bautizado distinto de lo que su hermana espera. La verificación por AST completo es v0.2 (§6.8).

func Path

func Path(dir, id string) string

Path returns the file path of a task inside a tasks directory.

func Remove

func Remove(dir, id string) error

Remove deletes the task file.

func Save

func Save(dir string, t Task) error

Save writes the task to dir/<id>.md.

func ValidID

func ValidID(id string) bool

ValidID reports whether id has the contract format.

Types

type Task

type Task struct {
	Version     int      `json:"version"`
	ID          string   `json:"id"`
	Titulo      string   `json:"titulo"`
	Porque      string   `json:"porque"`
	ListoCuando string   `json:"listo_cuando"`
	TocarSolo   []string `json:"tocar_solo"`
	NoTocar     []string `json:"no_tocar"`
	DependeDe   []string `json:"depende_de,omitempty"`

	// Expone son las firmas públicas que esta tarea produce y que otras
	// consumen: "wol.Send(mac, addr string) error", "POST /wake".
	// Usa son las que consume de sus hermanas (§6.10). Congelarlas en
	// ambos contratos es lo que deja que dos tareas de la misma oleada,
	// que corren ciegas en cuartos separados, se encuentren.
	Expone []string `json:"expone,omitempty"`
	Usa    []string `json:"usa,omitempty"`

	LimiteIntentos int    `json:"limite_intentos"`
	LimiteLineas   int    `json:"limite_lineas"`
	Riesgos        string `json:"riesgos"`
	Peso           string `json:"peso,omitempty"` // liviana | media | pesada ("" = estrategia global)

	// Notas is the free body after the frontmatter.
	Notas string `json:"notas,omitempty"`

	// Aviso carries the warning of a contract written by a newer
	// devclean: it parsed, but fields were skipped.
	Aviso string `json:"aviso,omitempty"`
}

Task is the task contract. ListoCuando is the only mandatory field beyond id and titulo; the rest carry defaults.

func List

func List(dir string) ([]Task, error)

List returns every task in dir, sorted by ID. A malformed file fails the whole listing: the tasks directory must stay clean.

func Load

func Load(dir, id string) (Task, error)

Load reads the task with the given id from dir.

func Parse

func Parse(data []byte) (Task, error)

Parse reads a task file. Unknown keys and malformed values are rejected: the contract is the guardrail, so it is strict.

func (Task) Marshal

func (t Task) Marshal() []byte

Marshal renders the task file.

func (Task) Validate

func (t Task) Validate() []error

Validate checks the contract rules and returns every problem found. An empty slice means the contract is valid.

Jump to

Keyboard shortcuts

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