Files
phase-memory/workplans/PMEM-WP-0016-ops-warden-cross-runtime-memory.md
tegwick dc699be976 Implement PMEM-WP-0016 ops-warden cross-runtime memory contracts.
Add ops-warden coordination profile, session event schemas, activation helpers,
adapter pack, evaluation scenarios, and contract documentation for shared memory
across worker, agent session, and operator CLI surfaces.
2026-07-02 23:40:45 +02:00

236 lines
8.0 KiB
Markdown

---
id: PMEM-WP-0016
type: workplan
title: "Ops-Warden Cross-Runtime Memory Profile And Contracts"
domain: communication
repo: phase-memory
status: finished
owner: codex
topic_slug: phase-memory
created: "2026-07-02"
updated: "2026-07-02"
state_hub_workstream_id: "0f817f83-bb43-4e60-b3a7-b7cca0e9e6ed"
---
# PMEM-WP-0016: Ops-Warden Cross-Runtime Memory Profile And Contracts
## Goal
Define the phase-memory profile, event schemas, activation packs, and evaluation
gates that let **ops-warden learn from experience** across every runtime surface:
- **Direct ops-warden use** — `warden worker` with llm-connect / OpenRouter
inference, scheduled ticks, and operator CLI (`route`, `access`, `sign`).
- **Coding agent sessions** — Claude Code, Codex, Grok, and future agents that
invoke warden commands during an interactive session.
Memory must be **present** (discoverable, activatable, writable) in all three
modes without duplicating stores or leaking secrets.
## Current Evidence
`PMEM-WP-0015` added credential-safe pilot artifacts, ops-warden routing
advisories, evaluation trend regression gates, and redacted operator reports.
`WARDEN-WP-0020` shipped `warden worker` with `RuleBrain` and `LlmConnectBrain`,
fixed guardrails, and metadata-only audit via `warden activity`.
The gap: no shared memory substrate connects worker ticks, agent sessions, and
operator CLI usage. Each invocation starts cold.
## Non-Goals
- Store secret values, tokens, endpoint URLs, or prompt bodies with credentials.
- Override ops-warden's fixed charter, action allowlist, or no-secret invariant
through learned memory.
- Own llm-connect, OpenRouter configuration, or ops-warden worker scheduling.
- Replace State Hub as the coordination transport.
## Cross-Runtime Model
```mermaid
flowchart LR
subgraph surfaces [Runtime surfaces]
Worker[warden worker tick]
Agent[Agent session<br/>claude / codex / grok]
Operator[Operator CLI]
end
subgraph contract [Shared contract]
Store[(warden memory store)]
Profile[ops-warden profile]
Activate[activation plan]
end
Worker --> Store
Agent --> Store
Operator --> Store
Store --> Profile
Profile --> Activate
```
| Runtime mode | `session_kind` | Typical trigger |
| --- | --- | --- |
| `worker` | `warden.worker` | Scheduled tick, `warden worker run` |
| `agent_session` | `warden.agent.<agent_id>` | Coding agent invokes `warden route` / `warden access` |
| `operator` | `warden.operator` | Human shell without agent wrapper |
All modes read/write the **same canonical store** (path owned by ops-warden,
schema owned by phase-memory). Modes differ only in `session_kind` metadata and
activation budget — not in storage location.
## T01 - Define ops-warden memory profile
```task
id: PMEM-WP-0016-T01
status: done
priority: high
state_hub_task_id: "53dbc3f0-d2cb-4e0a-b558-64166ab976f3"
```
Author the `ops-warden-coordination` memory profile covering routing,
coordination, escalation, and pilot-feedback memory kinds.
Acceptance:
- Profile declares memory kinds, retention, compaction, activation budgets, and
policy (`secrets_allowed: false`, `durable_writes: review-gated`).
- Rigid memory kinds are documented as **import-only** (charter, allowlist) and
never promoted from learned episodes.
- Profile validates through existing `profile_from_markitect` / runtime planning
paths with deterministic diagnostics.
- Fixture lives at `tests/fixtures/ops-warden-coordination-profile.json`.
## T02 - Cross-runtime memory contract
```task
id: PMEM-WP-0016-T02
status: done
priority: high
state_hub_task_id: "6933918e-3ae0-4e0b-aade-1fbcf88ef0a1"
```
Define the `phase_memory.ops_warden.runtime.v1` contract: canonical store path
resolution, `session_kind` enum, read/write envelopes, and redaction rules.
Acceptance:
- Contract specifies canonical store default (XDG-based, overridable via
`WARDEN_MEMORY_STORE`) without embedding secrets.
- `session_kind` covers `warden.worker`, `warden.agent.*`, and `warden.operator`.
- Write envelopes reject payloads containing secret-field patterns (tokens, raw
URLs with credentials, key material).
- Contract is documented in `docs/ops-warden-memory-contract.md` and covered by
unit tests.
## T03 - Agent session event schema
```task
id: PMEM-WP-0016-T03
status: done
priority: high
state_hub_task_id: "9d436ccb-11df-49f1-82bd-eb75b1834018"
```
Define metadata-only event schemas for coding agent sessions (Claude, Codex,
Grok, extensible `agent_id`).
Acceptance:
- Events capture: `agent_id`, `session_id`, `command` (`route find`, `access`,
`worker run`, etc.), `need_fingerprint`, `route_id`, `outcome`
(`resolved|escalated|skipped`), and `diagnostic_codes`.
- Schema supports unknown future `agent_id` values without code changes.
- No event field may contain secret values or full credential payloads.
- Conformance fixtures cover at least claude, codex, and grok agent ids.
## T04 - Activation pack for routing memory
```task
id: PMEM-WP-0016-T04
status: done
priority: high
state_hub_task_id: "2f1f65a3-9a82-4854-83bb-20ef5eb3bac8"
```
Build an ops-warden activation pack that retrieves relevant coordination
episodes before inference or routing decisions.
Acceptance:
- Pack retrieves stabilized routing patterns, recent fluid thread summaries, and
applicable troubleshooting rows within profile token/item budgets.
- Activation output is a bounded context package suitable for llm-connect
injection and for agent session orientation.
- Pack works without network access (local store only).
- Tests prove deterministic selection for fixture graphs with duplicate need
fingerprints.
## T05 - Evaluation scenarios and regression gate
```task
id: PMEM-WP-0016-T05
status: done
priority: medium
state_hub_task_id: "ba0d35b3-2de1-483f-9761-cec5cbe3e8da"
```
Add evaluation scenarios and trend metrics for ops-warden memory quality across
runtime modes.
Acceptance:
- Scenarios cover: routing repeat accuracy, escalation precision, cross-runtime
continuity (agent session write → worker read), and OpenRouter call avoidance
when stabilized memory matches.
- Metrics integrate with `evaluation_trend_regression_gate`.
- Scenario fixture at `tests/fixtures/ops-warden-evaluation-scenarios.json`.
- Threshold report runs in default CI without live OpenRouter access.
## T06 - Ops-warden adapter pack conformance
```task
id: PMEM-WP-0016-T06
status: done
priority: medium
state_hub_task_id: "d430906b-6852-4328-8bc9-ad8c79fa8b03"
```
Publish a live-shaped ops-warden adapter pack and conformance suite for
ops-warden to consume.
Acceptance:
- Adapter pack manifest declares graph store, event log, audit sink, and
activation helpers required by `WARDEN-WP-0024`.
- `validate_adapter_pack_manifest` passes for the ops-warden pack.
- Public exports and API snapshot updated if new symbols are added.
- Pack documentation explains how ops-warden depends on phase-memory without
circular repo ownership.
## Acceptance Criteria
- ops-warden can activate phase-memory consistently from worker, agent session,
and operator CLI modes using one canonical store.
- Learned memory improves routing suggestions without weakening security
guardrails.
- Evaluation gates can block promotion when cross-runtime continuity or routing
accuracy regresses.
## Dependencies
- `WARDEN-WP-0024` (ops-warden repo) — consumes the contract and adapter pack.
- `WARDEN-WP-0020` — worker brain and guardrail foundation (finished).
- `PMEM-WP-0015` — pilot evidence and regression gate patterns (finished).
## Closure Review
Implemented cross-runtime memory contracts and activation helpers:
- `ops-warden-coordination` profile fixture with activation budgets and
`secrets_allowed: false`.
- `phase_memory.ops_warden.runtime.v1` contract with canonical store path,
`session_kind` coverage, and secret-field rejection.
- Agent session event schema supporting claude, codex, grok, and future agent ids.
- `activate_ops_warden_memory`, stabilized route matching, and ops-warden adapter
pack with evaluation scenarios and report helpers.
- Contract documentation in `docs/ops-warden-memory-contract.md`.