# v8.16 Older Follow-Ons (Plugin-Feasible) Implementation Plan

> **For Claude:** REQUIRED SUB-SKILL: Use superpowers:executing-plans to implement this plan task-by-task.

**Goal:** Deliver the remaining non-paper legacy follow-ons that are feasible entirely inside OpenClaw Engram plugin boundaries.

**Architecture:** Ship three scoped slices: (1) migration CLI suite from v2.3 roadmap, (2) v4 shared-context cross-signal enrichment (deterministic + optional semantic pass), and (3) v5 compounding artifacts expansion (rubrics/provenance/outcome weighting/promotions). Keep each slice behind explicit config gates with fail-open behavior.

**Tech Stack:** TypeScript, existing CLI/orchestrator/storage/shared-context/compounding modules, node:test, existing OpenClaw plugin hooks/tools.

---

## Scope (In)

1. v2.3 migration command group:
- `openclaw engram migrate rescore-importance`
- `openclaw engram migrate rechunk`
- `openclaw engram migrate normalize-frontmatter`
- `openclaw engram migrate reextract --model <id> [--limit N]`

2. v4 cross-signal follow-on:
- deterministic cross-signal computation from shared outputs + feedback.
- optional semantic enhancer path behind config flag.

3. v5 compounding follow-on:
- generate `rubrics.md` and provenance-linked weekly artifacts.
- outcome-aware weighting in synthesis summaries.
- optional curated promotion candidate output for shared namespace.

## Scope (Out)

- FAISS backend (explicitly deferred for now).
- OpenClaw core identity API dependency (separate blocked plan).

## Task 1: Add migration CLI command group

**Files:**
- Modify: `src/cli.ts`
- Modify: `src/storage.ts`
- Modify: `src/importance.ts`
- Test: `tests/cli-migrate.test.ts`
- Docs: `docs/operations.md`, `docs/import-export.md`

**Steps:**
1. Add `engram migrate` command namespace with subcommands and dry-run defaults.
2. Implement `normalize-frontmatter` (safe round-trip normalization only).
3. Implement `rescore-importance` using current local importance engine.
4. Implement `rechunk` using existing chunking heuristics.
5. Implement `reextract` plumbing with explicit model arg and hard safety caps.
6. Add tests for dry-run/no-op behavior and write-path correctness.

## Task 2: Add deterministic cross-signal generation

**Files:**
- Modify: `src/shared-context/manager.ts`
- Modify: `src/tools.ts`
- Test: `tests/shared-context-cross-signals.test.ts`
- Docs: `docs/shared-context.md`

**Steps:**
1. Add a deterministic extractor for entity/topic overlap from daily outputs.
2. Write `shared-context/cross-signals/<YYYY-MM-DD>.json` during daily curation.
3. Append cross-signal summary section to roundtable output.
4. Add tests for empty day, single-source day, and multi-source overlap.

## Task 3: Add optional semantic cross-signal enhancer

**Files:**
- Modify: `src/types.ts`
- Modify: `src/config.ts`
- Modify: `src/shared-context/manager.ts`
- Test: `tests/config-shared-context-semantic.test.ts`
- Test: `tests/shared-context-cross-signals-semantic.test.ts`
- Docs: `docs/config-reference.md`, `docs/shared-context.md`

**Steps:**
1. Add config flags (`sharedCrossSignalSemanticEnabled`, timeout/max-candidate bounds).
2. Implement optional semantic pass with strict timeout and fail-open fallback to deterministic output.
3. Add guardrails to prevent blocking daily curation.
4. Add config and behavior tests.

## Task 4: Expand compounding artifacts (rubrics + provenance + outcomes)

**Files:**
- Modify: `src/compounding/engine.ts`
- Modify: `src/tools.ts`
- Modify: `src/orchestrator.ts`
- Test: `tests/compounding-weekly-artifacts.test.ts`
- Test: `tests/compounding-outcome-weighting.test.ts`
- Docs: `docs/compounding.md`

**Steps:**
1. Add `compounding/rubrics.md` output with stable format.
2. Add provenance references in weekly report sections (source entry IDs/lines).
3. Add outcome-aware weighting summaries (applied/skipped/failed by action type).
4. Add optional promotion candidate section (advisory only; no auto-write into shared memory).
5. Add tests covering no-feedback, mixed-feedback, and outcome-heavy weeks.

## Task 5: Verification and hardening

**Files:**
- Modify: `docs/ops/pr-review-hardening-playbook.md` (if needed for new invariants)

**Steps:**
1. Run:
   - `npm run check-types`
   - `npm test`
   - `npm run preflight:quick`
2. Run targeted tests for each new subsystem.
3. Validate no-regression behavior with all new flags disabled.
4. Update changelog entries by slice.

## Rollout

1. Ship per-slice PRs, not one mega PR.
2. Keep all new behavior gated.
3. Promote defaults only after production telemetry confirms latency and recall quality remain stable.
