Documentation
¶
Overview ¶
Package usecase orchestrates COMMAND → Aggregate → EVENT flows and dispatches events through the PolicyEngine.
Layer rules (enforced by semgrep):
- usecase MAY import usecase/port and domain
- usecase MUST NOT import cmd, session, or eventsource directly
- I/O delegation uses usecase/port output interfaces (dependency inversion)
Index ¶
- func NewReviewGateRunner(reviewer port.ReviewExecutor, fixer port.ReviewFixRunner, logger domain.Logger) port.ReviewGateRunner
- func NewSessionEventEmitter(agg *domain.SessionAggregate, recorder port.Recorder, logger domain.Logger) port.SessionEventEmitter
- func RescanSession(ctx context.Context, cmd domain.RunSessionCommand, cfg *domain.Config, ...) error
- func ResumeSession(ctx context.Context, cmd domain.ResumeSessionCommand, cfg *domain.Config, ...) error
- func RunInit(cmd domain.InitCommand, runner port.InitRunner) ([]string, error)
- func RunReviewGate(ctx context.Context, gate domain.GateConfig, timeoutSec int, ...) (bool, error)
- func RunScan(ctx context.Context, cmd domain.RunScanCommand, cfg *domain.Config, ...) (*domain.ScanResult, error)
- func RunSession(ctx context.Context, cmd domain.RunSessionCommand, cfg *domain.Config, ...) error
- type PolicyEngine
- type PolicyHandler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewReviewGateRunner ¶ added in v0.0.11
func NewReviewGateRunner(reviewer port.ReviewExecutor, fixer port.ReviewFixRunner, logger domain.Logger) port.ReviewGateRunner
NewReviewGateRunner creates a ReviewGateRunner with the given dependencies.
func NewSessionEventEmitter ¶
func NewSessionEventEmitter(agg *domain.SessionAggregate, recorder port.Recorder, logger domain.Logger) port.SessionEventEmitter
NewSessionEventEmitter creates a SessionEventEmitter that wraps aggregate event production and recording. Record errors are logged as warnings via logger and do not abort the session.
func RescanSession ¶
func RescanSession(ctx context.Context, cmd domain.RunSessionCommand, cfg *domain.Config, baseDir string, oldState *domain.SessionState, sessionID string, input io.Reader, out io.Writer, recorder port.Recorder, logger domain.Logger, metrics port.PolicyMetrics, runner port.SessionRunner) error
RescanSession orchestrates the session rescan pipeline. The command is always-valid by construction — no validation needed.
func ResumeSession ¶
func ResumeSession(ctx context.Context, cmd domain.ResumeSessionCommand, cfg *domain.Config, baseDir string, state *domain.SessionState, input io.Reader, out io.Writer, recorder port.Recorder, logger domain.Logger, metrics port.PolicyMetrics, runner port.SessionRunner) error
ResumeSession orchestrates the session resume pipeline. The command is always-valid by construction — no validation needed.
func RunInit ¶
func RunInit(cmd domain.InitCommand, runner port.InitRunner) ([]string, error)
RunInit delegates project initialization to the InitRunner port. The command is always-valid by construction — no validation needed. Default values for lang/strictness are applied at the cmd layer before construction.
func RunReviewGate ¶ added in v0.0.11
func RunReviewGate( ctx context.Context, gate domain.GateConfig, timeoutSec int, reviewer port.ReviewExecutor, fixer port.ReviewFixRunner, logger domain.Logger, ) (bool, error)
RunReviewGate runs the review-fix cycle before ComposeReport. Returns (true, nil) if review passes or is skipped (no ReviewCmd). Returns (false, nil) if review fails after all cycles. Returns (false, err) on infrastructure errors.
OTel spans are the caller's responsibility (session layer).
func RunScan ¶
func RunScan(ctx context.Context, cmd domain.RunScanCommand, cfg *domain.Config, baseDir, sessionID string, dryRun bool, streamOut io.Writer, logger domain.Logger, scanner port.ScanRunner, factory port.RecorderFactory) (*domain.ScanResult, error)
RunScan executes the scan, caches the result, and records session events. The command is always-valid by construction — no validation needed.
func RunSession ¶
func RunSession(ctx context.Context, cmd domain.RunSessionCommand, cfg *domain.Config, baseDir, sessionID string, dryRun bool, input io.Reader, out io.Writer, recorder port.Recorder, logger domain.Logger, metrics port.PolicyMetrics, runner port.SessionRunner) error
RunSession orchestrates the sightjack session pipeline. The command is always-valid by construction — no validation needed.
Types ¶
type PolicyEngine ¶
type PolicyEngine struct {
// contains filtered or unexported fields
}
PolicyEngine dispatches domain events to registered policy handlers. This connects the POLICY registry (domain.Policies) to executable handlers.
func NewPolicyEngine ¶
func NewPolicyEngine(logger domain.Logger) *PolicyEngine
NewPolicyEngine creates a PolicyEngine. Pass nil logger for silent operation.
func (*PolicyEngine) Dispatch ¶
Dispatch sends an event to all handlers registered for its type. Best-effort: handler errors are logged but never block event processing.
func (*PolicyEngine) Register ¶
func (e *PolicyEngine) Register(trigger domain.EventType, handler PolicyHandler)
Register adds a handler for the given event type. Multiple handlers can be registered for the same event type.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package port defines context-aware interface contracts and trivial default implementations (null objects) for the port-adapter pattern.
|
Package port defines context-aware interface contracts and trivial default implementations (null objects) for the port-adapter pattern. |