Skip to main content
Rugix Bakery 0.9.6 is here: Build rules for custom image pipelines and verified boot for EFI and Raspberry Pi. Read the release post.
Documentation

Discovery and Transport

Preview
You're viewing the Next docs — a rolling preview of in-development changes. The current release docs may differ.

On Linux, the system image, apps, and services publish their records as JSON files in standard directories, and tools read the records from there. For example, on the gateway from the overview, the system image ships its component declaration as /usr/lib/system-runtime/components/system.gateway-os.json, and a service of the telemetry app writes the result of its latest database check to /run/system-runtime/health/status/app.telemetry.postgres.json. This page describes where the files go, how to write them, how readers find and combine them, and how to send health information to another system.

Why Files

Records are published as plain files rather than through a central service or API. Files let each contributor publish its records in the way that suits it best:

  • The system image ships its declarations as part of its root filesystem, so they change exactly when the system image does.
  • An app ships its declarations inside its installation directory, so they appear and disappear with the app.
  • A service writes its status records whenever it has run a check, without knowing which tools will read them, and without failing when none is running.

Readers, in turn, load the records whenever they need them. No daemon has to run for records to be published, and a reader that starts late still sees the current records.

Directory Layout

The specification defines standard directories for each kind of record:

RecordsStandard Directories
Component declarations/usr/lib/system-runtime/components
/etc/system-runtime/components
/run/system-runtime/components
Health nodes/usr/lib/system-runtime/health/nodes
/etc/system-runtime/health/nodes
/run/system-runtime/health/nodes
Health status records/run/system-runtime/health/status
Metric definitions/usr/lib/system-runtime/metrics/definitions
/etc/system-runtime/metrics/definitions
/run/system-runtime/metrics/definitions
Metric samples/run/system-runtime/metrics/samples
Directory configurations/usr/lib/system-runtime/directories
/etc/system-runtime/directories
/run/system-runtime/directories

The three locations for definitions follow common Linux conventions:

  • /usr/lib/system-runtime holds records that belong to the system image, such as its component declaration and the health nodes of its checks.
  • /etc/system-runtime holds records specific to a device, such as records that an administrator adds for a single device.
  • /run/system-runtime holds records generated at runtime, such as the board revision that a service reads from the hardware at boot. It is typically on a temporary filesystem and empty after every boot.

The standard directories for status records and metric samples exist only below /run/system-runtime, because these records are only valid during the boot in which they were published. Directory configurations add further directories, for example, those of apps, as described in Adding Directories.

Publishing Records

Each record is a regular file with the extension .json that contains exactly one record of the directory’s kind. The file name is up to the publisher; the record’s ID determines its identity. Writers omit optional fields that are not set.

Readers may load a file at any moment, including while it is being written. To prevent them from reading a partially written file, write the record to a temporary file with a different extension in the same directory, then rename it to its final name. Renaming within a directory replaces a file atomically. There are no transactions across files, so a reader may see a new version of one file and an old version of another.

For example, the following script checks with pg_isready whether PostgreSQL accepts connections and publishes the result as a status record for the app.telemetry.postgres node from Health. A systemd timer can run it every 5 seconds:

#!/bin/sh
# Take the time before running the check, so that a slow check does
# not extend the validity of its result. /proc/uptime contains the
# boot-time clock in seconds.
boot_id=$(cat /proc/sys/kernel/random/boot_id)
observed_at_ms=$(awk '{ printf "%.0f", $1 * 1000 }' /proc/uptime)

if pg_isready -q -h 127.0.0.1 -p 5432; then
    state=healthy message="Accepting connections"
else
    state=unhealthy message="Not accepting connections"
fi

dir=/run/system-runtime/health/status
mkdir -p "$dir"
cat > "$dir/app.telemetry.postgres.json.tmp" <<EOF
{
  "id": "app.telemetry.postgres",
  "owner": "rugix.apps.telemetry",
  "state": "$state",
  "bootId": "$boot_id",
  "observedAtMs": $observed_at_ms,
  "maxAgeMs": 15000,
  "message": "$message"
}
EOF
mv "$dir/app.telemetry.postgres.json.tmp" "$dir/app.telemetry.postgres.json"

Each status record and each metric sample has exactly one publisher. The directories do not authenticate publishers, so restrict write access to them. To let an unprivileged service publish its records without giving it access to the records of other services, give the service a directory of its own and add it with a directory configuration.

Reading Records

A reader collects the records of each kind from all directories of that kind and combines them. Records in different directories do not override each other, so a file in /etc/system-runtime with the same name as a file in /usr/lib/system-runtime adds a second record. Two components with the same ID make the composition inconsistent, and two health or metric records of the same kind with the same ID make evaluation fail.

