Todo sync groundwork: provider, Vikunja adapter, extract/match #70

Manually merged
jfro merged 20 commits from feature/51-todo-sync into main 2026-11-09 00:45:06 +00:00
Owner

Refs #51

Draft: groundwork only. The design (docs/todo-sync.md) is still waiting on Jeremy, so this has none of the schema, workers, settings or UI. It holds the parts the design fixes either way (D2, D3, D9):

  • docs/todo-sync.md: the design, plus the Vikunja calls as checked on a real 2.8.0.
  • RmAnalyzer.Todos.Provider: the behaviour the sync engine will use (check_credentials, list_projects, create_task, complete_task, reopen_task, delete_task, optional changes_since), plain maps with string ids, and Provider.module/1 by name. Tests get Todos.FakeProvider through config.
  • Todos.Providers.Vikunja: API v2 with Req. Create is POST /projects/{id}/tasks?format=markdown. Done and reopen send a merge-patch PATCH /tasks/{id} with only done, and 304 counts as ok. Delete is DELETE /tasks/{id}, and 404 counts as already gone. Project lists page until total_pages, treat null items as empty, and leave out archived projects. Each call logs its method, path, host, ids, status and ms, never the token. Ids are path-escaped.
  • Todos.Extract: walks the MDEx task list for every task item in order, nested ones included. Each gets its text, ticked or not, ordinal, section heading, and a struck flag (the whole item in ~~ ~~). Plain bullets and empty boxes are skipped.
  • Todos.Match: normalizes text (NFKC, case, Markdown marks, [?]/[illegible], punctuation). Then it pairs one to one in three passes: exact, then jaro >= 0.85, then the same ordinal and section with jaro >= 0.6. Text under 6 characters only pairs exactly. Ties go to the same section, then the nearest ordinal.

Checked

  • mix precommit: 1136 tests, 0 failures.
  • mix test --include live_vikunja against a real Vikunja 2.8.0: create, done twice (200 then 304), reopen, delete twice (204 then 404), and a bad token (401). See test/rm_analyzer/todos/providers/vikunja_live_test.exs for how to run it.

Found on 2.8.0: v2 DELETE moves a task to the trash, where it can be restored for 30 days. It isn't permanent. The adapter never purges.

Added (6ad5487)

  • docs/todo-sync.md replaced with Haystack's revision: Nye's final check C1–C8 (page_checked kept apart from provider state, moves followed by hash only when the old page is gone and the hash is unique, mass-removal hold only for more than 1 task) and the trash/restore notes (D17).
  • Optional restore_task/2 on the Provider, for the Status page's Undo. Vikunja: POST /tasks/{id}/restore, logged like the others. 200 restores it, 409 (not in the trash) counts as ok, 404 (purged or past 30 days) is an error. A 401/403 says the token needs the tasks restore permission: tokens made with only create/update/delete get a 401 here, so the doc's permission list now includes it.
  • todos: 1 Oban queue.
  • mix precommit: 1142 tests, 0 failures. The live test now also deletes, restores (twice) and re-deletes a task, and checks an unknown task can't be restored.

Fixed (3438a5b)

  • list_projects/1 leaves out Vikunja's pseudo projects (saved filters, Favorites; ids below 1).
  • Match pairs tasks whose text normalises to "" ([illegible], emoji-only) on the same raw text, or the same ordinal and section, so they aren't deleted and recreated.
  • 412 says "the project is archived".

Added (5e64a9b)

  • docs/todo-sync.md replaced with Haystack's latest revision: Methods .template (D21), in-page write-back (D20/D22, W1–W5), and Nye's N1 (only items with empty raw text drop on pages with our boxes) and N2 (lasso fallback only when our stroke ids are missing).
  • delete_task/2 now gives the "project is archived" message on a 412, like create/complete/reopen/restore.
  • Nye's probe tests folded into match_test.exs and providers/vikunja_test.exs.
  • Out of draft. mix precommit: 1146 tests, 0 failures.
