Introducing a new way to review your PRs.

Read the announcement

hcavarsan / pipedash

One dashboard for CI/CD pipelines across multiple providers

View on GitHub

19 documents · Updated Nov 23, 2026

docs / core-domain-and-persistence

Core domain and persistence

The crates/pipedash-core crate is the framework-free center of Pipedash. It gives the product one model for providers, pipelines, runs, health, alerts, logs, and settings. It also joins provider plugins, application work, events, and durable storage so that product hosts can use the same rules across desktop, web, and background flows.

Domain model

The domain model gives data from many build and delivery systems one shared meaning. Application services and product hosts use these types to show state, choose safe actions, filter history, and handle errors without knowing a provider's API shape.

Domain areaProduct meaning
ProvidersConfigured connections to external build or delivery systems.
Pipelines and runsWorkflows, their state, run history, source details, inputs, and actions.
HealthEvidence about provider access, service state, incidents, maintenance, and limits.
MetricsRun measures and summaries over time.
Pipeline viewsSaved ways to group, filter, sort, and pin pipelines.
Alerts and devicesStored alerts, paired-device state, push state, and notification preferences.
Notification centerA bounded ordered view of current and missed notices with read state.
Run logsLog trees and log documents that can be followed, searched, and exported.
CCTray feedA common XML status view for external build monitors.
Domain errorsStable failure classes that guide display, retry, and recovery.

Provider data becomes common pipeline and run data before application services use it. A pipeline can remain readable when its provider has no credentials, while write actions stay blocked. Pipeline state also carries learned timing signals: a run can be marked overdue, stuck in a queue, or quiet when it stops following its usual cadence.

Alerts use stable kinds for failed, degraded, long-running, stuck, outage, recovered, finished, quiet, and test notices. Preferences can enable kinds, mute providers or pipelines, watch a pipeline, or watch only its next finish. A one-time watch expires after seven days and records the finish that used it. The notification center keeps at most 50 items and tracks unread changes with a revision.

The domain also exposes a CCTray view. It maps pipeline state to build activity and result, adds a product link when the host origin is usable, escapes XML values, encodes path segments, and disambiguates equal display names.

References: crates/…/mod.rs• L1-201 crates/…/pipeline.rs• L22-157 crates/…/device_alert.rs• L14-264 crates/…/preferences.rs• L23-192 crates/…/notification_center.rs• L23-253 crates/…/tests.rs• L32-133

Application services

The application layer turns domain rules into product actions and background work. It coordinates providers, cache state, refresh timing, health checks, metrics, views, alerts, and logs without depending on a product host.

The main service boundaries are:

  • ProviderService owns provider configuration, connections, permissions, health inputs, and provider replacement.
  • PipelineService fetches current pipelines, manages run history, presents actions, and marks timing signals.
  • RefreshManager and the fetch scheduler control scheduled, background, idle, and forced work.
  • ProviderHealthService combines fetch results, status feeds, component checks, and rate-limit evidence.
  • MetricsService records and reads run measures when metrics are enabled.
  • PipelineViewService manages saved views over provider and pipeline state.
  • LogService manages live access, cached documents, search, and export.
  • Device-alert and push services turn core changes into durable or remote notices.

Services builds these parts around shared configuration, persistence, plugins, events, and log storage. CoreContext owns the resulting graph and its lifecycle.

References: crates/…/mod.rs• L8-155 crates/…/device_alerts.rs• L134-161 crates/…/config.rs• L28-312 crates/…/config.rs• L26-168

Provider plugin boundary

The provider plugin boundary lets each external system keep its own API rules while the core uses one provider contract. A plugin supplies pipeline data, run history, actions, health checks, status sources, archive rules, and log access. The core converts those results into shared domain objects.

The adapter gives every provider resource a core ID that includes provider type and provider identity. It removes that wrapper before a plugin call and adds it again to returned pipelines, runs, and trigger results. It also maps plugin failures into domain errors and forwards capability and history rules to application services. This keeps provider-specific behavior inside the plugin boundary while common flows remain provider-neutral.

