Cascade template slug changes to referencing posts and tags #80

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

Source: Audit section 2.11.

Spec: specs/template.allium rule CascadeSlugUpdate: when a template slug changes, update all referencing posts' template_slug and tags' post_template_slug.

bDS2: ../bDS2/lib/bds/templates.ex cascade_template_slug_change (~line 488) updates posts.template_slug and tags.post_template_slug inside the update transaction (commit_update_transaction ~line 229) and returns affected posts for side-effect sync.

Current behaviour (RuDS): crates/bds-core/src/engine/template.rs update_template (~line 61) changes the slug and leaves posts.template_slug/tags.post_template_slug pointing at the old slug — references dangle and posts silently fall back to default templates at render time.

Task: On slug change in update_template, inside a savepoint: update referencing posts and tags to the new slug (bump their updated_at), and consider whether published referencing posts need their frontmatter rewritten (templateSlug is written to post files — bDS2 syncs side effects for affected posts; check sync_template_update_side_effects in templates.ex and mirror). Emit domain events for changed entities.

Acceptance: Test: template referenced by a post + a tag, rename slug → both references updated, no dangling slug; published referencing post's file frontmatter matches DB.

**Source:** Audit section 2.11. **Spec:** `specs/template.allium` rule CascadeSlugUpdate: when a template slug changes, update all referencing posts' template_slug and tags' post_template_slug. **bDS2:** `../bDS2/lib/bds/templates.ex` `cascade_template_slug_change` (~line 488) updates posts.template_slug and tags.post_template_slug inside the update transaction (`commit_update_transaction` ~line 229) and returns affected posts for side-effect sync. **Current behaviour (RuDS):** `crates/bds-core/src/engine/template.rs` `update_template` (~line 61) changes the slug and leaves `posts.template_slug`/`tags.post_template_slug` pointing at the old slug — references dangle and posts silently fall back to default templates at render time. **Task:** On slug change in `update_template`, inside a savepoint: update referencing posts and tags to the new slug (bump their updated_at), and consider whether published referencing posts need their frontmatter rewritten (templateSlug is written to post files — bDS2 syncs side effects for affected posts; check `sync_template_update_side_effects` in templates.ex and mirror). Emit domain events for changed entities. **Acceptance:** Test: template referenced by a post + a tag, rename slug → both references updated, no dangling slug; published referencing post's file frontmatter matches DB.
hugo added the bug label 2026-07-20 19:44:00 +00:00
Author
Owner

Implemented in e28d42d. Template slug updates now capture project-scoped referencing posts and tags and update the template plus both reference sets atomically in one savepoint, bumping affected timestamps. After commit, every published affected post file is rewritten with the new templateSlug, tags.json is regenerated, and typed Updated events are emitted for the template, posts, and tags. Desktop, TUI, and scripting callers now provide the real data directory. Added end-to-end coverage for DB references, published frontmatter, tags.json, events, and a trigger-induced whole-cascade rollback; template-file renaming remains isolated to #81. Updated README. Verified against bDS2 and CascadeSlugUpdate with Allium check/analyse, cargo fmt --check, cargo check --workspace, cargo machete --with-metadata, cargo build --workspace, focused tests, ORM-boundary validation, and cargo test --workspace (all passed; one intentional model-download test ignored).

Implemented in e28d42d. Template slug updates now capture project-scoped referencing posts and tags and update the template plus both reference sets atomically in one savepoint, bumping affected timestamps. After commit, every published affected post file is rewritten with the new templateSlug, tags.json is regenerated, and typed Updated events are emitted for the template, posts, and tags. Desktop, TUI, and scripting callers now provide the real data directory. Added end-to-end coverage for DB references, published frontmatter, tags.json, events, and a trigger-induced whole-cascade rollback; template-file renaming remains isolated to #81. Updated README. Verified against bDS2 and CascadeSlugUpdate with Allium check/analyse, cargo fmt --check, cargo check --workspace, cargo machete --with-metadata, cargo build --workspace, focused tests, ORM-boundary validation, and cargo test --workspace (all passed; one intentional model-download test ignored).
hugo closed this issue 2026-07-21 21:06:21 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: hugo/RuDS#80