forgexa-cli 1.104.3__tar.gz → 1.105.0__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.3 → forgexa_cli-1.105.0}/PKG-INFO +1 -1
- {forgexa_cli-1.104.3 → forgexa_cli-1.105.0}/forgexa_cli/__init__.py +1 -1
- {forgexa_cli-1.104.3 → forgexa_cli-1.105.0}/forgexa_cli/agent_core.py +21 -1
- {forgexa_cli-1.104.3 → forgexa_cli-1.105.0}/forgexa_cli/daemon.py +133 -53
- {forgexa_cli-1.104.3 → forgexa_cli-1.105.0}/forgexa_cli.egg-info/PKG-INFO +1 -1
- {forgexa_cli-1.104.3 → forgexa_cli-1.105.0}/pyproject.toml +1 -1
- {forgexa_cli-1.104.3 → forgexa_cli-1.105.0}/README.md +0 -0
- {forgexa_cli-1.104.3 → forgexa_cli-1.105.0}/forgexa_cli/_build_config.py +0 -0
- {forgexa_cli-1.104.3 → forgexa_cli-1.105.0}/forgexa_cli/_local_bind.py +0 -0
- {forgexa_cli-1.104.3 → forgexa_cli-1.105.0}/forgexa_cli/autoupgrade.py +0 -0
- {forgexa_cli-1.104.3 → forgexa_cli-1.105.0}/forgexa_cli/aws_evidence.py +0 -0
- {forgexa_cli-1.104.3 → forgexa_cli-1.105.0}/forgexa_cli/aws_logs_evidence.py +0 -0
- {forgexa_cli-1.104.3 → forgexa_cli-1.105.0}/forgexa_cli/code_review_rules.py +0 -0
- {forgexa_cli-1.104.3 → forgexa_cli-1.105.0}/forgexa_cli/component_runtime.py +0 -0
- {forgexa_cli-1.104.3 → forgexa_cli-1.105.0}/forgexa_cli/main.py +0 -0
- {forgexa_cli-1.104.3 → forgexa_cli-1.105.0}/forgexa_cli/observability_contract.py +0 -0
- {forgexa_cli-1.104.3 → forgexa_cli-1.105.0}/forgexa_cli/observability_evidence.py +0 -0
- {forgexa_cli-1.104.3 → forgexa_cli-1.105.0}/forgexa_cli/ocr_adapter.py +0 -0
- {forgexa_cli-1.104.3 → forgexa_cli-1.105.0}/forgexa_cli/py.typed +0 -0
- {forgexa_cli-1.104.3 → forgexa_cli-1.105.0}/forgexa_cli/runtime_evidence.py +0 -0
- {forgexa_cli-1.104.3 → forgexa_cli-1.105.0}/forgexa_cli/workspace_storage.py +0 -0
- {forgexa_cli-1.104.3 → forgexa_cli-1.105.0}/forgexa_cli/zcode_protocol.py +0 -0
- {forgexa_cli-1.104.3 → forgexa_cli-1.105.0}/forgexa_cli.egg-info/SOURCES.txt +0 -0
- {forgexa_cli-1.104.3 → forgexa_cli-1.105.0}/forgexa_cli.egg-info/dependency_links.txt +0 -0
- {forgexa_cli-1.104.3 → forgexa_cli-1.105.0}/forgexa_cli.egg-info/entry_points.txt +0 -0
- {forgexa_cli-1.104.3 → forgexa_cli-1.105.0}/forgexa_cli.egg-info/requires.txt +0 -0
- {forgexa_cli-1.104.3 → forgexa_cli-1.105.0}/forgexa_cli.egg-info/top_level.txt +0 -0
- {forgexa_cli-1.104.3 → forgexa_cli-1.105.0}/setup.cfg +0 -0
- {forgexa_cli-1.104.3 → forgexa_cli-1.105.0}/tests/test_auth_and_runtime_commands.py +0 -0
- {forgexa_cli-1.104.3 → forgexa_cli-1.105.0}/tests/test_autoupgrade.py +0 -0
- {forgexa_cli-1.104.3 → forgexa_cli-1.105.0}/tests/test_check_command.py +0 -0
- {forgexa_cli-1.104.3 → forgexa_cli-1.105.0}/tests/test_delivery_review_packaged.py +0 -0
- {forgexa_cli-1.104.3 → forgexa_cli-1.105.0}/tests/test_expiry_warnings_and_revoke.py +0 -0
- {forgexa_cli-1.104.3 → forgexa_cli-1.105.0}/tests/test_local_bind_commands.py +0 -0
- {forgexa_cli-1.104.3 → forgexa_cli-1.105.0}/tests/test_publish_script.py +0 -0
- {forgexa_cli-1.104.3 → forgexa_cli-1.105.0}/tests/test_runtime_credentials.py +0 -0
- {forgexa_cli-1.104.3 → forgexa_cli-1.105.0}/tests/test_session_credentials.py +0 -0
- {forgexa_cli-1.104.3 → forgexa_cli-1.105.0}/tests/test_silent_install.py +0 -0
- {forgexa_cli-1.104.3 → forgexa_cli-1.105.0}/tests/test_upgrade_observability.py +0 -0
- {forgexa_cli-1.104.3 → forgexa_cli-1.105.0}/tests/test_workspace_storage.py +0 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"""forgexa-cli — Forgexa command-line client."""
|
|
2
|
-
__version__ = "1.
|
|
2
|
+
__version__ = "1.105.0"
|
|
@@ -1516,9 +1516,11 @@ async def agent_runtime_commit_error(
|
|
|
1516
1516
|
)
|
|
1517
1517
|
commits = await git("rev-list", *revisions, cwd=workspace_path)
|
|
1518
1518
|
for commit_sha in commits.splitlines():
|
|
1519
|
+
# Other merge parents can lack files inherited unchanged from the baseline.
|
|
1519
1520
|
output = await git(
|
|
1520
1521
|
"diff-tree", "--root", "--no-commit-id", "--name-status",
|
|
1521
|
-
"--no-renames", "--diff-filter=ACMRTUXB", "-r",
|
|
1522
|
+
"--no-renames", "--diff-filter=ACMRTUXB", "-r",
|
|
1523
|
+
"--diff-merges=first-parent", "-z",
|
|
1522
1524
|
commit_sha, cwd=workspace_path,
|
|
1523
1525
|
)
|
|
1524
1526
|
runtime_paths.update(_agent_runtime_paths_from_diff(output))
|
|
@@ -1566,6 +1568,24 @@ async def stage_agent_runtime_deletions(
|
|
|
1566
1568
|
)
|
|
1567
1569
|
|
|
1568
1570
|
|
|
1571
|
+
async def untrack_agent_runtime_files(
|
|
1572
|
+
workspace_path: Path, git: Callable[..., Awaitable[str]],
|
|
1573
|
+
) -> list[str]:
|
|
1574
|
+
"""Remove generated state from a managed candidate's index, not its local files."""
|
|
1575
|
+
tracked = await git("ls-files", "--cached", "-z", cwd=workspace_path)
|
|
1576
|
+
paths = sorted({
|
|
1577
|
+
path for path in tracked.split("\0")
|
|
1578
|
+
if path and is_agent_runtime_path(path)
|
|
1579
|
+
})
|
|
1580
|
+
for offset in range(0, len(paths), 100):
|
|
1581
|
+
await git(
|
|
1582
|
+
"rm", "--cached", "--force", "--",
|
|
1583
|
+
*(f":(literal){path}" for path in paths[offset:offset + 100]),
|
|
1584
|
+
cwd=workspace_path,
|
|
1585
|
+
)
|
|
1586
|
+
return paths
|
|
1587
|
+
|
|
1588
|
+
|
|
1569
1589
|
def _redirect_prompt_through_task_file(
|
|
1570
1590
|
cwd: Path, prompt: str, task_id: str, agent_label: str,
|
|
1571
1591
|
*, task_file: Path | None = None, git_exclude: Path | None = None,
|
|
@@ -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.
|
|
1431
|
+
DAEMON_VERSION = "1.105.0"
|
|
1432
1432
|
|
|
1433
1433
|
|
|
1434
1434
|
def _detect_client_type() -> str:
|
|
@@ -3972,18 +3972,60 @@ class WorkspaceManager:
|
|
|
3972
3972
|
parent = self.projects_root / ".delivery-reviews"
|
|
3973
3973
|
parent.mkdir(parents=True, exist_ok=True)
|
|
3974
3974
|
workspace_path = Path(tempfile.mkdtemp(prefix="candidate-", dir=str(parent)))
|
|
3975
|
+
stage = "validate_refs"
|
|
3975
3976
|
try:
|
|
3976
3977
|
await self._git("check-ref-format", f"refs/heads/{candidate['branch']}", cwd=workspace_path, timeout=10)
|
|
3977
3978
|
await self._git("check-ref-format", f"refs/heads/{candidate['target_branch']}", cwd=workspace_path, timeout=10)
|
|
3978
|
-
|
|
3979
|
+
cache = None
|
|
3980
|
+
read_env = {"GIT_NO_LAZY_FETCH": "1", "GIT_OPTIONAL_LOCKS": "0", "GIT_TERMINAL_PROMPT": "0"}
|
|
3981
|
+
if not re.fullmatch(r"[a-zA-Z0-9_-]+", project_key):
|
|
3982
|
+
raise ValueError("Invalid project identity")
|
|
3983
|
+
stage = "cache_probe"
|
|
3984
|
+
for existing in (self.projects_root / project_key / self._workspace_key(task), self.projects_root / project_key / "_main"):
|
|
3985
|
+
if not (existing / ".git").exists():
|
|
3986
|
+
continue
|
|
3987
|
+
try:
|
|
3988
|
+
remote = await self._git("config", "--local", "--get", "remote.origin.url", cwd=existing, timeout=10, env_overrides=read_env)
|
|
3989
|
+
if _normalize_repo_identity(remote.strip()) != candidate["repo_identity"]:
|
|
3990
|
+
continue
|
|
3991
|
+
shallow = await self._git("rev-parse", "--is-shallow-repository", cwd=existing, timeout=10, env_overrides=read_env)
|
|
3992
|
+
if shallow.strip() != "false":
|
|
3993
|
+
continue
|
|
3994
|
+
local_config = await self._git("config", "--local", "--null", "--list", cwd=existing, timeout=10, env_overrides=read_env)
|
|
3995
|
+
if any(
|
|
3996
|
+
key == "extensions.partialclone" or key.endswith(".promisor") and value.strip().lower() not in {"false", "no", "0"}
|
|
3997
|
+
for entry in local_config.split("\x00") if entry
|
|
3998
|
+
for key, _, value in [entry.partition("\n")]
|
|
3999
|
+
):
|
|
4000
|
+
continue
|
|
4001
|
+
except (OSError, RuntimeError, UnicodeError):
|
|
4002
|
+
continue
|
|
4003
|
+
try:
|
|
4004
|
+
for commit in (candidate["head_sha"], candidate["target_sha"]):
|
|
4005
|
+
await self._git("cat-file", "-e", f"{commit}^{{commit}}", cwd=existing, timeout=10, env_overrides=read_env)
|
|
4006
|
+
await self._git("merge-base", candidate["target_sha"], candidate["head_sha"], cwd=existing, timeout=10, env_overrides=read_env)
|
|
4007
|
+
except RuntimeError:
|
|
4008
|
+
continue
|
|
4009
|
+
cache = existing
|
|
4010
|
+
break
|
|
4011
|
+
stage = "initialize"
|
|
4012
|
+
if cache is not None:
|
|
4013
|
+
await self._git("clone", "--shared", "--no-hardlinks", "--no-checkout", "--no-tags", "--template=", "--", str(cache), str(workspace_path),
|
|
4014
|
+
timeout=60, env_overrides=read_env)
|
|
4015
|
+
else:
|
|
4016
|
+
await self._git("init", "--quiet", "--template=", f"--object-format={'sha256' if len(candidate['head_sha']) == 64 else 'sha1'}", cwd=workspace_path, timeout=10)
|
|
3979
4017
|
await self._git("config", "core.hooksPath", os.devnull, cwd=workspace_path, timeout=10)
|
|
3980
4018
|
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
|
-
|
|
3983
|
-
|
|
3984
|
-
|
|
4019
|
+
await self._git("remote", "set-url" if cache else "add", "origin", repo_url, cwd=workspace_path, timeout=10)
|
|
4020
|
+
if cache is None:
|
|
4021
|
+
stage = "fetch"
|
|
4022
|
+
await self._git("fetch", "--depth=1", "--no-tags", "--no-recurse-submodules", "--no-write-fetch-head", "--refmap=",
|
|
4023
|
+
"origin", candidate["head_sha"], candidate["target_sha"],
|
|
4024
|
+
cwd=workspace_path, timeout=settings.GIT_CLONE_TIMEOUT, project_key=project_key)
|
|
4025
|
+
stage = "checkout"
|
|
3985
4026
|
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", "-
|
|
4027
|
+
await self._git("checkout", "--quiet", "-B", candidate["branch"], candidate["head_sha"], cwd=workspace_path, timeout=60)
|
|
4028
|
+
stage = "predecessor"
|
|
3987
4029
|
for commit_sha in task.required_commit_shas:
|
|
3988
4030
|
if not isinstance(commit_sha, str) or not re.fullmatch(r"[a-f0-9]{40}|[a-f0-9]{64}", commit_sha):
|
|
3989
4031
|
raise ValueError("Invalid predecessor commit")
|
|
@@ -3992,7 +4034,22 @@ class WorkspaceManager:
|
|
|
3992
4034
|
except BaseException as error:
|
|
3993
4035
|
shutil.rmtree(workspace_path, ignore_errors=True)
|
|
3994
4036
|
if isinstance(error, (OSError, RuntimeError, ValueError, UnicodeError)):
|
|
3995
|
-
|
|
4037
|
+
detail = str(error).lower()
|
|
4038
|
+
reason = "git_command_failed"
|
|
4039
|
+
for category, pattern in (
|
|
4040
|
+
("git_timeout", r"timed out|timeout"),
|
|
4041
|
+
("git_access_denied", r"permission denied|authentication failed|could not read username|publickey|repository not found|(?:http(?:/[\d.]+)?\s+|returned error:\s*)(?:401|403)\b"),
|
|
4042
|
+
("git_resource_exhausted", r"cannot allocate memory|unable to mmap|out of memory|no space left"),
|
|
4043
|
+
("git_object_unavailable", r"not our ref|bad object|not a valid|unknown revision|invalid object|unable to read|missing blob|bad tree|corrupt"),
|
|
4044
|
+
("git_transport_unavailable", r"could not resolve|connection refused|connection reset|network is unreachable|unexpected disconnect|early eof"),
|
|
4045
|
+
):
|
|
4046
|
+
if re.search(pattern, detail):
|
|
4047
|
+
reason = category
|
|
4048
|
+
break
|
|
4049
|
+
if isinstance(error, UnicodeError):
|
|
4050
|
+
reason = "git_output_encoding"
|
|
4051
|
+
logger.warning("Delivery candidate reconstruction failed (stage=%s, reason=%s, type=%s)", stage, reason, type(error).__name__)
|
|
4052
|
+
raise RuntimeError(f"delivery_review_candidate_unavailable: fixed commits could not be reconstructed (stage={stage}; reason={reason})") from None
|
|
3996
4053
|
raise
|
|
3997
4054
|
|
|
3998
4055
|
if (task.input_data or {}).get("task") in ("delivery_code_review", "delivery_review_fix", "delivery_review_retest"):
|
|
@@ -6350,7 +6407,7 @@ class WorkspaceManager:
|
|
|
6350
6407
|
shutil.rmtree(workspace_path, ignore_errors=True)
|
|
6351
6408
|
|
|
6352
6409
|
async def _git(self, *args: str, cwd: Path | str | None = None, timeout: int | None = None,
|
|
6353
|
-
project_key: str | None = None) -> str:
|
|
6410
|
+
project_key: str | None = None, env_overrides: dict[str, str] | None = None) -> str:
|
|
6354
6411
|
"""Run a git command safely using exec (no shell injection).
|
|
6355
6412
|
|
|
6356
6413
|
If a project SSH key is registered, remote-touching commands
|
|
@@ -6521,6 +6578,8 @@ class WorkspaceManager:
|
|
|
6521
6578
|
"Git executable not found. Install Git for Windows and ensure "
|
|
6522
6579
|
"'C:\\Program Files\\Git\\cmd' is accessible to the Forgexa daemon."
|
|
6523
6580
|
)
|
|
6581
|
+
if env_overrides:
|
|
6582
|
+
env = {**(env or os.environ), **env_overrides}
|
|
6524
6583
|
|
|
6525
6584
|
# start_new_session=True puts git in its own process group.
|
|
6526
6585
|
# On timeout we send SIGKILL to the entire group, which includes
|
|
@@ -6560,7 +6619,7 @@ class WorkspaceManager:
|
|
|
6560
6619
|
raise RuntimeError(error_message) from None
|
|
6561
6620
|
finally:
|
|
6562
6621
|
# Clean up temp SSH key file if created
|
|
6563
|
-
if env and "GIT_SSH_COMMAND" in env:
|
|
6622
|
+
if env and "GIT_SSH_COMMAND" in env and project_key and self._ssh_keys.get(project_key) and args[0] in remote_commands:
|
|
6564
6623
|
import re as _re
|
|
6565
6624
|
m = _re.search(r'-i\s+"?([^"\s]+)"?', env["GIT_SSH_COMMAND"])
|
|
6566
6625
|
if m:
|
|
@@ -17158,6 +17217,7 @@ class RuntimeDaemon:
|
|
|
17158
17217
|
timeout_seconds = min(int(input_ctx.get("timeout_seconds", 300)), 300)
|
|
17159
17218
|
sensitive_patterns = input_ctx.get("sensitive_path_patterns") or []
|
|
17160
17219
|
candidate_ref = f"refs/heads/merge-candidate/{merge_job_id}"
|
|
17220
|
+
base_ref = base_integration_sha
|
|
17161
17221
|
|
|
17162
17222
|
# Record merge_job_id → project_id so GC can query eligibility later.
|
|
17163
17223
|
self._record_merge_job(merge_job_id, str(input_ctx.get("project_id") or ""))
|
|
@@ -17166,6 +17226,10 @@ class RuntimeDaemon:
|
|
|
17166
17226
|
result = dict(result)
|
|
17167
17227
|
if source_commit_sha and not result.get("source_commit_sha"):
|
|
17168
17228
|
result["source_commit_sha"] = source_commit_sha
|
|
17229
|
+
if base_ref and not result.get("base_integration_sha"):
|
|
17230
|
+
result["base_integration_sha"] = base_ref
|
|
17231
|
+
if error and not result.get("ai_resolution_notes"):
|
|
17232
|
+
result["ai_resolution_notes"] = error[:2000]
|
|
17169
17233
|
payload = {"status": status, "output_result": result}
|
|
17170
17234
|
if error:
|
|
17171
17235
|
payload["error"] = error[:1000]
|
|
@@ -17317,25 +17381,34 @@ class RuntimeDaemon:
|
|
|
17317
17381
|
)
|
|
17318
17382
|
return
|
|
17319
17383
|
|
|
17320
|
-
|
|
17384
|
+
merge_message = f"deploy-merge: {source_branch or source_commit_sha[:8]}"
|
|
17385
|
+
merge_error: RuntimeError | None = None
|
|
17321
17386
|
try:
|
|
17322
17387
|
await git(
|
|
17323
17388
|
"-c", f"user.name={_git_name}",
|
|
17324
17389
|
"-c", f"user.email={_git_email}",
|
|
17325
|
-
"merge", "--no-ff", "--no-
|
|
17390
|
+
"merge", "--no-ff", "--no-commit", "--no-edit", "-m", merge_message,
|
|
17326
17391
|
source_commit_sha,
|
|
17327
17392
|
cwd=workspace_path,
|
|
17328
17393
|
)
|
|
17329
|
-
|
|
17330
|
-
|
|
17331
|
-
merge_conflicted = True
|
|
17394
|
+
except RuntimeError as exc:
|
|
17395
|
+
merge_error = exc
|
|
17332
17396
|
|
|
17333
17397
|
# Check for unresolved conflicts.
|
|
17334
|
-
|
|
17335
|
-
|
|
17336
|
-
|
|
17337
|
-
|
|
17338
|
-
|
|
17398
|
+
diff_u = await git(
|
|
17399
|
+
"diff", "--name-only", "--diff-filter=U", "-z", cwd=workspace_path,
|
|
17400
|
+
)
|
|
17401
|
+
conflicted_files = [path for path in diff_u.split("\0") if path]
|
|
17402
|
+
if merge_error and not conflicted_files:
|
|
17403
|
+
raise merge_error
|
|
17404
|
+
|
|
17405
|
+
excluded_runtime_paths = await agent_core.untrack_agent_runtime_files(
|
|
17406
|
+
workspace_path, git,
|
|
17407
|
+
)
|
|
17408
|
+
conflicted_files = [
|
|
17409
|
+
path for path in conflicted_files if not agent_core.is_agent_runtime_path(path)
|
|
17410
|
+
]
|
|
17411
|
+
merge_conflicted = bool(conflicted_files)
|
|
17339
17412
|
replayed_artifact_paths: list[str] = []
|
|
17340
17413
|
|
|
17341
17414
|
artifact_prefix = f"docs/requirements/{requirement_key}/"
|
|
@@ -17369,12 +17442,6 @@ class RuntimeDaemon:
|
|
|
17369
17442
|
cwd=workspace_path,
|
|
17370
17443
|
)
|
|
17371
17444
|
await git("add", "--", conflict_path, cwd=workspace_path)
|
|
17372
|
-
await git(
|
|
17373
|
-
"-c", f"user.name={_git_name}",
|
|
17374
|
-
"-c", f"user.email={_git_email}",
|
|
17375
|
-
"commit", "--no-edit",
|
|
17376
|
-
cwd=workspace_path,
|
|
17377
|
-
)
|
|
17378
17445
|
replayed_artifact_paths = list(conflicted_files)
|
|
17379
17446
|
conflicted_files = []
|
|
17380
17447
|
merge_conflicted = False
|
|
@@ -17570,10 +17637,10 @@ class RuntimeDaemon:
|
|
|
17570
17637
|
|
|
17571
17638
|
# Re-check remaining conflicts after this batch.
|
|
17572
17639
|
try:
|
|
17573
|
-
diff_u = await git(
|
|
17574
|
-
|
|
17575
|
-
|
|
17576
|
-
]
|
|
17640
|
+
diff_u = await git(
|
|
17641
|
+
"diff", "--name-only", "--diff-filter=U", "-z", cwd=workspace_path,
|
|
17642
|
+
)
|
|
17643
|
+
remaining = [path for path in diff_u.split("\0") if path]
|
|
17577
17644
|
except RuntimeError:
|
|
17578
17645
|
pass # keep the previous remaining list
|
|
17579
17646
|
|
|
@@ -17611,15 +17678,6 @@ class RuntimeDaemon:
|
|
|
17611
17678
|
)
|
|
17612
17679
|
if runtime_error:
|
|
17613
17680
|
raise RuntimeError(runtime_error)
|
|
17614
|
-
try:
|
|
17615
|
-
await git(
|
|
17616
|
-
"-c", f"user.name={_git_name}",
|
|
17617
|
-
"-c", f"user.email={_git_email}",
|
|
17618
|
-
"commit", "--no-edit",
|
|
17619
|
-
cwd=workspace_path,
|
|
17620
|
-
)
|
|
17621
|
-
except RuntimeError:
|
|
17622
|
-
pass # merge may have already committed
|
|
17623
17681
|
logger.info(
|
|
17624
17682
|
"deployment_merge: AI resolution succeeded for job %s via %s",
|
|
17625
17683
|
job_id, resolved_agent_id,
|
|
@@ -17628,6 +17686,16 @@ class RuntimeDaemon:
|
|
|
17628
17686
|
# AI resolution succeeded — falls through to the shared
|
|
17629
17687
|
# deterministic precheck + reporting block below.
|
|
17630
17688
|
|
|
17689
|
+
merge_head = await git("rev-parse", "--revs-only", "MERGE_HEAD", cwd=workspace_path)
|
|
17690
|
+
staged_paths = await git("diff", "--cached", "--name-only", "-z", cwd=workspace_path)
|
|
17691
|
+
if merge_head.strip() or staged_paths:
|
|
17692
|
+
await git(
|
|
17693
|
+
"-c", f"user.name={_git_name}",
|
|
17694
|
+
"-c", f"user.email={_git_email}",
|
|
17695
|
+
"commit", "-m", merge_message,
|
|
17696
|
+
cwd=workspace_path,
|
|
17697
|
+
)
|
|
17698
|
+
|
|
17631
17699
|
# Deterministic precheck: scan for residual conflict markers.
|
|
17632
17700
|
# Applies to both clean merges and AI-resolved merges. Scoped to
|
|
17633
17701
|
# files actually in conflict — see _scan_conflicted_files_for_markers.
|
|
@@ -17645,21 +17713,21 @@ class RuntimeDaemon:
|
|
|
17645
17713
|
"merge_outcome": "precheck_failed",
|
|
17646
17714
|
"conflicted_files": marker_files[:30],
|
|
17647
17715
|
"candidate_commit_sha": candidate_sha,
|
|
17716
|
+
"ai_resolution_notes": (
|
|
17717
|
+
"Residual Git conflict markers remain in the listed files."
|
|
17718
|
+
),
|
|
17648
17719
|
})
|
|
17649
17720
|
return
|
|
17650
17721
|
|
|
17651
17722
|
# Deterministic precheck: the working tree must be clean (no
|
|
17652
17723
|
# unstaged/staged leftovers) after merge/commit. Untracked files
|
|
17653
17724
|
# are ignored — worktrees may contain unrelated artifacts.
|
|
17654
|
-
|
|
17655
|
-
|
|
17656
|
-
|
|
17657
|
-
)
|
|
17658
|
-
except RuntimeError:
|
|
17659
|
-
status_out = ""
|
|
17725
|
+
status_out = await git(
|
|
17726
|
+
"status", "--porcelain", "--untracked-files=no", cwd=workspace_path,
|
|
17727
|
+
)
|
|
17660
17728
|
dirty_files = [
|
|
17661
17729
|
(line[3:].strip() if len(line) > 3 else line.strip())
|
|
17662
|
-
for line in status_out.
|
|
17730
|
+
for line in status_out.splitlines()
|
|
17663
17731
|
if line.strip()
|
|
17664
17732
|
]
|
|
17665
17733
|
if dirty_files:
|
|
@@ -17671,6 +17739,9 @@ class RuntimeDaemon:
|
|
|
17671
17739
|
"merge_outcome": "precheck_failed",
|
|
17672
17740
|
"conflicted_files": dirty_files[:30],
|
|
17673
17741
|
"candidate_commit_sha": candidate_sha,
|
|
17742
|
+
"ai_resolution_notes": (
|
|
17743
|
+
"The merge working tree has uncommitted changes in the listed files."
|
|
17744
|
+
),
|
|
17674
17745
|
})
|
|
17675
17746
|
return
|
|
17676
17747
|
|
|
@@ -17679,6 +17750,7 @@ class RuntimeDaemon:
|
|
|
17679
17750
|
# because the candidate ref is ephemeral — a re-merge (new train
|
|
17680
17751
|
# round, baseline resync) produces a different commit history that
|
|
17681
17752
|
# is NOT a fast-forward of the previous candidate.
|
|
17753
|
+
runtime_error = None
|
|
17682
17754
|
try:
|
|
17683
17755
|
runtime_error = await self._agent_runtime_commit_error(workspace_path)
|
|
17684
17756
|
if runtime_error:
|
|
@@ -17689,8 +17761,9 @@ class RuntimeDaemon:
|
|
|
17689
17761
|
timeout=settings.GIT_PUSH_TIMEOUT,
|
|
17690
17762
|
)
|
|
17691
17763
|
except RuntimeError as exc:
|
|
17764
|
+
error_message = runtime_error or f"candidate push failed: {exc}"
|
|
17692
17765
|
logger.warning(
|
|
17693
|
-
"deployment_merge: job %s
|
|
17766
|
+
"deployment_merge: job %s precheck failed: %s", job_id, error_message,
|
|
17694
17767
|
)
|
|
17695
17768
|
await _report(
|
|
17696
17769
|
{
|
|
@@ -17699,7 +17772,7 @@ class RuntimeDaemon:
|
|
|
17699
17772
|
"candidate_ref": candidate_ref,
|
|
17700
17773
|
},
|
|
17701
17774
|
status="failed",
|
|
17702
|
-
error=
|
|
17775
|
+
error=error_message,
|
|
17703
17776
|
)
|
|
17704
17777
|
return
|
|
17705
17778
|
|
|
@@ -17723,6 +17796,17 @@ class RuntimeDaemon:
|
|
|
17723
17796
|
"deployment_merge: job %s %s → %s",
|
|
17724
17797
|
job_id, outcome, candidate_sha[:12],
|
|
17725
17798
|
)
|
|
17799
|
+
resolution_notes = []
|
|
17800
|
+
if replayed_artifact_paths:
|
|
17801
|
+
resolution_notes.append(
|
|
17802
|
+
f"Replaced {len(replayed_artifact_paths)} replayed requirement artifacts "
|
|
17803
|
+
f"under {artifact_prefix} from the new source commit."
|
|
17804
|
+
)
|
|
17805
|
+
if excluded_runtime_paths:
|
|
17806
|
+
resolution_notes.append(
|
|
17807
|
+
f"Excluded {len(excluded_runtime_paths)} tracked agent runtime state files "
|
|
17808
|
+
"from the deployment candidate; local files were preserved."
|
|
17809
|
+
)
|
|
17726
17810
|
await _report({
|
|
17727
17811
|
"merge_outcome": outcome,
|
|
17728
17812
|
"resolved_agent": resolved_agent_id,
|
|
@@ -17731,11 +17815,7 @@ class RuntimeDaemon:
|
|
|
17731
17815
|
"merge_commit_sha": candidate_sha,
|
|
17732
17816
|
"base_integration_sha": base_ref,
|
|
17733
17817
|
"source_commit_sha": source_commit_sha,
|
|
17734
|
-
"ai_resolution_notes": (
|
|
17735
|
-
f"Replaced {len(replayed_artifact_paths)} replayed requirement artifacts "
|
|
17736
|
-
f"under {artifact_prefix} from the new source commit."
|
|
17737
|
-
if replayed_artifact_paths else None
|
|
17738
|
-
),
|
|
17818
|
+
"ai_resolution_notes": "\n".join(resolution_notes) or None,
|
|
17739
17819
|
})
|
|
17740
17820
|
|
|
17741
17821
|
except Exception as exc:
|
|
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
|