knowledge

package
v0.36.0 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package knowledge stores project guidance independently of contract workflows.

Index

Constants

View Source
const (
	// MaxQueryBytes bounds user-provided search text.
	MaxQueryBytes = 1024
	// MaxQueryTerms bounds the distinct normalized terms in a search.
	MaxQueryTerms = 32
	// DefaultSearchLimit is the result limit used by the CLI when omitted.
	DefaultSearchLimit = 20
	// MaxSearchLimit is the largest result set retained and returned.
	MaxSearchLimit = 100
	// MaxSnippetRunes bounds body context without splitting UTF-8.
	MaxSnippetRunes = 240
)
View Source
const MaxBodyBytes = 1 << 20

MaxBodyBytes bounds one page to 1 MiB of UTF-8 text.

Variables

View Source
var (
	ErrProjectNotFound  = errors.New("project not found")
	ErrProjectArchived  = errors.New("project is archived")
	ErrPageNotFound     = errors.New("knowledge page not found")
	ErrPageExists       = errors.New("knowledge page already exists")
	ErrRevisionConflict = errors.New("knowledge page changed; read the latest revision and reconcile the edit")
	ErrInvalidInput     = errors.New("invalid knowledge input")
)

Functions

This section is empty.

Types

type CreateParams

type CreateParams struct {
	Project, Slug, Title, Body, Actor string
}

CreateParams defines the initial content of a project page.

type Metadata

type Metadata struct {
	ID         int64     `json:"id"`
	ProjectID  int64     `json:"projectId"`
	ProjectKey string    `json:"projectKey"`
	Slug       string    `json:"slug"`
	Title      string    `json:"title"`
	Revision   int       `json:"revision"`
	CreatedAt  time.Time `json:"createdAt"`
	UpdatedAt  time.Time `json:"updatedAt"`
}

Metadata is the body-free index entry for a project page.

type Page

type Page struct {
	Metadata
	Body string `json:"body"`
}

Page is the latest content at a stable project/slug reference.

type SearchParams added in v0.4.0

type SearchParams struct {
	Project string
	Query   string
	Limit   int
}

SearchParams identifies one bounded project knowledge search.

type SearchResult added in v0.4.0

type SearchResult struct {
	Metadata
	Snippet       string   `json:"snippet"`
	MatchedFields []string `json:"matchedFields"`
	// contains filtered or unexported fields
}

SearchResult is page metadata plus safe body context and fixed-order match fields.

type SearchResults added in v0.4.0

type SearchResults struct {
	Query     string         `json:"query"`
	Results   []SearchResult `json:"results"`
	Total     int            `json:"total"`
	Limit     int            `json:"limit"`
	Truncated bool           `json:"truncated"`
}

SearchResults contains exact match metadata and at most Limit ranked results.

type Store

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

Store owns knowledge persistence in the shared control plane.

func Open

func Open(ctx context.Context, path string) (*Store, error)

Open opens the control plane and applies forward technical migrations.

func OpenReadOnly added in v0.4.0

func OpenReadOnly(ctx context.Context, path string) (*Store, error)

OpenReadOnly opens an existing fully migrated control plane without creating, migrating, auditing, or otherwise changing it.

func (*Store) Close

func (s *Store) Close() error

Close releases the database connection.

func (*Store) Create

func (s *Store) Create(ctx context.Context, p CreateParams) (Page, error)

Create persists a page and its audit event in one transaction.

func (*Store) Get

func (s *Store) Get(ctx context.Context, reference, slug string) (Page, error)

Get reads current content by project name/key and stable page slug.

func (*Store) List

func (s *Store) List(ctx context.Context, reference string) ([]Metadata, error)

List returns the small project index without loading page bodies.

func (*Store) Search added in v0.4.0

func (s *Store) Search(ctx context.Context, params SearchParams) (SearchResults, error)

Search scans current pages within one project and retains only the bounded top results.

func (*Store) Update

func (s *Store) Update(ctx context.Context, p UpdateParams) (Page, error)

Update atomically replaces content, advances its revision, and records audit.

type UpdateParams

type UpdateParams struct {
	Project, Slug, Title, Body, Actor string
	ExpectedRevision                  int
}

UpdateParams replaces a page only if the caller observed its current revision.

Jump to

Keyboard shortcuts

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