Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
caccc82
spike(sync): prove encrypted transcript envelopes and define Drive pa…
daniele21 Nov 19, 2026
d9c2cfd
feat(sync-spike): add signed vault manifest and fail-closed Mac Keych…
daniele21 Nov 19, 2026
98ff49a
docs(sync): distinguish iteration governance from unrun crypto gates
daniele21 Nov 19, 2026
c14c8e1
test(sync): require encrypted vault and real Keychain smoke on Mac lane
daniele21 Nov 19, 2026
b4cfd62
docs(sync): respect active workstream context budget without weakenin…
daniele21 Nov 19, 2026
159afbf
docs(sync): record Mac crypto PASS and Keychain session blocker with …
daniele21 Nov 19, 2026
3e78909
docs(sync): record repeat Mac Keychain background-session failure aft…
daniele21 Nov 19, 2026
390cfd1
docs(sync): record GUI-session synthetic Keychain success and remaini…
daniele21 Nov 19, 2026
25fb5e5
test(sync): add native packaged-app Keychain identity probe with synt…
daniele21 Nov 19, 2026
e422895
docs(sync): distinguish Mac unit PASS from background and packaged GU…
daniele21 Nov 19, 2026
b8dfea6
ci(sync): separate deterministic Mac checks from required GUI Keychai…
daniele21 Nov 19, 2026
56e8693
docs(sync): record exact-source ad-hoc packaged GUI Keychain PASS and…
daniele21 Nov 20, 2026
ca4549f
spike(sync): independent recovery capsule and authenticated offline r…
daniele21 Nov 20, 2026
05eeca1
docs(sync): record offline recovery and pairing security Mac PASS wit…
daniele21 Nov 20, 2026
f03e283
spike(sync): Keychain-anchored durable owner ledger and future-key re…
daniele21 Nov 20, 2026
5cd4d78
docs(sync): keep active security plan bounded, remove stale duplicate…
daniele21 Nov 20, 2026
d923719
docs(sync): remove redundant Keychain history to meet bounded plan bu…
daniele21 Nov 20, 2026
846f703
docs(sync): capture exact Mac PASS for durable owner ledger and revoc…
daniele21 Nov 20, 2026
a1a962c
spike(sync): stage Keychain intent and require authenticated forward-…
daniele21 Nov 20, 2026
d659874
docs(sync): record exact Mac evidence for authenticated forward-only …
daniele21 Nov 20, 2026
4da41fc
spike(sync): verify native macOS Keychain update and cleanup in signe…
daniele21 Nov 20, 2026
cc9d6e9
docs(sync): record exact Mac validation of native Keychain probe back…
daniele21 Nov 20, 2026
e90e952
fix(sync): select macOS Data Protection Keychain for device-only nati…
daniele21 Nov 20, 2026
519fd28
docs(sync): record exact Mac PASS for protected native Keychain query…
daniele21 Nov 20, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .github/ci/local-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,18 @@ uv sync --all-extras --frozen --python 3.12
pnpm exec tsc --noEmit
)
UV_CACHE_DIR=.cache/uv uv run --frozen --python 3.12 python -m unittest discover -s test -v