Provider configuration follows the same boundary. The service checks that a provider type is registered, validates the provider draft, stores resolved credentials through the token boundary, and replaces the active connection as one coordinated change. A file change can add, update, or remove file-managed providers. The change also rebuilds health state and queues fresh work.

References: crates/…/plugin_adapter.rs• L31-175 crates/…/plugin_adapter.rs• L177-390 crates/…/config.rs• L106-214 crates/…/config.rs• L265-306

Refresh and pipeline timing

Refresh work turns provider configuration into current pipeline state. Scheduled work claims due providers through the scheduler. Forced work can run during idle mode, while scheduled work stops before it consumes a fetch permit. A provider generation prevents a result from an older connection from replacing newer state.

The refresh path joins current data, run history, health evidence, metrics, and events.

flowchart LR
    Config[Provider configuration] --> Scheduler[Refresh scheduler]
    Scheduler --> Fetch[Pipeline fetch]
    Fetch --> Plugin[Provider plugin]
    Plugin --> Cache[Pipeline and run cache]
    Fetch --> Health[Health evidence]
    Cache --> Timing[Overdue and cadence signals]
    Timing --> Notices[Alerts and notifications]
    Fetch --> Events[Core events]

After a successful fetch, the service writes the pipeline cache and emits updates only for meaningful changes. It keeps the last good cache after a failed fetch and records the failure for health and retry decisions. A changed pipeline clears run history for providers that do not retain history. Providers that retain native history keep the cache and can mark missing runs as archived.

The service derives overdue state from recent successful durations and marks a queued run as stuck when it passes the configured queue limit. It learns a pipeline's usual run gap from recent starts. A pipeline becomes quiet only after it passes twice that gap. Learning uses a small fetch budget so one provider with failing history cannot block other pipelines. These timing signals feed both pipeline presentation and notification selection.

The service also supports filtered run-history queries. It validates sort columns against the provider's table schema, filters before pagination, and scans deeper remote history when the cached prefix cannot answer the request. A bounded provider history is refreshed fully. An unbounded history can return a scan notice when the work cap prevents a complete global sort.

References: crates/…/fetch.rs• L39-307 crates/…/refresh.rs• L35-221 crates/…/overdue.rs• L33-287 crates/…/cadence.rs• L24-221 crates/…/history.rs• L23-195 crates/…/query.rs• L33-211 crates/…/cache.rs• L5-64 crates/…/pipeline.rs• L63-150

Notification flow

Notifications convert state changes into user-visible notices without treating every repeated observation as a new event. NotificationState keeps a baseline for providers and pipelines. It compares later updates with that baseline to find new failures, recoveries, finishes, long runs, stuck queues, quiet pipelines, and provider health changes.

The recorder observes selected core events, publishes recent observations, applies device preferences, and stores accepted alerts. Finished and quiet notices are opt-in. A one-time watch is marked as used in the device preference store before the alert is saved. The observation queue is bounded, and old stored alerts are pruned on a schedule.

sequenceDiagram
    participant Source as Core events or health scan
    participant State as Notification state
    participant Prefs as Device preferences
    participant Store as Alert store
    participant Center as Notification center

    Source->>State: Observe provider or pipeline change
    State->>State: Compare with baseline and suppress duplicates
    State->>Prefs: Check mute and watch rules
    Prefs-->>State: Admit or reject notice
    State->>Center: Publish recent observation
    State->>Store: Save accepted device alert

The notification center is a separate bounded view. It replaces an item with the same key, inserts new items at the front, keeps the newest 50 items, and increments its revision when content or read state changes. This gives hosts a small durable snapshot while the alert recorder keeps the event-to-alert rules.

References: crates/…/notifications.rs• L48-381 crates/…/pipelines.rs• L16-225 crates/…/device_alerts.rs• L47-289 crates/…/preferences.rs• L78-188 crates/…/notification_center.rs• L84-249

Event boundary

