Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,22 @@ It is a coordination protocol, workspace layout, and operating discipline. Add s
6. Put recurring integrations in n8n, cron, CI, or another deterministic scheduler.
7. Add backup/versioning and pass a restore drill before trusting the deployment.

## Hermes-native control plane

This repository is also a standalone Hermes Agent plugin. Install it directly from GitHub:

```bash
hermes plugins install LiquidMatty/federated-vaults --enable
hermes tools enable federation --platform cli
```

It adds two deliberately read-only tools:

- `federation_context` loads bounded START context only for a registry lane owned by the active Hermes profile, plus an optional project. Reads fail closed above explicit size budgets (256 KiB project note; 1 MiB worklist/control file).
- `federation_doctor` checks registry paths, doorway protocol echoes, and worklist schema/status drift.

It also adds `/federation` and the bundled `federated-vaults:federated-vaults` skill. See [`hermes_plugin/README.md`](hermes_plugin/README.md).

## License

MIT. Use freely, without warranty. Adapt the templates to your own inventory, permissions, integrations, and operational requirements.
5 changes: 5 additions & 0 deletions __init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
"""Installable Hermes plugin entry point for Federated Vaults."""

from .hermes_plugin import _split_args, federation_context, federation_doctor, register

__all__ = ["federation_context", "federation_doctor", "register"]
25 changes: 25 additions & 0 deletions hermes_plugin/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Federated Vaults Hermes Plugin

This repository is directly installable as a Hermes plugin:

```bash
hermes plugins install LiquidMatty/federated-vaults --enable
hermes tools enable federation --platform cli
```

The plugin adds:

- `federation_context` — loads bounded START context only for a lane owned by the active Hermes profile: newest HUB/lane changelog lines, the named project note, and its full worklist within explicit read budgets. Cross-lane reads require an explicit operator-mediated handoff. Oversized project notes (>256 KiB) and worklists/control files (>1 MiB) fail closed rather than being truncated silently.
- `federation_doctor` — read-only checks for missing registered lanes, doorway protocol-version drift, invalid worklist JSON, and non-canonical task statuses.
- `/federation doctor [root]` and `/federation context <lane> [project] [root]`.
- `federated-vaults:federated-vaults` — the operational skill bundled with the plugin.

The implementation is intentionally read-only. It surfaces drift but never rewrites HUB canon, doorways, changelogs, or worklists automatically.

## Local development

```bash
python3 -m unittest discover -s tests -p 'test_federation_plugin.py' -v
```

A federation is discovered by walking upward until a `HUB/` directory contains `PROTOCOL.md`, `PRINCIPLES.md`, and `CHANGELOG.md`. Lanes come from `HUB/REGISTRY.md`; no machine-specific root path is compiled into the plugin.
144 changes: 144 additions & 0 deletions hermes_plugin/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
"""Hermes registration surface for the Federated Vaults plugin."""

from __future__ import annotations

import json
import os
import shlex
from pathlib import Path

from .federation import load_context, run_doctor


def _json(value: object) -> str:
return json.dumps(value, default=lambda item: str(item), indent=2)


def _root(args: dict) -> str:
return args.get("root") or os.getcwd()


def _active_profile() -> str:
"""Resolve the active Hermes profile, failing closed outside Hermes."""
try:
from hermes_cli.profiles import get_active_profile_name

return get_active_profile_name()
except Exception:
return "__unknown_profile__"


def federation_doctor(args: dict, **_: object) -> str:
"""Hermes tool handler for read-only federation checks."""
try:
return _json(run_doctor(_root(args)))
except Exception as exc:
return _json({"success": False, "error": str(exc), "type": exc.__class__.__name__})


def federation_context(args: dict, **_: object) -> str:
"""Hermes tool handler for bounded lane context."""
try:
lane = args.get("lane")
if not lane:
return _json({"success": False, "error": "lane is required"})
return _json(
load_context(
_root(args),
lane=lane,
project=args.get("project"),
log_lines=int(args.get("log_lines", 20)),
requesting_profile=_active_profile(),
)
)
except Exception as exc:
return _json({"success": False, "error": str(exc), "type": exc.__class__.__name__})


def _split_args(raw_args: str, windows: bool = False) -> list[str]:
"""Split slash-command arguments without consuming Windows path separators."""
parts = shlex.split(raw_args, posix=not windows)
if not windows:
return parts
return [
part[1:-1] if len(part) >= 2 and part[0] == part[-1] and part[0] in {'"', "'"} else part
for part in parts
]


def _slash(raw_args: str = "", **_: object) -> str:
"""Handle `/federation doctor` and `/federation context <lane> [project]`."""
try:
parts = _split_args(raw_args, windows=os.name == "nt")
except ValueError as exc:
return f"Invalid arguments: {exc}"
if not parts or parts[0] in {"help", "-h", "--help"}:
return "Usage: /federation doctor [root] | /federation context <lane> [project] [root]"
if parts[0] in {"doctor", "status"}:
return federation_doctor({"root": parts[1] if len(parts) > 1 else os.getcwd()})
if parts[0] == "context" and len(parts) >= 2:
return federation_context(
{
"lane": parts[1],
"project": parts[2] if len(parts) > 2 else None,
"root": parts[3] if len(parts) > 3 else os.getcwd(),
}
)
return "Usage: /federation doctor [root] | /federation context <lane> [project] [root]"


_DOCTOR_SCHEMA = {
"name": "federation_doctor",
"description": "Run read-only drift and integrity checks on a Federated Vaults HUB and its registered active lanes.",
"parameters": {
"type": "object",
"properties": {
"root": {"type": "string", "description": "Federation root or any path inside it. Defaults to the current working directory."}
},
},
}

_CONTEXT_SCHEMA = {
"name": "federation_context",
"description": "Load bounded START context for a lane owned by the active Hermes profile: top changelog lines, project note, and full worklist.",
"parameters": {
"type": "object",
"properties": {
"lane": {"type": "string", "description": "Registry vault name, profile name, or vault directory name."},
"project": {"type": "string", "description": "Optional project note/worklist slug."},
"root": {"type": "string", "description": "Federation root or any path inside it."},
"log_lines": {"type": "integer", "minimum": 1, "maximum": 100, "default": 20},
},
"required": ["lane"],
},
}


def register(ctx) -> None:
ctx.register_tool(
name="federation_doctor",
toolset="federation",
schema=_DOCTOR_SCHEMA,
handler=federation_doctor,
description=_DOCTOR_SCHEMA["description"],
emoji="🗂️",
)
ctx.register_tool(
name="federation_context",
toolset="federation",
schema=_CONTEXT_SCHEMA,
handler=federation_context,
description=_CONTEXT_SCHEMA["description"],
emoji="🗂️",
)
ctx.register_command(
"federation",
handler=_slash,
description="Inspect a Federated Vaults tree and load bounded lane context.",
args_hint="doctor [root] | context <lane> [project] [root]",
)
ctx.register_skill(
"federated-vaults",
Path(__file__).parent / "skills" / "federated-vaults" / "SKILL.md",
"Operate safely inside a HUB-and-lanes Federated Vaults tree.",
)
Loading
Loading