Skip to content

Commit 65849e5

Browse files
Route Hermes updates through Sandwich
1 parent 80d23e0 commit 65849e5

7 files changed

Lines changed: 107 additions & 51 deletions

‎src/ulysses_hermes_control.py‎

Lines changed: 21 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -200,41 +200,31 @@ def _steps(
200200
*common_health,
201201
]
202202
if action == "update":
203-
sandwich_root = (
204-
Path(
203+
configured = os.environ.get("ULYSSES_SANDWICH_ROOT", "").strip()
204+
if configured:
205+
sandwich_root = Path(configured).expanduser().resolve()
206+
else:
207+
services_root = Path(
205208
os.environ.get("ULYSSES_MICROSERVICES_ROOT")
206209
or Path.home() / "Hermes"
207-
)
208-
/ "sandwich"
209-
).resolve()
210-
preflight = sandwich_root / "scripts" / "apply-hermes-maintenance.sh"
211-
refresh = sandwich_root / "scripts" / "refresh-hermes-artifacts.sh"
212-
if not preflight.is_file():
213-
raise RuntimeJobError("Sandwich Hermes preflight is unavailable")
214-
steps = [
215-
{
216-
"label": "Run Sandwich Hermes preflight",
217-
"argv": [str(preflight), "--check", "--allow-active"],
218-
"timeout": 120,
219-
},
210+
).expanduser()
211+
sandwich_root = (services_root / "sandwich").resolve()
212+
sandwich = sandwich_root / "bin" / "sandwich"
213+
if not sandwich.is_file():
214+
raise RuntimeJobError("Sandwich Hermes updater is unavailable")
215+
return [
220216
{
221-
"label": "Back up and update Hermes",
222-
"argv": [executable, "update", "--backup", "--yes"],
223-
"cwd": identity["source_root"],
224-
"timeout": 1800,
217+
"label": "Update pristine Hermes through Sandwich",
218+
"argv": [
219+
str(sandwich),
220+
"hermes",
221+
"update",
222+
"--backup",
223+
"--yes",
224+
],
225+
"timeout": 7200,
225226
},
226227
]
227-
if refresh.is_file():
228-
steps.append(
229-
{
230-
"label": "Refresh commit-pinned Sandwich artifacts",
231-
"argv": [str(refresh)],
232-
"environment": {"HERMES_UPSTREAM_REF": "origin/main"},
233-
"timeout": 120,
234-
"allow_failure": True,
235-
}
236-
)
237-
return [*steps, *common_health]
238228
raise RuntimeJobError(f"unsupported Hermes lifecycle action: {action}")
239229

240230
def create_lifecycle_plan(
@@ -245,7 +235,7 @@ def create_lifecycle_plan(
245235
) -> tuple[dict[str, Any], str]:
246236
if action not in ALLOWED_ACTIONS:
247237
raise RuntimeJobError("unsupported Hermes lifecycle action")
248-
if not self.adoption_status(report)["current"]:
238+
if action != "update" and not self.adoption_status(report)["current"]:
249239
raise RuntimeJobError("Hermes must be adopted before lifecycle control")
250240
label = action.capitalize()
251241
return self.jobs.create_plan(

‎src/ulysses_sandwich_control.py‎

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212

1313
class SandwichControl:
14-
ACTIONS = {"system-update", "audit", "self-update"}
14+
ACTIONS = {"hermes-update", "system-update", "audit", "self-update"}
1515

1616
def __init__(self, root: Path | None = None) -> None:
1717
from src.constants import DATA_DIR
@@ -127,6 +127,22 @@ def create_plan(
127127
]
128128
summary = "Update detected Bun projects without pulling Git"
129129
phrase = "UPDATE JAVASCRIPT SYSTEM"
130+
elif action == "hermes-update":
131+
steps = [
132+
{
133+
"label": "Update pristine Hermes through Sandwich",
134+
"argv": [
135+
str(executable),
136+
"hermes",
137+
"update",
138+
"--backup",
139+
"--yes",
140+
],
141+
"timeout": 7200,
142+
}
143+
]
144+
summary = "Back up and update official Hermes through Bun"
145+
phrase = "UPDATE HERMES WITH SANDWICH"
130146
else:
131147
source = self._diogenes_source()
132148
steps = [

‎static/js/ulyssesServices.js‎

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -625,14 +625,15 @@ function renderSandwich() {
625625
<details class="dio-dependency-files">
626626
<summary>Native commands</summary>
627627
<div class="dio-dependency-copy">
628-
<p><code>hermes update</code>Canonical Hermes update; Sandwich preserves its Bun integration internally.</p>
628+
<p><code>sandwich hermes update</code>Back up and update official Hermes through external Bun command shims. Hermes source stays pristine.</p>
629+
<p><code>sandwich hermes check</code>Verify the official checkout has no local source changes.</p>
629630
<p><code>sandwich doctor</code>Verify Bun and every Node-compatible command shim.</p>
630631
<p><code>sandwich audit</code>Report foreign JavaScript runtimes without changing them.</p>
631632
</div>
632633
</details>
633634
<div class="dio-maintenance-grid">
634-
<button type="button" data-hermes-update>
635-
<strong>Hermes update</strong><span>Run the canonical Hermes update with Sandwich preflight and backup.</span>
635+
<button type="button" data-sandwich-action="hermes-update">
636+
<strong>Hermes update</strong><span>Back up and update pristine Hermes through Sandwich.</span>
636637
</button>
637638
<button type="button" data-sandwich-action="system-update">
638639
<strong>System update</strong><span>Audit and update detected Bun projects; pull no Git repositories.</span>
@@ -1012,14 +1013,6 @@ function handleServicesClick(event) {
10121013
}
10131014
const containerLog = event.target.closest('[data-docker-container-log]');
10141015
if (containerLog) return loadDockerContainerLog(containerLog.dataset.dockerContainerLog);
1015-
const hermesUpdate = event.target.closest('[data-hermes-update]');
1016-
if (hermesUpdate) {
1017-
return executePlan(
1018-
'/api/odysseus/hermes/jobs/plan',
1019-
{ action: 'update' },
1020-
{ danger: true },
1021-
);
1022-
}
10231016
const sandwichAction = event.target.closest('[data-sandwich-action]');
10241017
if (sandwichAction) return planSandwichAction(sandwichAction.dataset.sandwichAction);
10251018
const expandOwner = event.target.closest('[data-expand-owner]');

‎tests/test_sandwich_runtime.py‎

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def _write_component(root: Path, *, version: str = "0.3.0") -> Path:
3737
executable.write_text("#!/bin/sh\n", encoding="utf-8")
3838
executable.chmod(0o755)
3939
entrypoints[command] = f"bin/{command}"
40-
maintenance = root / "scripts" / "apply-hermes-maintenance.sh"
40+
maintenance = root / "scripts" / "update-hermes.sh"
4141
maintenance.write_text("#!/bin/sh\n", encoding="utf-8")
4242
maintenance.chmod(0o755)
4343
(root / "manifest.json").write_text(
@@ -55,16 +55,19 @@ def _write_component(root: Path, *, version: str = "0.3.0") -> Path:
5555
},
5656
"hermes_check": {
5757
"argv": [
58-
"scripts/apply-hermes-maintenance.sh",
58+
"scripts/update-hermes.sh",
5959
"--check",
6060
],
6161
"mutating": False,
6262
"human_confirmation": False,
6363
},
64-
"hermes_apply": {
64+
"hermes_update": {
6565
"argv": [
66-
"scripts/apply-hermes-maintenance.sh",
67-
"--apply",
66+
"bin/sandwich",
67+
"hermes",
68+
"update",
69+
"--backup",
70+
"--yes",
6871
],
6972
"mutating": True,
7073
"human_confirmation": True,
@@ -93,7 +96,7 @@ def test_standalone_manifest_is_valid_and_mutations_are_human_gated(tmp_path):
9396

9497
assert manifest.version == "0.3.0"
9598
assert manifest.operations["hermes_check"].mutating is False
96-
assert manifest.operations["hermes_apply"].maintenance_window is True
99+
assert manifest.operations["hermes_update"].maintenance_window is True
97100
assert all(
98101
not operation.mutating or operation.human_confirmation
99102
for operation in manifest.operations.values()
@@ -130,7 +133,7 @@ def test_operation_specs_resolve_only_standalone_executables(tmp_path):
130133
/ "Hermes"
131134
/ "sandwich"
132135
/ "scripts"
133-
/ "apply-hermes-maintenance.sh"
136+
/ "update-hermes.sh"
134137
).resolve()
135138
assert executable.is_relative_to(layout.component_root)
136139
assert spec.argv[1:] == ("--check",)

‎tests/test_ulysses_hermes_control.py‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,31 @@ def test_unadopted_hermes_cannot_create_a_lifecycle_plan(tmp_path: Path) -> None
107107
control.create_lifecycle_plan(_report(tmp_path), action="restart")
108108

109109

110+
def test_unadopted_update_routes_only_to_sandwich(
111+
monkeypatch,
112+
tmp_path: Path,
113+
) -> None:
114+
sandwich_root = tmp_path / "sandwich"
115+
executable = sandwich_root / "bin" / "sandwich"
116+
executable.parent.mkdir(parents=True)
117+
executable.touch()
118+
monkeypatch.setenv("ULYSSES_SANDWICH_ROOT", str(sandwich_root))
119+
120+
plan, _token = HermesControl(tmp_path / "control").create_lifecycle_plan(
121+
_report(tmp_path),
122+
action="update",
123+
)
124+
125+
assert len(plan["steps"]) == 1
126+
assert plan["steps"][0]["argv"] == [
127+
str(executable),
128+
"hermes",
129+
"update",
130+
"--backup",
131+
"--yes",
132+
]
133+
134+
110135
def _adopt(control: HermesControl, report: dict) -> None:
111136
control.apply_adoption(
112137
report,

‎tests/test_ulysses_sandwich_control.py‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,30 @@ def test_audit_plan_targets_configured_microservices_root(
3131
"src.diogenes_javascript_maintenance",
3232
"audit",
3333
]
34+
35+
36+
def test_hermes_update_is_one_sandwich_command(
37+
monkeypatch,
38+
tmp_path: Path,
39+
) -> None:
40+
services = tmp_path / "services"
41+
monkeypatch.setenv("ULYSSES_MICROSERVICES_ROOT", str(services))
42+
executable = services / "sandwich" / "bin" / "sandwich"
43+
executable.parent.mkdir(parents=True)
44+
executable.write_text("", encoding="utf-8")
45+
control = SandwichControl(tmp_path / "state")
46+
47+
plan, _token = control.create_plan(
48+
{"ready": True, "installed_version": "0.5.0"},
49+
action="hermes-update",
50+
)
51+
52+
assert plan["confirmation_phrase"] == "UPDATE HERMES WITH SANDWICH"
53+
assert len(plan["steps"]) == 1
54+
assert plan["steps"][0]["argv"] == [
55+
str(executable),
56+
"hermes",
57+
"update",
58+
"--backup",
59+
"--yes",
60+
]

‎tests/test_ulysses_ui_identity.py‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,9 @@ def test_services_exposes_native_sandwich_lifecycle() -> None:
143143
assert 'data-sandwich-action="system-update"' in services
144144
assert 'data-sandwich-action="audit"' in services
145145
assert 'data-sandwich-action="self-update"' in services
146-
assert "Bun compatibility and host maintenance." in services
146+
assert "Bun compatibility for native project commands." in services
147+
assert "sandwich hermes update" in services
148+
assert "data-hermes-update" not in services
147149

148150

149151
def test_native_engine_source_failures_are_specific() -> None:

0 commit comments

Comments
 (0)