feat(reports): scan archive/ subdir as fallback to handle post-07:30 UTC window #8
No reviewers
Labels
No labels
source:analyste
source:defenseur
source:human
source:medic
status:approved
status:blocked
status:in-progress
status:needs-fix
status:ready
status:review
status:triage
type:bug
type:feature
type:infra
type:refactor
type:schema
type:security
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: maximus/vps-health-api#8
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/reports-scans-archive-fallback"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Extends
GET /reports/scansto scan${REPORTS_DIR}/archive/as automatic fallback.Bug constate en prod : le handler ne lit que
REPORTS_DIRtop-level. Or cote VPS, le Sergent faitrenameSync(reports/X.json, reports/archive/X.json)quotidien a 07:30 UTC (defenseurs/src/sergent.ts:680). Donc :reports/direct (~2h window)reports/archive/(~22h/jour)Un run manuel de defenseur-auto apres 07:30 UTC trouvait
count=0. Le cron a 06:00 UTC marchait par chance.Initial endpoint introduced in #6.
Implementation
collectScanReportsFromDir(dir, date)(returnsMap<filename, report>to enable filename-keyed dedupe).readScanReportsForDate(date)calls it twice (top-level + archive), merges with top-level priority on filename collision (defensive — top-level is the more recent copy by definition), then sorts asc by timestamp (unchanged contract).archive/missing -> silent skip (existsSyncguard, like REPORTS_DIR).Conserve : auth bearer, regex date validation,
isScanReportfilter, response shape{ date, count, reports: Report[] }.Test coverage
test-curl.shextended : 17/17 cases pass locally (11 existing + 6 new).New cases :
archive-only date 2026-05-04 -> count=1(the 22h window)archive report agent matches(right report returned)top-level priority over archive (no STALE)(dedupe regression)no dedupe duplication on 2026-05-07(count stays at 3)missing archive/ -> still count=3 from top-level(silent skip)missing archive/ + archive-only date -> count=0(silent skip end-to-end)Coolify changes (manual, post-merge)
custom_docker_run_optionsvia UI ou API :-v /home/defenseur/defenseurs/reports:/data/scans:roREPORTS_DIR=/data/scans(is_runtime=true,is_buildtime=false)Validation post-deploy
Doit retourner > 0 (peu importe l'heure UTC).
Test plan
test-curl.shpasses locally (17/17)