closedhumanPR #288Transport

feat: add network partition transport plugin and scenario

Adds a partitioned.v1 transport plugin that splits agents into isolated groups. Messages crossing group boundaries are silently blocked and recorded as message_partition_blocked events.

Author

VarunGore36 avatar

@VarunGore36

github profile →
Status
Closed without merging
Opened on
Sep 22
Branch
feature/network-partition

Description

The pitch.

## What

Adds a `partitioned.v1` transport plugin that splits agents into isolated groups. Messages crossing group boundaries are silently blocked and recorded as `message_partition_blocked` events. All existing fault types (drop, duplicate, delay, drop_rate) still apply within each partition group.

## Why

The README currently says `network_partition` is "explicitly reported as not modeled" in upstream scenarios. This contribution fills that gap: network partitions can now be declared, injected, recorded in evidence bundles, and validated — deterministically.

## How

### Transport Plugin: `partitioned.v1`

Extends `memory.v1` with partition group support:

```yaml
# In any scenario YAML:
layers:
  transport: partitioned.v1
faults:
  - action: partition
    groups:
      - [buyer-1, seller-a]   # group 0
      - [seller-b]             # group 1
```

- Messages within a group: normal delivery (all existing faults still work)
- Messages crossing groups: blocked, recorded as `message_partition_blocked`
- Unlisted agents: treated as isolated singletons
- Deterministic: same seed → same trace

### Scenario: `network_partition`

A marketplace variant where a buyer and two sellers are split by a partition. The buyer can only reach one seller, completes a trade, and the isolated seller receives zero traffic. Tests that the partition is detected, contained, and the reachable path still completes.

### Validator: `network_partition`

Four stages:
1. `partition_detected` — cross-group messages were blocked
2. `isolated_seller_contained` — isolated seller received no delivered messages
3. `reachable_trade_completed` — buyer completed trade with reachable seller
4. `reputation` — receipt-driven reputation is consistent

### Failure Matrix Integration

- `transport/partition` fault in the catalog
- `network_partition` scenario in `DEFAULT_MATRIX`
- Propagation chain for partition events
- `message_partition_blocked` in `FAULT_EVENT_KINDS`

## Files Changed

| File | Change |
|---|---|
| `layers/transport.py` | `PartitionedTransport` plugin (+100 lines) |
| `sim/scenario.py` | `FaultRule` accepts `partition` action with `groups` |
| `sim/scenarios/network_partition.yaml` | New scenario |
| `sim/validators.py` | `network_partition` validator (+66 lines) |
| `matrix.py` | Partition fault in catalog, default matrix, propagation |
| `schemas/scenario.schema.json` | Regenerated |
| `tests/test_network_partition.py` | 35 new tests |
| `tests/test_sim.py` | Added to `ALL_SCENARIOS` |

## Usage

```bash
nandatown run network_partition                                    # run the scenario
nandatown matrix --scenario network_partition                      # include in matrix
nandatown matrix --scenario network_partition --fault transport/partition --trials 20
```

## Tests

All 1,907 tests pass (35 new + 1,872 existing). No existing behavior modified.

## Builds On

This PR builds on [#287](https://github.com/projnanda/nandatown/pull/287) (Protocol Failure Matrix). If merged independently, the matrix-related changes can be dropped.

Try it

Open PR on GitHubView diff

Checkout locally

git fetch origin pull/288/head:pr-288
git checkout pr-288