Files
AgentLab/backend/tests/sqlite_baseline.py
ThearchyHelios e15e94f93e 口径工作台:结构化语义导入、起草续跑恢复与本体关系编排
- 新增口径结构化语义定义、分批解析与 SQL 生成管道(semantic / semantic_import / semantic_sql)
- 支持起草断点续跑恢复、指标自动匹配对齐与存量口径语义迁移面板(MigrationPanel / SemanticPanel)
- 口径草稿与变更流程接入候选本体边提议、审阅确认与一键修改保护,同步更新可移植 SQLite 基线校验
2026-11-12 12:58:12 +08:00

18 lines
740 B
Python

"""Compare SQLite golden bytes across runtimes without changing stored artifacts."""
from __future__ import annotations
import hashlib
import sqlite3
from pathlib import Path
def baseline_file_hash(path: Path, *, writer_version: int) -> str:
data = bytearray(path.read_bytes())
assert data[:16] == b"SQLite format 3\x00"
major, minor, patch = sqlite3.sqlite_version_info
# Offset 96 is the SQLite library version that last wrote the file. All other
# bytes, including page layout, schema and data, remain part of the assertion.
assert int.from_bytes(data[96:100], "big") == major * 1_000_000 + minor * 1_000 + patch
data[96:100] = writer_version.to_bytes(4, "big")
return hashlib.sha256(data).hexdigest()