Files
docs/IMPLEMENTATION_PLAN.md

22 KiB
Raw Permalink Blame History

Implementation Plan — Breakpilot Platform

Companion to PLATFORM_ARCHITECTURE.md, INFRASTRUCTURE.md, PRODUCT_INTEGRATION_SPEC.md and ERP/03 Implementation Plan.

Revised 2026-09-11. The greenfield plan (M0–M19, SysEleven, three clusters) is replaced by a migration plan: the platform is reorganised in place and brought live on staging first. Milestones are named M-MIG-{n} and keep the old format (Goal, Depends on, Repos, Deliverables, Acceptance, Tests, Gate, Effort). Production is a separate plan written after the staging gate (M-MIG-8) passes.


0. How to read this document

  • Each milestone ships independently and leaves the system in a working state; no milestone starts before the previous one's Acceptance is verified.
  • "Gate": standard = 1 human reviewer + green CI; some milestones add a manual sign-off (anything that touches live systems, DNS, or is irreversible).
  • Effort: S ≤ 1 day, M = 2–4 days, L ≥ 1 week.
  • §1 conventions apply to every PR in every repo.

1. Cross-cutting conventions

1.1 Repo strategy

Polyrepo under the Gitea org git.breakpilot.com/platform/. One repo per deployable unit.

Repo Purpose Status
platform/orca-platform IaC for the platform cluster: cluster.toml, services/<project>/service.toml, keycloak/ realm exports, tests/stage/, scripts/validate.sh, dev/ compose exists; restructured in M-MIG-3
sharang/orca-infra IaC for the core cluster (unchanged owner; company infra) exists
platform/tenant-registry Go: tenants, catalog, entitlements, usage, licences, ERP link, audit, cmd/erpmock exists; extended M-MIG-5/7
platform/portal Next.js 16 customer area + backstage exists; path tenancy M-MIG-5
platform/pruefwerk Prüfwerk (moved from sharang/compliance-scanner-agent) M-MIG-4
platform/werkbank Werkbank runner (moved from sharang/werkbank) M-MIG-4
platform/werkpilot Werkpilot CLI (moved from sharang/werkpilot) M-MIG-4
platform/firmwerk Firmwerk CLI + cloud-server (moved from sharang/firmwerk) M-MIG-4
platform/docs Mirror of the Collectives specs (Collectives is canonical) exists
platform/seed-data Demo tenant fixtures per product exists (scaffold)
platform/design-tokens CSS variables / fonts, optional for product UIs exists; no longer required by the contract

Stays put: sharang/certifai (parked), sharang/breakpilot-site, sharang/breakpilot-notetaker, Benjamin_Boenisch/breakpilot-compliance (dsms; migrates as a deployment in M-MIG-9, repo unchanged).

1.2 Per-repo scaffolding, 1.3 branch + commit conventions, 1.4 PR template, 1.5 CI checks, 1.6 approval gates — unchanged from the 2026-05 plan (trunk-based, Conventional Commits, squash-merge, commitlint + gitleaks + trivy, CODEOWNERS).

1.7 Versioning + release strategy (Orca reality)

  • Semver per repo. Images: :sha-<short> and :latest on every main build (Harbor repo.breakpilot.com/<project>/<image>), cosign-signed.
  • Stage auto-deploys on merge to main: CI POSTs a signed webhook to the platform master, Orca re-pulls and restarts <svc>-stage.
  • Production (later): tag vX.Y.Z → CI retags :sha-… as :prod-<version> and pushes to a prod branch that triggers the <svc>-prod webhook. Manual sign-off before the tag.
  • Rollback: orca rollback <svc>-<env> on the master (previous image). RTO ≤ 5 min.
  • Config changes (service files): PR → merge → git pull && orca deploy on the master (documented in orca-platform/README.md).
  • Database migrations forward-only, run by an init container / migrate binary before the service starts.

1.8 Environments

Env Where Keycloak realm tenant-registry ERPNext Data Deploy
dev laptop, orca-platform/dev/ compose breakpilot-dev (local KC) local mock fixtures n/a
stage bp-platform-stage (cluster master) breakpilot-stage on core KC tenant-registry-stage + pg-stage erpnext-mock-stage synthetic + demo auto on merge
prod bp-platform-prod (agent) breakpilot-prod on core KC tenant-registry-prod + pg-prod live erp.breakpilot.com real tag + sign-off

Hosts: app-stage.breakpilot.com / app.breakpilot.com (portal, tenants by path), registry-stage / registry (+ licence), pruefwerk-stage / pruefwerk, firmwerk-stage / firmwerk. Dev: localhost ports.

