halkyon/apps/learn/halkyon_learn_client/lib/migrations/migration_registry.dart
Tizian 「ティツィアーン」 dbae802915
feat(base,learn,todo): the operator's assistants, and the instance's privacy page (ADR 0021, step 2)
The server half of the assistants (points 4 to 8, D27 to D46): the
operator sets language models in deploy/assistants.env, grants them to
people with limits, and the module forwards their questions with the
operator's key, counting what each used, never what was asked.

- assistantsFrom: ASSISTANTS, ASSISTANT_ID_KEY, ASSISTANT_<ID>_NAME,
  _PROTOCOL (anthropic, openai, openai-responses), _BASE_URL, _MODEL,
  _KEY, _IMAGES, _PRICE_INPUT and _PRICE_OUTPUT (per million tokens),
  ASSISTANT_CURRENCY, ASSISTANT_OWN_KEYS; anything unusable stops the
  server as it starts, naming the variable.
- The assistant endpoint (identified): offered, agree (D40), ask as a
  Serverpod stream (D35): the text as the model writes it, then the
  whole turn, sent once the request is counted; figures, the caller's
  own. Checked in order: at most 2 questions on their way per person
  (tooManyAtOnce), the grant, the agreement, limits in the pricing's
  unit now (limitOutdated), the month's and the day's limits (with when
  they reset, UTC), the question (malformed, imagesNotRead, tooLarge
  past 400,000 characters, an image over 3,932,160 bytes or more than
  20 images); output capped at 16,384 tokens. Each request carries the
  person's opaque ID (HMAC-SHA256 under ASSISTANT_ID_KEY, D30). Once
  sent, the provider's reply is read to its end even if the app
  cancels, and counted on a session of its own; a provider's failure is
  logged by kind and status, told as providerKey, providerBusy (with
  its wait), providerRefused or providerFailed.
- The assistantOperator endpoint (identified and operator, on the
  register): setUp, grants, grant (assistantNotSet, invalidLimit,
  notFound), revoke, figures of a UTC month.
- Tables assistant_grant and assistant_figures (per person, assistant
  and UTC day), in the module's, Learn's and Todo's migrations. The
  daily pruning keeps this month and the two before
  (forgetOldAssistantFigures, D41); deletePerson deletes both.
  A member offers no assistant (D43).
- instance.basics() gains assistantOwnKeys.
- /privacy (D39, addPrivacyPageRoute, on the register's web server,
  before the profile pages' route): made from the instance's settings,
  English or German, no JavaScript: who may sign up, where the data and
  backups are, what the module keeps (the account, sessions, IP
  addresses, the server's log), the host's privacyPagePoints (Learn's:
  studysets synced, private ones encrypted on the devices with what
  stays readable, what is published, dictionary lookups, the learner
  count), each assistant with its model and host, what goes and what is
  counted, and whether personal keys are allowed. Never a key.

Tests: 70 on the assistants (grants, limits, refusals in order,
streaming, cancelling, counting, concurrency, the operator's denials,
deletion, pruning), 19 on the settings, 8 on the privacy page.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Tizian 「ティツィアーン」 <raisondetredev@pm.me>
2026-10-26 07:17:06 +01:00

73 lines
3.5 KiB
Dart

/// AUTOGENERATED BY SERVERPOD create-migration - DO NOT EDIT BY HAND
/// Merging: resolve registry conflicts the same as migration_registry.txt.
library;
import 'package:serverpod_database/serverpod_database.dart';
part '20260930094729362-studysets/migration.dart';
part '20260930122235111-cards/migration.dart';
part '20260930145136285-reviews/migration.dart';
part '20261001064926911-tree-tags-assets/migration.dart';
part '20261002191122122-notes/migration.dart';
part '20261002211346701-learning-paths/migration.dart';
part '20261003110855698-pdf-sources/migration.dart';
part '20261007205440868-card-buried-at/migration.dart';
part '20261008165051407-pdf-position/migration.dart';
part '20261009224606274-feedback/migration.dart';
part '20261012162411835-studyset-deleted-at/migration.dart';
part '20261019121406578-halkyon-base/migration.dart';
part '20261019201023295-profiles-in-halkyon-base/migration.dart';
part '20261019204112282-deletion-notices/migration.dart';
part '20261020111943300-passwords/migration.dart';
part '20261020125117584-sessions-ended/migration.dart';
part '20261020185750538-recovery-proof-key/migration.dart';
part '20261020194228286-second-factor-waits/migration.dart';
part '20261020204619104-session-code-tries/migration.dart';
part '20261020211224692-email-code-purpose/migration.dart';
part '20261021100422048-session-ended-warning/migration.dart';
part '20261021110159867-second-factor-paths/migration.dart';
part '20261021134803749-reset-hold-outs/migration.dart';
part '20261021184601197-private-studysets/migration.dart';
part '20261023181810112-oidc-module/migration.dart';
part '20261023192913178-simplelogin-keys/migration.dart';
part '20261025135744595-waiting-accounts/migration.dart';
part '20261025165102861-assistants/migration.dart';
/// Migration registry for the client-side database.
class MigrationRegistry {
/// Ordered list of all client-side database migrations.
/// New migrations are always appended at the end.
static final List<MigrationVersionSql> migrations = [
_Migration20260930094729362_studysets(),
_Migration20260930122235111_cards(),
_Migration20260930145136285_reviews(),
_Migration20261001064926911_tree_tags_assets(),
_Migration20261002191122122_notes(),
_Migration20261002211346701_learning_paths(),
_Migration20261003110855698_pdf_sources(),
_Migration20261007205440868_card_buried_at(),
_Migration20261008165051407_pdf_position(),
_Migration20261009224606274_feedback(),
_Migration20261012162411835_studyset_deleted_at(),
_Migration20261019121406578_halkyon_base(),
_Migration20261019201023295_profiles_in_halkyon_base(),
_Migration20261019204112282_deletion_notices(),
_Migration20261020111943300_passwords(),
_Migration20261020125117584_sessions_ended(),
_Migration20261020185750538_recovery_proof_key(),
_Migration20261020194228286_second_factor_waits(),
_Migration20261020204619104_session_code_tries(),
_Migration20261020211224692_email_code_purpose(),
_Migration20261021100422048_session_ended_warning(),
_Migration20261021110159867_second_factor_paths(),
_Migration20261021134803749_reset_hold_outs(),
_Migration20261021184601197_private_studysets(),
_Migration20261023181810112_oidc_module(),
_Migration20261023192913178_simplelogin_keys(),
_Migration20261025135744595_waiting_accounts(),
_Migration20261025165102861_assistants(),
];
/// List of all client-side database migration versions.
static List<String> get versions => migrations.map((m) => m.version).toList();
}