Documentation
¶
Index ¶
- func DeduplicateFrontmatter(ctx context.Context, fmYAML string) (string, bool, error)
- func InjectTaskIdentifier(ctx context.Context, content []byte, id string) ([]byte, error)
- func ParseTask(ctx context.Context, content []byte) *lib.Task
- func ParseTaskFields(fm map[string]any, body string) *lib.Task
- type ScanResult
- type VaultScanner
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DeduplicateFrontmatter ¶
DeduplicateFrontmatter removes duplicate keys from YAML frontmatter, keeping the last value for each key.
func InjectTaskIdentifier ¶
InjectTaskIdentifier injects a task_identifier into the frontmatter of content.
func ParseTask ¶ added in v0.26.0
ParseTask parses a task file's frontmatter and body into a Task. Returns nil when the content has no parseable task frontmatter with a task_identifier. Unlike processFile it performs no hash tracking, no auto-injection, and no counter reset — a pure parse for read-only consumers (e.g. the redrive sweep).
func ParseTaskFields ¶ added in v0.31.1
ParseTaskFields builds a Task from an already-split frontmatter map and body.
It exists for callers that never hold the file's bytes: the typed vault API returns a task as frontmatter and body, so re-rendering it to `---\n<yaml>---` just to call ParseTask would round-trip YAML for every task on every pass — and the redrive sweep, which exists precisely to bypass the hash cache, walks the whole population each cycle.
It shares ParseTask's field mapping by construction (ParseTask delegates here), so the two cannot drift: a field added to one is added to both. The frontmatter is already a map, so the duplicate-key repair ParseTask performs on YAML text has nothing left to do.
Types ¶
type ScanResult ¶
type ScanResult struct {
Changed []lib.Task // tasks whose content changed (new or modified)
Deleted []lib.TaskIdentifier // task identifiers that were previously known but are now gone
}
ScanResult holds the outcome of a single vault scan cycle.
type VaultScanner ¶
type VaultScanner interface {
// Run starts the polling loop. Blocks until ctx is cancelled.
// Results are sent to the provided channel; the caller owns the channel.
Run(ctx context.Context, results chan<- ScanResult) error
// RunCycle executes a single scan cycle (git pull + file scan + optional commit/push).
// Exported for use in scanner_test package; prefer Run() in production.
RunCycle(ctx context.Context, results chan<- ScanResult)
// Resolve returns the vault-relative path of the task file carrying id, from the
// identifier→path index the last completed scan cycle — or, in trigger-only mode,
// the boot build — published, including entries recorded since that rebuild.
// It returns ("", false, nil) when the index does not hold id — an unknown
// identifier is not an error — and ("", false, err) naming both paths when two
// files carry id. The index is empty until the first cycle completes.
Resolve(ctx context.Context, id lib.TaskIdentifier) (string, bool, error)
// Record tells the resolver that relPath is the vault-relative path of the task
// file carrying id, so a later Resolve(id) hits instead of missing. The caller
// must have just established that fact — by writing that file or by a walk that
// found exactly one file carrying id. It returns nothing: recording is a cache
// fill, and a failure to record only costs a later walk. An empty id or empty
// relPath is ignored. A resolver that already knows of two or more paths for id
// keeps them, so a known duplicate is never hidden.
Record(ctx context.Context, id lib.TaskIdentifier, relPath string)
// RecordDuplicate adds relPath alongside the path(s) already known for id, where
// Record would replace them, so a second file carrying id makes Resolve report
// the duplicate as an error. See result.TaskPathResolver.RecordDuplicate for the
// contract.
RecordDuplicate(ctx context.Context, id lib.TaskIdentifier, relPath string)
}
func NewVaultScanner ¶
func NewVaultScanner( client vaultapi.Client, taskDir string, pollInterval time.Duration, trigger <-chan struct{}, m metrics.Metrics, autoInject bool, vaultName string, metricsInterval time.Duration, ) VaultScanner
NewVaultScanner creates a VaultScanner that reads the vault through the typed API. There is one constructor, not two: the local-file-ops variant existed only to serve a clone this controller no longer holds, and a second constructor would be a dead path the grep criterion cannot see.