Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Phase 1 Execution Record

Work item: `docs/exec-plans/current/epics/adaptive_page_improvements/adaptive_duplication`
Phase: `1`

## Scope from plan.md
- Create the adaptive-specific entry path without changing non-adaptive duplication behavior.
- Add the scoped feature-flag gate in curriculum actions and in the server-side duplication branch.
- Scaffold the adaptive duplication module interface and structured error contract.

## Implementation Blocks
- [x] Core behavior changes
- [x] Data or interface changes
- [x] Access-control or safety checks
- [x] Observability or operational updates when needed

## Test Blocks
- [x] Tests added or updated
- [x] Required verification commands run
- [x] Results captured

## Work-Item Sync
- [x] PRD, FDD, and plan updated when implementation diverged
- [x] Open questions added to docs when needed

## Review Loop
- Round 1 findings:
- `Actions.render/1` required the new `project` assign but some existing callers still passed only `project_slug`.
- Round 1 fixes:
- Updated the workspace curriculum entry and both pages table models to pass the full project assign through to `Actions.render/1`.
- Round 2 findings (optional):
- No additional actionable findings from the repository review-guideline pass.
- Round 2 fixes (optional):
- None.

## Done Definition
- [x] Phase tasks complete
- [x] Tests and verification pass
- [x] Review completed when enabled
- [x] Validation passes
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Phase 2 Execution Record

Work item: `docs/exec-plans/current/epics/adaptive_page_improvements/adaptive_duplication`
Phase: `2`

## Scope from plan.md
- Implement source-page validation and ordered extraction of adaptive screen refs from the deck page content.
- Implement the bulk duplication phase for adaptive screens and produce deterministic old-to-new resource and revision mappings.
- Add row-count assertions and rollback-safe behavior for missing source revisions and partial-write protection.

## Implementation Blocks
- [x] Core behavior changes
- [x] Data or interface changes
- [x] Access-control or safety checks
- [x] Observability or operational updates when needed

## Test Blocks
- [x] Tests added or updated
- [x] Required verification commands run
- [x] Results captured

## Work-Item Sync
- [x] PRD, FDD, and plan updated when implementation diverged
- [x] Open questions added to docs when needed

## Review Loop
- Round 1 findings:
- The new test helper referenced `Publishing.get_unpublished_publication_id!/1` without the `Oli.Publishing` alias.
- Screen slug generation used a piped `Slug.generate/2` call with reversed arguments, which caused slug-table lookup failures.
- Round 1 fixes:
- Added the missing `Oli.Publishing` alias in the test module.
- Corrected `generate_screen_slugs/1` to call `Slug.generate("revisions", titles)` with the proper argument order.
- Round 2 findings (optional):
- The implementation needed working-publication `published_resources` rows for duplicated screens so `AuthoringResolver` could resolve them in later phases.
- Round 2 fixes (optional):
- Added bulk `published_resources` insertion to the screen duplication engine.
- Synced the FDD and plan to reflect the working-publication mapping requirement.

## Done Definition
- [x] Phase tasks complete
- [x] Tests and verification pass
- [x] Review completed when enabled
- [x] Validation passes
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Phase 3 Execution Record

## Scope Delivered

Phase 3 completed the adaptive duplication transaction end-to-end:

- duplicated adaptive screen resources are remapped in-place after bulk copy
- duplicated adaptive page resources are created and their deck references are remapped
- duplicated adaptive pages are attached back into the requested container
- curriculum duplication flows now succeed for adaptive pages when the feature flag is enabled

## Implementation Notes

- `lib/oli/authoring/editing/adaptive_duplication.ex`
- completed `duplicate/3` so the transaction now:
- bulk duplicates referenced adaptive screens
- bulk rewrites only changed duplicated screen revisions
- creates the duplicated adaptive page resource/revision
- rewrites duplicated page content to the new screen resource ids
- attaches the duplicated page to the destination container
- added focused remap helpers for:
- `authoring.flowchart.paths[*].destinationScreenId`
- `authoring.activitiesRequiredForEvaluation[*]`
- nested `activity-reference.activity_id`
- nested adaptive `idref`
- nested adaptive iframe `resource_id` / `idref`
- implemented a single bulk SQL update for heterogeneous revision content rewrites

- Tests updated:
- `test/oli/authoring/editing/adaptive_duplication_test.exs`
- `test/oli/editing/container_editor_test.exs`
- `test/oli_web/live/curriculum/container_test.exs`
- `test/oli_web/live/workspaces/course_author/curriculum_live_test.exs`

