knowledge

package
v0.0.0-...-9e5e0b2 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2026 License: MIT Imports: 23 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

Index

Constants

View Source
const (
	PageTypeSourceSummary = "source_summary"
	PageTypeEntity        = "entity"
	PageTypeConcept       = "concept"
	PageTypeComparison    = "comparison"
	PageTypeSynthesis     = "synthesis"
	PageTypeDecision      = "decision"
)

Variables

View Source
var (
	ErrJobNotFound        = errors.New("knowledge job not found")
	ErrJobForbidden       = errors.New("knowledge job forbidden")
	ErrReportNotReady     = errors.New("knowledge report not ready")
	ErrJobAlreadyTerminal = errors.New("knowledge job already terminal")
	ErrPageNotFound       = errors.New("knowledge page not found")
)

Functions

This section is empty.

Types

type AnswerRequest

type AnswerRequest struct {
	Query         string   `json:"query"`
	PageSlug      string   `json:"page_slug,omitempty"`
	ArchiveAnswer bool     `json:"archive_answer,omitempty"`
	QueryScope    string   `json:"query_scope,omitempty"`
	SelectedRefs  []string `json:"selected_refs,omitempty"`
}

type CompileRequest

type CompileRequest struct {
	TargetPaths []string `json:"target_paths,omitempty"`
	ProviderID  string   `json:"provider_id,omitempty"`
}

type CreateJobRequest

type CreateJobRequest struct {
	RequestedID   string   `json:"requested_id,omitempty"`
	UserID        string   `json:"user_id,omitempty"`
	TenantID      string   `json:"tenant_id,omitempty"`
	ProviderID    string   `json:"provider_id,omitempty"`
	Query         string   `json:"query,omitempty"`
	Kind          JobKind  `json:"kind"`
	TargetPaths   []string `json:"target_paths,omitempty"`
	TargetSlugs   []string `json:"target_slugs,omitempty"`
	PageSlug      string   `json:"page_slug,omitempty"`
	ArchiveAnswer bool     `json:"archive_answer,omitempty"`
	QueryScope    string   `json:"query_scope,omitempty"`
	SelectedRefs  []string `json:"selected_refs,omitempty"`
}

type Event

type Event struct {
	ID        string      `json:"id,omitempty"`
	Type      string      `json:"type"`
	Timestamp time.Time   `json:"timestamp"`
	Payload   interface{} `json:"payload,omitempty"`
}

type EventPublisher

type EventPublisher interface {
	Publish(userID string, eventType string, data any)
}

type Handler

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

func NewHandler

func NewHandler(service *Service) *Handler

func (*Handler) CancelJob

func (h *Handler) CancelJob(c echo.Context) error

func (*Handler) CreateJob

func (h *Handler) CreateJob(c echo.Context) error

func (*Handler) GetIndex

func (h *Handler) GetIndex(c echo.Context) error

func (*Handler) GetJob

func (h *Handler) GetJob(c echo.Context) error

func (*Handler) GetLatestLint

func (h *Handler) GetLatestLint(c echo.Context) error

func (*Handler) GetLog

func (h *Handler) GetLog(c echo.Context) error

func (*Handler) GetPage

func (h *Handler) GetPage(c echo.Context) error

func (*Handler) GetReport

func (h *Handler) GetReport(c echo.Context) error

func (*Handler) GetSchema

func (h *Handler) GetSchema(c echo.Context) error

func (*Handler) ListJobs

func (h *Handler) ListJobs(c echo.Context) error

func (*Handler) ListPages

func (h *Handler) ListPages(c echo.Context) error

func (*Handler) PromoteQuery

func (h *Handler) PromoteQuery(c echo.Context) error

func (*Handler) RegisterGroup

func (h *Handler) RegisterGroup(g *echo.Group)

func (*Handler) RegisterRoutes

func (h *Handler) RegisterRoutes(e *echo.Echo)

func (*Handler) SetJobCreator

func (h *Handler) SetJobCreator(creator interface {
	CreateJob(ctx context.Context, req CreateJobRequest) (*KnowledgeJob, error)
})

