🪐 MOTHER BRIEF · Planet Module System Foundation

Sessione orchestratrice 2026-05-16 sab · 8h hard budget

Modello: Opus 4.7 · effort xhigh Repo: D:\Desktop\Multiverbe\ · branch base master HEAD bbb9b71 BOS SSoT: D:\Desktop\Multiverbe-Business\ Protocollo: ops/operating-protocol-orchestrator.md (BOS) · 10 XML tag obbligatori Hard gate: 10 Giugno 2026 (24gg) · MVP + 5 paganti CHF Quality target: $1B SaaS standard · zero tech-debt netto · scale-readiness +50%

🔥 MODALITÀ AUTONOMOUS FULL · ZERO BLOCKING (founder authorization 2026-05-16 sera v2 + memoria feedback_autonomous_window_auto_merge.md v2):

  • Auto-merge PR gate-passed (gh pr merge --auto --squash)
  • Auto-push code + auto-deploy Vercel (master = prod)
  • Auto-commit + auto-push BOS + auto-deploy multiverbe-bos-app (trigger "aggiorna BOS" interno)
  • Decisioni zona grigia → DECIDI best technical + LOGGA in decisions-log · NON bloccare
  • DB migration write AUTORIZZATO (Supabase apply_migration + SQL editor) · safety rails OBBLIGATORI:
    • Test prima su create_branch Supabase ephemeral (delete_branch post)
    • Migration file in database/migrations/YYYY-MM-DD{slug}.sql con UP + DOWN reversibile
    • RLS policies incluse · workspace_id scoped (no anon write su tabelle scoped)
    • get_advisors smoke pre+post (diff zero new high warning)
    • ADR per ogni nuova tabella + decisione schema
    • Project canonico yqhixdqipojvgzfadufo eu-central-1 (MAI iouqemthcpccyyfhcrno vecchio Maind)
    • Idempotency: CREATE TABLE IF NOT EXISTS + CREATE POLICY IF NOT EXISTS
    • NO DROP TABLE live · NO ALTER COLUMN distruttivo (rename+migrate pattern) · NO TRUNCATE prod

<task_spec> · SDD 6 elementi

1. Goal

Stabilire il Planet Module System (PMS) — fondazione plug-in architecture multi-tenant, scale-ready — e migrare Pianeta Web + Pianeta Booking come primi due moduli conformi. L'app deve essere pronta a far crescere CRM/Sales/Content Studio/HR a costo marginale 1-2gg/pianeta vs 5-7gg attuali, con UX/UI poi unificabile grazie a PlanetSlot + manifest condivisi.

2. Out-of-scope (NON toccare oggi)

  • Nuove feature funzionali Web/Booking (solo refactor strutturale)
  • Pianeti CRM/Sales/Content Studio implementazione (solo manifest skeleton + ADR + smoke scaffold)
  • Multilingua 5 lingue runtime (solo scaffolding LocalizedString type + i18n keys placeholder)
  • Stripe live activation, OAuth Google blockers, Reach Perplexity key (action_items separati)
  • Schema DB nuove tabelle (solo tipi + RLS policy review · migration solo se ASSOLUTAMENTE necessario, gated founder)

3. Vincoli hard

  • ZERO breaking change end-user (Web + Booking devono restare 100% funzionali a fine giornata, verified via Playwright smoke)
  • TypeScript strict: true · zero any · zero @ts-ignore senza commento WHY · branded types per WorkspaceId/PlanetId
  • Bundle size budget: core ≤25KB gz · ogni planet ≤80KB gz lazy chunk · adapters ≤15KB gz cad
  • Test coverage public surface ≥80% line · ≥70% branch · mutation score ≥60% (Stryker su packages/planet-core/)
  • Performance: planet lazy boot ≤180ms p95 (Lighthouse perf budget enforced)
  • A11y: WCAG 2.2 AA · axe-core zero violations critical/serious
  • Security: get_advisors Supabase zero new warning · CSP-strict compatible · pnpm audit 0 high/critical
  • Branch lifetime ≤1 giornata · merge entro fine sessione
  • ZERO INFO LOSS · ogni rimozione necessita ADR justifying

