aboutsummaryrefslogtreecommitdiff
path: root/claude-templates
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-06-11 16:53:21 -0500
committerCraig Jennings <c@cjennings.net>2026-06-11 16:53:21 -0500
commit61e37f55c044ff7bbd41cb142ce9dfe232934216 (patch)
tree0557c3b66535f63057ab1ba0aba258c78e365c62 /claude-templates
parente32a7f55cbb877b978e7012b300377361a227c21 (diff)
downloadrulesets-61e37f55c044ff7bbd41cb142ce9dfe232934216.tar.gz
rulesets-61e37f55c044ff7bbd41cb142ce9dfe232934216.zip
feat(workflows): session-harvest monthly promotion-mining pass
session-harvest runs a monthly pass over recent session summaries across every AI project and proposes promotion candidates in four lanes: patterns catalog, KB facts, rule refinements, workflow learnings. Capture already happens continuously. This adds the batched review cadence that turns it into curated promotion. The window filter reads each session filename's date prefix instead of mtime. Clones and syncs reset mtime, which let 2025 sessions pass a recency filter. The run also aggregates the KB receipt lines from session summaries, so it doubles as the 30-day KB metrics readout.
Diffstat (limited to 'claude-templates')
-rw-r--r--claude-templates/.ai/workflows/INDEX.org2
-rw-r--r--claude-templates/.ai/workflows/session-harvest.org104
2 files changed, 106 insertions, 0 deletions
diff --git a/claude-templates/.ai/workflows/INDEX.org b/claude-templates/.ai/workflows/INDEX.org
index 3f54f7c..a910230 100644
--- a/claude-templates/.ai/workflows/INDEX.org
+++ b/claude-templates/.ai/workflows/INDEX.org
@@ -102,6 +102,8 @@ This index must list every =.org= file in =.ai/workflows/= except this one and e
- Triggers: "let's create/define/design a workflow for [activity]", or unmatched workflow request after this index returns no hit.
- =rename-artifact.org= — rename an =.ai/= workflow or script across the canonical + mirror trees, rewriting every reference on a token boundary and leaving =sessions/= history alone. Backed by =scripts/rename-ai-artifact.sh=, which runs =workflow-integrity= + =sync-check= after the move.
- Triggers: "rename this workflow", "rename the [X] workflow/script", "let's run the rename-artifact workflow".
+- =session-harvest.org= — monthly mining pass over recent =.ai/sessions/= summaries across every AI project, proposing promotion candidates in four lanes: patterns for the catalog, durable facts for the KB, rule refinements, workflow learnings. Dedups against each lane's existing content, applies the =/codify=-grade quality gates plus a work-confidentiality scrub, presents a multi-select slate, executes approved promotions, and aggregates the =KB:= receipt lines into a metrics readout. Stamps =:LAST_HARVEST:= in =notes.org=. Natural home: the rulesets project.
+ - Triggers: "session harvest", "harvest the sessions", "let's run the session-harvest workflow", "monthly harvest", "mine the sessions"
- =no-approvals.org= — drop the interaction-level approval gates for a pre-agreed batch while keeping engineering-discipline gates (=/review-code=, =/voice personal=, tests, session-log updates, subagent reviews, destructive-action consent). Mode stays on until Craig turns it off, a real question arises, the queue empties, or the conversation switches topics.
- Triggers: "no-approvals mode", "no approvals", "no-approval", "no need for approval gates", "stop asking, just keep going", "I'll check back in when you're done or stuck", "do all =<selector>= with no-approval"
- =cross-agent-comms.org= — protocol for cross-project agent coordination via =inbox/from-agents/= (file-based IPC, GPG-signed, supports cross-machine over Tailscale). Auto: when =cross-agent-watch= detects a new inbound message, or when an agent decides to initiate a cross-project conversation. Operational scripts (=cross-agent-send=, =-recv=, =-watch=, =-status=, =-discover=, =-halt=, =-resume=) and their READMEs live at =.ai/scripts/cross-agent-comms/=.
diff --git a/claude-templates/.ai/workflows/session-harvest.org b/claude-templates/.ai/workflows/session-harvest.org
new file mode 100644
index 0000000..c48d689
--- /dev/null
+++ b/claude-templates/.ai/workflows/session-harvest.org
@@ -0,0 +1,104 @@
+#+TITLE: Session-Harvest Workflow
+#+AUTHOR: Craig Jennings & Claude
+#+DATE: 2026-06-11
+
+* Overview
+
+A monthly mining pass over recent =.ai/sessions/= summaries across every AI project, proposing promotion candidates the per-session machinery missed. Capture happens continuously (session archives, harness memory, =docs/design/= notes, the wrap-up KB check); this workflow adds the *batched review cadence* that turns scattered capture into curated promotion.
+
+Four promotion lanes, each with an existing destination:
+
+| Lane | What qualifies | Destination |
+|------+----------------+-------------|
+| Patterns | A reusable interaction-design shape (prompt, picker, default, confirmation) discovered in one project | =~/code/rulesets/patterns/= per its frontmatter contract |
+| KB facts | Durable facts with cross-project or cross-machine value that the wrap-up check missed | =~/org/roam/agents/= node per =knowledge-base.md= |
+| Rule refinements | A lesson that contradicts, gaps, or sharpens an existing rule file | =~/code/rulesets/claude-rules/*.md= edit, or a filed task when non-trivial |
+| Workflow learnings | A template workflow that sessions show being misread, worked around, or extended ad hoc | Template edit + mirror sync, or a filed task when non-trivial |
+
+This is a workflow run on schedule, not a standing agent — the sibling cadence to the roam-hygiene timer. It also doubles as the KB instrumentation readout: the =KB: promoted N / consulted yes-no= receipt lines in session summaries get aggregated here.
+
+* When to Use
+
+- Monthly, when the =:LAST_HARVEST:= marker in =notes.org= is 30+ days old. Nothing nudges automatically yet — the marker is the cadence record, and the run is manual.
+- Triggers: "session harvest", "harvest the sessions", "let's run the session-harvest workflow", "monthly harvest", "mine the sessions"
+
+The natural home is the *rulesets* project — three of the four lanes write to rulesets files, and rulesets is personal-classified so KB writes are allowed. Running from another personal project works (all targets are absolute paths) but the promotion commits still land in =~/code/rulesets= and =~/org/roam=. Do not run from a work-classified project: the KB lane would be blocked by the write boundary, and the harvest's value is mostly lost.
+
+* Workflow Steps
+
+** Phase 1 — Scope the window and inventory the sessions
+
+1. Read =:LAST_HARVEST:= from the running project's =notes.org= Workflow State section. The window is from that date to today; if the marker is absent (first run), default to 35 days back.
+2. Inventory session files in the window across every AI project. Same discovery fingerprint as =broadcast.py= (=.ai/protocols.org= under =~/code=, =~/projects=, =~/.emacs.d=):
+
+ #+begin_src bash
+ since="2026-05-12" # from the marker
+ for root in ~/code ~/projects ~/.emacs.d; do
+ [ -d "$root" ] || continue
+ for d in "$root" "$root"/*/; do
+ [ -f "$d/.ai/protocols.org" ] || continue
+ find "$d/.ai/sessions" -maxdepth 1 -name '*.org' 2>/dev/null | sort \
+ | awk -F/ -v since="$since" 'substr($NF,1,10) >= since' \
+ | sed "s|^|$(basename "$d"): |"
+ done
+ done
+ #+end_src
+
+ The window filter reads the =YYYY-MM-DD= prefix of each session *filename*, not file mtime — mtime gets reset by clones, syncs, and sweeps, and a live test showed 2025 sessions passing an mtime filter.
+
+3. Print the inventory: per-project counts and the total. A window with zero sessions ends the run — stamp the marker and stop.
+
+** Phase 2 — Mine the summaries
+
+Read only the =* Summary= section of each session file — Decisions, Data Collected / Findings, and Next Steps are where candidates live. Never read full Session Logs in this pass; drill into a specific log later only to verify a candidate's context.
+
+When more than ~5 projects have sessions in the window, fan out read-only subagents — one per project, parallel-safe per =subagents.md=. Each subagent's contract: scope (that project's session files in the window, Summary sections only), context (the four lanes and what qualifies, pasted from the table above), constraints (read-only; no edits; skip Session Logs), output (a list of candidates, each with lane, one-line statement, source file, and the evidence sentence quoted). Fewer projects: mine inline.
+
+For each candidate, capture four fields: *lane*, *the claim* (one line), *source* (project + session file), *evidence* (the summary sentence that backs it).
+
+Also collect, from every summary in the window, the =KB: promoted N / consulted yes-no= receipt line for the Phase 5 metrics readout. Note sessions missing the line — that's a wrap-up discipline slip worth surfacing.
+
+** Phase 3 — Dedup and gate
+
+Walk the candidate list against each lane's existing content before anything reaches Craig:
+
+- Patterns: grep =~/code/rulesets/patterns/= frontmatter (=#+PRINCIPLE:=, =#+TAGS:=) for overlap.
+- KB: search =~/org/roam/= per =knowledge-base.md='s read recipe (pull first).
+- Rules: grep =~/code/rulesets/claude-rules/= for the topic.
+- Workflows: check whether the template already says it.
+
+Then apply the quality gates (same bar as =/codify=): atomic, evidence-backed, non-redundant, durable (won't be stale in a month), and safe to write down. Drop failures silently — the slate Craig sees should already be defensible.
+
+*Work-confidentiality scrub.* Candidates mined from work-classified projects (the =knowledge-base.md= denylist) can still inform rules, patterns, and workflow refinements *if* the written artifact carries no work-confidential content — names, clients, internal systems, commercial terms all stripped, only the transferable shape kept. KB nodes sourced from work sessions are barred outright per the write boundary. When in doubt, drop the candidate and note it for Craig.
+
+** Phase 4 — Propose the slate
+
+Present surviving candidates grouped by lane, numbered continuously, each with: the claim, the source session, and a one-word recommendation (promote / file-as-task / skip). Inline numbered list, multi-select ("pick any combination — reply with the numbers, or 'all'"), recommendation-first per =interaction.md=. An empty slate is a fine outcome — say so and jump to Phase 5.
+
+** Phase 5 — Execute and record
+
+For each approved candidate:
+
+- *Pattern* → one file in =patterns/= per the README's frontmatter contract; add the catalog-table row.
+- *KB fact* → one =agents/= node per =knowledge-base.md= (pull, write, commit, push).
+- *Rule refinement* → edit the rule file directly when the change is a paragraph or less; otherwise file a =todo.org= task in rulesets carrying the evidence.
+- *Workflow learning* → same split: small edits land now (canonical + =sync-check --fix= mirror), larger ones become tasks.
+
+Then close out:
+
+1. Aggregate the Phase 2 receipt lines into a three-line metrics readout: sessions in window, promote rate (sum of =promoted N=), consult rate (=consulted yes= fraction). Surface it — this is the KB success-metrics checkpoint input.
+2. Stamp =:LAST_HARVEST: YYYY-MM-DD= in the running project's =notes.org= Workflow State section.
+3. Commit per =commits.md= — rulesets changes and roam changes in their own repos, each through the normal review-and-publish flow.
+
+* Common Mistakes
+
+1. *Reading full session files.* Summaries only. The Session Log is drill-down for verifying a specific candidate, not mining input.
+2. *Re-proposing what wrap-up already promoted.* The KB lane exists for what the per-session check *missed* — Phase 3's dedup against the KB is what keeps this workflow from double-writing.
+3. *Promoting volume.* Most sessions yield nothing; a monthly slate of 2-5 strong candidates beats 20 weak ones. The gates exist to be failed.
+4. *Letting work content leak.* The scrub in Phase 3 is mandatory, not advisory. A pattern can carry a work-discovered shape; it cannot carry the work specifics that revealed it.
+5. *Skipping the marker stamp on an empty run.* A zero-candidate harvest still happened — stamp =:LAST_HARVEST:= or the staleness signal lies.
+6. *Editing the =.ai/= mirror in rulesets.* Workflow-learning edits go to =claude-templates/.ai/workflows/= (canonical), then =scripts/sync-check.sh --fix=.
+
+* Living Document
+
+Refine as harvest runs accumulate: if a lane never yields candidates, question it; if a fifth lane keeps appearing in the "dropped, didn't fit" pile, add it. The Phase 5 metrics readout format may grow when the KB checkpoint (first one ~2026-07-10) shows what's actually worth measuring.