Documentation
¶
Overview ¶
Package l7report narrates layout7's decision trace (docs/dev/layout-gen/layout-debug.md): the engine emits structured TraceEvents through its one seam (layout7.Trace); this package collects them and renders the human-readable views — Text for the terminal (`layout-debug --why`) and Explain for the narrated pipeline-ordered report (`layout-explain`). The engine itself contains no narration.
Index ¶
Constants ¶
const RecordingVersion = 1
RecordingVersion is bumped whenever the event vocabulary or graph shape changes in a way that would make an older recording narrate wrong. The version guards against narrating a stale recording with newer templates.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ExplainOpts ¶
type ExplainOpts struct {
Heading string // section heading (the source doc's heading)
SourceRef string // "file.md:123" or "" — the reference line
Ipmt string // the original ipmt, embedded as a fenced block
SVGRelPath string // relative link to a rendered companion, "" = none
Candidates bool // include the per-candidate route story in a <details>
Verbose bool // append the full raw trace in a <details>
Color bool // wrap node names / kinds / arrows in as-token markers
// PrinciplesHref / DebugDocHref are the CLICKABLE urls for the two
// linked docs, relative to where the report is written (compute with
// pkg/markdown.RelPath). Empty falls back to the repo-relative display
// path, which only resolves from the repo root.
PrinciplesHref string
DebugDocHref string
}
ExplainOpts configure one narrated report.
type Recording ¶
type Recording struct {
Version int `json:"version"`
Source Source `json:"source,omitempty"`
Events []layout7.TraceEvent `json:"events"`
Graph *layout.Graph `json:"graph"`
}
Recording is a captured run: the decision trace plus the resulting graph. Deterministic (no timestamps) — event kinds and payload keys ARE the grep/diff contract, so two recordings diff clean and a recording diff doubles as a behaviour diff between engine versions.
func NewRecording ¶
NewRecording snapshots a report for serialization.
type Report ¶
type Report struct {
Events []layout7.TraceEvent
Graph *layout.Graph
}
Report is a collected trace plus the generated graph.
func DecodeRecording ¶
DecodeRecording parses a .debug.json back into a Report. Event payloads round-trip through JSON as map[string]any with []interface{} slices; normalizeDecoded restores the []string / [][]string shapes the renderers type-assert on. A version mismatch is a hard error — narrating a stale recording with the current templates is worse than refusing.
func (*Report) Explain ¶
func (r *Report) Explain(o ExplainOpts) string
Explain renders the full narrated report for one graph.
type TextOpts ¶
type TextOpts struct {
Sel []string
Candidates bool // include the per-candidate route story
Verbose bool // append the FULL raw trace (every event, one line each)
}
TextOpts filter the terminal view. Sel limits every section to events mentioning the named nodes (context budget: a 20-line filtered answer beats a 2000-line dump — docs/dev/layout-gen/layout-debug.md, output contract).