cache

package
v0.9.3 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package cache is the local, NON-versioned index at .spectackle/cache/index.db (pure-Go SQLite via modernc.org/sqlite, FTS5). The versioned .spectackle files are the source of truth; the cache is rebuildable at any time. There are no migrations: a generation-stamp mismatch drops everything and rebuilds (the sync engine re-feeds it from disk).

v0 scope: meta, file stats and the FTS5 docs table. Graph persistence (nodes/edges/parse blobs) joins when the M1 indexer lands.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache struct {
	// contains filtered or unexported fields
}

Cache wraps the SQLite handle.

func Open

func Open(cacheDir string) (*Cache, error)

Open opens (or rebuilds) the cache under the given cache directory. WAL + busy_timeout + immediate transactions: two agent processes rooted at the same workspace share this file and must not trip over each other.

func (*Cache) Close

func (c *Cache) Close() error

Close closes the handle.

func (*Cache) FileStat

func (c *Cache) FileStat(path string) (mtime, size int64, sha string, ok bool)

FileStat returns what the cache recorded for a path the last time it was indexed: the cheap metadata gate (mtime, size) plus the hash of the content those docs were actually built from. An empty sha means the content is unknown and the metadata alone must not be trusted.

func (*Cache) List added in v0.8.2

func (c *Cache) List(kinds []string, k int) ([]Doc, error)

List enumerates docs of the given kinds with no query at all, in a stable descending-ID order — chronological for the time-ordered ID kinds, see the ORDER BY comment below. Search returns (nil, nil) for an empty query, which the find tool rendered as `ok no matches` — a successful call carrying a false answer on a workspace that had 96 rules (B-01KYR01E2VFEF). Enumeration is a separate question from matching, so it gets a separate query rather than a magic query string: there is no FTS MATCH here, only a kind filter.

func (*Cache) PutFileStat

func (c *Cache) PutFileStat(path string, mtime, size int64, sha string) error

PutFileStat records a path's stat together with the content hash that was indexed from it. Pass the hash the docs were derived from, never a hash of some later read: the pair is what makes freshness follow content instead of metadata a same-size, timestamp-preserving write leaves untouched.

func (*Cache) ReplaceDocs

func (c *Cache) ReplaceDocs(dir string, kinds []string, docs []Doc) error

ReplaceDocs atomically replaces all docs of the given kinds within one context dir — the FTS5-has-no-PK maintenance strategy: one changed file re-feeds all its record kinds.

func (*Cache) Search

func (c *Cache) Search(q string, kinds []string, k int) ([]Doc, error)

Search runs a sanitized FTS query. kinds empty = all kinds. Results are rank-ordered (bm25), at most k.

type Doc

type Doc struct {
	Kind, ID, Dir, Title, Body string
}

Doc is one searchable record. Kinds: rule, section, proposal, task, bug, research, adr, journal, rejection.

Jump to

Keyboard shortcuts

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