Skip to content

DraftOwner sparkles:build-primitivesReviewed 2026-11-01

Task DAG — Decisions ​

The owner accepted T1–T4 and T8 on 2026-11-01, in a design interview held to rework the apps/ci task DAG. T5–T7 and T9 were settled while delivering and reviewing M4–M6, and are recorded in the SPEC. T10–T12 were settled while fixing defects an external review found in the executor.

T1: Package edges are not ordering edges for tests ​

Question. Must a dependency's test succeed before a dependent's test starts?

Alternatives.

  • Hard onSuccess edges between tests: less wasted work when a dependency fails, but every dependency chain serializes.
  • No ordering between tests: each test is authoritative for its own package.

Choice. No ordering between tests. A test waits only for the builds its binary needs. Package edges remain selection data for the closures.

Revisit when a measured run shows that tests of failed dependencies waste more than the serialization would cost.

T2: One executor fiber owns the graph ​

Choice. One fiber owns admission, edge resolution and outcomes, while actions run on any worker and report over cross-worker channels.

Alternative. Distributed admission from a shared structure. It makes the "lowest presentation key wins" rule hard to keep, and admission is cheap next to the work it admits. It may be revisited for very large graphs.

T3: Interlaced output and provider groups in CI ​

Question. Buffered blocks are deterministic but hide a hung task's output until the end. What should a CI log show?

Choice.

  • CI workflows run --interlaced.
  • The deterministic block transcript stays the local non-TTY default.
  • A provider module adds collapsible groups, annotations and masks for the common CI services, and degrades to plain output elsewhere.

T4: The generic layers live in sparkles:build-primitives ​

Choice.

  • The model, graph, executor, process adapter, plain reporter, workspace selection live in sparkles:build-primitives. The CI-provider module has a package of its own (T8).
  • Commands, the CLI and the TTY reporter stay in apps/ci.

Alternatives rejected.

  • Keeping the layers in apps/ci would make the build graph depend on an application.
  • A new package for the layers would duplicate the dependency on Event Horizon that sparkles:build-primitives already plans for its filesets.

T5: No backfilling past a capacity-blocked task (superseded) ​

Choice. A ready task that waits for capacity stops admission of later tasks. A task that waits only for an exclusive key does not.

Superseded by T17: in presentation order, it held every link and generator behind a test root's compile waiting for memory, and every test behind the last compile.

T6: An interrupted failure is a cancellation ​

Choice. A task the executor interrupted that then reports Failed is recorded as Cancelled(interrupted). The interrupt caused the failure, and counting it would invent a second primary cause.

T7: Events hold no pointers ​

Choice. Outcomes and event payloads name tasks by graph index, and an output line travels beside the payload. A SumType holding a pointer is @system to assign, and pointer-free events cross channels without borrowing.

T8: The CI-provider module is a leaf package (accepted) ​

Question. sparkles:build-primitives' unittest configuration depends on the test runner, so the test runner cannot import a module of that package without a dependency cycle. Yet the test runner is a natural second consumer: its failures can become provider annotations.

Alternatives.

  • Keep the module in sparkles:build-primitives, unused by the test runner.
  • Put it in sparkles:base.
  • Create a leaf package.

Choice. A leaf package, sparkles:ci-provider. It may depend on sparkles:base only if it needs something there.

Revisit when sparkles:base needs provider conventions itself.

T9: An unneeded fallback is not a failure (accepted) ​

Choice. A node behind an onFailure edge whose prerequisite succeeded is Blocked(conditionUnmet). It never fails the command, and summaries count it apart from blocks caused by failures. Without this, every green coverage run would report one blocked plain retry per package.

T10: A task directory is its id, percent-escaped ​

Question. A task directory was the id's segments as directories, with the /s inside a segment kept and ./.. components replaced by _. Then docs:verify:a/b and docs:verify:a:b shared a directory, and the second spill truncated the first; and a \ in a segment climbed out of the root on Windows.

Choice. Each id segment is one directory. Within it, /, \, % and a final . are percent-escaped (%2F, %5C, %25, %2E). The map is injective, no component is empty, . or .., and an ordinary id reads as itself. A path inside a segment no longer nests (docs%2Fguide.md).

Revisit when a case-insensitive file system hosts runs whose ids differ only in case.

T11: Each line of a multiline secret is masked ​

Choice. Output is masked after it is framed into lines, so a multiline redacted value (a PEM key) never appears whole in one line. Each of its non-empty lines, without a trailing \r, is masked too, after the whole value: needles are tried longest first. Unrelated output that happens to contain such a line is masked as well; masking too much is the safe error.

T12: A task that cannot get a fiber fails to start ​

Choice. When the scheduler's fiber slab rejects a task's fiber, the task is settled at once as Failed(spawnFailed, ENOBUFS) through the ordinary completion path: its weight and keys are released, it can trigger fail-fast, and the run ends. Left running, it held its claim forever and the run hung.

T13: An unasked cancellation is a failure ​

