Skip to content

Commit c22dee0

Browse files
pajomaclaude
andcommitted
docs(specs,plans): amend #230 — drop 2-letter aliases entirely, week-fix only
3-letter English abbreviations are the supported standard. 2-letter aliases removed from scope due to collision risk with common English words. #230 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent cb6939c commit c22dee0

2 files changed

Lines changed: 21 additions & 40 deletions

File tree

docs/plans/2026-06-01-fix-230-smart-input-week-and-weekday-aliases.md

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Plan — Issue #230: Smart input week-text boundary and 2-letter weekday aliases
1+
# Plan — Issue #230: Smart input week-text boundary fix
22

33
> **Spec:** [docs/specs/2026-06-01-fix-230-smart-input-week-and-weekday-aliases.md](../specs/2026-06-01-fix-230-smart-input-week-and-weekday-aliases.md)
44
> **Issue:** [pajoma/vscode-journal#230](https://github.com/pajoma/vscode-journal/issues/230)
@@ -7,21 +7,17 @@
77
88
## Approach
99

10-
Both bugs are addressed in the #177 tokenizer branch. Bug 1 is already resolved by the tokenizer's architecture — `recognizeWeek` uses `(?=\s|$)` as a zero-width lookahead so no character is consumed from the following text. Bug 2 requires adding `mo`, `tu`, `we`, `th` to `weekdayVocab()` (plus `fr` is already covered by the German section). `getDayOfWeekForString` in `dates.ts` already maps all five 2-letter forms correctly; only the vocab recognizer needs updating.
10+
Bug 1 (week-text boundary) is already resolved by the #177 tokenizer's architecture — `recognizeWeek` uses `(?=\s|$)` as a zero-width lookahead so no character is consumed from the following text. No code change needed; only regression tests required.
1111

12-
**Trade-off:** `we` and `th` are common English words; adding them as standalone weekday tokens introduces the same ambiguity class as German `di`/`do`. This is accepted per spec: the tokenizer marks them `ambiguous` (≤3 chars), which triggers the yellow border feedback in the QuickPick.
12+
2-letter English aliases are out of scope — 3-letter forms are the supported standard.
1313

1414
## Steps
1515

1616
1. **Verify Bug 1 is resolved** — add regression test: `parseInput("task week Finalize Shoppinglist")``flags="task"`, `text="Finalize Shoppinglist"`, `hasWeek()=true`. No code change needed.
1717

18-
2. **Add 2-letter English aliases to `weekdayVocab()`** — append `'mo', 'tu', 'fr'` after the 3-letter English block (`mon/tue/wed/thu/fri/sat/sun`). `we` and `th` excluded: both are high-frequency English words that would destructively consume text. `fr` already present in German section; adding it to English section makes intent explicit (same result from `getDayOfWeekForString`). Longest-first ordering preserved.
19-
20-
3. **Invalidate pattern cache**`_weekdayPatterns` is built lazily from `weekdayVocab()`. Adding entries to the array changes the return value; since the cache is built per `MatchInput` instance, no reset needed.
21-
22-
4. **Add regression tests** to `src/test/suite/match-input-vocab.test.ts`:
18+
2. **Add regression tests** to `src/test/suite/match-input-vocab.test.ts`:
2319
- `"task week Finalize Shoppinglist"` → Bug 1 regression
24-
- `"mo"`, `"tu"`, `"we"`, `"th"`, `"fr"` each → correct weekday offset (same as 3-letter form)
20+
- `"week"` → hasWeek=true, no crash
2521
- `"w15"` → week 15, no regression from `recognizeWeekNum` priority
2622

2723
## Test scenarios
@@ -31,10 +27,6 @@ Both bugs are addressed in the #177 tokenizer branch. Bug 1 is already resolved
3127
| Bug 1 regression — week+text | `"task week Finalize Shoppinglist"` | flag=task, text="Finalize Shoppinglist", hasWeek=true |
3228
| Bug 1 regression — week alone | `"week"` | hasWeek=true, no crash |
3329
| Bug 1 regression — w15 still numeric | `"w15"` | week=15 |
34-
| 2-letter alias mo | `"mo"` | same offset as `"mon"` |
35-
| 2-letter alias tu | `"tu"` | same offset as `"tue"` |
36-
| 2-letter alias fr | `"fr"` | same offset as `"fri"` |
37-
| No alias we/th | `"we"`, `"th"` | text-only (not weekday aliases — collision risk) |
3830
| No regression — task do | `"task do the shopping"` | flag=task, text="the shopping" (do = German Thursday) |
3931

4032
## Dependencies
@@ -45,13 +37,11 @@ Both bugs are addressed in the #177 tokenizer branch. Bug 1 is already resolved
4537

4638
| Risk | Mitigation |
4739
|------|-----------|
48-
| `we`/`th` collision with English words | Excluded from aliases — not added |
49-
| `fr` duplication (English + German section) | `getDayOfWeekForString("fr", locale)` returns 5 (Friday) for all locales — result identical |
50-
| `_weekdayPatterns` cache stale | Cache is per-instance, built lazily on first `recognizeWeekday` call — no stale state possible |
40+
| `recognizeWeek` lookahead differs from old regex fix | Regression tests cover all three inputs from issue report |
5141

5242
## Rollback
5343

54-
Part of #177 PR. Revert the `weekdayVocab()` addition (two lines) if 2-letter aliases cause regressions after release.
44+
Part of #177 PR. Tests-only change — no rollback risk.
5545

5646
## Reference spec
5747

Lines changed: 14 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,52 @@
1-
# Spec: Smart Input — week-text boundary and 2-letter English weekday aliases (#230)
1+
# Spec: Smart Input — week-text boundary fix (#230)
22

33
## Goal
44

5-
Fix two parsing defects in `MatchInput`: (1) the week-token regex consumes the first character of the following text, and (2) 2-letter English weekday abbreviations (`mo`, `tu`, `we`, `th`, `fr`) are not recognized.
5+
Fix one parsing defect in `MatchInput`: the week-token regex consumes the first character of the following text. 2-letter English weekday aliases are out of scope — 3-letter forms (`mon`, `tue`, `wed`, `thu`, `fri`) are the supported standard.
66

77
## Why now
88

9-
Both defects break user-visible output in the current 1.1.0 milestone. The week-text bug silently corrupts task and memo content; the missing aliases were discovered in the same report.
9+
Defect breaks user-visible output in the current 1.1.0 milestone. The week-text bug silently corrupts task and memo content (e.g. `"task week Finalize Shoppinglist"` → text becomes `"inalize Shoppinglist"`).
1010

1111
## In scope
1212

1313
- Fix `weekPattern` in `MatchInput.getExpression()` so it does not consume any character beyond the week token itself.
14-
- Add `mo`, `tu`, `fr` to `getWeekdayPattern()` as recognized English aliases (longest-first ordering; after the 3-letter set). `we` and `th` are excluded — both are high-frequency English words that would destructively consume text (e.g. `"task we need to buy milk"``we` parsed as Wednesday).
15-
- Add regression tests in `src/test/suite/input.test.ts` and/or `week-input.test.ts` covering the exact inputs from the issue report.
14+
- Add regression tests covering the exact inputs from the issue report.
1615

1716
## Out of scope
1817

18+
- 2-letter English weekday aliases (`mo`, `tu`, `we`, `th`, `fr`) — 3-letter forms (`mon/tue/wed/thu/fri`) are the supported standard. Adding shorter forms introduces unacceptable collision risk with common English words (`we`, `th`).
1919
- German 2-letter abbreviation conflicts (`di`, `do`, `fr`, `sa`, `so`) — tracked in #177 (parser rewrite).
2020
- Locale-based weekday filtering — also #177.
21-
- Any change to `getDayOfWeekForString` in `dates.ts` (already maps `mo/tu/we/th/fr` correctly).
21+
- Any change to `getDayOfWeekForString` in `dates.ts`.
2222

2323
## Acceptance criteria
2424

2525
1. `parseInput("task week Finalize Shoppinglist")``flags="task"`, `text="Finalize Shoppinglist"`, `week` = current week number.
26-
2. `parseInput("task do the shopping")` — behaviour unchanged (deferred; `do` still fires as German Thursday, text = "the shopping"). No regression.
27-
3. `parseInput("mo")``weekday` group matched, `offset` resolves to next/prev Monday relative to today (same as `parseInput("mon")`).
28-
4. Same for `tu`, `fr`. `we` and `th` are NOT added — they collide with common English words.
29-
5. `parseInput("w15")``week=15` (no regression from week-pattern change).
30-
6. `parseInput("week")` alone (no following text) → `hasWeek()` true, no crash.
31-
7. Full test suite green.
26+
2. `parseInput("task do the shopping")` — behaviour unchanged (`do` still fires as German Thursday, text = "the shopping"). No regression.
27+
3. `parseInput("w15")``week=15` (no regression from week-pattern change).
28+
4. `parseInput("week")` alone (no following text) → `hasWeek()` true, no crash.
29+
5. Full test suite green.
3230

33-
## Root causes
31+
## Root cause
3432

3533
### Bug 1 — week pattern consumes first character of text
3634

3735
Current:
3836
```
3937
const weekPattern = '(?<week>w(?:eek)?(?:\\s\\D|$))';
4038
```
41-
`(?:\\s\\D|$)` alternates between (whitespace + one non-digit character consumed) and end-of-string. For input `"week Finalize…"` the `\\D` captures `"F"`, leaving `"inalize…"` in the text group.
39+
`(?:\\s\\D|$)` alternates between (whitespace + one non-digit character consumed) and end-of-string. For input `"week Finalize…"` the `\\D` captures `"F"`, leaving `"inalize…"` in the text group.
4240

4341
Fix: replace the consuming `\\D` with a lookahead so the non-digit character stays available for the trailing `\\s?` and `textPattern`:
4442
```
4543
const weekPattern = '(?<week>w(?:eek)?)(?=\\s(?!\\d)|$)';
4644
```
4745
`(?=\\s(?!\\d)|$)` asserts (without consuming) that the week token is followed by whitespace-then-non-digit or end-of-string, which prevents `"week15"` from matching this branch (it falls through to `weekNumPattern`).
4846

49-
### Bug 2 — 2-letter English aliases absent from weekday pattern
50-
51-
`getDayOfWeekForString` (dates.ts:86-90) already maps `mo → 1`, `tu → 2`, `we → 3`, `th → 4`, `fr → 5`. `getWeekdayPattern()` only lists 3-letter English forms (`mon`, `tue`, `wed`, `thu`, `fri`), so the 2-letter variants never reach `resolveWeekday`.
52-
53-
Fix: append `'mo', 'tu', 'fr'` after the 3-letter English group in the `alternatives` array (longest-first ordering preserved). `we` and `th` are excluded — `we` is a common English pronoun and would destructively consume words like "we" in `"task we need to buy milk"`; `th` appears at the start of many English words.
54-
5547
## Entities / interfaces
5648

5749
- `MatchInput.getExpression()``weekPattern` constant (one line change).
58-
- `MatchInput.getWeekdayPattern()``alternatives` array (one section addition).
5950
- No interface or model changes.
6051

6152
## Constraints
@@ -66,9 +57,9 @@ Fix: append `'mo', 'tu', 'fr'` after the 3-letter English group in the `alternat
6657

6758
## Open questions
6859

69-
None after clarification.
60+
None.
7061

7162
## Related issues
7263

7364
- Blocks: none.
74-
- Related: #177 (parser rewrite — will supersede the German 2-letter abbreviation side of this report).
65+
- Related: #177 (parser rewrite — tokenizer's `recognizeWeek` uses zero-width lookahead by design, so Bug 1 is also fixed there).

0 commit comments

Comments
 (0)