# Yunke — bounded owner-number CLI test

Part of the [AI Voice Agent](/docs/modules_handbook/shared/voice-agent/readMe.md).
Added 2026-10-27. This is an offline-tested implementation, not live acceptance or
permission to call. No server was updated, no gate enabled and no task submitted for
this change.

## What it does

`voice-agent:yunke-self-test` previews by default. A separately approved invocation
with `--confirm` and an exact `--database` can submit one owner-number task through
the existing `PlaceAiVoiceCall` / Yunke transport, including outside business hours.
It never activates a profile, changes runtime flags, logs in, queues a call or retries.
The database option checks the operator's reviewed target name; it cannot prove
database isolation by itself. Review the host/database before execution.

The ordinary profile window is whatever same-day hours the profile sets (any hours since
2026-11-10). A typed, in-memory,
console-only `YunkeSelfTestWindow` grants the exception to one exact profile, number
and newly created unlinked call UUID. Only this typed context changes both placement
and adapter time checks. Persisted JSON metadata cannot grant or resume an exception.
Ordinary funnel/HTTP calls, Retell and `ignoreQuietHours` behavior are unchanged.

## How it works

- The profile must be a platform `app_single_task` phone profile with daily cap 1.
  The runtime allowlist must contain exactly the requested E.164 owner number.
- Existing calling/read/result/watch controls and an active, configured profile are
  required for confirmed execution. The command refuses enabled aftermath, recording
  copies, watch alerts or legacy App reads, and refuses local simulated calling.
  Saving the allowlist invalidates the Web check and pauses controls: save first,
  check the current session, then enable approved controls through the console.
- The temporary period starts in the current local minute. `startTime` uses the actual
  current timestamp; `endTime` and the period end agree and are no later than 20 minutes
  after issue, rounded down to a minute. A test near midnight ends at 23:59 on the
  same local date; the final minute refuses a new test. No interval crosses midnight.
  The task does not retain a 10:00 start or 21:00 expiry.
- Frozen primitive boundaries are stored in `meta.yunke_self_test`, alongside the
  existing submission/binding evidence. The live context is bound once; expired,
  reused, wrong-profile/provider or customer-linked contexts cannot grant an exception.
  A previously committed accepted/unknown UUID still recovers its receipt without
  another send. The normal cap, market, blocking and runtime controls remain enforced.
- One confirmed invocation makes at most one create request. Uncertainty remains
  pending and exits unsuccessfully; rejection also stops. Do not rerun a consumed
  authorization. The cap is a submission guard, not proof of the vendor dial count.

## Reference usage

On the reviewed isolated dev-yc test site, after preparing the exact owner-number
allowlist, preview without creating a row or contacting Yunke:

```bash
php artisan voice-agent:yunke-self-test 14 '+60<owner-number>'
```

After separate authorization for the displayed number/time/database and phone-side
stop plan, prepare the profile/runtime controls and run exactly once:

```bash
php artisan voice-agent:yunke-self-test 14 '+60<owner-number>' --database=peta_yc_dev --confirm
```

These are templates, not an authorized real recipient. Do not enable customer funnel
routing, substitute a customer number or bypass consent/blocking. Use the project's
PHP 8.4 runtime. The existing `voice-agent:test-call` is Retell-only.

The command returns after submission; it does not monitor/hang up the phone. Observe
the device, answer on the owner handset, and stop the corresponding phone task by the
bound or on an exception. A bounded request does not prove the vendor honored its
expiry or disabled every retry path. Local pause cannot cancel an accepted task, and
force-stopping the App before upload can lose analysis. Keep the explicit stop/upload
plan; do not leave a real test unattended.

Collect only the existing binding using `voice-agent:yunke-watch` or the explicit Web
collector, with aftermath/media/alerts disabled. Test-database writes include connection
and profile controls, `ai_voice_calls`, `yunke_app_call_bindings` and
`ai_voice_call_turns`. A second watch may skip a completed record; verify ingestion
idempotency by recollecting that exact binding with `YunkeAppResultIngest::collectWeb`
and comparing counts/content. Unknown outcomes remain held. Do not close an ambiguous
call as never placed merely because the phone is currently idle.

## Related files

- `TestYunkeOwnerCall.php`, `YunkeSelfTestWindow.php` — explicit CLI entry and bound scope.
- `PlaceAiVoiceCall.php`, `YunkeConversationalCaller.php` — matching local/vendor windows.
- `YunkeAppCallerTest.php` — early-morning wire bounds, preview/confirmation, cap,
  identity/customer/forged/expired scopes, midnight and uncertain-send regressions.
