> ## Documentation Index
> Fetch the complete documentation index at: https://docs.withwhile.com/llms.txt
> Use this file to discover all available pages before exploring further.

# whileai.simulations.world

> The mock world that answers tool calls and fails on schedule.

The mock world that answers tool calls and fails on schedule.

2 public names. `import whileai.simulations as wai`, then `wai.name`.

| Name                                  | What it does                                 |
| ------------------------------------- | -------------------------------------------- |
| [`MockEnvironment`](#mockenvironment) | In-memory tool world.                        |
| [`WorldOptions`](#worldoptions)       | Everything the mock world can be steered by. |

### MockEnvironment

```python theme={null}
MockEnvironment(
    tools: list[dict],
    seed: int = 0,
    faults: dict[str, dict] | None = None,
    world_state: str = '',
    result_shapes: dict[str, dict] | None = None,
    options: WorldOptions | Mapping[str, Any] | None = None,
) -> None
```

In-memory tool world. User-named refs exist `exists_share` of the
time; issued ids must be created. `options` steers every generator.

### WorldOptions

```python theme={null}
WorldOptions(
    fault_modes: Mapping[str, FaultMode] = <factory>,
    condition_modes: Mapping[str, str] = <factory>,
    default_fault_mode: str = 'timeout',
    default_fault_rate: float = 1.0,
    stale_as_of: str = '3 days ago',
    malformed_payload: Any = '<<garbled resp0nse',
    exists_share: float = 0.7,
    search_hits: tuple[int, int] = (1, 6),
    template_hits: tuple[int, int] = (1, 5),
    id_range: tuple[int, int] = (1000, 90000),
    date_years: tuple[int, int] = (2022, 5),
    jitter_divisor: int = 3,
    shell_flavors: int = 11,
    ci_fail_one_in: int = 7,
    result_kinds: tuple[tuple[str, KindRule], ...] = (('shell', <function _is_shell>), ('grep', <function _is_grep>), ('file', <function _is_file>), ('files', <function _is_files>), ('git', <function _is_git>), ('ci', <function _is_ci>), ('money', <function _is_money>)),
    payloads: Mapping[str, PayloadBuilder] = <factory>,
    people: tuple[str, ...] = ('tessa okonkwo', 'ravi lindgren', 'mireille tanaka', 'bao castellanos', 'ingrid abubakar', 'kwame sorensen', 'leila varga', 'dmitri achebe', 'noor kavanagh', 'hiro delacroix', 'amara fitzgerald', 'sven nakamura', 'zainab holmberg', 'tomasz oyelowo', 'farah eriksen', 'kenji abernathy', 'esperanza kowalski', 'olu brennan', 'yara thorsen', 'matteo nwachukwu', 'sigrid bhatt', 'idris halvorsen', "priyanka o'rourke", 'lucas adeyemi', 'hanna quispe', 'tariq lindqvist', 'rosalind mbeki', 'anselm ravalli', 'chiara okafor', 'jonas amankwah', 'beatriz sundstrom', 'emeka fontaine', 'solveig ramaswamy', 'yusuf mackenzie', 'ines takahashi', 'birgit anand', 'cyrus wanjiru', 'marisol dybek', 'elio berhane', 'ayesha lindstrom'),
    adjectives: tuple[str, ...] = ('nightly', 'routine', 'primary', 'draft', 'updated', 'automated', 'manual', 'initial', 'final', 'weekly', 'legacy', 'follow-up', 'quarterly', 'urgent', 'archived', 'revised', 'secondary', 'provisional', 'recurring', 'expedited', 'deferred', 'standing', 'seasonal', 'interim'),
    topics: tuple[str, ...] = ('config', 'cleanup', 'handoff', 'review', 'rollout', 'migration', 'sync', 'audit', 'onboarding', 'renewal', 'billing', 'escalation', 'inventory', 'compliance', 'backlog', 'outreach', 'reconciliation', 'staging', 'triage', 'closeout'),
    statuses: tuple[str, ...] = ('completed', 'in_progress', 'pending', 'failed', 'active', 'queued', 'approved', 'open'),
    code_verbs: tuple[str, ...] = ('load', 'parse', 'render', 'sync', 'build', 'handle', 'validate', 'merge', 'format', 'dispatch'),
    code_nouns: tuple[str, ...] = ('config', 'payload', 'record', 'client', 'worker', 'schema', 'queue', 'session', 'index', 'router'),
    check_names: tuple[str, ...] = ('lint', 'tests', 'typecheck', 'build', 'coverage', 'security', 'format'),
    file_stems: tuple[str, ...] = ('app', 'util', 'worker', 'client', 'schema', 'router', 'session', 'queue'),
) -> None
```

Everything the mock world can be steered by. Defaults in `defaults.py`.

Pass one to `MockEnvironment(options=)`, or the same fields as a dict
through `simulate(advanced={"world": {...}})` and
`export_environment(world={...})`; unknown keys raise so a typo is not
a silent default. The instance is frozen and its mapping fields are
read-only views: to add a fault mode or a payload builder, build a new
`WorldOptions` with the wider table.

Attributes:
fault\_modes: mode name -> builder; `FAULT_MODES` plus whatever a
caller adds. A read-only mapping.
condition\_modes: coverage-grid `tool_condition` value -> the
fault mode a situation with that condition carries
(`WORLD_CONDITION_MODES`). A condition that is itself a
`fault_modes` key needs no entry; every value here must be
a `fault_modes` key. A read-only mapping.
default\_fault\_mode: the mode a fault plan gets when it names none.
default\_fault\_rate: the fire probability a plan gets when it names
none.
stale\_as\_of: the age stamped on a stale read.
malformed\_payload: what a malformed fault returns.
exists\_share: share of user-named references that exist when no
world state says otherwise.
search\_hits: records a search returns, inclusive bounds.
template\_hits: records a model-written list template expands to,
inclusive bounds.
id\_range: generated record ids, `[lo, hi)`.
date\_years: `(first year, span)` generated dates fall in.
jitter\_divisor: a template number moves by up to 1/this of itself.
shell\_flavors: one shell call in this many takes each failing
flavor; the rest pass.
ci\_fail\_one\_in: one CI listing in this many carries a failed check.
result\_kinds: the routing table, `(kind, rule)` in order.
payloads: kind -> payload builder. A read-only mapping.
people, adjectives, topics, statuses, code\_verbs, code\_nouns,
check\_names, file\_stems: the content pools generated records
draw from.

#### WorldOptions.fault\_mode\_for

```python theme={null}
fault_mode_for(self, condition: str) -> str | None
```

The fault mode a coverage-grid `tool_condition` carries:
`condition_modes[condition]`, else the condition itself when it
is a `fault_modes` key, else `None` (a clean call).

#### WorldOptions.summary

```python theme={null}
summary(self) -> dict[str, Any]
```

The options as plain data for a run record: every non-callable
field as it is, and the callable tables (`fault_modes`,
`payloads`, `result_kinds`) as the sorted names they carry.
