package memorysearch

// SourceKind enumerates the path-domain kinds the search derivative recognizes.
// Kind is derived from the source-relative path's leading segment(s) and is
// used by filters and result grouping. It is independent of the on-disk source
// format (markdown / text / json / yaml), which is recorded in SourceFile.Format.
const (
	SourceKindSystem     = "system"
	SourceKindProfile    = "profile"
	SourceKindConcept    = "concept"
	SourceKindWorkflow   = "workflow"
	SourceKindEvent      = "event"
	SourceKindReflection = "reflection"
	SourceKindRoot       = "root"
	SourceKindOther      = "other"
)

// SourceFormat enumerates the on-disk source formats the scanner admits. The
// chunker dispatches on this value (markdown vs. plain text); future formats
// would extend the dispatcher without changing SourceFile.Kind semantics.
const (
	SourceFormatMarkdown = "markdown"
	SourceFormatText     = "text"
	SourceFormatJSON     = "json"
	SourceFormatYAML     = "yaml"
)

// SourceFile captures the stable scanned attributes of one source
// file. Kind is path-domain (system/profile/concept/workflow/event/reflection/
// root/other); Format records the on-disk source format. The derivative index
// keys chunks by stable path-derived IDs, so SourceFile.Path is the
// source-relative slash-normalized form.
type SourceFile struct {
	Path        string
	Size        int64
	MTimeNS     int64
	ContentHash string
	Kind        string
	Format      string
	Archived    bool
	ChunkIDs    []string
}

// SourceSnapshot is the deterministic scanned view of the source
// tree at one moment. Revision is the sha256 of the sorted (path, contentHash)
// pairs and is the only stable identity of the snapshot.
type SourceSnapshot struct {
	Revision string
	Files    map[string]SourceFile
}

// SearchChunk is one indexed retrieval unit. The Body is the only field that
// is never returned to callers; everything else is a locator that lets the
// caller reopen the source file and regenerate snippet/line bounds.
type SearchChunk struct {
	ID              string
	Path            string
	Title           string
	HeadingPath     []string
	HeadingText     string
	HeadingAnchor   string
	Body            string
	Kind            string
	Format          string
	Archived        bool
	Identifiers     []string
	IdentifierParts []string
	Ordinal         int
	StartLine       int // 1-based, inclusive
	EndLine         int // 1-based, inclusive
	ContentHash     string
	SourceRevision  string
}