To read the records of one kind, a reader:

  1. Loads the directory configurations and appends their directories to the standard directories.
  2. Visits the directories in order and traverses each recursively, visiting entries in lexical order.
  3. Reads every regular file with the extension .json, skipping files with other extensions and symlinks inside the directories.
  4. Reads each file only once, even when several directories overlap.

Missing directories are skipped. A path that exists but is not a directory, a broken symlink in place of a directory, a file that cannot be read, and a file that does not contain a valid record are errors. Readers ignore unknown fields in records, so records with fields added by a newer version of the specification remain readable. New kinds of health rules or new units, in contrast, require updated readers.

Because records can change at any moment, a reader loads a fresh set of records before acting on them. If loading fails because a file changed during the read, for example, because it was removed, the reader loads the records again. The language packages report such failures as errors and leave retrying to the caller.

Adding Directories

A directory configuration adds directories in which readers look for records. Readers load directory configurations from /usr/lib/system-runtime/directories, /etc/system-runtime/directories, and /run/system-runtime/directories. For example, a Node-RED installation in /opt/node-red can add its own directories, including a status directory for its service, with /etc/system-runtime/directories/node-red.json:

{
  "components": ["/opt/node-red/components"],
  "healthNodes": ["/opt/node-red/health/nodes"],
  "healthStatuses": ["/run/node-red/health/status"]
}

Paths must be absolute. A path segment consisting of only * matches every directory at that level, in lexical order. Readers expand such patterns every time they load records, so one configuration covers installations added later. Relative paths, .. segments, and other wildcards, such as *.d or **, make loading fail.

Wildcards only match real directories, not symlinks to directories. Explicit path segments, in contrast, may be symlinks, such as the current symlink of Rugix Apps. A reader resolves every matched directory to its physical location before reading its files. If the symlink changes while the reader traverses the directory, the reader still reads all files from the directory it resolved first, never a mix of both.

Directory configurations cannot add further directory configurations.

Discovering Rugix Apps

Rugix Apps keeps each installed version of an app, a generation, in its own directory. A current symlink in the app’s directory points to the active generation. An app’s payloads can place health nodes in the .rugix/health/nodes directory of the generation, as described in Rugix Apps Internals. Adding the following configuration to the system image, for example, as /usr/lib/system-runtime/directories/rugix-apps.json, makes the health nodes and component declarations of all active apps visible to readers:

{
  "components": ["/run/rugix/state/apps/*/current/.rugix/components"],
  "healthNodes": ["/run/rugix/state/apps/*/current/.rugix/health/nodes"]
}

If Rugix state management is not active, apps live in /var/lib/rugix/apps instead of /run/rugix/state/apps.

The current symlink makes this configuration follow the app’s lifecycle. While Rugix Apps switches to a new generation, the symlink keeps pointing to the previous generation and changes atomically once the new generation has been activated successfully. If activation fails and Rugix Apps rolls back, the symlink never changes. When an app is activated for the first time, the symlink appears once activation has succeeded. After an app has been deactivated or has entered the Error state, the symlink is removed, and the app’s records disappear.

Rugix Ctrl’s Component Directories

For its compatibility checks, Rugix Ctrl reads component declarations from its own directories. The following configuration, for example, as /usr/lib/system-runtime/directories/rugix.json, makes them visible to readers of the specification:

{
  "components": [
    "/usr/lib/rugix/components",
    "/etc/rugix/components",
    "/run/rugix/components"
  ]
}

Rugix Ctrl accepts component declarations in TOML or JSON, while readers of the specification only read .json files. Write declarations in JSON, including those shipped with apps, to make them visible to both. Give them an owner as well, because readers do not derive owners from directories.

Rugix Ctrl also adds a rugix.host component with the capabilities host.arch and rugix.ctrl when it checks compatibility. This component does not exist as a file, so for other readers, requirements on these capabilities remain unsatisfied unless another component provides them.

Sending Health to Another System

A fleet-management server or a remote diagnostic tool may want to show a device’s health. Sending only the evaluated states loses the information an operator needs to understand them: which checks a function depends on, what each check reported, and when it ran. A health snapshot therefore contains the records themselves, so that the receiver can evaluate and display the complete graph. It contains:

  • the health nodes,
  • the status records, unchanged,
  • metric definitions and samples, including at least the definition of every metric referenced by a threshold node, and
  • a clock sample of the observed system.

The status records carry their observation times on the boot-time clock of the device, which the receiver cannot interpret on its own. The clock sample connects that clock to the wall clock: it contains the device’s boot ID and boot time together with the device’s wall-clock time at the same moment. Collect the records first and take the clock sample afterwards, so that no record appears to be observed after the sample was taken.

