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
3 changes: 2 additions & 1 deletion src/basic_memory/markdown/plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
# observation categories, so indexed transcripts would mint one junk observation per
# spoken line. A category that is purely a clock value is never a semantic category;
# those bracket prefixes stay ordinary content (issue #1219).
_TIMESTAMP_CATEGORY = re.compile(r"^\d{1,3}:\d{2}(:\d{2})?([.,]\d{1,3})?$")
_TIMESTAMP_VALUE = r"\d{1,3}:\d{2}(?::\d{2})?(?:[.,]\d{1,3})?"
_TIMESTAMP_CATEGORY = re.compile(rf"^{_TIMESTAMP_VALUE}(?:\s+-\s+{_TIMESTAMP_VALUE})?$")


def _is_task_marker_category(category: str) -> bool:
Expand Down
15 changes: 15 additions & 0 deletions tests/markdown/test_observation_edge_cases.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,20 @@ def test_timestamp_shapes_rejected_across_formats():
assert not any(t.meta and "observation" in t.meta for t in tokens), line


def test_timestamp_ranges_are_not_observation_categories():
"""Spaced transcript time ranges stay ordinary content (issue #1270)."""
md = MarkdownIt().use(observation_plugin)

for line in (
"- [24:33.098 - 24:41.260] fractional range",
"- [1:02 - 2:03] minute range",
"- [00:01:02 - 100:02:11] long recording range",
"- [12:03,250 - 13:04,500] comma-millisecond range",
):
tokens = md.parse(line)
assert not any(t.meta and "observation" in t.meta for t in tokens), line


def test_hashtag_promoted_timestamp_line_keeps_timecode_in_content():
"""A tagged transcript line is an observation via its hashtag, never via the timecode."""
md = MarkdownIt().use(observation_plugin)
Expand All @@ -180,6 +194,7 @@ def test_numeric_but_non_timestamp_categories_still_parse():
("- [2024] year in review", "2024"),
("- [v1:2] odd but not a clock", "v1:2"),
("- [10:30am] time-of-day words", "10:30am"),
("- [10:30am - 11:30am] named time range", "10:30am - 11:30am"),
):
tokens = md.parse(line)
token = next(t for t in tokens if t.type == "inline")
Expand Down
Loading