feat(cms): require multi-model validation before approving legal translations (MITHOME-113)
Legal pages get a sidebar "legal validation" record (validating models, date, report reference). Their English translation status can only be set to "approved" when at least two distinct models, the date and the report are recorded; page globals are unaffected. The admin description states that model review does not replace legal advice. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
822646a82a
commit
329e2e3403
@@ -0,0 +1,25 @@
|
||||
import { missingLegalValidation, validateLegalApproval } from './legal-validation'
|
||||
|
||||
const complete = { models: ['Claude Fable 5.1', 'Claude Opus 5.5'], validatedAt: '2026-09-29', reportRef: 'docs/legal-translation-validation.md' }
|
||||
|
||||
describe('legal approval rule (MITHOME-113)', () => {
|
||||
it('should accept a complete validation record', () => {
|
||||
expect(missingLegalValidation(complete)).toBeUndefined()
|
||||
expect(validateLegalApproval('approved', { siblingData: { legalValidation: complete } })).toBe(true)
|
||||
})
|
||||
|
||||
it.each([
|
||||
[{ ...complete, models: ['Claude Opus 5.5'] }, 'validáló modell'],
|
||||
[{ ...complete, models: ['Claude Opus 5.5', ' Claude Opus 5.5 '] }, 'validáló modell'],
|
||||
[{ ...complete, validatedAt: null }, 'dátuma'],
|
||||
[{ ...complete, reportRef: ' ' }, 'riport'],
|
||||
[undefined, 'validáló modell'],
|
||||
])('should reject approval when the record is incomplete (%#)', (record, missing) => {
|
||||
const result = validateLegalApproval('approved', { siblingData: { legalValidation: record } })
|
||||
expect(result).toEqual(expect.stringContaining(missing))
|
||||
})
|
||||
|
||||
it.each(['none', 'ai-draft', undefined])('should not require a record for status %s', (status) => {
|
||||
expect(validateLegalApproval(status, { siblingData: {} })).toBe(true)
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,32 @@
|
||||
/**
|
||||
* MITHOME-113 (user decision): the English translation of a legal page may
|
||||
* only be approved after at least two independent high-capability models
|
||||
* reviewed it, with the date and the report recorded.
|
||||
*/
|
||||
export const MIN_VALIDATING_MODELS = 2
|
||||
|
||||
export type LegalValidationRecord = {
|
||||
models?: (string | null)[] | null
|
||||
validatedAt?: string | null
|
||||
reportRef?: string | null
|
||||
} | null | undefined
|
||||
|
||||
/** Returns what is missing from the record, or undefined when complete. */
|
||||
export function missingLegalValidation(record: LegalValidationRecord): string | undefined {
|
||||
const models = new Set((record?.models ?? []).map((m) => m?.trim()).filter(Boolean))
|
||||
const missing = [
|
||||
models.size < MIN_VALIDATING_MODELS && `legalább ${MIN_VALIDATING_MODELS} különböző validáló modell`,
|
||||
!record?.validatedAt && 'a validálás dátuma',
|
||||
!record?.reportRef?.trim() && 'a validációs riport hivatkozása',
|
||||
].filter(Boolean)
|
||||
return missing.length ? missing.join(', ') : undefined
|
||||
}
|
||||
|
||||
/** `validate` for the legal pages' enTranslationStatus field. */
|
||||
export function validateLegalApproval(value: unknown, { siblingData }: { siblingData?: { legalValidation?: LegalValidationRecord } }) {
|
||||
if (value !== 'approved') return true
|
||||
const missing = missingLegalValidation(siblingData?.legalValidation)
|
||||
return missing
|
||||
? `Jogi oldal angol fordítása csak többmodelles validáció után hagyható jóvá. Hiányzik: ${missing}.`
|
||||
: true
|
||||
}
|
||||
Reference in New Issue
Block a user