@@ -380,13 +380,13 @@ require(
380380 needle in unix_installer
381381 for needle in (
382382 "ARCHIVE_MEMBER_COUNT",
383- "EXPECTED_MEMBER_COUNT=5 ",
384- "EXPECTED_MEMBER_COUNT=6 ",
383+ "CORE_MEMBER_SET ",
384+ "CANONICAL_MEMBER_SET ",
385385 "^cbm-ui-[0-9a-f]{64}\\.pack$",
386386 "release archive contains unexpected member",
387387 )
388388 ),
389- "install.sh must validate the exact five -member standard or six-member UI archive ",
389+ "install.sh must validate exact legacy four -member or canonical runtime-asset archives ",
390390)
391391unix_binary_publish = unix_installer.find('"$DLBIN" install "${INSTALL_ARGS[@]}"')
392392require(
@@ -830,6 +830,146 @@ if os.name != "nt" and helper.is_file():
830830 fixture_server.kill()
831831 fixture_server.wait(timeout=3)
832832
833+ def exercise_installer_member_set(variant: str, legacy_four_member: bool) -> None:
834+ with tempfile.TemporaryDirectory(prefix=f"cbm-installer-members-{variant}-") as install_temp:
835+ install_root = pathlib.Path(install_temp)
836+ fixture = install_root / "fixture"
837+ stage = install_root / "stage"
838+ fake_bin = install_root / "fake-bin"
839+ install_dir = install_root / "installed"
840+ fake_home = install_root / "home"
841+ for directory in (fixture, stage, fake_bin, install_dir, fake_home):
842+ directory.mkdir()
843+
844+ candidate = stage / "codebase-memory-mcp"
845+ candidate.write_text(
846+ "#!/usr/bin/env bash\n"
847+ "set -euo pipefail\n"
848+ "case \"${1:-}\" in\n"
849+ " --version) echo 'codebase-memory-mcp member-set fixture';;\n"
850+ " install)\n"
851+ " install_dir=''\n"
852+ " for arg in \"$@\"; do\n"
853+ " case \"$arg\" in --dir=*) install_dir=${arg#--dir=};; esac\n"
854+ " done\n"
855+ " test -n \"$install_dir\"\n"
856+ " cp \"$0\" \"$install_dir/codebase-memory-mcp\"\n"
857+ " chmod 755 \"$install_dir/codebase-memory-mcp\";;\n"
858+ " *) exit 2;;\n"
859+ "esac\n",
860+ encoding="utf-8",
861+ )
862+ candidate.chmod(0o755)
863+ (stage / "LICENSE").write_bytes(b"fixture license\n")
864+ (stage / "THIRD_PARTY_NOTICES.md").write_bytes(b"fixture notices\n")
865+ (stage / "install.sh").write_bytes(b"#!/bin/sh\n# fixture installer\n")
866+ (stage / "cbm-integrations.json").write_bytes(b"{}\n")
867+ pack = b"fixture ui asset pack\n"
868+ pack_name = f"cbm-ui-{hashlib.sha256(pack).hexdigest()}.pack"
869+ (stage / pack_name).write_bytes(pack)
870+
871+ prefix = "codebase-memory-mcp-ui" if variant == "ui" else "codebase-memory-mcp"
872+ archive_name = f"{prefix}-linux-amd64-portable.tar.gz"
873+ archive_path = fixture / archive_name
874+ members = [
875+ "codebase-memory-mcp",
876+ "LICENSE",
877+ "install.sh",
878+ "THIRD_PARTY_NOTICES.md",
879+ ]
880+ if not legacy_four_member:
881+ members.append("cbm-integrations.json")
882+ if variant == "ui":
883+ members.append(pack_name)
884+ with tarfile.open(archive_path, "w:gz") as archive:
885+ for name in members:
886+ archive.add(stage / name, arcname=name)
887+ archive_digest = hashlib.sha256(archive_path.read_bytes()).hexdigest()
888+ (fixture / "checksums.txt").write_text(
889+ f"{archive_digest} {archive_name}\n", encoding="ascii"
890+ )
891+
892+ fake_uname = fake_bin / "uname"
893+ fake_uname.write_text(
894+ "#!/bin/sh\n"
895+ "case \"${1:-}\" in\n"
896+ " -s) echo Linux;;\n"
897+ " -m) echo x86_64;;\n"
898+ " *) echo Linux;;\n"
899+ "esac\n",
900+ encoding="utf-8",
901+ )
902+ fake_uname.chmod(0o755)
903+
904+ port_file = install_root / "port"
905+ server_log = install_root / "server.log"
906+ with server_log.open("wb") as log_handle:
907+ fixture_server = subprocess.Popen(
908+ [
909+ sys.executable,
910+ str(helper),
911+ "--directory",
912+ str(fixture),
913+ "--port-file",
914+ str(port_file),
915+ ],
916+ stdout=log_handle,
917+ stderr=subprocess.STDOUT,
918+ )
919+ try:
920+ port = 0
921+ deadline = time.monotonic() + 30
922+ while time.monotonic() < deadline:
923+ if port_file.is_file():
924+ port_text = port_file.read_text(encoding="ascii").strip()
925+ if port_text:
926+ port = int(port_text)
927+ break
928+ if fixture_server.poll() is not None:
929+ break
930+ time.sleep(0.02)
931+ require(port > 0, "installer member-set fixture server did not publish a port")
932+ if port > 0:
933+ environment = os.environ.copy()
934+ environment["HOME"] = str(fake_home)
935+ environment["PATH"] = (
936+ str(fake_bin) + os.pathsep + environment.get("PATH", "")
937+ )
938+ environment["CBM_DOWNLOAD_URL"] = f"http://127.0.0.1:{port}"
939+ command = [
940+ str(bash_executable),
941+ str(root / "install.sh"),
942+ f"--{variant}",
943+ f"--dir={install_dir}",
944+ "--skip-config",
945+ ]
946+ installed = subprocess.run(
947+ command,
948+ env=environment,
949+ text=True,
950+ stdout=subprocess.PIPE,
951+ stderr=subprocess.STDOUT,
952+ timeout=60,
953+ check=False,
954+ )
955+ shape = "legacy four-member" if legacy_four_member else "canonical"
956+ require(
957+ installed.returncode == 0,
958+ f"install.sh rejected {shape} {variant} release fixture: "
959+ + installed.stdout.strip(),
960+ )
961+ finally:
962+ fixture_server.terminate()
963+ try:
964+ fixture_server.wait(timeout=3)
965+ except subprocess.TimeoutExpired:
966+ fixture_server.kill()
967+ fixture_server.wait(timeout=3)
968+
969+ exercise_installer_member_set("standard", legacy_four_member=True)
970+ exercise_installer_member_set("ui", legacy_four_member=True)
971+ exercise_installer_member_set("ui", legacy_four_member=False)
972+
833973# The complete canonical-matrix extraction, pack parsing, association retention,
834974# byte-exact deduplication and fail-closed malformed-pack cases run above via
835975# test_release_archive_extractor_contract.sh. Keep the packaging-side digest
0 commit comments