Question. A Cancelled outcome adds no failure, because the cause that cancelled the run controls the exit status. A driver can still report one when nothing cancelled the run: the process driver maps ProcessEnd.cancelled to Cancelled(interrupted) whatever ended the child, and an in-process action may give up on its own. Its dependents then became Cancelled(notAdmitted) and the command exited 0 over work that never finished.

Alternatives.

  • Keep the outcome and fail the command anyway, with no failing task to name.
  • Record it as Failed(contract).
  • A new failure reason for it.

Choice. Failed(contract), mirroring T6: the executor knows whether it interrupted a task, or whether its own fiber was interrupted by an enclosing shutdown, and a cancellation with neither is the action breaking its contract. Dependents are then blocked by a failure, the task can be the primary cause and trigger fail-fast, and reporters need no new reason.

Revisit when a driver needs to report a cancellation it initiated itself for a reason the run should accept.

T14: A secret's short lines are not masked on their own ​

Question. T11 masks each non-empty line of a multiline redacted value, accepting that unrelated output containing such a line is masked too. For a JSON credential that means every { and } the child prints, and for a PEM key every occurrence of the short last line of its body: the over-masking is not occasional but structural, and it wrecks the diagnostic output TDM14 keeps.

Alternatives.

  • Keep every non-empty line.
  • Match the value's lines as one contiguous block across output lines. A line is already emitted and spooled before the next one shows whether the block continues, so this needs output held back, and a block interleaved with stderr or cut short still leaks.
  • Mask only lines of at least a minimum length.

Choice. A minimum of 8 bytes for a line needle; the whole value is still a needle at any length. A line shorter than that holds at most seven bytes of the secret, structural text in practice (}, -----, a base64 tail), and masking it everywhere costs more than it hides.

Trade-offs. A secret made of short lines is masked only where it appears whole on one line.

Revisit when output is held back per task anyway, so block matching costs nothing more.

T15: An unordered read of a write rejects the graph ​

Question. When task nodes carry file claims (fileset-native workspace, BGW16), a node may read what another writes while no path of edges orders the two. Reject the graph, or infer the edge from writer to reader?

Alternatives.

  • Infer the edge, silently: friendlier, and it hides a planner that forgot the dependency, and can close a cycle the planner never wrote.
  • Infer it and warn: plans keep working, and the warning is easy to ignore.
  • Reject the graph, naming both nodes and the overlapping path.

Choice. Reject, accepted by the owner on 2026-11-12 (BGW17). Validation fails before anything runs, as it does for a cycle (TDS1), so a planner's mistake is found at the plan that makes it.

Revisit when a planner can only know an order from claims, with no other way to state the edge.

T16: The command line changes before the executor ​

Question. apps/ci's command surface (its SPEC §1) was to arrive with the cutover of ci test onto the build graph, which waits for build graph E3 and the test runner's core library. Must the two arrive together?

Alternatives.

  • Together, as planned: one migration of every caller, but ci keeps growing flat flags until then, and the cutover carries the rewrite of the whole command line besides the executor.
  • The command line first, over the current implementations: callers migrate once, now, and each later cutover swaps one command's implementation behind a command that no longer changes.

Choice. The command line first, accepted by the owner on 2026-11-18. The commands of SPEC §1.1 replace every flag in one change (apps/ci PLAN M7a), each returning its outcome as an Expected (CIC16). An option whose meaning needs the build graph, such as --since or --require-cached, is not accepted until the command that honours it exists, so no option is parsed and ignored.

The owner settled the details in the same interview:

  • Verbs over subjects (CIC17). Pass/fail checks are commands of ci check, the checks that rewrite are commands of ci fix, and GitHub-side actions are commands of ci github. This replaces the first draft's subject-first groups such as ci docs sidebar check, eleven of which held a single verb.
  • Options belong where they mean something. --log-level is the program's and is accepted anywhere. --fail-fast and --host-system belong to the commands that honour them.
  • Enums spell their default. --special-modes and --sanitize spell their default off, since core-cli has no optional enum option.
  • Removed flags are unknown options (CIC4). They get no table of replacements in the parser; SPEC §2 is the migration map.
  • Errors print as core-cli prints them, Error: <message>. A common rendering of ci's output, possibly through sparkles:ui, is a later design pass.
  • No default commands. A bare group prints its help and fails.
  • ci test --build-only runs today's dub build until M7b.
  • The command tree lives in cli.d first; moving each group's implementation out of app.d into SPEC §7's modules follows in later commits.

Revisit when never: the flags it removes do not return (CIC4).

T17: Admission by the longest chain, with bounded backfilling ​

Question. In which order are ready nodes admitted, and may a node that fits start past one that does not?

Evidence. A cold ci test --build-only of the repository on a 32-core, 60 GiB host took 150 s against a 61 s critical path, at 22 % CPU: in presentation order, alphabetical by task id, every compile: sorted before every generate: and link:, so the shader compiler's link, on the critical path, waited 64 s behind test roots' compiles; and a test root's compile waiting for memory held back every link and generator that fitted. A model of the executor fed that run's durations gave 130 s for presentation order without backfilling, 108 s for the longest chain first with backfilling.

