Documentation
¶
Overview ¶
Package repository materializes the research domain model from kernel surfaces. It is a thin read-side client over the public Control API v1 contract: workflows, tasks, and the operator memory search endpoint. The application layer never opens kernel internals or the database directly, so the same code serves the API server, the CLI, and the tests.
Index ¶
- Variables
- func ResearchIDFor(workflowID string) string
- func WorkflowIDFrom(researchID string) (string, error)
- type Client
- func (c *Client) CancelWorkflow(ctx context.Context, workflowID string, resourceVersion int64) (WorkflowView, error)
- func (c *Client) CreateWorkflow(ctx context.Context, namespace, goal string, document json.RawMessage, ...) (WorkflowView, error)
- func (c *Client) GetTask(ctx context.Context, taskID string) (TaskView, error)
- func (c *Client) GetWorkflow(ctx context.Context, workflowID string) (WorkflowView, error)
- func (c *Client) LoadRunView(ctx context.Context, workflowID, namespaceKey string) (RunView, error)
- func (c *Client) LoadUsage(ctx context.Context, workflowID string) (UsageSummary, error)
- func (c *Client) SearchMemories(ctx context.Context, namespace, query string, limit int) ([]MemoryRecordView, error)
- type MemoryRecordView
- type RunView
- type TaskUsageView
- type TaskView
- type UsageSummary
- type WorkflowStepView
- type WorkflowView
Constants ¶
This section is empty.
Variables ¶
var ErrConflict = fmt.Errorf("conflict")
ErrConflict reports an optimistic-concurrency rejection (409): the caller must re-read and retry with a fresh resource version.
var ErrNotFound = fmt.Errorf("not found")
ErrNotFound reports a missing workflow, task, or record.
Functions ¶
func ResearchIDFor ¶
ResearchIDFor derives the stable application research ID of one workflow.
func WorkflowIDFrom ¶
WorkflowIDFrom parses the research ID back into the kernel workflow ID.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is one Control API v1 HTTP client.
func NewClient ¶
NewClient builds a client. A nil httpClient installs sane defaults; a non-empty token is sent as a bearer token (production Control APIs).
func (*Client) CancelWorkflow ¶
func (c *Client) CancelWorkflow(ctx context.Context, workflowID string, resourceVersion int64) (WorkflowView, error)
CancelWorkflow requests cancellation with the required optimistic concurrency header (POST /v1/workflows/{id}/cancel).
func (*Client) CreateWorkflow ¶
func (c *Client) CreateWorkflow(ctx context.Context, namespace, goal string, document json.RawMessage, idempotencyKey string) (WorkflowView, error)
CreateWorkflow publishes one workflow document (POST /v1/workflows).
func (*Client) GetWorkflow ¶
GetWorkflow reads one workflow document (GET /v1/workflows/{id}).
func (*Client) LoadRunView ¶
LoadRunView materializes one research run from the workflow document and its memory namespaces. workflowID is the kernel workflow UUID used for the Control API; namespaceKey is the id embedded in the agent envelopes (the memory namespace is research/<namespaceKey>). When the envelope key equals the kernel workflow ID (direct-store test paths), pass namespaceKey = "". Memory queries follow the runtime's own search tokens so the hybrid index reliably matches each record family.
func (*Client) LoadUsage ¶
LoadUsage sums the task usage of every step task. Every declared step has a taskId once the orchestrator dispatches it, so at terminal state the aggregation is complete; dynamic children appear in the step list as the workflow extends.
func (*Client) SearchMemories ¶
func (c *Client) SearchMemories(ctx context.Context, namespace, query string, limit int) ([]MemoryRecordView, error)
SearchMemories lists memory records of one namespace through the operator memory search endpoint. The query token follows the runtime's own search usage so the hybrid index reliably matches the record family.
type MemoryRecordView ¶
type MemoryRecordView struct {
ID string `json:"id"`
Namespace string `json:"namespace"`
Key string `json:"key"`
ContentType string `json:"contentType"`
Content string `json:"content"`
}
MemoryRecordView mirrors one Memory object of the memory search response.
type RunView ¶
type RunView struct {
Run domain.ResearchRun
Questions []domain.ResearchQuestion
Sources []domain.Source
Evidence []domain.Evidence
Findings []domain.Finding
Gaps []domain.ResearchGap
CriticVerdict string
StepCount int
Retries int
}
RunView is the materialized application view of one research run: the §5 domain objects plus derived counters the API and CLI surface.
type TaskUsageView ¶
type TaskUsageView struct {
Tokens int64 `json:"tokens"`
CostUSD float64 `json:"costUsd"`
ToolCalls int64 `json:"toolCalls"`
WallSeconds int64 `json:"wallSeconds"`
}
TaskUsageView mirrors the cumulative task usage object.
type TaskView ¶
type TaskView struct {
ID string `json:"id"`
Phase string `json:"phase"`
Usage *TaskUsageView `json:"usage,omitempty"`
}
TaskView mirrors the Control API Task object (usage subset).
type UsageSummary ¶
type UsageSummary struct {
Tokens int64 `json:"tokens"`
ToolCalls int64 `json:"toolCalls"`
CostUSD float64 `json:"costUsd"`
WallSeconds int64 `json:"wallSeconds"`
}
UsageSummary aggregates the cumulative settlement usage of every workflow step task (tokens, tool calls, cost, wall time).
type WorkflowStepView ¶
type WorkflowStepView struct {
Name string `json:"name"`
Ordinal int `json:"ordinal"`
Status string `json:"status"`
AttemptCount int `json:"attemptCount"`
TaskID string `json:"taskId,omitempty"`
FailureCode string `json:"failureCode,omitempty"`
ParentStepName string `json:"parentStepName,omitempty"`
IsDynamic bool `json:"isDynamic,omitempty"`
}
WorkflowStepView mirrors the workflow response's step objects (api/openapi/control-v1.yaml).
type WorkflowView ¶
type WorkflowView struct {
ID string `json:"id"`
Namespace string `json:"namespace"`
Goal string `json:"goal"`
Status string `json:"status"`
ResourceVersion int64 `json:"resourceVersion"`
FailureCode string `json:"failureCode,omitempty"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
Deadline *time.Time `json:"deadline,omitempty"`
Steps []WorkflowStepView `json:"steps"`
}
WorkflowView mirrors the Control API workflow document.