synth

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package synth provides spec synthesis (generation) capabilities.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CanSynthesize

func CanSynthesize(specType types.SpecType) bool

CanSynthesize returns whether a spec type can be synthesized under the legacy pre-merge Working Backwards flow. Used only as a fallback when no workflow is configured — callers with a resolved workflow should check whether its Synthesis map declares a rule for the type instead, since a workflow can make types synthesizable (e.g. enterprise's bmc) that this hardcoded list doesn't know about.

func CanSynthesizeWithRule added in v0.17.0

func CanSynthesizeWithRule(rule *workflow.SynthesisRule, ok bool, specType types.SpecType) bool

CanSynthesizeWithRule reports whether specType can be synthesized given an optionally-resolved workflow rule from ResolveRule. A resolved rule with zero sources (deliberately human-authored, e.g. press under aws-one-way-door) is never synthesizable, regardless of the legacy table. With no resolved rule, falls back to CanSynthesize.

func LoadWorkflowRule added in v0.17.0

func LoadWorkflowRule(loader sws.Loader, profileName string, specType types.SpecType) (loaded *sws.LoadedWorkflow, rule *workflow.SynthesisRule, ok bool)

LoadWorkflowRule loads profileName via loader (falling back to workflows.DefaultLoader() when loader is nil) and resolves specType's synthesis rule from it. Returns a nil LoadedWorkflow and ok=false when profileName is empty or the profile fails to load, so callers can fall back to the legacy hardcoded tables via CanSynthesize/RequiredSources.

func RequiredSources

func RequiredSources(targetType types.SpecType) []types.SpecType

RequiredSources returns the source spec types needed to synthesize a target type under the legacy pre-merge Working Backwards flow. Used only as a fallback when no workflow is configured, or the configured workflow declares no synthesis rule for targetType — callers with a resolved workflow should prefer SourcesForRule instead.

func ResolveRule added in v0.17.0

func ResolveRule(w *workflow.Workflow, specType types.SpecType) (rule *workflow.SynthesisRule, ok bool)

ResolveRule looks up a workflow's synthesis rule for a spec type, including inheritance — LoadedWorkflow.Workflow.Synthesis already reflects extends-resolved, per-key-merged rules, so this is a plain map lookup. ok is true whenever the workflow declares a rule at all, including an explicit empty-Sources rule (e.g. aws-one-way-door's press: sources: [] deliberately overrides an inherited press<-mrd rule to mark press as human-authored, not synthesizable). Callers use ok=false to mean "fall back to the legacy hardcoded tables", not ok=true-with-empty.

func SourcesForRule added in v0.17.0

func SourcesForRule(rule *workflow.SynthesisRule, ok bool, specType types.SpecType) []types.SpecType

SourcesForRule returns the required source types given an optionally- resolved workflow rule from ResolveRule, falling back to RequiredSources when the workflow declares no rule for specType.

Types

type LLMClient

type LLMClient interface {
	Complete(ctx context.Context, prompt string) (string, error)
}

LLMClient defines the interface for LLM operations.

type SynthesisInput

type SynthesisInput struct {
	Sources      map[types.SpecType]string
	Constitution string // Project/org constitution
	Context      string // Aggregated context summary (for grounding)
}

SynthesisInput contains the input documents for synthesis. Sources is keyed by spec type so callers aren't limited to a fixed set of document types — a workflow's synthesis rule can name any spec type as a source (opportunity-spec, narrative-6p, v2mom-*, etc.), not just the handful the pre-merge Working Backwards flow used.

func (SynthesisInput) Get added in v0.17.0

func (in SynthesisInput) Get(specType types.SpecType) string

Get returns the recorded content for a source spec, or "" if absent.

func (*SynthesisInput) Set added in v0.17.0

func (in *SynthesisInput) Set(specType types.SpecType, content string)

Set records the content of a source spec, lazily initializing the underlying map.

type SynthesisResult

type SynthesisResult struct {
	SpecType types.SpecType
	Content  string
	Sources  []types.SpecType // Source specs used
}

SynthesisResult contains the generated document and metadata.

type Synthesizer

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

Synthesizer generates specs from source documents using LLM.

func NewSynthesizer

func NewSynthesizer(client LLMClient) *Synthesizer

NewSynthesizer creates a new synthesizer with the given LLM client.

func (*Synthesizer) Synthesize

func (s *Synthesizer) Synthesize(ctx context.Context, targetType types.SpecType, input SynthesisInput, rule *workflow.SynthesisRule, templateContent string) (*SynthesisResult, error)

Synthesize generates a spec of the given type from input documents.

rule is the target's synthesis rule from the project's actual configured workflow (profile.yaml's synthesis: block), when one is resolved. When rule is nil — no workflow configured, or the workflow declares no rule for targetType — the prompt falls back to the original hardcoded pre-merge Working Backwards prompts for the eight types they cover.

Jump to

Keyboard shortcuts

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