Skip to content

Structured multi-perspective deliberation for hard decisions. Run full councils, focused triads, or duo debates across Claude Code, Codex, Gemini CLI, and OpenCode.

feat: session metadata block (issue #7 Phase 1) (#27)

nyk906438577834
diff --git a/SKILL.codex.md b/SKILL.codex.md
index cd62c98..a0bf6a9 100644
--- a/SKILL.codex.md
+++ b/SKILL.codex.md
@@ -222,3 +222,7 @@ If `spawn_agent` is unavailable or too many seats fail, run a local simulated co
- Produce clearly labeled `[Simulated]` outputs per member.
- Keep the same round structure.
- Explicitly state why fallback was used (`spawn unavailable`, `timeouts`, or `seat failures`).
+
+### Step 7: Session Metadata (issue #7, Phase 1)
+
+After the verdict is emitted, append a `Session Metadata` block with `schema_version: 1` containing: `mode`, `panel_size`, `rounds_run`, `tools_used`, `provider_count`, `fallbacks_triggered`, and best-effort `input_tokens_estimate` / `output_tokens_estimate` / `duration_seconds` (write `~unknown` if not available from the host runtime). Block is delimited by `---` so it's grep-able and redirectable.
diff --git a/SKILL.md b/SKILL.md
index 327a23e..82e7276 100644
--- a/SKILL.md
+++ b/SKILL.md
@@ -471,6 +471,25 @@ Pass the rendered prompt to the Chairman's `exec_method` from STEP 1.7. Capture
**Fallback**: If the Chairman call fails or times out (using the same 60s/120s budget as Round 1), fall back to the coordinator producing the verdict directly. Annotate the verdict metadata: `Chairman: <name> (FAILED — synthesized by coordinator fallback)`.
+### STEP 8: Append Session Metadata (issue #7, Phase 1)
+
+After the verdict is rendered, the coordinator appends a `Session Metadata` block at the end. Best-effort — fill every field that's knowable from coordinator state; write `~unknown` for any field the host runtime doesn't expose. The block uses a fixed `schema_version: 1` so future log aggregation can rely on the shape.
+
+Required fields:
+- `schema_version: 1`
+- `mode`: full | quick | duo | triad
+- `panel_size`: integer
+- `rounds_run`: integer (actual, not target — count any rounds that were truncated)
+- `tools_used`: yes if any subagent invoked Read/Grep/Glob/Bash/WebSearch/WebFetch; no otherwise
+- `provider_count`: from the detection JSON
+- `fallbacks_triggered`: list of `member→provider/model` lines, or `none`
+
+Best-effort fields (write `~unknown` if not available):
+- `input_tokens_estimate`, `output_tokens_estimate` (host-runtime dependent)
+- `duration_seconds`
+
+This block is intentionally not a sub-section of the verdict — it's session telemetry appended below a separator. Reasoning: keeps it cheap to grep, future-easy to redirect to a log file, and avoids polluting the auditable decision artifact with infra noise. Phase 2 (benchmarking harness) and Phase 3 (cost/quality sweet spots) build on this same schema once 5–10 real sessions have been collected.
+
---
## Quick Mode Sequence (`--quick`)
@@ -664,6 +683,23 @@ Dispatch synthesis to the Chairman selected via STEP 1.7. In duo mode the Chairm
### Follow-Up
After acting on this verdict, revisit: Was this verdict useful? Was the recommended action taken? What happened? {This section is a prompt for the user, not filled by the council.}
+
+---
+
+### Session Metadata
+```
+schema_version: 1
+mode: full | quick | duo | triad
+panel_size: <N>
+rounds_run: <N>
+chairman_failed_fallback: yes | no
+tools_used: yes | no # did members read files, grep, fetch URLs, etc.
+input_tokens_estimate: ~<N>k # best-effort if available from the host runtime
+output_tokens_estimate: ~<N>k # best-effort
+duration_seconds: ~<N>
+provider_count: <N> # from detect-providers.sh
+fallbacks_triggered: <list of "member→provider/model" entries, or "none">
+```
```
### Quick Verdict
@@ -704,6 +740,22 @@ After acting on this verdict, revisit: Was this verdict useful? Was the recommen
### Follow-Up
After acting on this verdict, revisit: Was this useful? What happened?
+
+---
+
+### Session Metadata
+```
+schema_version: 1
+mode: quick
+panel_size: <N>
+rounds_run: 2
+tools_used: yes | no
+input_tokens_estimate: ~<N>k
+output_tokens_estimate: ~<N>k
+duration_seconds: ~<N>
+provider_count: <N>
+fallbacks_triggered: <list or "none">
+```
```
### Duo Verdict
@@ -743,6 +795,22 @@ After acting on this verdict, revisit: Was this useful? What happened?
### Follow-Up
After deciding, revisit: Which perspective proved more useful? What happened?
+
+---
+
+### Session Metadata
+```
+schema_version: 1
+mode: duo
+panel_size: 2
+rounds_run: 3
+tools_used: yes | no
+input_tokens_estimate: ~<N>k
+output_tokens_estimate: ~<N>k
+duration_seconds: ~<N>
+provider_count: <N>
+fallbacks_triggered: <list or "none">
+```
```
---
diff --git a/scripts/council-simulation-checklist.sh b/scripts/council-simulation-checklist.sh
index 028724b..bbe2319 100755
--- a/scripts/council-simulation-checklist.sh
+++ b/scripts/council-simulation-checklist.sh
@@ -103,6 +103,14 @@ pass "openai_compatible_api archetype wired in SKILL.md (dispatch + base_url + a
grep -q "openai_compatible_api\|openai-compatible\|OpenAI-Compatible" SKILL.codex.md || fail "openai_compatible_api archetype missing in SKILL.codex.md (issue #16)"
pass "openai_compatible_api archetype wired in SKILL.codex.md"
+# Session Metadata schema (issue #7 Phase 1)
+grep -q "Session Metadata" SKILL.md || fail "Session Metadata block missing in SKILL.md (issue #7)"
+grep -q "schema_version: 1" SKILL.md || fail "schema_version: 1 marker missing in SKILL.md Session Metadata (issue #7)"
+pass "Session Metadata schema wired in SKILL.md"
+
+grep -q "Session Metadata\|session metadata\|session_metadata" SKILL.codex.md || fail "Session Metadata missing in SKILL.codex.md (issue #7)"
+pass "Session Metadata referenced in SKILL.codex.md"
+
# --- Agent structure checks ---
required_sections=("Identity" "Grounding Protocol" "Analytical Method" "What You See" "What You Tend to Miss" "When Deliberating" "Output Format (Council Round 2)" "Output Format (Standalone)")