--- id: PMEM-WP-0009 type: workplan title: "Profile-Driven Lifecycle Rules" domain: markitect repo: phase-memory status: finished owner: codex topic_slug: phase-memory created: "2026-05-18" updated: "2026-05-18" state_hub_workstream_id: "1f7ec5d1-d468-4295-9512-8ee192d2afad" --- # PMEM-WP-0009: Profile-Driven Lifecycle Rules ## Goal Let Markitect-compatible memory profiles drive lifecycle planning directly, instead of requiring every retention, refresh, compaction, and transition parameter to be passed by hand. This moves the phase domain model and lifecycle planning rows toward their target maturity by turning profile policy into executable dry-run behavior. ## Current Evidence PMEM-WP-0008 added profile-derived runtime configuration. Lifecycle planning still depended on explicit CLI/runtime parameters for stale/delete thresholds, refresh digests, and compaction targets. ## Non-Goals - Mutate durable lifecycle state automatically. - Add physical delete behavior. - Replace review gates for stabilization, rigid promotion, refresh, or compaction. - Build a profile migration engine. ## Implementation Update - 2026-05-18 Implemented the first profile-driven lifecycle rules slice: - Added `LifecycleRuleConfig` with retention, transition, refresh, and compaction rule extraction from `ProfileIntent` or mappings. - Added profile-derived retention planning. - Added profile metadata phase transition rules. - Added `plan_lifecycle_from_profile(...)`. - Added `PhaseMemoryRuntime.plan_lifecycle_with_profile(...)`. - Added CLI `graph lifecycle --profile`. - Added local service runner support for profile-driven lifecycle planning. - Added docs, README examples, and regression tests. ## T01 - Add lifecycle rule config ```task id: PMEM-WP-0009-T01 status: done priority: high state_hub_task_id: "1038269f-9cb4-466b-a03d-80697f4ae439" ``` Derive retention, transition, refresh, and compaction rule settings from a profile. ## T02 - Plan retention from profile rules ```task id: PMEM-WP-0009-T02 status: done priority: high state_hub_task_id: "7a24d683-48ca-4d2f-b080-bf180d6b05db" ``` Support default retention rules and node-kind-specific retention rules. ## T03 - Plan phase transitions from profile metadata ```task id: PMEM-WP-0009-T03 status: done priority: medium state_hub_task_id: "7309a34d-245b-42d1-9b80-9fd493b318ee" ``` Support first-slice metadata transition rules with node kind, source phase, target phase, minimum age, and review-gated transition actions. ## T04 - Wire runtime and CLI profile lifecycle planning ```task id: PMEM-WP-0009-T04 status: done priority: high state_hub_task_id: "86174d24-0752-4e27-842b-75ef3023f790" ``` Expose profile-driven lifecycle planning through the runtime facade and CLI. Include local service runner handling for the same contract. ## T05 - Document and test the rule path ```task id: PMEM-WP-0009-T05 status: done priority: medium state_hub_task_id: "43cd7d24-0691-4bca-ac78-6e88040e432e" ``` Add lifecycle rule docs, README examples, fixture coverage, transition rule coverage, and CLI regression coverage. ## Acceptance Criteria - Profile retention rules can produce lifecycle actions. - Profile transition metadata can produce review-gated phase transitions. - Refresh and compaction remain deliberate caller/profile inputs. - Runtime and CLI envelopes expose the derived rule config. - Tests cover fixture-derived rules and explicit transition rules. ## Closure Review - 2026-05-18 Closed after adding executable profile lifecycle rules, runtime/CLI support, documentation, and deterministic regression tests.