magus v0.4.3 is out. See what's new
¶ View markdown source · ✎ Suggest an edit
1 min read

MGS4010: target keys on a file its own run generates

A target finished successfully and magus did not cache it. A file its key read changed while it ran, and that file is a declared output: something in the target's own run generated it after the key was taken.

[MGS4010] .:test is never cached: its key reads 1 file its own run generates after the key is taken: gen/api.json. Generate them before this target's key, as a skip_cache target it composes or a target it depends on

The run stays green, and the next one runs in full again, every time. Nothing else says so: each run looks like an ordinary miss.

Why only generated files

One invocation runs a file's writer before its readers, so a declared output that moves under a step moved inside that step's own run. A moved file no target declares is a concurrent writer instead, an editor or another magus, and magus reports it as a plain notice: the next run hashes the new bytes and caches normally.

Resolution

The generator has to finish before the key is taken. Two ways do that:

  • Compose it as a skip_cache target. A skip_cache target a composer reaches through ctx.needs runs ahead of the composer's key, once its dependencies have finished, and the body does not run it again.
  • Depend on it. A target in another project that the composer's project depends on runs, and finishes, before the composer starts.

If the target does not actually need the file, drop it from the target's inputs instead.

Distinct from MGS4007

MGS4007 is a declared source the run changed, and it fails the run. This code is a generated file the key reads, and it only declines to cache.

MGS4010racecachekeygeneratorsskip_cache
Last updated (479ce5c7)
Glossary

Project

A directory magus recognizes as a unit of work (it has a magusfile); the unit of caching, scheduling, and dependency tracking. See workspace.

Target

A named operation (build, test, ...) you invoke with magus run <target>; it may compose a spell's tool-native operations and depend on other targets. See targets.

Op

A single tool-native command a target composes (long form: operation); the middle of the work hierarchy (Spell to Op to Target). See operations.

Cache

The content-addressed store magus consults before running a target, so unchanged work is skipped. See cache.

CI

An ordinary magusfile-defined target you compose yourself with magus\needs: magus does not hardcode its stages. Magus.RunCI treats it specially only in that it strips the rw charm, it is the anchor magus affected ci keys off, and a selected scope with no project declaring it is a load error rather than a silent no-op. See targets.

Invocation

One magus process's recorded facts (the targets it finished, their outcomes, the lease it acted as, and the session it ran in when a host delivered one), kept in a repo-scoped store every worktree shares. magus session lists them; the store prunes itself by last-fact age.

Run

One target executing under one magus invocation, such as magus run test web or magus affected ci. A run keeps its captured output behind an output reference. Every magus run is a run whether or not any job asked for it; see Job for how the two relate.

Conventions

This page uses none of the site's convention markers. The full set is on the conventions page.