halkyon/packages/halkyon_app/test/assistant/model/provider_terms_test.dart
Tizian 「ティツィアーン」 bf46f8c460
feat(learn): a private studyset goes to an assistant only once agreed
ADR 0021, D9 and D17. Before a question sends a private studyset's
content to a remote model, through the parts chosen or a wider reach
with private studysets switched on, a warning names the studysets, the
provider's host and its terms (where checked: Anthropic, OpenAI,
Google, OpenRouter), and is asked once per studyset and assistant: the
agreement is kept in the person's sealed settings (schema 13,
privateAgreements, folded only where both rows hold it), shown in the
studyset's privacy dialog with Take back, and marked on the folded
button while it holds. Follow-ups and Try again ask again once taken
back, as the scope keeps where the parts came from (partsFrom). No
warning for an own assistant on this machine (loopback or localhost,
halkyon_llm's LlmEndpoint.onThisMachine); the local network may be
shared.

Texts that step 3 made untrue: the consent sheet now says what an
assistant looks up goes too and that conversations are kept encrypted
for the person's devices; the privacy dialogs no longer mention
showing a studyset to Claude; the privacy page says what is looked up
and when a private studyset goes.

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

45 lines
1.4 KiB
Dart

import 'package:flutter_test/flutter_test.dart';
import 'package:halkyon_app/assistant_models.dart';
import 'package:halkyon_llm/halkyon_llm.dart' show LlmProtocol;
void main() {
test("links the terms of the providers it knows, by their API's host", () {
expect(
providerTermsOf('api.anthropic.com'),
Uri.parse('https://www.anthropic.com/legal/commercial-terms'),
);
expect(
providerTermsOf('API.OpenAI.com'),
Uri.parse('https://openai.com/policies/services-agreement/'),
);
expect(
providerTermsOf('generativelanguage.googleapis.com'),
Uri.parse('https://ai.google.dev/gemini-api/terms'),
);
expect(
providerTermsOf('openrouter.ai'),
Uri.parse('https://openrouter.ai/terms'),
);
});
test('links nothing for another host, which is named alone', () {
expect(providerTermsOf('api.mistral.ai'), isNull);
expect(providerTermsOf('192.168.1.20'), isNull);
expect(providerTermsOf('anthropic.com.example.org'), isNull);
});
test('knows an own assistant on this machine, never one elsewhere', () {
OwnAssistant at(String? baseUrl) => OwnAssistant(
id: 'own',
name: 'Mine',
protocol: LlmProtocol.openai,
baseUrl: baseUrl,
model: 'm',
apiKey: '',
);
expect(at('http://localhost:11434/v1').onThisMachine, isTrue);
expect(at('http://192.168.1.20:11434/v1').onThisMachine, isFalse);
expect(at(null).onThisMachine, isFalse);
});
}