Skip to content

Lab 08: Resume, recover and tear down

Objectives

Resume work from evidence instead of blindly rerunning prompts. Reconcile interrupted writes, rehearse isolated backup/restore and source drift, and remove selected synthetic data without claiming secure erasure.

Prerequisites

Use the prior build, QA, and publication records as applicable. Restore exercises require a real app and a synthetic ignored DB, not a source-only workflow or native scratch proof. Obtain explicit owner permission for destructive cleanup. The Python backend's 18-test suite includes an isolated recovery exercise; the 10 proxy tests are separate. This is not human approval of a manual backup/restore or a browser journey. Read the existing evidence\recovery\backend-recovery.md before repeating an exercise.

Bounded prompt

Work only in C:\src\GitHub\devopsabcs-engineering\ontario-form-practice.
Read existing contracts, Git status and actual evidence. Create only
evidence/recovery/recovery-plan.md describing last acknowledged revisions,
unknown outcomes, exact local process IDs, synthetic DB paths, isolated
backup/restore checks, source-drift decisions and approved cleanup targets.
Do not execute deletion, stop unrelated processes, change source hashes,
rerun uncertain mutations, acquire excluded content, resume a new unrelated
run, push, disable Pages or remove repositories. Ask for explicit confirmation
before any later destructive operation. No secure-erasure claim.
Stop after a recoverable plan and identify missing runtime/human evidence.

Steps

Step 1: Resume from the last known state

Read app/curriculum revisions, working-tree changes, last successful command, evidence, and the specific blocker. If your assistant supports session resume, use that known session's documented interface; no plugin-specific command is assumed. Restate allowed paths and stop conditions in the resumed conversation. Never ask it to repeat every previous action.

A locator reloads the local saved row while API/DB exist. Compare its current revision with your last acknowledgment. Preserve unsaved input in memory before choosing reload. If a save/review/delete response was lost after possible commit, reload by known ID before any retry. Do not auto-adopt the newest revision and overwrite. Lost first-create response may leave an unlocated synthetic row; there is no list/recovery/account endpoint in this lab.

Step 2: Rehearse backup and isolated restore

Use only a known synthetic DB from a recorded test. Stop the exact API process using its printed PID; confirm the connection is closed. Do not copy a live WAL-mode database main file alone. Have the app's approved shutdown/checkpoint procedure complete before copying, or use a separately reviewed SQLite backup procedure. If clean closure/checkpoint cannot be confirmed, stop.

Copy the closed/checkpointed database to a distinct ignored scratch folder. Keep the original untouched. Restore a second copy under another scratch path, start the app against it, apply numbered migrations if necessary, reload the known locator/values/revision, restart again, and test stale rejection/deletion. Never restore over the live DB or change an applied migration to hide failure. Record exact paths and observations in evidence\recovery\.

Step 3: Rehearse drift without changing the baseline

Use an isolated test source registry to simulate pending/mismatched acceptance. Prove review/export return 409 SOURCE_REVIEW_REQUIRED while load/save/delete remain usable and source identity stays unchanged. Do not fetch modified government content or update the live manifest to manufacture this exercise.

For actual public-source drift, use the authorized source-only inspection and human comparison described in the source manifest. Artifact retention is three days. A changed hash/revision/structure blocks acceptance until explicit review; an expired report calls for rerun, not pretending old evidence is current.

Step 4: Clean up deliberately

First stop only the recorded app/helper PIDs. Ask the owner which exact synthetic DB, WAL/SHM, backup/restore copies, downloaded summaries, and screenshots may be removed. Clear any locator history separately if desired; history clearing is not DB deletion.

Use the revision-guarded API deletion for individual live rows while the API is available. For complete synthetic DB teardown, stop the API first and remove only the approved file plus sidecars. Do not remove repositories, branches, virtual environments, source evidence, or unrelated data by default. Removing a row/file is not secure erasure of OS caches, backups, or SQLite pages.

If Pages was actually published, only the authorized owner may disable its release flag or site through their approved process. A local cleanup prompt does not authorize remote repository/site deletion.

Validation

This backup example copies only a recorded default synthetic DB after confirmed clean shutdown/checkpoint. It creates a new destination and refuses reuse:

