Skip to content

Commit e6389ac

Browse files
authored
Preserve owner request h3 packet boundaries (#245)
1 parent 8c3d693 commit e6389ac

2 files changed

Lines changed: 25 additions & 1 deletion

File tree

scripts/owner_requests/validate_owner_request_docs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def load_json(path: Path) -> dict[str, Any]:
4343

4444
def request_packet_body(text: str, request_id: str) -> str | None:
4545
match = re.search(
46-
rf"^### {re.escape(request_id)}\n(?P<body>.*?)(?=^## |\Z)",
46+
rf"^### {re.escape(request_id)}\n(?P<body>.*?)(?=^#{{2,3}} |\Z)",
4747
text,
4848
re.MULTILINE | re.DOTALL,
4949
)

tests/test_owner_request_docs.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,30 @@ def test_request_packet_body_stops_before_later_h2_sections(self):
9999
self.assertIn("fake/OWNER_REQUESTS.md: ORQ-FAKE-SKILLS-001 must name owner_landing_ref in its packet", problems)
100100
self.assertIn("fake/OWNER_REQUESTS.md: ORQ-FAKE-SKILLS-001 must name owner_proof_ref in its packet", problems)
101101

102+
def test_request_packet_body_stops_before_next_h3_packet(self):
103+
module = load("validate_owner_request_docs", "scripts/owner_requests/validate_owner_request_docs.py")
104+
text = """## Ready-to-carry packets
105+
106+
### ORQ-FAKE-SKILLS-001
107+
108+
Status: `landed`; owner receipt linked.
109+
110+
### ORQ-FAKE-SKILLS-002
111+
112+
Receipt-backed status: `owner_landing_ref` and `owner_proof_ref` are linked here.
113+
"""
114+
body = module.request_packet_body(text, "ORQ-FAKE-SKILLS-001")
115+
self.assertIsNotNone(body)
116+
self.assertNotIn("ORQ-FAKE-SKILLS-002", body)
117+
problems = module.receipt_backed_packet_section_problems(
118+
"fake/OWNER_REQUESTS.md",
119+
text,
120+
[{"id": "ORQ-FAKE-SKILLS-001", "queue_status": "landed"}],
121+
)
122+
self.assertIn("fake/OWNER_REQUESTS.md: ORQ-FAKE-SKILLS-001 must distinguish its receipt-backed status", problems)
123+
self.assertIn("fake/OWNER_REQUESTS.md: ORQ-FAKE-SKILLS-001 must name owner_landing_ref in its packet", problems)
124+
self.assertIn("fake/OWNER_REQUESTS.md: ORQ-FAKE-SKILLS-001 must name owner_proof_ref in its packet", problems)
125+
102126
def test_owner_request_protocol_declines_center_activation(self):
103127
text = (ROOT / "mechanics/OWNER_REQUEST_PROTOCOL.md").read_text(encoding="utf-8")
104128
self.assertIn("A request packet is not owner acceptance", text)

0 commit comments

Comments
 (0)