Documentation
¶
Index ¶
- func ClearAssigneeIfHumanReview(merged lib.TaskFrontmatter) string
- func ExtractBody(ctx context.Context, content []byte) (string, error)
- func ExtractFrontmatter(ctx context.Context, content []byte) (string, error)
- func FindTaskFilePath(ctx context.Context, gitClient gitclient.GitClient, taskDir string, ...) (string, lib.TaskFrontmatter, error)
- func HealTargetVault(fm lib.TaskFrontmatter, vaultName string)
- type GuardDecision
- type ResultWriter
- type TaskPathResolver
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ClearAssigneeIfHumanReview ¶
func ClearAssigneeIfHumanReview(merged lib.TaskFrontmatter) string
ClearAssigneeIfHumanReview enforces the spec-039 / spec-042 doctrine: when merged frontmatter has phase == "human_review", clear assignee via clearAssignee (which captures the prior assignee into previous_assignee if non-empty, then sets assignee to ""). Returns the prior assignee name (empty string when no clear happened OR when the prior assignee was already empty). This is the single chokepoint for the human_review assignee-clear invariant; both the result writer and the partial-update executor (spec 042) route through here.
func ExtractBody ¶
ExtractBody returns the file body — the bytes after the closing "---\n" delimiter. Returns an empty string if the body is empty; error if delimiters are missing.
func ExtractFrontmatter ¶
ExtractFrontmatter returns the YAML frontmatter string between the opening and closing "---" delimiters. Returns an error if delimiters are missing.
func FindTaskFilePath ¶
func FindTaskFilePath( ctx context.Context, gitClient gitclient.GitClient, taskDir string, id lib.TaskIdentifier, resolver TaskPathResolver, ) (string, lib.TaskFrontmatter, error)
FindTaskFilePath returns the relative path of the .md file whose frontmatter has task_identifier == id, plus the parsed existing frontmatter.
It consults resolver first: on a hit it reads exactly that one file — no directory listing — and on a miss, on a nil resolver, and on a hit whose single read or frontmatter parse fails, it falls back to listing files in taskDir via gitClient and reading each one. A resolver error is returned as-is and does not trigger the walk.
Returns ("", nil, nil) when no match is found (not an error). Returns ("", nil, err) naming both paths when more than one file carries id: the match is ambiguous, so no caller may write. Callers must check the error before treating an empty path as "not found" — the two outcomes mean opposite things.
func HealTargetVault ¶ added in v0.7.0
func HealTargetVault(fm lib.TaskFrontmatter, vaultName string)
HealTargetVault stamps the controller's vaultName into frontmatter when the target_vault key is absent. An existing value (any value) is never overridden. This is the heal-on-write half of the frontmatter-command routing guard: a legacy task file created before target_vault stamping is written by whichever controller owns the write, and this stamp ensures the non-owning controller permanently stops falling through to that file (ShouldProcessResult and ShouldProcessFrontmatterCommand both return false for a mismatched stamp). Mutates fm in place; no-op when the key is already present.
Types ¶
type GuardDecision ¶ added in v0.6.2
GuardDecision records a single ownership-guard discard: the merge kept the on-disk value of a controller-owned field (or the pinned terminal status) and rejected a differing incoming value. Equal values produce no decision.
func MergeFrontmatter ¶ added in v0.6.2
func MergeFrontmatter( existing, incoming lib.TaskFrontmatter, ) (lib.TaskFrontmatter, []GuardDecision)
MergeFrontmatter returns a new frontmatter map with all keys from existing, overridden by all keys from incoming, then applies the field-ownership guard: controller-owned counters take the on-disk value when present on disk and are absent from the result when not; a terminal on-disk status is pinned; and operator-owned routing fields (assignee, previous_assignee) take the on-disk value when present on disk, with two exceptions that apply the incoming assignee instead — an incoming empty string (the deliverer's clear) and a fresh reassignment declaration (reassignmentDeclarationKey); a discarded incoming assignee also discards the incoming task_type (the routing tuple travels together). The accumulated counters (metrics_agent_turns, metrics_interaction_count) are summed when both sides carry a numeric value, keep the on-disk value when the incoming key is absent, and take the incoming value when the key is absent on disk; a non-numeric value on either side keeps the on-disk value verbatim and is reported as a decision when the two values differ. The returned decisions name every field whose differing incoming value was discarded (equal values produce no decision). Neither input map is modified.
type ResultWriter ¶
ResultWriter writes a Task back to the vault task file.
func NewResultWriter ¶
func NewResultWriter( gitClient gitclient.GitClient, taskDir string, vaultName string, currentDateTime libtime.CurrentDateTimeGetter, m metrics.Metrics, waiter libtime.WaiterDuration, notificationSender notifcmd.NotificationPublishCommandSender, resolver TaskPathResolver, ) ResultWriter
NewResultWriter creates a ResultWriter that locates task files in the vault and writes the result, committing via gitClient. vaultName is the controller's VAULT_NAME, used to heal legacy task files that lack a target_vault stamp. resolver is the scanner's identifier→path index, consulted before the vault walk; a nil resolver selects the walk-only behaviour and is a test-only value — no production call site passes nil.
type TaskPathResolver ¶ added in v0.11.3
type TaskPathResolver interface {
Resolve(ctx context.Context, id lib.TaskIdentifier) (string, bool, error)
}
TaskPathResolver resolves a task_identifier to the vault-relative path of the task file that carries it.
Three outcomes, and a caller must not conflate them:
- (path, true, nil) — the identifier is known. path is a path the resolver itself observed; it is never built from the identifier.
- ("", false, nil) — the identifier is unknown, so the caller runs its own lookup. A miss is NOT an error. The empty identifier is never indexed, so it is unknown by construction.
- ("", false, err) — more than one file carries the identifier, and the error names both paths. A resolver error is never a miss: treating it as one re-derives the ambiguity and can silently resolve to one of the two files.