Files
kaizen-agentic/wiki/IdempotentCompounding.md

5.0 KiB
Raw Blame History

IdempotentCompounding

Kaizen Agentic Philosophy

IdempotentCompounding — a primer

Definition (one-liner): Build and evolve systems by idempotent automation (safe to run repeatedly) and compounding increments (small units that add durable value), governed by outcomes and quality gates.

Core principles

  • Idempotence by default — Every operation (provision, deploy, migrate, refactor) is safe to re-run; desired state > imperative steps.
  • Compound value, not complexity — Ship small, composable capability units that stack cleanly and raise the baseline.
  • Evidence over intention — Each increment must declare its value metric and show before/after.
  • Reversibility — Fast rollback/roll-forward; changes are sliceable and isolated.
  • Sustainability as a constraint — Optimize for maintainability, cost, energy, and human time.
  • Quality is automated — Tests, checks, and drift detection run continuously, not occasionally.
  • Documentation is generated — Architecture, runbooks, and changelogs are derived from code & traces, then curated.

The operating cycle (repeatable)

Select → Specify → Safeguard → Apply → Verify → Record

  • Select a high-ROI increment (hotspot × business value).
  • Specify desired state (declarative spec, schema, or refactor objective).
  • Safeguard with idempotent checks: contract tests, drift monitors, health probes.
  • Apply via automation (IaC, pipelines, codemods) — re-runnable end-to-end.
  • Verify outcomes (SLOs, cost, complexity, security).
  • Record: update arc42 views, ADR, and the quality dashboard.

Rule of thumb: if youre afraid to re-run it, its not IdempotentCompounding yet.

Units of change (the “compounders”)

  • Infra Module (e.g., Terraform/Kubernetes object)
  • Service Capability (feature flag, API slice)
  • Quality Guide Move (codemod + lint rule)
  • Data Contract (schema + migration + validation)
  • Ops Control (SLO, alert, autoscaler policy)

Each unit carries:

  • Spec (YAML/DSL + schema)
  • Guards (tests/checks)
  • KPIs (value metric)
  • Rollbacks (delete/replace plan)
  • Docs hooks (arc42/ADR update hints)

Minimal guardrails

  • Idempotence test: run the job twice; expect no diff.
  • Blast-radius cap: feature flags, canaries, or scoped namespaces.
  • Drift sentry: reconcile loop or plan delta must be ≈0 after apply.
  • Budget bound: change must not breach cost/latency/error-rate budgets.
  • Timebox: if verification cant prove value in X hours, revert or park.

Metrics that matter

  • Value: SLO attainment, cycle time, revenue/usage lift, defect escape rate ↓
  • Quality: Maintainability index ↑, complexity/duplication ↓, DoC compliance %
  • Sustainability: € per request ↓, watts per request ↓, toil hours ↓
  • Reliability: MTTR ↓, change failure rate ↓, successful re-runs % = 100

Tooling patterns (typical stack)

  • Desired state: Terraform/Pulumi, Helm/Kustomize, GitOps (Argo CD/Flux)
  • Idempotent app changes: migration frameworks, codemods (libCST/jscodeshift), OpenRewrite
  • Verification: contract & golden tests; load tests in CI for hot paths
  • Observability: traces/metrics feeding fitness functions in pipelines
  • Docs: Structurizr/PlantUML generated from code + traces; ADRs as code

How it fits the AbcdekGuidance Practice

A — Architecture (ArcFortyTwo): auto-generate views; define fitness functions (what “value” means). B — Build (SafetyNetTests): make verification idempotent; contract tests become guards. C — Clean (CleanByDefinition): encode idempotence rules (no side-effect scripts, reversible migrations). D — Direction (GamePlan): prioritize compounders with best value/effort ratio. E — Evolve (RefactoringLoop): codemods + tests prove idempotent repeats and measurable deltas. K — KeepClean (Kaizen): weekly trend checks; drift/DoC gates keep compounded value from decaying.

Templates (drop-in)

  1. Value Ticket (per increment)

Title: Desired State: Guards: <tests/checks to pass; idempotence proof: re-run yields no diff> Value Metric: <name, baseline, target, window> Rollback: Docs Hooks: <arc42 sections / ADR to update> Owner / ETA:

  1. Idempotence Checklist

[ ] Declarative spec exists [ ] Dry-run/plan produces stable diff [ ] Double-apply yields zero change [ ] Safe to parallelize or properly serialized [ ] Idempotent cleanup (delete/apply symmetry)

Example (brief)

  • Goal: Reduce p95 latency by 20% on /checkout.
  • Compounder: Add Redis read-through cache for product lookups (Helm values + code toggle).
  • Guards: Contract tests for /checkout; load test at 95th percentile; drift check on Helm release.
  • Apply: helm upgrade (safe to re-run), feature flag rollout 10%→100%.
  • Verify: p95 from 480 ms → 360 ms (7-day window), error rate unchanged.
  • Record: ADR-012, arc42 runtime view updated, dashboard shows value trend.

Bottom line

IdempotentCompounding turns improvement into a safe, repeatable habit: every step is re-runnable, every change compounds value, and every gain is proven.

xxx