# Green behavior tests, reduced static call resolution

Tested 2026-10-02 on Linux x86_64, CPython 3.12.14.
ArchKeel source: https://github.com/rapiddweller/archkeel/tree/34017671559a19bfe5fd909689400fb5fb0a6317
Installed version: 0.8.5.dev1+g340176715 (a commit after release 0.8.4, not a released 0.8.5).
The commit, not the shallow-clone-dependent version string, identifies the implementation.

Requires Python, Git and network access for installation. Run from the extracted directory:

```sh
python3.12 -m venv .venv
.venv/bin/python -m pip install -r requirements.txt
.venv/bin/python -B run.py --output ./replay
```

`replay` must not already exist. On Windows use `.venv\Scripts\python.exe`.
The runner creates a new local Git repository and bare local origin, runs the identical unittest suite on both versions, creates an accepted measurement lock, publishes a local expectation before the candidate, and invokes the actual `archkeel check` CLI. It exits 0 only after checking the expected rejection and successful tests. The nested ArchKeel check is expected to exit 1. Individual commands and their observed exits are written to `replay/commands.json`.

Behavior command in each revision (run by the runner from `replay/A`):

```sh
python -B -m unittest -v test_behavior
```

ArchKeel command (B, E, H and DIGEST are generated Git commit and SHA-256 values, not literal inputs):

```sh
archkeel check --root replay/A --baseline "$B" \
  --expectation-commit "$E" --head "$H" \
  --expected expectation.json --expected-digest "$DIGEST" \
  --branch candidate --accepted-branch main \
  --host-records replay/A-host-records.json \
  --output replay/A-check.stdout.json
```

The runner also executes `archkeel report --root … --output …` before the change, and `archkeel report --root … --only calls --output …` afterward. `commands.json` records the exact arguments, including the check output path. Reports are produced by ArchKeel itself.

## Expected and observed

| Check | Expected | Observed |
|---|---|---|
| Before behavior | 8 tests, exit 0 | 8 tests, exit 0 |
| After behavior | same 8 tests, exit 0 | same 8 tests, exit 0 |
| Unresolved calls | rise | 0 → 1 |
| Unresolved / total calls | rise | 0/3 → 1/1 |
| Violations | no new violation | 0 → 0 |
| ArchKeel check | FAIL, exit 1 | expectation_fulfilled: FAIL, exit 1 |

The exact failures are:

```text
regression check failed in calls_unresolved: 0->1
regression check failed in unresolved_ratio: 0/3->1/1
```

The new unresolved expression is `handlers[key]`, `sample.work.run`, `sample/work.py:6`, reason `expression is dynamic`. The baseline counts two helper calls and the explicit KeyError constructor. The candidate contains one dynamic call. These are static call sites, not execution counts.

The tests cover credit, debit, zero, negative and large integer amounts, repeated calls, unknown and empty operation names. A separate negative control deliberately changes debit to add instead of subtract: 5 of 8 tests fail, exit 1 (`evidence/negative-control.txt`). This checks that the suite detects a real behavior defect.

## Boundaries

- This is a separate behavior-preserving demo, not the upstream A-dispatch fixture. That fixture changes behavior and runs no behavior tests.
- Eight passing tests demonstrate the specified cases, not equivalence for every possible Python object or software correctness.
- Only `sample` is scanned. The minimal contract has no architecture rules. `declared_rules: PASS` is not proof of a meaningful application architecture; the result demonstrates the measurement regression gate.
- Host events and CI lock authorship are simulated locally. `host_order: PASS` demonstrates processing supplied records, not authenticated real-host publication order.
- This proves reduced static call resolution, not a runtime defect or a claim that dictionary dispatch is inherently bad. Whether to accept that trade-off is an engineering decision.
- This is Python evidence. It does not establish Dart call-analysis support.
- The website's 0.8.3 shop Target report is a separate exploration example, not this regression's result.
- Git commit IDs and metadata can differ on replay. The test outcomes and measured regression are the intended reproducible results.

`evidence/` contains the actual outputs from the documented run, unchanged. `SHA256SUMS` covers the delivered sources and evidence. The runner is adapted from ArchKeel's MIT-licensed `fixtures/reproduce_milestone1.py` at the pinned commit.
