Something went wrong. Try again.
small gleam coding and persistent agent daemon with a detachable cli and a canvas ui forked from okami.mom/albedo
Something went wrong. Try again.
# Python kernel state
A kernel snapshot carries serializable namespace values and selected kernel
state into a replacement. It is separate from the conversation projection
described in [compaction](compaction.md).
[`kernel.snapshot` and `kernel.restore`](../src/albedo/harness/extensions/python/kernel.gleam)
take a path and timeout and return a `Saved` report. A busy kernel answers
`Busy`. A missing state file returns an `Invalid` error.
## Saved namespace
[`save_state`](../priv/python/albedo_state.py) excludes names beginning with `_`
and injected names. It records module import names, serializes other values with
`dill` when available or `pickle` otherwise, and stores captured definition
source separately. The snapshot also records the working directory and added
`sys.path` entries. It writes a temporary file and replaces the destination.
The serialized values have a 64 MiB total limit and an 8 MiB per-value limit.
Definition source has a 256 KiB total limit and a 32 KiB per-definition limit.
The report lists saved names, skipped names and reasons, the engine,
definitions, and up to five large values. These limits apply to the listed
components, not a promise about the total file size.
## Restore and trust
[`load_state`](../priv/python/albedo_state.py) restores path entries and
modules, kernel state, serialized values, and definition source. It retries
values deferred by an `AttributeError` after replaying definitions. It reports
failures and prior skips. If the saved working directory still exists, restore
changes to it.
Loading uses pickle and executes saved definition source. A state file therefore
belongs to the session's trust domain and must not be treated as safe untrusted
input. A successful restore does not imply every name survived. The `Saved`
report also includes `output_lost` when the saved kernel state reports lost
output or job-book channels. See
[`restore_kernel`](../priv/python/albedo_cells.py).
## Unchanged snapshots
[`snapshot`](../priv/python/albedo_cells.py) reuses its previous repo…