chainresolver

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package chainresolver resolves the ordered list of files that form the context chain for a given target logical name. The chain is divided into three groups: ancestor spec nodes (root → parent), the target node itself, and cross-tree / external dependencies declared in the target's frontmatter.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Chain

type Chain struct {
	Ancestors    []ChainItem
	Target       ChainItem
	Dependencies []ChainItem
}

Chain is the complete, ordered context for a code generation subagent. It mirrors the structure described in the Code from Spec methodology:

  • Ancestors: all spec nodes from ROOT down to (but not including) Target, sorted alphabetically by logical name.
  • Target: the leaf node (or test node) being implemented.
  • Dependencies: cross-tree (ROOT/) and external (EXTERNAL/) depends_on entries declared by the target, sorted alphabetically by logical name.

func ResolveChain

func ResolveChain(targetLogicalName string) (*Chain, error)

ResolveChain builds the complete chain for the given target logical name.

Step 1 – Ancestors and Target:

Walk up the tree via ParentLogicalName, collecting every logical name from
the target to ROOT. Sort alphabetically — because logical names use path
notation (ROOT/a/b) alphabetical order is top-down. The last item in the
sorted slice is the Target; the remaining items are Ancestors.

Step 2 – Dependencies:

Read the target node's frontmatter. If the target is a TEST/ node, also
read the parent leaf node's frontmatter and merge their DependsOn lists.
Resolve each entry to a ChainItem and sort by logical name.

Returns an error if any logical name cannot be resolved, frontmatter cannot be parsed, or a glob pattern fails to evaluate.

type ChainItem

type ChainItem struct {
	LogicalName string
	FilePaths   []string
}

ChainItem pairs a logical name with the set of file paths it contributes to the chain. Most items have a single path; EXTERNAL/ dependencies may have many (the _external.md plus supporting files).

Jump to

Keyboard shortcuts

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