# סיכום סשן — 0014
תאריך: 2026-05-20 18:15
אפליקציה: VitSiteTrack
נושא: מחקרי דאטה ופרטיות + סקילים + עדכון תוכנית

## מה נבנה/הושלם

### 1. מחקר עומק דאטה אנליסט (סאב-אייג'נט)
מסקנות אופרטיביות שהוטמעו בתוכנית:
- **Stack:** Firebase Analytics (GA4, חינמי, baseline) + **PostHog EU Cloud/Frankfurt** (group analytics ל-B2B + feature flags; חינם עד 1M events/חודש). BigQuery נדחה עד לקוחות Office משלמים.
- **North-Star = `report_sent`**. Funnel ליבה: `visit_started → report_sent`. Activation = report_sent ראשון תוך 7 ימים.
- **Event taxonomy MUST מ-M2:** project_created · visit_started/ended · finding_added(type) · voice_transcription_used · transcription_completed/failed · draft_opened/edited · report_rendered · report_sent · user_signed_in · seat_invited/activated · upgrade_prompt_shown/clicked
- **שדות tenant/attribution שחובה מ-M2 (לא ניתן backfill):** orgId + schemaVersion + createdByUid על כל doc · collection orgs/{orgId} (tier, seatLimit, ownerUid, analyticsOptOut) · orgs/{orgId}/usage/current rollup · users עם orgId/seatRole/invitedByUid/firstReportSentAt
- **מוניטיזציה:** seat upsell (activeSeats→seatLimit) · tier-gating דרך PostHog flags · churn early-warning מ-rollup · usage-based pricing טריוויאלי בזכות המונים

### 2. מחקר עומק סקיוריטי ופרטיות (סאב-אייג'נט, ריצה שנייה אחרי rate limit)
מסקנות אופרטיביות:
- **Firestore Rules:** deny-by-default + tenancy **path-scoped תחת `orgs/{orgId}/...`** (לא flat+שדה orgId) + `orgId`/`role` כ-**custom claim חתום-server** (Function `setOrgClaim`) + write validation (immutable fields, hasOnly, role gating). **מצב הנוכחי `auth!=null` = פגיעת cross-tenant חיה** — תיקון ב-M2.
- **Storage:** UUID אקראי בנתיב + signed URL קצר-TTL מ-Function בלבד (לא getDownloadURL ארוך).
- **App Check:** monitor ב-M2 → enforce לפני beta; חובה על sendReportEmail/cryptoFn.
- **Tokens:** Cloud KMS envelope encryption (לא AES נגזר-UID — UID אינו סוד). decrypt רק ב-cryptoFn. Token doc: kmsKeyVersion/scope/expiresAt/rotatedAt.
- **OAuth — חוסם launch, lead-time שבועות:** Google `gmail.send` בלבד (sensitive, ללא CASA) · Microsoft delegated `Mail.Send` בלבד + **Publisher Verification** (Partner account + DNS-verified domain) · PKCE + exact-match redirect.
- **מגן משפטי (תיקון 13, בתוקף 14.8.2025, אכיפה מ-1.2026):** משרד=controller, VitSiteTrack=processor. חובה: DPA מול כל משרד · Privacy Policy+ToS · sub-processor DPAs (במיוחד ספק תמלול EU/no-training) · DPIA קל · נוהל breach. DPO לא חובה בסקייל זה (לתעד ניתוח).
- **Client:** `--obfuscate --split-debug-info` · `FLAG_SECURE` על PII/report · secure_storage קצר-טווח בלבד.

### 3. סקילים חדשים — מוכללים לכל האקוסיסטם
- **`data-analyst` (דאטה אנליסט)** — `D:\Vitruvius Ecosystem\Skills\data-analyst\SKILL.md` + מותקן ב-`~/.claude/skills/data-analyst/`. הפעלה יזומה לפני models/schema של B2B app חדשה.
- **`security-agent` (סוכן סקיוריטי)** — `D:\Vitruvius Ecosystem\Skills\security-agent\SKILL.md` + מותקן ב-`~/.claude/skills/security-agent/`. הפעלה יזומה לפני Rules/models/OAuth.
- שני קבצי registry עודכנו: `skills-registry.md` (סעיפים 5+6) + `skills-registry.html` (כרטיסים 05+06).