The event boundary carries core state changes to hosts and listeners. CoreEvent is the shared vocabulary for provider changes, pipeline updates, run actions, metrics, health alerts, migrations, vault state, devices, and log progress.

Events announce changes. The owning repository or service remains the source of durable provider, cache, alert, device, and configuration state. Broadcast and targeted delivery are available, and a no-op bus lets the core run without an external listener.

References: crates/…/event.rs• L28-235 crates/…/lib.rs• L43-47 crates/…/fetch.rs• L244-273

Logging boundary

The core has a runtime tracing boundary and a user run-log boundary. Tracing explains core work and failures. Run-log handling keeps provider output as a user resource that can be followed during a run and read later.

The log service uses provider access and a dedicated store to build log trees, ingest documents, publish revisions, search content, and export data. Provider generations, cache epochs, leases, and cancellation stop old work from publishing after a provider changes or the core shuts down. A live document can resume from a cursor and keeps its prior output when a later read fails.

References: crates/…/logging.rs• L8-22 crates/…/documents.rs• L44-109 crates/…/documents.rs• L199-273 crates/…/store.rs• L119-187 crates/…/store.rs• L245-339

Configuration boundary

Configuration is the durable source for host settings, provider definitions, saved views, push relay choice, and storage choice. The loader parses and validates the file before the settings become active. The state layer keeps the validated in-memory view and applies provider changes through ProviderService.

Saving a setting edits the existing TOML document instead of replacing its useful structure. Environment references remain in place when their resolved value still matches the setting. File writes use a temporary file and rename when possible. They follow symlinks, keep the existing mode, and refuse a read-only target. The storage service validates new content before saving it, then applies the provider changes to the active core when a context is present.

Provider import and file sync use the plugin registry to reject unknown types. They can preserve token references rather than copying secret values into exported configuration. File-managed providers are tracked so a removed entry can be removed from the active store, while database-managed providers can remain outside that file flow.

References: crates/…/mod.rs• L1-44 crates/…/persistence.rs• L24-141 crates/…/persistence.rs• L22-113 crates/…/file.rs• L15-64 crates/…/tests.rs• L5-73 crates/…/config.rs• L69-164 crates/…/config.rs• L28-214

Persistence boundary

Persistence separates settings, secrets, product cache, metrics, and file-like data. Application services use contracts for these data classes, so the same product rules can run with local SQLite or PostgreSQL where supported.

Data classOwning boundaryProduct role
Provider settingsConfigBackendProvider definitions, preferences, permissions, and transfer.
Provider secretsTokenStoreCredential access without exposing secret protection to services.
Product stateDatabase repositoriesPipelines, runs, metrics, views, alerts, devices, and push registrations.
Object dataStorageBackend and the run-log storeCached objects and large log documents.

Pipeline rows are converted back into shared domain state when read. The repository accepts SQLite and PostgreSQL time shapes, restores status and metadata, and rejects invalid stored JSON rather than returning partial pipeline data. Run-cache epochs prevent a history response that started before invalidation from refilling cleared data.

The backend contracts must stay equivalent. Cache writes and reads need matching query meaning in both database modes. Metrics avoid duplicate observations for the same run and metric type. Snapshot-only data does not become durable failure history. Provider removal also cleans dependent local records within the supported storage boundary.

References: crates/…/mod.rs• L1-56 crates/…/config_backend.rs• L14-74 crates/…/pipeline_row.rs• L17-118 crates/…/repository.rs• L20-45 crates/…/sqlite_backend.rs• L31-334 crates/…/postgres_backend.rs• L31-257 crates/…/cache.rs• L34-64

Secret storage

Secret storage keeps provider credentials behind the asynchronous TokenStore contract. The storage manager selects a platform keyring or an encrypted vault, so provider services do not need to know how tokens are protected.

The vault checks its password before loading tokens and can start locked when the password is not available. Each vault has its own key-derivation salt. A legacy vault can upgrade to that salt without discarding readable tokens. Token export and import use a separate backup password. Locked or incorrectly unlocked stores fail clearly instead of treating missing credentials as valid data.

