mustflow 2.116.1 → 2.116.2
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.
- package/package.json +1 -1
- package/templates/default/i18n.toml +72 -6
- package/templates/default/locales/en/.mustflow/skills/INDEX.md +37 -11
- package/templates/default/locales/en/.mustflow/skills/compiler-engineering-review/SKILL.md +477 -0
- package/templates/default/locales/en/.mustflow/skills/compiler-engineering-review/references/compiler-diagnostics-abi-linker-checklist.md +778 -0
- package/templates/default/locales/en/.mustflow/skills/compiler-engineering-review/references/compiler-generators-properties-checklist.md +501 -0
- package/templates/default/locales/en/.mustflow/skills/compiler-engineering-review/references/compiler-test-strategy-differential-checklist.md +498 -0
- package/templates/default/locales/en/.mustflow/skills/compiler-engineering-review/references/debug-symbol-symbolication-checklist.md +412 -0
- package/templates/default/locales/en/.mustflow/skills/compiler-engineering-review/references/ir-design-ssa-pass-pipeline-checklist.md +759 -0
- package/templates/default/locales/en/.mustflow/skills/compiler-engineering-review/references/miscompile-reduction-ir-checklist.md +434 -0
- package/templates/default/locales/en/.mustflow/skills/cross-platform-filesystem-safety/SKILL.md +55 -36
- package/templates/default/locales/en/.mustflow/skills/cross-platform-filesystem-safety/references/path-containment-handle-checklist.md +251 -0
- package/templates/default/locales/en/.mustflow/skills/file-upload-security-review/SKILL.md +133 -32
- package/templates/default/locales/en/.mustflow/skills/file-upload-security-review/references/file-upload-parser-ssrf-resource-checklist.md +306 -0
- package/templates/default/locales/en/.mustflow/skills/formal-verification-review/SKILL.md +310 -0
- package/templates/default/locales/en/.mustflow/skills/formal-verification-review/references/formal-concurrency-model-checking-smt-checklist.md +457 -0
- package/templates/default/locales/en/.mustflow/skills/formal-verification-review/references/formal-contracts-modeling-checklist.md +434 -0
- package/templates/default/locales/en/.mustflow/skills/formal-verification-review/references/formal-memory-bounds-ci-checklist.md +509 -0
- package/templates/default/locales/en/.mustflow/skills/fuzz-harness-review/SKILL.md +439 -0
- package/templates/default/locales/en/.mustflow/skills/fuzz-harness-review/references/fuzz-harness-campaign-checklist.md +379 -0
- package/templates/default/locales/en/.mustflow/skills/fuzz-harness-review/references/fuzz-oracle-triage-ci-checklist.md +307 -0
- package/templates/default/locales/en/.mustflow/skills/idempotency-integrity-review/SKILL.md +48 -28
- package/templates/default/locales/en/.mustflow/skills/idempotency-integrity-review/references/operation-ordering-stale-write-checklist.md +259 -0
- package/templates/default/locales/en/.mustflow/skills/input-boundary-validation-review/SKILL.md +329 -0
- package/templates/default/locales/en/.mustflow/skills/input-boundary-validation-review/references/input-boundary-security-checklist.md +319 -0
- package/templates/default/locales/en/.mustflow/skills/input-event-synchronization-review/SKILL.md +306 -0
- package/templates/default/locales/en/.mustflow/skills/input-event-synchronization-review/references/input-session-state-checklist.md +298 -0
- package/templates/default/locales/en/.mustflow/skills/input-event-synchronization-review/references/remote-input-transport-interaction-checklist.md +328 -0
- package/templates/default/locales/en/.mustflow/skills/interpreter-engineering-review/SKILL.md +353 -0
- package/templates/default/locales/en/.mustflow/skills/interpreter-engineering-review/references/interpreter-diagnostics-recovery-checklist.md +267 -0
- package/templates/default/locales/en/.mustflow/skills/interpreter-engineering-review/references/interpreter-execution-closure-performance-checklist.md +428 -0
- package/templates/default/locales/en/.mustflow/skills/interpreter-engineering-review/references/interpreter-gc-verification-checklist.md +457 -0
- package/templates/default/locales/en/.mustflow/skills/interpreter-engineering-review/references/interpreter-semantics-runtime-checklist.md +391 -0
- package/templates/default/locales/en/.mustflow/skills/modal-loop-reentrancy-review/SKILL.md +294 -0
- package/templates/default/locales/en/.mustflow/skills/modal-loop-reentrancy-review/references/modal-loop-reentrancy-checklist.md +290 -0
- package/templates/default/locales/en/.mustflow/skills/modal-loop-reentrancy-review/references/nested-modal-state-lifetime-checklist.md +297 -0
- package/templates/default/locales/en/.mustflow/skills/name-resolution-integrity-review/SKILL.md +252 -0
- package/templates/default/locales/en/.mustflow/skills/name-resolution-integrity-review/references/dns-network-resolution-checklist.md +394 -0
- package/templates/default/locales/en/.mustflow/skills/name-resolution-integrity-review/references/language-symbol-resolution-checklist.md +282 -0
- package/templates/default/locales/en/.mustflow/skills/name-resolution-integrity-review/references/module-package-loader-resolution-checklist.md +352 -0
- package/templates/default/locales/en/.mustflow/skills/parser-engineering-review/SKILL.md +103 -17
- package/templates/default/locales/en/.mustflow/skills/parser-engineering-review/references/cst-ast-lowering-checklist.md +260 -0
- package/templates/default/locales/en/.mustflow/skills/parser-engineering-review/references/lexer-tokenization-checklist.md +397 -0
- package/templates/default/locales/en/.mustflow/skills/parser-engineering-review/references/tree-serialization-compatibility-checklist.md +164 -0
- package/templates/default/locales/en/.mustflow/skills/parser-engineering-review/references/tree-traversal-rewrite-checklist.md +209 -0
- package/templates/default/locales/en/.mustflow/skills/race-condition-review/SKILL.md +68 -11
- package/templates/default/locales/en/.mustflow/skills/race-condition-review/references/race-reproduction-memory-model-checklist.md +268 -0
- package/templates/default/locales/en/.mustflow/skills/routes.toml +151 -0
- package/templates/default/locales/en/.mustflow/skills/session-handoff-integrity-review/SKILL.md +343 -0
- package/templates/default/locales/en/.mustflow/skills/session-handoff-integrity-review/references/session-auth-stream-resume-checklist.md +413 -0
- package/templates/default/locales/en/.mustflow/skills/session-handoff-integrity-review/references/session-handoff-protocol-checklist.md +485 -0
- package/templates/default/locales/en/.mustflow/skills/two-phase-transition-integrity-review/SKILL.md +267 -0
- package/templates/default/locales/en/.mustflow/skills/two-phase-transition-integrity-review/references/admission-decision-recovery-checklist.md +308 -0
- package/templates/default/locales/en/.mustflow/skills/two-phase-transition-integrity-review/references/two-phase-transition-checklist.md +229 -0
- package/templates/default/locales/en/.mustflow/skills/ui-dispatch-lifecycle-review/SKILL.md +300 -0
- package/templates/default/locales/en/.mustflow/skills/ui-dispatch-lifecycle-review/references/ui-affinity-event-loop-checklist.md +277 -0
- package/templates/default/locales/en/.mustflow/skills/ui-dispatch-lifecycle-review/references/ui-dispatch-lifecycle-checklist.md +292 -0
- package/templates/default/manifest.toml +115 -1
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
# UI Affinity and Event Loop Checklist
|
|
2
|
+
|
|
3
|
+
Use this checklist when UI ownership, native peer creation, object graphs, bound models, await
|
|
4
|
+
continuations, synchronous marshaling, timers, deletion, or event-loop availability are in scope.
|
|
5
|
+
Confirm toolkit behavior against the repository's actual framework and version.
|
|
6
|
+
|
|
7
|
+
## Contents
|
|
8
|
+
|
|
9
|
+
1. [Owner identity](#owner-identity)
|
|
10
|
+
2. [Affinity creation](#affinity-creation)
|
|
11
|
+
3. [Object graphs and bound models](#object-graphs-and-bound-models)
|
|
12
|
+
4. [Worker transfer boundary](#worker-transfer-boundary)
|
|
13
|
+
5. [Await and continuation context](#await-and-continuation-context)
|
|
14
|
+
6. [Event-loop availability](#event-loop-availability)
|
|
15
|
+
7. [Send, post, and timers](#send-post-and-timers)
|
|
16
|
+
8. [Blocking and wait graphs](#blocking-and-wait-graphs)
|
|
17
|
+
9. [Deletion and shutdown](#deletion-and-shutdown)
|
|
18
|
+
10. [Responsiveness evidence](#responsiveness-evidence)
|
|
19
|
+
11. [Fault matrix](#fault-matrix)
|
|
20
|
+
12. [Invariants](#invariants)
|
|
21
|
+
13. [Skill handoffs](#skill-handoffs)
|
|
22
|
+
|
|
23
|
+
## Owner identity
|
|
24
|
+
|
|
25
|
+
Do not collapse these concepts:
|
|
26
|
+
|
|
27
|
+
- process entry or main thread;
|
|
28
|
+
- toolkit UI event thread;
|
|
29
|
+
- owner dispatcher, looper, actor or serial queue;
|
|
30
|
+
- rendering or compositor thread;
|
|
31
|
+
- worker thread and its event loop;
|
|
32
|
+
- object instance affinity;
|
|
33
|
+
- native handle or peer ownership.
|
|
34
|
+
|
|
35
|
+
Ask which dispatcher or thread owns this exact instance. Two objects of the same class can have
|
|
36
|
+
different owners.
|
|
37
|
+
|
|
38
|
+
Use toolkit assertions or stored owner identity. Thread name, class name, generic synchronization
|
|
39
|
+
context and “main” naming are not sufficient proof.
|
|
40
|
+
|
|
41
|
+
## Affinity creation
|
|
42
|
+
|
|
43
|
+
Identify when affinity becomes fixed:
|
|
44
|
+
|
|
45
|
+
- object construction;
|
|
46
|
+
- native handle or peer creation;
|
|
47
|
+
- attachment to a scene, window or parent;
|
|
48
|
+
- dispatcher or looper registration;
|
|
49
|
+
- first property access that lazily realizes native state;
|
|
50
|
+
- binding or event-source attachment.
|
|
51
|
+
|
|
52
|
+
An early affinity predicate can be ambiguous before a handle exists. Prevent workers from touching
|
|
53
|
+
properties that can create the handle or peer on the wrong thread.
|
|
54
|
+
|
|
55
|
+
Create UI roots and native peers deliberately on their owner context before exposing them to workers.
|
|
56
|
+
|
|
57
|
+
Treat recreation, reparenting, detach and reattach as new attachment generations.
|
|
58
|
+
|
|
59
|
+
## Object graphs and bound models
|
|
60
|
+
|
|
61
|
+
Affinity can cover an ownership graph:
|
|
62
|
+
|
|
63
|
+
- parent and child controls;
|
|
64
|
+
- timer and event source;
|
|
65
|
+
- socket or notifier;
|
|
66
|
+
- image, brush, font and native resource;
|
|
67
|
+
- model or collection consumed by bindings;
|
|
68
|
+
- layout, template and accessibility caches.
|
|
69
|
+
|
|
70
|
+
Do not move only the root while children or resources remain owned elsewhere. Move a supported whole
|
|
71
|
+
graph or recreate it on the destination.
|
|
72
|
+
|
|
73
|
+
A plain model or collection becomes affinity-sensitive when the UI enumerates it or consumes its
|
|
74
|
+
change events. Thread-safe container methods do not make one coherent rendering snapshot.
|
|
75
|
+
|
|
76
|
+
Treat getters as potentially active. They can realize templates, create handles, calculate layout,
|
|
77
|
+
populate caches, query native state or emit messages.
|
|
78
|
+
|
|
79
|
+
## Worker transfer boundary
|
|
80
|
+
|
|
81
|
+
Workers should return pure data:
|
|
82
|
+
|
|
83
|
+
- bytes or immutable pixel buffers;
|
|
84
|
+
- strings and numbers;
|
|
85
|
+
- immutable DTOs;
|
|
86
|
+
- immutable collection snapshots;
|
|
87
|
+
- effect descriptions.
|
|
88
|
+
|
|
89
|
+
Do not transfer mutable toolkit resources merely because construction finished. Use only
|
|
90
|
+
framework-documented frozen, detached or transferable forms and prove the freeze happened before
|
|
91
|
+
publication.
|
|
92
|
+
|
|
93
|
+
After ownership transfer, the producer must not continue mutating the same graph.
|
|
94
|
+
|
|
95
|
+
Publish one result snapshot with operation, view, attachment, edit and source versions.
|
|
96
|
+
|
|
97
|
+
## Await and continuation context
|
|
98
|
+
|
|
99
|
+
An async method starts on its caller until the first incomplete suspension. Continuation destination
|
|
100
|
+
depends on the runtime, captured context, explicit executor or actor, and code path.
|
|
101
|
+
|
|
102
|
+
At every suspension boundary ask:
|
|
103
|
+
|
|
104
|
+
- which context is captured;
|
|
105
|
+
- whether continuation is allowed to resume elsewhere;
|
|
106
|
+
- whether the destination loop is alive;
|
|
107
|
+
- whether the target owner and generation remain current;
|
|
108
|
+
- whether locks or gates cross the wait;
|
|
109
|
+
- whether terminal paths complete on success, failure and cancellation.
|
|
110
|
+
|
|
111
|
+
A synchronization context is a scheduling address, not a universal UI-thread identity card. It can
|
|
112
|
+
be absent during startup, custom in tests or hosts, and stale during shutdown.
|
|
113
|
+
|
|
114
|
+
Complete promises or task sources outside locks when continuations can run inline. Prefer explicit
|
|
115
|
+
asynchronous continuation scheduling for infrastructure primitives where supported.
|
|
116
|
+
|
|
117
|
+
## Event-loop availability
|
|
118
|
+
|
|
119
|
+
A thread's existence does not prove it consumes queued callbacks.
|
|
120
|
+
|
|
121
|
+
Verify:
|
|
122
|
+
|
|
123
|
+
- event loop was started;
|
|
124
|
+
- correct context or dispatcher is active;
|
|
125
|
+
- target object still has that affinity;
|
|
126
|
+
- loop has not begun shutdown;
|
|
127
|
+
- priority or mode permits the callback;
|
|
128
|
+
- queued deletion and timers can run;
|
|
129
|
+
- shutdown rejects or drains work observably.
|
|
130
|
+
|
|
131
|
+
A queue post can succeed while no consumer ever executes it. Missing completion can be starvation or
|
|
132
|
+
an absent terminal path, not a lock deadlock.
|
|
133
|
+
|
|
134
|
+
Separate worker-thread controller objects from worker objects that actually live on the target
|
|
135
|
+
thread. A thread wrapper instance can itself remain owned by the creator thread.
|
|
136
|
+
|
|
137
|
+
## Send, post, and timers
|
|
138
|
+
|
|
139
|
+
Classify delivery:
|
|
140
|
+
|
|
141
|
+
| Delivery | Structure |
|
|
142
|
+
| --- | --- |
|
|
143
|
+
| direct call | same caller stack and immediate reentrancy |
|
|
144
|
+
| synchronous send or invoke | caller waits for target completion |
|
|
145
|
+
| asynchronous post | caller returns; target loop executes later |
|
|
146
|
+
| timer | callback becomes eligible after a time condition; execution may be delayed or coalesced |
|
|
147
|
+
| paint or layout invalidation | request is recorded and often merged for a later frame |
|
|
148
|
+
|
|
149
|
+
Submitting synchronously to the same serial queue is self-deadlock. Cross-thread synchronous marshal
|
|
150
|
+
can deadlock when UI waits for the caller or its lock.
|
|
151
|
+
|
|
152
|
+
Asynchronous post is not parallel work. CPU-heavy code posted to the UI remains UI-thread work.
|
|
153
|
+
|
|
154
|
+
Use monotonic elapsed time for animation or timeout decisions. Timer intervals do not guarantee
|
|
155
|
+
exact execution times or tick counts.
|
|
156
|
+
|
|
157
|
+
## Blocking and wait graphs
|
|
158
|
+
|
|
159
|
+
Include these patterns:
|
|
160
|
+
|
|
161
|
+
- UI waits synchronously for a continuation targeting UI;
|
|
162
|
+
- worker synchronously invokes UI while UI joins worker;
|
|
163
|
+
- serial queue synchronously submits to itself;
|
|
164
|
+
- UI and model locks are acquired in opposite order;
|
|
165
|
+
- a logical async gate is held across work that needs the same gate;
|
|
166
|
+
- completion runs a continuation inline under a lock;
|
|
167
|
+
- destination loop does not run queued completion;
|
|
168
|
+
- one success-only completion source leaves failure or cancel waiting forever;
|
|
169
|
+
- bounded queue producer waits for space while consumer waits for UI approval;
|
|
170
|
+
- cleanup or native release needs the UI or STA context while UI waits for cleanup;
|
|
171
|
+
- thread-pool workers are consumed by sync-over-async waits.
|
|
172
|
+
|
|
173
|
+
Distinguish blocking deadlock, missing completion, loop starvation and pool starvation.
|
|
174
|
+
|
|
175
|
+
Do not use manual pumping to make a synchronous wait appear responsive; route that case to the modal
|
|
176
|
+
reentrancy review.
|
|
177
|
+
|
|
178
|
+
## Deletion and shutdown
|
|
179
|
+
|
|
180
|
+
Creation, timers, queued signals, native release and deletion can all require owner affinity.
|
|
181
|
+
|
|
182
|
+
For deferred deletion record:
|
|
183
|
+
|
|
184
|
+
- owner loop;
|
|
185
|
+
- whether it has started;
|
|
186
|
+
- shutdown state;
|
|
187
|
+
- queued-delete identity;
|
|
188
|
+
- outstanding callbacks and timers;
|
|
189
|
+
- confirmation or observable terminal state.
|
|
190
|
+
|
|
191
|
+
A deferred delete posted to a stopped loop is not cleanup.
|
|
192
|
+
|
|
193
|
+
Shutdown sequence:
|
|
194
|
+
|
|
195
|
+
1. stop new admissions;
|
|
196
|
+
2. stop producers and timers;
|
|
197
|
+
3. request cancellation;
|
|
198
|
+
4. drain or reject queued callbacks;
|
|
199
|
+
5. await owned tasks without blocking their completion context;
|
|
200
|
+
6. release resources on required owners;
|
|
201
|
+
7. delete object graphs;
|
|
202
|
+
8. stop event loops and dispatchers;
|
|
203
|
+
9. verify no queued lifetime work remains.
|
|
204
|
+
|
|
205
|
+
A rendering thread or mutex does not authorize general UI-object access.
|
|
206
|
+
|
|
207
|
+
## Responsiveness evidence
|
|
208
|
+
|
|
209
|
+
Record:
|
|
210
|
+
|
|
211
|
+
`created -> worker_started -> enqueued -> ui_started -> state_applied -> layout -> paint -> presented`
|
|
212
|
+
|
|
213
|
+
Also retain:
|
|
214
|
+
|
|
215
|
+
- target dispatcher and priority;
|
|
216
|
+
- queue age and depth by priority;
|
|
217
|
+
- event-loop heartbeat delay;
|
|
218
|
+
- worker queue age and active pool size;
|
|
219
|
+
- lock owner and hold duration;
|
|
220
|
+
- allocation types before GC pauses;
|
|
221
|
+
- invalidation origin and layout pass count;
|
|
222
|
+
- damaged region and overdraw;
|
|
223
|
+
- GPU fence, readback and upload waits;
|
|
224
|
+
- synchronous external-process calls;
|
|
225
|
+
- high-rate input and progress production.
|
|
226
|
+
|
|
227
|
+
A low-CPU UI can be blocked. A high-CPU UI can be live but starve input and rendering.
|
|
228
|
+
|
|
229
|
+
## Fault matrix
|
|
230
|
+
|
|
231
|
+
| Fault | Required result |
|
|
232
|
+
| --- | --- |
|
|
233
|
+
| main thread is not toolkit UI thread | owner assertion routes correctly |
|
|
234
|
+
| affinity checked before native handle exists | worker cannot create the handle |
|
|
235
|
+
| child resource has another owner | graph audit rejects or recreates |
|
|
236
|
+
| getter invoked from worker | affinity assertion catches active read |
|
|
237
|
+
| bound collection mutates from worker | immutable snapshot boundary holds |
|
|
238
|
+
| mutable image or font crosses thread | transfer contract rejects it |
|
|
239
|
+
| continuation resumes after context change | application guard revalidates |
|
|
240
|
+
| synchronization context is null or custom | owner identity does not depend on it |
|
|
241
|
+
| target loop never started | queued work is rejected or diagnosed |
|
|
242
|
+
| loop shuts down with queued deletion | cleanup remains observable and bounded |
|
|
243
|
+
| synchronous invoke targets same queue | self-deadlock prevention fires |
|
|
244
|
+
| UI waits while worker invokes UI | wait graph exposes the cycle |
|
|
245
|
+
| completion runs inline under lock | continuation cannot reenter protected state |
|
|
246
|
+
| one task path omits completion | terminal-path invariant fails |
|
|
247
|
+
| bounded queue and UI approval cycle | protocol avoids circular backpressure |
|
|
248
|
+
| timer fires late or coalesces | elapsed-time logic remains correct |
|
|
249
|
+
| high-priority work floods dispatcher | lower-priority progress remains bounded |
|
|
250
|
+
|
|
251
|
+
## Invariants
|
|
252
|
+
|
|
253
|
+
Choose applicable invariants:
|
|
254
|
+
|
|
255
|
+
- every UI or bound object has one known owner;
|
|
256
|
+
- no worker creates a native UI peer accidentally;
|
|
257
|
+
- every owned object graph has compatible affinity;
|
|
258
|
+
- only pure or explicitly frozen data crosses worker-to-UI boundary;
|
|
259
|
+
- every continuation has an observable destination and terminal path;
|
|
260
|
+
- queued work requires a live consuming event loop;
|
|
261
|
+
- no synchronous dispatch targets its current serial queue;
|
|
262
|
+
- no wait cycle depends on a blocked UI context;
|
|
263
|
+
- deletion and timer shutdown execute on required owners;
|
|
264
|
+
- stopped loops retain no unaccounted queued lifetime work;
|
|
265
|
+
- timer and dispatcher delay cannot masquerade as physical elapsed time;
|
|
266
|
+
- affinity assertions remain enabled in development and representative tests.
|
|
267
|
+
|
|
268
|
+
## Skill handoffs
|
|
269
|
+
|
|
270
|
+
- Use `ui-dispatch-lifecycle-review` for freshness, view epochs, cancellation, closing and queue
|
|
271
|
+
pressure.
|
|
272
|
+
- Use `modal-loop-reentrancy-review` for nested pumping and same-stack reentry.
|
|
273
|
+
- Use `race-condition-review` for memory ordering and parallel interleavings.
|
|
274
|
+
- Use `frame-render-performance-review` after delay is localized to layout, paint or GPU work.
|
|
275
|
+
- Use `memory-lifetime-review` for raw pointer and native-resource lifetime.
|
|
276
|
+
- Use the framework-specific skill when exact toolkit or runtime behavior determines the fix.
|
|
277
|
+
|
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
# UI Dispatch and Lifecycle Checklist
|
|
2
|
+
|
|
3
|
+
Use this checklist when work is scheduled onto a UI affinity context and can outlive the operation,
|
|
4
|
+
view, native peer, edit version, cancellation source, or queue budget that created it.
|
|
5
|
+
|
|
6
|
+
## Contents
|
|
7
|
+
|
|
8
|
+
1. [Authority model](#authority-model)
|
|
9
|
+
2. [Application-time guard](#application-time-guard)
|
|
10
|
+
3. [Immutable payloads](#immutable-payloads)
|
|
11
|
+
4. [Ordering and ABA](#ordering-and-aba)
|
|
12
|
+
5. [User edits and remote results](#user-edits-and-remote-results)
|
|
13
|
+
6. [View and handle generations](#view-and-handle-generations)
|
|
14
|
+
7. [Cancellation ownership](#cancellation-ownership)
|
|
15
|
+
8. [Closing state machine](#closing-state-machine)
|
|
16
|
+
9. [Subscriptions, gates, and shutdown](#subscriptions-gates-and-shutdown)
|
|
17
|
+
10. [Queue pressure and progress](#queue-pressure-and-progress)
|
|
18
|
+
11. [Responsiveness diagnosis](#responsiveness-diagnosis)
|
|
19
|
+
12. [Deterministic fault matrix](#deterministic-fault-matrix)
|
|
20
|
+
13. [Invariants](#invariants)
|
|
21
|
+
14. [Skill handoffs](#skill-handoffs)
|
|
22
|
+
|
|
23
|
+
## Authority model
|
|
24
|
+
|
|
25
|
+
Keep these identities distinct:
|
|
26
|
+
|
|
27
|
+
| Identity | Meaning |
|
|
28
|
+
| --- | --- |
|
|
29
|
+
| operation ID | one logical load, validation, synchronization or save |
|
|
30
|
+
| attempt ID | one execution try |
|
|
31
|
+
| view instance ID | one constructed UI owner |
|
|
32
|
+
| attachment epoch | one native handle, peer, scene or window attachment |
|
|
33
|
+
| operation generation | current winner among superseding work |
|
|
34
|
+
| state version | UI state assumed by the result |
|
|
35
|
+
| edit version | local user-edit state assumed by background work |
|
|
36
|
+
| source version | server, file, device or model authority used for computation |
|
|
37
|
+
| close request ID | one shared asynchronous close sequence |
|
|
38
|
+
|
|
39
|
+
A dispatcher ensures only the scheduled execution context. It does not choose the current operation
|
|
40
|
+
or view generation.
|
|
41
|
+
|
|
42
|
+
## Application-time guard
|
|
43
|
+
|
|
44
|
+
Validate inside the UI callback immediately before mutation:
|
|
45
|
+
|
|
46
|
+
- owner is still open;
|
|
47
|
+
- view instance matches;
|
|
48
|
+
- attachment or handle epoch matches;
|
|
49
|
+
- operation is still current;
|
|
50
|
+
- cancellation has not become terminal;
|
|
51
|
+
- expected state and edit versions still match;
|
|
52
|
+
- target entity still exists;
|
|
53
|
+
- result has not already applied;
|
|
54
|
+
- terminal state does not forbid the transition.
|
|
55
|
+
|
|
56
|
+
A check before enqueue is useful for avoiding obvious work but is not a correctness gate.
|
|
57
|
+
|
|
58
|
+
Log rejection with stable reason such as `owner_closed`, `view_epoch_mismatch`,
|
|
59
|
+
`operation_superseded`, `edit_conflict`, `canceled` or `terminal_state`.
|
|
60
|
+
|
|
61
|
+
## Immutable payloads
|
|
62
|
+
|
|
63
|
+
Construct one immutable result before enqueue. Include every field that must agree:
|
|
64
|
+
|
|
65
|
+
- item collection and count;
|
|
66
|
+
- ordering and grouping;
|
|
67
|
+
- totals and derived values;
|
|
68
|
+
- selected stable ID;
|
|
69
|
+
- loading, error and completion state;
|
|
70
|
+
- source and edit versions;
|
|
71
|
+
- operation and view generations.
|
|
72
|
+
|
|
73
|
+
Do not capture a mutable model, list, builder, iterator or child graph that a worker can continue
|
|
74
|
+
changing. Copying only the outer object reference does not transfer ownership.
|
|
75
|
+
|
|
76
|
+
Prefer one UI state replacement to several property notifications whose intermediate combinations
|
|
77
|
+
can trigger bindings, converters, validation or commands.
|
|
78
|
+
|
|
79
|
+
## Ordering and ABA
|
|
80
|
+
|
|
81
|
+
A FIFO dispatcher orders enqueue operations, not background task start order or source causality.
|
|
82
|
+
|
|
83
|
+
Give superseding work a monotonic generation. A repeated value does not prove the same generation:
|
|
84
|
+
|
|
85
|
+
`A request 17 -> B request 18 -> A request 19`
|
|
86
|
+
|
|
87
|
+
Result 17 must not pass merely because the current visible value is A.
|
|
88
|
+
|
|
89
|
+
Define a terminal precedence table. Completion, cancellation, failure and progress must not regress
|
|
90
|
+
each other. An obsolete progress callback cannot follow a terminal result.
|
|
91
|
+
|
|
92
|
+
## User edits and remote results
|
|
93
|
+
|
|
94
|
+
Capture:
|
|
95
|
+
|
|
96
|
+
- edit version at background-work start;
|
|
97
|
+
- source version;
|
|
98
|
+
- target range or stable field identity;
|
|
99
|
+
- composition or selection state when relevant;
|
|
100
|
+
- local dirty or uncommitted status.
|
|
101
|
+
|
|
102
|
+
At application choose one explicit policy:
|
|
103
|
+
|
|
104
|
+
- local edit wins and remote result becomes stale;
|
|
105
|
+
- merge by domain rule;
|
|
106
|
+
- show conflict without overwriting;
|
|
107
|
+
- restart computation against the current edit;
|
|
108
|
+
- apply only untouched fields.
|
|
109
|
+
|
|
110
|
+
Do not overwrite active composition, caret, selection or uncommitted text solely because a server
|
|
111
|
+
response completed later.
|
|
112
|
+
|
|
113
|
+
## View and handle generations
|
|
114
|
+
|
|
115
|
+
Increment an attachment epoch on applicable events:
|
|
116
|
+
|
|
117
|
+
- native handle recreation;
|
|
118
|
+
- detach and reattach;
|
|
119
|
+
- scene or window change;
|
|
120
|
+
- owner or parent change;
|
|
121
|
+
- view reuse;
|
|
122
|
+
- close and reopen;
|
|
123
|
+
- model replacement;
|
|
124
|
+
- display or rendering-peer recreation.
|
|
125
|
+
|
|
126
|
+
Object reference equality, same title, same entity ID or reused view model does not prove the same
|
|
127
|
+
rendering lifetime.
|
|
128
|
+
|
|
129
|
+
Callbacks carry both view instance and attachment epoch. A callback from a retired epoch cannot
|
|
130
|
+
mutate the new peer.
|
|
131
|
+
|
|
132
|
+
## Cancellation ownership
|
|
133
|
+
|
|
134
|
+
Cancellation is a request to cooperate. It does not:
|
|
135
|
+
|
|
136
|
+
- remove already queued UI callbacks;
|
|
137
|
+
- prove the worker stopped;
|
|
138
|
+
- authorize disposal of resources still in use;
|
|
139
|
+
- clear an operation's busy state;
|
|
140
|
+
- guarantee a callback runs later or on another thread.
|
|
141
|
+
|
|
142
|
+
Each operation owns a local cancellation source. An old `finally` disposes only its captured source
|
|
143
|
+
and clears shared fields only through compare-by-identity or generation.
|
|
144
|
+
|
|
145
|
+
Treat cancellation callbacks as potentially synchronous at registration or cancel call. Keep them
|
|
146
|
+
small, nonblocking and free of complex UI or lock reentry.
|
|
147
|
+
|
|
148
|
+
For semaphores and gates, track acquisition locally. Release only after successful acquisition and
|
|
149
|
+
only once. Prefer an owner-bearing lease for complex gates.
|
|
150
|
+
|
|
151
|
+
## Closing state machine
|
|
152
|
+
|
|
153
|
+
Use:
|
|
154
|
+
|
|
155
|
+
`Open -> Closing -> Closed`
|
|
156
|
+
|
|
157
|
+
When the framework close event is synchronous:
|
|
158
|
+
|
|
159
|
+
1. first request cancels immediate destruction;
|
|
160
|
+
2. atomically enter Closing and store one close task;
|
|
161
|
+
3. reject new work and input admission;
|
|
162
|
+
4. request cancellation from owned operations;
|
|
163
|
+
5. await owned completion without blocking the UI affinity context;
|
|
164
|
+
6. dispose lifetime subscriptions, timers and resources;
|
|
165
|
+
7. flush required state;
|
|
166
|
+
8. request final framework close once;
|
|
167
|
+
9. enter Closed.
|
|
168
|
+
|
|
169
|
+
Additional close requests during Closing return or join the same close task.
|
|
170
|
+
|
|
171
|
+
Every continuation checks close state and view generation. Queued callbacks after Closing are
|
|
172
|
+
rejected even if their worker succeeded.
|
|
173
|
+
|
|
174
|
+
## Subscriptions, gates, and shutdown
|
|
175
|
+
|
|
176
|
+
Bind event, timer, observable, message-bus, progress and global-service subscriptions to one lifetime
|
|
177
|
+
container. Dispose the container at close, while retaining callback generation guards for work
|
|
178
|
+
already queued.
|
|
179
|
+
|
|
180
|
+
Zombie views are correctness bugs, not only leaks: a retained closed view can consume events and
|
|
181
|
+
race a newly opened view.
|
|
182
|
+
|
|
183
|
+
Order application shutdown:
|
|
184
|
+
|
|
185
|
+
1. block new UI and background work;
|
|
186
|
+
2. stop periodic and event-driven producers;
|
|
187
|
+
3. request cancellation;
|
|
188
|
+
4. drain owned tasks to a bounded deadline;
|
|
189
|
+
5. persist required durable state;
|
|
190
|
+
6. stop services in dependency order;
|
|
191
|
+
7. destroy views and dispatch infrastructure;
|
|
192
|
+
8. finalize diagnostics.
|
|
193
|
+
|
|
194
|
+
Avoid relying on one long last-second save. Use normal-operation journaling or atomic persistence
|
|
195
|
+
where durability matters.
|
|
196
|
+
|
|
197
|
+
## Queue pressure and progress
|
|
198
|
+
|
|
199
|
+
Record enqueue, start and apply time per callback. Queue delay is `start - enqueue`.
|
|
200
|
+
|
|
201
|
+
Coalesce supersedable updates:
|
|
202
|
+
|
|
203
|
+
- progress retains latest current-generation value;
|
|
204
|
+
- pointer or high-rate input follows its semantic compaction policy;
|
|
205
|
+
- status boundaries and terminal states are never discarded;
|
|
206
|
+
- final completion invalidates older queued progress;
|
|
207
|
+
- per-source update rate is bounded;
|
|
208
|
+
- queue age and oldest useful work are bounded.
|
|
209
|
+
|
|
210
|
+
Different dispatcher priorities can reorder visible outcomes. Include priority in the contract and
|
|
211
|
+
trace.
|
|
212
|
+
|
|
213
|
+
## Responsiveness diagnosis
|
|
214
|
+
|
|
215
|
+
Correlate these stages:
|
|
216
|
+
|
|
217
|
+
`created -> worker_started -> dispatch_enqueued -> ui_started -> state_applied -> layout -> paint -> presented`
|
|
218
|
+
|
|
219
|
+
Classify delay:
|
|
220
|
+
|
|
221
|
+
| Delay surface | Evidence |
|
|
222
|
+
| --- | --- |
|
|
223
|
+
| worker start | thread-pool queue age and worker availability |
|
|
224
|
+
| UI queue | enqueue-to-start latency and priority |
|
|
225
|
+
| lock or sync call | off-CPU wait and owner chain |
|
|
226
|
+
| allocation or GC | allocation types before pause and stop timeline |
|
|
227
|
+
| layout | invalidation source and pass fan-out |
|
|
228
|
+
| paint | damage region, layers and overdraw |
|
|
229
|
+
| GPU | fence, readback, upload and presentation waits |
|
|
230
|
+
| external component | RPC, COM, IME, accessibility, clipboard, shell or driver wait |
|
|
231
|
+
| input storm | event rate, work per event and starvation of render or idle |
|
|
232
|
+
|
|
233
|
+
Low CPU can mean blocked or starved work. Short callbacks can still form a long queue.
|
|
234
|
+
|
|
235
|
+
Use a UI heartbeat to retain traces when tail queue delay crosses a product threshold. Track tail
|
|
236
|
+
and consecutive delays, not only averages.
|
|
237
|
+
|
|
238
|
+
## Deterministic fault matrix
|
|
239
|
+
|
|
240
|
+
Use a controllable dispatcher, virtual clock and explicit barriers:
|
|
241
|
+
|
|
242
|
+
| Schedule or fault | Required result |
|
|
243
|
+
| --- | --- |
|
|
244
|
+
| old result completes after new result | old generation is rejected |
|
|
245
|
+
| value A returns after A-B-A | ABA generation rejects first A |
|
|
246
|
+
| view closes after enqueue before run | callback performs no mutation |
|
|
247
|
+
| native peer recreates before run | old attachment epoch is rejected |
|
|
248
|
+
| cancel occurs after enqueue | callback checks terminal cancellation |
|
|
249
|
+
| mutable source changes after enqueue | immutable payload remains coherent |
|
|
250
|
+
| progress backlog precedes completion | terminal state cannot regress |
|
|
251
|
+
| old finally runs after new start | new owner state remains intact |
|
|
252
|
+
| close requested twice | one close task and cleanup sequence |
|
|
253
|
+
| cancellation callback runs inline | no lock or UI reentry corruption |
|
|
254
|
+
| semaphore wait cancels before acquire | permit count remains correct |
|
|
255
|
+
| subscription retains closed view | lifetime invariant detects leak |
|
|
256
|
+
| thread pool is saturated | worker-start delay is visible |
|
|
257
|
+
| layout or input storm floods queue | queue age and compaction show cause |
|
|
258
|
+
| shutdown destroys service early | dependency-order invariant fails |
|
|
259
|
+
|
|
260
|
+
Preserve schedule decisions and state transitions when a fixture fails.
|
|
261
|
+
|
|
262
|
+
## Invariants
|
|
263
|
+
|
|
264
|
+
Choose applicable invariants:
|
|
265
|
+
|
|
266
|
+
- closed or retired views receive zero state mutations;
|
|
267
|
+
- an old operation or attachment generation cannot apply;
|
|
268
|
+
- UI state snapshots are internally coherent;
|
|
269
|
+
- one current operation owns busy, cancellation and cleanup state;
|
|
270
|
+
- a terminal state cannot transition back to progress or loaded work from an old generation;
|
|
271
|
+
- cancellation request is not reported as completed cleanup;
|
|
272
|
+
- no operation releases a gate it did not acquire;
|
|
273
|
+
- every lifetime subscription returns to baseline after close;
|
|
274
|
+
- Closing admits no new owned work;
|
|
275
|
+
- shutdown destroys dependencies only after their owned users drain or reach a documented bound;
|
|
276
|
+
- queue age and callback production remain bounded;
|
|
277
|
+
- each interaction trace can distinguish worker, dispatcher, layout, paint and presentation delay.
|
|
278
|
+
|
|
279
|
+
## Skill handoffs
|
|
280
|
+
|
|
281
|
+
- Use `modal-loop-reentrancy-review` when nested pumping or a blocking dialog keeps the outer
|
|
282
|
+
callback stack active.
|
|
283
|
+
- Use `race-condition-review` for general interleavings and happens-before evidence.
|
|
284
|
+
- Use `frontend-state-ownership-review` for browser state duplication without native lifecycle.
|
|
285
|
+
- Use `frame-render-performance-review` for layout, paint and compositing remediation after the
|
|
286
|
+
dispatch delay is localized.
|
|
287
|
+
- Use `performance-measurement-integrity-review` for latency units, tail metrics, clock domains and
|
|
288
|
+
benchmark comparability.
|
|
289
|
+
- Use `input-event-synchronization-review` for high-rate device-event compaction and input-session
|
|
290
|
+
epochs.
|
|
291
|
+
- Use `state-machine-pattern` to implement close or operation lifecycle transitions.
|
|
292
|
+
|