Documentation
¶
Overview ¶
Bundles of markdown files in and out of Postgres, ported from 2de90d2:src/keepsake/cli/__init__.py.
The seven tool bodies, ported from 2de90d2:src/keepsake/server/tools.py. The tenant comes from the request's caller, so no tool takes one, and no tool returns a body the agent could not read.
Index ¶
- Constants
- Variables
- func Prune(ctx context.Context, cs *repositories.ConceptRepository, r Retention, ...) (reads, revisions int, err error)
- func ValidateBundle(root string) (errs, warnings []string, err error)
- type BundleService
- func (b *BundleService) Export(ctx context.Context, tenant uuid.UUID, root string) (int, error)
- func (b *BundleService) Import(ctx context.Context, tenant uuid.UUID, root string) (int, error)
- func (b *BundleService) Replace(ctx context.Context, tenant uuid.UUID, prefix string, concepts []okf.Concept, ...) (written, deleted int, err error)
- type Card
- type Concept
- type ConceptService
- func (t *ConceptService) Actor() string
- func (t *ConceptService) As(tenant uuid.UUID, actor string) *ConceptService
- func (t *ConceptService) Create(ctx context.Context, path string, kw map[string]any) (WriteResult, error)
- func (t *ConceptService) Grep(ctx context.Context, pattern string, limit int) ([]GrepHit, error)
- func (t *ConceptService) List(ctx context.Context, prefix string, limit int) (Listing, error)
- func (t *ConceptService) PoolSize() int
- func (t *ConceptService) Read(ctx context.Context, path string, o ReadOptions) (*Concept, error)
- func (t *ConceptService) Relate(ctx context.Context, fromPath, toPath string) (any, error)
- func (t *ConceptService) Search(ctx context.Context, query string, limit int, prefix *string) ([]Card, error)
- func (t *ConceptService) Tenant() uuid.UUID
- func (t *ConceptService) Update(ctx context.Context, path string, expectedVersion *int, kw map[string]any) (any, error)
- type ConflictResult
- type ConsoleService
- func (s *ConsoleService) Activity(ctx context.Context, tenant *uuid.UUID, limit int) ([]models.Revision, error)
- func (s *ConsoleService) Detail(ctx context.Context, tenant uuid.UUID, path string, limit int) (*okf.Concept, []string, []models.Revision, error)
- func (s *ConsoleService) Graph(ctx context.Context, tenant uuid.UUID) (Graph, error)
- func (s *ConsoleService) Grep(ctx context.Context, tenant uuid.UUID, pattern string, limit int) ([]GrepHit, error)
- func (s *ConsoleService) Page(ctx context.Context, tenant *uuid.UUID, prefix string, limit, offset int) ([]models.Summary, int, error)
- func (s *ConsoleService) Search(ctx context.Context, tenant uuid.UUID, query string, limit int) ([]SearchHit, error)
- func (s *ConsoleService) Tenants(ctx context.Context) ([]models.TenantCount, error)
- func (s *ConsoleService) Timeseries(ctx context.Context, tenant *uuid.UUID, unit string, n int) ([]models.Bucket, error)
- func (s *ConsoleService) Totals(ctx context.Context, tenant *uuid.UUID) (models.Totals, error)
- type Graph
- type GraphNode
- type GrepHit
- type Listing
- type ReadOptions
- type Retention
- type SearchHit
- type ToolError
- type WriteResult
Constants ¶
const ( // DefaultBodyChars is the window the platform's triage agent cut bodies to before keepsake did. DefaultBodyChars = 40_000 // MaxLinks is the link count the platform's triage agent capped each list to. MaxLinks = 25 // FrontmatterBytes is the JSON size past which read drops trailing frontmatter keys. FrontmatterBytes = 4096 // SnippetBytes leaves search's two 25-word passages whole and stops one unbroken run. SnippetBytes = 512 )
The bounds on what one read, search or grep returns, so a single call cannot fill an agent's context.
const ImportActor = "process:import"
ImportActor is the OKF §7 process actor an import records, since it copies a bundle in.
Variables ¶
var ProvenanceKeys = []string{"sources", "generated"}
ProvenanceKeys are left out of read unless included, since every import and write grows them.
Functions ¶
func Prune ¶
func Prune(ctx context.Context, cs *repositories.ConceptRepository, r Retention, now time.Time) (reads, revisions int, err error)
Prune applies r to every tenant, one tenant at a time, and returns how many reads and revisions it deleted.
func ValidateBundle ¶
ValidateBundle returns every rule the bundle breaks, and its broken links as warnings, since OKF §6.1 allows them.
Types ¶
type BundleService ¶
type BundleService struct {
// contains filtered or unexported fields
}
BundleService moves bundles of markdown files in and out of a tenant's concepts.
func NewBundleService ¶
func NewBundleService(r *repositories.ConceptRepository) *BundleService
type Concept ¶
type Concept struct {
Path string `json:"path"`
Type string `json:"type"`
Title string `json:"title"`
Description string `json:"description"`
Body string `json:"body"`
BodyChars int `json:"body_chars"`
NextOffset *int `json:"next_offset"`
Frontmatter *okf.Map `json:"frontmatter"`
FrontmatterTruncated bool `json:"frontmatter_truncated"`
Version int `json:"version"`
Links []string `json:"links"`
LinksCount int `json:"links_count"`
Backlinks []string `json:"backlinks"`
BacklinksCount int `json:"backlinks_count"`
okf.Signals
}
type ConceptService ¶
type ConceptService struct {
// contains filtered or unexported fields
}
func NewConceptService ¶
func NewConceptService(cs *repositories.ConceptRepository, tenant uuid.UUID, actor string) *ConceptService
func (*ConceptService) Actor ¶
func (t *ConceptService) Actor() string
func (*ConceptService) As ¶
func (t *ConceptService) As(tenant uuid.UUID, actor string) *ConceptService
As returns a copy acting for tenant as actor.
func (*ConceptService) Create ¶
func (t *ConceptService) Create(ctx context.Context, path string, kw map[string]any) (WriteResult, error)
func (*ConceptService) List ¶
List returns the first limit paths under prefix, with counts and a total over all of them.
func (*ConceptService) PoolSize ¶
func (t *ConceptService) PoolSize() int
PoolSize is the most database connections the service can hold at once.
func (*ConceptService) Read ¶
func (t *ConceptService) Read(ctx context.Context, path string, o ReadOptions) (*Concept, error)
Read returns one page of the concept at path, or nil when nothing is stored there.
func (*ConceptService) Relate ¶
Relate appends the edge, retrying past concurrent writers, since appending a link commutes.
func (*ConceptService) Tenant ¶
func (t *ConceptService) Tenant() uuid.UUID
type ConflictResult ¶
type ConsoleService ¶
type ConsoleService struct {
// contains filtered or unexported fields
}
ConsoleService serves the admin console's reads.
func NewConsoleService ¶
func NewConsoleService(r *repositories.ConceptRepository) *ConsoleService
func (*ConsoleService) Tenants ¶
func (s *ConsoleService) Tenants(ctx context.Context) ([]models.TenantCount, error)
func (*ConsoleService) Timeseries ¶
type ReadOptions ¶
type ReadOptions struct {
Offset int
MaxChars int
// Include names the ProvenanceKeys to return.
Include []string
}
ReadOptions bounds a Read. A zero MaxChars means DefaultBodyChars.
type Retention ¶
type Retention struct {
ReadDays int
RevisionDays int
// RevisionKeep is how many of each path's newest revisions survive any age.
RevisionKeep int
}
Retention is how long prune keeps reads and revisions. RevisionDays 0 keeps every revision.
type ToolError ¶
type ToolError struct{ Msg string }
ToolError is surfaced to the agent. It MUST NOT contain a concept body.