Record a bundled mesh server as one tarball, and install it by its integrity #170

Manually merged
terra merged 7 commits from pluto/168-bundled-tarball into main 2026-11-25 09:57:16 +00:00
Member

Purpose (product): martha records a bundled mesh server as its one tarball and installs it by the integrity the forge's registry publishes, so a member's mesh server comes from the forge with npmjs unreachable (martha-ai/martha#168). Approach: the issue's own section, with the Supervisor's ruling that the file list stays (the integrity covers transit, the file list covers the placed tree).

  • The tree model: RecordedMeshTree.lock is now optional and tarball (the URL the recorded registry serves) is added; integrity pins the tarball itself. recordMeshTree unpacks the tarball once into a tree's shape, and branches to recordBundledTree when the manifest declares bundleDependencies: the URL, the integrity npm publishes for those bytes, every file the tarball carries, and what each of its packages reads.
  • environment_reads of a bundled tree are attributed from the tarball's own node_modules layout (packageOfBundledFile), so a read belongs to the package that makes it rather than to the server's directory, and known_environment_reads means what it meant. A locked tree's attribution is unchanged.
  • The install: installBundled fetches that one URL (npm pack, isolated home), refuses a URL outside the recorded registry, checks the bytes against the recorded integrity before using any of them, unpacks them into node_modules/<server>/, and then goes through the same tree comparison as a locked tree, so a file changed, removed or added after the place still refuses the next one.
  • The recording: registry is https://git.macula.io/api/packages/macula-pub/npm/. 0.51.6 is recorded from the tarball the forge publishes: no lock (bundled), 4513 files, 15 packages with reads, 23 settings, 35 tools, 7 bins. 0.51.0 and 0.51.2 retire from both recordings in the same commit, because their locks name registry.npmjs.org and refusalOfLocked refuses them once the registry is the forge's. The recordings that name those versions for other reasons (petnames, answer shapes, ring results) are records of server behaviour and stay.
  • A defect the real recording found, fixed here: record:mesh-tools read the tree the old recorder left at extracted/package, which the new one does not write, so it died with ENOENT; and it then walked the bundled dependencies, where an @modelcontextprotocol/sdk example registers a tool by a computed name. The recording, the launch and the script now unpack a tarball through one rule (unpackServerTarball, which installBundled, recordMeshTree and the script call) and read a server's own files by one rule (ownCodeOf).

A locked server's path is unchanged: its lock, its install and its tests run as before.

Five new tests, each with its mutant, in the recorder's test file (34 there, 92 across the three affected files):

  • a bundled server records as its one tarball: URL, integrity, every file it carries (passes);
  • a tarball the registry does not publish is refused at the record, naming both integrities (mutant: drop the record-time check, 33/34);
  • a tarball the registry serves other bytes for is refused at the place, naming both integrities (mutant: drop the install-time check, 33/34);
  • a recorded URL anywhere but the recorded registry is refused, naming where it points (mutant: drop the URL guard in installBundled, 33/34);
  • a bundled file altered after the place is refused at the next place, naming it (mutant: skip the tree comparison for a lockless tree, 33/34).

Proof, run here with npmjs dead: in a mount namespace (/etc/hosts naming only the forge, an empty resolv.conf, hosts: files in nsswitch.conf) npmjs answers http=000 and the forge http=200. theRecordedNodeIdOf (what martha up reads its roster's node ids with, which starts macula-mcp-node-id through startOfARecordedBin) printed a 64-hex node id; startOfARecordedBin for macula-mcp-node-id ran status 0 and printed the same id; startOfARecordedBin for macula-mcp started the recorded bin under the launcher's confining hook, and one initialize answered serverInfo {"name":"macula-mcp","version":"0.51.6"}. The tree root was empty before the run, so this installed the one tarball.

Gates here: tsc --noEmit clean, eslint clean on the touched files, check:restated-values green, check:private over the range nothing private, and the parallel stage of npm test green. The 17 recorded-host runs and the installer job are CI's (the installer's own dependencies would be fetched from npmjs, which we no longer do).

Review r=1 fold-in (fable), commit fcac4483, on top of the merge with main

The required finding: record_ring_results.ts and record_mesh_answers.ts read trees the recorder no longer writes, so the ring recorder died ENOENT for any server and neither could record a bundled version. One rule now decides where a recording leaves the tree with its dependencies, treeWithItsDependencies (the bundled tarball's own tree, or the lock's install), with packageDirInTree for the server's package inside it. The launch, the unpack, the recorder and both scripts use them, and no layout literal is left outside the install module. A new test pins the rule for both shapes, and it fails when the rule names the wrong tree.

The smaller points, all taken: the fake registry can publish a dist it does not serve, which gives publishedTarballOf's two guards tests (a tarball URL on another host, an integrity that is no sha512); a file added inside a bundled tree and a link planted in it are tested refusals by name; unpackServerTarball names tar when it cannot be run instead of reading null; the installBundled comment now says npm pack reads the manifest before the check; and the plugin-dirs rationale restates no version.

The recorder test file holds 38 tests on this tree, 96 across the three affected files, 6 in the npm-alone file. Mutants, each planted alone on this tree: record-time check dropped, 36/37; install-time check dropped, 36/37; tree comparison skipped for a lockless tree, 35/37 (two tests); URL guard dropped, 36/37; and the new tree rule naming the lock's install for a bundled server, 0/1.

Not in this change: 0.51.6 recorded for the answer shapes, ring result keys, host ring answers and petnames. Both recorders join the live mesh, which is a fleet act on the DEV realm and wants one round covering all four, so it is filed as martha-ai/martha#176 and the reason is on the issue.

Refs martha-ai/martha#168

🤖 Generated with Claude Code

Purpose (product): martha records a bundled mesh server as its one tarball and installs it by the integrity the forge's registry publishes, so a member's mesh server comes from the forge with npmjs unreachable (martha-ai/martha#168). Approach: the issue's own section, with the Supervisor's ruling that the file list stays (the integrity covers transit, the file list covers the placed tree). - The tree model: `RecordedMeshTree.lock` is now optional and `tarball` (the URL the recorded registry serves) is added; `integrity` pins the tarball itself. `recordMeshTree` unpacks the tarball once into a tree's shape, and branches to `recordBundledTree` when the manifest declares `bundleDependencies`: the URL, the integrity npm publishes for those bytes, every file the tarball carries, and what each of its packages reads. - `environment_reads` of a bundled tree are attributed from the tarball's own `node_modules` layout (`packageOfBundledFile`), so a read belongs to the package that makes it rather than to the server's directory, and `known_environment_reads` means what it meant. A locked tree's attribution is unchanged. - The install: `installBundled` fetches that one URL (`npm pack`, isolated home), refuses a URL outside the recorded registry, checks the bytes against the recorded integrity before using any of them, unpacks them into `node_modules/<server>/`, and then goes through the same tree comparison as a locked tree, so a file changed, removed or added after the place still refuses the next one. - The recording: `registry` is `https://git.macula.io/api/packages/macula-pub/npm/`. 0.51.6 is recorded from the tarball the forge publishes: no lock (bundled), 4513 files, 15 packages with reads, 23 settings, 35 tools, 7 bins. 0.51.0 and 0.51.2 retire from both recordings in the same commit, because their locks name registry.npmjs.org and `refusalOfLocked` refuses them once the registry is the forge's. The recordings that name those versions for other reasons (petnames, answer shapes, ring results) are records of server behaviour and stay. - A defect the real recording found, fixed here: `record:mesh-tools` read the tree the old recorder left at `extracted/package`, which the new one does not write, so it died with ENOENT; and it then walked the bundled dependencies, where an `@modelcontextprotocol/sdk` example registers a tool by a computed name. The recording, the launch and the script now unpack a tarball through one rule (`unpackServerTarball`, which `installBundled`, `recordMeshTree` and the script call) and read a server's own files by one rule (`ownCodeOf`). A locked server's path is unchanged: its lock, its install and its tests run as before. Five new tests, each with its mutant, in the recorder's test file (34 there, 92 across the three affected files): - a bundled server records as its one tarball: URL, integrity, every file it carries (passes); - a tarball the registry does not publish is refused at the record, naming both integrities (mutant: drop the record-time check, 33/34); - a tarball the registry serves other bytes for is refused at the place, naming both integrities (mutant: drop the install-time check, 33/34); - a recorded URL anywhere but the recorded registry is refused, naming where it points (mutant: drop the URL guard in `installBundled`, 33/34); - a bundled file altered after the place is refused at the next place, naming it (mutant: skip the tree comparison for a lockless tree, 33/34). Proof, run here with npmjs dead: in a mount namespace (`/etc/hosts` naming only the forge, an empty `resolv.conf`, `hosts: files` in `nsswitch.conf`) npmjs answers `http=000` and the forge `http=200`. `theRecordedNodeIdOf` (what `martha up` reads its roster's node ids with, which starts `macula-mcp-node-id` through `startOfARecordedBin`) printed a 64-hex node id; `startOfARecordedBin` for `macula-mcp-node-id` ran status 0 and printed the same id; `startOfARecordedBin` for `macula-mcp` started the recorded bin under the launcher's confining hook, and one `initialize` answered `serverInfo {"name":"macula-mcp","version":"0.51.6"}`. The tree root was empty before the run, so this installed the one tarball. Gates here: `tsc --noEmit` clean, eslint clean on the touched files, `check:restated-values` green, `check:private` over the range nothing private, and the parallel stage of `npm test` green. The 17 recorded-host runs and the installer job are CI's (the installer's own dependencies would be fetched from npmjs, which we no longer do). ## Review r=1 fold-in (fable), commit `fcac4483`, on top of the merge with main The required finding: `record_ring_results.ts` and `record_mesh_answers.ts` read trees the recorder no longer writes, so the ring recorder died ENOENT for any server and neither could record a bundled version. One rule now decides where a recording leaves the tree with its dependencies, `treeWithItsDependencies` (the bundled tarball's own tree, or the lock's install), with `packageDirInTree` for the server's package inside it. The launch, the unpack, the recorder and both scripts use them, and no layout literal is left outside the install module. A new test pins the rule for both shapes, and it fails when the rule names the wrong tree. The smaller points, all taken: the fake registry can publish a `dist` it does not serve, which gives `publishedTarballOf`'s two guards tests (a tarball URL on another host, an integrity that is no sha512); a file added inside a bundled tree and a link planted in it are tested refusals by name; `unpackServerTarball` names tar when it cannot be run instead of reading null; the `installBundled` comment now says npm pack reads the manifest before the check; and the plugin-dirs rationale restates no version. The recorder test file holds 38 tests on this tree, 96 across the three affected files, 6 in the npm-alone file. Mutants, each planted alone on this tree: record-time check dropped, 36/37; install-time check dropped, 36/37; tree comparison skipped for a lockless tree, 35/37 (two tests); URL guard dropped, 36/37; and the new tree rule naming the lock's install for a bundled server, 0/1. Not in this change: 0.51.6 recorded for the answer shapes, ring result keys, host ring answers and petnames. Both recorders join the live mesh, which is a fleet act on the DEV realm and wants one round covering all four, so it is filed as martha-ai/martha#176 and the reason is on the issue. Refs martha-ai/martha#168 🤖 Generated with [Claude Code](https://claude.com/claude-code)
A server that names its dependencies in bundleDependencies carries them inside its own
tarball, so the tree IS that tarball. martha recorded such a server as a registry lock plus
npm ci, which cannot describe it: the lock has 127 inBundle entries naming no registry (all
refused by refusalOfLocked), and npm ci from that lock cannot resolve fast-uri for ajv once
only our registry is reachable.

Now: the recording holds the version, the URL the recorded registry serves the tarball at,
the sha512 npm publishes for those bytes, every file the tarball carries, and what each of
its packages reads, attributed from the tarball's own node_modules layout rather than a lock.
The install fetches that one tarball (npm pack of the URL, isolated home), checks the bytes
against the recorded integrity before using any, unpacks them into node_modules/<server>/, and
then goes through the same tree comparison as a locked tree, so a file changed, removed or
added after the place still refuses the next one. A recorded URL outside the recorded registry
is refused. A locked server's path is unchanged.

Tests, five, each with its mutant (34 in the file, 78 across the three affected files):
- a bundled server records as its one tarball: URL, integrity, every file (passes);
- a tarball the registry does not publish is refused at the record, naming both integrities
  (mutant: drop the record-time check -> this one fails, 33/34);
- a tarball the registry serves other bytes for is refused at the place, naming both
  (mutant: drop the install-time check -> this one fails, 33/34);
- a recorded URL anywhere but the recorded registry is refused, naming where it points;
- a bundled file altered after the place is refused at the next place, naming it.
Mutant 3 and 4 runs were cut by the session's handover at the context limit: the tree-comparison
mutant (skip treeUnlike for bundled) and the URL-guard mutant are planted-but-unrun, to be rerun
first in the next session.

Measured: tsc --noEmit clean, eslint clean on the five touched files, check:restated-values
green, 78/78 across the recorder's, the produced-bytes' and the npm-alone test files.

Not in this commit: the registry flip and the retirement of the npmjs-recorded 0.51.0/0.51.2,
which need the real recording against macula-pub; and the npmjs-dead proof run.
recordMeshTree unpacks the tarball into a recorded tree's shape now, under
node_modules/<server>/, and no longer leaves the old extracted/package for the
recording script: `npm run record:mesh-tools` died there with ENOENT. The script
also walked every .js under the package, which now includes the bundled
dependencies, and an example in @modelcontextprotocol/sdk registers a tool whose
name is no literal, so no tool list could be read.

unpackServerTarball is that one unpack rule, used by the recording, the launch
and the script; ownCodeOf is the recorder's own-files rule, exported so the
script reads the same files the recorder does and skips the bundles the manifest
names.
Record: 0.51.6, the server the forge registry publishes, as its one bundled tarball (martha-ai/martha#168)
All checks were successful
dependency advisories / node in . (pull_request) Successful in 13s
dependency advisories / node in carry_marthas_own_node/try_a_single_executable (pull_request) Successful in 20s
dependency advisories / node in . (container) (pull_request) Has been skipped
dependency advisories / node in carry_marthas_own_node/try_a_single_executable (container) (pull_request) Has been skipped
dependency advisories / node in installer (container) (pull_request) Has been skipped
dependency advisories / node in installer (pull_request) Successful in 13s
dependency advisories / advisories (pull_request) Successful in 0s
c4 model / c4-model-1 (pull_request) Successful in 6s
CI / links resolve (pull_request) Successful in 5s
c4 model / c4-model (pull_request) Successful in 0s
CI / structural floor (pull_request) Successful in 27s
CI / Martha's names are its own (pull_request) Successful in 34s
CI / no import cycle (pull_request) Successful in 33s
CI / the engine drift check bites (pull_request) Successful in 36s
CI / the posted text check bites (pull_request) Successful in 12s
CI / the host drift check bites (pull_request) Successful in 1m7s
CI / the ring reaches the owner on the live run's tmux (pull_request) Successful in 13s
CI / workflows are valid (pull_request) Successful in 11s
CI / nothing private (pull_request) Has been skipped
CI / no test the base passed goes missing (pull_request) Successful in 34s
CI / the pictures change only with the version (pull_request) Successful in 19s
CI / no literal restates a defined value (pull_request) Successful in 58s
CI / installer (pull_request) Successful in 2m8s
CI / every check runs in a job (pull_request) Successful in 12s
CI / every job has a timeout (pull_request) Successful in 15s
standalone / the pinned Node is nodejs.org's (pull_request) Successful in 17s
standalone / standalone Martha runs alone (ubuntu-latest) (pull_request) Successful in 30s
CI / the relay loads in the recorded host (pull_request) Successful in 15m33s
CI / the clean-install proof removes its container (pull_request) Successful in 16m25s
CI / gate coverage (pull_request) Successful in 17m2s
49a2d698fe
The registry is now macula-pub on the forge, so every recorded version must come
from it. 0.51.6 is the one the forge publishes: recorded as the bundled tree it
is, with no lock (its bundleDependencies carry every dependency inside its own
tarball), the URL macula-pub serves it at, its sha512, the 4513 files it carries,
what each of its 15 packages reads, its 23 settings, and its 35 tools and 7 bins.

0.51.0 and 0.51.2 are retired from both recordings in this same commit: their
locks name registry.npmjs.org, which refusalOfLocked refuses once the recording's
registry is the forge's, so a member pinning either would have had no tree at all.
Nothing installs them any more.

The plugin-dirs variable is still named by no file of the recorded tree, now
0.51.6 (the recordings of 0.51.0 and 0.51.2 are gone).
Merge remote-tracking branch 'origin/main' into pluto/168-bundled-tarball
All checks were successful
dependency advisories / node in . (pull_request) Successful in 13s
dependency advisories / node in . (container) (pull_request) Has been skipped
dependency advisories / node in carry_marthas_own_node/try_a_single_executable (pull_request) Successful in 11s
dependency advisories / node in installer (pull_request) Successful in 11s
dependency advisories / advisories (pull_request) Successful in 0s
c4 model / c4-model (pull_request) Successful in 0s
CI / Martha's names are its own (pull_request) Successful in 29s
dependency advisories / node in carry_marthas_own_node/try_a_single_executable (container) (pull_request) Has been skipped
dependency advisories / node in installer (container) (pull_request) Has been skipped
c4 model / c4-model-1 (pull_request) Successful in 3s
CI / links resolve (pull_request) Successful in 6s
CI / structural floor (pull_request) Successful in 29s
CI / no import cycle (pull_request) Successful in 34s
CI / the engine drift check bites (pull_request) Successful in 40s
CI / the posted text check bites (pull_request) Successful in 12s
CI / the host drift check bites (pull_request) Successful in 1m19s
CI / the ring reaches the owner on the live run's tmux (pull_request) Successful in 12s
CI / workflows are valid (pull_request) Successful in 14s
CI / installer (pull_request) Successful in 3m41s
CI / nothing private (pull_request) Has been skipped
CI / no test the base passed goes missing (pull_request) Successful in 37s
CI / the pictures change only with the version (pull_request) Successful in 18s
CI / no literal restates a defined value (pull_request) Successful in 1m9s
CI / every check runs in a job (pull_request) Successful in 14s
CI / every job has a timeout (pull_request) Successful in 14s
standalone / the pinned Node is nodejs.org's (pull_request) Successful in 19s
standalone / standalone Martha runs alone (ubuntu-latest) (pull_request) Successful in 34s
CI / the relay loads in the recorded host (pull_request) Successful in 15m44s
CI / the clean-install proof removes its container (pull_request) Successful in 16m46s
CI / gate coverage (pull_request) Successful in 16m11s
9c940d585f
Fold in the review: one tree rule for every recording script, and the guards it was missing (martha#168)
Some checks failed
dependency advisories / node in . (pull_request) Successful in 8s
dependency advisories / node in carry_marthas_own_node/try_a_single_executable (pull_request) Successful in 7s
dependency advisories / node in . (container) (pull_request) Has been skipped
dependency advisories / node in carry_marthas_own_node/try_a_single_executable (container) (pull_request) Has been skipped
dependency advisories / node in installer (container) (pull_request) Has been skipped
c4 model / c4-model-1 (pull_request) Successful in 3s
c4 model / c4-model (pull_request) Successful in 0s
dependency advisories / node in installer (pull_request) Successful in 8s
dependency advisories / advisories (pull_request) Successful in 0s
CI / links resolve (pull_request) Successful in 8s
CI / structural floor (pull_request) Successful in 22s
CI / Martha's names are its own (pull_request) Successful in 22s
CI / no import cycle (pull_request) Successful in 32s
CI / the engine drift check bites (pull_request) Successful in 18s
CI / the posted text check bites (pull_request) Successful in 19s
CI / workflows are valid (pull_request) Successful in 9s
CI / nothing private (pull_request) Has been skipped
CI / the ring reaches the owner on the live run's tmux (pull_request) Successful in 16s
CI / the host drift check bites (pull_request) Successful in 59s
CI / the pictures change only with the version (pull_request) Successful in 19s
CI / no test the base passed goes missing (pull_request) Successful in 29s
CI / every check runs in a job (pull_request) Successful in 15s
CI / every job has a timeout (pull_request) Successful in 9s
standalone / the pinned Node is nodejs.org's (pull_request) Successful in 11s
standalone / standalone Martha runs alone (ubuntu-latest) (pull_request) Successful in 36s
CI / no literal restates a defined value (pull_request) Successful in 53s
CI / installer (pull_request) Successful in 2m12s
CI / the relay loads in the recorded host (pull_request) Successful in 14m37s
CI / the clean-install proof removes its container (pull_request) Successful in 16m20s
CI / gate coverage (pull_request) Has been cancelled
fcac448366
The reviewer's required finding, and its sibling of the record:mesh-tools fix: record_ring_results
and record_mesh_answers still read the trees the recorder no longer writes. The ring recorder read
<scratch>/extracted/package, which recordMeshTree stopped making (it unpacks to a recorded tree's
shape now), so it died ENOENT for any server; and both started the server from <scratch>/installed-
tree, which only the lock path creates, so neither could record a bundled version at all.

Now one rule decides where a recording leaves the tree WITH its dependencies, treeWithItsDependencies
(the bundled tarball's own tree, or the lock's install), and packageDirInTree names the server's own
package inside it. The launch, the unpack, the recorder and both scripts use those, and no layout
literal is left outside the install module.

Also, the review's smaller points: the fake registry can publish a dist that says something it does
not serve, which gives publishedTarballOf's two guards tests (a tarball URL on another host, an
integrity that is no sha512); a file added inside a bundled tree and a link planted in it are now
tested refusals by name; unpackServerTarball names tar when it cannot be run, rather than reading
null; the installBundled comment says npm pack reads the manifest before the check; and the
plugin-dirs rationale no longer restates a version.

Tests: 38 in the recorder file, 6 in the npm-alone file. Mutants, each alone on this tree: the
record-time check dropped fails "a bundled server hands the registry a tarball it does not publish"
(36/37); the install-time check dropped fails "a bundled tree whose tarball the registry serves other
bytes for" (36/37); the tree comparison skipped for a lockless tree fails "a bundled file altered
after the place" and "a file added inside a bundled tree, or a link planted in it" (35/37); the URL
guard dropped fails "a recorded tarball anywhere but the recorded registry" (36/37); and the new tree
rule naming the lock's install for a bundled server fails the new tree test (0/1).

Not in this commit: 0.51.6 recorded for the answer shapes, ring result keys, host ring answers and
petnames, which is said on the issue: both recorders join the live mesh.
Merge remote-tracking branch 'origin/main' into pluto/168-bundled-tarball
Some checks failed
CI / gate coverage (pull_request) Successful in 16m54s
dependency advisories / node in carry_marthas_own_node/try_a_single_executable (pull_request) Successful in 13s
dependency advisories / node in . (pull_request) Successful in 13s
dependency advisories / node in . (container) (pull_request) Has been skipped
dependency advisories / node in carry_marthas_own_node/try_a_single_executable (container) (pull_request) Has been skipped
dependency advisories / node in installer (pull_request) Successful in 13s
dependency advisories / node in installer (container) (pull_request) Has been skipped
dependency advisories / advisories (pull_request) Successful in 0s
c4 model / c4-model-1 (pull_request) Successful in 3s
c4 model / c4-model (pull_request) Successful in 0s
CI / links resolve (pull_request) Successful in 7s
CI / structural floor (pull_request) Successful in 26s
CI / Martha's names are its own (pull_request) Successful in 30s
CI / no import cycle (pull_request) Successful in 29s
CI / the posted text check bites (pull_request) Successful in 8s
CI / the engine drift check bites (pull_request) Successful in 47s
CI / the ring reaches the owner on the live run's tmux (pull_request) Successful in 15s
CI / the host drift check bites (pull_request) Successful in 1m21s
CI / workflows are valid (pull_request) Successful in 13s
CI / nothing private (pull_request) Has been skipped
CI / the pictures change only with the version (pull_request) Successful in 22s
CI / every check runs in a job (pull_request) Successful in 16s
CI / no test the base passed goes missing (pull_request) Successful in 37s
CI / every job has a timeout (pull_request) Successful in 15s
CI / no literal restates a defined value (pull_request) Successful in 1m10s
standalone / standalone Martha runs alone (ubuntu-latest) (pull_request) Successful in 33s
standalone / the pinned Node is nodejs.org's (pull_request) Successful in 21s
CI / installer (pull_request) Successful in 3m46s
CI / the relay loads in the recorded host (pull_request) Failing after 11m19s
CI / the clean-install proof removes its container (pull_request) Failing after 19m24s
78c6ed2388
terra manually merged commit 5c36f101e0 into main 2026-11-25 09:57:16 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
martha-ai/martha!170
No description provided.