References: crates/…/crypto.rs• L23-108 crates/…/vault.rs• L20-139 crates/…/sqlite.rs• L30-181 crates/…/postgres.rs• L34-183 crates/…/manager.rs• L45-183

Database migrations

Schema migration and storage migration are different flows. Schema migration prepares a database for normal use at startup. Storage migration moves user data when the backend, database identity, or data directory changes.

Storage migration first analyzes the target and shows counts for the data that can move. The user confirms which cache and secret data to include. The orchestrator then validates the target, creates backups, moves selected records, remaps linked IDs, verifies the target, and saves the new storage configuration.

This diagram shows the storage-migration boundary and its recovery path.

flowchart TD
    Analyze[Analyze source and target] --> Confirm[Confirm data choices]
    Confirm --> Backup[Create source and target backups]
    Backup --> Move[Move selected settings secrets and cache]
    Move --> Remap[Remap provider and pipeline links]
    Remap --> Verify[Verify target records]
    Verify --> Save[Save target storage settings]
    Move -->|failure| Restore[Restore supported backups]
    Verify -->|failure| Restore

Provider ID maps must reach pipelines, tokens, metrics, views, notification preferences, alerts, and cached history. Links to providers that do not exist in the target are removed. A PostgreSQL credential or option change keeps the same database when host, port, and database name do not change. A database identity change requires migration.

The backup manager makes a SQLite copy with committed data, exports PostgreSQL source data when a backend is available, and copies the configuration file. Local SQLite backups can be restored automatically. PostgreSQL JSON exports are retained for manual recovery rather than being restored automatically.

References: crates/…/schema.rs• L17-78 crates/…/migration.rs• L77-235 crates/…/backup.rs• L27-369 crates/…/execution.rs• L84-190 crates/…/verify.rs• L15-121 crates/…/remap.rs• L13-118 crates/…/tests.rs• L8-87

Core lifecycle

CoreContext is the lifecycle boundary for the crate. It prepares configuration and storage, applies schema migrations, synchronizes providers, builds the shared services, starts background work, and joins that work during shutdown.

sequenceDiagram
    participant Host as Product host
    participant Core as CoreContext
    participant Store as Configuration and storage
    participant Services as Application services
    participant Bus as Event bus

    Host->>Core: Create context
    Core->>Store: Load settings and open storage
    Core->>Store: Apply schema migrations
    Core->>Services: Build service graph
    Core->>Bus: Attach event delivery
    Host->>Core: Start background work
    Core->>Services: Start refresh health logs and alerts
    Host->>Core: Shutdown
    Core->>Services: Cancel and join background work

Factory reset uses the same ownership boundaries. It removes provider settings, secrets, caches, views, logs, metrics, alerts, device state, and push registrations through their owning services.

References: crates/…/context.rs• L58-171 crates/…/lib.rs• L99-187 crates/…/lib.rs• L232-250

The core supplies shared contracts to the pages below. Read them when the question moves from core coordination to a product-facing boundary:

Change checklist

When these files or sections are changed, remember to consider these:

  • A pipeline timing change must keep fetch, run-history cache, health notices, notification baselines, and host presentation aligned.
  • A run-history scan or sort change must preserve provider history policy, cache merge behavior, pagination completeness, scan notices, and metric extraction.
  • A notification kind or preference change must keep event observation, opt-in filtering, one-time watch state, stored alerts, and center tones aligned.
  • A provider ID or pipeline ID change must cover tokens, cache rows, metrics, views, notification preferences, alerts, history, and log paths.
  • A provider generation or run-cache epoch change must reject old fetch, history, cadence, health, metric, and log results before they publish state.
  • A configuration-file write change must preserve environment references, symlink targets, file mode, and the apply-after-save contract.
  • A new persisted field must have matching domain serialization, repository conversion, schema, and SQLite/PostgreSQL behavior.
  • A plugin capability or local identifier change must pass through the adapter, provider service, presenter, and every application action that uses it.
  • A storage identity or migration-choice change must keep analysis, confirmation, backups, remapping, target verification, and saved configuration consistent.
  • A lifecycle change must preserve start-once behavior, cancellation, task joining, and shutdown ordering for refresh, health, logs, alerts, and config watching.

