llmops

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatEntryForPrompt

func FormatEntryForPrompt(e *model.Entry) string

FormatEntryForPrompt formats an entry as readable text for inclusion in a prompt.

Refs rendering is conditional on the entry's ref shape, per d-tac-4ub:

  • All-legacy (every ref has Kind == RefKindUnknown — bare-string YAML fallback): render the flat `Refs: id1, id2` format. Legacy refs carry no kind or desc, so the object form would only add empty `(kind: unknown)` noise.
  • Object-form (any ref carries a capturable kind): render multi-line ` - id (kind: K): desc` so the LLM sees ref metadata, enabling the ref-meta consistency check (see ref_meta_consistency.tmpl).

Mixed entries (some refs legacy, some object) get the multi-line form — the presence of any object-form ref signals an entry authored under the new contract; rendering uniformly preserves clarity.

This renders canonical (parse-resolved) ref kinds — the single form both pre-flight and summary generation consume.

func RenderSummaryPrompt

func RenderSummaryPrompt(entry *model.Entry, graph *model.Graph, configuredLanguage string) (llm.Request, error)

RenderSummaryPrompt renders the summary prompt for an entry. Returns a Request with the full rendered prompt in UserPrompt; the system/user split is introduced when templates are refactored (see the plan decision).

Types

type FactSource

type FactSource interface {
	FactBody(id string) (string, error)
}

FactSource resolves a fact entry's body for inlining into the prompt. Consumer-defined so the prompt layer stays free of graph wiring; the finder supplies a graph-backed implementation that resolves to live supersession heads, so a project override of a base fact wins.

type Finding

type Finding struct {
	Severity    Severity
	Category    string
	Observation string
}

Finding is a single observation from pre-flight validation.

type GuideFinding

type GuideFinding struct {
	Reasoning string
	Axis      string
	Quote     string
	Repair    string
	Severity  GuideSeverity
}

GuideFinding is a single writing-guide observation. Reasoning leads — it is the finding's work; axis, repair, and severity are its conclusions.

type GuideSeverity

type GuideSeverity string

GuideSeverity weighs a writing-guide finding. Nothing gates on it: the levels steer the drafting agent's attention (substantive → take it up in dialogue, minor → fold in or ignore). Mirrored in the query package.

const (
	GuideSubstantive GuideSeverity = "substantive"
	GuideMinor       GuideSeverity = "minor"
)

type PreflightResult

type PreflightResult struct {
	Findings []Finding
}

PreflightResult holds the parsed findings from a pre-flight validator run. An empty Findings slice means the validator reported no findings.

func Preflight

func Preflight(ctx context.Context, runner llm.Runner, entry *model.Entry, graph *model.Graph, configuredLanguage string) (*PreflightResult, error)

Preflight runs the pre-flight validator against the given entry and graph. Returns the parsed result regardless of finding severity. Returns an error only for infrastructure failures (runner error, template error, parse error).

Participant validation is handled by mechanical checks in the finders layer (see finders.mechanicalPreflight) — the LLM participant-drift rubric is retired per plan d-cpt-d34 AC 9.

configuredLanguage is the graph authoring language (locale code) from `.sdd/config.yaml` (empty string when unset — English default). It feeds the language-drift check which flags entries whose description prose does not match the configured language.

func (*PreflightResult) HasBlocking

func (r *PreflightResult) HasBlocking() bool

HasBlocking reports whether any finding blocks entry creation. Currently only SeverityHigh blocks.

type ReferenceFacts

type ReferenceFacts struct {
	Source           FactSource
	TypeSystemFactID string
	// KindFactID is empty when the drafted kind has no authoring fact yet;
	// the prompt section is simply absent then.
	KindFactID string
}

ReferenceFacts names the graph facts the prompt inlines as framework knowledge: the type-system overview always, the drafted kind's authoring fact when one ships. This is reference knowledge, not neighborhood — the guide still judges the draft in isolation from the dialogue and the graph around it (d-cpt-20r).

type Severity

type Severity string

Severity classifies a pre-flight finding. Mirrored in the query package; templates describe severity in purely semantic terms.

const (
	SeverityHigh   Severity = "high"
	SeverityMedium Severity = "medium"
	SeverityLow    Severity = "low"
)

type SummarizeResult

type SummarizeResult struct {
	Summary string
}

SummarizeResult holds the generated summary.

func Summarize

func Summarize(ctx context.Context, runner llm.Runner, entry *model.Entry, graph *model.Graph, configuredLanguage string) (*SummarizeResult, error)

Summarize generates a summary for a single entry using the LLM runner. Summaries are derived on demand with no staleness tracking (d-cpt-4qi), so this always regenerates — the caller decides when to invoke it. configuredLanguage is the graph's authoring language locale code from config (empty = English default); the summary is written in it regardless of the source material's language.

type WritingGuideResult

type WritingGuideResult struct {
	Findings []GuideFinding
}

WritingGuideResult holds the parsed findings from a writing-guide run. An empty Findings slice means the draft passed clean.

func WritingGuide

func WritingGuide(ctx context.Context, runner llm.Runner, entry *model.Entry, closureTargets []model.ClosureTarget, refFacts ReferenceFacts) (*WritingGuideResult, error)

WritingGuide runs the writing guide against a draft entry in isolation: the prompt carries the draft, the entry-craft instructions, and the framework's own kind knowledge rendered from the graph — no dialogue and no neighborhood context. That absence is the instrument (d-cpt-20r): only a reader outside the dialogue can run the stands-alone test, and the reference facts tell that reader what the draft's kind means (s-tac-fu8). Returns an error only for infrastructure failures.

Jump to

Keyboard shortcuts

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