okami.mom/albedo

git clone https://git.nkp.pet/okami.mom/albedo

dawnkernel: run the python kernel detached behind a bridge, with a durable seq/ack session layer so it survives dropped connections and daemon restartsc3dc8ec

main
673 B22 linesraw
1"""Content hash of the packaged python tree.
2
3The remote plugin stages a bundle under this hash, and a detached kernel and
4its bridge announce it, so the daemon can tell when a kernel runs older code
5than the daemon's own tree.
6"""
7
8from __future__ import annotations
9
10import hashlib
11from pathlib import Path
12
13ROOT = Path(__file__).resolve().parent
14
15
16def digest(root: Path = ROOT) -> str:
17    """sha256 over every .py file's relative path and bytes, in path order."""
18    hasher = hashlib.sha256()
19    for path in sorted(root.rglob("*.py")):
20        hasher.update(str(path.relative_to(root)).encode())
21        hasher.update(path.read_bytes())
22    return hasher.hexdigest()