Documentation
¶
Overview ¶
Package documents indexes managed local markdown roots for model-facing rediscovery, browse, search, and section retrieval.
The operator-facing contract for what counts as a managed document root lives in docs/understanding/document-roots.md. Keep that document in sync with behavioral changes here, especially when changing how config paths become indexed corpora or how the documents capability is meant to differ from raw file access.
Index ¶
- Constants
- func RenderGeneratedFrontmatter(m GeneratedMetadata) (string, error)
- type AuthoringMode
- type Backlink
- type BrowseArgs
- type BrowseDirectory
- type BrowseResult
- type CommitArgs
- type CommitResult
- type CopyArgs
- type CopyResult
- type DeleteArgs
- type DeleteResult
- type DocumentLink
- type DocumentRecord
- type DocumentSummary
- type EditArgs
- type GeneratedMetadata
- type IntakeAction
- type IntakeArgs
- type IntakeCommitPlan
- type IntakeRelatedDocument
- type IntakeResult
- type IntakeStatus
- type JournalUpdateArgs
- type LinksArgs
- type LinksResult
- type MoveArgs
- type MoveResult
- type MutationResult
- type RefArgs
- type RootDocumentHint
- type RootGitPolicy
- type RootGitPolicySummary
- type RootPolicy
- type RootPolicySummary
- type RootSummary
- type RootVerifier
- type RootWriter
- type SearchArgs
- type SearchQuery
- type Section
- type SectionArgs
- type SectionTransferArgs
- type SectionTransferResult
- type SignatureStatus
- type SignatureVerification
- type Store
- func (s *Store) Browse(ctx context.Context, root, prefix string, limit int) (*BrowseResult, error)
- func (s *Store) Copy(ctx context.Context, args CopyArgs) (*CopyResult, error)
- func (s *Store) CopySection(ctx context.Context, args SectionTransferArgs) (*SectionTransferResult, error)
- func (s *Store) Delete(ctx context.Context, args DeleteArgs) (*DeleteResult, error)
- func (s *Store) Edit(ctx context.Context, args EditArgs) (*MutationResult, error)
- func (s *Store) Intake(ctx context.Context, args IntakeArgs) (*IntakeResult, error)
- func (s *Store) JournalUpdate(ctx context.Context, args JournalUpdateArgs) (*MutationResult, error)
- func (s *Store) Links(ctx context.Context, ref string, mode string, limit int, perBacklinkLimit int) (*LinksResult, error)
- func (s *Store) Move(ctx context.Context, args MoveArgs) (*MoveResult, error)
- func (s *Store) MoveSection(ctx context.Context, args SectionTransferArgs) (*SectionTransferResult, error)
- func (s *Store) Outline(ctx context.Context, ref string) ([]Section, error)
- func (s *Store) Read(ctx context.Context, ref string) (*DocumentRecord, error)
- func (s *Store) Refresh(ctx context.Context) error
- func (s *Store) Roots(ctx context.Context) ([]RootSummary, error)
- func (s *Store) RunRefresher(ctx context.Context)
- func (s *Store) Search(ctx context.Context, q SearchQuery) ([]DocumentSummary, error)
- func (s *Store) Section(ctx context.Context, ref string, selector string) (*Section, error)
- func (s *Store) Values(ctx context.Context, root, key string, limit int) ([]ValueCount, error)
- func (s *Store) VerifyMutationPath(_ context.Context, path string, consumer string) error
- func (s *Store) VerifyPath(ctx context.Context, path string, consumer string) error
- func (s *Store) VerifyRef(ctx context.Context, ref string, consumer string) error
- func (s *Store) Write(ctx context.Context, args WriteArgs) (*MutationResult, error)
- type StoreOptions
- type Tools
- func (t *Tools) Browse(ctx context.Context, args BrowseArgs) (string, error)
- func (t *Tools) Commit(ctx context.Context, args CommitArgs) (string, error)
- func (t *Tools) Copy(ctx context.Context, args CopyArgs) (string, error)
- func (t *Tools) CopySection(ctx context.Context, args SectionTransferArgs) (string, error)
- func (t *Tools) Delete(ctx context.Context, args DeleteArgs) (string, error)
- func (t *Tools) Edit(ctx context.Context, args EditArgs) (string, error)
- func (t *Tools) Intake(ctx context.Context, args IntakeArgs) (string, error)
- func (t *Tools) JournalUpdate(ctx context.Context, args JournalUpdateArgs) (string, error)
- func (t *Tools) Links(ctx context.Context, args LinksArgs) (string, error)
- func (t *Tools) Move(ctx context.Context, args MoveArgs) (string, error)
- func (t *Tools) MoveSection(ctx context.Context, args SectionTransferArgs) (string, error)
- func (t *Tools) Outline(ctx context.Context, args RefArgs) (string, error)
- func (t *Tools) Read(ctx context.Context, args RefArgs) (string, error)
- func (t *Tools) Roots(ctx context.Context) (string, error)
- func (t *Tools) Search(ctx context.Context, args SearchArgs) (string, error)
- func (t *Tools) Section(ctx context.Context, args SectionArgs) (string, error)
- func (t *Tools) Values(ctx context.Context, args ValuesArgs) (string, error)
- func (t *Tools) Write(ctx context.Context, args WriteArgs) (string, error)
- type ValueCount
- type ValuesArgs
- type VerificationMode
- type WriteArgs
Constants ¶
const ( // GeneratedFieldBy is the frontmatter field naming the subsystem or // loop that produced a generated document. GeneratedFieldBy = "generated_by" // GeneratedFieldAt is the frontmatter field recording when a generated // document was produced. GeneratedFieldAt = "generated_at" // GeneratedFieldSourceRefs is the frontmatter field listing source // references used to produce a generated document. GeneratedFieldSourceRefs = "source_refs" // GeneratedFieldDocumentKind is the frontmatter field describing the // semantic kind of generated document. GeneratedFieldDocumentKind = "document_kind" // GeneratedFieldRefreshStrategy is the frontmatter field describing how // repeated generation should treat the document. GeneratedFieldRefreshStrategy = "refresh_strategy" // GeneratedFieldManagedRoot is the optional frontmatter field naming the // managed root prefix when the writer knows it. GeneratedFieldManagedRoot = "managed_root" )
const ( // RefreshStrategyImmutable marks generated documents that should be // written once and left unchanged. RefreshStrategyImmutable = "immutable" // RefreshStrategyReplace marks generated documents that are replaced in // full on refresh. RefreshStrategyReplace = "replace" // RefreshStrategyAppend marks generated documents that grow by appending // new entries. RefreshStrategyAppend = "append" // RefreshStrategyRollingWindow marks generated documents that keep a // bounded recent window. RefreshStrategyRollingWindow = "rolling-window" )
const ( // DocumentKindMediaAnalysis identifies a generated media analysis page. DocumentKindMediaAnalysis = "media_analysis" // DocumentKindMediaChannelIndex identifies an automatically maintained // media channel index page. DocumentKindMediaChannelIndex = "media_channel_index" )
Variables ¶
This section is empty.
Functions ¶
func RenderGeneratedFrontmatter ¶
func RenderGeneratedFrontmatter(m GeneratedMetadata) (string, error)
RenderGeneratedFrontmatter renders generated-document metadata as YAML frontmatter lines suitable for insertion into a larger frontmatter block.
Types ¶
type AuthoringMode ¶
type AuthoringMode string
AuthoringMode describes whether managed document mutation APIs may write to a root.
const ( // AuthoringManaged allows managed document mutation APIs to write // to the root. AuthoringManaged AuthoringMode = "managed" // AuthoringReadOnly prevents managed document mutation APIs from // writing to the root. AuthoringReadOnly AuthoringMode = "read_only" // AuthoringRestricted reserves the root for narrower policy-aware // authoring flows and blocks generic document mutations. AuthoringRestricted AuthoringMode = "restricted" )
type Backlink ¶
type Backlink struct {
Ref string `json:"ref"`
Path string `json:"path"`
Title string `json:"title"`
ModifiedAt string `json:"modified_at"`
Targets []string `json:"targets,omitempty"`
TargetsTruncated bool `json:"targets_truncated,omitempty"`
}
Backlink is one indexed document that links to another document.
type BrowseArgs ¶
type BrowseArgs struct {
Root string `json:"root"`
PathPrefix string `json:"path_prefix,omitempty"`
Limit int `json:"limit,omitempty"`
}
BrowseArgs requests one rooted browse step through an indexed corpus.
type BrowseDirectory ¶
type BrowseDirectory struct {
Name string `json:"name"`
PathPrefix string `json:"path_prefix"`
DocumentCount int `json:"document_count"`
}
BrowseDirectory describes one child directory in a rooted browse view.
type BrowseResult ¶
type BrowseResult struct {
Root string `json:"root"`
PathPrefix string `json:"path_prefix,omitempty"`
Directories []BrowseDirectory `json:"directories,omitempty"`
Documents []DocumentSummary `json:"documents,omitempty"`
}
BrowseResult is the rooted "phone tree" view for one root/prefix.
type CommitArgs ¶
type CommitArgs struct {
IntakeID string `json:"intake_id"`
Action IntakeAction `json:"action,omitempty"`
Body string `json:"body,omitempty"`
Section string `json:"section,omitempty"`
Heading string `json:"heading,omitempty"`
Window string `json:"window,omitempty"`
Confirm bool `json:"confirm,omitempty"`
}
CommitArgs commits an approved document intake plan.
type CommitResult ¶
type CommitResult struct {
IntakeID string `json:"intake_id"`
Action IntakeAction `json:"action"`
Ref string `json:"ref,omitempty"`
Status string `json:"status"`
Result any `json:"result,omitempty"`
}
CommitResult describes the mutation, or draft, created from an intake.
type CopyArgs ¶
type CopyArgs struct {
Ref string `json:"ref"`
DestinationRef string `json:"destination_ref"`
Overwrite bool `json:"overwrite,omitempty"`
}
CopyArgs duplicates one managed document at a new semantic ref.
type CopyResult ¶
type CopyResult struct {
Action string `json:"action"`
FromRef string `json:"from_ref"`
ToRef string `json:"to_ref"`
FromRoot string `json:"from_root"`
FromPath string `json:"from_path"`
ToRoot string `json:"to_root"`
ToPath string `json:"to_path"`
Overwrote bool `json:"overwrote,omitempty"`
Title string `json:"title"`
Description string `json:"description,omitempty"`
Tags []string `json:"tags,omitempty"`
CreatedAt string `json:"created_at,omitempty"`
UpdatedAt string `json:"updated_at,omitempty"`
ModifiedAt string `json:"modified_at"`
WordCount int `json:"word_count"`
SizeBytes int64 `json:"size_bytes"`
}
CopyResult summarizes one managed document copy.
type DeleteArgs ¶
type DeleteArgs struct {
Ref string `json:"ref"`
}
DeleteArgs removes one managed document by semantic ref.
type DeleteResult ¶
type DeleteResult struct {
Action string `json:"action"`
DeletedRef string `json:"deleted_ref"`
Root string `json:"root"`
Path string `json:"path"`
Title string `json:"title"`
Description string `json:"description,omitempty"`
Tags []string `json:"tags,omitempty"`
CreatedAt string `json:"created_at,omitempty"`
UpdatedAt string `json:"updated_at,omitempty"`
ModifiedAt string `json:"modified_at"`
WordCount int `json:"word_count"`
SizeBytes int64 `json:"size_bytes"`
}
DeleteResult summarizes one managed document deletion.
type DocumentLink ¶
type DocumentLink struct {
Target string `json:"target"`
Kind string `json:"kind"`
Ref string `json:"ref,omitempty"`
Title string `json:"title,omitempty"`
URL string `json:"url,omitempty"`
Anchor string `json:"anchor,omitempty"`
}
DocumentLink is one outgoing link projected from an indexed document.
type DocumentRecord ¶
type DocumentRecord struct {
Root string `json:"root"`
Ref string `json:"ref"`
Path string `json:"path"`
Title string `json:"title"`
Description string `json:"description,omitempty"`
Tags []string `json:"tags,omitempty"`
Frontmatter map[string][]string `json:"frontmatter,omitempty"`
Body string `json:"body"`
Outline []Section `json:"outline,omitempty"`
ModifiedAt string `json:"modified_at"`
WordCount int `json:"word_count"`
SizeBytes int64 `json:"size_bytes"`
}
DocumentRecord is the full model-facing view of one managed document.
type DocumentSummary ¶
type DocumentSummary struct {
Root string `json:"root"`
Ref string `json:"ref"`
Path string `json:"path"`
Title string `json:"title"`
Summary string `json:"summary,omitempty"`
Tags []string `json:"tags,omitempty"`
Frontmatter map[string][]string `json:"frontmatter,omitempty"`
ModifiedAt string `json:"modified_at"`
WordCount int `json:"word_count"`
}
DocumentSummary is the compact search/browse view of a document.
type EditArgs ¶
type EditArgs struct {
Ref string `json:"ref"`
Mode string `json:"mode"`
Content string `json:"content,omitempty"`
Section string `json:"section,omitempty"`
Heading string `json:"heading,omitempty"`
Level int `json:"level,omitempty"`
Title string `json:"title,omitempty"`
Description string `json:"description,omitempty"`
Tags []string `json:"tags,omitempty"`
Frontmatter map[string][]string `json:"frontmatter,omitempty"`
}
EditArgs updates part of a managed document without leaving the semantic document abstraction.
type GeneratedMetadata ¶
type GeneratedMetadata struct {
GeneratedBy string `json:"generated_by" yaml:"generated_by"`
GeneratedAt time.Time `json:"generated_at" yaml:"generated_at"`
SourceRefs []string `json:"source_refs,omitempty" yaml:"source_refs,omitempty"`
DocumentKind string `json:"document_kind" yaml:"document_kind"`
RefreshStrategy string `json:"refresh_strategy" yaml:"refresh_strategy"`
ManagedRoot string `json:"managed_root,omitempty" yaml:"managed_root,omitempty"`
}
GeneratedMetadata is the document-local provenance contract for generated markdown artifacts in managed document roots. It intentionally uses only flat frontmatter fields so the document index can filter and expose it without nested YAML support.
func (GeneratedMetadata) Frontmatter ¶
func (m GeneratedMetadata) Frontmatter() map[string][]string
Frontmatter returns the generated-document metadata as index-compatible frontmatter values. Empty optional fields are omitted.
func (GeneratedMetadata) Validate ¶
func (m GeneratedMetadata) Validate() error
Validate reports whether metadata has the minimum fields required for a generated document to be machine-legible.
type IntakeAction ¶
type IntakeAction string
IntakeAction is the document mutation shape recommended by intake.
const ( // IntakeActionCreateNew creates a new managed document at proposed_ref. IntakeActionCreateNew IntakeAction = "create_new" // IntakeActionUpdateExisting updates an existing related document. IntakeActionUpdateExisting IntakeAction = "update_existing" // IntakeActionAppendExisting appends a journal-style note to an // existing related document. IntakeActionAppendExisting IntakeAction = "append_existing" // IntakeActionDraftForReview declines mutation and returns a draft // plan for human or later review. IntakeActionDraftForReview IntakeAction = "draft_for_review" )
type IntakeArgs ¶
type IntakeArgs struct {
Root string `json:"root,omitempty"`
Intent string `json:"intent,omitempty"`
Summary string `json:"summary,omitempty"`
BodySnippet string `json:"body_snippet,omitempty"`
ContentDigest string `json:"content_digest,omitempty"`
DesiredTitle string `json:"desired_title,omitempty"`
DesiredRef string `json:"desired_ref,omitempty"`
Tags []string `json:"tags,omitempty"`
PathPrefix string `json:"path_prefix,omitempty"`
}
IntakeArgs describes a proposed managed-document addition before it is assigned to a final corpus destination.
type IntakeCommitPlan ¶
type IntakeCommitPlan struct {
IntakeID string `json:"intake_id,omitempty"`
RecommendedAction IntakeAction `json:"recommended_action"`
ProposedRef string `json:"proposed_ref,omitempty"`
TargetRef string `json:"target_ref,omitempty"`
NormalizedTitle string `json:"normalized_title,omitempty"`
NormalizedTags []string `json:"normalized_tags,omitempty"`
NormalizedFrontmatter map[string][]string `json:"normalized_frontmatter,omitempty"`
RequiresConfirmation bool `json:"requires_confirmation,omitempty"`
ConfirmationReason string `json:"confirmation_reason,omitempty"`
}
IntakeCommitPlan is the exact structured handoff expected by doc_commit.
type IntakeRelatedDocument ¶
type IntakeRelatedDocument struct {
Ref string `json:"ref"`
Title string `json:"title"`
Path string `json:"path"`
Tags []string `json:"tags,omitempty"`
Score float64 `json:"score"`
Rationale string `json:"rationale,omitempty"`
}
IntakeRelatedDocument describes a corpus document that overlaps with the proposed intake.
type IntakeResult ¶
type IntakeResult struct {
IntakeID string `json:"intake_id,omitempty"`
Status IntakeStatus `json:"status"`
Reason string `json:"reason,omitempty"`
Root string `json:"root"`
RootPolicy RootPolicySummary `json:"root_policy"`
RecommendedAction IntakeAction `json:"recommended_action"`
ProposedRef string `json:"proposed_ref,omitempty"`
TargetRef string `json:"target_ref,omitempty"`
NormalizedTitle string `json:"normalized_title,omitempty"`
NormalizedTags []string `json:"normalized_tags,omitempty"`
NormalizedFrontmatter map[string][]string `json:"normalized_frontmatter,omitempty"`
ObservedTags []ValueCount `json:"observed_tags,omitempty"`
RelatedDocuments []IntakeRelatedDocument `json:"related_documents,omitempty"`
Rationale []string `json:"rationale,omitempty"`
CommitPlan IntakeCommitPlan `json:"commit_plan"`
}
IntakeResult is the model-facing corpus-aware placement analysis.
type IntakeStatus ¶
type IntakeStatus string
IntakeStatus describes whether an intake can be committed directly or needs a second explicit decision.
const ( // IntakeReady means the proposed commit can proceed without extra // confirmation. IntakeReady IntakeStatus = "ready" // IntakeConfirmCreate means a new document is possible, but similar // documents make an update the safer default. IntakeConfirmCreate IntakeStatus = "confirm_create" // IntakeConfirmUpdate means the intake is likely an update or append // to an existing document and should be confirmed before committing. IntakeConfirmUpdate IntakeStatus = "confirm_update" // IntakeDraftForReview means root policy or corpus ambiguity suggests // leaving the content as a draft instead of committing it. IntakeDraftForReview IntakeStatus = "draft_for_review" // IntakeRefused means the target root cannot accept managed commits. IntakeRefused IntakeStatus = "refused" )
type JournalUpdateArgs ¶
type JournalUpdateArgs struct {
Ref string `json:"ref"`
Entry string `json:"entry"`
Window string `json:"window,omitempty"`
MaxWindows int `json:"max_windows,omitempty"`
HeadingLevel int `json:"heading_level,omitempty"`
Title string `json:"title,omitempty"`
Description string `json:"description,omitempty"`
Tags []string `json:"tags,omitempty"`
Frontmatter map[string][]string `json:"frontmatter,omitempty"`
}
JournalUpdateArgs appends a timestamped note into a rolling window journal document while keeping window headings and timestamps stable.
type LinksArgs ¶
type LinksArgs struct {
Ref string `json:"ref"`
Mode string `json:"mode,omitempty"`
Limit int `json:"limit,omitempty"`
PerBacklinkLimit int `json:"per_backlink_limit,omitempty"`
}
LinksArgs requests outgoing links, backlinks, or both for one document.
type LinksResult ¶
type LinksResult struct {
Ref string `json:"ref"`
Mode string `json:"mode"`
Limit int `json:"limit,omitempty"`
PerBacklinkLimit int `json:"per_backlink_limit,omitempty"`
Outgoing []DocumentLink `json:"outgoing,omitempty"`
OutgoingTruncated bool `json:"outgoing_truncated,omitempty"`
Backlinks []Backlink `json:"backlinks,omitempty"`
BacklinksTruncated bool `json:"backlinks_truncated,omitempty"`
}
LinksResult is the outgoing/backlink view for one indexed document.
type MoveArgs ¶
type MoveArgs struct {
Ref string `json:"ref"`
DestinationRef string `json:"destination_ref"`
Overwrite bool `json:"overwrite,omitempty"`
}
MoveArgs relocates one managed document to a new semantic ref.
type MoveResult ¶
type MoveResult struct {
Action string `json:"action"`
FromRef string `json:"from_ref"`
ToRef string `json:"to_ref"`
FromRoot string `json:"from_root"`
FromPath string `json:"from_path"`
ToRoot string `json:"to_root"`
ToPath string `json:"to_path"`
Overwrote bool `json:"overwrote,omitempty"`
Title string `json:"title"`
Description string `json:"description,omitempty"`
Tags []string `json:"tags,omitempty"`
CreatedAt string `json:"created_at,omitempty"`
UpdatedAt string `json:"updated_at,omitempty"`
ModifiedAt string `json:"modified_at"`
WordCount int `json:"word_count"`
SizeBytes int64 `json:"size_bytes"`
}
MoveResult summarizes one managed document move/rename.
type MutationResult ¶
type MutationResult struct {
Action string `json:"action"`
Ref string `json:"ref"`
Root string `json:"root"`
Path string `json:"path"`
Existed bool `json:"existed"`
Title string `json:"title"`
Description string `json:"description,omitempty"`
Tags []string `json:"tags,omitempty"`
CreatedAt string `json:"created_at,omitempty"`
UpdatedAt string `json:"updated_at,omitempty"`
ModifiedAt string `json:"modified_at"`
WordCount int `json:"word_count"`
SizeBytes int64 `json:"size_bytes"`
Section string `json:"section,omitempty"`
Window string `json:"window,omitempty"`
}
MutationResult summarizes one managed document write/edit.
type RefArgs ¶
type RefArgs struct {
Ref string `json:"ref"`
}
RefArgs identifies one managed document by canonical semantic ref.
type RootDocumentHint ¶
type RootDocumentHint struct {
Ref string `json:"ref"`
Path string `json:"path"`
Title string `json:"title"`
ModifiedAt string `json:"modified_at"`
}
RootDocumentHint is a compact example document attached to a root summary.
type RootGitPolicy ¶
type RootGitPolicy struct {
Enabled bool `json:"enabled"`
SignCommits bool `json:"sign_commits,omitempty"`
VerifySignatures VerificationMode `json:"verify_signatures,omitempty"`
RepoPath string `json:"-"`
}
RootGitPolicy describes git-backed provenance policy for a managed document root.
type RootGitPolicySummary ¶
type RootGitPolicySummary struct {
Enabled bool `json:"enabled"`
SignCommits bool `json:"sign_commits,omitempty"`
VerifySignatures VerificationMode `json:"verify_signatures,omitempty"`
}
RootGitPolicySummary is the model-facing form of RootGitPolicy.
type RootPolicy ¶
type RootPolicy struct {
Indexing bool `json:"indexing"`
Authoring AuthoringMode `json:"authoring"`
Git RootGitPolicy `json:"git,omitempty"`
}
RootPolicy describes indexing, authoring, and integrity policy for a managed document root.
type RootPolicySummary ¶
type RootPolicySummary struct {
Indexing bool `json:"indexing"`
Authoring AuthoringMode `json:"authoring"`
Git RootGitPolicySummary `json:"git"`
}
RootPolicySummary is the model-facing form of RootPolicy. It omits local filesystem paths and key material.
type RootSummary ¶
type RootSummary struct {
Root string `json:"root"`
Path string `json:"-"`
Policy RootPolicySummary `json:"policy"`
Verification *SignatureVerification `json:"verification,omitempty"`
DocumentCount int `json:"document_count"`
TotalSizeBytes int64 `json:"total_size_bytes"`
TotalWordCount int `json:"total_word_count"`
LastModifiedAt string `json:"last_modified_at,omitempty"`
TopTags []string `json:"top_tags,omitempty"`
TopDirectories []BrowseDirectory `json:"top_directories,omitempty"`
RecentDocuments []RootDocumentHint `json:"recent_documents,omitempty"`
}
RootSummary describes one indexed document root.
type RootVerifier ¶
type RootVerifier interface {
Verify(ctx context.Context, filename string) (SignatureVerification, error)
VerifyRoot(ctx context.Context) (SignatureVerification, error)
}
RootVerifier verifies that a git-backed root or file is clean and trusted before policy-sensitive consumers load it.
type RootWriter ¶
type RootWriter interface {
Write(ctx context.Context, filename, content, message string) error
Delete(ctx context.Context, filename, message string) error
}
RootWriter applies a managed document mutation to a root. Git-backed roots use this hook to sign and commit writes without exposing git to the model.
type SearchArgs ¶
type SearchArgs struct {
Root string `json:"root,omitempty"`
PathPrefix string `json:"path_prefix,omitempty"`
Query string `json:"query,omitempty"`
Tags []string `json:"tags,omitempty"`
Frontmatter map[string][]string `json:"frontmatter,omitempty"`
FrontmatterKeys []string `json:"frontmatter_keys,omitempty"`
ModifiedAfter string `json:"modified_after,omitempty"`
ModifiedBefore string `json:"modified_before,omitempty"`
Limit int `json:"limit,omitempty"`
}
SearchArgs requests structured document search over indexed roots.
type SearchQuery ¶
type SearchQuery struct {
Root string `json:"root,omitempty"`
PathPrefix string `json:"path_prefix,omitempty"`
Query string `json:"query,omitempty"`
Tags []string `json:"tags,omitempty"`
Frontmatter map[string][]string `json:"frontmatter,omitempty"`
FrontmatterKeys []string `json:"frontmatter_keys,omitempty"`
ModifiedAfter *time.Time `json:"-"`
ModifiedBefore *time.Time `json:"-"`
Limit int `json:"limit,omitempty"`
}
SearchQuery filters document search results.
type Section ¶
type Section struct {
Heading string `json:"heading"`
Slug string `json:"slug"`
Level int `json:"level"`
StartLine int `json:"start_line"`
EndLine int `json:"end_line"`
Content string `json:"content,omitempty"`
}
Section captures one heading-defined region in a markdown document.
type SectionArgs ¶
SectionArgs selects one document section by ref and optional heading.
type SectionTransferArgs ¶
type SectionTransferArgs struct {
Ref string `json:"ref"`
Section string `json:"section"`
DestinationRef string `json:"destination_ref"`
DestinationSection string `json:"destination_section,omitempty"`
DestinationLevel int `json:"destination_level,omitempty"`
}
SectionTransferArgs copies or moves one section into another managed doc.
type SectionTransferResult ¶
type SectionTransferResult struct {
Action string `json:"action"`
SourceRef string `json:"source_ref"`
SourceRoot string `json:"source_root"`
SourcePath string `json:"source_path"`
SourceSection string `json:"source_section"`
DestinationRef string `json:"destination_ref"`
DestinationRoot string `json:"destination_root"`
DestinationPath string `json:"destination_path"`
DestinationSection string `json:"destination_section"`
DestinationLevel int `json:"destination_level"`
DestinationExisted bool `json:"destination_existed"`
Title string `json:"title"`
Description string `json:"description,omitempty"`
Tags []string `json:"tags,omitempty"`
CreatedAt string `json:"created_at,omitempty"`
UpdatedAt string `json:"updated_at,omitempty"`
ModifiedAt string `json:"modified_at"`
WordCount int `json:"word_count"`
SizeBytes int64 `json:"size_bytes"`
}
SectionTransferResult summarizes one section-level copy or move.
type SignatureStatus ¶
type SignatureStatus string
SignatureStatus describes the last known signature verification state for a root or document.
const ( // SignatureTrusted means the checked content is clean and covered by // trusted signed git history. SignatureTrusted SignatureStatus = "trusted" // SignatureFailed means signature policy could not verify the checked // content. SignatureFailed SignatureStatus = "failed" // no verifier could be configured. SignatureUnavailable SignatureStatus = "unavailable" )
type SignatureVerification ¶
type SignatureVerification struct {
Status SignatureStatus `json:"status"`
Mode VerificationMode `json:"mode,omitempty"`
Commit string `json:"commit,omitempty"`
Message string `json:"message,omitempty"`
CheckedAt string `json:"checked_at,omitempty"`
Consumer string `json:"consumer,omitempty"`
}
SignatureVerification is the document package's verifier-neutral signature status shape.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store indexes managed markdown roots into the primary Thane SQLite DB.
func NewStoreWithOptions ¶
func NewStoreWithOptions(db *sql.DB, roots map[string]string, logger *slog.Logger, opts StoreOptions) (*Store, error)
NewStoreWithOptions creates a document index store backed by db and optional per-root policy.
func (*Store) Browse ¶
Browse returns the immediate child directories and documents for a rooted prefix.
func (*Store) CopySection ¶
func (s *Store) CopySection(ctx context.Context, args SectionTransferArgs) (*SectionTransferResult, error)
func (*Store) Delete ¶
func (s *Store) Delete(ctx context.Context, args DeleteArgs) (*DeleteResult, error)
func (*Store) Intake ¶
func (s *Store) Intake(ctx context.Context, args IntakeArgs) (*IntakeResult, error)
Intake analyzes a proposed document contribution against existing corpus structure.
func (*Store) JournalUpdate ¶
func (s *Store) JournalUpdate(ctx context.Context, args JournalUpdateArgs) (*MutationResult, error)
func (*Store) Links ¶
func (s *Store) Links(ctx context.Context, ref string, mode string, limit int, perBacklinkLimit int) (*LinksResult, error)
Links returns outgoing links, backlinks, or both for one indexed document.
func (*Store) MoveSection ¶
func (s *Store) MoveSection(ctx context.Context, args SectionTransferArgs) (*SectionTransferResult, error)
func (*Store) Roots ¶
func (s *Store) Roots(ctx context.Context) ([]RootSummary, error)
Roots returns the current indexed root summaries.
func (*Store) RunRefresher ¶
RunRefresher keeps the index warm in the background using the store's refresh interval. Errors are logged and retried on the next tick.
func (*Store) Search ¶
func (s *Store) Search(ctx context.Context, q SearchQuery) ([]DocumentSummary, error)
Search returns matching documents, sorted by relevance and recency.
func (*Store) Section ¶
Section returns one section by heading text or slug. An empty selector returns the whole document.
func (*Store) VerifyMutationPath ¶
VerifyMutationPath reports whether a raw filesystem mutation is allowed for path. Paths outside configured roots are ignored.
This is deliberately stricter than Store.VerifyPath. A trusted file inside a signed root may be safe to read, but raw writes would dirty the tree without using the root writer that signs managed document mutations. Read-only/restricted roots are also blocked here so file tools cannot bypass root authoring policy.
func (*Store) VerifyPath ¶
VerifyPath verifies an absolute file path when it belongs to a managed document root. Paths outside configured roots are ignored.
type StoreOptions ¶
type StoreOptions struct {
RootPolicies map[string]RootPolicy
RootWriters map[string]RootWriter
RootVerifiers map[string]RootVerifier
}
StoreOptions configures optional root policy and backing writers for Store.
type Tools ¶
type Tools struct {
// contains filtered or unexported fields
}
Tools exposes model-facing document navigation tools.
func (*Tools) Commit ¶
Commit applies a previously returned intake plan through managed document mutation paths.
func (*Tools) CopySection ¶
CopySection copies one section into another managed document.
func (*Tools) JournalUpdate ¶
JournalUpdate appends one journal-window entry to a managed document.
func (*Tools) MoveSection ¶
MoveSection moves one section into another managed document.
func (*Tools) Search ¶
Search returns compact summaries for documents matching the structured filters.
func (*Tools) Section ¶
Section returns one named section, or the whole body when no selector is given.
type ValueCount ¶
ValueCount counts observed frontmatter values.
type ValuesArgs ¶
type ValuesArgs struct {
Root string `json:"root,omitempty"`
Key string `json:"key"`
Limit int `json:"limit,omitempty"`
}
ValuesArgs requests observed values for one frontmatter key.
type VerificationMode ¶
type VerificationMode string
VerificationMode describes the desired signature verification policy for consumers of a managed document root.
const ( // VerificationNone disables signature verification enforcement. VerificationNone VerificationMode = "none" // VerificationWarn records verification failures without blocking // consumers. VerificationWarn VerificationMode = "warn" // VerificationRequired marks the root as requiring trusted signed // history before high-integrity consumers should load or activate // content from it. VerificationRequired VerificationMode = "required" )
type WriteArgs ¶
type WriteArgs struct {
Ref string `json:"ref"`
Title string `json:"title,omitempty"`
Description string `json:"description,omitempty"`
Tags []string `json:"tags,omitempty"`
Frontmatter map[string][]string `json:"frontmatter,omitempty"`
Body *string `json:"body,omitempty"`
JournalEntry string `json:"journal_entry,omitempty"`
}
WriteArgs creates or replaces a whole managed document.
Source Files
¶
- contracts.go
- doc.go
- generated.go
- intake_paths.go
- intake_similarity.go
- intake_store.go
- intake_tools.go
- intake_types.go
- links.go
- model_tool_mutation_results.go
- model_tool_results.go
- mutate.go
- mutate_document_ops.go
- mutate_helpers.go
- mutate_policy.go
- mutate_section_ops.go
- parser.go
- policy.go
- query.go
- query_helpers.go
- refs.go
- root_summary.go
- store.go
- tools.go
- values.go
- verification.go