facts

package
v1.0.13 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2026 License: MIT Imports: 12 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Store of findings an agent records while it works, persisted as session records and exported as Markdown

Index

Constants

View Source
const (
	StatusOpen      = "open"
	StatusResolved  = "resolved"
	StatusRetracted = "retracted"
)
View Source
const (
	OpAdd    = "add"
	OpUpdate = "update"
	OpRemove = "remove"
)
View Source
const RecordKind = "fact"

Kind of record a session keeps for every fact change

View Source
const ToolName = "Record"

Name the model calls to record a finding

Variables

View Source
var DefaultKinds = []string{"finding", "risk", "decision", "question", "note"}

Kinds a fact may use when the caller does not restrict them

Functions

This section is empty.

Types

type Change

type Change struct {
	Op   string `json:"op"`
	Fact Fact   `json:"fact"`
}

Change to the store, written to the session log and handed to listeners

type Evidence

type Evidence struct {
	// What the reference names, such as file, url, command or tool
	Kind string `json:"kind"`
	Ref  string `json:"ref"`
	Line int    `json:"line,omitempty"`
	// Passage copied from the source
	Quote string `json:"quote,omitempty"`
}

Where a fact was seen

type Fact

type Fact struct {
	ID    string    `json:"id"`
	Time  time.Time `json:"time"`
	Agent string    `json:"agent,omitempty"`
	// Grouping such as finding, risk, decision, question or note
	Kind  string   `json:"kind"`
	Title string   `json:"title"`
	Body  string   `json:"body,omitempty"`
	Tags  []string `json:"tags,omitempty"`
	// Belief from zero to one, one when the agent states it as verified
	Confidence float64    `json:"confidence"`
	Evidence   []Evidence `json:"evidence,omitempty"`
	// Open, resolved or retracted
	Status string `json:"status"`
	// Id of the fact this one refines
	Parent string `json:"parent,omitempty"`
}

One recorded finding

func (Fact) Markdown

func (f Fact) Markdown() string

Renders one fact as a Markdown entry

type Node

type Node struct {
	Fact     Fact
	Children []Node
}

One node of the tree view

type Query

type Query struct {
	Kind   string
	Tag    string
	Status string
	Agent  string
	// Case insensitive match over title, body, tags and evidence references
	Text string
	// Smallest confidence included
	MinConfidence float64
}

Filter over the store

type Store

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

Facts keyed by id in insertion order with change listeners

func New

func New() *Store

func (*Store) Add

func (s *Store) Add(f Fact) (Fact, error)

Records a fact, assigning an id and time when the caller gave none

func (*Store) Attach

func (s *Store) Attach(sess *session.Session)

Writes every later change into the session log so the facts survive with the transcript

func (*Store) ByKind

func (s *Store) ByKind() [][]Fact

Facts grouped by kind, kinds sorted and facts in insertion order

func (*Store) Get

func (s *Store) Get(id string) (Fact, bool)

func (*Store) JSON

func (s *Store) JSON() ([]byte, error)

Serializes every fact as a JSON list

func (*Store) Kinds

func (s *Store) Kinds() map[string]int

Kinds present in the store with how many facts each holds, sorted by kind

func (*Store) Len

func (s *Store) Len() int

func (*Store) List

func (s *Store) List(q Query) []Fact

Facts in insertion order, every one when the query is empty

func (*Store) Markdown

func (s *Store) Markdown() string

Renders every fact as Markdown grouped by kind with evidence as a list under each

func (*Store) OnChange

func (s *Store) OnChange(fn func(Change))

Registers a listener called after every change outside the store lock

func (*Store) Remove

func (s *Store) Remove(id string) bool

Forgets a fact

func (*Store) Restore

func (s *Store) Restore(sess *session.Session) error

Rebuilds the store from the fact records of a session, replaying adds, updates and removes in order

func (*Store) SetStatus

func (s *Store) SetStatus(id, status string) (Fact, error)

Marks a fact resolved or retracted without rewriting it

func (*Store) Tags

func (s *Store) Tags() map[string]int

Tags present in the store with how many facts carry each

func (*Store) Tree

func (s *Store) Tree() []Node

Facts arranged by parent, roots in insertion order and children under the fact they refine

func (*Store) Update

func (s *Store) Update(f Fact) (Fact, error)

Replaces the fact with the same id, keeping its time and position

type Tool

type Tool struct {
	// Store of the calling run
	Resolve func(context.Context) *Store
}

Tool that lets an agent record, refine and resolve facts in the store of its run

func (Tool) Annotations

func (Tool) Annotations() tool.Annotations

func (Tool) Definition

func (t Tool) Definition() protocol.Tool

func (Tool) Run

func (t Tool) Run(ctx context.Context, args json.RawMessage) (tool.Result, error)

Jump to

Keyboard shortcuts

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