2026-11-20T04:13:27+03:00
reconciler drill: baseline, grace period, dry-run, apply, repeat

$ scripts/reconcile.sh            # dry-run, grace 1h, clean baseline
{
  "prefix": "chats/",
  "grace_seconds": 3600,
  "dry_run": true,
  "scanned_objects": 15,
  "scanned_rows": 15,
  "truncated": false,
  "orphans": [],
  "missing": [],
  "deleted_objects": 0,
  "delete_failures": 0,
  "duration_ms": 7
}

$ scripts/s3tool.sh put chats/aaaaaaaa-0000-4000-8000-000000000000/bbbbbbbb-0000-4000-8000-000000000000 - < scripts/fixtures/sample.jpg
put chats/aaaaaaaa-0000-4000-8000-000000000000/bbbbbbbb-0000-4000-8000-000000000000 (653 bytes)

$ scripts/reconcile.sh            # fresh orphan stays: grace 1h
{
  "prefix": "chats/",
  "grace_seconds": 3600,
  "dry_run": true,
  "scanned_objects": 16,
  "scanned_rows": 15,
  "truncated": false,
  "orphans": [],
  "missing": [],
  "deleted_objects": 0,
  "delete_failures": 0,
  "duration_ms": 7
}

$ scripts/reconcile.sh -grace 0s  # orphan detected, dry-run keeps it
{
  "prefix": "chats/",
  "grace_seconds": 0,
  "dry_run": true,
  "scanned_objects": 16,
  "scanned_rows": 15,
  "truncated": false,
  "orphans": [
    {
      "key": "chats/aaaaaaaa-0000-4000-8000-000000000000/bbbbbbbb-0000-4000-8000-000000000000",
      "size_bytes": 653,
      "last_modified": "2026-11-20T01:13:27Z",
      "age_seconds": 0
    }
  ],
  "missing": [],
  "deleted_objects": 0,
  "delete_failures": 0,
  "duration_ms": 6
}

$ scripts/reconcile.sh -grace 0s -dry-run=false   # apply
{
  "prefix": "chats/",
  "grace_seconds": 0,
  "dry_run": false,
  "scanned_objects": 16,
  "scanned_rows": 15,
  "truncated": false,
  "orphans": [
    {
      "key": "chats/aaaaaaaa-0000-4000-8000-000000000000/bbbbbbbb-0000-4000-8000-000000000000",
      "size_bytes": 653,
      "last_modified": "2026-11-20T01:13:27Z",
      "age_seconds": 3
    }
  ],
  "missing": [],
  "deleted_objects": 1,
  "delete_failures": 0,
  "duration_ms": 12
}

$ scripts/reconcile.sh -grace 0s -dry-run=false   # repeat: nothing left
{
  "prefix": "chats/",
  "grace_seconds": 0,
  "dry_run": false,
  "scanned_objects": 15,
  "scanned_rows": 15,
  "truncated": false,
  "orphans": [],
  "missing": [],
  "deleted_objects": 0,
  "delete_failures": 0,
  "duration_ms": 7
}

missing drill: metadata row without object

$ scripts/s3tool.sh delete chats/9452049e-b86c-4d9a-8060-d98f6966b956/97121cfe-6b29-4227-867f-3188e72a725c
deleted chats/9452049e-b86c-4d9a-8060-d98f6966b956/97121cfe-6b29-4227-867f-3188e72a725c

$ scripts/reconcile.sh -grace 0s   # reports missing, keeps metadata
{
  "prefix": "chats/",
  "grace_seconds": 0,
  "dry_run": true,
  "scanned_objects": 14,
  "scanned_rows": 15,
  "truncated": false,
  "orphans": [],
  "missing": [
    {
      "id": "97121cfe-6b29-4227-867f-3188e72a725c",
      "object_key": "chats/9452049e-b86c-4d9a-8060-d98f6966b956/97121cfe-6b29-4227-867f-3188e72a725c",
      "chat_id": "9452049e-b86c-4d9a-8060-d98f6966b956",
      "created_at": "2026-11-20T01:11:14Z"
    }
  ],
  "deleted_objects": 0,
  "delete_failures": 0,
  "duration_ms": 6
}

metadata rows still present: 1
