Skip to content

Add durable signed root-action approval relay - #77163

Open
erdemkulunk wants to merge 4 commits into
NousResearch:mainfrom
erdemkulunk:rollout/automatic-updates-hermes
Open

erdemkulunk wants to merge 4 commits into
NousResearch:mainfrom
erdemkulunk:rollout/automatic-updates-hermes

Conversation

@erdemkulunk

Copy link
Copy Markdown

Closes #77161.\n\nAdds the narrow, deliver-only root-action proposal and callback contract used by Pythia automatic-update recovery. Includes HMAC-bound payloads, profile-authorized Telegram decisions, durable one-shot callback retry, exact managed-incident acknowledgements, and restart/idempotency coverage.\n\nFocused verification: 63 gateway tests passed. Full gateway run on Windows: 4,372 passed, 36 skipped, 64 unrelated platform/dependency/Windows failures.

@alt-glitch alt-glitch added type/feature New feature or request P3 Low — cosmetic, nice to have comp/gateway Gateway runner, session dispatch, delivery comp/plugins Plugin system and bundled plugins platform/webhook Webhook / API server platform/telegram Telegram bot adapter area/auth Authentication, OAuth, credential pools needs-decision Awaiting maintainer decision before any implementation sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages sweeper:risk-security-boundary Sweeper risk: may affect sandboxing, auth, credentials, or sensitive data sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades labels Aug 3, 2026
@alt-glitch

Copy link
Copy Markdown
Contributor

This was generated by AI during triage.

Related: #77161 is the feature request and #75707 is adjacent approval-identity work. This PR introduces a separate Pythia-specific webhook/Telegram contract requiring maintainer review.

@erdemkulunk
erdemkulunk marked this pull request as ready for review August 3, 2026 01:02
@erdemkulunk
erdemkulunk requested review from a team and Copilot August 3, 2026 01:02

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR adds a durable, signed “root-action approval relay” path in the gateway: webhook routes can accept narrowly-scoped, immutable root-action proposals (HMAC V2), deliver approval buttons to Telegram, and then retry a one-shot signed callback to the upstream system until acknowledged—persisting state for idempotency and restart recovery.

Changes:

  • Introduces gateway/root_action_approval.py with an immutable proposal/decision contract and a durable approval store used across adapters.
  • Extends the webhook adapter to validate timestamp-bound HMAC-V2 for root-action proposals and to add durable idempotency for a managed incident delivery route.
  • Extends the Telegram adapter to render root-action approval buttons and retry signed callback delivery after user decision; adds focused gateway tests for restart/idempotency behavior.

Reviewed changes

Copilot reviewed 8 out of 9 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
gateway/root_action_approval.py New durable store + proposal/decision signing helpers for root-action approvals.
gateway/platforms/webhook.py Adds root-action proposal route handling (V2 signature), profile-bound Telegram delivery, and durable managed-incident delivery bindings.
plugins/platforms/telegram/adapter.py Adds root-action approval UI + durable callback retry/resume logic.
tests/gateway/test_root_action_approval.py Behavioral tests for immutable proposal validation, signing, and store durability.
tests/gateway/test_root_action_profile_delivery.py Tests profile-bound Telegram routing and callback retry/idempotency semantics.
tests/gateway/test_webhook_adapter.py Adds managed-incident durability/idempotency tests.
tests/gateway/test_telegram_callback_auth_fail_closed.py Adds test ensuring profile-bound callback auth does not fall back to global allowlists.
web/package.json Pins react-router-dom to 7.18.2.
package-lock.json Lockfile updates consistent with dependency bumps.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +89 to +98
def _default_state_path() -> Path:
configured = os.getenv("HERMES_ROOT_ACTION_STATE", "").strip()
if configured:
return Path(configured)
try:
from hermes_constants import get_hermes_home

return get_hermes_home() / "root-action-approvals.json"
except Exception:
return Path.home() / ".hermes" / "root-action-approvals.json"
Comment on lines +606 to +610
def replay_response(existing: dict) -> "web.Response":
if (
existing.get("incident_id") != binding["incident_id"]
or existing.get("state_revision") != binding["state_revision"]
):
Comment on lines +6356 to +6359
def _done(completed: asyncio.Task, *, key: str = action_id) -> None:
self._root_action_delivery_tasks.discard(completed)
self._root_action_delivery_task_ids.discard(key)

@erdemkulunk

Copy link
Copy Markdown
Author

Release evidence (2026-08-03): fork head 2213fa4 is pinned by Pythia and passed the full hosted candidate gate, including immutable source/PEP 610 provenance, SQLite/WAL, npm high/critical, and pip-audit checks: https://github.com/erdemkulunk/pythia/actions/runs/30778323821/job/91577992558. The production scheduler remains disabled pending staged node rollout evidence.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/auth Authentication, OAuth, credential pools comp/gateway Gateway runner, session dispatch, delivery comp/plugins Plugin system and bundled plugins needs-decision Awaiting maintainer decision before any implementation P3 Low — cosmetic, nice to have platform/telegram Telegram bot adapter platform/webhook Webhook / API server sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages sweeper:risk-security-boundary Sweeper risk: may affect sandboxing, auth, credentials, or sensitive data sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add durable signed root-action approval relay

3 participants