class

TransFS::Index

Inherits Reference < Object

The SQLite index: a materialized facet view folded from the claim logs (docs/architecture.md §6). It is a rebuildable cache, never the source of truth — delete it and the next open rebuilds it from the logs.

Two deliberate deviations from the §6 DDL, both because this is a disposable cache, not the truth layer:

  • ids/hashes are stored as hex TEXT, not BLOB — debuggable with the sqlite3 CLI, no hex<->bytes conversion at every boundary, and the whole codebase already speaks hex. 32 bytes/row is irrelevant for a personal archive's metadata.
  • the db lives at <root>/.transfs/index.db (the §6 DDL sketch wrote <root>/files.db).

Constructors

new(root : String)
Source

Instance methods

by_name(substr : String) : Array(Row)
Source
by_tag(key : String) : Array(Row)

CLI find tag:<key> — docs having key as any component of a tag-path.

Source
by_type(prefix : String) : Array(Row)
Source
close
Source
db_path
Source
docs(walk : Walk, limit : Int32 | Nil = nil) : Array(Row2)

The documents matching a walk (S), newest first. Empty walk => all docs. limit is optional and currently unused by the mount (no paging yet — it lists everything); kept for when DirFiller-based paging lands (§7 scale).

Source
facets(walk : Walk) : Array(String)

The facet entries at a walk position: the distinct next path-component among S's tag-paths with prefix partial, kept only if it would actually narrow S (some doc lacks it, or it branches further) — the §7 appearance rule.

Source
index_document(doc : Document) : Nil

Materialize one document's facet rows (delete-then-insert so it's idempotent — safe to call after every mutating op to keep the index fresh).

Source
neighborhood(name : String, type : String | Nil) : Array(Row)

The collision neighborhood (§7): documents sharing a name (and type) — the stable set against which a minimal distinguishing description is computed. Exposed now; the description-rendering UX is a later slice.

Source
rebuild

Full rebuild from the logs — the disposable-cache guarantee made real.

Source
rebuild_errors
Source
rebuild_warnings
Source
tag_complete?(path : String) : Bool

Does a tag-path equal path exactly (a completed tag, not just a prefix)?

Source
tag_prefix_exists?(prefix : String) : Bool

Does any tag-path equal prefix or extend it (prefix/...)? Drives the walk's boundary detection: a segment extends the current partial iff this is true; otherwise the partial was a completed leaf and a new tag begins.

Source
walk(components : Array(String)) : Walk

Fold path components into a Walk: greedily extend the current partial while it stays a real tag-prefix; a component that can't extend it starts a fresh tag (the old partial becomes an AND constraint). Crucially, when the partial reaches a COMPLETE tag it is committed as a constraint and reset to empty — so the next position enumerates the docs' other keys (co-facets), not just the (nonexistent) children of the completed leaf (§7: "P' is a stored tag => reset").

Source

Nested types