Skip to content

feat(contract-review): ja-JP/de-DE/fr-FR review corpus, jurisdiction checklists, typography round-trip guard (dev-board#1957) - #1960

Merged
AIWorkDeckAdmin merged 1 commit into
masterfrom
90d/ml-corpus-multilingual-contracts
Dec 5, 2026
Merged

AIWorkDeckAdmin merged 1 commit into
masterfrom
90d/ml-corpus-multilingual-contracts

Conversation

@AIWorkDeckAdmin

Copy link
Copy Markdown
Collaborator

Card: zeweihan/dev-board#1957

What

  • Synthetic multilingual review corpus: fixtures/contracts/gen-multilingual-contracts.py writes one short commercial contract each for ja-JP (売買基本契約書), de-DE (Liefervertrag) and fr-FR (Contrat de fourniture), with fictional parties and 4, 5 and 4 planted review points. The output is reproducible (fixed zip timestamps; md5 stays the same across runs). multilingual-review-points.json maps each planted point to its paragraph and to a checklist item.
  • contract-review jurisdiction checklists: backend/skills/contract-review/checklists/{ja-JP,de-DE,fr-FR}.md contain items JA-1..5, DE-1..5 and FR-1..5 (2020 Civil Code terminology and the Subcontract Act / 取適法; §§ 271a, 438, 276 III/309 Nr. 7, 307, 305b BGB; L. 441-10, 1170/1231-3 C. civ., L. 442-1 II). Each checklist also states the typography that edits in that language must keep. SkillRegistry appends the files, sorted by name, to both prompt versions. Native-language triggers (契約書をレビュー, Vertrag prüfen, revoir le contrat, …) go in triggers_en, which only matches in a non-Chinese UI, so Chinese matching does not change at all.
  • Typography proof on the real engine: npm run test:lowa-revision-roundtrip now round-trips the three files unedited. It then applies five scripted character-level tracked edits per file through modify_paragraph (the same applyMinimalRedline diff the AI edit tools use), placed right next to 、。「」, „…“ / ß / 1.000,50 €, « », NBSP before : and €, and U+202F before ; ! ?. Checks are byte for byte, NBSP and U+202F included: accept-all and reject-all text in the export, the engine's own Accept All / Reject All on the re-opened export, no deletion that strikes unchanged punctuation or spacing, and every changed figure struck as one token.
  • Engine loss found and fixed: under the Q23 rule a figure is redlined as one token, but a no-break, narrow no-break or thin space between digits ended the token. In French, 1 000,50 € -> 1 250,75 € was therefore struck as 1 kept + 000,50 -> 250,75. These spaces are now treated as group separators when they sit between digits; a space between a figure and its unit (€, %) still is not part of the figure. The fix is ported to the Python twin (native_document_edit_uno.py), and the oracle test covers the new pairs.

Why locale resources of contract-review, not a new skill

Per docs/SKILL_SPEC.md a skill is one workflow, injected according to the app language (prompt.md / prompt.en.md). The review workflow is the same in every jurisdiction, and the contract-review prompt already says that the document decides the governing law. What differs by locale is the substantive checklist and the typography, and those depend on the document's language, not the UI's (a Chinese-UI lawyer can review a German contract). Separate per-locale skills would duplicate the workflow and its tool whitelist, and their triggers would compete under the longest-match rule. So the checklists are resources of the one skill and both prompt versions include all of them. Each file says when it applies. Trade-off: about 800 words added to every contract-review prompt. If many more locales are added, select checklists by detected document language instead. Online-market bundles still ship only skill.yml/prompt.md, so checklists/ works for built-in skills only (documented in SKILL_SPEC).

Tests (red before, green after)

  • ContractReviewChecklistsTest (6): red before the loader and triggers (3 failures: checklist not in prompt; 3 errors: ja/de/fr request did not match), green after. The skill package suite (167) and the com.checkba.service.ai.** suite are green.
  • node --test tests/lowa-unit/minimalEdits.test.mjs: the new French/German amount test is red on master and green with the fix. All lowa-unit tests pass (401/0); the 50 test files that slice office_thread.js pass (432/0).
  • python -m unittest discover -s desktop/tests -p 'test_native_*.py': the old twin fails 2 tests (new test + oracle), and the old worker fails the oracle; green with both fixed.
  • LOWA round trip (r11 engine, local): green with 13 checks. Red runs used scratch dists via LOWA_DIST_DIR. (1) master worker: fr-FR fails with figure "1<NNBSP>000,50" is not struck as one token. (2) inserted text NFKC-normalised and 、 -> ", ": ja, de and fr all fail on exact accept-all text, both in the export and in the engine. (3) whole-paragraph replace instead of the char diff: all three fail with deletions that strike unchanged 「」/„“/«»/NBSP and figures not struck as one token.

🤖 Generated with Claude Code

…checklists and typography round-trip guard (dev-board#1957)

- fixtures/contracts/gen-multilingual-contracts.py: one synthetic supply/sales
  contract per language (fictional parties), 4-5 planted review points each,
  mapped to checklist items in multilingual-review-points.json.
- contract-review: checklists/{ja-JP,de-DE,fr-FR}.md (JA-*/DE-*/FR-*), appended
  by SkillRegistry to both prompt versions; native-language triggers in
  triggers_en.
- LOWA revision round-trip guard: the three files round-trip untouched, then
  get character-level tracked edits next to 、。「」, „…“/ß/1.000,50 €, « »,
  NBSP before : and €, U+202F before ; ! ?; accept/reject text asserted byte
  for byte in the export and in the engine.
- Engine loss found and fixed: a NBSP / U+202F / thin space between digits
  is a group separator, so 1 000,50 -> 1 250,75 is struck as one figure
  (Q23), not "1 " + 000,50. Ported to the Python twin.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@AIWorkDeckAdmin
AIWorkDeckAdmin force-pushed the 90d/ml-corpus-multilingual-contracts branch from 56d9b1b to fb10ab5 Compare December 5, 2026 06:31
@AIWorkDeckAdmin
AIWorkDeckAdmin merged commit 20c6ef6 into master Dec 5, 2026
47 of 49 checks passed
AIWorkDeckAdmin added a commit that referenced this pull request Dec 5, 2026
The essays said 8; #1955 added 4 stress fixtures and #1960 added the
ja/de/fr contracts.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

This branch was previously deployed

1 inactive deployment
windows-signing — fb10ab54 Deployed Dec 5, 2026 by AIWorkDeckAdmin via Build (windows-latest) #2990
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant