# How shld works
Source: https://shld.app/docs/how-it-works · Updated 2026-11-30 · Synced from shld f6c77924

> Follow a server observation through inventory, advisory matching, local evidence, alert delivery, and the administrator's own AI assistant.


This page explains how shld turns installed software and host activity into reviewable incidents. It also separates the deterministic host agent from the administrator's AI assistant.

## The agent on the host

shld runs as one static Go binary. The supplied systemd service executes `shld run` every time the host starts the unit. Its collection interval is 5 seconds, and its state lives at `/var/lib/private/shld` by default.

The agent contains no LLM. Local code reads metadata, evaluates rules, and decides each action. The agent does not invoke Claude Code or another assistant.

1. The collector reads package inventories, file metadata, `/proc`, and enabled SSH log sources.
2. The advisory evaluator compares installed versions with verified bundle records.
3. Activity rules turn observations into findings.
4. The agent appends events and findings to a local hash-chained tape.
5. The running agent exports finding summaries and heartbeats to the configured platform.

A one-shot `shld scan` performs collection and keeps notification records local. `shld run` starts configured notification export and the local API before its first collection cycle, then repeats collection until termination.

## Inventory and matching

The inventory covers dpkg, apk, selected language package files and binaries, and WordPress components. The watched folder (`--root`, chosen at install) controls the filesystem scope. Process and SSH log visibility follow separate host interfaces and permissions, so the root does not confine those signals.

The agent selects advisory bundles for the ecosystems and distro release it finds. `Record.Judge` compares each installed version with a record's affected ranges or distro statement. A result can be affected, unaffected, or unknown. Unknown does not count as clean.

`Record.Action` in `internal/advisory/policy.go` then applies the alert policy. With a fix available, email requires CISA KEV, EPSS of at least 0.1 (a 10% exploit likelihood), or critical severity. A KEV record without a fix also emails. An affected malicious package record emails, and an unconfirmed record downgrades an email action to the dashboard. The company's email level then filters those emails a second time; the default holds medium and low advisories for a weekly summary. The full table appears in [How shld decides to email](/docs/alerts).

## The local tape

The tape retains event and finding metadata in sequence. Each record points to the previous record's hash, which lets shld detect changed history when it opens or verifies the state. Its in-memory index holds at most 1,024 sparse checkpoints, and replay and scans stream verified records from disk. The tape file has no total size cap or pruning. The tape is evidence for investigation, with local paths, process details, and package context that a hosted summary can omit.

Keep state outside the watched folder and preserve the original directory after an integrity error. Use the physical service path when you verify an installed service:

```sh
sudo shld verify --state /var/lib/private/shld
```

For a check beside a running writer, use `sudo shld doctor`. Its tape check reads complete records without taking the writer lock.

## The platform

The shld platform is a Cloudflare Worker with D1 storage. The agent sends bounded summaries and heartbeat counters to the agent origin. The Worker stores host and incident state, delivers email through its email binding, and serves the dashboard behind shld's own email-code sign-in. Every company uses the same dashboard at `https://app.shld.app` and the same agent address `https://api.shld.app`. The Worker resolves the company from the signed-in email or the server token on every request, and each company sees only its own servers, incidents and alert recipients. A client that needs its own instance gets a dedicated Worker and database.

The Worker also checks the public feed manifest and CISA KEV metadata. It asks the feed workflow to rebuild when the manifest cannot be read, the feed is at least 5 hours 50 minutes old, or KEV has changed. Feed publication uses an Ed25519 key that is separate from the RSA release-signing key.

## Email and the administrator's assistant

An advisory email identifies the host, issue, severity, package, installed version, and incident. When the advisory supplies them, it also includes the fixed version, update command, verify command, affected packages, and restart hint.

The dashboard incident offers a deterministic fix prompt. The prompt marks embedded evidence as untrusted data, preserves the producer-supplied commands for review, and tells the receiving assistant to request approval before running a command. The administrator supplies host access and authorizes each change. Copying the prompt starts no command and records no acknowledgment.

The platform has a separate optional Workers AI drafting feature. It runs only when an operator enables it and confirms billing. That platform feature does not put AI in the host agent.

## Limits

A poll observes only what remains visible at that instant. Inventory caps, unreadable paths, unsupported layouts, and stale or unverified advisory data reduce coverage. A finding supplies evidence to assess, and a quiet report leaves unknowns unknown.

## Related

- [Advisory feed and signing](/docs/advisory-feed)
- [Activity findings](/docs/activity-findings)
- [The dashboard](/docs/dashboard)
- [Limits and coverage](/limits)
