Skip to content

emrg: daemon auth credentials emrgd.port → emrgd.token — single-line token, constant port (rant 2026-08-20T14:32:52) - #884

Merged
argszero merged 1 commit into
masterfrom
feature/emrgd-token-file
Aug 20, 2026
Merged

emrg: daemon auth credentials emrgd.port → emrgd.token — single-line token, constant port (rant 2026-08-20T14:32:52)#884
argszero merged 1 commit into
masterfrom
feature/emrgd-token-file

Conversation

@argszero

Copy link
Copy Markdown
Owner

Summary

Rant 2026-08-20T14:32:52 (host design-final, option A): the daemon credentials file ~/.emrg/emrgd.port was 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.token containing ONLY the single-line token (0o600); every connection/probe now uses the port constant.

Changes

  • emrg/connect.pyget_server_path()emrgd.token; connect_to_server() reads single-line token (.strip(), no split); docstrings updated.
  • emrg/server/daemon.py_assert_port_file(port)_assert_token_file() writing token only; startup self-proof log → token_file=/token_file_written_ok=; keepalive loop re-asserts emrgd.token.
  • emrg/_stop_all.pystop_daemon() reads single-line token from emrgd.token, graceful shutdown via _EMRGD_PORT constant, cleanup unlinks .token.
  • emrg/server/scheduler.py — G129 connect-failure alert checks/mentions emrgd.token.
  • emrg/server/atomic.py — doc comment updated.
  • emrg/gui/daemon_client.jsPORT_FILETOKEN_FILE (emrgd.token); new EMRGD_PORT = 56031 constant (sync comment with connect.py/_stop_all.py); _readPortToken() reads single-line token and returns port: EMRGD_PORT; isRunning() probes the constant; probe logs no longer leak the token (token_file_content=present).
  • packaging/smoke-test.sh — reads emrgd.token single-line, port hard-coded 56031.
  • Docs — Agent.md, DEVELOPMENT.md updated.
  • Tests — all port-file tests migrated to emrgd.token single-line semantics (test_connect, test_atomic, test_daemon, test_scheduler, test_ws_e2e, test_daemon_manager, GUI daemon_client/conn-manager/integration); the old test_assert_port_file_writes_fixed_port became test_assert_token_file_writes_token_only which also asserts emrgd.port is 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

  • pytest: 987 passed + 1 skipped (incl. doc-count guard; touched-file subset 293 passed)
  • GUI unit tests (daemon_client + conn-manager): 64/64 pass
  • GUI full: 253 pass + 7 fail — the 7 fails are integration.test.js spawning a second real daemon, blocked by fixed-port admission (emrg: daemon single-instance via fixed-port bind exclusivity (rant 2026-08-19T08:05:21) #861, pre-existing local-environment limitation, unchanged)
  • import + emrg --help OK
  • grep emrgd.port — no functional references remain (only the rename-explaining docstring/assertions and historical memory records)

…line token only, port constant everywhere (rant 2026-08-20T14:32:52)

@argszero argszero left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ 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 argszero left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ 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 argszero left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ 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.

@argszero
argszero merged commit 6edae26 into master Aug 20, 2026
2 checks passed
@argszero
argszero deleted the feature/emrgd-token-file branch August 20, 2026 07:12
argszero added a commit that referenced this pull request Aug 20, 2026
#885)

Co-authored-by: EMRG Evolution <emrg@argszero.dev>
argszero added a commit that referenced this pull request Aug 20, 2026
…-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>
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