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,229 @@
|
|
|
1
|
+
# Two-Phase Transition Checklist
|
|
2
|
+
|
|
3
|
+
Use this reference to inspect an authority handoff that prepares a target and then activates it.
|
|
4
|
+
This is not a claim that every handoff uses a distributed transaction coordinator.
|
|
5
|
+
|
|
6
|
+
## Contents
|
|
7
|
+
|
|
8
|
+
1. [Authority invariant](#authority-invariant)
|
|
9
|
+
2. [Transition record](#transition-record)
|
|
10
|
+
3. [Phase and command matrix](#phase-and-command-matrix)
|
|
11
|
+
4. [Prepare evidence](#prepare-evidence)
|
|
12
|
+
5. [Commit predicate and atomic mutation](#commit-predicate-and-atomic-mutation)
|
|
13
|
+
6. [Lease and fencing matrix](#lease-and-fencing-matrix)
|
|
14
|
+
7. [Live-input handoff](#live-input-handoff)
|
|
15
|
+
8. [Abort, expiry, cleanup, and reversal](#abort-expiry-cleanup-and-reversal)
|
|
16
|
+
9. [Reads, events, and caches](#reads-events-and-caches)
|
|
17
|
+
10. [Conflict taxonomy](#conflict-taxonomy)
|
|
18
|
+
11. [Failure-injection matrix](#failure-injection-matrix)
|
|
19
|
+
12. [Invariant monitoring](#invariant-monitoring)
|
|
20
|
+
13. [Skill handoffs](#skill-handoffs)
|
|
21
|
+
|
|
22
|
+
## Authority invariant
|
|
23
|
+
|
|
24
|
+
Write the invariant before reviewing code:
|
|
25
|
+
|
|
26
|
+
- Before commit, the source remains the sole committed authority.
|
|
27
|
+
- A prepared target may hold data or reservations but cannot accept authoritative writes.
|
|
28
|
+
- One conditional atomic commit changes the authority pointer and monotonically advances its fence.
|
|
29
|
+
- After commit, the source may continue running but every authoritative sink rejects its old fence.
|
|
30
|
+
- Cleanup can lag without changing which owner is authoritative.
|
|
31
|
+
|
|
32
|
+
Identify the concrete record that answers `who may write now?`. A process-local flag, service
|
|
33
|
+
discovery entry, cache value, or notification is insufficient when a stale process can still reach
|
|
34
|
+
the durable sink.
|
|
35
|
+
|
|
36
|
+
## Transition record
|
|
37
|
+
|
|
38
|
+
Record the fields needed to distinguish intent, attempt, and authority:
|
|
39
|
+
|
|
40
|
+
| Field | Review question |
|
|
41
|
+
| --- | --- |
|
|
42
|
+
| `transition_id` | Is one handoff attempt uniquely addressable across retries and cleanup? |
|
|
43
|
+
| `request_id` | Can duplicate client intent replay the prior response without creating a new attempt? |
|
|
44
|
+
| `object_id` | Is the authority domain scoped to one object, session, shard, or resource? |
|
|
45
|
+
| `source_version` | Can commit prove it prepared from the state that is still current? |
|
|
46
|
+
| `target_owner` or `target_state` | Is the prepared destination immutable? |
|
|
47
|
+
| `request_hash` | Do all security- and business-relevant inputs participate in mismatch detection? |
|
|
48
|
+
| `phase` | Are `PREPARING`, `PREPARED`, `COMMITTED`, `ABORTED`, and `EXPIRED` distinguishable? |
|
|
49
|
+
| `lease_expires_at` | Does abandoned preparation terminate without relying on process memory? |
|
|
50
|
+
| `fencing_token` | Is authority monotonic across retry, expiry, and reversal? |
|
|
51
|
+
| timestamps | Can operators distinguish slow work, abandoned work, and delayed cleanup? |
|
|
52
|
+
|
|
53
|
+
Keep the prepared snapshot immutable. If the target, amount, permission set, configuration, base
|
|
54
|
+
version, or normalized input changes, require a new transition or return a mismatch conflict.
|
|
55
|
+
|
|
56
|
+
## Phase and command matrix
|
|
57
|
+
|
|
58
|
+
Define outcomes rather than letting handlers improvise:
|
|
59
|
+
|
|
60
|
+
| Current phase | Prepare same input | Prepare different input | Commit | Abort or expire |
|
|
61
|
+
| --- | --- | --- | --- | --- |
|
|
62
|
+
| absent | create `PREPARING` | create `PREPARING` | not prepared | no-op or not found |
|
|
63
|
+
| `PREPARING` | return progress | conflict | not ready | conditional abort or expiry |
|
|
64
|
+
| `PREPARED` | replay prepared response | conflict | conditional commit | conditional abort or expiry |
|
|
65
|
+
| `COMMITTED` | replay committed result | conflict | replay committed result | reject; use reverse transition |
|
|
66
|
+
| `ABORTED` | return terminal result or start a new ID | conflict on reused ID | reject | replay aborted result |
|
|
67
|
+
| `EXPIRED` | return terminal result or start a new ID | conflict on reused ID | reject | replay expired result |
|
|
68
|
+
|
|
69
|
+
Combine this table with an object-level active-transition slot. A unique transition ID alone does
|
|
70
|
+
not prevent two different transitions from preparing the same object concurrently.
|
|
71
|
+
|
|
72
|
+
## Prepare evidence
|
|
73
|
+
|
|
74
|
+
Check that prepare establishes readiness without changing committed truth:
|
|
75
|
+
|
|
76
|
+
- reserve or allocate resources under the transition ID;
|
|
77
|
+
- copy or reconstruct state from the recorded source version;
|
|
78
|
+
- validate permissions and business inputs that commit will later bind;
|
|
79
|
+
- prove capacity, dependencies, and target-specific readiness;
|
|
80
|
+
- record checksums, schema versions, or watermarks required to detect drift;
|
|
81
|
+
- keep ordinary reads on the committed owner or state;
|
|
82
|
+
- expose preparation details only through an explicit operational view;
|
|
83
|
+
- define deterministic cleanup for every allocated object.
|
|
84
|
+
|
|
85
|
+
A target process answering a health probe proves only that the probe ran. It does not prove that the
|
|
86
|
+
right state, epoch, permissions, capacity, dependencies, or pending input are present.
|
|
87
|
+
|
|
88
|
+
## Commit predicate and atomic mutation
|
|
89
|
+
|
|
90
|
+
Revalidate these conditions immediately before commit:
|
|
91
|
+
|
|
92
|
+
- object committed version still equals `source_version`;
|
|
93
|
+
- object `active_transition_id` still equals this transition;
|
|
94
|
+
- transition phase is `PREPARED`;
|
|
95
|
+
- lease has not expired and renewal outcome is known;
|
|
96
|
+
- request hash and prepared snapshot are unchanged;
|
|
97
|
+
- target generation is the next permitted generation;
|
|
98
|
+
- target readiness evidence is still within its validity contract.
|
|
99
|
+
|
|
100
|
+
The atomic mutation should cover every local fact whose disagreement would make authority
|
|
101
|
+
ambiguous:
|
|
102
|
+
|
|
103
|
+
- committed owner or state;
|
|
104
|
+
- object version and owner epoch or generation;
|
|
105
|
+
- active-transition slot;
|
|
106
|
+
- transition phase and committed result;
|
|
107
|
+
- outbox record required to announce the new generation.
|
|
108
|
+
|
|
109
|
+
Keep this boundary short. Do not copy data, wait for drains, call another service, poll readiness, or
|
|
110
|
+
delete the source while holding it. If an external system commits independently, model convergence
|
|
111
|
+
rather than pretending the entire operation has one atomic boundary.
|
|
112
|
+
|
|
113
|
+
## Lease and fencing matrix
|
|
114
|
+
|
|
115
|
+
| Mechanism | What it proves | What it does not prove |
|
|
116
|
+
| --- | --- | --- |
|
|
117
|
+
| lease | an owner may act until a bounded expiry under known clock assumptions | an expired process has stopped or cannot write |
|
|
118
|
+
| heartbeat | an owner recently reported liveness | current authority at the durable sink |
|
|
119
|
+
| notification | a source was asked to stop | that the source received or obeyed the request |
|
|
120
|
+
| epoch or generation | which authority is newer | rejection unless every sink compares it |
|
|
121
|
+
| fencing check | a sink rejects commands older than its current generation | exactly-once execution or complete event delivery |
|
|
122
|
+
|
|
123
|
+
Carry the fence through database writes, object-store manifests, provider commands, cache mutations,
|
|
124
|
+
queued work, and any downstream effect that can outlive the owner. If renewal times out, stop effects
|
|
125
|
+
and reread authority before continuing; treating a timeout as either success or failure creates a
|
|
126
|
+
split-brain window.
|
|
127
|
+
|
|
128
|
+
## Live-input handoff
|
|
129
|
+
|
|
130
|
+
For sessions and active writers, define a sequence timeline:
|
|
131
|
+
|
|
132
|
+
1. Choose and durably record a cutoff sequence.
|
|
133
|
+
2. Let the source finish or durably record work before the cutoff.
|
|
134
|
+
3. Route work after the cutoff into a durable log or buffer owned by the transition or next epoch.
|
|
135
|
+
4. Capture state together with the last processed sequence.
|
|
136
|
+
5. Restore the target from that pair and replay only later sequences.
|
|
137
|
+
6. Run shadow computation without externally visible effects when comparison is useful.
|
|
138
|
+
7. Commit owner and epoch atomically.
|
|
139
|
+
8. Release buffered input to the target under the new epoch.
|
|
140
|
+
9. Reject late source acknowledgements or writes carrying the old epoch.
|
|
141
|
+
|
|
142
|
+
Include session ID, epoch, input sequence, and request identity in commands. A snapshot without its
|
|
143
|
+
watermark admits duplicates or gaps; a watermark stored separately from the snapshot can describe a
|
|
144
|
+
state that never existed.
|
|
145
|
+
|
|
146
|
+
## Abort, expiry, cleanup, and reversal
|
|
147
|
+
|
|
148
|
+
- Abort or expiry must conditionally close only the matching active transition.
|
|
149
|
+
- Prepared resources must be tagged with the transition ID and target generation.
|
|
150
|
+
- Cleanup must verify those tags before deletion so it cannot remove a newer transition's resource.
|
|
151
|
+
- After commit, cleanup is retriable work; it does not restore old authority.
|
|
152
|
+
- Revoke the source fence immediately, but delay destructive deletion through the required
|
|
153
|
+
observation, rollback, audit, or forensics window.
|
|
154
|
+
- Reverse a committed cutover through a new transition with a higher generation. Never rewrite the
|
|
155
|
+
old committed result into an aborted state.
|
|
156
|
+
|
|
157
|
+
## Reads, events, and caches
|
|
158
|
+
|
|
159
|
+
Default reads should expose committed state only. Operational APIs may reveal preparation phase,
|
|
160
|
+
lease, target, progress, and cleanup state when access control permits it.
|
|
161
|
+
|
|
162
|
+
Attach object version and authority generation to outbox events, cache entries, projections, and
|
|
163
|
+
subscriber updates. Consumers should apply monotonic comparison rules and discard stale arrivals.
|
|
164
|
+
Backoff reduces contention; it does not repair missing conditional writes or missing fences.
|
|
165
|
+
|
|
166
|
+
## Conflict taxonomy
|
|
167
|
+
|
|
168
|
+
Return explicit outcomes for:
|
|
169
|
+
|
|
170
|
+
- another active transition owns the object;
|
|
171
|
+
- source version changed after prepare;
|
|
172
|
+
- request identity was reused with different immutable input;
|
|
173
|
+
- transition expired before commit;
|
|
174
|
+
- stale owner or stale generation attempted a write;
|
|
175
|
+
- command is invalid for the current transition phase;
|
|
176
|
+
- commit outcome is already recorded and the response should be replayed;
|
|
177
|
+
- external delivery outcome remains unknown after local commit.
|
|
178
|
+
|
|
179
|
+
Use per-object serialization or conditional writes where contention is real. Avoid broad locks, and
|
|
180
|
+
never keep a lock across a network call. Revalidate after any work performed outside the lock.
|
|
181
|
+
|
|
182
|
+
## Failure-injection matrix
|
|
183
|
+
|
|
184
|
+
| Injection | Required observation |
|
|
185
|
+
| --- | --- |
|
|
186
|
+
| crash before prepared record | source remains authoritative; abandoned resources expire |
|
|
187
|
+
| crash after prepared record | retry observes the same immutable snapshot |
|
|
188
|
+
| lease expires during prepare | old or newer authority wins; expired attempt cannot commit |
|
|
189
|
+
| crash immediately before commit | either old authority remains or commit is durably visible |
|
|
190
|
+
| crash after commit before response | retry replays committed result without a second cutover |
|
|
191
|
+
| commit response lost | request and transition identity recover the recorded outcome |
|
|
192
|
+
| stale source writes after commit | authoritative sink rejects old epoch |
|
|
193
|
+
| target receives duplicated input | sequence and request identity suppress duplicate effect |
|
|
194
|
+
| target receives reordered input | sequence policy buffers, rejects, or deterministically reorders |
|
|
195
|
+
| outbox delivery is delayed | committed reads are correct; consumers later converge monotonically |
|
|
196
|
+
| cleanup repeatedly fails | new authority stays valid; cleanup remains observable and retryable |
|
|
197
|
+
| reverse transition races cleanup | transition tags and higher generation protect new resources |
|
|
198
|
+
|
|
199
|
+
Prefer model-based state exploration, controlled schedulers, barriers, and fault injection over sleep
|
|
200
|
+
timing. Preserve the failing transition ID, seed or schedule, phase, and epoch so the interleaving can
|
|
201
|
+
be reproduced.
|
|
202
|
+
|
|
203
|
+
## Invariant monitoring
|
|
204
|
+
|
|
205
|
+
Continuously query or derive:
|
|
206
|
+
|
|
207
|
+
- no object has more than one committed owner for the same generation;
|
|
208
|
+
- no object has more than one active transition slot;
|
|
209
|
+
- no uncommitted target has authoritative writes;
|
|
210
|
+
- no accepted write carries an epoch below the current fence;
|
|
211
|
+
- every committed transition agrees with the object's owner and generation;
|
|
212
|
+
- every expired or aborted transition eventually reaches bounded cleanup or a named terminal alert;
|
|
213
|
+
- every committed outbox record eventually delivers or remains in a visible retry or dead-letter
|
|
214
|
+
state.
|
|
215
|
+
|
|
216
|
+
Alert on invariant violations, not only handler errors. A quiet service can still hold split state.
|
|
217
|
+
|
|
218
|
+
## Skill handoffs
|
|
219
|
+
|
|
220
|
+
- Use `state-machine-pattern` for one entity's ordinary lifecycle table.
|
|
221
|
+
- Use `durable-workflow-orchestration` for multi-step persisted business progress, callbacks,
|
|
222
|
+
compensation, and resume.
|
|
223
|
+
- Use `dual-write-consistency` for local commit plus independent publication, projection, or provider
|
|
224
|
+
convergence.
|
|
225
|
+
- Use `idempotency-integrity-review` for duplicate logical intent, request hashing, and response
|
|
226
|
+
replay details.
|
|
227
|
+
- Use `concurrency-invariant-review` when the wider problem is shared-state synchronization rather
|
|
228
|
+
than an authority handoff.
|
|
229
|
+
- Use `transaction-boundary-integrity-review` for atomic local invariants that do not move authority.
|
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
---
|
|
2
|
+
mustflow_doc: skill.ui-dispatch-lifecycle-review
|
|
3
|
+
locale: en
|
|
4
|
+
canonical: true
|
|
5
|
+
revision: 2
|
|
6
|
+
lifecycle: mustflow-owned
|
|
7
|
+
authority: procedure
|
|
8
|
+
name: ui-dispatch-lifecycle-review
|
|
9
|
+
description: Apply this skill when desktop, mobile, embedded, or rich-client UI code creates or accesses thread-affine UI objects, native handles, bound models, timers, resources, dispatchers, event loops, Invoke or posted callbacks, synchronization contexts, main queues, actors, progress reporters, background results, cancellation, closing, or shutdown and code can run on the wrong owner thread, create affinity on the wrong thread, outlive its event loop, apply stale data, reorder state, flood the queue, freeze input, or touch a destroyed owner.
|
|
10
|
+
metadata:
|
|
11
|
+
mustflow_schema: "1"
|
|
12
|
+
mustflow_kind: procedure
|
|
13
|
+
pack_id: mustflow.core
|
|
14
|
+
skill_id: mustflow.core.ui-dispatch-lifecycle-review
|
|
15
|
+
command_intents:
|
|
16
|
+
- changes_status
|
|
17
|
+
- changes_diff_summary
|
|
18
|
+
- lint
|
|
19
|
+
- build
|
|
20
|
+
- test_related
|
|
21
|
+
- test
|
|
22
|
+
- test_audit
|
|
23
|
+
- docs_validate_fast
|
|
24
|
+
- test_release
|
|
25
|
+
- mustflow_check
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
# UI Dispatch Lifecycle Review
|
|
29
|
+
|
|
30
|
+
<!-- mustflow-section: purpose -->
|
|
31
|
+
## Purpose
|
|
32
|
+
|
|
33
|
+
Review UI dispatch as scheduling onto an affinity context, not as proof of freshness, lifecycle,
|
|
34
|
+
ordering, cancellation, ownership transfer, or visible completion.
|
|
35
|
+
|
|
36
|
+
A callback can execute on the correct UI thread and still belong to an old operation, closed view,
|
|
37
|
+
recreated native handle, stale user-edit version, canceled request, superseded progress stream, or
|
|
38
|
+
partially torn snapshot. The review question is which generation and state preconditions are checked
|
|
39
|
+
at actual application time.
|
|
40
|
+
|
|
41
|
+
<!-- mustflow-section: use-when -->
|
|
42
|
+
## Use When
|
|
43
|
+
|
|
44
|
+
- Code posts or invokes work through a UI dispatcher, synchronization context, main queue, actor,
|
|
45
|
+
event queue, binding callback, progress reporter, observable, timer, or framework scheduling API.
|
|
46
|
+
- Background search, validation, synchronization, loading, parsing, device, network, database, or
|
|
47
|
+
worker results update a window, view, control, scene, model, binding, collection, progress
|
|
48
|
+
indicator, busy state, selection, editor, or rendered peer.
|
|
49
|
+
- A view can close, reopen, detach, reattach, recreate its native handle, change owner, change scene,
|
|
50
|
+
replace its model, or begin a newer operation before an old callback runs.
|
|
51
|
+
- Closing, cancel, restart, duplicate close, subscription disposal, timer shutdown, semaphore,
|
|
52
|
+
busy-gate, resource cleanup, app shutdown, queue backlog, GUI freeze, input delay, layout storm,
|
|
53
|
+
GPU wait, or thread-pool starvation affects UI work.
|
|
54
|
+
- Code or docs claim dispatching to the UI thread makes data race-free, FIFO preserves request order,
|
|
55
|
+
cancellation removes queued callbacks, an object reference proves one lifecycle, or low UI-thread
|
|
56
|
+
CPU proves the UI pipeline is healthy.
|
|
57
|
+
|
|
58
|
+
<!-- mustflow-section: do-not-use-when -->
|
|
59
|
+
## Do Not Use When
|
|
60
|
+
|
|
61
|
+
- A blocking dialog, nested event loop, message pump, synchronous UI wait, run-loop mode, local loop,
|
|
62
|
+
or host callback reenters before the outer handler returns; use
|
|
63
|
+
`modal-loop-reentrancy-review` first.
|
|
64
|
+
- The task is ordinary browser component state ownership with no native or dispatcher lifecycle;
|
|
65
|
+
use `frontend-state-ownership-review`.
|
|
66
|
+
- The main problem is layout, paint, compositing, hydration or frame work rather than dispatch
|
|
67
|
+
freshness and lifecycle; use `frame-render-performance-review`.
|
|
68
|
+
- The main problem is a background service process, OS supervisor, durable checkpoint or restart;
|
|
69
|
+
use `desktop-background-process-stability-review`.
|
|
70
|
+
- The main problem is generic shared-memory synchronization without a UI dispatch target; use
|
|
71
|
+
`race-condition-review` or `concurrency-invariant-review`.
|
|
72
|
+
- The callback consumes a current immutable snapshot under a verified live owner and generation,
|
|
73
|
+
with no cancellation, queue, closing, binding, progress, or shutdown risk.
|
|
74
|
+
|
|
75
|
+
<!-- mustflow-section: required-inputs -->
|
|
76
|
+
## Required Inputs
|
|
77
|
+
|
|
78
|
+
- Dispatch ledger: scheduling API, target UI context or actor, priority, enqueue time, execution
|
|
79
|
+
start, application time, render or presentation evidence, nested-pump depth, and rejection or
|
|
80
|
+
cancellation behavior.
|
|
81
|
+
- Affinity ledger: toolkit-defined owner for each UI instance and object graph, main thread versus
|
|
82
|
+
UI event thread, native-handle or peer creation point, bound model and collection ownership,
|
|
83
|
+
mutable framework resources, worker objects, active event loop, getter side effects, deletion
|
|
84
|
+
context, and affinity assertions.
|
|
85
|
+
- Identity ledger: operation, attempt, view instance, owner, native handle or peer generation,
|
|
86
|
+
attachment or scene generation, state version, edit version, request key, and correlation ID.
|
|
87
|
+
- Payload ledger: values captured by the callback, mutable aliases, collections, ownership transfer,
|
|
88
|
+
snapshot construction, notification order, and fields that must change atomically.
|
|
89
|
+
- Freshness ledger: latest-operation rule, ABA protection, expected view and state generations,
|
|
90
|
+
current selection or edit preconditions, server and local edit versions, and stale-result policy.
|
|
91
|
+
- Lifecycle ledger: open, closing and closed states; close request identity; cancellation source
|
|
92
|
+
ownership; queued continuations; subscriptions; timers; semaphore or gate ownership; worker drain;
|
|
93
|
+
service disposal; and shutdown order.
|
|
94
|
+
- Pressure ledger: progress and high-rate update producers, coalescing, queue age, priority,
|
|
95
|
+
thread-pool start delay, lock owners, allocation, layout invalidation, paint damage, GPU waits,
|
|
96
|
+
external synchronous calls, and input-event rate.
|
|
97
|
+
- Test and observability evidence: deterministic dispatcher, virtual clock, barriers, fault hooks,
|
|
98
|
+
state-transition invariants, environment matrix, lifecycle and queue telemetry, and configured
|
|
99
|
+
command intents.
|
|
100
|
+
|
|
101
|
+
<!-- mustflow-section: preconditions -->
|
|
102
|
+
## Preconditions
|
|
103
|
+
|
|
104
|
+
- The task matches the Use When conditions and does not match the exclusions.
|
|
105
|
+
- Higher-priority instructions and `.mustflow/config/commands.toml` have been checked.
|
|
106
|
+
- The actual dispatch target, view lifecycle, operation owner and application point are identified.
|
|
107
|
+
- Framework affinity, cancellation and closing behavior is taken from current repository or
|
|
108
|
+
authoritative version-matched evidence rather than API-name folklore.
|
|
109
|
+
- Existing immutable-result, generation, close-state, lifetime subscription, coalescing, telemetry
|
|
110
|
+
and deterministic scheduler patterns have been searched.
|
|
111
|
+
|
|
112
|
+
<!-- mustflow-section: allowed-edits -->
|
|
113
|
+
## Allowed Edits
|
|
114
|
+
|
|
115
|
+
- Add operation and view generations, immutable UI snapshots, execution-time freshness checks,
|
|
116
|
+
conditional application, owner-scoped cancellation, close state machines, exactly-once cleanup,
|
|
117
|
+
lifetime-bound subscriptions, coalescing, batch state replacement, queue telemetry, deterministic
|
|
118
|
+
dispatch abstractions, virtual clocks, and focused race fixtures.
|
|
119
|
+
- Move UI state ownership to one UI reducer and make workers return immutable results or effect
|
|
120
|
+
descriptions.
|
|
121
|
+
- Add bounded shutdown sequencing: stop admission, request cancellation, await owned completion,
|
|
122
|
+
release subscriptions and resources, stop services, then destroy UI.
|
|
123
|
+
- Add queue-delay, wait-chain, allocation, layout, GPU and input-pressure evidence when the symptom
|
|
124
|
+
is a freeze or responsiveness regression.
|
|
125
|
+
- Add instance-owner assertions, early owner-thread handle creation, object-graph affinity rules,
|
|
126
|
+
pure-data transfer boundaries, framework-approved frozen resources, worker-object isolation,
|
|
127
|
+
await-boundary context checks, owner-loop deletion, and event-loop liveness gates.
|
|
128
|
+
- Do not add repeated liveness checks only before dispatch, global cancellation-source fields without
|
|
129
|
+
owner comparison, unlimited per-item progress posts, sync-over-async waits, or sleeps as fixes.
|
|
130
|
+
|
|
131
|
+
<!-- mustflow-section: procedure -->
|
|
132
|
+
## Procedure
|
|
133
|
+
|
|
134
|
+
1. Identify the actual UI application point.
|
|
135
|
+
- Distinguish process main thread from the toolkit's UI event thread. Resolve affinity from the
|
|
136
|
+
owning object instance or framework assertion, not class name, thread name, or a generic
|
|
137
|
+
synchronization context.
|
|
138
|
+
- Identify when native handle, peer, dispatcher, looper or scene affinity becomes fixed. Prevent
|
|
139
|
+
lazy UI creation on a worker after an ambiguous early affinity check.
|
|
140
|
+
- A worker-side liveness check followed by dispatch has a time-of-check gap. Recheck owner,
|
|
141
|
+
view-instance, attachment or handle generation, operation generation, cancellation and state
|
|
142
|
+
preconditions inside the UI callback immediately before mutation.
|
|
143
|
+
- Treat enqueue success as scheduling evidence only.
|
|
144
|
+
2. Separate operation identity from displayed value.
|
|
145
|
+
- Assign a monotonic operation or request generation. Compare generation, not only search text,
|
|
146
|
+
item ID, path or selection value, because values can leave and return through an ABA cycle.
|
|
147
|
+
- Define whether stale completion is dropped, merged, shown as conflict, cached without display,
|
|
148
|
+
or recomputed.
|
|
149
|
+
3. Transfer immutable payload ownership.
|
|
150
|
+
- Freeze the values and collection snapshot before enqueue. A captured object reference is not a
|
|
151
|
+
snapshot when the worker can continue mutating its fields, children or list.
|
|
152
|
+
- Publish one coherent UI state instead of combining a count, items, selection and totals from
|
|
153
|
+
different moments.
|
|
154
|
+
- Treat UI getters and bound models as affinity-sensitive unless the framework explicitly says
|
|
155
|
+
otherwise. A getter can create handles, realize templates, calculate layout, query native
|
|
156
|
+
state or mutate caches.
|
|
157
|
+
- Transfer pure bytes, pixels, strings or immutable DTOs from workers. Do not pass mutable image,
|
|
158
|
+
brush, font, timer, model, collection or framework resources across owners unless the toolkit
|
|
159
|
+
provides and the code proves a frozen cross-thread contract.
|
|
160
|
+
4. Revalidate user-edit assumptions.
|
|
161
|
+
- Carry the UI or document version observed before background work and the server or source
|
|
162
|
+
version used for computation.
|
|
163
|
+
- At application time choose user-edit priority, merge, conflict display or restart. Do not
|
|
164
|
+
overwrite composition, cursor, selection or uncommitted input merely because the remote result
|
|
165
|
+
arrived later.
|
|
166
|
+
5. Treat native handles and visual attachment as generations.
|
|
167
|
+
- Object identity does not prove the same native peer, scene, window attachment, DPI generation
|
|
168
|
+
or owner lifetime.
|
|
169
|
+
- Increment a view or attachment epoch on recreation, detach, reparent, reopen or model
|
|
170
|
+
replacement and reject callbacks from older epochs.
|
|
171
|
+
- Audit the whole owned object graph. Moving or recreating one node while children, timers,
|
|
172
|
+
sockets, models or native resources remain on another owner can split affinity.
|
|
173
|
+
6. Keep cancellation checks at every authority boundary.
|
|
174
|
+
- Cancellation before scheduling does not remove a callback already queued. Check before work,
|
|
175
|
+
before enqueue and inside the UI callback, together with operation and view generations.
|
|
176
|
+
- A cancellation request is not task completion and does not authorize resource disposal.
|
|
177
|
+
- Re-evaluate execution context after every suspension boundary that can resume elsewhere.
|
|
178
|
+
Captured context is a scheduling address, not identity proof, and a queued continuation needs
|
|
179
|
+
the destination event loop to remain alive and consuming work.
|
|
180
|
+
7. Batch dependent state transitions.
|
|
181
|
+
- Replace multiple order-sensitive property notifications with one immutable state update or an
|
|
182
|
+
explicit UI-thread batch whose intermediate states are not observable.
|
|
183
|
+
- Record invalid transitions such as closing to loaded or completed to progress.
|
|
184
|
+
8. Coalesce progress and live updates.
|
|
185
|
+
- Keep the newest supersedable value, preserve required boundary transitions and cap visible
|
|
186
|
+
update frequency.
|
|
187
|
+
- Ensure a final state cannot be followed by queued obsolete progress. Bound by queue age and
|
|
188
|
+
generation, not only item count.
|
|
189
|
+
9. Model closing asynchronously.
|
|
190
|
+
- If the framework's closing event is synchronous, cancel the first close, enter
|
|
191
|
+
`Open -> Closing`, stop new work, request cancellation, await owned tasks without blocking the
|
|
192
|
+
UI context, release lifetime resources, then request the one final close.
|
|
193
|
+
- A second close during `Closing` joins the existing completion instead of starting cleanup
|
|
194
|
+
again.
|
|
195
|
+
10. Keep cancellation and gate ownership local to the operation.
|
|
196
|
+
- Capture each cancellation source, task, semaphore acquisition and lease in local operation
|
|
197
|
+
state. An old `finally` cannot dispose a replacement source or reset a new operation.
|
|
198
|
+
- Release a permit only when that operation actually acquired it and still owns the shared busy
|
|
199
|
+
state it clears.
|
|
200
|
+
11. Bound callbacks to owner lifetime.
|
|
201
|
+
- Tie event subscriptions, observables, timers, progress reporters and message-bus listeners to
|
|
202
|
+
one view lifetime and dispose them as a group.
|
|
203
|
+
- Already queued callbacks still require generation checks. Collection or event-source disposal
|
|
204
|
+
alone is not enough.
|
|
205
|
+
12. Order application shutdown.
|
|
206
|
+
- Block new input and work admission, stop producing UI callbacks, request cancellation, drain
|
|
207
|
+
owned work to a bounded deadline, flush required durable state, stop dependent services, then
|
|
208
|
+
destroy views and dispatch infrastructure.
|
|
209
|
+
- Do not destroy UI, logging, storage or worker resources while owned tasks can still use them.
|
|
210
|
+
- Stop timers, drain or reject queued signals, release native resources and delete objects on the
|
|
211
|
+
owning context when required. Deferred deletion posted to a stopped or never-started loop is
|
|
212
|
+
not completed cleanup.
|
|
213
|
+
13. Diagnose responsiveness as a pipeline.
|
|
214
|
+
- Record created, worker-started, dispatch-enqueued, UI-started, state-applied, layout, paint and
|
|
215
|
+
presented stages. Queue delay is start minus enqueue, not callback duration.
|
|
216
|
+
- Build wait chains through lock owners, thread-pool queues, synchronous dispatch, RPC or COM,
|
|
217
|
+
external input components and GPU fences. Low UI CPU can mean blocked or starved work.
|
|
218
|
+
- Correlate allocation bursts, layout invalidation fan-out, paint damage, GPU synchronization and
|
|
219
|
+
input storms with the same frame and interaction trace.
|
|
220
|
+
- Include sync-over-async waits, synchronous marshal to the same serial queue, reverse UI-worker
|
|
221
|
+
waits, locks across await, inline continuation completion, missing task terminal paths,
|
|
222
|
+
bounded-queue approval cycles and thread-pool starvation in the wait graph.
|
|
223
|
+
14. Read [UI Dispatch and Lifecycle Checklist](references/ui-dispatch-lifecycle-checklist.md) for
|
|
224
|
+
the freshness, close-state, queue-pressure, diagnostic and fault matrices.
|
|
225
|
+
15. Read [UI Affinity and Event Loop Checklist](references/ui-affinity-event-loop-checklist.md) when ownership, native handle creation, bound models, framework resources, worker objects, event-loop availability, synchronous marshaling, timers, deletion, or await continuations are in scope.
|
|
226
|
+
16. Require deterministic evidence.
|
|
227
|
+
- Use a controllable dispatcher and virtual clock to force old-result-after-new-result,
|
|
228
|
+
close-after-enqueue-before-run, handle recreation, cancellation-after-enqueue, old-finally
|
|
229
|
+
after new-start, duplicate close, immediate cancellation callback, queue-flood-before-final,
|
|
230
|
+
subscription-after-close and shutdown races.
|
|
231
|
+
- Assert that closed views never mutate, old epochs never apply, exactly one current operation
|
|
232
|
+
owns busy and cancellation state, queued work drains or is rejected, subscriptions return to
|
|
233
|
+
baseline, and every invalid transition is observable.
|
|
234
|
+
- If configured proof is unavailable, report static UI-dispatch risk instead of approving the
|
|
235
|
+
path.
|
|
236
|
+
|
|
237
|
+
<!-- mustflow-section: postconditions -->
|
|
238
|
+
## Postconditions
|
|
239
|
+
|
|
240
|
+
- Dispatch target, priority, enqueue and apply stages, operation and view generations, immutable
|
|
241
|
+
payload, freshness rule, edit conflict policy, cancellation ownership, close state, subscription
|
|
242
|
+
lifetime, shutdown order, queue pressure, responsiveness evidence and tests are explicit.
|
|
243
|
+
- UI owner thread, instance and object-graph affinity, handle or peer creation, getter and binding
|
|
244
|
+
behavior, worker transfer boundary, continuation destination, event-loop liveness, resource
|
|
245
|
+
deletion and affinity assertions are explicit.
|
|
246
|
+
- Pre-dispatch-only liveness checks, out-of-order result overwrite, mutable closure capture, stale
|
|
247
|
+
read-compute-write, ABA value checks, canceled queued callbacks, handle-generation reuse, torn
|
|
248
|
+
collection snapshots, notification-order exposure, progress backlog, old-finally cleanup,
|
|
249
|
+
unowned permit release, zombie view subscriptions, sync close waits and torn shutdown are fixed or
|
|
250
|
+
reported.
|
|
251
|
+
- UI-thread safety claims are backed by configured tests, framework evidence matched to current
|
|
252
|
+
code, queue and wait traces, or labeled as static review risk.
|
|
253
|
+
|
|
254
|
+
<!-- mustflow-section: verification -->
|
|
255
|
+
## Verification
|
|
256
|
+
|
|
257
|
+
Use configured oneshot command intents when available:
|
|
258
|
+
|
|
259
|
+
- `changes_status`
|
|
260
|
+
- `changes_diff_summary`
|
|
261
|
+
- `lint`
|
|
262
|
+
- `build`
|
|
263
|
+
- `test_related`
|
|
264
|
+
- `test`
|
|
265
|
+
- `test_audit`
|
|
266
|
+
- `docs_validate_fast`
|
|
267
|
+
- `test_release`
|
|
268
|
+
- `mustflow_check`
|
|
269
|
+
|
|
270
|
+
Prefer the narrowest configured intent that covers the changed dispatch lifecycle and template
|
|
271
|
+
surfaces. Do not infer raw GUI sessions, profilers, system traces, live device tests, watchers or
|
|
272
|
+
manual stress commands outside the command contract.
|
|
273
|
+
|
|
274
|
+
<!-- mustflow-section: failure-handling -->
|
|
275
|
+
## Failure Handling
|
|
276
|
+
|
|
277
|
+
- If the current operation owner, view generation or actual application point cannot be named,
|
|
278
|
+
report that queued UI work has no freshness authority.
|
|
279
|
+
- If closing cannot be awaited by framework contract, cancel the initial close and move cleanup to
|
|
280
|
+
an explicit asynchronous state machine rather than relying on an ignored continuation.
|
|
281
|
+
- If safe repair requires public API change, view-model ownership redesign, dispatcher abstraction,
|
|
282
|
+
native tracing or real-device coverage outside scope, report the missing boundary.
|
|
283
|
+
- If instrumentation changes priority, allocation, locking or queue behavior materially, redesign
|
|
284
|
+
the observer before trusting its result.
|
|
285
|
+
- If a configured command fails, preserve the failing lifecycle invariant and deterministic
|
|
286
|
+
schedule before editing again.
|
|
287
|
+
|
|
288
|
+
<!-- mustflow-section: output-format -->
|
|
289
|
+
## Output Format
|
|
290
|
+
|
|
291
|
+
- UI dispatch lifecycle boundary reviewed
|
|
292
|
+
- Dispatch context, operation/view generation, immutable payload, freshness, edit conflict,
|
|
293
|
+
cancellation, close state, subscriptions, gate ownership, shutdown, queue pressure,
|
|
294
|
+
responsiveness, diagnostic and test findings
|
|
295
|
+
- Affinity, event-loop and UI dispatch lifecycle fixes made or recommended
|
|
296
|
+
- Evidence level: configured-test evidence, framework evidence, affinity assertion, queue or wait trace, static review
|
|
297
|
+
risk, manual-only, missing, or not applicable
|
|
298
|
+
- Command intents run
|
|
299
|
+
- Skipped GUI diagnostics and reasons
|
|
300
|
+
- Remaining UI-dispatch lifecycle risk
|