Use the spawn ledger rather than a last-writer stamp. Record the canonical profile home and require an exact live PID/create-time pair for warnings. Keep the default ledger policy unchanged for process reapers. Expose the advisory message through the existing status response. The desktop shows a dismissible warning on its existing refresh cadence. Do not block startup, redirect HERMES_HOME, or add a timer or lock. Verified with real subprocess ledger tests and the status API. The targeted Python run passed 27 tests. The desktop run passed 12 tests, TypeScript checking, and lint. No full suite or packaged-app test was run.
25 lines
998 B
Python
25 lines
998 B
Python
"""Advisory only: simultaneous installs share profile data, not ownership."""
|
|
from __future__ import annotations
|
|
|
|
from pathlib import Path
|
|
|
|
from hermes_cli.process_identity import install_id, ledger_entries
|
|
from hermes_constants import hermes_home_key
|
|
|
|
|
|
def shared_profile_warning(*, home: Path | None = None, project_root: Path | None = None) -> str:
|
|
"""An old stamp or a profile name alone cannot prove concurrent use."""
|
|
own_install = install_id(project_root)
|
|
home_key = hermes_home_key(home)
|
|
if any(
|
|
entry.get("install") and entry["install"] != own_install
|
|
and entry.get("hermes_home") == home_key
|
|
for entry in ledger_entries(all_installs=True, verified_only=True)
|
|
):
|
|
return (
|
|
"Another Hermes installation is using this profile. Both installations share "
|
|
"its settings and data, so changes can conflict. You can continue, or close "
|
|
"the other installation before making changes."
|
|
)
|
|
return ""
|