02-Architecture / 02.07.Rollback-Reporting-Refactor

02.07.Rollback Reporting Refactor

02.07. Rollback Reporting Refactor

Purpose

This document defines the rollback path for the March 13, 2026 reporting-core refactor work across:

Use this plan if the reporting refactor causes regressions in:

This is the source of truth for backout order, target SHAs, and file groups.

Rollback Principle

Rollback must restore the last known remote state first.

Do not attempt ad hoc file edits during an incident. Do not mix old and new logic during rollback. Either:

Last Known Safe Remote Targets

These are the rollback targets for the refactor work described in this document.

Local-Only Refactor Commits

If these commits exist only locally, do not revert them. Reset to the remote target instead.

What Changed

bnc-cpt-api

Commit 445cdf5 introduced:

Additional local-only, uncommitted API work introduced:

bnc-cpt-wui

Commit 781725b introduced:

Additional local-only, uncommitted WUI work introduced:

bnc-cpt-utl

Commit 1dbd362 introduced:

Additional local-only, uncommitted UTL work introduced:

Incident Types And Rollback Scope

1. API report generation broken

Symptoms:

Rollback scope:

2. PDF generation or PDF polling broken

Symptoms:

Rollback scope:

3. API container build or startup broken

Symptoms:

Rollback scope:

4. WUI report rendering or session resume broken

Symptoms:

Rollback scope:

Backout Order

If changes have been pushed and must be reverted, use this order:

  1. bnc-cpt-wui
  2. bnc-cpt-api
  3. bnc-cpt-utl

Reason:

If the failure is purely Docker build/startup, use:

  1. bnc-cpt-utl
  2. bnc-cpt-api

Fastest Full Local Rollback

Use this only if nothing has been pushed and the goal is to get back to the last remote state immediately.

bnc-cpt-api

git -C /opt/bnc/bnc-cpt/bnc-cpt-api reset --hard origin/master
git -C /opt/bnc/bnc-cpt/bnc-cpt-api clean -fd

bnc-cpt-wui

git -C /opt/bnc/bnc-cpt/bnc-cpt-wui reset --hard origin/master

bnc-cpt-utl

git -C /opt/bnc/bnc-cpt/bnc-cpt-utl reset --hard origin/master

Effect:

Safe Shared-History Rollback

Use this if commits have already been pushed or deployed.

Do not reset --hard shared history. Use git revert.

bnc-cpt-wui

git -C /opt/bnc/bnc-cpt/bnc-cpt-wui revert 781725b

bnc-cpt-api

git -C /opt/bnc/bnc-cpt/bnc-cpt-api revert 445cdf5

bnc-cpt-utl

git -C /opt/bnc/bnc-cpt/bnc-cpt-utl revert 1dbd362

Notes:

File Groups To Remove First If The Refactor Must Be Unwound

Highest-risk API code

Highest-risk WUI code

Highest-risk Docker/runtime files

Targeted Partial Rollback

Use this only if documentation should be kept but risky code should be removed.

Recommended process:

  1. create a rescue branch
  2. restore risky code files from origin/master
  3. delete newly added untracked files
  4. keep documentation files if desired

Example: API targeted partial rollback

git -C /opt/bnc/bnc-cpt/bnc-cpt-api switch -c rescue/reporting-refactor
git -C /opt/bnc/bnc-cpt/bnc-cpt-api restore --source=origin/master src/python/cpt-api/app/api/v1/routers/tesla.py
git -C /opt/bnc/bnc-cpt/bnc-cpt-api restore --source=origin/master src/python/cpt-api/app/models/tesla.py
git -C /opt/bnc/bnc-cpt/bnc-cpt-api restore --source=origin/master src/python/cpt-api/app/services/i18n.py
git -C /opt/bnc/bnc-cpt/bnc-cpt-api restore --source=origin/master src/python/cpt-api/app/services/tesla_fleet.py
git -C /opt/bnc/bnc-cpt/bnc-cpt-api restore --source=origin/master src/python/cpt-api/app/__init__.py
git -C /opt/bnc/bnc-cpt/bnc-cpt-api restore --source=origin/master src/python/cpt-api/app/services/__init__.py
rm -f /opt/bnc/bnc-cpt/bnc-cpt-api/src/python/cpt-api/app/models/tesla_acquisition.py
rm -f /opt/bnc/bnc-cpt/bnc-cpt-api/src/python/cpt-api/app/services/tesla_provider_normalization.py
rm -f /opt/bnc/bnc-cpt/bnc-cpt-api/src/python/cpt-api/tests/test_tesla_normalization.py

Use the same pattern for WUI and UTL if only part of the refactor must be removed.

Pre-Push Safety Step

Before any push, create a backup branch in each touched repo.

git -C /opt/bnc/bnc-cpt/bnc-cpt-api switch -c backup/reporting-refactor-2026-03-13
git -C /opt/bnc/bnc-cpt/bnc-cpt-wui switch -c backup/reporting-refactor-2026-03-13
git -C /opt/bnc/bnc-cpt/bnc-cpt-utl switch -c backup/reporting-refactor-2026-03-13

This does not replace rollback, but it preserves the exact local state before any push or reset.

Validation After Rollback

After any rollback, verify:

  1. API build or container startup works again
  2. /health returns 200
  3. session resume works
  4. report generation works
  5. PDF generation works
  6. WUI report page loads correctly

If rollback restores build/startup but not reporting, rollback was incomplete.

Decision Rule

Use full rollback if:

Use targeted partial rollback only if: