vfs

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: May 9, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package vfs provides a pluggable virtual handler chain for mache's virtual path types (_schema.json, PROMPT.txt, _diagnostics/, context, callers/, callees/, .query/). Both the FUSE and NFS backends delegate to a shared Resolver instead of duplicating if-chains.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CalleesHandler

type CalleesHandler struct {
	Graph graph.Graph
}

CalleesHandler serves the virtual callees/ directory and its symlink entries.

func (*CalleesHandler) DirExtras

func (h *CalleesHandler) DirExtras(parentPath string, _ *graph.Node) []DirExtra

func (*CalleesHandler) ListDir

func (h *CalleesHandler) ListDir(path string) ([]DirExtra, bool)

func (*CalleesHandler) Match

func (h *CalleesHandler) Match(path string) bool

func (*CalleesHandler) ReadContent

func (h *CalleesHandler) ReadContent(path string) ([]byte, bool)

func (*CalleesHandler) Stat

func (h *CalleesHandler) Stat(path string) *VEntry

type CallersHandler

type CallersHandler struct {
	Graph graph.Graph
}

CallersHandler serves the virtual callers/ directory and its symlink entries.

func (*CallersHandler) DirExtras

func (h *CallersHandler) DirExtras(parentPath string, _ *graph.Node) []DirExtra

func (*CallersHandler) ListDir

func (h *CallersHandler) ListDir(path string) ([]DirExtra, bool)

func (*CallersHandler) Match

func (h *CallersHandler) Match(path string) bool

func (*CallersHandler) ReadContent

func (h *CallersHandler) ReadContent(path string) ([]byte, bool)

func (*CallersHandler) Stat

func (h *CallersHandler) Stat(path string) *VEntry

type ContextHandler

type ContextHandler struct {
	Graph graph.Graph
}

ContextHandler serves the virtual "context" file inside directory nodes.

func (*ContextHandler) DirExtras

func (h *ContextHandler) DirExtras(parentPath string, node *graph.Node) []DirExtra

func (*ContextHandler) ListDir

func (h *ContextHandler) ListDir(_ string) ([]DirExtra, bool)

func (*ContextHandler) Match

func (h *ContextHandler) Match(path string) bool

func (*ContextHandler) ReadContent

func (h *ContextHandler) ReadContent(path string) ([]byte, bool)

func (*ContextHandler) Stat

func (h *ContextHandler) Stat(path string) *VEntry

type DiagnosticsHandler

type DiagnosticsHandler struct {
	Writable   bool
	DiagStatus *sync.Map // parentDir → status string
}

DiagnosticsHandler serves the /_diagnostics/ virtual directory. Requires Writable=true and a DiagStatus sync.Map (shared with MemoryStore.WriteStatus).

func (*DiagnosticsHandler) DirExtras

func (h *DiagnosticsHandler) DirExtras(parentPath string, _ *graph.Node) []DirExtra

func (*DiagnosticsHandler) ListDir

func (h *DiagnosticsHandler) ListDir(path string) ([]DirExtra, bool)

func (*DiagnosticsHandler) Match

func (h *DiagnosticsHandler) Match(path string) bool

func (*DiagnosticsHandler) ReadContent

func (h *DiagnosticsHandler) ReadContent(path string) ([]byte, bool)

func (*DiagnosticsHandler) Stat

func (h *DiagnosticsHandler) Stat(path string) *VEntry

type DirExtra

type DirExtra struct {
	Name string
	Kind EntryKind
	Size int64
	Perm uint32
}

DirExtra is a child entry injected into a real directory listing.

type EntryKind

type EntryKind int

EntryKind classifies a virtual entry.

const (
	KindNone    EntryKind = iota
	KindDir               // Virtual directory (e.g., _diagnostics/, callers/)
	KindFile              // Virtual regular file (e.g., _schema.json, context)
	KindSymlink           // Virtual symlink (e.g., callers/<entry>, callees/<entry>)
)

type LocationHandler

type LocationHandler struct {
	Graph graph.Graph
}

LocationHandler serves the virtual "location" file inside directory nodes that have a Properties["location"] value (e.g., "internal/ingest/engine.go:142:298"). This bridges the orientation gap between mache's construct-based paths and the original source file coordinates.

func (*LocationHandler) DirExtras

func (h *LocationHandler) DirExtras(parentPath string, node *graph.Node) []DirExtra

func (*LocationHandler) ListDir

func (h *LocationHandler) ListDir(_ string) ([]DirExtra, bool)

func (*LocationHandler) Match

func (h *LocationHandler) Match(path string) bool

func (*LocationHandler) ReadContent

func (h *LocationHandler) ReadContent(path string) ([]byte, bool)

func (*LocationHandler) Stat

