internal/

directory
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2026 License: AGPL-3.0

README

internal/

Server-internal Go packages. Go's internal rule makes these importable only by code in this module — they are not part of any public API and may change without notice. Anything that needs to be consumed from outside the module belongs in pkg/ instead.

Dependency direction

cmd/ → internal/server → (internal/api, internal/scheduler) → (internal/store, internal/bus). internal/server is the only wiring layer: it constructs the store, bus, scheduler, hub, auth chain and router and hands them to each other. Leaf packages (internal/store, internal/bus, internal/log, internal/health, internal/metrics, internal/version) import no other internal package. Two near-leaves are worth naming: internal/diag imports only internal/log, and internal/config imports internal/auth/oidc, internal/auth/policy, and internal/auth/rolemap to validate auth settings.

Concrete types never cross a package boundary. Handlers and the scheduler receive the store.Store interface, never *sqlite.Store, so tests inject internal/store/fake. internal/store/sqlite is imported only by internal/server and cmd/.

internal/openjd imports internal/store, so internal/store can never import internal/openjd. That is why the task state machine lives in internal/store/statemachine.go while the step state machine lives in internal/openjd/statemachine.go. It is also why the worker binary — which must not link internal/store — cannot import internal/openjd, and why the shared expression leaves internal/openjd/expr and internal/openjd/intrange exist.

Packages

Package Purpose
internal/api REST surface: chi router, handlers, request/response wire types, error shape
internal/auth Opt-in authentication and authorization: local passwords, sessions, API keys, RBAC policy, role mapping, LDAP/AD and OIDC/SSO
internal/bus Embedded NATS broker (JetStream streams for task status/logs/cancel and worker registration/heartbeat/deregister; plain core NATS for work.lease.<queue> request/reply and worker.diag.<workerID>) and the typed client wrapper over it
internal/config Layered runtime configuration (defaults → file → env → flags) and validation
internal/diag Bounded in-memory ring buffer of diagnostic (operational) log records from the server and connected workers
internal/discovery mDNS responder that advertises the running server on the local network
internal/fsutil Filesystem helpers shared across packages (AppleDouble sidecar filtering)
internal/health Liveness (/healthz, no checkers, always 200) and readiness (/readyz, runs the registered sqlite and nats checkers concurrently under a 5 s deadline; 503 degraded on any failure)
internal/log slog-based structured logging setup and helpers
internal/metrics Prometheus metric definitions and registration
internal/middleware net/http middleware (request logging, recovery, etc.)
internal/openjd OpenJD template parsing, validation, parameter-space expansion, path mapping
internal/presetgen Generates the shipped preset catalog artifacts from the reference preset definitions
internal/presetlib Fetches and caches the remote preset index; verifies SHA-256 on install
internal/product Product catalog: embedded built-ins overlaid on stored custom/installed products
internal/scheduler Lease handler and scheduling policy, worker registry, heartbeat/retention/unschedulable sweeps, cross-job dependency reconcile, and the server-side NATS consumers for task status, task logs, and worker diagnostics
internal/server Component lifecycle: starting and stopping the server's subsystems
internal/store Storage interface, SQLite-backed implementation, migrations, domain types, fake
internal/ui Serves the embedded web UI bundle with single-page-application fallback routing
internal/version Build-time metadata injected by the release toolchain
internal/worker sqi-worker agent internals (see subpackages below)
internal/ws WebSocket envelope, subscription hub, and fanout to web clients
internal/worker/ subpackages