# Isolated security spike, synthetic-only. These tests are deliberately
# mandatory on the Mac runner: a green draft PR governance check does not run
# the experiments directory. Do not upload private data or install globally.
SECURE_SYNC_PY=(uv run --no-project --python 3.12 --with 'cryptography>=46,<47' --with 'keyring>=25,<26' -- python)
UV_CACHE_DIR=.cache/uv "${SECURE_SYNC_PY[@]}" -m unittest discover -s experiments/secure_sync -p 'test_*.py' -v
# REAL_ENVIRONMENT: Keychain calls require an interactive macOS GUI login session.
# This shared background runner returned errSecInteractionNotAllowed (-25308)
# twice, even after login Keychain unlock. The native installed/frozen app
# validation is a SEPARATE blocking physical GUI-user gate, never inferred from
# successful deterministic CI: scripts/probe_packaged_keychain.py --build.
echo "KEYCHAIN_REAL_ENVIRONMENT=NOT_RUN context=background-runner (separate GUI gate required)"
source .github/ci/setup-browser.sh
E2E_SOURCE_REVISION="$(git rev-parse HEAD)" node scripts/browser_meeting_ui_e2e.mjs
echo "ClosedRoom Mac source and browser FULL_MEDIA checks passed"
2 changes: 2 additions & 0 deletions ClosedRoom.spec
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,8 @@ hidden_imports = [
"local_asr_server.runtime.service_manager",
"korgis_sdk", # opt-in SDK is bundled; legacy analysis remains the default
"local_asr_server.bundled_module_dispatch",
"local_asr_server.macos_keychain_native",
"local_asr_server.macos_keychain_probe",
"local_asr_server.services",
"local_asr_server.services.analysis_service",
"local_asr_server.services.transcription_service",
Expand Down
71 changes: 71 additions & 0 deletions docs/workstreams/secure-sync-google-drive.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Secure multi-device transcript sync — Google Drive pilot

Status: ACTIVE / isolated security-format experiment on `feature/google-drive-secure-sync-foundation`
Target: `dev`. Product: PRODUCT_FEATURE; delivery: ITERATION; validation: FULL (repository selector: unknown executable `experiments/` path; risk floor STRONG for crypto/data lifecycle); execution: AGENT_LOCAL prototype, REMOTE_AUTOMATED integration, REAL_ENVIRONMENT for Keychain/OAuth and independent second Mac. No release claim.

## User and outcome

A ClosedRoom user records, transcribes, diarizes and analyzes meetings on-device, and can privately read the resulting transcript/notes on an authorized second device **while the original Mac is powered off**. Primary experience is read-only until conflicts and trust-recovery are proven. No assumption of cloud inference, cloud account requirement, browser execution or cloud fallback.

Non-goals of first pilot: remotely transcribing, syncing audio/screenshots/models, collaborative sharing, bidirectional editing, server-hosted plaintext search, silent automatic upload, cleanup or migration of legacy material.

### Risks and decisions

- **VALUE:** verify that a second Mac can read a finalized transcript offline; no mobile build is needed to validate the job.
- **USABILITY:** Google connection must not be confused with cryptographic authorization; device enrollment requires mutual verification and explicit approval. A comprehensible independent recovery flow is essential.
- **FEASIBILITY:** canonical data are split across `TranscriptionStore`, `RecordingStore` and `CatalogStore`; do not sync their raw files, WAL DB or directories, and do not create alternate persistence owners.
- **VIABILITY:** user-owned Google Drive storage avoids a ClosedRoom-hosted content server, but OAuth setup/review, API quotas and support still have costs.
- **PRIVACY/SECURITY:** default is local-only, user opts into Drive separately. The app encrypts *before* any network call. Google can observe account, traffic, object counts/sizes and timing. Google OAuth is not vault authorization. No analytics, meeting content or secrets in logs/CI.
- **DATA INTEGRITY:** upload success is not verified recovery; snapshot must be decryptable and restorable on an independent device before claiming recoverability. Do not evict audio/transcripts. A provider can delete/replay old authenticated data unless trusted state/backup prevents it.

## Canonical ownership and system contract

- `TranscriptionStore` owns transcription identity, content, correction and analysis; `RecordingStore` owns notes, screenshots and recording/audio lifecycle; `CatalogStore` owns local indexes.
- Future sync **reads a versioned allowlisted projection** from these owners. Do not mutate local canonical source data on import; remote read-only cache needs a scoped persistence owner and lifecycle design before implementation.
- Encrypt whole snapshot on originating Mac. In the proof format the public header is only schema version, opaque random object id, random HKDF salt/nonce, ciphertext. IDs, titles, speaker labels, notes and transcript are inside authenticated encryption.
- For production: a vault root key protected by Keychain (and a separately held user recovery secret), device-specific asymmetric identities, explicit pairing, key epoch/rotation, authenticated signed append-only manifest/head, replay/rollback detection with pinned trusted checkpoints, signed revocation and tested failure recovery.
- Storage: Drive API v3 `appDataFolder`, OAuth `drive.appdata` least privilege, on-device token storage, `changes.list` with `spaces=appDataFolder` only after an initial exhaustive inventory; bounded retry/rate limiting and offline queue. No sharing in appDataFolder: new device authenticates to same Google account but gets vault access **only** via authenticated pairing/recovery.
- Safe deletion in every layer: remote cache deletion != meeting deletion != audio eviction. Never delete the last verified copy. No secrets/API tokens in public manifests or exported docs.

## UX — first enrollment and additional device

1. Settings → Privacy & storage → Sync devices. Default OFF; consent explains what leaves the Mac (only ciphertext; no audio or screenshots). Connect Google account through OS/browser OAuth; show actual effective state, not saved preference as success.
2. Mac generates vault secret and device identity **locally**, stores secrets in Keychain; user receives independent recovery code and must confirm they saved it before enabling upload. No server stores plaintext keys. New transcripts remain local until explicit opt-in.
3. Second Mac: choose "Link existing vault" then sign in to same Google account (this proves storage access only). New device creates ephemeral key pair and a short-lived QR challenge.
4. Existing Mac: scan QR or enter a safe short linking code, compare a human-readable authentication phrase/6-digit code on *both* screens, explicitly approve the new device with name and permission "Read only". Expiring one-time challenge, mutual authentication, replay protection and no unverified key substitution.
5. Existing Mac encrypts a device-specific vault-key grant bound to new device public key and confirmed challenge; new Mac verifies owner signature and decrypts the grant locally. **Never put the root key, grants to unintended recipients or recovery secret in a QR or Drive plaintext.** A compromised Drive account alone must not authorize a new device.
6. New Mac downloads encrypted manifest/objects, checks authenticated revisions and decrypts into private read-only offline cache. UI: Downloading / Available offline / Locked / Key needed / Conflict / Not recoverable, with retry. No fake success when no verified decrypt.
7. Devices list: show name, enrollment time, last authenticated sync and read-only privilege; explicit revoke. Revocation rotates future content keys and stops new grants. Cached plaintext already accessed on a stolen device is **not remotely erasable with certainty**.
8. Recovery if no authorized device remains: supply independent recovery secret *plus* ownership of Drive data, reconstruct identity/keys on clean Mac, rotate device grants and invalidate old devices. If every key/recovery secret is lost, data are unrecoverable by design. Test a genuine independent restore before calling it backup.

## Execution graph and evidence

| ID | Outcome | Status | Required evidence |
| --- | --- | --- | --- |
| SYNC-0 | Threat model, consent boundaries, pairing/recovery flow; no implicit remote fallback | DONE design | Review with canonical storage owners |
| SYNC-1 | Prove a portable AES-256-GCM authenticated transcript-only object with no raw export of paths/provider credentials | DONE experimental | Synthetic round-trip, wrong key, tamper, invalid schema/size, plaintext absence (6 local tests) |
| SYNC-2 | Production vault identity/Keychain, independent recovery and signed manifest/head | ACTIVE (offline proof PASS only) | Durable anti-replay, authenticated pairing UX, key rotation/revocation, real second Mac recovery, review |
| SYNC-3 | Explicit OAuth `drive.appdata` and Drive read/write adapter, offline outbox, receipts and bounded incremental list | BLOCKED on SYNC-2 | Fake transport faults + real isolated Google test account, no sensitive user meetings |
| SYNC-4 | Read-only canonical projection and isolated second-Mac cache; pairing/permissions/revoke UX | BLOCKED on SYNC-2/3 | Second physical Mac with source powered off, cache offline, mutual QR verification, revoke |
| SYNC-5 | Integrated Settings/Meeting status, complete privacy copy, accessible UX and correct cleanup | BLOCKED on SYNC-4 | Automated E2E FULL_MEDIA; WKWebView/Keychain target Mac; security/recovery audit |
| SYNC-6 | Consider mobile companion/read-write editing **only after** the above is verified | BLOCKED | Product evidence and conflict-management design |

### Security prototype boundary

- `vault_manifest.py`: Ed25519 owner-signed head, contiguous epochs, checkpoint and encrypted-object digest verification. A new Mac cannot infer freshness from Drive.
- `vault_keychain.py`: local-only Keychain experiment for vault/owner identity and trusted checkpoints; not Secure Enclave or product integration.
- `recovery_capsule.py`, `device_pairing.py`, `owner_ledger.py`: separate recovery material, X25519 read-only grants, SQLite serialized/signed registry with a Keychain high-water anchor, fresh independent future-epoch keys on revocation. All synthetic/offline; pairing UX, crash recovery, independent restore and provider freshness still unproven.

### Physical Keychain proof and Mac evidence

- [Mac #44552089974](https://github.com/daniele21/local-runner-infra/actions/runs/44552089974): 987 app tests, 17 security tests and browser FULL_MEDIA PASS on `b8dfea64`. Headless Keychain deliberately NOT_RUN (`-25308`).
- **GUI-user ad-hoc packaged probe PASS** (operator log, exact `b8dfea6474eee488b2a99e754941aab91fb17648`, local artifact `local-20261119T161450Z-f0de04`): same signed binary's second-process read, cleanup and no installed-app modification. Not Developer ID/notarized or installed product functionality; no pairing or Drive proof.

### Current checkpoint

- Source branch from `dev`; draft PR #225. The Keychain experiment and packaged-app synthetic security smoke are **implemented and qualified at the scope above**; product sync is still OFF. No GCS/Drive transmission or real user meeting data transferred.
- SYNC-2 offline proof at `ca4549f4`: [Mac run 44709517507](https://github.com/daniele21/local-runner-infra/actions/runs/44709517507) **987 app tests PASS, 31 isolated security tests PASS, browser FULL_MEDIA PASS**, `local-ci/mac=success`. Random 256-bit recovery code + AES-GCM capsule of owner key/vault key/trusted checkpoint; 5-minute X25519 read-only grant signed by Ed25519 owner, independently pinned owner key and manual SAS UX required. All synthetic, no production sync or real two-Mac pairing.
- SYNC-2 P0 offline candidate **tested**: [Mac #44727751442](https://github.com/daniele21/local-runner-infra/actions/runs/44727751442) exact `d923719a`: **987 app tests PASS, 45 isolated security tests PASS (14 new), FULL_MEDIA PASS**, `local-ci/mac=success`. `owner_ledger.py`: signed SQLite registry + durable nonce consumption, Keychain high-water anchor and fail-closed split-commit; fresh independent future key stored before signed epoch rotation, revoked device cannot decrypt newer data. Fake-Keychain/canonical-path tests, not production.
- SYNC-2 local forward-crash recovery **PASS**: [Mac #44763250585](https://github.com/daniele21/local-runner-infra/actions/runs/44763250585), source `a1a962c6`: **987 app tests, 57 security tests (12 new), browser FULL_MEDIA PASS**, `local-ci/mac=success`. Keychain prepared-intent precedes SQLite COMMIT; signed successor and actual epoch key must match. Only explicit owner-confirmed forward completion; old/rolled-back DB, missing/forged intent, unsigned/alternate state fail closed.
- Native Keychain fix: user's 2026-11-20 GUI packaged run **FAIL** on new vault probe after successful artifact build. Likely root cause: missing `kSecUseDataProtectionKeychain` qualifier for macOS `ThisDeviceOnly` item. Patched in `e90e9527` for all native CRUD without fallback; [Mac #44783958239](https://github.com/daniele21/local-runner-infra/actions/runs/44783958239) **995 app tests PASS (3 new), 57 isolated security tests PASS, FULL_MEDIA PASS**, `local-ci/mac=success`. Sanitized OSStatus now available if rerun fails. **New exact-head GUI Keychain still PENDING**, not a verified fix on user's session.
- Still ACTIVE: ambiguous pre-commit/genesis recovery, OS Keychain rollback, owner/recovery rotation, recipient trust/two-screen UI, real two-Mac restore, actual product consent/integration and provider freshness. No Drive/OAuth/user-data sync.
Loading
Loading