When plugins change, magpie retires the old plugin host and starts a new one. The old host can keep port 43717 for up to 10 minutes while it finishes calls. In 0.10.0, the new host stored its failed bind as the service, and `if (service) return` blocked every later try. Once the old host exited, the page stayed refused until the host restarted.
Now a service is kept only once it is listening. A failed bind retries with backoff (1s, doubling, capped at 30s, the timer unref'd) while a store exists, and a listener that closes starts again. A failed backend start is retried too, and the first mutation's race with the empty-store check gets one more check. layerfs 0.10.1.
Run at the reviewed head 6f2d484e8f3367d1d614d4be5d9a44a701165fb4, on mote (temp HOME, Bun 1.4.2):
- bun test packages/layerfs: 68 pass (main: 64). page-lifecycle.test.mjs: 3 of 3 green. bun scripts/check.mjs: exit 0.
- The new tests against main's index.mjs: the handover and backend-retry tests go red.
- Broken by hand: dropping the backendPromise reset, the retry schedule, or storing the service before it listens each turns a test red.
- Probes: a closed listener comes back; with the port held for good, the retries cap at one every 30s and leak no servers; a pending retry doesn't hold the process open. page-service.mjs is unchanged, so its Host and Origin checks cover every retry.
Not covered by a test (follow-up): restarting a closed listener, sharing one startup between concurrent calls, and the store-version recheck. recheck and storeVersion overlap: either alone handles the race.
LayerFS's trajectory page is served by a loopback service the host starts once a store exists (no write into the install), keeps its view in location.hash across its 5 s reload, reports every skipped secret-shaped file in sorted order (#477), and drops the unloaded sample. By @Mola-maker.
Run at dfa99f7e merged onto current main:
- mote (macOS, Bun 1.4.2, temp HOME): bun test in packages/layerfs, 64 pass 0 fail, 2 of 2; bun scripts/check.mjs layerfs ok; the temp HOME held nothing from layerfs afterwards.
- WSL2 Ubuntu 24.04 (temp HOME): 64 pass 0 fail, 2 of 2 (#477's item 3 was red here on f3633eaf8).
- Broken by hand: dropping the `location.hash =` assignment in page/app.js turns the hash test red. Earlier rounds' breaks (Origin/Host checks, < escape, start gates, nosniff, sort, restore/settle/round, reload guard) each went red, see the 05:18 and 05:45 reviews.
- Earlier round: the page in a magpie-shaped sandboxed frame with pagePolicy CSP, Chromium and WebKit.
- PR checks: test and on-npm pass.
Not tried: a real magpie window.
layerfs 0.9.0 (sim-only): each provision, checkpoint, fork, publish and exec records the calling agent from the tool host's ctx.agent, and the page names it, ahead of the branch-name guess. trajectory() reads each commit record once per backend lifetime (summaries cached, manifest left out) and yields between branches, so a rebuild reads only new commits. Native backend requests are still refused loudly.
Run at e3c7ee94 (macOS): bun test packages/layerfs 57 pass (2 of 3 runs; the third hit ENOSPC on a full disk in 4 #360/accounting tests that pass in the others); origin/main 53 pass. bun scripts/check.mjs layerfs ok. Checked that magpie's host.js runTool passes ctx.agent as execute's second argument.
Not tried: the page in the real magpie app with a live agent.
provision, resolve and exec answer the workspace's path, and a tool
result goes to the vendor in the agent's next request. With the default
root ~/.magpie-layerfs every provision named magpie upstream.
The default root is now ~/.layerfs-tools. A ~/.magpie-layerfs made by
0.7.2 or earlier is renamed to it once, at the first backend made, and
a link is left at the old path, so a session still holding an old
workspace path keeps working. A legacy root that is itself a link (the
user's own setup) is used where it is, as is one the rename is refused
on. MAGPIE_LAYERFS_HOME set by the user is unchanged. A second host
racing the rename finds the new root and uses it.
Run, in a sandbox HOME:
- bun test packages/layerfs: 53 pass, 0 fail. bun scripts/check.mjs
layerfs: ok.
- The three #360 tests against the old default (defaultRoot answering
~/.magpie-layerfs): 2 of them red, the third (a user's link) is
unchanged behaviour.
- Through magpie's real plugin host (origin/main 4dfd88206,
plugin.Add of this package + plugin.RunTool "provision" in a
testenv sandbox HOME): a fresh home answers
~/.layerfs-tools/workspaces/demo/main and makes nothing at the old
name; a home with a ~/.magpie-layerfs holding a marker answers the
new path, the marker is under ~/.layerfs-tools, and ~/.magpie-layerfs
is a symlink.
Not tried: Windows (the link is a junction there), and moving a root
while an agent's exec runs in it.
Tool descriptions, and the errors a call answers, are part of the prompt
the agent sends its vendor. provision said "magpie's config directory",
exec "magpie serves these tools…", "MAGPIE_LAYERFS_EXEC=1" and "in
magpie's plugin options". They now say "the app's config directory",
"the host serves these tools…", "the exec switch in the host's
environment (see the package's README)" and "the host's plugin options".
The siblings that reach the model too are reworded the same way: the
source refusal ("the app's config directory"), the sim-only error (no
package or repo name, no variable names) and the bad-backend error.
Every environment variable is still read as before.
Not changed, filed as plugins#360: the workspace path provision answers
is under ~/.magpie-layerfs by default; moving it needs a plan for
existing workspaces.
Run:
- bun test (packages/layerfs): 50 pass, 0 fail
- bun scripts/check.mjs: ok
- no-magpie.test.mjs against HEAD's index.mjs and layerfs.mjs: 2 of 2 red
New community tools package @magpie-community/tools-layerfs 0.7.1 (Mola-maker): LayerFS workspaces as tools for every agent. It imports a source folder into a versioned workspace under MAGPIE_LAYERFS_HOME (default ~/.magpie-layerfs), with checkpoints, history and diffs. Running commands (exec) is off unless the user turns it on. No network access. registry.json gains its one entry.
Run at the reviewed head 4795df0 (merges cleanly onto origin/main 1ae89aa):
- bun scripts/check.mjs layerfs: ok
- bun test in the package under a temp HOME: 48 of 48 pass, worktree clean after
- the seven points from the last review, each re-run:
1. source guard: ~/.Config/Magpie, a symlink to ~/.config/magpie, ~/.AWS, ~/.CONFIG and a symlinked parent are all refused
2. names: project a / branch b--c and project a--b / branch c no longer share a workspace; Main and main are apart
3. layerfs_history {limit:1} at 200 checkpoints: 0.1 ms (151 ms before), no trajectory.json written
4. native backend and its SDK path removed; asking for it throws a clear error
5. repository points at this repo; README images pinned
6. runShell: cat returns in 32 ms (2005 before), a backgrounded sleep doesn't hold the call, a timeout kills the process
7. storedBytes equals stored content plus checkpoint records; the description says so
- read every line changed since 1c9e4c1: no path escape, no writes outside its home
Not tried: a real agent using the tools through magpie.
Known: something exec starts in the background keeps running after a successful call, like a normal shell, and can land in the next checkpoint.