func (h *LocationHandler) Stat(path string) *VEntry

type PromptHandler

type PromptHandler struct {
	Content []byte
}

PromptHandler serves the /PROMPT.txt virtual file (agent mode). If Content is nil/empty, the handler reports no match.

func (*PromptHandler) DirExtras

func (h *PromptHandler) DirExtras(parentPath string, _ *graph.Node) []DirExtra

func (*PromptHandler) ListDir

func (h *PromptHandler) ListDir(_ string) ([]DirExtra, bool)

func (*PromptHandler) Match

func (h *PromptHandler) Match(path string) bool

func (*PromptHandler) ReadContent

func (h *PromptHandler) ReadContent(path string) ([]byte, bool)

func (*PromptHandler) Stat

func (h *PromptHandler) Stat(path string) *VEntry

type Resolver

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

Resolver iterates a chain of VHandlers in registration order. The first handler whose Match returns true wins.

func NewDefaultResolver

func NewDefaultResolver(g graph.Graph, schemaJSON []byte) *Resolver

NewDefaultResolver builds the standard handler chain for the NFS backend. Callers configure behaviour via SetPromptContent and SetWritable rather than accessing individual handlers.

func NewResolver

func NewResolver(handlers ...VHandler) *Resolver

NewResolver creates a Resolver with the given handlers. Order matters — first match wins.

func (*Resolver) DirExtras

func (r *Resolver) DirExtras(parentPath string, node *graph.Node) []DirExtra

DirExtras collects extras from ALL handlers (not just first match). Each handler decides independently whether to inject entries.

func (*Resolver) ListDir

func (r *Resolver) ListDir(path string) ([]DirExtra, bool)

ListDir delegates to the first matching handler that returns entries.

func (*Resolver) Match

func (r *Resolver) Match(path string) bool

Match returns true if any handler matches the path.

func (*Resolver) ReadContent

func (r *Resolver) ReadContent(path string) ([]byte, bool)

ReadContent delegates to the first matching handler that returns content.

func (*Resolver) Resolve

func (r *Resolver) Resolve(path string) *VEntry

Resolve returns a VEntry for the path, or nil if no handler matches. When a handler matches but Stat returns nil (e.g., a node named "context" that has no virtual content), resolution continues to the next handler so the path can fall through to the graph lookup.

func (*Resolver) SetPromptContent

func (r *Resolver) SetPromptContent(content []byte)

SetPromptContent sets the content for the /PROMPT.txt virtual file.

func (*Resolver) SetWritable

func (r *Resolver) SetWritable(writable bool, diagStatus *sync.Map)

SetWritable enables _diagnostics/ virtual dirs and wires the status map.

type SchemaHandler

type SchemaHandler struct {
	Content []byte // Serialized schema JSON
}

SchemaHandler serves the /_schema.json virtual file.

func (*SchemaHandler) DirExtras

func (h *SchemaHandler) DirExtras(parentPath string, _ *graph.Node) []DirExtra

func (*SchemaHandler) ListDir

func (h *SchemaHandler) ListDir(_ string) ([]DirExtra, bool)

func (*SchemaHandler) Match

func (h *SchemaHandler) Match(path string) bool

func (*SchemaHandler) ReadContent

func (h *SchemaHandler) ReadContent(path string) ([]byte, bool)

func (*SchemaHandler) Stat

func (h *SchemaHandler) Stat(path string) *VEntry

type VEntry

type VEntry struct {
	Kind    EntryKind
	Size    int64
	Perm    uint32 // Unix permission bits (e.g. 0o444, 0o555)
	Content []byte // File content (KindFile) or symlink target (KindSymlink)
	NodeID  string // Graph node ID — NFS uses this to create graphFile
}

VEntry is the stat result for a virtual path.

type VHandler

type VHandler interface {
	// Match returns true if this handler owns the given path.
	Match(path string) bool

	// Stat returns a VEntry for the path, or nil if the path does not exist.
	Stat(path string) *VEntry

	// ReadContent returns the byte content for a virtual file.
	// Returns (nil, false) if not applicable.
	ReadContent(path string) ([]byte, bool)

	// ListDir returns directory entries for a virtual directory.
	// Returns (nil, false) if not applicable (i.e. path is not a virtual dir).
	ListDir(path string) ([]DirExtra, bool)

	// DirExtras returns extra entries to inject into a real directory listing.
	// Called for every non-virtual directory to let handlers add their entries
	// (e.g., _diagnostics/ added to writable dirs, callers/ added when callers exist).
	DirExtras(parentPath string, node *graph.Node) []DirExtra
}

VHandler resolves one family of virtual paths (e.g., callers/, _diagnostics/).

Jump to

Keyboard shortcuts

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