1.9 Observability + audit, 1.10 secrets, 1.11 testing policy, 1.12 feature flags — unchanged, except: secrets are Orca project-scoped (orca secrets set --project), Infisical only for the licence signing key and CI credentials.


2. What already exists (2026-09-11 baseline)

  • Core cluster breakpilot (orca-infra) with Keycloak (realms master, breakpilot, breakpilot-dev, certifai), Gitea 1.27 + Actions, Harbor, LiteLLM, Infisical, SigNoz, ERPNext v15 + CRM + Helpdesk, Nextcloud, chat, status page, landing + kontakt-relay (website form → CRM Lead).
  • On that cluster, to be moved: portal (portal-dev + 4 per-tenant containers), tenant-registry (tenant-registry-dev), the Prüfwerk stack (project certifai), and the dsms stack (project breakpilot-dsms, 12 services on *.breakpilot.ai).
  • platform/tenant-registry: schema (tenants, tenant_projects, tenant_products, tenant_idp_config, api_keys, audit_log), tenant lifecycle + catalog (hard-coded) + API keys + audit + memberships endpoints, Keycloak org provisioning, product provisioning callback. No usage / plans / subscriptions / ERP / licence code.
  • platform/portal: signup, tenant shell, catalog + trial, products, api-keys, audit (registry-backed); billing/users/settings are fixtures; host-based tenancy.
  • Prüfwerk: multi-tenant (Mongo per tenant), Keycloak auth, MCP, docs; JWT validation without iss/aud; no registry integration beyond claims.
  • Werkbank: runner, no packaging. Werkpilot: release pipeline, no licensing. Firmwerk: own licensing.
  • ERP: nothing implemented (ERP/03 Phase 0 blocked on Steuerberater; Phase 1 SKUs can start).

3. Migration milestones

M-MIG-0 — Preparation (no service changes)

  • Goal: clean repos, recorded live state, cold archives, credentials ready.
  • Depends on: plan approval.
  • Repos: sharang/orca-infra, platform/orca-platform, Gitea admin, Harbor.
  • Deliverables: commit the master's uncommitted cluster.toml on orca-infra and pull everywhere; discard the stale local edits in orca-platform and pull origin/main; record orca status, orca webhooks list, docker ps (both nodes), realm export of breakpilot-dev, Gitea runner host + labels; archives to s3://bp-orca-backups/archive-2026-09-platform-stop/ (registry pg_dumpall, certifai-mongo mongodump, tar of every portal/registry/certifai volume) with one test restore; lower Strato TTLs on the hosts that move; Gitea org secrets in platform (REGISTRY_USER/PASS, COSIGN_KEY/PASSWORD, ORCA_WEBHOOK_SECRET_STAGE, BP_S3_*) and a bot user platform-ci with read access to platform/*; Harbor projects pruefwerk, firmwerk, platform.
  • Acceptance: both IaC repos clean on origin/main; archive listed in S3 and the registry dump restores into a scratch Postgres; runner known; org secrets present.
  • Gate: standard + manual (touches the core master). Effort: S–M.

M-MIG-1 — Spec revision (this revision)

  • Goal: Collectives specs describe the target; platform/docs mirrors them.
  • Deliverables: PLATFORM_ARCHITECTURE.md, INFRASTRUCTURE.md, IMPLEMENTATION_PLAN.md, PRODUCT_INTEGRATION_SPEC.md (2.0), COST_PLAN.md, CHANGELOG.md, Readme.md template, ERP/02, ERP/03 revised; BreakPilot Infra docs updated after M-MIG-2; one mirror commit in platform/docs.
  • Acceptance: grep of the Collectives tree for *.stage.breakpilot.com, web component, widget, custom domain, SysEleven, PowerDNS, Stalwart, Stripe, Polar hits only changelog/history lines; platform/docs diff equals Collectives.
  • Gate: owner review. Effort: M. Status: in progress 2026-09-11.

M-MIG-2 — Stop and archive on the core cluster

  • Goal: the core cluster runs company infrastructure plus (temporarily) dsms and its two dependencies.
  • Depends on: M-MIG-0.
  • Repos: sharang/orca-infra.
  • Deliverables: orca stop in order: breakpilot-portal-{acme,hello,globex,sandbox}, breakpilot-portal, compliance-dashboard, compliance-docs, compliance-agent, browserless, soft-plc, plc-sim, mailserver. Keep breakpilot-tenant-registry(+db), compliance-mcp, certifai-mongo (dsms depends on them) → moved into services/dsms-deps/service.toml. Remove the stopped blocks, git pull && orca deploy on the master, verify prune or docker rm -f on both nodes. Clean-up: Gatus portal checks (services/core/status/config.yaml), Keycloak admin password rotation (the agent held it), scanner mailserver certbot + ports 25/587/993, orca webhook registrations for portal/registry/scanner. Volumes kept until M-MIG-6 verification. Update BreakPilot Infra Readme + Service Catalog.
  • Acceptance: orca status = core + dsms + dsms-deps; docker ps on both nodes matches; Gatus green; https://api-dev.breakpilot.ai/health and a membership-checked dsms call succeed; next nightly backup succeeds.
  • Gate: standard + manual sign-off. Effort: S–M.

