Architektur: Craftvia-Domänenmodell, Verträge und Team-Schnitte

- Migration 0002_craftvia_domain: 27 Fachtabellen inkl. RLS (enable_tenant_rls)
- TENANT_MODELS (db.ts, backup/topology.ts) um alle Fachmodelle ergänzt
- moduleGuard liefert DB-autoritative Rechte; ServiceCtx für Domänen-Services
- Verträge: Statusmaschine, Events, Nummernkreise, Sichtbarkeits-Scopes,
  Job-Queues + Worker, KI-Provider-Interfaces, Sync-Envelope
- docs/craftvia/ARCHITEKTUR.md mit Lanes, Ownership und DoD

Gate: tsc, lint, build, 22/22 Tests grün.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-09-14 11:49:21 +02:00
co-authored by Claude Opus 5
parent 1701db0a62
commit bf4456718e
21 changed files with 2670 additions and 12 deletions
+16
View File
@@ -0,0 +1,16 @@
import type { DomainEvent } from "@/lib/events";
import type { ServiceCtx } from "@/server/services/context";
/**
* Emit a domain event AFTER the mutation succeeded. Never throws: a failing notification
* must not roll back business data — failures are logged and surfaced via sync/notification
* monitoring. Lanes call ONLY this function; the notifications lane owns the handler.
*/
export async function emitEvent(ctx: ServiceCtx, event: DomainEvent): Promise<void> {
try {
const { handleEvent } = await import("@/server/services/notifications/handle-event");
await handleEvent(ctx, event);
} catch (err) {
console.error(`[events] ${event.type} for ${event.entityType}:${event.entityId} failed:`, (err as Error).message);
}
}