earful 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- earful-0.1.0/.gitignore +9 -0
- earful-0.1.0/CONTRIBUTING.md +125 -0
- earful-0.1.0/LICENSE +201 -0
- earful-0.1.0/NOTICE +15 -0
- earful-0.1.0/PKG-INFO +318 -0
- earful-0.1.0/README.md +285 -0
- earful-0.1.0/compat/lk-1.5.6.lock.txt +77 -0
- earful-0.1.0/compat/lk-1.5.7.lock.txt +77 -0
- earful-0.1.0/compat/lk-1.6.5.lock.txt +80 -0
- earful-0.1.0/compat/lk-1.6.6.lock.txt +80 -0
- earful-0.1.0/compat/lk-1.8.12.lock.txt +79 -0
- earful-0.1.0/docs/cases/3702-tool-result-lost-on-interruption.md +147 -0
- earful-0.1.0/docs/cases/5509-reply-starts-over-new-turn.md +134 -0
- earful-0.1.0/docs/compatibility.md +63 -0
- earful-0.1.0/docs/contracts.md +666 -0
- earful-0.1.0/docs/gate0/evidence/lk-1.5.6.barge_in_mid_word.ledger.normalized.jsonl +43 -0
- earful-0.1.0/docs/gate0/evidence/lk-1.5.6.barge_in_mid_word.repeat.json +23 -0
- earful-0.1.0/docs/gate0/evidence/lk-1.5.6.book_then_interrupt.ledger.normalized.jsonl +54 -0
- earful-0.1.0/docs/gate0/evidence/lk-1.5.6.book_then_interrupt.repeat.json +23 -0
- earful-0.1.0/docs/gate0/evidence/lk-1.5.6.book_then_interrupt.summary.json +45 -0
- earful-0.1.0/docs/gate0/evidence/lk-1.5.6.speak_over_new_turn.ledger.normalized.jsonl +43 -0
- earful-0.1.0/docs/gate0/evidence/lk-1.5.6.speak_over_new_turn.repeat.json +23 -0
- earful-0.1.0/docs/gate0/evidence/lk-1.5.6.speak_over_new_turn.summary.json +32 -0
- earful-0.1.0/docs/gate0/evidence/lk-1.5.7.barge_in_mid_word.ledger.normalized.jsonl +43 -0
- earful-0.1.0/docs/gate0/evidence/lk-1.5.7.barge_in_mid_word.repeat.json +23 -0
- earful-0.1.0/docs/gate0/evidence/lk-1.5.7.book_then_interrupt.ledger.normalized.jsonl +54 -0
- earful-0.1.0/docs/gate0/evidence/lk-1.5.7.book_then_interrupt.repeat.json +23 -0
- earful-0.1.0/docs/gate0/evidence/lk-1.5.7.book_then_interrupt.summary.json +45 -0
- earful-0.1.0/docs/gate0/evidence/lk-1.5.7.speak_over_new_turn.ledger.normalized.jsonl +40 -0
- earful-0.1.0/docs/gate0/evidence/lk-1.5.7.speak_over_new_turn.no_pause.ledger.normalized.jsonl +41 -0
- earful-0.1.0/docs/gate0/evidence/lk-1.5.7.speak_over_new_turn.no_pause.summary.json +34 -0
- earful-0.1.0/docs/gate0/evidence/lk-1.5.7.speak_over_new_turn.repeat.json +23 -0
- earful-0.1.0/docs/gate0/evidence/lk-1.5.7.speak_over_new_turn.summary.json +22 -0
- earful-0.1.0/docs/gate0/evidence/lk-1.6.5.barge_in_mid_word.ledger.normalized.jsonl +43 -0
- earful-0.1.0/docs/gate0/evidence/lk-1.6.5.barge_in_mid_word.repeat.json +23 -0
- earful-0.1.0/docs/gate0/evidence/lk-1.6.5.book_then_interrupt.ledger.normalized.jsonl +54 -0
- earful-0.1.0/docs/gate0/evidence/lk-1.6.5.book_then_interrupt.repeat.json +23 -0
- earful-0.1.0/docs/gate0/evidence/lk-1.6.5.book_then_interrupt.summary.json +45 -0
- earful-0.1.0/docs/gate0/evidence/lk-1.6.5.speak_over_new_turn.ledger.normalized.jsonl +40 -0
- earful-0.1.0/docs/gate0/evidence/lk-1.6.5.speak_over_new_turn.repeat.json +23 -0
- earful-0.1.0/docs/gate0/evidence/lk-1.6.5.speak_over_new_turn.summary.json +22 -0
- earful-0.1.0/docs/gate0/evidence/lk-1.6.6.barge_in_mid_word.ledger.normalized.jsonl +43 -0
- earful-0.1.0/docs/gate0/evidence/lk-1.6.6.barge_in_mid_word.repeat.json +23 -0
- earful-0.1.0/docs/gate0/evidence/lk-1.6.6.book_then_interrupt.ledger.normalized.jsonl +44 -0
- earful-0.1.0/docs/gate0/evidence/lk-1.6.6.book_then_interrupt.repeat.json +23 -0
- earful-0.1.0/docs/gate0/evidence/lk-1.6.6.book_then_interrupt.summary.json +35 -0
- earful-0.1.0/docs/gate0/evidence/lk-1.6.6.speak_over_new_turn.ledger.normalized.jsonl +40 -0
- earful-0.1.0/docs/gate0/evidence/lk-1.6.6.speak_over_new_turn.repeat.json +23 -0
- earful-0.1.0/docs/gate0/evidence/lk-1.6.6.speak_over_new_turn.summary.json +22 -0
- earful-0.1.0/docs/gate0/evidence/lk-1.8.12.barge_in_mid_word.ledger.normalized.jsonl +43 -0
- earful-0.1.0/docs/gate0/evidence/lk-1.8.12.barge_in_mid_word.repeat.json +23 -0
- earful-0.1.0/docs/gate0/evidence/lk-1.8.12.book_then_interrupt.ledger.normalized.jsonl +45 -0
- earful-0.1.0/docs/gate0/evidence/lk-1.8.12.book_then_interrupt.repeat.json +23 -0
- earful-0.1.0/docs/gate0/evidence/lk-1.8.12.book_then_interrupt.summary.json +35 -0
- earful-0.1.0/docs/gate0/evidence/lk-1.8.12.speak_over_new_turn.ledger.normalized.jsonl +40 -0
- earful-0.1.0/docs/gate0/evidence/lk-1.8.12.speak_over_new_turn.no_pause.ledger.normalized.jsonl +41 -0
- earful-0.1.0/docs/gate0/evidence/lk-1.8.12.speak_over_new_turn.no_pause.summary.json +34 -0
- earful-0.1.0/docs/gate0/evidence/lk-1.8.12.speak_over_new_turn.repeat.json +23 -0
- earful-0.1.0/docs/gate0/evidence/lk-1.8.12.speak_over_new_turn.summary.json +22 -0
- earful-0.1.0/docs/gate0-feasibility.md +204 -0
- earful-0.1.0/docs/gate1-core.md +273 -0
- earful-0.1.0/docs/gate2-historical-proof.md +48 -0
- earful-0.1.0/docs/ledger.md +471 -0
- earful-0.1.0/docs/report.md +164 -0
- earful-0.1.0/docs/search.md +381 -0
- earful-0.1.0/docs/testing.md +407 -0
- earful-0.1.0/examples/booking/agent.py +30 -0
- earful-0.1.0/examples/booking/test_booking.py +57 -0
- earful-0.1.0/pyproject.toml +107 -0
- earful-0.1.0/scripts/check_all.sh +79 -0
- earful-0.1.0/scripts/ci_scope.sh +35 -0
- earful-0.1.0/scripts/ci_tested.sh +36 -0
- earful-0.1.0/scripts/contracts_m1_sweep.py +98 -0
- earful-0.1.0/scripts/contracts_sweep.py +487 -0
- earful-0.1.0/scripts/gate1_figures.py +173 -0
- earful-0.1.0/scripts/ledger_diff.py +22 -0
- earful-0.1.0/scripts/ledger_show.py +13 -0
- earful-0.1.0/scripts/lint.sh +36 -0
- earful-0.1.0/scripts/make_env.sh +24 -0
- earful-0.1.0/scripts/mutate.py +190 -0
- earful-0.1.0/scripts/quickstart_check.sh +81 -0
- earful-0.1.0/scripts/realtime_control.py +43 -0
- earful-0.1.0/scripts/repeat.py +182 -0
- earful-0.1.0/scripts/search_vs_sweep.py +114 -0
- earful-0.1.0/scripts/show_run.py +27 -0
- earful-0.1.0/scripts/spike_3702.py +48 -0
- earful-0.1.0/scripts/spike_5509.py +54 -0
- earful-0.1.0/scripts/wheel_smoke.sh +132 -0
- earful-0.1.0/src/earful/__init__.py +46 -0
- earful-0.1.0/src/earful/__main__.py +7 -0
- earful-0.1.0/src/earful/cli.py +504 -0
- earful-0.1.0/src/earful/core/__init__.py +47 -0
- earful-0.1.0/src/earful/core/backend.py +322 -0
- earful-0.1.0/src/earful/core/bundle.py +257 -0
- earful-0.1.0/src/earful/core/case.py +237 -0
- earful-0.1.0/src/earful/core/checker/__init__.py +110 -0
- earful-0.1.0/src/earful/core/checker/a1.py +80 -0
- earful-0.1.0/src/earful/core/checker/a2.py +71 -0
- earful-0.1.0/src/earful/core/checker/a3.py +97 -0
- earful-0.1.0/src/earful/core/checker/l1.py +335 -0
- earful-0.1.0/src/earful/core/checker/l2.py +126 -0
- earful-0.1.0/src/earful/core/checker/m1.py +243 -0
- earful-0.1.0/src/earful/core/checker/m2.py +225 -0
- earful-0.1.0/src/earful/core/checker/memory.py +202 -0
- earful-0.1.0/src/earful/core/checker/policy.py +106 -0
- earful-0.1.0/src/earful/core/checker/report.py +233 -0
- earful-0.1.0/src/earful/core/checker/view.py +592 -0
- earful-0.1.0/src/earful/core/crosscheck.py +443 -0
- earful-0.1.0/src/earful/core/html.py +2300 -0
- earful-0.1.0/src/earful/core/ledger.py +183 -0
- earful-0.1.0/src/earful/core/predicate.py +51 -0
- earful-0.1.0/src/earful/core/schema.py +391 -0
- earful-0.1.0/src/earful/core/schemas/earful.bundle-1.schema.json +275 -0
- earful-0.1.0/src/earful/core/schemas/earful.case-1.schema.json +194 -0
- earful-0.1.0/src/earful/core/schemas/earful.ledger-1.schema.json +2157 -0
- earful-0.1.0/src/earful/core/search.py +1069 -0
- earful-0.1.0/src/earful/core/shrink.py +497 -0
- earful-0.1.0/src/earful/core/timebase.py +28 -0
- earful-0.1.0/src/earful/core/timeline.py +56 -0
- earful-0.1.0/src/earful/livekit/__init__.py +81 -0
- earful-0.1.0/src/earful/livekit/_compat.py +10 -0
- earful-0.1.0/src/earful/livekit/api.py +232 -0
- earful-0.1.0/src/earful/livekit/cases.py +177 -0
- earful-0.1.0/src/earful/livekit/clock.py +458 -0
- earful-0.1.0/src/earful/livekit/harness.py +751 -0
- earful-0.1.0/src/earful/livekit/playbook.py +320 -0
- earful-0.1.0/src/earful/livekit/providers.py +723 -0
- earful-0.1.0/src/earful/livekit/scenario.py +346 -0
- earful-0.1.0/src/earful/livekit/sink.py +371 -0
- earful-0.1.0/src/earful/livekit/tools.py +345 -0
- earful-0.1.0/src/earful/py.typed +0 -0
- earful-0.1.0/src/earful/pytest_plugin.py +185 -0
- earful-0.1.0/tests/breaks.py +326 -0
- earful-0.1.0/tests/bundles/lk-1.5.6.book_then_interrupt.A2-rule/manifest.json +79 -0
- earful-0.1.0/tests/bundles/lk-1.5.6.book_then_interrupt.A2-rule/minimal.case.json +44 -0
- earful-0.1.0/tests/bundles/lk-1.5.6.book_then_interrupt.A2-rule/minimal.ledger.jsonl +67 -0
- earful-0.1.0/tests/bundles/lk-1.5.6.book_then_interrupt.A2-rule/original.case.json +50 -0
- earful-0.1.0/tests/bundles/lk-1.5.6.book_then_interrupt.A2-rule/original.ledger.jsonl +67 -0
- earful-0.1.0/tests/bundles/lk-1.5.6.speak_over_new_turn.L2-rule-b/manifest.json +79 -0
- earful-0.1.0/tests/bundles/lk-1.5.6.speak_over_new_turn.L2-rule-b/minimal.case.json +44 -0
- earful-0.1.0/tests/bundles/lk-1.5.6.speak_over_new_turn.L2-rule-b/minimal.ledger.jsonl +49 -0
- earful-0.1.0/tests/bundles/lk-1.5.6.speak_over_new_turn.L2-rule-b/original.case.json +50 -0
- earful-0.1.0/tests/bundles/lk-1.5.6.speak_over_new_turn.L2-rule-b/original.ledger.jsonl +49 -0
- earful-0.1.0/tests/conftest.py +3 -0
- earful-0.1.0/tests/golden/lk-1.5.6.barge_in_mid_word.ledger.normalized.jsonl +49 -0
- earful-0.1.0/tests/golden/lk-1.5.6.book_then_interrupt.ledger.normalized.jsonl +67 -0
- earful-0.1.0/tests/golden/lk-1.5.6.speak_over_new_turn.ledger.normalized.jsonl +49 -0
- earful-0.1.0/tests/golden/lk-1.5.7.barge_in_mid_word.ledger.normalized.jsonl +49 -0
- earful-0.1.0/tests/golden/lk-1.5.7.book_then_interrupt.ledger.normalized.jsonl +67 -0
- earful-0.1.0/tests/golden/lk-1.5.7.speak_over_new_turn.ledger.normalized.jsonl +45 -0
- earful-0.1.0/tests/golden/lk-1.6.5.barge_in_mid_word.ledger.normalized.jsonl +49 -0
- earful-0.1.0/tests/golden/lk-1.6.5.book_then_interrupt.ledger.normalized.jsonl +67 -0
- earful-0.1.0/tests/golden/lk-1.6.5.speak_over_new_turn.ledger.normalized.jsonl +45 -0
- earful-0.1.0/tests/golden/lk-1.6.6.barge_in_mid_word.ledger.normalized.jsonl +49 -0
- earful-0.1.0/tests/golden/lk-1.6.6.book_then_interrupt.ledger.normalized.jsonl +53 -0
- earful-0.1.0/tests/golden/lk-1.6.6.speak_over_new_turn.ledger.normalized.jsonl +45 -0
- earful-0.1.0/tests/golden/lk-1.8.12.barge_in_mid_word.ledger.normalized.jsonl +49 -0
- earful-0.1.0/tests/golden/lk-1.8.12.book_then_interrupt.ledger.normalized.jsonl +54 -0
- earful-0.1.0/tests/golden/lk-1.8.12.speak_over_new_turn.ledger.normalized.jsonl +45 -0
- earful-0.1.0/tests/mutants.py +1756 -0
- earful-0.1.0/tests/test_checker.py +1084 -0
- earful-0.1.0/tests/test_cli.py +360 -0
- earful-0.1.0/tests/test_clock.py +134 -0
- earful-0.1.0/tests/test_contract_breaks.py +755 -0
- earful-0.1.0/tests/test_core_boundary.py +58 -0
- earful-0.1.0/tests/test_crosscheck.py +328 -0
- earful-0.1.0/tests/test_determinism.py +15 -0
- earful-0.1.0/tests/test_docs.py +213 -0
- earful-0.1.0/tests/test_effects.py +540 -0
- earful-0.1.0/tests/test_examples.py +65 -0
- earful-0.1.0/tests/test_formats.py +103 -0
- earful-0.1.0/tests/test_golden.py +31 -0
- earful-0.1.0/tests/test_historical_cases.py +64 -0
- earful-0.1.0/tests/test_html.py +702 -0
- earful-0.1.0/tests/test_inline.py +337 -0
- earful-0.1.0/tests/test_ledger_schema.py +399 -0
- earful-0.1.0/tests/test_playbook.py +230 -0
- earful-0.1.0/tests/test_pytest_plugin.py +174 -0
- earful-0.1.0/tests/test_search.py +1366 -0
- earful-0.1.0/tests/test_search_live.py +864 -0
- earful-0.1.0/tests/test_sink.py +126 -0
- earful-0.1.0/tests/test_streaming.py +160 -0
- earful-0.1.0/tests/test_timing.py +37 -0
- earful-0.1.0/tests/test_witnesses.py +736 -0
earful-0.1.0/.gitignore
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
# Contributing
|
|
2
|
+
|
|
3
|
+
## Set up
|
|
4
|
+
|
|
5
|
+
Earful needs [uv](https://docs.astral.sh/uv/) and nothing else installed by hand.
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
git clone https://github.com/smartfox96/earful && cd earful
|
|
9
|
+
scripts/make_env.sh 1.8.12 2026-11-14 # one pinned environment: .venvs/lk-1.8.12
|
|
10
|
+
.venvs/lk-1.8.12/bin/python -m pytest -m "not slow"
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
`make_env.sh` takes a livekit-agents release and the date its dependencies are resolved
|
|
14
|
+
as of. `docs/compatibility.md` lists the supported releases with their dates. The package
|
|
15
|
+
is installed editable, so the `earful` command and the pytest plugin in that environment
|
|
16
|
+
run the code in your checkout.
|
|
17
|
+
|
|
18
|
+
## The checks
|
|
19
|
+
|
|
20
|
+
| Command | What it runs | Time |
|
|
21
|
+
| --- | --- | --- |
|
|
22
|
+
| `.venvs/lk-1.8.12/bin/python -m pytest -m "not slow"` | Every test under a second, on one release | 20 s |
|
|
23
|
+
| `scripts/lint.sh` | ruff format, ruff, mypy, and that every deliberate break still applies. `--fix` reformats first | 20 s |
|
|
24
|
+
| `scripts/wheel_smoke.sh` | Builds the wheel and the source distribution, installs the wheel alone outside the repository and uses it | 5 s |
|
|
25
|
+
| `scripts/quickstart_check.sh` | Follows the README's quickstart from the wheel, with livekit-agents, outside the repository | 90 s |
|
|
26
|
+
| `scripts/check_all.sh` | All of the above, then on each of the five releases: every test, repeatability of the reference ledgers, the two historical cases and the replays | 8 min |
|
|
27
|
+
| `.venvs/lk-1.8.12/bin/python scripts/mutate.py` | Applies each deliberate break of `tests/mutants.py` and checks that a test fails | 30 min |
|
|
28
|
+
|
|
29
|
+
CI runs `check_all.sh`'s parts on every pull request, on Linux for the five releases and
|
|
30
|
+
on macOS for the oldest and the newest. The deliberate breaks run each night.
|
|
31
|
+
|
|
32
|
+
Run `check_all.sh` before opening a pull request that touches `src/`. A change can pass
|
|
33
|
+
on the newest release and fail on the oldest: some tests search a real session, and the
|
|
34
|
+
older releases have the two defects described in `docs/cases/`.
|
|
35
|
+
|
|
36
|
+
## Rules the code keeps
|
|
37
|
+
|
|
38
|
+
**The core imports no framework.** Everything under `src/earful/core/` works on plain
|
|
39
|
+
data. `tests/test_core_boundary.py` fails if a module there imports `livekit` or
|
|
40
|
+
`earful.livekit`. Anything that touches livekit-agents belongs in `src/earful/livekit/`,
|
|
41
|
+
and a name taken from inside livekit-agents, one that it does not export at its top
|
|
42
|
+
level, goes through `src/earful/livekit/_compat.py`.
|
|
43
|
+
|
|
44
|
+
**Time is integer microseconds.** Authors write seconds. Providers, the sink and the
|
|
45
|
+
backend convert once (`earful.core.timebase`) and compute in integers, so that an event on
|
|
46
|
+
a framework threshold is decided by the scenario and never by float rounding.
|
|
47
|
+
|
|
48
|
+
**The checker reads only the ledger.** A contract may use `world`, `llm`, `sink`,
|
|
49
|
+
`backend` and `harness` events. The framework's own `fw.*` events explain a run and
|
|
50
|
+
decide nothing (`docs/contracts.md`, section 2).
|
|
51
|
+
|
|
52
|
+
**The reference ledgers change only on purpose.** `tests/golden/` holds 15 ledgers that
|
|
53
|
+
every platform must reproduce byte for byte, and `tests/bundles/` the two reduced
|
|
54
|
+
historical failures. Checks never write there. If a change is meant to alter a ledger,
|
|
55
|
+
run `scripts/check_all.sh --update`, read the diff, and say in the pull request why each
|
|
56
|
+
change is expected. An unexplained diff in a reference ledger is a bug.
|
|
57
|
+
|
|
58
|
+
**The formats are versioned.** `earful.ledger/1`, `earful.case/1` and `earful.bundle/1`
|
|
59
|
+
each have a JSON Schema under `src/earful/core/schemas/`. An optional field can be added
|
|
60
|
+
within `/1`. A new kind, a new required field or a changed meaning is a new major version
|
|
61
|
+
(`docs/ledger.md`, Versioning). A test keeps `docs/ledger.md` and `docs/search.md` in step
|
|
62
|
+
with the schemas: a field the schema has and the page does not mention fails it.
|
|
63
|
+
|
|
64
|
+
**A change to behaviour comes with a deliberate break.** `tests/mutants.py` lists small
|
|
65
|
+
breaks of the code, each one piece of source text and what replaces it. When you add
|
|
66
|
+
behaviour, add the break that removes it and name the test that should catch it. When you
|
|
67
|
+
move code a break is anchored on, `scripts/lint.sh` fails until the break's text is
|
|
68
|
+
brought along. A break that no test can catch is a sign the code it breaks is not needed.
|
|
69
|
+
|
|
70
|
+
**Tests over a second are marked `slow`.** `pytest -m "not slow"` is the loop to work in.
|
|
71
|
+
|
|
72
|
+
**The README's quickstart is run.** Its two files are `examples/booking`, a test runs
|
|
73
|
+
them as shipped and with the fix, and `scripts/quickstart_check.sh` follows the steps from
|
|
74
|
+
a built wheel. A change to the example, to a message the README quotes or to a command it
|
|
75
|
+
uses fails one of them until the README is brought along.
|
|
76
|
+
|
|
77
|
+
## Adding a livekit-agents release
|
|
78
|
+
|
|
79
|
+
1. `scripts/make_env.sh <version> <date>`, with a date a few days after the release. This
|
|
80
|
+
writes `compat/lk-<version>.lock.txt`.
|
|
81
|
+
2. Add the release to `scripts/check_all.sh`, to the matrix in `.github/workflows/ci.yml`
|
|
82
|
+
and to `docs/compatibility.md`. A test fails while the three disagree.
|
|
83
|
+
3. `scripts/check_all.sh --update` records its three reference ledgers.
|
|
84
|
+
4. Read the new ledgers against those of the release before it
|
|
85
|
+
(`python scripts/ledger_diff.py`). Differences in behaviour belong in the pull request.
|
|
86
|
+
|
|
87
|
+
## Releasing
|
|
88
|
+
|
|
89
|
+
A release is a tag. `.github/workflows/release.yml` builds the wheel and the source
|
|
90
|
+
distribution from it, runs `scripts/wheel_smoke.sh` and `scripts/quickstart_check.sh`
|
|
91
|
+
against them, and publishes both to PyPI.
|
|
92
|
+
|
|
93
|
+
1. Set `version` in `pyproject.toml` and merge that to `main`.
|
|
94
|
+
2. Run the deliberate breaks on that commit: the `mutation` workflow, from the Actions
|
|
95
|
+
page. Every one has to be caught.
|
|
96
|
+
3. `git tag v<version>` on that commit of `main` and push the tag. The workflow refuses a
|
|
97
|
+
tag that does not name the version in `pyproject.toml`.
|
|
98
|
+
|
|
99
|
+
Publishing uses a PyPI trusted publisher, which is set up once on pypi.org for the
|
|
100
|
+
project `earful`: owner `smartfox96`, repository `earful`, workflow `release.yml`,
|
|
101
|
+
environment `pypi`. No token is stored in the repository.
|
|
102
|
+
|
|
103
|
+
The formats have their own versions (`docs/ledger.md`, Versioning). A release that
|
|
104
|
+
changes what a recorded ledger hashes to says so in its notes.
|
|
105
|
+
|
|
106
|
+
## Reporting what Earful finds
|
|
107
|
+
|
|
108
|
+
A broken contract is evidence, and what it is evidence of has to be worked out before
|
|
109
|
+
anything is said in public. Classify a failure as one of: a defect in the framework, a
|
|
110
|
+
default that is hazardous and documented, an error in the application or its backend, or
|
|
111
|
+
an artifact of the harness. Compare the behaviour with what livekit-agents documents
|
|
112
|
+
before attributing it to livekit-agents, reproduce it on purpose with `earful search`,
|
|
113
|
+
and keep the bundle so that someone else can replay it. `docs/cases/` shows the form.
|
|
114
|
+
|
|
115
|
+
## Pull requests
|
|
116
|
+
|
|
117
|
+
Work on a branch and open a pull request against `main`. Keep commit messages short: a
|
|
118
|
+
subject line and a few plain sentences on what changed and why. CI has to pass.
|
|
119
|
+
|
|
120
|
+
## Prose
|
|
121
|
+
|
|
122
|
+
Docs, comments and messages are written for developers who use voice-agent frameworks.
|
|
123
|
+
State what is true, with the command, the number or the event that shows it. Short
|
|
124
|
+
sentences, active voice, no selling adjectives. Define Earful's own terms the first time
|
|
125
|
+
and do not explain what the reader already knows.
|
earful-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
earful-0.1.0/NOTICE
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
Earful
|
|
2
|
+
Copyright 2026 The Earful Authors
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0.
|
|
5
|
+
|
|
6
|
+
This product includes software adapted from LiveKit Agents
|
|
7
|
+
(https://github.com/livekit/agents), Copyright 2023 LiveKit, Inc.,
|
|
8
|
+
licensed under the Apache License, Version 2.0:
|
|
9
|
+
|
|
10
|
+
- src/earful/livekit/clock.py is adapted from tests/virtual_time.py
|
|
11
|
+
(the virtual-time event loop and the wall-clock patch).
|
|
12
|
+
- The playout timing model in src/earful/livekit/sink.py follows
|
|
13
|
+
tests/fake_io.py.
|
|
14
|
+
- The scripted provider timing in src/earful/livekit/providers.py follows
|
|
15
|
+
tests/fake_vad.py, tests/fake_stt.py, tests/fake_llm.py and tests/fake_tts.py.
|
earful-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,318 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: earful
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Deterministic regression tests for real-time voice agents
|
|
5
|
+
Project-URL: Homepage, https://github.com/smartfox96/earful
|
|
6
|
+
Project-URL: Documentation, https://github.com/smartfox96/earful/blob/main/docs/testing.md
|
|
7
|
+
Project-URL: Repository, https://github.com/smartfox96/earful
|
|
8
|
+
Project-URL: Issues, https://github.com/smartfox96/earful/issues
|
|
9
|
+
License-Expression: Apache-2.0
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
License-File: NOTICE
|
|
12
|
+
Keywords: deterministic,livekit,pytest,regression,testing,voice agents
|
|
13
|
+
Classifier: Development Status :: 3 - Alpha
|
|
14
|
+
Classifier: Framework :: AsyncIO
|
|
15
|
+
Classifier: Framework :: Pytest
|
|
16
|
+
Classifier: Intended Audience :: Developers
|
|
17
|
+
Classifier: Operating System :: MacOS
|
|
18
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
19
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
24
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
25
|
+
Classifier: Topic :: Multimedia :: Sound/Audio :: Speech
|
|
26
|
+
Classifier: Topic :: Software Development :: Testing
|
|
27
|
+
Classifier: Typing :: Typed
|
|
28
|
+
Requires-Python: >=3.10
|
|
29
|
+
Requires-Dist: jsonschema>=4.18
|
|
30
|
+
Provides-Extra: livekit
|
|
31
|
+
Requires-Dist: livekit-agents<1.9,>=1.5.6; extra == 'livekit'
|
|
32
|
+
Description-Content-Type: text/markdown
|
|
33
|
+
|
|
34
|
+
# Earful
|
|
35
|
+
|
|
36
|
+
Deterministic regression tests for real-time voice agents. First target: LiveKit Agents
|
|
37
|
+
(Python, STT-LLM-TTS pipelines).
|
|
38
|
+
|
|
39
|
+
A voice agent can sound fine in a demo and still book a table twice or keep talking over
|
|
40
|
+
the caller. These failures live in timing: an interruption that lands while a tool is
|
|
41
|
+
running, a write that commits after its caller gave up.
|
|
42
|
+
|
|
43
|
+
Earful runs your real `AgentSession` on a virtual clock, against a scripted user, a
|
|
44
|
+
scripted model, a scripted voice and a fake backend, and records everything that happened
|
|
45
|
+
in a ledger. It checks seven contracts against that ledger, searches the timings and
|
|
46
|
+
backend faults near your scenario for a run that breaks one, and reduces what it finds to
|
|
47
|
+
a small case that replays the same way every time.
|
|
48
|
+
|
|
49
|
+
## Quickstart
|
|
50
|
+
|
|
51
|
+
Ten minutes, Python 3.10 or later. The two files below are in
|
|
52
|
+
[`examples/booking`](https://github.com/smartfox96/earful/tree/main/examples/booking). The output shown is from livekit-agents 1.8.12.
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
pip install "earful[livekit]" pytest
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
**1. An agent.** This one takes restaurant bookings. It is handed the service it books
|
|
59
|
+
with and knows nothing of Earful. Save it as `agent.py`.
|
|
60
|
+
|
|
61
|
+
<!-- examples/booking/agent.py -->
|
|
62
|
+
```python
|
|
63
|
+
"""A restaurant booking agent, as an application would write it. Nothing here knows of
|
|
64
|
+
Earful: the agent is handed the service it books with."""
|
|
65
|
+
|
|
66
|
+
from typing import Protocol
|
|
67
|
+
|
|
68
|
+
import livekit.agents as lk
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
class Reservations(Protocol):
|
|
72
|
+
"""The reservation service, as the agent uses it."""
|
|
73
|
+
|
|
74
|
+
async def create(self, party_size: int, *, idempotency_key: str | None = None) -> str:
|
|
75
|
+
"""Book a table and return the confirmation number."""
|
|
76
|
+
...
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
class BookingAgent(lk.Agent):
|
|
80
|
+
def __init__(self, reservations: Reservations) -> None:
|
|
81
|
+
super().__init__(instructions="You take reservations for a restaurant.")
|
|
82
|
+
self._reservations = reservations
|
|
83
|
+
|
|
84
|
+
@lk.function_tool
|
|
85
|
+
async def create_reservation(self, party_size: int) -> str:
|
|
86
|
+
"""Book a table for tonight.
|
|
87
|
+
|
|
88
|
+
Args:
|
|
89
|
+
party_size: Number of guests
|
|
90
|
+
"""
|
|
91
|
+
confirmation = await self._reservations.create(party_size)
|
|
92
|
+
return f"Booked. Confirmation {confirmation}."
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
**2. A test.** A stand-in for the reservation service, a scripted model, one user turn,
|
|
96
|
+
and two tests. Save it as `test_booking.py`.
|
|
97
|
+
|
|
98
|
+
<!-- examples/booking/test_booking.py -->
|
|
99
|
+
```python
|
|
100
|
+
"""One conversation with the booking agent, run as written and then searched."""
|
|
101
|
+
|
|
102
|
+
from agent import BookingAgent
|
|
103
|
+
|
|
104
|
+
from earful import effect
|
|
105
|
+
from earful.livekit import (
|
|
106
|
+
Case,
|
|
107
|
+
Intent,
|
|
108
|
+
ScriptedModel,
|
|
109
|
+
UserSpeech,
|
|
110
|
+
tool_failed,
|
|
111
|
+
tool_succeeded,
|
|
112
|
+
user_ever_said,
|
|
113
|
+
)
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
class FakeReservations:
|
|
117
|
+
"""Stands in for the reservation service. A booking is one write to Earful's backend,
|
|
118
|
+
which a search makes slow, failing or lossy."""
|
|
119
|
+
|
|
120
|
+
async def create(self, party_size: int, *, idempotency_key: str | None = None) -> str:
|
|
121
|
+
return await effect("book-table", {"party_size": party_size}, key=idempotency_key)
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
# The scripted model. It books when asked, tries once more if the tool fails, and tells
|
|
125
|
+
# the user the table is booked only after a call that succeeded.
|
|
126
|
+
BOOK = ("create_reservation", {"party_size": 4})
|
|
127
|
+
model = (
|
|
128
|
+
ScriptedModel()
|
|
129
|
+
.when(tool_succeeded(), say="Your table for four is booked.", claims=["book-table"])
|
|
130
|
+
.when(
|
|
131
|
+
tool_failed() & (lambda context: len(context.tool_results) >= 2),
|
|
132
|
+
say="Sorry, I could not book that. Please call the restaurant.",
|
|
133
|
+
)
|
|
134
|
+
.when(tool_failed(), say="One moment, let me try that again.", call=BOOK)
|
|
135
|
+
.when(user_ever_said("table"), say="Let me book that for you.", call=BOOK)
|
|
136
|
+
.otherwise(say="How can I help?")
|
|
137
|
+
)
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
def booking() -> Case:
|
|
141
|
+
return Case(
|
|
142
|
+
name="booking",
|
|
143
|
+
agent=lambda: BookingAgent(FakeReservations()),
|
|
144
|
+
speeches=[UserSpeech(start=0.5, end=2.5, transcript="A table for four tonight, please.")],
|
|
145
|
+
policy=model,
|
|
146
|
+
intents=[Intent("book-table")], # what the user wants done, once
|
|
147
|
+
backend_mode="keyed", # the service honours an idempotency key, if it is sent one
|
|
148
|
+
)
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
def test_the_conversation_as_written(earful):
|
|
152
|
+
earful.run(booking).assert_contracts()
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
def test_every_timing_and_fault_near_it(earful):
|
|
156
|
+
earful.explore(booking).assert_contracts()
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
**3. Run it.**
|
|
160
|
+
|
|
161
|
+
```bash
|
|
162
|
+
pytest
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
The conversation as written passes. The search fails, in about half a minute:
|
|
166
|
+
|
|
167
|
+
```
|
|
168
|
+
test_booking.py .F [100%]
|
|
169
|
+
|
|
170
|
+
=================================== FAILURES ===================================
|
|
171
|
+
_____________________ test_every_timing_and_fault_near_it ______________________
|
|
172
|
+
|
|
173
|
+
earful = <earful.pytest_plugin.Earful object at 0x...>
|
|
174
|
+
|
|
175
|
+
def test_every_timing_and_fault_near_it(earful):
|
|
176
|
+
> earful.explore(booking).assert_contracts()
|
|
177
|
+
E earful.core.checker.report.ContractFailure: booking on livekit-agents 1.8.12: 736 cases tried, 736 judged, 1 contract rule(s) broken
|
|
178
|
+
E
|
|
179
|
+
E A2/rule in 261 case(s)
|
|
180
|
+
E 2 durable effects for 'book-table'; the scenario authorized 1
|
|
181
|
+
E changed: backend.timeout 1, commit first
|
|
182
|
+
E also by changing: backend.timeout 1, commit first + backend.latency 1, backend.timeout 1, commit first + backend.wait 1, backend.timeout 1, commit later, backend.timeout 1, commit later + backend.wait 1
|
|
183
|
+
E breaks with backend.latency 1 from 0.000 s (no case exists beyond it) to 5.061 s (passes beyond it)
|
|
184
|
+
E breaks with backend.wait 1 from 0.000 s (no case exists beyond it) to 4.699 s (passes beyond it)
|
|
185
|
+
|
|
186
|
+
test_booking.py:57: ContractFailure
|
|
187
|
+
------------------------------------ earful ------------------------------------
|
|
188
|
+
search 1 (booking) breaks A2/rule: backend.timeout 1, commit first
|
|
189
|
+
case .earful/test_booking.py-test_every_timing_and_fault_near_it/search-1.booking.A2-rule.case.json
|
|
190
|
+
ledger .earful/test_booking.py-test_every_timing_and_fault_near_it/search-1.booking.A2-rule.ledger.jsonl
|
|
191
|
+
report .earful/test_booking.py-test_every_timing_and_fault_near_it/search-1.booking.A2-rule.html
|
|
192
|
+
=========================== short test summary info ============================
|
|
193
|
+
FAILED test_booking.py::test_every_timing_and_fault_near_it - earful.core.che...
|
|
194
|
+
========================= 1 failed, 1 passed in 25.19s =========================
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
Earful ran the conversation 736 times, each with one time moved or one backend fault
|
|
198
|
+
added. In 261 of them the restaurant holds two bookings. The simplest is the first one
|
|
199
|
+
listed: the reservation service takes the booking, the agent's tool stops waiting before
|
|
200
|
+
it hears back, the model is told the tool failed and tries again.
|
|
201
|
+
|
|
202
|
+
**4. Look at it.** The failure names a report. Open it in a browser:
|
|
203
|
+
|
|
204
|
+
```bash
|
|
205
|
+
open .earful/test_booking.py-test_every_timing_and_fault_near_it/search-1.booking.A2-rule.html
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
The page is a timeline of that run. On the backend lane the first write commits at 3.0 s
|
|
209
|
+
(a filled diamond). A second later its caller stops waiting (a clock) and the tool raises
|
|
210
|
+
(a cross). The model tries again, and a second write commits at 4.6 s. Under Verdicts, A2
|
|
211
|
+
links to the two commits it rests on. [`docs/report.md`](https://github.com/smartfox96/earful/blob/main/docs/report.md) explains every
|
|
212
|
+
mark.
|
|
213
|
+
|
|
214
|
+
**5. Keep it.** Reduce the failure to the smallest case that still breaks the rule, and
|
|
215
|
+
save it:
|
|
216
|
+
|
|
217
|
+
```bash
|
|
218
|
+
earful search test_booking:booking --keep A2/rule --out failures
|
|
219
|
+
earful replay failures/lk-1.8.12.booking.A2-rule --expect reproduced
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
The kept case is the conversation as written with one fault: the first write times out
|
|
223
|
+
for its caller. It gives the same ledger, byte for byte, on every run.
|
|
224
|
+
|
|
225
|
+
**6. Fix it.** The service honours an idempotency key and the agent never sends one. In
|
|
226
|
+
`agent.py`:
|
|
227
|
+
|
|
228
|
+
```python
|
|
229
|
+
confirmation = await self._reservations.create(
|
|
230
|
+
party_size, idempotency_key=f"table-for-{party_size}"
|
|
231
|
+
)
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
```bash
|
|
235
|
+
pytest # 2 passed
|
|
236
|
+
earful replay failures/lk-1.8.12.booking.A2-rule --expect clean # the kept failure is gone
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
The kept failure is now a regression test: `earful replay --expect clean` fails if the
|
|
240
|
+
double booking ever comes back.
|
|
241
|
+
|
|
242
|
+
To test your own agent, start from [`docs/testing.md`](https://github.com/smartfox96/earful/blob/main/docs/testing.md). A tool that
|
|
243
|
+
talks to its service directly needs no stand-in: declare it as an effect in the test, and
|
|
244
|
+
the agent stays as it is.
|
|
245
|
+
|
|
246
|
+
## What is checked
|
|
247
|
+
|
|
248
|
+
Each contract is decided from the ledger alone ([`docs/contracts.md`](https://github.com/smartfox96/earful/blob/main/docs/contracts.md)).
|
|
249
|
+
|
|
250
|
+
| | Contract | It fails when |
|
|
251
|
+
| --- | --- | --- |
|
|
252
|
+
| A1 | Retired intent | The user cancels or corrects something and a new write for it starts anyway |
|
|
253
|
+
| A2 | One logical effect | One request leaves more durable effects than it was allowed |
|
|
254
|
+
| A3 | Truthful confirmation | The user hears that something succeeded before the backend recorded it |
|
|
255
|
+
| M1 | Played vs. remembered | What the agent remembers saying is not what was played |
|
|
256
|
+
| M2 | Turn integrity | A model call is not shown the conversation that happened |
|
|
257
|
+
| L1 | Progress | A turn that is owed a reply does not get one in time |
|
|
258
|
+
| L2 | Interruption | The agent is audible while the user holds the floor |
|
|
259
|
+
|
|
260
|
+
A verdict is pass, fail or unobservable. A failed contract is evidence about one run
|
|
261
|
+
against what the test declared. Whether it is a defect of the framework, of the
|
|
262
|
+
application or of the test is a separate question, and `docs/contracts.md` says how to
|
|
263
|
+
answer it.
|
|
264
|
+
|
|
265
|
+
## What it is not
|
|
266
|
+
|
|
267
|
+
Earful does not grade conversations, prompts, recognition accuracy or voice quality. The
|
|
268
|
+
model, the recognizer and the voice are scripted, so it says nothing about how a real
|
|
269
|
+
provider behaves. Playout is what a simulated sink consumed: it does not measure a
|
|
270
|
+
network, a client buffer or what a caller heard. It does not record production calls.
|
|
271
|
+
|
|
272
|
+
## Two known defects, reproduced
|
|
273
|
+
|
|
274
|
+
Both were found by the same search and are checked by the same contracts on every
|
|
275
|
+
supported release. Both also break the same rules when the reduced case is run on the
|
|
276
|
+
real clock (`earful crosscheck`).
|
|
277
|
+
|
|
278
|
+
| Issue | What happens | Fails on | Passes on |
|
|
279
|
+
| --- | --- | --- | --- |
|
|
280
|
+
| [livekit/agents#3702](https://github.com/smartfox96/earful/blob/main/docs/cases/3702-tool-result-lost-on-interruption.md) | A tool result is lost when its reply is interrupted, and the booking is made twice | 1.5.6, 1.5.7, 1.6.5 | 1.6.6, 1.8.12 |
|
|
281
|
+
| [livekit/agents#5509](https://github.com/smartfox96/earful/blob/main/docs/cases/5509-reply-starts-over-new-turn.md) | A reply starts playing after the user has begun a new turn | 1.5.6 | 1.5.7, 1.6.5, 1.6.6, 1.8.12 |
|
|
282
|
+
|
|
283
|
+
```bash
|
|
284
|
+
earful replay tests/bundles/lk-1.5.6.book_then_interrupt.A2-rule
|
|
285
|
+
earful report tests/bundles/lk-1.5.6.book_then_interrupt.A2-rule -o report.html
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
## Supported
|
|
289
|
+
|
|
290
|
+
livekit-agents 1.5.6, 1.5.7, 1.6.5, 1.6.6 and 1.8.12, on Linux and macOS, Python 3.10
|
|
291
|
+
to 3.14. [`docs/compatibility.md`](https://github.com/smartfox96/earful/blob/main/docs/compatibility.md) has the exact dependency sets
|
|
292
|
+
and what CI runs for each.
|
|
293
|
+
|
|
294
|
+
## Documentation
|
|
295
|
+
|
|
296
|
+
| Page | What it covers |
|
|
297
|
+
| --- | --- |
|
|
298
|
+
| [`docs/testing.md`](https://github.com/smartfox96/earful/blob/main/docs/testing.md) | Writing a test: the scenario, the scripted model, side effects, pytest, the command line, the real clock |
|
|
299
|
+
| [`docs/report.md`](https://github.com/smartfox96/earful/blob/main/docs/report.md) | The HTML report, lane by lane |
|
|
300
|
+
| [`docs/contracts.md`](https://github.com/smartfox96/earful/blob/main/docs/contracts.md) | The seven contracts, their evidence and their policies |
|
|
301
|
+
| [`docs/search.md`](https://github.com/smartfox96/earful/blob/main/docs/search.md) | The search, the reduction of a failing case, and the bundle that is kept |
|
|
302
|
+
| [`docs/ledger.md`](https://github.com/smartfox96/earful/blob/main/docs/ledger.md) | Every event in a ledger, and what makes a run valid |
|
|
303
|
+
| [`docs/compatibility.md`](https://github.com/smartfox96/earful/blob/main/docs/compatibility.md) | Supported releases and what is tested |
|
|
304
|
+
| [`docs/gate0-feasibility.md`](https://github.com/smartfox96/earful/blob/main/docs/gate0-feasibility.md), [`gate1-core.md`](https://github.com/smartfox96/earful/blob/main/docs/gate1-core.md), [`gate2-historical-proof.md`](https://github.com/smartfox96/earful/blob/main/docs/gate2-historical-proof.md) | The evidence each stage of the project rests on |
|
|
305
|
+
|
|
306
|
+
## Layout
|
|
307
|
+
|
|
308
|
+
- `src/earful/core/` is the portable part: ledger, validator, contract checker, effect
|
|
309
|
+
backend, case format, search, shrinker, bundle, report. It imports no framework.
|
|
310
|
+
- `src/earful/livekit/` is the adapter: virtual clock, scripted providers, tool witness,
|
|
311
|
+
clocked sink, harness.
|
|
312
|
+
- `examples/` holds the quickstart. `tests/golden/` and `tests/bundles/` hold the
|
|
313
|
+
reference ledgers and the two kept failures.
|
|
314
|
+
|
|
315
|
+
## Contributing
|
|
316
|
+
|
|
317
|
+
[`CONTRIBUTING.md`](https://github.com/smartfox96/earful/blob/main/CONTRIBUTING.md) covers setup, the checks and the rules the code
|
|
318
|
+
keeps. Apache-2.0.
|