filetime

package
v0.0.0-beta Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package filetime tracks file read operations to enforce "read before edit" semantics. Each Tracker instance maintains its own read map, providing per-session isolation (parent assistant and each subagent get independent tracking).

Index

Constants

This section is empty.

Variables

View Source
var ErrReadRequired = errors.New("file was modified or not yet read — read it again to see current content before making changes")

ErrReadRequired is returned when a file must be read before editing.

Functions

func WithTracker

func WithTracker(ctx context.Context, t *Tracker) context.Context

WithTracker returns a derived context carrying a Tracker.

Types

type Tracker

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

Tracker tracks file reads and carries the read-before enforcement policy for a single session boundary (parent assistant or individual subagent).

All methods are nil-safe: a nil Tracker is a no-op for mutations and returns sane defaults for queries. This allows tools to call FromContext(ctx).RecordRead(...) without nil-checking, even when no Tracker is on the context (e.g. aura tools subcommand).

func FromContext

func FromContext(ctx context.Context) *Tracker

FromContext extracts the Tracker from the context, or nil. A nil Tracker is safe to use — all methods are nil-safe.

func NewTracker

func NewTracker(policy tool.ReadBeforePolicy) *Tracker

NewTracker creates a Tracker with the given base policy and an empty read map.

func (*Tracker) AssertRead

func (t *Tracker) AssertRead(path string) error

AssertRead returns ErrReadRequired if file was not read.

func (*Tracker) ClearRead

func (t *Tracker) ClearRead(path string)

ClearRead marks a file as needing to be read again.

func (*Tracker) Policy

func (t *Tracker) Policy() tool.ReadBeforePolicy

Policy returns the effective read-before policy.

func (*Tracker) RecordRead

func (t *Tracker) RecordRead(path string)

RecordRead marks a file as read.

func (*Tracker) RuntimeOverride

func (t *Tracker) RuntimeOverride() *tool.ReadBeforePolicy

RuntimeOverride returns the runtime policy override, or nil if none was set. Used by subagent construction to decide whether to override the child's config-resolved policy with the parent's session-wide runtime decision.

func (*Tracker) SetPolicy

func (t *Tracker) SetPolicy(p tool.ReadBeforePolicy)

SetPolicy records a runtime policy override. This is called from the /readbefore slash command and session resume — both represent deliberate non-default policy that should propagate to subagents.

func (*Tracker) WasRead

func (t *Tracker) WasRead(path string) bool

WasRead returns true if the file was read in this tracker's session.

Jump to

Keyboard shortcuts

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