Domain Code Never Moves Into Delta
Delta knows files, folders, links, hashes and HTTP. It does not know what an Eagle item is, which image in an item's folder is the real original, or what a soul vault's committed bytes are. It should not have to. The design rule in Delta's house sign is short: root class first; apps are children. A plain tree is a DirectoryShare; an app whose data needs domain knowledge ships a child of DataShare in its own repository and declares it in a file named delta.json at that repository's root. Domain code stays with the domain.
The Declaration
Loomis, the drawing-study app, was the first to need it. Its engine runs on the service host; the Eagle library it studies lives on the workbench. Its delta.json (shown below) says everything Delta needs and nothing it should not know:
versionis1; a file with any other version declares nothing.namebecomes the second half of the share id:cwkLoomis/eagle.hostsays which Mac serves it, as a role (@workbench), a member name, or a fleet label. Every Mac reads every declaration and loads only the shares whose host resolves to itself; the rest are skipped without a word.classisfile:Class, a path inside the app's repository and the class name in it:loomis/delta_eagle.py:EagleLibraryShare.readers,writers,apps: who may ask (lesson 5). Loomis lets only the Mac that hosts Loomis' engine, plus the workbench itself, read it, and only for the appcwkLoomis.options: free settings the child reads itself. Loomis passesenv_file, the name of the file on that Mac that holds the Eagle API token.
Loading by File Path, Fenced to the Repository
At start, load_shares walks the family's projects folder for repositories that carry a delta.json, and for each declaration placed on this Mac it calls _load_child. That function does four things, and the order is the safety:
- It resolves the class file and refuses unless the real path is a file inside the declaring repository. A declaration cannot point Delta at another app's code, or at anything outside the projects tree, with
../. - It imports the file under a module name of its own making (
delta_app_<repo>_<share>), withimportlib.util.spec_from_file_location. No package install, no entry point, nosys.pathedit by Delta. - It refuses unless the named attribute is a class and a subclass of
DataShare. - It constructs the child with the declaration's fields and the repository's path as
repo_root.
A Child's Bug Is Its Own Problem
The whole call is wrapped. Any exception while loading one share, a syntax error in the child, a missing option, a constructor that raises, is logged with its traceback and recorded as that share's failure: {"id": "cwkLoomis/eagle", "error": "ValueError: …"}. Every other share loads. Delta keeps serving the home folder and every app share that did load, its health document lists the failure and turns its status from ok to degraded, delta status prints it, and a caller asking for the broken share gets a named answer rather than a vague 404: share cwkLoomis/eagle failed to load on <mac>: ValueError: ….
That is the right blast radius. A daemon that every Mac's data rides on cannot fall over because one app pushed a typo. Fixing it is an app-side change plus a reload: the engine answers POST /v1/reload on loopback by loading every share again.
What a Child Must Live With
The child runs inside Delta's process, so it inherits Delta's constraints. Delta runs on Apple's /usr/bin/python3 with the standard library only, so Loomis' child imports nothing from Loomis and nothing from pip: its docstring says so in its first paragraph. To decide whether an item sits inside Loomis' declared folder scope, it reads the item's own metadata.json from disk and checks it against Eagle's folder tree. The tree comes from Eagle's /api/folder/list, kept for five seconds, so a burst of 384 thumbnails asks Eagle for it about once rather than 384 times; when Eagle is closed, the child reads the same tree from the library's own metadata.json instead. The library's path is asked once, on first use, and remembered. For its four read-only API operations it calls Eagle's localhost API with the token from Loomis' .env on that Mac, and when that call fails it deliberately does not echo the URL, because the URL carries the token. The token never leaves the workbench.
Soul Vault's child takes the other path a child can take: it puts its own repository on sys.path and imports its store code, and on construction it drops any soulvault modules a long-lived Delta imported earlier, so that a reload after a git pull serves the code on disk instead of yesterday's.
And the child serves only what its declaration grants. Loomis' one write, an item's star rating, is not part of the share at all; it stays a command over SSH, which is what SSH is for in this family.