Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -221,9 +221,9 @@ containers have no mount for that export.
- Fleet updates use rolling replacement and an explicit rollback version.
- Controller routing, capacity, lifecycle, and engine updates use reviewed full commits from private desired-state configuration; hosts never follow an unreviewed moving branch.

## Planned endpoint observation
## Endpoint observation

The [endpoint observation UI design](ENDPOINT-UI-DESIGN.md) defines a future optional host service on loopback port 80, authenticated through an independently provisioned HTTPS gateway. Its [acceptance record](ENDPOINT-UI-DESIGN.md#acceptance-record) distinguishes the proposal from a reviewed decision. It keeps observation independent of Docker and preserves role, credential, configuration, and outbound-reporting boundaries. No endpoint UI or inbound listener is implemented by that design.
The [endpoint observation UI design](ENDPOINT-UI-DESIGN.md) defines an optional host service on loopback port 80, authenticated through an independently provisioned HTTPS gateway. The [read-only worker views](WORKER-VIEWS.md) read protected exports independently of Docker. Host installation, listener activation, and gateway integration are tracked in #122.

## Project adoption

Expand Down
2 changes: 1 addition & 1 deletion docs/DESIGN-DECISIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ Stop the proxy and unmount the volume to remove the route. The disposable
Docker proof covers the repository contract. Staging cutover requires separate
acceptance on the intended dedicated rootless deployer. [Issue #194](https://github.com/RandomDevelopment/ci-fleet/issues/194)

The [endpoint observation UI ADR](ENDPOINT-UI-DESIGN.md) has an explicit [acceptance record](ENDPOINT-UI-DESIGN.md#acceptance-record) under [issue #117](https://github.com/RandomDevelopment/ci-fleet/issues/117). It is proposed while PR #126 is open and accepted after that reviewed PR merges into `main`. It records port-80 access, local data contracts, retention, outage behavior, and a conditional management-access exception to the outbound-only worker model. Implementation remains planned; it adds no runtime, schema field, or host activation and preserves the decisions below.
The [endpoint observation UI ADR](ENDPOINT-UI-DESIGN.md) was accepted when PR #126 merged. It records port-80 access, local data contracts, retention, outage behavior, and a conditional management-access exception to the outbound-only worker model. The [worker views](WORKER-VIEWS.md) consume the protected exports. The schema and host activation are tracked in #122.

## Managed controller desired state after the isolated proof

Expand Down
8 changes: 5 additions & 3 deletions docs/ENDPOINT-SNAPSHOTS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Worker snapshots

This is the read-only worker snapshot contract for [#118](https://github.com/RandomDevelopment/ci-fleet/issues/118) under the accepted [endpoint UI design](ENDPOINT-UI-DESIGN.md). The repository provides one privileged publication command and an authenticated file reader. Browser delivery remains in #121. Packaging, service activation, and live-host acceptance remain in #122. Bootstrap still uses its temporary authenticated callback. Reconciliation captures the desired engine only after existing validation and the opt-in independent configuration-approval check.
This is the read-only worker snapshot contract for [#118](https://github.com/RandomDevelopment/ci-fleet/issues/118) under the accepted [endpoint UI design](ENDPOINT-UI-DESIGN.md). The repository provides one privileged publication command and an authenticated file reader used by the [worker views](WORKER-VIEWS.md). Packaging, service activation, and live-host acceptance remain in #122. Bootstrap still uses its temporary authenticated callback. Reconciliation captures the desired engine only after existing validation and the opt-in independent configuration-approval check.

## Producer and consumer interfaces

Expand All @@ -16,7 +16,7 @@ sudo python3 scripts/endpoint_snapshot.py \

This is a foundation interface, not an enrollment or installation procedure. Preparation, approved credentials, role admission, and service activation belong to #122. The command does not create directories, groups, units, credentials, or network rules. It prints only a controlled success/failure code and returns nonzero when publication fails. A future caller must isolate that failure from CI and reconciliation.

`SnapshotReader` accepts a fixed export base, observer GID, expected controller identity, and an already provisioned backend bearer. Its `read(headers)` method authenticates before any filesystem access and ignores forwarded identity headers. The caller must supply the bearer through the separately approved credential mechanism; it must never derive configuration from browser input or reuse controller credentials. This PR adds no credential loader or HTTP listener. The transport must enforce the ADR's request and response limits and `Cache-Control: no-store`.
`SnapshotReader` accepts a fixed export base, observer GID, expected controller identity, and an already provisioned backend bearer. Its `read(headers)` method authenticates before any filesystem access and ignores forwarded identity headers. The caller must supply the bearer through the separately approved credential mechanism. The worker HTTP application accepts a prepared loopback listener and applies the ADR's request and response limits and `Cache-Control: no-store`.

## Snapshot version 1

Expand Down Expand Up @@ -133,7 +133,9 @@ results and original observation times. The aggregate activity flag also
accounts for retained coverage gaps and loss of nonterminal records. A
directly observed running job can remain current while aggregate coverage is
unknown. Missing summary evidence defaults
to unknown activity. The API accepts only the fixed job file.
to unknown activity. The authenticated read also returns the validated
publication fingerprint for pagination and the endpoint evidence used to
assess current activity. The API accepts only the fixed job file.

## Verification

Expand Down
4 changes: 1 addition & 3 deletions docs/ENDPOINT-UI-DESIGN.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# Endpoint observation UI

Implementation status: planned. This ADR addresses [issue #117](https://github.com/RandomDevelopment/ci-fleet/issues/117). It adds no supported command, schema field, service, listener, or engine capability.

The [worker snapshot contract](ENDPOINT-SNAPSHOTS.md) records the current #118 interfaces and which producers can supply each observation. The UI and its host activation remain planned.
This ADR records the accepted design for [issue #117](https://github.com/RandomDevelopment/ci-fleet/issues/117). The [worker snapshot contract](ENDPOINT-SNAPSHOTS.md) records the producers and their evidence. The [worker views](WORKER-VIEWS.md) provide a repository HTTP application. Host activation and gateway integration remain in #122.

## Acceptance record

Expand Down
2 changes: 1 addition & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Operators can start with the task below. Agents use the [task-routing checklist]
| Configure automatic updates and cleanup | [Host maintenance](HOST-MAINTENANCE.md) and [reproducible managed images](MANAGED-IMAGES.md) |
| Install or operate a dedicated deployment host | [Deployer host installation](DEPLOYER-HOST.md) |
| Monitor hosts and detect missed reports | [Fleet health monitoring](HEALTH-MONITORING.md), [local capacity telemetry](CAPACITY-TELEMETRY.md), and [authenticated status reporting](STATUS-REPORTING.md) |
| Review the planned endpoint web UI and its access/data contracts | [Endpoint observation UI design](ENDPOINT-UI-DESIGN.md), design only; no supported UI yet |
| Inspect the worker UI and its evidence and access boundaries | [Read-only worker views](WORKER-VIEWS.md), [endpoint observation design](ENDPOINT-UI-DESIGN.md) |
| Handle GitHub App, workflow, or deployment secrets | [Secrets model](SECRETS.md) and [security policy](../SECURITY.md) |
| Review accepted implementation scope | [Design decisions](DESIGN-DECISIONS.md) |
| Run private CI or deployment for a public project | [Public projects, private delivery, and private configuration](PUBLIC-PRIVATE-CONFIGURATION.md) |
Expand Down
2 changes: 1 addition & 1 deletion docs/SECRETS.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ For a distributed fleet, use a secret manager or encrypted configuration system

### Planned endpoint observer access

The [endpoint observation design](ENDPOINT-UI-DESIGN.md#access-on-port-80) introduces a separate backend read bearer only when its packaging and access gates are implemented and separately authorized. No observer credential or listener is supported by this design change alone.
The [worker HTTP application](WORKER-VIEWS.md#repository-interface) checks the separate backend read bearer described in the [endpoint observation design](ENDPOINT-UI-DESIGN.md#access-on-port-80). Credential provisioning, gateway integration, and listener activation remain in #122.

Provision 32 random bytes as 43 unpadded base64url ASCII characters without a trailing newline, in root-owned mode-`0600` files outside Git. The privileged installer reads the protected access references in `/etc/ci-fleet/observer/access.json`. Systemd `LoadCredential` supplies the observer's copy through its isolated credential directory; the observer does not read the private `/etc/ci-fleet` tree. Provision the gateway copy independently through its approved secret mechanism.

Expand Down
91 changes: 91 additions & 0 deletions docs/WORKER-VIEWS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# Read-only worker views

The ordinary-CI worker UI reads the protected `endpoint.json` and `jobs.json`
exports described in the [worker snapshot contract](ENDPOINT-SNAPSHOTS.md).
The [endpoint UI design](ENDPOINT-UI-DESIGN.md) defines the access and
isolation boundary. Packaging, gateway integration, and live acceptance
are tracked in [#122](https://github.com/RandomDevelopment/ci-fleet/issues/122).

## What the views show

- **Overview.** Applied lifecycle and policy, busy and current runners,
configured and reviewed limits, reported problems, and observation times.
The effective configuration can record an intentional drain or disablement.
Snapshot v1 has no live admission decision or gate reason for maintenance,
disk, network reserve, authentication, or inspection. Check results and
spare runner slots cannot establish readiness.
- **Jobs.** Filter retained observations by repository, recorded state, and
result. Running activity depends on fresh publisher and listener evidence
for the matching export. Pending publisher gaps have their own evidence
time. Exported gaps and omitted records remain visible. Clock uncertainty
leaves terminal results available with their original evidence. Elapsed
time identifies the local start and whether the finish came from the source
or a local completion observation. GitHub run links use the validated owner,
repository, and workflow run ID.
- **Health.** The five-minute health report supplies check outcomes, including
subnet headroom, OOM evidence, controller restarts, and timer checks. It does
not supply numeric values for those checks. Anonymous seven-day capacity
percentiles cover the exported CPU, memory, swap, disk, and inode metrics.
The latest included sample has its own timestamp. Capacity samples run
every 30 seconds while runners are active and pause at idle.
- **Configuration.** Compare desired and applied commits and engine revisions,
manager and runtime selections, the running controller, resource limits,
and routing. The desired-engine observation records validation of the
approved configuration. Individual review records are unavailable.
Local image binding verification has its own time and revision.
- **Enrollment.** Installation, credential presence, successful
authentication, scale-set match, listener polling, signed reporting, and
owner confirmation each have separate evidence. A GitHub App owner must
confirm visibility. The export has no durable confirmation of that step.

During a controller or Docker outage an available observer can still serve
the views. A retained value shows its original time and last-success status.
An unavailable or invalid export leaves the relevant view navigable with
unknown observations. A missing metric does not show as zero or passed.

## Repository interface

`scripts/endpoint_ui.py` takes a validated `SnapshotReader` through
`WorkerObserver(reader)`. `ObserverServer(listener, observer)` owns an
already listening IPv4 loopback socket. The caller owns provisioning and
activation under #122. The observer reads only the existing export reader
and its bundled static assets. It does not use Docker, host probes, or
private job history.

The authenticated routes support `GET` and `HEAD`.

| Route | Response |
| --- | --- |
| `/`, `/jobs`, `/health`, `/configuration`, `/enrollment` | Worker HTML views |
| `/worker.css`, `/worker.js` | Bundled styles and polling script |
| `/api/v1/endpoint` | Snapshot v1 with derived freshness |
| `/api/v1/capacity` | Capacity evidence from the same snapshot |
| `/api/v1/jobs` | Retained job history, its liveness and coverage, and up to 50 matching records |

Read APIs include `read_schema_version: 1`. Job routes accept
`repository` as a case-insensitive substring of the owner and repository,
`state` as the recorded state, `result` as the recorded result, and
`cursor` from the prior page. A cursor expires when its validated export
changes, its anchor falls out of retention, or the observer restarts. A
`409` prompts the client to reload the first page. Missing or invalid
exports return `503` from the affected API.

Every request requires the backend bearer. The server caps connections at
16 and authenticated handlers at four. It allows one request per
connection, caps headers at 16 KiB with a five-second receive deadline,
and caps responses at 1 MiB with a 30-second write deadline. Responses have
no cross-origin access and use `Cache-Control: no-store`. The browser
refreshes an active view every 15 seconds, backs off to at most two minutes
when data or transport is unavailable, and pauses while hidden. The page
explains when focus pauses refresh. It resumes when focus leaves, subject
to a five-second minimum between requests and the failure backoff. Browser
polling uses the published files at their existing producer cadences.

## Verification

Run `python3 scripts/test_endpoint_ui.py` for protected temporary export
and HTTP integration tests. The `endpoint-ui` group in
[local validation](LOCAL-VALIDATION.md) records test durations and output.
Gateway authentication, service activation, loopback port conflicts,
installation lifecycle, and outage tests on an approved worker remain part
of #122.
19 changes: 13 additions & 6 deletions scripts/endpoint_snapshot.py
Original file line number Diff line number Diff line change
Expand Up @@ -807,7 +807,7 @@ def __init__(self, base: Path, *, observer_gid: int, controller: str, backend_be
self.base, self.observer_gid, self.controller, self._bearer = base, observer_gid, controller, backend_bearer
self._job_cache = None

def _authenticate(self, headers: Mapping[str, str]) -> None:
def authenticate(self, headers: Mapping[str, str]) -> None:
if not isinstance(headers, Mapping):
raise SnapshotError("authentication_failed")
authorization = [value for key, value in headers.items() if isinstance(key, str) and key.lower() == "authorization"]
Expand All @@ -816,7 +816,7 @@ def _authenticate(self, headers: Mapping[str, str]) -> None:
raise SnapshotError("authentication_failed")

def read(self, headers: Mapping[str, str], *, now: int | None = None) -> dict:
self._authenticate(headers)
self.authenticate(headers)
value = read_endpoint(self.base, self.observer_gid)
validate_snapshot(value, controller=self.controller)
for name in SOURCE_NAMES - value["sources"].keys():
Expand All @@ -840,7 +840,7 @@ def read(self, headers: Mapping[str, str], *, now: int | None = None) -> dict:
return value

def read_job_history(self, headers: Mapping[str, str], *, now: int | None = None) -> dict:
self._authenticate(headers)
self.authenticate(headers)
now = int(time.time()) if now is None else now
if not integer(now):
raise SnapshotError("invalid_argument")
Expand All @@ -853,20 +853,27 @@ def read_job_history(self, headers: Mapping[str, str], *, now: int | None = None
self._job_cache = None
raise
self._job_cache = (identity, history)
export_fingerprint = fingerprint(identity)
activity_evidence = None
try:
endpoint = self.read(headers, now=now)
source = endpoint["sources"]["jobs"]
data = source["data"]
current = (endpoint["publisher_freshness"] == source["freshness"] == "current"
and data["generation"] == history["generation"] and data["scale_set"] == history["scale_set"]
and data["export_fingerprint"] == fingerprint(identity)
matches = (data.get("generation") == history["generation"] and data.get("scale_set") == history["scale_set"]
and data.get("export_fingerprint") == export_fingerprint)
activity_evidence = {"published_at": endpoint["published_at"], "clock_state": endpoint["clock_state"],
"publisher_freshness": endpoint["publisher_freshness"],
"source": source, "generation_matches": matches}
current = (endpoint["publisher_freshness"] == source["freshness"] == "current" and matches
and history["published_at"] <= now
and not data["pending"] and data["source_available"]
and 0 <= now - data["last_poll_at"] <= 120 and history["omitted_nonterminal"] == 0)
except (KeyError, StoreError, SnapshotError):
current = False
rows = [{**row, "current_activity": "unknown" if row["state"] == "running" and not current else row["state"]}
for row in history["records"] if row["last_observed_at"] > now - JOB_MAX_AGE]
return {**history, "gaps": dict(history["gaps"]), "records": rows,
"export_fingerprint": export_fingerprint, "activity_evidence": activity_evidence,
"current_activity_verified": current and not (CURRENT_COVERAGE_GAPS & history["gaps"].keys())}


Expand Down
Loading