WP-0004: ecosystem integration complete

Add Helix Forge correlation (HELIX_SESSION_UID env, metrics correlate),
artifact-store publish (metrics publish), activity-core ActivityDefinition
references, integration patterns docs, and canon/knowledge design artifacts.
This commit is contained in:
2026-06-16 01:53:01 +02:00
parent 4a9c2d9bea
commit b48a2102d7
22 changed files with 1451 additions and 408 deletions

View File

@@ -0,0 +1,43 @@
---
id: kaizen-low-success-rate-review
name: Low Agent Success Rate Review
enabled: false
owner: kaizen-agentic
governance: custodian
status: proposed
trigger:
type: event
event_type: kaizen.metrics.recorded
context_sources:
- type: event-payload
bind_to: context.metrics
---
# Low Agent Success Rate Review
When a project agent's rolling success rate drops below 0.8, create a review
task in issue-core for human or optimizer-agent follow-up.
```rule
id: flag-low-success-rate
condition: 'context.metrics.summary.success_rate < 0.8 && context.metrics.summary.execution_count >= 5'
action:
task_template: "Review {{context.metrics.agent}} success rate ({{context.metrics.summary.success_rate}})"
description: |
Agent {{context.metrics.agent}} in {{context.metrics.project}} has success_rate
below 0.8 over {{context.metrics.summary.execution_count}} executions.
Run: kaizen-agentic metrics show {{context.metrics.agent}}
Then: kaizen-agentic metrics optimize {{context.metrics.agent}}
target_repo: "{{context.metrics.project}}"
priority: high
labels: ["kaizen", "metrics", "review", "automated"]
```
**Threshold:** 0.8 success rate, minimum 5 executions (avoids noise on early pilots).
**CLI mapping:** Event emitter is future work; manual check today:
```bash
kaizen-agentic metrics show <agent> # inspect summary.success_rate
kaizen-agentic metrics optimize <agent>
```

View File

@@ -0,0 +1,41 @@
---
id: kaizen-post-install-metrics-scaffold
name: Post-Install Metrics Scaffold Validation
enabled: false
owner: kaizen-agentic
governance: custodian
status: proposed
trigger:
type: event
event_type: kaizen.agent.installed
context_sources:
- type: event-payload
bind_to: context.install
---
# Post-Install Metrics Scaffold Validation
Fires when an agent is installed into a project. Verifies that memory and metrics
scaffolds exist for the installed agent.
```rule
id: validate-metrics-scaffold
condition: 'context.install.agent != ""'
action:
task_template: "Validate kaizen scaffold for {{context.install.agent}}"
description: |
In {{context.install.project_root}} verify:
- .kaizen/agents/{{context.install.agent}}/memory.md exists OR run:
kaizen-agentic memory init {{context.install.agent}}
- .kaizen/metrics/{{context.install.agent}}/ exists OR re-run init without --no-metrics
target_repo: "{{context.install.repo}}"
priority: low
labels: ["kaizen", "metrics", "scaffold", "automated"]
```
**CLI mapping:**
```bash
kaizen-agentic memory init <agent> # scaffolds memory + metrics by default
kaizen-agentic metrics list # confirms metrics directory after first record
```

View File

@@ -0,0 +1,44 @@
---
id: kaizen-weekly-metrics-optimize
name: Weekly Kaizen Metrics Optimization
enabled: false
owner: kaizen-agentic
governance: custodian
status: proposed
trigger:
type: cron
cron_expression: "0 8 * * 1"
timezone: Europe/Berlin
misfire_policy: skip
context_sources:
- type: shell
query: discover_kaizen_projects
params:
marker: .kaizen/metrics
bind_to: context.projects
---
# Weekly Kaizen Metrics Optimization
Runs every Monday 08:00 Berlin time on repos that contain `.kaizen/metrics/`.
Invokes the kaizen-agentic optimizer CLI per project.
```rule
id: run-weekly-optimizer
for_each: context.projects
bind_as: p
condition: 'p.has_metrics == true'
action:
task_template: "Run kaizen metrics optimize on {{p.repo}}"
description: |
cd {{p.root}} && kaizen-agentic metrics optimize
Optional: kaizen-agentic metrics publish (when artifact-store configured)
target_repo: "{{p.repo}}"
priority: medium
labels: ["kaizen", "metrics", "optimizer", "automated"]
```
**Activation:** sync this definition into activity-core via `make sync-activity-definitions`
after enabling the shell resolver for `discover_kaizen_projects`.
**CLI mapping:** `kaizen-agentic metrics optimize` (no agent filter = all agents with metrics).

View File

