utils/crdt-sync/tool/_seeded_apps.py
Krzysztof kuhy Rudnicki 29ea6e2c50
Some checks failed
dependency freshness / dependencies on newest stable (push) Waiting to run
file length / file-length (push) Waiting to run
md-naming / markdown naming convention (push) Waiting to run
palette drift / palette (push) Waiting to run
repo-contract / repo contract (push) Waiting to run
shared gate tests / gate unit tests (push) Waiting to run
crdt-sync pre-commit / pre-commit (push) Has been cancelled
crdt-sync tests / test (push) Has been cancelled
crdt-sync: seed_session accepts --app sufler
The sufler PC TTS relay reads ~/.config/sufler/firebase_auth.json via
credential_store_for("sufler"), like tutor, so it needs a seeded session.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Jw52sNWquCp34dy3rj19GD
2026-10-24 08:00:42 +02:00

63 lines
3.0 KiB
Python

# Copyright (c) 2026 Krzysztof Rudnicki
"""Which apps keep a desktop Firebase session, and why the list is hand-kept.
Split out of ``seed_session.py`` for the 250-line cap. The rationale is worth
more than the tuple: it is what stops the next person from "simplifying" this
into a directory scan.
"""
from __future__ import annotations
from typing import Final
# Every app that calls firebase_client_for/mirror_client_for from the desktop,
# and so keeps a refresh token under ~/.config/<app>/. Named here rather than
# discovered from ~/.config: a missing directory is exactly the case that
# needs seeding, so discovery would skip the app that needs this most.
# The remaining Flutter-only apps (home_inventory, workout_app) are absent on
# purpose: they authenticate in-app on the phone and have no desktop session.
# `todo` used to be grouped with them, but it grew a real desktop wrapper
# (lib/desktop/wrapper_server.dart) with its own Firebase REST client that
# needs a session exactly like the Python daemons do -- see
# lib/sync/firebase_backend.dart and lib/desktop/wrapper_server.dart in
# ~/todo. Its credential cache lives at ~/.config/todo/firebase_auth.json,
# same shape as every entry below, even though the reader is Dart, not
# Python: FirebaseCredentials.fromJson in crdt_sync_dart parses the exact
# {id_token, refresh_token, expires_at} shape credential_store_for writes.
#
# Re-derive rather than guess when adding one; a repo-by-repo sweep missed two
# of these. Grep all of ~ for the string literal passed to firebase_client_for,
# mirror_client_for and credential_store_for across every *.py. That still
# misses call sites passing a constant (wake_alarm._constants.SYNC_APP_NAME,
# home_guard._constants.APP_NAME), so check those by name too. "interop" is
# tool/interop_seed.py's own scratch store, not an app.
DEFAULT_APPS: Final = (
"diet_guard",
"wake_alarm",
"screen_locker",
"byox_ladder",
"leetcode_guard",
"todo",
"home_guard",
# The shared free-day pool (~/src/utils/freedays), not an app: its systemd
# timer is headless and it has no session of its own to inherit, so
# without this a day marked on the phone never reaches the PC.
"freedays",
# The shared sick-day pool (~/src/utils/sickdays): headless like freedays,
# and the screen-locker "I'm sick" button pushes through it too.
"sickdays",
# The daily RTDB backup (~/src/dufs-cloud/firebase_backup). A headless
# user timer with its own session, so it never races an app's token file.
"firebase_backup",
# ~/src/daily-limits: its user timer publishes today's limits for the
# phone app and answers its requests, with a session of its own.
"daily_limits",
# ~/src/tutor: its PC worker answers the Flutter client's requests over
# RTDB (/tutor/v1), headless, with a session of its own.
"tutor",
# ~/src/sufler: its PC TTS relay (tts/sufler_tts/relay/setup.py) answers
# the Flutter client over RTDB (/sufler), headless, reading
# ~/.config/sufler/firebase_auth.json via credential_store_for("sufler").
"sufler",
)