id_effect 0.7.0

Effect<A, E, R>: lazy Send effects over a typed capability list, run on a fiber runtime (Tokio executor), with layers, streams, schedules and coordination
Documentation
# Platform I/O (`id_effect_platform`)

Workspace crate **`id_effect_platform`** mirrors Effect.ts **`@effect/platform`**: **HTTP**,
**filesystem** and **process** as typed capabilities in `R`, not ad hoc `reqwest` / `std::fs`
calls in domain code.

## Why separate from `id_effect`?

- **Ports, not drivers** — traits like `HttpClient`, `FileSystem`, `ProcessRuntime` describe
  *what* you need; layers install live implementations or test doubles.
- **Test doubles** — `TestFileSystem` is in-memory; production uses `LiveFileSystemProvider`.
- **Stable HTTP boundary** — domain code depends on the `HttpClient` trait and `execute`, not on
  `reqwest::RequestBuilder`.

## Modules

| Module | Capability (`R`) | Layers | Effects |
|--------|------------------|--------|---------|
| `http` | `HttpClientService` (`HttpClientEnv`) | `ReqwestHttpClientProvider::layer()`, `provide_http_client(c)` | `execute`, `execute_stream` |
| `fs` | `FileSystemService` (`FileSystemEnv`) | `LiveFileSystemProvider::layer()`, `provide_file_system(fs)` | `read`, `exists` |
| `command` | `ProcessRuntimeService` (`ProcessRuntimeEnv`) | `TokioProcessRuntimeProvider::layer()`, `provide_process_runtime(rt)` | `spawn`, `spawn_wait`, `child_wait`, `child_kill` |
| `http::reqwest` | `ReqwestClient`, `ReqwestPool` | `ReqwestClientLive::layer()`, `provide_reqwest_client(c)`, `provide_reqwest_pool(n, ttl)` | `send`, `text`, `bytes`, `json`, `json_schema`, … |
| `auth` | — | — | `SessionStore`, `OAuthClient` and memory doubles |
| `error`, `uri` | — | — | `HttpError`, `FsError`, `ProcessError`; URI helpers |

Each capability is a newtype over `Arc<dyn Trait>` that derefs to the trait; each `*Env` alias is
the one-element list (`HttpClientEnv = HCons<HttpClientService, HNil>`), and `http_client_env(c)`
/ `file_system_env(fs)` / `process_runtime_env(rt)` build one for `.provide_all(..)`.

Every layer needs nothing (`In = HNil`) and is generic over the error type, so they merge into
one platform layer under your application's `E`:

```rust,ignore
let platform: Layer<_, AppError> = LiveFileSystemProvider::layer()
    .merge(ReqwestHttpClientProvider::layer())
    .merge(TokioProcessRuntimeProvider::layer());
```

## Running an HTTP effect

`execute` is generic over any `R` that contains `HttpClientService`. When the effect is fed to
`provide_layer`, name `R` (from `examples/010_platform_http_get.rs`):

```rust,ignore
use id_effect::{Cause, Exit};
use id_effect_platform::http::{HttpClientEnv, HttpRequest, ReqwestHttpClientProvider, execute};
use id_effect_tokio::TokioRuntime;

let program = execute::<HttpClientEnv, _>(HttpRequest::get("https://example.com"))
    .provide_layer(ReqwestHttpClientProvider::layer());
match TokioRuntime::current()?.run(program).await {
    Exit::Success(res) => println!("status={} bytes={}", res.status, res.body.len()),
    Exit::Failure(Cause::Fail(e)) => return Err(e),
    Exit::Failure(c) => panic!("run failed: {c:?}"),
}
```

A test swaps in a canned client and runs anywhere, `block_on` included:

```rust,ignore
let exit = execute(HttpRequest::get(url))
    .provide_all(http_client_env(Canned))
    .block_on();
```

The live implementations need a Tokio runtime **with its IO driver** (see
[Tokio bridge](./ch07-05-tokio-bridge.md)); the in-memory doubles (`TestFileSystem`,
`MemorySessionStore`, `MemoryOAuthClient`) do not.

Streaming responses (`execute_stream`) carry an `HttpBody` read on demand (`next_chunk()`,
`collect()`, both effects) with the `max_body_bytes` cap enforced as chunks arrive.

## Security note (filesystem)

`TestFileSystem` rejects paths containing `..`. Live I/O follows OS semantics — sandbox untrusted
paths at a higher layer.

## Runnable examples

```bash
cargo run -p id_effect_platform --example 010_platform_http_get
cargo run -p id_effect_platform --example 030_layer_default_env
```

## Next

For reqwest-specific pools and JSON helpers, see [HTTP via reqwest](./ch07-07-reqwest-http.md).