### 4. עדכון התוכנית (סונכרן: snuggly-exploring-newell.md + PLAN.md)
- **§3.1 schema** — שינוי ארכיטקטוני: כל מידע tenant עבר ל-path-scoped subcollections `orgs/{orgId}/projects/.../visits/.../findings`. נוספו `orgs/{orgId}/auditLog` (append-only), `orgs/{orgId}/consentRecords`, שדות retainUntil/deletedAt על visits+findings, mfaEnabled על users, token doc עם kmsKeyVersion/scope/expiresAt
- **Storage paths** עברו ל-`orgs/{orgId}/...` + UUID אקראי
- **§3.2 Cloud Functions נוספו:** setOrgClaim · cryptoFn (KMS) · mintSignedUrl · scheduledHardDelete (TTL sweep)
- **§3.3** — token encryption שונה מ-AES נגזר-UID ל-Cloud KMS envelope; scopes ננעלו (`gmail.send` + delegated `Mail.Send` בלבד); PKCE + exact-match redirect
- **§3.4 חדש** — Analytics & Data Instrumentation מלא
- **§3.5 חדש** — Security & Privacy Architecture מלא
- **עץ services נוסף:** `audit_service.dart`, `secure_storage_service.dart`, `analytics_service.dart`; token_crypto_service תוקן להפנות ל-cryptoFn
- **Models עודכנו:** `org.dart` חדש; project/contact/visit/finding/user_profile עם orgId/createdByUid/schemaVersion/retention
- **Milestones M2 הורחב** ל-"Projects + Contacts + Analytics + Security bootstrap" + הערה על מקבילות התחלת OAuth verification

### 5. CLAUDE.md
- תת-סעיף "VitSiteTrack — Analytics & Data" נוסף
- תת-סעיף "VitSiteTrack — Security & Privacy" נוסף
- נקודה 3 ב-"4 ארכיטקטורות חיוניות" עודכנה (KMS במקום AES נגזר-UID)
- שורת Milestones M2 עודכנה

### 6. תרשימים (vit-diagram, מספור VIT-005..008)
- VIT-005 — Updated PLAN Architecture (`plan-architecture-diagram.html`): UI→Services→Data→Cloud (4 zones, חיבורי bezier)
- VIT-006 — Roadmap M1-M8 (`roadmap-diagram.html`): Foundations→Capture→Report→Launch; M1 סומן ✓ DONE, M2 סומן ▶ NEXT
- VIT-007 — Security Architecture §3.5 (`security-architecture-diagram.html`): Access→Crypto→Identity→Legal Shield; מסומנים תגי `breach חי` ו-`חוסם launch`
- VIT-008 — Data+Security Layer §3.4+§3.5 (`data-security-layer-diagram.html`): Capture→Allowlist→Tenancy→Privacy Boundary, כולל קו אדום שמסמן BLOCK של PII

## החלטות שהתקבלו

1. **PostHog EU על פני Mixpanel** — Mixpanel גובה group analytics כתוספת בתשלום; PostHog נותן בחינם + feature flags + session replay. EU Cloud (Frankfurt) משאיר את הדאטה תחת תיקון 13/GDPR.
2. **BigQuery נדחה** — scan quotas 2025 הופכים אותו לא-כדאי בסקייל מוקדם; הביטוח הזול עכשיו = schema, לא warehouse.
3. **path-scoped subcollections על פני flat + orgId field** — flat collection היה וקטור דליפת cross-tenant הקלאסי. החלטה ארכיטקטונית משמעותית שמשפיעה על firestore_service ו-queries.
4. **`orgId`/`role` כ-custom claim, לא שדה ב-doc לבדיקת גישה** — מקור האמת חתום-server, לא ניתן לזיוף; כתיבה ע"י Function `setOrgClaim` בלבד.
5. **Cloud KMS envelope על פני AES נגזר-UID** — UID אינו סוד (בכל JWT/doc); KMS מוסיף HSM + auto-rotate + Cloud Audit Logs.
6. **OAuth verification מתחיל מ-M2 במקביל** — lead-time שבועות. Microsoft Publisher Verification דורש Partner account + DNS-verified domain (משימה ידנית של המשתמש).
7. **DPO לא ממונה רשמית בסקייל זה** — לתעד את הניתוח; למנות איש קשר פרטיות בשם.
8. **סקילים שניהם נכתבו בפורמט Vitruvius** (header-based, ללא YAML frontmatter) — תואם ל-RTL/vit-diagram/vit-session-close הקיימים. שניהם עם **טריגר יזום** כדי להתפעל לפני קוד שיהיה יקר לתקן אחורה.

## בעיות שנפתרו

