emrg: daemon auth credentials emrgd.port → emrgd.token — single-line token, constant port (rant 2026-08-20T14:32:52) - #884
Conversation
…line token only, port constant everywhere (rant 2026-08-20T14:32:52)
argszero
left a comment
There was a problem hiding this comment.
✅ LGTM — cycle (20260820-143548)
Reviewed the full diff (21 files, 268+/260−): emrgd.port → emrgd.token rename with single-line token only, port constant 56031 everywhere (rant 2026-08-20T14:32:52 design-final A). Core verified:
- connect.py — get_server_path → emrgd.token; connect_to_server reads .strip() single line; URL/probe use EMRGD_PORT constant.
- daemon.py — _assert_token_file() writes token only (no port); startup self-proof log + keepalive loop re-assert emrgd.token; _assert_port_file fully removed.
- _stop_all.py — stop_daemon reads single-line token, graceful shutdown via _EMRGD_PORT, cleanup unlinks .token.
- scheduler.py — G129 alert path + message reference emrgd.token.
- GUI daemon_client.js — TOKEN_FILE/HOME_TOKEN_FILE + EMRGD_PORT constant; _readPortToken returns port: EMRGD_PORT (no port read from file); isRunning probes constant; probe log shows token presence without leaking the token.
- packaging/smoke-test.sh + docs — migrated to token file + constant port.
- Tests — all port-file tests migrated; old fixed-port test became test_assert_token_file_writes_token_only asserting emrgd.port is NOT written.
Verification: pytest 987 passed + 1 skipped (incl. doc-count guard); GUI unit 64/64; GUI full 253 pass + 7 integration fails = known #861 fixed-port environmental (real daemon holds 56031), pre-existing; import + CLI OK. CI run 32341012945: test PASS + test-windows PASS. 1/3 LGTM.
argszero
left a comment
There was a problem hiding this comment.
✅ LGTM — cycle (20260820-150026) — fresh per-cycle re-review
Re-verified head d98394b (unchanged since LGTM #1): 21-file diff (268+/260−), emrgd.port → emrgd.token rename with single-line token + EMRGD_PORT constant everywhere. Spot-checked connect.py (get_server_path → emrgd.token, connect_to_server reads .strip() single line) and daemon.py _assert_token_file semantics; GUI uses TOKEN_FILE + constant port, no token leakage in probe logs; tests migrated with old .port not-written assertion. CI run 32341012945: test PASS + test-windows PASS; mergeState CLEAN. 2/3 LGTMs.
argszero
left a comment
There was a problem hiding this comment.
✅ LGTM — cycle (20260820-150958) — fresh per-cycle re-review
Re-verified head d98394b (unchanged, now MERGEABLE/CLEAN after #882 merge — the daemon.py token-rename hunks do not overlap #882's upgrade-tick changes): 21-file diff (268+/260−) emrgd.port → emrgd.token single-line token + EMRGD_PORT constant everywhere; spot-checked connect.py/daemon.py/GUI probe logging. CI: test PASS + test-windows PASS (run 32341012945). 3/3 LGTMs.
…-08-20T16:03:31) (#888) Host design-finalized: the GUI's global project_dir is useless — a session's real cwd is its project path (projectPath, P5 slice 2). Remove the concept; keep cwd semantics (real project dir per session). - config.toml [gui] project_dir: no longer read/written/validated - GUI fallback cwd fixed to os.homedir() (DEFAULT_CWD in main.js) - Settings panel: workdir tab removed (6 → 5 tabs); settings-body-workdir block deleted - Welcome page: step 2 'choose a working directory' removed - daemon_client: TOKEN_FILE/EMRGD_LOG fixed to canonical ~/.emrg/emrgd.token and ~/.emrg/emrgd.log — projectDir parameter and G129 fallback logic removed (emrgd.token is the sole canonical location since #884) - conn-manager: projectDir passthrough removed - renderer app.js: state.projectDir gone; project_dir_valid startup check gone; sessionProjectName fallback → 'home'; projectPathFor fallback → '' - dialogs/i18n/index.html: workdir inputs, tabs, step2 and keys removed - Tests: 45 daemon_client + 16 i18n + 246 unit green (7 integration fail locally by design); pytest 980 passed + 1 skipped; import + CLI OK Co-authored-by: EMRG Evolution <emrg@argszero.dev>
Summary
Rant 2026-08-20T14:32:52 (host design-final, option A): the daemon credentials file
~/.emrg/emrgd.portwas a misnomer — the port has been a constant (EMRGD_PORT = 56031, rant 2026-08-19T08:05:21 fixed-port single-instance admission) for a long time, and the file actually carried the auth token. Renamed to~/.emrg/emrgd.tokencontaining ONLY the single-line token (0o600); every connection/probe now uses the port constant.Changes
get_server_path()→emrgd.token;connect_to_server()reads single-line token (.strip(), no split); docstrings updated._assert_port_file(port)→_assert_token_file()writing token only; startup self-proof log →token_file=/token_file_written_ok=; keepalive loop re-assertsemrgd.token.stop_daemon()reads single-line token fromemrgd.token, graceful shutdown via_EMRGD_PORTconstant, cleanup unlinks.token.emrgd.token.PORT_FILE→TOKEN_FILE(emrgd.token); newEMRGD_PORT = 56031constant (sync comment with connect.py/_stop_all.py);_readPortToken()reads single-line token and returnsport: EMRGD_PORT;isRunning()probes the constant; probe logs no longer leak the token (token_file_content=present).emrgd.tokensingle-line, port hard-coded 56031.emrgd.tokensingle-line semantics (test_connect, test_atomic, test_daemon, test_scheduler, test_ws_e2e, test_daemon_manager, GUI daemon_client/conn-manager/integration); the oldtest_assert_port_file_writes_fixed_portbecametest_assert_token_file_writes_token_onlywhich also assertsemrgd.portis NOT created.No dual-file compat read (host decision: direct switch; daemon restart writes the new file). Token mechanism unchanged (per-start random, first-frame auth, compare_digest).
Verification
emrg --helpOKgrep emrgd.port— no functional references remain (only the rename-explaining docstring/assertions and historical memory records)