Set-Location C:\src\GitHub\devopsabcs-engineering\ontario-form-practice
$confirmation = Read-Host 'Type CLOSED-SYNTHETIC only after confirming clean shutdown/checkpoint and fictional data'
if ($confirmation -cne 'CLOSED-SYNTHETIC') { throw 'Backup not authorized' }
$source = 'C:\src\GitHub\devopsabcs-engineering\ontario-form-practice\data\practice.sqlite'
$folder = 'C:\src\GitHub\devopsabcs-engineering\ontario-form-practice\.scratch\recovery-' + [guid]::NewGuid().ToString('N')
if (!(Test-Path -LiteralPath $source)) { throw 'Recorded DB is missing' }
foreach ($path in @(
    'C:\src\GitHub\devopsabcs-engineering\ontario-form-practice',
    'C:\src\GitHub\devopsabcs-engineering\ontario-form-practice\data',
    'C:\src\GitHub\devopsabcs-engineering\ontario-form-practice\.scratch',
    $source
)) {
    if ((Test-Path -LiteralPath $path) -and
        ((Get-Item -LiteralPath $path).Attributes -band [IO.FileAttributes]::ReparsePoint)) {
        throw "Reject junction/symlink before copying: $path"
    }
}
if (Test-Path -LiteralPath $folder) { throw 'Destination already exists' }
New-Item -ItemType Directory -Path $folder | Out-Null
Copy-Item -LiteralPath $source -Destination (Join-Path $folder 'backup.sqlite')
Copy-Item -LiteralPath (Join-Path $folder 'backup.sqlite') -Destination (Join-Path $folder 'restored.sqlite')
Get-FileHash -Algorithm SHA256 -LiteralPath $source, (Join-Path $folder 'backup.sqlite'), (Join-Path $folder 'restored.sqlite')

Use only ordinary local files within LearnerRoot; reject junction/symlink escape as specified in the configuration contract. Equal copy hashes prove copying, not application restore. Set PRACTICE_DB_PATH to that specific restored file in the same session as .\.venv\Scripts\python.exe -m api.server, then perform actual load/restart/API checks. Use .\.venv\Scripts\python.exe -m web.dev_server in a separate terminal for the browser. Do not infer recovery from a file hash.

After the owner confirms teardown and every DB connection is stopped, this guarded example targets only the default DB and sidecars:

Set-Location C:\src\GitHub\devopsabcs-engineering\ontario-form-practice
$confirmation = Read-Host 'Type DELETE-SYNTHETIC-DB after confirming the API is stopped and this default DB may be removed'
if ($confirmation -cne 'DELETE-SYNTHETIC-DB') { throw 'Teardown not authorized' }
$db = 'C:\src\GitHub\devopsabcs-engineering\ontario-form-practice\data\practice.sqlite'
foreach ($path in @(
    'C:\src\GitHub\devopsabcs-engineering\ontario-form-practice',
    'C:\src\GitHub\devopsabcs-engineering\ontario-form-practice\data',
    $db, "$db-wal", "$db-shm"
)) {
    if ((Test-Path -LiteralPath $path) -and
        ((Get-Item -LiteralPath $path).Attributes -band [IO.FileAttributes]::ReparsePoint)) {
        throw "Reject junction/symlink before cleanup: $path"
    }
}
foreach ($file in @($db, "$db-wal", "$db-shm")) {
    if (Test-Path -LiteralPath $file) { Remove-Item -LiteralPath $file }
    if (Test-Path -LiteralPath $file) { throw "Cleanup failed: $file" }
}
git --no-pager status --short

For a custom DB path, inspect and approve a separate exact-target command; never substitute an arbitrary browser-provided path. Backup/restore copies and downloaded files need their own explicit cleanup targets. Record actual recovery and teardown results, including what remains.

Expected observable results

After actual execution, an isolated restored app reads the recorded synthetic values across a process restart and preserves revision protections. Drift blocks only gated operations without relabelling rows. Approved cleanup removes selected live files/sidecars while evidence distinguishes retained copies. These are manual learner targets. The existing isolated automated recovery test proves only its owned synthetic paths/processes, not a live or manual restore.

Troubleshooting

If restore sees missing rows, check the exact path, clean checkpoint/backup, schema version, and known locator; do not seed fake rows to pass. If a process ID changed, inspect the current recorded process rather than killing by name. If policy remains blocked, retain a recovery plan and mark execution unfulfilled.

Costs

Recovery/AI usage and any prior hosted charges are unmeasured. Sum your own recorded usage across lessons, distinguish missing measurements, and avoid invented credit totals or claims that teardown refunds charges.

Knowledge checks

  • Why is copying a live WAL-mode main DB file insufficient?
  • How do you reconcile an unknown write outcome without silently overwriting?
  • What survives logical deletion, and which cleanup requires owner permission?

Previous: Publication. Next: Return to the lab map.