## Verification

- `mix format lib/oli/authoring/editing/adaptive_duplication.ex test/oli/authoring/editing/adaptive_duplication_test.exs test/oli/editing/container_editor_test.exs test/oli_web/live/curriculum/container_test.exs test/oli_web/live/workspaces/course_author/curriculum_live_test.exs`
- `mix test test/oli/authoring/editing/adaptive_duplication_test.exs test/oli/editing/container_editor_test.exs test/oli_web/live/curriculum/container_test.exs test/oli_web/live/workspaces/course_author/curriculum_live_test.exs`

## Follow-Up

- No additional telemetry work was added.
- No work-item doc drift was introduced beyond recording execution outcomes.
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Phase 4 Execution Record

## Scope Delivered

Phase 4 closed the feature with targeted verification and rollout-readiness evidence:

- added explicit independence coverage showing a duplicated adaptive screen can be edited without mutating the original
- added failure-path curriculum coverage showing adaptive duplication surfaces a user-facing error when duplication fails
- reran the targeted backend and LiveView suites for the adaptive duplication slice
- revalidated the work item after the final verification updates

## Verification Additions

- `test/oli/authoring/editing/adaptive_duplication_test.exs`
- verifies duplicated adaptive screens remain independent from originals after a post-duplication edit
- `test/oli_web/live/curriculum/container_test.exs`
- verifies a broken adaptive page duplication attempt shows the authoring error flash
- `test/oli_web/live/workspaces/course_author/curriculum_live_test.exs`
- verifies the course author curriculum surface also shows the authoring error flash

## Automated Verification

- `mix format lib/oli/authoring/editing/adaptive_duplication.ex test/oli/authoring/editing/adaptive_duplication_test.exs test/oli/editing/container_editor_test.exs test/oli_web/live/curriculum/container_test.exs test/oli_web/live/workspaces/course_author/curriculum_live_test.exs`
- `mix test test/oli/authoring/editing/adaptive_duplication_test.exs test/oli/editing/container_editor_test.exs test/oli_web/live/curriculum/container_test.exs test/oli_web/live/workspaces/course_author/curriculum_live_test.exs`
- `python3 /Users/darren/.local/share/harness/skills/validate/scripts/validate_work_item.py docs/exec-plans/current/epics/adaptive_page_improvements/adaptive_duplication --check all`

## Manual Verification Notes

Manual browser-driven authoring verification was not performed in this CLI environment. The recommended guarded-rollout checklist remains:

- duplicate an adaptive page from curriculum authoring with the feature flag enabled
- confirm the duplicated page title uses the standard copy naming convention
- confirm the duplicated page deck points only at duplicated adaptive screen resources
- edit a duplicated adaptive screen and confirm the original screen is unchanged
- attempt duplication of a deliberately broken adaptive page and confirm no duplicate remains and the author sees the existing failure flash

## Release Readiness

- feature remains guarded behind `adaptive_duplication`
- no telemetry or observability work was added
- no work-item doc drift required reconciliation beyond this execution record
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
# Adaptive Duplication - Delivery Plan

Scope and reference artifacts:
- PRD: `docs/exec-plans/current/epics/adaptive_page_improvements/adaptive_duplication/prd.md`
- FDD: `docs/exec-plans/current/epics/adaptive_page_improvements/adaptive_duplication/fdd.md`

## Scope
Implement adaptive page duplication as a feature-flagged authoring workflow that duplicates an adaptive page, bulk-copies its referenced adaptive screens, remaps duplicated resource references, and preserves existing non-adaptive duplication behavior.

Guardrails:
- keep the existing non-adaptive duplication path intact (`FR-006`, `AC-010`)
- preserve `custom.sequenceId` and `custom.sequenceName` on the duplicated page (`FR-004`, `AC-005`)
- use set-based persistence inside one transaction rather than per-screen inserts (`FR-003`, `AC-004`)
- fail closed on unresolved or malformed adaptive references (`FR-005`, `AC-008`, `AC-009`)
- do not add feature-specific telemetry or observability work for this item
- do not introduce schema changes, migrations, or cross-project duplication behavior

