Resync the post link graph on content updates and file→DB repairs #75
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Source: Audit section 2.6.
Spec:
specs/engine_side_effects.alliumUpdatePostSideEffects: "if changes.content: ensures PostLinksUpdated(post)".bDS2:
../bDS2/lib/bds/posts.exupdate_postcallsPostLinks.sync_post_links(updated_post)on every update;sync_post_from_fileanddiscard_post_changesdo too.Current behaviour (RuDS): the link graph is only rebuilt inside
publish_post_in_savepoint(crates/bds-core/src/engine/post.rs~line 301) andrebuild_all_links.update_postnever touchespost_links;metadata_diff.rsrepair 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.
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).