Skip to content

feat: compaction-proof Nelson at every phase boundary#118

Merged
harrymunro merged 2 commits into
mainfrom
worktree-mighty-yawning-moonbeam
May 8, 2026
Merged

feat: compaction-proof Nelson at every phase boundary#118
harrymunro merged 2 commits into
mainfrom
worktree-mighty-yawning-moonbeam

Conversation

@harrymunro
Copy link
Copy Markdown
Collaborator

Summary

  • /compact is now safe at every phase boundary except inside Step 5. Admiral state persists to disk after each step instead of living only in chat context.
  • cmd_recover is phase-aware: the briefing carries current_phase, surfaces Phase: … in text output, and emits per-phase recommended_actions (with a missing-battle-plan.md warning in BATTLE_PLAN / FORMATION / PERMISSION).
  • SKILL.md §3 now directs the admiral to write the drafted plan to {mission-dir}/battle-plan.md before Step 4 — the prose authority alongside battle-plan.json as the structured authority.

Why

Issue #113 — the only natural compaction window today is between Steps 4 and 5. Step 3's plan exists only in admiral chat context, so compacting there loses the prose draft. cmd_recover returned the same generic briefing regardless of phase, so a resumed admiral couldn't pick up where the last one left off without rebuilding state.

Changes

  • skills/nelson/scripts/nelson_data_lifecycle.py — add PHASE_RECOVERY_GUIDANCE (one entry per non-UNDERWAY phase), make _build_recovery_briefing phase-aware, print Phase: in _format_recovery_text. UNDERWAY (and unknown) keep the existing handoff-packet-derived actions.
  • skills/nelson/scripts/test_nelson_data.py — parameterised test_recover_phase_specific_actions over all six phases, test_recover_warns_when_battle_plan_md_missing, test_recover_includes_phase_in_briefing, plus updated assertions on test_recover_text_output and test_full_handoff_lifecycle.
  • skills/nelson/SKILL.md — new "Persist the drafted plan" directive in §3 marking the safe compaction point; softened the template pointer line; added Admiralty Doctrine bullet on safe /compact windows.
  • skills/nelson/references/damage-control/session-resumption.md — appended "Safe compaction windows" subsection.
  • skills/nelson/references/admiralty-templates/battle-plan.md — preamble declaring .md as prose authority and .json as execution-data authority.

Out of scope (follow-ups noted in plan risks)

  • Hard phase-exit enforcement of battle-plan.md (needs cmd_headless interaction first).
  • New battle_plan_drafted event type — file existence is sufficient signal for this pass.
  • PreCompact hook / two-phase permission gate.

Test plan

  • python3 -m pytest skills/nelson/scripts/ -k Recover -v — 15 passed (7 existing + 8 new/updated).
  • python3 -m pytest skills/nelson/scripts/ — 286 passed.
  • Manual smoke: initrecover (SAILING_ORDERS guidance), phase advancerecover (ESTIMATE guidance), advance to BATTLE_PLAN → recover shows missing-battle-plan.md warning; warning disappears after writing the file.
  • bash scripts/check-references.sh — all cross-references valid.

harrymunro added 2 commits May 8, 2026 13:44
Today the only natural compaction window is between Step 4 and Step 5.
Step 3's drafted plan lives only in admiral chat context, and cmd_recover
emits the same generic briefing regardless of phase, so a resumed admiral
can't pick up where the last one left off without rebuilding state.

Three coordinated changes:

- Persist battle-plan.md at the end of Step 3 — SKILL.md §3 now directs
  the admiral to write the drafted plan to {mission-dir}/battle-plan.md
  before Step 4. The .md becomes the prose authority; battle-plan.json
  remains the structured authority.
- Phase-aware cmd_recover — new PHASE_RECOVERY_GUIDANCE table drives
  recommended_actions per phase. UNDERWAY (and unknown) keep the
  existing handoff-packet logic. BATTLE_PLAN/FORMATION/PERMISSION
  prepend a warning when battle-plan.md is missing on disk. Phase
  is now surfaced in both JSON briefing (current_phase) and text
  output (Phase: …).
- Document safe compaction windows in SKILL.md Admiralty Doctrine and
  references/damage-control/session-resumption.md. The unsafe window
  is the single tightly coupled turn inside Step 5.

Tests: 8 new Recover tests covering phase guidance, missing
battle-plan.md warning, and phase visibility; updated existing
text-output and full-handoff-lifecycle tests. 286 tests pass.

Closes #113.
- Rename _BATTLE_PLAN_MD_REQUIRED_PHASES to BATTLE_PLAN_MD_REQUIRED_PHASES
  so tests can import the set directly instead of re-listing phases.
- Add comment explaining phase guidance precedence over handoff packets
  in anomalous mid-flight states.
- Parameterise test_recover_warns_when_battle_plan_md_missing over the
  required-phases set so FORMATION and PERMISSION are also locked in as
  regression tests (was BATTLE_PLAN only).
@harrymunro harrymunro merged commit 2a06662 into main May 8, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant