Skip to content

bugfix(timeline): anchor decision-date regex to bullet end, not first match#7

Open
CryptoJones wants to merge 1 commit into
mainfrom
bugfix/timeline-decision-date-anchor
Open

bugfix(timeline): anchor decision-date regex to bullet end, not first match#7
CryptoJones wants to merge 1 commit into
mainfrom
bugfix/timeline-decision-date-anchor

Conversation

@CryptoJones
Copy link
Copy Markdown
Owner

_decision_events parsed lines like

  • Migrate by (2024-12-31) for compliance (2026-05-20)
    with an unanchored regex \((\d{4}-\d{2}-\d{2})\). re.search returns
    the FIRST match — so the user's deadline date (2024-12-31) was used as
    the decision's recording date, instead of the trailing stamp
    (2026-05-20) that record_decision/_decisions_md actually emit.

socrates timeline would then place the decision at the wrong point
in the chronological feed, breaking the whole "what happened on this
project in order?" premise.

Fix: try an end-anchored regex first
((\d{4}-\d{2}-\d{2}))*{0,2}\s*$
which matches the canonical bullet shape (with or without the bold
markers). Fall back to the unanchored regex for legacy bullets that
don't end in )**. The stripped-from-content regex is also anchored,
so a user-typed date in the body is preserved in the rendered title.

Tests added (2):

  • bullet with user-typed date BEFORE the recording stamp → uses the
    trailing stamp, and the body-date is preserved in the title.
  • bullet with NO trailing )** → fallback regex still picks up
    the single in-line date.

149/149 tests pass; ruff + mypy clean.

Self-review caveat: partial fix. The unanchored FALLBACK regex (for legacy non-canonical bullets) still has the original bug — for those, the FIRST date in the line still wins. Only the canonical )** -terminated bullets get the fix. Acceptable because all NEW bullets from record_decision use the canonical form.

… match

`_decision_events` parsed lines like
  - **Migrate by (2024-12-31) for compliance (2026-05-20)**
with an unanchored regex `\((\d{4}-\d{2}-\d{2})\)`. re.search returns
the FIRST match — so the user's deadline date (2024-12-31) was used as
the decision's recording date, instead of the trailing stamp
(2026-05-20) that `record_decision`/`_decisions_md` actually emit.

`socrates timeline` would then place the decision at the wrong point
in the chronological feed, breaking the whole "what happened on this
project in order?" premise.

Fix: try an end-anchored regex first
  \((\d{4}-\d{2}-\d{2})\)\*{0,2}\s*$
which matches the canonical bullet shape (with or without the bold
markers). Fall back to the unanchored regex for legacy bullets that
don't end in `)**`. The stripped-from-content regex is also anchored,
so a user-typed date in the body is preserved in the rendered title.

Tests added (2):
- bullet with user-typed date BEFORE the recording stamp → uses the
  trailing stamp, and the body-date is preserved in the title.
- bullet with NO trailing `)**` → fallback regex still picks up
  the single in-line date.

149/149 tests pass; ruff + mypy clean.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant