mustflow 2.116.1 → 2.116.3
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,164 @@
|
|
|
1
|
+
# Tree Serialization and Compatibility Checklist
|
|
2
|
+
|
|
3
|
+
Use this checklist when a CST, AST, HIR, analysis index, or related tree snapshot is serialized,
|
|
4
|
+
cached, exchanged across versions, deserialized from untrusted bytes, migrated, or fuzzed.
|
|
5
|
+
|
|
6
|
+
## Contents
|
|
7
|
+
|
|
8
|
+
1. [Artifact lifetime contract](#artifact-lifetime-contract)
|
|
9
|
+
2. [Memory model and wire schema](#memory-model-and-wire-schema)
|
|
10
|
+
3. [Header and early rejection](#header-and-early-rejection)
|
|
11
|
+
4. [Schema evolution and presence](#schema-evolution-and-presence)
|
|
12
|
+
5. [Bounded decoding](#bounded-decoding)
|
|
13
|
+
6. [Two-phase graph reconstruction](#two-phase-graph-reconstruction)
|
|
14
|
+
7. [Validation layers](#validation-layers)
|
|
15
|
+
8. [Deterministic encoding](#deterministic-encoding)
|
|
16
|
+
9. [Cross-version and migration matrix](#cross-version-and-migration-matrix)
|
|
17
|
+
10. [Identity and snapshot scope](#identity-and-snapshot-scope)
|
|
18
|
+
11. [Fuzz targets and oracles](#fuzz-targets-and-oracles)
|
|
19
|
+
12. [Invariants and handoffs](#invariants-and-handoffs)
|
|
20
|
+
|
|
21
|
+
## Artifact lifetime contract
|
|
22
|
+
|
|
23
|
+
Decide first whether the artifact is:
|
|
24
|
+
|
|
25
|
+
- a disposable cache that may reject incompatible data and regenerate;
|
|
26
|
+
- a build or IDE exchange artifact with a bounded compatibility window;
|
|
27
|
+
- a durable user or ecosystem format requiring migration and unknown-data preservation.
|
|
28
|
+
|
|
29
|
+
Name readers, writers, retention, privacy, trust boundary, regeneration source, and supported version
|
|
30
|
+
matrix. Do not burden a disposable cache with indefinite migration or treat durable data as safely
|
|
31
|
+
discardable.
|
|
32
|
+
|
|
33
|
+
## Memory model and wire schema
|
|
34
|
+
|
|
35
|
+
Separate runtime nodes from the wire contract. Define stable integer widths, signedness, byte order,
|
|
36
|
+
string encoding, node-kind numbers, field numbers, union tags, presence, list lengths, reference IDs,
|
|
37
|
+
and ordering rules. Never serialize pointers, allocator slots, object padding, host enum ordinals, or
|
|
38
|
+
compiler-dependent layouts as a portable format.
|
|
39
|
+
|
|
40
|
+
Keep encoder and decoder adapters between the wire schema and current in-memory representation. A
|
|
41
|
+
node-class refactor must not silently reinterpret old bytes.
|
|
42
|
+
|
|
43
|
+
## Header and early rejection
|
|
44
|
+
|
|
45
|
+
Validate a bounded fixed header before decompression, allocation, or graph construction. Include
|
|
46
|
+
applicable magic, schema major and minor, language or dialect identity, feature bitmap, payload and
|
|
47
|
+
expanded lengths, compression mode, checksum or digest, producer diagnostics, and artifact class.
|
|
48
|
+
|
|
49
|
+
Treat producer version as evidence for diagnostics, not permission to trust the payload. Reject
|
|
50
|
+
unsupported mandatory features, impossible lengths, incompatible major versions, and policy limits
|
|
51
|
+
before expensive work.
|
|
52
|
+
|
|
53
|
+
## Schema evolution and presence
|
|
54
|
+
|
|
55
|
+
- Assign stable node-kind and field numbers. Reserve removed numbers and never reuse them for a new
|
|
56
|
+
meaning.
|
|
57
|
+
- Distinguish absent fields from fields explicitly set to their default when migration or semantics
|
|
58
|
+
can observe presence.
|
|
59
|
+
- Add optional fields with safe reader behavior. Do not add required fields that older writers cannot
|
|
60
|
+
provide inside a claimed compatibility window.
|
|
61
|
+
- Define unknown field and unknown variant behavior: preserve, skip, quarantine, or reject by field
|
|
62
|
+
criticality and artifact contract.
|
|
63
|
+
- Keep migrations pure, ordered, restartable, and independently testable. Preserve extensions that a
|
|
64
|
+
migration does not understand when the durable-format contract requires round trips.
|
|
65
|
+
|
|
66
|
+
## Bounded decoding
|
|
67
|
+
|
|
68
|
+
Charge limits before allocation and expansion. Bound compressed and expanded bytes, strings, node
|
|
69
|
+
count, children per node, total edges, reference tables, diagnostics, nesting, work units, and wall-
|
|
70
|
+
clock deadline. Use an explicit stack when attacker-controlled depth could overflow the call stack.
|
|
71
|
+
|
|
72
|
+
Require integer arithmetic for lengths and offsets to reject overflow, overlap, truncation, and
|
|
73
|
+
out-of-range slices. A checksum detects corruption; it does not establish safe structure or meaning.
|
|
74
|
+
|
|
75
|
+
## Two-phase graph reconstruction
|
|
76
|
+
|
|
77
|
+
Decode bounded tables and node records without creating raw pointers. In a second phase, resolve IDs
|
|
78
|
+
and verify:
|
|
79
|
+
|
|
80
|
+
- reference range and expected target kind;
|
|
81
|
+
- ID uniqueness and owning document, item, or body;
|
|
82
|
+
- single structural parent where a tree contract requires it;
|
|
83
|
+
- absence of structural cycles;
|
|
84
|
+
- list cardinality and source-order constraints;
|
|
85
|
+
- separation of ownership edges from symbol, use-def, or control-flow references.
|
|
86
|
+
|
|
87
|
+
Do not expose a partially linked graph to visitors, destructors, plugins, or semantic consumers.
|
|
88
|
+
|
|
89
|
+
## Validation layers
|
|
90
|
+
|
|
91
|
+
Keep four results distinct:
|
|
92
|
+
|
|
93
|
+
1. wire validity: lengths, tags, encoding, checksum, and feature framing;
|
|
94
|
+
2. structural validity: node kinds, fields, IDs, edges, cycles, and cardinality;
|
|
95
|
+
3. semantic validity: scopes, symbol kinds, types, effects, and source relationships;
|
|
96
|
+
4. phase validity: invariants promised by CST, AST, typed HIR, MIR, or another declared layer.
|
|
97
|
+
|
|
98
|
+
A successful decoder proves only the earlier layers it actually checked. Run the owning tree or IR
|
|
99
|
+
verifier before publishing the artifact as usable.
|
|
100
|
+
|
|
101
|
+
## Deterministic encoding
|
|
102
|
+
|
|
103
|
+
Make one supported writer emit canonical bytes for the same declared semantic or syntax identity.
|
|
104
|
+
Normalize map order, string tables, temporary IDs, diagnostic order, feature ordering, and equivalent
|
|
105
|
+
encodings. Do not make readers depend on field arrival order unless the wire schema requires it.
|
|
106
|
+
|
|
107
|
+
Define whether source spelling, trivia, positions, nondeterministic analysis facts, and producer-only
|
|
108
|
+
metadata participate in the canonical identity. Keep semantic and exact-source hashes separate.
|
|
109
|
+
|
|
110
|
+
## Cross-version and migration matrix
|
|
111
|
+
|
|
112
|
+
Maintain golden artifacts from every supported writer version and verify every promised reader and
|
|
113
|
+
writer pairing. Cover oldest-supported to current migrations, current writer to older compatible
|
|
114
|
+
reader where promised, unknown fields, retired fields, optional presence, unsupported features, and
|
|
115
|
+
corrupt headers.
|
|
116
|
+
|
|
117
|
+
Compare migration chains with direct construction of the latest schema. Make the support window and
|
|
118
|
+
rejection diagnostic executable rather than relying on prose compatibility claims.
|
|
119
|
+
|
|
120
|
+
## Identity and snapshot scope
|
|
121
|
+
|
|
122
|
+
Do not serialize raw snapshot-local IDs as durable semantic identity. Namespace serialized IDs by
|
|
123
|
+
artifact and owner, remap them on load, and preserve explicit origin or definition identities only
|
|
124
|
+
when their stability contract spans the artifact boundary.
|
|
125
|
+
|
|
126
|
+
Bind cached analysis to source or tree fingerprint, language options, dependency generations, schema
|
|
127
|
+
version, and producer contract. Reject a structurally valid cache whose semantic dependency capsule
|
|
128
|
+
does not match the current workspace.
|
|
129
|
+
|
|
130
|
+
## Fuzz targets and oracles
|
|
131
|
+
|
|
132
|
+
Keep complementary bounded targets:
|
|
133
|
+
|
|
134
|
+
- raw bytes for framing, length, decoder, and rejection safety;
|
|
135
|
+
- schema-aware near-valid records for deep structural validation;
|
|
136
|
+
- valid generated trees for semantic verifier, encode, decode, rewrite, and migration paths;
|
|
137
|
+
- API sequences such as decode, verify, rewrite, encode, reload, and discard-old-snapshot.
|
|
138
|
+
|
|
139
|
+
Use oracles beyond crashes:
|
|
140
|
+
|
|
141
|
+
- decode then encode produces canonical bytes for accepted artifacts;
|
|
142
|
+
- encode then decode preserves the declared semantic and source-aware identity;
|
|
143
|
+
- migrations agree with direct latest-schema construction;
|
|
144
|
+
- repeated canonical encoding is deterministic;
|
|
145
|
+
- invalid graphs are rejected by the correct validation layer;
|
|
146
|
+
- work, memory, depth, and output stay within budgets;
|
|
147
|
+
- stale handles and snapshot references do not resolve after replacement.
|
|
148
|
+
|
|
149
|
+
Keep raw mutation, structured generation, campaign feedback, corpora, minimization, sanitizer lanes,
|
|
150
|
+
and long-running execution under `fuzz-harness-review`. This checklist owns tree-format semantics and
|
|
151
|
+
oracles, not campaign authority.
|
|
152
|
+
|
|
153
|
+
## Invariants and handoffs
|
|
154
|
+
|
|
155
|
+
- Every artifact declares cache, exchange, or durable lifetime semantics.
|
|
156
|
+
- Every accepted payload passes bounded wire, structural, semantic, and phase checks as applicable.
|
|
157
|
+
- Every schema number and presence rule has an evolution contract.
|
|
158
|
+
- Every durable identity is distinct from runtime pointers and snapshot-local IDs.
|
|
159
|
+
- Every compatibility claim names tested reader and writer versions.
|
|
160
|
+
- Every fuzz claim names a semantic, determinism, validation, or resource oracle beyond coverage.
|
|
161
|
+
- Use `parser-engineering-review` for CST and AST wire or snapshot contracts.
|
|
162
|
+
- Use `compiler-engineering-review` for persisted HIR, MIR, IR, and compiler metadata semantics.
|
|
163
|
+
- Use `fuzz-harness-review` for maintained campaigns, mutators, corpora, and sanitizer execution.
|
|
164
|
+
- Use the matching public-contract or data-migration skill for durable external formats.
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
# Tree Traversal and Rewrite Checklist
|
|
2
|
+
|
|
3
|
+
Use this checklist when syntax or semantic trees are visited, transformed, rewritten, structurally
|
|
4
|
+
shared, incrementally remapped, or used as keys for cached analysis.
|
|
5
|
+
|
|
6
|
+
## Contents
|
|
7
|
+
|
|
8
|
+
1. [Responsibility split](#responsibility-split)
|
|
9
|
+
2. [Traversal policy](#traversal-policy)
|
|
10
|
+
3. [Immutable snapshot boundary](#immutable-snapshot-boundary)
|
|
11
|
+
4. [Traversal context](#traversal-context)
|
|
12
|
+
5. [Transformation result algebra](#transformation-result-algebra)
|
|
13
|
+
6. [Edit collection and conflict resolution](#edit-collection-and-conflict-resolution)
|
|
14
|
+
7. [Structural sharing and source fidelity](#structural-sharing-and-source-fidelity)
|
|
15
|
+
8. [Handles and identity across snapshots](#handles-and-identity-across-snapshots)
|
|
16
|
+
9. [Analysis invalidation](#analysis-invalidation)
|
|
17
|
+
10. [Rewrite termination](#rewrite-termination)
|
|
18
|
+
11. [Tree and graph traversal](#tree-and-graph-traversal)
|
|
19
|
+
12. [Transactional commit and verification](#transactional-commit-and-verification)
|
|
20
|
+
13. [Test matrix](#test-matrix)
|
|
21
|
+
14. [Invariants and handoffs](#invariants-and-handoffs)
|
|
22
|
+
|
|
23
|
+
## Responsibility split
|
|
24
|
+
|
|
25
|
+
Keep three contracts distinct even when a library uses different names:
|
|
26
|
+
|
|
27
|
+
| Role | Reads | Produces | Must not do |
|
|
28
|
+
| --- | --- | --- | --- |
|
|
29
|
+
| Visitor | One immutable snapshot | Observations or side-table facts | Mutate the traversed structure |
|
|
30
|
+
| Transformer | One immutable snapshot | A new snapshot or typed change result | Edit nodes in place or resolve rule conflicts implicitly |
|
|
31
|
+
| Rewriter | Snapshot, rules, edit policy | Validated transactional commit | Apply a match immediately without conflict and termination policy |
|
|
32
|
+
|
|
33
|
+
A visitor is not a weak rewriter, and a rewriter is not a visitor with writable nodes. Name the role
|
|
34
|
+
in APIs, ownership types, tests, and diagnostics.
|
|
35
|
+
|
|
36
|
+
## Traversal policy
|
|
37
|
+
|
|
38
|
+
Declare the policy as data or typed configuration:
|
|
39
|
+
|
|
40
|
+
- preorder, postorder, enter and leave callbacks, or an explicitly mixed schedule;
|
|
41
|
+
- structural nodes, tokens, trivia, missing and error nodes, and synthetic nodes included or skipped;
|
|
42
|
+
- source-written versus expanded or generated forms;
|
|
43
|
+
- child field order and list order;
|
|
44
|
+
- one visit per ownership edge or one visit per unique shared node;
|
|
45
|
+
- cancellation, early stop, depth budget, and error propagation;
|
|
46
|
+
- behavior for a node kind unknown to the visitor implementation.
|
|
47
|
+
|
|
48
|
+
Fail closed in development and contract tests when a closed node union gains an unhandled variant.
|
|
49
|
+
Do not let a default branch silently omit new syntax from security, refactoring, or semantic passes.
|
|
50
|
+
|
|
51
|
+
## Immutable snapshot boundary
|
|
52
|
+
|
|
53
|
+
- Give a visitor read-only access to a versioned snapshot and write observations to a separate result
|
|
54
|
+
builder or generation-aware side table.
|
|
55
|
+
- Make a transformer return a new root while reusing unchanged immutable subtrees. Do not mutate the
|
|
56
|
+
child list currently being traversed.
|
|
57
|
+
- Collect rewrite proposals against one base snapshot. Do not let an early proposal change what later
|
|
58
|
+
matchers see unless the rewrite contract explicitly starts another bounded epoch.
|
|
59
|
+
- Invalidate iterators, wrappers, positions, and parent views when their owning snapshot changes.
|
|
60
|
+
- If in-place mutation is unavoidable, require a generation-checked cursor and make every existing
|
|
61
|
+
iterator unusable after mutation. Do not expose this as the ordinary tree API.
|
|
62
|
+
|
|
63
|
+
## Traversal context
|
|
64
|
+
|
|
65
|
+
Pass context explicitly rather than hiding it in mutable visitor fields. Include applicable facts:
|
|
66
|
+
|
|
67
|
+
- document and snapshot generation;
|
|
68
|
+
- parent kind, named child field, list index, and ownership path;
|
|
69
|
+
- scope owner, language mode, expected node category, and source region;
|
|
70
|
+
- cancellation and work budget;
|
|
71
|
+
- traversal policy and rewrite epoch.
|
|
72
|
+
|
|
73
|
+
Use immutable context frames or scoped push and pop guards whose cleanup is guaranteed on early
|
|
74
|
+
return and error. Never infer a semantic parent from an obsolete parent pointer.
|
|
75
|
+
|
|
76
|
+
## Transformation result algebra
|
|
77
|
+
|
|
78
|
+
Do not overload null with several outcomes. Use typed results such as:
|
|
79
|
+
|
|
80
|
+
- `Keep` for unchanged identity and structure;
|
|
81
|
+
- `Replace(node)` for one category-compatible replacement;
|
|
82
|
+
- `Delete` only where the parent field is optional or repeated;
|
|
83
|
+
- `Splice(nodes)` only in a repeated slot with compatible element kinds;
|
|
84
|
+
- `Stop(result)` for successful bounded early termination;
|
|
85
|
+
- `Error(diagnostic)` for a failed transformation with no commit.
|
|
86
|
+
|
|
87
|
+
Validate result kind and cardinality at the parent boundary. Reject deletion of a required child,
|
|
88
|
+
splicing into a scalar field, or replacing an expression with a declaration before a malformed
|
|
89
|
+
intermediate tree becomes observable.
|
|
90
|
+
|
|
91
|
+
## Edit collection and conflict resolution
|
|
92
|
+
|
|
93
|
+
Represent every proposal with rule identity, base snapshot, target handle, expected kind, parent
|
|
94
|
+
field, source or structural anchor, replacement, priority, and provenance. Then:
|
|
95
|
+
|
|
96
|
+
1. collect candidates without mutation;
|
|
97
|
+
2. reject stale or unresolved targets;
|
|
98
|
+
3. group overlapping parent, child, sibling, and source-range edits;
|
|
99
|
+
4. resolve conflicts under one documented policy;
|
|
100
|
+
5. sort accepted edits deterministically;
|
|
101
|
+
6. apply them to a private new snapshot;
|
|
102
|
+
7. verify and publish atomically.
|
|
103
|
+
|
|
104
|
+
Define whether outer replacement suppresses inner edits, deeper edits win, or a conflict is an error.
|
|
105
|
+
Rule registration order must not become accidental precedence. A failed commit exposes neither a
|
|
106
|
+
partial tree nor partially updated side tables.
|
|
107
|
+
|
|
108
|
+
## Structural sharing and source fidelity
|
|
109
|
+
|
|
110
|
+
- Keep reusable persistent nodes free of parent pointers and absolute positions. Derive snapshot-
|
|
111
|
+
specific parents and positions through ephemeral wrappers or indexed views.
|
|
112
|
+
- Preserve syntax origins, token ownership, trivia, missing tokens, and delimiter relationships when
|
|
113
|
+
replacing source-aware nodes.
|
|
114
|
+
- Reuse an original node only when all structural children, payload, recovery state, and relevant
|
|
115
|
+
source references are unchanged.
|
|
116
|
+
- Distinguish generated text from original slices. Do not copy a parent's full span onto a synthetic
|
|
117
|
+
child or claim user authorship for inserted syntax.
|
|
118
|
+
- Reconcile leading, trailing, and dangling trivia at edit boundaries under a deterministic policy.
|
|
119
|
+
|
|
120
|
+
## Handles and identity across snapshots
|
|
121
|
+
|
|
122
|
+
Separate allocation identity, snapshot-local node identity, persistent syntax identity, and semantic
|
|
123
|
+
definition identity. A byte offset or structural hash is not any of those identities.
|
|
124
|
+
|
|
125
|
+
A durable handle should carry document identity, expected snapshot or generation, node key, expected
|
|
126
|
+
kind, and optional owner or field anchor. Resolve it through the current snapshot into a state such as
|
|
127
|
+
`Alive`, `Replaced`, `Deleted`, `Ambiguous`, `WrongDocument`, or `OutOfDate`; do not return one null for
|
|
128
|
+
every failure class.
|
|
129
|
+
|
|
130
|
+
Inherit persistent identity only from actual subtree reuse or one unambiguous bounded reconciliation.
|
|
131
|
+
Match within an owner using kind, field role, stable token anchors, sibling alignment, and structure.
|
|
132
|
+
When candidates tie, allocate a new identity. Copy and move identity require edit-lineage evidence;
|
|
133
|
+
final text alone cannot prove user intent.
|
|
134
|
+
|
|
135
|
+
Mark recovery regions and their ancestor chain unstable. Avoid aggressively transferring identity
|
|
136
|
+
through rapidly changing missing and error nodes.
|
|
137
|
+
|
|
138
|
+
## Analysis invalidation
|
|
139
|
+
|
|
140
|
+
Each transformation declares:
|
|
141
|
+
|
|
142
|
+
- node fields, ownership regions, symbols, control flow, and source relations it reads;
|
|
143
|
+
- structure, names, effects, types, scopes, or origins it may change;
|
|
144
|
+
- analyses proven preserved and the proof boundary;
|
|
145
|
+
- analyses invalidated, recomputed, or weakened;
|
|
146
|
+
- deleted-node keys and snapshot generations retired at commit.
|
|
147
|
+
|
|
148
|
+
Default unproven analyses to invalid. Syntax identity survival does not prove symbol, type, control-
|
|
149
|
+
flow, macro, language-option, or cross-file dependency facts remain valid.
|
|
150
|
+
|
|
151
|
+
## Rewrite termination
|
|
152
|
+
|
|
153
|
+
Bound every repeated rewrite by at least one explicit mechanism:
|
|
154
|
+
|
|
155
|
+
- a well-founded cost that strictly decreases;
|
|
156
|
+
- stage direction that forbids returning to an earlier form;
|
|
157
|
+
- rule and node application history within an epoch;
|
|
158
|
+
- repeated structural-state detection;
|
|
159
|
+
- maximum epochs, proposals, committed edits, and work units.
|
|
160
|
+
|
|
161
|
+
Reject self-recreating and mutually inverse rule cycles. For canonicalization, require idempotence:
|
|
162
|
+
running the completed rewrite again produces no structural or semantic change. If a pass intentionally
|
|
163
|
+
is not idempotent, name its finite convergence contract.
|
|
164
|
+
|
|
165
|
+
## Tree and graph traversal
|
|
166
|
+
|
|
167
|
+
Walk ownership children as a tree or forest. Treat symbol links, use-def relations, control-flow
|
|
168
|
+
edges, parent maps, and cross-file references as separate graphs with their own visited set, cycle
|
|
169
|
+
policy, ordering, and budget. Do not recursively follow all references with the ownership visitor.
|
|
170
|
+
|
|
171
|
+
For graphs, state whether work is per node, edge, path, strongly connected component, block, or
|
|
172
|
+
program point. Shared targets and cycles are ordinary graph structure, not tree exceptions.
|
|
173
|
+
|
|
174
|
+
## Transactional commit and verification
|
|
175
|
+
|
|
176
|
+
Before commit, verify proposal freshness and replacement category. After private construction, run
|
|
177
|
+
the phase verifier for node kinds, required children, cycles, parent ownership, identities, spans,
|
|
178
|
+
origins, recovery states, and side-table generation. Publish the new root and compatible analysis
|
|
179
|
+
generation together or publish neither.
|
|
180
|
+
|
|
181
|
+
Keep diagnostics tied to rule identity and the smallest input/output boundary. A later crash must not
|
|
182
|
+
be the first evidence that an earlier rewrite broke the tree.
|
|
183
|
+
|
|
184
|
+
## Test matrix
|
|
185
|
+
|
|
186
|
+
- Assert preorder, postorder, enter/leave, token/trivia, generated-node, error-node, and stop behavior.
|
|
187
|
+
- Add a new node variant and prove exhaustive visitors or contract tests reject missing handling.
|
|
188
|
+
- Exercise every typed transformation outcome in scalar, optional, and repeated fields.
|
|
189
|
+
- Generate overlapping parent/child and sibling edits; permute rule registration and candidate order.
|
|
190
|
+
- Compare old-snapshot traversal with new-snapshot output and prove no inserted node is accidentally
|
|
191
|
+
revisited in the same epoch.
|
|
192
|
+
- Verify unchanged subtrees are shared and changed wrappers, positions, and handles become stale.
|
|
193
|
+
- Test ambiguous reconciliation, copy, move, deletion, recovery zones, generation reuse, and ABA-like
|
|
194
|
+
slot reuse.
|
|
195
|
+
- Compare preserved analyses with independent full recomputation.
|
|
196
|
+
- Run rewrite idempotence, cycle, work-budget, cancellation, rollback, and verifier-failure cases.
|
|
197
|
+
- Apply randomized edit sequences and compare incremental trees and handles with fresh reconstruction.
|
|
198
|
+
|
|
199
|
+
## Invariants and handoffs
|
|
200
|
+
|
|
201
|
+
- Every traversal has a declared order, edge model, inclusion policy, and budget.
|
|
202
|
+
- Every visitor is read-only and every transformation creates a new validated snapshot.
|
|
203
|
+
- Every edit conflict and rewrite cycle reaches a deterministic bounded outcome.
|
|
204
|
+
- Every durable handle is resolved against document and generation context.
|
|
205
|
+
- Every preserved analysis is explicitly justified; all others are invalidated.
|
|
206
|
+
- Use `parser-engineering-review` for syntax-tree traversal, source-aware transforms, and snapshots.
|
|
207
|
+
- Use `compiler-engineering-review` for IR pass preservation, CFG, SSA, and semantic refinement.
|
|
208
|
+
- Use `name-resolution-integrity-review` for symbol identity and binding-side-table disagreements.
|
|
209
|
+
- Use `fuzz-harness-review` when traversal or rewrite fuzzing becomes a maintained campaign.
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
mustflow_doc: skill.race-condition-review
|
|
3
3
|
locale: en
|
|
4
4
|
canonical: true
|
|
5
|
-
revision:
|
|
5
|
+
revision: 4
|
|
6
6
|
lifecycle: mustflow-owned
|
|
7
7
|
authority: procedure
|
|
8
8
|
name: race-condition-review
|
|
9
|
-
description: Apply this skill when code is created, changed, reviewed, or reported and shared state can be observed across interleaving execution flows, including check-then-act, read-modify-write, stale reads after await or I/O, lock scope and order,
|
|
9
|
+
description: Apply this skill when code is created, changed, reviewed, reproduced, or reported and shared state can be observed across interleaving execution flows, including logical race versus data-race classification, forbidden-outcome assertions, deterministic schedule gates, record and replay, happens-before evidence, check-then-act, read-modify-write, stale reads after await or I/O, lock scope and order, mutex, semaphore, condition, channel, atomic and memory ordering choices, CAS and ABA, concurrent memory reclamation, linearizability, database transaction races, distributed locks, queues, shutdown, cancellation, object reuse, and schedule-sensitive tests.
|
|
10
10
|
metadata:
|
|
11
11
|
mustflow_schema: "1"
|
|
12
12
|
mustflow_kind: procedure
|
|
@@ -33,6 +33,10 @@ Find race conditions by tracing which shared facts can become stale before code
|
|
|
33
33
|
|
|
34
34
|
The review question is not "does this code use threads?" The stronger question is "does code read a shared value, keep a meaning in its head for more than one step, and then let another execution flow change that meaning before the action?" Race bugs appear in async servers, queues, database writes, caches, filesystems, timers, shutdown paths, and event streams even when the language runtime has a single event loop.
|
|
35
35
|
|
|
36
|
+
Distinguish a logical race condition from an unsynchronized conflicting memory access. A dynamic
|
|
37
|
+
data-race detector can expose the latter on executed paths without proving that higher-level
|
|
38
|
+
check-then-act, ordering, ownership, or linearizability invariants are safe.
|
|
39
|
+
|
|
36
40
|
<!-- mustflow-section: use-when -->
|
|
37
41
|
## Use When
|
|
38
42
|
|
|
@@ -62,6 +66,17 @@ The review question is not "does this code use threads?" The stronger question i
|
|
|
62
66
|
- Idempotency and ownership rule: business idempotency key, processing/succeeded/failed record state, duplicate-in-progress behavior, fencing token or generation owner, and whether same-key work is serialized while unrelated keys can run concurrently.
|
|
63
67
|
- Evidence surface: existing tests, fixtures, schema constraints, command intents, logs, metrics, sequence numbers, request ids, transaction ids, versions, or manual-only concurrency evidence.
|
|
64
68
|
- Incident file when a concurrency failure was observed: test name, seed, worker or thread count, scheduler settings, timeout, input, build hash, OS/runtime version, environment slice, and exact failure time when available.
|
|
69
|
+
- Defect classification and oracle: forbidden outcome, logical race, data race, lifetime violation,
|
|
70
|
+
deadlock, starvation, or ordering failure, plus the exact assertion that distinguishes failure.
|
|
71
|
+
- Schedule evidence: actor count, deterministic gate decisions, scheduler seed, decision trace,
|
|
72
|
+
synchronization edges, input and schedule reductions, and record/replay trace when available.
|
|
73
|
+
- Native-memory evidence when applicable: compiler and flags, architecture, optimization level,
|
|
74
|
+
atomic orderings, linearization point, allocator behavior, address reuse, reclamation protocol,
|
|
75
|
+
and sanitizer class.
|
|
76
|
+
|
|
77
|
+
Read [references/race-reproduction-memory-model-checklist.md](references/race-reproduction-memory-model-checklist.md)
|
|
78
|
+
when an incident is intermittent, native threads or lock-free structures are involved, primitive
|
|
79
|
+
selection is disputed, or a race-free or linearizable claim needs schedule evidence.
|
|
65
80
|
|
|
66
81
|
<!-- mustflow-section: preconditions -->
|
|
67
82
|
## Preconditions
|
|
@@ -84,9 +99,19 @@ The review question is not "does this code use threads?" The stronger question i
|
|
|
84
99
|
<!-- mustflow-section: procedure -->
|
|
85
100
|
## Procedure
|
|
86
101
|
|
|
87
|
-
1.
|
|
88
|
-
-
|
|
89
|
-
|
|
102
|
+
1. Classify and preserve the incident before changing code.
|
|
103
|
+
- Define one machine-checkable forbidden outcome such as two successful reservations for one
|
|
104
|
+
unit, a callback after close, a removed object becoming visible again, or a history with no
|
|
105
|
+
valid sequential explanation.
|
|
106
|
+
- Distinguish a logical race condition, data race, lifetime violation, deadlock, starvation, and
|
|
107
|
+
ordering failure. Do not treat one detector class as proof about the others.
|
|
108
|
+
- Capture the failing test or workflow name, input, worker or thread count, deterministic gate or
|
|
109
|
+
scheduler decisions, random seed, timeout, executable and build hash, compiler and flags,
|
|
110
|
+
linked runtime, OS, architecture, CPU count, allocator, optimization level, environment values
|
|
111
|
+
that affect scheduling, and exact failure time when available.
|
|
112
|
+
- Treat a dynamic detector pass as evidence only for the paths and schedule that executed. Do not
|
|
113
|
+
replace a missing incident capsule with "ran many times"; repeated passing runs are weaker than
|
|
114
|
+
one reproducible failing condition.
|
|
90
115
|
2. Name the shared fact. State the exact value or invariant another execution flow could change: balance, status, cache entry, uniqueness, queue offset, file existence, socket state, collection membership, timer owner, shutdown flag, or object ownership.
|
|
91
116
|
3. Build a stale-read ledger.
|
|
92
117
|
- For each shared state read, mark every later `await`, I/O, DB call, callback, event publish, queue insertion, lock release, timer, retry, cancellation, shutdown, close, send, or function call before the action.
|
|
@@ -113,6 +138,16 @@ The review question is not "does this code use threads?" The stronger question i
|
|
|
113
138
|
- Double-checked locking needs a memory-ordering story in runtimes where construction visibility is not automatically safe.
|
|
114
139
|
10. Review atomics and memory ordering.
|
|
115
140
|
- Atomics protect a specific operation on a specific value. They do not automatically make surrounding objects, arrays, maps, or multi-field invariants safe.
|
|
141
|
+
- Check which write becomes visible to which read through a continuous happens-before edge. A
|
|
142
|
+
relaxed flag does not publish ordinary payload by itself, and several atomics do not form one
|
|
143
|
+
transaction over a multi-field invariant.
|
|
144
|
+
- Keep retryable compare-and-swap calculations free of external effects until the update wins, or
|
|
145
|
+
bind those effects to an idempotent durable identity.
|
|
146
|
+
- Treat pointer equality, object identity, and object lifetime as separate claims. CAS-based
|
|
147
|
+
structures need an ABA and tag-wrap story plus a memory-reclamation protocol such as a verified
|
|
148
|
+
hazard, epoch, RCU, or reference-counting design.
|
|
149
|
+
- Name each operation's linearization point and validate completed histories against a sequential
|
|
150
|
+
model when final-state assertions cannot expose an invalid intermediate history.
|
|
116
151
|
- Check acquire/release or stronger memory ordering where the language exposes it, and report missing expertise or evidence instead of guessing.
|
|
117
152
|
11. Review database races.
|
|
118
153
|
- A database transaction does not erase a race by itself. Check isolation level, row locks, predicate locks, uniqueness, conditional updates, and whether `SELECT` then `UPDATE` can be invalidated before commit.
|
|
@@ -140,11 +175,23 @@ The review question is not "does this code use threads?" The stronger question i
|
|
|
140
175
|
- Object pooling, buffer reuse, mutable DTO reuse, and reused request contexts are unsafe if async work can still hold references.
|
|
141
176
|
- Fake immutable objects with mutable internals, getters, shared maps, or cached arrays should be treated as mutable shared state.
|
|
142
177
|
17. Review tests and logs with suspicion.
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
178
|
+
- `sleep`-based race tests are usually probability tests. Prefer deterministic barriers, fake schedulers, controlled promises, version assertions, unique constraints, or repeated stress only as supplementary evidence.
|
|
179
|
+
- Shake the schedule, not only the load: widen context-switch windows with configured deterministic barriers, fake schedulers, controlled yields, delay injection, or repeated stress harnesses only when the repository command contract allows them.
|
|
180
|
+
- Reduce the reproducer to the smallest useful actors, shared object, operations, and arbiter.
|
|
181
|
+
Force meaningful windows after shared reads, validation, lock release, compare-and-swap load,
|
|
182
|
+
cancellation checks, removal, and publication rather than delaying arbitrary function entries.
|
|
183
|
+
- Explore schedules systematically when a bounded scheduler exists. For randomized disruption,
|
|
184
|
+
preserve both the seed and the actual decision trace; seed alone may not replay after thread,
|
|
185
|
+
timer, or random-call counts change.
|
|
186
|
+
- Minimize the failing input and the schedule. Remove unrelated operations, actors, switches, and
|
|
187
|
+
delay points while preserving the same forbidden outcome and defect class.
|
|
188
|
+
- Logging can hide or change a race. Log order is not event order across threads, processes, async tasks, buffers, or machines.
|
|
189
|
+
- Prefer bounded per-actor event buffers over a contended global logger. Build a happens-before
|
|
190
|
+
graph from actor-local order and synchronization edges such as queue push/pop, mutex
|
|
191
|
+
unlock/lock, atomic release/acquire, promise or future completion, channel send/receive,
|
|
192
|
+
callback registration/execution, and thread start/join. A timestamp order alone is not a
|
|
193
|
+
visibility proof.
|
|
194
|
+
- Treat race detectors, thread sanitizers, deterministic record/replay, profilers, kernel tracing, or stress tools as configured or manual diagnostics only; never infer raw commands from the tool names.
|
|
148
195
|
18. Escalate broad status fields into state-machine review.
|
|
149
196
|
- If values such as `pending`, `processing`, `done`, `failed`, `cancelled`, `closed`, or `deleted` drive behavior, draw allowed transitions and reject stale concurrent transitions.
|
|
150
197
|
- Use `state-machine-pattern` when the race fix needs a transition table, event union, transition log, retry reconciliation, or effect ordering.
|
|
@@ -159,6 +206,10 @@ The review question is not "does this code use threads?" The stronger question i
|
|
|
159
206
|
- Database, cache, queue, event, filesystem, cancellation, shutdown, timer, close/send, collection, and object-reuse races are checked where relevant.
|
|
160
207
|
- Idempotency processing states, duplicate-in-progress behavior, fencing tokens, outbox/inbox handoffs, and per-key serialization are checked where relevant.
|
|
161
208
|
- Tests or configured verification cover the highest-risk concurrency invariant when feasible.
|
|
209
|
+
- Incident evidence distinguishes logical races, data races, lifetime failures, and other timing
|
|
210
|
+
defects without treating a detector pass as universal proof.
|
|
211
|
+
- The highest-risk reproducer has a forbidden-outcome oracle, bounded actor model, replayable
|
|
212
|
+
schedule evidence, and minimized input or named evidence gaps when feasible.
|
|
162
213
|
|
|
163
214
|
<!-- mustflow-section: verification -->
|
|
164
215
|
## Verification
|
|
@@ -184,17 +235,23 @@ Prefer the narrowest configured test, build, docs, release, or mustflow intent t
|
|
|
184
235
|
- If the invariant cannot be named, stop and report that the code is not reviewable for races yet.
|
|
185
236
|
- If a fix requires a schema constraint, isolation change, outbox, queue contract, state-machine transition, or idempotency store outside the current scope, report the missing durable boundary instead of adding a local lock that cannot enforce it.
|
|
186
237
|
- If deterministic race proof is not configured, report the missing manual evidence and complete the configured checks that are available.
|
|
238
|
+
- If a detector finds a data race, preserve that finding without inflating it into every possible
|
|
239
|
+
business impact; if the detector is clean, do not upgrade the result to logical race safety.
|
|
240
|
+
- If a schedule cannot replay, preserve the full decision trace and environment capsule before
|
|
241
|
+
changing the code or shrinking the reproducer further.
|
|
187
242
|
|
|
188
243
|
<!-- mustflow-section: output-format -->
|
|
189
244
|
## Output Format
|
|
190
245
|
|
|
191
246
|
- Shared state and invariant reviewed
|
|
192
|
-
-
|
|
247
|
+
- Defect class, forbidden outcome, and incident capsule captured or reported missing
|
|
248
|
+
- Actor model, schedule gates, replay evidence, and input or schedule minimization
|
|
193
249
|
- Interleaving points checked
|
|
194
250
|
- Check-then-act and read-modify-write findings
|
|
195
251
|
- Async stale-read, lock scope/order, tryLock/timeout/retry, cache/lazy init, atomic/memory ordering, database transaction, uniqueness, distributed lock, idempotency, filesystem, event/outbox, queue, shutdown, cancellation, timer, close/send, shared collection, object reuse, fake immutable, test, log, and state-machine checks where relevant
|
|
196
252
|
- Idempotency record states, fencing token, inbox or dedupe, per-key serialization, and duplicate-in-progress checks where relevant
|
|
197
253
|
- Race fixes made or recommended
|
|
254
|
+
- Primitive choice, happens-before graph, memory ordering, ABA, reclamation, and linearizability evidence where relevant
|
|
198
255
|
- Tests or verification evidence
|
|
199
256
|
- Command intents run
|
|
200
257
|
- Skipped concurrency diagnostics and reasons
|