# Imladris — Codebase Data Map & 20-Point Global Compliance Audit

> **DRAFT FOR LEGAL COUNSEL REVIEW:** This technical-legal audit and data map reflects the verified state of the Imladris codebase (`v0.45.0`). All legal conclusions, placeholders, and draft policies must be reviewed and approved by qualified legal counsel prior to commercial distribution or public reliance.

---

## 1. Verified Codebase Data Map

Imladris is a **local-first desktop application** written in Vala/GTK4 (`io.github.Antux912012.Imladris`). It operates **zero analytics**, **zero advertising SDKs**, **zero HTTP cookies**, and **zero central backend servers** operated by `[LEGAL_ENTITY_NAME]`.

### A. Local Data Storage (On-Device Only)

| Store / Path | Data Stored | Purpose | Retention & Erasure |
| :--- | :--- | :--- | :--- |
| `~/.config/imladris/` (`SettingsManager`, `AiConfigManager`) | UI preferences, hardware settings, opt-in AI provider URLs/API keys (`ai_config.json`, `0600`), fallback Copilot token (`0600`) | Persist user configuration and credentials locally | Retained until deleted by user or via `imladris --purge-user-data` (`Application.vala:143-155`) |
| OS Keyring (`libsecret` — `io.github.Antux912012.Imladris.Copilot`) | GitHub Copilot OAuth token (if user authenticates) | Secure credential storage | Retained until logout or keyring deletion |
| `~/.cache/imladris/` (`DocsRepositoryClient`, `PackageIndexCache`) | Cached 11-domain Help Hub manuals + `etags.json`, optional CRAN/PyPI package index | Offline documentation & autocomplete | Cleared via `imladris --purge-user-data` |
| `~/.local/share/imladris/` (`LocalModelManager`, `ToolchainManager`) | Downloaded GGUF local LLM weights, managed micromamba/uv environments | Offline local inference and reproducible R/Python sandboxes | Cleared via `imladris --purge-user-data` |
| Workspace `.imladris-qual.db` (`QualDatabase.vala`) | Qualitative span indices, SHA-256 line hashes, analytical memos, CRA queries, AI suggestions, and append-only `audit_log` | Reproducible research & ALCOA+ audit trail | Stored inside user's local project directory; controlled solely by user |
| `/proc/<pid>/status` & `/proc/cpuinfo` (`main.vala`, status bar) | Local process RAM/VRAM usage & CPU family check for `GSK_RENDERER` | Local performance telemetry & Haswell iGPU compatibility | Ephemeral in-memory; never transmitted over network |

### B. External Network Endpoints (All User-Initiated or Opt-In)

