<feed xmlns='http://www.w3.org/2005/Atom'>
<title>meshbay.git/packages/meshbay-node/tests/test_platform.py, branch 0.13</title>
<subtitle>MeshBay — read-only public mirror</subtitle>
<id>https://git.meshbay.org/meshbay.git/atom?h=0.13</id>
<link rel='self' href='https://git.meshbay.org/meshbay.git/atom?h=0.13'/>
<link rel='alternate' type='text/html' href='https://git.meshbay.org/meshbay.git/'/>
<updated>2026-09-08T11:54:53Z</updated>
<entry>
<title>test(node): close the eleven failures, and the order-dependence behind seven</title>
<updated>2026-09-08T11:54:53Z</updated>
<author>
<name>Christophe Besson</name>
<email>cbesson@gmail.com</email>
</author>
<published>2026-09-08T11:54:53Z</published>
<link rel='alternate' type='text/html' href='https://git.meshbay.org/meshbay.git/commit/?id=28f1b5686c7ab200aeda6782f5f6e829c24759dd'/>
<id>urn:sha1:28f1b5686c7ab200aeda6782f5f6e829c24759dd</id>
<content type='text'>
Nine of the eleven were defects in the suite, two were assertions describing
behaviour the code had deliberately changed. None was a bug in the node.

Seven had one cause. `check_media_tools()` writes two module globals;
`monkeypatch` restores what a test patched and knows nothing about what the
call under test then wrote, so a test that pointed `shutil.which` at
"/opt/bin/{n}.exe" left `_ffprobe_path` there — a Windows path, on Linux — for
the rest of the session. Every later test that actually runs ffprobe died on
FileNotFoundError, in two files about video transcoding, for a reason nowhere
near themselves. Run those files alone and they passed; that is what made it
look like an environment problem for so long.

The autouse `_restore_media_tool_paths` fixture in conftest.py puts both back
after every test. That closes the class, not just this instance: any future test
that resolves media tools is undone whether it remembers to or not, which is the
only way an order-dependent suite stops being one. Verified by removing the
call-site guard entirely and running the whole suite — green, so the fixture is
carrying it, and the call site keeps a pointer rather than a second copy of the
explanation.

The other four:

- two service tests were the only ones in test_platform.py that never set
  `sys.platform` to "win32", so they hit "service mode is Windows-only";
- test_apps_enabled_policy expected `["chat"]` where `roster.enabled_apps`
  inserts "files" at the front on read (and `ops.set_enabled_apps` on write),
  because Settings is the one way back if every app were turned off. The code
  is right; the assertion predates the guard, and is now ["files", "chat"];
- test_invite_then_join_delivers_the_gek passed a bare Path as a group's
  `roots` two lines below building a RootSet for the transport. The handshake
  died on `'PosixPath' object has no attribute 'describe'` and answered `error`
  — scaffolding that never followed the move to several named roots (draft v6,
  change 1).

1081 passed, 4 skipped, 0 failed.

Co-Authored-By: Claude Opus 5 &lt;noreply@anthropic.com&gt;
Claude-Session: https://claude.ai/code/session_01HCGdheDLxGReuKHga3BtST
</content>
</entry>
<entry>
<title>fix(node): register the service-mode task with Register-ScheduledTask -LogonType S4U</title>
<updated>2026-09-05T12:48:08Z</updated>
<author>
<name>Christophe Besson</name>
<email>cbesson@gmail.com</email>
</author>
<published>2026-09-05T12:48:08Z</published>
<link rel='alternate' type='text/html' href='https://git.meshbay.org/meshbay.git/commit/?id=c11dd22b593358ef7932deec53c8200f5f14ed8b'/>
<id>urn:sha1:c11dd22b593358ef7932deec53c8200f5f14ed8b</id>
<content type='text'>
schtasks.exe has no flag naming the logon type directly -- it only infers
S4U vs Interactive from whether /rp is present, and both readings broke
live on a blank-password account: /rp "" fails schtasks' own credential
validation, and omitting /rp registers "Interactive only", which never
launches the process at boot or on demand despite installing cleanly.

