Model force-delete of templates in template.allium #95

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

Source: Audit section 4.

Context: specs/template.allium rule DeleteTemplate only models the guarded delete (requires zero referencing posts/tags). Both implementations additionally support force-delete that clears references first: RuDS crates/bds-core/src/engine/template.rs delete_template(..., force) nulls posts.template_slug / tags.post_template_slug; bDS2 ../bDS2/lib/bds/templates.ex delete_template(id, force: true)clear_template_references (~line 465).

Task: Extend the spec: add a ForceDeleteTemplateRequested (or a force flag on DeleteTemplateRequested) rule ensuring references are cleared (posts template_slug=null, tags post_template_slug=null, updated_at bumped) before deletion + file removal. Check whether scripts have an analogous force path and spec it if so. Validate with allium. Confirm the RuDS behaviour is covered by a unit test (AGENTS.md: spec invariants need test coverage) — add one if missing, including that cleared published posts get their frontmatter rewritten if that's what bDS2 does (verify in templates.ex sync side effects).

Acceptance: Spec models both delete paths; allium check passes; Rust test covers force-delete reference clearing.

**Source:** Audit section 4. **Context:** `specs/template.allium` rule DeleteTemplate only models the guarded delete (requires zero referencing posts/tags). Both implementations additionally support force-delete that clears references first: RuDS `crates/bds-core/src/engine/template.rs` `delete_template(..., force)` nulls posts.template_slug / tags.post_template_slug; bDS2 `../bDS2/lib/bds/templates.ex` `delete_template(id, force: true)` → `clear_template_references` (~line 465). **Task:** Extend the spec: add a ForceDeleteTemplateRequested (or a force flag on DeleteTemplateRequested) rule ensuring references are cleared (posts template_slug=null, tags post_template_slug=null, updated_at bumped) before deletion + file removal. Check whether scripts have an analogous force path and spec it if so. Validate with `allium`. Confirm the RuDS behaviour is covered by a unit test (AGENTS.md: spec invariants need test coverage) — add one if missing, including that cleared published posts get their frontmatter rewritten if that's what bDS2 does (verify in templates.ex sync side effects). **Acceptance:** Spec models both delete paths; `allium check` passes; Rust test covers force-delete reference clearing.
hugo added the enhancement label 2026-07-20 19:44:04 +00:00
Author
Owner

Implemented and pushed in commit 0753b29. Forced template deletion now scopes reference checks and clearing by project, clears post and tag references with updated timestamps before deletion, rewrites published post frontmatter while preserving body content, flushes tags.json, emits post/tag update events, and leaves same-slug templates and references in other projects untouched. Added red/green regression coverage for guarded deletion, cross-project isolation, database state, timestamps, published files, tag metadata, and template files. Added and validated the ForceDeleteTemplate Allium rule against bDS2 behavior. Verification: cargo test --workspace, cargo build --workspace, cargo clippy --workspace --all-targets -- -D warnings, cargo machete, cargo fmt --all --check, allium check, and allium analyse all pass. Neutral review against the issue, bDS2, and template.allium found no remaining gaps.

Implemented and pushed in commit 0753b29. Forced template deletion now scopes reference checks and clearing by project, clears post and tag references with updated timestamps before deletion, rewrites published post frontmatter while preserving body content, flushes tags.json, emits post/tag update events, and leaves same-slug templates and references in other projects untouched. Added red/green regression coverage for guarded deletion, cross-project isolation, database state, timestamps, published files, tag metadata, and template files. Added and validated the ForceDeleteTemplate Allium rule against bDS2 behavior. Verification: cargo test --workspace, cargo build --workspace, cargo clippy --workspace --all-targets -- -D warnings, cargo machete, cargo fmt --all --check, allium check, and allium analyse all pass. Neutral review against the issue, bDS2, and template.allium found no remaining gaps.
hugo closed this issue 2026-07-22 17:27:43 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: hugo/RuDS#95