## Clarifications & Default Assumptions
- The adaptive path will be introduced behind the canary rollout feature `adaptive_duplication`; when the rollout stage is `off`, current UI and backend behavior remain unchanged (`FR-001`, `AC-001`, `AC-002`).
- The new module boundary is `Oli.Authoring.Editing.AdaptiveDuplication`, with `ContainerEditor.duplicate_page/4` remaining the caller and non-adaptive fallback.
- "Single query" is implemented as a small number of set-based bulk insert/update queries inside one `Repo.transaction`, not as a single hand-written SQL statement across all touched tables.
- The first implementation will target the rewrite surfaces named in the FDD: page `activity-reference.activity_id`, screen `destinationScreenId`, `activitiesRequiredForEvaluation`, and nested `idref` / `resource_id` references (`FR-003`, `FR-004`, `AC-004`, `AC-006`).
- Scenario coverage is not planned initially; targeted ExUnit and LiveView tests are the expected confidence level unless implementation reveals workflow risk that cannot be covered there.

## Phase 1: Feature Gate And Call Path
- Goal: Create the adaptive-specific entry path without changing non-adaptive duplication behavior.
- Tasks:
- [ ] Add a scoped feature-flag check for adaptive duplication at the curriculum action affordance and at the server-side duplication branch (`FR-001`, `FR-006`, `AC-001`, `AC-002`, `AC-010`).
- [ ] Update `ContainerEditor.duplicate_page/4` to detect adaptive pages and delegate to `Oli.Authoring.Editing.AdaptiveDuplication`, while preserving the current path for non-adaptive pages (`FR-006`, `AC-010`).
- [ ] Scaffold the adaptive duplication module interface and structured error contract expected by the caller (`FR-005`, `AC-008`, `AC-009`).
- Testing Tasks:
- [ ] Add or update LiveView coverage for duplicate action visibility with the feature flag on and off (`AC-001`, `AC-002`).
- [ ] Add a regression test proving non-adaptive duplication still uses existing behavior (`AC-010`).
- [ ] Command(s): `mix test test/oli_web/live/curriculum/container_test.exs test/oli/editing/container_editor_test.exs`
- Definition of Done:
- Adaptive pages are routed to a dedicated backend branch only when the feature flag is enabled.
- Non-adaptive duplication behavior and tests remain unchanged.
- Gate:
- The adaptive path is reachable only behind the flag and does not regress non-adaptive duplication.
- Dependencies:
- None.
- Parallelizable Work:
- LiveView affordance updates and backend branch scaffolding can proceed in parallel once the feature-flag contract is agreed.

## Phase 2: Bulk Screen Duplication Engine
- Goal: Implement the transactional, set-based duplication of adaptive screen resources and revisions and produce the old-to-new resource mapping (`FR-002`, `FR-003`, `AC-003`, `AC-004`).
- Tasks:
- [ ] Implement source-page validation and ordered extraction of adaptive screen refs from the deck page content (`FR-002`, `AC-003`, `AC-005`).
- [ ] Implement the bulk duplication phase for adaptive screens: set-based inserts into `resources`, `project_resources`, `revisions`, and current working-publication `published_resources`, all inside one transaction (`FR-003`, `AC-003`, `AC-004`).
- [ ] Return deterministic mapping structures for source screen resource ids to duplicated screen resource ids and duplicated revision ids (`FR-002`, `FR-003`, `AC-003`, `AC-004`).
- [ ] Add row-count and ownership assertions that force rollback on any mismatch (`FR-005`, `AC-008`).
- Testing Tasks:
- [ ] Add backend tests for successful duplication of an adaptive page with multiple screens, verifying new screen resources and unchanged originals (`AC-003`, `AC-007`).
- [ ] Add rollback tests for missing source revisions or insert-count mismatches (`AC-008`).
- [ ] Command(s): `mix test test/oli/authoring/editing/adaptive_duplication_test.exs`
- Definition of Done:
- The module can duplicate all referenced adaptive screens in one transaction and produce a complete old-to-new screen map.
- Any persistence mismatch causes rollback with no partial duplicate left behind.
- Gate:
- Bulk duplication is set-based and transactionally safe before any remapping logic is layered on.
- Dependencies:
- Phase 1.
- Parallelizable Work:
- Test fixture creation for adaptive source pages can proceed alongside the bulk insert implementation.