4. Stakeholder

  • Gregorio (founder · architect+code+product) — sblocca decisioni zona grigia
  • Loris (sales · indirettamente · gli serve Booking stabile per demo W4)
  • Claude Mother (questa sessione · helper risposte NON decisore zona grigia)
  • 2 Claude Child (sub-sessioni paralleli · worktree isolati)

5. Success metric

  • packages/{contracts, planet-core, planet-testkit, sector-adapters, planet-web, planet-booking} pubblicati monorepo, build green
  • ✅ Pianeta Web + Booking esportano PlanetModule<TState> conforme · registry loader funziona end-to-end
  • ✅ 1 nuovo pianeta skeleton (CRM) generabile via pnpm run scaffold:planet crm in <60s
  • ✅ Quality gates L1-L10 tutti verdi (pnpm typecheck && pnpm test && pnpm test:e2e && pnpm test:a11y && pnpm size && pnpm test:mutation && pnpm audit exit 0)
  • ✅ 2 PR squash-merged · <dashboard_update> BOS · 3 ADR · 1 quality_report §9 archiviato

6. Definition of Done

Vedi README.md § "Definition of Done sessione" + 50-acceptance-checklist.md.

</task_spec>


<reasoning_map>

Trade-off centrale: 8h in foundation (feature shippable visibili minori oggi) vs +50% velocity sui 4 pianeti rimanenti (CRM/Sales/Content/HR) + UX/UI unificabile = ROI 1:5 entro 10 Giu.

Perché ORA:

  • Web (70%) + Booking (30%) ancora plasmabili a costo basso. Dopo CRM/Sales/Content scriviamo lock-in inflessibile.
  • UX/UI unificata (obiettivo founder) richiede PlanetSlot shared layout · impossibile retrofit ex-post.
  • Hard gate 10 Giu in 24gg: 4 pianeti × 5-7gg vecchio pattern = 28gg FAIL. PMS comprime a 4 × 1-2gg = 8gg ✅.
  • Tech debt scoperto in Wow Audit (W-002 keyframe morti / W-010 sezioni null / W-011 screenshot stub) si chiude come side-effect del retrofit Web sotto PMS (manifest forza definizioni esplicite).

Architettura scelta — Hexagonal + DDD bounded contexts + Strangler retrofit:

  • packages/contracts/ = ports (TS interface + Zod runtime + branded types)
  • packages/planet-core/ = orchestratore (registry + loader + event bus + telemetry + feature flag + state migrator)
  • packages/sector-adapters/ = adapter layer Sole AI cross-pianeta (7 settori)
  • packages/planet-{kind}/ = bounded context per pianeta
  • packages/planet-testkit/ = contract test harness condiviso
  • Strangler: nuova interfaccia avvolge codice esistente progressivamente · zero big-bang · CI verde a ogni commit

Continuous improvement embedded:

  • ADR-driven decisioni · ogni "perché" tracciato
  • Pattern Learned + Wow Backlog auto-append a memoria/BOS
  • Quality Report §9 + Self-critique sul protocollo (meta-loop)
  • Renovate group · SBOM generato · LICENSE check · pre-commit lint-staged + commitlint conventional

</reasoning_map>


<planning_map> · 4 fasi · 8h budget

Fase 0 · Mother bootstrap (75min, 0:00–1:15)

0.1 Repo audit (15min)

cd D:\Desktop\Multiverbe
pnpm -r ls --depth 0                                      # mappa workspaces
git ls-files frontend/multiverbe-app/src/ | grep -iE "(web|booking|site)"  # locations
pnpm dlx madge --circular frontend/multiverbe-app/src/    # circular baseline

Via Supabase MCP: list_tables per RLS context su sites, bookings, form_submissions, seo_config.

0.2 Pacchetti scaffold (20min) — pnpm workspaces struttura:

packages/
  contracts/              # ports + branded types + Zod runtime
  planet-core/            # registry + loader + bus + telemetry + flags + state-migrator + healthcheck
  planet-testkit/         # contract test harness condiviso
  sector-adapters/        # Sole AI cross-planet adapters (7 settori)
  planet-web/             # retrofit target Child-1
  planet-booking/         # retrofit target Child-2

Tooling per package: tsup build · vitest test · size-limit · publint (anche se private).

0.3 Contracts committed (25min)packages/contracts/src/planet.ts da 10-contracts.ts di questo kit. Commit su feat/pms-foundation-base.

