forgexa-cli 1.68.0__tar.gz → 1.68.1__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.68.0 → forgexa_cli-1.68.1}/PKG-INFO +1 -1
- {forgexa_cli-1.68.0 → forgexa_cli-1.68.1}/forgexa_cli/__init__.py +1 -1
- {forgexa_cli-1.68.0 → forgexa_cli-1.68.1}/forgexa_cli/daemon.py +192 -37
- {forgexa_cli-1.68.0 → forgexa_cli-1.68.1}/forgexa_cli.egg-info/PKG-INFO +1 -1
- {forgexa_cli-1.68.0 → forgexa_cli-1.68.1}/pyproject.toml +1 -1
- {forgexa_cli-1.68.0 → forgexa_cli-1.68.1}/README.md +0 -0
- {forgexa_cli-1.68.0 → forgexa_cli-1.68.1}/forgexa_cli/_build_config.py +0 -0
- {forgexa_cli-1.68.0 → forgexa_cli-1.68.1}/forgexa_cli/_local_bind.py +0 -0
- {forgexa_cli-1.68.0 → forgexa_cli-1.68.1}/forgexa_cli/agent_core.py +0 -0
- {forgexa_cli-1.68.0 → forgexa_cli-1.68.1}/forgexa_cli/autoupgrade.py +0 -0
- {forgexa_cli-1.68.0 → forgexa_cli-1.68.1}/forgexa_cli/aws_evidence.py +0 -0
- {forgexa_cli-1.68.0 → forgexa_cli-1.68.1}/forgexa_cli/aws_logs_evidence.py +0 -0
- {forgexa_cli-1.68.0 → forgexa_cli-1.68.1}/forgexa_cli/main.py +0 -0
- {forgexa_cli-1.68.0 → forgexa_cli-1.68.1}/forgexa_cli/py.typed +0 -0
- {forgexa_cli-1.68.0 → forgexa_cli-1.68.1}/forgexa_cli/runtime_evidence.py +0 -0
- {forgexa_cli-1.68.0 → forgexa_cli-1.68.1}/forgexa_cli/zcode_protocol.py +0 -0
- {forgexa_cli-1.68.0 → forgexa_cli-1.68.1}/forgexa_cli.egg-info/SOURCES.txt +0 -0
- {forgexa_cli-1.68.0 → forgexa_cli-1.68.1}/forgexa_cli.egg-info/dependency_links.txt +0 -0
- {forgexa_cli-1.68.0 → forgexa_cli-1.68.1}/forgexa_cli.egg-info/entry_points.txt +0 -0
- {forgexa_cli-1.68.0 → forgexa_cli-1.68.1}/forgexa_cli.egg-info/requires.txt +0 -0
- {forgexa_cli-1.68.0 → forgexa_cli-1.68.1}/forgexa_cli.egg-info/top_level.txt +0 -0
- {forgexa_cli-1.68.0 → forgexa_cli-1.68.1}/setup.cfg +0 -0
- {forgexa_cli-1.68.0 → forgexa_cli-1.68.1}/tests/test_auth_and_runtime_commands.py +0 -0
- {forgexa_cli-1.68.0 → forgexa_cli-1.68.1}/tests/test_autoupgrade.py +0 -0
- {forgexa_cli-1.68.0 → forgexa_cli-1.68.1}/tests/test_check_command.py +0 -0
- {forgexa_cli-1.68.0 → forgexa_cli-1.68.1}/tests/test_expiry_warnings_and_revoke.py +0 -0
- {forgexa_cli-1.68.0 → forgexa_cli-1.68.1}/tests/test_local_bind_commands.py +0 -0
- {forgexa_cli-1.68.0 → forgexa_cli-1.68.1}/tests/test_runtime_credentials.py +0 -0
- {forgexa_cli-1.68.0 → forgexa_cli-1.68.1}/tests/test_session_credentials.py +0 -0
- {forgexa_cli-1.68.0 → forgexa_cli-1.68.1}/tests/test_silent_install.py +0 -0
- {forgexa_cli-1.68.0 → forgexa_cli-1.68.1}/tests/test_upgrade_observability.py +0 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"""forgexa-cli — Forgexa command-line client."""
|
|
2
|
-
__version__ = "1.68.
|
|
2
|
+
__version__ = "1.68.1"
|
|
@@ -1234,7 +1234,7 @@ except (ImportError, ModuleNotFoundError):
|
|
|
1234
1234
|
# DAEMON_VERSION is the protocol/logic version of the daemon code.
|
|
1235
1235
|
# Kept in sync with pyproject.toml version via bump-version.sh.
|
|
1236
1236
|
# CLIENT_TYPE identifies which packaging/distribution this daemon runs in.
|
|
1237
|
-
DAEMON_VERSION = "1.68.
|
|
1237
|
+
DAEMON_VERSION = "1.68.1"
|
|
1238
1238
|
|
|
1239
1239
|
|
|
1240
1240
|
def _detect_client_type() -> str:
|
|
@@ -1624,6 +1624,7 @@ class TaskInfo:
|
|
|
1624
1624
|
runtime_evidence_plan: dict | None = None
|
|
1625
1625
|
local_evidence_upload: bool = False
|
|
1626
1626
|
critic_review_required: bool = False
|
|
1627
|
+
local_untracked_paths: set[str] = field(default_factory=set, repr=False)
|
|
1627
1628
|
|
|
1628
1629
|
|
|
1629
1630
|
@dataclass
|
|
@@ -2612,6 +2613,8 @@ def _read_local_bind_shared_output_snapshot(task_id: str) -> dict | None:
|
|
|
2612
2613
|
start = max(total_bytes - _LOCAL_BIND_SHARED_OUTPUT_MAX_BYTES, 0)
|
|
2613
2614
|
output_file.seek(start)
|
|
2614
2615
|
raw = output_file.read()
|
|
2616
|
+
except FileNotFoundError:
|
|
2617
|
+
return None
|
|
2615
2618
|
except OSError as exc:
|
|
2616
2619
|
logger.warning("Failed to read local-bind output log for task %s: %s", task_id, exc)
|
|
2617
2620
|
return None
|
|
@@ -3650,8 +3653,9 @@ class WorkspaceManager:
|
|
|
3650
3653
|
"""Resolve the workspace path for a workspace_resolution="local_bind" task.
|
|
3651
3654
|
|
|
3652
3655
|
Validates the daemon-private mapping entry (binding_id -> local_path),
|
|
3653
|
-
the directory's git remote identity, and
|
|
3654
|
-
|
|
3656
|
+
the directory's git remote identity, branch, and tracked changes.
|
|
3657
|
+
Pre-existing untracked and ignored files remain user-owned and local.
|
|
3658
|
+
Ordinary local-bind tasks perform NO destructive git operation
|
|
3655
3659
|
(no reset --hard, clean, branch deletion, or implicit branch switch)
|
|
3656
3660
|
on the user's real directory. The only exception is an explicitly
|
|
3657
3661
|
authorized fresh-analysis reset, which has its own server marker,
|
|
@@ -3739,16 +3743,25 @@ class WorkspaceManager:
|
|
|
3739
3743
|
"will never switch branches in your real working directory automatically."
|
|
3740
3744
|
)
|
|
3741
3745
|
|
|
3742
|
-
status_output = await self._git(
|
|
3743
|
-
|
|
3744
|
-
|
|
3746
|
+
status_output = await self._git(
|
|
3747
|
+
"status", "--porcelain=v1", "--untracked-files=no", "-z", cwd=local_path,
|
|
3748
|
+
)
|
|
3749
|
+
dirty_paths = _git_status_paths(status_output)
|
|
3750
|
+
if dirty_paths:
|
|
3745
3751
|
shown = ", ".join(dirty_paths[:20])
|
|
3746
3752
|
more = f" (+{len(dirty_paths) - 20} more)" if len(dirty_paths) > 20 else ""
|
|
3747
3753
|
raise RuntimeError(
|
|
3748
|
-
"local_binding_unavailable: local directory has uncommitted changes,
|
|
3749
|
-
f"to
|
|
3754
|
+
"local_binding_unavailable: local directory has uncommitted tracked changes, "
|
|
3755
|
+
f"refusing to overwrite user work: {shown}{more}. Commit or stash these "
|
|
3756
|
+
"changes, then retry; unrelated untracked files do not need to be deleted."
|
|
3750
3757
|
)
|
|
3751
3758
|
|
|
3759
|
+
task.local_untracked_paths = {
|
|
3760
|
+
path for path in (await self._git(
|
|
3761
|
+
"ls-files", "--others", "-z", cwd=local_path,
|
|
3762
|
+
)).split("\0") if path
|
|
3763
|
+
}
|
|
3764
|
+
|
|
3752
3765
|
try:
|
|
3753
3766
|
remote_branch = await self._git(
|
|
3754
3767
|
"ls-remote", "--heads", "origin", f"refs/heads/{target_branch}",
|
|
@@ -3784,8 +3797,12 @@ class WorkspaceManager:
|
|
|
3784
3797
|
await self._git("rev-parse", f"origin/{target_branch}", cwd=local_path)
|
|
3785
3798
|
).strip()
|
|
3786
3799
|
if local_head != remote_head:
|
|
3800
|
+
await self._check_local_untracked_overwrites(local_path, remote_head)
|
|
3787
3801
|
try:
|
|
3788
|
-
await self._git(
|
|
3802
|
+
await self._git(
|
|
3803
|
+
"merge", "--ff-only", "--no-overwrite-ignore",
|
|
3804
|
+
f"origin/{target_branch}", cwd=local_path,
|
|
3805
|
+
)
|
|
3789
3806
|
except RuntimeError as exc:
|
|
3790
3807
|
raise RuntimeError(
|
|
3791
3808
|
f"local_binding_unavailable: local branch '{target_branch}' cannot "
|
|
@@ -3866,6 +3883,33 @@ class WorkspaceManager:
|
|
|
3866
3883
|
|
|
3867
3884
|
return local_path
|
|
3868
3885
|
|
|
3886
|
+
async def _check_local_untracked_overwrites(self, local_path: Path, revision: str) -> None:
|
|
3887
|
+
untracked_paths = {
|
|
3888
|
+
path for path in (await self._git(
|
|
3889
|
+
"ls-files", "--others", "-z", cwd=local_path,
|
|
3890
|
+
)).split("\0") if path
|
|
3891
|
+
}
|
|
3892
|
+
if not untracked_paths:
|
|
3893
|
+
return
|
|
3894
|
+
target_paths = {
|
|
3895
|
+
path for path in (await self._git(
|
|
3896
|
+
"ls-tree", "-r", "--name-only", "-z", revision, cwd=local_path,
|
|
3897
|
+
)).split("\0") if path
|
|
3898
|
+
}
|
|
3899
|
+
conflicts = {
|
|
3900
|
+
path for path in target_paths if _is_preserved_local_path(path, untracked_paths)
|
|
3901
|
+
}
|
|
3902
|
+
conflicts.update(
|
|
3903
|
+
path.rstrip("/") for path in untracked_paths
|
|
3904
|
+
if _is_preserved_local_path(path.rstrip("/"), target_paths)
|
|
3905
|
+
)
|
|
3906
|
+
if conflicts:
|
|
3907
|
+
raise RuntimeError(
|
|
3908
|
+
"local_binding_unavailable: branch update would overwrite untracked or "
|
|
3909
|
+
"ignored local files; no branch was updated. Preserve the conflicting "
|
|
3910
|
+
f"files, then retry: {', '.join(sorted(conflicts)[:20])}"
|
|
3911
|
+
)
|
|
3912
|
+
|
|
3869
3913
|
async def _reset_authorized_local_fresh_branch(
|
|
3870
3914
|
self,
|
|
3871
3915
|
local_path: Path,
|
|
@@ -3903,6 +3947,18 @@ class WorkspaceManager:
|
|
|
3903
3947
|
)
|
|
3904
3948
|
return
|
|
3905
3949
|
|
|
3950
|
+
await self._check_local_untracked_overwrites(local_path, default_sha)
|
|
3951
|
+
try:
|
|
3952
|
+
await git(
|
|
3953
|
+
"read-tree", "--dry-run", "-m", "-u", "HEAD", default_sha,
|
|
3954
|
+
cwd=local_path,
|
|
3955
|
+
)
|
|
3956
|
+
except RuntimeError as exc:
|
|
3957
|
+
raise RuntimeError(
|
|
3958
|
+
"local_binding_unavailable: local fresh branch reset would overwrite local "
|
|
3959
|
+
f"files; no branch was reset. Preserve the conflicting files, then retry: {exc}"
|
|
3960
|
+
) from exc
|
|
3961
|
+
|
|
3906
3962
|
backup_tag = f"forgexa/fresh-analysis-backup/{task_id}"
|
|
3907
3963
|
await git("check-ref-format", f"refs/tags/{backup_tag}", cwd=local_path)
|
|
3908
3964
|
remote_tag = await git(
|
|
@@ -3948,7 +4004,8 @@ class WorkspaceManager:
|
|
|
3948
4004
|
) from exc
|
|
3949
4005
|
|
|
3950
4006
|
try:
|
|
3951
|
-
await
|
|
4007
|
+
await self._check_local_untracked_overwrites(local_path, default_sha)
|
|
4008
|
+
await git("reset", "--keep", default_sha, cwd=local_path)
|
|
3952
4009
|
except RuntimeError as exc:
|
|
3953
4010
|
try:
|
|
3954
4011
|
await git(
|
|
@@ -6563,6 +6620,18 @@ class ProcessManager:
|
|
|
6563
6620
|
"Fix ALL listed issues. Focus on the specific problems above."
|
|
6564
6621
|
)
|
|
6565
6622
|
|
|
6623
|
+
if task.workspace_resolution == "local_bind":
|
|
6624
|
+
prompt += (
|
|
6625
|
+
"\n\n## Local Workspace Safety\n"
|
|
6626
|
+
"This is the user's real working directory. Pre-existing untracked and "
|
|
6627
|
+
"ignored files are user-owned, not task output. Preserve them: do not delete, "
|
|
6628
|
+
"overwrite, stage, or commit them. Modify only tracked task files or create "
|
|
6629
|
+
"new task files. If the task requires changing a pre-existing untracked "
|
|
6630
|
+
"file, report the conflict instead of overwriting it. Never run git clean, "
|
|
6631
|
+
"git reset --hard, force-push, or blanket staging such as git add -A. "
|
|
6632
|
+
"Leave committing and pushing task changes to Forgexa."
|
|
6633
|
+
)
|
|
6634
|
+
|
|
6566
6635
|
if workspace_path is not None:
|
|
6567
6636
|
return agent_core.with_workspace_environment_guidance(
|
|
6568
6637
|
prompt, workspace_path,
|
|
@@ -10412,9 +10481,9 @@ def _testing_intents_have_e2e(workspace_path: Path, input_data: dict[str, Any])
|
|
|
10412
10481
|
_QA_TEST_LEVELS = frozenset({"unit", "integration", "e2e"})
|
|
10413
10482
|
|
|
10414
10483
|
|
|
10415
|
-
def
|
|
10416
|
-
"""Extract
|
|
10417
|
-
|
|
10484
|
+
def _git_status_entries(status_output: str) -> list[tuple[str, str]]:
|
|
10485
|
+
"""Extract status/path pairs from porcelain-v1 `-z` output."""
|
|
10486
|
+
entries: list[tuple[str, str]] = []
|
|
10418
10487
|
records = status_output.split("\0")
|
|
10419
10488
|
index = 0
|
|
10420
10489
|
while index < len(records):
|
|
@@ -10422,12 +10491,35 @@ def _git_status_paths(status_output: str) -> list[str]:
|
|
|
10422
10491
|
index += 1
|
|
10423
10492
|
if len(record) < 4 or record[2] != " ":
|
|
10424
10493
|
continue
|
|
10425
|
-
|
|
10494
|
+
entries.append((record[:2], record[3:]))
|
|
10426
10495
|
if "R" in record[:2] or "C" in record[:2]:
|
|
10427
10496
|
if index < len(records) and records[index]:
|
|
10428
|
-
|
|
10497
|
+
entries.append((record[:2], records[index]))
|
|
10429
10498
|
index += 1
|
|
10430
|
-
return
|
|
10499
|
+
return entries
|
|
10500
|
+
|
|
10501
|
+
|
|
10502
|
+
def _git_status_paths(status_output: str) -> list[str]:
|
|
10503
|
+
"""Extract changed paths from porcelain-v1 `-z` output."""
|
|
10504
|
+
return [path for _status, path in _git_status_entries(status_output)]
|
|
10505
|
+
|
|
10506
|
+
|
|
10507
|
+
def _is_preserved_local_path(path: str, preserved_paths: set[str]) -> bool:
|
|
10508
|
+
if path in preserved_paths or path + "/" in preserved_paths:
|
|
10509
|
+
return True
|
|
10510
|
+
prefix = ""
|
|
10511
|
+
for component in path.split("/")[:-1]:
|
|
10512
|
+
prefix += component + "/"
|
|
10513
|
+
if prefix in preserved_paths or prefix[:-1] in preserved_paths:
|
|
10514
|
+
return True
|
|
10515
|
+
return False
|
|
10516
|
+
|
|
10517
|
+
|
|
10518
|
+
def _local_bind_changed_paths(status_output: str, preserved_paths: set[str]) -> list[str]:
|
|
10519
|
+
return [
|
|
10520
|
+
path for status, path in _git_status_entries(status_output)
|
|
10521
|
+
if status != "??" or not _is_preserved_local_path(path, preserved_paths)
|
|
10522
|
+
]
|
|
10431
10523
|
|
|
10432
10524
|
|
|
10433
10525
|
def _qa_test_level_from_source_path(path: object) -> str | None:
|
|
@@ -12258,6 +12350,8 @@ class RuntimeDaemon:
|
|
|
12258
12350
|
is_local_bind = task.workspace_resolution == "local_bind"
|
|
12259
12351
|
async def report_task_complete(result: TaskResult) -> None:
|
|
12260
12352
|
if is_local_bind:
|
|
12353
|
+
if result.error:
|
|
12354
|
+
_append_local_bind_output_log(task.task_id, [f"[daemon] {result.error}"])
|
|
12261
12355
|
_prepare_local_bind_completion(task, result)
|
|
12262
12356
|
if self.managed_policy is not None and not await self.managed_policy.finish_task():
|
|
12263
12357
|
result.status = "failed"
|
|
@@ -13217,6 +13311,9 @@ class RuntimeDaemon:
|
|
|
13217
13311
|
logger.info("Task %s completed: %s (agent=%s)", task.task_id, result.status, agent.agent_id)
|
|
13218
13312
|
|
|
13219
13313
|
except Exception as e:
|
|
13314
|
+
failure_code = str(getattr(e, "code", "") or "")
|
|
13315
|
+
if is_local_bind and str(e).startswith("local_binding_unavailable:"):
|
|
13316
|
+
failure_code = "local_binding_unavailable"
|
|
13220
13317
|
if self.managed_policy is not None:
|
|
13221
13318
|
_append_local_bind_output_log(task.task_id, [str(e)])
|
|
13222
13319
|
logger.warning("Managed local task failed: %s", getattr(e, "code", "local_task_failed"))
|
|
@@ -13225,6 +13322,7 @@ class RuntimeDaemon:
|
|
|
13225
13322
|
await report_task_complete(TaskResult(
|
|
13226
13323
|
status="failed", exit_code=-1, stdout="", stderr="",
|
|
13227
13324
|
error=str(e),
|
|
13325
|
+
failure_code=failure_code,
|
|
13228
13326
|
execution_attempt_id=task.execution_attempt_id,
|
|
13229
13327
|
))
|
|
13230
13328
|
finally:
|
|
@@ -15416,12 +15514,18 @@ class RuntimeDaemon:
|
|
|
15416
15514
|
require_source_inventory = _qa_source_test_validation_required(
|
|
15417
15515
|
(task.input_data or {}).get("qa_test_level_policy_snapshot")
|
|
15418
15516
|
)
|
|
15517
|
+
preserved_paths = (
|
|
15518
|
+
getattr(task, "local_untracked_paths", None)
|
|
15519
|
+
if getattr(task, "workspace_resolution", None) == "local_bind"
|
|
15520
|
+
else None
|
|
15521
|
+
)
|
|
15419
15522
|
for attempt in range(max_retries):
|
|
15420
15523
|
inventory_issues = await self._refresh_validation_changed_paths(
|
|
15421
15524
|
workspace_path,
|
|
15422
15525
|
result,
|
|
15423
15526
|
default_branch=default_branch,
|
|
15424
15527
|
before_sha=before_sha,
|
|
15528
|
+
preserved_paths=preserved_paths,
|
|
15425
15529
|
)
|
|
15426
15530
|
issues = self._validate_outputs(workspace_path, task, result)
|
|
15427
15531
|
if require_source_inventory:
|
|
@@ -15545,6 +15649,7 @@ class RuntimeDaemon:
|
|
|
15545
15649
|
result,
|
|
15546
15650
|
default_branch=default_branch,
|
|
15547
15651
|
before_sha=before_sha,
|
|
15652
|
+
preserved_paths=preserved_paths,
|
|
15548
15653
|
)
|
|
15549
15654
|
remaining = self._validate_outputs(workspace_path, task, result)
|
|
15550
15655
|
if require_source_inventory:
|
|
@@ -15639,6 +15744,7 @@ class RuntimeDaemon:
|
|
|
15639
15744
|
*,
|
|
15640
15745
|
default_branch: str,
|
|
15641
15746
|
before_sha: str,
|
|
15747
|
+
preserved_paths: set[str] | None = None,
|
|
15642
15748
|
) -> list[str]:
|
|
15643
15749
|
"""Merge reported, working-tree, and already-committed task paths."""
|
|
15644
15750
|
reported_paths = ProcessManager._normalize_repo_paths(result.files_changed)
|
|
@@ -15654,7 +15760,7 @@ class RuntimeDaemon:
|
|
|
15654
15760
|
cwd=workspace_path,
|
|
15655
15761
|
)
|
|
15656
15762
|
paths.update(ProcessManager._normalize_repo_paths(
|
|
15657
|
-
|
|
15763
|
+
_local_bind_changed_paths(status_output, preserved_paths or set())
|
|
15658
15764
|
))
|
|
15659
15765
|
collected_paths = True
|
|
15660
15766
|
except Exception:
|
|
@@ -16007,6 +16113,8 @@ class RuntimeDaemon:
|
|
|
16007
16113
|
async def _discard_transient_untracked_runtime_files(
|
|
16008
16114
|
self,
|
|
16009
16115
|
workspace_path: Path,
|
|
16116
|
+
*,
|
|
16117
|
+
preserved_paths: set[str] | None = None,
|
|
16010
16118
|
) -> list[str]:
|
|
16011
16119
|
"""Discard known untracked test-run metadata before automatic staging."""
|
|
16012
16120
|
git = self.workspace_manager._git
|
|
@@ -16026,6 +16134,8 @@ class RuntimeDaemon:
|
|
|
16026
16134
|
if not line.startswith("?? "):
|
|
16027
16135
|
continue
|
|
16028
16136
|
relative_path = line[3:].replace("\\", "/").lstrip("./")
|
|
16137
|
+
if _is_preserved_local_path(relative_path, preserved_paths or set()):
|
|
16138
|
+
continue
|
|
16029
16139
|
if relative_path not in _TRANSIENT_UNTRACKED_RUNTIME_PATHS:
|
|
16030
16140
|
continue
|
|
16031
16141
|
candidate = workspace_path / relative_path
|
|
@@ -16126,12 +16236,12 @@ class RuntimeDaemon:
|
|
|
16126
16236
|
before staging and again before pushing: if the user switched
|
|
16127
16237
|
branches while the agent ran, the task fails closed instead of
|
|
16128
16238
|
committing/pushing the changes onto the wrong branch
|
|
16129
|
-
|
|
16130
|
-
|
|
16131
|
-
|
|
16132
|
-
|
|
16133
|
-
|
|
16134
|
-
|
|
16239
|
+
- preserves the startup inventory of user-owned untracked/ignored
|
|
16240
|
+
files and excludes it from staging and convergence checks; if the
|
|
16241
|
+
agent stages or commits those files, refuses to push
|
|
16242
|
+
- refuses to commit/push task paths that look like secrets (.env,
|
|
16243
|
+
private keys, etc.), including paths committed by the agent itself
|
|
16244
|
+
since before_sha; untouched pre-existing private files stay local
|
|
16135
16245
|
- never rebases, merges, resets, or force-pushes; a non-fast-forward
|
|
16136
16246
|
push failure just fails the task closed, no automatic recovery
|
|
16137
16247
|
Returns a dict with commit/push status info (empty dict on success),
|
|
@@ -16173,9 +16283,26 @@ class RuntimeDaemon:
|
|
|
16173
16283
|
"from HEAD. Review the branch history yourself before retrying."
|
|
16174
16284
|
)}
|
|
16175
16285
|
|
|
16176
|
-
|
|
16177
|
-
|
|
16178
|
-
|
|
16286
|
+
if task.local_untracked_paths and not before_sha:
|
|
16287
|
+
return {"commit_error": "Refusing to commit: the local task baseline is unavailable"}
|
|
16288
|
+
|
|
16289
|
+
await self._discard_transient_untracked_runtime_files(
|
|
16290
|
+
workspace_path, preserved_paths=task.local_untracked_paths,
|
|
16291
|
+
)
|
|
16292
|
+
status_output = await git(
|
|
16293
|
+
"status", "--porcelain=v1", "--untracked-files=all", "-z", cwd=workspace_path,
|
|
16294
|
+
)
|
|
16295
|
+
dirty_paths = _local_bind_changed_paths(status_output, task.local_untracked_paths)
|
|
16296
|
+
preserved_dirty = [
|
|
16297
|
+
path for path in dirty_paths
|
|
16298
|
+
if _is_preserved_local_path(path, task.local_untracked_paths)
|
|
16299
|
+
]
|
|
16300
|
+
if preserved_dirty:
|
|
16301
|
+
return {"commit_error": (
|
|
16302
|
+
"Refusing to commit: pre-existing user-owned local files were staged ("
|
|
16303
|
+
+ ", ".join(preserved_dirty[:20])
|
|
16304
|
+
+ "). Not pushed; unstage these files and review the task changes."
|
|
16305
|
+
)}
|
|
16179
16306
|
|
|
16180
16307
|
sensitive_dirty = [p for p in dirty_paths if _is_sensitive_local_path(p)]
|
|
16181
16308
|
if sensitive_dirty:
|
|
@@ -16186,7 +16313,19 @@ class RuntimeDaemon:
|
|
|
16186
16313
|
)}
|
|
16187
16314
|
|
|
16188
16315
|
if dirty_paths:
|
|
16189
|
-
await git("add", "-
|
|
16316
|
+
await git("add", "-u", cwd=workspace_path)
|
|
16317
|
+
new_paths = [
|
|
16318
|
+
path for status, path in _git_status_entries(status_output)
|
|
16319
|
+
if status == "??" and not _is_preserved_local_path(
|
|
16320
|
+
path, task.local_untracked_paths,
|
|
16321
|
+
)
|
|
16322
|
+
]
|
|
16323
|
+
for offset in range(0, len(new_paths), 100):
|
|
16324
|
+
await git(
|
|
16325
|
+
"add", "--",
|
|
16326
|
+
*(f":(literal){path}" for path in new_paths[offset:offset + 100]),
|
|
16327
|
+
cwd=workspace_path,
|
|
16328
|
+
)
|
|
16190
16329
|
|
|
16191
16330
|
mode_change_error = await self._pure_file_mode_change_error(
|
|
16192
16331
|
workspace_path, "--cached"
|
|
@@ -16254,15 +16393,27 @@ class RuntimeDaemon:
|
|
|
16254
16393
|
# every path touched since before_sha for sensitive content too,
|
|
16255
16394
|
# not just what we just staged ourselves.
|
|
16256
16395
|
if before_sha:
|
|
16257
|
-
|
|
16396
|
+
committed_paths: set[str] = set()
|
|
16397
|
+
commits = await git("rev-list", f"{before_sha}..HEAD", cwd=workspace_path)
|
|
16398
|
+
for commit_sha in commits.splitlines():
|
|
16258
16399
|
changed_since_before = await git(
|
|
16259
|
-
"diff", "--name-only",
|
|
16400
|
+
"diff-tree", "--no-commit-id", "--name-only", "--no-renames",
|
|
16401
|
+
"-r", "-m", "-z", commit_sha, cwd=workspace_path,
|
|
16260
16402
|
)
|
|
16261
|
-
|
|
16262
|
-
|
|
16403
|
+
committed_paths.update(path for path in changed_since_before.split("\0") if path)
|
|
16404
|
+
preserved_committed = sorted(
|
|
16405
|
+
path for path in committed_paths
|
|
16406
|
+
if _is_preserved_local_path(path, task.local_untracked_paths)
|
|
16407
|
+
)
|
|
16408
|
+
if preserved_committed:
|
|
16409
|
+
return {"commit_error": (
|
|
16410
|
+
"Refusing to push: commit(s) made during this task include pre-existing "
|
|
16411
|
+
"user-owned local files ("
|
|
16412
|
+
+ ", ".join(preserved_committed[:20])
|
|
16413
|
+
+ "). Not pushed; inspect and fix the commit(s) yourself."
|
|
16414
|
+
)}
|
|
16263
16415
|
agent_sensitive = [
|
|
16264
|
-
|
|
16265
|
-
if p.strip() and _is_sensitive_local_path(p)
|
|
16416
|
+
path for path in sorted(committed_paths) if _is_sensitive_local_path(path)
|
|
16266
16417
|
]
|
|
16267
16418
|
if agent_sensitive:
|
|
16268
16419
|
return {"commit_error": (
|
|
@@ -16272,8 +16423,10 @@ class RuntimeDaemon:
|
|
|
16272
16423
|
+ "). Not pushed — inspect and fix the commit(s) yourself."
|
|
16273
16424
|
)}
|
|
16274
16425
|
|
|
16275
|
-
post_commit_status = await git(
|
|
16276
|
-
|
|
16426
|
+
post_commit_status = await git(
|
|
16427
|
+
"status", "--porcelain=v1", "--untracked-files=all", "-z", cwd=workspace_path,
|
|
16428
|
+
)
|
|
16429
|
+
if _local_bind_changed_paths(post_commit_status, task.local_untracked_paths):
|
|
16277
16430
|
if _post_commit_sync_attempts_remaining > 0:
|
|
16278
16431
|
logger.warning(
|
|
16279
16432
|
"local_bind: workspace changed after commit in %s; "
|
|
@@ -16328,8 +16481,10 @@ class RuntimeDaemon:
|
|
|
16328
16481
|
"yourself (e.g. pull/merge), then retry."
|
|
16329
16482
|
)}
|
|
16330
16483
|
|
|
16331
|
-
post_push_status = await git(
|
|
16332
|
-
|
|
16484
|
+
post_push_status = await git(
|
|
16485
|
+
"status", "--porcelain=v1", "--untracked-files=all", "-z", cwd=workspace_path,
|
|
16486
|
+
)
|
|
16487
|
+
if not _local_bind_changed_paths(post_push_status, task.local_untracked_paths):
|
|
16333
16488
|
return {}
|
|
16334
16489
|
|
|
16335
16490
|
if _post_commit_sync_attempts_remaining > 0:
|
|
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
|