projection

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2026 License: Apache-2.0 Imports: 6 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package projection computes the user-facing projections — Current Understanding (§5), Recommended Next Move (§6), and What Changed (§7) — deterministically from relational state. They are projections, not a source of truth, and every statement retains provenance.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DedupDecisions added in v0.5.0

func DedupDecisions(decs []domain.Decision) []domain.Decision

DedupDecisions is dedupDecisionsForDisplay for callers outside the package: the decisions endpoint the UI reads applies it too, so the page and the guidance agree on how many decisions there are.

func SameQuestion added in v0.5.0

func SameQuestion(a, b string) bool

SameQuestion reports whether two decision questions are the same question for display: equal after normalizeDecisionQuestion.

Types

type ChangeGroup

type ChangeGroup struct {
	Category string   `json:"category"`
	Items    []string `json:"items"`
}

ChangeGroup is one grouped category of changes.

type Changed

type Changed struct {
	Groups  []ChangeGroup `json:"groups"`
	Through int64         `json:"through"`
}

Changed is the grouped What Changed projection. Through is the highest event sequence actually consumed by this projection (or the caller's cursor when no events matched) — the client echoes it back to the read-cursor write so that exactly what was shown is marked seen, never events that arrived mid-read.

func BuildChanged

func BuildChanged(ctx context.Context, db *store.DB, sinceSeq int64, limit int) (Changed, error)

BuildChanged summarizes events since sinceSeq into grouped, narrated items (§7). The raw event timeline is served separately via /activity.

type DecisionView

type DecisionView struct {
	ID             string                `json:"id"`
	Code           string                `json:"code"`
	Question       string                `json:"question"`
	Recommendation string                `json:"recommendation"`
	Options        []string              `json:"options"`
	Resolution     string                `json:"resolution,omitempty"`
	Status         domain.DecisionStatus `json:"status"`
	HasDissent     bool                  `json:"has_dissent"`
	Dissents       []DissentView         `json:"dissents"`
	Synthesis      string                `json:"synthesis,omitempty"`
}

DecisionView is a decision in the projection (with dissent presence).

type DissentView

type DissentView struct {
	ProponentRole string `json:"proponent_role"`
	Position      string `json:"position"`
}

DissentView is one dissenting position on a decision (§8).

type Guidance

type Guidance struct {
	Action   string   `json:"action"`
	Why      string   `json:"why"`
	Affected []string `json:"affected"`
	// NextTask is the task Execute would run next, omitted when there is none
	// (the Build contract's `next_task`, reusing workflow's nextReadyTask).
	// Omitted rather than null: every other daemon endpoint's contract is
	// "never emit a null field" (TestNoEndpointEmitsANullArray), and this is
	// the same rule applied to a single optional object instead of a slice.
	// BuildGuidance leaves this nil: it stays a pure function of Understanding
	// with no engine/task-store access, so the daemon handler populates it
	// after calling BuildGuidance (via Engine.NextReadyTask).
	NextTask *NextTaskRef `json:"next_task,omitempty"`
	// RunBlockedReason is empty (and so omitted) when Execute could start
	// right now for this initiative, otherwise a user-facing sentence naming
	// the fix (the Build contract's `run_blocked_reason`): another change set
	// still open, an operation already running, the plan not approved yet, or
	// -- composed in by the daemon handler, not here -- the executor not
	// being ready. Same population note as NextTask.
	RunBlockedReason string `json:"run_blocked_reason,omitempty"`
	// PartialWork is what a stopped run left for the next run of its task
	// to continue from, omitted when nothing was kept. Same population note
	// as NextTask.
	PartialWork *PartialWorkRef `json:"partial_work,omitempty"`
}

Guidance is the Recommended Next Move projection.

func BuildGuidance

func BuildGuidance(ini domain.Initiative, understanding Understanding) Guidance

BuildGuidance computes the Recommended Next Move with deterministic precedence: judgment items outrank stage advancement (§6, §9).

type NextTaskRef added in v0.5.0

type NextTaskRef struct {
	ID      string `json:"id"`
	HumanID string `json:"human_id"`
	Title   string `json:"title"`
}

NextTaskRef is the Build contract's `next_task` shape: enough to name and link the task without exposing the full domain.Task.

type PartialWorkRef added in v0.5.1

type PartialWorkRef struct {
	TaskID      string `json:"task_id"`
	TaskHumanID string `json:"task_human_id,omitempty"`
	Files       int    `json:"files"`
	// Note says why nothing was kept, when the stopped run's files looked
	// like they contained a secret.
	Note string `json:"note,omitempty"`
}

PartialWorkRef names a stopped run's kept files for the Build page.

type QuestionView

type QuestionView struct {
	ID       string                `json:"id"`
	Question string                `json:"question"`
	Status   domain.QuestionStatus `json:"status"`
}

QuestionView is an open question in the projection.

type RequirementView

type RequirementView struct {
	ID                 string                       `json:"id"`
	Code               string                       `json:"code"`
	Statement          string                       `json:"statement"`
	Priority           domain.RequirementPriority   `json:"priority"`
	Status             domain.RequirementStatus     `json:"status"`
	AcceptanceCriteria []domain.AcceptanceCriterion `json:"acceptance_criteria"`
}

RequirementView is a requirement in the projection.

type Understanding

type Understanding struct {
	Title         string                  `json:"title"`
	Description   string                  `json:"description"`
	Status        domain.InitiativeStatus `json:"status"`
	FailureReason string                  `json:"failure_reason,omitempty"`
	Summary       string                  `json:"summary"`
	NeedsJudgment []string                `json:"needs_judgment"`
	Assertions    []UnderstandingItem     `json:"assertions"`
	Requirements  []RequirementView       `json:"requirements"`
	Decisions     []DecisionView          `json:"decisions"`
	Questions     []QuestionView          `json:"questions"`
}

Understanding is the Current Understanding projection.

func BuildUnderstanding

func BuildUnderstanding(ctx context.Context, db *store.DB, ini domain.Initiative) (Understanding, error)

BuildUnderstanding assembles the Current Understanding projection.

type UnderstandingItem

type UnderstandingItem struct {
	ID            string                 `json:"id"`
	Type          domain.AssertionType   `json:"type"`
	Status        domain.AssertionStatus `json:"status"`
	Statement     string                 `json:"statement"`
	Confidence    domain.Confidence      `json:"confidence"`
	Source        string                 `json:"source"`
	Provenance    []domain.ProvenanceRef `json:"provenance"`
	ProducedByRun string                 `json:"produced_by_run"`
}

UnderstandingItem is one provenance-backed statement.

Jump to

Keyboard shortcuts

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