1. **Rate limit באמצע מחקר הסקיוריטי** — הסאב-אייג'נט הראשון נעצר על "You've hit your limit · resets 9:20pm". פתרון: הרצה מחדש של Agent עם אותו prompt מלא; הרצה השנייה הצליחה.
2. **PowerShell tool עם נתיב עם רווח** — שימוש ב-Bash במקום נכשל עם quoting. פתרון: כל הפקודות לקבצים בנתיב `D:\Vitruvius Ecosystem\` רצו דרך PowerShell tool.

## מה לא עבד / צריך להיזהר

- **SendMessage tool לא זמין** למרות שהוא מוזכר בתיאור Agent — סאב-אייג'נט אחרי rate limit לא ניתן להמשיך, רק לרוץ מחדש.
- **השינוי הארכיטקטוני של path-scoped subcollections** משפיע על: queries (אין collectionGroup query פשוט על projects בלי scope) · indexes · firestore_service כל ה-CRUD · ייתכן ויידרשו indexes מורכבים יותר. צריך לוודא ב-M2 לפני שמתחילים.
- **OAuth verification חוסם launch** — Microsoft Publisher Verification דורש Microsoft Partner account שהמשתמש צריך לפתוח ידנית + לאמת domain ב-DNS. לא נעשה הסשן הזה.
- **CLAUDE.md הולך וגדל** — כלל הסקיל אומר "לא לעלות על 150 שורות" אבל הוא כבר הרבה יותר (יש בו 4 אפליקציות). יש לעשות consolidate בסשן עתידי.
- **rules placeholder `auth != null` עדיין פעיל בפועל** — לא תוקן הסשן הזה, רק תועד שצריך לתקן ב-M2. נשאר breach risk עד שמתחילים M2 בקוד.

## קבצים שנוצרו/שונו

### נוצרו
- `D:\Vitruvius Ecosystem\Skills\data-analyst\SKILL.md`
- `C:\Users\elyas\.claude\skills\data-analyst\SKILL.md` (עותק מותקן)
- `D:\Vitruvius Ecosystem\Skills\security-agent\SKILL.md`
- `C:\Users\elyas\.claude\skills\security-agent\SKILL.md` (עותק מותקן)
- `D:\Vitruvius Ecosystem\VitSiteTrack\plan-architecture-diagram.html` (VIT-005)
- `D:\Vitruvius Ecosystem\VitSiteTrack\roadmap-diagram.html` (VIT-006)
- `D:\Vitruvius Ecosystem\VitSiteTrack\security-architecture-diagram.html` (VIT-007)
- `D:\Vitruvius Ecosystem\VitSiteTrack\data-security-layer-diagram.html` (VIT-008)

### שונו
- `C:\Users\elyas\.claude\plans\snuggly-exploring-newell.md` — §3.1 schema (path-scoped + auditLog/consent/retention) · §3.2 (4 Functions נוספו) · §3.3 (KMS + scopes ננעלו) · §3.4 חדש · §3.5 חדש · עץ services + models · Milestones M2
- `D:\Vitruvius Ecosystem\VitSiteTrack\PLAN.md` — סונכרן (38KB)
- `D:\Vitruvius Ecosystem\CLAUDE.md` — Analytics & Data section · Security & Privacy section · token encryption point · M2 milestones line
- `D:\Vitruvius Ecosystem\Skills\skills-registry.md` — סעיף 5 (data-analyst) · סעיף 6 (security-agent) · רשימת VIT עודכנה ל-VIT-008
- `D:\Vitruvius Ecosystem\Skills\skills-registry.html` — כרטיסים 05+06

## הצעד הבא — M2 שלב 1 (קוד)

1. **הפעלת Firestore** בפרויקט vitsitetrack, region europe-west1, חשבון עסקי:
   `firebase firestore:databases:create "(default)" --location=europe-west1 --project=vitsitetrack --account=vitruviusecosystem@gmail.com`
2. **Models** לפי §3.1 המעודכן:
   - `lib/models/org.dart` חדש — Org(id, name, tier, seatLimit, ownerUid, createdAt, analyticsOptOut, schemaVersion)
   - `lib/models/user_profile.dart` עדכון — להוסיף orgId, seatRole, mfaEnabled, invitedByUid, firstReportSentAt, analyticsOptOut
   - `lib/models/project.dart` חדש — Project עם orgId, createdByUid, schemaVersion, lastActivityAt + fromFirestore/toMap בסגנון VitPMIS
   - `lib/models/contact.dart` חדש — Contact עם orgId, role enum, schemaVersion
3. **`analytics_service.dart` allowlist wrapper** — לפני קריאת logEvent ראשונה (חוסם PII מבנית)
4. **Firestore Rules** (`firestore.rules`) — deny-by-default + path-scoped + write validation
5. **Cloud Function `setOrgClaim`** (Admin SDK) — כותב custom claim orgId/role
6. **`firestore_service.dart`** CRUD ל-path-scoped subcollections + Riverpod providers
7. **App Check** monitor mode + email-enumeration protection
8. **מקביל (lead-time, ידני המשתמש):** Google OAuth verification + Microsoft Publisher Verification (Partner account + DNS domain)