Alternatives.

  • Presentation order without backfilling (T5): no starvation, but the head of the queue sets the pace, and a 58 ms generator waits as long as a 40 s compile ahead of it.
  • Backfilling with reservations sized by predicted durations (EASY): admits a node only if it ends before the reserved one could start. Tighter, but a wrong prediction delays the reserved node, and the predictions are recorded wall times under varying contention.
  • The longest chain first, backfilling freely, and a bound after which a node that was passed over is reserved.

Choice. The third (TDM8), with the second inside the bound. The order follows the critical path, which bounds the makespan when resources do not, so the nodes that start late tend to be the ones with slack; under the tokens and the memory the longest chain is a heuristic, not an optimum. Backfilling keeps the tokens and the memory busy. Once a node is reserved, a node predicted to end before it could start still starts, until twice the bound; then nothing does. A strict reservation from the first moment idled the host: in a ci test on that host, the font leg (22 tokens) was reserved behind wired's 59 s leg, and the CPU sat at 17–23 % for 20 s while short legs waited. Predictions decide only when within the bound the reserved node starts; the bound itself does not trust them.

Revisit when a run shows a reserved node idling the host for long, or a prediction error delaying one past twice the bound.

T18: What a test leg claims, and cold predictions ​

Question. How many tokens, and threads, does a test leg take, and what does ci predict for an action no run has measured (ci CIC11, CIC23)?

Evidence. Measured on a 16-core, 32-thread host with 60 GiB, the repository's 85 test legs, 146 compiles and 89 links, 2026-11-28:

  • At -t 32 and a claim of every token, the legs ran one after another, 306 s of legs in 306 s, at 18–20 % CPU. Their CPU over their wall time ranged from 0 (legs that wait on timers) to 18.8 (font, whose tests run their own thread pools); the mean was 5.3.
  • wired's leg, the longest, reached 2.1 cores' worth over 59 s at 8 threads and took 84 s at 4: a mean understates a leg's bursts.
  • A compile's CPU over its wall time was 0.7 to 0.99, a link's at most 1.2.
  • A test root's compile peaked at 0.6 GiB at the median, 1.4 GiB at the 75th percentile, 3.8 GiB at the 90th and 8.5 GiB at most (hue, terminal, ci); another compile at 1.9 GiB at most; a link at 0.17 GiB at the 75th percentile, 0.5 GiB at most. Admitting each test root's compile at 8 GiB, the largest, held a cold build to six at once under a 49.5 GiB budget while they used a quarter of it.
  • A compile took 0.1 to 0.3 s for each module it compiles; the kinds' means were 6 s for a test root's compile, 3 s for another, 4 s for a test leg, 0.3 s for a link.

Choice.

  • A leg claims ceil(p) tokens, p its last run's parallelism, at most half the capacity so the claims of the two longest legs (wired, font) fit together, and runs ceil(1.25 p) + 1 threads but at least its claim, and at least 8 after a run of 10 s or more, both at most as planned and the capacity; unmeasured, or with no CPU, it runs 8 and claims as many, at most half the capacity. The claim fills the CPU on average; the threads cover a leg's bursts (wired took 84 s at 4 threads, 59 s at 8); the run's thread budget, twice its capacity, bounds how far the bursts can oversubscribe the host.
  • A compile weighs one token (build-graph BGA8).
  • A cold default is about the 75th percentile, not the most: 1.5 GiB for a test root's compile, 256 MiB for a link, 2 GiB for another compile. At 4 GiB, the 90th percentile, a cold build still waited on the memory budget 45-65 % of its time while its compiles used a quarter of it. Such an action is charged more while it runs (4 GiB for a test root's compile, 512 MiB for a link): at 1.5 GiB alone a cold run admits about fifteen in one pass before any is measured, and the largest sort first. Releasing the extra charge at the first resident set reported after ten seconds let the budget fill again while those compiles were still growing: under a 20 GiB scope two runs lost three test roots' compiles to the OOM killer (hue's and terminal's, coverage-instrumented, 22-29 s in). Limiting how many unmeasured actions start per sampling interval was the alternative; it bounds the count but not the bytes. The few larger compiles are caught by the resident sets the running nodes report (TDM18), by the gate's hold while memory runs short, and past those by the scope's OOM killer, whose victim's next prediction is at least twice what it ran under. A test leg's default stays 4 GiB: its workers report no resident set while they run.
  • A compile's predicted duration, with no record, is 200 ms a module.

Alternatives rejected.

  • A leg's claim from its CPU and its threads left at the plan's, unbounded: the closest fit to what a leg uses, but nothing would bound the threads of many legs running at once.
  • Its claim and threads one number: no oversubscription, but the CPU idle. Measured so, the legs' tokens filled while the CPU sat at 30–45 % and the warm test phase took 97–156 s against a 60–70 s floor.
  • A fixed smaller -t for every leg: font and base would be throttled, and legs that wait on timers would still take tokens they do not use.
  • The largest peak as the cold default: safe, but a cold build waits on memory it never uses.

Revisit when a cold run on a small host loses an action to the scope's OOM killer twice, or a leg's threads oscillate between runs.