# Engram Consolidation Implementation Plan

> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.

**Goal:** Consolidate the legacy Goose-hosted Engram data store into the canonical project repo at `entities/telemetry/`, then scrub all stale path references.

**Architecture:** Copy-verify-delete pattern (never destructive until checksums confirmed). Source is `/home/geodesix/.goose/engram/`. Destination is `/home/geodesix/engram/entities/telemetry/`. Final step repoints all `.py`/`.yaml` references to the new absolute path.

**Tech Stack:** bash, rsync, du, diff, Python (sed/grep for path rewriting)

---

## Pre-flight Facts

| Item | Value |
|------|-------|
| Source | `/home/geodesix/.goose/engram/` |
| Non-.git files in source | **40,563** |
| Source data size (excl. .git) | **7.6 G** |
| Source `.git` size | **4.0 G** (embedded legacy repo — see Task 0) |
| Destination | `/home/geodesix/engram/entities/telemetry/` (does not exist yet) |
| Stray items to purge | `/home/geodesix/.goose/engram_backup_tiered_20260319_045257.tar.gz` |
| Files with `.goose` path refs | `util/import_goose.py` |

---

## ⚠️ Decision Required Before Task 1

The source contains two large sub-trees that may not belong in the consolidated repo:

| Sub-tree | Size | Recommendation |
|----------|------|----------------|
| `.git/` (embedded git history of legacy repo) | 4 G | **Exclude** — 4G of orphaned objects; history lives in remote |
| `venv/` (Python virtual environment) | unknown | **Exclude** — regenerable, not data |
| `__pycache__/` | small | **Exclude** — regenerable |

The plan below **excludes** these three trees by default. Override at execution time if you need them.

---

## Task 0: Create Destination Directory

**Files:**
- Create: `entities/telemetry/` (directory only)

- [ ] **Step 1: Create the destination**

```bash
mkdir -p /home/geodesix/engram/entities/telemetry
```

- [ ] **Step 2: Verify it exists**

```bash
ls -la /home/geodesix/engram/entities/telemetry
```
Expected: empty directory, no errors.

---

## Task 1: Copy Source → Destination (rsync dry-run first)

**Files:**
- Source: `/home/geodesix/.goose/engram/`
- Destination: `/home/geodesix/engram/entities/telemetry/`

- [ ] **Step 1: Capture pre-copy baseline sizes**

```bash
echo "=== SOURCE ===" && du -sh /home/geodesix/.goose/engram/ --exclude=.git --exclude=venv --exclude=__pycache__
echo "=== DEST (should be 0) ===" && du -sh /home/geodesix/engram/entities/telemetry/
```

Record both numbers — you'll compare them after the copy.

- [ ] **Step 2: Dry-run to verify what will be transferred**

```bash
rsync -av --dry-run \
  --exclude='.git/' \
  --exclude='venv/' \
  --exclude='__pycache__/' \
  /home/geodesix/.goose/engram/ \
  /home/geodesix/engram/entities/telemetry/ \
  2>&1 | tail -20
```

Expected: list of files ending with `sent X bytes  received Y bytes`.

- [ ] **Step 3: Execute the copy**

```bash
rsync -av \
  --exclude='.git/' \
  --exclude='venv/' \
  --exclude='__pycache__/' \
  /home/geodesix/.goose/engram/ \
  /home/geodesix/engram/entities/telemetry/ \
  2>&1 | tee /tmp/engram_rsync.log
echo "Exit code: $?"
```

Expected: exit code 0.

---

## Task 2: Safety Diff — Verify File Sizes Match

- [ ] **Step 1: Compare file counts**

```bash
echo "=== SOURCE file count ===" && find /home/geodesix/.goose/engram/ -not -path '*/.git/*' -not -path '*/venv/*' -not -path '*/__pycache__/*' -type f | wc -l
echo "=== DEST file count ===" && find /home/geodesix/engram/entities/telemetry/ -type f | wc -l
```

Expected: both numbers match.

- [ ] **Step 2: Compare disk usage**

