feat(deploy): build active comment reader overlays

This commit is contained in:
Codex
2026-08-22 00:36:45 +03:00
parent fe4dad0af5
commit a30da1938c
2 changed files with 234 additions and 0 deletions
@@ -0,0 +1,97 @@
#!/usr/bin/env python3
import hashlib
import importlib.machinery
import importlib.util
import json
import os
import subprocess
import tempfile
import unittest
from pathlib import Path
SCRIPT_DIR = Path(__file__).resolve().parent
PLATFORM_ROOT = SCRIPT_DIR.parent.parent
BUILDER_PATH = SCRIPT_DIR / "build-tasker-ops-comments-read-artifacts.mjs"
RUNNER_PATH = SCRIPT_DIR / "nodedc-deploy"
RELEASE = "20260822-003"
def load_runner():
loader = importlib.machinery.SourceFileLoader("nodedc_comments_read_runner", str(RUNNER_PATH))
spec = importlib.util.spec_from_loader(loader.name, loader)
module = importlib.util.module_from_spec(spec)
loader.exec_module(module)
return module
RUNNER = load_runner()
class TaskerOpsCommentsReadArtifactTest(unittest.TestCase):
@classmethod
def setUpClass(cls):
cls.temporary = tempfile.TemporaryDirectory(prefix="nodedc-comments-read-")
cls.root = Path(cls.temporary.name)
cls.builds = []
for index in range(2):
output = cls.root / f"build-{index}"
output.mkdir()
env = os.environ.copy()
env["NODEDC_DEPLOY_ARTIFACT_DIR"] = str(output)
result = subprocess.run(
["node", str(BUILDER_PATH), RELEASE],
cwd=PLATFORM_ROOT,
env=env,
check=True,
capture_output=True,
text=True,
)
cls.builds.append(json.loads(result.stdout))
@classmethod
def tearDownClass(cls):
cls.temporary.cleanup()
def artifact(self, build_index, component):
return next(item for item in self.builds[build_index]["artifacts"] if item["component"] == component)
def test_artifacts_are_reproducible_and_runner_accepted(self):
self.assertEqual(self.builds[0]["deployOrder"], ["tasker", "ops-agents"])
for component in ("tasker", "ops-agents"):
first = self.artifact(0, component)
second = self.artifact(1, component)
first_path = Path(first["artifact"])
second_path = Path(second["artifact"])
first_bytes = first_path.read_bytes()
self.assertEqual(first_bytes, second_path.read_bytes())
self.assertEqual(first_bytes[4:8], bytes(4))
self.assertEqual(first["sha256"], hashlib.sha256(first_bytes).hexdigest())
with tempfile.TemporaryDirectory() as directory:
manifest, entries, payload = RUNNER.load_artifact(first_path, Path(directory))
self.assertEqual(manifest["component"], component)
self.assertEqual(manifest["id"], first["patchId"])
self.assertEqual(entries, first["files"])
for relative_path in entries:
self.assertTrue((payload / relative_path).is_file())
def test_tasker_overlay_contains_only_active_comment_reader(self):
tasker = self.artifact(0, "tasker")
self.assertEqual(tasker["sourceCommit"], "7f97c21886ff7dff314db89aa1877e2113e5570b")
self.assertEqual(
tasker["files"],
["plane-src/apps/api/plane/authentication/views/nodedc_agent_adapter.py"],
)
def test_ops_agents_overlay_contains_only_active_comment_reader(self):
ops_agents = self.artifact(0, "ops-agents")
self.assertEqual(ops_agents["sourceCommit"], "6b63049d79eb975372d9f6a01cc32684563678a8")
self.assertEqual(
set(ops_agents["files"]),
{"src/mcp/tool-runtime.ts", "src/routes/tools.ts", "src/tasker/client.ts"},
)
if __name__ == "__main__":
unittest.main(verbosity=2)