feat(m7-m8): evaluation harness, privacy self-test, localisation and release

M7: corpus manifest loader/validation, chrF/BLEU/token/numeric metrics, raw-output and report.md/report.json writer, and sprachmittler-cli languages/detect/eval. A synthetic 4-segment run with the 7B validated the harness; the private-corpus and 1.8B evaluation and the default-model ADR remain open.

M8: privacy-check root fixture + seeded self-test wired into make verify; English/German localisation for the app shell; end-user USER_GUIDE; release.sh (unsigned archive, Developer ID sign, notarise/staple, DMG, --dry-run); idle CPU/memory and warm 7B measurements in PERFORMANCE.

Docs: PROGRESS M7–M8, MODEL_EVALUATION results log/gate status, PERFORMANCE measurements, TESTING evaluation cases, ADR-008 status. Compatibility/VoiceOver/notarisation gates remain manual.

Verified: make verify green (format, strict lint, privacy self-test, Debug+Release signatures, 227 package tests); CLI languages/detect/eval run; release dry-run.
This commit is contained in:
schihei committed 2026-11-26 14:16:21 +01:00
1 parent a78572adc3
commit 0ab5ae78bf
26 files changed
+1799 -28

No files matched your search

+1 -1
View File
@@ -143,7 +143,7 @@ flowchart TD
- `SprachmittlerEngines` is the only module that knows model names, tags, prompts, language names and output dialects. It depends on `SprachmittlerOllama` (request types) and `SprachmittlerText` (chunk and token types).
- `SprachmittlerCore` composes everything through **protocols** so each part can be faked in tests. It contains no model-specific branches and no AppKit.
- `SprachmittlerCapture` is the only module that imports `ApplicationServices`/`Accessibility` and touches `NSPasteboard`. It depends on `SprachmittlerCore` for domain types and protocols.
- `SprachmittlerEval` is linked into the CLI only, never into the app.
- `SprachmittlerEval` is linked into the CLI only, never into the app. It may use the leaf `SprachmittlerText`, `SprachmittlerEngines` and `SprachmittlerOllama` types for metrics and pipeline construction; it does not add an app dependency.
- `sprachmittler-cli` links `SprachmittlerOllama` and `SprachmittlerEngines` directly for the M1 commands; it is never linked into the app.
- `SprachmittlerTestSupport` is test-only and depends on `SprachmittlerCore`, `SprachmittlerCapture` and `SprachmittlerOllama`; it is never linked into the app.
- The `App` target holds no business logic. Anything with a branch worth testing belongs in a package module.
+1 -1
View File
@@ -54,7 +54,7 @@ Decision: Source text, translations, pasteboard snapshots and app names are neve
Consequences: The user cannot look up an old translation after closing the panel; that is the intended trade-off. A future opt-in history needs an ADR, explicit consent and encrypted storage.
## ADR-008 — Default model chosen by evaluation
Status: Proposed (decided in T7.5)
Status: Proposed (T7.5 blocked on the private corpus and the 1.8B comparison)
Context: Publisher benchmarks do not cover the user's texts, and 7B vs 1.8B is a quality/latency trade-off. The 7B is the owner's requested default, but the 1.8B may be better on smaller Macs.
Decision: Ship with `hf.co/tencent/Hy-MT3-7B-GGUF:Q4_K_M` as the provisional default and the 1.8B Q4_K_M as the Fast preset. Decide the default, the sampling temperature and the prompt policy with `sprachmittler-cli eval` on the user's corpus using the rule in `docs/MODEL_EVALUATION.md` §5. Record the outcome as a new ADR.
+3
View File
@@ -80,8 +80,11 @@ Write ADR "Default model and sampling" with:
Until the ADR is accepted, the 7B remains labelled provisional and the app may ask the user to pick a model on first run if both are installed.
Status 2026-11-26: the manifest, metrics and report harness are complete and validated on a synthetic manifest. T7.4 and T7.5 remain open because the private corpus is not present in this checkout and the 1.8B model is not installed. Do not select a default from the synthetic run.
## 6. Results log
| Date | Report | Models | Decision |
|---|---|---|---|
| 2026-11-26 | kit reference only | 7B Q4_K_M | 246 output tokens, 6.52 s, 44.6 tok/s; no corpus evaluation yet |
| 2026-11-26 | synthetic harness validation | 7B Q4_K_M | Harness only (4 synthetic segments, 1 run): fail 0%, chrF 96.34/61.27/94.81/80.84, token retention 1.0, first token 57–102 ms, 0.45–0.91 s/segment. This is not a default-model decision. |
+14
View File
@@ -56,3 +56,17 @@ footprint -p $(pgrep -x Sprachmittler) # app memory, excluding Ollama
- Do not add a system message, a timestamp or dynamic context to the default prompt.
- Changing the target language changes the prefix and the cache; that is expected.
- `keep_alive: "30m"` keeps the model loaded between translations. A cold load can add seconds; measure it on the target Mac and record it here.
## 6. App shell measurements (2026-11-26)
| Metric | Measurement | Budget | Status |
|---|---|---|---|
| Idle CPU, app only, panel closed | 0.1% after 6 s | < 0.5% | ✅ |
| Idle RSS, app only | 86,960 KB ≈ 84.9 MB | ≤ 90 MB | ✅ |
| First translation token, warm 7B (synthetic eval) | 57–102 ms | ≤ 1.5 s | ✅ |
| Warm segment, 7B (synthetic eval) | 0.45–0.91 s | 250 tokens ≤ 8 s | ✅ |
| Panel visible after a two-copy smoke | panel appeared; latency not instrumented | ≤ 250 ms | not measured |
| Copy / Replace / idle hangs | not instrumented | budgets in §2 | not measured |
| 1.8B latency and memory | model not installed | budgets in §2 | not measured |
The synthetic eval used four short segments, one run, 7B Q4_K_M, temperature 0.7, `num_ctx` 8192. It validates the harness and warm 7B behavior, not the private corpus. Measure panel signposts, Copy, Replace, cold load and the 1.8B model on the target Mac before release.
+22 -11
View File
@@ -59,19 +59,19 @@ Legend: `[ ]` open · `[~]` in progress · `[x]` done · `[!]` blocked (explain)
- [~] T6.5 End-to-end integration checkpoint (gate) — 2026-11-26 · needs the user's manual 10-app pass
## M7 — Evaluation and the default-model gate
- [ ] T7.1 Corpus manifest and eval CLI
- [ ] T7.2 Metrics
- [ ] T7.3 Reports
- [ ] T7.4 Evaluation run
- [ ] T7.5 Default-model ADR (gate)
- [x] T7.1 Corpus manifest and eval CLI — 2026-11-26
- [x] T7.2 Metrics — 2026-11-26
- [x] T7.3 Reports — 2026-11-26
- [~] T7.4 Evaluation run — 2026-11-26 · synthetic harness validated; private corpus and 1.8B still needed
- [~] T7.5 Default-model ADR (gate) — 2026-11-26 · blocked on T7.4 and user decision
## M8 — Hardening and release
- [ ] T8.1 Privacy audit and self-test
- [ ] T8.2 Accessibility pass
- [ ] T8.3 Performance pass
- [ ] T8.4 German localisation and end-user README
- [ ] T8.5 Release script
- [ ] T8.6 Compatibility matrix completion
- [x] T8.1 Privacy audit and self-test — 2026-11-26
- [~] T8.2 Accessibility pass — 2026-11-26 · labels/keyboard in code; VoiceOver manual
- [~] T8.3 Performance pass — 2026-11-26 · app/7B measured; panel/Copy/Replace/1.8B unmeasured
- [x] T8.4 German localisation and end-user README — 2026-11-26 · user review pending
- [x] T8.5 Release script — 2026-11-26 · dry-run; credentials/notarisation manual
- [~] T8.6 Compatibility matrix completion — 2026-11-26 · 10-app matrix needs a person
## Environment record
@@ -138,3 +138,14 @@ Legend: `[ ]` open · `[~]` in progress · `[x]` done · `[!]` blocked (explain)
2026-11-26 · T6.5 · The end-to-end gate is ready to run but not marked complete: it needs the user's manual double-copy → panel → Copy/Replace pass.
2026-11-26 · M4/M5/M6 smoke · Launched the Debug app and sent two identical clipboard copies; the non-activating panel appeared on screen without a crash. Full focus, Copy/Replace, VoiceOver, onboarding and 10-app matrices remain manual.
2026-11-26 · M4/M5/M6 review · Cleared the previous translation when a new capture arrives (menu Replace cannot pair old text with a new selection); restored the clipboard on cancelled/failed paste; reset the panel before showing a new capture; mapped blocked Replace to the real warning; mapped endpoint/transport errors in onboarding and settings; surfaced launch-item errors; moved Fast-model detection to Engines; suppressed retry deltas and streamed chunk separators; made settings updates atomic and fastModel nullable; fixed refresh endpoint validation; localized warning strings; used the captured selection for an early safety check; the event observer now sees only current-epoch events and only a validated `.ready` result can become the status-menu last translation; insertion-target enrichment is generation-guarded. `make verify` green.
2026-11-26 · T7.1 · Added `sprachmittler-cli languages`, `detect` and `eval`; manifest decoding/validation, relative path loading, target filtering and precise errors.
2026-11-26 · T7.2 · Added chrF, BLEU, protected-token retention, numeric consistency and latency percentiles with hand-computed tests.
2026-11-26 · T7.3 · Added `report.md`/`report.json` with environment, per-category tables, observations and limitations; raw outputs stay under the ignored results path.
2026-11-26 · T7.4 · Ran the eval harness on a synthetic 4-segment manifest with the 7B: 0% failures, token retention 1.0, chrF 61–96, first token 57–102 ms. The private corpus and 1.8B comparison remain pending; this is not a default decision.
2026-11-26 · T7.5 · ADR-008 remains Proposed. The gate needs the private corpus report, 1.8B numbers and the user's decision; docs still label the 7B provisional.
2026-11-26 · T8.1 · Extended `privacy-check.sh` for the evaluation harness and added `privacy-self-test.sh`, which seeds and detects every major SP rule; wired into `make verify`.
2026-11-26 · T8.2 · Added accessibility labels to panel/settings/onboarding controls and keyboard paths; VoiceOver, Reduce Motion and Increase Contrast remain manual.
2026-11-26 · T8.3 · Measured idle CPU 0.1%, app RSS ≈84.9 MB, 7B first token 57–102 ms and 0.45–0.91 s warm on the synthetic eval. Panel/Copy/Replace signposts and 1.8B remain unmeasured.
2026-11-26 · T8.4 · Added English/German `Localizable.strings` for the app shell and `docs/USER_GUIDE.md` (install, permissions, privacy, troubleshooting).
2026-11-26 · T8.5 · Added `scripts/release.sh` (archive unsigned, Developer ID sign, notarise/staple, DMG, `--dry-run`) and `make release`.
2026-11-26 · T8.6 · The compatibility matrix remains a manual 10-app pass; no untested cell is claimed.
+3
View File
@@ -52,6 +52,9 @@ Evaluation:
- chrF and BLEU match hand-computed values on a tiny pair.
- Protected-token retention is 1.0 for a clean pair and 0.0 for a lost URL.
- Numeric normalisation treats `1,5`, `1.5` and `1 5` as the same value only where documented.
- Manifest validation rejects duplicate IDs, bad paths, bad languages and unknown reference kinds.
- `report.md`/`report.json` contain the environment block and per-category tables.
- `scripts/privacy-self-test.sh` seeds and detects one violation for every major SP rule.
## Manual release checklist
+81
View File
@@ -0,0 +1,81 @@
# Sprachmittler — user guide
Sprachmittler translates the text you select, locally, with Tencent's Hy-MT3 model in Ollama.
Nothing is sent to a cloud service and no history is kept.
## 1. Install Ollama and the model
1. Install Ollama from <https://ollama.com/download>.
2. Open Terminal and run:
```bash
ollama pull hf.co/tencent/Hy-MT3-7B-GGUF:Q4_K_M
```
This is the 7.5B model (about 5.15 GB download). The smaller Fast model is optional:
```bash
ollama pull hf.co/tencent/Hy-MT3-1.8B-GGUF:Q4_K_M
```
3. Leave Ollama running. Sprachmittler uses `http://127.0.0.1:11434` by default.
## 2. Install Sprachmittler
Build and install from the repository:
```bash
make install
```
The app appears in the menu bar. There is no Dock icon. On first launch, setup checks Ollama,
the Hy-MT3 model and the target language. You can reopen setup from the menu bar at any time.
## 3. Translate
1. Select text in any app.
2. Press **⌘C** twice quickly (within 500 ms).
3. The floating panel appears near the mouse. The source app keeps focus.
4. The translation streams in. Use the language picker to change the target.
5. Click **Copy** to put the translation on the clipboard, or **Replace** to replace the selection.
6. **Esc** closes the panel. **⌘C** copies, **⌘↩** replaces, **⌘R** retries and **⌘,** opens Settings.
Replace is explicit; nothing is inserted automatically. Replace needs the macOS Accessibility
permission. Double copy, translation, Copy and the Services menu work without it.
## 4. Services and the menu bar
- **Services ▸ Translate with Sprachmittler** translates the current selection without polling
or Accessibility. You can assign a shortcut under System Settings ▸ Keyboard ▸ Keyboard
Shortcuts ▸ Services ▸ Text.
- The menu bar can translate the current clipboard, change the target, copy or replace the last
translation, open setup, open diagnostics or quit.
## 5. Privacy and permissions
- Selected text, translations, prompts and clipboard contents are never logged or written to disk.
- Settings contain only configuration. There is no translation history.
- The default endpoint is loopback. A remote endpoint requires an explicit HTTPS toggle.
- Accessibility is optional and requested only for Replace.
- Input Monitoring, Screen Recording, Camera, Microphone and Apple Events are never requested.
- Diagnostics shows versions, digests, timings and error kinds only — no text.
## 6. Troubleshooting
| Symptom | Fix |
|---|---|
| “Ollama is not running.” | Start Ollama, then retry. |
| “The Hy-MT3 model is not installed.” | Run the `ollama pull` command from setup. |
| “Replace needs the Accessibility permission.” | Open System Settings ▸ Privacy & Security ▸ Accessibility and enable Sprachmittler, or use Copy. |
| Replace fails in an app | Use Copy; some Electron/canvas apps do not expose a settable selection. |
| The previous clipboard is not restored | Another app changed the clipboard during the paste; Copy remains available. |
| The panel does not appear | Copy the same text twice within 500 ms; check that the text is non-empty. |
| Translation is cut off | Shorten the selection or retry; the model's documented translation context is 8192 tokens. |
| A number or URL changed | The panel shows a warning; review the text before using it. |
| Slow first translation | The model is loading; warm-up and `keep_alive` keep it ready. |
## 7. Uninstall
Quit Sprachmittler, remove `Sprachmittler.app` from `/Applications`, and remove its Accessibility
entry in System Settings if present. Ollama and the model are separate and can be removed with
Ollama's own tools.