Skip to content

Instantly share code, notes, and snippets.

@tinnus-napbus
Last active January 18, 2023 09:31
Show Gist options
  • Select an option

  • Save tinnus-napbus/5549fbf38d72a8ae482425c9694fa268 to your computer and use it in GitHub Desktop.

Select an option

Save tinnus-napbus/5549fbf38d72a8ae482425c9694fa268 to your computer and use it in GitHub Desktop.
kelvin shims clay summary

kelvin shims in clay

Key points:

  • desks can now be committed with any kelvin version
  • clay will look backwards through the %base desk's aeons for a weft matching the one in question, build its zuse, save it in a zuse cache and return it.
  • the leak key in the cache now includes the weft the files are built against
  • the raft now contains a zuse cache
  • domes now record the weft they're currently built against
  • +lu now builds agent-any:gall weft-agent pairs as long as they're gall-compatible.
  • only gall-compatible wefts can be set %live

type changes

Clay's external types are unchanged, and it internal types are changed like so:

  • raft: a zuse cache is added as zuz=(map weft vase). This contains the compiled zuses in use for all desks.
  • leak: the ford cache keys have a =weft field added which records which zuse they're compiled against.
  • dome: a wef=weft field records which zuse version its current aeon is compiled against. There will always be a corresponding vase in the zuse cache.

Additionally, the ford-args includes a topic=[=weft =vase], providing the zuse version and vase being built against.

new functions

the +de core has two functions added: +got-zuse and +sweep-zuse-cache.

+got-zuse:de

+got-zuse takes a waft, and searches backwards through aeons in the %base desk, looking for a match in each aeon's sys.kelvin. If a match is found, it reads out hoon.hoon, arvo.hoon, lull.hoon and zuse.hoon and compiles them into a vase. The vase is added to the zuz zuse cache in the raft, and also returned along with the exact weft of the zuse.

Before looking through the %base aeons, it first looks in the zuse cache for a match, and if found, just returns it straight away.

When searching, it'll give up and fail if:

  • it gets to the end of the aeons
  • it gets to an aeon where everything in the sys.kelvin is older than what we're looking for (it's assumed that newer commits have newer kelvin ranges).

+sweep-zuse-cache:de

this just gets the set of all wefts of all desks and compares it to those in the zuse cache, deleting unused entries. The zuse cache has no reference counting or anything, this sweep is just run at the end of park.

allowable %live versions

Clay will allow any kelvin-versioned desk to be committed, but it only allows desks to be %live if they're shimmable by gall. There is an $agent-wefts:gall union in lull.hoon which defines the compatible wefts. This correspond to the $agent-any:gall tagged union in lull, which pairs wefts with their agent-xxx version.

The weft will be checked for compatibility in +goad:lu, +set-zest:de and +take-park-held:de. The former two will crash if it's incompatible, the latter one will just do nothing if incompatible, and the desk will continue to be in a %held state.

This means there's no way to set a desk live if it's not compatible with gall, regardless of whether it even has gall agents in it.

+park:de changes

park's initial test now passes if:

  • it's %base and the kelvin version is newer or equal to the existing one
  • it's not %base and the kelvin version is older of equal to the current one.

other changes are fairly light, it just makes sure to record the new weft in the dome & allows desks to be old.

+sweep-zuse-cache is called at the end depending on goat, since it only needs to be called once during a kernel update.

+ford:fusion changes

mostly the same except the target weft and its zuse vase are given in the topic argument and stored in its state. They're only referenced a couple of times - once in +build-nave and once in +run-prelude

build-agents:lu changes

when building an agent, it reads out the weft from wef.dom and then extracts the agent to a matching agent type like agent-416:gall, producing a load task with $agent-any:gall's, which are a pair of the weft and a matching agent-xxx:gall. If there's not an entry for the weft in $agent-any:gall, it'll fail.

+stay changes

+stay no longer clears ford caches, it just exports the state as-is, since we don't want to clear desks with old zuses if we're not upgrading them. All cache clearance will now happen in +park.

+load

+raft-13-to-14 is added which updates the structures and builds zuses for all desks except %base cos it's guaranteed to get upgraded in +park.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment