frontend-patterns/scripts/language_replication_03.py
tegwick f8c3ce3938 Freeze replication-03 with clarified criteria (FEP-WP-0009-T02)
Owner decisions D1-D3 applied; execution not authorized.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Assistant: claude-code
Assistant-Model: opus
Assistant-Process: 182330@bnt-lap001
Assistant-Session: 242866cf-789d-4e24-ac5e-0a1d7b47a701
2026-10-20 00:19:00 +02:00

69 lines
2.7 KiB
Python

#!/usr/bin/env python3
"""Freeze, verify and execute the clarified-criteria replication 03.
Reuses language_replication unchanged, because that module is a frozen input of
replication-02; only the packet location, identity and brief-reuse rule differ.
"""
from datetime import datetime, timezone
from pathlib import Path
import sys
import language_replication as base
from reference_consume import ROOT
from reference_preview import require
PACKET = Path('research/evaluations/language-replication-03')
SOURCE = Path('research/evaluations/language-replication-02')
DEPENDENCIES = (*base.DEPENDENCIES, 'scripts/language_replication_03.py')
CONTEXT_FIELDS = ('placement', 'qualifies', 'does_not_qualify', 'change_from_r02')
BASE_CHECK = base.check
def scenarios_check(scenarios, root=ROOT):
base.scenarios_check(scenarios)
source = {s['id']: s for s in base.read(root / SOURCE / 'scenarios.json')}
for scenario in scenarios:
original = source[scenario['source_scenario']]
require(scenario['brief'] == original['brief'] and scenario['prohibited'] == original['prohibited'],
'Reused brief or prohibited list changed')
require(scenario['reviewer_context'].strip(), 'Reviewer context required')
for criterion in scenario['criteria']:
require(criterion['placement'] in {'recommendation', 'anywhere'}, 'Invalid criterion placement')
require(all(criterion[k] for k in CONTEXT_FIELDS), 'Criterion examples required')
def prepare(root=ROOT):
packet = root / PACKET
require(not (packet / 'freeze.json').exists(), 'Packet already frozen; do not overwrite')
scenarios_check(base.read(packet / 'scenarios.json'), root)
base.PACKET, base.DEPENDENCIES = PACKET, DEPENDENCIES
base.prepare(root)
frozen = base.read(packet / 'freeze.json')
frozen['packet'] = PACKET.name
frozen['files'][str(SOURCE / 'scenarios.json')] = base.digest((root / SOURCE / 'scenarios.json').read_bytes())
frozen['limits'].append('Briefs reused unseen from replication-02 (owner decision D1, 2026-10-20).')
frozen['finalized_at'] = datetime.now(timezone.utc).isoformat()
(packet / 'freeze.json').write_text(base.json.dumps(frozen, indent=2, allow_nan=False) + '\n')
return check(root)
def check(root=ROOT):
base.PACKET, base.DEPENDENCIES = PACKET, DEPENDENCIES
result = BASE_CHECK(root)
require(result[0]['packet'] == PACKET.name, 'Packet identity mismatch')
scenarios_check(result[2], root)
return result
def main():
base.PACKET, base.DEPENDENCIES = PACKET, DEPENDENCIES
if sys.argv[1:2] == ['prepare']:
prepare()
print('Replication 03 frozen; no inference performed.')
return
base.check = check
base.main()
if __name__ == '__main__':
main()