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
75 changes: 75 additions & 0 deletions openspec/changes/route-authors-to-the-harness/design.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
## Context

The skill is distribution, not decoration. `README.md` documents installing it
by symlinking this checkout into an agent's skills directory, so what the skill
says is what an author — or a coding agent authoring a plugin — will do.

That creates a coupling the skill has to be honest about. The symlink points at
a moving checkout, while `AGENTS.md` requires consumers to pin the kit to an
immutable commit. A reader's skill is therefore always at least as new as their
kit, and can be much newer. An import path named without a minimum revision is
an `ImportError` waiting for whoever is furthest behind.

The audience also does not share this repository's tooling. `just` is the task
runner here; consumer plugin repositories predominantly use `make`. A lane
documented only as a `just` recipe reads as instructions in the repositories
that most need it and executes in none of them.

## Goals / Non-Goals

**Goals:**

- An author following the Validation section reaches a real drift check, or a
refusal that names what to do about it.
- Every import path the skill names carries the revision that provides it.
- The instructions work regardless of task runner, OS, or network access.
- Reference-file links stop rotting unnoticed.

**Non-Goals:**

- Converting any consumer repository. The lane ends at documentation and the
shipped entry points.
- Version-coupling the skill to the pinned kit revision. That is the real fix
for the symlink/pin mismatch and is deferred; naming a minimum revision is
the cheap mitigation, not a solution.

## Decisions

**Route by import path, never by repository path.** `references/plugin-kit.md`
currently links canonical sources as `../../../tests/test_kit.py`. Those
resolve inside a kit checkout and are meaningless to a consumer, whose install
contains no `tests/` at all — the sdist carries it, the wheel does not, and
`git+…@sha` installs neither. Anything the skill tells a consumer to use is
named as `hermes_plugin_kit.testing.…`.

**Document the Python entry point, not a `just` recipe.** The harness is
importable; a consumer wires it into whatever runner they already have. The
`just` recipes stay documented for work *in this repository* and are marked as
such, rather than presented as the lane.

**State the minimum revision beside every import path.** One line, next to the
name, so a reader on an older pin sees the requirement before the traceback.

**Extend the existing skills test rather than adding a new one.** It already
walks `SKILL.md` bodies and resolves relative links; reference files are the
gap, not the mechanism.

## Risks / Trade-offs

- A minimum-revision note is a manual claim. Nothing enforces that the number
in the skill matches the release that actually introduced the harness, and
the link test cannot check it. The deferred version-coupling work is what
would; until then this is documentation discipline.
- Documenting provisioning invites an author to run a fetch inside a sandbox
that forbids it. The harness already degrades to an explicit unchecked
result, so the failure is legible — but the skill must say so plainly rather
than presenting the fetch as unconditional.

## Migration

None. Documentation and a test only.

## Open Questions

None blocking. The symlink/pin coupling is recorded as deferred follow-up in
the plan rather than left implicit here.
56 changes: 56 additions & 0 deletions openspec/changes/route-authors-to-the-harness/proposal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
## Why

The repository's own skill tells an author to do something they cannot do.

`skills/hermes-plugins/SKILL.md` instructs: "When compatibility matters, run
contract tests against the real pinned Hermes Agent checkout." It names no
mechanism, no pin, and no import path — and until the harness shipped, no
consumer could carry it out at all. `references/plugin-kit.md` states the
principle in the same breath ("a fake context alone can hide signature drift")
while its Surface Map lists no way to act on it.

The harness now exists, but nothing points at it. The skill is the only channel
through which an author — human or coding agent — learns it is there, so a
harness nobody is routed to is a harness nobody adopts.

Two things make the routing non-obvious. The skill is read from a symlinked
checkout while consumers pin the kit to an immutable commit, so the skill can
name an import path that a reader's pinned kit predates — an `ImportError` for
following the instructions. And consumer repositories predominantly drive tests
with `make`, so a recipe documented only as `just test-contract` is unusable in
the repositories that most need it.

## What Changes

- The Validation section names the harness by import path, names the pin by
constant, and states the minimum kit revision that provides both.
- The lane is documented in a form a consumer can actually invoke, not as a
`just` recipe they do not have.
- Provisioning is documented: how a checkout is resolved, and what to set when
an environment cannot fetch one.
- The Surface Map gains a row for the harness, so the guard that checks
documented names against `__all__` covers it.
- `tests/test_skills.py` validates relative links in `references/*.md`, which
it does not do today — only `SKILL.md` bodies are checked, so reference-file
links rot silently.

