Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 2 additions & 12 deletions docs/DELEGATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ Model/effort: <resolved from the task repository's models.toml>
Effort policy: Children inherit this policy; return to the parent before raising effort or launching a stronger model.
Launch policy: Children inherit this rule: never approval-required; use auto only for read-only children and say "read-only, do not edit" in the brief; a child that runs commands or edits inherits the parent's mode, because auto can stall on approval review. After launch, verify pendingRequestCount 0 and a completed tool call.
Waiting: One blocking wait: Codex exec/write_stdin yield >=30 s (>=120 s for builds, tests, CI, review, ready or merge); shell `until <done>; do sleep 30; done`. Claude: background notification or t3_background_wait. Read the completed result once; never use t3_thread_read/task_status for liveness. Every ended turn wakes the parent: end it only with a final result, a blocker or a question, never with a progress note while your own job runs.
Output: Cap at the producer: REST `gh api --jq` selected fields, shell `| head -c 2000`; t3_thread_read limit <=2, maxCharsPerItem <=600.
Output: <Coordinator rollover caps. Use `gh api --jq` at source.>
Shell commands: Keep cleanup/removal and commit operations separate and simple; do not hide commands in scripts to evade approval review.
Verification: <focused owning tests and coverage; available proof methods and their task-scoped authorization within runtime permissions>
Integration executor: <named executor for returned heads and one owner of any readiness/merge waiter; parent retains acceptance responsibility>
Expand All @@ -424,17 +424,7 @@ Return: <authorized finish: evidence, readiness, or merge; deployment needs its
Report: Final message to the parent, which posts it on the owning PR or issue (post directly only when the delegate has GitHub access): changed files, evidence, check results, deviations, open questions and next action. Message the parent mid-task only for a blocker.
```

Example using those fields, with an illustrative requester instruction:

```text
Context: Requester said “prepare the fix for review; leave it unmerged” (<request link>).
Verification: Focused regression and browser observation on the local fixture, within existing task permissions; report unavailable proof.
Integration executor: Parent integrates and owns the sole loopzero ready --wait; child starts no waiter.
Return: Tested changes and evidence to parent; parent finishes through readiness, leaving merge to the requester.
```

The source request supplies authority; neither this example nor a finish label
grants it. Follow the [Worker role](#team-roles) for blockers.
Follow the [Worker role](#team-roles) for blockers.
The owner decides and continues anything
within its authority; only a decision reserved to a person goes to the harness
question tool with the PR/task link, exact decision and recommended option. If
Expand Down
4 changes: 1 addition & 3 deletions src/loopzero/_proc.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,7 @@ def build_env(
) -> dict[str, str]:
"""Copy only allowlisted variables from the current environment, then apply extras."""
env = {key: os.environ[key] for key in env_allowlist if key in os.environ}
if extra_env:
env.update(extra_env)
env.update(extra_env or {})
return env


Expand Down Expand Up @@ -138,7 +137,6 @@ def run(
stdin=subprocess.PIPE if input is not None else subprocess.DEVNULL,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT if merge_output else subprocess.PIPE,
text=not preserve_newlines,
encoding=None if preserve_newlines else encoding,
errors=None if preserve_newlines else "replace",
start_new_session=os.name == "posix",
Expand Down
10 changes: 8 additions & 2 deletions src/loopzero/runners.py
Original file line number Diff line number Diff line change
Expand Up @@ -502,10 +502,13 @@ def _codex_repository_skill_overrides(cwd: Path) -> list[str]:

def _repository_skill_paths(cwd: Path) -> set[str]:
tree, paths, seen = cwd.resolve(), set(), set()
pending = [cwd / ".agents" / "skills", cwd / ".codex" / "skills"]
roots = (cwd / ".agents", cwd / ".codex")
pending = list(roots)
while pending:
path = pending.pop()
if not os.path.lexists(path):
try:
path.lstat()
except FileNotFoundError:
continue
# Strict: a looping or dangling link fails closed; Codex might resolve it elsewhere.
real = path.resolve(strict=True)
Expand All @@ -515,6 +518,9 @@ def _repository_skill_paths(cwd: Path) -> set[str]:
if path.name == "SKILL.md":
paths.add(str(real))
continue
if path in roots:
pending.append(path / "skills")
continue
if real in seen:
continue
seen.add(real)
Expand Down
15 changes: 7 additions & 8 deletions tests/test_runners.py
Original file line number Diff line number Diff line change
Expand Up @@ -1159,20 +1159,19 @@ def spy(path=".", *rest):


@pytest.mark.parametrize("plant", [
"too_many", "loop", "undecodable", "dangling", "root_loop:.agents/skills", "root_loop:.codex/skills"])
"too_many", "loop", "undecodable", "dangling", "loop:.agents/skills", "loop:.codex/skills",
"loop:.agents", "loop:.codex", "dangling:.agents", "dangling:.codex"])
def test_codex_skill_lists_it_cannot_disable_fail_before_any_codex_call(
repo, fake_bin: Path, fake_tool, fake_bwrap: Path, monkeypatch: pytest.MonkeyPatch, plant: str,
) -> None:
if plant == "too_many":
_plant_skills(repo)
monkeypatch.setattr("loopzero.runners.CODEX_SKILL_OVERRIDE_LIMIT", 100)
elif plant in ("loop", "dangling"):
(repo / ".agents/skills").mkdir(parents=True)
(repo / ".agents/skills/x").symlink_to("x" if plant == "loop" else "/nonexistent/skills")
elif plant.startswith("root_loop:"):
root = repo / plant.partition(":")[2]
root.parent.mkdir(parents=True)
root.symlink_to(root.name)
elif plant != "undecodable":
kind, _, name = plant.partition(":")
link = repo / (name or ".agents/skills/x")
link.parent.mkdir(parents=True, exist_ok=True)
link.symlink_to(link.name if kind == "loop" else "missing")
else:
skill = repo / ".codex/skills" / os.fsdecode(b"\xff")
skill.mkdir(parents=True)
Expand Down
Loading