@@ -0,0 +1,44 @@
# tdd-workflow — InfoTechCanon-style Brief
Compact agent brief derived from `agents/agent-tdd-workflow.md` (metrics pilot).
Reference for fleet-wide brief rollout.
```yaml
profile:
id: kaizen/tdd-workflow
version: "1.0"
domain: development-process
intent:
summary: Guide TDD8 ISSUE-TEST-RED-GREEN-REFACTOR-DOCUMENT-REFINE-PUBLISH cycles
outcomes:
- Acceptance criteria covered by tests before PUBLISH
- Sidequests tracked without blocking parent issues
- Workspace integrated cleanly via make tdd-finish
metrics:
primary:
name: test_pass_rate
target: 1.0
measurement: passing_tests / total_tests at PUBLISH
secondary:
- name: cycle_time_s
measurement: session duration (execution_time_s)
collection:
storage: .kaizen/metrics/tdd-workflow/
frequency: per_execution
idempotency:
signals:
- current_issue.json workspace state
- idempotency_key on metrics record
session_protocol:
start: read .kaizen/agents/tdd-workflow/memory.md
close:
- update memory.md sections
- kaizen-agentic metrics record tdd-workflow
ecosystem:
fleet_correlation: helix_session_uid (ADR-004)
optimizer: kaizen-agentic metrics optimize
evidence: kaizen-agentic metrics publish (optional)
```
Full specification: [agents/agent-tdd-workflow.md](../../../agents/agent-tdd-workflow.md).
Pilot documentation: [wiki/AboutKaizenAgents.md](../../../wiki/AboutKaizenAgents.md).

View File

@@ -0,0 +1,32 @@
# KaizenAgentTemplate → InfoTechCanon Profile Mapping
Design note (WP-0004 Part 4). No runtime dependency on info-tech-canon.
## Section mapping
| `wiki/KaizenAgentTemplate.md` | InfoTechCanon profile outline |
|------------------------------|------------------------------|
| `specification.outcomes` | `profile.intent.outcomes[]` |
| `specification.constraints` | `profile.constraints.hard[]` / `soft[]` |
| `idempotency.detection` | `profile.idempotency.signals[]` |
| `idempotency.rollback` | `profile.safety.rollback` |
| `metrics.primary` | `profile.metrics.primary` |
| `metrics.secondary[]` | `profile.metrics.secondary[]` |
| `metrics.collection` | `profile.observability.collection` |
| `testing.unit_tests[]` | `profile.validation.unit[]` |
| `testing.integration_tests[]` | `profile.validation.integration[]` |
| `evolution.history` | `profile.evolution.changelog` |
| `evolution.optimization_hooks` | `profile.evolution.feedback_sources[]` |
## Validation hooks (future)
Extend `kaizen-agentic validate` to check:
1. Frontmatter contains `metrics.primary.name` when `memory: enabled`
2. Session-close block references `metrics record`
3. Required template sections present in agent body (warn, not fail)
## Reference pilot
`tdd-workflow` brief in [briefs/tdd-workflow-canon-brief.md](briefs/tdd-workflow-canon-brief.md)
demonstrates a compact canon-style export derived from the full agent spec.

View File

