Skip to content

The agent that grows with you

fix: reconcile the cutover with main after the merge

teknium1111ee7249e61
diff --git a/hermes_cli/config.py b/hermes_cli/config.py
index e64f249bca9..75d17e765bd 100644
--- a/hermes_cli/config.py
+++ b/hermes_cli/config.py
@@ -2371,6 +2371,12 @@ def load_env() -> Dict[str, str]:
"""Load ~/.hermes/.env as a dict (memoised; ``get_env_value()`` runs hundreds of times per
interactive menu render). Each assignment's value is opaque data for boundary discovery."""
global _env_cache
+ from agent.safe_worker_policy import worker_config_snapshot
+
+ # A frozen-policy worker never opens the profile's files; its secrets arrive
+ # through the owner-installed scope, so the .env layer is empty here.
+ if worker_config_snapshot() is not None:
+ return {}
env_path = get_env_path()
try:
diff --git a/hermes_cli/config_effective.py b/hermes_cli/config_effective.py
index d37d82d0a0f..9534faf8ee2 100644
--- a/hermes_cli/config_effective.py
+++ b/hermes_cli/config_effective.py
@@ -59,6 +59,13 @@ def load_user_config_effective(config_path: Optional[Path] = None, *, fail_close
the newest ``backups/config/*.good.*`` copy — is served through the same pipeline, so a
mid-edit torn write never silently drops user overrides (same contract as ``load_config``).
Cached on the user + managed file signatures and the values of every referenced env var."""
+ from agent.safe_worker_policy import worker_config_snapshot
+
+ # A frozen-policy worker is detached from the profile's files: the owner-supplied
+ # snapshot IS the user layer (same seam load_config / read_raw_config honour).
+ snapshot = worker_config_snapshot()
+ if snapshot is not None:
+ return _effective(snapshot)
if config_path is None:
config_path = _config.get_config_path()
path_key = str(config_path)
diff --git a/hermes_state_local_lineage.py b/hermes_state_local_lineage.py
index 8437408336c..1da8155e03b 100644
--- a/hermes_state_local_lineage.py
+++ b/hermes_state_local_lineage.py
@@ -101,8 +101,8 @@ def reset_local_target(db, *, epoch, parent_session_id, entry):
logical_id = receipt['session_id']
if validate_local_lineage(conn, receipt) != parent_session_id:
raise RuntimeStoreError('admission_conflict')
- from hermes_state_mutation_guards import require_idle
- require_idle(db, conn, list({logical_id, parent_session_id}))
+ from hermes_state_mutation_guards import require_not_executing
+ require_not_executing(conn, list({logical_id, parent_session_id}))
policy = receipt['policy']
db._publish_child_session_row(conn, parent, parent_session_id=parent_session_id,
child_session_id=entry['session_id'], source=policy['source'], model=policy['model'],
diff --git a/hermes_state_mutation_guards.py b/hermes_state_mutation_guards.py
index 72184404b98..a7888a7a3c5 100644
--- a/hermes_state_mutation_guards.py
+++ b/hermes_state_mutation_guards.py
@@ -3,6 +3,20 @@ from hermes_state_common import _ENDED_ROW_SQL, _ended_by_compression
from hermes_state_runtime import RuntimeStoreError
+def require_not_executing(conn, session_ids):
+ """Refuse while a turn is running (or its outcome is unknown) on any of ``session_ids``.
+ Queued admissions are allowed: a follower waits on the logical owner and simply runs
+ against whatever physical target the mutation publishes."""
+ for sid in session_ids:
+ admissions = conn.execute("SELECT status FROM session_admissions WHERE target_session_id=? AND status IN ('started','unknown')", (sid,)).fetchall()
+ workers = conn.execute("SELECT status FROM worker_executions WHERE session_id=? AND status IN ('started','unknown')", (sid,)).fetchall()
+ states = {row[0] for row in [*admissions, *workers]}
+ if 'unknown' in states:
+ raise RuntimeStoreError('unknown_execution')
+ if states:
+ raise RuntimeStoreError('session_busy')
+
+
def require_idle(db, conn, session_ids):
for sid in session_ids:
admissions = conn.execute("SELECT status FROM session_admissions WHERE target_session_id=? AND status!='terminal'", (sid,)).fetchall()
diff --git a/tests/cron/test_scheduler.py b/tests/cron/test_scheduler.py
index 60ddcee3a9a..5040c1c3227 100644
--- a/tests/cron/test_scheduler.py
+++ b/tests/cron/test_scheduler.py
@@ -1139,8 +1139,12 @@ class TestRunJobConfigLogging:
with caplog.at_level(logging.WARNING):
_run_owned_job(job, tmp_path)
- assert any("Failed to parse" in r.message and "config.yaml" in r.message for r in caplog.records), \
- f"Expected a config.yaml parse warning in logs, got: {[r.message for r in caplog.records]}"
+ # The owner bridge fails closed on a corrupt config before load_config()'s
+ # fallback warning; either message names the file and the parse error.
+ assert any(
+ ("Failed to parse" in r.message or "is invalid" in r.message) and "config.yaml" in r.message
+ for r in caplog.records
+ ), f"Expected a config.yaml parse warning in logs, got: {[r.message for r in caplog.records]}"
class TestRunJobConfigEnvVarExpansion:
diff --git a/tests/gateway/fixtures/authority_controls_peer.py b/tests/gateway/fixtures/authority_controls_peer.py
index b5255019b91..9b603ba33ed 100644
--- a/tests/gateway/fixtures/authority_controls_peer.py
+++ b/tests/gateway/fixtures/authority_controls_peer.py
@@ -75,7 +75,7 @@ async def probe(peer, target):
pass
async def get_chat_info(self, chat_id):
return {'id': chat_id}
- async def send_exec_approval(self, **kwargs):
+ async def _send_exec_approval_prompt(self, prompt):
self.card.set()
return SendResult(success=True, message_id='card')
diff --git a/tests/gateway/test_shared_session_controls.py b/tests/gateway/test_shared_session_controls.py
index b8048b21775..c2689bb7b00 100644
--- a/tests/gateway/test_shared_session_controls.py
+++ b/tests/gateway/test_shared_session_controls.py
@@ -11,7 +11,7 @@ def test_shared_approval_outlives_viewer_and_bypasses_fifo(tmp_path):
home, state = tmp_path / 'home', tmp_path / 'state'
home.mkdir()
state.mkdir()
- env = {k: os.environ[k] for k in ('PATH', 'SYSTEMROOT', 'LANG', 'TZ') if k in os.environ}
+ env = {k: os.environ[k] for k in ('PATH', 'SYSTEMROOT', 'LANG', 'TZ', 'TIRITH_ENABLED') if k in os.environ}
env.update(HOME=str(home), USERPROFILE=str(home), HERMES_HOME=str(state), PYTHONPATH=str(repo))
result = subprocess.run([sys.executable, str(Path(__file__).parent / 'fixtures' / 'authority_controls_peer.py')],
cwd=repo, env=env, stdin=subprocess.DEVNULL, capture_output=True, text=True, timeout=100)
diff --git a/tests/gateway/test_worker_compression_admission.py b/tests/gateway/test_worker_compression_admission.py
index 254f27dc8be..2502ffe662a 100644
--- a/tests/gateway/test_worker_compression_admission.py
+++ b/tests/gateway/test_worker_compression_admission.py
@@ -140,7 +140,9 @@ def test_automatic_worker_rotation_retains_retry_identity_and_fifo(tmp_path, end
await asyncio.to_thread(owner.wait, 10)
return
peer.release.set()
- async with asyncio.timeout(45):
+ # Follower turn = a fresh worker process + one inference; on a loaded runner
+ # (40 parallel test files) that has taken >45 s.
+ async with asyncio.timeout(120):
while rows("SELECT status FROM session_admissions WHERE request_id='follower'")[0]['status'] != 'terminal':
await asyncio.sleep(.03)
assert rows("SELECT status FROM session_admissions WHERE status!='terminal'") == []
diff --git a/tests/hermes_state/test_delegate_cascade.py b/tests/hermes_state/test_delegate_cascade.py
index 211a3061b1a..20e3dd2fd41 100644
--- a/tests/hermes_state/test_delegate_cascade.py
+++ b/tests/hermes_state/test_delegate_cascade.py
@@ -11,30 +11,30 @@ the deletion set, permanently deleting the parent session and its messages.
import json
import sqlite3
+from hermes_state_schema import reconcile_state_schema
from hermes_state_sessions import _collect_delegate_child_ids, _delete_delegate_children
def _make_conn():
+ # The real schema: deleting a session first retires its admission/worker
+ # ledger rows, so the cascade needs those tables to exist.
conn = sqlite3.connect(":memory:")
conn.row_factory = sqlite3.Row
- conn.execute(
- "CREATE TABLE sessions ("
- " id TEXT PRIMARY KEY,"
- " parent_session_id TEXT,"
- " model_config TEXT)"
- )
- conn.execute("CREATE TABLE messages (session_id TEXT)")
+ reconcile_state_schema(conn)
return conn
def _add_session(conn, sid, *, delegate_from=None, parent_session_id=None, messages=0):
model_config = json.dumps({"_delegate_from": delegate_from}) if delegate_from else None
conn.execute(
- "INSERT INTO sessions (id, parent_session_id, model_config) VALUES (?, ?, ?)",
+ "INSERT INTO sessions (id, source, started_at, parent_session_id, model_config)"
+ " VALUES (?, 'cli', 0, ?, ?)",
(sid, parent_session_id, model_config),
)
for _ in range(messages):
- conn.execute("INSERT INTO messages (session_id) VALUES (?)", (sid,))
+ conn.execute(
+ "INSERT INTO messages (session_id, role, content, timestamp) VALUES (?, 'user', 'x', 0)", (sid,)
+ )
class TestCollectDelegateChildIds: