feat(m2-m3): adapter, text pipeline, double-copy capture and Services (T2.1-T2.7, T3.1-T3.4)

M2: TranslationAdapter/AdapterRegistry with documented Hy-MT3 prompts and publisher sampling; all 102 languages with BCP-47 variants, RTL and dense-script flags; normalisation, NLLanguage detection, content classification and exact-join script-aware chunking; protected-token scanning and output validation; prompt policy with one documented fallback; shared TranslationPipeline with Core error mapping. The CLI now reports sourceLanguage and warning codes.

M3: pure DoubleCopyDetector, 120 ms PasteboardWatcher with 750 ms own-write suppression, SystemPasteboard snapshot/restore and markers, CapturePolicy for the 4000/2000 limits, ServicesProvider and the menu-bar action. T3.5 (10-app manual matrix) remains intentionally open.

Docs: ARCHITECTURE, TRANSLATION_OUTPUT, HYMT3_MODEL (§7 spike), SELECTION_AND_CLIPBOARD, PROGRESS; ADR-016 superseded by ADR-017/018.

Verified: make verify green (format, strict lint, scripts, privacy, Debug+Release signatures, package tests); live 7B CLI en→de/de→en/Markdown/JSON/placeholders; empty input exits 2 and unreachable exits 3.
This commit is contained in:
schihei committed 2026-11-26 13:30:32 +01:00
1 parent 26b493e7e5
commit 64078e2f04
80 files changed
+4090 -325

No files matched your search

