{
  "passed": true,
  "results": [
    {
      "name": "source_integrity",
      "passed": true,
      "commit": "158fd638da1629c8e62caf9ade1515d162def8ab",
      "python": "3.12.14 (main, Aug 25 2026, 14:00:49) [Clang 22.1.3 ]",
      "sqlite": "3.53.1",
      "helper_sha256": "ca8f443b802614680a0f7af46307473cef1c4a9a7858c4acde8ca8e8fd5ee675",
      "upstream_test_sha256": "e2b718c83375809d3839df95b8b19ac2e4fba76131a12e8c0d7564aed3e1f7d1"
    },
    {
      "name": "unmodified_upstream_preflight_test",
      "passed": true,
      "stdout": "",
      "stderr": "",
      "checks": [
        "raw-main-file control omits committed WAL row",
        "three real snapshots include committed WAL row",
        "integrity_check returns ok",
        "newest two snapshots retained",
        "corrupt input exits nonzero and preserves both snapshots",
        "handled failure leaves no .partial file"
      ]
    },
    {
      "name": "missing_database",
      "argv": [
        "python",
        "-I",
        "-S",
        "$LAB/upstream/hermes_cli/backup_sqlite.py",
        "$LAB/runs/20261004T012041Z/missing_database"
      ],
      "exit_code": 0,
      "elapsed_seconds": 0.042,
      "stdout": "{\"path\": null, \"message\": \"state.db not found (fresh install?)\"}\n",
      "stderr": ""
    },
    {
      "name": "missing_database_checks",
      "passed": true,
      "meaning": "No database is a no-op success, not a successful backup artifact"
    },
    {
      "name": "before_corruption",
      "argv": [
        "python",
        "-I",
        "-S",
        "$LAB/upstream/hermes_cli/backup_sqlite.py",
        "$LAB/runs/20261004T012041Z/corrupt_database"
      ],
      "exit_code": 0,
      "elapsed_seconds": 0.054,
      "stdout": "{\"path\": \"$LAB/runs/20261004T012041Z/corrupt_database/state.db.pre-update-emergency-2026-10-04T01-20-42-142182Z-11.bak\", \"bytes\": 8192}\n",
      "stderr": ""
    },
    {
      "name": "corrupt_database",
      "argv": [
        "python",
        "-I",
        "-S",
        "$LAB/upstream/hermes_cli/backup_sqlite.py",
        "$LAB/runs/20261004T012041Z/corrupt_database"
      ],
      "exit_code": 1,
      "elapsed_seconds": 0.043,
      "stdout": "",
      "stderr": "SQLite safe copy failed for $LAB/runs/20261004T012041Z/corrupt_database/state.db: file is not a database\nTraceback (most recent call last):\n  File \"$LAB/upstream/hermes_cli/backup_sqlite.py\", line 117, in <module>\n    print(json.dumps(preflight_state_db(Path(sys.argv[1]))))\n                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n  File \"$LAB/upstream/hermes_cli/backup_sqlite.py\", line 96, in preflight_state_db\n    raise RuntimeError(\"SQLite safe copy failed; previous emergency snapshots were retained\")\nRuntimeError: SQLite safe copy failed; previous emergency snapshots were retained\n"
    },
    {
      "name": "corrupt_database_checks",
      "passed": true,
      "checks": [
        "corrupt input exits nonzero",
        "prior published snapshot retained unchanged",
        "no partial staging file after handled failure"
      ]
    },
    {
      "name": "locked_source",
      "argv": [
        "python",
        "-I",
        "-S",
        "-c",
        "import runpy,sys; from pathlib import Path; m=runpy.run_path(sys.argv[1]); ok=m['_safe_copy_db'](Path(sys.argv[2]),Path(sys.argv[3]),timeout_seconds=0.2); print('copy_result='+str(ok)); sys.exit(0 if ok is False else 1)",
        "$LAB/upstream/hermes_cli/backup_sqlite.py",
        "$LAB/runs/20261004T012041Z/locked_source/state.db",
        "$LAB/runs/20261004T012041Z/locked_source/copy.db"
      ],
      "exit_code": 0,
      "elapsed_seconds": 0.246,
      "stdout": "copy_result=False\n",
      "stderr": "SQLite safe copy failed for $LAB/runs/20261004T012041Z/locked_source/state.db: database remained locked for 0.2 seconds\n"
    },
    {
      "name": "locked_source_checks",
      "passed": true,
      "checks": [
        "real helper returns False within a bounded lock deadline",
        "partial destination removed",
        "no raw-file-copy fallback"
      ]
    },
    {
      "name": "before_interruption",
      "argv": [
        "python",
        "-I",
        "-S",
        "$LAB/upstream/hermes_cli/backup_sqlite.py",
        "$LAB/runs/20261004T012041Z/interrupted_preflight"
      ],
      "exit_code": 0,
      "elapsed_seconds": 0.038,
      "stdout": "{\"path\": \"$LAB/runs/20261004T012041Z/interrupted_preflight/state.db.pre-update-emergency-2026-10-04T01-20-42-470702Z-14.bak\", \"bytes\": 8192}\n",
      "stderr": ""
    },
    {
      "name": "interrupted_preflight",
      "argv": [
        "python",
        "-I",
        "-S",
        "$LAB/upstream/hermes_cli/backup_sqlite.py",
        "$LAB/runs/20261004T012041Z/interrupted_preflight"
      ],
      "exit_code": -15,
      "stdout": "",
      "stderr": ""
    },
    {
      "name": "interruption_checks",
      "passed": true,
      "prior_snapshot_sha256": "4e120dbd97f325e5f1d4e1abd331698e75bb7009a0939d3e8c6765d2815d18cd",
      "checks": [
        "prior published snapshot is unchanged",
        "no new .bak is published"
      ],
      "limitation": "SIGTERM leaves a .partial staging file; Python finally does not run",
      "leftover_staging_files": [
        "interrupted_preflight/state.db.pre-update-emergency-u1byjkaf.partial"
      ]
    },
    {
      "name": "after_interruption_retry",
      "argv": [
        "python",
        "-I",
        "-S",
        "$LAB/upstream/hermes_cli/backup_sqlite.py",
        "$LAB/runs/20261004T012041Z/interrupted_preflight"
      ],
      "exit_code": 0,
      "elapsed_seconds": 0.038,
      "stdout": "{\"path\": \"$LAB/runs/20261004T012041Z/interrupted_preflight/state.db.pre-update-emergency-2026-10-04T01-20-42-550380Z-16.bak\", \"bytes\": 8192}\n",
      "stderr": ""
    },
    {
      "name": "retry_checks",
      "passed": true,
      "checks": [
        "real snapshot retry is usable",
        "committed synthetic row preserved",
        "uncommitted transaction absent",
        "snapshot mode is 0600"
      ],
      "limitation": "Retry does not remove stale .partial files from the terminated process"
    }
  ],
  "scope": "Partial proof of upstream SQLite snapshot helper only; not full Hermes runtime.",
  "run_utc": "2026-10-04T01:20:41Z",
  "invocation": "python -I -S run_lab.py",
  "redactions": "Absolute environment paths replaced with $LAB; Python executable path normalized to python. Results and exit codes unchanged.",
  "source_manifest": {
    "repository": "NousResearch/hermes-agent",
    "commit": "158fd638da1629c8e62caf9ade1515d162def8ab",
    "retrieved_at": "2026-10-04T01:17:53Z",
    "files": [
      {
        "path": "hermes_cli/backup_sqlite.py",
        "git_blob_sha": "1f0177b1db4175451a64b42968d86376e5b7cfcb",
        "url": "https://github.com/NousResearch/hermes-agent/blob/158fd638da1629c8e62caf9ade1515d162def8ab/hermes_cli/backup_sqlite.py"
      },
      {
        "path": "tests/hermes_cli/test_backup_preflight.py",
        "git_blob_sha": "e23e6ea99790636a728f2648627e82e6a71c9dd1",
        "url": "https://github.com/NousResearch/hermes-agent/blob/158fd638da1629c8e62caf9ade1515d162def8ab/tests/hermes_cli/test_backup_preflight.py"
      }
    ]
  },
  "not_tested": [
    "Full Hermes runtime",
    "Full backup/import ZIP round-trip",
    "Real SessionDB schema",
    "Cron execution and duplicate-action behavior",
    "Dashboard, SSH, external ports and host reboot"
  ]
}