## Capabilities

### New Capabilities

<!-- None. This change updates repo-owned documentation and a link test; it
adds no capability-level requirement, which is why .openspec.yaml sets
skip_specs: true rather than inventing one. -->

### Modified Capabilities

<!-- None. -->

## Impact

- `skills/hermes-plugins/SKILL.md` — Validation section rewritten.
- `skills/hermes-plugins/references/plugin-kit.md` — Surface Map row, harness
routing, minimum revision.
- `tests/test_skills.py` — reference-file link validation.
- No production code changes. `AGENTS.md` already binds `plugin-kit.md` to
public-API changes; this change honors that rule rather than adding a new one.
30 changes: 30 additions & 0 deletions openspec/changes/route-authors-to-the-harness/tasks.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
## 1. Route the skill to the harness (U8)

- [x] 1.1 Rewrite the Validation section's contract-test instruction to name
the harness by import path and the pin by constant, replacing an
instruction that names no mechanism. Verify: every name it gives resolves
against the installed package, not a repository path.
- [x] 1.2 Document the lane in a Python-invocable form a consumer can wire into
their own runner, and mark the `just` recipes as work in this repository.
Verify: no instruction aimed at consumers requires `just`.
- [x] 1.3 Document provisioning — how a checkout is resolved, what to set when
an environment cannot fetch, and that a refusal is a legible outcome
rather than a failure to work around. Verify: the sandboxed case is
described, not just the happy path.
- [x] 1.4 State the minimum kit revision beside every harness import path the
skill names. Verify: a reader on an older pin learns the requirement
before hitting an ImportError.
- [x] 1.5 Add the harness row to the Surface Map's `Kit API` column, so the
reachability guard covers it. Verify: the guard's documented-name set
grows to include the harness, and still passes.

## 2. Stop reference links rotting (U8)

- [x] 2.1 Extend `tests/test_skills.py` to resolve relative links in
`references/*.md`, which it checks only in `SKILL.md` bodies today.
Verify: a deliberately broken reference link fails the test, and the
existing `SKILL.md` validation still passes.
- [x] 2.2 Repoint or remove reference links that are meaningless to a consumer
— repository paths into `tests/`, which no install contains. Verify: the
links that remain resolve, and none instructs a consumer to open a file
their install does not have.
55 changes: 47 additions & 8 deletions skills/hermes-plugins/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,17 +70,56 @@ For catalog or content plugins, keep public summaries from leaking raw prompts,

## Validation

