# Yunke Web — offline missed/busy contract

## What it does

Provides a strict, fake-tested route from a single task's explicit missed/busy result to
the shared redial chain and final missed follow-up. **No vendor reason code is enabled.**
The production dictionary is empty; unknown statuses/reasons and incomplete identity stay
held with no settlement, new association, redial or message.

This is engineering support for a candidate read-side contract, not a claim that a real
missed/busy response has been verified. The connected result contract remains unchanged.
No runtime Yunke gate, App login, task creation or recording download is enabled here.

## How it works

### Evidence boundary

Offline APK 2.0.20 evidence confirms `TaskCallStatusEnum.NOT_CONNECTED = 2` and the
write-side `sd.d0` keys `callStatus`, `callTime`, `callId`, `ids`, and optional integer
`notConnectedReason`. `TaskStatusReporter` obtains that reason from unconnected-audio
classification. **It is not Android Telecom's DisconnectCause namespace.** In particular,
Android BUSY=7 must not be copied into the vendor reason map.

These write-side declarations do not prove the read-side field echoes, their ID meaning,
count semantics or the reason dictionary. A vendor-confirmed schema or correctly scoped
existing result is still required before any real mapping is populated. Fake codes
401/402 in tests deliberately make no claim about the vendor's numbers.

### Closed-by-default normalization

`services.yunke_app_results.verified_unconnected_reasons` is an empty PHP array by
default. Only confirmed integer vendor codes may map to `AiVoiceCall::STATUS_NO_ANSWER`
or `AiVoiceCall::STATUS_BUSY`. There is no environment variable or phone/UI control that
silently supplies a guessed dictionary. Test configuration overrides never persist it.

For a candidate row, the mapper requires all existing identity/uniqueness checks:
accepted task, literal matching company/user/task, exact child/call IDs, agreeing aliases,
exactly one returned result and `callNum=phoneCallCount=1`. It additionally requires
integer status 2, an integer reason present in that explicit dictionary, and positive
integer `callTime` in milliseconds. Connected evidence (positive connected duration or
turnOnTime, connected hangup flags or analysis) conflicts with this missed-only contract.
Strings, unknown values, missing IDs, multiple attempts and contradictory data stay held.

A validated missed-only row does not request `callDetail`: a missing recording must never
be deduced from a failed detail/auth request. Results-page authentication, tenant and
business errors still throw; they are never converted to empty results or a missed call.

The normalized outcome records its explicit per-call ID and dial timestamp with provenance.
Duration, end time, recording, transcript, summary, intent and cost remain unknown/absent;
no customer turns or zero-cost claim is fabricated. IDs and terminal outcome commit in the
existing binding transaction. The new missed/busy terminal digest includes outcome and
native reason so contradictory replays stay held. Existing completed-result digests keep
their original format and their recorded turns remain unchanged.

### Shared after-call rules

A confirmed miss enters `AiCallRedial`, using the control profile's policy in either pilot
arm. Each retry preserves the arm, profile and root, rechecks time/contact/attendance/caps,
and needs a new local attempt and its own single-number task. Vendor auto-redial remains
zero in the existing caller contract. Only the final miss queues `KIND_MISSED`.

Replayed result snapshots cannot queue the redial or final message again. At-least-once
queue deliveries of call-backed thanks/missed also share the existing send lock and
recheck `followup_sent`. This is not an atomic guarantee across an external send and its
local acknowledgement. Explicit contact refusal stops customer follow-ups. No new sender or worker is installed.

## Reference usage

`YunkeMissedRedialTest` uses a fake caller (local synthetic binding receipts, no import
HTTP), fake Web result pages, fake queues and synthetic reason mappings. It drives three
attempts at two-hour gaps, including BUSY, verifies one final missed job and unchanged
pilot identity, and proves unknown/contradictory/cross-tenant data cannot settle or bind.
It also checks that an empty dictionary stays closed and that no detail/recording endpoint
is requested. Tests do not stand in for real enum/schema verification.

## Related files

- `src/VoiceAgent/Support/YunkeWebCallMapper.php` — strict outcome/recording dispatch split.
- `src/VoiceAgent/Services/YunkeAppResultIngest.php` — existing Web collector and pending effects.
- `src/VoiceAgent/Repositories/YunkeAppCallBindingRepository.php` — binding/hash transaction.
- `src/VoiceAgent/Support/YunkeCallPresentation.php` — fixed held-reason labels.
- `config/services.php` — empty verified reason dictionary; runtime flags unchanged.
- `src/VoiceAgent/Services/AiCallRedial.php`, `app/Jobs/Automation/SendAiCallFollowUp.php` — existing shared chain and send idempotency.
- `tests/Feature/VoiceAgent/YunkeMissedRedialTest.php` — fake-only complete branch.