0.4 Quality gates CI scaffold (15min):

  • .github/workflows/planet-system-ci.yml da 20-ci-workflow.yml
  • Pre-commit + commitlint + lint-staged + size-limit + stryker + changesets + Renovate group da 30-tooling-configs.md

0.5 ADR seed (docs/adr/) — da 40-adr-templates.md:

  • 001-planet-module-system.md (PMS · alternative scartate · trade-off)
  • 002-hexagonal-bounded-contexts.md (DDD boundary per pianeta)
  • 003-strangler-retrofit-strategy.md (refactor incrementale)

0.6 Child briefs finali + worktree creation:

git checkout feat/pms-foundation-base
git push -u origin feat/pms-foundation-base

git worktree add ../Multiverbe-child1-pms-core -b feat/pms-core-web-retrofit feat/pms-foundation-base
git worktree add ../Multiverbe-child2-adapters -b feat/pms-adapters-booking-retrofit feat/pms-foundation-base

Children leggono 01-child-1-brief.md e 02-child-2-brief.md del session kit.


Fase 1 · Child paralleli (5h30, 1:15–6:45)

Mother fa check-in ogni 90min (ore 2:45, 4:15, 5:45):

  • Status update breve da ogni child (1 frase: cosa fatto · cosa next · blocker?)
  • Se blocker → Mother unblock entro 10min o escalate founder
  • Se scope creep → time-box hard · ritaglia su acceptance ridotto

Mother NON dirige · solo unblock + verifier-mode adversariale alla fine.

Deliverable Child-1 + Child-2: vedi rispettivi brief 01- e 02- (self-contained).


Fase 2 · Mother integration + quality gates + auto-deploy (75min, 6:45–8:00)

2.1 Verifica auto-merge (10min) — Child-1/2 hanno già aperto PR con gh pr merge --auto --squash al loro completamento. CI hard gates fanno il resto:

  1. gh pr list --base master --state merged --search "feat/pms" → entrambi mergiati post-CI green
  2. Se uno bloccato (CI rosso o conflict) → gh pr checks + gh pr view per diagnosi · fix forward (mai revert se non rompi prod)
  3. Verifier review post-merge è ADVISORY (non blocker): se trovi gap su master → action_item BOS + ADR · NON revert se non breaking prod
  4. git worktree remove ../Multiverbe-child1-pms-core && git worktree remove ../Multiverbe-child2-adapters

2.2 Full quality gate run (25min) su master:

pnpm install --frozen-lockfile
pnpm typecheck                                  # 0 errors
pnpm lint                                       # 0 new warning
pnpm test --coverage                            # ≥80% line / ≥70% branch
pnpm test:mutation                              # ≥60% planet-core
pnpm test:e2e                                   # Playwright smoke green
pnpm test:a11y                                  # axe-core 0 critical/serious
pnpm size                                       # size-limit budgets
pnpm audit --audit-level=high                   # 0 high/critical
pnpm dlx madge --circular packages/             # 0 circular
pnpm build                                      # 0 errors · sourcemaps ok

Tutti exit 0 obbligatorio. Se rosso → fix-loop · MAI mergiare con gate rosso.

2.3 Vercel PRODUCTION deploy + health smoke (10min) — push master = prod live:

  • Auto-trigger post-merge (Vercel project multiverbe-app connected a master)
  • curl https://app.multiverbe.com/api/health/planets{ web: 'ok', booking: 'ok' }
  • Lighthouse CI on PROD URL · perf budget assert hard
  • Smoke Playwright su prod: golden path + 2 edge case
  • Se prod smoke fail → feature flag pms.enabled=false flip immediato (rollback 5sec) + action_item BOS critical

