# Adaptive Production And MCP Operator Contract

Use this contract for real Hermes installs, repairs, MCP calls, and production
proof. The objective and verified outcome drive the loop; no monolithic script
owns the diagnostic strategy.

## Run contract

Persist before the first mutation:

```yaml
objective: Perform the real production operation and prove the requested end state.
allowed_mutations: [exact named resources]
forbidden: [customer contact, unapproved actions, unrelated workspace changes]
success_proof: [live MCP or API state, runtime identity, negative boundaries]
real_blockers: [missing authority or credentials, permission denial, irreversible ambiguity, confirmed product defect]
execution_policy: [inspect before acting, adapt, never repeat an unchanged failed strategy]
```

## Operator loop

1. Read the current contract and run ledger.
2. Observe the live process, resource, lock, and receipt state relevant to the
   next action.
3. Choose one primitive inside the allowed mutation envelope.
4. Execute it and independently verify progress.
5. On failure, append the observed condition, evidence-backed diagnosis,
   materially revised strategy, and proof target before acting again.
6. Continue until the requested end state is proven or a real blocker is
   confirmed.

Never encode failure interpretation, UI navigation, diagnostic order, or
unchanged retry loops in a script. Scripts may own secret loading/redaction,
package hashing/publishing, locks and ownership checks, no-contact enforcement,
exact identity constraints, structured receipts, and independent final checks.

## Hermes preflight defaults

Inspect these when relevant to the next primitive:

- runtime user and ownership of the profile, Admin home, and target evidence
  directory; full Admin installs run as `hermes`, not container root;
- mode `0700` on private directories and `0600` on credential/receipt files;
- exact host, container, profile, package specs, integrity, tarball hashes,
  workspace, and resource binding;
- active lifecycle owners or processes such as `onboard-client-v3-hermes` and
  `browserbase-slack-provision`; never kill or overlap them—wait for an idle
  observation and recheck immediately before install, restart, or application
  mutation;
- explicit npm registry propagation and exact `gitHead`/integrity readback;
- MCP launch through the profile-owned `with-sellable-admin-env` wrapper when
  profile secrets live in `.sellable-admin/.env`;
- credential presence in the actual MCP child environment without printing the
  value;
- preservation of the checksum-pinned Slack binary and unrelated profile state;
- dashboard/gateway reload only after exact config readback and an idle check.

## Gotcha ledger

Append one entry immediately after every failed action and read all current
entries before the next attempt:

```json
{
  "surface": "hermes-admin-mcp-launch",
  "condition": "token exists in profile env but MCP cannot see it",
  "diagnosis": "server bypassed generated env wrapper",
  "recovery": "launch MCP through with-sellable-admin-env",
  "proof": "actual MCP child has the variable and the installed call succeeds",
  "verifiedAt": null
}
```

A retry is valid only when live state changed or the recorded strategy changed.
Promote verified reusable lessons into the owning skill preflight and the
project UAT learning ledger. Return blocked only for concrete authority,
credential, permission, irreversible-ambiguity, or product-code evidence.
