Documentation
¶
Overview ¶
Package service composes the `da service` runtime out of the pieces the sibling packages ship (spec §2A shape, OQ5 option B): the event bus behind the D4.1 EventBus interface seam, the in-process scheduler hosting the two v1 background tasks (iter-log ingester + rubric-bump rescorer), and BOTH transport listeners — the Unix-domain-socket control plane (`da service status`/`stop`, peer-credential gated per OQ4/§2A) and the HTTP/SSE edge (loopback-only by default per OQ3).
The package owns composition and lifecycle only: construction order is bus → scheduler (tasks registered) → listeners, and shutdown unwinds in reverse — listeners down, scheduler drained (bounded), bus closed. It deliberately contains no cobra surface and never calls os.Exit; errors are returned clean so the CLI layer can render them.
Index ¶
Constants ¶
const ControlSocketName = "service.sock"
ControlSocketName is the filename of the default per-repo control socket, placed under <RepoDir>/.agents/active/ alongside the other live service artifacts (the iteration log, the service-state watermarks).
const DefaultHTTPAddr = "127.0.0.1:7878"
DefaultHTTPAddr is the default bind address of the HTTP/SSE edge: loopback-only per spec OQ3. Binding beyond loopback is a deliberate external opt-in made by passing an explicit non-loopback HTTPAddr.
Variables ¶
var ErrUnknownTask = errors.New("service: unknown task name in EnabledTasks")
ErrUnknownTask is returned by Run when Config.EnabledTasks names a task the runtime does not know how to build.
Functions ¶
func Run ¶
Run composes and runs the full service runtime until ctx is cancelled or an authorized stop request arrives on the control socket (OQ4: stop rides the peer-credential-gated control plane, wired here to the runtime cancel). It wires the event bus into the scheduler tasks, starts the scheduler, serves both listeners, and on shutdown unwinds everything in reverse construction order: listeners first, then the scheduler drain (bounded by shutdownTimeout), then the bus. A nil return means a clean ctx- or stop-driven shutdown with every goroutine accounted for.
Types ¶
type Config ¶
type Config struct {
// ControlSocket is the local control-plane endpoint (spec §2A "local
// control plane" row): the Unix-domain socket path (named-pipe name on
// Windows, once the pipe transport lands) that answers `da service
// status`/`stop`. Empty defaults to
// <RepoDir>/.agents/active/service.sock.
ControlSocket string
// HTTPAddr is the HTTP/SSE edge bind address. Empty defaults to
// DefaultHTTPAddr (loopback-only, OQ3); an explicit non-loopback
// address is the deliberate external opt-in.
HTTPAddr string
// IterLogDir is the iteration-log directory the ingester task watches.
// Empty defaults to <RepoDir>/.agents/active/iteration-log.
IterLogDir string
// RepoDir is the repository root the tasks resolve scoring and
// watermark state against. Empty defaults to the current working
// directory.
RepoDir string
// RescoreInterval is the rescore task's rubric-version check cadence.
// Zero applies the tasks package default.
RescoreInterval time.Duration
// ShutdownTimeout is the single wall-clock budget covering the whole
// teardown (both listeners + scheduler drain, concurrently) once shutdown
// begins. Zero applies shutdownTimeout (5s, the spec exit-within-5s bound).
// A straggler still draining when the budget expires is abandoned.
ShutdownTimeout time.Duration
// EnabledTasks selects which background tasks Run registers, by
// scheduler task name (tasks.IterLogIngesterName, tasks.RescoreName).
// Empty enables every builtin task; an unknown name is rejected.
EnabledTasks []string
// Bus is the event transport backend behind the spec D4.1 EventBus
// interface seam. Nil constructs the in-process builtin (D4.3) — the
// only backend that ships in v1 per the OQ6 interface-only ruling.
// Injecting a bus is how a future config-selected adapter (D4.4) — or
// a test subscriber — plugs in; either way Run owns the bus lifecycle
// and closes it on shutdown.
Bus events.EventBus
}
Config configures the composed `da service` runtime (Run). The zero value is usable: every field resolves to a sensible per-repo default that matches the rest of the CLI's conventions.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package events provides an in-process publish/subscribe bus that lets background tasks notify subscribers about state changes without coupling to them.
|
Package events provides an in-process publish/subscribe bus that lets background tasks notify subscribers about state changes without coupling to them. |
|
eventbustest
Package eventbustest ships the backend-conformance suite for the events.EventBus transport seam (spec D4.6).
|
Package eventbustest ships the backend-conformance suite for the events.EventBus transport seam (spec D4.6). |
|
Package http is the transport layer of the `da service` runtime (spec §2A, OQ5 option B).
|
Package http is the transport layer of the `da service` runtime (spec §2A, OQ5 option B). |
|
Package scheduler is the in-process job scheduler that hosts the background tasks of the `da service` runtime.
|
Package scheduler is the in-process job scheduler that hosts the background tasks of the `da service` runtime. |
|
Package state persists the per-task watermark sidecars that give the `da service` background tasks restart safety (R3 design decision D3).
|
Package state persists the per-task watermark sidecars that give the `da service` background tasks restart safety (R3 design decision D3). |
|
Package tasks contains the concrete background tasks hosted by the `da service` scheduler (R3 design D2).
|
Package tasks contains the concrete background tasks hosted by the `da service` scheduler (R3 design D2). |