{
  "context": {
    "bootId": "e09a482c-4a41-4f95-891e-042af3d3c4a4",
    "nowMs": 45000
  },
  "timestamp": "2026-10-14T12:00:00Z"
}

With this sample, the receiver can estimate when a check ran. For a status record from the same boot, the observation time is the sample’s timestamp minus the difference between the sample’s nowMs and the record’s observedAtMs. The status record of the database check from the overview, observed at boot time 42000, ran 3 seconds before the sample, at about 2026-10-14T11:59:57Z. The estimate is only as accurate as the device’s wall clock at the time of sampling. For a record from another boot or with an observation time after the sample, no wall-clock time can be estimated.

To determine the device’s health, the receiver evaluates the snapshot with the sample’s context as the current boot and time. The result describes the device’s health at the moment the snapshot was taken, because transport does not renew the validity of records. A tool that needs the current health of the device evaluates the records on the device itself.

Reference

Directory Configurations

record

DirectoryConfig

Additional absolute directory paths supplied by packages or administrators. Whole * path segments match real directories in lexical order on each load. Explicit path segments may follow symlinks; .. and partial wildcards are invalid.

  • componentsoptional

    Additional component declaration directories.

    array<string>
    string
  • healthNodes(from health_nodes)optional

    Additional health definition directories.

    array<string>
    string
  • healthStatuses(from health_statuses)optional

    Additional health status directories.

    array<string>
    string
  • metricsoptional

    Additional metric definition directories.

    array<string>
    string
  • metricSamples(from metric_samples)optional

    Additional metric sample directories.

    array<string>
    string

Health Snapshots

record

HealthSnapshot

