{"modulePath":"github.com/bborbe/agent-task-controller","version":"v0.38.3","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package scanner\n\n## Functions\n\n```go\nfunc DeduplicateFrontmatter(ctx context.Context, fmYAML string) (string, bool, error)\n```\nDeduplicateFrontmatter removes duplicate keys from YAML frontmatter, keeping the last value for each key.\n\n```go\nfunc InjectTaskIdentifier(ctx context.Context, content []byte, id string) ([]byte, error)\n```\nInjectTaskIdentifier injects a task\\_identifier into the frontmatter of content.\n\n```go\nfunc ParseTask(ctx context.Context, content []byte) *lib.Task\n```\nParseTask 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).\n\n```go\nfunc ParseTaskFields(fm map[string]any, body string) *lib.Task\n```\nParseTaskFields builds a Task from an already-split frontmatter map and body.\n\nIt 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\\\u003cyaml\u003e---\\` 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.\n\nIt 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.\n\n## Types\n\n```go\ntype ScanResult struct {\n\tChanged []lib.Task           // tasks whose content changed (new or modified)\n\tDeleted []lib.TaskIdentifier // task identifiers that were previously known but are now gone\n}\n```\nScanResult holds the outcome of a single vault scan cycle.\n\n```go\ntype VaultScanner interface {\n\t// Run starts the polling loop. Blocks until ctx is cancelled.\n\t// Results are sent to the provided channel; the caller owns the channel.\n\tRun(ctx context.Context, results chan\u003c- ScanResult) error\n\t// RunCycle executes a single scan cycle (git pull + file scan + optional commit/push).\n\t// Exported for use in scanner_test package; prefer Run() in production.\n\tRunCycle(ctx context.Context, results chan\u003c- ScanResult)\n\t// Resolve returns the vault-relative path of the task file carrying id, from the\n\t// identifier→path index the last completed scan cycle — or, in trigger-only mode,\n\t// the boot build — published, including entries recorded since that rebuild.\n\t// It returns (\"\", false, nil) when the index does not hold id — an unknown\n\t// identifier is not an error — and (\"\", false, err) naming both paths when two\n\t// files carry id. The index is empty until the first cycle completes.\n\tResolve(ctx context.Context, id lib.TaskIdentifier) (string, bool, error)\n\t// Record tells the resolver that relPath is the vault-relative path of the task\n\t// file carrying id, so a later Resolve(id) hits instead of missing. The caller\n\t// must have just established that fact — by writing that file or by a walk that\n\t// found exactly one file carrying id. It returns nothing: recording is a cache\n\t// fill, and a failure to record only costs a later walk. An empty id or empty\n\t// relPath is ignored. A resolver that already knows of two or more paths for id\n\t// keeps them, so a known duplicate is never hidden.\n\tRecord(ctx context.Context, id lib.TaskIdentifier, relPath string)\n\t// RecordDuplicate adds relPath alongside the path(s) already known for id, where\n\t// Record would replace them, so a second file carrying id makes Resolve report\n\t// the duplicate as an error. See result.TaskPathResolver.RecordDuplicate for the\n\t// contract.\n\tRecordDuplicate(ctx context.Context, id lib.TaskIdentifier, relPath string)\n}\n```\n\n```go\nfunc NewVaultScanner(\n\tclient vaultapi.Client,\n\ttaskDir string,\n\tpollInterval time.Duration,\n\ttrigger \u003c-chan struct{},\n\tm metrics.Metrics,\n\tautoInject bool,\n\tvaultName string,\n\tmetricsInterval time.Duration,\n) VaultScanner\n```\nNewVaultScanner 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.\n\n","path":"github.com/bborbe/agent-task-controller/pkg/scanner","name":"scanner","synopsis":"","isRedistributable":true}
