// SPDX-License-Identifier: CC-BY-SA-4.0
// SPDX-FileCopyrightText: 2026 Jonathan D.A. Jewell (hyperpolymath)
= Planned Session Close Protocol Checklist
:toc:
:status: ACTIVE
:protocol: continuity / planned-session-close
:version: 1.1.0

This protocol defines the procedure for a planned session termination,
ensuring continuity and knowledge transfer to the next session.

== Canonical Command

`close planned <path>`

== Goal

Achieve a state-verified, groundable, and documented session closure that
allows the next assistant (or the same one later) to resume work with
zero context loss.

== Shared Core Reference

Every artefact produced by this protocol MUST follow the
link:../../SHARED-CONTINUITY-CORE.adoc[Shared Continuity Core].

== Procedure

1.  **Stop work**: Immediately cease all implementation or research tasks.
2.  **State check**: Run `git status && git branch` to confirm the local repo state.
3.  **Final build**: Run the project's primary build command (e.g., `just build`).
4.  **Final test**: Run the project's primary test suite (e.g., `just test`).
5.  **Grounding pass**: Execute `invariant-path doc-claims` on all new or modified prose.
6.  **Fix authoring bugs**: Resolve any `ungrounded` paths found by `doc-claims`.
7.  **Memory audit**: Verify that all persistent facts are recorded in `../../../../../../../home/hyper/.claude/projects/-var-mnt-eclipse-repos/memory/MEMORY.md`.
8.  **Residual risks**: Identify any remaining technical debt or unverified assumptions.
9.  **Goal definition**: Summarise the high-level objective of the session.
10. **Last action**: Record the final successful milestone reached.
11. **Next action**: Define the very first task for the next session.
12. **Blockers**: Explicitly list any obstacles that prevented completion.
13. **Commits log**: Compile a table of all local commits made during the session.
14. **Verifications log**: Compile a table of all manual or automated tests performed.
15. **Decision log**: List all significant architectural or philosophical choices.
16. **Open questions**: Document any deferred tasks or open questions.
17. **User invitations**: Formulate specific questions for the human owner.
18. **Discipline check**: Perform a meta-rule audit against the standing rules.
19. **Next protocol**: Explicitly set the `Recommended next protocol`.
20. **ID generation**: Generate a unique session ID (`YYYY-MM-DD-short-topic`).
21. **Assemble artefact**: Compile the data into the enriched 25-field format.
22. **Archival save**: Save as `SESSION-CLOSE-<ISO-date>-<topic>.adoc`.
23. **Integrity check**: Run `panic-attack assail` if required by the project.
24. **Commit closure**: Add and commit the closure artefact to the local repo.
25. **Final summary**: Provide a concise summary of the closure to the user.

== Post-Conditions

1.  A timestamped `.adoc` closure file exists in the repository.
2.  All authoring bugs found by `doc-claims` are fixed.
3.  The local git branch is clean (only intended unpushed commits exist).
4.  The next intended action is unambiguous.

== Verification Block

[cols="1,3,2",options="header"]
|===
| Item | What was verified | Result
| `doc-claims` | Grounding pass on the closure artefact | ✅
| `just test` | Verification of the broader project state | ✅
| `SHARED-CORE` | Adherence to the 25-field standard | ✅
|===

== Anti-Patterns

*   **Overwriting**: Never overwrite a single `SESSION_STATE` file.
*   **Stubs**: Never leave "forthcoming" or "TBD" in the closure document.
*   **Pushing**: Never push the closure to origin without explicit approval.
*   **Amnesia**: Forgetting to update `../../../../../../../home/hyper/.claude/projects/-var-mnt-eclipse-repos/memory/MEMORY.md` before closing.
