continuous

package
v0.0.0-...-3024e77 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ApprovalService

type ApprovalService struct {
	// contains filtered or unexported fields
}

ApprovalService handles the approval workflow for plan update proposals.

func NewApprovalService

func NewApprovalService(repo PlanUpdateProposalRepository) *ApprovalService

NewApprovalService creates a new ApprovalService.

func (*ApprovalService) RequestApproval

func (s *ApprovalService) RequestApproval(proposalID string) (PlanUpdateProposal, error)

RequestApproval moves a proposal from draft to pending_approval.

type ContextDelivery

type ContextDelivery struct {
	ID        string       `json:"id"`
	ProjectID string       `json:"project_id"`
	Level     ContextLevel `json:"level"`
	Content   string       `json:"content"`
	CreatedAt string       `json:"created_at"`
}

ContextDelivery represents a delivered context response.

type ContextDeliveryRepository

type ContextDeliveryRepository interface {
	CreateDelivery(d ContextDelivery) (ContextDelivery, error)
	ListDeliveries(projectID string, level ContextLevel, limit int) ([]ContextDelivery, error)
}

ContextDeliveryRepository persists context deliveries.

type ContextGenerator

type ContextGenerator struct {
	// contains filtered or unexported fields
}

ContextGenerator generates context at different detail levels.

func NewContextGenerator

func NewContextGenerator(db *sql.DB) *ContextGenerator

NewContextGenerator creates a new ContextGenerator.

func (*ContextGenerator) Generate

func (g *ContextGenerator) Generate(projectID string, level ContextLevel) (string, error)

Generate generates context at the requested level.

type ContextLevel

type ContextLevel string

ContextLevel represents the detail level for context serving.

const (
	ContextL0Executive      ContextLevel = "L0_Executive"
	ContextL1Planning       ContextLevel = "L1_Planning"
	ContextL2Plan           ContextLevel = "L2_Specific_Plan"
	ContextL3Task           ContextLevel = "L3_Task"
	ContextL4Implementation ContextLevel = "L4_Implementation"
)

type ContinuousEvent

type ContinuousEvent struct {
	ID        string    `json:"id"`
	ProjectID string    `json:"project_id"`
	EventType EventKind `json:"event_type"`
	Summary   string    `json:"summary"`
	Details   string    `json:"details"` // JSON
	Source    string    `json:"source"`
	CreatedAt string    `json:"created_at"`
}

ContinuousEvent represents a detected event for continuous planning.

type ContinuousEventRepository

type ContinuousEventRepository interface {
	CreateEvent(ev ContinuousEvent) (ContinuousEvent, error)
	ListEvents(projectID string, limit int) ([]ContinuousEvent, error)
}

ContinuousEventRepository persists continuous events.

type Detector

type Detector struct {
	// contains filtered or unexported fields
}

Detector detects events that may trigger plan updates.

func NewDetector

func NewDetector(db *sql.DB) *Detector

NewDetector creates a new Detector.

func (*Detector) Detect

func (d *Detector) Detect(projectID string) ([]ContinuousEvent, error)

Detect checks for new events since the given event count baseline.

func (*Detector) DetectOutdatedPlans

func (d *Detector) DetectOutdatedPlans(projectID string) ([]string, error)

DetectOutdatedPlans checks if any plans may be outdated based on recent events.

type EventKind

type EventKind string

EventKind represents the type of event detected.

const (
	EventNewApprovedContext     EventKind = "new_approved_context"
	EventNewResearch            EventKind = "new_research"
	EventNewKnowledge           EventKind = "new_knowledge"
	EventDecisionChanged        EventKind = "decision_changed"
	EventPlanOutdated           EventKind = "plan_outdated"
	EventImplementationFeedback EventKind = "implementation_feedback"
	EventTaskCompleted          EventKind = "task_completed"
	EventValidationFailed       EventKind = "validation_failed"
	EventChangeRequestCreated   EventKind = "change_request_created"
)

type LoopResult

type LoopResult struct {
	ProjectID          string               `json:"project_id"`
	EventsDetected     int                  `json:"events_detected"`
	ProposalsCreated   []PlanUpdateProposal `json:"proposals_created"`
	ApprovalsRequested int                  `json:"approvals_requested"`
	Status             *ProjectStatus       `json:"status,omitempty"`
	Errors             []string             `json:"errors,omitempty"`
}

LoopResult captures the outcome of a continuous planning loop run.

type LoopService

type LoopService struct {
	// contains filtered or unexported fields
}

LoopService orchestrates the full continuous planning cycle: detect → analyze → propose → approve → apply.

It is the single entry point for both CLI and MCP continuous planning workflows, ensuring consistent invariants across all paths.

func NewLoopService

func NewLoopService(db *sql.DB, eventRepo ContinuousEventRepository, proposalRepo PlanUpdateProposalRepository) *LoopService

NewLoopService creates a loop service with all dependencies.

func (*LoopService) ApplyProposal

func (s *LoopService) ApplyProposal(proposalID string) (PlanUpdateProposal, error)

ApplyProposal applies an approved proposal. It marks the proposal as applied and records the application in project memory. Idempotent — calling it on an already-applied proposal returns successfully.

func (*LoopService) ApproveProposal

func (s *LoopService) ApproveProposal(proposalID string) (PlanUpdateProposal, error)

ApproveProposal moves a proposal from draft/pending to approved.

func (*LoopService) DetectAndPropose

func (s *LoopService) DetectAndPropose(projectID string) ([]PlanUpdateProposal, error)

DetectAndPropose detects recent events and creates plan update proposals from them. Returns the created proposals and any error.

func (*LoopService) RejectProposal

func (s *LoopService) RejectProposal(proposalID string) (PlanUpdateProposal, error)

RejectProposal moves a proposal to rejected status.

func (*LoopService) RunLoop

func (s *LoopService) RunLoop(projectID string) (*LoopResult, error)

RunLoop executes the full detect → propose → approve → apply cycle for a project. Proposals that require approval are left in pending; proposals that can be auto-applied are applied immediately.

type PlanUpdateProposal

type PlanUpdateProposal struct {
	ID                string         `json:"id"`
	ProjectID         string         `json:"project_id"`
	Reason            string         `json:"reason"`
	AffectedPlans     []string       `json:"affected_plans"`
	AffectedTasks     []string       `json:"affected_tasks"`
	AffectedDecisions []string       `json:"affected_decisions"`
	SuggestedUpdates  string         `json:"suggested_updates"`
	RequiresResearch  bool           `json:"requires_research"`
	RequiresApproval  bool           `json:"requires_approval"`
	Status            ProposalStatus `json:"status"`
	CreatedAt         string         `json:"created_at"`
	UpdatedAt         string         `json:"updated_at"`
}

PlanUpdateProposal represents a proposed update to plans based on detected events.

type PlanUpdateProposalRepository

type PlanUpdateProposalRepository interface {
	CreateProposal(p PlanUpdateProposal) (PlanUpdateProposal, error)
	GetProposal(id string) (PlanUpdateProposal, error)
	ListProposals(projectID string) ([]PlanUpdateProposal, error)
	UpdateProposalStatus(id string, status ProposalStatus) error
}

PlanUpdateProposalRepository persists plan update proposals.

type Planner

type Planner struct {
	// contains filtered or unexported fields
}

Planner creates plan update proposals from detected events.

func NewPlanner

func NewPlanner(repo PlanUpdateProposalRepository) *Planner

NewPlanner creates a new Planner.

func (*Planner) CreateProposal

func (p *Planner) CreateProposal(projectID string, event ContinuousEvent, affectedPlans, affectedTasks, affectedDecisions []string) (PlanUpdateProposal, error)

CreateProposal creates a plan update proposal from a detected event.

type PlanningV2Service

type PlanningV2Service struct {
	// contains filtered or unexported fields
}

func (PlanningV2Service) List

func (s PlanningV2Service) List(projectID string) ([]TargetedRegeneration, error)

func (PlanningV2Service) Regenerate

func (s PlanningV2Service) Regenerate(projectID, reason, scope string) (TargetedRegeneration, error)

type ProjectStatus

type ProjectStatus struct {
	ProjectID        string   `json:"project_id"`
	ActivePlan       string   `json:"active_plan"`
	ActivePhase      string   `json:"active_phase"`
	NextTask         string   `json:"next_task"`
	BlockedItems     []string `json:"blocked_items"`
	ApprovalsNeeded  []string `json:"approvals_needed"`
	OutdatedPlans    []string `json:"outdated_plans"`
	RecentEvents     int      `json:"recent_events"`
	PendingProposals int      `json:"pending_proposals"`
}

ProjectStatus represents the continuous status of a project.

type ProposalStatus

type ProposalStatus string

ProposalStatus represents the lifecycle status of a plan update proposal.

const (
	ProposalDraft           ProposalStatus = "draft"
	ProposalPendingApproval ProposalStatus = "pending_approval"
	ProposalApproved        ProposalStatus = "approved"
	ProposalRejected        ProposalStatus = "rejected"
	ProposalApplied         ProposalStatus = "applied"
)

type StatusService

type StatusService struct {
	// contains filtered or unexported fields
}

StatusService generates continuous status for a project.

func NewStatusService

func NewStatusService(db *sql.DB) *StatusService

NewStatusService creates a new StatusService.

func (*StatusService) GetStatus

func (s *StatusService) GetStatus(projectID string) (ProjectStatus, error)

GetStatus returns the continuous status of a project.

type TargetedRegeneration

type TargetedRegeneration struct {
	ID                string
	ProjectID         string
	Reason            string
	Scope             string
	AffectedSections  []string
	PreservedSections []string
	SnapshotRequired  bool
	ApprovalRequired  bool
	Status            ProposalStatus
	CreatedAt         time.Time
	UpdatedAt         time.Time
}

func BuildTargetedRegeneration

func BuildTargetedRegeneration(projectID, reason, scope string) TargetedRegeneration

type TargetedRegenerationRepository

type TargetedRegenerationRepository interface {
	SaveRegeneration(TargetedRegeneration) (TargetedRegeneration, error)
	ListRegenerations(projectID string) ([]TargetedRegeneration, error)
}

type Updater

type Updater struct {
	// contains filtered or unexported fields
}

Updater applies approved plan updates.

func NewUpdater

func NewUpdater(repo PlanUpdateProposalRepository) *Updater

NewUpdater creates a new Updater.

func (*Updater) Apply

func (u *Updater) Apply(proposalID string) (PlanUpdateProposal, error)

Apply marks a proposal as applied.

func (*Updater) Approve

func (u *Updater) Approve(proposalID string) (PlanUpdateProposal, error)

Approve marks a proposal as approved.

func (*Updater) Reject

func (u *Updater) Reject(proposalID string) (PlanUpdateProposal, error)

Reject marks a proposal as rejected.

Jump to

Keyboard shortcuts

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