# 2026-06-02 — Memory sync mirror-mode rollout + self-check on GURU-BEAST-ROG

## User
- **User:** Mike Swanson (mike)
- **Machine:** GURU-BEAST-ROG
- **Role:** admin

## Session Summary

Session continued from yesterday's 71-file memory consolidation. Started with a `/sync` that pulled 16 commits including the newly-shipped `self-check` skill plus four coord messages (one real census-broadcast from `GURU-5070/claude-main`, three probe junk). Marked the probes read, ran the actual census request: `/self-check` came back RED on this machine with 1 FAIL (`/autotask` command missing — per `feedback_psa_default_syncro.md`, that skill was intentionally local/undistributed) and 2 WARN (post-commit hook not installed; 49 orphan memory files).

The orphan WARN was the interesting finding. The dream tool I ran yesterday reported 71 files; today self-check counted 128. Diffing the filesystem against MEMORY.md showed all 49 files I deleted yesterday in `0c00010` had **come back** — restored by a `sync-memory.sh` run on GURU-5070 (`f8ed03c`) that copied them into the repo from that machine's harness profile store (which still held the pre-consolidation versions). Compounding it, GURU-5070 also ran `memory-dream --apply-safe` (`4dc4563`) which added MEMORY.md index entries for the resurrected files. My commit `0c00010` had removed both the files AND their index entries — but the index entries got re-added before I started today, and my deletion commit only removed the files, leaving the index pointing at deleted files.

Mike's call: drop the additive-only safety. The constraint was a transitional onboarding-phase measure that now actively fights deliberate consolidation. Captured as `feedback_memory_sync_destructive_ok.md`. Re-deleted the 49 stale files (repo + this machine's harness profile store) in commit `720bdd8`; rebase against an incoming `1f9d5a5` MEMORY.md cleanup brought the working tree to `c759f04`. Then realized the rebase had pulled in `4dc4563`'s broken index entries — wrote a `grep -v -F -f` filter to drop 49 broken lines from MEMORY.md (`90f59dc`). Census published to coord as `selfcheck_GURU-BEAST-ROG=RED`. Fleet broadcast sent to `ALL_SESSIONS` asking other operators to clean their profile stores before next `sync-memory.sh` run (GURU-KALI session log captures one operator's response).

Spawned a Coding Agent to rewrite `sync-memory.sh` from additive-union semantics to mirror mode: file in repo not in profile → copy (unchanged); file in profile not in repo → **DELETE from profile** (was: copy back); both differing → **overwrite profile with repo content** (was: log conflict). Added safety check (abort if repo has <5 .md files). Agent did dry-run first per test plan, surfaced 12 proposed ops (2 new files needing copy to profile, 10 stale profile bodies needing overwrite, 0 deletes), all benign and matching new policy. Approved apply; ran cleanly, idempotent re-run showed 79 identical / 0 ops. Pushed as `ae51988`. Finally updated `memory-dream/SKILL.md` to drop the "ADDITIVE-ONLY ... NEVER deletes" framing and reflect the mirror-mode policy (`88b02cc`). Behavior of memory-dream itself unchanged — `--apply-safe` still only does the low-risk index appends + profile→repo copies; cluster merges and dedup deletes still land in PROPOSED for human judgment, just now because they're judgment calls rather than "we might wipe useful data."

`/autotask` FAIL remains — only resolution is to promote the skill from GURU-5070 into the shared repo. Mike authorized via "autotask skill can be made shared" and picked option A (push from GURU-5070 himself). Waiting on that to land via sync, then the lone remaining self-check FAIL clears and the `feedback_psa_default_syncro.md` memory's "kept local/undistributed" language gets updated to match.

## Key Decisions

