session-memory: distribute entrypoint + live verify (WP-0007 T05)

python -m session_memory.distribute: reads approved catalog patterns, builds
targets from repo->domain map x flavors, renders scoped per-flavor proposals
(HITL) + active registry. Live verify against the real catalog: 12 renders
across 5 repos, idempotent, provisional skipped. proposals/ gitignored
(regenerated); active_patterns.json committed. README documents detect->curate->
distribute. Phase 3 finished; suite 126/126.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-07 15:25:20 +02:00
parent 00e8958540
commit 59632e94db
7 changed files with 307 additions and 3 deletions

View File

@@ -33,6 +33,12 @@ session_memory/
curate/decisions.py # hub decision audit trail (graceful local-queue fallback)
curate/__main__.py # python -m session_memory.curate (interactive / --auto-approve)
catalog/ # the committed Pattern Catalog (source of truth)
distribute/base.py # Artifact + Distributor protocol + idempotent snippet markers
distribute/claude.py # CLAUDE.md (or skill) renderer } per-flavor edges
distribute/codex.py # AGENTS.md renderer } (agnostic body,
distribute/grok.py # native instruction renderer } different targets)
distribute/proposals.py # scoping + proposed-not-applied output + active registry
distribute/__main__.py # python -m session_memory.distribute
config.toml # store paths, retention caps, sources, repo->domain map, curate gate
```
@@ -114,6 +120,27 @@ python -m session_memory.curate --json # machine-readable result
| `dist_require_cross_flavor` | require cross-flavor evidence to be distribution-eligible |
| `dist_min_frequency` / `dist_min_cost_impact` | stricter floor for `distribution_ready` |
## Distribute patterns as per-flavor proposals
Render approved catalog patterns into per-flavor artifacts — **proposed, never
auto-applied** (HITL). Completes the loop: **detect → curate → distribute**.
```bash
python -m session_memory.distribute # proposals for all repos/flavors
python -m session_memory.distribute --repo state-hub --flavor claude
python -m session_memory.distribute --json
```
- Only `approved` + `distribution_ready` patterns are rendered; each pattern's
`Scope` (repos/domains/flavors) decides where it lands (FR-X2).
- Each flavor renders the **same agnostic body** to its own target (Claude →
`CLAUDE.md`/skill, Codex → `AGENTS.md`, Grok → native) via `rendering_hints`
(FR-A3); blocks carry stable `BEGIN/END` markers so re-running updates in place.
- Output goes to `session_memory/proposals/<repo>/<target>` (gitignored,
regenerated) — a reviewable diff a human applies (FR-X3). The committed
`distribute/active_patterns.json` records which pattern+version is proposed in
which `(repo, flavor)` (FR-X4).
## Retention knobs (`[retention]` in config.toml)
| Key | Meaning |
@@ -141,4 +168,10 @@ python -m pytest # schema, adapters, store, digest, retention, ingest,
- **Phase 2** (AGENTIC-WP-0004): Curate — Solution Pattern schema, versioned
files-first Pattern Catalog, discuss/approve/reject review with an evidence bar +
bloat guard, and hub-decision audit trail.
- **Next — Phase 3 (Distribute) / Phase 4 (Measure)** follow per the PRD.
- **Detect hardening** (AGENTIC-WP-0005): session-quality filter + tool-mix /
infra-overhead signals. **Error mining** (AGENTIC-WP-0006): recurring error
fingerprints → root-cause patterns.
- **Phase 3** (AGENTIC-WP-0007): Distribute — per-flavor distributor adapters
render approved patterns into proposed (HITL) artifacts, scoped by repo/domain,
with an active-pattern registry.
- **Next — Phase 4 (Measure)** closes the loop per the PRD.