Skip to content

Commit e5f7d11

Browse files
james-in-a-box[bot]eggegg-reviewer[bot]
authored
Fix feedback iteration limit never enforcing (#820)
* Fix feedback iteration limit never enforcing * Exempt reviewer agents from reviews/ readonly mount * Remove dangling setup-gateway symlink The symlink target (gateway/setup.sh) was deleted but the symlink in bin/ was not cleaned up. This dangling symlink breaks GitHub Actions action downloads because the runner cannot resolve it during the Set up job step. * Revert dangling symlink removal (moved to PR #823) * Skip .egg-readonly marker in reviews/ for reviewer agents Thread agent_role through ensure_egg_state_dirs so that reviewer agents don't get a misleading .egg-readonly marker in reviews/, since that directory is not mounted readonly for them. Addresses review feedback on the reviewer readonly exemption. --------- Co-authored-by: egg <egg@localhost> Co-authored-by: egg-reviewer[bot] <261018737+egg-reviewer[bot]@users.noreply.github.com>
1 parent ed954c8 commit e5f7d11

4 files changed

Lines changed: 139 additions & 10 deletions

File tree

‎.github/workflows/on-review-feedback.yml‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -369,11 +369,11 @@ jobs:
369369
# this for most cases, but a brief window remains. This is acceptable since
370370
# the worst case is one extra round, and the human notification still fires.
371371
#
372-
# Uses --paginate to handle PRs with >30 comments. The --slurp combines
373-
# paginated results into a nested array, hence the .[][] in jq.
372+
# Uses --paginate --slurp to handle PRs with >30 comments, piped to
373+
# external jq (gh api does not support --slurp combined with --jq).
374374
feedback_count=$(gh api "repos/${{ github.repository }}/issues/${{ env.PR_NUMBER }}/comments" \
375375
--paginate --slurp \
376-
--jq '[.[][] | select(.body | test("egg-feedback-addressing"))] | length' 2>/dev/null || echo "0")
376+
| jq '[.[][] | select(.body | test("egg-feedback-addressing"))] | length' 2>/dev/null || echo "0")
377377
378378
echo "Found $feedback_count previous feedback-addressing run(s)"
379379

‎orchestrator/container_spawner.py‎

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,7 @@ def _host_to_local_volumes(repo_volumes: dict[str, str]) -> dict[str, str]:
106106
if not host_home or host_home == container_home:
107107
return repo_volumes
108108
return {
109-
name: path.replace(host_home, container_home, 1)
110-
if path.startswith(host_home)
111-
else path
109+
name: path.replace(host_home, container_home, 1) if path.startswith(host_home) else path
112110
for name, path in repo_volumes.items()
113111
}
114112

@@ -311,8 +309,21 @@ def spawn_agent_container(
311309
# (the orchestrator can't access host paths like /home/jwies/...).
312310
if phase:
313311
local_volumes = _host_to_local_volumes(repo_volumes)
314-
ensure_egg_state_dirs(local_volumes, uid=host_uid, gid=host_gid, phase=phase)
315-
mounts.extend(phase_readonly_mounts(repo_volumes, phase, local_volumes=local_volumes))
312+
ensure_egg_state_dirs(
313+
local_volumes,
314+
uid=host_uid,
315+
gid=host_gid,
316+
phase=phase,
317+
agent_role=agent_role.value,
318+
)
319+
mounts.extend(
320+
phase_readonly_mounts(
321+
repo_volumes,
322+
phase,
323+
local_volumes=local_volumes,
324+
agent_role=agent_role.value,
325+
)
326+
)
316327
if certs_volume:
317328
mounts.append(
318329
MountSpec(

‎shared/egg_container/__init__.py‎

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ def ensure_egg_state_dirs(
137137
uid: int | None = None,
138138
gid: int | None = None,
139139
phase: str | None = None,
140+
agent_role: str | None = None,
140141
) -> None:
141142
"""Ensure ``.egg-state/`` subdirectories exist in each repo worktree.
142143
@@ -146,16 +147,23 @@ def ensure_egg_state_dirs(
146147
147148
When ``phase`` is ``"implement"``, ``.egg-readonly`` marker files are
148149
placed in each readonly directory to explain the restriction to agents.
150+
Reviewer agents are exempted from the ``reviews/`` marker since that
151+
directory is not mounted readonly for them.
149152
150153
Args:
151154
repo_volumes: Mapping of repo_name -> host_path.
152155
uid: Owner UID for created directories (default: current user).
153156
gid: Owner GID for created directories (default: current group).
154157
phase: Current SDLC phase. When ``"implement"``, marker files
155158
are written into readonly directories.
159+
agent_role: Agent role string (e.g., "reviewer_code"). Reviewer
160+
roles (starting with "reviewer") are exempted from the
161+
``reviews/`` marker file.
156162
"""
157163
import os
158164

165+
is_reviewer = agent_role is not None and agent_role.startswith("reviewer")
166+
159167
for _repo_name, host_path in repo_volumes.items():
160168
egg_state = Path(host_path) / ".egg-state"
161169
for dirname in _IMPLEMENT_READONLY_DIRS:
@@ -165,7 +173,9 @@ def ensure_egg_state_dirs(
165173
os.chown(str(target), uid, gid)
166174

167175
# Place marker files in readonly directories during implement phase.
168-
if phase == "implement":
176+
# Skip the reviews/ marker for reviewer agents since reviews/ is
177+
# not mounted readonly for them.
178+
if phase == "implement" and not (dirname == "reviews" and is_reviewer):
169179
marker = target / ".egg-readonly"
170180
marker.write_text(
171181
f"This directory is readonly during the '{phase}' phase.\n"
@@ -184,6 +194,7 @@ def phase_readonly_mounts(
184194
phase: str | None,
185195
container_base: str = "/home/egg/repos",
186196
local_volumes: dict[str, str] | None = None,
197+
agent_role: str | None = None,
187198
) -> list[MountSpec]:
188199
"""Create readonly overlay mounts for phase-protected directories.
189200
@@ -192,6 +203,9 @@ def phase_readonly_mounts(
192203
``.egg-state/reviews/`` are mounted readonly to prevent agents from
193204
modifying plan/contract artifacts via direct filesystem writes.
194205
206+
Reviewer agents are exempted from the ``reviews/`` readonly mount
207+
because they need to write verdict files there.
208+
195209
Args:
196210
repo_volumes: Mapping of repo_name -> host_path. These paths are
197211
used as Docker mount sources and may be host-absolute paths
@@ -203,19 +217,26 @@ def phase_readonly_mounts(
203217
for ``is_dir()`` filesystem checks when ``repo_volumes``
204218
contains host paths inaccessible to the current process.
205219
Mount sources still come from ``repo_volumes``.
220+
agent_role: Agent role string (e.g., "reviewer_code"). Reviewer
221+
roles (starting with "reviewer") are exempted from the
222+
``reviews/`` readonly mount so they can write verdict files.
206223
207224
Returns:
208225
List of MountSpec for readonly overlay mounts.
209226
"""
210227
if phase != "implement":
211228
return []
212229

230+
is_reviewer = agent_role is not None and agent_role.startswith("reviewer")
231+
213232
check_volumes = local_volumes if local_volumes is not None else repo_volumes
214233

215234
mounts: list[MountSpec] = []
216235
for repo_name, host_path in repo_volumes.items():
217236
check_path = check_volumes.get(repo_name, host_path)
218237
for dirname in _IMPLEMENT_READONLY_DIRS:
238+
if dirname == "reviews" and is_reviewer:
239+
continue
219240
host_dir = Path(host_path) / ".egg-state" / dirname
220241
check_dir = Path(check_path) / ".egg-state" / dirname
221242
container_dir = f"{container_base}/{repo_name}/.egg-state/{dirname}"

‎tests/shared/egg_container/test_phase_mounts.py‎

Lines changed: 98 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,55 @@ def test_marker_files_chowned_when_uid_gid_provided(self, tmp_path):
137137
repo_volumes = {"repo": str(tmp_path)}
138138
with patch("os.chown") as mock_chown:
139139
ensure_egg_state_dirs(repo_volumes, uid=1000, gid=1000, phase="implement")
140-
# 3 directory chowns + 3 marker file chowns
140+
# 4 directory chowns + 4 marker file chowns
141141
assert mock_chown.call_count == 2 * len(_IMPLEMENT_READONLY_DIRS)
142142

143+
@pytest.mark.parametrize(
144+
"role",
145+
[
146+
"reviewer_code",
147+
"reviewer_contract",
148+
"reviewer_agent_design",
149+
"reviewer_refine",
150+
"reviewer_plan",
151+
"reviewer",
152+
],
153+
)
154+
def test_reviewer_skips_reviews_marker(self, role, tmp_path):
155+
"""Reviewer agents don't get .egg-readonly marker in reviews/."""
156+
repo_volumes = {"repo": str(tmp_path)}
157+
ensure_egg_state_dirs(repo_volumes, phase="implement", agent_role=role)
158+
159+
# reviews/ should NOT have the marker
160+
reviews_marker = tmp_path / ".egg-state" / "reviews" / ".egg-readonly"
161+
assert not reviews_marker.exists()
162+
163+
# Other dirs still get markers
164+
for dirname in _IMPLEMENT_READONLY_DIRS:
165+
if dirname == "reviews":
166+
continue
167+
marker = tmp_path / ".egg-state" / dirname / ".egg-readonly"
168+
assert marker.exists(), f"Missing marker in {dirname}"
169+
170+
@pytest.mark.parametrize("role", ["coder", "tester", "integrator", "documenter"])
171+
def test_non_reviewer_keeps_reviews_marker(self, role, tmp_path):
172+
"""Non-reviewer agents still get .egg-readonly marker in reviews/."""
173+
repo_volumes = {"repo": str(tmp_path)}
174+
ensure_egg_state_dirs(repo_volumes, phase="implement", agent_role=role)
175+
176+
for dirname in _IMPLEMENT_READONLY_DIRS:
177+
marker = tmp_path / ".egg-state" / dirname / ".egg-readonly"
178+
assert marker.exists(), f"Missing marker in {dirname}"
179+
180+
def test_no_role_keeps_reviews_marker(self, tmp_path):
181+
"""No agent_role (default) keeps .egg-readonly marker in reviews/."""
182+
repo_volumes = {"repo": str(tmp_path)}
183+
ensure_egg_state_dirs(repo_volumes, phase="implement", agent_role=None)
184+
185+
for dirname in _IMPLEMENT_READONLY_DIRS:
186+
marker = tmp_path / ".egg-state" / dirname / ".egg-readonly"
187+
assert marker.exists(), f"Missing marker in {dirname}"
188+
143189

144190
class TestPhaseReadonlyMounts:
145191
"""Tests for phase_readonly_mounts()."""
@@ -278,3 +324,54 @@ def test_local_volumes_missing_dir_skipped(self, tmp_path):
278324

279325
mounts = phase_readonly_mounts(repo_volumes, "implement", local_volumes=local_volumes)
280326
assert mounts == []
327+
328+
@pytest.mark.parametrize(
329+
"role",
330+
[
331+
"reviewer_code",
332+
"reviewer_contract",
333+
"reviewer_agent_design",
334+
"reviewer_refine",
335+
"reviewer_plan",
336+
"reviewer",
337+
],
338+
)
339+
def test_reviewer_roles_skip_reviews_readonly(self, role, tmp_path):
340+
"""Reviewer agents are exempted from the reviews/ readonly mount."""
341+
for dirname in _IMPLEMENT_READONLY_DIRS:
342+
(tmp_path / ".egg-state" / dirname).mkdir(parents=True)
343+
344+
repo_volumes = {"myrepo": str(tmp_path)}
345+
mounts = phase_readonly_mounts(repo_volumes, "implement", agent_role=role)
346+
347+
destinations = {m.destination for m in mounts}
348+
assert "/home/egg/repos/myrepo/.egg-state/reviews" not in destinations
349+
# Other dirs still readonly
350+
assert "/home/egg/repos/myrepo/.egg-state/drafts" in destinations
351+
assert "/home/egg/repos/myrepo/.egg-state/contracts" in destinations
352+
assert "/home/egg/repos/myrepo/.egg-state/pipelines" in destinations
353+
assert len(mounts) == len(_IMPLEMENT_READONLY_DIRS) - 1
354+
355+
@pytest.mark.parametrize("role", ["coder", "tester", "integrator", "documenter"])
356+
def test_non_reviewer_roles_keep_reviews_readonly(self, role, tmp_path):
357+
"""Non-reviewer agents still get reviews/ mounted readonly."""
358+
for dirname in _IMPLEMENT_READONLY_DIRS:
359+
(tmp_path / ".egg-state" / dirname).mkdir(parents=True)
360+
361+
repo_volumes = {"myrepo": str(tmp_path)}
362+
mounts = phase_readonly_mounts(repo_volumes, "implement", agent_role=role)
363+
364+
destinations = {m.destination for m in mounts}
365+
assert "/home/egg/repos/myrepo/.egg-state/reviews" in destinations
366+
assert len(mounts) == len(_IMPLEMENT_READONLY_DIRS)
367+
368+
def test_no_role_keeps_reviews_readonly(self, tmp_path):
369+
"""No agent_role (default) keeps reviews/ readonly."""
370+
for dirname in _IMPLEMENT_READONLY_DIRS:
371+
(tmp_path / ".egg-state" / dirname).mkdir(parents=True)
372+
373+
repo_volumes = {"myrepo": str(tmp_path)}
374+
mounts = phase_readonly_mounts(repo_volumes, "implement", agent_role=None)
375+
376+
destinations = {m.destination for m in mounts}
377+
assert "/home/egg/repos/myrepo/.egg-state/reviews" in destinations

0 commit comments

Comments
 (0)