facts

package
v0.51.0 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2026 License: MIT Imports: 23 Imported by: 0

Documentation

Overview

Package facts merges the declared project.md layers with detection and the contract's defaults. Only facts with a fixed vocabulary become structure, so the binary is incomplete but never wrong; scaffold.go writes the prose here too, so its words cannot drift from the readers' vocabulary.

Index

Constants

View Source
const (
	OriginDetected = "detected"
	OriginDefault  = "default"
	OriginAbsent   = "absent"
	// OriginJudgment is guidance the probe could not turn into commands
	OriginJudgment = "judgment"
)

Origins an effective value can have. Declared origins are qualified by the layer label at build time: "declared (main)", "declared (worktree)".

View Source
const (
	ReviewerBot   = "bot"
	ReviewerHuman = "human"
	ReviewerCheck = "check"

	ArrivesComment = "issue comment"
	ArrivesInline  = "inline review"
	ArrivesCheck   = "check run"

	TriggerAutomatic = "automatic"
	TriggerManual    = "manual"

	DonePosted    = "posted"
	DoneMarker    = "marker"
	DoneSubmitted = "submitted"
	DoneConcluded = "concluded"

	HandledReaction = "reaction"
	HandledMarker   = "marker"
	HandledCheckbox = "checkbox"
	HandledThread   = "thread resolved"
)

The vocabularies, as the words the parser looks for.

View Source
const (
	ManualComment = "comment"
	ManualRequest = "request"
)

The manual triggers `f10 review trigger` can perform: a comment on the request, or a review requested from a login.

View Source
const AgentKeyDefault = "default"

AgentKeyDefault is the key the task's agent runs on.

View Source
const DefaultFlow = "plan implement pr"

DefaultFlow is the flow a project that declares none runs.

Variables

View Source
var ErrHasFrontmatter = errors.New("already has a frontmatter block and nothing left to migrate")

ErrHasFrontmatter refuses a second migration.

View Source
var StatusMoments = []string{"started", "shipped"}

StatusMoments are the moments tracker.status may name.

View Source
var TaskKinds = []string{"feature", "bug", "refactor", "spike"}

TaskKinds are the kinds a step key may be scoped by: `plan.bug` sets the plan step's profile for a bug. The words are the plan's Kind line.

Functions

func CheckAgentKey added in v0.48.0

func CheckAgentKey(key string, steps []string) error

CheckAgentKey reports why key is no agents key: not `default`, not a step some flow names, or a kind scope outside TaskKinds. steps are the step names every flow names, merged; a map read outside a project (the user's file) passes nil and keeps any step word.

func JudgeKind added in v0.43.0

func JudgeKind(flow []string, i int) string

JudgeKind is what the judge at entry i judges: the plan before any `implement`, the change after one.

func ParseDriverTimeout added in v0.46.0

func ParseDriverTimeout(value string) (time.Duration, error)

ParseDriverTimeout reads a driver_timeout value, a positive Go duration like `45s` or `2m`.

func ParseStaleAfter added in v0.43.0

func ParseStaleAfter(value string) (time.Duration, error)

ParseStaleAfter reads a stale_after value, `10d` or `3w`.

func Planless added in v0.43.0

func Planless(flow []string) bool

Planless reports a flow that writes no plan file.

func ProjectPrefix added in v0.38.0

func ProjectPrefix(name string) string

ProjectPrefix derives a task id prefix from the project's name, since the host's letters would name every GitLab project GL. A name yielding nothing usable derives none, so f10 init leaves the Tracker section to a human.

func ReviewHalves added in v0.43.0

func ReviewHalves(arg string) (bool, bool)

ReviewHalves is which halves a review entry's argument runs: none or `local` the local review, `ci` the remote one, `local+ci` both, in either order. Neither for any other argument.

func ShipEntries added in v0.43.0

func ShipEntries(flow []string) []string

ShipEntries is what /f10:ship runs: the flow after a leading `plan`.

func SplitEntry added in v0.43.0

func SplitEntry(e string) (string, string)

SplitEntry is an entry's step and its argument, in either form: `review:local` and `review (local)` are both review and local.

Types

type Declared added in v0.29.0

type Declared struct {
	Visibility     string            `yaml:"visibility,omitempty"`
	Storage        string            `yaml:"storage,omitempty"`
	Layering       string            `yaml:"layering,omitempty"`
	Tracker        TrackerDecl       `yaml:"tracker,omitempty"`
	MergeMethod    string            `yaml:"merge_method,omitempty"`
	Catchup        string            `yaml:"catchup,omitempty"`
	CatchupStacked string            `yaml:"catchup_stacked,omitempty"` // how a branch catches up with a base that is another task's branch
	Traces         string            `yaml:"traces,omitempty"`
	Lore           string            `yaml:"lore,omitempty"`
	LoreGate       string            `yaml:"lore_gate,omitempty"`      // what finish does with a failing lore check before a merge
	StaleAfter     string            `yaml:"stale_after,omitempty"`    // a task older than this is judged before it is planned
	DriverTimeout  string            `yaml:"driver_timeout,omitempty"` // one driver verb's limit, a Go duration
	ReviewTraces   string            `yaml:"review_traces,omitempty"`  // the old spelling of traces, read and folded in
	Flows          map[string]Flow   `yaml:"flows,omitempty"`
	FlowByArea     map[string]string `yaml:"flow_by_area,omitempty"` // an area, in Roles' plain words, to the flow its tasks run
	DriveFinish    string            `yaml:"drive_finish,omitempty"`
	DriveEnv       []string          `yaml:"drive_env,omitempty"`     // environment keys a drive passes to its commands, beyond the built-in ones
	Watch          string            `yaml:"watch,omitempty"`         // what the daemon does for tasks no drive owns
	WatchCatchup   string            `yaml:"watch_catchup,omitempty"` // the watcher also catches an undriven open PR up with its target
	ReportBack     string            `yaml:"report_back,omitempty"`
	Review         ReviewDecl        `yaml:"review,omitempty"`
	Standup        StandupDecl       `yaml:"standup,omitempty"`
	Agents         map[string]string `yaml:"agents,omitempty"` // a step, `default` or `step.kind` to the agent profile it runs on

	// The keys flows replaces, read and converted with a warning.
	Pipelines  map[string]Steps  `yaml:"pipelines,omitempty"`
	Planless   []string          `yaml:"planless,omitempty"`
	ByArea     map[string]string `yaml:"pipeline_by_area,omitempty"`
	DriveChain Steps             `yaml:"drive_chain,omitempty"`
}

Declared is one layer's frontmatter.

type Draft

type Draft struct {
	Markdown string
	Keys     []string
	Sections []string
	Omitted  []string
}

A Draft is one rendered project.md, with what it carries and the sections nothing detected.

func Scaffold

func Scaffold(lay *layout.Layout, pb *probe.Probes, eff *Effective) (*Draft, error)

Scaffold renders a project.md for a checkout that declares none. Pure: the caller owns the filesystem, this owns the contract.

type Effective

type Effective struct {
	Fields       []Field `json:"fields"`
	Unrecognized []Field `json:"unrecognized,omitempty"`

	// The fixed-vocabulary sub-facts.
	Layering        string `json:"layering"`
	Visibility      string `json:"visibility"`
	Storage         string `json:"storage"`
	TrackerKind     string `json:"trackerKind,omitempty"`
	IDPrefix        string `json:"idPrefix,omitempty"`        // "ABC", "F10" - the task id format's letters
	IDPrefixOrigin  string `json:"idPrefixOrigin,omitempty"`  // "declared (<layer>)" or "derived from project name <name>"
	IDPrefixDerived bool   `json:"idPrefixDerived,omitempty"` // the prefix came from the project's name, not a declaration

	// PriorityLabels is tracker.priority inverted: a lower-cased host label
	// to the level it carries; nil when none is declared.
	PriorityLabels map[string]string `json:"priorityLabels,omitempty"`

	// TitleTemplate is tracker.title, the template a task's title is written
	// through on the tracker; "" when none is declared, and titles stay bare.
	TitleTemplate tasktitle.Template `json:"titleTemplate,omitempty"`

	// TrackerStatus is tracker.status: `started` and `shipped` to the
	// tracker's own word; nil when none is declared, and f10 moves no status.
	TrackerStatus map[string]string `json:"trackerStatus,omitempty"`

	// The remote review's four facts (review.go); zero when Review declares
	// no remote reviewer.
	Review Review `json:"review"`

	// The rest of the typed facts (resolve.go). MergeMethod "" means none
	// declared: finish asks the repo.
	MergeMethod    string              `json:"mergeMethod,omitempty"`
	Catchup        string              `json:"catchup"`
	CatchupStacked string              `json:"catchupStacked"`        // catchup_stacked: the method for a base that is another task's branch
	Traces         bool                `json:"traces"`                // traces: on; a step's commits carry trailers, the squash commit keeps the task, a review or judge after the PR leaves a status and a comment
	Lore           string              `json:"lore"`                  // local: lore under the storage root; committed: .lore/ at the checkout root
	LoreGate       string              `json:"loreGate"`              // lore_gate: warn or block, what f10 finish does with a failing lore check before a merge
	StaleAfter     string              `json:"staleAfter,omitempty"`  // stale_after: a task older than this is judged before it is planned; "" is off
	DriverTimeout  time.Duration       `json:"driverTimeout"`         // driver_timeout: one driver verb's limit
	Flows          map[string][]string `json:"flows"`                 // a flow's name to its entries, in the colon form
	FlowByArea     map[string]string   `json:"flowByArea,omitempty"`  // flow_by_area: an area to the flow its tasks run
	DriveFinish    bool                `json:"driveFinish"`           // drive_finish: f10 drive ends each task with finish
	DriveEnv       []string            `json:"driveEnv,omitempty"`    // drive_env: environment keys a drive passes on, beyond the built-in ones
	Watch          string              `json:"watch"`                 // watch: report, finish or off, for tasks no drive owns; finish unless declared
	WatchCatchup   bool                `json:"watchCatchup"`          // watch_catchup: on; a watch pass also catches an undriven open PR up with its target and pushes it
	ReportBack     bool                `json:"reportBack"`            // report_back: a ship run posts its shipment on the task; on unless declared off
	UpkeepPaths    []string            `json:"upkeepPaths,omitempty"` // standup.upkeep: globs on top of the defaults
	// Agents is agents: a step, `default` or `step.kind` to the profile it
	// runs on, the layers merged key by key; AgentsOrigin names each key's
	// layer. Nil when none is declared.
	Agents       map[string]string `json:"agents,omitempty"`
	AgentsOrigin map[string]string `json:"agentsOrigin,omitempty"`

	// Facts is every typed value with its origin; Problems what is wrong
	// with how they were declared.
	Facts    []Fact    `json:"facts"`
	Problems []Problem `json:"problems,omitempty"`
	// contains filtered or unexported fields
}

Effective is the merged, attributed view of a project's configuration.

func Build

func Build(lay *layout.Layout, pb *probe.Probes) *Effective

Build merges the declared layers with detection and the contract's defaults into one attributed view.

func (*Effective) Errors added in v0.29.0

func (e *Effective) Errors() string

Errors are the problems that stop a command, joined for its message.

func (*Effective) Flow added in v0.43.0

func (e *Effective) Flow(name string) ([]string, bool)

Flow is the named flow, in any case, and whether it is declared.

func (*Effective) FlowNames added in v0.43.0

func (e *Effective) FlowNames() []string

FlowNames is every declared flow, default first, then by name.

func (*Effective) FlowSteps added in v0.48.0

func (e *Effective) FlowSteps() []string

FlowSteps is every step the flows name, each once, sorted.

type Fact added in v0.29.0

type Fact struct {
	Key    string `json:"key"`
	Value  string `json:"value"`
	Origin string `json:"origin"`
}

A Fact is one typed value and where it came from.

type Field

type Field struct {
	Name   string `json:"name"`
	Value  string `json:"value"`
	Prose  bool   `json:"prose,omitempty"`  // multi-line prose, not a scalar
	Origin string `json:"origin"`           // "detected", "declared (<layer>)", "default", "judgment", "absent"
	Source string `json:"source,omitempty"` // file for declared, evidence for detected
}

A Field is one effective configuration value with its provenance.

type Flow added in v0.43.0

type Flow []string

Flow is one declared flow's entries as written: a list, or one string split on whitespace and arrows, never on commas, which an argument may hold. The old `review (local)` form stays one entry until normalizeEntry.

func (Flow) MarshalYAML added in v0.43.0

func (f Flow) MarshalYAML() (any, error)

MarshalYAML writes the flow as one space-separated string, the shape f10 init --migrate leaves.

func (*Flow) UnmarshalYAML added in v0.43.0

func (f *Flow) UnmarshalYAML(node *yaml.Node) error

UnmarshalYAML accepts a sequence of entries or one string.

type Labels added in v0.38.0

type Labels []string

Labels is a list of label names, written as a YAML list or as one string.

func (*Labels) UnmarshalYAML added in v0.38.0

func (l *Labels) UnmarshalYAML(node *yaml.Node) error

UnmarshalYAML accepts a sequence of strings or one string; blanks drop.

type Migration added in v0.29.0

type Migration struct {
	Content    string
	Moved      []string // the frontmatter keys written
	Superseded []string // "<key>: <where in the prose>"
}

A Migration is what `f10 init --migrate` makes of one project.md, with the prose each moved fact came from, for the user to delete.

func Migrate added in v0.29.0

func Migrate(data []byte, path string) (*Migration, error)

Migrate moves the facts a project.md declares in prose into a frontmatter block, defaults and detection left out so the block says no more than the prose did; under an existing block, old keys are rewritten and gaps filled.

type Problem added in v0.29.0

type Problem struct {
	Error   bool   `json:"error,omitempty"`
	Message string `json:"message"`
}

A Problem is something wrong with the declaration. An error stops the commands that act on facts; a warning is shown and nothing else.

type Review added in v0.26.0

type Review struct {
	Reviewer     string `json:"reviewer,omitempty"`     // the identity: a login, or a check's name
	ReviewerKind string `json:"reviewerKind,omitempty"` // bot | human | check
	Arrives      string `json:"arrives,omitempty"`      // issue comment | inline review | check run
	Trigger      string `json:"trigger,omitempty"`      // automatic | manual | automatic, manual
	TriggerHow   string `json:"triggerHow,omitempty"`   // the rest of the line: how a human fires it
	ManualHow    string `json:"manualHow,omitempty"`    // the manual part alone, when the line names both
	Done         string `json:"done,omitempty"`         // posted | marker | submitted | concluded
	DoneText     string `json:"doneText,omitempty"`     // the marker's text
	Handled      string `json:"handled,omitempty"`      // reaction | marker | checkbox | thread resolved
	HandledText  string `json:"handledText,omitempty"`  // the reaction's emoji, or the marker's text
	Settled      string `json:"settled,omitempty"`      // reaction | marker
	SettledText  string `json:"settledText,omitempty"`  // the reaction's emoji, or the marker's text
	// contains filtered or unexported fields
}

A Review is the parsed remote-review contract. The zero value means the section declares no remote reviewer, which is the common case.

func (Review) Manual added in v0.43.0

func (r Review) Manual() string

Manual is how the manual trigger fires: the manual part of a line naming both, else the whole how, so a code span describing the automatic half is never posted.

func (Review) ManualAction added in v0.38.0

func (r Review) ManualAction() (string, string, bool)

ManualAction is the manual how as a kind and its text: a comment posting the first code span, or a review requested from the span's login. Both need the span, since a word guessed from prose could reach a real account.

func (Review) Missing added in v0.26.0

func (r Review) Missing() []string

Missing names the facts a remote review still lacks, in contract order, so a refusal can say which line to fix. Settled is optional: it is missing only when declared and unreadable.

func (Review) Remote added in v0.26.0

func (r Review) Remote() bool

Remote reports whether the section names a remote reviewer at all.

type ReviewDecl added in v0.29.0

type ReviewDecl struct {
	Reviewer string `yaml:"reviewer,omitempty"`
	Arrives  string `yaml:"arrives,omitempty"`
	Trigger  string `yaml:"trigger,omitempty"`
	Done     string `yaml:"done,omitempty"`
	Settled  string `yaml:"settled,omitempty"`
}

ReviewDecl is the remote review's facts in the prose items' vocabulary, so the same sub-parsers read both.

type StandupDecl added in v0.33.0

type StandupDecl struct {
	Upkeep []string `yaml:"upkeep,omitempty"`
}

StandupDecl lists paths that, alone in a commit, make it upkeep, on top of the lockfiles and generated files standup already knows.

type Steps added in v0.29.0

type Steps []string

Steps is an ordered list of names, written as a YAML list or as one `a → b → c` string.

func (*Steps) UnmarshalYAML added in v0.29.0

func (s *Steps) UnmarshalYAML(node *yaml.Node) error

UnmarshalYAML accepts a sequence of strings or one arrow-separated string.

type TrackerDecl added in v0.29.0

type TrackerDecl struct {
	Kind     string            `yaml:"kind,omitempty"`
	ID       string            `yaml:"id,omitempty"`
	Priority map[string]Labels `yaml:"priority,omitempty"`
	Status   map[string]string `yaml:"status,omitempty"`
	Title    string            `yaml:"title,omitempty"`
}

TrackerDecl is the frontmatter's tracker key. Priority maps a contract level to host labels, since issues have no priority field of their own.

Jump to

Keyboard shortcuts

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