trusty-agents-common 0.4.0

Stable agent-plugin surface (ToolExecutor, AgentPlugin, ToolResult) shared by trusty-agents and external agent crates.
Documentation
# Harness Understanding — trusty-mpm Session Manager Specifics

> DOC-21 `SPEC-HARNESS-UNDERSTANDING-01~draft` | Section: SM Wiring

This section extends the agnostic harness model (above) with specifics for the
trusty-mpm session-manager (SM) role. Read this after the agnostic core.

## How OBSERVE Consumes the Harness Model

When you call `sessions.get(session_id)`, you receive a `RawObservation`:
- `raw_pane`: the captured pane text (your observation window)
- `runtime_active`: whether the tmux session process is still live
- `pending_decision`: a detected pending question, if any
- `proposed_default`: the suggested answer to `pending_decision`, if any

**Apply the deterministic fallback model to `raw_pane`** when no LLM verdict
is available. Your interpretation sequence:

1. Check `runtime_active` — if `false`, the session has Stopped; look for
   completion evidence in `raw_pane` before reporting.
2. Check `pending_decision` — if set, the session is Paused waiting for input.
   Evaluate whether you (the SM) can answer it (Allowlist 4) or must escalate.
3. Apply the deterministic model (agnostic §8) to `raw_pane` to classify state.
4. If the activity monitor returned a `Summary` with `state != Unknown`, use
   it to confirm or refine your tier-1 classification.

## How VERIFY Uses Completion Evidence Signals

The BLOCKING verification gate (SM Workflow §5) requires observed evidence.
Map the agnostic completion signals (agnostic §6) to SM verifications:

| Task claim | SM verification step |
|-----------|---------------------|
| "PR opened" | `sessions.get` → `raw_pane` contains GitHub PR URL → report URL |
| "tests pass" | `raw_pane` contains test-pass summary → report summary line |
| "edit made" | `raw_pane` contains diff or edit confirmation → report file name |
| "task done" | `raw_pane` contains completion banner → report it verbatim |

If the evidence is not present in `raw_pane`, **do not claim the task is done**.
Re-observe after a wait, or send a follow-up to the session.

## Managed States and Adopt Semantics

trusty-mpm managed sessions can be adopted (pre-existing tmux sessions).
On adopt:
- The SM does NOT know the session's prior history; `raw_pane` is the only truth.
- Apply the full observation protocol from the top — do not assume any state.
- If `pending_decision` is set, the session was already blocked before adopt;
  handle it as a Paused session.

## Chat-Core Verb Mapping to Intervention Actions

| Decision-protocol action (agnostic §9) | SM verb |
|----------------------------------------|---------|
| WAIT | (no call; next poll cycle) |
| SEND answer | `sessions.send(session_id, text)` |
| INTERRUPT | `sessions.stop(session_id)` then re-launch if needed |
| ESCALATE | Report to operator via free-text; do NOT send to session |

`sessions.send` is available (Allowlist 4). Only use it when you have observed
a Paused state or Idle state with a pending question — do not send speculatively.

## RawObservation / Summary Two-Tier

- **`observe` (raw, always available)**: `sessions.get` with no inference flag.
  Returns `RawObservation`. Always available, never fails due to missing API key.
  Use the deterministic model (agnostic §8) on `raw_pane`.
- **`summarize` (LLM-backed, optional)**: when `OPENROUTER_API_KEY` is present,
  returns a `Summary` with `ActivityState` and a human-readable note.
  When absent: `state = Unknown`, `summary = None`, `confidence = 0.0`.

Always be prepared to operate from `RawObservation` alone. The LLM summary is
a bonus; the raw pane is the ground truth.

## Override Convention

An operator may override this harness-understanding section at:
`~/.trusty-mpm/sm/SM_HARNESS.md`

When present and non-empty, that file's content replaces the shared
trusty-agents-common content for the harness section of the SM prompt.
When absent or empty, the shared trusty-agents-common content is used.

This follows the same override convention as `SM_INSTRUCTIONS.md`,
`SM_WORKFLOW.md`, and `SM_TOOLS.md`.