2.4 BOS auto-update FULL PIPELINE (15min) — trigger "aggiorna BOS" interno automatic:

  • status.json:
    • close web-quality-gap-closure-2026-05-15 (done · via PMS side-effect)
    • close planet-module-system-foundation-prep-2026-05-16 (done)
    • add planet-module-system-foundation-2026-05-16 (done)
    • add 4 new: planet-crm-implementation-2026-05-19, planet-sales-implementation-2026-05-22, planet-content-studio-implementation-2026-05-26, planet-hr-skeleton-2026-Q3 (todo)
  • decisions-log.md: entry full "2026-05-16 · Planet Module System foundation + retrofit Web/Booking" (why · cosa · impatto · reversed)
  • activity.json: append 2 PR events + quality_report ref
  • 3 ADR riferimenti in canon/05-stack.md § "Stack Architettura"
  • cd D:\Desktop\Multiverbe-Business && npm run verify → expect PASSED
  • cd D:\Desktop\Multiverbe-Business && npm run build → expect DONE
  • cd D:\Desktop\Multiverbe-Business && git add -A && git commit -m "feat(bos): PMS foundation merged · 2 PR · 3 ADR · scale-readiness +50%" && git push origin main
  • Vercel auto-deploy multiverbe-bos-app via push hook (GitHub→Vercel integration · ~60s)
  • Verify deploy READY via Vercel MCP list_deployments --project multiverbe-bos-app --limit 1

2.5 Continuous improvement loop (5min):

  • <quality_report> §9 rubric 10 cat → execution/quality-reports/2026-05-16T{HH}-pms-foundation.md
  • <wow_check> §9-bis 3 lenti → append execution/wow-backlog.md
  • <pattern_learned> → memoria feedback_planet_module_system_architecture.md + index MEMORY.md
  • Self-critique sul protocollo: append lessons learned a ops/operating-protocol-orchestrator.md

</planning_map>


<model_recommendation>

Ruolo Modello Effort Motivazione
Mother orchestrator Opus 4.7 xhigh Decisioni architetturali · contracts design · verifier adversariale · ADR writing
Child-1 base work Sonnet 4.6 high Code generation conforme contracts pre-definiti · 6h execution lineare
Child-1 event bus design Opus 4.7 high Concurrency primitive · backpressure · OTel propagation (zona alta complessità)
Child-2 base work Sonnet 4.6 high Adapter implementation · Zod schema · Supabase integration
Child-2 contract design Opus 4.7 high SoleAdapter<I,O> ergonomia + future-proof per 4 settori non implementati
Verifier post-merge Opus 4.7 xhigh Generator-Verifier §7 adversariale · cerca attivamente buchi
Quality Report §9 Opus 4.7 xhigh $1B SaaS rubric 10 cat · critical thinking max

</model_recommendation>


<test_strategy> · piramide L1-L10

Livello Stack Target CI gate
L1 Unit vitest per-package ≥80% line / ≥70% branch hard
L2 Integration vitest + Supabase branch ephemeral RLS isolation + adapter Result<T,E> + state migrator forward/back hard
L3 Contract planet-testkit shared suite (18 test) 100% pass per ogni PlanetModule hard
L4 E2E Playwright Golden path + 3 edge case hard
L5 Visual Playwright snapshot 6 viewport Baseline pre-merge soft (review)
L6 A11y @axe-core/playwright WCAG 2.2 AA · 0 critical/serious hard
L7 Perf Lighthouse CI · Vercel preview LCP ≤2.5s · INP ≤200ms · CLS ≤0.1 · boot ≤180ms p95 hard
L8 Mutation Stryker · planet-core/ ≥60% hard
L9 Security pnpm audit + get_advisors + is-website-vulnerable + SBOM CycloneDX 0 high/critical · 0 new advisor warning hard
L10 Load k6 100vu/30s /api/health/planets p95 ≤500ms soft (info)

</test_strategy>


<acceptance_criteria>

Vedi 50-acceptance-checklist.md — printable, per-Child + Mother gate finale.

</acceptance_criteria>


Branch + PR strategy zero-conflict

  • Base branch feat/pms-foundation-base (Mother fase-0) con packages/contracts/ + .github/workflows/ + tooling configs
  • Child-1 feat/pms-core-web-retrofit da base · tocca packages/planet-core/ + packages/planet-testkit/ + packages/planet-web/
  • Child-2 feat/pms-adapters-booking-retrofit da base · tocca packages/sector-adapters/ + packages/planet-booking/
  • Zero overlap file (verified git diff --stat pre-merge)
  • Merge ordine: base + Child-1 + rebase Child-2 + Child-2

Commit convention (commitlint enforced):

  • feat(planet-system): ... · refactor(planet-web): ... · test(adapters): ... · docs(adr): ...
  • Body: 3-line summary + bullet impact + footer Refs: BOS#planet-module-system-foundation-2026-05-16

