Add the Remote manifest and review packaging
remote/tentacle.toml declares protocol 1.1 with all six remote grants, and make check validates it with the reader's negotiation rules. The packager builds cmd/<id> mains and can package a manifest-only Tentacle into the generated review catalog; the committed catalog is unchanged until a verified release is published. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
764d2c1e9e
commit
5d6801a71b
5 files changed
+71
-6
No files matched your search
@@ -3,6 +3,7 @@
|
||||
"""Check the repository and the built Tentacle without running a reader."""
|
||||
|
||||
import json
|
||||
import sys
|
||||
import hashlib
|
||||
import os
|
||||
from pathlib import Path
|
||||
@@ -154,9 +155,28 @@ def check_host(repoRoot, programPath, name):
|
||||
}, "The actual host returned an unexpected greeting")
|
||||
|
||||
|
||||
def check_remote_manifest(repoRoot, readerRoot):
|
||||
"""Remote is not in the catalog until a release is published and verified."""
|
||||
manifest = read_toml(repoRoot / "remote/tentacle.toml")
|
||||
require(manifest["format-version"] == 1 and manifest["id"] == "remote" and manifest["name"] == "Remote"
|
||||
and manifest["runtime"] == "native" and manifest["platforms"] == ["linux"]
|
||||
and manifest["entry-point"] == ["bin/remote"]
|
||||
and manifest["protocol"] == {"major": 1, "minor": 1}, "Invalid Remote manifest")
|
||||
require((repoRoot / "remote/LICENSE").is_file() and (repoRoot / "remote/README.md").is_file(),
|
||||
"Remote license and help are required")
|
||||
script = ("import json,sys; sys.path.insert(0, sys.argv[1]); "
|
||||
"from cthulhu_tentacle.session import valid_negotiation; "
|
||||
"print(json.dumps(valid_negotiation(json.loads(sys.argv[2]), json.loads(sys.argv[3]))))")
|
||||
result = subprocess.run([sys.executable, "-I", "-c", script, str(readerRoot / "sdk/python"),
|
||||
json.dumps(manifest["apis"]), json.dumps(manifest["capabilities"])],
|
||||
capture_output=True, text=True, timeout=30, check=True)
|
||||
require(json.loads(result.stdout) is True, "Remote manifest APIs and grants fail reader negotiation")
|
||||
|
||||
|
||||
def check_remote(repoRoot):
|
||||
programPath = repoRoot / "remote/bin/remote"
|
||||
readerRoot = repoRoot.parent / "cthulhu"
|
||||
check_remote_manifest(repoRoot, readerRoot)
|
||||
environment = os.environ.copy()
|
||||
environment["CTHULHU_REMOTE_BINARY"] = str(programPath)
|
||||
with tempfile.TemporaryDirectory(prefix="cthulhu-remote-check-") as directory:
|
||||
|
||||
+10
-3
@@ -24,8 +24,10 @@ def build_package(repoRoot, architecture, version, name):
|
||||
programPath = distRoot / f"{name}-linux-{architecture}"
|
||||
environment = dict(os.environ, CGO_ENABLED="0", GOOS="linux", GOARCH=architecture)
|
||||
environment.setdefault("GOCACHE", "/tmp/cthulhu-cache")
|
||||
# A Tentacle with a cmd/<id> main builds that; others build their src package.
|
||||
mainPackage = f"./{name}/cmd/{name}" if (sourceRoot / "cmd" / name).is_dir() else f"./{name}/src"
|
||||
subprocess.run(["go", "build", "-buildvcs=false", "-mod=readonly", "-trimpath",
|
||||
"-ldflags=-s -w", "-o", str(programPath), f"./{name}/src"],
|
||||
"-ldflags=-s -w", "-o", str(programPath), mainPackage],
|
||||
cwd=repoRoot, env=environment, check=True)
|
||||
artifactPath = distRoot / f"{name}-{version}-linux-{architecture}.tar.gz"
|
||||
with artifactPath.open("wb") as output:
|
||||
@@ -60,8 +62,13 @@ def main():
|
||||
catalog = tomllib.loads((repoRoot / "catalog.toml").read_text())
|
||||
names = [item["id"] for item in catalog["tentacles"]]
|
||||
selected = args.tentacle or ["hello-world"]
|
||||
if len(set(selected)) != len(selected) or any(name not in names for name in selected):
|
||||
parser.error("Select distinct Tentacle IDs from catalog.toml")
|
||||
# A Tentacle with a manifest but no published release (such as Remote before
|
||||
# its first release) can be packaged for review; it appears only in the
|
||||
# generated dist/catalog.toml, never in the committed catalog.
|
||||
unpublished = [name for name in selected if name not in names and (repoRoot / name / "tentacle.toml").is_file()]
|
||||
if len(set(selected)) != len(selected) or any(name not in names and name not in unpublished for name in selected):
|
||||
parser.error("Select distinct Tentacle IDs from catalog.toml or with a tentacle.toml")
|
||||
catalog["tentacles"] = catalog["tentacles"] + [{"id": name, "manifest": f"{name}/tentacle.toml"} for name in unpublished]
|
||||
lines = ["format-version = 1"]
|
||||
checksums = []
|
||||
for item in catalog["tentacles"]:
|
||||
|
||||
Reference in new issue
Block a user