func (*Handler) StreamEvents

func (h *Handler) StreamEvents(c echo.Context) error

func (*Handler) UpdateSchema

func (h *Handler) UpdateSchema(c echo.Context) error

type IssueKind

type IssueKind string
const (
	IssueKindStaleHash        IssueKind = "stale_hash"
	IssueKindOrphanPage       IssueKind = "orphan_page"
	IssueKindDuplicateTopic   IssueKind = "duplicate_topic"
	IssueKindMissingBacklinks IssueKind = "missing_backlinks"
	IssueKindLowQuality       IssueKind = "low_quality"
	IssueKindMissingIndex     IssueKind = "missing_index"
	IssueKindConflictingClaim IssueKind = "conflicting_claim"
	IssueKindInsufficientSrc  IssueKind = "insufficient_sources"
	IssueKindMissingConcept   IssueKind = "missing_concept_page"
	IssueKindMissingEntity    IssueKind = "missing_entity_page"
)

type JobKind

type JobKind string
const (
	JobKindIngest          JobKind = "ingest"
	JobKindCompile         JobKind = "compile"
	JobKindLint            JobKind = "lint"
	JobKindAnswer          JobKind = "answer"
	JobKindRepairConflicts JobKind = "repair_conflicts"
)

type JobStatus

type JobStatus string
const (
	JobStatusPending   JobStatus = "pending"
	JobStatusRunning   JobStatus = "running"
	JobStatusCompleted JobStatus = "completed"
	JobStatusFailed    JobStatus = "failed"
	JobStatusCancelled JobStatus = "cancelled"
)

type KnowledgeAnswerReport

type KnowledgeAnswerReport struct {
	GeneratedAt      time.Time              `json:"generated_at"`
	Query            string                 `json:"query"`
	Answer           string                 `json:"answer"`
	Citations        []KnowledgeCitation    `json:"citations"`
	RelatedPages     []KnowledgePageSummary `json:"related_pages,omitempty"`
	ArchivedPath     string                 `json:"archived_path,omitempty"`
	Confidence       KnowledgeConfidence    `json:"confidence,omitempty"`
	ConflictNotes    []string               `json:"conflict_notes,omitempty"`
	OpenQuestions    []string               `json:"open_questions,omitempty"`
	PromotedPageSlug string                 `json:"promoted_page_slug,omitempty"`
}

type KnowledgeArchivedAnswer

type KnowledgeArchivedAnswer struct {
	Title       string    `json:"title"`
	Path        string    `json:"path"`
	PageSlug    string    `json:"page_slug"`
	Query       string    `json:"query"`
	Summary     string    `json:"summary"`
	GeneratedAt time.Time `json:"generated_at"`
}

type KnowledgeAuthor

type KnowledgeAuthor interface {
	AuthorDelta(ctx context.Context, req KnowledgeAuthorRequest) (*KnowledgeAuthorResult, error)
}

type KnowledgeAuthorRequest

type KnowledgeAuthorRequest struct {
	Schema        string
	Source        SourceSnapshot
	ExistingPages []KnowledgePageSummary
	GeneratedAt   time.Time
	WorkspaceRoot string
}

type KnowledgeAuthorResult

type KnowledgeAuthorResult struct {
	Pages        []KnowledgePage
	Conflicts    []string
	Gaps         []string
	FallbackMode bool
}

type KnowledgeCitation

type KnowledgeCitation struct {
	PageSlug   string   `json:"page_slug"`
	Title      string   `json:"title"`
	SourceRefs []string `json:"source_refs,omitempty"`
}

type KnowledgeCompileReport

type KnowledgeCompileReport = KnowledgeIngestReport

type KnowledgeConfidence

type KnowledgeConfidence string
const (
	KnowledgeConfidenceLow    KnowledgeConfidence = "low"
	KnowledgeConfidenceMedium KnowledgeConfidence = "medium"
	KnowledgeConfidenceHigh   KnowledgeConfidence = "high"
)

type KnowledgeConflictRepairReport

type KnowledgeConflictRepairReport struct {
	GeneratedAt     time.Time              `json:"generated_at"`
	CanonicalPages  []KnowledgePageSummary `json:"canonical_pages,omitempty"`
	SupersededPages []KnowledgePageSummary `json:"superseded_pages,omitempty"`
	FixedPaths      []string               `json:"fixed_paths,omitempty"`
	Lint            *KnowledgeLintReport   `json:"lint,omitempty"`
}

type KnowledgeIngestReport

type KnowledgeIngestReport struct {
	GeneratedAt    time.Time              `json:"generated_at"`
	Pages          []KnowledgePageSummary `json:"pages"`
	NewPages       []KnowledgePageSummary `json:"new_pages,omitempty"`
	UpdatedPages   []KnowledgePageSummary `json:"updated_pages,omitempty"`
	SkippedSources []string               `json:"skipped_sources,omitempty"`
	Conflicts      []string               `json:"conflicts,omitempty"`
	Gaps           []string               `json:"gaps,omitempty"`
	ManifestPath   string                 `json:"manifest_path"`
	IndexPath      string                 `json:"index_path"`
	SchemaPath     string                 `json:"schema_path"`
	LogPath        string                 `json:"log_path"`
	FallbackMode   bool                   `json:"fallback_mode,omitempty"`
}

type KnowledgeJob

type KnowledgeJob struct {
	ID          string              `json:"id"`
	UserID      string              `json:"user_id,omitempty"`
	TenantID    string              `json:"tenant_id,omitempty"`
	ProviderID  string              `json:"provider_id,omitempty"`
	Query       string              `json:"query,omitempty"`
	Kind        JobKind             `json:"kind"`
	Status      JobStatus           `json:"status"`
	Progress    int                 `json:"progress"`
	Stage       string              `json:"stage,omitempty"`
	Detail      string              `json:"detail,omitempty"`
	Error       string              `json:"error,omitempty"`
	CreatedAt   time.Time           `json:"created_at"`
	UpdatedAt   time.Time           `json:"updated_at"`
	CompletedAt *time.Time          `json:"completed_at,omitempty"`
	Report      *KnowledgeJobReport `json:"report,omitempty"`
}

type KnowledgeJobReport

type KnowledgeJobReport struct {
	Kind    JobKind                        `json:"kind"`
	Ingest  *KnowledgeIngestReport         `json:"ingest,omitempty"`
	Compile *KnowledgeCompileReport        `json:"compile,omitempty"`
	Lint    *KnowledgeLintReport           `json:"lint,omitempty"`
	Repair  *KnowledgeConflictRepairReport `json:"repair,omitempty"`
	Answer  *KnowledgeAnswerReport         `json:"answer,omitempty"`
}

type KnowledgeJobSummary

type KnowledgeJobSummary struct {
	ID         string    `json:"id"`
	JobID      string    `json:"job_id"`
	ProviderID string    `json:"provider_id,omitempty"`
	Query      string    `json:"query,omitempty"`
	Kind       JobKind   `json:"kind"`
	Status     JobStatus `json:"status"`
	Progress   int       `json:"progress"`
	Stage      string    `json:"stage,omitempty"`
	Detail     string    `json:"detail,omitempty"`
	UpdatedAt  time.Time `json:"updated_at"`
}

type KnowledgeLintReport

type KnowledgeLintReport struct {
	GeneratedAt time.Time   `json:"generated_at"`
	Issues      []LintIssue `json:"issues"`
	FixedPaths  []string    `json:"fixed_paths,omitempty"`
}

type KnowledgeLogEntry

type KnowledgeLogEntry struct {
	Timestamp    time.Time `json:"timestamp"`
	Operation    string    `json:"operation"`
	Title        string    `json:"title"`
	Sources      []string  `json:"sources,omitempty"`
	NewPages     []string  `json:"new_pages,omitempty"`
	UpdatedPages []string  `json:"updated_pages,omitempty"`
	Conflicts    []string  `json:"conflicts,omitempty"`
	Gaps         []string  `json:"gaps,omitempty"`
	Reason       string    `json:"reason,omitempty"`
}

