You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: restore path end-to-end — sha256, S3 key, round-trip test
Closes the three review BLOCKERs that broke the flagship restore feature
end-to-end (v1.3.0 and earlier shipped a restore path that silently
fails — empty POST to /v1/upload/request means the server records
sha256=NULL and hydration refuses to install with HYDRATION_ERR_PROTO).
B1 (sha256 never sent):
- class.c get_signed_url now accepts a sha256 parameter and POSTs
{"sha256":"..."} to /v1/upload/request so the server records
the digest in the snapshots table.
- class.c run_hourly_backup computes ark_sha256_hex_file of the
backup file before any upload attempt.
B2 (direct-S3 wrong key + no CP registration):
- Direct-S3 s3_key changed from backups/<filename> to tenant-scoped
db_<db_id>/backup.sqlite (the server already uses this key for the
presigned-URL path — both paths now land at the same S3 prefix,
and the db_id prefix isolates tenants in the shared bucket).
- After a successful direct-S3 upload, register_snapshot_with_cp
POSTs {"sha256":"..."} to /v1/snapshot/register so the server
records the snapshot row for hydrate plans.
B3 (server synthesised bogus URL → 404 → client masked as cold start):
- server handleHydratePlan returns 404 when no snapshot row exists
(previously synthesised a URL to a non-existent S3 key, which the
client downloaded → S3 404 → hydrated an empty DB → reported OK).
- hydration.c http_get_string maps HTTP 404 → HYDRATION_ERR_NOTFOUND
(was mapping to HYDRATION_ERR_NET) so plan-404 correctly signals
'no snapshot' rather than looking like a network error.
Test suite — 3 new round-trip restore tests in test_hydration.c:
- test_round_trip_restore_happy_path: mock CP+S3 serve a plan with
correct sha256 + the file, client downloads, verifies sha256,
installs, asserts restored data matches.
- test_round_trip_sha256_mismatch: mock plan has wrong sha256,
client refuses with HYDRATION_ERR_PROTO.
- test_round_trip_cold_start: mock plan has no sha256, client
returns HYDRATION_ERR_PROTO (correct security posture; real cold
start requires sha256-present + 404 on snapshot download).
All three test the full download→verify→install pipeline that had
zero coverage before. The existing mock_plan_server was enhanced to
serve snapshot files and include sha256 in the plan.
Verification: 14/14 ctest, 25/25 hydrate tests, 10/10 node tests,
go test server passed.
0 commit comments