Register-ScheduledTask -LogonType S4U names the logon type explicitly, no
inference. Confirmed live: install, manual start, and unattended boot-time
start all now work.

Co-Authored-By: Claude Sonnet 5 &lt;noreply@anthropic.com&gt;
</content>
</entry>
<entry>
<title>fix(win): graceful shutdown, one startup-mode control, and a stray-\r bug</title>
<updated>2026-09-05T11:06:55Z</updated>
<author>
<name>Christophe Besson</name>
<email>cbesson@gmail.com</email>
</author>
<published>2026-09-05T11:06:55Z</published>
<link rel='alternate' type='text/html' href='https://git.meshbay.org/meshbay.git/commit/?id=e89a57bb97b5a0d624e8d490b6b8aa38ba140817'/>
<id>urn:sha1:e89a57bb97b5a0d624e8d490b6b8aa38ba140817</id>
<content type='text'>
Windows-only changes, all found by actually running the previous session's
work rather than by review alone:

- CTRL_CLOSE_EVENT/LOGOFF/SHUTDOWN handler (platform.py, ctypes
  SetConsoleCtrlHandler) so closing a console window, signing off, or a
  system shutdown runs the daemon's real _shutdown() instead of Windows
  just ending the process — closing WebRTC sessions and any in-flight
  ffmpeg transcode instead of orphaning it. `taskkill /F` itself stays
  uncatchable (like SIGKILL), so autostart_run() now spawns with
  CREATE_NEW_PROCESS_GROUP instead of DETACHED_PROCESS and autostart_end()
  tries CTRL_BREAK_EVENT against the recorded pid first, falling back to
  the hard kill only if that doesn't stop it in time.

- Replaced the Node page's two independent autostart/service-mode toggles
  with one "start automatically" select (off / at sign-in / as a
  background service). The old pair let both be active at once — starting
  the daemon twice, at boot and at sign-in — and their layout broke
  wrapping inside .node-service's flex row. The new control always removes
  whichever mechanism is active before installing the target; platform.py's
  service_install() does the same on the CLI side. The "background
  service" option disables itself (with a hint pointing at the CLI) when
  running unpackaged, since service-mode.ps1/service.ps1/firewall.ps1 all
  assume an installed build's layout — verified live rather than assumed
  by actually running those scripts unelevated.

- findNodeBinary() no longer bakes a stray \r into resolved paths. Found by
  rebooting after enabling per-user autostart: where.exe listed two
  matches, and stdout.trim().split('\n')[0] only strips the whole string's
  ends, leaving line one's own trailing \r attached — which landed inside
  the Startup .vbs's quoted path and broke it with "Unterminated string
  constant" at boot. Fixed by splitting on \r?\n and trimming every line.

- Dependency audit for the Windows installer (docs/WINDOWS-PORT.md): no
  VC++ Redistributable needed, confirmed by inspecting the built
  node-runtime's actual import table rather than assuming. New
  docs/windows-build.md: a concise clone-to-installer build guide.

Co-Authored-By: Claude Sonnet 5 &lt;noreply@anthropic.com&gt;
</content>
</entry>
<entry>
<title>fix(packaging): actually ship the TMDB token, on Linux and Windows</title>
<updated>2026-09-04T12:33:33Z</updated>
<author>
<name>Christophe Besson</name>
<email>cbesson@gmail.com</email>
</author>
<published>2026-09-04T12:33:33Z</published>
<link rel='alternate' type='text/html' href='https://git.meshbay.org/meshbay.git/commit/?id=c2eade6db582966fa7fc3dd037f952baf3ae1cb5'/>
<id>urn:sha1:c2eade6db582966fa7fc3dd037f952baf3ae1cb5</id>
<content type='text'>
default.env was empty in every build, for three independent reasons:

