Skip to content

abso-core

Public

abso is version control for agents: the client, the engine and a server you can run on your own Cloudflare account.

Check passed
MCP
show on this site's /mcp
CLI
abso show 210 --json
JSON
/christopher/abso-core/versions/210?format=json

Pipelines: a run job may set timeout, the seconds each of its steps may take (1 to 900, 300 when unset). JOB_TIMEOUT_DEFAULT and JOB_TIMEOUT_MAX are exported, and the job carries timeout when it is set. A timeout on a uses job, or one that isn't whole seconds in range, is refused with the reason. Tests: src/pipeline/test/pipeline.test.ts (25).

of shared·onboard··Not checked

Version 209 · Files at version 210

2 files, 69 lines added, 5 removed.

--- a/src/pipeline/pipeline.ts
+++ b/src/pipeline/pipeline.ts
@@ -9,7 +9,8 @@
99// jobs make a version green (`required`). A job runs a command (`run`) or a
1010// built-in step (`uses`), after the jobs it `needs`, and may take another
1111// job's kept files (`from`) and named `secrets`, and a run job may ask for an
12−// abso key on its own project (`abso: reader` or `writer`) for the length of the job.
12+// abso key on its own project (`abso: reader` or `writer`) for the length of the job. A run job may
13+// say how long each of its steps may take (`timeout`, in seconds: 300 unless it says, 900 at most).
1314//
1415// What the check refuses: a cycle in needs; needs, required or from naming a
1516// job that doesn't exist; secrets in a pipeline a draft can start, since a
@@ -42,6 +43,8 @@
4243 readonly secrets: readonly string[];
4344 /** An abso key on the project for the job's length (abso 343): none unless asked. */
4445 readonly abso?: "reader" | "writer";
46+ /** Seconds each step of a run job may take, when it says (JOB_TIMEOUT_DEFAULT otherwise). */
47+ readonly timeout?: number;
4548 /** The built-in step's own settings (deploy's worker, staging, live; notify's to), as written. */
4649 readonly with: Readonly<Record<string, unknown>>;
4750}
@@ -98,7 +101,21 @@
98101}
99102const SIZES: readonly Size[] = ["small", "standard", "large"];
100103const MACHINE_KEYS = ["image", "dockerfile", "size"] as const;
101−const JOB_KEYS = ["needs", "run", "uses", "from", "keep", "cache", "secrets", "abso", ...MACHINE_KEYS] as const;
104+const JOB_KEYS = [
105+ "needs",
106+ "run",
107+ "uses",
108+ "from",
109+ "keep",
110+ "cache",
111+ "secrets",
112+ "abso",
113+ "timeout",
114+ ...MACHINE_KEYS,
115+] as const;
116+/** A run job's step limit when it names none, and the most it may name (the customer runner's cap too). */
117+export const JOB_TIMEOUT_DEFAULT = 300;
118+export const JOB_TIMEOUT_MAX = 900;
102119const PIPELINE_KEYS = ["on", "only", "jobs", "required"] as const;
103120/** avcs.json's keys for today's CI (worker/src/ci.ts) and the merge queue: read elsewhere, left alone here. */
104121const AVCS_JSON_KEYS = ["setup", "check", "build", "out", "queue", "whole"] as const;
@@ -299,6 +316,21 @@
299316 else if (j.uses !== undefined)
300317 say(`${at}.abso`, "gives a run job a key; a uses step runs on the server and has none");
301318 }
319+ const timeout = j.timeout;
320+ const timed =
321+ timeout !== undefined &&
322+ typeof timeout === "number" &&
323+ Number.isInteger(timeout) &&
324+ timeout >= 1 &&
325+ timeout <= JOB_TIMEOUT_MAX &&
326+ j.uses === undefined;
327+ if (timeout !== undefined && !timed)
328+ say(
329+ `${at}.timeout`,
330+ j.uses !== undefined
331+ ? "gives a run job's steps more time; a uses step runs on the server and has none"
332+ : `must be whole seconds from 1 to ${JOB_TIMEOUT_MAX}, not ${q(timeout)}`,
333+ );
302334 const withs: Record<string, unknown> = {};
303335 for (const k of settings) if (j[k] !== undefined) withs[k] = j[k];
304336 if (uses === "deploy" && typeof j.worker !== "string")
@@ -327,6 +359,7 @@
327359 cache: list(j.cache, `${at}.cache`, say, "a list of files"),
328360 secrets,
329361 ...((j.abso === "reader" || j.abso === "writer") && j.uses === undefined ? { abso: j.abso } : {}),
362+ ...(timed ? { timeout: timeout as number } : {}),
330363 with: withs,
331364 ...machine(j, at, say, false),
332365 };
--- a/src/pipeline/test/pipeline.test.ts
+++ b/src/pipeline/test/pipeline.test.ts
@@ -5,7 +5,14 @@
55import assert from "node:assert/strict";
66import { describe, it } from "node:test";
77import { parse } from "yaml";
8−import { type Checked, checkPipelines, type Problem, readPipelineFile } from "../pipeline.ts";
8+import {
9+ type Checked,
10+ checkPipelines,
11+ JOB_TIMEOUT_DEFAULT,
12+ JOB_TIMEOUT_MAX,
13+ type Problem,
14+ readPipelineFile,
15+} from "../pipeline.ts";
1017/** The draft pipeline file, comments included. */
1118const DRAFT = `defaults: { image: node, size: standard } # image: a menu or \`dockerfile: path\`
@@ -300,14 +307,14 @@
300307 const ps = problems(
301308 checkPipelines({
302309 defaults: { image: "node", colour: "blue" },
303− pipelines: { p: { on: ["push"], when: "always", jobs: { a: { run: "x", timeout: 5, worker: "w" } } } },
310+ pipelines: { p: { on: ["push"], when: "always", jobs: { a: { run: "x", retries: 5, worker: "w" } } } },
304311 extra: 1,
305312 }),
306313 );
307314 has(ps, "extra", /isn't a key here/);
308315 has(ps, "defaults.colour", /isn't a key here/);
309316 has(ps, "pipelines.p.when", /isn't a key here \(known: on, only, jobs, required\)/);
310− has(ps, "pipelines.p.jobs.a.timeout", /isn't a key here/);
317+ has(ps, "pipelines.p.jobs.a.retries", /isn't a key here/);
311318 // worker is deploy's own setting, not a run job's.
312319 has(ps, "pipelines.p.jobs.a.worker", /isn't a key here/);
313320 });
@@ -415,3 +422,27 @@
415422 has(ps, "out", /must be a folder under the project/);
416423 });
417424});
426+describe("a run job's step limit", () => {
427+ it("takes whole seconds up to the most a step may run, and keeps them on the job", () => {
428+ const file = ok(checkPipelines(one({ test: { run: "npm test", timeout: 600 }, lint: { run: "npx biome ci ." } })));
429+ const jobs = file.pipelines[0]!.jobs;
430+ assert.equal(jobs.find((j) => j.name === "test")?.timeout, 600);
431+ assert.equal(jobs.find((j) => j.name === "lint")?.timeout, undefined, "no timeout: the default, unsaid");
432+ ok(checkPipelines(one({ a: { run: "x", timeout: JOB_TIMEOUT_MAX } })));
433+ });
434+ it("refuses a limit that isn't whole seconds from 1 to the most, and one on a uses step", () => {
435+ for (const bad of [0, -5, 901, 2.5, "600", null])
436+ has(
437+ problems(checkPipelines(one({ a: { run: "x", timeout: bad } }))),
438+ "pipelines.p.jobs.a.timeout",
439+ /whole seconds from 1 to 900/,
440+ );
441+ has(
442+ problems(checkPipelines(one({ a: { uses: "notify", to: "x", timeout: 600 } }))),
443+ "pipelines.p.jobs.a.timeout",
444+ /a uses step runs on the server/,
445+ );
446+ assert.equal(JOB_TIMEOUT_DEFAULT, 300);
447+ });
448+});