Help us shape the future of Go! Take the 2026 Go Developer Survey

fix

package
v0.10.18 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package fix implements the `vaultmind frontmatter fix` command's logic — walking the vault and identifying domain notes that are missing the `created` field, then optionally writing it via the existing mutator.

Scope was originally `created` + `vm_updated` (the four-tier vaultmind-owned tier). The 2026-05-04 dogfood pass retired vm_updated entirely (no read-side consumer survived the false- positive collapse of mtime-based drift), so this command now covers only `created` — a tolerated optional field worth filling for migration vaults where notes pre-date any auto-stamp era.

Default mode is dry-run. Apply is opt-in. Per the extend-don't-overwrite principle, vaultmind never silently rewrites user files; the human/agent must explicitly --apply to commit the changes.

User-owned fields (title, status, tags, related_ids, etc.) are NEVER touched. The mutator's existing infrastructure (atomic writes, conflict detection, schema validation) handles the actual write — this package is the discovery + iteration layer.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultCreatedDateResolver

func DefaultCreatedDateResolver(absPath string) (string, string)

DefaultCreatedDateResolver tries git first-commit, falls back to file mtime, falls back to today. Returns (date-string, source) where source is "git", "mtime", or "today". Date is YYYY-MM-DD (date-only) — created is a humanish "when this was born" stamp.

Types

type Config

type Config struct {
	// VaultPath is the vault root.
	VaultPath string
	// Apply: when true, write changes via mutator. When false (default),
	// dry-run — items are populated with proposed values + diffs but no
	// file is written.
	Apply bool
	// CreatedResolver is optional; defaults to DefaultCreatedDateResolver
	// (git first-commit → file mtime → today). Tests inject deterministic
	// resolvers for stable assertions.
	CreatedResolver CreatedDateResolver
}

Config controls a fix run.

type CreatedDateResolver

type CreatedDateResolver func(absPath string) (value string, source string)

CreatedDateResolver computes a `created` date for a note path. Returns (value, source) where source describes provenance — "git", "mtime", or "today". Allows tests to inject deterministic values without touching the filesystem or git.

type Item

type Item struct {
	Path           string            `json:"path"`
	ID             string            `json:"id"`
	MissingFields  []string          `json:"missing_fields"`
	ProposedValues map[string]string `json:"proposed_values"`
	Sources        map[string]string `json:"sources"`
	Diff           string            `json:"diff,omitempty"`
	Error          string            `json:"error,omitempty"`
}

Item is one note that needs backfill.

type Result

type Result struct {
	VaultPath     string `json:"vault_path"`
	FilesScanned  int    `json:"files_scanned"`
	NotesAffected int    `json:"notes_affected"`
	Items         []Item `json:"items"`
	Applied       bool   `json:"applied"`

	// SkippedSymlinks holds vault-relative paths of *.md symlinks that were not
	// examined. A backfill reporting "0 notes affected" over a vault where a
	// note was never opened is telling the operator the wrong thing.
	SkippedSymlinks []string `json:"skipped_symlinks,omitempty"`
}

Result is the JSON-serializable output of RunBackfill.

func RunBackfill

func RunBackfill(cfg Config) (*Result, error)

RunBackfill walks the vault, identifies domain notes missing vaultmind-owned fields, and (if cfg.Apply) writes the missing fields via the mutator. Always returns a Result describing what was found / what would change.

Jump to

Keyboard shortcuts

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