forgexa-cli 1.104.1__tar.gz → 1.104.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {forgexa_cli-1.104.1 → forgexa_cli-1.104.3}/PKG-INFO +1 -1
- {forgexa_cli-1.104.1 → forgexa_cli-1.104.3}/forgexa_cli/__init__.py +1 -1
- {forgexa_cli-1.104.1 → forgexa_cli-1.104.3}/forgexa_cli/agent_core.py +89 -2
- {forgexa_cli-1.104.1 → forgexa_cli-1.104.3}/forgexa_cli/daemon.py +109 -44
- {forgexa_cli-1.104.1 → forgexa_cli-1.104.3}/forgexa_cli.egg-info/PKG-INFO +1 -1
- {forgexa_cli-1.104.1 → forgexa_cli-1.104.3}/pyproject.toml +1 -1
- {forgexa_cli-1.104.1 → forgexa_cli-1.104.3}/README.md +0 -0
- {forgexa_cli-1.104.1 → forgexa_cli-1.104.3}/forgexa_cli/_build_config.py +0 -0
- {forgexa_cli-1.104.1 → forgexa_cli-1.104.3}/forgexa_cli/_local_bind.py +0 -0
- {forgexa_cli-1.104.1 → forgexa_cli-1.104.3}/forgexa_cli/autoupgrade.py +0 -0
- {forgexa_cli-1.104.1 → forgexa_cli-1.104.3}/forgexa_cli/aws_evidence.py +0 -0
- {forgexa_cli-1.104.1 → forgexa_cli-1.104.3}/forgexa_cli/aws_logs_evidence.py +0 -0
- {forgexa_cli-1.104.1 → forgexa_cli-1.104.3}/forgexa_cli/code_review_rules.py +0 -0
- {forgexa_cli-1.104.1 → forgexa_cli-1.104.3}/forgexa_cli/component_runtime.py +0 -0
- {forgexa_cli-1.104.1 → forgexa_cli-1.104.3}/forgexa_cli/main.py +0 -0
- {forgexa_cli-1.104.1 → forgexa_cli-1.104.3}/forgexa_cli/observability_contract.py +0 -0
- {forgexa_cli-1.104.1 → forgexa_cli-1.104.3}/forgexa_cli/observability_evidence.py +0 -0
- {forgexa_cli-1.104.1 → forgexa_cli-1.104.3}/forgexa_cli/ocr_adapter.py +0 -0
- {forgexa_cli-1.104.1 → forgexa_cli-1.104.3}/forgexa_cli/py.typed +0 -0
- {forgexa_cli-1.104.1 → forgexa_cli-1.104.3}/forgexa_cli/runtime_evidence.py +0 -0
- {forgexa_cli-1.104.1 → forgexa_cli-1.104.3}/forgexa_cli/workspace_storage.py +0 -0
- {forgexa_cli-1.104.1 → forgexa_cli-1.104.3}/forgexa_cli/zcode_protocol.py +0 -0
- {forgexa_cli-1.104.1 → forgexa_cli-1.104.3}/forgexa_cli.egg-info/SOURCES.txt +0 -0
- {forgexa_cli-1.104.1 → forgexa_cli-1.104.3}/forgexa_cli.egg-info/dependency_links.txt +0 -0
- {forgexa_cli-1.104.1 → forgexa_cli-1.104.3}/forgexa_cli.egg-info/entry_points.txt +0 -0
- {forgexa_cli-1.104.1 → forgexa_cli-1.104.3}/forgexa_cli.egg-info/requires.txt +0 -0
- {forgexa_cli-1.104.1 → forgexa_cli-1.104.3}/forgexa_cli.egg-info/top_level.txt +0 -0
- {forgexa_cli-1.104.1 → forgexa_cli-1.104.3}/setup.cfg +0 -0
- {forgexa_cli-1.104.1 → forgexa_cli-1.104.3}/tests/test_auth_and_runtime_commands.py +0 -0
- {forgexa_cli-1.104.1 → forgexa_cli-1.104.3}/tests/test_autoupgrade.py +0 -0
- {forgexa_cli-1.104.1 → forgexa_cli-1.104.3}/tests/test_check_command.py +0 -0
- {forgexa_cli-1.104.1 → forgexa_cli-1.104.3}/tests/test_delivery_review_packaged.py +0 -0
- {forgexa_cli-1.104.1 → forgexa_cli-1.104.3}/tests/test_expiry_warnings_and_revoke.py +0 -0
- {forgexa_cli-1.104.1 → forgexa_cli-1.104.3}/tests/test_local_bind_commands.py +0 -0
- {forgexa_cli-1.104.1 → forgexa_cli-1.104.3}/tests/test_publish_script.py +0 -0
- {forgexa_cli-1.104.1 → forgexa_cli-1.104.3}/tests/test_runtime_credentials.py +0 -0
- {forgexa_cli-1.104.1 → forgexa_cli-1.104.3}/tests/test_session_credentials.py +0 -0
- {forgexa_cli-1.104.1 → forgexa_cli-1.104.3}/tests/test_silent_install.py +0 -0
- {forgexa_cli-1.104.1 → forgexa_cli-1.104.3}/tests/test_upgrade_observability.py +0 -0
- {forgexa_cli-1.104.1 → forgexa_cli-1.104.3}/tests/test_workspace_storage.py +0 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"""forgexa-cli — Forgexa command-line client."""
|
|
2
|
-
__version__ = "1.104.
|
|
2
|
+
__version__ = "1.104.3"
|
|
@@ -3731,13 +3731,28 @@ DELIVERY_REVIEW_AGENT_IDS = frozenset({
|
|
|
3731
3731
|
"claude", "codebuddy", "codex", "copilot", "deepseek", "gemini", "kimi",
|
|
3732
3732
|
"mimo", "minimax", "opencode", "qoder", "qwen", "trae", "zcode",
|
|
3733
3733
|
})
|
|
3734
|
-
LINUX_DELIVERY_REVIEW_AGENT_IDS = frozenset({"claude", "copilot", "opencode"})
|
|
3735
3734
|
DELIVERY_REVIEW_SENSITIVE_PATTERNS = (
|
|
3736
3735
|
r"/[.]env([.][^/]*)?$", r"[.](pem|key|p12|pfx)$", r"/(id_rsa|id_ed25519)([.][^/]*)?$",
|
|
3737
3736
|
r"/[.]aws/credentials$", r"/[.](npmrc|netrc)$", r"/[.]git(/|$)",
|
|
3738
3737
|
)
|
|
3739
3738
|
|
|
3740
3739
|
|
|
3740
|
+
def delivery_review_candidate(input_data: dict | None, workspace_resolution: str = "cloud_worktree") -> dict | None:
|
|
3741
|
+
data = input_data if isinstance(input_data, dict) else {}
|
|
3742
|
+
candidate = data.get("delivery_review_candidate")
|
|
3743
|
+
if (workspace_resolution != "cloud_worktree" or data.get("task") != "delivery_code_review"
|
|
3744
|
+
or not isinstance(candidate, dict) or type(candidate.get("version")) is not int or candidate["version"] != 1
|
|
3745
|
+
or not isinstance(candidate.get("source_delivery_node_id"), str)
|
|
3746
|
+
or candidate["source_delivery_node_id"] != data.get("source_delivery_node_id")
|
|
3747
|
+
or any(not isinstance(candidate.get(key), str) or not candidate[key] for key in ("repo_identity", "branch", "target_branch"))
|
|
3748
|
+
or any(not isinstance(candidate.get(key), str) or not re.fullmatch(r"[a-f0-9]{40}|[a-f0-9]{64}", candidate[key])
|
|
3749
|
+
for key in ("head_sha", "target_sha"))
|
|
3750
|
+
or any(data.get(field) is not None and data[field] != candidate[key]
|
|
3751
|
+
for field, key in (("delivery_review_expected_head", "head_sha"), ("delivery_review_expected_target", "target_sha")))):
|
|
3752
|
+
return None
|
|
3753
|
+
return candidate
|
|
3754
|
+
|
|
3755
|
+
|
|
3741
3756
|
def delivery_review_sandbox_exec() -> str | None:
|
|
3742
3757
|
if sys.platform not in {"darwin", "linux"}:
|
|
3743
3758
|
return None
|
|
@@ -3747,7 +3762,7 @@ def delivery_review_sandbox_exec() -> str | None:
|
|
|
3747
3762
|
if sys.platform == "linux":
|
|
3748
3763
|
try:
|
|
3749
3764
|
probe = subprocess.run(
|
|
3750
|
-
[executable, "--unshare-all", "--die-with-parent", "--new-session",
|
|
3765
|
+
[executable, "--unshare-all", "--share-net", "--die-with-parent", "--new-session",
|
|
3751
3766
|
"--ro-bind", "/", "/", "--proc", "/proc", "--dev", "/dev", "--", "/bin/true"],
|
|
3752
3767
|
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, timeout=3, check=False,
|
|
3753
3768
|
)
|
|
@@ -3758,6 +3773,66 @@ def delivery_review_sandbox_exec() -> str | None:
|
|
|
3758
3773
|
return executable
|
|
3759
3774
|
|
|
3760
3775
|
|
|
3776
|
+
def delivery_review_linux_command(
|
|
3777
|
+
command: list[str], *, cwd: Path, home: Path, writable: bool = False, network: bool = True,
|
|
3778
|
+
read_paths: list[Path] | None = None, write_paths: list[Path] | None = None,
|
|
3779
|
+
read_only_paths: list[Path] | None = None, deny_paths: list[Path] | None = None,
|
|
3780
|
+
) -> list[str]:
|
|
3781
|
+
sandbox = delivery_review_sandbox_exec()
|
|
3782
|
+
if sys.platform != "linux" or not sandbox:
|
|
3783
|
+
raise RuntimeError("delivery_review_sandbox_unavailable")
|
|
3784
|
+
user_home, workspace, isolated_home = Path.home().resolve(), cwd.resolve(), home.resolve()
|
|
3785
|
+
roots = {path.resolve() for path in (read_paths or [])}
|
|
3786
|
+
writable_roots = {path.resolve() for path in (write_paths or [])}
|
|
3787
|
+
readonly_roots = {path.resolve() for path in (read_only_paths or [])}
|
|
3788
|
+
if (workspace == isolated_home or workspace in isolated_home.parents or isolated_home in workspace.parents
|
|
3789
|
+
or any(path == user_home or path in user_home.parents for path in {workspace, isolated_home, *roots, *writable_roots, *readonly_roots})
|
|
3790
|
+
or not writable and any(path == workspace or path in workspace.parents or workspace in path.parents for path in writable_roots)):
|
|
3791
|
+
raise RuntimeError("delivery_review_sandbox_scope_invalid")
|
|
3792
|
+
wrapped = [sandbox, "--unshare-all", "--die-with-parent", "--new-session", "--cap-drop", "ALL"]
|
|
3793
|
+
if network:
|
|
3794
|
+
wrapped.append("--share-net")
|
|
3795
|
+
for path in (
|
|
3796
|
+
"/usr", "/bin", "/sbin", "/lib", "/lib64", "/etc/ssl/certs", "/etc/ca-certificates", "/etc/pki",
|
|
3797
|
+
"/etc/resolv.conf", "/etc/hosts", "/etc/nsswitch.conf", "/etc/gai.conf", "/etc/localtime",
|
|
3798
|
+
"/etc/passwd", "/etc/group", "/etc/ld.so.cache", "/etc/alternatives",
|
|
3799
|
+
):
|
|
3800
|
+
if Path(path).exists():
|
|
3801
|
+
wrapped += ["--ro-bind", path, path]
|
|
3802
|
+
wrapped += ["--proc", "/proc", "--dev", "/dev", "--tmpfs", "/tmp", "--tmpfs", "/var/tmp"]
|
|
3803
|
+
for path in sorted(roots):
|
|
3804
|
+
if path.exists():
|
|
3805
|
+
if not path.is_dir() and not path.is_file():
|
|
3806
|
+
raise RuntimeError("delivery_review_sandbox_scope_invalid")
|
|
3807
|
+
wrapped += ["--ro-bind", str(path), str(path)]
|
|
3808
|
+
wrapped += ["--bind" if writable else "--ro-bind", str(workspace), str(workspace)]
|
|
3809
|
+
wrapped += ["--bind", str(isolated_home), str(isolated_home)]
|
|
3810
|
+
for path in sorted(writable_roots):
|
|
3811
|
+
if path.exists():
|
|
3812
|
+
wrapped += ["--bind", str(path), str(path)]
|
|
3813
|
+
for path in sorted(readonly_roots):
|
|
3814
|
+
if path.exists():
|
|
3815
|
+
wrapped += ["--ro-bind", str(path), str(path)]
|
|
3816
|
+
protected = {path.resolve() for path in (deny_paths or [])}
|
|
3817
|
+
for root in {workspace, isolated_home, *writable_roots, *readonly_roots, *(path for path in roots if str(path) != "/usr" and not str(path).startswith(("/usr/", "/bin", "/sbin", "/lib")))}:
|
|
3818
|
+
if any(re.search(pattern, str(root)) for pattern in DELIVERY_REVIEW_SENSITIVE_PATTERNS):
|
|
3819
|
+
protected.add(root)
|
|
3820
|
+
continue
|
|
3821
|
+
for directory, directories, files in os.walk(root, followlinks=False):
|
|
3822
|
+
for name in [*directories, *files]:
|
|
3823
|
+
path = Path(directory) / name
|
|
3824
|
+
if any(re.search(pattern, str(path)) for pattern in DELIVERY_REVIEW_SENSITIVE_PATTERNS):
|
|
3825
|
+
protected.add(path)
|
|
3826
|
+
if name in directories:
|
|
3827
|
+
directories.remove(name)
|
|
3828
|
+
for path in sorted(protected):
|
|
3829
|
+
if path.is_dir():
|
|
3830
|
+
wrapped += ["--tmpfs", str(path)]
|
|
3831
|
+
elif path.exists() or path.is_symlink():
|
|
3832
|
+
wrapped += ["--ro-bind", "/dev/null", str(path)]
|
|
3833
|
+
return [*wrapped, "--chdir", str(workspace), "--", *command]
|
|
3834
|
+
|
|
3835
|
+
|
|
3761
3836
|
_OPENCODE_WORKER_DENIED_TOOLS = (
|
|
3762
3837
|
"task", "subagent", "delegate_task", "call_omo_agent",
|
|
3763
3838
|
"background_output", "background_cancel",
|
|
@@ -4180,6 +4255,12 @@ def _minimax_sandbox(
|
|
|
4180
4255
|
if not sandbox:
|
|
4181
4256
|
raise RuntimeError("MiniMax delivery review sandbox is unavailable")
|
|
4182
4257
|
return [sandbox, "-p", "\n".join(profile), *command]
|
|
4258
|
+
if delivery_review:
|
|
4259
|
+
return delivery_review_linux_command(
|
|
4260
|
+
command, cwd=cwd, home=temporary_root, writable=not read_only,
|
|
4261
|
+
read_paths=[root, Path(admission["build"]["package_root"]).parents[1], Path(admission["build"]["node"]).parent.parent],
|
|
4262
|
+
write_paths=[root / "data"], read_only_paths=protected,
|
|
4263
|
+
)
|
|
4183
4264
|
wrapped = ["bwrap", "--die-with-parent", "--new-session", "--ro-bind", "/", "/",
|
|
4184
4265
|
"--tmpfs", str(Path.home()), "--dev", "/dev", "--proc", "/proc"]
|
|
4185
4266
|
for path in (Path(admission["build"]["package_root"]).parents[1],
|
|
@@ -5022,6 +5103,12 @@ def deepseek_harness_sandbox_command(
|
|
|
5022
5103
|
)
|
|
5023
5104
|
return [sandbox, "-p", profile, *command]
|
|
5024
5105
|
if sys.platform == "linux":
|
|
5106
|
+
if delivery_review:
|
|
5107
|
+
return delivery_review_linux_command(
|
|
5108
|
+
command, cwd=cwd, home=home, writable=not read_only,
|
|
5109
|
+
read_paths=[*(read_paths or []), *([credentials_path] if credentials_path else [])],
|
|
5110
|
+
write_paths=[temporary_root], read_only_paths=git_roots,
|
|
5111
|
+
)
|
|
5025
5112
|
sandbox = shutil.which("bwrap")
|
|
5026
5113
|
if not sandbox:
|
|
5027
5114
|
raise RuntimeError("DeepSeek Harness requires a working bubblewrap outer sandbox")
|
|
@@ -1428,7 +1428,7 @@ except (ImportError, ModuleNotFoundError):
|
|
|
1428
1428
|
# DAEMON_VERSION is the protocol/logic version of the daemon code.
|
|
1429
1429
|
# Kept in sync with pyproject.toml version via bump-version.sh.
|
|
1430
1430
|
# CLIENT_TYPE identifies which packaging/distribution this daemon runs in.
|
|
1431
|
-
DAEMON_VERSION = "1.104.
|
|
1431
|
+
DAEMON_VERSION = "1.104.3"
|
|
1432
1432
|
|
|
1433
1433
|
|
|
1434
1434
|
def _detect_client_type() -> str:
|
|
@@ -3963,6 +3963,38 @@ class WorkspaceManager:
|
|
|
3963
3963
|
if task.workspace_resolution == "local_bind":
|
|
3964
3964
|
return await self._bind_local_workspace(project, task, runtime_id=runtime_id)
|
|
3965
3965
|
|
|
3966
|
+
candidate = agent_core.delivery_review_candidate(task.input_data, task.workspace_resolution)
|
|
3967
|
+
if candidate is not None:
|
|
3968
|
+
self._ensure_dirs()
|
|
3969
|
+
project_key, repo_url, _ = self._configure_project_git_auth(project)
|
|
3970
|
+
if _normalize_repo_identity(repo_url) != candidate["repo_identity"] or task.workspace_branch != candidate["branch"]:
|
|
3971
|
+
raise RuntimeError("delivery_review_candidate_changed: repository or branch identity does not match")
|
|
3972
|
+
parent = self.projects_root / ".delivery-reviews"
|
|
3973
|
+
parent.mkdir(parents=True, exist_ok=True)
|
|
3974
|
+
workspace_path = Path(tempfile.mkdtemp(prefix="candidate-", dir=str(parent)))
|
|
3975
|
+
try:
|
|
3976
|
+
await self._git("check-ref-format", f"refs/heads/{candidate['branch']}", cwd=workspace_path, timeout=10)
|
|
3977
|
+
await self._git("check-ref-format", f"refs/heads/{candidate['target_branch']}", cwd=workspace_path, timeout=10)
|
|
3978
|
+
await self._git("init", "--quiet", "--template=", f"--object-format={'sha256' if len(candidate['head_sha']) == 64 else 'sha1'}", cwd=workspace_path, timeout=10)
|
|
3979
|
+
await self._git("config", "core.hooksPath", os.devnull, cwd=workspace_path, timeout=10)
|
|
3980
|
+
await self._git("config", "core.autocrlf", "false", cwd=workspace_path, timeout=10)
|
|
3981
|
+
await self._git("remote", "add", "origin", repo_url, cwd=workspace_path, timeout=10)
|
|
3982
|
+
await self._git("fetch", "--no-tags", "--no-recurse-submodules", "--no-write-fetch-head", "--refmap=",
|
|
3983
|
+
"origin", candidate["head_sha"], candidate["target_sha"],
|
|
3984
|
+
cwd=workspace_path, timeout=120, project_key=project_key)
|
|
3985
|
+
await self._git("update-ref", f"refs/remotes/origin/{candidate['target_branch']}", candidate["target_sha"], cwd=workspace_path, timeout=10)
|
|
3986
|
+
await self._git("checkout", "--quiet", "-b", candidate["branch"], candidate["head_sha"], cwd=workspace_path, timeout=60)
|
|
3987
|
+
for commit_sha in task.required_commit_shas:
|
|
3988
|
+
if not isinstance(commit_sha, str) or not re.fullmatch(r"[a-f0-9]{40}|[a-f0-9]{64}", commit_sha):
|
|
3989
|
+
raise ValueError("Invalid predecessor commit")
|
|
3990
|
+
await self._git("merge-base", "--is-ancestor", commit_sha, candidate["head_sha"], cwd=workspace_path, timeout=10)
|
|
3991
|
+
return workspace_path
|
|
3992
|
+
except BaseException as error:
|
|
3993
|
+
shutil.rmtree(workspace_path, ignore_errors=True)
|
|
3994
|
+
if isinstance(error, (OSError, RuntimeError, ValueError, UnicodeError)):
|
|
3995
|
+
raise RuntimeError("delivery_review_candidate_unavailable: the fixed commits could not be reconstructed with authorized project access") from None
|
|
3996
|
+
raise
|
|
3997
|
+
|
|
3966
3998
|
if (task.input_data or {}).get("task") in ("delivery_code_review", "delivery_review_fix", "delivery_review_retest"):
|
|
3967
3999
|
project_key = str(project.get("project_key") or "default")
|
|
3968
4000
|
if not re.fullmatch(r"[a-zA-Z0-9_-]+", project_key):
|
|
@@ -6314,8 +6346,8 @@ class WorkspaceManager:
|
|
|
6314
6346
|
return ws_path
|
|
6315
6347
|
|
|
6316
6348
|
async def cleanup_workspace(self, workspace_path: Path):
|
|
6317
|
-
|
|
6318
|
-
|
|
6349
|
+
if workspace_path.parent.resolve() == (self.projects_root / ".delivery-reviews").resolve():
|
|
6350
|
+
shutil.rmtree(workspace_path, ignore_errors=True)
|
|
6319
6351
|
|
|
6320
6352
|
async def _git(self, *args: str, cwd: Path | str | None = None, timeout: int | None = None,
|
|
6321
6353
|
project_key: str | None = None) -> str:
|
|
@@ -6624,7 +6656,8 @@ def _delivery_review_capabilities() -> dict:
|
|
|
6624
6656
|
return {"delivery_code_review": {
|
|
6625
6657
|
"protocol_version": 2,
|
|
6626
6658
|
"ocr_delegation_version": 1,
|
|
6627
|
-
"
|
|
6659
|
+
"candidate_snapshot_version": 1,
|
|
6660
|
+
"agent_ids": sorted(agent_core.DELIVERY_REVIEW_AGENT_IDS),
|
|
6628
6661
|
}}
|
|
6629
6662
|
return {}
|
|
6630
6663
|
|
|
@@ -6696,39 +6729,10 @@ def _delivery_review_sandbox_command(command: list[str], workspace: Path, home:
|
|
|
6696
6729
|
if any(Path(root) == user_home_path or Path(root) in user_home_path.parents for root in read_roots):
|
|
6697
6730
|
raise RuntimeError("delivery_review_sandbox_scope_invalid")
|
|
6698
6731
|
if sys.platform == "linux":
|
|
6699
|
-
|
|
6700
|
-
|
|
6701
|
-
|
|
6702
|
-
system_paths = (
|
|
6703
|
-
"/usr", "/bin", "/sbin", "/lib", "/lib64", "/etc/ssl/certs", "/etc/ca-certificates",
|
|
6704
|
-
"/etc/pki", "/etc/resolv.conf", "/etc/hosts", "/etc/nsswitch.conf", "/etc/gai.conf",
|
|
6705
|
-
"/etc/localtime", "/etc/passwd", "/etc/group", "/etc/ld.so.cache", "/etc/alternatives",
|
|
6732
|
+
return agent_core.delivery_review_linux_command(
|
|
6733
|
+
command, cwd=workspace_path, home=home_path, writable=writable, network=network,
|
|
6734
|
+
read_paths=[Path(root) for root in read_roots], deny_paths=deny_paths,
|
|
6706
6735
|
)
|
|
6707
|
-
for path in system_paths:
|
|
6708
|
-
if Path(path).exists():
|
|
6709
|
-
wrapped += ["--ro-bind", path, path]
|
|
6710
|
-
wrapped += ["--proc", "/proc", "--dev", "/dev", "--tmpfs", "/tmp", "--tmpfs", "/var/tmp"]
|
|
6711
|
-
for root in sorted(read_roots):
|
|
6712
|
-
if not Path(root).is_dir():
|
|
6713
|
-
raise RuntimeError("delivery_review_sandbox_scope_invalid")
|
|
6714
|
-
wrapped += ["--ro-bind", root, root]
|
|
6715
|
-
wrapped += ["--bind" if writable else "--ro-bind", str(workspace_path), str(workspace_path)]
|
|
6716
|
-
wrapped += ["--bind", str(home_path), str(home_path)]
|
|
6717
|
-
protected = {path.absolute() for path in (deny_paths or [])}
|
|
6718
|
-
for root in (workspace_path, home_path, *(Path(path) for path in read_roots if not str(path).startswith(("/usr/", "/bin", "/sbin", "/lib")))):
|
|
6719
|
-
for directory, directories, files in os.walk(root, followlinks=False):
|
|
6720
|
-
for name in [*directories, *files]:
|
|
6721
|
-
path = Path(directory) / name
|
|
6722
|
-
if any(re.search(pattern, str(path)) for pattern in agent_core.DELIVERY_REVIEW_SENSITIVE_PATTERNS):
|
|
6723
|
-
protected.add(path)
|
|
6724
|
-
if name in directories:
|
|
6725
|
-
directories.remove(name)
|
|
6726
|
-
for path in sorted(protected):
|
|
6727
|
-
if path.is_dir():
|
|
6728
|
-
wrapped += ["--tmpfs", str(path)]
|
|
6729
|
-
elif path.exists() or path.is_symlink():
|
|
6730
|
-
wrapped += ["--ro-bind", "/dev/null", str(path)]
|
|
6731
|
-
return [*wrapped, "--chdir", str(workspace_path), "--", *command]
|
|
6732
6736
|
executable_rules = " ".join(f"(subpath {json.dumps(root)})" for root in sorted(read_roots))
|
|
6733
6737
|
metadata_paths = {
|
|
6734
6738
|
str(parent) for root in [*read_roots, str(workspace.resolve()), str(home.resolve())]
|
|
@@ -14023,6 +14027,7 @@ class RuntimeDaemon:
|
|
|
14023
14027
|
workspace_execution_lock: _WorkspaceFileLock | None = None
|
|
14024
14028
|
local_bind_file_lock = None
|
|
14025
14029
|
attachment_staging_dir: Path | None = None
|
|
14030
|
+
workspace_path: Path | None = None
|
|
14026
14031
|
if is_local_bind and task.local_workspace_binding_id:
|
|
14027
14032
|
# OS-level file lock keyed by binding_id (docs/designs/forgexa-
|
|
14028
14033
|
# ide-design.md §6.3): the DB lease (orchestrator.py) prevents
|
|
@@ -15028,6 +15033,8 @@ class RuntimeDaemon:
|
|
|
15028
15033
|
finally:
|
|
15029
15034
|
if self.managed_policy is not None:
|
|
15030
15035
|
await self.managed_policy.finish_task()
|
|
15036
|
+
if workspace_path is not None and agent_core.delivery_review_candidate(task.input_data, task.workspace_resolution) is not None:
|
|
15037
|
+
await self.workspace_manager.cleanup_workspace(workspace_path)
|
|
15031
15038
|
if attachment_staging_dir is not None:
|
|
15032
15039
|
shutil.rmtree(attachment_staging_dir, ignore_errors=True)
|
|
15033
15040
|
if workspace_execution_lock is not None:
|
|
@@ -15260,11 +15267,15 @@ class RuntimeDaemon:
|
|
|
15260
15267
|
|
|
15261
15268
|
async def _execute_delivery_code_review(self, task, agent, workspace_path) -> TaskResult:
|
|
15262
15269
|
engine_identity = None
|
|
15270
|
+
preparation_failure = None
|
|
15263
15271
|
|
|
15264
15272
|
def failed(code: str, message: str) -> TaskResult:
|
|
15265
15273
|
return TaskResult(status="failed", exit_code=-1, stdout="", stderr="", failure_code=code,
|
|
15266
15274
|
error=message, execution_attempt_id=task.execution_attempt_id,
|
|
15267
|
-
metrics={
|
|
15275
|
+
metrics={
|
|
15276
|
+
**({"delivery_review_engine_identity": engine_identity} if engine_identity else {}),
|
|
15277
|
+
**({"delivery_review_preparation": preparation_failure} if preparation_failure else {}),
|
|
15278
|
+
})
|
|
15268
15279
|
|
|
15269
15280
|
def remember_identity(identity):
|
|
15270
15281
|
nonlocal engine_identity
|
|
@@ -15305,16 +15316,20 @@ class RuntimeDaemon:
|
|
|
15305
15316
|
if not task.workspace_branch or not default_branch or default_branch.startswith("-"):
|
|
15306
15317
|
return failed("delivery_review_scope_incomplete", "The candidate or target branch is unavailable")
|
|
15307
15318
|
|
|
15319
|
+
preparation_stage = "workspace_branch"
|
|
15308
15320
|
try:
|
|
15309
15321
|
branch = (await self.workspace_manager._git("branch", "--show-current", cwd=workspace_path, timeout=10)).strip()
|
|
15322
|
+
preparation_stage = "candidate_head"
|
|
15310
15323
|
head = (await self.workspace_manager._git("rev-parse", "--verify", "HEAD^{commit}", cwd=workspace_path, timeout=10)).strip()
|
|
15324
|
+
preparation_stage = "workspace_status"
|
|
15311
15325
|
dirty = await self.workspace_manager._git(
|
|
15312
15326
|
"--no-optional-locks", "status", "--porcelain=v1", "-z", "--untracked-files=no", cwd=workspace_path, timeout=10,
|
|
15313
15327
|
)
|
|
15314
|
-
if branch != task.workspace_branch or not re.fullmatch(r"[0-9a-f]{40}", head) or dirty:
|
|
15328
|
+
if branch != task.workspace_branch or not re.fullmatch(r"[0-9a-f]{40}|[0-9a-f]{64}", head) or dirty:
|
|
15315
15329
|
return failed("delivery_review_candidate_changed", "The candidate branch or workspace changed")
|
|
15316
15330
|
target_ref = ""
|
|
15317
15331
|
target = ""
|
|
15332
|
+
preparation_stage = "target_ref"
|
|
15318
15333
|
for candidate in (f"refs/remotes/origin/{default_branch}", f"refs/heads/{default_branch}"):
|
|
15319
15334
|
try:
|
|
15320
15335
|
target = (await self.workspace_manager._git(
|
|
@@ -15324,13 +15339,44 @@ class RuntimeDaemon:
|
|
|
15324
15339
|
break
|
|
15325
15340
|
except RuntimeError:
|
|
15326
15341
|
continue
|
|
15327
|
-
if not target_ref or not re.fullmatch(r"[0-9a-f]{40}", target):
|
|
15342
|
+
if not target_ref or not re.fullmatch(r"[0-9a-f]{40}|[0-9a-f]{64}", target):
|
|
15328
15343
|
return failed("delivery_review_scope_incomplete", "The target branch cannot be resolved")
|
|
15329
|
-
|
|
15330
|
-
|
|
15344
|
+
candidate = agent_core.delivery_review_candidate(task.input_data, task.workspace_resolution) or {}
|
|
15345
|
+
expected_head = (task.input_data or {}).get("delivery_review_expected_head") or candidate.get("head_sha")
|
|
15346
|
+
expected_target = (task.input_data or {}).get("delivery_review_expected_target") or candidate.get("target_sha")
|
|
15331
15347
|
if (expected_head is not None and expected_head != head) or (expected_target is not None and expected_target != target):
|
|
15332
15348
|
return failed("delivery_review_candidate_changed", "The local workspace does not match the requested review version")
|
|
15333
|
-
|
|
15349
|
+
preparation_stage = "merge_base"
|
|
15350
|
+
try:
|
|
15351
|
+
base = (await self.workspace_manager._git("merge-base", target, head, cwd=workspace_path, timeout=10)).strip()
|
|
15352
|
+
except RuntimeError:
|
|
15353
|
+
if task.workspace_resolution != "cloud_worktree":
|
|
15354
|
+
raise
|
|
15355
|
+
shallow = (await self.workspace_manager._git(
|
|
15356
|
+
"rev-parse", "--is-shallow-repository", cwd=workspace_path, timeout=10,
|
|
15357
|
+
)).strip()
|
|
15358
|
+
if shallow != "true":
|
|
15359
|
+
raise
|
|
15360
|
+
await self.workspace_manager._git("check-ref-format", f"refs/heads/{default_branch}", cwd=workspace_path, timeout=10)
|
|
15361
|
+
for deepen in (128, 512):
|
|
15362
|
+
preparation_stage = "history_fetch"
|
|
15363
|
+
await self.workspace_manager._git(
|
|
15364
|
+
"fetch", "--no-tags", "--no-recurse-submodules", "--no-write-fetch-head", "--refmap=",
|
|
15365
|
+
f"--deepen={deepen}", "origin", f"refs/heads/{default_branch}", f"refs/heads/{branch}",
|
|
15366
|
+
cwd=workspace_path, timeout=60, project_key=(task.project or {}).get("project_key"),
|
|
15367
|
+
)
|
|
15368
|
+
preparation_stage = "merge_base"
|
|
15369
|
+
try:
|
|
15370
|
+
base = (await self.workspace_manager._git("merge-base", target, head, cwd=workspace_path, timeout=10)).strip()
|
|
15371
|
+
break
|
|
15372
|
+
except RuntimeError:
|
|
15373
|
+
if deepen == 512:
|
|
15374
|
+
raise
|
|
15375
|
+
current_head = (await self.workspace_manager._git("rev-parse", "--verify", "HEAD^{commit}", cwd=workspace_path, timeout=10)).strip()
|
|
15376
|
+
current_target = (await self.workspace_manager._git("rev-parse", "--verify", f"{target_ref}^{{commit}}", cwd=workspace_path, timeout=10)).strip()
|
|
15377
|
+
if current_head != head or current_target != target:
|
|
15378
|
+
return failed("delivery_review_candidate_changed", "The candidate or target changed while resolving review history")
|
|
15379
|
+
preparation_stage = "changed_files"
|
|
15334
15380
|
changed = await self.workspace_manager._git(
|
|
15335
15381
|
"diff", "--no-ext-diff", "--no-textconv", "--no-renames", "--name-only", "-z",
|
|
15336
15382
|
base, head, "--", cwd=workspace_path, timeout=60,
|
|
@@ -15338,6 +15384,7 @@ class RuntimeDaemon:
|
|
|
15338
15384
|
paths = [path for path in changed.split("\x00") if path]
|
|
15339
15385
|
if len(paths) > 200 or any(_is_sensitive_local_path(path) for path in paths):
|
|
15340
15386
|
return failed("delivery_review_scope_incomplete", "The changed-file scope exceeds review limits")
|
|
15387
|
+
preparation_stage = "candidate_diff"
|
|
15341
15388
|
diff = await self.workspace_manager._git(
|
|
15342
15389
|
"diff", "--no-ext-diff", "--no-textconv", "--no-renames", "--unified=3",
|
|
15343
15390
|
base, head, "--", cwd=workspace_path, timeout=60,
|
|
@@ -15349,6 +15396,7 @@ class RuntimeDaemon:
|
|
|
15349
15396
|
batches = []
|
|
15350
15397
|
batch_paths, batch_diff = [], ""
|
|
15351
15398
|
for path in paths:
|
|
15399
|
+
preparation_stage = "file_diff"
|
|
15352
15400
|
file_diff = await self.workspace_manager._git(
|
|
15353
15401
|
"--literal-pathspecs", "diff", "--no-ext-diff", "--no-textconv", "--no-renames", "--unified=3",
|
|
15354
15402
|
base, head, "--", path, cwd=workspace_path, timeout=60,
|
|
@@ -15365,8 +15413,25 @@ class RuntimeDaemon:
|
|
|
15365
15413
|
if len(batches) > 8:
|
|
15366
15414
|
return failed("delivery_review_scope_incomplete", "The complete diff requires too many review batches")
|
|
15367
15415
|
except (OSError, RuntimeError, ValueError, UnicodeError) as error:
|
|
15368
|
-
|
|
15369
|
-
|
|
15416
|
+
detail = str(error).lower()
|
|
15417
|
+
reason = "git_command_failed"
|
|
15418
|
+
for category, pattern in (
|
|
15419
|
+
("git_timeout", r"timed out|timeout"),
|
|
15420
|
+
("git_resource_exhausted", r"cannot allocate memory|unable to mmap|out of memory"),
|
|
15421
|
+
("git_access_denied", r"permission denied|dubious ownership|authentication failed|could not read username"),
|
|
15422
|
+
("git_object_unavailable", r"bad object|not a valid|unknown revision|invalid object|unable to read|missing blob|bad tree|corrupt"),
|
|
15423
|
+
("git_history_unavailable", r"no merge base|no merge-base|unrelated histories"),
|
|
15424
|
+
):
|
|
15425
|
+
if re.search(pattern, detail):
|
|
15426
|
+
reason = category
|
|
15427
|
+
break
|
|
15428
|
+
if isinstance(error, UnicodeError):
|
|
15429
|
+
reason = "git_output_encoding"
|
|
15430
|
+
elif preparation_stage == "merge_base" and reason == "git_command_failed":
|
|
15431
|
+
reason = "git_history_unavailable"
|
|
15432
|
+
preparation_failure = {"stage": preparation_stage, "reason": reason, "error_type": type(error).__name__}
|
|
15433
|
+
logger.warning("Cannot prepare delivery review scope (stage=%s, reason=%s, type=%s)", preparation_stage, reason, type(error).__name__)
|
|
15434
|
+
return failed("delivery_review_scope_incomplete", f"The complete candidate diff is unavailable (stage={preparation_stage}; reason={reason}). Resolve the original workspace's Git prerequisite before retrying; switching Agent cannot fix this preparation failure.")
|
|
15370
15435
|
|
|
15371
15436
|
metadata = {"version": protocol, "base_sha": base, "target_sha": target, "head_sha": head,
|
|
15372
15437
|
"changed_files": paths, "reviewed_batches": [batch_paths for batch_paths, _ in batches] if paths else []}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|