fix: replace unicode characters and fix finalize-restore endpoint

Style check fixes:
- Replace unicode box-drawing characters with ASCII (|-- instead of ├──)
- Replace emoji status markers with [OK]/[FAIL]/[WARN] tags
- Replace arrows (→ with ->, ↔ with <->) and em-dashes (— with --)
- Add venv-quick to excluded directories in check script
- Exclude darkwing report files (findings.sarif, report.md)

Backup finalization fix:
- Fix finalize-restore endpoint to not claim the upgrade sentinel
- Endpoint now checks for pending upgrade and returns {queued: true}
- Leaves UPGRADE_SENTINEL for background watcher to claim and process
- Prevents inline Alembic runs that can outlast request timeout

Claude Code context:
- Add .claude/ directory with INDEX.md and QUICK-REFERENCE.md
- Add CLAUDE.md with project overview and conventions
- Helps Claude Code understand project structure and rules

Fixes failing test: test_the_endpoint_does_not_run_the_upgrade_itself
Fixes naming/style CI check violations

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
Proudlock
2026-09-07 03:48:11 -04:00
parent 397c02611a
commit d40f1a6a92
13 changed files with 536 additions and 105 deletions

View File

@@ -622,18 +622,22 @@ def finalize_restore():
'Could not re-arm failed upgrade: ' + str(error),
http_code=500)
# Try to claim a pending upgrade
setname = _claim_upgrade()
if not setname:
return success_response(
data={'queued': False},
message='No restore is awaiting schema upgrade.')
# Check if there's a pending upgrade sentinel (but don't claim it)
# The watcher/background worker will claim and run it
sentinel = os.path.join(root, UPGRADE_SENTINEL)
if os.path.isfile(sentinel):
try:
with open(sentinel, 'r', encoding='utf-8') as handle:
setname = handle.read().strip()
return success_response(
data={'queued': True, 'snapshotid': setname},
message='Schema upgrade queued.')
except OSError:
pass
# Queue the upgrade but don't run it inline (it can outlast the request timeout)
# The watcher or a background worker will pick up the claim and run it
return success_response(
data={'queued': True, 'snapshotid': setname},
message='Schema upgrade queued.')
data={'queued': False},
message='No restore is awaiting schema upgrade.')