mana-swift-event-sync/CLAUDE.md
Till JS 3be550a154 feat: ManaEventSync E-4.0–E-4.2 — geteilte native Event-Sync-Lib
Extrahiert die zuvor zweimal von Hand gebaute Plumbing aus pageta-native
+ nutriphi-native in ein Paket ManaEventSync (Counterpart zu @mana/event-sync):

- Core: EventEnvelope (+clientId/payloadHash), JSONValue, ULID, JWTSubject, EventSyncError
- EventStorage (SwiftData): parametrierbar (Store/App-Group/additionalModels/In-Memory),
  Outbox, Claim-Reattribute, Anonymous-Retention-Prune
- Transport: SyncHTTPClient (+X-Schema-Hash/422), optionaler SyncWSClient
- Crypto: CryptoProvider/NoOp/MasterKey (AES-GCM enc:1:), VaultClient — opt-in
- EventSyncEngine: besitzt die Identität (makeEnvelope anon/echt), emit offline,
  signIn(realUserId) re-taggt idempotent + drained, Retention 10k/90d

18 Tests grün. Plan: mana/docs/playbooks/MANA_SWIFT_EVENT_SYNC.md.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-25 12:39:59 +02:00

1.8 KiB
Raw Permalink Blame History

CLAUDE.md — mana-swift-event-sync

Guidance für Claude Code in diesem Repo.

Übergeordneter Plan: ../mana/docs/playbooks/MANA_SWIFT_EVENT_SYNC.md (Phasen E-4.0–E-4.6). Plattform-SOT: ../mana/docs/MANA_SWIFT.md.

Was dieses Repo ist

ManaEventSync — geteilte Event-Sourcing-Sync-Library für alle nativen mana-e.V.-Apps. Nativer Counterpart zu @mana/event-sync (TS). Spiegelt dessen Wire-Format + Anonymous-Mode/Claim. Konsumiert ManaCore (AuthClient) aus ../mana-swift-core.

Architektonische Invarianten

Nicht ohne explizite Diskussion antasten:

  1. Nur Plattform-Plumbing, keine App-Domäne. Payload-Typen, State-Projektionen, Reducer und Repository-API leben in der App, nicht hier. Diese Lib weiß nichts über Articles, Meals, Decks.
  2. Wire-Parität zu @mana/event-sync + mana-sync. Envelope-Felder, enc:1:-Crypto, X-Schema-Hash, Endpoints, Idempotency, attributedToUserId == JWT.sub-Grenze. Bei Drift gewinnt der Server.
  3. Identität in der Engine. attributedToUserId/actor werden in makeEnvelope gestempelt — anonym (anon:<id>) oder echt (JWT-sub). Apps rufen kein currentUserId() mehr.
  4. Anonyme Events bleiben lokal. Push/Pull/WS sind aus, bis signIn(realUserId) re-taggt + drained. Server akzeptiert nur JWT-validierte Pushes.
  5. Keine 3rd-Party-Dependencies (Compliance). Nur Foundation, SwiftData, CryptoKit, OSLog + ManaCore.
  6. Public API ist Sendable/Swift-6-Concurrency-sauber.

Konventionen

  • 4-Space-Indent, 120-col (.swiftformat/.swiftlint.yml aus mana-swift-core)
  • DE als Primary-Locale, Doc-Comments (///) auf jedem public-Symbol
  • CHANGELOG.md pflicht, Semver strikt, Git-Tag pro Sinn-Abschnitt

Lokal

swift build
swift test