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
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ madp owner-decide DIR --decision DECISION.md
- **Hermes Agent** — provider, model, session, API usage, and final active message derived from the actor profile's `state.db`.
- **Generic command** — requires a separate identity-verifier command; worker self-report is rejected.

Every accepted turn also records the engine-probed adapter CLI version (`--version` output, stored verbatim up to 500 chars with SHA-256 over the full untruncated output) as `cli_version` in the turn's evidence record, since real adapters depend on the exact installed CLI versions. The probe runs under the actor's own settings env and is informational only: a failed probe is recorded, never fatal to the turn.

Real adapters depend on the exact installed CLI versions. Run the fake demo first, then perform a harmless live smoke and bounded canary on your own machine before relying on a real transport.

## Why trust it?
Expand Down
3 changes: 3 additions & 0 deletions examples/fakes/bin/fake-fable-session
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,9 @@ def cmd_audit(argv: list[str]) -> int:

def main() -> int:
argv = sys.argv[1:]
if argv == ["--version"]:
print("fake-fable-session 0.3.0b1 (fixture)")
return 0
if not argv:
print("usage: fake-fable-session {run,audit,watch} ...", file=sys.stderr)
return 2
Expand Down
3 changes: 3 additions & 0 deletions examples/fakes/bin/fake-hermes
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ def parse_chat_args(argv: list[str]) -> dict:

def main() -> int:
argv = sys.argv[1:]
if argv == ["--version"]:
print("fake-hermes 1.1.0 (fixture)")
return 0
if not argv or argv[0] != "chat":
print(
"fake-hermes: error: this fixture only implements the real "
Expand Down
3 changes: 3 additions & 0 deletions examples/fakes/bin/fake-worker
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ import _fakelib # noqa: E402

if __name__ == "__main__":
parser = argparse.ArgumentParser(prog="fake-worker")
parser.add_argument(
"--version", action="version", version="fake-worker 1.0.0 (fixture)"
)
parser.add_argument("--task", required=True)
parser.add_argument("--turn-output", required=True)
parser.add_argument("--round", required=True)
Expand Down
100 changes: 87 additions & 13 deletions schemas/runtime-evidence.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,28 @@
],
"additionalProperties": false,
"properties": {
"evidence_version": {"const": 1},
"actor_id": {"type": "string", "minLength": 1},
"round_id": {"type": "string", "minLength": 1},
"adapter": {"type": "string", "minLength": 1},
"evidence_version": {
"const": 1
},
"actor_id": {
"type": "string",
"minLength": 1
},
"round_id": {
"type": "string",
"minLength": 1
},
"adapter": {
"type": "string",
"minLength": 1
},
"transport": {
"type": "string",
"enum": ["command", "fable-session", "hermes-cli"]
"enum": [
"command",
"fable-session",
"hermes-cli"
]
},
"provider": {
"type": "string",
Expand All @@ -47,20 +62,35 @@
},
"outcome": {
"type": "string",
"enum": ["success", "failure", "timeout", "cancelled"],
"enum": [
"success",
"failure",
"timeout",
"cancelled"
],
"description": "Terminal outcome; anything other than success blocks completion."
},
"exit_status": {"type": "integer"},
"artifact_path": {"type": "string", "minLength": 1},
"artifact_sha256": {"type": "string", "pattern": "^[0-9a-f]{64}$"},
"exit_status": {
"type": "integer"
},
"artifact_path": {
"type": "string",
"minLength": 1
},
"artifact_sha256": {
"type": "string",
"pattern": "^[0-9a-f]{64}$"
},
"captured_at": {
"type": "string",
"pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$",
"description": "UTC capture time."
},
"proof": {
"type": "object",
"required": ["kind"],
"required": [
"kind"
],
"minProperties": 1,
"description": "Adapter-derived proof references from EXTERNAL records — never worker-authored. kind names the record family; the remaining keys point at the backing records (manifest/audit/stream for fable-session, state.db facts for hermes-cli, the verifier report for command).",
"properties": {
Expand All @@ -70,6 +100,38 @@
"description": "External record family, e.g. fable-session, hermes-state-db, external-command-verifier."
}
}
},
"cli_version": {
Comment thread
askclaw-vesper marked this conversation as resolved.
"type": "object",
"description": "Engine-probed adapter CLI version record. argv/exit_status/output/probed_at describe the probe; output is truncated at 500 chars while output_sha256 always attests the FULL untruncated output (output_truncated=true marks that case). An 'error' key appears when the probe itself failed; if even the probe argv could not be built, only 'error' is present. Informational provenance only — never part of turn acceptance.",
"additionalProperties": false,
"properties": {
"argv": {
"type": "array",
"items": {
"type": "string"
}
},
"exit_status": {
"type": "integer"
},
"output": {
"type": "string"
},
"output_sha256": {
"type": "string",
"pattern": "^[0-9a-f]{64}$"
},
"output_truncated": {
"type": "boolean"
},
"probed_at": {
"type": "string"
},
"error": {
"type": "string"
}
}
}
},
"examples": [
Expand All @@ -89,9 +151,21 @@
"captured_at": "2026-07-16T00:00:00Z",
"proof": {
"kind": "external-command-verifier",
"worker_argv": ["fake-worker", "--task", "task.md"],
"verifier_argv": ["fake-verifier", "--turn", "turn.md"],
"report": {"fake": true, "provider": "provider-a", "model": "model-a"}
"worker_argv": [
"fake-worker",
"--task",
"task.md"
],
"verifier_argv": [
"fake-verifier",
"--turn",
"turn.md"
],
"report": {
"fake": true,
"provider": "provider-a",
"model": "model-a"
}
}
}
]
Expand Down
69 changes: 68 additions & 1 deletion src/multi_agent_dialogue/adapters/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from datetime import datetime, timezone
from pathlib import Path

