# Runtime Health Remediation Program

**Program ID:** RHR-2026-09-02
**Status:** active, implementation authorized
**Owner:** Omnius runtime, orchestration, execution, memory, and Telegram packages
**External dependency:** `/home/roko/Desktop/ollama-unify`
**Last reconciled:** 2026-09-03

## Mission

Remove the runtime failure loops observed in the active `telegram_test` session.
The completed system must prefer foreground user work, admit broker requests
without amplification, project one exact and bounded model context, preserve
work state without diagnostic growth, complete only from host-derived evidence,
and receive Telegram updates durably.

This is a repair program. It does not authorize prompt-specific heuristics,
regex-based reply decisions, hidden success claims, or destructive migration of
existing session data.

## Observed baseline

The 2026-09-02 intake established these production facts:

- The active run reached a 61,351-token context with 49,886 characters of tool
  schemas, 67 raw tool messages, and 11 duplicated run-evidence projections.
- A 13 KB context frame was selected, but the transport later truncated system
  messages to 8 KB. The selection trace therefore did not describe the request
  that the model received.
- Six equivalent requests were emitted during one retry cluster. The broker had
  recorded 21,432 enqueues, 19,863 admissions, and 1,537 timeouts.
- Background Telegram and emotion inference could enter the host broker while a
  foreground TUI task was active.
- The workboard had 19 cards, 15 marked `in_progress`, no completed cards, and
  191 events. Evidence was present but rejected by prose-substring matching.
- Failure cards accumulated after later success because the persistent failure
  store and workboard were not resolved together.
- The Telegram bridge held the expected cooperative locks and opened its
  database, but status data could not distinguish successful empty polls from
  hidden nonfatal polling failures. Poll offsets advanced before durable intake.

These values are diagnostic baselines, not permanent thresholds.

## Architectural decisions

1. **One process-wide inference pressure authority.** Every local or brokered
   inference declares a workload class. Foreground work can yield or cancel
   background work before another model request is admitted.
2. **One logical broker request.** A retry keeps or resumes one admission claim.
   It does not create an unbounded series of independent queue entries.
3. **One canonical model projection.** Every turn is structurally normalized.
   Semantic compaction remains pressure-driven and evidence-preserving.
4. **Typed evidence, not prose coincidence.** Workboard verification uses
   explicit predicates and receipts tied to targets and revisions.
5. **Host-derived completion.** The model can request completion. A deterministic
   readiness snapshot decides whether completion is admissible.
6. **Durable intake before acknowledgement.** Telegram updates enter a spool
   before the contiguous offset advances. Restart replays nonterminal entries.
7. **Additive rollout.** New behavior is feature-flagged, shadowable, reversible,
   and verified before old paths are removed.

## Work-order index

| ID | Work order | Depends on | Current evidence state |
|---|---|---|---|
| WO-00 | [Hermetic Test Boundary](./WO-00-hermetic-test-boundary.md) | none | deterministic boundary accepted |
| WO-01 | [Inference Pressure Scheduler](./WO-01-inference-pressure-scheduler.md) | WO-00 | deterministic production boundary accepted |
| WO-02 | [Resumable Broker Admission](./WO-02-resumable-broker-admission.md) | WO-00, WO-01 | deterministic boundary accepted and broker activated |
| WO-03 | [Workboard and Failure Lifecycle V2](./WO-03-workboard-failure-lifecycle-v2.md) | WO-00 | deterministic boundary accepted |
| WO-04 | [Canonical Context Projection](./WO-04-canonical-context-projection.md) | WO-00, WO-03 | deterministic production projection accepted |
| WO-05 | [Completion Readiness Authority](./WO-05-completion-readiness-authority.md) | WO-03, WO-04 | deterministic authority accepted |
| WO-06 | [Durable Telegram Intake and Health](./WO-06-durable-telegram-intake-health.md) | WO-00, WO-01 | deterministic continuity accepted |
| WO-07 | [Integration, Rollout, and Canaries](./WO-07-integration-rollout-canary.md) | WO-00 through WO-06 | deterministic aggregate plus shadow/rollback complete; physical-device, operator, and live-inference canaries remain |
| WO-19 | [Clean Build Reproducibility](./WO-19-clean-build-reproducibility.md) | WO-00 | deterministic clean-checkout boundary accepted |

The cross-cutting requests for Telegram behavior, safe media tooling,
governance, reminders, ontology, adjudication, prompt policy, cross-platform
runtime support, the daemon frontend, and pause/stop/resume interruption
semantics are preserved in the
[extended work-order register](./EXTENDED-WORK-ORDERS.md). They are part of
this program and use the same evidence and completion rules.

The [master tracker](./TRACKER.md) is the canonical status ledger. The
[traceability matrix](./TRACEABILITY.md) maps every observed failure to code,
tests, and acceptance evidence. Operational commands and results are recorded
in [the audit log](./AUDIT.md). The
[remaining gap-closure register](./GAP-CLOSURE-WORK-ORDERS.md) records the
second-audit gaps that broad earlier completion labels did not prove.
The [final deterministic closure receipt](./FINAL-DETERMINISTIC-CLOSURE-EVIDENCE.md)
records the aggregate release gates and the exact external canaries that remain.

## Program invariants

- Unit tests cannot make an unmocked network connection.
- Foreground work cannot be delayed by new background inference admissions.
- A retryable broker wait cannot hard-exit the user task.
- A permanent broker placement refusal cannot retry forever.
- One logical request produces one diagnostic series, regardless of retries.
- Workboard diagnostics have bounded cardinality.
- A later phase cannot activate until its dependencies have accepted completion.
- A successful action resolves the matching failure epoch in all durable stores.
- Current user authority and active work state occur once in the model-visible
  projection.
- Tool schemas have an explicit byte/token budget and a finite promotion TTL.
- A generic shell invocation is not verification evidence by itself.
- Telegram offsets never advance past an update that has not been durably
  recorded.
- Every service restart has a pre-change health capture and a post-change
  verification result.

## Delivery policy

Each coherent work order receives a scoped commit after its tests pass. Omnius
commits go to the tracked `main` branch of `open-agents`. Broker commits go to
the tracked `main` branch of `ollama-unify`. Fetch precedes push. No unrelated
dirty files, especially the existing `publish/` changes, enter these commits.

Live inference is the last gate. Before any token-generating request, the exact
endpoint, model tag, and runner placement must pass the repository hardware
preflight. A live canary is omitted, not redirected, if that mapping cannot be
proved.