1. build-node.sh read QE/node.env, which does not exist. Even pointed at the
   real file it would have failed: its `grep MESHBAY_TMDB_DEFAULT_TOKEN=`
   cannot match QE/tmdb.txt, which is a free-form note, not KEY=VALUE.

2. Nothing consumed default.env. packaging/README.md and build-node.sh both
   claimed `meshbay-node init` copies it to &lt;config&gt;/node.env; grep found the
   name in exactly two places, the README and the script that writes it. No
   code implemented the copy, and `EnvironmentFile=-` hid the absence.

3. build-win.ps1 had no env handling at all, so Windows was empty for a
   different reason than Linux.

Now: the build extracts the v4 read token -- tmdb.py sends `Authorization:
Bearer`, so it is the JWT, not the 32-char v3 key beside it in the same file --
matching KEY=VALUE first and then by shape, from MESHBAY_TMDB_TOKEN,
MESHBAY_TMDB_TOKEN_FILE, QE/node.env, QE/tmdb.txt. It writes default.env 0600
and *fails the build* if no token resolves; MESHBAY_ALLOW_NO_TMDB=1 opts out.
An empty default.env is invisible until a user opens Videos and finds no
metadata, which is how this shipped empty on two platforms at once.

platform.py gains packaged_default_env()/install_node_env()/load_node_env().
init copies the packaged file once, never overwriting an existing node.env,
and the daemon loads node.env itself at startup: systemd does this on Linux
via EnvironmentFile, but Windows autostart is a Startup-folder .vbs with no
equivalent. Already-set variables always win.

Also fixes an UnboundLocalError in main(): `config_dir` was assigned at the
top of the init branch, which made it function-local for all of main(), while
the reset branch calls `config_dir()` as the imported function. init returns
before that line, so `meshbay-node reset` could only ever raise. The local is
now cfg_dir.

Verified end to end on Linux: token baked (239 chars), init writes
&lt;config&gt;/node.env 0600 with it. The PowerShell half is written but unrun --
no pwsh on this machine.

Co-Authored-By: Claude Opus 5 &lt;noreply@anthropic.com&gt;
Claude-Session: https://claude.ai/code/session_01DtfG7z6wHWj8RKHCvxQtY1
</content>
</entry>
<entry>
<title>feat: Windows daemon lifecycle (W3) — Startup-folder autostart</title>
<updated>2026-09-04T01:58:16Z</updated>
<author>
<name>Christophe Besson</name>
<email>cbesson@gmail.com</email>
</author>
<published>2026-09-04T01:58:16Z</published>
<link rel='alternate' type='text/html' href='https://git.meshbay.org/meshbay.git/commit/?id=220e6e701806213a576ce80fa655cd9cf4a51880'/>
<id>urn:sha1:220e6e701806213a576ce80fa655cd9cf4a51880</id>
<content type='text'>
The Linux node runs under `systemctl --user`. Windows has no per-user
equivalent that works without elevation: `schtasks /create /sc ONLOGON`
(even `/rl LIMITED /it`) fails with "Access is denied" for a non-admin
user, because a logon trigger touches machine-wide scheduler state.

So autostart is a `.vbs` in the per-user Startup folder instead:

    CreateObject("WScript.Shell").Run Chr(34) &amp; "&lt;exe&gt;" &amp; Chr(34), 0, False

wscript runs it at every sign-in, hidden (0) and non-blocking. No admin,
no console window, no new dependency. Verified end to end: the launcher
brings the daemon up with no window and it answers its loopback API.

node/platform.py
  autostart_install/remove/status  — write / delete / detect the launcher
  autostart_run/end                — start now (DETACHED|NO_WINDOW) / taskkill
  _node_exe                        — PATH, then next to sys.executable, then argv[0]

node/daemon.py
  new `autostart install|remove|start|stop|status` verb
  reload (win32)         -&gt; POST /api/reload on the loopback API
  restart-daemon (win32) -&gt; autostart_end + autostart_run
  reset (win32)          -&gt; also removes the launcher