| Service / Endpoint | Source File | Data Sent | Out of EEA/UK? | DPA Needed (if Enterprise/SaaS)? |
| :--- | :--- | :--- | :--- | :--- |
| **Elrond Cloud AI Providers** (OpenAI, Anthropic, Gemini, DeepSeek, NVIDIA, Moonshot/Kimi, Qwen, Groq, Cerebras, OpenRouter, GitHub Models) | `src/core/AiConfigManager.vala`, `src/AiClient.vala` | User-selected prompts / manuscript excerpts (strictly opt-in; free-tier failover gated by `free_api_consent_accepted`) | Yes (US / CN depending on chosen provider) | User brings own API key; controller/user contracts directly with chosen provider |
| **GitHub Copilot OAuth** (`github.com/login/device`, `api.github.com`) | `src/ai/CopilotAuthService.vala` | OAuth device code, GitHub user token, Copilot completions | Yes (US — GitHub, Inc.) | User's GitHub Copilot account governs |
| **HuggingFace Hub** (`huggingface.co/api/models/...`) | `src/ai/LocalModelManager.vala` | Model repository GET requests (no personal data) | Yes (US/Global CDN) | No (public model weight downloads) |
| **Bioinformatics APIs** (UniProt `rest.uniprot.org`, Ensembl `rest.ensembl.org`, AlphaFold `alphafold.ebi.ac.uk`, Galaxy `usegalaxy.eu`/`.org`/`.org.au`) | `BioEntityPopover.vala`, `AlphaFoldBridgePopover.vala`, `QualSubsystemBridges.vala`, `galaxy_client.vala` | Gene/protein symbol or accession queries; Galaxy workflow/history API requests (with user's Galaxy API key) | EU (EMBL-EBI / UseGalaxy.eu) or US/AU depending on chosen Galaxy server | Only if user uploads sensitive human/clinical data to a remote Galaxy instance |
| **Citation & Package Registries** (Zotero, CrossRef DOI, CRAN `cloud.r-project.org`, PyPI) | `ZoteroService.vala`, `DoiBibService.vala`, `PackagesRibbonBar.vala`, `PackageIndexCache.vala` | DOI/citation queries, package names | Global CDNs / US / EU | No (unless syncing private Zotero libraries with user API key) |
| **GitHub Docs & Community Plugins** (`raw.githubusercontent.com/Antux912012/imladris/main/...`) | `DocsRepositoryClient.vala`, `HelpHubPanel.vala`, `PluginManager.vala` | User-initiated conditional HTTP `GET` (`If-None-Match` ETag) for manuals/registry (auto-fetch on map disabled; blocked in air-gapped mode) | Yes (US — GitHub CDN) | No (public read-only static assets) |
| **Cytoscape Desktop CyREST** (`http://localhost:1234/v1`) | `CyRestClient.vala` | Local CX2 network graph JSON | No (loopback `127.0.0.1`) | No (local IPC) |
| **Exported Reveal.js HTML Slides** (`cdn.jsdelivr.net/npm/reveal.js@5`) | `PresentationTemplateDialog.vala:584-592` | Browser requests Reveal.js JS/CSS when exported HTML slides are opened online | Global CDN | Disclosed in `COOKIE_AND_STORAGE_POLICY.md` |

---

## 2. 20-Point Compliance Matrix (EU, DMA, UK Common Law, US & Global)

| # | Requirement | Status Before | Action Taken / Codebase Evidence | Status After |
| :-: | :--- | :--- | :--- | :--- |
| **1** | **Privacy Notice (GDPR Art. 13, UK GDPR, CCPA)** | Partial (`PRIVACY.md` lacked UK/US disclosures, controller placeholders, DPA/ICO/AG rights) | Authored [PRIVACY_POLICY.md](PRIVACY_POLICY.md) mapped strictly to verified code flows with `[PLACEHOLDER]` controller fields | **Compliant (Draft for Counsel)** |
| **2** | **Terms & Conditions (EU, DMA, UK Common Law, US)** | Missing formal ToS/EULA | Authored [TERMS_AND_CONDITIONS.md](TERMS_AND_CONDITIONS.md) with Apache-2.0 core licence, UK CRA 2015 statutory carve-outs, DMA portability alignment, and commercial add-on terms | **Compliant (Draft for Counsel)** |
| **3** | **Right of Withdrawal (EU 2011/83/EU & UK CCR 2013)** | Missing | Authored [RIGHT_OF_WITHDRAWAL.md](RIGHT_OF_WITHDRAWAL.md) with 14-day withdrawal notice, digital content exception, and statutory Model Withdrawal Form | **Compliant (Draft for Counsel)** |
| **4** | **Cookie & Local Storage Policy (ePrivacy, UK PECR)** | Undocumented local XDG/SQLite/WebKit storage | Authored [COOKIE_AND_STORAGE_POLICY.md](COOKIE_AND_STORAGE_POLICY.md) inventorying zero HTTP cookies, XDG paths, `.imladris-qual.db`, and exported Reveal.js CDN | **Compliant (Draft for Counsel)** |
| **5** | **Consent Banner & Gatekeeping** | Desktop app has zero analytics/tracking scripts; cloud failover gated by `free_api_consent_accepted` | Verified zero pre-consent telemetry in `src/`; documented ePrivacy/Garante banner rules for any future web portal in [COOKIE_AND_STORAGE_POLICY.md](COOKIE_AND_STORAGE_POLICY.md) | **Compliant (Desktop) / Documented (Web)** |
| **6** | **Forms & Consent Records** | No pre-ticked marketing boxes; `free_api_consent_accepted` opt-in; `.imladris-qual.db` logs UTC timestamps | Verified opt-in consent gates in `AiClient.vala` / `AiSettingsDialog.vala`; immutable `audit_log` records UTC timestamps and actor IDs | **Compliant** |
| **7** | **Data Minimization** | Local-first; no unnecessary user profile fields collected | Verified no central user registration database exists; desktop stores only functional config and user-authored files | **Compliant** |
| **8** | **SDKs, Fonts & External Services** | Local GTK4 system fonts; external endpoints undocumented in one register | Mapped all external HTTPS endpoints above; verified `HelpHubPanel` uses local system/monospace fonts with zero external font CDNs | **Compliant** |
| **9** | **Dark Patterns Audit (DSA Art. 25, UCPD, DMCC)** | No timers, scarcity, or roach-motel flows in app | Verified zero dark patterns in UI dialogs; added explicit null-effect validation in `ClinicalBiostatsPopover` | **Compliant** |
| **10** | **Price Transparency & Auto-Renewal** | Core app is free/open-source (`Apache-2.0`); commercial Enterprise Packs mentioned in `NOTICE` | Added clear VAT/tax-inclusive pre-checkout and cancellation terms in [TERMS_AND_CONDITIONS.md](TERMS_AND_CONDITIONS.md) for any future paid packs | **Compliant (Draft for Counsel)** |
| **11** | **Authentic Reviews** | No fabricated reviews in app or metadata | Verified zero fake reviews in `metainfo.xml` and `README.md` | **Compliant** |
| **12** | **Substantiated Claims** | ASD-STE100 copy audit cleaned uncalibrated claims in `docs/manuals/` | Verified objective technical descriptions across `docs/manuals/` and `metainfo.xml` | **Compliant** |
| **13** | **Alt Text / Accessible Labels (EAA / WCAG 1.1.1)** | `HelpHubPanel` snippet button lacked `aria-label` (fixed earlier) | Added `aria-label` on WebKit snippet buttons; GTK4 widgets use `tooltip_text` / `label` | **Compliant** |
| **14** | **Color Contrast >= 4.5:1 (EAA / WCAG 1.4.3)** | Nord palette (`#ECEFF4` on `#2E3440`, `#1E242B` on `#FFFFFF`) >= 11:1 | Verified Nord Dark (`#ECEFF4` on `#2E3440` = 12.1:1) and Light (`#1E242B` on `#FFFFFF` = 15.6:1) exceed 4.5:1; documented in [ACCESSIBILITY_STATEMENT.md](ACCESSIBILITY_STATEMENT.md) | **Compliant** |
| **15** | **Keyboard Navigation & Focus (EAA / WCAG 2.1.1 / 2.4.7)** | `HelpHubPanel` HTML lacked `:focus-visible` outline (fixed earlier) | Added `:focus-visible` outlines in `HelpHubPanel.vala`; GTK4/Adwaita dialogs support `Tab` and `Esc` natively | **Compliant** |
| **16** | **Corporate Disclosures** | Only author name & GitHub email present | Added `[LEGAL_ENTITY_NAME]`, `[VAT_OR_TAX_ID]`, `[COMPANY_REG_NUMBER]`, `[REGISTERED_ADDRESS]`, `[PRIVACY_CONTACT_EMAIL]` placeholders in legal docs | **Pending Entity Fill-In** |
| **17** | **Children's Data Protection (GDPR Art. 8, UK AADC, COPPA)** | Not applicable to local offline app; disclosed for any online features | Added explicit age-eligibility clause (13/14/16 per jurisdiction) in [PRIVACY_POLICY.md](PRIVACY_POLICY.md) and [TERMS_AND_CONDITIONS.md](TERMS_AND_CONDITIONS.md) | **Compliant (Draft for Counsel)** |
| **18** | **Email Separation & Unsubscribe** | App sends zero emails | Documented zero email transmission; any future commercial mailing list must use one-click unsubscribe per PECR/CAN-SPAM | **Compliant** |
| **19** | **Licenses & IP Compliance** | **Discrepancy found:** `PRIVACY.md` stated `GPL-3.0-or-later`, while `LICENSE`/`NOTICE`/`meson.build` state `Apache-2.0` | Aligned `PRIVACY.md` to `Apache-2.0` (core) + `GPL-3.0-or-later` (`data/icons/papirus/`), updated `NOTICE` and [LICENSES_AND_DPA_REGISTER.md](LICENSES_AND_DPA_REGISTER.md) | **Compliant** |
| **20** | **Self-Service Data Erasure (GDPR Art. 17, CCPA, DMA)** | `imladris --purge-user-data` already implemented (`Application.vala:143`) | Verified deterministic local erasure command + open-format portability (`.md`, `.qmd`, `.cx2`, `.graphml`, `.csv`, `.sqlite`) | **Compliant** |

---

## 3. Placeholders Requiring Completion Prior to Publication

Before publishing these legal documents for commercial or organizational distribution, replace every placeholder below:

* `[LEGAL_ENTITY_NAME]` — Full legal name of the company or sole trader (or individual maintainer).
* `[COMPANY_REG_NUMBER]` — Company registration number (e.g., Companies House No., REA / Registro Imprese, or equivalent).
* `[VAT_OR_TAX_ID]` — VAT / P.IVA / Tax Identification Number (mandatory on EU/UK commercial websites).
* `[REGISTERED_ADDRESS]` — Registered physical business address.
* `[PRIVACY_CONTACT_EMAIL]` / `[SUPPORT_EMAIL]` / `[PEC_OR_LEGAL_EMAIL]` — Monitored contact addresses for data subject requests and legal notices.
* `[GOVERNING_LAW_JURISDICTION]` & `[COMPETENT_COURTS]` — Governing law and venue (e.g., Laws of England and Wales / Italy, subject to mandatory consumer domicile rules).
* `[EFFECTIVE_DATE]` — Date of adoption.

---

## 4. Items for Qualified Legal Counsel Review

1. **License Alignment (`Apache-2.0` core + `GPL-3.0-or-later` icons):** `PRIVACY.md` and `NOTICE` have been aligned to `Apache-2.0` for core application code and `GPL-3.0-or-later` for bundled `data/icons/papirus/` symbolic icons (`LICENSE`, `meson.build`, `imladris.spec`, `PKGBUILD`). Confirm final commercial distribution posture with counsel.
2. **Commercial Enterprise Packs:** Finalize SLA, liability caps, and DPA templates if commercial Enterprise Packs (SSO / centralized GxP audit) are offered for sale.
3. **DMA & Clinical GxP Positioning:** Confirm regulatory classification (research workbench vs. regulated medical device / SaMD under EU MDR or FDA 21 CFR Part 11).
