Skip to content

fix: consolidate bug fixes from PR #9 and PR #15#16

Closed
Longado wants to merge 1 commit intoHKUDS:mainfrom
Longado:fix/consolidate-pr9-pr15
Closed

fix: consolidate bug fixes from PR #9 and PR #15#16
Longado wants to merge 1 commit intoHKUDS:mainfrom
Longado:fix/consolidate-pr9-pr15

Conversation

@Longado
Copy link
Copy Markdown

@Longado Longado commented Mar 18, 2026

Context

Two open PRs (#9 and #15) fix overlapping bugs with different approaches. This PR consolidates the best of both, resolves their conflicts, and applies all 6 fixes not yet in `main`.

The one area of overlap — plans cleanup — was already merged via PR #6 using the subdirectory strategy (PR #9's cleaner approach). It is intentionally excluded here.


Changes

`clawteam/team/mailbox.py`

Bug 1 — broadcast sender exclusion broken (from PR #15)

`broadcast()` compared inbox directory names (e.g. `alice_worker`) against logical agent names (e.g. `worker`) in the exclude set. These never matched, so the sender always received their own broadcast.

Fix: resolve each logical name to its inbox directory name via `TeamManager.resolve_inbox()` before building the exclusion set.

Bug 2 — receive() / peek() crash on corrupted messages (from PR #9)

A single invalid JSON file in an inbox raised an exception that aborted the entire fetch, losing all subsequent valid messages (with `consume=True`, already-deleted messages were gone too).

Fix: extract a `_parse_messages()` helper that wraps each message in `try/except`, silently skipping corrupted entries.


`clawteam/transport/file.py`

Bug 3 — fetch(consume=True) has a race condition (from PR #15)

When two processes call `fetch(consume=True)` concurrently, both could `read_bytes()` the same file before either called `unlink()`, resulting in duplicate message delivery.

Fix: atomically `rename()` the file to `.consumed` before reading. Only one process can win the rename; others get `OSError` and skip the message.


`clawteam/cli/commands.py`

Bug 4 — config set/get only accept 3 of 7 valid keys (from PR #15)

Both commands hardcoded `{"data_dir", "user", "default_team"}`, making `transport`, `workspace`, `default_backend`, and `skip_permissions` impossible to set or get via CLI (even though `config show` displays all 7).

Fix: derive `valid_keys` dynamically from `ClawTeamConfig.model_fields`. Handle boolean fields (`skip_permissions`) with an explicit string→bool conversion.

Bug 5 — approve-join silently fabricates an agent name (from PR #9)

When no matching join request is found, `team approve-join` fabricated a name (`agent-{id[:6]}`) and proceeded to add a spurious team member.

Fix: return an error message and `exit(1)` when the join request cannot be found.

Bug 6 — launch does not pass skip_permissions to spawned agents (from PR #15)

`clawteam spawn` correctly reads `skip_permissions` from config and passes `--dangerously-skip-permissions` to Claude. `clawteam launch` did not, so agents spawned via templates always ran without the flag regardless of config.

Fix: read `skip_permissions` from config via `get_effective()` and forward it to `be.spawn()`.


Relationship to PR #9 and PR #15

Fix This PR PR #9 PR #15
broadcast exclusion
receive/peek crash
file transport race
config set/get keys
approve-join fabrication
launch skip_permissions
plans cleanup already merged (PR #6) ✅ subdirectory ✅ member-filter

If this PR is merged, both #9 and #15 can be closed as superseded (or cherry-picked for anything missed).

Test plan

  • All 135 existing tests pass (pytest tests/ -q)
  • Manually verify broadcast does not deliver to sender
  • Manually verify config set transport file and config set skip_permissions true work
  • Manually verify team approve-join with an invalid request ID returns an error
  • Manually verify clawteam launch hedge-fund respects skip_permissions config

🤖 Generated with Claude Code

Combines the best of both open PRs, resolving their overlapping approaches
and applying all 6 fixes that are not yet in main:

**mailbox.py**
- broadcast(): resolve logical agent names to inbox directory names before
  exclusion check, so the sender is not delivered their own broadcast when
  inboxes use user-prefixed format (e.g. "alice_worker" vs "worker")
  [from PR HKUDS#15]
- receive() / peek(): replace bare list comprehension with _parse_messages()
  helper that wraps each message in try/except, so a single corrupted file
  no longer crashes the entire fetch [from PR HKUDS#9]

**transport/file.py**
- fetch(consume=True): atomically rename msg file to .consumed before
  reading, so concurrent callers cannot both receive the same message
  [from PR HKUDS#15]

**cli/commands.py**
- config set / config get: derive valid_keys from ClawTeamConfig.model_fields
  instead of a hardcoded 3-item set, making all 7 config keys accessible;
  handle boolean fields (skip_permissions) correctly [from PR HKUDS#15]
- approve-join: return an error and exit(1) when no matching join request
  is found, instead of silently fabricating an agent name [from PR HKUDS#9]
- launch_team: read skip_permissions from config and pass it to be.spawn(),
  matching the behaviour of the standalone spawn command [from PR HKUDS#15]

Note: the plans-cleanup fix (PR HKUDS#9 subdirectory approach, PR HKUDS#15 member-filter
approach) was already merged via PR HKUDS#6 using the subdirectory strategy, so it
is intentionally excluded here.

All 135 existing tests pass.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
tjb-tech added a commit that referenced this pull request Mar 19, 2026
Co-authored-by: Eddylin03 <79293834+Eddylin03@users.noreply.github.com>
tjb-tech added a commit that referenced this pull request Mar 19, 2026
Co-authored-by: Eddylin03 <ylin474@wisc.edu>
@tjb-tech
Copy link
Copy Markdown
Collaborator

Context

Two open PRs (#9 and #15) fix overlapping bugs with different approaches. This PR consolidates the best of both, resolves their conflicts, and applies all 6 fixes not yet in main.

The one area of overlap — plans cleanup — was already merged via PR #6 using the subdirectory strategy (PR #9's cleaner approach). It is intentionally excluded here.

Changes

clawteam/team/mailbox.py

Bug 1 — broadcast sender exclusion broken (from PR #15)

broadcast() compared inbox directory names (e.g. alice_worker) against logical agent names (e.g. worker) in the exclude set. These never matched, so the sender always received their own broadcast.

Fix: resolve each logical name to its inbox directory name via TeamManager.resolve_inbox() before building the exclusion set.

Bug 2 — receive() / peek() crash on corrupted messages (from PR #9)

A single invalid JSON file in an inbox raised an exception that aborted the entire fetch, losing all subsequent valid messages (with consume=True, already-deleted messages were gone too).

Fix: extract a _parse_messages() helper that wraps each message in try/except, silently skipping corrupted entries.

clawteam/transport/file.py

Bug 3 — fetch(consume=True) has a race condition (from PR #15)

When two processes call fetch(consume=True) concurrently, both could read_bytes() the same file before either called unlink(), resulting in duplicate message delivery.

Fix: atomically rename() the file to .consumed before reading. Only one process can win the rename; others get OSError and skip the message.

clawteam/cli/commands.py

Bug 4 — config set/get only accept 3 of 7 valid keys (from PR #15)

Both commands hardcoded {"data_dir", "user", "default_team"}, making transport, workspace, default_backend, and skip_permissions impossible to set or get via CLI (even though config show displays all 7).

Fix: derive valid_keys dynamically from ClawTeamConfig.model_fields. Handle boolean fields (skip_permissions) with an explicit string→bool conversion.

Bug 5 — approve-join silently fabricates an agent name (from PR #9)

When no matching join request is found, team approve-join fabricated a name (agent-{id[:6]}) and proceeded to add a spurious team member.

Fix: return an error message and exit(1) when the join request cannot be found.

Bug 6 — launch does not pass skip_permissions to spawned agents (from PR #15)

clawteam spawn correctly reads skip_permissions from config and passes --dangerously-skip-permissions to Claude. clawteam launch did not, so agents spawned via templates always ran without the flag regardless of config.

Fix: read skip_permissions from config via get_effective() and forward it to be.spawn().

Relationship to PR #9 and PR #15

Fix This PR PR #9 PR #15
broadcast exclusion ✅ ❌ ✅
receive/peek crash ✅ ✅ ❌
file transport race ✅ ❌ ✅
config set/get keys ✅ ❌ ✅
approve-join fabrication ✅ ✅ ❌
launch skip_permissions ✅ ❌ ✅
plans cleanup already merged (PR #6) ✅ subdirectory ✅ member-filter
If this PR is merged, both #9 and #15 can be closed as superseded (or cherry-picked for anything missed).

Test plan

  • All 135 existing tests pass (pytest tests/ -q)
  • Manually verify broadcast does not deliver to sender
  • Manually verify config set transport file and config set skip_permissions true work
  • Manually verify team approve-join with an invalid request ID returns an error
  • Manually verify clawteam launch hedge-fund respects skip_permissions config

🤖 Generated with Claude Code

Thanks for putting this together.

I didn’t merge this PR as-is because it no longer applies cleanly on top of current main, and part of it had already been fixed upstream. Instead, I manually absorbed the remaining high-value fixes into main in a
smaller, current-main-compatible form.

The fixes now in main include:

  • config set/get supporting the full config surface, including boolean handling
  • team approve-join erroring when the request ID does not exist
  • mailbox receive/peek skipping corrupted messages instead of failing the whole batch
  • broadcast exclude working correctly with namespaced inboxes
  • file transport reducing duplicate-consumption risk when consume=True

Merged into main via:

  • 791ce16 Fix CLI and mailbox edge cases from PR #16

Thanks again — this PR was useful and directly informed the fixes that are now in main.

Closing this PR since the relevant fixes have now been absorbed into main.

@tjb-tech tjb-tech closed this Mar 19, 2026
a24ibrah pushed a commit to a24ibrah/ClawTeam that referenced this pull request Mar 30, 2026
Co-authored-by: Eddylin03 <ylin474@wisc.edu>
juntaochi added a commit to novix-science/ClawTeam-gstack that referenced this pull request Apr 20, 2026
…r increment + turn_id dedupe

- 9 tests covering D-14..D-17 + Pitfall HKUDS#2/HKUDS#3/HKUDS#16 invariants
- Module import fails at RED (ModuleNotFoundError)
- Covers: 0/1/2 no-progress turns, TaskCompleted reset, net-positive artifact delta,
  per-agent isolation, turn_id dedupe, question file write, ForcedProgressTriggered emit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants