plancompile

package
v0.10.3 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SummarizerRefExecTerminal = "__exec_terminal__"
	SummarizerRefNextStep     = "__next_step__"
)

Summarizer chain symbolic references — plancompile rewrites these per-step when cloning the operator-supplied summarizer chain into the compiled plan DAG:

  • SummarizerRefExecTerminal: use as a task's InputVar (or Transition.Goto) to refer to the executor's terminal output for the current step. Compile inserts an `exec_done_{N}` noop between the executor's success terminals and the summarizer subgraph, and rewrites this sentinel to that noop's ID.
  • SummarizerRefNextStep: use as a Transition.Goto to refer to the next step's seed (or the chain's end for the final step).

Variables

This section is empty.

Functions

func Compile

Compile turns a parsed plan, an executor chain, and a summarizer chain into one linear TaskChainDefinition. For each plan step it emits:

  1. `seed_step_{N}` (HandleNoop) seeding the prompt template with plan macro vars;
  2. a full copy of the executor graph with `s{N}__` prefixed task IDs;
  3. `exec_done_{N}` (HandleNoop) splicing the executor's success terminals into the summarizer;
  4. a full copy of the summarizer graph with `s{N}__sum__` prefixed IDs, symbolic references (SummarizerRefExecTerminal, SummarizerRefNextStep) rewritten.

Successful summarizer terminals route to `seed_step_{N+1}` when N < last step, or to TermEnd for the final step. Matches the state-machine pattern in enterprise/site/public/images/about/1763497730022.jpeg: every LLM role is a typed node in the graph, not imperative glue in a service.

func ExtractStepChain

func ExtractStepChain(full *taskengine.TaskChainDefinition, stepIndex1Based int) (*taskengine.TaskChainDefinition, error)

ExtractStepChain returns the subgraph for a single plan step from a chain produced by Compile. It includes seed_step_k and all tasks with IDs prefixed s{k}__, and rewrites transitions that jump to seed_step_{k+1} so the subgraph terminates at the end of the step instead.

Types

type ParsedPlan

type ParsedPlan struct {
	Goal  string
	Steps []string
}

ParsedPlan is the result of parsing plan Markdown (same shape as planservice.renderMarkdown).

func ParseMarkdown

func ParseMarkdown(md string) (*ParsedPlan, error)

ParseMarkdown extracts goal and ordered step descriptions from rendered plan Markdown. It understands lines like "**Goal:** ...", "## Steps", and checklist items "- [ ] 1. text". Indented lines starting with ">" (execution result excerpts) are skipped.

type PlanShowActive

type PlanShowActive interface {
	Show(ctx context.Context) (string, error)
	Active(ctx context.Context) (*planstore.Plan, []*planstore.PlanStep, error)
}

PlanShowActive is implemented by planservice.Service for RunActiveCompiled without importing planservice (avoids cycles).

type RunActiveCompiledResult

type RunActiveCompiledResult struct {
	Goal       string
	Steps      []string
	Chain      *taskengine.TaskChainDefinition
	Path       string
	Output     any
	OutputType taskengine.DataType
	State      []taskengine.CapturedStateUnit
}

RunActiveCompiledResult is the outcome of compiling the active plan markdown and executing the compiled chain.

func RunActiveCompiled

func RunActiveCompiled(
	ctx context.Context,
	planSvc PlanShowActive,
	chains taskchainservice.Service,
	exec execservice.TasksEnvService,
	executorChainID string,
	summarizerChainID string,
	compiledChainID string,
	writePath string,
	precompiled *taskengine.TaskChainDefinition,
	eventSink taskengine.TaskEventSink,
) (*RunActiveCompiledResult, error)

RunActiveCompiled loads markdown via planservice.Show, parses and compiles it with the executor chain + summarizer chain, optionally persists the compiled JSON, then runs Execute with the plan goal as string input. precompiled, when non-empty, skips Compile (reuse planservice Next cache or explicit artifact). eventSink publishes plan_run_* events to the same bus/TaskEvent pipeline as task execution (optional; nil disables).

Jump to

Keyboard shortcuts

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