mustflow 2.115.4 → 2.115.9

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 (30) hide show
  1. package/package.json +1 -1
  2. package/templates/default/i18n.toml +52 -22
  3. package/templates/default/locales/en/.mustflow/docs/agent-workflow.md +13 -1
  4. package/templates/default/locales/en/.mustflow/skills/INDEX.md +16 -8
  5. package/templates/default/locales/en/.mustflow/skills/ada-code-change/SKILL.md +293 -0
  6. package/templates/default/locales/en/.mustflow/skills/astro-code-change/SKILL.md +10 -2
  7. package/templates/default/locales/en/.mustflow/skills/completion-evidence-gate/SKILL.md +14 -1
  8. package/templates/default/locales/en/.mustflow/skills/core-web-vitals-field-review/SKILL.md +2 -2
  9. package/templates/default/locales/en/.mustflow/skills/deno-code-change/SKILL.md +291 -0
  10. package/templates/default/locales/en/.mustflow/skills/dependency-upgrade-review/SKILL.md +12 -6
  11. package/templates/default/locales/en/.mustflow/skills/elysia-code-change/SKILL.md +3 -3
  12. package/templates/default/locales/en/.mustflow/skills/hono-code-change/SKILL.md +2 -2
  13. package/templates/default/locales/en/.mustflow/skills/instruction-conflict-scope-check/SKILL.md +23 -12
  14. package/templates/default/locales/en/.mustflow/skills/nestjs-code-change/SKILL.md +5 -7
  15. package/templates/default/locales/en/.mustflow/skills/node-code-change/SKILL.md +2 -2
  16. package/templates/default/locales/en/.mustflow/skills/pascal-code-change/SKILL.md +301 -0
  17. package/templates/default/locales/en/.mustflow/skills/php-code-change/SKILL.md +327 -0
  18. package/templates/default/locales/en/.mustflow/skills/python-code-change/SKILL.md +11 -7
  19. package/templates/default/locales/en/.mustflow/skills/release-publish-change/SKILL.md +13 -5
  20. package/templates/default/locales/en/.mustflow/skills/routes.toml +30 -0
  21. package/templates/default/locales/en/.mustflow/skills/skill-authoring/SKILL.md +35 -9
  22. package/templates/default/locales/en/.mustflow/skills/skill-refresh/SKILL.md +10 -1
  23. package/templates/default/locales/en/.mustflow/skills/source-freshness-check/SKILL.md +13 -6
  24. package/templates/default/locales/en/.mustflow/skills/svelte-code-change/SKILL.md +16 -5
  25. package/templates/default/locales/en/.mustflow/skills/tauri-code-change/SKILL.md +3 -2
  26. package/templates/default/locales/en/.mustflow/skills/threejs-code-change/SKILL.md +207 -0
  27. package/templates/default/locales/en/.mustflow/skills/typescript-code-change/SKILL.md +23 -16
  28. package/templates/default/locales/en/.mustflow/skills/version-freshness-check/SKILL.md +12 -6
  29. package/templates/default/locales/en/AGENTS.md +8 -1
  30. package/templates/default/manifest.toml +36 -1
@@ -0,0 +1,301 @@
1
+ ---
2
+ mustflow_doc: skill.pascal-code-change
3
+ locale: en
4
+ canonical: true
5
+ revision: 2
6
+ lifecycle: mustflow-owned
7
+ authority: procedure
8
+ name: pascal-code-change
9
+ description: Apply this skill when Pascal or Object Pascal source, Delphi or Free Pascal compiler behavior, RAD Studio or Lazarus projects, RTL, VCL, FireMonkey, LCL, generics, managed records, packages, DLLs, threading, synchronization, async I/O, C or C++ interop, tests, or deployment behavior are created, changed, reviewed, migrated, or upgraded.
10
+ metadata:
11
+ mustflow_schema: "1"
12
+ mustflow_kind: procedure
13
+ pack_id: mustflow.core
14
+ skill_id: mustflow.core.pascal-code-change
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
+ # Pascal Code Change
28
+
29
+ <!-- mustflow-section: purpose -->
30
+ ## Purpose
31
+
32
+ Preserve Pascal language-mode, compiler, RTL, type, range-check, managed-value, UI-thread,
33
+ concurrency, ABI, package, platform, and deployment contracts. Keep Delphi and Free Pascal or
34
+ Lazarus behavior separate unless current evidence proves a portable shared contract.
35
+
36
+ <!-- mustflow-section: use-when -->
37
+ ## Use When
38
+
39
+ - Pascal or Object Pascal units, programs, libraries, packages, forms, generics, records, classes,
40
+ interfaces, exceptions, tests, or compiler directives change.
41
+ - Delphi, RAD Studio, RTL, VCL, FireMonkey, WebBroker, or platform target behavior changes.
42
+ - Free Pascal, Lazarus, LCL, RTL, compiler mode, target, package, threading, or pas2js behavior changes.
43
+ - Threads, synchronization, callbacks, async I/O, COM, DLLs, C or C++ interop, layout, strings,
44
+ memory ownership, or release packaging changes.
45
+
46
+ <!-- mustflow-section: do-not-use-when -->
47
+ ## Do Not Use When
48
+
49
+ - The changed surface is only C or C++ and no Pascal-owned binding or package contract changes.
50
+ - The task asks only for the latest Delphi, Lazarus, or Free Pascal version; use source-freshness
51
+ guidance unless durable code or documentation changes too.
52
+ - A Delphi-only feature is proposed for an FPC target, or an FPC development feature for a stable
53
+ release, without an explicit migration or conditional compilation plan.
54
+
55
+ <!-- mustflow-section: required-inputs -->
56
+ ## Required Inputs
57
+
58
+ - Compiler family and version, language mode, RTL, IDE, target OS and architecture, build profile,
59
+ project and package metadata, search paths, conditional symbols, directives, and CI image.
60
+ - Application model: console, service, VCL, FireMonkey, LCL, WebBroker, library, package, mobile,
61
+ embedded, pas2js, WebAssembly, or another target.
62
+ - Public units, package and DLL surfaces, managed types, generics, record and class ownership,
63
+ range and overflow policy, enum and set serialization, strings, arrays, pointers, exceptions,
64
+ RTTI, initialization and finalization, BPL or DLL lifetime, and form resources.
65
+ - Concurrency ledger: UI or main thread, workers, thread pool, queues, synchronization, cancellation,
66
+ captured values, callbacks, COM apartments, async I/O, shutdown, and exception observation.
67
+ - ABI ledger: calling conventions, scalar widths and signedness, record size and offsets, packing,
68
+ strings and encoding, pointer-length units, allocation owner, opaque handles, errors, and callbacks.
69
+
70
+ <!-- mustflow-section: preconditions -->
71
+ ## Preconditions
72
+
73
+ - Read current project files, compiler directives, target matrix, package dependencies, RTL or
74
+ framework code, tests, and deployment evidence before changing language or runtime assumptions.
75
+ - Refresh official Embarcadero, Free Pascal, Lazarus, platform, and library sources before preserving
76
+ exact version, default, feature, ABI, deprecation, or support claims.
77
+ - Treat version research as dated evidence. The source snapshot reviewed on 2026-07-11 identified
78
+ Delphi or RAD Studio 13.1, Lazarus 4.8, and Free Pascal 3.2.2 as separate stable baselines while
79
+ later Delphi beta and FPC development tracks were prerelease; recheck each track before reuse.
80
+ - Identify which compiler and RTL owns every changed behavior. Similar syntax does not establish
81
+ equivalent threading, memory-manager, exception, ABI, package, or managed-type semantics.
82
+
83
+ <!-- mustflow-section: allowed-edits -->
84
+ ## Allowed Edits
85
+
86
+ - Make focused Pascal, project, package, binding, form-resource, runtime, test, and docs changes
87
+ required by the task.
88
+ - Add explicit domain records, conversion tables, lifetime owners, cancellation state, C wrappers,
89
+ ABI probes, and regression tests where they protect changed behavior.
90
+ - Preserve supported compilers, targets, public unit APIs, package boundaries, form resources,
91
+ calling conventions, and wire or storage formats unless migration is explicit.
92
+ - Do not disable range or overflow checks, widen conditional compilation, share a memory manager,
93
+ swallow worker exceptions, or change packing merely to make one target pass.
94
+
95
+ <!-- mustflow-section: procedure -->
96
+ ## Procedure
97
+
98
+ 1. **Split the compiler, RTL, IDE, and target tracks.**
99
+ - Record Delphi or FPC compiler version, language mode, RTL, Lazarus or RAD Studio version,
100
+ architecture, widget or UI framework, package format, backend, linker, and deployment target.
101
+ - Treat Lazarus and FPC as independent release trains. Keep stable, release-candidate,
102
+ development, pas2js, WebAssembly, LLVM, and platform-preview behavior separately gated.
103
+ - Scope compiler directives with local push and pop mechanisms where supported. Do not let an
104
+ include or unit silently change range, overflow, enum, packing, alignment, or syntax policy.
105
+ - Verify design-time package architecture separately from runtime application architecture.
106
+ 2. **Model domain identity beyond decorative aliases.**
107
+ - Distinguish aliases from new ordinal types, but do not assume a new numeric type is fully opaque;
108
+ verify assignment compatibility under the selected compiler and mode.
109
+ - Wrap values that must never mix in records with private storage, explicit validation, no broad
110
+ implicit conversion, and a deliberate valid or invalid default-record state.
111
+ - Receive external input in a wider raw type, validate it explicitly, then convert to a range type.
112
+ Keep range and overflow checks explicitly enabled for the intended builds and tested boundaries.
113
+ - Use enums for one closed choice, subranges for contiguous ordinal subsets, and sets for bounded
114
+ combinations. Keep reusable enums scoped where supported.
115
+ - Keep internal enums dense and map wire names, database codes, HTTP values, and display text
116
+ explicitly. Never persist `Ord`, raw set bytes, RTTI layout, or compiler-dependent enum storage.
117
+ - Use enum-indexed arrays and set operations for complete mappings and structural transition
118
+ tables, while keeping authorization and business conditions in explicit policy functions.
119
+ 3. **Design managed values and records with copy semantics in mind.**
120
+ - Managed strings, interfaces, dynamic arrays, anonymous methods, variants, and compiler-managed
121
+ records carry runtime-specific lifetime behavior, not thread-safe shared-state semantics.
122
+ - A custom managed record is not automatic unique ownership. Define initialization, assignment,
123
+ copying, moving where supported, finalization, self-assignment, exception, and container behavior.
124
+ - Keep `unmanaged`-style generic constraints separate from stable binary representation claims;
125
+ unmanaged values may still have padding, alignment, endian, and ABI differences.
126
+ - Keep helpers limited to representation and convenience. Core validity, permission, transition,
127
+ and money rules must not depend on which helper is visible through unit order.
128
+ - Do not use raw move, fill, or byte comparison on records containing strings, interfaces,
129
+ dynamic arrays, variants, managed records, or other finalized fields. Use typed assignment,
130
+ initialization, finalization, equality, and serialization.
131
+ - Choose one ownership model for an object exposed as both class and interface. Account for
132
+ Delphi reference counting, FPC COM versus CORBA interfaces, temporary interface lifetime,
133
+ interface cycles, weak references, and explicit owner-backed non-owning contracts.
134
+ - Require derived destructors to override the virtual destructor and tolerate partial construction.
135
+ Keep constructor constraints, class references, and default constructors separate from a real
136
+ factory contract with dependencies and validity rules.
137
+ - Keep dictionary keys immutable and provide equality and hash rules as one policy. Make owning
138
+ collection removal distinct from ownership transfer, and do not infer serialization schema from RTTI.
139
+ 4. **Preserve string, array, and pointer lifetime explicitly.**
140
+ - Treat a pointer derived from a temporary string or array as valid only for the bounded call that
141
+ owns the temporary. If native code retains it, allocate or pin an owned buffer with an explicit
142
+ release path and a lifetime longer than every callback or asynchronous operation.
143
+ - Do not mutate shared copy-on-write strings through raw pointers. Establish uniqueness, capacity,
144
+ write bounds, and final logical length, or write into a separate character buffer and construct
145
+ the string afterward.
146
+ - Distinguish UTF-16 code units, Unicode scalar values, grapheme clusters, encoded byte length,
147
+ and NUL-terminated length. Keep binary data in byte containers rather than `RawByteString`.
148
+ - Dynamic-array assignment aliases one backing store and element writes do not trigger string-like
149
+ copy-on-write. Copy explicitly for snapshots, use `const` for read-only access, and use `var` only
150
+ when replacement or resize is part of the contract.
151
+ - Invalidate every saved element pointer after resize. Represent contiguous foreign or SIMD
152
+ matrices as one buffer plus dimensions and stride rather than nested dynamic arrays.
153
+ - Treat an open array as a call-scoped zero-based view whose source lower bound is lost. Avoid
154
+ temporary array constructors and non-const large open-array parameters in hot or stack-bounded paths.
155
+ - Use pointer arithmetic only with an explicit element type and bounds. Use pointer-sized integer
156
+ types only when integer representation is unavoidable; do not truncate addresses through `Integer`.
157
+ - Use managed `out` only for a genuinely fresh result because the prior value may be finalized
158
+ before entry. Produce into a local temporary and commit by assignment when failure must preserve input.
159
+ 5. **Own unit, package, and process lifecycle explicitly.**
160
+ - Treat interface `uses` as public dependency and initialization-graph change. Keep implementation
161
+ dependencies private and move service startup out of cyclic unit initialization into one bootstrap owner.
162
+ - Make initialization publish only fully built state and make finalization tolerate partial startup.
163
+ Finalization must be idempotent, nonthrowing, and independent of UI, newly created loggers, or
164
+ services that may already be finalized.
165
+ - Do not use compiler-specific `Halt`, class-constructor timing, or unit order as a portable shutdown
166
+ or service-start contract. Generic specializations may create more than one class-level initializer.
167
+ - Treat package loading as immediate code execution. Validate a separate manifest first and roll
168
+ back registration if initialization fails.
169
+ - Before unloading a package, stop new calls, drain active calls and callbacks, unregister factories,
170
+ destroy interfaces and objects, and remove RTTI or class references into its code pages.
171
+ - Keep stateful shared units in one required runtime package. Separate design-time and runtime
172
+ packages, compiler, platform, and configuration output directories, and deploy DCP, DCU, and BPL
173
+ according to their distinct compile-time and runtime roles.
174
+ 6. **Make UI and worker lifetimes nonblocking and observable.**
175
+ - Do not block the UI thread waiting for work that needs synchronization, queued callbacks,
176
+ termination events, or UI message processing. Model completion as success, failure, or cancellation.
177
+ - Treat queue APIs as potentially immediate when called from the main thread unless the selected
178
+ RTL guarantees forced deferral. Make state reentrant-safe before scheduling a callback.
179
+ - Capture immutable result values rather than `Self`, raw pointers, or mutable interfaces. Remove
180
+ pending callbacks during shutdown and still account for callbacks already executing.
181
+ - Treat `FreeOnTerminate` as a no-external-reference policy, not automatic ownership. With an owner,
182
+ request cancellation, await termination without UI dependency, observe the result, then destroy.
183
+ - Treat `Terminate` and OS cancellation calls as requests. Give blocking I/O finite interruption
184
+ paths and retain buffers, overlapped state, and context until a completion result is observed.
185
+ - On FPC Unix targets, establish the selected thread manager before any unit can create threads.
186
+ Ensure console main loops service synchronization callbacks when that RTL requires it.
187
+ 7. **Protect compound state, not just individual variables.**
188
+ - Reference counting and one interlocked counter do not make a compound invariant atomic. Use one
189
+ owned lock or a proved single-word state transition; account for publication, ABA, and reclamation.
190
+ - Use semaphores for counts and queues for data. A pulse, condition, or event is not durable work;
191
+ update state under the lock, signal afterward, and recheck wait predicates in a loop.
192
+ - Lock on a dedicated stable object whose identity cannot change and whose lifetime outlives all
193
+ users. Define one global lock order across normal, error, cancellation, and shutdown paths.
194
+ - Copy state and callback lists under the lock, then release it before logging, callbacks, UI
195
+ queueing, COM, interface release, destructors, allocator calls, or other reentrant code.
196
+ - Observe every worker exception exactly once and map it into the owner-visible completion state.
197
+ A worker stack does not propagate an exception to the thread creator's `try..except` block.
198
+ 8. **Keep native boundaries intentionally narrow.**
199
+ - Put C++ classes, STL, templates, overloads, virtual layout, and exceptions behind an `extern "C"`
200
+ facade. Expose fixed scalars, POD records, pointer-length buffers, opaque handles, and status codes.
201
+ - Match function and callback calling conventions, parameter count, width, signedness, return mode,
202
+ and variadic behavior exactly. Prefer platform and compiler C-type units over `Integer` or `Boolean`.
203
+ - Verify every shared record with C-side size, alignment, and offset probes on each target. Do not
204
+ add `packed` unless the foreign declaration itself requires that exact packing.
205
+ - Define string pointer, length unit, encoding, embedded-NUL rule, ownership, retention, and release.
206
+ Copy borrowed return buffers before their documented validity ends.
207
+ - Allocate and free in the same module or documented allocator family. Do not expose managed Pascal
208
+ strings, arrays, interfaces, variants, classes, open arrays, or anonymous methods through a C ABI.
209
+ - Register callbacks as function, context, calling convention, thread, lifetime, and drain contracts.
210
+ Block new callbacks and wait for in-flight callbacks before destroying context or unloading code.
211
+ - Catch Pascal and C++ exceptions inside their wrappers. Read `GetLastError` or `errno` immediately
212
+ after a documented failing return, before logging or other calls can overwrite it.
213
+ - Initialize COM per thread with the required apartment and marshal interfaces across apartments.
214
+ Shut down by lifetime dependency: stop work, drain callbacks and I/O, destroy handles, then unload.
215
+ 9. **Measure hidden managed and dispatch cost before tuning switches.**
216
+ - Measure representative wall time, allocations, reference-count traffic, copies, stack use,
217
+ generated assembly, and code size. Debug symbols do not add runtime checks; retain symbols and
218
+ map files while treating range, overflow, and assertion policy separately.
219
+ - Use ordinary `const` as an optimization opportunity, not a guaranteed by-reference ABI. Apply
220
+ Delphi forced-reference or FPC `constref` only where the selected compiler, structure size, and
221
+ calling boundary justify it; pass small scalars by value.
222
+ - Reuse output buffers with `var` and an explicit logical count. Grow arrays geometrically or
223
+ allocate once, avoid repeated string concatenation and encoding conversion, and perform encoding
224
+ conversion once at an owned boundary.
225
+ - Keep managed fields out of hot numeric records where practical. Batch virtual and interface
226
+ dispatch so concrete loops remain visible to the optimizer.
227
+ - Resolve RTTI metadata once per type and cache immutable descriptors or generated delegates.
228
+ Do not rediscover schema or wrap every element in a reflective value on a hot path.
229
+ - Convert packed external records into naturally aligned internal records before computation.
230
+ Verify actual inlining and optimization in generated output; `inline`, a higher optimization
231
+ number, WPO, or smart linking is not proof of a faster or equivalent program.
232
+ - For FPC generics, keep type-independent heavy logic in a non-generic core to control repeated
233
+ specialization, compile time, and binary size. Measure the Delphi result too rather than assuming sharing.
234
+ 10. **Gate modern features by the actual release track.**
235
+ - Use Delphi conditional expressions only where both branch type and evaluation remain clear;
236
+ parenthesize them inside larger expressions. Use `NameOf` for refactoring-coupled diagnostics,
237
+ never for stable wire, database, event, or storage names.
238
+ - Verify generic constraint and managed-record support under every supported compiler. Do not
239
+ silently translate Delphi-only semantics into FPC mode switches or vice versa.
240
+ - Audit pointer width, inline assembly, atomics, SIMD, packing, DLLs, COM, and third-party packages
241
+ before claiming a new CPU target such as Windows on Arm is supported.
242
+ - For FireMonkey, separate display timing and GPU residency from Pascal CPU micro-optimization.
243
+ For web or AI components, separate transport support from protocol, auth, session, provider,
244
+ privacy, and deployment contracts.
245
+ 11. **Verify every supported compiler and target boundary.**
246
+ - Cover type mixing, default records, invalid ranges, overflow, enum and set mappings, managed-record
247
+ copies, temporary pointer lifetime, array aliasing and resize, partial construction, unit startup
248
+ failure, package unload, UI reentrancy, cancellation, worker failure, queue and lock behavior,
249
+ shutdown, callback drain, ABI layout, allocator pairing, error capture, COM apartment use, and
250
+ DLL version negotiation.
251
+ - Run configured build, test, package, ABI, and target intents for each changed supported track.
252
+ Report a missing compiler, target, design-time package, device, or ABI probe instead of claiming
253
+ portability from one successful host build.
254
+
255
+ <!-- mustflow-section: postconditions -->
256
+ ## Postconditions
257
+
258
+ - Compiler, RTL, IDE, language mode, target, directive, package, and deployment identity are explicit.
259
+ - Domain type, range, enum, set, managed-record, ownership, threading, cancellation, ABI, callback,
260
+ string, array, pointer, initialization, package, performance, error, and shutdown contracts are observable.
261
+ - Delphi, FPC, Lazarus, stable, prerelease, development, design-time, and runtime evidence are not conflated.
262
+ - Portability and compatibility claims are limited to the compilers, architectures, packages, and
263
+ ABI probes actually verified.
264
+
265
+ <!-- mustflow-section: verification -->
266
+ ## Verification
267
+
268
+ Use configured oneshot intents that cover the changed scope:
269
+
270
+ - `changes_status`
271
+ - `changes_diff_summary`
272
+ - `lint`
273
+ - `build`
274
+ - `test_related`
275
+ - `test`
276
+ - `docs_validate_fast`
277
+ - `test_release`
278
+ - `mustflow_check`
279
+
280
+ <!-- mustflow-section: failure-handling -->
281
+ ## Failure Handling
282
+
283
+ - If compiler, RTL, mode, target, package, or directive identity is unclear, preserve existing
284
+ behavior and report the missing evidence.
285
+ - If range or overflow policy is unknown, validate external values explicitly and do not claim the
286
+ range type alone enforces the boundary.
287
+ - If worker cancellation, callback drain, or shutdown ownership is unclear, keep the lifetime change
288
+ out and report the missing state machine.
289
+ - If ABI layout, calling convention, allocation owner, or string lifetime cannot be verified, keep
290
+ the foreign representation raw and stop before exposing it as a Pascal domain value.
291
+ - If only one compiler or host target is available, report that limitation and do not claim cross-
292
+ compiler, architecture, package, UI-framework, or deployment compatibility.
293
+
294
+ <!-- mustflow-section: output-format -->
295
+ ## Output Format
296
+
297
+ - Compiler, RTL, IDE, language mode, target, package, and deployment tracks
298
+ - Type, range, enum, set, managed-value, ownership, threading, cancellation, ABI, and shutdown decisions
299
+ - Delphi versus FPC or Lazarus compatibility and version-gate decisions
300
+ - Configured intents run and target or ABI evidence obtained
301
+ - Skipped checks and remaining Pascal, package, platform, threading, ABI, or deployment risk
@@ -0,0 +1,327 @@
1
+ ---
2
+ mustflow_doc: skill.php-code-change
3
+ locale: en
4
+ canonical: true
5
+ revision: 2
6
+ lifecycle: mustflow-owned
7
+ authority: procedure
8
+ name: php-code-change
9
+ description: Apply this skill when PHP source, Composer packages, Laravel or Symfony applications, Eloquent or Doctrine persistence, PHP-FPM, OPcache, Octane, RoadRunner, Swoole, Messenger or queue workers, authentication, sessions, uploads, database concurrency, tests, or PHP deployment behavior are created, changed, reviewed, migrated, or upgraded.
10
+ metadata:
11
+ mustflow_schema: "1"
12
+ mustflow_kind: procedure
13
+ pack_id: mustflow.core
14
+ skill_id: mustflow.core.php-code-change
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
+ # PHP Code Change
28
+
29
+ <!-- mustflow-section: purpose -->
30
+ ## Purpose
31
+
32
+ Preserve PHP language, Composer, dependency injection, request lifetime, ORM, transaction, input,
33
+ authentication, session, filesystem, worker, FPM, OPcache, container, and deployment contracts.
34
+ Do not let PHP-FPM's request reset hide stateful design that leaks users or resources under Octane,
35
+ RoadRunner, Swoole, Messenger, queue workers, persistent connections, or other long-lived processes.
36
+
37
+ <!-- mustflow-section: use-when -->
38
+ ## Use When
39
+
40
+ - PHP source, Composer metadata or lockfiles, autoloading, extensions, static analysis, tests,
41
+ framework bootstrap, console commands, queues, scheduled jobs, or package APIs change.
42
+ - Laravel, Symfony, Eloquent, Doctrine, service containers, middleware, events, cache, sessions,
43
+ authentication, authorization, uploads, validation, serialization, or database behavior changes.
44
+ - PHP-FPM pools, OPcache, web-server/FastCGI integration, containers, health probes, timeouts,
45
+ long-running workers, deployment caches, migrations, or rollout behavior changes.
46
+
47
+ <!-- mustflow-section: do-not-use-when -->
48
+ ## Do Not Use When
49
+
50
+ - The change is framework-free frontend code or another language with no PHP runtime boundary.
51
+ - Only SQL schema or database operations change and PHP behavior is unaffected; use the narrower
52
+ data or migration skill.
53
+ - The task asks only for the current PHP, Laravel, Symfony, or Doctrine version; use
54
+ source-freshness guidance unless code or durable documentation changes too.
55
+
56
+ <!-- mustflow-section: required-inputs -->
57
+ ## Required Inputs
58
+
59
+ - PHP version source, supported runtime range, required extensions, Composer metadata and lockfile,
60
+ autoload rules, framework and ORM versions, static-analysis level, test config, CI and image.
61
+ - Execution model: PHP-FPM, CLI, server, Octane, RoadRunner, Swoole, queue worker, Messenger,
62
+ scheduled job, persistent process, or mixed deployment.
63
+ - Request and state ledger: container scope, request/user/tenant state, globals, statics, singleton
64
+ fields, ORM unit of work, sessions, caches, connections, files, timers, buffers, and reset owners.
65
+ - Security ledger: input sources, validation, output context, SQL, commands, paths, uploads,
66
+ deserialization, secrets, passwords, authentication, CSRF, session lifetime, and proxy trust.
67
+ - Data ledger: query count, rows and bytes, hydration, lazy loading, transaction owner, connection,
68
+ locks, unique constraints, optimistic versions, retries, outbox, pagination, and batch ownership.
69
+ - Runtime ledger: FPM mode and limits, OPcache policy, timeouts, web server, probes, container
70
+ resources, deployment cache generation, worker reload, observability, and rollback.
71
+
72
+ <!-- mustflow-section: preconditions -->
73
+ ## Preconditions
74
+
75
+ - Read repository PHP, Composer, framework, ORM, extension, deployment, and test evidence before
76
+ using current APIs or migration guidance.
77
+ - Refresh official PHP, Composer, Laravel, Symfony, Doctrine, web-server, database, and platform
78
+ sources before preserving exact version, default, deprecation, security, or support claims.
79
+ - Treat version research as a dated snapshot. The official-source snapshot reviewed on 2026-07-11
80
+ identified PHP 8.5.8 as stable and PHP 8.6.0 Alpha 1 as prerelease; recheck the current stable,
81
+ supported branches, migration guides, and each feature's actual release status before reuse.
82
+ - Identify whether process state ends after one request. Treat every service as potentially reused
83
+ until the selected runtime proves request-scoped destruction.
84
+ - Apply narrower auth, upload, transaction, cache, queue, logging, performance, or deployment skills
85
+ when those boundaries materially change.
86
+
87
+ <!-- mustflow-section: allowed-edits -->
88
+ ## Allowed Edits
89
+
90
+ - Make focused PHP, Composer, framework, ORM, config, test, deployment, and docs changes required by
91
+ the task.
92
+ - Add explicit DTOs, query objects, reset hooks, transaction owners, validation, session controls,
93
+ performance instrumentation, or deployment checks where they protect changed behavior.
94
+ - Preserve supported PHP versions and framework conventions unless migration is explicit.
95
+ - Do not hide failures by lowering static analysis, disabling tests, granting broad filesystem
96
+ permissions, enabling unsafe deserialization, widening session scope, or raising resource limits
97
+ without evidence.
98
+
99
+ <!-- mustflow-section: procedure -->
100
+ ## Procedure
101
+
102
+ 1. **Classify runtime and package contracts.**
103
+ - Record PHP SAPI, version, extensions, Composer platform requirements, autoload roots, scripts,
104
+ plugins, package type, framework, ORM, worker model, image, and deployment target.
105
+ - Treat Composer scripts and plugins as executable supply-chain boundaries. Review lockfile,
106
+ platform checks, extension requirements, optimized autoload, authoritative classmaps, and
107
+ packaged files separately from source-tree success.
108
+ - Keep library dependency ranges compatible and application environments reproducible. Commit
109
+ application lockfiles, use `composer install` in CI and deployment, and validate the lock
110
+ rather than resolving a fresh graph during release.
111
+ - Treat repository priority, canonical repositories, package names, `replace`, `provide`,
112
+ `conflict`, stability flags, Composer plugins, and `autoload.files` as supply-chain behavior.
113
+ Do not assume a dependency's `repositories` configuration propagates to the root project.
114
+ - Use `composer why` and `why-not` before widening constraints or deleting a lockfile. Verify the
115
+ built artifact with real platform requirements; `config.platform` and
116
+ `--ignore-platform-reqs` do not prove that production has the required PHP or extensions.
117
+ - Enforce PSR-4 path and case correctness on a case-sensitive CI filesystem and detect ambiguous
118
+ classes. Optimize production autoloading, but use authoritative classmaps only after proving
119
+ that runtime-generated proxies or classes do not depend on fallback discovery.
120
+ 2. **Keep dependencies and state ownership visible.**
121
+ - Confine container access and service location to composition roots. Prefer constructor
122
+ injection of narrow contracts over global helpers, facades, or arbitrary container lookup.
123
+ - Add layers only where policy, representation, transaction, authorization, or replacement
124
+ changes. Remove pass-through controller, action, service, manager, and generic repository
125
+ chains that hide cost without owning a boundary.
126
+ - Keep request, user, tenant, locale, auth, and transaction state out of singleton and static
127
+ fields. Pass request values explicitly or use a resettable request-scoped owner.
128
+ - For long-lived runtimes, reset application state, ORM units of work, log buffers, caches,
129
+ files, connections, and framework services between jobs or requests. Bound worker lifetime and
130
+ reload workers during deployment.
131
+ 3. **Separate ORM entities from external contracts.**
132
+ - Do not use Eloquent models or Doctrine entities as universal API, queue, event, cache, or
133
+ integration payloads. Define whether a queued job needs an identifier and execution-time state
134
+ or an immutable publication-time snapshot.
135
+ - Keep business invariants in explicit application or domain operations. Do not hide critical
136
+ payments, stock, authorization, or external effects in model listeners whose execution differs
137
+ across bulk update, delete, flush, or import paths.
138
+ - Use transactional outbox and idempotent consumers for external side effects.
139
+ 4. **Measure query shape, not only query count.**
140
+ - Detect N+1 by request-level query count, normalized fingerprints, total DB time, rows, bytes,
141
+ and result-size scaling. Make unexpected lazy loading fail in development or tests.
142
+ - Do not replace N+1 with an unbounded eager-loaded graph or multi-collection join explosion.
143
+ Page parent identifiers first and batch child, aggregate, or projection queries deliberately.
144
+ - Use entities for behavior-changing writes. Use DTO, scalar, array, DBAL, or query-builder
145
+ projections for lists, reports, exports, counts, and read-only views.
146
+ - Use bounded iteration, keyset or cursor pagination, stable unique tie-breakers, and unit-of-work
147
+ clearing for large datasets. Avoid deep OFFSET and per-request exact counts without product need.
148
+ - Avoid `fetchAll()` and full ORM hydration for large streams. Select only required columns,
149
+ choose an explicit fetch mode, and account for driver buffering, identity maps, and connection
150
+ restrictions while an unbuffered result remains open.
151
+ 5. **Own transactions and concurrency at the use case.**
152
+ - Let one business operation own begin, commit, rollback, retry, and the shared connection.
153
+ Nested work cannot commit independently; use explicit savepoints only when supported and intended.
154
+ - Keep HTTP, email, queue publication, and long computation outside row-locking transactions.
155
+ Store business data and outbox records atomically, then publish after commit.
156
+ - Enforce uniqueness and invariants with database constraints and atomic updates or upserts.
157
+ Treat check-then-insert and read-compute-write as races.
158
+ - Verify affected rows, optimistic versions, lock scope, index support, and deterministic lock
159
+ order. Retry the whole transaction on classified deadlock or serialization failure with a
160
+ bounded backoff; never repeat only the final statement with stale reads.
161
+ - Persistent PDO connections require explicit cleanup of transactions, locks, temporary state,
162
+ and session settings before reuse.
163
+ 6. **Validate input by meaning and encode output by context.**
164
+ - Avoid loose comparison for authentication, tokens, signatures, hashes, identifiers, and
165
+ security decisions. Use strict types and constant-time comparison where secret equality matters.
166
+ - Distinguish filtering from validation. Normalize only according to a named domain rule and
167
+ preserve missing, empty, null, zero, and false as different states where the contract does.
168
+ - Use parameterized SQL for values and allowlists for identifiers, sort direction, table,
169
+ column, operator, and dynamic query structure.
170
+ - Avoid `extract()`, variable variables, mass assignment, and broad array-to-object hydration at
171
+ trust boundaries. Define allowed fields and nested shapes explicitly.
172
+ - Encode output for HTML text, attributes, URLs, JavaScript, JSON, headers, and logs at the final
173
+ sink; one escaping function does not fit every context.
174
+ 7. **Harden files, commands, serialization, and secrets.**
175
+ - For uploads, validate authorization, size, count, extension, MIME, magic bytes, image or archive
176
+ structure, decompression limits, generated server-side names, storage outside executable roots,
177
+ and safe download headers. Never trust the client filename or MIME alone.
178
+ - Canonicalize and constrain filesystem paths against an owned root, accounting for symlinks,
179
+ races, archive traversal, stream wrappers, and web-server handlers.
180
+ - Avoid shell construction. Use argument-safe process APIs, narrow executable allowlists,
181
+ timeouts, bounded output, environment control, and least OS privilege.
182
+ - Do not `unserialize()` untrusted data. Use explicit schemas; when signed client state is
183
+ unavoidable, authenticate integrity and separate confidentiality requirements.
184
+ - Keep secrets out of errors, dumps, logs, phpinfo, source control, build artifacts, caches, and
185
+ browser-visible configuration.
186
+ 8. **Harden passwords, authentication, and sessions.**
187
+ - Use supported password APIs and sufficient storage width. Account for bcrypt's byte limit,
188
+ reject over-limit input rather than truncating, avoid silent normalization, and rehash after
189
+ successful login when policy changes.
190
+ - Keep unknown-account and wrong-password responses, status, shape, and expensive hash path
191
+ comparable. Apply bounded risk-based throttling without creating an attacker-controlled
192
+ permanent account lock.
193
+ - Generate reset and verification URLs from a configured trusted origin. Store token hashes,
194
+ enforce short expiry and single use, and revoke affected sessions after sensitive changes.
195
+ - Enable strict session-ID handling, cookie-only transport, secure cookie attributes, ID rotation
196
+ at privilege changes, and a concurrency-safe transition from old IDs.
197
+ - Treat SameSite as defense in depth, not CSRF authorization. Protect state-changing and login
198
+ requests with CSRF tokens and origin checks as appropriate.
199
+ - Enforce idle, absolute, renewal, revocation, and recent-authentication policy server-side;
200
+ garbage collection and cookie expiry are not authentication policy.
201
+ 9. **Design cache and middleware cost explicitly.**
202
+ - Include tenant, locale, currency, authorization visibility, query shape, and schema version in
203
+ cache identity. Avoid caching ORM entities.
204
+ - Prevent stampedes with jitter, locks, stale-while-revalidate, and one refresh owner.
205
+ - Keep global middleware and subscribers limited to truly universal work. Measure auth, tenant,
206
+ session, locale, feature flag, audit, and activity-update costs by route.
207
+ - Release a file-backed session lock as soon as session mutation is complete. Do not hold one
208
+ user's parallel requests behind database, HTTP, upload, or other slow work.
209
+ 10. **Measure algorithm, allocation, and discovery cost before micro-optimizing.**
210
+ - Profile representative data sizes and concurrency with wall time, CPU, allocations, peak RSS,
211
+ I/O waits, and tail latency. Do not trade clarity for `isset()`-scale folklore while quadratic
212
+ copying, serialization, locks, or network waits dominate.
213
+ - Avoid repeated `array_merge()` accumulation and front-removal with `array_shift()` in growing
214
+ loops. Append directly, merge once, use a cursor, or choose a queue with the required
215
+ complexity while preserving numeric and string key semantics.
216
+ - Remember that PHP arrays are ordered maps, not compact primitive vectors. Avoid retaining
217
+ millions of rows or duplicate numeric and associative PDO keys; benchmark specialized
218
+ structures before accepting their compatibility and maintenance cost.
219
+ - Collapse filter-map-reindex chains when intermediate arrays dominate memory. Use generators
220
+ or streaming only when every downstream stage also remains bounded; laziness does not repair a
221
+ consumer that collects the whole result again.
222
+ - Rely on copy-on-write for ordinary read-only arguments instead of adding references as a
223
+ speculative optimization. Minimize aliases, return explicit result objects instead of output
224
+ parameters, and `unset` a reference variable immediately after reference iteration.
225
+ - Bound adversarial input before regular expressions and remove ambiguous nested repetition.
226
+ Check regex failure separately from no-match; raising backtracking limits is not a fix for
227
+ catastrophic backtracking.
228
+ - Compile route, container, event, serialization, template, and class discovery metadata during
229
+ build or cache warmup where supported. Account for autoload side effects from `class_exists()`,
230
+ and instantiate delayed attributes in CI so invalid targets do not wait for first traffic.
231
+ - Observe OPcache capacity, cached scripts, wasted memory, hit rate, and restart causes. Do not
232
+ infer health from `opcache.enable` alone, and do not assume JIT improves framework or I/O-bound
233
+ workloads without a representative benchmark.
234
+ 11. **Tune FPM, OPcache, web server, and containers from evidence.**
235
+ - Bound FPM concurrency by the smallest of memory, CPU/tail-latency, and downstream connection
236
+ budgets. Choose static, dynamic, or ondemand from traffic shape, not container folklore.
237
+ - Set worker recycling from measured memory growth. Observe listen queue, max-children events,
238
+ worker RSS, CPU throttling, DB waits, slow logs, and OOM behavior together.
239
+ - Order database, application, FPM, FastCGI, proxy, and load-balancer timeouts deliberately.
240
+ Know whether post-response work remains subject to termination and cancellation.
241
+ - Keep liveness limited to restart-recoverable process failure; use startup and readiness for
242
+ boot and dependency availability without causing restart storms.
243
+ - Build or warm environment-independent caches before traffic and environment-dependent caches
244
+ only after correct configuration exists. Do not let every replica race migrations or mutate
245
+ a shared cache directory.
246
+ - Treat OPcache preload and immutable-container assumptions as deployment contracts. Reload
247
+ FPM and long-running workers when code or cached containers change.
248
+ 12. **Apply language and type contracts deliberately.**
249
+ - Enforce `declare(strict_types=1)` across owned source files, not only entrypoints. Remember that
250
+ scalar argument coercion follows the calling file, return coercion follows the defining file,
251
+ and typed-property assignment follows the write site; strict types do not validate domain
252
+ formats, ranges, or decoded input shapes.
253
+ - Keep `mixed` at untrusted or dynamic boundaries and narrow it immediately. Layer precise
254
+ PHPDoc shapes, lists, ranges, callable signatures, generics, conditional returns, and
255
+ assertions over native runtime types rather than replacing native types with comments.
256
+ - Prefer `Closure` plus an analyzed signature for stored callbacks. Preserve generic type
257
+ relationships and collection variance; mutable collections are not automatically covariant.
258
+ - Fix inaccurate types at their source through native declarations, PHPDoc, stubs, generics,
259
+ assertions, or analysis extensions. Do not scatter inline `@var` claims or grow a baseline to
260
+ silence new errors; run the strongest practical rules and make legacy suppressions shrink.
261
+ - For PHP 8.5 upgrades, verify URI interpretation against the actual consumer, pipe only unary
262
+ callables, preserve shallow-clone semantics, and test ignored `#[NoDiscard]` results as
263
+ failures where the return value is contractual. Instantiate delayed attributes during build.
264
+ - Audit migration warnings and deprecations before changing the runtime, including OPcache
265
+ loading assumptions, destructuring non-arrays, lossy numeric casts, legacy casts, backtick
266
+ execution, legacy serialization hooks, null array keys, and changed extension APIs. Keep
267
+ prerelease-only features out of production code unless the project explicitly targets them.
268
+ 13. **Verify framework-specific behavior.**
269
+ - For Laravel, inspect container and facade use, mass assignment, model events, lazy loading,
270
+ queue model serialization, after-commit dispatch, cache locks, config/route/view caches,
271
+ Octane reset behavior, and worker reload.
272
+ - For Symfony and Doctrine, inspect service scope and reset, kernel subscribers, Messenger
273
+ redelivery, Doctrine hydration and identity map, flush/listener behavior, cache warmup, and
274
+ long-running worker reset.
275
+ - Treat framework cache, ORM, queue, and runtime features as separate version-sensitive tracks.
276
+ 14. **Verify the real execution model.**
277
+ - Cover static analysis, unit and integration tests, query-count growth, transaction conflict,
278
+ auth/session failure, upload rejection, repeated request/job state reset, FPM/container smoke,
279
+ worker reload, and production cache behavior according to the changed surface.
280
+ - Report missing configured intents rather than running raw servers, migrations, deploys,
281
+ dependency installs, or long-running workers.
282
+
283
+ <!-- mustflow-section: postconditions -->
284
+ ## Postconditions
285
+
286
+ - Runtime, package, container, request state, ORM, transaction, validation, authentication, session,
287
+ filesystem, worker, FPM, cache, and deployment ownership are explicit.
288
+ - Code that is safe only because PHP-FPM resets the request is not silently reused in a persistent process.
289
+ - Query and performance claims include rows, hydration, concurrency, memory, and tail-latency evidence.
290
+ - Security decisions do not depend on loose comparison, client metadata, unsafe serialization,
291
+ cookie expiry, or application-only uniqueness checks.
292
+
293
+ <!-- mustflow-section: verification -->
294
+ ## Verification
295
+
296
+ Use configured oneshot intents that cover the changed scope:
297
+
298
+ - `changes_status`
299
+ - `changes_diff_summary`
300
+ - `lint`
301
+ - `build`
302
+ - `test_related`
303
+ - `test`
304
+ - `docs_validate_fast`
305
+ - `test_release`
306
+ - `mustflow_check`
307
+
308
+ <!-- mustflow-section: failure-handling -->
309
+ ## Failure Handling
310
+
311
+ - If the PHP, framework, ORM, SAPI, or worker track is unclear, preserve existing behavior and
312
+ report the missing evidence.
313
+ - If a performance fix only raises workers, memory, timeout, eager loading, or cache TTL without
314
+ proving the bottleneck, keep it out and report the missing measurement.
315
+ - If a transaction path includes external side effects, split it behind an outbox or report the
316
+ atomicity gap before claiming safety.
317
+ - If long-running reset behavior cannot be verified, keep services stateless and report missing
318
+ repeated-request or repeated-message coverage.
319
+
320
+ <!-- mustflow-section: output-format -->
321
+ ## Output Format
322
+
323
+ - PHP runtime, Composer, framework, ORM, SAPI, and worker tracks
324
+ - State, security, data, cache, FPM, container, and deployment owners
325
+ - Structural, performance, compatibility, and migration decisions
326
+ - Verification evidence and configured intents run
327
+ - Skipped checks and remaining PHP, framework, persistence, security, or deployment risk