from .. import artifacts
from ..config import Actor, TurnSpec

EVIDENCE_VERSION = 1
Expand Down Expand Up @@ -161,6 +162,12 @@ def command_failed(result: subprocess.CompletedProcess, what: str) -> AdapterErr
return AdapterError(f"{what} exited {result.returncode}: {detail}")


# Bounded probe for the adapter CLI's own version string. The README
# warns that real adapters depend on the exact installed CLI versions,
# so accepted-turn evidence records the probed version verbatim.
VERSION_PROBE_TIMEOUT_SECONDS = 15


class Adapter(ABC):
name: str = "abstract"
transport: str = ""
Expand All @@ -186,10 +193,66 @@ def output_contract(self, context: PrepareContext) -> tuple[str, ...]:
f"{context.turn_file}",
)

def version_probe_argv(self, context: PrepareContext) -> list[str] | None:
"""Argv that prints the adapter CLI's version, or None if unknown.

Engine-probed, never adapter self-report: the output of THIS
command is what lands in evidence.
"""
return None

def cli_version_evidence(self, context: PrepareContext) -> dict | None:
"""Probe the adapter CLI version for the evidence record.

Informational only: a failed probe is recorded, never fatal —
the turn's acceptance still rests on the identity evidence.
"""
where = f"actor {context.actor.actor_id!r} ({self.name})"
argv: list[str] | None = None
try:
# Inside the try: a subclass hook raising AdapterError (bad
# settings, malformed env) must degrade to a recorded error,
# never fail the accepted turn.
argv = self.version_probe_argv(context)
if argv is None:
return None
# Probe under the actor's own settings env (same substitution
# as the turn packet) so PATH- or env-dependent CLIs resolve
# the binary the turn actually used.
probe_env = substitute_env(
context.actor.settings.get("env"), context.placeholders(), where
)
result = run_command(
argv, env=probe_env, cwd=context.work_dir,
timeout=VERSION_PROBE_TIMEOUT_SECONDS,
what=f"{where}: version probe",
)
except AdapterError as exc:
record: dict = {"error": str(exc)}
if argv is not None:
record["argv"] = list(argv)
return record
raw_output = (result.stdout or result.stderr or "").strip()
record = {
"argv": list(argv),
"exit_status": result.returncode,
"output": raw_output[:500],
# The hash attests the FULL probe output, computed before the
# 500-char storage truncation; output_truncated flags when the
# stored output is a prefix of what the hash covers.
"output_sha256": artifacts.sha256_bytes(raw_output.encode("utf-8")),
"probed_at": utc_now(),
}
if len(raw_output) > 500:
record["output_truncated"] = True
if result.returncode != 0:
record["error"] = f"version probe exited {result.returncode}"
return record

def base_evidence(self, context: PrepareContext, *, provider: str, model: str,
session_id: str, exit_status: int, artifact_sha256: str,
proof: dict) -> dict:
return {
record = {
"evidence_version": EVIDENCE_VERSION,
"actor_id": context.actor.actor_id,
"round_id": context.turn.round_id,
Expand All @@ -205,6 +268,10 @@ def base_evidence(self, context: PrepareContext, *, provider: str, model: str,
"captured_at": utc_now(),
"proof": proof,
}
cli_version = self.cli_version_evidence(context)
if cli_version is not None:
record["cli_version"] = cli_version
return record


def get_adapter(transport: str) -> Adapter:
Expand Down
8 changes: 8 additions & 0 deletions src/multi_agent_dialogue/adapters/claude_fable.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,14 @@ class ClaudeFableAdapter(Adapter):
name = "claude-fable"
transport = "fable-session"

def version_probe_argv(self, context: PrepareContext) -> list[str]:
settings = context.actor.settings
where = f"actor {context.actor.actor_id!r} (claude-fable)"
command_name = require_str_setting(
settings, "command_name", where, "fable-session"
)
return [command_name, "--version"]

# -- packet ------------------------------------------------------------

def _settings(self, context: PrepareContext) -> dict:
Expand Down
6 changes: 6 additions & 0 deletions src/multi_agent_dialogue/adapters/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ class CommandAdapter(Adapter):
name = "command"
transport = "command"

def version_probe_argv(self, context: PrepareContext) -> list[str]:
settings = context.actor.settings
where = f"actor {context.actor.actor_id!r} (command)"
argv_setting = _argv_setting(settings, "argv", where, required=True)
return [argv_setting[0], "--version"]

def prepare(self, context: PrepareContext) -> CommandPacket:
settings = context.actor.settings
where = f"actor {context.actor.actor_id!r} (command)"
Expand Down
6 changes: 6 additions & 0 deletions src/multi_agent_dialogue/adapters/hermes.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,12 @@ def _source(self, context: PrepareContext) -> str:
f"{secrets.token_hex(4)}"
)

def version_probe_argv(self, context: PrepareContext) -> list[str]:
settings = context.actor.settings
where = f"actor {context.actor.actor_id!r} (hermes)"
command_name = require_str_setting(settings, "command_name", where)
return [command_name, "--version"]

def _argv(self, command_name: str, prompt: str, source: str) -> tuple[str, ...]:
return (
command_name,
Expand Down
Loading