Refs #51 **Draft: groundwork only.** The design (docs/todo-sync.md) is still waiting on Jeremy, so this has none of the schema, workers, settings or UI. It holds the parts the design fixes either way (D2, D3, D9): - `docs/todo-sync.md`: the design, plus the Vikunja calls as checked on a real 2.8.0. - `RmAnalyzer.Todos.Provider`: the behaviour the sync engine will use (`check_credentials`, `list_projects`, `create_task`, `complete_task`, `reopen_task`, `delete_task`, optional `changes_since`), plain maps with string ids, and `Provider.module/1` by name. Tests get `Todos.FakeProvider` through config. - `Todos.Providers.Vikunja`: API v2 with Req. Create is `POST /projects/{id}/tasks?format=markdown`. Done and reopen send a merge-patch `PATCH /tasks/{id}` with only `done`, and 304 counts as ok. Delete is `DELETE /tasks/{id}`, and 404 counts as already gone. Project lists page until `total_pages`, treat null `items` as empty, and leave out archived projects. Each call logs its method, path, host, ids, status and ms, never the token. Ids are path-escaped. - `Todos.Extract`: walks the MDEx task list for every task item in order, nested ones included. Each gets its text, ticked or not, ordinal, section heading, and a struck flag (the whole item in `~~ ~~`). Plain bullets and empty boxes are skipped. - `Todos.Match`: normalizes text (NFKC, case, Markdown marks, `[?]`/`[illegible]`, punctuation). Then it pairs one to one in three passes: exact, then jaro >= 0.85, then the same ordinal and section with jaro >= 0.6. Text under 6 characters only pairs exactly. Ties go to the same section, then the nearest ordinal. **Checked** - `mix precommit`: 1136 tests, 0 failures. - `mix test --include live_vikunja` against a real Vikunja 2.8.0: create, done twice (200 then 304), reopen, delete twice (204 then 404), and a bad token (401). See `test/rm_analyzer/todos/providers/vikunja_live_test.exs` for how to run it. **Found on 2.8.0:** v2 `DELETE` moves a task to the trash, where it can be restored for 30 days. It isn't permanent. The adapter never purges. **Added (6ad5487)** - `docs/todo-sync.md` replaced with Haystack's revision: Nye's final check C1–C8 (page_checked kept apart from provider state, moves followed by hash only when the old page is gone and the hash is unique, mass-removal hold only for more than 1 task) and the trash/restore notes (D17). - Optional `restore_task/2` on the Provider, for the Status page's Undo. Vikunja: `POST /tasks/{id}/restore`, logged like the others. 200 restores it, 409 (not in the trash) counts as ok, 404 (purged or past 30 days) is an error. A 401/403 says the token needs the tasks **restore** permission: tokens made with only create/update/delete get a 401 here, so the doc's permission list now includes it. - `todos: 1` Oban queue. - `mix precommit`: 1142 tests, 0 failures. The live test now also deletes, restores (twice) and re-deletes a task, and checks an unknown task can't be restored. **Fixed (3438a5b)** - `list_projects/1` leaves out Vikunja's pseudo projects (saved filters, Favorites; ids below 1). - `Match` pairs tasks whose text normalises to "" (`[illegible]`, emoji-only) on the same raw text, or the same ordinal and section, so they aren't deleted and recreated. - 412 says "the project is archived". **Added (5e64a9b)** - `docs/todo-sync.md` replaced with Haystack's latest revision: Methods `.template` (D21), in-page write-back (D20/D22, W1–W5), and Nye's N1 (only items with empty raw text drop on pages with our boxes) and N2 (lasso fallback only when our stroke ids are missing). - `delete_task/2` now gives the "project is archived" message on a 412, like create/complete/reopen/restore. - Nye's probe tests folded into `match_test.exs` and `providers/vikunja_test.exs`. - Out of draft. `mix precommit`: 1146 tests, 0 failures.
RmAnalyzer.Todos.Provider is what the sync engine will talk to; Vikunja
is its first adapter, over API v2 with Req, every call logged. Extract
reads a page's task items from its Markdown; Match pairs them with the
items as last synced. No schema, workers or UI yet: those wait on the
design being agreed.
docs(todos): Vikunja v2 calls as checked on 2.8.0 (#51)
Some checks failed
CI / test (pull_request) Has been cancelled
0b0d095e6d
test(todos): load the adapter before checking restore_task/2 (#51)
Some checks failed
CI / test (pull_request) Has been cancelled
6ad5487279
F1: list_projects drops saved filters and Favorites (ids < 1).
F2: tasks that normalise to nothing ([illegible], emoji only) pair on the
same raw text or the same ordinal and section.
Nye's note: a 412 says the project is archived.
Nye's probes kept as regression tests.
jfro changed title from WIP: Todo sync groundwork: provider, Vikunja adapter, extract/match to Todo sync groundwork: provider, Vikunja adapter, extract/match 2026-11-08 20:32:50 +00:00
docs(todos): restore pseudo-project and empty-norm pairing lines (F4) (#51)
Some checks failed
CI / test (pull_request) Has been cancelled
85f4e0c378
docs(todo-sync): F6 'our strokes' wording, N2 fallback edge cases
Some checks failed
CI / test (pull_request) Has been cancelled
80467f73a4
docs(todo-sync): F7/F8 row rules and F9 tick glyphs in Finding tasks
Some checks failed
CI / test (pull_request) Has been cancelled
691af3f97f
docs(todo-sync): D36 title band and toolbar-clear boxes
Some checks failed
CI / test (pull_request) Has been cancelled
756c0c3548
docs(todo-sync): N17/N18 write-back for ticks and reopen
Some checks failed
CI / test (pull_request) Has been cancelled
46ca4f6a13
docs(todo-sync): untick carries our tick's stroke ids, {:untick, ids} (Nye N21; refs #51)
All checks were successful
CI / test (pull_request) Successful in 2m14s
5fb8c13e2d
jfro manually merged commit d8cbb90050 into main 2026-11-09 00:45:06 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
jfro/rm-analyzer!70
No description provided.