type KnowledgePage

type KnowledgePage struct {
	KnowledgePageSummary
	Content string                    `json:"content"`
	Answers []KnowledgeArchivedAnswer `json:"answers,omitempty"`
}

type KnowledgePageSummary

type KnowledgePageSummary struct {
	Title            string              `json:"title"`
	Slug             string              `json:"slug"`
	PageType         string              `json:"page_type"`
	Summary          string              `json:"summary"`
	SourceRefs       []string            `json:"source_refs"`
	Keywords         []string            `json:"keywords"`
	Backlinks        []string            `json:"backlinks"`
	GeneratedAt      time.Time           `json:"generated_at"`
	UpdatedAt        time.Time           `json:"updated_at"`
	SourceHash       string              `json:"source_hash"`
	Status           KnowledgeStatus     `json:"status"`
	Confidence       KnowledgeConfidence `json:"confidence"`
	ConflictsWith    []string            `json:"conflicts_with,omitempty"`
	SupersededBy     []string            `json:"superseded_by,omitempty"`
	DerivedFromQuery string              `json:"derived_from_query,omitempty"`
}

type KnowledgeSchemaDocument

type KnowledgeSchemaDocument struct {
	Content string `json:"content"`
}

type KnowledgeStatus

type KnowledgeStatus string
const (
	KnowledgeStatusActive     KnowledgeStatus = "active"
	KnowledgeStatusSuperseded KnowledgeStatus = "superseded"
	KnowledgeStatusConflicted KnowledgeStatus = "conflicted"
)

type LintIssue

type LintIssue struct {
	Kind            IssueKind `json:"kind"`
	PageSlug        string    `json:"page_slug,omitempty"`
	Message         string    `json:"message"`
	AutoFixed       bool      `json:"auto_fixed,omitempty"`
	Severity        string    `json:"severity,omitempty"`
	Category        string    `json:"category,omitempty"`
	RelatedPages    []string  `json:"related_pages,omitempty"`
	SuggestedAction string    `json:"suggested_action,omitempty"`
}

type LintRequest

type LintRequest struct {
	TargetPaths []string `json:"target_paths,omitempty"`
	ProviderID  string   `json:"provider_id,omitempty"`
}

type LoopContextRequest

type LoopContextRequest struct {
	Stage             LoopContextStage `json:"stage"`
	Goal              string           `json:"goal,omitempty"`
	CurrentStep       string           `json:"current_step,omitempty"`
	PlanSummary       string           `json:"plan_summary,omitempty"`
	TokenBudget       int              `json:"token_budget,omitempty"`
	PriorFailureHints []string         `json:"prior_failure_hints,omitempty"`
}

type LoopContextResult

type LoopContextResult struct {
	Context    string               `json:"context,omitempty"`
	Snippets   []LoopContextSnippet `json:"snippets,omitempty"`
	SkipReason string               `json:"skip_reason,omitempty"`
	UsedCount  int                  `json:"used_count,omitempty"`
	UsedSlugs  []string             `json:"used_slugs,omitempty"`
}

type LoopContextSnippet

type LoopContextSnippet struct {
	Slug       string              `json:"slug"`
	PageType   string              `json:"page_type"`
	Status     KnowledgeStatus     `json:"status"`
	Confidence KnowledgeConfidence `json:"confidence"`
	Summary    string              `json:"summary"`
	SourceRefs []string            `json:"source_refs,omitempty"`
	RiskLabel  string              `json:"risk_label,omitempty"`
}

type LoopContextStage

type LoopContextStage string
const (
	LoopContextStagePlanning     LoopContextStage = "planning"
	LoopContextStageExecution    LoopContextStage = "execution"
	LoopContextStageRecovery     LoopContextStage = "recovery"
	LoopContextStageVerification LoopContextStage = "verification"
)

type MemorySink

type MemorySink interface {
	Remember(ctx context.Context, content string, tags []string) error
}

