domain

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package domain holds the research domain model of the reference application (design doc §5). These objects live in the application layer on purpose: the Fenced kernel never sees them, and every state they carry is derived from observable kernel surfaces (workflow documents, memory namespaces), never from kernel internals.

Index

Constants

View Source
const (
	PlannerMaxQuestions         = 8
	SearchMaxSourcesPerQuesiton = 8
	ReaderMaxSourceBytes        = 2 << 20 // 2 MiB
	CriticMaxRounds             = 3
	WorkflowMaxTasks            = 80
)

Hard limits of design doc §10. PlannerMaxQuestions is the application decoder bound (the runtime truncates at 6, inside this ceiling).

View Source
const WorkflowBudgetExhaustedCode = "WORKFLOW_BUDGET_EXHAUSTED"

WorkflowBudgetExhaustedCode is the kernel failure code the orchestrator stamps when the workflow budget reservation loop rejects further work.

Variables

View Source
var RoleBudgetTokens = map[string]int64{
	"planner":            20000,
	"search":             5000,
	"reader":             6000,
	"analyst":            30000,
	"critic":             20000,
	"writer":             30000,
	"citation-validator": 15000,
}

Role budget reference of design doc §10. The workflow template's defaultTaskSpec stays the operational truth for kernel admission (the kernel reserves each declared step's task ceiling against the workflow budget), so these values document the per-role intent and drive the budget-calculation unit tests of the test matrix (§16).

Functions

func ResearchDecompositionBudget

func ResearchDecompositionBudget() int64

ResearchDecompositionBudget returns the token ceiling the planner may spend for one research run per §10.

func SumRoleBudgetTokens

func SumRoleBudgetTokens() int64

SumRoleBudgetTokens adds the per-role budgets (§16 "Research Budget Calculation" unit subject).

func ValidateRequestBudget

func ValidateRequestBudget(maxTasks, maxTokens int64) error

ValidateRequestBudget range-checks the §13 request budget override before it is applied to the workflow document. Zero leaves the template default.

Types

type Evidence

type Evidence struct {
	ID         string  `json:"id"`
	SourceID   string  `json:"sourceId"`
	QuestionID string  `json:"questionId"`
	Claim      string  `json:"claim"`
	Evidence   string  `json:"evidence"`
	Confidence float64 `json:"confidence"`
}

Evidence is one grounded claim extracted from a source (§5).

type Finding

type Finding struct {
	ID          string   `json:"id"`
	Statement   string   `json:"statement"`
	EvidenceIDs []string `json:"evidenceIds"`
	Confidence  float64  `json:"confidence"`
}

Finding is one analyst synthesis backed by evidence IDs (§5).

type Report

type Report struct {
	ID               string  `json:"id"`
	ResearchRunID    string  `json:"researchRunId"`
	ArtifactRef      string  `json:"artifactRef"`
	CitationCoverage float64 `json:"citationCoverage"`
}

Report is the final deliverable reference (§5). The artifactRef points at the content-addressed artifact store entry that holds the rendered Markdown report.

type ResearchGap

type ResearchGap struct {
	ID       string `json:"id"`
	Question string `json:"question"`
	Severity string `json:"severity"`
	Resolved bool   `json:"resolved"`
}

ResearchGap is one critic-identified hole (§5).

type ResearchQuestion

type ResearchQuestion struct {
	ID            string `json:"id"`
	ResearchRunID string `json:"researchRunId"`
	Question      string `json:"question"`
	Priority      int    `json:"priority"`
	Status        string `json:"status"`
}

ResearchQuestion is one planner decomposition unit (§5).

type ResearchRun

type ResearchRun struct {
	ID          string     `json:"id"`
	WorkflowID  string     `json:"workflowId"`
	Goal        string     `json:"goal"`
	Status      string     `json:"status"`
	CreatedAt   time.Time  `json:"createdAt"`
	CompletedAt *time.Time `json:"completedAt"`
}

ResearchRun is one research submission (§5). The ID is the stable application-level handle ("research-<workflowId>") so the mapping between the application surface and the kernel WorkflowRun is deterministic and survives process restarts.

type RunState

type RunState string

RunState is the application-layer research state machine of design doc §9. These states describe the research run for operators and the CLI; they are derived from the kernel WorkflowRun and its steps and are never written back into kernel state.

const (
	StateCreated       RunState = "CREATED"
	StatePlanning      RunState = "PLANNING"
	StateResearching   RunState = "RESEARCHING"
	StateAnalyzing     RunState = "ANALYZING"
	StateCritiquing    RunState = "CRITIQUING"
	StateWriting       RunState = "WRITING"
	StateValidating    RunState = "VALIDATING"
	StateCompleted     RunState = "COMPLETED"
	StateFailed        RunState = "FAILED"
	StateCancelled     RunState = "CANCELLED"
	StateBudgetExhaust RunState = "BUDGET_EXHAUSTED"
)

func DeriveRunState

func DeriveRunState(view WorkflowView) RunState

DeriveRunState maps one kernel workflow observation onto the §9 state machine. The mapping is pure so the CLI, the API server and the tests all render identical statuses from identical observations.

func (RunState) Terminal

func (s RunState) Terminal() bool

Terminal reports whether the state ends the research run.

type Source

type Source struct {
	ID          string `json:"id"`
	QuestionID  string `json:"questionId"`
	URL         string `json:"url"`
	Title       string `json:"title"`
	PublishedAt string `json:"publishedAt"`
	RetrievedAt string `json:"retrievedAt"`
}

Source is one discovered document (§5).

type StepView

type StepView struct {
	Name           string
	Status         string
	ParentStepName string
}

StepView is the slice of one workflow step the state machine needs.

type WorkflowBudgetDefaults

type WorkflowBudgetDefaults struct {
	MaxTasks        int64
	MaxTokens       int64
	MaxToolCalls    int64
	MaxCostMicroUSD int64
}

WorkflowBudgetDefaults are the §10 workflow-level defaults. Note the kernel's budget-commitment rule (every declared step reserves its task ceiling) makes the illustrative 250k token default unreachable for the 11-step research template; the API server therefore validates request overrides against the kernel decoder and fails closed with the computed floor instead of silently raising the number.

func DefaultWorkflowBudget

func DefaultWorkflowBudget() WorkflowBudgetDefaults

DefaultWorkflowBudget returns the §10 defaults.

type WorkflowView

type WorkflowView struct {
	Status      string
	FailureCode string
	Steps       []StepView
}

WorkflowView is the slice of one kernel workflow the state machine needs.

Jump to

Keyboard shortcuts

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