M-MIG-3 — Staging VM and the platform cluster

  • Goal: breakpilot-platform cluster exists with one node serving https://app-stage.breakpilot.com.
  • Depends on: M-MIG-0.
  • Repos: platform/orca-platform.
  • Deliverables: Hetzner VM bp-platform-stage (CPX32, 4 vCPU / 8 GB — booked 2026-09-11; Ubuntu 24.04, company project, private network breakpilot-platform, Cloud Firewall per INFRASTRUCTURE.md §3; browserless / soft-plc / plc-sim are not deployed on staging, see INFRASTRUCTURE.md §2); docker + docker login repo.breakpilot.com; Orca at the core master's version or newer (both ≥ 0.2.13 with ACME fast-retry), installed as master with orca install-service; repo restructure: cluster.toml (name breakpilot-platform, ACME email, S3 backup bp-platform-backups, LiteLLM, admin + deployer tokens), services/<project>/service.toml layout (platform-stage, pruefwerk-stage, firmwerk-stage), every service pinned + memory-limited, [security_headers] frame_options="DENY"; delete clusters/, overlays/, dns/, manifests/, scripts/{apply,plan}.sh, release.yaml, the restore-drill stub; adapt validate.sh (pins ∈ {bp-platform-stage,bp-platform-prod}, memory required, secret refs project-scoped); README + WEBHOOKS.md describe the deploy flow; Strato A records app-stage, registry-stage, pruefwerk-stage, firmwerk-stage; a hello service on app-stage.
  • Acceptance: orca status healthy; curl -I https://app-stage.breakpilot.com = valid Let's Encrypt cert; backup lands in S3; a signed test webhook redeploys the hello service.
  • Gate: standard + manual (spend + DNS). Effort: M.