```bash
echo "=== SOURCE ===" && du -sh /home/geodesix/.goose/engram/ --exclude=.git --exclude=venv --exclude=__pycache__
echo "=== DEST ===" && du -sh /home/geodesix/engram/entities/telemetry/
```

Expected: sizes match within a few KB (filesystem block rounding).

- [ ] **Step 3: Spot-check critical files exist in destination**

```bash
for f in engram.toml engram-doctor.py README.md beliefs_hot.json; do
  [ -f "/home/geodesix/engram/entities/telemetry/$f" ] && echo "OK: $f" || echo "MISSING: $f"
done
```

Expected: all `OK`.

- [ ] **Step 4: STOP — Report results to user for approval before proceeding to purge**

Do NOT continue to Task 3 until the user explicitly approves.

---

## Task 3: Purge Legacy Source (ONLY after user approval)

- [ ] **Step 1: Remove source directory**

```bash
rm -rf /home/geodesix/.goose/engram/
```

- [ ] **Step 2: Verify it's gone**

```bash
[ -d /home/geodesix/.goose/engram/ ] && echo "ERROR: still exists" || echo "OK: removed"
```

- [ ] **Step 3: Remove stray backup tarball**

```bash
rm -f /home/geodesix/.goose/engram_backup_tiered_20260319_045257.tar.gz
[ -f /home/geodesix/.goose/engram_backup_tiered_20260319_045257.tar.gz ] && echo "ERROR: still exists" || echo "OK: removed"
```

- [ ] **Step 4: List remaining .goose contents (do NOT auto-delete these)**

```bash
ls -la /home/geodesix/.goose/
```

The remaining dirs (`bin/`, `logs/`, `memory/`, `secrets/`, `tools/`) are Goose agent infrastructure — **present these to the user** and ask if they should also be removed. Do not delete them automatically.

---

## Task 4: Repoint Path References in .py and .yaml Files

- [ ] **Step 1: Find all files with .goose path references**

```bash
grep -r '\.goose' /home/geodesix/engram --include="*.py" --include="*.yaml" -n
```

Expected: at minimum `util/import_goose.py`.

- [ ] **Step 2: Preview replacements (dry-run)**

```bash
grep -n '\.goose' /home/geodesix/engram/util/import_goose.py
```

Review each line — confirm the replacement `/home/geodesix/.goose/engram` → `/home/geodesix/engram/entities/telemetry` is correct for each context.

- [ ] **Step 3: Apply replacements**

```bash
# Replace the full goose engram path
sed -i 's|/home/geodesix/\.goose/engram|/home/geodesix/engram/entities/telemetry|g' /home/geodesix/engram/util/import_goose.py
# Also catch tilde form
sed -i 's|~/.goose/engram|/home/geodesix/engram/entities/telemetry|g' /home/geodesix/engram/util/import_goose.py
```

- [ ] **Step 4: Verify no residual .goose/engram references remain**

```bash
grep -r '\.goose/engram\|~/.goose/engram' /home/geodesix/engram --include="*.py" --include="*.yaml"
```

Expected: no output.

- [ ] **Step 5: Commit the path update**

```bash
cd /home/geodesix/engram
git add util/import_goose.py
git commit -m "refactor: repoint goose legacy paths to entities/telemetry

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>"
```

---

## Verification Checklist

After all tasks:

```bash
# 1. Destination exists and has content
du -sh /home/geodesix/engram/entities/telemetry/

# 2. Source is gone
[ -d /home/geodesix/.goose/engram ] && echo "FAIL" || echo "PASS: source deleted"

# 3. Backup tarball is gone
[ -f /home/geodesix/.goose/engram_backup_tiered_20260319_045257.tar.gz ] && echo "FAIL" || echo "PASS: tarball deleted"

# 4. No stale .goose/engram refs in code
grep -r '\.goose/engram' /home/geodesix/engram --include="*.py" --include="*.yaml" && echo "FAIL: refs remain" || echo "PASS: no refs"
```

All four should show PASS.