Run the repo-native install/test commands before committing. Common examples:
Run the plugin repository's own install/test commands before committing —
whatever its task runner is. (`just install` / `just test` / `just build` are
this kit's own recipes, not something a consumer repository has.)

```bash
just install
just test
just build
Also run focused registration, manifest-parity, hook or middleware, and local
import tests for the surface touched.

### Checking your plugin against the real host

A fake plugin context cannot tell you the host changed underneath you. A
permissive one accepts every future signature, and a hand-written one is a
frozen snapshot of whichever Hermes revision you wrote it against — both keep
passing when Hermes adds a required parameter.

Use the kit's harness instead. It records what your plugin registers and
replays those calls against the real `PluginContext` signatures:

```python
from hermes_plugin_kit.testing import (
DEPLOYED_HERMES_REVISION,
RecordingPluginContext,
resolve_hermes_checkout,
)

ctx = RecordingPluginContext(name="your-plugin", config={})
register(ctx) # your plugin's own registration entry point

host = resolve_hermes_checkout() # honors HERMES_AGENT_PATH; fetches at the pin otherwise
report = ctx.check_against_host(host.plugin_context_class())
assert report.clean, report # `checked` is False when no host was available
```

Also run focused registration, manifest-parity, hook or middleware, and local
import tests for the surface touched. When compatibility matters, run contract
tests against the real pinned Hermes Agent checkout.
Requires **hermes-plugin-kit 0.9.0 or newer** — earlier pins have no
`hermes_plugin_kit.testing` module, and this skill tracks a moving checkout
while your plugin pins the kit to a commit, so check before you follow this.

This is plain Python. Wire it into `make`, `pytest`, `unittest`, or whatever
the repository already uses; it does not need this kit's task runner.

**When no checkout is available** — a sandboxed runner, no network, no `git` —
`resolve_hermes_checkout()` returns an unavailable result naming
`DEPLOYED_HERMES_REVISION`, and `check_against_host(None)` gives a report with
`checked == False`. That is the honest outcome, not a failure to route around:
treat an unchecked report as "not verified", never as "verified clean". Set
`HERMES_AGENT_PATH` to a local checkout to run the check offline, or
`HERMES_PLUGIN_KIT_CACHE` to control where a fetched one is stored.

`check_registration(ctx)` additionally reports duplicate names, non-deterministic
ordering, and tool schemas whose arguments are flattened beside `parameters`
instead of inside it.

For tool surfaces, prefer a test that asserts every registered tool has:
matching `plugin.yaml` exposure, matching schema `name`, non-empty schema
Expand Down
26 changes: 21 additions & 5 deletions skills/hermes-plugins/references/plugin-kit.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,17 @@ path-loaded Hermes plugin and not an upstream Hermes API.

## Canonical Local Sources

Reachable from an installed kit — name these to a consumer:

- Exported API and behavior: `hermes_plugin_kit` (the package's own `__all__`)
- Consumer test support: `hermes_plugin_kit.testing`

Present only in a checkout of this repository. A consumer installing via
`git+…@sha` gets neither `tests/` nor `skills/`, so do not route them here:

- Public guide and examples: [`README.md`](../../../README.md)
- Maintainer rules: [`AGENTS.md`](../../../AGENTS.md)
- Exported API and behavior: [`hermes_plugin_kit/__init__.py`](../../../hermes_plugin_kit/__init__.py)
- Implementation: [`hermes_plugin_kit/__init__.py`](../../../hermes_plugin_kit/__init__.py)
- Unit contracts: [`tests/test_kit.py`](../../../tests/test_kit.py)
- Structured observability contracts:
[`tests/test_observability.py`](../../../tests/test_observability.py)
Expand All @@ -32,6 +40,7 @@ guidance, not a second implementation specification.
| Context engine | Hermes `ContextEngine` instance | `register_plugin(..., context_engine=...)` | Singular native engine registration; schemas and recovery dispatch stay in `get_tool_schemas()` / `handle_tool_call()`, never duplicated with `@tool`. |
| Host-managed call | `invoke_host_tool` | None | Use for supported non-registry capabilities such as `send_message`; pre/post-tool hooks remain active. |
| Local media delivery | `MediaPayload`, `MediaType`, `deliver_media` | Consumer registers suppression hooks | File must be absolute, present, and non-empty; `origin` resolves from task-local Hermes context. |
| Checking a plugin against the real host | `RecordingPluginContext`, `resolve_hermes_checkout`, `check_registration`, `DEPLOYED_HERMES_REVISION` | None — test-time only | Records what the plugin registers, and its `check_against_host()` replays those calls against the real `PluginContext` signatures. Needs no host to record; reports `checked == False` rather than clean when it could not check. Requires kit 0.9.0 or newer. |
| Correlated lifecycle receipt | `ObservabilityEvent`, `log_observability_event`, `new_correlation_id`, `credential_identity_hash` | None | Emits bounded, redacted JSON through the supplied local logger; consumers provide domain stages and never place credentials in event fields. |

`RegistrationSummary` reports commands, tools, middleware, hooks, skills,
Expand Down Expand Up @@ -105,9 +114,16 @@ In this repository:
```bash
just install
just test
just build
just test-contract-pinned # full contract suite at the deployed pin
```

In a consumer, run its native suite plus registration and manifest-parity tests.
Point contract tests at a real checkout with `HERMES_AGENT_PATH` when automatic
checkout discovery is not appropriate.
In a consumer, run its native suite plus registration and manifest-parity
tests, then check against the real host through `hermes_plugin_kit.testing` —
see the Validation section of [`SKILL.md`](../SKILL.md) for the worked call.
That path is plain Python and needs no particular task runner.

`HERMES_AGENT_PATH` points at an existing checkout and always wins over a
fetch. `HERMES_PLUGIN_KIT_CACHE` controls where a fetched one is stored, for
environments where the default cache location is wrong or unwritable. When
neither a checkout nor a fetch is possible, the result is explicitly
*unchecked* — read that as "not verified", never as "verified clean".
54 changes: 51 additions & 3 deletions tests/test_skills.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,18 @@
ROOT = Path(__file__).parents[1]
SKILLS = ROOT / "skills"

_LINK = re.compile(r"\[[^]]+\]\(([^)]+)\)")


def _relative_link_targets(text: str) -> list[str]:
"""Link targets that should resolve on disk, ignoring URLs and anchors."""
targets = []
for target in _LINK.findall(text):
if "://" in target or target.startswith("#") or target.startswith("mailto:"):
continue
targets.append(target)
return targets


class SkillDistributionTests(unittest.TestCase):
def test_skills_are_self_contained_and_named_for_their_directory(self) -> None:
Expand All @@ -24,12 +36,48 @@ def test_skills_are_self_contained_and_named_for_their_directory(self) -> None:
self.assertEqual(skill_file.parent.name, metadata["name"])
self.assertTrue(metadata["description"])

for target in re.findall(r"\[[^]]+\]\(([^)]+)\)", body):
if "://" in target:
continue
for target in _relative_link_targets(body):
resolved = skill_file.parent / target.split("#", 1)[0]
self.assertTrue(resolved.is_file(), f"Missing {target} from {skill_file}")


class SkillReferenceLinkTests(unittest.TestCase):
"""Reference files were never link-checked, so their links rotted unseen.

The suite validated `SKILL.md` bodies only. Everything under `references/`
— which is where the detailed routing lives, and the most likely place to
name a path — went unchecked.
"""

def _reference_files(self) -> list[Path]:
return sorted(SKILLS.glob("*/references/*.md"))

def test_there_are_reference_files_to_check(self) -> None:
# A glob that silently matched nothing would make every assertion below
# vacuous, and this test would be the only sign.
self.assertTrue(self._reference_files(), "no skill reference files found")

def test_relative_links_in_reference_files_resolve(self) -> None:
for reference in self._reference_files():
for target in _relative_link_targets(reference.read_text()):
with self.subTest(reference=reference.name, target=target):
resolved = (reference.parent / target.split("#", 1)[0]).resolve()
self.assertTrue(
resolved.is_file(), f"Missing {target} from {reference}"
)

def test_reference_links_stay_inside_the_repository(self) -> None:
"""A link escaping the repo resolves only on the machine that wrote it."""
root = ROOT.resolve()
for reference in self._reference_files():
for target in _relative_link_targets(reference.read_text()):
with self.subTest(reference=reference.name, target=target):
resolved = (reference.parent / target.split("#", 1)[0]).resolve()
self.assertTrue(
resolved.is_relative_to(root),
f"{target} in {reference} escapes the repository",
)


if __name__ == "__main__":
unittest.main()
26 changes: 22 additions & 4 deletions tests/test_testing_harness.py
Original file line number Diff line number Diff line change
Expand Up @@ -465,25 +465,43 @@ def test_the_surface_map_is_readable_and_non_empty(self) -> None:
self.assertGreater(len(documented), 8, "Surface Map parsed as nearly empty")
self.assertIn("tool", documented)

#: Modules whose `__all__` together form the kit's public surface.
#:
#: The harness is exported as a submodule rather than by name, so its
#: classes live on `hermes_plugin_kit.testing` -- still a public import
#: path, so a documented name resolving there is reachable.
PUBLIC_MODULES = (hpk, hpk_testing)

def _exported_names(self) -> set[str]:
return {n for module in self.PUBLIC_MODULES for n in module.__all__}

def _resolves(self, name: str) -> bool:
return any(hasattr(module, name) for module in self.PUBLIC_MODULES)

def test_every_documented_name_is_exported_and_importable(self) -> None:
documented = _documented_kit_api_names(self.REFERENCE) - HOST_OWNED_NAMES
exported = self._exported_names()

missing_from_all = sorted(n for n in documented if n not in hpk.__all__)
not_importable = sorted(n for n in documented if not hasattr(hpk, n))
missing_from_all = sorted(n for n in documented if n not in exported)
not_importable = sorted(n for n in documented if not self._resolves(n))

self.assertEqual([], missing_from_all, "documented but absent from __all__")
self.assertEqual([], not_importable, "documented but not importable")

def test_every_exported_name_is_importable(self) -> None:
self.assertEqual([], sorted(n for n in hpk.__all__ if not hasattr(hpk, n)))
for module in self.PUBLIC_MODULES:
with self.subTest(module=module.__name__):
self.assertEqual(
[], sorted(n for n in module.__all__ if not hasattr(module, n))
)

def test_the_guard_fails_when_a_documented_name_is_unexported(self) -> None:
"""Proves the guard has teeth rather than trivially passing."""
documented = {"tool", "a_name_the_kit_does_not_export"}

self.assertEqual(
["a_name_the_kit_does_not_export"],
sorted(n for n in documented if n not in hpk.__all__),
sorted(n for n in documented if n not in self._exported_names()),
)


Expand Down
Loading