client/main.js, preload.js
  node:autostart handler + winAutostart* helpers (kept in step with platform.py)
  node:service-status (win32) probes the daemon; stop/restart/start use
  taskkill + a detached, windowless spawn

Tests: 8 autostart cases in test_platform.py (mocked sys.platform, APPDATA
pointed at tmp); `autostart status` added to the CLI dispatch sweep. Full
meshbay-node suite green on Windows (784 passed / 34 skipped).

Still open: no CTRL_CLOSE_EVENT handler, so a bare taskkill / window close
does not run _shutdown() (SetConsoleCtrlHandler, follow-up). Service mode
(pywin32/NSSM) stays Phase 2.

Co-Authored-By: Claude Sonnet 5 &lt;noreply@anthropic.com&gt;
</content>
</entry>
<entry>
<title>fix(node): run on the default Windows event loop (Proactor)</title>
<updated>2026-09-04T01:23:10Z</updated>
<author>
<name>Christophe Besson</name>
<email>cbesson@gmail.com</email>
</author>
<published>2026-09-04T01:23:10Z</published>
<link rel='alternate' type='text/html' href='https://git.meshbay.org/meshbay.git/commit/?id=5098e6cb54173b27673f5761ce187d799ba36b30'/>
<id>urn:sha1:5098e6cb54173b27673f5761ce187d799ba36b30</id>
<content type='text'>
Verified end to end: a live browser peer on Windows connecting to a Windows
node — handshake, index sync, file download and an ffmpeg-transcoded video
stream all work on the ProactorEventLoop. aiortc only hangs on it in the
same-process loopback the tests use, which the repo-root conftest already
handles for the suite.

So the daemon no longer forces the SelectorEventLoop: that fixed
aiortc-in-one-process but broke ffmpeg (no subprocess support on a Windows
SelectorEventLoop). `use_compatible_event_loop()` becomes
`configure_event_loop()` — a no-op unless MESHBAY_NODE_EVENT_LOOP=selector
is set explicitly, as an escape hatch that probably never needs pulling.

This drops the planned "move ffmpeg off the asyncio loop" work.

Co-Authored-By: Claude Sonnet 5 &lt;noreply@anthropic.com&gt;
</content>
</entry>
<entry>
<title>test(node): make the suite pass on Windows</title>
<updated>2026-09-04T00:20:57Z</updated>
<author>
<name>Christophe Besson</name>
<email>cbesson@gmail.com</email>
</author>
<published>2026-09-04T00:20:57Z</published>
<link rel='alternate' type='text/html' href='https://git.meshbay.org/meshbay.git/commit/?id=d11e571c5b6c24b586ef5b8fb2cfcf6a6bfa6d6d'/>
<id>urn:sha1:d11e571c5b6c24b586ef5b8fb2cfcf6a6bfa6d6d</id>
<content type='text'>
- `.read_text()` on source files now `encoding="utf-8"` — cp1252 chokes on
  the em dashes / box-drawing chars those files contain.
- test node.toml templates embed paths via `Path.as_posix()`: a raw Windows
  path in a basic TOML string is a parse error (`\U`, `\a`, ... are escapes).
- new `test_platform.py` covers `meshbay_node.platform` by mocking
  `sys.platform` / `os.environ` — runs on both OSes.
- `skipif(sys.platform == "win32")`, in `conftest.needs_subprocess` and
  inline, for the documented gaps: ffmpeg/ffprobe via asyncio subprocess
  (the win32 selector loop, forced for aiortc, cannot spawn one), the
  systemd `reload`/`restart-daemon` delegation (Windows path is W3), the
  keystore `st_mode == 600` assertion (NTFS ignores mode bits), and the
  symlink-escape test (needs Developer Mode).

Windows: 781 passed, 25 skipped. No change on Linux.

Co-Authored-By: Claude Sonnet 5 &lt;noreply@anthropic.com&gt;
</content>
</entry>
</feed>
