Assets

What an asset is, how assets reach the desk, how git versions are numbered and move at sync, how a launch card suggests assets, and what plugging as reference, target or instructions does

An asset is a folder, a repo, a link or a note that the library tracks and a run can read or write. This page says what the code does; file:line citations are in parentheses.

01what an asset is#

An asset is a record in the library. Its fields are id (a- and 16 hex digits), name, kind, about, working_dir, engine, picked_version, remote and branch (git assets), url and notes (link and notes assets), tags, created_at and created_by.

There are three engines:

picked_version is read by AtGo, which returns what a run would read if go were pressed now:

02how assets get on the desk#

The asset_import tool takes project and one of asset (add a library asset by id, as a reference and never a copy), dir (adopt a folder; the top of a git repo becomes a git asset) or new (a name for a new empty asset). main also makes it the project's main asset.

Adopting a repo (AdoptRepo) makes a git asset whose created_by is adopted. Adopting the same checkout and remote again returns the record already there. The branch is origin/HEAD's branch, else main, else master, else the checked-out branch.

When the desk boots, registerRepoAssets runs:

03snapshot assets#

Four facts about a new snapshot asset. Line numbers were read at the commit this page was written from.

04git versions#

Version n is the n-th commit of the asset's branch in git log --first-parent --reverse, oldest first. A version's files come from one ls-tree of its commit.

Numbers stay stable only while the first-parent history is not rewritten. Nothing in the code checks that.

The assets page shows the file count of the tip for a git asset and of picked_version for a snapshot asset (assetDetailOf).

05launch-card suggestions#

A launch card suggests assets for its ticket. Everything here is in internal/desk/launch_assets.go.

06plugging#

A plug has a role. Any other role is refused.

The rules:

When a plug names no nodes it reaches harness.ReadingNodes: plan then work, those the template has as runtime nodes.

At go, each plug is frozen at the AtGo version shown on the card (LaunchAsset).

The plug itself is AssetPlug with the fields id, role, nodes, files and copy (; the card tool's copy).

07kind#

kind is a free label on the record with two that the code treats specially:

08tags, about and derived_from#

09asset checks#

checks are the command checks a run that writes this asset is held to. Each has an id, executable, args, cwd and timeout. See checks.

10retired#

retired takes an asset out of the lists and out of suggestions without deleting it. A card proposes it with propose_asset_retire. Launch records and the "used in" list keep naming a retired asset at the version they froze.

11immutable versions#

A snapshot version is a manifest over a content-addressed blob store. A version is never rewritten: asset_snapshot and asset_version cut a new one and earlier versions stay. asset_version writes files into a snapshot asset's working folder first, and refuses a path outside the folder or an asset with no folder smith may write to (git, link or notes).

A run reads a version from a mount: Mount lays version n of the asset out once at <library>/mounts/<id>/<n>, built in a sibling temp folder and renamed into place so a half-written mount is never seen.

12target runs#

A run whose target is a snapshot asset works in a folder of its own that is not a git checkout. The folder carries a marker, .smith/target.json, naming the version it began as and its files. The run's changes are the files that differ from the marker's, and the gate approves them as the asset's next version (; the write is in internal/service/harness_assets.go and patch_target.go; the steps of that write: not checked).

Reviewers get target_diff: the text diff of the folder the run edited against the version it began as, with binary files listed by size (;).

13used in#

An asset's "used in" list reads the launch records that plugged it, with the role and the frozen version. Retiring the asset later changes neither.

14a run sees only what is plugged#

A run reads no asset it is not plugged with. A reference is handed over as data, an instructions plug is loaded as a skill, and a target is the folder it writes. Nothing else in the library is visible to the run. How the run's sandbox enforces this beyond what the plugs hand over: not checked.