The worker agent is decomposed into focused subpackages: capabilities and registration (self-reporting and registering with the server), discovery (locating the server via mDNS), natsclient and protocol (NATS transport and message types), lease (the long-poll work-lease loop over core NATS), heartbeat, executor and session (OpenJD session lifecycle and bare-metal process execution), isolation (run-as-user execution, one Provider per GOOS plus a fake), pathmap (storage-location path resolution), staging (stage_locally copy in/out via the operator's sync command), openjd and fmtres (worker-side OpenJD format-string and EXPR phase-3 resolution), envutil (environment filtering), logstreamer and status (streaming task output and status back to the server), cancel (task/Session cancellation), diaglog (the diagnostic-log sink that publishes to worker.diag.<workerID>), config, metrics, and obs (observability).

Directories

Path Synopsis
Package api wires together the sqi-server HTTP surface: the chi router, standard middleware stack, and all route groups.
Package api wires together the sqi-server HTTP surface: the chi router, standard middleware stack, and all route groups.
Package auth defines the authentication vocabulary shared across the sqi server surface: the request Principal, the pluggable Authenticator interface, and a no-op anonymous authenticator used when auth is disabled.
Package auth defines the authentication vocabulary shared across the sqi server surface: the request Principal, the pluggable Authenticator interface, and a no-op anonymous authenticator used when auth is disabled.
apikey
Package apikey implements a Bearer-token auth.Authenticator: it reads an Authorization: Bearer <key> header, resolves the key's hash to a live, non-revoked, non-expired api_keys row and its owning user, and returns the corresponding auth.Principal.
Package apikey implements a Bearer-token auth.Authenticator: it reads an Authorization: Bearer <key> header, resolves the key's hash to a live, non-revoked, non-expired api_keys row and its owning user, and returns the corresponding auth.Principal.
ldap
Package ldap authenticates usernames and passwords against an LDAP or Active Directory server.
Package ldap authenticates usernames and passwords against an LDAP or Active Directory server.
oidc
Package oidc authenticates sqi web UI logins against an OAuth2/OIDC identity provider (Phase 3, C2).
Package oidc authenticates sqi web UI logins against an OAuth2/OIDC identity provider (Phase 3, C2).
password
Package password hashes and verifies user passwords with argon2id and mints opaque session tokens.
Package password hashes and verifies user passwords with argon2id and mints opaque session tokens.
policy
Package policy is the authorization matrix for sqi's four built-in roles.
Package policy is the authorization matrix for sqi's four built-in roles.
rolemap
Package rolemap resolves an external identity's group memberships to one of B1's roles.
Package rolemap resolves an external identity's group memberships to one of B1's roles.
session
Package session implements a cookie-backed auth.Authenticator: it reads the session cookie, resolves its hashed token to a live session and user, and returns the corresponding auth.Principal.
Package session implements a cookie-backed auth.Authenticator: it reads the session cookie, resolves its hashed token to a live session and user, and returns the corresponding auth.Principal.
Package bus provides the embedded NATS JetStream message broker and the subject/stream definitions used for sqi-server's internal messaging.
Package bus provides the embedded NATS JetStream message broker and the subject/stream definitions used for sqi-server's internal messaging.
Package config defines the sqi-server runtime configuration and provides layered loading from built-in defaults, a YAML/JSON file, SQI_* environment variables, and CLI flag overrides — in that override order.
Package config defines the sqi-server runtime configuration and provides layered loading from built-in defaults, a YAML/JSON file, SQI_* environment variables, and CLI flag overrides — in that override order.
Package diag holds the server-side in-memory ring buffer of diagnostic (operational) log records gathered from sqi-server itself and from connected workers.
Package diag holds the server-side in-memory ring buffer of diagnostic (operational) log records gathered from sqi-server itself and from connected workers.
Package discovery advertises the running sqi-server on the local network via multicast DNS (mDNS / DNS-SD) so that workers and the sqi CLI can find it without manual address configuration.
Package discovery advertises the running sqi-server on the local network via multicast DNS (mDNS / DNS-SD) so that workers and the sqi CLI can find it without manual address configuration.
Package fsutil holds small filesystem helpers shared across sqi.
Package fsutil holds small filesystem helpers shared across sqi.
Package health implements liveness and readiness checks for sqi-server.
Package health implements liveness and readiness checks for sqi-server.
Package log provides slog-based structured logging for the sqi binaries.
Package log provides slog-based structured logging for the sqi binaries.
Package metrics defines and registers all Prometheus metrics for sqi-server.
Package metrics defines and registers all Prometheus metrics for sqi-server.
Package middleware provides net/http middleware for sqi-server.
Package middleware provides net/http middleware for sqi-server.
Package openjd implements parsing, validation, and parameter-space expansion for Open Job Description (OpenJD) job templates.
Package openjd implements parsing, validation, and parameter-space expansion for Open Job Description (OpenJD) job templates.
expr
Package expr reads and evaluates the OpenJD EXPR extension's expression language.
Package expr reads and evaluates the OpenJD EXPR extension's expression language.
fmtstring
Package fmtstring resolves Open Job Description (OpenJD) format strings.
Package fmtstring resolves Open Job Description (OpenJD) format strings.
intrange
Package intrange implements the OpenJD base specification's <IntRangeExpr> grammar (2023-09 Template Schemas, section 3.4.1.1.1): the succinct "1,3,7-10:2" form used for frame ranges.
Package intrange implements the OpenJD base specification's <IntRangeExpr> grammar (2023-09 Template Schemas, section 3.4.1.1.1): the succinct "1,3,7-10:2" form used for frame ranges.
Package presetgen generates a preset-library index and definition files from the repo's authored presets (presets/sqi/*.yaml) and publishes them into a library checkout.
Package presetgen generates a preset-library index and definition files from the repo's authored presets (presets/sqi/*.yaml) and publishes them into a library checkout.
Package presetlib is the client for a community preset library: it fetches a static JSON index (cached in memory) and, on install, fetches and verifies a single preset definition.
Package presetlib is the client for a community preset library: it fetches a static JSON index (cached in memory) and, on install, fetches and verifies a single preset definition.
Package product is the catalog layer over OpenJD templates: it parses product definition files, holds the embedded built-ins, validates inline templates, and overlays read-only built-ins on the store via Catalog.
Package product is the catalog layer over OpenJD templates: it parses product definition files, holds the embedded built-ins, validates inline templates, and overlays read-only built-ins on the store via Catalog.
Package scheduler implements the sqi-server assignment loop and worker registry — the authoritative component for deciding which task runs on which worker.
Package scheduler implements the sqi-server assignment loop and worker registry — the authoritative component for deciding which task runs on which worker.
Package server owns the sqi-server component lifecycle: starting and stopping the store, message bus, scheduler, HTTP server, and mDNS responder in the correct dependency order.
Package server owns the sqi-server component lifecycle: starting and stopping the store, message bus, scheduler, HTTP server, and mDNS responder in the correct dependency order.
Package store defines the storage interface for sqi-server and the domain model types shared across all components.
Package store defines the storage interface for sqi-server and the domain model types shared across all components.
fake
Package fake provides an in-memory implementation of store.Store for unit tests that must avoid touching the filesystem.
Package fake provides an in-memory implementation of store.Store for unit tests that must avoid touching the filesystem.
migrations
Package migrations embeds the SQL migration files used by goose to manage the sqi-server SQLite schema.
Package migrations embeds the SQL migration files used by goose to manage the sqi-server SQLite schema.
sqlite
Package sqlite provides a SQLite-backed implementation of store.Store.
Package sqlite provides a SQLite-backed implementation of store.Store.
Package ui serves the embedded web UI bundle over HTTP with single-page application (SPA) routing semantics.
Package ui serves the embedded web UI bundle over HTTP with single-page application (SPA) routing semantics.
Package version holds build-time metadata injected by the release toolchain.
Package version holds build-time metadata injected by the release toolchain.
worker
cancel
Package cancel implements per-task cancel-signal subscriptions for sqi-worker.
Package cancel implements per-task cancel-signal subscriptions for sqi-worker.
capabilities
Package capabilities provides auto-detection and manual override of sqi-worker host capabilities reported to sqi-server at registration time.
Package capabilities provides auto-detection and manual override of sqi-worker host capabilities reported to sqi-server at registration time.
config
Package config defines the sqi-worker runtime configuration and provides layered loading from built-in defaults, a YAML/JSON file, SQI_WORKER_* environment variables, and CLI flag overrides — in that override order.
Package config defines the sqi-worker runtime configuration and provides layered loading from built-in defaults, a YAML/JSON file, SQI_WORKER_* environment variables, and CLI flag overrides — in that override order.
diaglog
Package diaglog implements the sqi-worker diagnostic-log sink.
Package diaglog implements the sqi-worker diagnostic-log sink.
discovery
Package discovery provides mDNS-based sqi-server discovery for sqi-worker.
Package discovery provides mDNS-based sqi-server discovery for sqi-worker.
envutil
Package envutil provides shared helpers for building process environment variable slices from os.Environ() plus a caller-supplied override map.
Package envutil provides shared helpers for building process environment variable slices from os.Environ() plus a caller-supplied override map.
executor
Package executor implements the bare-metal task executor for sqi-worker.
Package executor implements the bare-metal task executor for sqi-worker.
fmtres
Package fmtres resolves OpenJD "{{...}}" format strings on the worker, where the session working directory — and therefore Session.WorkingDirectory — is only known at run time.
Package fmtres resolves OpenJD "{{...}}" format strings on the worker, where the session working directory — and therefore Session.WorkingDirectory — is only known at run time.
heartbeat
Package heartbeat implements the worker's periodic liveness signal to sqi-server.
Package heartbeat implements the worker's periodic liveness signal to sqi-server.
isolation
Package isolation runs job-supplied processes under a queue-configured OS identity instead of the worker daemon's own account.
Package isolation runs job-supplied processes under a queue-configured OS identity instead of the worker daemon's own account.
lease
Package lease implements the worker side of the work-lease protocol: it keeps exactly one outstanding lease request per queue and dispatches each assignment the server returns.
Package lease implements the worker side of the work-lease protocol: it keeps exactly one outstanding lease request per queue and dispatches each assignment the server returns.
logstreamer
Package logstreamer implements the log-chunk publisher for sqi-worker.
Package logstreamer implements the log-chunk publisher for sqi-worker.
metrics
Package metrics defines and registers all Prometheus metrics for sqi-worker.
Package metrics defines and registers all Prometheus metrics for sqi-worker.
natsclient
Package natsclient provides the NATS client factory for sqi-worker.
Package natsclient provides the NATS client factory for sqi-worker.
obs
Package obs provides the local observability HTTP server for sqi-worker.
Package obs provides the local observability HTTP server for sqi-worker.
openjd
Package openjd implements the OpenJD progress-line interceptor for sqi-worker.
Package openjd implements the OpenJD progress-line interceptor for sqi-worker.
pathmap
Package pathmap implements resolved-mode path substitution for sqi-worker.
Package pathmap implements resolved-mode path substitution for sqi-worker.
protocol
Package protocol defines the versioned JSON wire protocol used between sqi-server and sqi-worker agents.
Package protocol defines the versioned JSON wire protocol used between sqi-server and sqi-worker agents.
registration
Package registration manages worker registration with sqi-server over NATS.
Package registration manages worker registration with sqi-server over NATS.
session
Package session manages the lifecycle of OpenJD sessions on the worker.
Package session manages the lifecycle of OpenJD sessions on the worker.
staging
Package staging implements the stage_locally path delivery: copying job inputs to worker-local scratch before a task runs and outputs back afterward.
Package staging implements the stage_locally path delivery: copying job inputs to worker-local scratch before a task runs and outputs back afterward.
status
Package status implements the typed task-status publisher for sqi-worker.
Package status implements the typed task-status publisher for sqi-worker.
Package ws defines the typed WebSocket message envelope shared by the server upgrade handler (internal/api) and the fanout layer.
Package ws defines the typed WebSocket message envelope shared by the server upgrade handler (internal/api) and the fanout layer.

Jump to

Keyboard shortcuts

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