## Phase 3: Screen Remapping And Page Finalization
- Goal: Rewrite duplicated adaptive screen/page content to point exclusively at duplicated resources, then finalize the duplicated page (`FR-002`, `FR-004`, `FR-005`, `AC-004`, `AC-005`, `AC-006`, `AC-009`).
- Tasks:
- [ ] Implement screen-content remapping for `authoring.flowchart.paths[*].destinationScreenId`, `authoring.activitiesRequiredForEvaluation[*]`, and nested `idref` / `resource_id` surfaces using the screen resource map (`FR-004`, `AC-006`).
- [ ] Reuse or extract existing interop rewiring helpers where practical rather than duplicating traversal logic (`FR-004`, `AC-006`).
- [ ] Bulk update only the duplicated screen revisions whose content changed (`FR-003`, `FR-004`, `AC-004`, `AC-006`).
- [ ] Duplicate the adaptive page resource/revision and rewrite page `activity-reference.activity_id` plus any nested duplicated-screen resource refs, preserving deck order, `sequenceId`, and `sequenceName` (`FR-002`, `FR-004`, `AC-004`, `AC-005`).
- [ ] Reattach the duplicated page through the existing container flow and propagate a user-facing failure when the adaptive duplication transaction aborts (`FR-005`, `AC-009`).
- Testing Tasks:
- [ ] Add targeted remapper tests for each known rewrite surface in screen and page content (`AC-004`, `AC-006`).
- [ ] Add an end-to-end authoring-side duplication test proving the duplicated page references only duplicated screens and preserves sequence metadata (`AC-004`, `AC-005`, `AC-006`).
- [ ] Add failure-path tests ensuring no duplicated page entry or screens survive a remap failure (`AC-008`, `AC-009`).
- [ ] Command(s): `mix test test/oli/authoring/editing/adaptive_duplication_test.exs test/oli/editing/container_editor_test.exs test/oli/interop/rewire_links_test.exs`
- Definition of Done:
- All known duplicated-screen resource-id surfaces are rewritten correctly.
- The duplicated page sequence listing points only at duplicated screens and preserves authored sequencing metadata.
- Gate:
- Adaptive duplicates are internally consistent and fail closed on unsupported or malformed content.
- Dependencies:
- Phase 2.
- Parallelizable Work:
- Page-content remapping tests and screen-content remapping tests can be built in parallel once the mapping contract is stable.

## Phase 4: Verification And Release Readiness
- Goal: Close the feature with targeted regression coverage, manual verification notes, and work-item validation (`FR-001` through `FR-006`, `AC-001` through `AC-010`).
- Tasks:
- [ ] Run targeted backend and LiveView suites covering flag gating, duplication success, remapping correctness, rollback behavior, and non-adaptive regression.
- [ ] Perform manual authoring verification: duplicate an adaptive page, confirm copied-title behavior, confirm copied screens diverge from originals, and confirm forced failure leaves no duplicate behind (`AC-002`, `AC-003`, `AC-007`, `AC-009`).
- [ ] Reconcile any implementation drift back into the work-item docs only if behavior changed from the approved PRD/FDD.
- Testing Tasks:
- [ ] Run the targeted Elixir tests for this feature and any touched regression modules.
- [ ] Run formatting on touched backend files.
- [ ] Re-run harness validation if docs changed.
- [ ] Command(s): `mix test test/oli/authoring/editing/adaptive_duplication_test.exs test/oli/editing/container_editor_test.exs test/oli_web/live/curriculum/container_test.exs && mix format`
- Definition of Done:
- All targeted automated tests pass.
- Manual authoring checks confirm the duplicate behaves as specified.
- The work item remains validated and traceable.
- Gate:
- The feature is ready for guarded rollout behind `adaptive_duplication` using the incremental rollout admin UI.
- Dependencies:
- Phases 1 through 3.
- Parallelizable Work:
- Manual verification can begin once the automated duplication path is stable, while final regression and formatting are run in parallel.

## Parallelization Notes
- The safest split is by seam, not by file count: UI flag affordance work, backend branch wiring, and backend test fixture setup can overlap early.
- Bulk-copy persistence and remapper implementation should stay serialized once transaction semantics are in flight, because they share the same mapping contract.
- No telemetry, metrics, or dashboard tasks should be added during implementation even though `harness.yml` enables telemetry by default; the PRD/FDD explicitly remove that requirement for this work item.

## Phase Gate Summary
- Gate A: Adaptive duplication is feature-flagged and non-adaptive duplication is unchanged.
- Gate B: Bulk screen duplication is set-based, mapped, and transactionally safe.
- Gate C: Remapped duplicated screens and duplicated page point only at duplicated resources while preserving sequence metadata.
- Gate D: Targeted automated and manual verification pass, and the feature is ready for guarded rollout.
Loading
Loading