maestro-session-manage
Manage a v3 Session — inspect status/resume-view, review knowledge
git clone --depth 1 https://github.com/catlog22/maestro-flow /tmp/maestro-session-manage && cp -r /tmp/maestro-session-manage/.codex/skills/maestro-session-manage ~/.claude/skills/maestro-session-manageSKILL.md
<required_reading>
@~/.maestro/workflows/run-mode.md
@~/.maestro/workflows/codex-run-mode.md
</required_reading>
If any required file above was not expanded into context by the host, or its content is no longer in context, Read it explicitly before executing any step.
<purpose>
Manage the lifecycle of a v3 Session (`session/3.0`) through its read-only projections, knowledge governance, and explicit lifecycle transitions.
Session completion (`maestro session complete`) is part of the default Run loop — Ralph S_DONE, the orchestrator run loop, and Companion all execute it when the chain turns terminal. This command is the **management surface**: inspection, knowledge candidate review/promotion, and the explicit transitions the default loop does not perform (`--complete` for manual pipelines, `--archive`/`--unarchive` for optional freezing).
Run completion already stages accepted decisions, locked constraints, and explicit `maestro knowledge stage` entries. This command reviews those receipts; it does not re-extract the same artifacts or write project knowledge through a second path.
</purpose>
<context>
$ARGUMENTS -- optional session ID and action flags.
**Actions (first match wins; default = inspect):**
| Flag | Effect |
|------|--------|
| *(none)* | Inspect: `session status` + `session resume-view` projection |
| `--complete` | Readiness check → knowledge reconciliation → fenced `maestro session complete` → DAG progression |
| `--archive` | Fenced `maestro session archive` (only from `completed`/`failed`; optional freeze) |
| `--unarchive` | Fenced `maestro session unarchive` (only from `archived`; returns to `open`) |
| `--knowledge` | Knowledge review/promotion only — no lifecycle mutation |
**Shared flags:**
| Flag | Effect | Default |
|------|--------|---------|
| `--session <id>` | Target session (slug or full ID) | `active_session_id` |
| `-y` / `--yes` | Auto mode — skip confirmations | false |
| `--skip-knowledge` | With `--complete`: leave candidate backlog pending | false |
</context>
<v3_lifecycle_reference>
```
open ──complete──> completed ──archive──> archived ──unarchive──> open
│
└──fail──> failed ──archive──> archived
Permissions: open = all mutations; completed/failed/archived = none.
```
- `--complete` requires: no running Run, every chain step completed/skipped with evidence, no open decision gate (escalated gates pass as recorded concerns).
- `--archive` is optional: a completed Session identity stays durable either way; archived Sessions cannot host new Runs until `--unarchive`.
- Every mutation returns a `run-response/1.2` envelope with an immutable transition receipt; never edit runtime-owned protocol JSON.
</v3_lifecycle_reference>
<execution>
### Step 0: Resolve Target
1. Resolve target session from `--session` flag or `active_session_id`
2. Read `maestro session status --session {session_id} --json` — capture `status`, `orchestration_revision`, `activity_revision`, `active_run_ids`
3. Route to the selected action below; default (no action flag) → Step 1 (Inspect)
### Step 1: Inspect (default)
1. Run `maestro session status --session {session_id} --json` and `maestro session resume-view --session {session_id} --json`
2. Report: status, orchestration/activity revision, active runs, open decisions (`openDecisions` from the ResumeMap), pending publications, and `nextActions`
3. Suggest the matching action: open decision gates → `maestro run decide`; active runs → let the Run loop finish; `completed` → offer `--archive`; `archived` → offer `--unarchive`; `open` with terminal chain → offer `--complete`
### Step 2: Complete (`--complete`) — manual-pipeline terminal step
Note: maestro-next suggests `--complete` when 'Tests green + active session'. Orchestrated flows (Ralph/orchestrator/Companion) complete the Session themselves; use this action only when driving the pipeline manually.
**2a. Readiness check**
1. Verify status is `open` (a completed/archived Session needs no completion; `archived` requires `--unarchive` first)
2. Verify no active runs (`active_run_ids` empty; all runs sealed)
3. Verify critical gates passed (entry/exit gates from last verify/review run). If no verify/review run exists in this session, treat gate check as not applicable (pass) but emit W002
4. Verify no open decision gates (`session status` → `decisions[]`; open gates block `session complete` with `DECISION_GATE_BLOCKED`). If open gates exist → run `maestro run decide <point> --verdict proceed|fix` first
5. If not ready → display blockers, suggest next action (e.g., "run the `review` step first")
**2b. Knowledge reconciliation** (skip to 2c with `--skip-knowledge`)
1. Run `maestro knowledge review {session_id} --json`. Treat its Run ledgers, reconciliation policies, diversified matches, and candidate IDs as authoritative; do not rescan outputs to recreate candidates. Use `--refresh` only when the review reports missing or stale source receipts
2. Explain signal semantics when relevant: search/injection is exposure only; explicit loads are consumed; `cited`, `validated`, and `contradicted` are explicit Run relations
3. Report exact/semantic duplicates, related/extends candidates, potential conflicts, supersession candidates, missing receipts, and promotion eligibility separately. Exact duplicates are suppressed automatically; unresolved `review_required` candidates cannot be promoted
4. If `--skip-knowledge`, report the pending/promoting/review-required/suppressed counts and continue. The backlog and reconciliation receipts remain durable after completion
5. Otherwise resolve review-required candidates before promotion with `maestro knowledge review {session_id} --resolve <candidate-id> --as duplicate|related|conflict|supersede|unique [--target <knowledge-id>] --reason "<reason>"`. A target must come from that candidate's evidence-backed matches
6. Present eligible pending candidates via `request_user_input`:
```
qRead-only code exploration via Bash + CLI semantic dual-source analysis, with schema-validated structured output.
Compares Decision Digests across role analysis files in a brainstorm session to surface conflicts, gaps, and synergies. Read-only — returns structured text for the orchestrator to apply.
Autonomous executor for non-interactive impeccable commands. Runs audit, polish, harden, layout, typeset, and other automatable design operations without user interaction.
Generates multi-file role analysis for a brainstorm session — analysis.md index + per-feature files + optional findings under {output_dir}/{role}/.
Resident pipeline supervisor agent. Message-driven lifecycle for cross-checkpoint quality observation and health monitoring.
Unified worker agent for team pipelines. Executes role-specific logic loaded from a role_spec file within a built-in task lifecycle (discover, execute, report).
UI design token management and prototype generation — W3C Design Tokens Format, state-based components, WCAG AA validation, responsive layout templates.
Evaluates technical topics, proposals, or decisions across multiple dimensions with evidence-based scoring and recommendations.