mustflow 2.117.0 → 2.118.0

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.
Files changed (42) hide show
  1. package/README.md +1 -0
  2. package/dist/cli/commands/run/args.js +5 -0
  3. package/dist/cli/commands/run/execution.js +7 -6
  4. package/dist/cli/commands/run/preview.js +6 -5
  5. package/dist/cli/commands/run/receipt.js +1 -0
  6. package/dist/cli/commands/run.js +2 -1
  7. package/dist/cli/commands/workspace.js +216 -81
  8. package/dist/cli/i18n/en.js +1 -0
  9. package/dist/cli/i18n/es.js +1 -0
  10. package/dist/cli/i18n/fr.js +1 -0
  11. package/dist/cli/i18n/hi.js +1 -0
  12. package/dist/cli/i18n/ko.js +1 -0
  13. package/dist/cli/i18n/zh.js +1 -0
  14. package/dist/cli/lib/manifest-lock.js +10 -1
  15. package/dist/cli/lib/repo-map.js +5 -0
  16. package/dist/cli/lib/run-context.js +136 -0
  17. package/dist/cli/lib/run-root-trust.js +22 -15
  18. package/dist/cli/lib/validation/index.js +8 -0
  19. package/dist/core/config-loading.js +107 -14
  20. package/dist/core/run-receipt.js +1 -0
  21. package/dist/core/workspace-command-authority.js +98 -0
  22. package/package.json +1 -1
  23. package/schemas/run-receipt.schema.json +10 -0
  24. package/schemas/workspace-command-catalog.schema.json +3 -0
  25. package/schemas/workspace-command-fragments.schema.json +2 -0
  26. package/schemas/workspace-status.schema.json +4 -1
  27. package/schemas/workspace-verification-plan.schema.json +3 -0
  28. package/templates/default/common/.mustflow/config/mustflow.toml +2 -0
  29. package/templates/default/i18n.toml +14 -2
  30. package/templates/default/locales/en/.mustflow/skills/INDEX.md +12 -3
  31. package/templates/default/locales/en/.mustflow/skills/ai-game-asset-production/SKILL.md +209 -0
  32. package/templates/default/locales/en/.mustflow/skills/ai-game-asset-production/references/asset-contract-validation.md +106 -0
  33. package/templates/default/locales/en/.mustflow/skills/ai-game-asset-production/references/raster-alpha-atlas-checklist.md +109 -0
  34. package/templates/default/locales/en/.mustflow/skills/ai-game-asset-production/references/tile-animation-checklist.md +98 -0
  35. package/templates/default/locales/en/.mustflow/skills/connection-lifecycle-integrity-review/SKILL.md +302 -0
  36. package/templates/default/locales/en/.mustflow/skills/connection-lifecycle-integrity-review/references/connection-fault-injection-resource-lifetime-validation.md +277 -0
  37. package/templates/default/locales/en/.mustflow/skills/connection-lifecycle-integrity-review/references/node-stream-transport-lifecycle-checklist.md +381 -0
  38. package/templates/default/locales/en/.mustflow/skills/memory-lifetime-review/SKILL.md +94 -2
  39. package/templates/default/locales/en/.mustflow/skills/memory-lifetime-review/references/cross-runtime-memory-stream-reproduction-harness.md +289 -0
  40. package/templates/default/locales/en/.mustflow/skills/memory-lifetime-review/references/node-memory-resource-backpressure-diagnostics.md +369 -0
  41. package/templates/default/locales/en/.mustflow/skills/routes.toml +23 -0
  42. package/templates/default/manifest.toml +17 -1
@@ -0,0 +1,109 @@
1
+ # Raster, Alpha, Icon, and Atlas Checklist
2
+
3
+ Use this checklist for isolated PNGs, translucent effects, icons, frame extraction, trimming, resizing,
4
+ packing, and engine import. Verify exact engine-version options from current project files or official
5
+ documentation before naming a setting.
6
+
7
+ ## Real transparency
8
+
9
+ 1. Decode the file and inspect its actual channel layout; a PNG extension or visible checkerboard is
10
+ not proof of an alpha channel.
11
+ 2. For an isolated cutout, require the contract's corner and border alpha. Do not apply the same rule
12
+ to full-canvas fog, light, edge effects, or intentionally edge-touching tiles.
13
+ 3. Inspect the alpha histogram and border-connected low-alpha regions. A large faint background can
14
+ pass a four-corner test, while a legitimate soft effect can have many distinct alpha values.
15
+ 4. Detect baked checkerboards as image content by looking for repeated alternating blocks in opaque
16
+ or near-opaque background regions; route suspicious cases to review instead of claiming a perfect
17
+ detector.
18
+ 5. Composite the decoded image on dark, light, neutral, and saturated backgrounds at target size.
19
+ Measure the edge band as well as reviewing it visually.
20
+
21
+ ## Straight and premultiplied alpha
22
+
23
+ - Record whether working images, resize operations, packed textures, renderer uploads, and blend
24
+ equations expect straight or premultiplied alpha.
25
+ - For color resampling, convert color to the correct linear-light working space when required,
26
+ premultiply RGB by alpha, resize color and alpha together, and unpremultiply only when the output
27
+ contract requires straight alpha. Protect alpha zero from division noise.
28
+ - A white, black, or gray halo usually means a matte color was mixed into antialiased pixels, hidden
29
+ transparent RGB entered filtering, or straight data was blended as premultiplied data or vice versa.
30
+ - Normal, roughness, ID, and mask textures are data, not display color. Do not apply sRGB color
31
+ transforms or color-image alpha repair to them without an explicit format rule.
32
+
33
+ ## Hidden RGB policy
34
+
35
+ Choose by runtime behavior:
36
+
37
+ - Clear RGB under alpha zero only for pipelines that never sample beyond visible texels and whose
38
+ compression or tooling contract requires canonical transparent bytes.
39
+ - Extend nearby visible color into transparent texels for linearly filtered, resized, mipmapped, or
40
+ atlased color sprites. Use nearest visible color or bounded edge dilation without changing alpha.
41
+ - Keep cutout-color dilation distinct from soft-effect matting. Smoke, glass, fire, glow, and hair
42
+ need foreground color and fractional alpha recovered together; hard thresholding deletes the
43
+ effect or leaves a matte.
44
+
45
+ ## Multi-object separation
46
+
47
+ For a sheet containing several generated objects:
48
+
49
+ 1. Estimate foreground alpha or foreground probability, preserving a soft channel for effects.
50
+ 2. Remove border-connected background residue and isolated components below a role-specific area
51
+ threshold.
52
+ 3. Run connected-component analysis at more than one alpha threshold so faint shadows and solid
53
+ objects can be reasoned about separately.
54
+ 4. Merge components only with semantic evidence such as a declared object group, containment,
55
+ proximity, shared anchor, or source mask. A detached weapon decoration may belong to the object;
56
+ smoke or a ground glow may require a separate blend layer.
57
+ 5. Split touching candidates with masks, contour concavities, watershed or distance fields, and a
58
+ review fallback. Do not slice solely through the narrowest pixel column.
59
+ 6. Dilate the accepted mask only enough to preserve antialiasing, then compute a safety margin and
60
+ reject any crop that touches the output border outside an intentional exception.
61
+ 7. Store the source image, extraction mask, component membership, original bounds, expanded bounds,
62
+ and confidence or review disposition.
63
+
64
+ ## Icons and optical sizes
65
+
66
+ - Do not downsample one detailed master into every size and call the result complete. Treat 16, 24,
67
+ 32, 64, 128, and larger outputs as optical-size families selected by the product, not as a mandatory
68
+ Mustflow size list.
69
+ - At the smallest sizes, prioritize silhouette, negative space, one dominant feature, strong value
70
+ separation, grid-aligned edges, and strokes that survive the target raster.
71
+ - Add secondary forms and material detail only as the target size can resolve them. Measure the final
72
+ raster rather than trusting a large preview.
73
+ - Generate each size from the largest approved source or a size-specific master in one resampling
74
+ step, then perform final-size cleanup. Do not repeatedly resize from the previous smaller output.
75
+
76
+ ## Trimming and atlas metadata
77
+
78
+ Trimming may remove transparent storage but must not erase placement:
79
+
80
+ - original source width and height;
81
+ - trimmed frame rectangle in the original canvas;
82
+ - sprite-source position or corner offset;
83
+ - pivot in normalized and source-pixel coordinates when useful;
84
+ - ground contact, center of mass, sockets, and semantic anchors;
85
+ - frame duration, loop range, animation event references, and gameplay shape references;
86
+ - atlas frame rectangle, rotation flag, extrude, shape padding, border padding, and page identity.
87
+
88
+ Apply identical trim and placement to paired color, normal, emissive, and mask textures. Disable atlas
89
+ rotation when direction, UI orientation, tiling, paired maps, or local axes make rotation unsafe.
90
+
91
+ ## Bleeding and engine import
92
+
93
+ - Transparent gaps alone do not stop sampling. Keep extruded edge color, spacing between packed
94
+ shapes, and atlas-border padding as separate values derived from filtering, mip depth, compression,
95
+ and maximum reduction.
96
+ - Do not use UV inset as the only repair; it can shrink or shimmer sprites and still fails at deeper
97
+ mips. Verify the packed result with deliberately high-contrast neighbors.
98
+ - Use clamp for independent sprites and repeat only for textures whose opposite edges are contracted
99
+ to repeat. Select nearest or linear filtering from the asset role and camera behavior; pixel art may
100
+ still need a deliberate mip strategy when heavily minified.
101
+ - For PixiJS, verify the installed renderer version's texture source, alpha, scale, mipmap, wrap, UV,
102
+ resolution, and atlas metadata behavior rather than copying properties from another major version.
103
+ - For Unity, verify sprite import mode, pixels per unit, pivot, mesh, filter, mipmaps, color space,
104
+ alpha handling, compression, atlas padding or extrude, rotation, and paired texture behavior.
105
+ - For Godot, verify texture import filtering, mipmaps, repeat, alpha-border repair, lossless or VRAM
106
+ compression, normal-map handling, region filtering, SpriteFrames metadata, offset, and pixel-snap
107
+ behavior for the installed major version.
108
+ - Compare the source, packed texture, imported resource, and rendered frame. Disk compression size is
109
+ not GPU-memory evidence.
@@ -0,0 +1,98 @@
1
+ # Tile, Background, Object, and Animation Checklist
2
+
3
+ Use this checklist when assets must join a shared world or form a stable animation instead of merely
4
+ looking related in isolation.
5
+
6
+ ## Tile and background continuity
7
+
8
+ - Contract tile size, pixels per unit, projection, world-axis screen directions, horizon or ground
9
+ line, light vector, outline, palette, detail frequency, edge-lock width, and shadow policy.
10
+ - Generate a new object inside a representative scene or from locked geometry and lighting guides,
11
+ then extract the deliverable. A transparent isolated generation has no evidence that it belongs to
12
+ the world's scale or contact plane.
13
+ - For two large images, establish one shared seam band and outpaint away from it. Do not generate both
14
+ sides independently and expect prompt wording to repair incompatible geometry.
15
+ - For repeatable textures, offset opposite edges into the center, repair the crossed seam, restore the
16
+ image, and inspect a repeated grid including all corner meetings.
17
+ - Define terrain topology and masks before surface generation. Edge or corner codes, legal neighbor
18
+ sets, and transition masks belong to code or data; the generator supplies material appearance.
19
+ - Separate base materials, transition masks, and decorative overlays so a palette or material change
20
+ does not require regenerating every transition tile.
21
+ - Compare low-frequency value masses and high-frequency detail density separately. Matching average
22
+ color cannot repair incompatible feature scale.
23
+ - Generate parallax layers independently with common horizon and vanishing-point constraints, enough
24
+ hidden overlap for the full camera range, and low-information cut boundaries.
25
+ - Test same-tile repeats, every valid worst neighbor, randomized maps, multiple zooms, filters,
26
+ mipmaps, packing, and compression in the actual renderer.
27
+
28
+ ## Object contact and world ownership
29
+
30
+ - Keep long cast shadows out of reusable object color unless the game is fully baked to one lighting
31
+ contract. Separate contact shadow, cast-shadow mask, occluder, emissive, normal, and depth layers as
32
+ needed.
33
+ - Use terrain-specific contact patches such as grass overlap, soil roots, snow compression, or water
34
+ ripple instead of regenerating the full object for every surface.
35
+ - Align by semantic world anchors such as ground center, feet, wheel contact, hinge, grip, muzzle, or
36
+ center of mass. Alpha-bounds center is not a stable pivot for hats, weapons, tails, or asymmetric
37
+ effects.
38
+ - Keep movement collision, hurtbox, hitbox, interaction region, projectile blocker, navigation
39
+ footprint, z-sort point, and occluder as separate gameplay roles. Decorative alpha is a skin, not a
40
+ universal collider generator.
41
+
42
+ ## Character identity and directional sets
43
+
44
+ - Approve a reference package containing front, side, back, representative action, palette, body
45
+ landmarks, equipment handedness, smallest-size render, and neutral root position.
46
+ - Generate each frame from the approved package and pose or geometry guide, not from only the previous
47
+ generated frame. Assemble the sheet after frame validation.
48
+ - For four- or eight-direction sets, keep camera and body measurements common while explicitly
49
+ tracking left/right equipment, text, scars, asymmetrical costume, lighting, and weapon attachment.
50
+ Mirror only components whose contract permits mirroring.
51
+ - Track joints, parent-child relationships, nominal bone lengths, joint ranges, silhouette landmarks,
52
+ and allowed deformable regions. Report occluded or low-confidence landmarks instead of fabricating
53
+ a precise skeleton measurement.
54
+
55
+ ## Motion construction
56
+
57
+ - Build locomotion from meaningful phases such as contact, down, passing, up, and flight where
58
+ applicable. More evenly spaced frames do not fix a missing weight transfer.
59
+ - During support contact, compare the planted foot in world coordinates after root motion. Measure
60
+ support-foot drift separately from intentional body translation.
61
+ - Assign durations by action: anticipation, pre-impact hold, impact, follow-through, overshoot, and
62
+ recovery often need unequal time. Store duration per frame instead of assuming a uniform sheet FPS.
63
+ - Track hands, feet, head, center of mass, weapon tip, and other action points along expected arcs.
64
+ Uniform straight interpolation between poses is not motion evidence.
65
+ - Attach a weapon through a grip anchor and local weapon coordinate system; track wrist rotation,
66
+ weapon length, tip path, and hit event separately from generated hand pixels.
67
+ - Define squash, stretch, overshoot, and follow-through limits per body region. Preserve identity by
68
+ fixing regions whose proportions or equipment geometry must not change.
69
+
70
+ ## Loop and gameplay metadata
71
+
72
+ - Compare the last-to-first boundary for root position, joint rotation, silhouette, color, motion
73
+ direction, velocity, and acceleration. Do not duplicate the first frame at the end merely to hide
74
+ the boundary.
75
+ - Preserve original frame size, trim rectangle, sprite-source position, pivot, sockets, ground
76
+ contact, frame duration, loop range, event frames, hitbox, hurtbox, attack shape, and collision
77
+ profile in the atlas or adjacent metadata.
78
+ - Keep movement collider and root hurtbox stable across frames unless gameplay explicitly changes
79
+ them. Drive attacks, invulnerability, sounds, particles, and movement impulses from named events,
80
+ not from guessed image differences.
81
+
82
+ ## Automated animation evidence
83
+
84
+ Measure at the target display scale and in world space where applicable:
85
+
86
+ - silhouette area, height, and centroid variation;
87
+ - root, pivot, ground-contact, and socket drift;
88
+ - joint position, bone length, joint-range, handedness, and equipment-attachment violations;
89
+ - support-foot world drift during planted intervals;
90
+ - palette or regional color drift and face or costume identity outliers;
91
+ - motion-arc residual for hands, feet, center of mass, and weapon tip;
92
+ - optical-flow outliers after compensating declared root motion;
93
+ - last-to-first pose, velocity, and acceleration discontinuity;
94
+ - metadata completeness for timing, loop, events, pivots, and gameplay shapes.
95
+
96
+ Automatic scores triage candidates; they do not prove anatomy, intent, copyright status, or visual
97
+ quality. Review metric outliers in contact sheets and the engine scene, then accept, rework,
98
+ quarantine, or reject them under the project contract.
@@ -0,0 +1,302 @@
1
+ ---
2
+ mustflow_doc: skill.connection-lifecycle-integrity-review
3
+ locale: en
4
+ canonical: true
5
+ revision: 2
6
+ lifecycle: mustflow-owned
7
+ authority: procedure
8
+ name: connection-lifecycle-integrity-review
9
+ description: Apply this skill when TCP sockets, HTTP keep-alive or pooling, HTTP/2 streams or sessions, Node.js streams, Web Streams readers or writers, FIN/RST handling, half-close behavior, destroy or abort races, unconsumed response bodies, backpressure, connection shutdown, transport resource leaks, fault injection, soak tests, or connection-lifetime resolution claims are created, changed, reviewed, debugged, validated, or reported.
10
+ metadata:
11
+ mustflow_schema: "1"
12
+ mustflow_kind: procedure
13
+ pack_id: mustflow.core
14
+ skill_id: mustflow.core.connection-lifecycle-integrity-review
15
+ command_intents:
16
+ - changes_status
17
+ - changes_diff_summary
18
+ - lint
19
+ - build
20
+ - test_related
21
+ - test
22
+ - docs_validate_fast
23
+ - test_release
24
+ - mustflow_check
25
+ ---
26
+
27
+ # Connection Lifecycle Integrity Review
28
+
29
+ <!-- mustflow-section: purpose -->
30
+ ## Purpose
31
+
32
+ Keep physical connections, transport read and write sides, logical requests, response bodies,
33
+ reader or writer ownership, pool eligibility, and process shutdown from being collapsed into one
34
+ misleading lifecycle flag.
35
+
36
+ The central invariant is not that every connection is destroyed. Graceful FIN paths may never call
37
+ `destroy`. The stronger invariant is that every owned connection record is finalized exactly once,
38
+ and an abortive destroy or reset action is accepted at most once.
39
+
40
+ <!-- mustflow-section: use-when -->
41
+ ## Use When
42
+
43
+ - TCP, TLS, HTTP/1.1 keep-alive, HTTP/2 multiplexing, HTTP clients, servers, agents, dispatchers,
44
+ connection pools, upgraded sockets, WebSocket, CONNECT, or raw stream transports change.
45
+ - Code handles `end`, `finish`, `error`, `close`, FIN, RST, timeout, abort, `destroy`,
46
+ `resetAndDestroy`, half-close, pending writes, drain, or shutdown deadlines.
47
+ - A logical request, response body, body reader, stream, or HTTP/2 stream can finish or cancel while
48
+ its physical connection or session remains alive.
49
+ - Response bodies can be partially read, paused, abandoned, discarded, cancelled, or left locked.
50
+ - Slow consumers, backpressure, retries, transforms, adapters, or observability capture can retain
51
+ unbounded buffers.
52
+ - A review or report claims that sockets are leak-free, safely reusable, fully drained, naturally
53
+ terminating, or closed exactly once.
54
+
55
+ <!-- mustflow-section: do-not-use-when -->
56
+ ## Do Not Use When
57
+
58
+ - The task only changes HTTP schemas, status codes, or headers with no connection, body, pooling,
59
+ cancellation, streaming, or shutdown behavior; use `api-contract-change` or
60
+ `http-api-semantics-review`.
61
+ - The task only changes compression, CDN caching, SSE replay, WebTransport delivery choice, or proxy
62
+ buffering without transport lifetime risk; use `http-delivery-streaming`.
63
+ - The task is a general retained-object or cleanup review without network or stream lifecycle
64
+ semantics; use `memory-lifetime-review`.
65
+ - The task models a durable business entity lifecycle rather than independently closing transport
66
+ dimensions; use `state-machine-pattern`.
67
+ - No connection, request, body, stream, pool, timer, listener, buffer, or shutdown boundary is
68
+ present to inspect.
69
+
70
+ <!-- mustflow-section: required-inputs -->
71
+ ## Required Inputs
72
+
73
+ - Protocol and role: raw TCP, TLS, HTTP/1.1, HTTP/2, WebSocket, CONNECT, client, server, proxy, or
74
+ adapter.
75
+ - Ownership ledger for the physical connection or session, logical request, response body, reader,
76
+ writer, pool slot, timers, listeners, retry entries, and buffer reservations.
77
+ - Event and action ledger distinguishing observed events from local actions such as graceful end,
78
+ cancel, destroy, reset, quarantine, pool return, or forced shutdown.
79
+ - State dimensions for transport, readable side, writable side, pool membership, request, body
80
+ disposition, reader or writer lock, and server or client shutdown when each is relevant.
81
+ - Terminal-cause policy, including which contender records the primary cause and how later causes
82
+ are retained for diagnostics without repeating side effects.
83
+ - Reuse criteria, parser or framing boundary evidence, pending write state, buffered bytes, protocol
84
+ corruption state, and body disposition.
85
+ - Success, half-close, timeout, abort, peer reset, writer error, reader cancel, unconsumed body,
86
+ slow-consumer, and shutdown paths that the implementation supports.
87
+ - Relevant command-intent contract entries for tests, build, docs, release checks, and mustflow
88
+ validation.
89
+ - For Node.js, Web Streams, or Undici-specific work, read
90
+ `references/node-stream-transport-lifecycle-checklist.md` before changing event-order,
91
+ cancellation, body-consumption, active-resource, or natural-exit behavior.
92
+ - For repeated fault injection, soak testing, resource-growth gates, runtime or library attribution,
93
+ operational containment, or permanent-resolution claims, read
94
+ `references/connection-fault-injection-resource-lifetime-validation.md` before designing the
95
+ campaign or accepting its conclusion.
96
+
97
+ <!-- mustflow-section: preconditions -->
98
+ ## Preconditions
99
+
100
+ - Higher-priority instructions and `.mustflow/config/commands.toml` have been checked for the
101
+ selected repository.
102
+ - Required inputs are available, or missing protocol and ownership decisions can be reported
103
+ without inventing behavior.
104
+ - Version-sensitive runtime behavior is tied to current official documentation or repository tests;
105
+ supplied reference material is guidance, not proof that every runtime version behaves identically.
106
+ - If general retained-reference risk dominates, also use `memory-lifetime-review`.
107
+ - If races between termination contenders dominate, also use `race-condition-review`.
108
+ - If delivery, cache, reconnect, or proxy semantics dominate, also use `http-delivery-streaming`.
109
+
110
+ <!-- mustflow-section: allowed-edits -->
111
+ ## Allowed Edits
112
+
113
+ - Add or tighten lifecycle state, terminal-cause arbitration, connection and request scopes, body
114
+ lease policy, pool quarantine, buffer budgets, shutdown phases, diagnostics, and focused tests.
115
+ - Separate physical connection finalization from logical request and body settlement.
116
+ - Centralize graceful-end and abortive-termination actions so timers, abort signals, writer errors,
117
+ and shutdown do not each perform duplicate cleanup.
118
+ - Add bounded discard, cancellation, drain, grace, or force deadlines where protocol semantics allow.
119
+ - Do not call `destroy` from every completion path merely because repeated destruction is a runtime
120
+ no-op.
121
+ - Do not remove a connection from the active registry before its physical close event is observed.
122
+ - Do not return a connection to a pool from writable/readable flags alone without parser or framing
123
+ boundary and body-disposition evidence.
124
+ - Do not use `unref`, garbage collection, finalization registries, or process exit as connection
125
+ cleanup.
126
+ - Do not weaken event-count, callback-settlement, buffer-bound, natural-exit, or open-handle tests.
127
+ - Do not treat static review, one green reproducer, a flat RSS graph, a restart, or traffic limiting
128
+ as proof that a connection-lifetime defect is permanently resolved.
129
+
130
+ <!-- mustflow-section: procedure -->
131
+ ## Procedure
132
+
133
+ 1. Draw the ownership layers before editing.
134
+ - Separate physical connection or HTTP/2 session, logical request, response body or stream,
135
+ reader and writer locks, pool lease, and process or server lifecycle.
136
+ - Name which layer owns each timer, listener, pending callback, retry item, buffer reservation,
137
+ and registry entry.
138
+ 2. Replace a single closing enum with orthogonal dimensions where shutdown can happen
139
+ independently.
140
+ - Model transport, read side, write side, pool membership, request state, body disposition, and
141
+ reader or writer ownership separately when the protocol permits independent progress.
142
+ - Treat remote and local half-close as valid combinations, not impossible intermediate states.
143
+ 3. Separate events from actions.
144
+ - Treat EOF or `end`, write completion or `finish`, `error`, and physical `close` as observed
145
+ events.
146
+ - Treat graceful `end`, cancel, discard, quarantine, `destroy`, reset, and force-close as local
147
+ actions whose admission must be controlled.
148
+ - Do not require an abortive action on a graceful path.
149
+ 4. Centralize terminal-cause arbitration.
150
+ - Route timeout, abort signal, writer error, protocol error, peer reset, body abandonment, and
151
+ forced shutdown through one termination admission function.
152
+ - Atomically accept the first terminal cause and at most one abortive action.
153
+ - Record later competing causes as secondary diagnostics without repeating destroy, reset,
154
+ callback settlement, metrics, or registry removal.
155
+ 5. Define finalization boundaries.
156
+ - Finalize and remove a physical connection record once, after physical close is observed.
157
+ - Permit a request to settle earlier after its request-scoped timers, listeners, retries, body
158
+ lease, and user result are finalized.
159
+ - Keep connection-core close and error observation alive even after request cleanup.
160
+ 6. Write the protocol-specific reuse gate as a conjunction of observable conditions.
161
+ - Require open transport sides, parser or framing boundary, terminal body disposition, no pending
162
+ writes, no reserved buffers, no terminal cause, no protocol corruption, and correct pool owner.
163
+ - Quarantine any HTTP/1.1 connection that observed premature close, truncated framing, parser
164
+ failure, content-length mismatch, reset, or unrecoverable body abandonment.
165
+ - Apply cancellation and reuse at HTTP/2 stream scope unless connection-level GOAWAY, session
166
+ error, or flow-control corruption invalidates the whole session.
167
+ 7. Give every response body a disposition and deadline.
168
+ - Require consume, bounded discard, protocol-specific cancel, or failure.
169
+ - Use both byte and wall-clock limits for discard; endless discard is a denial-of-service path.
170
+ - Settle cancellation separately from releasing a reader lock, and release the owner in a
171
+ finally-like boundary.
172
+ 8. Make write and backpressure accounting explicit.
173
+ - Stop or pause production after a write or enqueue signal reports backpressure.
174
+ - Settle every accepted write callback or promise exactly once as success or failure.
175
+ - Reserve bytes before enqueueing across readable, writable, adapter, parser, transform, retry,
176
+ discard, and observability layers; do not mistake a high-water mark for a global hard limit.
177
+ 9. Build connection and request resource scopes.
178
+ - Register timers, listener removers, retry tokens, body leases, locks, pending writes, buffer
179
+ reservations, and close waiters at creation time.
180
+ - Make disposal idempotent and keep request cleanup from deleting connection-core observers.
181
+ 10. Define server and client shutdown as bounded phases.
182
+ - Stop new accepts or requests first, then drain idle and active work, reject new HTTP/2 streams
183
+ when applicable, escalate after a deadline, and wait for physical closes.
184
+ - Track WebSocket, CONNECT, HTTP/2, and other upgraded or separately owned transports explicitly;
185
+ generic HTTP close-all helpers may not own them.
186
+ 11. Add observable conservation and cleanup invariants.
187
+ - Compare created, active, and closed connections; started and terminal requests; accepted and
188
+ settled writes; opened and disposed body leases; reserved, current, and released buffers.
189
+ - Keep identifiers in logs or traces and metric labels bounded to reason, protocol, role, or
190
+ mode.
191
+ 12. Test races and partial orders, not one pretty sequence.
192
+ - Cover local-first, remote-first, simultaneous FIN, RST, timeout plus abort, pending write plus
193
+ reset, body end plus cancel, paused read, unconsumed body, slow consumer, and shutdown races.
194
+ - Assert event counts, primary cause, accepted destroy count, request result, pool state,
195
+ registry size, pending writes, body disposition, lock ownership, and peak reserved bytes.
196
+ - Add a child-process natural-exit test without `process.exit` when configured test surfaces can
197
+ exercise event-loop handle leaks.
198
+ 13. Separate heap retention from event-loop liveness and native resource leakage.
199
+ - An unresolved promise alone does not keep the event loop alive, but a reachable promise chain
200
+ can retain request state.
201
+ - Check active timers, sockets, DNS/TLS work, file descriptors or handles, and heap retaining
202
+ paths with the configured diagnostics available to the repository.
203
+ 14. Design fault campaigns around closed cohorts and uncontaminated resource evidence when the task
204
+ requires more than focused lifecycle tests.
205
+ - Separate the system under test from load generators, raw fault peers, proxies, and packet or
206
+ network injectors so their timers and handles do not enter the system ledger.
207
+ - Give each request deterministic bytes, digest, idempotency identity, lifecycle timestamps, and
208
+ exactly one terminal outcome; compare clean and faulted traffic under predeclared load, seed,
209
+ duration, and statistical gates.
210
+ - Keep explicit-agent teardown campaigns separate from pool-reuse steady-state campaigns.
211
+ 15. Attribute the owner with differential reproduction before choosing a fix.
212
+ - Repeat the same fault schedule through the full application, a library-only reproducer, a
213
+ runtime-core reproducer, and direct versus production-like network paths where available.
214
+ - Classify application, library, runtime, or environment cause only from the layer where the
215
+ failure appears or disappears, retaining-path evidence, version bisect, or reproducible
216
+ infrastructure mechanics.
217
+ 16. Calibrate the conclusion to the evidence.
218
+ - Distinguish fix candidate, mitigation, symptom suppression, and permanent resolution.
219
+ - Require pre-fix failure, post-fix success, compatible correctness and performance regression,
220
+ bounded repeated and soak evidence, and a causal owner before claiming permanent resolution.
221
+ - Treat long-running soak, packet, native-handle, heap, or production-path checks as manual-only
222
+ or missing unless the selected repository configures them.
223
+ 17. Verify through configured command intents and report unavailable protocol, fault-injection,
224
+ active-resource, heap, file-descriptor, or natural-exit evidence instead of inventing commands.
225
+
226
+ <!-- mustflow-section: postconditions -->
227
+ ## Postconditions
228
+
229
+ - Physical connection, request, body, stream, lock, pool, and shutdown ownership are distinct where
230
+ their lifetimes can diverge.
231
+ - Every connection record has one observable finalization path; graceful paths do not require
232
+ destroy, and abortive paths accept at most one destroy or reset action.
233
+ - Primary terminal cause, secondary contenders, event counts, callback settlement, and registry
234
+ removal are deterministic under supported races.
235
+ - Connection reuse requires framing completion, terminal body disposition, clean transport state,
236
+ zero pending writes or reservations, and protocol-specific eligibility.
237
+ - Response bodies, locks, timers, listeners, retries, buffers, and upgraded connections have bounded
238
+ ownership and shutdown behavior.
239
+ - Tests or explicitly reported evidence gaps cover the highest-risk FIN, RST, timeout, abort,
240
+ cancellation, backpressure, and shutdown paths.
241
+ - Fault and soak conclusions preserve the tested protocol, role, environment, cohort, seed,
242
+ duration, measurement gate, and causal-owner boundary instead of generalizing from one run.
243
+
244
+ <!-- mustflow-section: verification -->
245
+ ## Verification
246
+
247
+ Use configured oneshot command intents when available:
248
+
249
+ - `changes_status`
250
+ - `changes_diff_summary`
251
+ - `lint`
252
+ - `build`
253
+ - `test_related`
254
+ - `test`
255
+ - `docs_validate_fast`
256
+ - `test_release`
257
+ - `mustflow_check`
258
+
259
+ Prefer the narrowest configured tests that exercise the changed protocol and lifecycle boundary.
260
+ Do not infer raw packet tools, load generators, heap profilers, active-handle inspectors, open-FD
261
+ commands, or child-process harnesses from this skill.
262
+
263
+ <!-- mustflow-section: failure-handling -->
264
+ ## Failure Handling
265
+
266
+ - If protocol and ownership boundaries are unknown, stop and list the missing decisions before
267
+ inventing a universal state machine.
268
+ - If observed event order differs across valid runs, encode the supported partial order and event
269
+ counts instead of forcing one total order.
270
+ - If a second termination contender repeats side effects, centralize admission before patching each
271
+ callback independently.
272
+ - If safe reuse cannot be proved from parser or framing and body evidence, quarantine the connection.
273
+ - If a body cannot be consumed, discarded, or cancelled within bounds, fail the body and retire the
274
+ owning stream or connection at the narrowest safe protocol scope.
275
+ - If shutdown passes only after adding `unref` or `process.exit`, keep the test failing and report the
276
+ live handle or missing owner.
277
+ - If exact runtime behavior is version-sensitive and current official evidence is unavailable,
278
+ narrow the claim and report the freshness gap.
279
+ - If a reproducer turns green without retained-owner, handle, version, or infrastructure evidence,
280
+ report a fix candidate rather than a resolved root cause.
281
+ - If only traffic limiting, isolation, version pinning, or process restart prevents exhaustion,
282
+ report mitigation and preserve the unresolved ownership risk.
283
+
284
+ <!-- mustflow-section: output-format -->
285
+ ## Output Format
286
+
287
+ - Protocol, role, and ownership layers reviewed
288
+ - Transport, read, write, pool, request, body, lock, and shutdown states
289
+ - Event versus action ledger
290
+ - Primary and secondary termination-cause policy
291
+ - Finalization and destroy or reset admission result
292
+ - Reuse and quarantine gate
293
+ - Body disposition, reader or writer ownership, and backpressure or buffer budget
294
+ - Resource scopes, timers, listeners, retries, registries, and upgraded transports
295
+ - Shutdown phases and escalation deadline
296
+ - Invariants, fault matrix, event counts, and natural-exit or active-resource evidence
297
+ - Harness isolation, closed-cohort ledger, repeated-fault and soak gates, and clean-traffic isolation
298
+ - Application, library, runtime, or environment attribution evidence
299
+ - Fix candidate, mitigation, symptom suppression, or permanent-resolution classification
300
+ - Command intents run
301
+ - Skipped diagnostics and reasons
302
+ - Remaining connection lifecycle risk