Risk register + mitigations

Rischio Prob Impact Mitigation
Child-1 scope creep su event bus → time overrun M H Hard cap 90min · escalate Opus 4.7 se >90min · fallback EventEmitter typed
Web retrofit rompe demo Loris L H Feature flag pms.enabled=true default · rollback 5sec
Supabase branch ephemeral cost spike L L confirm_cost MCP · delete_branch obbligatorio post-test
Mutation score <60% impossibile M M Allargare scope a contracts + planet-core · accept 50% giustificato in ADR
Quality gate fail in fase-2 → no merge M H Time-box fix-loop 30min · se rosso oltre → revert · NON merge gate rosso
Vercel preview deploy fail L M vercel logs + get_deployment_build_logs MCP · fix forward
Founder pinned focus drift (es. demo Loris urgente in-day) L H Mother pausa esecuzione · re-prioritize · parcheggia PMS in WIP branch · resume domenica

<dashboard_update> template (end of session)

Vedi 00-mother-brief.md § Fase 2.4 sopra + 50-acceptance-checklist.md sezione "BOS update".

</dashboard_update>


<handover_log> template (end of session)

## 2026-05-16 sab evening · Mother PMS Foundation handover

**Modalità**: Mother (Opus 4.7) + Child-1 (Sonnet 4.6 · 6h · feat/pms-core-web-retrofit) + Child-2 (Sonnet 4.6 · 6h · feat/pms-adapters-booking-retrofit)

**Output**:
- 2 PR merged a master: #{N1} (Planet Core + Web retrofit) + #{N2} (Adapters + Booking retrofit)
- 4 nuovi packages monorepo: contracts, planet-core, planet-testkit, sector-adapters (+ retrofit planet-web e planet-booking esistenti)
- 1 scaffold script DX: `pnpm run scaffold:planet <kind>` <60s
- 3 ADR archiviati: 001-pms · 002-hexagonal · 003-strangler
- 1 quality_report §9 + 1 wow_check §9-bis + 1 pattern_learned memory
- Quality gates L1-L10 tutti green

**Hard-learnings (per prossima sessione)**:
- {TODO Mother fills}
- {TODO Mother fills}
- {TODO Mother fills}

**Open follow-ups**:
- planet-crm-implementation-2026-05-19 (1-2gg target via scaffold)
- planet-sales-implementation-2026-05-22
- planet-content-studio-implementation-2026-05-26
- planet-hr-skeleton-2026-Q3
- web-quality-gap-closure-2026-05-15 CLOSED via PMS side-effect (W-002 + W-010 + W-011)

**Memory updates**:
- `feedback_planet_module_system_architecture.md` NEW (pattern_learned)
- `MEMORY.md` index updated

**Protocol updates**:
- `ops/operating-protocol-orchestrator.md` § Lessons-Learned: {TODO Mother fills}

</handover_log>


<quality_report> §9 · 10 cat A-F rubric

Mother compila a fine sessione (15min) — archive execution/quality-reports/2026-05-16T{HH}-pms-foundation.md:

# Categoria Peso Note
A Correttezza funzionale 1x Web + Booking demo end-to-end + zero regressioni
B Performance 1x Boot p95 · bundle · LCP misurati
C Security 1x RLS · audit · headers · SBOM
D A11y WCAG 2.2 AA 1x axe-core report attached
E DX 1x Scaffold script · docs · ADR · onboarding new planet docs
F Scale-readiness 1x Decoupling · contracts · event bus · state migration · feature flag
G Decision-split adherence 2x Founder vs Claude zone grigie rispettate
H Test pyramid completezza 2x L1-L10 tutti coperti
I Documentation 1x ADR · README package · inline JSDoc esempi
J Continuous improvement 1x Memory + protocol delta + wow_backlog

Score complessivo X/12 = (sum × peso) / max possible. Target ≥9.5/12.

</quality_report>


<wow_check> §9-bis · 3 lenti

Mother riflette 5min a fine sessione:

  • Magic: l'utente apre l'app e vede pianeti orbitare · scaffold genera CRM in 60s · è "incredibile"?
  • Moat: PMS è copiabile? difficile · è nostro moat tecnico? sì se documentato bene + DX onboarding
  • Polish: micro-interazioni (loading skeleton per planet boot · error boundary delight · scaffold output ASCII art?)

