Appearance
Folder-backed source
"Folder-backed source" means: the runtime is loading code directly from a working directory in your repo, not from a copy under <MATRIX_HOME>/packages/.../node_modules/<name>/. This is the fastest iteration mode and the one Run in place gives you by default.
When the runtime is folder-backed
A runtime is folder-backed in any of these cases:
- You ran
matrix run .(ormx run .) inside the package directory. - You ran
matrix up <path-to-package-dir>against a Host. The resolver inhost-service/src/cli.ts:resolvePackageTargetaccepts an absolute or relative directory path; if the path exists, the Host uses that directory. - You ran
mx install <local-folder>with no copy step (see Installing → Install from local folder for the actual copy-modeinstalldoes — folder-backed is the non-install case).
Each of these uses the source dist/ directly. Edit + rebuild + restart picks up changes.
When it is not
A runtime is not folder-backed when:
- It was started by name (
matrix up @open-matrix/chat). Host Service resolves names to the package store under<MATRIX_HOME>/packages/. - The Host was installed via
hivecast install, which seeds the bundled package store. Those copies sit under<host-home>/packages/system/node_modules/and<host-home>/packages/global/node_modules/— seepackages/hivecast/bin/hivecast.mjs:205-216:seedBundledHostPackages.
Fast iteration recipe
The deployless inner loop:
bash
cd projects/matrix-3/packages/<my-pkg>
$EDITOR src/...
pnpm build
matrix run . --env dev
# Ctrl+C, edit, rebuild, restartThree things to remember:
- Always
pnpm buildbetween edits. Tests and runtime usedist/. - The embedded NATS in
.matrix/dev.environment.jsonruns in process. Killing the runner kills it. runtime.rootandruntimeIdcome from the env file, not from any Host config. There is no Host involved.
Folder-backed against an already-running Host
You can supervise a folder-backed package inside a running Host:
bash
hivecast start --home /tmp/matrix-home
matrix up /abs/path/to/projects/matrix-3/packages/<my-pkg> \
--env hivecast --home /tmp/matrix-homehost-service/src/cli.ts:145-235 builds a startSpec whose packageDir is the absolute path you passed. The Host writes a runtime record under <host-home>/runtimes/<runtimeId>.json referencing that absolute path; the runner process imports runtime.entry from there.
This is useful when:
- You want the Host's gateway (port 3100) to route to your folder- backed runtime under
/apps/<appName>/. - You want logs aggregated under
<host-home>/logs/runtimes/<runtimeId>.stdout.log. - You want
system.runtimesto know about your runtime so other packages can talk to it.
Caveats
- Build pollution. A folder-backed runtime sees what's in
dist/at startup time. Subsequent rebuilds do not auto-reload; restart the runtime. - Path stability. Don't move or rename the package directory while a Host is supervising it. The runtime record stores the absolute path; rename and restart breaks.
- Workspace dependencies.
pnpmworkspaces use symlinks undernode_modules/. Rebuilds of dependencies update the symlinkeddist/immediately, but your runtime won't see them until you restart.
See also
- Overview → Deployless lifecycle
- Local Development → Run in place
- Local Development → Installed source
- Local Development → Refresh without copying
- Installing → Install from local folder
Source:
host-service/src/cli.ts:resolvePackageTargetis the piece that decides folder-backed vs name-resolved atuptime.