Skip to content

Continue: per-installation passphrase + MCP lifecycle (Windows CI fix) - #27

Merged
foursecondfivefour merged 5 commits into
mainfrom
arena/4a0d0e04-nerveforge
Dec 4, 2026
Merged

foursecondfivefour merged 5 commits into
mainfrom
arena/4a0d0e04-nerveforge

Conversation

@foursecondfivefour

Copy link
Copy Markdown
Owner

Continuation of PR #26

The previous agent implemented the per-installation passphrase (8.11.0) and the
MCP lifecycle that survives being used (8.12.0), then ran out of limits with the
Windows unit-test job still red.

This branch is branched from the same commit as arena/36a4d756-nerveforge
(7cc11bb, "Make the lifecycle tests mean the same thing on Windows"), so it
carries the full feature set. The only change here is the last failing check.

What changed

  • tests/test_phrase_store.py::test_the_file_is_private now uses
    @unittest.skipIf(os.name == "nt", "POSIX file modes do not exist on Windows").

    The test asserts the stored passphrase file is mode 0600. Windows does not
    honor POSIX permission bits (os.chmod(0o600) leaves the file readable as
    0666), so the assertion can never hold there. The identical situation for the
    MCP backup file is already handled with the same skipIf guard in
    tests/test_mcp_lifecycle.py, and every other 0600 assertion in the suite is
    already Windows-guarded. This one was simply missed.

Verification

  • Linux: python -m unittest discover -s tests -> Ran 2030 tests ... OK.
  • scripts/gen_api_doc.py --check, scripts/bump_version.py --check,
    scripts/check_docs.py all pass.
  • CI should now be green on all three jobs (linux 3.10 / 3.12, windows, image):
    the linux and image jobs already passed; the Windows job failed solely on the
    one skipped test above.

Supersedes the failing PR #26 (same content, now with the CI fix).

foursecondfivefour and others added 5 commits December 4, 2026 08:33
It was a constant of the build: every installation shared it, the repository
published it, and 8.9.0 had to fight the public endpoint that handed it out.
Moving it out of the public answer fixed the leak without fixing the shape of the
problem — a value nobody chose and everybody knows is a ritual, not a second step.

It now belongs to the installation. Generated on first run from a word list (three
words and a number, because the operator reads it off a terminal and retypes it on
a phone), stored in <config>/phrase at 0600 next to the token, and replaced through
POST /api/full-access/passphrase or the panel.

That route needs the bearer token *and* the current value. The token is the thing
a plugin, a log line or a screenshot leaks; rotating the second credential is
exactly what a leaked token must not authorise by itself. A successful change
disarms full access and the old value dies at once.

Details with reasons:
- writes go through a temporary file, so a crash mid-write leaves the previous
  value readable instead of locking the operator out;
- 'yesiknow' is accepted once (an upgrade must not lock out a running server) and
  refused as a new value forever (re-adopting it recreates the 8.9.0 problem);
- the mismatch error no longer repeats the value — it used to put the passphrase
  in a response body, a log line and a screenshot.

The terminal banner prints it now: the banner in tunnel/cli.py is what a person
actually sees, and it did not know about the phrase at all.

Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
The lifecycle existed; the properties around it did not. An update replaced the
entry wholesale, so every update reset created_at and dropped the catalogue
preset, and nothing said so. A delete was final — one click, no copy, no way
back — in a file a person can only fix by hand. And a broken entry only announced
itself by spawning a child that printed nothing and died.

What is there now:

- POST /api/mcp/update keeps identity (created_at, preset) because an update must
  not make a two-month-old server look new, reports what changed, closes the
  running session so the next call is answered by the new configuration, and
  refuses an unknown id instead of quietly creating one.
- Every update and delete writes the previous version to <id>.prev.json first,
  and POST /api/mcp/rollback puts it back. Deletion is one request away from
  undone, which is the right direction for a hand-edited file.
- GET /api/mcp/health checks each entry and each preset before anything is
  spawned: a bare name is looked up in PATH, an absolute path must exist, and the
  failure names the fix ("install Node") rather than the symptom. It never
  touches the network, so the panel calls it on mount.
- Deleting the last server deletes servers.json. The first thing anyone checks
  after an uninstall is whether the files are gone; an empty config file is the
  opposite of a clean answer.

Two bugs were found by writing the checks rather than by reading the code:
probe() reported an empty command for every pip-installed preset, so the panel
could not say how Serena starts and the health check called a working preset "no
command"; and removing the last server left an empty servers.json behind for
good.

The CI step runs a full install-update-rollback-delete cycle four times and fails
if the install ends up with a file it did not have.

Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
The route table knew DELETE and the generated API reference documented removing a
server, but BaseJsonHandler had no do_DELETE: BaseHTTPRequestHandler answered
every real request with an HTML 501. Found by calling the route from a live
server rather than by reading the table - which is the whole point, since a
missing do_* is invisible from the table and from the docs.

Also corrects the delete path the panel and the READMEs used: the route lives at
/api/mcp/delete, not /api/mcp.

Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
The Windows job failed on the new tests, and every reason was a Unix assumption
written by someone testing on Unix:

- os.kill(pid, 0) is a permission probe on POSIX and a *termination* on Windows.
  The check for a child that outlived its config now asks tasklist there.
- 0o600 on a file is not a Windows concept; the mode assertion is skipped, and
  the registry still calls secure_chmod, which is a no-op on nt by design.
- 'python3' and 'sh' do not exist on Windows. The tests now name sys.executable
  and ask PATH for the interpreter that is running them.
- A command string is split the way a shell would split it; C:\Program Files
  does not survive that. The process test passes argv as a list, which is how the
  registry stores it anyway.
- The route tests invented their own BadRequest/NotFound by patching module
  globals. They now import the real ones, which is also what _dispatch sees.

The CI gains a Windows step that asks the library where the config lives
(%APPDATA% there, not ~/.config) and asserts the stored phrase is generated and
not the compiled default.

Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
…onvention

The Windows CI job failed on tests/test_phrase_store.py::test_the_file_is_private,
which asserts the stored passphrase file is mode 0600. Windows does not honor
POSIX permission bits (os.chmod(0o600) leaves the file readable as 0666), so the
assertion can never hold there. The same fact is already handled for the MCP
backup test via a skipIf(os.name == "nt", ...) guard; do the same here so the
Windows unit-test job turns green.

This is the last failing check on PR #26's CI: linux (3.10/3.12) and the image
build already pass, and every other 0600 assertion in the suite is already
Windows-guarded.

Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
@foursecondfivefour
foursecondfivefour merged commit c179630 into main Dec 4, 2026
4 checks passed
foursecondfivefour added a commit that referenced this pull request Dec 4, 2026
Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant