htmlreport

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2026 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Overview

Package htmlreport renders the index as one self-contained HTML page. Agents read compact text reports over MCP; this page supports a broader audit of pending decisions, duplicate pins, fix concentrations, and the raw lessons behind them. It is a file-based snapshot with no server or external assets.

Everything it displays is untrusted text — review comments, commit subjects, and model-written proposals — so the page is built through html/template with auto-escaping, including the SVG map: geometry is computed here, markup is emitted there. Nothing in this package produces template.HTML.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Generate

func Generate(w io.Writer, st *store.Store, root string, now time.Time) error

Generate builds the report from the index and writes the page.

func LessonInScope

func LessonInScope(lessonRegion, scope string) bool

LessonInScope reports whether a lesson mined for lessonRegion belongs to the area named by scope: the region itself, anything beneath it, and the ancestors that govern it — the same "area" the lesson ledger and `expand lessons:<dir>` use. An empty region is repo-wide and so belongs to every scope.

It exists because the page filters client-side, and a filter that matched substrings would put a `web` lesson mentioning "API" under scope `api` while hiding the repo-wide lesson that really governs it. Deciding membership here keeps one implementation of the rule; the page only reads the answer back off each row.

func Render

func Render(w io.Writer, r *Report) error

Render writes the report as a self-contained HTML page. Every value passes through html/template's contextual escaping — the report shows text written by reviewers, by commit authors, and by a language model, none of which may become markup.

Types

type Box

type Box struct {
	Key        string
	X, Y, W, H float64
}

Box is a laid-out rectangle in the map's coordinate space. Its fields are exported because the template draws directly from them — the SVG is emitted by html/template, not assembled as markup here, so every value it carries stays escaped.

type Card

type Card struct {
	ID      int64
	Rule    string
	Region  string
	Note    string
	Agent   string
	Status  string
	Pending bool
	// Cited is how many findings the agent cited when the pattern was
	// distilled — a fact of the proposal record, true forever.
	// Retrieved is how many of those the index can still show: mining
	// windows move on, and a pin applied months ago may cite comments
	// that have since aged out. When they differ the page says so
	// rather than presenting the shortfall as the evidence.
	Cited     int
	Retrieved int
	Events    int
	// Evidence health (RFC-002 §7), recomputed at report time: the
	// confidence tier with its facts, the prompt era when the proposal
	// predates the current recurrence rules, and the regions today's
	// inference would assign when they differ from the stored ones.
	Tier       string
	Facts      string
	Era        string
	RegionsNow string
	// Scope is the trigger-scope advisory sentence (RFC-004): the note
	// and co-change history point outside the pin's regions, so
	// delivery may miss the trigger site. Same Line() the ledger prints.
	Scope string
	// Blocked reports confirmed triggers that cannot become delivery scopes —
	// no drift and no advisory would otherwise mention them.
	Blocked  string
	Evidence []Evidence
	// Outcome is the passive loop's verdict sentence,
	// present only for measured applied pins.
	Outcome string
	// NotLanding styles the outcome as the class that needs action.
	NotLanding bool
}

Card is a distilled proposal awaiting — or having received — a decision, with the evidence it cited.

type Cell

type Cell struct {
	Box
	File    string
	Scope   string // what clicking it filters the lessons table by
	Label   string // truncated to what the cell can show; "" when it cannot
	Metric  string // the fix count line; "" when the cell is too short
	Fill    string
	Ink     string
	Tooltip string
}

Cell is one file on the hotspot map.

type Duplicate

type Duplicate struct {
	Pins []DuplicatePin
}

Duplicate is a set of applied pins that restate one theme.

type DuplicatePin

type DuplicatePin struct {
	ID     int64
	Rule   string
	Digest string
}

DuplicatePin is one member of such a set.

type Evidence

type Evidence struct {
	Source string // review | fix:conventional | ...
	Kind   string // the source's provider, for the badge colour
	Path   string
	Body   string
	URL    string // "" unless it is a plain http(s) link
}

Evidence is one finding behind a proposal, as displayed.

type Group

type Group struct {
	Box
	Label string
	Files int
}

Group is a directory box on the hotspot map. Files is how many the directory holds, not how many are drawn — the label carries the difference so a four-cell box does not read as a four-file directory.

type LessonRow

type LessonRow struct {
	Occurrences int
	Region      string
	Reviewer    string
	Symptom     string
	Search      string // lowercased region + symptom, for the text filter
	// Scopes are the map scopes this lesson belongs to, space-separated.
	// Region membership is decided here rather than in the page, so
	// clicking a cell cannot disagree with the count in its tooltip.
	Scopes string
}

LessonRow is one mined lesson in the explorer table.

type Report

type Report struct {
	Repo       string
	IndexState string
	Generated  string
	Stale      bool

	Stats   []Stat
	Sources string // the evidence mix behind every proposal

	Cards       []Card
	CardsTotal  int
	Pending     int
	Duplicates  []Duplicate
	AppliedPins int
	Redundant   int

	Groups    []Group
	Cells     []Cell
	MapWidth  float64
	MapHeight float64
	// FilesWithHistory is every file the index has commits for. The map
	// draws a fraction of them, and says which fraction: a picture that
	// silently omits most of the repo reads as the whole repo.
	FilesWithHistory int

	Lessons      []LessonRow
	LessonsTotal int
}

Report is one rendered page: the view model, fully resolved, so the template only ranges and prints.

func Build

func Build(st *store.Store, root string, now time.Time) (*Report, error)

Build assembles the view model. now is a parameter rather than read from the clock so a test can assert the whole page byte for byte.

type Stat

type Stat struct {
	Value int
	Label string
}

Stat is one headline number.

Jump to

Keyboard shortcuts

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