Skip to content
15 changes: 8 additions & 7 deletions docs/flows/github-actions-testing.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
created: 2026-09-04
updated: 2026-11-11
last_updated_session: authoring-run/c0ca6f34-2aa6-47f9-87c1-e5f3708617f6
last_updated_session: authoring-run/59e3fbae-c2ef-496b-ad18-c965758bee04
---

# GitHub Actions testing flow
Expand Down Expand Up @@ -112,17 +112,17 @@ The application lane gives the native IAM barrier test its own migrated PostgreS
`runtime-artifact` supplies CI `image-lanes`, Full Integration's `image-lanes-same-sha`
and Docker Model Runtime, and First Agent Smoke. Aggregates check producer and consumers.

The [run-ci-lane action](../../.github/actions/run-ci-lane/action.yml) prepares, runs, and cleans up lanes and uploads sanitized results. Callers set the commit, environment, credentials, and timeout. Tests stop five minutes early.
[run-ci-lane](../../.github/actions/run-ci-lane/action.yml) prepares and cleans resources, runs tests, and uploads sanitized results. Callers set source, credentials, environment and timeout; tests stop five minutes early.

PR dependency caches stay within GitHub's PR merge-ref scope; main caches stay main-scoped. Results and credential-bearing state are not caches; protected jobs do not promote PR artifacts.
Dependency caches stay scoped to GitHub PR merge-refs or main. Results and credential-bearing state are never cached; protected jobs never promote PR artifacts.

### 2. Prepare resources under the job owner

`scripts/ci/prepare.mjs:main` and `scripts/ci/prepare.mjs:ensureK3dCluster`

[CI resource preparation](github-actions-testing/preparation.md) covers tools, images, clusters, credentials and ownership.
[Preparation](github-actions-testing/preparation.md) covers tools, images, clusters, credentials and ownership.

For `logging-collector`, `scripts/ci/prepare.mjs:prepareLane` pre-pulls configured
`scripts/ci/prepare.mjs:prepareLane` pre-pulls `logging-collector`’s configured
Collector and Node images and the shared Prometheus and Grafana pins.
`ensureDockerSourceImage` reuses verified local digests or verifies downloads from
`scripts/ci/image-pull.ts:pullImage` before publishing inputs. Registry 5xx/rate
Expand All @@ -135,8 +135,7 @@ Cache credentials stay in preparation.

Kubernetes preparation records host snapshots. Failed reads, bounded
by time and size, save `<state-file>.diagnostics.json` outside the cluster directory.
These lanes use `--no-rollback`; workflows own teardown after capture, while
local callers use the failed state file. Observation failures preserve the original error. `nodeLogExcerpt` orders Docker streams
These lanes use `--no-rollback`; workflows own teardown after capture; local callers use failed state. Observation failures preserve the original error. `nodeLogExcerpt` orders Docker streams
and retry summaries by full UTC timestamp precision using locale-independent ASCII comparison ([CI guide](../testing/ci.md)).

`scripts/ci/run-tests.mjs:runFile` watches Compute-managed Pods and namespace
Expand Down Expand Up @@ -282,6 +281,8 @@ awaits an approved resource ledger.

## Changelog

- 2026-11-11 07:55: Retain selected runtime Codex provenance in CI evidence. (authoring-run/59e3fbae-c2ef-496b-ad18-c965758bee04 - 7fa7a37738bb24b27d9a835e409ea20eafb43cee)

- 2026-11-11 03:43: Guard reuse and fresh fallback. (authoring-run/c0ca6f34-2aa6-47f9-87c1-e5f3708617f6 - 993a38b318c249b00f951bf92c8d136214ec82fd)
- 2026-11-11 03:28: Explain qualified CI reuse. (authoring-run/1b85588b-87c6-47d0-8c6e-8b78b0030aea - dfd55e679c9c9869ddc786b85f6f9b27a53fb833)

Expand Down
22 changes: 13 additions & 9 deletions docs/flows/github-actions-testing/preparation.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ First Agent Smoke and `run-ci-lane` use `setup-ci-tools` to restore yq and k3d
downloads outside `PATH`. On Linux, `scripts/ci/setup-tools.sh` selects the
checked-in platform checksum. `scripts/ci/download-pinned.sh` verifies installed
or cached bytes in private staging before atomic publication with mode 0755.
Missing or corrupt entries use the pinned downloader; unavailable cache storage
or service does not fail setup. Verified hits do not rewrite the cache.
Missing or corrupt entries use pinned downloads; cache outages do not fail setup. Hits do not rewrite the cache.
PostgreSQL, image and Kubernetes profiles share OS-, architecture- and
installer-source-keyed caches. Direct callers can reuse verified installed bytes.

