| name | kb-session-wrap |
| description | Execute the GT-KB knowledge-first session wrap-up procedure. Collects durable session knowledge, updates governed memory surfaces, records blockers, syncs the current branch, and generates the next-session handoff prompt. |
| disable-model-invocation | true |
| argument-hint | ["session-id"] |
| allowed-tools | Bash, Read, Write, Edit, Grep, Glob, Agent |
| license | Proprietary - Remaker Digital |
| compatibility | ["claude-code >= 1.0"] |
| metadata | {"project":"groundtruth-kb","category":"session-management","owner-only":true,"references":["references/audit-checklist.md","references/handoff-template.md"]} |
Session Wrap-Up
Run the mutating GT-KB session wrap-up. The purpose is knowledge collection first: preserve what future agents need to know, where the canonical state now lives, what evidence supports it, and what remains blocked.
Arguments: $ARGUMENTS[0] = session ID, for example S347. If omitted, derive the session from memory/MEMORY.md, the current bridge/work item, or the latest owner-visible session marker.
Operating Rules
- Stay inside
E:/GT-KB.
- Run or review
kb-session-wrap-scan first when feasible. Treat wrap scanner outputs as evidence, not as the final wrap.
- Use live state for branch, commit, bridge, work items, and tests. Never assume
main, develop, or any release target.
- Do not force-add
groundtruth.db, .env*, snapshots, logs, transcript captures, or other ignored local evidence. Reference ignored evidence paths in reports when they matter.
- Do not hide blocked knowledge writes. If MemBase, Deliberation Archive, formal-artifact approval,
session_prompts, git, or external sync cannot be updated, record the blocker and the reason in the wrap summary.
- Mutating wrap-up actions still require applicable bridge, formal-artifact, owner-approval, credential, release, and deployment gates.
Phase 0: Live Inventory
Collect the state that the handoff and memory updates must account for:
git rev-parse --show-toplevel
git status --short --branch
git rev-parse HEAD
python scripts/wrap_capture_transcript.py --session-id <SESSION_ID>
python scripts/wrap_scan_hygiene.py --report-format markdown --write-report .groundtruth/session/wrap-scan-reports/<SESSION_ID>/wrap-scan-hygiene.md
python scripts/wrap_scan_consistency.py --report-format markdown --write-report .groundtruth/session/wrap-scan-reports/<SESSION_ID>/wrap-scan-consistency.md
Also inspect:
- TAFE-backed bridge state and dispatcher status/health for latest bridge statuses and any GO/NO-GO/NEW/VERIFIED changes created this session. Do not consult or recreate aggregate queue artifacts as live queue sources.
groundtruth.db through the current groundtruth_kb CLI or KnowledgeDB helpers for current work item, spec, assertion, and session_prompts state.
memory/MEMORY.md for current status, recent sessions, and quick references.
independent-progress-assessments/CODEX-INSIGHT-DROPBOX/ for reports produced this session.
- ignored local evidence under
.groundtruth/session/, .gtkb-state/, and generated reports that should be referenced but not committed.
Knowledge Collection Matrix
Use this matrix before editing anything. Every row must be updated, explicitly deferred, or marked not applicable with a reason.
| Knowledge class | Durable home | Required wrap action |
|---|
| Owner decisions, requirements, approvals, rejections | Deliberation Archive, spec intake records, formal-artifact approval packets | Confirm the DA/spec/approval evidence exists or record a blocker. Do not rely on chat recall. |
| Completed implementation work | MemBase work items/spec status, bridge implementation report, tests/assertions | Reconcile work item/spec state, list changed artifacts, and cite verification evidence. |
| Bridge state | TAFE-backed bridge state, dispatcher status/health, and versioned bridge files | Ensure proposals, reports, GO/NO-GO, and VERIFIED entries are current and latest-status accurate. Do not consult or recreate aggregate queue artifacts. |
| Future work, unresolved blockers, drift risks | MemBase backlog/current work items or explicit deferred/blocker section | Create or link backlog candidates when authorized; otherwise preserve the candidate and reason. |
| Session operating state | memory/MEMORY.md and wrap summary/report | Update current status, recent session notes, quick references, and known caveats. |
| Cross-session continuity | session_prompts plus the handoff prompt | Insert a self-contained handoff prompt or record why insertion is blocked. |
| Verification evidence | Test output, assertion output, wrap scanner outputs, bridge reports | Record commands, outcomes, failures, and any skipped verification with reasons. |
| Ignored local evidence | Wrap summary references, not git staging | Name relevant ignored paths and explain whether they are evidence, scratch, or generated artifacts. |
Phase 1: Classify Session Knowledge
Review the session transcript/context and classify:
- Decisions or requirements that need DA/spec capture.
- Specs implemented, verified, retired, or left unmet.
- Work items created, advanced, blocked, or completed.
- Bridge threads opened, approved, implemented, verified, or left waiting.
- Tests/assertions added or run.
- Procedure, skill, rule, or configuration changes that affect future agents.
- Local evidence that is useful but intentionally untracked.
If a required artifact update is not authorized, do not improvise. Record the required owner/governance action in the wrap summary and handoff.
Phase 2: Update Durable Knowledge
2.1 MemBase
Use the current groundtruth_kb package/CLI or KnowledgeDB("groundtruth.db") helpers. Do not use deprecated knowledge-db helper imports.
Update only records supported by this session's evidence:
- promote specs through the governed assertion path when implemented or verified;
- close or update work items with completion evidence;
- add backlog/future-work candidates only under the standing backlog rules;
- insert or update
session_prompts with the handoff prompt;
- record quality or assertion data only when the current API supports it.
2.2 Deliberation Archive
Run the session harvest when there are new deliberations or owner decisions:
python scripts/harvest_session_deliberations.py --apply --session <SESSION_ID>
Report created/skipped/warning counts. If harvest is blocked by formal-artifact approval, DB state, missing input, or tool failure, record the exact blocker and preserve the pending decision/requirement in the handoff.
2.3 Memory
Update memory/MEMORY.md with only durable, reusable facts:
- current project/session status;
- recent session summary with bridge/work item/spec IDs;
- changed command surfaces, skills, rules, or safety gates;
- next-session caveats that are likely to prevent recall drift.
Keep it evidence-based. Do not invent verification that did not run.
2.4 Reports And Procedures
When a session produced an implementation report, review report, incident note, or procedure update, make sure it is linked from the relevant bridge thread, work item, or memory surface. If the report directory is ignored, reference the path in the wrap summary instead of force-adding it.
Phase 3: Verification And Hygiene
Run the narrow verification relevant to the session's changes. Prefer repo-native commands already used by CI/config, for example:
python -m pytest <target> -q --tb=short
python -m ruff check .
python -m ruff format --check .
Also record:
- assertion results and new failures;
- wrap scanner outputs and unresolved findings;
- bridge applicability/ADR-DCL preflight results when bridge-backed implementation occurred;
- tests intentionally skipped, with the reason.
New failures become work items or blockers. Existing tracked failures should be cited, not rediscovered from memory.
Phase 4: Git And External Sync
Commit only intentional tracked changes. Review staged content before committing.
git status --short --branch
git add <intentional tracked paths>
git status --short
git commit -m "<type>(<scope>): <summary>"
git push origin <current-branch>
Use the current branch from git status --short --branch; do not hard-code main. Do not deploy, push docs/wiki, mutate external systems, or perform credential lifecycle actions unless that work has the applicable approval and verification evidence.
Phase 5: Handoff Prompt
Generate a self-contained next-session prompt using references/handoff-template.md. It must include:
::init gtkb pb or the owner-approved init keyword for the next role;
- project root, branch, commit, and dirty-state summary;
- latest bridge state and any pending GO/NO-GO/NEW/VERIFIED implications;
- MemBase work item/spec status for the session's work;
- DA captures or harvest blockers;
- tests/assertions/wrap scanner outcomes;
- ignored local evidence paths that future agents may need to inspect;
- blockers, risks, and next recommended actions.
Insert the prompt into session_prompts when the current MemBase API permits it. If insertion fails, include the prompt text in the wrap report and record the session_prompts blocker explicitly.
Completion Output
End with a compact wrap summary:
Session Wrap-Up: <SESSION_ID>
Branch/HEAD: <branch> @ <sha>
[ ] Knowledge matrix accounted for
[ ] MemBase updates completed or blockers recorded
[ ] Deliberation Archive harvest completed or blockers recorded
[ ] memory/MEMORY.md updated or no-op reason recorded
[ ] Bridge state reconciled
[ ] Verification commands recorded
[ ] Ignored local evidence referenced, not force-added
[ ] Current branch committed and pushed, or sync blocker recorded
[ ] session_prompts handoff inserted, or blocker recorded
Audit Session Check
Every 5th session requires the additional checks in references/audit-checklist.md.
Copyright 2026 Remaker Digital, a DBA of VanDusen & Palmeter, LLC. All rights reserved.