Conventions
Architecture Decision Records Every significant decision that shaped the platform, each with a one-line rationale and its current status.
Architecture Decision Records (ADRs) capture the why behind the platform's
structure. The full records live in docs/ai-context/decisions/ in the repo,
indexed by docs/ai-context/decisions/README.md. This page lists every ADR,
grouped by area. Status mirrors the record's own header.
Accepted means the record describes how the system works today.
Proposed documents an intended direction that is not (fully) built;
Rejected was never adopted. Superseded means a later ADR or PRD
replaced it; Deprecated means the mechanism was removed with no successor.
Both records are kept as history. Number 060 was never used.
ADR Decision Status 001 Dual database — emofyplatform_auth (identity) separate from emofyplatform_core (business data).Accepted 002 RS256 JWT (migrated from EdDSA) so any JWKS verifier can check tokens.Accepted 005 Better Auth over NextAuth — org plugin, 2FA, JWT, multi-session.Accepted 006 OrgScopedRepository — auto-injected orgId + soft-delete filtering; raw tenant queries forbidden.Accepted 007 Prefixed nanoid IDs — generateId("entity") → entity_....Accepted 024 API keys — custom backend module instead of Better Auth's apiKey plugin.Accepted 026 Seed data lives in the pure leaf package @emofy/seed-data.Accepted 027 Prefixed-ID SSOT in the pure leaf package @emofy/ids.Accepted 028 Org role vocabulary renamed; platform privilege has a single SSOT.Accepted 031 Account onboarding — user-scoped state + org invite short codes.Accepted 085 Native passkeys via react-native-passkeys + the official server plugin.Accepted 090 Native → web session handoff — one-time token, single handoff page on the account host.Accepted
ADR Decision Status 021 Relationship-based permissions — access = role ∧ active relationship/enrollment ∧ consent.Accepted 034 Internal authorization platform — decision service, policy sources, fact store, PEP adapters.Accepted 035 Authorization leaf packages @emofy/authz-core + @emofy/authz.Accepted 036 ABAC operator engine — restrict-only AST, narrows after the RBAC decision.Accepted 037 Scope-plane model — tenant / personal / platform planes, enforced by a coverage ratchet.Accepted 070 RLS pilot — database-level tenant backstop on report_cards and grades.Accepted 071 Response-view serialization with zod view schemas, not class-transformer.Accepted 077 Third-party authz enforcement — composite guard, two trust branches, measured back-compat.Accepted 078 Row-level authz — imperative handler checks + repository predicates; ABAC projection deferred.Accepted 084 Platform authorization tiers — support / auditor / admin / operator.Accepted 103 Org custom roles are grant-only — extra rows on the static matrix, lazy-loaded in the guard.Accepted 116 Deny policies on the allowed path — in-process org cache (30 s), owner exemption, fail-closed.Accepted
ADR Decision Status 020 Dual ledger — org operational ledger + parent-owned child passport.Accepted 022 Child-data classification — ledger / consent / retention / visibility matrix.Accepted 032 Legal document content has one SSOT package, @emofy/legals.Accepted 033 Docs reference blocks are generated from code SSOTs and drift-gated.Accepted 046 Guardian-authored passport entries — a second writer on the parent ledger.Accepted 048 Child badges are a read-only derivation of the passport.Accepted 049 Child mode — age-appropriate access and closed surfaces.Accepted 050 Account deletion scope and the field-level anonymization boundary.Accepted 052 Import consent boundary + batch / rollback model.Accepted 068 DSAR orchestration ledger + class-based retention engine.Accepted 069 Driver location data regime — purpose limitation, 72 h raw-ping purge.Accepted
ADR Decision Status 009 Messaging SSOT — Postgres SSOT + Convex realtime mirror. Superseded by 025 → 073 → 104 010 Transactional outbox for durable side-effect dispatch (webhook outbox is the live use).Accepted 025 Messaging Convex-first SSOT + Postgres compliance archive. Superseded by 073 → 104 029 Convex mirror table naming aligned to the SSOT. Deprecated (104) 030 Identity-plane Convex mirroring via a transactional outbox. Superseded by 104 044 Structured message cards — versioned data payload validated on send; stored message is plaintext.Accepted 045 Expo Push HTTP API as the native push provider.Accepted 047 Convex → backend notification bridge. Superseded by 104 051 SMS — TR-first provider abstraction with a fallback chain.Accepted 055 Push credential operator handoff and secret regime (VAPID + Expo).Accepted 073 Messaging hybrid dual writer — REST/Postgres authoritative, opt-in Convex-first. Superseded by 104 074 Conversation create — best-effort synchronous mirror + outbox fallback. Superseded by 104 075 Convex ↔ Postgres sync hardening. Superseded by 104 083 Announcement channels and bulk email delivery paths.Accepted 104 Realtime provider = Cloudflare Durable Objects ; Convex retired.Accepted
ADR Decision Status 018 MongoDB decommission — the audit firehose moved to partitioned Postgres.Accepted 023 API versioning & deprecation policy for the partner API.Accepted 038 Organization-deletion cascade — schema-introspected purge order.Accepted 039 Event replay — typed reconstruction + idempotency ledger.Accepted 042 Perf baseline — Redis histograms over Prometheus/OTel.Accepted 043 Flag evaluation precedence — kill > override > cohort > percentage > default.Accepted 054 Search — Meilisearch pre-filter + row scope, fail-closed permission trimming.Accepted 057 Analytics warehouse — separate analytics schema, T+1 rollup, PII-free.Accepted 063 Billing provider abstraction and entitlement model.Accepted 064 Media scan provider seam — interface + no-op default.Accepted 065 Backup & disaster recovery — inventory, RPO / RTO.Accepted 066 Org lifecycle state machine — single-writer matrix + windowed purge.Accepted 067 Surveys is a core module, separate from family forms.Accepted 072 Fees (org → parent) are separate from platform billing (Emofy → org).Accepted 086 Onboarding step payloads in jsonb + a shared pure state machine in @emofy/types.Accepted 087 Seed plan artifacts in R2; only aggregates in the ledger.Accepted 088 Ops incident data ownership.Accepted 110 SIS copy-model records — org-native record, optional account link, mirror columns.Accepted 117 Org as seller — iyzico marketplace / sub-merchant, one seller-account seam.Accepted 119 Org sales invoices — e-Arşiv / e-Fatura integrator port, none by default.Accepted 122 Seed universe — the mock universe lands in a real DB through domain writers.Accepted
ADR Decision Status 003 EMA-first architecture — domain features are EMAs; core holds only interaction channels.Accepted 012 EMA R2 immutable publish — R2 is an artifact store, not a root of trust.Accepted 041 EMA mobile-view compatibility flag semantics.Accepted 056 EMA manifest v2 — agent-surface schema and tool registration.Accepted 059 Cafeteria scopes as EMA permissions + the ema/cafeteria surface.Accepted 061 EMA event-subscription delivery gating.Accepted 062 dev-sdk resource client generated from the OpenAPI snapshot.Accepted 076 Personal-plane app surface — install = tenant, global flag, no org override.Accepted 080 EMA runtime activation — web env gate, native ungated.Accepted 081 Personal-plane runtime deferral. Superseded by 112 112 Personal-plane EMA runtime — personal token, plane-default deny, native host.Accepted 118 EMA data plane — acting-user token, direct REST, host owns only the experience.Accepted 124 Host-owned EMA navigation — host draws title and back button; one back controller.Accepted
ADR Decision Status 004 RDS + Ramarkable split — low-level primitives vs. high-level components.Accepted 053 Observability stack — OTel via the Sentry provider, exporter selection, rollback levers.Accepted 082 Native Sentry re-enable gate — killswitch stays on until a real-device retest passes.Accepted 089 App route story-coverage ratchet .Accepted 091 Native list header — pull-to-reveal secondary layer, in-place collapsing search.Accepted 092 Consumer web rewrite — thin host apps/app, packaged consumer screens, incremental ports.Accepted 093 Sentry v11 + OTel bootstrap — mode matrix, single provider (replaces 053 §1).Accepted 095 Consumer demo mode — build flag + shared mock ports package.Accepted
ADR Decision Status 011 Multi-environment credentials — dev / staging / production + CLI.Accepted 013 Decouple backend env validation from T3 — shared Zod schema. Rejected 014 Runtime destructive-target guard + agent secret-handling policy.Accepted 015 Railway as the backend platform — EU, env per project.Accepted 016 OpenTofu hybrid IaC — no secrets in state.Accepted 017 Infisical as the secret SSOT — three-way ownership.Accepted 019 Domain split — emofy.com.tr = prod, emofy.net = non-prod. Superseded by 108 058 Turbo task-scoped env — strict mode, generated from the env schema.Accepted 079 Package boundary tags + repo-wide turbo boundaries.Accepted 107 Deploys run from the operator's machine — pnpm deploy:<env>, clean clone, staging first.Accepted 108 All tiers under emofy.com.tr — tier host pattern, prefix + strip mitigations.Accepted 109 Railway ownership split — tofu project + domains, Railway IaC services, Infisical shared vars.Accepted 115 Build once, promote many — CodeBuild build plane, sha-bound artifact set. Rejected 120 R2 storage + CDN — tier × purpose buckets, EU jurisdiction, separate EMA domain.Accepted
ADR Decision Status 008 Paperclip AI agent orchestration. Superseded 040 Parallel-agent orchestration — path-conflict plane, ready queue, generated status panel.Accepted 094 Gotcha pool SSOT — lane table + secret-value pattern in one module.Accepted 096 Probabilistic model output is advice, not a gate .Accepted 097 Proof-carrying FRs — named Phase 5 evidence + red-revert.Accepted 098 Readiness v2 — question bank + pre-mortem + assumptions instead of a score.Accepted 099 Independence is the runner's job — isolated headless agent, run record as proof.Accepted 100 Out-of-band memory consolidation — probabilistic proposal, deterministic apply.Accepted 101 Night driver — deterministic loop controls, segment agent judges, never pushes.Accepted 102 _provegate — standalone control app outside the workspace, HTTP-only boundary.Accepted 105 Agent core single source — five entry files, injection + measurement.Accepted 106 Single-family panel / scorer — effort in the launch contract, routing kill switch.Accepted 111 Operator's chat Go is operator approval — hook record, ask binding, per-turn push.Accepted 113 Model router — one routing point, suggested vs. applied route, shadow mode.Accepted 114 Cross-machine PRD assignments — tracked single-writer record, network-free gates.Accepted 121 Single-writer lander + signed feat push — narrow exception to 114 §2.Accepted 123 Emofy CLI REPL runs in-process with Ink; commands take a CommandRuntime.Accepted 125 Panel lens plan bound to the diff, quorum in code, recheck round.Accepted
Data model — 001, 006, 007, 010, 018, 020, 021.
Authentication — 002, 005, 084, 085, 090.
Domains — 003, 020, 021, 104.
The EMA ecosystem — 012, 024, 112, 118.
Deployment — 015, 016, 017, 107, 108, 109.