Resync the post link graph on content updates and file→DB repairs #75

Closed
opened 2026-07-20 19:43:58 +00:00 by hugo · 1 comment
Owner

Source: Audit section 2.6.

Spec: specs/engine_side_effects.allium UpdatePostSideEffects: "if changes.content: ensures PostLinksUpdated(post)".

bDS2: ../bDS2/lib/bds/posts.ex update_post calls PostLinks.sync_post_links(updated_post) on every update; sync_post_from_file and discard_post_changes do too.

Current behaviour (RuDS): the link graph is only rebuilt inside publish_post_in_savepoint (crates/bds-core/src/engine/post.rs ~line 301) and rebuild_all_links. update_post never touches post_links; metadata_diff.rs repair file→DB for posts (rebuild_canonical_post) also skips link resync (bDS2's sync_post_from_file resyncs). Backlinks/outgoing links shown in the editor and used by render assigns go stale between edits.

Task: Extract the parse-and-replace-links logic (delete_links_by_source + parse_post_links + insert) into a sync_post_links(conn, post, body) helper; call it from update_post when content changed, from discard_post_draft, and from the metadata_diff post repair path. Note: for published posts whose content is NULL, resolve the body the same way rendering does.

Acceptance: Test: update a draft's content to add/remove a canonical link → post_links rows reflect it without publishing. Repair path test likewise.

**Source:** Audit section 2.6. **Spec:** `specs/engine_side_effects.allium` UpdatePostSideEffects: "if changes.content: ensures PostLinksUpdated(post)". **bDS2:** `../bDS2/lib/bds/posts.ex` `update_post` calls `PostLinks.sync_post_links(updated_post)` on every update; `sync_post_from_file` and `discard_post_changes` do too. **Current behaviour (RuDS):** the link graph is only rebuilt inside `publish_post_in_savepoint` (`crates/bds-core/src/engine/post.rs` ~line 301) and `rebuild_all_links`. `update_post` never touches `post_links`; `metadata_diff.rs` repair file→DB for posts (`rebuild_canonical_post`) also skips link resync (bDS2's sync_post_from_file resyncs). Backlinks/outgoing links shown in the editor and used by render assigns go stale between edits. **Task:** Extract the parse-and-replace-links logic (delete_links_by_source + parse_post_links + insert) into a `sync_post_links(conn, post, body)` helper; call it from update_post when content changed, from discard_post_draft, and from the metadata_diff post repair path. Note: for published posts whose content is NULL, resolve the body the same way rendering does. **Acceptance:** Test: update a draft's content to add/remove a canonical link → post_links rows reflect it without publishing. Repair path test likewise.
hugo added the bug label 2026-07-20 19:43:58 +00:00
Author
Owner

Implemented and pushed in 3920d6f. Added a shared transactional sync_post_links replacement path and wired it into content-changing post updates, publish, discard, canonical file rebuild/metadata repair, and the final project filesystem rebuild pass. Published NULL-content posts resolve their body from the file; full rebuild performs a final pass after every target exists. Link extraction now matches the bDS2/Allium contract for Markdown and HTML links across dated, localized, and short routes, strips HTML labels, ignores unresolved targets, and de-duplicates target/label pairs. The desktop editor’s existing relationship refresh now shows new outlinks immediately after a draft save. README updated. Neutral review compared issue #75, bDS2 PostLinks/posts behavior, and UpdatePost/SyncPostFromFile/Discard Allium rules. Verification: Allium check/analyse, cargo fmt/check/build, cargo machete, all post and metadata-diff tests, focused desktop integration, and cargo test --workspace (green; one intentional model-download ignore).

Implemented and pushed in 3920d6f. Added a shared transactional sync_post_links replacement path and wired it into content-changing post updates, publish, discard, canonical file rebuild/metadata repair, and the final project filesystem rebuild pass. Published NULL-content posts resolve their body from the file; full rebuild performs a final pass after every target exists. Link extraction now matches the bDS2/Allium contract for Markdown and HTML links across dated, localized, and short routes, strips HTML labels, ignores unresolved targets, and de-duplicates target/label pairs. The desktop editor’s existing relationship refresh now shows new outlinks immediately after a draft save. README updated. Neutral review compared issue #75, bDS2 PostLinks/posts behavior, and UpdatePost/SyncPostFromFile/Discard Allium rules. Verification: Allium check/analyse, cargo fmt/check/build, cargo machete, all post and metadata-diff tests, focused desktop integration, and cargo test --workspace (green; one intentional model-download ignore).
hugo closed this issue 2026-07-21 20:24:56 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: hugo/RuDS#75