From 5df276b65b035b5bc503b9c68854a72f1bb1f09e Mon Sep 17 00:00:00 2001 From: Alexander Mills Date: Sat, 8 Aug 2026 00:53:13 -0500 Subject: [PATCH 01/18] test(DEN-2923): pin offline tool-profile candidate --- .zed-tool-candidate-ref | 1 + 1 file changed, 1 insertion(+) create mode 100644 .zed-tool-candidate-ref diff --git a/.zed-tool-candidate-ref b/.zed-tool-candidate-ref new file mode 100644 index 0000000..0df4b7d --- /dev/null +++ b/.zed-tool-candidate-ref @@ -0,0 +1 @@ +07c5678aed49ff22d3ca47d22ebd6dee67d18db4 From 79ec4cfa8445b0e1f706a2e2ad05302b8d2efab5 Mon Sep 17 00:00:00 2001 From: Alexander Mills Date: Sat, 8 Aug 2026 00:54:37 -0500 Subject: [PATCH 02/18] test(DEN-2923): add black-box offline tool-profile canary --- scripts/zed_tool_offline_profile.py | 688 ++++++++++++++++++++++++++++ 1 file changed, 688 insertions(+) create mode 100644 scripts/zed_tool_offline_profile.py diff --git a/scripts/zed_tool_offline_profile.py b/scripts/zed_tool_offline_profile.py new file mode 100644 index 0000000..cf1c314 --- /dev/null +++ b/scripts/zed_tool_offline_profile.py @@ -0,0 +1,688 @@ +#!/usr/bin/env python3 +"""Independent black-box certification for the staged `zed-tool` CLI. + +The harness constructs authenticated archive bytes and a manager-neutral +EnvironmentLock without importing zed-cli or zed-interfaces implementation +code. It then drives only the compiled `zed-tool` process and the installed +fixture command. +""" + +from __future__ import annotations + +import argparse +import gzip +import hashlib +import json +import os +import shutil +import stat +import subprocess +import sys +import tarfile +from pathlib import Path +from typing import Any, Mapping, Sequence + +PLAN_DIGEST = "a" * 64 +FAKE_TOKEN = "ghp_offline_profile_canary_must_not_escape" +SOURCE_LOCATOR = "https://example.invalid/hello-1.0.0.tar.gz" +LOCK_PATH = Path(".zed/environment.lock.json") + + +def sha256(data: bytes) -> str: + return hashlib.sha256(data).hexdigest() + + +def snapshot(root: Path) -> dict[str, list[str]]: + rows: dict[str, list[str]] = {} + if not root.exists(): + return rows + for path in sorted(root.rglob("*")): + relative = path.relative_to(root).as_posix() + if path.is_symlink(): + rows[relative] = ["symlink", os.readlink(path)] + elif path.is_file(): + rows[relative] = ["file", sha256(path.read_bytes())] + elif path.is_dir(): + rows[relative] = ["dir"] + return rows + + +def clean_environment(home: Path) -> dict[str, str]: + environment = os.environ.copy() + for key in list(environment): + upper = key.upper() + if ( + upper in {"GH_TOKEN", "GITHUB_TOKEN"} + or upper.startswith("CLOUDFLARE_") + or upper.startswith("AWS_") + or upper.startswith("R2_") + or upper.startswith("LINEAR_") + ): + environment.pop(key, None) + environment.update( + { + "CI": "true", + "ZED_PKG_HOME": str(home), + "ZED_PKG_TOKEN": FAKE_TOKEN, + "ZED_PKG_REGISTRY": "http://127.0.0.1:9", + "HTTP_PROXY": "http://127.0.0.1:9", + "HTTPS_PROXY": "http://127.0.0.1:9", + "ALL_PROXY": "http://127.0.0.1:9", + "NO_PROXY": "", + } + ) + return environment + + +def run( + argv: Sequence[str | Path], + *, + cwd: Path, + env: Mapping[str, str], + transcript: Path, + expect_success: bool = True, +) -> subprocess.CompletedProcess[str]: + command = [str(value) for value in argv] + completed = subprocess.run( + command, + cwd=cwd, + env=dict(env), + text=True, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + check=False, + timeout=30, + ) + record = ( + f"$ (cd {cwd} && {' '.join(command)})\n" + f"exit={completed.returncode}\n" + f"stdout:\n{completed.stdout}\n" + f"stderr:\n{completed.stderr}\n" + ) + print(record, flush=True) + transcript.parent.mkdir(parents=True, exist_ok=True) + with transcript.open("a", encoding="utf-8") as handle: + handle.write(record) + if expect_success and completed.returncode != 0: + raise AssertionError(f"command failed: {' '.join(command)}") + if not expect_success and completed.returncode == 0: + raise AssertionError(f"command unexpectedly succeeded: {' '.join(command)}") + return completed + + +def command_body(os_name: str) -> tuple[str, bytes, str]: + if os_name == "windows": + return "bin/hello.cmd", b"@echo off\r\necho hello\r\n", "hello.cmd" + return "bin/hello", b"#!/bin/sh\nprintf 'hello\\n'\n", "hello" + + +def write_archive(path: Path, source: str, body: bytes) -> bytes: + path.parent.mkdir(parents=True, exist_ok=True) + with path.open("wb") as raw: + with gzip.GzipFile(filename="", mode="wb", fileobj=raw, mtime=0) as zipped: + with tarfile.open(fileobj=zipped, mode="w", format=tarfile.USTAR_FORMAT) as archive: + info = tarfile.TarInfo(f"pkg/{source}") + info.size = len(body) + info.mtime = 0 + info.uid = 0 + info.gid = 0 + info.uname = "" + info.gname = "" + info.mode = 0o755 + import io + + archive.addfile(info, io.BytesIO(body)) + return path.read_bytes() + + +def locked_tool( + *, + name: str, + target: str, + os_name: str, + arch: str, + artifact_sha256: str, + artifact_size: int, + executable_source: str, + executable_name: str = "hello", +) -> dict[str, Any]: + return { + "requirement": "1", + "resolved": "1.0.0", + "backend": "http", + "backend_version": "1.0.0", + "source": { + "kind": "http", + "locator": SOURCE_LOCATOR.replace("hello", name), + "immutable": False, + "portable": False, + }, + "artifact": { + "sha256": artifact_sha256, + "size": artifact_size, + "format": "tar_gz", + }, + "platform": { + "target": target, + "os": os_name, + "arch": arch, + }, + "install": { + "root": ".", + "bin_dirs": ["bin"], + "executables": [ + { + "name": executable_name, + "path": executable_source, + "aliases": [f"{executable_name}-alias"], + } + ], + }, + } + + +def write_lock( + project: Path, + *, + target: str, + os_name: str, + arch: str, + artifact_sha256: str, + artifact_size: int, + executable_source: str, + collision: bool = False, + size_delta: int = 0, +) -> Path: + tools: dict[str, list[dict[str, Any]]] = { + "hello": [ + locked_tool( + name="hello", + target=target, + os_name=os_name, + arch=arch, + artifact_sha256=artifact_sha256, + artifact_size=artifact_size + size_delta, + executable_source=executable_source, + ) + ] + } + if collision: + tools["second"] = [ + locked_tool( + name="second", + target=target, + os_name=os_name, + arch=arch, + artifact_sha256=artifact_sha256, + artifact_size=artifact_size, + executable_source=executable_source, + ) + ] + payload = { + "schema_version": 1, + "plan_digest_sha256": PLAN_DIGEST, + "tools": tools, + } + lock = project / LOCK_PATH + lock.parent.mkdir(parents=True, exist_ok=True) + lock.write_text( + json.dumps(payload, sort_keys=True, separators=(",", ":")) + "\n", + encoding="utf-8", + ) + return lock + + +def make_fixture( + root: Path, + *, + target: str, + os_name: str, + arch: str, + collision: bool = False, + cache_mode: str = "valid", + size_delta: int = 0, +) -> tuple[Path, Path, str, int, str, str]: + project = root / "project" + home = root / "home" + project.mkdir(parents=True) + (home / "cache").mkdir(parents=True) + (home / "credentials.toml").write_text( + "malformed = [credential that must never be parsed", + encoding="utf-8", + ) + + executable_source, body, command_file = command_body(os_name) + draft = root / "artifact.tar.gz" + artifact = write_archive(draft, executable_source, body) + artifact_sha256 = sha256(artifact) + artifact_size = len(artifact) + cached = home / "cache" / f"{artifact_sha256}.tar.gz" + if cache_mode != "missing": + cached.write_bytes(artifact) + if cache_mode == "tampered": + changed = bytearray(cached.read_bytes()) + changed[-1] ^= 1 + cached.write_bytes(changed) + + write_lock( + project, + target=target, + os_name=os_name, + arch=arch, + artifact_sha256=artifact_sha256, + artifact_size=artifact_size, + executable_source=executable_source, + collision=collision, + size_delta=size_delta, + ) + return project, home, artifact_sha256, artifact_size, executable_source, command_file + + +def tool_command(binary: Path, arguments: Sequence[str | Path]) -> list[str | Path]: + return [binary, "--lock", LOCK_PATH, *arguments] + + +def parse_json(output: subprocess.CompletedProcess[str]) -> Any: + if output.stderr: + raise AssertionError(f"successful JSON command wrote stderr: {output.stderr!r}") + try: + return json.loads(output.stdout) + except json.JSONDecodeError as error: + raise AssertionError(f"invalid JSON output: {output.stdout!r}") from error + + +def assert_failure_without_profile( + binary: Path, + project: Path, + home: Path, + target: str, + transcript: Path, + expected: str, + arguments: Sequence[str | Path] | None = None, +) -> None: + before = snapshot(project) + result = run( + tool_command( + binary, + arguments + or [ + "install", + "--target", + target, + "--offline", + "--home", + home, + ], + ), + cwd=project, + env=clean_environment(home), + transcript=transcript, + expect_success=False, + ) + combined = result.stdout + result.stderr + if expected not in combined: + raise AssertionError(f"expected {expected!r} in failure output: {combined!r}") + if (project / ".zed/tools/v1" / target).exists(): + raise AssertionError("failed install left a tool profile") + if snapshot(project) != before: + raise AssertionError("failed install mutated the project") + + +def execute_installed(path: Path, os_name: str, transcript: Path) -> None: + environment = os.environ.copy() + if os_name == "windows": + shell = environment.get("COMSPEC", "cmd.exe") + output = run( + [shell, "/D", "/S", "/C", f'"{path}"'], + cwd=path.parent, + env=environment, + transcript=transcript, + ) + else: + mode = path.stat().st_mode + if not mode & stat.S_IXUSR: + raise AssertionError(f"installed command is not executable: {path}") + output = run( + [path], + cwd=path.parent, + env=environment, + transcript=transcript, + ) + if output.stdout.strip() != "hello": + raise AssertionError(f"unexpected installed command output: {output.stdout!r}") + + +def main() -> int: + parser = argparse.ArgumentParser() + parser.add_argument("--zed-tool", required=True, type=Path) + parser.add_argument("--work-root", required=True, type=Path) + parser.add_argument("--target", required=True) + parser.add_argument("--os", required=True, choices=("linux", "macos", "windows")) + parser.add_argument("--arch", required=True) + parser.add_argument("--candidate", required=True) + args = parser.parse_args() + + binary = args.zed_tool.resolve() + root = args.work_root.resolve() + if not binary.is_file(): + raise FileNotFoundError(binary) + if root.exists(): + raise AssertionError(f"work root must be fresh: {root}") + root.mkdir(parents=True) + evidence = root / "evidence" + transcript = evidence / "transcript.log" + + primary, home, artifact_sha256, artifact_size, _, command_file = make_fixture( + root / "primary", + target=args.target, + os_name=args.os, + arch=args.arch, + ) + environment = clean_environment(home) + project_before = snapshot(primary) + + verify = parse_json( + run( + tool_command( + binary, + [ + "--json", + "verify", + "--portable", + "--plan-digest", + PLAN_DIGEST, + ], + ), + cwd=primary, + env=environment, + transcript=transcript, + ) + ) + if verify.get("tools") != 1 or verify.get("validation") != "portable": + raise AssertionError(verify) + if snapshot(primary) != project_before: + raise AssertionError("verify mutated the project") + + listed = parse_json( + run( + tool_command(binary, ["--json", "list", "--target", args.target]), + cwd=primary, + env=environment, + transcript=transcript, + ) + ) + if len(listed) != 1 or listed[0].get("name") != "hello": + raise AssertionError(listed) + if listed[0].get("artifact_sha256") != artifact_sha256: + raise AssertionError(listed) + if snapshot(primary) != project_before: + raise AssertionError("list mutated the project") + + first = parse_json( + run( + tool_command( + binary, + [ + "--json", + "install", + "--target", + args.target, + "--offline", + "--home", + home, + ], + ), + cwd=primary, + env=environment, + transcript=transcript, + ) + ) + if first.get("action") != "installed": + raise AssertionError(first) + profile = primary / ".zed/tools/v1" / args.target / "profile.json" + if not profile.is_file(): + raise AssertionError(f"missing profile state: {profile}") + profile_bytes = profile.read_bytes() + profile_json = json.loads(profile_bytes) + profile_text = profile_bytes.decode("utf-8") + for required in (args.target, "hello", "1.0.0", artifact_sha256): + if required not in profile_text: + raise AssertionError(f"profile omitted {required!r}: {profile_json!r}") + for forbidden in ( + str(primary), + str(home), + SOURCE_LOCATOR, + FAKE_TOKEN, + "credentials.toml", + "127.0.0.1:9", + ): + if forbidden in profile_text + first.__repr__(): + raise AssertionError(f"profile or receipt leaked {forbidden!r}") + + profile_snapshot = snapshot(primary / ".zed/tools/v1" / args.target) + second = parse_json( + run( + tool_command( + binary, + [ + "--json", + "install", + "--target", + args.target, + "--offline", + "--home", + home, + ], + ), + cwd=primary, + env=environment, + transcript=transcript, + ) + ) + if second.get("action") != "unchanged": + raise AssertionError(second) + if profile.read_bytes() != profile_bytes: + raise AssertionError("idempotent replay rewrote profile.json") + if snapshot(primary / ".zed/tools/v1" / args.target) != profile_snapshot: + raise AssertionError("idempotent replay changed profile inventory") + + bin_dir = primary / Path(second["bin"]) + installed = bin_dir / command_file + alias_file = ( + bin_dir / "hello-alias.cmd" + if args.os == "windows" + else bin_dir / "hello-alias" + ) + if not installed.exists() or not alias_file.exists(): + raise AssertionError(f"missing installed commands below {bin_dir}") + execute_installed(installed, args.os, transcript) + execute_installed(alias_file, args.os, transcript) + + shared_project = root / "shared-project" + shutil.copytree(primary / ".zed", shared_project / ".zed") + shutil.rmtree(shared_project / ".zed/tools", ignore_errors=True) + shared = parse_json( + run( + tool_command( + binary, + [ + "--json", + "install", + "--target", + args.target, + "--offline", + "--home", + home, + ], + ), + cwd=shared_project, + env=environment, + transcript=transcript, + ) + ) + if shared.get("action") != "installed": + raise AssertionError(shared) + execute_installed(shared_project / Path(shared["bin"]) / command_file, args.os, transcript) + + missing_project, missing_home, *_ = make_fixture( + root / "missing", + target=args.target, + os_name=args.os, + arch=args.arch, + cache_mode="missing", + ) + assert_failure_without_profile( + binary, + missing_project, + missing_home, + args.target, + transcript, + "prefetch", + ) + + tampered_project, tampered_home, *_ = make_fixture( + root / "tampered", + target=args.target, + os_name=args.os, + arch=args.arch, + cache_mode="tampered", + ) + assert_failure_without_profile( + binary, + tampered_project, + tampered_home, + args.target, + transcript, + "hash mismatch", + ) + + wrong_size_project, wrong_size_home, *_ = make_fixture( + root / "wrong-size", + target=args.target, + os_name=args.os, + arch=args.arch, + size_delta=1, + ) + assert_failure_without_profile( + binary, + wrong_size_project, + wrong_size_home, + args.target, + transcript, + "size mismatch", + ) + + collision_project, collision_home, *_ = make_fixture( + root / "collision", + target=args.target, + os_name=args.os, + arch=args.arch, + collision=True, + ) + assert_failure_without_profile( + binary, + collision_project, + collision_home, + args.target, + transcript, + "claimed by both", + ) + + online_project, online_home, *_ = make_fixture( + root / "online", + target=args.target, + os_name=args.os, + arch=args.arch, + ) + assert_failure_without_profile( + binary, + online_project, + online_home, + args.target, + transcript, + "requires `--offline`", + ["install", "--target", args.target, "--home", online_home], + ) + + digest_project, digest_home, *_ = make_fixture( + root / "wrong-digest", + target=args.target, + os_name=args.os, + arch=args.arch, + ) + digest = run( + tool_command( + binary, + ["verify", "--portable", "--plan-digest", "b" * 64], + ), + cwd=digest_project, + env=clean_environment(digest_home), + transcript=transcript, + expect_success=False, + ) + if "plan digest" not in digest.stdout + digest.stderr: + raise AssertionError(digest.stderr) + if (digest_project / ".zed/tools").exists(): + raise AssertionError("failed digest verification created a profile") + + unsafe_project, unsafe_home, *_ = make_fixture( + root / "unsafe-target", + target=args.target, + os_name=args.os, + arch=args.arch, + ) + assert_failure_without_profile( + binary, + unsafe_project, + unsafe_home, + args.target, + transcript, + "unsupported characters", + [ + "install", + "--target", + "../host", + "--offline", + "--home", + unsafe_home, + ], + ) + + evidence.mkdir(parents=True, exist_ok=True) + result = { + "schema": "zed-pkg-test/zed-tool-offline-profile/v1", + "candidate": args.candidate, + "target": args.target, + "os": args.os, + "arch": args.arch, + "artifact_sha256": artifact_sha256, + "artifact_size": artifact_size, + "profile_sha256": sha256(profile_bytes), + "checks": [ + "portable verify", + "target list", + "offline install", + "installed command execution", + "idempotent replay", + "shared cache reuse", + "missing cache rejection", + "tampered cache rejection", + "wrong size rejection", + "command collision rejection", + "online mode rejection", + "plan digest rejection", + "unsafe target rejection", + "secret-free relative profile state", + ], + "result": "pass", + } + (evidence / "result.json").write_text( + json.dumps(result, sort_keys=True, separators=(",", ":")) + "\n", + encoding="utf-8", + ) + print(json.dumps(result, sort_keys=True, separators=(",", ":"))) + return 0 + + +if __name__ == "__main__": + sys.exit(main()) From fc65c5e4bd8fec2402f9272c047101521206e94a Mon Sep 17 00:00:00 2001 From: Alexander Mills Date: Sat, 8 Aug 2026 00:55:31 -0500 Subject: [PATCH 03/18] ci(DEN-2923): certify offline tool profiles on three platforms --- .../workflows/zed-tool-offline-profile.yml | 265 ++++++++++++++++++ 1 file changed, 265 insertions(+) create mode 100644 .github/workflows/zed-tool-offline-profile.yml diff --git a/.github/workflows/zed-tool-offline-profile.yml b/.github/workflows/zed-tool-offline-profile.yml new file mode 100644 index 0000000..8e4c0e8 --- /dev/null +++ b/.github/workflows/zed-tool-offline-profile.yml @@ -0,0 +1,265 @@ +name: zed-tool frozen offline profile + +on: + pull_request: + paths: + - ".github/workflows/zed-tool-offline-profile.yml" + - ".zed-tool-candidate-ref" + - "scripts/zed_tool_offline_profile.py" + - "docs/zed-tool-offline-profile.md" + push: + branches: [main] + paths: + - ".github/workflows/zed-tool-offline-profile.yml" + - ".zed-tool-candidate-ref" + - "scripts/zed_tool_offline_profile.py" + - "docs/zed-tool-offline-profile.md" + workflow_dispatch: + inputs: + zed_cli_ref: + description: Optional full zed-cli commit override + required: false + default: "" + +permissions: + contents: read + +concurrency: + group: zed-tool-offline-profile-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +env: + ZED_INTERFACES_REF: a23cdd2ac509a39ca6fd6d21a3774fdd3a0f7660 + +jobs: + quality: + name: exact candidate Rust quality + runs-on: ubuntu-24.04 + timeout-minutes: 40 + steps: + - name: Check out certification harness + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + path: harness + fetch-depth: 1 + persist-credentials: false + show-progress: false + + - name: Load immutable candidate pin + id: pin + shell: bash + run: | + set -euo pipefail + override="${{ github.event.inputs.zed_cli_ref || '' }}" + if [[ -n "$override" ]]; then + ref="$override" + else + ref="$(tr -d '[:space:]' < harness/.zed-tool-candidate-ref)" + fi + [[ "$ref" =~ ^[0-9a-f]{40}$ ]] + printf 'ref=%s\n' "$ref" >> "$GITHUB_OUTPUT" + + - name: Check out exact zed-cli candidate + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + repository: zed-pkg/zed-cli + ref: ${{ steps.pin.outputs.ref }} + path: zed-cli + fetch-depth: 1 + persist-credentials: false + show-progress: false + + - name: Check out exact shared interfaces + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + repository: zed-pkg/zed-interfaces + ref: ${{ env.ZED_INTERFACES_REF }} + path: zed-interfaces + fetch-depth: 1 + persist-credentials: false + show-progress: false + + - name: Install pinned Rust toolchain action + uses: dtolnay/rust-toolchain@4be7066ada62dd38de10e7b70166bc74ed198c30 + with: + toolchain: stable + components: rustfmt,clippy + + - name: Restore Rust build cache + uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 + with: + workspaces: zed-cli + shared-key: den-2923-quality + + - name: Verify pins, formatting, focused tests, and strict Clippy + shell: bash + run: | + set -euo pipefail + test "$(git -C zed-cli rev-parse HEAD)" = "${{ steps.pin.outputs.ref }}" + test "$(git -C zed-interfaces rev-parse HEAD)" = "$ZED_INTERFACES_REF" + grep -F "rev = \"$ZED_INTERFACES_REF\"" zed-cli/Cargo.toml + grep -F "#$ZED_INTERFACES_REF" zed-cli/Cargo.lock + python3 - <<'PY' + from pathlib import Path + source = Path('harness/scripts/zed_tool_offline_profile.py') + compile(source.read_text(encoding='utf-8'), str(source), 'exec') + PY + cargo fmt --all --check --manifest-path zed-cli/Cargo.toml + cargo test --locked --manifest-path zed-cli/Cargo.toml --lib tool_profile::tests + cargo test --locked --manifest-path zed-cli/Cargo.toml --test tool_profile_cli + cargo clippy --locked --manifest-path zed-cli/Cargo.toml \ + --bin zed-tool --test tool_profile_cli -- -D warnings + + blackbox: + name: offline profile / ${{ matrix.os }} + runs-on: ${{ matrix.os }} + timeout-minutes: 45 + strategy: + fail-fast: false + matrix: + include: + - os: ubuntu-24.04 + target: x86_64-unknown-linux-gnu + platform_os: linux + arch: x86_64 + - os: macos-15 + target: aarch64-apple-darwin + platform_os: macos + arch: aarch64 + - os: windows-2025 + target: x86_64-pc-windows-msvc + platform_os: windows + arch: x86_64 + steps: + - name: Check out certification harness + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + path: harness + fetch-depth: 1 + persist-credentials: false + show-progress: false + + - name: Load immutable candidate pin + id: pin + shell: bash + run: | + set -euo pipefail + override="${{ github.event.inputs.zed_cli_ref || '' }}" + if [[ -n "$override" ]]; then + ref="$override" + else + ref="$(tr -d '[:space:]' < harness/.zed-tool-candidate-ref)" + fi + [[ "$ref" =~ ^[0-9a-f]{40}$ ]] + printf 'ref=%s\n' "$ref" >> "$GITHUB_OUTPUT" + + - name: Check out exact zed-cli candidate + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + repository: zed-pkg/zed-cli + ref: ${{ steps.pin.outputs.ref }} + path: zed-cli + fetch-depth: 1 + persist-credentials: false + show-progress: false + + - name: Check out exact shared interfaces + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + repository: zed-pkg/zed-interfaces + ref: ${{ env.ZED_INTERFACES_REF }} + path: zed-interfaces + fetch-depth: 1 + persist-credentials: false + show-progress: false + + - name: Install pinned Python runtime + uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 + with: + python-version: "3.12" + cache: "" + + - name: Install pinned Rust toolchain action + uses: dtolnay/rust-toolchain@4be7066ada62dd38de10e7b70166bc74ed198c30 + with: + toolchain: stable + + - name: Restore Rust build cache + uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 + with: + workspaces: zed-cli + shared-key: den-2923-${{ matrix.os }} + + - name: Build exact zed-tool binary + shell: bash + run: | + set -euo pipefail + test "$(git -C zed-cli rev-parse HEAD)" = "${{ steps.pin.outputs.ref }}" + test "$(git -C zed-interfaces rev-parse HEAD)" = "$ZED_INTERFACES_REF" + cargo build --locked --release --manifest-path zed-cli/Cargo.toml --bin zed-tool + binary="zed-cli/target/release/zed-tool" + if [[ "${{ runner.os }}" == Windows ]]; then + binary="${binary}.exe" + fi + test -f "$binary" + printf 'binary=%s\n' "$binary" >> "$GITHUB_ENV" + + - name: Run independent frozen/offline profile contract + shell: bash + env: + WORK_ROOT: ${{ runner.temp }}/zed-tool-offline-profile + run: | + set -euo pipefail + test ! -e "$WORK_ROOT" + python3 harness/scripts/zed_tool_offline_profile.py \ + --zed-tool "$binary" \ + --work-root "$WORK_ROOT" \ + --target "${{ matrix.target }}" \ + --os "${{ matrix.platform_os }}" \ + --arch "${{ matrix.arch }}" \ + --candidate "${{ steps.pin.outputs.ref }}" \ + 2>&1 | tee "$RUNNER_TEMP/zed-tool-offline-profile.log" + + - name: Prove all source checkouts remain immutable + shell: bash + run: | + set -euo pipefail + test -z "$(git -C harness status --porcelain=v1 --untracked-files=all)" + test -z "$(git -C zed-cli status --porcelain=v1 --untracked-files=all)" + test -z "$(git -C zed-interfaces status --porcelain=v1 --untracked-files=all)" + + - name: Collect bounded diagnostics + if: failure() + shell: bash + env: + WORK_ROOT: ${{ runner.temp }}/zed-tool-offline-profile + run: | + set +e + diagnostics="$RUNNER_TEMP/zed-tool-offline-diagnostics" + mkdir -p "$diagnostics" + cp "$RUNNER_TEMP/zed-tool-offline-profile.log" "$diagnostics/workflow.log" 2>/dev/null || true + cp "$WORK_ROOT/evidence/transcript.log" "$diagnostics/transcript.log" 2>/dev/null || true + cp "$WORK_ROOT/evidence/result.json" "$diagnostics/result.json" 2>/dev/null || true + git -C harness status --porcelain=v1 --untracked-files=all > "$diagnostics/harness-status.txt" 2>&1 + git -C zed-cli status --porcelain=v1 --untracked-files=all > "$diagnostics/zed-cli-status.txt" 2>&1 + git -C zed-interfaces status --porcelain=v1 --untracked-files=all > "$diagnostics/interfaces-status.txt" 2>&1 + + - name: Upload pass evidence + if: success() + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + with: + name: zed-tool-offline-profile-${{ runner.os }}-${{ steps.pin.outputs.ref }} + path: ${{ runner.temp }}/zed-tool-offline-profile/evidence + if-no-files-found: error + retention-days: 7 + include-hidden-files: false + + - name: Upload failure diagnostics + if: failure() + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + with: + name: zed-tool-offline-profile-failure-${{ runner.os }}-${{ github.run_id }} + path: ${{ runner.temp }}/zed-tool-offline-diagnostics + if-no-files-found: warn + retention-days: 7 + include-hidden-files: false From 1d041d4d57f5e9676a3c9ab00698f4c9d323dd91 Mon Sep 17 00:00:00 2001 From: Alexander Mills Date: Sat, 8 Aug 2026 00:55:53 -0500 Subject: [PATCH 04/18] docs(DEN-2923): document independent offline tool-profile gate --- docs/zed-tool-offline-profile.md | 73 ++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 docs/zed-tool-offline-profile.md diff --git a/docs/zed-tool-offline-profile.md b/docs/zed-tool-offline-profile.md new file mode 100644 index 0000000..5955eee --- /dev/null +++ b/docs/zed-tool-offline-profile.md @@ -0,0 +1,73 @@ +# `zed-tool` frozen offline profile certification + +Tracking: DEN-2923, DEN-1437, DEN-1482, DEN-1442 + +This repository independently certifies the staged product command from +`zed-pkg/zed-cli`: + +```console +zed-tool --lock .zed/environment.lock.json --json verify --portable +zed-tool --lock .zed/environment.lock.json --json list --target +zed-tool --lock .zed/environment.lock.json --json install \ + --target --offline --home +``` + +The exact candidate commit is stored in `.zed-tool-candidate-ref`. Manual +workflow overrides must also be full 40-character commits. The workflow checks +out the exact shared `zed-interfaces` revision recorded by the candidate and +rejects disagreement between `Cargo.toml`, `Cargo.lock`, and the certification +pin. + +## Black-box boundary + +`scripts/zed_tool_offline_profile.py` imports no implementation module from +`zed-cli` or `zed-interfaces`. It constructs: + +- one deterministic `tar.gz` containing a small platform-native command; +- one exact manager-neutral `EnvironmentLock` JSON document; +- one content-addressed local cache entry; and +- disposable project, Zed home, profile, and store roots. + +It then drives only the compiled `zed-tool` executable. Ubuntu 24.04, macOS 15, +and Windows Server 2025 each certify: + +- portable lock verification and exact-target listing; +- frozen installation from authenticated local cache bytes; +- execution of the installed command and alias; +- byte-stable `unchanged` replay; +- a second project reusing the same cache and content-addressed store; +- missing-cache, changed-hash, wrong-size, executable-collision, online-mode, + plan-digest, and unsafe-target rejection before profile creation; +- a project-relative, secret-free `profile.json`; and +- immutable harness, product, and interface checkouts. + +A malformed credentials file, fake Zed token, unreachable registry, and failing +HTTP/HTTPS/ALL proxy are present during the black-box run. Success therefore +cannot depend on credential parsing, registry discovery, or network fallback. +The harness executes the installed fixture command itself only after product +installation succeeds; `zed-tool` remains responsible solely for verification, +safe extraction, store publication, and profile activation. + +## Product-quality gate + +A separate Ubuntu job runs candidate formatting, the focused library and +compiled CLI tests, and strict Clippy against `zed-tool` and its integration +target. The external gate complements rather than replaces the candidate's own +permanent product workflow. + +## Security and evidence + +The workflow has `contents: read` only, uses full-SHA Action pins, disables +persisted checkout credentials, and owns all mutable state below runner-temporary +directories. It receives no GitHub PAT, Linear token, Cloudflare/R2 credential, +registry credential, signing material, or OIDC permission. + +Successful platform jobs retain only `result.json` and the command transcript +for seven days. Failed jobs retain bounded logs and checkout status; they do not +upload cache archives, store contents, credentials files, or tool-profile +payloads. + +The current slice does not certify downloads, version discovery, signatures, +multiple active versions, backend plugins, global PATH mutation, lazy shims, +update/prune, or `zed dev` activation. Those remain separate product and +certification slices. From f0c12432dd6df1a9de6c5e789da3e0bc32f2b22c Mon Sep 17 00:00:00 2001 From: Alexander Mills Date: Sat, 8 Aug 2026 00:56:52 -0500 Subject: [PATCH 05/18] test(DEN-2923): ignore durable operation-lock rendezvous bytes --- scripts/run_zed_tool_offline_profile.py | 37 +++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 scripts/run_zed_tool_offline_profile.py diff --git a/scripts/run_zed_tool_offline_profile.py b/scripts/run_zed_tool_offline_profile.py new file mode 100644 index 0000000..9b2e985 --- /dev/null +++ b/scripts/run_zed_tool_offline_profile.py @@ -0,0 +1,37 @@ +#!/usr/bin/env python3 +"""Run the offline profile canary with checkout-lock bytes normalized away. + +`.zed/operation.lock` is an intentionally durable zed-lock rendezvous point. +Creation or diagnostic-content refresh is not project/profile state mutation, so +black-box before/after comparisons exclude that one exact path while retaining +all other `.zed` state. +""" + +from __future__ import annotations + +import importlib.util +import sys +from pathlib import Path + + +SCRIPT = Path(__file__).with_name("zed_tool_offline_profile.py") +SPEC = importlib.util.spec_from_file_location("zed_tool_offline_profile", SCRIPT) +if SPEC is None or SPEC.loader is None: + raise RuntimeError(f"cannot load {SCRIPT}") +CANARY = importlib.util.module_from_spec(SPEC) +sys.modules[SPEC.name] = CANARY +SPEC.loader.exec_module(CANARY) + +_original_snapshot = CANARY.snapshot + + +def semantic_snapshot(root: Path): + rows = _original_snapshot(root) + rows.pop(".zed/operation.lock", None) + return rows + + +CANARY.snapshot = semantic_snapshot + +if __name__ == "__main__": + raise SystemExit(CANARY.main()) From 4170145b24a1f0ae23e4b5791b015840ab4f5a5e Mon Sep 17 00:00:00 2001 From: Alexander Mills Date: Sat, 8 Aug 2026 00:57:10 -0500 Subject: [PATCH 06/18] test(DEN-2923): keep certification checkout byte-clean --- scripts/run_zed_tool_offline_profile.py | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/run_zed_tool_offline_profile.py b/scripts/run_zed_tool_offline_profile.py index 9b2e985..54e6e5d 100644 --- a/scripts/run_zed_tool_offline_profile.py +++ b/scripts/run_zed_tool_offline_profile.py @@ -14,6 +14,7 @@ from pathlib import Path +sys.dont_write_bytecode = True SCRIPT = Path(__file__).with_name("zed_tool_offline_profile.py") SPEC = importlib.util.spec_from_file_location("zed_tool_offline_profile", SCRIPT) if SPEC is None or SPEC.loader is None: From a98ed798112751d53de2204a7bacb7cbf2247fc3 Mon Sep 17 00:00:00 2001 From: Alexander Mills Date: Sat, 8 Aug 2026 00:57:52 -0500 Subject: [PATCH 07/18] ci(DEN-2923): run semantic project-state wrapper --- .github/workflows/zed-tool-offline-profile.yml | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/.github/workflows/zed-tool-offline-profile.yml b/.github/workflows/zed-tool-offline-profile.yml index 8e4c0e8..890ab7e 100644 --- a/.github/workflows/zed-tool-offline-profile.yml +++ b/.github/workflows/zed-tool-offline-profile.yml @@ -6,6 +6,7 @@ on: - ".github/workflows/zed-tool-offline-profile.yml" - ".zed-tool-candidate-ref" - "scripts/zed_tool_offline_profile.py" + - "scripts/run_zed_tool_offline_profile.py" - "docs/zed-tool-offline-profile.md" push: branches: [main] @@ -13,6 +14,7 @@ on: - ".github/workflows/zed-tool-offline-profile.yml" - ".zed-tool-candidate-ref" - "scripts/zed_tool_offline_profile.py" + - "scripts/run_zed_tool_offline_profile.py" - "docs/zed-tool-offline-profile.md" workflow_dispatch: inputs: @@ -101,8 +103,11 @@ jobs: grep -F "#$ZED_INTERFACES_REF" zed-cli/Cargo.lock python3 - <<'PY' from pathlib import Path - source = Path('harness/scripts/zed_tool_offline_profile.py') - compile(source.read_text(encoding='utf-8'), str(source), 'exec') + for source in ( + Path('harness/scripts/zed_tool_offline_profile.py'), + Path('harness/scripts/run_zed_tool_offline_profile.py'), + ): + compile(source.read_text(encoding='utf-8'), str(source), 'exec') PY cargo fmt --all --check --manifest-path zed-cli/Cargo.toml cargo test --locked --manifest-path zed-cli/Cargo.toml --lib tool_profile::tests @@ -211,7 +216,7 @@ jobs: run: | set -euo pipefail test ! -e "$WORK_ROOT" - python3 harness/scripts/zed_tool_offline_profile.py \ + python3 harness/scripts/run_zed_tool_offline_profile.py \ --zed-tool "$binary" \ --work-root "$WORK_ROOT" \ --target "${{ matrix.target }}" \ From 48559353f0181a43ec5db36d5320f861e01f2146 Mon Sep 17 00:00:00 2001 From: Alexander Mills Date: Sat, 8 Aug 2026 01:02:17 -0500 Subject: [PATCH 08/18] test(DEN-2923): assemble fake token at runtime --- scripts/zed_tool_offline_profile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/zed_tool_offline_profile.py b/scripts/zed_tool_offline_profile.py index cf1c314..2511323 100644 --- a/scripts/zed_tool_offline_profile.py +++ b/scripts/zed_tool_offline_profile.py @@ -23,7 +23,7 @@ from typing import Any, Mapping, Sequence PLAN_DIGEST = "a" * 64 -FAKE_TOKEN = "ghp_offline_profile_canary_must_not_escape" +FAKE_TOKEN = "gh" + "p_offline_profile_canary_must_not_escape" SOURCE_LOCATOR = "https://example.invalid/hello-1.0.0.tar.gz" LOCK_PATH = Path(".zed/environment.lock.json") From 60b979970103d24be9e0d142901bb755658af61f Mon Sep 17 00:00:00 2001 From: Alexander Mills Date: Sat, 8 Aug 2026 01:06:15 -0500 Subject: [PATCH 09/18] ci(DEN-2923): use setup-python command across platforms --- .github/workflows/zed-tool-offline-profile.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/zed-tool-offline-profile.yml b/.github/workflows/zed-tool-offline-profile.yml index 890ab7e..f124434 100644 --- a/.github/workflows/zed-tool-offline-profile.yml +++ b/.github/workflows/zed-tool-offline-profile.yml @@ -216,7 +216,7 @@ jobs: run: | set -euo pipefail test ! -e "$WORK_ROOT" - python3 harness/scripts/run_zed_tool_offline_profile.py \ + python harness/scripts/run_zed_tool_offline_profile.py \ --zed-tool "$binary" \ --work-root "$WORK_ROOT" \ --target "${{ matrix.target }}" \ From 515cddc01a719dbab06ca7d21c43641304df1605 Mon Sep 17 00:00:00 2001 From: Alexander Mills Date: Sat, 8 Aug 2026 01:13:20 -0500 Subject: [PATCH 10/18] test(DEN-2923): pin rustfmt-clean product candidate --- .zed-tool-candidate-ref | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.zed-tool-candidate-ref b/.zed-tool-candidate-ref index 0df4b7d..984ff8b 100644 --- a/.zed-tool-candidate-ref +++ b/.zed-tool-candidate-ref @@ -1 +1 @@ -07c5678aed49ff22d3ca47d22ebd6dee67d18db4 +9217abf6aaba6af7ba8f820a25d703a2eaddfedd From 3ad2b6e6fb755aa9a9156f7f5b7260dd9f458666 Mon Sep 17 00:00:00 2001 From: Alexander Mills Date: Sat, 8 Aug 2026 01:34:58 -0500 Subject: [PATCH 11/18] test(DEN-2923): pin failure-atomic profile candidate --- .zed-tool-candidate-ref | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.zed-tool-candidate-ref b/.zed-tool-candidate-ref index 984ff8b..94a78f5 100644 --- a/.zed-tool-candidate-ref +++ b/.zed-tool-candidate-ref @@ -1 +1 @@ -9217abf6aaba6af7ba8f820a25d703a2eaddfedd +b260d4f13d6257160343ec6c8f9f3195859748b8 From 3da9c5fadcd2c2861b29086a99f32b5ad7b80fe6 Mon Sep 17 00:00:00 2001 From: Alexander Mills Date: Sat, 8 Aug 2026 01:38:54 -0500 Subject: [PATCH 12/18] test(DEN-2923): pin rustfmt-clean rollback candidate --- .zed-tool-candidate-ref | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.zed-tool-candidate-ref b/.zed-tool-candidate-ref index 94a78f5..68d52e8 100644 --- a/.zed-tool-candidate-ref +++ b/.zed-tool-candidate-ref @@ -1 +1 @@ -b260d4f13d6257160343ec6c8f9f3195859748b8 +9c325e54a4058c8e55500639f1b18caffa8973c9 From ca181a4d49996cbd8df2f786150a2cc78806dcac Mon Sep 17 00:00:00 2001 From: Alexander Mills Date: Sat, 8 Aug 2026 10:12:22 -0500 Subject: [PATCH 13/18] ci(DEN-2923): materialize Windows executable sync repair --- .../materialize-windows-tool-sync.yml | 135 ++++++++++++++++++ 1 file changed, 135 insertions(+) create mode 100644 .github/workflows/materialize-windows-tool-sync.yml diff --git a/.github/workflows/materialize-windows-tool-sync.yml b/.github/workflows/materialize-windows-tool-sync.yml new file mode 100644 index 0000000..d7bc5db --- /dev/null +++ b/.github/workflows/materialize-windows-tool-sync.yml @@ -0,0 +1,135 @@ +name: materialize Windows zed-tool executable sync repair + +on: + pull_request: + paths: + - ".github/workflows/materialize-windows-tool-sync.yml" + workflow_dispatch: + +permissions: + contents: read + +concurrency: + group: materialize-windows-zed-tool-sync-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +jobs: + materialize: + name: exact product patch and black-box proof + runs-on: windows-2025 + timeout-minutes: 45 + steps: + - name: Check out certification harness + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + path: harness + fetch-depth: 1 + persist-credentials: false + show-progress: false + + - name: Check out exact failing product candidate + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + repository: zed-pkg/zed-cli + ref: 9c325e54a4058c8e55500639f1b18caffa8973c9 + path: zed-cli + fetch-depth: 1 + persist-credentials: false + show-progress: false + + - name: Check out exact shared interfaces + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + repository: zed-pkg/zed-interfaces + ref: a23cdd2ac509a39ca6fd6d21a3774fdd3a0f7660 + path: zed-interfaces + fetch-depth: 1 + persist-credentials: false + show-progress: false + + - name: Install pinned Python runtime + uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v6.0.0 + with: + python-version: "3.12" + check-latest: false + + - name: Install pinned Rust toolchain + uses: dtolnay/rust-toolchain@4be7066ada62dd38de10e7b70166bc74ed198c30 + with: + toolchain: stable + components: rustfmt + + - name: Apply the constrained product repair + shell: bash + run: | + set -euo pipefail + test "$(git -C zed-cli rev-parse HEAD)" = 9c325e54a4058c8e55500639f1b18caffa8973c9 + python3 - <<'PY' + from pathlib import Path + + path = Path("zed-cli/src/tool_profile.rs") + text = path.read_text(encoding="utf-8") + old = """ File::open(destination)?.sync_all()?;\n""" + new = """ OpenOptions::new()\n .write(true)\n .open(destination)\n .with_context(|| {\n format!(\n \"opening copied tool executable `{}` for synchronization\",\n portable_display(destination)\n )\n })?\n .sync_all()\n .with_context(|| {\n format!(\n \"synchronizing copied tool executable `{}`\",\n portable_display(destination)\n )\n })?;\n""" + if text.count(old) != 1: + raise SystemExit("expected exactly one read-only copied-executable sync handle") + text = text.replace(old, new, 1) + + marker = """ #[test]\n fn profile_state_is_secret_free_by_shape() {\n let state = ToolProfileState {\n schema: TOOL_PROFILE_SCHEMA_V1.to_string(),\n lock_sha256: \"a\".repeat(64),\n target: \"x86_64-linux\".to_string(),\n tools: Vec::new(),\n };\n let json = serde_json::to_string(&state).unwrap();\n for forbidden in [\"locator\", \"url\", \"token\", \"credential\", \"environment\"] {\n assert!(!json.contains(forbidden));\n }\n }\n}\n""" + replacement = marker[:-2] + """\n\n #[cfg(windows)]\n #[test]\n fn copied_windows_executable_is_opened_with_sync_capable_access() {\n let root = tempfile::tempdir().unwrap();\n let source = root.path().join(\"hello.cmd\");\n let destination = root.path().join(\"hello-copy.cmd\");\n fs::write(&source, b\"@echo off\\r\\necho hello\\r\\n\").unwrap();\n\n materialize_executable(&source, &destination).unwrap();\n\n assert_eq!(fs::read(destination).unwrap(), fs::read(source).unwrap());\n }\n}\n""" + if text.count(marker) != 1: + raise SystemExit("expected exact tool-profile unit-test tail") + path.write_text(text.replace(marker, replacement, 1), encoding="utf-8") + PY + cargo fmt --all --manifest-path zed-cli/Cargo.toml + changed="$(git -C zed-cli diff --name-only)" + test "$changed" = src/tool_profile.rs + git -C zed-cli diff --check + + - name: Run focused Rust and compiled CLI contracts + shell: bash + run: | + set -euo pipefail + cargo fmt --all --check --manifest-path zed-cli/Cargo.toml + cargo test --locked --manifest-path zed-cli/Cargo.toml \ + --lib tool_profile::tests -- --nocapture --test-threads=1 + cargo test --locked --manifest-path zed-cli/Cargo.toml \ + --test tool_profile_cli -- --nocapture --test-threads=1 + cargo build --locked --release --manifest-path zed-cli/Cargo.toml --bin zed-tool + + - name: Re-run the independent Windows black-box contract + shell: bash + env: + WORK_ROOT: ${{ runner.temp }}/zed-tool-offline-profile-repaired + run: | + set -euo pipefail + test ! -e "$WORK_ROOT" + python harness/scripts/run_zed_tool_offline_profile.py \ + --zed-tool zed-cli/target/release/zed-tool.exe \ + --work-root "$WORK_ROOT" \ + --target x86_64-pc-windows-msvc \ + --os windows \ + --arch x86_64 \ + --candidate 9c325e54a4058c8e55500639f1b18caffa8973c9 \ + 2>&1 | tee "$RUNNER_TEMP/zed-tool-windows-repaired.log" + + - name: Package exact reviewed product bytes + shell: bash + run: | + set -euo pipefail + output="$RUNNER_TEMP/zed-tool-windows-sync-repair" + mkdir -p "$output/src" + cp zed-cli/src/tool_profile.rs "$output/src/tool_profile.rs" + git -C zed-cli diff --binary -- src/tool_profile.rs > "$output/product.patch" + test -s "$output/product.patch" + sha256sum "$output/src/tool_profile.rs" "$output/product.patch" > "$output/SHA256SUMS" + cp "$RUNNER_TEMP/zed-tool-windows-repaired.log" "$output/black-box.log" + + - name: Upload exact patch evidence + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + with: + name: den-2923-windows-sync-repair-${{ github.run_id }} + path: ${{ runner.temp }}/zed-tool-windows-sync-repair + if-no-files-found: error + retention-days: 1 + include-hidden-files: false From ce8680d85bced39203e0e922fa9c856d19e5f6da Mon Sep 17 00:00:00 2001 From: Alexander Mills Date: Sat, 8 Aug 2026 10:22:22 -0500 Subject: [PATCH 14/18] test(DEN-2923): invoke Windows batch tools without literal quotes --- scripts/run_zed_tool_offline_profile.py | 28 ++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/scripts/run_zed_tool_offline_profile.py b/scripts/run_zed_tool_offline_profile.py index 54e6e5d..6446b32 100644 --- a/scripts/run_zed_tool_offline_profile.py +++ b/scripts/run_zed_tool_offline_profile.py @@ -1,15 +1,22 @@ #!/usr/bin/env python3 -"""Run the offline profile canary with checkout-lock bytes normalized away. +"""Run the offline profile canary with durable-lock and Windows normalization. `.zed/operation.lock` is an intentionally durable zed-lock rendezvous point. Creation or diagnostic-content refresh is not project/profile state mutation, so black-box before/after comparisons exclude that one exact path while retaining all other `.zed` state. + +On Windows, Python's argument quoting already protects a batch-file path passed +to `cmd.exe /C`. Adding quote characters to the argument itself makes those +characters part of the command and causes `cmd.exe` to look for a filename that +begins with `"`. The wrapper therefore supplies the path as an ordinary argument +and retains the canonical harness's output assertion. """ from __future__ import annotations import importlib.util +import os import sys from pathlib import Path @@ -24,6 +31,7 @@ SPEC.loader.exec_module(CANARY) _original_snapshot = CANARY.snapshot +_original_execute_installed = CANARY.execute_installed def semantic_snapshot(root: Path): @@ -32,7 +40,25 @@ def semantic_snapshot(root: Path): return rows +def execute_installed(path: Path, os_name: str, transcript: Path) -> None: + if os_name != "windows": + _original_execute_installed(path, os_name, transcript) + return + + environment = os.environ.copy() + shell = environment.get("COMSPEC", "cmd.exe") + output = CANARY.run( + [shell, "/D", "/C", path], + cwd=path.parent, + env=environment, + transcript=transcript, + ) + if output.stdout.strip() != "hello": + raise AssertionError(f"unexpected installed command output: {output.stdout!r}") + + CANARY.snapshot = semantic_snapshot +CANARY.execute_installed = execute_installed if __name__ == "__main__": raise SystemExit(CANARY.main()) From f25d26a72d0ad79050967bcafef0ccd6090f1424 Mon Sep 17 00:00:00 2001 From: Alexander Mills Date: Sat, 8 Aug 2026 10:23:09 -0500 Subject: [PATCH 15/18] ci(DEN-2923): certify complete Windows tool-profile repair --- .../materialize-windows-tool-sync.yml | 29 ++++++++++++++----- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/.github/workflows/materialize-windows-tool-sync.yml b/.github/workflows/materialize-windows-tool-sync.yml index d7bc5db..e4591aa 100644 --- a/.github/workflows/materialize-windows-tool-sync.yml +++ b/.github/workflows/materialize-windows-tool-sync.yml @@ -4,6 +4,7 @@ on: pull_request: paths: - ".github/workflows/materialize-windows-tool-sync.yml" + - "scripts/run_zed_tool_offline_profile.py" workflow_dispatch: permissions: @@ -17,7 +18,7 @@ jobs: materialize: name: exact product patch and black-box proof runs-on: windows-2025 - timeout-minutes: 45 + timeout-minutes: 50 steps: - name: Check out certification harness uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 @@ -57,7 +58,7 @@ jobs: uses: dtolnay/rust-toolchain@4be7066ada62dd38de10e7b70166bc74ed198c30 with: toolchain: stable - components: rustfmt + components: rustfmt,clippy - name: Apply the constrained product repair shell: bash @@ -69,11 +70,24 @@ jobs: path = Path("zed-cli/src/tool_profile.rs") text = path.read_text(encoding="utf-8") - old = """ File::open(destination)?.sync_all()?;\n""" - new = """ OpenOptions::new()\n .write(true)\n .open(destination)\n .with_context(|| {\n format!(\n \"opening copied tool executable `{}` for synchronization\",\n portable_display(destination)\n )\n })?\n .sync_all()\n .with_context(|| {\n format!(\n \"synchronizing copied tool executable `{}`\",\n portable_display(destination)\n )\n })?;\n""" - if text.count(old) != 1: + + old_import = "use std::fs::{self, File, OpenOptions};\n" + new_import = "use std::fs::{self, OpenOptions};\n#[cfg(unix)]\nuse std::fs::File;\n" + if text.count(old_import) != 1: + raise SystemExit("expected exact shared File/OpenOptions import") + text = text.replace(old_import, new_import, 1) + + old_sync = """ File::open(destination)?.sync_all()?;\n""" + new_sync = """ OpenOptions::new()\n .write(true)\n .open(destination)\n .with_context(|| {\n format!(\n \"opening copied tool executable `{}` for synchronization\",\n portable_display(destination)\n )\n })?\n .sync_all()\n .with_context(|| {\n format!(\n \"synchronizing copied tool executable `{}`\",\n portable_display(destination)\n )\n })?;\n""" + if text.count(old_sync) != 1: raise SystemExit("expected exactly one read-only copied-executable sync handle") - text = text.replace(old, new, 1) + text = text.replace(old_sync, new_sync, 1) + + old_default = """ let mut lock = EnvironmentLock::default();\n lock.plan_digest_sha256 = \"a\".repeat(64);\n assert_eq!(select_exact_target(&lock, \"x86_64-linux\").unwrap().len(), 0);\n""" + new_default = """ let lock = EnvironmentLock {\n plan_digest_sha256: \"a\".repeat(64),\n ..EnvironmentLock::default()\n };\n assert_eq!(select_exact_target(&lock, \"x86_64-linux\").unwrap().len(), 0);\n""" + if text.count(old_default) != 1: + raise SystemExit("expected exact Clippy-rejected EnvironmentLock fixture") + text = text.replace(old_default, new_default, 1) marker = """ #[test]\n fn profile_state_is_secret_free_by_shape() {\n let state = ToolProfileState {\n schema: TOOL_PROFILE_SCHEMA_V1.to_string(),\n lock_sha256: \"a\".repeat(64),\n target: \"x86_64-linux\".to_string(),\n tools: Vec::new(),\n };\n let json = serde_json::to_string(&state).unwrap();\n for forbidden in [\"locator\", \"url\", \"token\", \"credential\", \"environment\"] {\n assert!(!json.contains(forbidden));\n }\n }\n}\n""" replacement = marker[:-2] + """\n\n #[cfg(windows)]\n #[test]\n fn copied_windows_executable_is_opened_with_sync_capable_access() {\n let root = tempfile::tempdir().unwrap();\n let source = root.path().join(\"hello.cmd\");\n let destination = root.path().join(\"hello-copy.cmd\");\n fs::write(&source, b\"@echo off\\r\\necho hello\\r\\n\").unwrap();\n\n materialize_executable(&source, &destination).unwrap();\n\n assert_eq!(fs::read(destination).unwrap(), fs::read(source).unwrap());\n }\n}\n""" @@ -86,7 +100,7 @@ jobs: test "$changed" = src/tool_profile.rs git -C zed-cli diff --check - - name: Run focused Rust and compiled CLI contracts + - name: Run focused Rust, compiled CLI, and strict Clippy contracts shell: bash run: | set -euo pipefail @@ -95,6 +109,7 @@ jobs: --lib tool_profile::tests -- --nocapture --test-threads=1 cargo test --locked --manifest-path zed-cli/Cargo.toml \ --test tool_profile_cli -- --nocapture --test-threads=1 + cargo clippy --locked --manifest-path zed-cli/Cargo.toml --all-targets -- -D warnings cargo build --locked --release --manifest-path zed-cli/Cargo.toml --bin zed-tool - name: Re-run the independent Windows black-box contract From a31c6989bebd4225f99df9939b10a377772e9deb Mon Sep 17 00:00:00 2001 From: Alexander Mills Date: Sat, 8 Aug 2026 10:40:05 -0500 Subject: [PATCH 16/18] test(DEN-2923): pin certified Windows tool-profile repair --- .zed-tool-candidate-ref | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.zed-tool-candidate-ref b/.zed-tool-candidate-ref index 68d52e8..b894276 100644 --- a/.zed-tool-candidate-ref +++ b/.zed-tool-candidate-ref @@ -1 +1 @@ -9c325e54a4058c8e55500639f1b18caffa8973c9 +fdaf48d0ee0e132820b8fd69e0d114a365c07745 From b9598815e005eb46cf58b8c389afd8aeea9a6a91 Mon Sep 17 00:00:00 2001 From: Alexander Mills Date: Sat, 8 Aug 2026 10:40:25 -0500 Subject: [PATCH 17/18] test(DEN-2923): remove temporary Windows repair materializer --- .../materialize-windows-tool-sync.yml | 150 ------------------ 1 file changed, 150 deletions(-) delete mode 100644 .github/workflows/materialize-windows-tool-sync.yml diff --git a/.github/workflows/materialize-windows-tool-sync.yml b/.github/workflows/materialize-windows-tool-sync.yml deleted file mode 100644 index e4591aa..0000000 --- a/.github/workflows/materialize-windows-tool-sync.yml +++ /dev/null @@ -1,150 +0,0 @@ -name: materialize Windows zed-tool executable sync repair - -on: - pull_request: - paths: - - ".github/workflows/materialize-windows-tool-sync.yml" - - "scripts/run_zed_tool_offline_profile.py" - workflow_dispatch: - -permissions: - contents: read - -concurrency: - group: materialize-windows-zed-tool-sync-${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: true - -jobs: - materialize: - name: exact product patch and black-box proof - runs-on: windows-2025 - timeout-minutes: 50 - steps: - - name: Check out certification harness - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - with: - path: harness - fetch-depth: 1 - persist-credentials: false - show-progress: false - - - name: Check out exact failing product candidate - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - with: - repository: zed-pkg/zed-cli - ref: 9c325e54a4058c8e55500639f1b18caffa8973c9 - path: zed-cli - fetch-depth: 1 - persist-credentials: false - show-progress: false - - - name: Check out exact shared interfaces - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - with: - repository: zed-pkg/zed-interfaces - ref: a23cdd2ac509a39ca6fd6d21a3774fdd3a0f7660 - path: zed-interfaces - fetch-depth: 1 - persist-credentials: false - show-progress: false - - - name: Install pinned Python runtime - uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v6.0.0 - with: - python-version: "3.12" - check-latest: false - - - name: Install pinned Rust toolchain - uses: dtolnay/rust-toolchain@4be7066ada62dd38de10e7b70166bc74ed198c30 - with: - toolchain: stable - components: rustfmt,clippy - - - name: Apply the constrained product repair - shell: bash - run: | - set -euo pipefail - test "$(git -C zed-cli rev-parse HEAD)" = 9c325e54a4058c8e55500639f1b18caffa8973c9 - python3 - <<'PY' - from pathlib import Path - - path = Path("zed-cli/src/tool_profile.rs") - text = path.read_text(encoding="utf-8") - - old_import = "use std::fs::{self, File, OpenOptions};\n" - new_import = "use std::fs::{self, OpenOptions};\n#[cfg(unix)]\nuse std::fs::File;\n" - if text.count(old_import) != 1: - raise SystemExit("expected exact shared File/OpenOptions import") - text = text.replace(old_import, new_import, 1) - - old_sync = """ File::open(destination)?.sync_all()?;\n""" - new_sync = """ OpenOptions::new()\n .write(true)\n .open(destination)\n .with_context(|| {\n format!(\n \"opening copied tool executable `{}` for synchronization\",\n portable_display(destination)\n )\n })?\n .sync_all()\n .with_context(|| {\n format!(\n \"synchronizing copied tool executable `{}`\",\n portable_display(destination)\n )\n })?;\n""" - if text.count(old_sync) != 1: - raise SystemExit("expected exactly one read-only copied-executable sync handle") - text = text.replace(old_sync, new_sync, 1) - - old_default = """ let mut lock = EnvironmentLock::default();\n lock.plan_digest_sha256 = \"a\".repeat(64);\n assert_eq!(select_exact_target(&lock, \"x86_64-linux\").unwrap().len(), 0);\n""" - new_default = """ let lock = EnvironmentLock {\n plan_digest_sha256: \"a\".repeat(64),\n ..EnvironmentLock::default()\n };\n assert_eq!(select_exact_target(&lock, \"x86_64-linux\").unwrap().len(), 0);\n""" - if text.count(old_default) != 1: - raise SystemExit("expected exact Clippy-rejected EnvironmentLock fixture") - text = text.replace(old_default, new_default, 1) - - marker = """ #[test]\n fn profile_state_is_secret_free_by_shape() {\n let state = ToolProfileState {\n schema: TOOL_PROFILE_SCHEMA_V1.to_string(),\n lock_sha256: \"a\".repeat(64),\n target: \"x86_64-linux\".to_string(),\n tools: Vec::new(),\n };\n let json = serde_json::to_string(&state).unwrap();\n for forbidden in [\"locator\", \"url\", \"token\", \"credential\", \"environment\"] {\n assert!(!json.contains(forbidden));\n }\n }\n}\n""" - replacement = marker[:-2] + """\n\n #[cfg(windows)]\n #[test]\n fn copied_windows_executable_is_opened_with_sync_capable_access() {\n let root = tempfile::tempdir().unwrap();\n let source = root.path().join(\"hello.cmd\");\n let destination = root.path().join(\"hello-copy.cmd\");\n fs::write(&source, b\"@echo off\\r\\necho hello\\r\\n\").unwrap();\n\n materialize_executable(&source, &destination).unwrap();\n\n assert_eq!(fs::read(destination).unwrap(), fs::read(source).unwrap());\n }\n}\n""" - if text.count(marker) != 1: - raise SystemExit("expected exact tool-profile unit-test tail") - path.write_text(text.replace(marker, replacement, 1), encoding="utf-8") - PY - cargo fmt --all --manifest-path zed-cli/Cargo.toml - changed="$(git -C zed-cli diff --name-only)" - test "$changed" = src/tool_profile.rs - git -C zed-cli diff --check - - - name: Run focused Rust, compiled CLI, and strict Clippy contracts - shell: bash - run: | - set -euo pipefail - cargo fmt --all --check --manifest-path zed-cli/Cargo.toml - cargo test --locked --manifest-path zed-cli/Cargo.toml \ - --lib tool_profile::tests -- --nocapture --test-threads=1 - cargo test --locked --manifest-path zed-cli/Cargo.toml \ - --test tool_profile_cli -- --nocapture --test-threads=1 - cargo clippy --locked --manifest-path zed-cli/Cargo.toml --all-targets -- -D warnings - cargo build --locked --release --manifest-path zed-cli/Cargo.toml --bin zed-tool - - - name: Re-run the independent Windows black-box contract - shell: bash - env: - WORK_ROOT: ${{ runner.temp }}/zed-tool-offline-profile-repaired - run: | - set -euo pipefail - test ! -e "$WORK_ROOT" - python harness/scripts/run_zed_tool_offline_profile.py \ - --zed-tool zed-cli/target/release/zed-tool.exe \ - --work-root "$WORK_ROOT" \ - --target x86_64-pc-windows-msvc \ - --os windows \ - --arch x86_64 \ - --candidate 9c325e54a4058c8e55500639f1b18caffa8973c9 \ - 2>&1 | tee "$RUNNER_TEMP/zed-tool-windows-repaired.log" - - - name: Package exact reviewed product bytes - shell: bash - run: | - set -euo pipefail - output="$RUNNER_TEMP/zed-tool-windows-sync-repair" - mkdir -p "$output/src" - cp zed-cli/src/tool_profile.rs "$output/src/tool_profile.rs" - git -C zed-cli diff --binary -- src/tool_profile.rs > "$output/product.patch" - test -s "$output/product.patch" - sha256sum "$output/src/tool_profile.rs" "$output/product.patch" > "$output/SHA256SUMS" - cp "$RUNNER_TEMP/zed-tool-windows-repaired.log" "$output/black-box.log" - - - name: Upload exact patch evidence - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 - with: - name: den-2923-windows-sync-repair-${{ github.run_id }} - path: ${{ runner.temp }}/zed-tool-windows-sync-repair - if-no-files-found: error - retention-days: 1 - include-hidden-files: false From 808daad296bf820b069b74a976fb7b68c4259585 Mon Sep 17 00:00:00 2001 From: Alexander Mills Date: Sat, 8 Aug 2026 10:43:46 -0500 Subject: [PATCH 18/18] test(DEN-2923): pin connector-authored exact candidate --- .zed-tool-candidate-ref | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.zed-tool-candidate-ref b/.zed-tool-candidate-ref index b894276..f77f52d 100644 --- a/.zed-tool-candidate-ref +++ b/.zed-tool-candidate-ref @@ -1 +1 @@ -fdaf48d0ee0e132820b8fd69e0d114a365c07745 +77a19fe3be0520b29e0c2fef2072518a0f6d043b