Transport view of a health graph and the evidence used to evaluate it.

  • clockrequired

    Clock correlation sampled after collecting the records.

    HealthClockSample
    • contextrequired

      Boot identifier and boot-time milliseconds at sampling.

      HealthContext
      • bootId(from boot_id)required

        Current boot identifier.

        string
      • nowMs(from now_ms)required

        Current boot-time clock value in milliseconds.

        integer (i64)
    • timestamprequired

      Wall-clock timestamp at the same instant, serialized as an RFC 3339 string.

      timestamp
  • nodesrequired

    Health definitions, including their owners.

    array<HealthNode>
    HealthNode
    • idrequired

      Unique health node ID.

      HealthNodeId
      string
    • owneroptional

      Ownership group for replacement or removal, matched exactly.

      string
    • labeloptional

      Human-readable label.

      string
    • componentsoptional

      Related component IDs; these associations do not imply health dependencies.

      array<string>
      string
    • ruleoptional

      How this node's health is determined; omitted means an observed node without constraints.

      HealthRule
      • Observed→ "observed"

        Health is supplied by an external status record.

        { "type": "observed", ...<payload fields> } — or "content" for non-object payloads

        ObservationRule
        • maxAgeMs(from max_age_ms)optional

          Optional consumer limit on status age, in milliseconds.

          integer
        • expectedTag(from expected_tag)optional

          Optional tag that published status records must match exactly.

          string
      • Threshold→ "threshold"

        Health is derived from a fresh metric sample.

        { "type": "threshold", ...<payload fields> } — or "content" for non-object payloads

        ThresholdRule
        • metricrequired

          Metric definition supplying the unit, identity, and freshness constraints.

          MetricId
          string
        • healthyrequired

          Desired range; must be a subset of the usable range.

          MetricRange
          • loweroptional

            Optional lower endpoint.

            MetricBound
            • valuerequired

              Finite endpoint in the referenced metric's unit.

              number
            • inclusiverequired

              Whether equality with this endpoint is inside the range.

              boolean
          • upperoptional

            Optional upper endpoint.

            MetricBound
            • valuerequired

              Finite endpoint in the referenced metric's unit.

              number
            • inclusiverequired

              Whether equality with this endpoint is inside the range.

              boolean
        • usablerequired

          Minimum range for usability.

          MetricRange
          • loweroptional

            Optional lower endpoint.

            MetricBound
            • valuerequired

              Finite endpoint in the referenced metric's unit.

              number
            • inclusiverequired

              Whether equality with this endpoint is inside the range.

              boolean
          • upperoptional

            Optional upper endpoint.

            MetricBound
            • valuerequired

              Finite endpoint in the referenced metric's unit.

              number
            • inclusiverequired

              Whether equality with this endpoint is inside the range.

              boolean
        • maxAgeMs(from max_age_ms)optional

          Optional consumer limit on sample age, in milliseconds; must be positive.

          integer
      • Aggregate→ "aggregate"

        Health is evaluated from other nodes.

        { "type": "aggregate", ...<payload fields> } — or "content" for non-object payloads

        AggregationRule
        • inputsrequired

          Dependencies with distinct node IDs.

          array<AggregationInput>
          AggregationInput
          • noderequired

            Referenced health node ID.

            HealthNodeId
            string
          • requiredoptional

            Whether this dependency must meet minimum and desired criteria; omitted means false.

            boolean
          • optionaloptional

            Whether this dependency only affects desired criteria; omitted means false. Must not be combined with required.

            boolean
        • requiredoptional

          Minimum healthy or degraded count of non-optional inputs, including mandatory inputs; omitted means the healthy count.

          integer
        • healthyoptional

          Desired healthy count of non-optional inputs, including mandatory inputs; omitted means all non-optional inputs. Must satisfy 1 <= required <= healthy <= non-optional inputs.

          integer
  • statusesrequired

    Original status records; observation times and validity are preserved.

    array<HealthStatus>
    HealthStatus
    • idrequired

      Observed node ID.

      HealthNodeId
      string
    • owneroptional

      Ownership group; must match the node's owner when one is specified.

      string
    • staterequired

      Reported health.

      HealthState
      • Healthy→ "healthy"

        Desired health criteria are confirmed.

        Value: "healthy"

      • Degraded→ "degraded"

        Minimum criteria are confirmed; desired criteria are unconfirmed or unmet.

        Value: "degraded"

      • Unhealthy→ "unhealthy"

        Minimum criteria are confirmed to be unmet.

        Value: "unhealthy"

      • Unknown→ "unknown"

        Evidence does not determine whether minimum criteria are met.

        Value: "unknown"

    • bootId(from boot_id)required

      Boot identifier defining the observation clock domain.

      string
    • observedAtMs(from observed_at_ms)required

      Milliseconds on the boot-time clock when health was observed.

      integer (i64)
    • maxAgeMs(from max_age_ms)required

      Finite positive validity duration in milliseconds.

      integer
    • tagoptional

      Opaque label identifying the check configuration or instance.

      string
    • messageoptional

      Explanation supplied by the observer.

      string
  • metricsoptional

    Metric definitions used by threshold nodes or displayed independently.

    array<MetricDefinition>
    MetricDefinition
    • idrequired

      Unique metric ID.

      MetricId
      string
    • owneroptional

      Ownership group for replacement or removal, matched exactly.

      string
    • labeloptional

      Human-readable label.

      string
    • componentsoptional

      Related component IDs; these associations do not imply health dependencies.

      array<string>
      string
    • unitrequired

      Unit shared by samples and all thresholds referencing this metric.

      MetricUnit
      • Celsius→ "celsius"

        Degrees Celsius; consumers may convert for display.

        Value: "celsius"

      • Bytes→ "bytes"

        Bytes; consumers may display decimal or binary prefixes.

        Value: "bytes"

      • Seconds→ "seconds"

        Seconds; consumers may display subsecond units.

        Value: "seconds"

      • Ratio→ "ratio"

        Dimensionless fraction, with 1 corresponding to 100 percent.

        Value: "ratio"

      • Count→ "count"

        Number of items or events.

        Value: "count"

      • BytesPerSecond→ "bytes-per-second"

        Bytes per second.

        Value: "bytes-per-second"

      • Hertz→ "hertz"

        Cycles per second.

        Value: "hertz"

      • Volts→ "volts"

        Electric potential in volts.

        Value: "volts"

      • Amperes→ "amperes"

        Electric current in amperes.

        Value: "amperes"

      • Watts→ "watts"

        Power in watts.

        Value: "watts"

      • RevolutionsPerMinute→ "revolutions-per-minute"

        Revolutions per minute.

        Value: "revolutions-per-minute"

    • maxAgeMs(from max_age_ms)optional

      Optional consumer limit on sample age, in milliseconds; must be positive.

      integer
    • expectedTag(from expected_tag)optional

      Optional tag that samples must match exactly.

      string
  • metricSamples(from metric_samples)optional

    Original metric samples; sample times and validity are preserved.

    array<MetricSample>
    MetricSample
    • idrequired

      Measured metric ID.

      MetricId
      string
    • owneroptional

      Ownership group; must match the definition's owner when specified.

      string
    • valuerequired

      Finite measurement in the definition's unit.

      number
    • bootId(from boot_id)required

      Boot identifier defining the sample clock domain.

      string
    • observedAtMs(from observed_at_ms)required

      Milliseconds on the boot-time clock when the measurement was taken.

      integer (i64)
    • maxAgeMs(from max_age_ms)required

      Positive validity duration in milliseconds.

      integer
    • tagoptional

      Opaque label identifying the measurement configuration or instance.

      string
    • messageoptional

      Explanation supplied by the observer.

      string

Clock sample timestamps use RFC 3339 in UTC, ending in Z, and may include fractional seconds. Estimated observation times have millisecond precision and are only defined for the years 0001 to 9999.