@@ -0,0 +1,103 @@
# Helix Forge Correlation Contract
Cross-repo contract between **kaizen-agentic** (project metrics, ADR-004) and
**agentic-resources** (Helix Forge fleet session metrics).
## Purpose
Link a project-scoped agent execution record to the fleet session that produced
it, without duplicating session JSONL ingestion in kaizen-agentic.
## Layers
| Layer | Owner | Storage |
|-------|-------|---------|
| Project | kaizen-agentic | `.kaizen/metrics/<agent>/executions.jsonl` |
| Fleet | agentic-resources | Helix Forge digest store (`digests` table) |
## Correlation fields (ADR-004)
Optional on each project execution record:
```json
{
"helix_session_uid": "claude:17092961-…",
"repo": "kaizen-agentic",
"flavor": "claude",
"tokens": 12500,
"infra_overhead_share": 0.12
}
```
### Field mapping
| Helix Forge (`session_memory`) | ADR-004 project record |
|-------------------------------|------------------------|
| `Session.session_uid` | `helix_session_uid` |
| `Session.repo` | `repo` |
| `Session.flavor` | `flavor` |
| `digest.cost.input_tokens + output_tokens` | `tokens` |
| MCP tool share of `tool_histogram` | `infra_overhead_share` |
| `digest.outcome == "success"` | informs `success` at record time |
| `digest.cost.wall_clock_s` | complements `execution_time_s` |
## Population at session close
### Automatic (environment)
When Helix Forge capture is active in the same shell session:
```bash
export HELIX_SESSION_UID="claude:17092961-…"
export HELIX_REPO="kaizen-agentic"
export HELIX_FLAVOR="claude"
export HELIX_TOKENS="12500"
export HELIX_INFRA_OVERHEAD_SHARE="0.12"
kaizen-agentic metrics record tdd-workflow --success --time 4200 --quality 0.9
```
`metrics record` merges env vars into the execution record before append.
### Explicit (JSON)
```bash
echo '{
"success": true,
"execution_time_s": 4200,
"quality_score": 0.9,
"helix_session_uid": "claude:17092961-…",
"repo": "kaizen-agentic",
"flavor": "claude",
"tokens": 12500,
"infra_overhead_share": 0.12
}' | kaizen-agentic metrics record tdd-workflow --json
```
## Fleet lookup (read-only)
```bash
export HELIX_STORE_DB=~/.helix-forge/store.db # agentic-resources session store
kaizen-agentic metrics correlate claude:17092961-…
```
When `HELIX_STORE_DB` is unset, `metrics correlate` returns a **stub** response
documenting expected fields — no ingestion code runs in kaizen-agentic.
## Bidirectional references
| Document | Repo |
|----------|------|
| [ADR-004](../adr/ADR-004-project-metrics-convention.md) | kaizen-agentic |
| [wiki/EcosystemIntegration.md](../../wiki/EcosystemIntegration.md) | kaizen-agentic |
| [DESIGN-session-memory.md](https://github.com/coulomb/agentic-resources/blob/main/docs/DESIGN-session-memory.md) | agentic-resources |
| `session_memory/core/store.py``get_digest()` | agentic-resources |
agentic-resources should link back to this document from its session-memory design
notes when documenting downstream consumers of `session_uid`.
## Non-goals
- No Claude/Codex/Grok JSONL ingestion in kaizen-agentic
- No write path to Helix Forge from kaizen-agentic CLI
- No merge of fleet baselines into project `summary.json` (Coach may cite both)

View File

@@ -0,0 +1,41 @@
# kontextual-engine Wiki Ingestion Spike
Design note (WP-0004 Part 4). No runtime dependency.
## Proposed manifest
```yaml
ingestion:
source_repo: kaizen-agentic
asset_class: strategic-knowledge
paths:
- wiki/**/*.md
- INTENT.md
- docs/adr/ADR-*.md
exclude:
- wiki/**/xxx
metadata:
domain: custodian
topic_id: cee7bedf-2b48-46ef-8601-006474f2ad7a
producer: kaizen-agentic
refresh:
trigger: git-push-main
retention_class: operational-knowledge
```
## Rationale
- `wiki/` holds product narrative and integration contracts not suited for agent prompts alone
- ADRs are normative; kontextual-engine can index them for cross-repo retrieval
- Agent definitions (`agents/`) remain separate — executable personas vs strategic docs
## Open questions
1. Chunking strategy for `KaizenAgentTemplate.md` (section-aware vs whole-file)
2. Whether Coach synthesis outputs should be ingested as derived assets
3. Correlation with info-tech-canon profiles when both exist for one agent
## Next step
Dedicated workplan after WP-0004 baseline; evaluate kontextual-engine ingestion API
stability before hard dependency.

View File

@@ -0,0 +1,60 @@
# Optimizer Evidence Artifact Manifest
Package schema for `kaizen-agentic metrics publish`**artifact-store**.
## Package identity
| Field | Value |
|-------|-------|
| `producer` | `kaizen-agentic` |
| `retention_class` | `raw-evidence` (180d default, ADR-004 aligned) |
| `name` | `kaizen-optimizer-<project-slug>` |
| `subject` | project directory name (override with `--subject`) |
## Files
| Relative path | Source | Media type |
|---------------|--------|------------|
| `optimizer/analysis.json` | `.kaizen/metrics/optimizer/analysis.json` | `application/json` |
| `optimizer/recommendations.jsonl` | `.kaizen/metrics/optimizer/recommendations.jsonl` | `application/x-ndjson` |
`recommendations.jsonl` is omitted from upload when absent (e.g. insufficient samples).
## Metadata (`POST /packages`)
```json
{
"schema": "kaizen-agentic/optimizer-evidence/v1",
"project": "demo-app",
"project_root": "/path/to/demo-app",
"producer": "kaizen-agentic",
"retention_class": "raw-evidence",
"retention_days": 180,
"optimized_at": "2026-06-18",
"agents": ["tdd-workflow", "coach"],
"files": [
"optimizer/analysis.json",
"optimizer/recommendations.jsonl"
]
}
```
## Publish workflow
```bash
# 1. Ensure optimizer has run
kaizen-agentic metrics optimize
# 2. Publish (artifact-store must be reachable)
export ARTIFACTSTORE_API_URL=http://127.0.0.1:8000
export ARTIFACTSTORE_API_TOKEN=<write-token>
kaizen-agentic metrics publish --target .
```
Local-only workflows skip publish; `.kaizen/metrics/optimizer/` remains authoritative.
## Related
- [artifact-store ingestion API](https://github.com/coulomb/artifact-store) — `POST /packages`, `/files`, `/finalize`
- [ADR-004](../adr/ADR-004-project-metrics-convention.md)
- [INTEGRATION_PATTERNS.md](../INTEGRATION_PATTERNS.md)