small gleam coding and persistent agent daemon with a detachable cli and a canvas ui forked from okami.mom/albedo
albedo robot-docs kernel-state.md
5.4 kB · 43 lines
Markdown

# python kernel state The Python kernel snapshots the session namespace into the session-owned state file. Plain values are serialized with dill when installed, otherwise pickle; each value is independent, so one unserializable value does not prevent other values from being saved. Loading runs in the same daemon-home/session trust domain as pickle and is not a security boundary. ## unchanged snapshots A snapshot to the file the kernel last saved, with nothing changed since, writes nothing and answers with that save's reply. The kernel counts every owner message except snapshots, interrupts (a cell they could stop already counted) and reads (`introspect`, `job_list`, `job_read`), and every job start and end; the file must still have the modification time and size it was written with. So a kernel kept for names it cannot save, which every idle sweep tries to release again, does not rewrite its state while it runs nothing. ## definitions from source After a successful cell, the kernel records source for direct, top-level imports, functions, async functions, and classes. Decorators are included. Definitions nested inside `if`, `try`, `with`, or other compound statements are not captured. A later top-level assignment, delete, loop target, or with target removes a recorded name, so rebinding a function name to a value is not resurrected on restore. The latest definition wins. After a failed cell, the kernel records only definitions from statements that completed before the failing statement. Statements that bind no names still count when locating that failure. Definitions after the failure are never replayed. On restore, pickled values load first, then definitions run in recorded order. Successfully restored definitions are registered again and saved on the next release. Definition source is authoritative when a name has both forms. A failing definition is reported and does not prevent later definitions. Definition replay has the same trust as pickle loading: it executes in the daemon home for this session. ## …