feat(hermes): link the pull request straight into the Hermes run
All checks were successful
Tests / Declarative: Post Actions passed: 1378
All checks were successful
Tests / Declarative: Post Actions passed: 1378
A run id in a pull request is a string to copy; a link is a page to open. The console reopens a finished run at /chat?resume=<id> - the prompt Hermes was given, the evidence bundle it read, the skill it invoked, and the JSON it returned, all on one page. That page is the whole answer to "who decided this". Making the reviewer reconstruct the URL from a bare id is the difference between evidence someone looks at and evidence someone takes on trust. run_url is shared rather than formatted at each call site, so the pull request and the demo monitor cannot drift into pointing at different pages. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
parent
ca5b22b977
commit
fe794b8ffe
@ -23,6 +23,8 @@ _REPAIR_BRANCH_PREFIX = "hermes-repair/"
|
|||||||
_OPEN_PULLS_LIMIT = 50
|
_OPEN_PULLS_LIMIT = 50
|
||||||
_COMMIT_IDENTITY = {"name": "Hermes Agent", "email": "hermes@bstein.dev"}
|
_COMMIT_IDENTITY = {"name": "Hermes Agent", "email": "hermes@bstein.dev"}
|
||||||
_COMMIT_OK_STATUSES = {HTTP_OK, HTTP_CREATED}
|
_COMMIT_OK_STATUSES = {HTTP_OK, HTTP_CREATED}
|
||||||
|
# The Hermes console reopens a finished run from its id at this route.
|
||||||
|
RUN_PATH = "/chat?resume="
|
||||||
_BRANCH_RETRY_STATUSES = {HTTP_NOT_FOUND, HTTP_UNPROCESSABLE}
|
_BRANCH_RETRY_STATUSES = {HTTP_NOT_FOUND, HTTP_UNPROCESSABLE}
|
||||||
_BRANCH_UNSAFE = re.compile(r"[^A-Za-z0-9._-]+")
|
_BRANCH_UNSAFE = re.compile(r"[^A-Za-z0-9._-]+")
|
||||||
|
|
||||||
@ -256,6 +258,19 @@ def _pr_result(response: Any) -> dict[str, Any]:
|
|||||||
return {"pr_number": number, "url": url, "error": None}
|
return {"pr_number": number, "url": url, "error": None}
|
||||||
|
|
||||||
|
|
||||||
|
def run_url(ui_url: str, run_id: str) -> str:
|
||||||
|
"""Build the deep link that reopens one Hermes run in its console.
|
||||||
|
|
||||||
|
Inputs: the Hermes UI base url and a run id. Outputs: the resume link, or
|
||||||
|
"" when either is missing. Kept here so the pull request and the demo
|
||||||
|
monitor cannot drift into pointing at different pages.
|
||||||
|
"""
|
||||||
|
|
||||||
|
base = str(ui_url or "").rstrip("/")
|
||||||
|
run = str(run_id or "").strip()
|
||||||
|
return f"{base}{RUN_PATH}{run}" if base and run else ""
|
||||||
|
|
||||||
|
|
||||||
def _pr_body(incident_id: str, patch: Any, analysis: str, run_id: str, cfg: dict) -> str:
|
def _pr_body(incident_id: str, patch: Any, analysis: str, run_id: str, cfg: dict) -> str:
|
||||||
"""Render the markdown pull-request body for human review.
|
"""Render the markdown pull-request body for human review.
|
||||||
|
|
||||||
@ -275,12 +290,15 @@ def _pr_body(incident_id: str, patch: Any, analysis: str, run_id: str, cfg: dict
|
|||||||
f"**Rationale:** {patch.rationale}",
|
f"**Rationale:** {patch.rationale}",
|
||||||
]
|
]
|
||||||
if run_id:
|
if run_id:
|
||||||
lines.append(f"**Hermes run:** `{run_id}`")
|
|
||||||
ui_url = str(cfg.get("hermes_ui_url") or "").rstrip("/")
|
ui_url = str(cfg.get("hermes_ui_url") or "").rstrip("/")
|
||||||
if ui_url:
|
if ui_url:
|
||||||
|
lines.append(f"**Hermes run:** [{run_id}]({run_url(ui_url, run_id)})")
|
||||||
lines.append(
|
lines.append(
|
||||||
f"The prompt this run was given and every tool call it made are at {ui_url}."
|
"That link opens the run itself: the prompt Hermes was given, the evidence "
|
||||||
|
"bundle it read, the tools it called, and the JSON it returned."
|
||||||
)
|
)
|
||||||
|
else:
|
||||||
|
lines.append(f"**Hermes run:** `{run_id}`")
|
||||||
lines += [
|
lines += [
|
||||||
"",
|
"",
|
||||||
"Proposed by Hermes; validated and pushed by Ariadne; "
|
"Proposed by Hermes; validated and pushed by Ariadne; "
|
||||||
|
|||||||
@ -363,9 +363,11 @@ def test_the_pull_request_names_the_hermes_run(monkeypatch) -> None:
|
|||||||
)
|
)
|
||||||
|
|
||||||
body = calls["requests"][0][2]["json"]["body"]
|
body = calls["requests"][0][2]["json"]["body"]
|
||||||
assert "**Hermes run:** `run_a5af87af`" in body
|
assert (
|
||||||
assert "https://agent.bstein.dev." in body
|
"**Hermes run:** [run_a5af87af]"
|
||||||
assert "every tool call it made" in body
|
"(https://agent.bstein.dev/chat?resume=run_a5af87af)"
|
||||||
|
) in body
|
||||||
|
assert "the tools it called" in body
|
||||||
|
|
||||||
|
|
||||||
def test_the_pull_request_omits_the_link_when_no_ui_is_configured(monkeypatch) -> None:
|
def test_the_pull_request_omits_the_link_when_no_ui_is_configured(monkeypatch) -> None:
|
||||||
@ -386,3 +388,13 @@ def test_the_pull_request_stays_readable_without_a_run_id(monkeypatch) -> None:
|
|||||||
body = calls["requests"][0][2]["json"]["body"]
|
body = calls["requests"][0][2]["json"]["body"]
|
||||||
assert "Hermes run" not in body
|
assert "Hermes run" not in body
|
||||||
assert "requires human review" in body
|
assert "requires human review" in body
|
||||||
|
|
||||||
|
|
||||||
|
def test_the_run_link_reopens_the_run_in_the_hermes_console() -> None:
|
||||||
|
"""One helper, so the pull request and the demo monitor cannot diverge."""
|
||||||
|
|
||||||
|
assert module.run_url("https://agent.bstein.dev/", "run_x") == (
|
||||||
|
"https://agent.bstein.dev/chat?resume=run_x"
|
||||||
|
)
|
||||||
|
assert module.run_url("", "run_x") == ""
|
||||||
|
assert module.run_url("https://agent.bstein.dev", " ") == ""
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user