Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions harness/src/scrip_harness/compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,8 @@ def extract_markers(body: str) -> list[str]:
"""Footnote reference *labels* in ``body``, distinct, in first-appearance order
(``[^a1]`` β†’ ``"a1"``). Returned verbatim β€” the caller requires them to be
exactly ``a1..aN`` (no leading zeros, no foreign labels) before stamping."""
seen: list[str] = []
for m in _MARKER.finditer(body):
label = m.group(1)
if label not in seen:
seen.append(label)
return seen
# ⚑ Bolt: Replace O(N) list membership checks with O(1) dict while preserving insertion order
return list(dict.fromkeys(m.group(1) for m in _MARKER.finditer(body)))

SYSTEM = (
"You are the scribe for a scriptorium knowledge base. From the source(s) "
Expand Down
7 changes: 2 additions & 5 deletions harness/src/scrip_harness/promote.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,8 @@ def split_body(body: str) -> tuple[str, list[str]]:


def _labels_in_order(body: str) -> list[str]:
seen: list[str] = []
for m in _MARKER.finditer(body):
if m.group(1) not in seen:
seen.append(m.group(1))
return seen
# ⚑ Bolt: Replace O(N) list membership checks with O(1) dict while preserving insertion order
return list(dict.fromkeys(m.group(1) for m in _MARKER.finditer(body)))


def renumber(body: str, start: int) -> str:
Expand Down