+25 -12
View File
@@ -21,20 +21,20 @@ Legend: `[ ]` open · `[~]` in progress · `[x]` done · `[!]` blocked (explain)
- [x] T1.6 sprachmittler-cli models / show / translate — 2026-11-26
## M2 — Hy-MT3 adapter and text pipeline
- [ ] T2.1 Adapter protocol, registry, sampling merge
- [ ] T2.2 Hy-MT3 adapter and byte-exact prompt
- [ ] T2.3 Language catalogue (102 languages)
- [ ] T2.4 Language detection, content classifier, chunker
- [ ] T2.5 Protected tokens, output validator, preamble detector
- [ ] T2.6 Prompt policy and documented fallbacks
- [ ] T2.7 Compatibility spike (gate)
- [x] T2.1 Adapter protocol, registry, sampling merge — 2026-11-26
- [x] T2.2 Hy-MT3 adapter and byte-exact prompt — 2026-11-26
- [x] T2.3 Language catalogue (102 languages) — 2026-11-26
- [x] T2.4 Language detection, content classifier, chunker — 2026-11-26
- [x] T2.5 Protected tokens, output validator, preamble detector — 2026-11-26
- [x] T2.6 Prompt policy and documented fallbacks — 2026-11-26
- [x] T2.7 Compatibility spike (gate) — 2026-11-26 · 7B passed; 1.8B not installed
## M3 — Double-copy capture
- [ ] T3.1 DoubleCopyDetector state machine
- [ ] T3.2 Pasteboard watcher and own-write suppression
- [ ] T3.3 Clipboard snapshot and restore
- [ ] T3.4 Services provider and menu item
- [ ] T3.5 Manual double-copy matrix
- [x] T3.1 DoubleCopyDetector state machine — 2026-11-26
- [x] T3.2 Pasteboard watcher and own-write suppression — 2026-11-26
- [x] T3.3 Clipboard snapshot and restore — 2026-11-26
- [x] T3.4 Services provider and menu item — 2026-11-26
- [~] T3.5 Manual double-copy matrix — 2026-11-26 · code complete; 10-app matrix needs a person
## M4 — Translation session and panel
- [ ] T4.1 TranslationSession actor and epochs
@@ -107,3 +107,16 @@ Legend: `[ ]` open · `[~]` in progress · `[x]` done · `[!]` blocked (explain)
2026-11-26 · T1.5 · Added the provisional Engines slice (`ModelLanguage`, 16 common names, byte-exact Default prompt, documented options, request factory) and the loopback-only warm-up policy. Warm-up uses fixed `Hello.` and `num_predict: 8`; unload uses `keep_alive:"0"`.
2026-11-26 · T1.6 · Implemented `sprachmittler-cli models`, `show` and `translate` (`--text/--file`, `--target`, `--model`, `--json`, `--include-source`). Live 7B checks: models/show, en→de text, JSON with null sourceLanguage/empty warnings, unreachable exit 3. The 102-language catalogue remains T2.3.
2026-11-26 · M1 · Review fixes: 180 s URLSession request/resource budget (no 60 s pre-emption), missing-`done` is an error, CLI diagnostics go to stderr and endpoint rejection exits 2, `CLIEnvironment` is the composition root, and cancellation/URL-task-stop tests are deterministic. Both reviewers approved.
2026-11-26 · T2.1 · Added `AdapterRequest`/`TranslationAdapter`/`AdapterRegistry`, `SamplingOptions` + overrides, and exact wire-option tests. Prompt literals remain only in Engines.
2026-11-26 · T2.2 · `HyMT3Adapter` builds one user message, publisher sampling, `num_ctx: 8192`, no system/think; byte-exact golden tests for Default, Delimiters and Structured Data 1.
2026-11-26 · T2.3 · `HyMT3Languages` now has all 102 entries with exact model names, BCP-47 variants (`zh-Hant`, `pt-BR`, `nb`/`nn`, `kk-Cyrl`, `mn-Cyrl`, `ku`/`ckb`), RTL and dense-script flags.
2026-11-26 · T2.4 · Added `TextNormalization` (N1–N3, T1), `NaturalLanguageDetector`, `ContentClassifier` and the script-aware `Chunker`; join round-trips exactly, grapheme clusters are never split.
2026-11-26 · T2.5 · Added `ProtectedTokenScanner` for all ten token kinds, `OutputValidator` for empty/preamble/truncation/repetition/token/number checks, and a streaming repetition detector. No output is rewritten.
2026-11-26 · T2.6 · Added `PromptPolicy`: Default first, one documented Delimiters/Structured Data 1 retry only after a lost protected token. `TranslationPipeline` (Core) enforces the one retry and joins chunks with the source separators.
2026-11-26 · T2.7 · 7B spike: en→de, de→en, Markdown, JSON, placeholders and a 4,315-char long text passed with no warnings; an 8,785-char repetitive source hit the repetition guard. Results and timings are in `HYMT3_MODEL.md` §7. The 1.8B spike still needs the model.
2026-11-26 · T3.1 · Added the pure `DoubleCopyDetector`: 500 ms default window, identical text after line-ending/outer-trim normalisation, duplicate changeCount ignored, reset rules.
2026-11-26 · T3.2 · Added `PasteboardWatcher` (120 ms injected ticker, read only after a change, 750 ms own-write suppression, 4000/2000 script limits, clear on stop) and `SystemPasteboard`.
2026-11-26 · T3.3 · Added `ClipboardSnapshot`/`ClipboardItemData`: all items and types, forced lazy data, restore only when `changeCount` still matches, own/transient/concealed markers on writes.
2026-11-26 · T3.4 · Added `ServicesProvider` and wired `NSApp.servicesProvider` + `NSUpdateDynamicServices`; the menu-bar “Translate Clipboard Text” item now delivers a `.menu` capture. The app has a log-only sink until the M4 panel.
2026-11-26 · M3 · The capture matrix (T3.5) is intentionally still unchecked; it needs a person in 10 real apps. No Accessibility is requested on the double-copy or Services path.
2026-11-26 · M2/M3 · Review fixes: `OllamaError` is mapped to `SprachmittlerError` at the Core boundary and the CLI maps domain errors to exit 2/3/4; the chunker preserves leading empty separators; `LanguageMatching` moved to Engines and `keepAlive` is supplied by the composition root; `CapturePolicy` enforces the 4000/2000 limit and own markers for menu/Services; golden prompt tests remove exactly one fixture terminator; docs aligned (TestSupport deps, warning enum, 15 common targets, Fixtures path).