fix(webui): reconcile running turns on reconnect (#6715)

* fix(webui): reconcile running turns on reconnect

* test(webui): verify only the current turn-sync policy
This commit is contained in:
chengyongru authored and GitHub committed 2026-11-19 16:08:20 +08:00
1 parent b453de9cf6
commit 094bac0dc3
25 files changed
+455 -226

No files matched your search

+9 -12
View File
@@ -1,8 +1,8 @@
# WebUI turn synchronization: bounded TLC models
These models check the missed-completion/stuck-busy ordering in [PR #6683](https://github.com/HKUDS/nanobot/pull/6683): a terminal frame is lost, a newer turn starts, and recovery history explicitly completes the older turn. Completing that turn must not stop the newer one or discard content that history has not covered.
These models check recovery from a missed terminal frame. History can explicitly complete an older turn without stopping a newer one or discarding uncovered content. Independently, trusted attach can retire a previously confirmed owner absent from the Gateway's complete live-ID set, even if paged history supplies no completion ID.
**These are handwritten abstractions of selected current-implementation transitions, not mechanical verification of TypeScript or proof of all WebUI/Gateway behavior.** The default runner checks twelve positive configurations. Two current-policy missing-evidence cases run separately and retain temporal counterexamples; they are never counted as positive passes.
**These are handwritten abstractions of selected transitions, not mechanical verification of implementation code or proof of all WebUI/Gateway behavior.** The runner checks thirteen configurations by default.
## Files and source mapping
@@ -14,8 +14,9 @@ These models check the missed-completion/stuck-busy ordering in [PR #6683](https
| `CacheHandoff.tla` | Shared full-page publication, superseded own reads, one mounted whole-snapshot adopter and rejected stale callbacks. |
| `SharedRequests.tla` | Per-key request sharing, consumer cancellation, invalidation/replacement, reconnect and stale/late delivery. |
| `CompletionAuthority.tla` | Exact-ID ledger closure, coverage-dependent content fencing, anonymous recovery and another-chat isolation. |
| `AttachReconciliation.tla` | Trusted attach snapshot and terminal fanout ordering; loss-marked ownership, stale socket callbacks and lifecycle-only absence reconciliation independent of paged history. |
The source owners are `client-run-ledger.ts`, `nanobot-client.ts`, `canonical-run-snapshot.ts`, `latest-thread-request.ts`, `thread-transcript.ts`, `webui-thread-cache.ts`, `useReconnectRuns.ts`, `useNanobotStream.ts` and `ThreadShell.tsx`. The runner can record their hashes; the mapping still requires human review. [`USAGE-LIFECYCLE.md`](USAGE-LIFECYCLE.md) details the dynamic full-page mapping.
The runner can record the relevant client and Gateway source hashes; the mapping still requires human review. [`USAGE-LIFECYCLE.md`](USAGE-LIFECYCLE.md) details the dynamic full-page mapping. [`ATTACH-RECONCILIATION.md`](ATTACH-RECONCILIATION.md) describes the separate attach model, fairness assumptions, and reference runs.
The Gateway owns execution. The request registry owns cancellation and stale-response eligibility; `ThreadTranscript` owns content admission/coverage; `ClientRunLedger` alone owns the client's observed run state. Fresh full pages supply explicit completion facts even when mount/cache eligibility prevents content adoption. Eligible history is cached before completion notifications. The mounted transcript alone adopts whole snapshots; only an unmounted reader can perform background adoption, and only for an eligible idle page. Lifecycle-only closure preserves uncovered content and independent anonymous recovery. Initial cached seeds are not fresh evidence. Mounted fragments hand off completed IDs only when their gap/admission rules expose them.
@@ -26,8 +27,9 @@ The Gateway owns execution. The request registry owns cancellation and stale-res
- `PartialCompletionPreservesRecovery` and `LifecycleOnlyPreservesContentAndRecovery`: named completion preserves independent anonymous recovery and uncovered content.
- `MountedFragmentRequiresAcceptance`, `ActiveUnmountedSnapshotIsNotAdopted`, `CachePrecedesIdleNotification` and `SoleCanonicalActor`: content admission, notification ordering and single-owner boundaries.
- `EventuallyIdle` and `EventuallyRequestsDrain`: conditional eventual quiescence under the stated finite workload and fairness assumptions.
- `LifecycleSafety` and `EventuallyRetiredOwnersSettle`: after healthy reconnection, retired owners settle without completion evidence from history and without closing live owners.
## Scope and limits
## History partition scope and limits
The fixed-mount submodel has one chat, two sequential server turns, at most one disconnect/reconnect and one logical latest-history read. `Mounted` is fixed for a run. Request, server capture and response processing are separate actions. Full pages contain all completed/observed IDs within the bounded turns. A real selected page can omit an ID, so this assumption matters. Mounted full-page facts are assumed to reach reconciliation; cache routing and dynamic selection are checked separately.
@@ -44,20 +46,15 @@ Requirements: Python 3.9+, Java and the official [`tla2tools.jar` from TLA+ v1.7
From this directory in PowerShell:
```powershell
# Twelve positive checks: every finite graph must exhaust without a counterexample.
python -B .\run_tlc.py --jar 'C:\path\to\tla2tools.jar'
if ($LASTEXITCODE -ne 0) { throw 'TLC check failed' }
# Current-policy missing-evidence limits, separate from positive checks.
python -B .\run_tlc.py --limits --jar 'C:\path\to\tla2tools.jar'
if ($LASTEXITCODE -ne 0) { throw 'Missing-evidence classification changed' }
```
Use `--case revised-unmounted-live` (repeatable) for individual cases. `--output-root` must name a new directory outside the checkout; otherwise a private temporary directory is allocated. `--implementation-root <repository-root>` records the relevant source hashes without asserting a checked refinement. Models/configs are copied into the external output directory before Java starts. Logs, state graphs and generated traces stay there. `manifest.json` records input/jar hashes, commands, exit statuses and graph counts. Defaults are two workers, a 1536 MiB heap and a 600-second per-case timeout; cases run sequentially.
A positive result requires exit 0, TLC's no-error completion message and an empty state queue. Timeouts, specification errors and other exits fail the runner. Limit cases instead require exit 13 and the temporal-violation signature, labeled `LIMITATION_COUNTEREXAMPLE`. A zero runner exit for `--limits` means the expected limitations were reproduced, not that liveness passed.
A passing case requires exit 0, TLC's no-error completion message and an empty state queue. Counterexamples, timeouts and specification errors fail the runner.
## Reference positive results
## Reference results
| Config | Checked scope | Distinct states |
| --- | --- | ---: |
@@ -74,4 +71,4 @@ A positive result requires exit 0, TLC's no-error completion message and an empt
| `handoff-fullpage-active` | Pending newer turn; shared-page handoff and sole canonical actor | 80 |
| `handoff-fullpage-idle` | Idle shared-page handoff and sole canonical actor | 80 |
`--case requests-two` and `--case lifecycle-fullpage-two-chats` expose larger current-policy products, not additional claimed positive results. The separate `--limits` cases retain two real evidence boundaries: a failed needed read without a later recovery read, and a fragment omitting the needed completed ID without a later bridge/read. Neither condition guarantees eventual idle.
See [Attach reconciliation](ATTACH-RECONCILIATION.md#reproduce-and-evidence) for the `attach-reconciliation` config and its graph counts. The larger `requests-two` and `lifecycle-fullpage-two-chats` configurations are optional; they are not part of the reference run.