from pathlib import Path
import re

html = Path('/work/index.html').read_text()
for field in ('artifact','change','invariant','verification'):
    assert f'id="{field}"' in html, field
assert 'status:\'REFUSED\'' in html
assert 'status:\'READY\'' in html
assert "!String(values[k] ?? '').trim()" in html
# Exercise the same decision rule in a bounded Python mirror.
def first_action(values):
    fields = ('artifact','change','invariant','verification')
    missing = [k for k in fields if not str(values.get(k, '')).strip()]
    return 'REFUSED' if missing else 'READY'

full = {'artifact':'src/check.ts','change':'add regression','invariant':'incomplete is not CLEAN','verification':'assert status != CLEAN'}
assert first_action(full) == 'READY'
assert first_action({**full, 'invariant':'   '}) == 'REFUSED'
assert first_action({}) == 'REFUSED'
print('PASS html-fields')
print('PASS complete-action READY')
print('PASS blank-and-whitespace-actions REFUSED')