M-MIG-4 — Move and rename the product repos

  • Goal: the four product repos live under platform/ with their final names and build green.
  • Depends on: M-MIG-0 (bot user, org secrets, Harbor projects).
  • Order (git dependencies): firmwerk → pruefwerk → werkbank → werkpilot; then registry/portal link fixes.
  • Deliverables:
    1. sharang/firmwerk → platform/firmwerk: README.md package path; workflows .github/ → .gitea/ (runs-on: docker); tag v0.4.3.
    2. sharang/compliance-scanner-agent → platform/pruefwerk (transfer + rename): firmwerk git deps → platform/firmwerk tag v0.4.3, imports tramiton_* → firmwerk_*, cargo update; CI + 3 Dockerfiles → platform-ci token, full_name: platform/pruefwerk, images → repo.breakpilot.com/pruefwerk/*; fix fixtures/demo-targets/targets.json, vitepress config, demo-targets docs, .cargo/audit.toml, .env.example + config.rs openplc default, dedup.rs, agent_client.rs; delete the mailserver compose; delete stale branches; remove the retired repo webhook.
    3. sharang/werkbank → platform/werkbank: Cargo deps → platform/pruefwerk at a tag; DESIGN.md; add Dockerfile + .gitea/workflows/ci.yml → repo.breakpilot.com/pruefwerk/werkbank.
    4. sharang/werkpilot → platform/werkpilot: release.yml fallback; custom_providers/litellm.json → llm.breakpilot.com.
    5. platform/tenant-registry go.mod module → git.breakpilot.com/platform/tenant-registry (+ imports); README/CONTRIBUTING links in registry, portal, seed-data, docs.
    6. sharang/certifai: delete its two retired webhooks only.
  • Acceptance: CI green on main in all four repos after the move; cargo build of werkbank and pruefwerk against the new git deps; grep -r "sharang/\|meghsakha" in the four repos returns only LICENSE/history; images visible under Harbor pruefwerk/.
  • Gate: standard. Effort: M.

M-MIG-5 — Platform services on staging

  • Goal: signup → tenant → login → catalog works at app-stage.breakpilot.com.
  • Depends on: M-MIG-3, M-MIG-4 (registry module path).
  • Repos: platform/orca-platform, platform/tenant-registry, platform/portal, Keycloak (core).
  • Deliverables: realm breakpilot-stage from an adapted dev/keycloak/realm-export.json (orgs on; clients per PLATFORM_ARCHITECTURE.md §4; scope tenant-context = tenant_id, tenant_slug, org_roles, tenant_status; device flow; roles; theme) exported to orca-platform/keycloak/breakpilot-stage.json. Registry: migration 0002 (products table replacing catalog.go, seeded pruefwerk (+addon werkbank), werkpilot, firmwerk; certifai and compliance keys removed/disabled), GET /v1/tenants, POST /v1/internal/entitlements/check, per-client authorization map, invite client_id/redirect_uri from env, provisioning fan-out with outbox retry, SyncClaims(tenant_status). Portal: path tenancy in middleware.ts/host.ts (PORTAL_APEX_HOSTS), fixtures only under BP_DEV_FIXTURE, product tiles use catalog launch_url, AUTH_URL. Deploy project platform-stage (pg-stage, tenant-registry-stage, portal-stage) with CI webhooks.
  • Acceptance: /start creates a tenant → KC org + invite mail (to a @breakpilot.com address); login at app-stage.breakpilot.com/<slug>/dashboard; catalog shows three products; API key create/verify; audit entries; portal Playwright suite passes against staging.
  • Gate: standard + security checklist. Effort: L.

M-MIG-6 — Products on staging

  • Goal: Prüfwerk (+Werkbank), Firmwerk cloud and the two CLIs run against staging with multi-tenancy.
  • Depends on: M-MIG-5.
  • Repos: platform/pruefwerk, platform/werkbank, platform/firmwerk, platform/werkpilot, platform/orca-platform.
  • Deliverables: Prüfwerk: iss+aud validation, CORS allowlist, scheduler via GET /v1/tenants, entitlement check on tenant-context build, §4.1 endpoints, usage events; services pruefwerk-{mongo,agent,dashboard,mcp,docs}-stage on pruefwerk-stage.breakpilot.com (+ /mcp, /docs); no browserless / soft-plc / plc-sim on staging (8 GB budget); no mailserver on stage. Werkbank: werkbank-runner-stage with a registry API key (werkbank:runner). Firmwerk: firmwerk-cloud-stage + firmwerk-mongo-stage on firmwerk-stage.breakpilot.com; CLI v0.4.3 under platform packages. Werkpilot: release under platform/werkpilot.
  • Acceptance: tenants acme and globex via portal; Prüfwerk login per tenant; scan of cra-vuln-demo; tenant B cannot read A's scan (404/403); MCP token bound to tenant; runner completes a dast job; firmwerk device login against firmwerk-stage; Gatus checks for the stage hosts; old volumes on core deleted afterwards.
  • Gate: standard + security checklist. Effort: L.
  • Goal: the always-on ERP link and CLI licensing work end-to-end against the ERPNext mock.
  • Depends on: M-MIG-6. (= ERP/03 Phase 5.)
  • Repos: platform/tenant-registry, platform/portal, platform/pruefwerk, platform/firmwerk, platform/werkpilot, platform/orca-platform.
  • Deliverables: cmd/erpmock (Frappe REST surface for Customer / Subscription / Usage Record / CRM Lead / Sales Invoice, seeded SKU items, request log, /_mock/fire/* webhook triggers) deployed as erpnext-mock-stage. Registry migration 0003: plans, subscriptions, usage_events, erp_outbox, licences; ladder statuses warning|restricted|halted on tenants.status; ERPNext client + outbox worker; HMAC webhook receiver (idempotent) + 15-min reconcile; licence endpoints (Ed25519 key in Infisical platform/stage/licence-signing, /.well-known/licence-keys.json, heartbeat, revoke); SyncClaims on every ladder change. Products: Prüfwerk usage events; Firmwerk cloud-server replaces its own model with registry licence verification + entitlements/check; firmwerk login / werkpilot login device flow → licence, offline verify, heartbeat, ladder; Werkpilot LiteLLM virtual key at licence issue. Portal: billing page from registry (subscriptions, invoices via ERP), ladder banner, catalog request → CRM Lead through the outbox.
  • Acceptance: see M-MIG-8.
  • Gate: standard + security checklist. Effort: L (2–3 weeks).

M-MIG-8 — End-to-end tests on staging (gate for the production plan)

  • Depends on: M-MIG-7.
  • Deliverables: Playwright (portal) + hurl/curl scripts in orca-platform/tests/stage/ covering:
    1. signup → trial → KC org → mock Customer with tenant_id → erp_customer_id set;
    2. fire/sales-order-submit (PLT-CORE-CLD-STD + CRA-CSA-CLD-STD) → active → Prüfwerk allowed; a tenant without entitlement → 403;
    3. scan → usage event → outbox → usage record in the mock ≤ 60 s; kill the worker, scan, restart → exactly one record;
    4. fire/invoice-overdue → warning banner; past grace → restricted → Prüfwerk writes 402, reads OK; fire/payment-entry → active;
    5. Firmwerk licence: login → offline verify with network off → revoke → degrade → hard-stop (clock-skewed);
    6. Werkpilot login, licence check, seat event;
    7. isolation: cross-tenant API key / MCP token → 403; separate Mongo databases;
    8. ops: restore drill of pg-stage; redeploy via CI webhook; Gatus green 24 h.
  • Acceptance: all eight pass on two consecutive days.
  • Gate: owner sign-off → production plan starts. Effort: M.

M-MIG-9 — breakpilot-dsms migration (last)

  • Depends on: M-MIG-8; decision on pitch-deck's home (shares breakpilot-db).
  • Deliverables: pin dsms images to digests; pg_dump compliance_db + breakpilot_db; tar /data/ipfs, Qdrant, dataroom, Ollama volumes; copy to the platform node; project dsms (12 services, pinned, no public Postgres port, Qdrant on the project network) with AUTH_TENANT_REGISTRY_URL → tenant-registry-stage, SCANNER_MCP_URL → pruefwerk-stage…/mcp, realm breakpilot-stage clients compliance-client/compliance-svc, BP_S3_*; Strato repoint of admin-dev/developers-dev/api-dev/sdk-dev/qdrant-dev.breakpilot.ai and pitch.breakpilot.com; then stop + remove breakpilot-dsms and dsms-deps on core, close port 54321, prune breakpilot-dev clients, drop auth-dev.meghsakha.com, retire mail.scanner.meghsakha.com, delete Harbor certifai/*; update BreakPilot Infra docs.
  • Acceptance: dsms health on the new IPs; a known CID resolves; Prüfwerk control mapping works against the new BREAKPILOT_BASE_URL; core orca status = core only.
  • Gate: standard + manual (data move, DNS). Effort: M–L.

4. Production (separate plan, after M-MIG-8)

Book bp-platform-prod, join as agent over the private network, realm breakpilot-prod, projects *-prod, A records app, registry, licence, pruefwerk, firmwerk; wire the live ERPNext (tenant_id custom field, API user platform-registry, Frappe Webhooks with HMAC — ERP/03 Phase 5 live steps); prod branch webhooks; deployer-token handling per RISK-2; demo tenant on prod; go-live checklist from PRODUCT_INTEGRATION_SPEC.md §13 per product.


5. Cross-cutting work (ongoing)

Regression tests first; security review per milestone (cargo audit, npm audit, semgrep); DR drill at M-MIG-8; doc currency (PR template tick); OSS swap-in readiness per PRODUCT_INTEGRATION_SPEC.md §15.


6. Dependency graph

M-MIG-0 ──┬── M-MIG-1 (specs, parallel)
          ├── M-MIG-2 (stop on core) ─────────────────────────────────────────┐
          ├── M-MIG-3 (stage VM + cluster) ──┐                                │
          └── M-MIG-4 (repo moves) ──────────┴── M-MIG-5 ── M-MIG-6 ── M-MIG-7 ── M-MIG-8 ── M-MIG-9
                                                                                        │
                                                                              production plan

Critical path: M-MIG-0 → M-MIG-3 → M-MIG-5 → M-MIG-6 → M-MIG-7 → M-MIG-8. With one agent and standard review pacing: 6–9 weeks to a passing staging gate. M-MIG-1, M-MIG-2 and M-MIG-4 run in parallel with M-MIG-3.


7. Open questions

  • Pitch-deck's home (shares the dsms Postgres): move with dsms or split the database first? Decide before M-MIG-9.
  • Gitea Actions runner location (not an Orca service; verify in M-MIG-0) and whether a second runner should live on the platform master for isolation.
  • Second backup provider for the platform bucket (3-2-1) before production.
  • Prüfwerk crate/binary renames (compliance-* → pruefwerk-*) and the Mongo prefix: cosmetic, deferred; the Mongo prefix rename is a data migration.
  • DR-WS-08 §6B role mapping remains open; staging uses the V1 org_roles model.
  • ERP Phase 0/1 (Steuerberater, SKU import) proceed independently on the live ERPNext; the platform only needs the SKU codes, which are already fixed in the SKU sheet.

End of document. Revised 2026-09-11.