* feat(platform): resolver core with locate/inspect/probe tiers and ordered candidates Every resource lookup needs one result shape and one cost contract. `locate` reads metadata only, `inspect` may open files and call OS APIs in-process, `probe` is fresh and the only tier that may spawn or connect. `Resolution.candidates` keeps probe order so fan-out consumers can try every present binary. Linear NS-921. * feat(platform): AppResolver over AppDef with plist, PE, registry, and server.json sources Desktop apps need presence, version, and liveness as separate observations. The runtime file's bearer token is parsed, used for one request, and discarded inside the probe; no public type carries it. Endpoints are accepted only when loopback with a numeric port. * refactor(copilot): gh candidates through locate_command and the Homebrew table First consumer of the resolver. The gh token probe still tries every present binary in order; the allowlist loses its two copilot_auth rows. * feat(platform): availability() over an application declaration locate() + inspect() only, never probes; the fail-closed _version in app.py treats a vendor's plist/PE/registry entry as untrusted input. Salvaged from PR #118122; reads any object with requires_app, min_version, app_for(os) — nothing here imports the MCP catalog. * feat(platform): application declarations parsed into AppDef per OS The parser slice of PR #118122's catalog manifest, re-homed as a catalog-free module: whoever owns an MCP server declares the app it fronts per OS and what it needs, and registers it here. Stdlib + hermes_platform.resolver only. register/lookup/clear are the one seam the MCP check_fn and the skill gate both read. * feat(mcp): check_fn honours a registered application declaration _make_check_fn ANDs the declared app's availability into the connection-alive check; with nothing registered for the server the behaviour is the pre-PR3 connection check. Provenance is explicit registration, not endpoint matching. Returns a plain bool: the registry caches bool(fn()). * feat(skills): requires_apps gate through registered declarations Offer-time filter beside environments:; names resolve through hermes_platform.declaration, an unknown name hides the skill (fail closed). The disk snapshot carries requires_apps and the fast path re-evaluates it (snapshot version bumped to 3): app presence is a host fact that changes without SKILL.md changing. * docs: application declarations page The plugin-facing schema reference: app: and requires: blocks, availability() states, and the two gates that read the registry. Registered under Extending > Plugins in the docs sidebar. * test(platform): declaration parser, availability, gates The PR3 app-block tests re-homed off the catalog: fixtures are dicts passed to parse_declaration, the check_fn gate keys on explicit registration (not endpoint matching), and the import-hygiene probe now covers hermes_platform.declaration and resolver.availability.
43 lines
1.7 KiB
Python
43 lines
1.7 KiB
Python
"""Application requirements survive disk and in-process skill-index reuse."""
|
|
|
|
import sys
|
|
|
|
from hermes_platform import declaration
|
|
|
|
|
|
def test_application_gate_rechecks_snapshot_without_losing_description(tmp_path, monkeypatch):
|
|
from agent import prompt_builder as pb
|
|
|
|
monkeypatch.setattr(declaration, "_REGISTRY", {})
|
|
monkeypatch.setenv("HERMES_HOME", str(tmp_path))
|
|
monkeypatch.setattr(pb, "get_disabled_skill_names", lambda *_: set())
|
|
skills = tmp_path / "skills"
|
|
skill = skills / "app-guide" / "SKILL.md"
|
|
skill.parent.mkdir(parents=True)
|
|
skill.write_text(
|
|
"---\nname: app-guide\ndescription: Application instructions.\n"
|
|
"requires_apps: [thing]\n---\nHelp with the application.\n", encoding="utf-8",
|
|
)
|
|
app = tmp_path / "application.exe"
|
|
declaration.register("thing", declaration.parse_declaration(
|
|
"thing", {sys.platform: {"presence": "executable", "location": str(app)}},
|
|
{"app": True}, where="test-plugin/plugin.yaml",
|
|
))
|
|
pb.clear_skills_system_prompt_cache(clear_snapshot=True)
|
|
try:
|
|
def build():
|
|
return pb._build_skills_system_prompt_inner(skills, [], None, None, None)
|
|
|
|
assert "app-guide" not in build()
|
|
snapshot = pb._load_skills_snapshot(skills)
|
|
assert snapshot is not None
|
|
assert snapshot["skills"][0]["requires_apps"] == ["thing"]
|
|
app.write_text("presence fixture", encoding="utf-8")
|
|
assert "app-guide: Application instructions." in build()
|
|
app.unlink()
|
|
assert "app-guide" not in build()
|
|
pb.clear_skills_system_prompt_cache()
|
|
assert "app-guide" not in build()
|
|
finally:
|
|
pb.clear_skills_system_prompt_cache(clear_snapshot=True)
|