20261117 固化13步自然回放、数据哈希与第二版性能基线

This commit is contained in:
2026-11-17 16:59:57 +08:00
parent 56db3cc6e7
commit 5c0ec3a04b
17 changed files with 7044 additions and 5 deletions

View File

@@ -20,7 +20,7 @@ def command(*args: str) -> None:
subprocess.run(args, check=True, timeout=30, capture_output=True, text=True)
def all_hosts(root: Path) -> list[str]:
def all_hosts(root: Path, extra_hosts: list[str] | None = None) -> list[str]:
hosts = set()
def add(uri):
url = urllib.parse.urlsplit(uri)
@@ -33,6 +33,11 @@ def all_hosts(root: Path) -> list[str]:
if not re.fullmatch(r"[a-z0-9.-]+", host):
raise ValueError(f"unsafe hostname: {host}")
hosts.add(host)
for host in extra_hosts or []:
add("https://" + host + "/")
if (root / "registry.json").exists():
for uri in read_json(root / "registry.json"):
add(uri)
for path in (root / "events").glob("*.json"):
add(read_json(path)["uri"])
for path in (root / "observations").glob("*.json"):
@@ -182,14 +187,21 @@ def main():
parser.add_argument("--archive", type=Path, required=True)
parser.add_argument("--epoch", type=Path, required=True)
parser.add_argument("--scope", type=Path)
parser.add_argument("--bundle-manifest", type=Path)
parser.add_argument("--bundle-sha256")
parser.add_argument("--out", type=Path, required=True)
parser.add_argument("--create-network", action="store_true")
args = parser.parse_args()
if args.scope:
from scope import require_closure
require_closure(args.archive, args.scope)
state = ReplayState(args.archive, args.epoch, args.scope)
hosts = all_hosts(args.archive)
state = ReplayState(args.archive, args.epoch, args.scope, args.bundle_manifest, args.bundle_sha256)
if args.bundle_manifest:
from replay_bundle import load_manifest
bundle = load_manifest(args.bundle_manifest, args.bundle_sha256)
hosts = all_hosts(args.archive, bundle["origin_hosts"])
else:
hosts = all_hosts(args.archive)
mapping = host_mapping(hosts)
args.out.mkdir(parents=True, exist_ok=True)
tls = tls_assets(args.out, hosts)
@@ -209,6 +221,8 @@ def main():
"server_namespace": "rp187srv", "rp_namespace": "rp187rp", "server_cpus": "0", "rp_cpus": "1-3"}
if args.scope:
manifest.update(scope_path=str(args.scope.resolve()), scope_sha256=file_sha256(args.scope))
if args.bundle_manifest:
manifest.update(bundle_manifest=str(args.bundle_manifest.resolve()), bundle_sha256=args.bundle_sha256)
atomic_json(epoch_root / "replay.json", manifest)
if args.create_network:
create_network(mapping)