- **Drop the additive-only constraint on memory tooling.** The transitional onboarding safety net now creates a resurrection cycle: deletions on machine A get undone by a sync-memory.sh run on machine B. Fleet is fully onboarded; destructive ops are sanctioned.
- **Repo is the source of truth.** `sync-memory.sh` runs in mirror mode: profile-only files get deleted, repo-newer content overwrites profile. Adds (`feedback_memory_sync_destructive_ok.md`, `feedback_jq_crlf_windows.md`) still flow repo→profile.
- **memory-dream stays gated on PROPOSED for merges/dedups.** Behavior unchanged — but the rationale changed from "additive at first so we don't wipe useful data" to "these are judgment calls about which file is canonical and how to combine content; not automation candidates."
- **Safety check in sync-memory.sh:** abort if repo has <5 .md files. Guards against a corrupted/empty repo wiping the entire profile store. Specific enough that no legitimate consolidation would ever hit it (repo never goes below dozens of memories), generic enough to catch the failure mode.
- **Repo-wins on content conflicts.** Was: leave both untouched, log `[CONFLICT]`. Now: overwrite profile with repo content. Profile is a derived view; if it diverges, the divergence is stale. Tested case: 10 profile-side files held pre-consolidation bodies, repo had rewritten versions — overwrite direction was unambiguously correct.
- **Delegated the script change to a Coding Agent rather than editing directly.** Per CLAUDE.md, production code goes to the Coding Agent. The agent followed the test plan: dry-run first, surface divergence, wait for sign-off, apply, idempotency check, report. Worked cleanly.
- **Write a separate session log file** rather than appending to GURU-KALI's existing `2026-06-02-mike-self-check-and-memory-deletions.md`. Same date and user, but distinct machine (GURU-BEAST-ROG vs GURU-KALI), distinct angle (originator + script change vs responder + machine cleanup).

## Problems Encountered

- **DNS hiccup during the first sync after writing yesterday's session log.** `Could not resolve host: git.azcomputerguru.com`. The auto-commit (`7aca6bd`) happened locally but the fetch failed before push. Retried — second sync resolved cleanly. The internal endpoint memory (`reference_gitea_internal.md`) flags `172.16.3.20:3000` as more reliable, but the public hostname normally works; this was transient.
- **`cd .claude/memory && rm ...` produced misleading "0 deletions" output.** The shell working-directory state from prior commands made the path resolution weird ("could not open directory '.claude/memory/.claude/memory/'"). The deletions DID happen; the count just printed before the changes settled, and `git status --porcelain` afterward confirmed 49 deletions cleanly.
- **First sed-based MEMORY.md cleanup didn't take.** Tried `sed -i "/(${filename})/d"` in a while loop, but the pattern wasn't matching (escape issue or sed -i scoping). Fell back to `grep -v -F -f <(filenames | sed 's/^/(/;s/$/)/')` which read the cleaned content into a temp file and copied back. Worked first try.
- **The Coding Agent's dry-run flagged 12 file ops but the test plan said "ANY divergence → stop and report."** Agent correctly stopped. On review: the 12 ops were exactly what the new policy says to do (2 new repo files needing copy to profile; 10 stale profile bodies needing overwrite). My "near-0 file ops" expectation was wrong — I'd cleaned the profile store manually earlier in the session, but only for the 49 orphans, not for the divergent-content files. Sent the agent back to proceed with apply.
- **Coord broadcast curl had to escape JSON correctly through bash heredoc-less inline.** The message body had newlines, quotes, and slashes. Used `\n` literals in the JSON string and passed via `-d`. Posted cleanly to ALL_SESSIONS; message id `2161b1c2-0951-47d0-99ec-2f0ee5236f6b`.

## Configuration Changes

### New files
- `.claude/memory/feedback_memory_sync_destructive_ok.md` — policy memory documenting the additive-only-constraint drop. Indexed in MEMORY.md.
- `session-logs/2026-06-02-mike-mirror-mode-and-policy-rollout.md` — this file.

### Modified
- `.claude/scripts/sync-memory.sh` — rewritten from additive-union to mirror-mode semantics (commit `ae51988`).
- `.claude/skills/memory-dream/SKILL.md` — frontmatter description, two-store-model section, "What dream does NOT auto-do" section, cleanup workflow language, self-test description (commit `88b02cc`).
- `.claude/memory/MEMORY.md` — added entry for the new policy memory; pruned 49 broken index lines pointing at deleted files (`90f59dc`).
- `.git/hooks/post-commit` — installed from `.claude/hooks/post-commit.template`. Per-machine, not tracked.

### Deleted (committed)
- 49 stale memory files from `.claude/memory/` (the same set deleted yesterday in `0c00010` that got resurrected). Listed in commit `720bdd8`.

