2026-06-16 01:53:01 +02:00
|
|
|
# Integration Patterns
|
2025-10-19 11:47:17 +02:00
|
|
|
|
2026-06-16 01:53:01 +02:00
|
|
|
How kaizen-agentic composes with ecosystem repos **by contract** — no merged
|
|
|
|
|
codebases, no duplicated capabilities.
|
2025-10-19 11:47:17 +02:00
|
|
|
|
2026-06-16 01:53:01 +02:00
|
|
|
Reference: [wiki/EcosystemIntegration.md](../wiki/EcosystemIntegration.md),
|
2026-08-20 11:04:43 +02:00
|
|
|
[KAIZEN-WP-0004](../workplans/KAIZEN-WP-0004-ecosystem-integration.md).
|
2025-10-19 11:47:17 +02:00
|
|
|
|
2026-06-16 01:53:01 +02:00
|
|
|
---
|
2025-10-19 11:47:17 +02:00
|
|
|
|
2026-06-16 01:53:01 +02:00
|
|
|
## Pattern 1 — Helix Forge correlation (agentic-resources)
|
2025-10-19 11:47:17 +02:00
|
|
|
|
2026-06-16 01:53:01 +02:00
|
|
|
**Problem:** Project metrics and fleet session metrics answer different questions.
|
2025-10-19 11:47:17 +02:00
|
|
|
|
2026-06-16 01:53:01 +02:00
|
|
|
**Contract:** Optional `helix_session_uid` on ADR-004 execution records.
|
2025-10-19 11:47:17 +02:00
|
|
|
|
2026-06-16 01:53:01 +02:00
|
|
|
| kaizen-agentic | agentic-resources |
|
|
|
|
|
|----------------|-------------------|
|
|
|
|
|
| `metrics record` at session close | Helix capture → digest store |
|
|
|
|
|
| `metrics correlate <uid>` read-only lookup | `Store.get_digest(session_uid)` |
|
|
|
|
|
| `HELIX_SESSION_UID` env auto-merge | `Session.session_uid` |
|
2025-10-19 11:47:17 +02:00
|
|
|
|
2026-06-16 01:53:01 +02:00
|
|
|
**Docs:** [integrations/helix-forge-correlation.md](integrations/helix-forge-correlation.md)
|
2025-10-19 11:47:17 +02:00
|
|
|
|
2026-06-16 01:53:01 +02:00
|
|
|
**Boundary:** kaizen-agentic does not ingest session JSONL.
|
2025-10-19 11:47:17 +02:00
|
|
|
|
2026-06-16 01:53:01 +02:00
|
|
|
---
|
2025-10-19 11:47:17 +02:00
|
|
|
|
2026-06-16 01:53:01 +02:00
|
|
|
## Pattern 2 — activity-core triggers
|
2025-10-19 11:47:17 +02:00
|
|
|
|
2026-06-16 01:53:01 +02:00
|
|
|
**Problem:** Recurring kaizen checks need scheduling without custom cron in this repo.
|
2025-10-19 11:47:17 +02:00
|
|
|
|
2026-06-16 01:53:01 +02:00
|
|
|
**Contract:** ActivityDefinition markdown files declare triggers + actions that
|
|
|
|
|
invoke kaizen-agentic CLI commands.
|
2025-10-19 11:47:17 +02:00
|
|
|
|
2026-06-16 01:53:01 +02:00
|
|
|
| Definition | Trigger | CLI command |
|
|
|
|
|
|------------|---------|-------------|
|
|
|
|
|
| [weekly-metrics-optimize](integrations/activity-definitions/weekly-metrics-optimize.md) | Cron Mon 08:00 | `metrics optimize` |
|
|
|
|
|
| [post-install-metrics-scaffold](integrations/activity-definitions/post-install-metrics-scaffold.md) | `kaizen.agent.installed` | `memory init` validation |
|
2026-06-18 08:53:36 +02:00
|
|
|
| [low-success-rate-review](integrations/activity-definitions/low-success-rate-review.md) | `kaizen.metrics.recorded` | `metrics record --emit-event` |
|
2025-10-19 11:47:17 +02:00
|
|
|
|
2026-06-16 02:26:13 +02:00
|
|
|
**Activation handoff (activity-core owners):**
|
|
|
|
|
|
|
|
|
|
1. **Copy definitions** from kaizen-agentic:
|
|
|
|
|
`docs/integrations/activity-definitions/*.md` → activity-core
|
|
|
|
|
`activity-definitions/kaizen-agentic/` (or org-equivalent path per ACT-ADR-002).
|
|
|
|
|
2. **Register in activity-core index** — ensure each definition slug appears in the
|
|
|
|
|
activity-core catalog consumed by the resolver.
|
|
|
|
|
3. **Run sync** in activity-core: `make sync-activity-definitions` (or repo-equivalent).
|
|
|
|
|
4. **Wire triggers** — map cron / NATS subjects (`kaizen.agent.installed`,
|
|
|
|
|
`kaizen.metrics.recorded`) to the documented CLI invocations.
|
|
|
|
|
5. **Enable gradually** — set `enabled: true` per definition after a manual smoke test
|
|
|
|
|
against a repo with `.kaizen/metrics/` populated.
|
|
|
|
|
6. **Verify credentials** — scheduled runs need `kaizen-agentic` on PATH and any
|
2026-08-20 09:43:49 +02:00
|
|
|
Forgejo PyPI extra index if the runner installs from registry (see PACKAGE_RELEASE.md).
|
2026-06-16 02:26:13 +02:00
|
|
|
|
|
|
|
|
**kaizen-agentic maintainer checklist:**
|
|
|
|
|
|
2026-08-20 22:43:55 +02:00
|
|
|
- [x] Three definition files committed under `docs/integrations/activity-definitions/`
|
|
|
|
|
- [x] activity-core handoff completed for the resolver and pilot definitions
|
|
|
|
|
- [x] Smoke test commands documented below passed on the pilot roster
|
2025-10-19 11:47:17 +02:00
|
|
|
|
2026-06-16 01:53:01 +02:00
|
|
|
**Smoke test (manual):**
|
2025-10-19 11:47:17 +02:00
|
|
|
|
|
|
|
|
```bash
|
2026-06-16 01:53:01 +02:00
|
|
|
# Against a repo with populated metrics
|
|
|
|
|
cd /path/to/project-with-kaizen
|
|
|
|
|
kaizen-agentic metrics list
|
|
|
|
|
kaizen-agentic metrics optimize
|
|
|
|
|
# Verify analysis.json written
|
|
|
|
|
test -f .kaizen/metrics/optimizer/analysis.json && echo OK
|
2025-10-19 11:47:17 +02:00
|
|
|
```
|
|
|
|
|
|
2026-08-20 22:43:55 +02:00
|
|
|
**Boundary:** kaizen-agentic does not run Temporal schedules or own durable work.
|
2025-10-19 11:47:17 +02:00
|
|
|
|
feat: scheduled agent execution via activity-core (WP-0006, v1.3.0)
Enable kaizen agents to run on a regular cadence against a preselected repo
roster, orchestrated by activity-core and prepared by kaizen-agentic — without
this repo owning cron, Temporal workers, or an LLM runtime.
CLI + module:
- src/kaizen_agentic/schedule.py — .kaizen/schedule.yml parse/validate/scaffold
- `kaizen-agentic schedule` group: init, validate, list, prepare <agent>
(prepare bundles agent prompt + memory + metrics + repo pointers, offline)
- tests/test_schedule_cli.py — 15 tests
Contract & design:
- ADR-005 scheduled agent execution; schema doc + example manifest
- discover_kaizen_scheduled_repos resolver spec, state-hub roster fields,
kaizen.schedule.prepared event payload, activity-core handoff checklist
- INTEGRATION_PATTERNS Pattern 2 extended with roster model
ActivityDefinition drafts (enabled: false):
- weekly-coach-orientation, weekly-optimization-review
Docs: agency-framework, CLI cheat sheet, PACKAGE_RELEASE runner prereqs,
EcosystemIntegration, CHANGELOG, TODO. Workplan closed (status: done).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-17 08:19:51 +02:00
|
|
|
### Scheduled agent execution (WP-0006, ADR-005)
|
|
|
|
|
|
|
|
|
|
Beyond the metrics-only definitions above, agents themselves run on a cadence
|
|
|
|
|
against a **preselected repo roster**. The roster combines three sources:
|
|
|
|
|
|
|
|
|
|
| Source | Purpose |
|
|
|
|
|
|--------|---------|
|
|
|
|
|
| State Hub `GET /repos/` | Canonical slug list + `host_paths` |
|
|
|
|
|
| Repo opt-in: `.kaizen/schedule.yml` exists with `version` set | Per-repo enablement |
|
|
|
|
|
| Optional hub flag `kaizen_schedule_enabled: true` (future) | Operator override |
|
|
|
|
|
|
|
|
|
|
A repo is **schedule-eligible** when it is registered with reachable
|
|
|
|
|
`host_paths` **and** carries a valid `.kaizen/schedule.yml`. The activity-core
|
|
|
|
|
resolver `discover_kaizen_scheduled_repos` intersects these and emits
|
|
|
|
|
`context.scheduled_runs` (one entry per `(repo, agent)`); definitions `for_each`
|
|
|
|
|
over that output.
|
|
|
|
|
|
|
|
|
|
| Definition | Trigger | Agent | Prepare command |
|
|
|
|
|
|------------|---------|-------|-----------------|
|
|
|
|
|
| [weekly-coach-orientation](integrations/activity-definitions/weekly-coach-orientation.md) | Cron Mon 09:00 | `coach` | `schedule prepare coach` |
|
|
|
|
|
| [weekly-optimization-review](integrations/activity-definitions/weekly-optimization-review.md) | Cron Mon 10:00 | `optimization` | `schedule prepare optimization` |
|
|
|
|
|
|
|
|
|
|
**Listing schedule-eligible repos** (operator, no activity-core code):
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
# In each candidate repo on a host listed in state-hub host_paths:
|
|
|
|
|
kaizen-agentic schedule validate && kaizen-agentic schedule list
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
**Design docs (no state-hub / activity-core code in this repo):**
|
|
|
|
|
|
|
|
|
|
- [schedule-schema.md](integrations/schedule-schema.md) — `.kaizen/schedule.yml`
|
|
|
|
|
- [state-hub-roster-fields.md](integrations/state-hub-roster-fields.md) — hub fields/filters
|
|
|
|
|
- [discover-kaizen-scheduled-repos.md](integrations/discover-kaizen-scheduled-repos.md) — resolver spec
|
|
|
|
|
- [kaizen-schedule-prepared-event.md](integrations/kaizen-schedule-prepared-event.md) — event payload
|
|
|
|
|
|
2026-08-20 22:43:55 +02:00
|
|
|
### Current automated runtime
|
|
|
|
|
|
|
|
|
|
The original WP-0006 resolver and manual prepare smoke established the supplier
|
|
|
|
|
contract. Current unattended execution composes it as follows:
|
|
|
|
|
|
|
|
|
|
| Stage | Owner | Contract |
|
|
|
|
|
|-------|-------|----------|
|
|
|
|
|
| Schedule/event and eligibility | activity-core | Temporal definition/rule plus repo/agent context |
|
|
|
|
|
| Durable work | activity-core | Unique idempotency key, `ops_run` state, lease, retry, result |
|
2026-08-21 08:30:13 +02:00
|
|
|
| Task intake | Caller or selected rein | Claim/receive bounded work; intake remains rein-local where implemented |
|
2026-08-20 22:43:55 +02:00
|
|
|
| Agent orientation | kaizen-agentic | `schedule prepare <agent>` offline bundle |
|
2026-08-21 08:30:13 +02:00
|
|
|
| Execution resolution | glas-harness | Explicit versioned `harness_profile_ref` → rein/model/sandbox/tools/limits; normalized evidence |
|
|
|
|
|
| Inner execution | Glas-selected rein | Backend-specific bounded loop, policy enforcement, and credential use |
|
2026-08-20 22:43:55 +02:00
|
|
|
| Coordination evidence | State Hub | Roster, workplan/progress references; never prompts or secrets |
|
|
|
|
|
| Improvement evidence | kaizen-agentic / artifact-store | Project metrics and optional durable artifacts |
|
|
|
|
|
|
|
|
|
|
Manual invocation remains supported for smoke tests and operator-controlled
|
|
|
|
|
work. The automated path should keep prompts, secrets, and raw model output out
|
|
|
|
|
of `ops_run` and State Hub records.
|
|
|
|
|
|
|
|
|
|
**Boundary:** kaizen-agentic declares and prepares; activity-core schedules and
|
2026-08-21 08:30:13 +02:00
|
|
|
queues; glas-harness resolves the explicit execution profile; the selected rein
|
|
|
|
|
executes; State Hub owns the roster and coordination view.
|
feat: scheduled agent execution via activity-core (WP-0006, v1.3.0)
Enable kaizen agents to run on a regular cadence against a preselected repo
roster, orchestrated by activity-core and prepared by kaizen-agentic — without
this repo owning cron, Temporal workers, or an LLM runtime.
CLI + module:
- src/kaizen_agentic/schedule.py — .kaizen/schedule.yml parse/validate/scaffold
- `kaizen-agentic schedule` group: init, validate, list, prepare <agent>
(prepare bundles agent prompt + memory + metrics + repo pointers, offline)
- tests/test_schedule_cli.py — 15 tests
Contract & design:
- ADR-005 scheduled agent execution; schema doc + example manifest
- discover_kaizen_scheduled_repos resolver spec, state-hub roster fields,
kaizen.schedule.prepared event payload, activity-core handoff checklist
- INTEGRATION_PATTERNS Pattern 2 extended with roster model
ActivityDefinition drafts (enabled: false):
- weekly-coach-orientation, weekly-optimization-review
Docs: agency-framework, CLI cheat sheet, PACKAGE_RELEASE runner prereqs,
EcosystemIntegration, CHANGELOG, TODO. Workplan closed (status: done).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-17 08:19:51 +02:00
|
|
|
|
2026-06-16 01:53:01 +02:00
|
|
|
---
|
2025-10-19 11:47:17 +02:00
|
|
|
|
2026-06-16 01:53:01 +02:00
|
|
|
## Pattern 3 — artifact-store evidence retention
|
2025-10-19 11:47:17 +02:00
|
|
|
|
2026-06-16 01:53:01 +02:00
|
|
|
**Problem:** Optimizer outputs need durable, attributable retention beyond local disk.
|
2025-10-19 11:47:17 +02:00
|
|
|
|
2026-06-16 01:53:01 +02:00
|
|
|
**Contract:** `metrics publish` registers `analysis.json` + `recommendations.jsonl`
|
|
|
|
|
as an artifact package with `retention_class: raw-evidence`.
|
2025-10-19 11:47:17 +02:00
|
|
|
|
|
|
|
|
```bash
|
2026-06-16 01:53:01 +02:00
|
|
|
export ARTIFACTSTORE_API_URL=http://127.0.0.1:8000
|
|
|
|
|
export ARTIFACTSTORE_API_TOKEN=<token>
|
|
|
|
|
kaizen-agentic metrics optimize
|
|
|
|
|
kaizen-agentic metrics publish --target .
|
2025-10-19 11:47:17 +02:00
|
|
|
```
|
|
|
|
|
|
2026-06-16 01:53:01 +02:00
|
|
|
**Manifest:** [integrations/optimizer-artifact-manifest.md](integrations/optimizer-artifact-manifest.md)
|
2025-10-19 11:47:17 +02:00
|
|
|
|
2026-06-16 01:53:01 +02:00
|
|
|
**Boundary:** Publish is optional; local `.kaizen/metrics/optimizer/` remains canonical.
|
2025-10-19 11:47:17 +02:00
|
|
|
|
2026-06-16 01:53:01 +02:00
|
|
|
---
|
2025-10-19 11:47:17 +02:00
|
|
|
|
2026-06-16 01:53:01 +02:00
|
|
|
## Pattern 4 — Canon and knowledge (stretch)
|
2025-10-19 11:47:17 +02:00
|
|
|
|
2026-06-16 01:53:01 +02:00
|
|
|
Design-only paths for info-tech-canon and kontextual-engine:
|
2025-10-19 11:47:17 +02:00
|
|
|
|
2026-06-16 01:53:01 +02:00
|
|
|
- [integrations/canon-template-mapping.md](integrations/canon-template-mapping.md)
|
|
|
|
|
- [integrations/briefs/tdd-workflow-canon-brief.md](integrations/briefs/tdd-workflow-canon-brief.md)
|
|
|
|
|
- [integrations/kontextual-wiki-ingestion-spike.md](integrations/kontextual-wiki-ingestion-spike.md)
|
2025-10-19 11:47:17 +02:00
|
|
|
|
2026-06-16 01:53:01 +02:00
|
|
|
No runtime dependency in WP-0004.
|
2025-10-19 11:47:17 +02:00
|
|
|
|
2026-06-16 01:53:01 +02:00
|
|
|
---
|
2025-10-19 11:47:17 +02:00
|
|
|
|
2026-06-16 01:53:01 +02:00
|
|
|
## Environment variables
|
2025-10-19 11:47:17 +02:00
|
|
|
|
2026-06-16 01:53:01 +02:00
|
|
|
| Variable | Used by | Purpose |
|
|
|
|
|
|----------|---------|---------|
|
|
|
|
|
| `HELIX_SESSION_UID` | `metrics record` | Fleet session correlation |
|
|
|
|
|
| `HELIX_REPO`, `HELIX_FLAVOR` | `metrics record` | Session context |
|
|
|
|
|
| `HELIX_TOKENS`, `HELIX_INFRA_OVERHEAD_SHARE` | `metrics record` | Fleet cost fields |
|
|
|
|
|
| `HELIX_STORE_DB` | `metrics correlate` | Digest lookup database |
|
|
|
|
|
| `ARTIFACTSTORE_API_URL` | `metrics publish` | Registry endpoint |
|
2026-06-16 02:26:13 +02:00
|
|
|
| `ARTIFACTSTORE_API_TOKEN` | `metrics publish` | Write auth bearer token |
|