T08: .claude/rules/worker-protocol.md (imported by CLAUDE.md, pointed to from AGENTS.md) and tools/contract-tests/excerpt.py: name the rows, hand every worker one excerpt, one owner per step, check with the excerpt's tests. A test requires every table row to have details and a contract test (found O4). T06: bounded-executor/window_watch.py flags or closes the write role when no run Job is active or recent; stub tests; in the image. Built from the excerpt for O5, E1, C1, E8, E9, R2. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Assistant: claude-code Assistant-Model: opus Assistant-Process: 943911@bnt-lap001 Assistant-Session: fc322940-1c8e-4bed-ab39-86cec99f23a0
67 lines
2.1 KiB
Python
67 lines
2.1 KiB
Python
"""tools/contract-tests/excerpt.py (NK-WP-0058-T08): worker excerpts from the contract table."""
|
||
import importlib.util
|
||
from pathlib import Path
|
||
|
||
import pytest
|
||
|
||
REPO = Path(__file__).resolve().parents[3]
|
||
spec = importlib.util.spec_from_file_location('contract_excerpt', REPO / 'tools/contract-tests/excerpt.py')
|
||
excerpt = importlib.util.module_from_spec(spec)
|
||
spec.loader.exec_module(excerpt)
|
||
|
||
SYNTHETIC = """## Part 1
|
||
|
||
| ID | Interface | Owner |
|
||
| --- | --- | --- |
|
||
| E1 | lanes | platform |
|
||
| O2 | lane child | warden |
|
||
|
||
### E1: lanes
|
||
|
||
- role `r`, path `p`
|
||
|
||
### O2 and O3: sessions
|
||
|
||
- silent child
|
||
|
||
## Contract CI
|
||
|
||
### Coverage by row (2026-11-06)
|
||
|
||
| Row | Contract test | Runs in |
|
||
| --- | --- | --- |
|
||
| E1 | `tests/test_lanes.py` | CI |
|
||
| O2–O4 | `tests/test_bx.py` | CI |
|
||
"""
|
||
|
||
|
||
def test_ranges_and_lists():
|
||
assert excerpt.ids_in('O2–O4, F1, F2') == {'O2', 'O3', 'O4', 'F1', 'F2'}
|
||
assert excerpt.ids_in('E2, E3') == {'E2', 'E3'}
|
||
|
||
|
||
def test_row_details_and_tests():
|
||
text = excerpt.excerpt(['E1', 'O2'], SYNTHETIC)
|
||
assert '| E1 | lanes | platform |' in text and 'role `r`, path `p`' in text
|
||
assert '`tests/test_lanes.py`' in text
|
||
assert '### O2 and O3: sessions' in text and '`tests/test_bx.py`' in text
|
||
|
||
|
||
def test_unknown_rows_fail():
|
||
with pytest.raises(SystemExit, match='add the interface to the table first'):
|
||
excerpt.excerpt(['C9'], SYNTHETIC)
|
||
with pytest.raises(SystemExit, match='not a row id'):
|
||
excerpt.excerpt(['nonsense'], SYNTHETIC)
|
||
|
||
|
||
def test_every_row_of_the_real_table_has_details_and_a_contract_test():
|
||
text = excerpt.TABLE.read_text()
|
||
rows = [line.split('|')[1].strip() for line in text.splitlines()
|
||
if line.startswith('| ') and excerpt.ROW.match(line.split('|')[1].strip())
|
||
and '## Routing' not in text[:text.index(line)][-2000:]]
|
||
rows = sorted({r for r in rows})
|
||
assert rows, 'no rows found'
|
||
for row in rows:
|
||
out = excerpt.excerpt([row], text)
|
||
assert f'### {row}' in out or f' {row}:' in out or f'and {row}' in out, f'{row}: no detail section'
|
||
assert 'none recorded' not in out, f'{row}: no contract test recorded'
|