Skip to main content
Status: draft · Version 1.0 · Filed 2026-04-21
Closes the two SPEC-021 §4.4 hygiene triggers shipped as deferred in Phase 4 (phase-advance and rename). Staleness already works; these two do not. Problem. To detect “phase advanced since last wrap,” the server needs two values: current project.phase (available) and phase-as-of-last-wrap (not stored anywhere). Same for rename. Solution. Add three nullable columns to the projects table: last_wrapped_phase, last_wrapped_name, last_wrapped_at. Written by prism_wrap on exit, read by prism_wrap on entry for comparison. Null values → no trigger fires (first-ever wrap has nothing to compare against). Server change. Update _compute_hygiene_triggers in mcp/server.py to take the full project dict alongside recent_deltas. Add phase-advance and rename detection. Update prism_wrap to patch the project row after delta storage but after trigger computation (order matters — write-back must not self-erase the comparison). Patch failure logs warning; does not fail prism_wrap (delta is already stored). Summary rendering (_render_memory_summary) unchanged. Minor polish: when phase-advance fires, the instruction text names the old→new phase transition explicitly. Non-goals. Not changing when prism_wrap is called (SPEC-023’s concern). Not adding triggers beyond the three in SPEC-021 §4.4. Not changing the summary format. Not auto-updating Claude Desktop / ChatGPT user-memory fields (paste-based workflow unchanged). Open questions.
  • Q1: Is last_wrapped_at worth the extra column? Lean yes, but cuttable if backend cost is material.
  • Q2: Should phase-advance fire on prism_start as well as prism_wrap? Spec §4.4 says wrap-only. Lean: ship wrap-only per SPEC-021, revisit if start-side nudge proves more valuable in practice.
  • Q3: Phase rollbacks (Phase 4 → Phase 3) — fire the trigger? Lean: any inequality fires, don’t overfit.
  • Q4: Write-back atomicity — gate on delta write succeeding? Lean yes.
Implementation. One PR. Half-day backend (columns + context response + patch endpoint + migration). Half-day MCP + smoke tests. 9-case test matrix in the mdx. Relationships. Companion to SPEC-023. ADR-24 unchanged — this is implementation completion of already-accepted architecture, no new ADR. Full spec on disk: /Users/fpn/projects/Prism/docs/specs/spec-022-v0-1-phase-advance-rename-wrap-triggers.mdx (drafted 2026-04-20 PM, Lola + Frank, during SPEC-021 implementation audit).
Last modified on April 22, 2026