AI Bible Commentary Site Page Builder

Page Editor Template System Repair Program

Document date: 2026-04-14. Scope: template loading, AI prompt generation, clipboard/export, payload import, persistence, documentation alignment, and release validation.

Purpose

This repair program defines the phased work needed to restore, harden, and govern the Page Editor template system so that defects are caught systematically rather than only after release. It treats the template feature as a production subsystem with its own contracts, validation requirements, release gates, and defect register.

Repair objectives

Current defect classes

Runtime breakage

Inline JavaScript or rendered-output failures that can disable the entire template workflow.

Contract drift

Manifest, templates, prompts, help text, and actual UI behavior falling out of sync.

Persistence defects

Template choice or workflow state failing to persist or restore predictably.

Environment fragility

Clipboard or browser-dependent behavior that fails silently under HTTP or restricted contexts.

Packaging defects

Broken bundles shipping because only source lint is checked instead of rendered runtime output.

Structural code defects

Warnings, malformed regex/path logic, or low-level issues that create hidden instability.

Phased repair program

Phase 0 - Freeze and baseline capture

Freeze the failing bundle, record the relevant file inventory, and create a defect ledger with exact reproduction paths.

Checkpoint: baseline snapshot and defect ledger exist. Acceptance: no repair proceeds without them.

Phase 1 - Failure-class inventory

Classify each issue under runtime, contract, persistence, environment, packaging, or structural code and assign impact and severity.

Checkpoint: every confirmed defect belongs to a tracked class. Acceptance: no known issue remains unclassified or unowned.

Phase 2 - Verification matrix definition

Define exactly what a working template system must do: selector load, defaults apply, prompt build, copy/export, payload import, persistence, and documentation alignment.

Checkpoint: verification matrix exists. Acceptance: every repair maps to one or more checks.

Phase 3 - Runtime blocker repair

Repair JavaScript parse failures and validate the rendered admin output, not just the PHP source.

Checkpoint: template UI executes in the browser. Acceptance: no runtime parse failure remains.

Phase 4 - Contract alignment

Treat the manifest as the source of truth and ensure each shipped template has matching JSON defaults, prompt file, UI label, and help/manual coverage.

Checkpoint: manifest, templates, prompts, and help are aligned. Acceptance: no documentation refers to nonexistent templates.

Phase 5 - Persistence and state integrity

Persist the selected template key, restore it on reopen, and define which AI-assist fields are durable or transient.

Checkpoint: saved pages reopen with correct template state. Acceptance: template state survives save/reload consistently.

Phase 6 - Clipboard and export hardening

Separate generation from copy success, use secure-context clipboard where available, and provide a truthful manual-copy fallback.

Checkpoint: clipboard/export tested in normal browser conditions. Acceptance: users always have a recoverable prompt-export path.

Phase 7 - Structural cleanup

Repair malformed regex/path logic and remove warning-producing code in normal admin operation.

Checkpoint: admin load and save flow runs without structural warnings. Acceptance: no known warning-producing defect remains.

Phase 8 - Automated validation

Add PHP lint, JSON validation, manifest-file existence checks, rendered admin validation, runtime smoke tests, and documentation drift checks.

Checkpoint: pre-release validation checklist exists. Acceptance: this class of failure would now be caught before release.

Phase 9 - Release gates

Require all validation layers to pass before any bundle is marked releasable.

Checkpoint: go/no-go gates defined and used. Acceptance: no bundle ships without passing them.

Phase 10 - Controlled expansion

Add missing template families only after stabilization, and ship each new template as a complete governed unit.

Checkpoint: new templates are added without reintroducing drift. Acceptance: every new template ships with manifest, defaults, prompt, help, and smoke test.

Execution waves

Wave A: baseline, defect ledger, runtime repair, full manual retest.

Wave B: manifest/template/prompt/help alignment.

Wave C: persistence and clipboard/export hardening.

Wave D: structural cleanup and warning audit.

Wave E: automated validation, release gates, then controlled expansion.

Acceptance criteria by subsystem

Template loading

  • selector is populated
  • description updates on change
  • defaults apply correctly

Prompt generation

  • prompt builds without JS errors
  • prompt reflects the selected template and page notes

Clipboard/export

  • copy succeeds in supported secure contexts
  • manual fallback is available and truthful when blocked

Import workflow

  • valid payloads import correctly
  • invalid payloads fail clearly
  • fields land in the correct controls

Persistence

  • selected template is saved
  • selected template restores on reopen

Runtime integrity

  • no JS parse failures
  • no normal-load PHP warnings

Defect tracking table

Defect IDTitleFailure classSymptomRoot causeAffected filesSeverityStatusValidation methodOwnerNotes
PED-001Template workflow JS parse failureRuntime breakageTemplate actions appear but do not workMalformed inline JS string prevented script executionpublic/admin.phpCriticalClosed in current patched bundleRender admin page and verify build/copy/apply flow
PED-002Clipboard success falsely reportedEnvironment fragilityUser may be told copy succeeded when browser blocked itFallback lacked confirmed success handlingpublic/admin.phpHighClosed in current patched bundleTest secure-context copy and manual-copy fallback
PED-003Selected template not persistedPersistence defectTemplate choice lost after save/reloadTemplate key not stored meaningfully in saved page metadatapublic/admin.php; src/PageFactory.phpHighClosed in current patched bundleSave page with selected template and reopen it
PED-004Missing long-form article blockContract / feature gapLong articles have no dedicated structured block beneath cardsNo dedicated editor fields or render block for substantial prose sectionpublic/admin.php; src/PageFactory.php; templates/page.php; templates/page.twig; public/assets/site.cssMediumClosed in current patched bundlePublish a page with long article content and verify render order
PED-005Dictionary template inventory gapContract driftHelp text referenced dictionary template but app did not ship oneMissing manifest/template/prompt unitconfig/page_templates/*; config/import_prompts/*MediumClosed in current patched bundleVerify template appears in selector and prompt builds
PED-006Article/teaching template inventory gapContract driftHelp text referred to article/teaching pages without a dedicated shipped templateMissing manifest/template/prompt unitconfig/page_templates/*; config/import_prompts/*MediumClosed in current patched bundleVerify template appears in selector and prompt builds
PED-007Config path regex warningStructural code defectRuntime warning during path detectionMalformed regex in config path resolutionsrc/Config.phpMediumClosed in current patched bundleLoad diagnostics and save/publish paths without warnings
PED-008No rendered-output release gatePackaging defectBroken UI can ship even if PHP lint passesNo rendered admin validation before packagingrelease processHighOpenAdd checklist / smoke test and require sign-offProcess defect
PED-009No manifest-driven documentation drift checkPackaging defectHelp/manual can diverge from shipped inventoryNo explicit comparison step between manifest and docsrelease processMediumOpenAdd pre-release manifest/documentation auditProcess defect

Release checklist