Model force-delete of templates in template.allium #95
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 4.
Context:
specs/template.alliumrule DeleteTemplate only models the guarded delete (requires zero referencing posts/tags). Both implementations additionally support force-delete that clears references first: RuDScrates/bds-core/src/engine/template.rsdelete_template(..., force)nulls posts.template_slug / tags.post_template_slug; bDS2../bDS2/lib/bds/templates.exdelete_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 checkpasses; Rust test covers force-delete reference clearing.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.