Expand All @@ -31,7 +30,7 @@ Version probes allow 10 seconds plus 5 seconds before forced termination;
each APT command allows 120 plus 10 seconds, three acquisition retries and
20-second HTTP/HTTPS timeouts. Sudo is non-interactive. Failed updates prevent
installation. APT output and failure status are preserved.
The final version probe must pass.
The final probe must pass.

`scripts/ci/image-pull.ts:pullImage` logs each failed pull attempt before deciding
whether to retry, including the final attempt. It reports elapsed time, timeout status and up to eight layer states from captured output tails.
Expand All @@ -41,8 +40,7 @@ The First Agent smoke adapter forwards both captured streams to this parser.
Diagnostic emission is best effort and cannot replace the terminal pull error.
Docker suppresses numeric progress on non-terminal
output, so these states provide partial evidence, not the current transfer phase. If no progress matches, the
summary says so. These diagnostics do not change timeouts, backoff, concurrency, or digest verification.
They do not establish registry health or stall causes.
summary says so. Diagnostics change no timeouts, backoff, concurrency or digest verification, and establish neither registry health nor stall causes.

The PR advisory OpenShell job uses Ubuntu 24.04 for Landlock and selects packaged Google Chrome through `OCC_TEST_BROWSER_EXECUTABLE`. The OpenShell manifest lists this optional input so test children receive it. Before image builds, `scripts/ci/setup-tools.sh:install_browser_dependencies` checks a headless sandboxed renderer and logs its version; errors fail setup. The browser inherits only `PATH`, with private `HOME` and `TMPDIR`. Ubuntu’s existing AppArmor profile permits its user namespaces. Without an override, Playwright uses its default headless shell.