Important failure modes

TriggerConsequenceGuard
A provider changes while fetch or history work is activeOld data can replace current state or refill a cache that was clearedProvider generations and run-cache epochs reject superseded work before commit.
A provider does not retain history but changed pipeline data keeps the old cacheRun details can describe a different pipeline instancePipeline changes invalidate run history for non-retaining providers.
A global history sort reaches its scan capThe host can show an incomplete result as a full sortThe page returns a scan notice and asks for deeper history.
A pipeline is quiet at the first observationThe user receives a false quiet alertCadence and notification state seed a silent baseline.
A finished or quiet notice has no matching watchOpt-in notices can become unwanted device alertsPreference admission and the recorder's opt-in check require a watcher.
A repeated health or pipeline event arrivesUsers receive duplicate alertsNotification baselines, alert keys, and delivered-key tracking suppress repeats.
Configuration writing replaces a symlink or loses an environment referenceThe active file target or secret indirection can breakAtomic writes resolve the link and save logic preserves matching variable references.
Stored pipeline JSON or status is invalidThe application can show partial or misleading pipeline stateRepository conversion returns a database error.
SQLite and PostgreSQL contracts driftOne storage mode can lose or misread product stateShared configuration contracts and equivalent backend query behavior are required.
A vault starts without a valid passwordProvider actions cannot authenticate or can use unclear empty dataLocked startup and verifier checks make token access fail clearly.
A migration moves linked records without applying provider mapsViews, alerts, preferences, metrics, or history point to missing resourcesRemapping runs before target verification.
Migration backup creation failsData movement can start without a recovery copyBackup creation is part of the guarded migration path and must complete first.

Key files

FileWhy to read it
crates/…/lib.rsDefines the public core boundary, context lifecycle, reset behavior, and exported contracts.
crates/…/context.rsShows how configuration, storage, plugins, events, and application services become one context.
crates/…/mod.rsShows the shared domain concepts exposed by the core.
crates/…/pipeline.rsDefines pipeline, run, status, cadence, and pace data used across refresh and notification flows.
crates/…/device_alert.rsDefines alert kinds, watches, notification preferences, and stored device alerts.
crates/…/notification_center.rsDefines the bounded read-state view used by hosts.
crates/…/mod.rsShows the application service graph and shared dependencies.
crates/…/fetch.rsShows how provider fetches become cache state, health input, timing work, and events.
crates/…/query.rsShows history filtering, sorting, pagination, and deeper scans.
crates/…/cadence.rsShows how run history becomes a usual cadence and quiet state.
crates/…/notifications.rsShows notification baselines, deduplication, health notices, and event observation.
crates/…/device_alerts.rsShows preference admission, durable alert recording, recent observations, and pruning.
crates/…/event.rsDefines the cross-boundary event vocabulary and delivery contract.
crates/…/plugin_adapter.rsShows ID conversion, plugin result mapping, capability forwarding, and error mapping.
crates/…/persistence.rsShows how settings are saved while preserving TOML structure and references.
crates/…/file.rsShows the safe file-write boundary for configuration.
crates/…/config_backend.rsDefines the storage-neutral contract for provider configuration and transfer.
crates/…/pipeline_row.rsShows how stored rows become shared pipeline state across database types.
crates/…/migration.rsShows storage-migration planning, movement, progress, verification, and configuration updates.
crates/…/backup.rsShows migration backup, restore, and cleanup boundaries.
crates/…/vault.rsShows vault verification, locked startup, salt upgrade, token loading, and backup handling.
crates/…/store.rsShows durable log revisions, leases, cache epochs, and file-backed log storage.
crates/…/logging.rsShows runtime tracing defaults for the core and related services.