Reopen canonical post to draft when a translation is manually edited #74

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

Source: Audit section 2.5.

Spec: specs/engine_side_effects.allium rule UpsertPostTranslationSideEffects: "If source is published and this is a manual edit: transition source post to draft (copies content from file to DB)".

bDS2: ../bDS2/lib/bds/posts/translations.ex upsert_post_translation calls maybe_reopen_source_post_for_manual_translation (~line 246): canonical post → draft with content copied from its file.

Current behaviour (RuDS): crates/bds-core/src/engine/post.rs fn upsert_translation (~line 530) demotes only the TRANSLATION to draft when its published content changes; the canonical post stays published.

Task: On manual translation upsert where the canonical post is published, also demote the canonical post to draft, restoring its DB content from the file (same pattern as the update_post reopen branch). Distinguish manual edits from auto-translation/batch paths (bDS2 passes attrs flags — the auto-translation engine crates/bds-core/src/engine/auto_translation.rs must NOT reopen the source). Emit domain events for the post so the UI refreshes.

Acceptance: Tests: manual translation edit reopens canonical post (content restored from file); auto-translation path leaves canonical published. Compare with bDS2 translations tests if present.

**Source:** Audit section 2.5. **Spec:** `specs/engine_side_effects.allium` rule UpsertPostTranslationSideEffects: "If source is published and this is a manual edit: transition source post to draft (copies content from file to DB)". **bDS2:** `../bDS2/lib/bds/posts/translations.ex` `upsert_post_translation` calls `maybe_reopen_source_post_for_manual_translation` (~line 246): canonical post → draft with content copied from its file. **Current behaviour (RuDS):** `crates/bds-core/src/engine/post.rs` fn `upsert_translation` (~line 530) demotes only the TRANSLATION to draft when its published content changes; the canonical post stays published. **Task:** On manual translation upsert where the canonical post is published, also demote the canonical post to draft, restoring its DB content from the file (same pattern as the update_post reopen branch). Distinguish manual edits from auto-translation/batch paths (bDS2 passes attrs flags — the auto-translation engine `crates/bds-core/src/engine/auto_translation.rs` must NOT reopen the source). Emit domain events for the post so the UI refreshes. **Acceptance:** Tests: manual translation edit reopens canonical post (content restored from file); auto-translation path leaves canonical published. Compare with bDS2 translations tests if present.
hugo added the bug label 2026-07-20 19:43:58 +00:00
Author
Owner

Implemented and pushed in b0e9223. Manual post-translation upserts now transactionally reopen a published canonical post to Draft, restore its body from the canonical file using bDS2-compatible fallback behavior, rebuild FTS, sync the embedding, and emit the post Updated domain event after persistence succeeds. The automatic/batch translation engine uses an explicit non-manual path and leaves the canonical source Published with NULL DB content. The desktop integration test proves the queued event refreshes an open editor while preserving the active translation and edited translation values. README updated. Neutral review compared the issue, bDS2 translations.ex/auto_translation.ex, and UpsertPostTranslationSideEffects. Verification: Allium check/analyse, cargo fmt/check/build, cargo machete, all post and auto-translation tests, focused UI integration, and cargo test --workspace (green; one intentional model-download ignore).

Implemented and pushed in b0e9223. Manual post-translation upserts now transactionally reopen a published canonical post to Draft, restore its body from the canonical file using bDS2-compatible fallback behavior, rebuild FTS, sync the embedding, and emit the post Updated domain event after persistence succeeds. The automatic/batch translation engine uses an explicit non-manual path and leaves the canonical source Published with NULL DB content. The desktop integration test proves the queued event refreshes an open editor while preserving the active translation and edited translation values. README updated. Neutral review compared the issue, bDS2 translations.ex/auto_translation.ex, and UpsertPostTranslationSideEffects. Verification: Allium check/analyse, cargo fmt/check/build, cargo machete, all post and auto-translation tests, focused UI integration, and cargo test --workspace (green; one intentional model-download ignore).
hugo closed this issue 2026-07-21 20:14:01 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: hugo/RuDS#74