Append a D:\Desktop\Multiverbe-Business\execution\wow-backlog.md formato:

## W-{N} · {titolo}
- **Lente**: magic / moat / polish
- **Idea**: {2-3 righe}
- **Effort**: S/M/L
- **MVP impact**: %
- **Source**: 2026-05-16 PMS foundation session §9-bis

</wow_check>


<pattern_learned> template

Memory file: C:\Users\Gregorio\.claude\projects\D--Desktop-Multiverbe-Business\memory\feedback_planet_module_system_architecture.md

---
name: Planet Module System architecture pattern (Multiverbe)
description: PMS hexagonal + DDD bounded contexts + Strangler retrofit pattern per scaling multi-pianeta SaaS Multiverbe
type: feedback
---

PMS = packages/contracts (ports) + planet-core (registry/loader/bus/telemetry/flags/migrator) + sector-adapters (Sole AI cross-planet) + planet-{kind} (bounded context) + planet-testkit (contract test shared).

**Why**: scale-readiness +50% verified · onboarding new planet 1-2gg vs 5-7gg · UX/UI unificata via PlanetSlot shared · tech debt negativo (paga debito esistente via retrofit Strangler) · contracts force explicit definition → side-effect Wow Audit gaps closed.

**How to apply**:
- Nuovo pianeta = `pnpm run scaffold:planet <kind>` <60s
- Ogni PlanetModule<T> passa 18 contract test gratis (planet-testkit)
- Decisioni architetturali → ADR `docs/adr/NNN-*.md` obbligatorio
- Feature flag default-on con override URL `?ff=` dev · audit log su flip
- Manifest forza dichiarazione: routes · permissions · rlsTables · telemetry · featureFlags · stateSchemaVersion · bundleBudgetKb
- Event bus typed + backpressure config · OTel span propagation
- RLS workspace_id isolation testato in planet-testkit gratis

</pattern_learned>


Continuous improvement loop · meta-protocol

Mother a fine sessione DEVE:

  1. Auto-critique: rileggere questo brief e identificare ≥3 cose che andrebbero migliorate next time
  2. Append a D:\Desktop\Multiverbe-Business\ops\operating-protocol-orchestrator.md § Lessons-Learned
  3. Skill memory update se emerge pattern riutilizzabile
  4. Wow Backlog: ≥1 "magic moment" candidato dall'output di oggi
  5. Next session prep: se identifica setup utile per session domani, generare nuovo session kit folder

Exit criteria · sessione chiusa solo se TUTTI ✅

  • [ ] 2 PR merged master · CI green · Vercel preview green
  • [ ] Tutti quality gate L1–L10 verdi (escludendo L5 visual / L10 load che sono soft)
  • [ ] BOS status.json + decisions-log + ADR aggiornati e committati e pushed
  • [ ] Memory + MEMORY.md aggiornati
  • [ ] Quality report §9 archiviato
  • [ ] Wow check §9-bis appended
  • [ ] Self-improvement entry su protocol
  • [ ] Founder briefed con riassunto 5-line + next-action proposta (1-2 frasi)

START COMMAND (per la Mother che riceve questo brief · MODALITÀ AUTONOMOUS):

  1. Leggi questo intero brief + README.md del session kit (skim mode · 15min)
  2. ACK in 5 righe (NO 8 · NO domande · NO wait):
    • 1 riga <task_spec> rephrased
    • 1 riga top 3 rischi compressi
    • 1 riga confidence % completion 8h
    • 1 riga 1 decisione zona grigia che presumi + motivo
    • 1 riga 🚀 START Fase 0 · ETA 75min
  3. INIZIA SUBITO Fase 0 senza aspettare conferma · founder è AFK
  4. Esegui Fase 0 (75min) usando file pre-scritti del kit (10-contracts.ts, 20-ci-workflow.yml, 30-tooling-configs.md, 40-adr-templates.md)
  5. Crea worktree Child-1 e Child-2
  6. Spawn Child via Task tool (subagent_type=general-purpose) IN PARALLELO same turn · pass 01-child-1-brief.md e 02-child-2-brief.md integralmente
  7. Aspetta Task tool result · Fase 2 integration · BOS auto-update · improvement loop
  8. Output 8-line summary finale