Expand All @@ -61,9 +59,9 @@ TUI, `k3d-otel` and OpenShell (`image-cache`; OpenShell: `first-agent-image-cach
alternate sources. Step counts deduplicate IDs; imports count lines.
Imports do not prove hits; loads may reuse probe work.

The four ordinary image lanes, First Agent Smoke and Docker Model Runtime look
up artifacts by repository, producer run ID and artifact ID. The lane action
and CI workflow give `actions/download-artifact` the job token with `actions: read`.
The four ordinary image lanes, First Agent Smoke and Docker Model Runtime
download artifacts by repository, producer run and artifact IDs, using the job
token’s `actions: read` permission.

Docker Model Runtime requires an artifact ID on producer success. Failure or
skip selects a standalone build. After download, local import cancellation
Expand All @@ -79,7 +77,13 @@ First Agent Smoke checks compressed and uncompressed layer digests with
`prepareRuntimeArtifactLayout`. Buildx uses the verified layout's platform
manifest digest to build the trust layer.

The preparation CLI records image resources in private state before tagging or import. GitHub Actions keeps it under `RUNNER_TEMP` for later steps, never artifact upload. Database tests use the limited application role with a fresh migrated database per file; each Agent revision worker test receives a migrated template copy (`prepareFile({ template })`). Failure and Kubernetes database names satisfy the existing test admission guards. An ordinary cluster lane selects an explicit loopback k3d context and a digest-pinned Kubernetes 1.35 K3s image. After node readiness, preparation rejects server versions outside Kubernetes 1.35. OpenShell retains its separately pinned K3s image. External images are pulled by their approved registry digest and exported for the selected platform; built and external images receive a run-owned reference at the imported platform manifest digest. Fresh preparation records sources and pins imported references against kubelet image garbage collection for the cluster's lifetime. The imported target must be an OCI or Docker image manifest. Every node must report its expected containerd digest and an exact CRI digest-list entry with boolean `pinned: true`. This retention excludes standalone manual or operator imports. The retired CLI-only installed repository lane is absent from the manifest: `assertLane` rejects it before state or resources are created. Its image and seccomp preparation below is unreachable. When either production TUI upgrade candidate is selected, preparation requires both candidate and baseline controller/runtime digests before allocating resources. It imports the four supplied sources, rejects a candidate resolving to the same local image as its baseline, and records their source and imported identities in private state. Per-file preparation checks the same selection against that state and passes the imported references to the test. Without candidate images, the lane builds the current source as before. Preparation failures still enter job cleanup. Cluster cleanup reads k3d inventory before and after deletion, then checks for matching Docker containers, networks, and volumes. An invalid inventory or possible surviving resource retains cleanup state.
Before tagging or import, the CLI records image resources in private `RUNNER_TEMP` state for later steps, never artifact upload. Database tests use the limited application role with a fresh migrated database per file; each Agent revision worker test receives a migrated template copy (`prepareFile({ template })`). Failure and Kubernetes database names satisfy the existing test admission guards. Ordinary lanes select explicit loopback k3d contexts and digest-pinned Kubernetes 1.35 K3s images. Readiness rejects server versions outside Kubernetes 1.35. OpenShell retains its separately pinned K3s image. External images are pulled by their approved registry digest and exported for the selected platform; built and external images receive a run-owned reference at the imported platform manifest digest. Preparation records sources and pins cluster references against kubelet image garbage collection. Import requires OCI or Docker manifests. Every node must report its expected containerd digest and an exact CRI digest-list entry with boolean `pinned: true`. This retention excludes standalone manual or operator imports. The retired CLI-only installed repository lane is absent from the manifest: `assertLane` rejects it before state or resources are created. Its image and seccomp preparation below is unreachable. When either production TUI upgrade candidate is selected, preparation requires both candidate and baseline controller/runtime digests before allocating resources. It imports the four supplied sources, rejects a candidate resolving to the same local image as its baseline, and records their source and imported identities in private state. Per-file preparation checks the same selection against that state and passes the imported references to the test. Without candidate images, the lane builds the current source as before. Failures still require cleanup. Cleanup checks k3d inventory before and after deletion and matching Docker containers, networks and volumes; invalid inventory or possible survivors retain state.

`scripts/ci/prepare.mjs:retainRuntimeProvenance` compares platform-selected host
and CRI config digests. `scripts/ci/runtime-provenance.mjs:readImageCodexProvenance`
reads bounded metadata; results and diagnostics retain only their preparation's evidence.
Missing metadata records `unavailable`; image policy is unchanged.
Extraction journals IDs before removal. Cleanup removes containers and anonymous volumes. Journal and cleanup errors fail preparation; unresolved resources retain receipts.

Before creating the bootstrap directory beside the state file,
`scripts/ci/prepare.mjs:ensurePostgresServer` records its absolute path. It refuses
Expand Down
17 changes: 17 additions & 0 deletions docs/testing/ci/run-lanes.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,23 @@ follow [native image checks](../../release/containers.md#check-native-images-wit

A lane fails if required cases are missing, skipped, marked TODO, or failed, or if cleanup fails. This includes skipped suites and Go tests. Results prove only selected coverage: inspect outcomes, source, cleanup and image digests. Retries have attempt-specific artifacts and replace the current result. Kubernetes preparation failures retain sanitized diagnostics when collection succeeds. Missing state or empty inventory does not prove cleanup.

Shared k3d runtime preparation adds `runtimeProvenance` to lane results and
Kubernetes diagnostics for the selected Gateway and Agent images. Each record
lists the observed local image ID and imported platform manifest digest.
An `available` record confirms their config digests match and includes the image-reported Codex version, binary SHA-256,
platform and upstream `openclawCommit`; `unavailable` means the metadata or
image binding could not be verified. This is diagnostic evidence, not release
qualification or an additional readiness check. The result's `sourceSha` names
the tested checkout, not an image build revision. Source builds may still have
no OCE build revision, and the upstream OpenClaw commit is a separate identity.
No image configuration, credentials or arbitrary provenance fields are uploaded.
Collection bounds the archive before accepting a single regular metadata file;
directories, oversized files and unsupported archive records remain unavailable.
Provenance reads and diagnostic merges require the same lane and preparation.
The public preparation identity hashes the private resource prefix; stateless
runs receive a fresh invocation identity. Validated current-run evidence
survives state cleanup.

For a failed matrix job, inspect each lane's result artifact to find the failing
lane. The aggregate reports the parent failure once and requires every selected
lane's same-source evidence, even when other lanes passed. If the artifact is
Expand Down
34 changes: 33 additions & 1 deletion scripts/ci/cleanup.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { removeImageFileContainer } from "../lib/image-file.mjs";
import { cleanupLogging, ciOtelBackendResourceKind } from "./logging.ts";
import { cleanupKeycloak, keycloakResourceKind } from "./keycloak.mjs";
import { laneImagesResourceKind, restoreLaneImages } from "./lane-images.ts";
Expand Down Expand Up @@ -711,6 +712,33 @@ async function cleanupFirstAgentImages(resource: CleanupResource, state: Cleanup

async function cleanupResource(resource: CleanupResource, state: CleanupState, statePath: string) {
switch (resource.kind) {
case "image-file":
if (resource.owner !== state.prefix) {
throw new Error("Refusing to clean an image extraction container owned by another prefix.");
}
if (
typeof resource.name !== "string" ||
!resource.name.startsWith(`${state.prefix}-provenance-`) ||
!/^openclaw-ci-[a-z0-9-]+-provenance-[a-f0-9]{12}$/.test(resource.name)
) {
throw new Error("Refusing to remove an unowned image extraction container.");
}
await removeImageFileContainer({
resource,
persist: () => writeState(statePath, state),
command: async (_docker: string, args: string[], options: { timeout?: number } = {}) => {
try {
return (
await execFile(process.env.OCC_DOCKER_BIN ?? "docker", args, {
timeoutMs: options.timeout ?? 30_000,
})
).stdout;
} catch {
throw new Error("Runtime provenance image cleanup command failed.");
}
},
});
break;
case "first-agent-image-registry":
await cleanupFirstAgentImages(resource, state);
break;
Expand Down Expand Up @@ -861,7 +889,11 @@ async function cleanupLockedResourceIds(
);
await writeState(path, state);
} catch (error) {
failures.push(`${resource.kind}:${resource.name ?? resource.id}:${errorMessage(error)}`);
failures.push(
resource.kind === "image-file"
? "image-file:Runtime provenance cleanup failed; private resource receipt retained."
: `${resource.kind}:${resource.name ?? resource.id}:${errorMessage(error)}`,
);
}
}

Expand Down
21 changes: 18 additions & 3 deletions scripts/ci/k3d-diagnostics.mjs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { preparationIdentity, readRuntimeProvenance } from "./runtime-provenance.mjs";
import { spawn } from "node:child_process";
import { randomUUID } from "node:crypto";
import { once } from "node:events";
Expand Down Expand Up @@ -377,6 +378,11 @@ export async function captureK3dDiagnostics({
const k3dCreateOutput = k3dOutputExcerpt(k3dOutput);
const report = {
capturedAt: new Date().toISOString(),
preparationId: preparationIdentity(cluster.owner),
runtimeProvenance: await readRuntimeProvenance(statePath, {
lane,
preparationId: preparationIdentity(cluster.owner),
}),
lane,
cluster: cluster.name,
...(failure ? { failure } : {}),
Expand Down Expand Up @@ -696,10 +702,13 @@ async function stopWatch(child) {
* projection to the report's `containerLogs`. Pass the child's environment as
* `finish({ env })` so its prepared secrets are redacted too.
*/
export async function startAgentNamespaceCapture({ statePath, lane, file }) {
export async function startAgentNamespaceCapture({ statePath, lane, file, preparationId }) {
let clusters;
try {
const state = JSON.parse(await readFile(statePath, "utf8"));
if (state.lane !== lane || preparationIdentity(state.prefix) !== preparationId) {
return undefined;
}
clusters = (state.resources ?? []).filter(
(resource) =>
resource.kind === "k3d-cluster" &&
Expand Down Expand Up @@ -804,12 +813,18 @@ export async function startAgentNamespaceCapture({ statePath, lane, file }) {
return;
}
const diagnosticsPath = `${statePath}.diagnostics.json`;
let report = { lane };
let report = { lane, preparationId };
try {
report = JSON.parse(await readFile(diagnosticsPath, "utf8"));
const previous = JSON.parse(await readFile(diagnosticsPath, "utf8"));
if (previous.lane === lane && previous.preparationId === preparationId) {
report = previous;
}
} catch {
// The first passing file starts the report.
}
report.runtimeProvenance =
(await readRuntimeProvenance(statePath, { lane, preparationId })) ??
report.runtimeProvenance;
if (captured.length > 0) {
report.agentNamespaces = [...(report.agentNamespaces ?? []), ...captured].slice(
-MAX_ACTIVITY_FILES,
Expand Down
Loading
Loading