type PromoteQueryResult

type PromoteQueryResult struct {
	Page KnowledgePageSummary `json:"page"`
}

type RepairConflictsRequest

type RepairConflictsRequest struct {
	TargetSlugs []string `json:"target_slugs,omitempty"`
	ProviderID  string   `json:"provider_id,omitempty"`
	// contains filtered or unexported fields
}

type Service

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

func NewService

func NewService(options ServiceOptions) *Service

func (*Service) Answer

func (*Service) CancelJob

func (s *Service) CancelJob(id string) error

func (*Service) CancelJobForUser

func (s *Service) CancelJobForUser(id, userID, tenantID string) error

func (*Service) Compile

func (*Service) CreateJob

func (s *Service) CreateJob(ctx context.Context, req CreateJobRequest) (*KnowledgeJob, error)

func (*Service) GetIndexMarkdown

func (s *Service) GetIndexMarkdown(_ context.Context) (string, error)

func (*Service) GetJob

func (s *Service) GetJob(id string) (*KnowledgeJob, error)

func (*Service) GetJobForUser

func (s *Service) GetJobForUser(id, userID, tenantID string) (*KnowledgeJob, error)

func (*Service) GetLatestLint

func (s *Service) GetLatestLint(_ context.Context) (*KnowledgeLintReport, error)

func (*Service) GetLog

func (s *Service) GetLog(_ context.Context, limit int) ([]KnowledgeLogEntry, error)

func (*Service) GetPage

func (s *Service) GetPage(_ context.Context, slug string) (*KnowledgePage, error)

func (*Service) GetReport

func (s *Service) GetReport(id string) (*KnowledgeJobReport, error)

func (*Service) GetReportForUser

func (s *Service) GetReportForUser(id, userID, tenantID string) (*KnowledgeJobReport, error)

func (*Service) GetSchema

func (s *Service) GetSchema(_ context.Context) (*KnowledgeSchemaDocument, error)

func (*Service) HasCompiledKnowledge

func (s *Service) HasCompiledKnowledge() bool

func (*Service) Lint

func (*Service) ListJobsForUser

func (s *Service) ListJobsForUser(userID, tenantID string, activeOnly bool) ([]KnowledgeJobSummary, error)

func (*Service) ListPages

func (s *Service) ListPages(_ context.Context) ([]KnowledgePageSummary, error)

func (*Service) PromoteQuery

func (s *Service) PromoteQuery(ctx context.Context, jobID string) (*KnowledgePageSummary, error)

func (*Service) RepairConflicts

func (*Service) ResolveLoopContext

func (s *Service) ResolveLoopContext(ctx context.Context, req LoopContextRequest) (*LoopContextResult, error)

func (*Service) RetrieveAnswer

func (s *Service) RetrieveAnswer(ctx context.Context, query string) (string, error)

func (*Service) RetrieveContext

func (s *Service) RetrieveContext(ctx context.Context, query string, limit int) (string, error)

func (*Service) Subscribe

func (s *Service) Subscribe(jobID string) (<-chan Event, func(), error)

func (*Service) SubscribeForUser

func (s *Service) SubscribeForUser(jobID, userID, tenantID string) (<-chan Event, func(), error)

func (*Service) UpdateSchema

func (s *Service) UpdateSchema(_ context.Context, content string) (*KnowledgeSchemaDocument, error)

type ServiceOptions

type ServiceOptions struct {
	WorkspaceDir          string
	RepoRoot              string
	MemorySink            MemorySink
	EventPublisher        EventPublisher
	KnowledgeAuthor       KnowledgeAuthor
	DefaultLintProviderID func() string
	OnCompileSuccess      func(context.Context, *KnowledgeCompileReport)
	Now                   func() time.Time
}

type SourceSnapshot

type SourceSnapshot struct {
	Ref        string
	Title      string
	PageType   string
	Content    string
	Summary    string
	Keywords   []string
	SourceHash string
	Slug       string
}

Jump to

Keyboard shortcuts

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