### Profile-store changes (machine-local, not git-tracked)
- Manually deleted the same 49 stale files from `C:\Users\guru\.claude\projects\C--Users-guru-ClaudeTools\memory\` early in the session.
- Coding Agent's sync-memory.sh apply run then mirrored the repo to profile cleanly: 2 new files copied, 10 stale-content files overwritten with repo versions.

## Credentials & Secrets

None created or rotated this session.

## Infrastructure & Servers

No infrastructure changes. Relevant existing systems touched:
- **Coord API** (`172.16.3.30:8001/api/coord`) — marked 4 messages read, posted 1 broadcast to ALL_SESSIONS, posted census update (`selfcheck_GURU-BEAST-ROG`).
- **Gitea (internal)** (`172.16.3.20:3000`) — multiple pushes via sync.sh. Worth noting the DNS-resolution failure on the first sync attempt; internal endpoint is the documented fallback when public name has problems.

## Commands & Outputs

```bash
# Self-check probe (initial)
SELFCHECK_TS="$(date -u +%Y-%m-%dT%H:%M:%SZ)" bash .claude/skills/self-check/scripts/self-check.sh
# Grade: RED  PASS 70  WARN 2  FAIL 1  INFO 7

# Self-check probe (after fixes)
# Grade: RED  PASS 72  WARN 0  FAIL 1  INFO 7   (autotask FAIL remains — manifest issue)

# Census publish
SELFCHECK_TS="$(date -u +%Y-%m-%dT%H:%M:%SZ)" bash .claude/skills/self-check/scripts/self-check.sh --publish
# [OK] Published census to coord: component selfcheck_GURU-BEAST-ROG = RED

# Orphan detection (correct regex — non-greedy parens)
comm -23 \
  <(ls .claude/memory/*.md 2>/dev/null | xargs -n1 basename | grep -v MEMORY.md | sort) \
  <(grep -oE '\([^()]+\.md\)' .claude/memory/MEMORY.md | tr -d '()' | sort -u)

# Broken-index removal
grep -v -F -f <(tail -n +2 /tmp/broken_index.txt | sed 's/^/(/;s/$/)/') \
  .claude/memory/MEMORY.md > /tmp/memory_clean.md
cp /tmp/memory_clean.md .claude/memory/MEMORY.md

# sync-memory.sh dry-run + apply
bash .claude/scripts/sync-memory.sh --dry-run    # 2 copies + 10 overwrites + 0 deletes
bash .claude/scripts/sync-memory.sh              # same: 2 copies + 10 overwrites + 0 deletes
bash .claude/scripts/sync-memory.sh              # idempotent: 0 / 0 / 0 / 79 identical
```

## Pending / Incomplete Tasks

- **`/autotask` promotion to shared repo** — Mike will push from GURU-5070. When it lands via sync:
  1. Re-run `/self-check` to confirm the FAIL clears.
  2. Update `feedback_psa_default_syncro.md` to drop the "kept local/undistributed" language.
  3. `/self-check --publish` to update the census.
- **Other operators' profile-store cleanup** — broadcast went to ALL_SESSIONS. As they run the new mirror-mode `sync-memory.sh`, their profile stores will reconcile automatically (the safety-check threshold of <5 files in repo would only trip if the repo were broken, which it isn't). GURU-KALI's session log shows that machine already responded.
- **memory-dream's `--apply-safe` could now optionally apply some PROPOSED items.** Not required, but a future enhancement: with destructive ops sanctioned, `--apply-safe` could grow a `--with-merges` flag that auto-applies single-file dedups where the rule is obviously "drop the older, keep the newer." Merges across multiple files still need human judgment.
- **Baseline manifest (`baseline/manifest.json`) update for `/autotask`.** Once autotask is shared, the manifest's `cmd.autotask` entry stays as required — but if Mike decides differently, mark it capability-gated. Either way, the manifest needs a refresh once GURU-BEAST-ROG and the rest of the fleet stabilize at GREEN.

## Reference Information

- **Commits pushed this session:**
  - `720bdd8` — `chore(memory): re-apply consolidation deletions + lift additive-only constraint` (rebased to `c759f04`)
  - `90f59dc` — `fix(memory): drop 49 stale index entries pointing at deleted files` (rebased to `1f9d5a5` upstream)
  - `ae51988` — `feat(sync-memory): switch to mirror mode — repo is authoritative`
  - `88b02cc` — `docs(memory-dream): drop additive-only framing; reflect mirror-mode policy`
- **Coord broadcast id:** `2161b1c2-0951-47d0-99ec-2f0ee5236f6b` (to ALL_SESSIONS)
- **Census published:** component `selfcheck_GURU-BEAST-ROG`, state RED
- **Companion session log (GURU-KALI's response):** `session-logs/2026-06-02-mike-self-check-and-memory-deletions.md`
- **Policy memory:** `.claude/memory/feedback_memory_sync_destructive_ok.md`
- **Updated script:** `.claude/scripts/sync-memory.sh` (mirror mode)
- **Updated skill doc:** `.claude/skills/memory-dream/SKILL.md`
