mustflow 2.116.1 → 2.116.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/package.json +1 -1
  2. package/templates/default/i18n.toml +72 -6
  3. package/templates/default/locales/en/.mustflow/skills/INDEX.md +37 -11
  4. package/templates/default/locales/en/.mustflow/skills/compiler-engineering-review/SKILL.md +477 -0
  5. package/templates/default/locales/en/.mustflow/skills/compiler-engineering-review/references/compiler-diagnostics-abi-linker-checklist.md +778 -0
  6. package/templates/default/locales/en/.mustflow/skills/compiler-engineering-review/references/compiler-generators-properties-checklist.md +501 -0
  7. package/templates/default/locales/en/.mustflow/skills/compiler-engineering-review/references/compiler-test-strategy-differential-checklist.md +498 -0
  8. package/templates/default/locales/en/.mustflow/skills/compiler-engineering-review/references/debug-symbol-symbolication-checklist.md +412 -0
  9. package/templates/default/locales/en/.mustflow/skills/compiler-engineering-review/references/ir-design-ssa-pass-pipeline-checklist.md +759 -0
  10. package/templates/default/locales/en/.mustflow/skills/compiler-engineering-review/references/miscompile-reduction-ir-checklist.md +434 -0
  11. package/templates/default/locales/en/.mustflow/skills/cross-platform-filesystem-safety/SKILL.md +55 -36
  12. package/templates/default/locales/en/.mustflow/skills/cross-platform-filesystem-safety/references/path-containment-handle-checklist.md +251 -0
  13. package/templates/default/locales/en/.mustflow/skills/file-upload-security-review/SKILL.md +133 -32
  14. package/templates/default/locales/en/.mustflow/skills/file-upload-security-review/references/file-upload-parser-ssrf-resource-checklist.md +306 -0
  15. package/templates/default/locales/en/.mustflow/skills/formal-verification-review/SKILL.md +310 -0
  16. package/templates/default/locales/en/.mustflow/skills/formal-verification-review/references/formal-concurrency-model-checking-smt-checklist.md +457 -0
  17. package/templates/default/locales/en/.mustflow/skills/formal-verification-review/references/formal-contracts-modeling-checklist.md +434 -0
  18. package/templates/default/locales/en/.mustflow/skills/formal-verification-review/references/formal-memory-bounds-ci-checklist.md +509 -0
  19. package/templates/default/locales/en/.mustflow/skills/fuzz-harness-review/SKILL.md +439 -0
  20. package/templates/default/locales/en/.mustflow/skills/fuzz-harness-review/references/fuzz-harness-campaign-checklist.md +379 -0
  21. package/templates/default/locales/en/.mustflow/skills/fuzz-harness-review/references/fuzz-oracle-triage-ci-checklist.md +307 -0
  22. package/templates/default/locales/en/.mustflow/skills/idempotency-integrity-review/SKILL.md +48 -28
  23. package/templates/default/locales/en/.mustflow/skills/idempotency-integrity-review/references/operation-ordering-stale-write-checklist.md +259 -0
  24. package/templates/default/locales/en/.mustflow/skills/input-boundary-validation-review/SKILL.md +329 -0
  25. package/templates/default/locales/en/.mustflow/skills/input-boundary-validation-review/references/input-boundary-security-checklist.md +319 -0
  26. package/templates/default/locales/en/.mustflow/skills/input-event-synchronization-review/SKILL.md +306 -0
  27. package/templates/default/locales/en/.mustflow/skills/input-event-synchronization-review/references/input-session-state-checklist.md +298 -0
  28. package/templates/default/locales/en/.mustflow/skills/input-event-synchronization-review/references/remote-input-transport-interaction-checklist.md +328 -0
  29. package/templates/default/locales/en/.mustflow/skills/interpreter-engineering-review/SKILL.md +353 -0
  30. package/templates/default/locales/en/.mustflow/skills/interpreter-engineering-review/references/interpreter-diagnostics-recovery-checklist.md +267 -0
  31. package/templates/default/locales/en/.mustflow/skills/interpreter-engineering-review/references/interpreter-execution-closure-performance-checklist.md +428 -0
  32. package/templates/default/locales/en/.mustflow/skills/interpreter-engineering-review/references/interpreter-gc-verification-checklist.md +457 -0
  33. package/templates/default/locales/en/.mustflow/skills/interpreter-engineering-review/references/interpreter-semantics-runtime-checklist.md +391 -0
  34. package/templates/default/locales/en/.mustflow/skills/modal-loop-reentrancy-review/SKILL.md +294 -0
  35. package/templates/default/locales/en/.mustflow/skills/modal-loop-reentrancy-review/references/modal-loop-reentrancy-checklist.md +290 -0
  36. package/templates/default/locales/en/.mustflow/skills/modal-loop-reentrancy-review/references/nested-modal-state-lifetime-checklist.md +297 -0
  37. package/templates/default/locales/en/.mustflow/skills/name-resolution-integrity-review/SKILL.md +252 -0
  38. package/templates/default/locales/en/.mustflow/skills/name-resolution-integrity-review/references/dns-network-resolution-checklist.md +394 -0
  39. package/templates/default/locales/en/.mustflow/skills/name-resolution-integrity-review/references/language-symbol-resolution-checklist.md +282 -0
  40. package/templates/default/locales/en/.mustflow/skills/name-resolution-integrity-review/references/module-package-loader-resolution-checklist.md +352 -0
  41. package/templates/default/locales/en/.mustflow/skills/parser-engineering-review/SKILL.md +103 -17
  42. package/templates/default/locales/en/.mustflow/skills/parser-engineering-review/references/cst-ast-lowering-checklist.md +260 -0
  43. package/templates/default/locales/en/.mustflow/skills/parser-engineering-review/references/lexer-tokenization-checklist.md +397 -0
  44. package/templates/default/locales/en/.mustflow/skills/parser-engineering-review/references/tree-serialization-compatibility-checklist.md +164 -0
  45. package/templates/default/locales/en/.mustflow/skills/parser-engineering-review/references/tree-traversal-rewrite-checklist.md +209 -0
  46. package/templates/default/locales/en/.mustflow/skills/race-condition-review/SKILL.md +68 -11
  47. package/templates/default/locales/en/.mustflow/skills/race-condition-review/references/race-reproduction-memory-model-checklist.md +268 -0
  48. package/templates/default/locales/en/.mustflow/skills/routes.toml +151 -0
  49. package/templates/default/locales/en/.mustflow/skills/session-handoff-integrity-review/SKILL.md +343 -0
  50. package/templates/default/locales/en/.mustflow/skills/session-handoff-integrity-review/references/session-auth-stream-resume-checklist.md +413 -0
  51. package/templates/default/locales/en/.mustflow/skills/session-handoff-integrity-review/references/session-handoff-protocol-checklist.md +485 -0
  52. package/templates/default/locales/en/.mustflow/skills/two-phase-transition-integrity-review/SKILL.md +267 -0
  53. package/templates/default/locales/en/.mustflow/skills/two-phase-transition-integrity-review/references/admission-decision-recovery-checklist.md +308 -0
  54. package/templates/default/locales/en/.mustflow/skills/two-phase-transition-integrity-review/references/two-phase-transition-checklist.md +229 -0
  55. package/templates/default/locales/en/.mustflow/skills/ui-dispatch-lifecycle-review/SKILL.md +300 -0
  56. package/templates/default/locales/en/.mustflow/skills/ui-dispatch-lifecycle-review/references/ui-affinity-event-loop-checklist.md +277 -0
  57. package/templates/default/locales/en/.mustflow/skills/ui-dispatch-lifecycle-review/references/ui-dispatch-lifecycle-checklist.md +292 -0
  58. package/templates/default/manifest.toml +115 -1
@@ -0,0 +1,259 @@
1
+ # Operation Identity, Ordering, and Stale-Write Checklist
2
+
3
+ Use this checklist when duplicate delivery, out-of-order completion, and stale decisions can affect
4
+ the same business operation. Keep database isolation, broker settlement, distributed protocol, and
5
+ memory-model work in their owning skills; this reference connects those boundaries through stable
6
+ operation identity and storage-enforced state validity.
7
+
8
+ ## Contents
9
+
10
+ 1. [One failure model](#one-failure-model)
11
+ 2. [Identity ledger](#identity-ledger)
12
+ 3. [Atomic duplicate admission](#atomic-duplicate-admission)
13
+ 4. [Ordering scope](#ordering-scope)
14
+ 5. [Causal tokens and gaps](#causal-tokens-and-gaps)
15
+ 6. [Stale completion rejection](#stale-completion-rejection)
16
+ 7. [UI and asynchronous completion](#ui-and-asynchronous-completion)
17
+ 8. [External effects and settlement](#external-effects-and-settlement)
18
+ 9. [Locks and request coalescing](#locks-and-request-coalescing)
19
+ 10. [Commutative operations and ledgers](#commutative-operations-and-ledgers)
20
+ 11. [Transaction traps](#transaction-traps)
21
+ 12. [Adversarial tests](#adversarial-tests)
22
+ 13. [Reconciliation invariants](#reconciliation-invariants)
23
+ 14. [AI-generated code review](#ai-generated-code-review)
24
+ 15. [Skill handoffs](#skill-handoffs)
25
+
26
+ ## One failure model
27
+
28
+ Treat duplicate execution, reversed completion order, and stale writes as variants of one question:
29
+
30
+ > Which durable authority proves that the state observed before an action is still valid when the
31
+ > action attempts to commit?
32
+
33
+ For every state-changing path, identify:
34
+
35
+ - the logical business operation;
36
+ - the attempt that is currently executing;
37
+ - the aggregate or resource whose order matters;
38
+ - the state, version, generation, or fence observed before work;
39
+ - the conditional commit that accepts or rejects the result;
40
+ - the stable result returned after duplicate or ambiguous delivery.
41
+
42
+ A mutex, queue, transaction wrapper, cancellation signal, or request-coalescing helper may reduce
43
+ overlap. None of them replaces the durable authority check when work crosses processes, storage,
44
+ leases, retries, or external effects.
45
+
46
+ ## Identity ledger
47
+
48
+ Keep these identities separate:
49
+
50
+ | Identity | Stable scope | Unsafe substitution |
51
+ | --- | --- | --- |
52
+ | operation ID | one business intent | per-attempt request ID |
53
+ | attempt ID | one execution try | operation ID reused as a trace span |
54
+ | message or event ID | one delivery artifact | aggregate ID |
55
+ | effect ID | one externally visible effect | worker or process ID |
56
+ | aggregate ID | one ordering domain | tenant-wide global key by default |
57
+ | sequence or version | one aggregate authority revision | wall-clock timestamp |
58
+ | generation | one latest-result admission domain | cancellation state |
59
+ | fencing token | one lease or ownership generation | boolean lock-held flag |
60
+
61
+ Generate the operation ID outside retry loops and propagate it through request, durable operation
62
+ record, inbox or outbox, provider call, result lookup, and response replay. A new attempt gets a new
63
+ attempt ID while retaining the operation ID.
64
+
65
+ Bind an idempotency claim to actor, tenant, operation type, target aggregate, and a canonical
66
+ semantic payload hash. Reusing one key with a different binding is a conflict, not a duplicate
67
+ success and not a new operation.
68
+
69
+ ## Atomic duplicate admission
70
+
71
+ Make duplicate admission a storage decision:
72
+
73
+ - require the operation key where the contract requires idempotency;
74
+ - make the durable uniqueness field non-null;
75
+ - enforce uniqueness at the authoritative store;
76
+ - store the semantic payload hash and binding fields with the claim;
77
+ - insert the claim and apply the local business mutation in one atomic boundary when both live in
78
+ the same transactional store;
79
+ - distinguish an existing matching claim from an existing conflicting claim;
80
+ - persist the replayable outcome or stable status lookup contract.
81
+
82
+ Do not record only "seen" before applying the local mutation unless a durable recovery owner can
83
+ prove and finish the missing work. Do not apply the mutation and record "seen" later unless repeat
84
+ application is independently safe.
85
+
86
+ ## Ordering scope
87
+
88
+ Name the smallest domain that actually requires order. Common domains are one order, account,
89
+ document, device, session, subscription, or resource owner. A global ordering key can create an
90
+ avoidable bottleneck; unrelated aggregates usually do not need serialization.
91
+
92
+ Transport order is evidence only within the broker's documented grouping or partition boundary.
93
+ It does not prove:
94
+
95
+ - one aggregate always maps to the same group;
96
+ - producers cannot send conflicting sequence values;
97
+ - redelivery cannot repeat an older event;
98
+ - consumers apply effects in delivery order;
99
+ - external effects complete in send order.
100
+
101
+ Record the aggregate key derivation and test hot-key behavior as the cost of the chosen ordering
102
+ scope, not as an excuse to silently weaken correctness.
103
+
104
+ ## Causal tokens and gaps
105
+
106
+ Use a token created for ordering, such as an aggregate version, store revision, generation, or
107
+ fencing token. Do not infer causality from wall-clock timestamps, retry timestamps, arrival time,
108
+ or auto-increment identifiers.
109
+
110
+ For an incoming aggregate sequence, define all three branches:
111
+
112
+ | Incoming relation | Required decision |
113
+ | --- | --- |
114
+ | older than or equal to applied authority | dedupe, replay, or reject without regression |
115
+ | exactly next | apply through a conditional authority update |
116
+ | ahead with a gap | buffer, quarantine, or refresh authoritative state before deciding |
117
+
118
+ Do not silently skip a gap and call the aggregate current. Bound buffers and retries, name the
119
+ resynchronization owner, and expose stuck-gap age.
120
+
121
+ ## Stale completion rejection
122
+
123
+ Carry the observed authority token to the final write. Make the authoritative store accept the
124
+ result only when the expected state, version, generation, ownership fence, and other business
125
+ preconditions still hold.
126
+
127
+ Treat zero affected rows or a failed compare-and-swap as a stale-decision result. It is not enough
128
+ to retry the same calculation blindly. Re-read current authority, decide whether the operation is
129
+ already satisfied, invalid, superseded, compensatable, or eligible for a new calculation, and then
130
+ use a new attempt under the same logical operation when appropriate.
131
+
132
+ Put irreversible side effects behind durable intent or effect records when the store cannot reject
133
+ the side effect itself. Use stable effect IDs and lookup-before-retry for ambiguous outcomes.
134
+
135
+ ## UI and asynchronous completion
136
+
137
+ Cancellation requests resource cleanup; it does not revoke already completed callbacks, cache
138
+ writes, state commits, or external effects. Use a generation token or expected-state token at every
139
+ state surface that can accept a late result.
140
+
141
+ Review UI state, client cache, server state, and external effects separately. Blocking a stale UI
142
+ render does not prove a stale cache update or server mutation was blocked.
143
+
144
+ ## External effects and settlement
145
+
146
+ When local state and another system commit independently:
147
+
148
+ - record local business state and an outbox or effect intent atomically;
149
+ - make relays and consumers tolerate repeat delivery;
150
+ - record inbox admission and local application atomically when one store owns both;
151
+ - settle or acknowledge delivery only after the authoritative local outcome is durable;
152
+ - preserve the same operation and effect identity across ambiguous retries;
153
+ - look up a provider result before replaying an effect whose request may have succeeded.
154
+
155
+ An outbox closes one local commit-to-publish loss window. It does not make consumers idempotent or
156
+ make external providers part of the local transaction.
157
+
158
+ ## Locks and request coalescing
159
+
160
+ Treat process-local single-flight and request coalescing as load controls. They lose authority at
161
+ process, instance, restart, failover, and leader-change boundaries.
162
+
163
+ Treat leases and distributed locks as admission controls. A paused old owner may resume after a
164
+ lease expires, so authoritative writes still need a fencing token or another monotonic ownership
165
+ check. If the destination cannot check the fence, state that the lock reduces overlap but does not
166
+ prove stale-writer exclusion.
167
+
168
+ ## Commutative operations and ledgers
169
+
170
+ Before imposing order, ask whether the mutation can become an immutable operation with a stable
171
+ operation ID. Appending independently identified deltas, facts, or set members can reduce ordering
172
+ sensitivity compared with replacing a whole snapshot.
173
+
174
+ Commutativity does not remove duplicate risk. Deduplicate the operation identity, define reversal
175
+ as another identified operation, and reconcile derived totals or projections against the immutable
176
+ source.
177
+
178
+ ## Transaction traps
179
+
180
+ Escalate these cases to `transaction-boundary-integrity-review`:
181
+
182
+ - existence check followed by insert without a durable unique constraint;
183
+ - read-modify-write that can lose a concurrent update;
184
+ - a multi-row invariant vulnerable to write skew;
185
+ - an absent-row lock that protects no future row;
186
+ - an isolation assumption not matched to the engine and statement shape;
187
+ - retrying only the failed statement instead of the complete read-decision-write action;
188
+ - executing an external effect inside a transaction callback that may rerun;
189
+ - assuming syntactically similar upsert operations have identical concurrency semantics;
190
+ - using queue-claiming skip behavior as a general consistent-read mechanism.
191
+
192
+ ## Adversarial tests
193
+
194
+ Define a forbidden outcome before choosing a harness. Cover the smallest relevant set:
195
+
196
+ - the same operation delivered twice sequentially and concurrently;
197
+ - one key reused with a different semantic payload;
198
+ - a later aggregate version applied before an earlier version;
199
+ - a missing-version gap and bounded resynchronization;
200
+ - two attempts reading the same authority before either writes;
201
+ - a stale worker completing after a newer owner or generation;
202
+ - request delivered but response lost;
203
+ - local commit followed by process death before response or settlement;
204
+ - external effect accepted followed by lost response;
205
+ - outbox publication repeated before its completion marker;
206
+ - lock or lease expiry during a process pause;
207
+ - shutdown with in-flight work and subsequent recovery.
208
+
209
+ Use deterministic barriers or controlled schedules around read, decision, commit, publish, effect,
210
+ and settlement boundaries. Preserve the input, operation identity, actor decisions, schedule or
211
+ fault plan, and forbidden outcome. Hand schedule exploration, memory ordering, linearizability,
212
+ and sanitizer work to `race-condition-review`.
213
+
214
+ ## Reconciliation invariants
215
+
216
+ Name an invariant that detects silent convergence failures, such as:
217
+
218
+ - at most one terminal effect for one operation identity;
219
+ - every acknowledged operation has a durable outcome;
220
+ - every completed operation has its required result or effect receipt;
221
+ - aggregate version never regresses;
222
+ - every applied effect has one originating operation;
223
+ - immutable ledger entries and derived totals agree;
224
+ - stale, conflicting, or gap-blocked work remains visible to a recovery owner.
225
+
226
+ Record the reconciliation owner, cadence or trigger, repair authority, quarantine path, and maximum
227
+ unowned age. Reconciliation is a protocol component, not a dashboard note.
228
+
229
+ ## AI-generated code review
230
+
231
+ Reject these patterns unless durable evidence closes the named gap:
232
+
233
+ - a concurrent collection around a multi-step check-then-act operation;
234
+ - one atomic field standing in for a multi-field invariant;
235
+ - different lock instances guarding the same shared fact;
236
+ - a lock held across callbacks, waits, or external I/O without stale-result validation;
237
+ - fire-and-forget work with no join, failure, shutdown, or recovery owner;
238
+ - an idempotency key generated inside a retry callback;
239
+ - cancellation described as rollback;
240
+ - timestamps used for latest-wins authority;
241
+ - a transaction context assumed to cross a helper or background boundary without connection
242
+ evidence;
243
+ - a concurrency test whose operations never actually overlap;
244
+ - local lock order that conflicts with another entry point;
245
+ - ordinary unit tests or a quiet race detector presented as complete logical-race proof.
246
+
247
+ ## Skill handoffs
248
+
249
+ - Use `transaction-boundary-integrity-review` for database isolation, lock targets, constraints,
250
+ commit behavior, and full-transaction retries.
251
+ - Use `queue-processing-integrity-review` for broker settlement, visibility, rebalance, poison
252
+ messages, ordering configuration, and shutdown drain.
253
+ - Use `dual-write-consistency` for independently committed local and external systems.
254
+ - Use `race-condition-review` for deterministic interleavings, happens-before evidence, memory
255
+ ordering, linearizability, and schedule replay.
256
+ - Use `two-phase-transition-integrity-review` when admission and commit form an explicit durable
257
+ transition protocol with recovery ownership.
258
+ - Use `execution-ledger-integrity-review` when attempts, effects, receipts, and terminal outcomes
259
+ require append-only execution truth.
@@ -0,0 +1,329 @@
1
+ ---
2
+ mustflow_doc: skill.input-boundary-validation-review
3
+ locale: en
4
+ canonical: true
5
+ revision: 1
6
+ lifecycle: mustflow-owned
7
+ authority: procedure
8
+ name: input-boundary-validation-review
9
+ description: Apply this skill when untrusted bytes, text, URL components, headers, query parameters, JSON, XML, YAML, CSV, identifiers, filenames, filters, sort keys, template values, process arguments, database inputs, or structured payloads are created, changed, reviewed, debugged, or reported and safety depends on strict decoding, field-specific canonicalization, duplicate handling, type coercion, full parsing, semantic validation, authorization handoff, resource budgets, or separation of data from executable grammar.
10
+ metadata:
11
+ mustflow_schema: "1"
12
+ mustflow_kind: procedure
13
+ pack_id: mustflow.core
14
+ skill_id: mustflow.core.input-boundary-validation-review
15
+ command_intents:
16
+ - changes_status
17
+ - changes_diff_summary
18
+ - lint
19
+ - build
20
+ - test_related
21
+ - test
22
+ - test_audit
23
+ - docs_validate_fast
24
+ - test_release
25
+ - mustflow_check
26
+ ---
27
+
28
+ # Input Boundary Validation Review
29
+
30
+ <!-- mustflow-section: purpose -->
31
+ ## Purpose
32
+
33
+ Review input validation as one representation pipeline from untrusted bytes to a structured sink.
34
+ Prevent two layers from approving and executing different values, and prevent a syntactically valid
35
+ value from becoming authority or executable grammar by accident.
36
+
37
+ The security boundary is not a list of bad strings. It is an explicit chain such as raw bytes,
38
+ strict decode, field-specific canonical form, one parser, typed value, semantic validation,
39
+ authorization, and a structure-preserving execution API.
40
+
41
+ <!-- mustflow-section: use-when -->
42
+ ## Use When
43
+
44
+ - A request, message, file, environment value, queue payload, webhook, import, or stored value crosses
45
+ byte, character, normalization, parsing, schema, type, authorization, or execution boundaries.
46
+ - Code decodes percent escapes, content encodings, UTF-8, JSON escapes, form values, IDNA names,
47
+ base64, compression, archives, or another nested representation.
48
+ - A field uses allowlists, denylists, regular expressions, sanitization, coercion, defaults, Unicode
49
+ normalization, case folding, duplicate-key policy, unknown-field policy, or parser recovery.
50
+ - SQL, NoSQL, process, path, URL, header, template, expression, query-language, or spreadsheet output
51
+ safety depends on keeping user data out of grammar positions.
52
+ - JSON, XML, YAML, CSV, regular expressions, multipart data, or another parser accepts hostile or
53
+ expanding input and needs full-consumption and resource-budget review.
54
+ - A validation, canonicalization, injection-resistance, parser-differential, or input-safety claim
55
+ needs current implementation and denial-case evidence.
56
+
57
+ <!-- mustflow-section: do-not-use-when -->
58
+ ## Do Not Use When
59
+
60
+ - The task changes lexer, grammar, CST, AST, recovery, incremental parsing, or parser implementation
61
+ semantics; use `parser-engineering-review` as the primary owner and this skill only for the outer
62
+ application boundary.
63
+ - The task is a general source-to-sink, actor, resource, tenant, or privilege review without a
64
+ representation mismatch; use `security-flow-review`.
65
+ - The task changes the authorization model itself; use `auth-permission-change` or the closest
66
+ access-control skill, then use this skill only for the validated handoff into that decision.
67
+ - The task changes only a caller-facing API request or response contract; use `api-contract-change`
68
+ as the primary owner and this skill only when decoding, canonicalization, coercion, or sink safety
69
+ is material.
70
+ - The task changes only a file-upload lifecycle, archive pipeline, preview, storage, or download
71
+ surface; use `file-upload-security-review` as the primary owner.
72
+ - The task changes only YAML, TOML, frontmatter, or repository configuration semantics; use
73
+ `structured-config-change` as the primary owner.
74
+ - The task needs only abuse-case regression tests after the boundary is understood; use
75
+ `security-regression-tests` for that part.
76
+ - The task asks for live exploit traffic, credential guessing, offensive payload collection, or
77
+ unowned external testing. Stay within defensive code, contracts, safe fixtures, and configured
78
+ verification.
79
+
80
+ <!-- mustflow-section: required-inputs -->
81
+ ## Required Inputs
82
+
83
+ - Entry points, raw transport representation, content encoding, character encoding, parser, schema,
84
+ typed model, semantic rules, authorization call, and final sinks.
85
+ - Every transformation that decodes, normalizes, folds, trims, repairs, defaults, coerces, expands,
86
+ concatenates, serializes, or reparses the value.
87
+ - Field identity policy: display value, comparison key, storage value, allowed character or script
88
+ profile, case sensitivity, normalization form, duplicate policy, and uniqueness owner.
89
+ - Parser policy: dialect, strictness, duplicate and unknown-field behavior, full-consumption rule,
90
+ recovery behavior, scalar and numeric model, and configured resource limits.
91
+ - Sink policy: fixed grammar, permitted dynamic slots, parameter or object binding, path or URL
92
+ construction, process invocation, template context, and authorization scope.
93
+ - Positive, boundary, malformed, ambiguous, duplicate, equivalent, resource-exhaustion, and denial
94
+ fixtures plus configured command intents.
95
+
96
+ Read [input-boundary-security-checklist.md](references/input-boundary-security-checklist.md) when the
97
+ task spans more than one decoder or parser, uses Unicode identity, reaches an executable sink, or
98
+ needs a format-specific resource matrix.
99
+
100
+ <!-- mustflow-section: preconditions -->
101
+ ## Preconditions
102
+
103
+ - Read the nearest instructions and command contract before running project commands.
104
+ - Name the selected repository and the exact boundary under review.
105
+ - Treat framework validation, static types, frontend controls, content-type labels, generated
106
+ clients, and a successful parse as evidence candidates, not proof of end-to-end safety.
107
+ - Record unknown decoder, parser, normalization, collation, or sink behavior instead of guessing.
108
+
109
+ <!-- mustflow-section: allowed-edits -->
110
+ ## Allowed Edits
111
+
112
+ - Strict decoders, field-specific normalizers, duplicate-aware parsers, schemas, DTOs, typed query or
113
+ command compilers, safe sink adapters, resource budgets, denial tests, and directly synchronized
114
+ documentation or templates owned by the selected boundary.
115
+ - Stable error codes and bounded metrics that identify the rejected stage without logging the raw
116
+ hostile or sensitive value.
117
+ - Do not silently broaden accepted syntax, normalize arbitrary display text, delete invalid bytes or
118
+ characters, add a generic sanitizer, or replace a structure-preserving API with string assembly.
119
+ - Do not add offensive corpora, live scanners, dependency installs, background workers, or raw
120
+ command examples under this skill.
121
+
122
+ <!-- mustflow-section: procedure -->
123
+ ## Procedure
124
+
125
+ ### 1. Build a representation ledger
126
+
127
+ Trace one value through every representation:
128
+
129
+ 1. wire or file bytes;
130
+ 2. decompressed or decoded bytes;
131
+ 3. decoded Unicode scalar values;
132
+ 4. field-specific normalized or comparison form;
133
+ 5. parsed tree or typed DTO;
134
+ 6. semantically validated domain value;
135
+ 7. authorization decision input; and
136
+ 8. structure-preserving sink input.
137
+
138
+ For each edge, name the owner, operation, failure behavior, size unit, retained raw form, and whether
139
+ another layer can repeat or reinterpret the operation. The same validated typed value should reach
140
+ authorization and execution; validating one string and reparsing another is a split boundary.
141
+
142
+ ### 2. Decode each protocol layer exactly once
143
+
144
+ - Assign percent decoding, transfer decoding, decompression, charset decoding, escape processing,
145
+ and container extraction to one named layer each. Do not recursively decode until a value "looks
146
+ clean."
147
+ - Use strict decoding for security identifiers and protocol fields. Reject malformed percent escapes,
148
+ invalid UTF-8, overlong sequences, unexpected BOMs, lone surrogates, truncated escapes, trailing
149
+ compressed data, and decoder warnings when the selected format forbids them.
150
+ - Bound raw bytes, decoded bytes, expansion ratio, decoded scalar count, and work before allocating
151
+ or forwarding the expanded representation.
152
+ - Preserve raw evidence separately when diagnostics, signatures, audit, or compatibility require it;
153
+ do not let downstream code reinterpret the raw value after the typed value exists.
154
+
155
+ ### 3. Define canonicalization per field
156
+
157
+ - Separate display value, storage value, and canonical comparison key. A single global
158
+ `normalizeInput` function is not a field policy.
159
+ - Choose NFC, NFKC, case folding, whitespace handling, IDNA processing, script restrictions,
160
+ default-ignorable handling, and confusable detection only where the field's identity semantics
161
+ require them.
162
+ - Apply the selected transformation before allowlist validation, uniqueness, cache keys,
163
+ authorization lookup, signatures, and persistence that depend on equivalence.
164
+ - Make canonicalization deterministic and idempotent. Back canonical uniqueness with the owning
165
+ database index or registry constraint; an application pre-check alone races.
166
+ - Reject invalid values rather than deleting characters. Permit repair only when a documented
167
+ business rule defines the unique repaired value, then validate the repaired result again.
168
+
169
+ ### 4. Parse one complete value under one policy
170
+
171
+ - Use one authoritative parser and configuration for validation and consumption. Pass the parsed
172
+ immutable value forward instead of reparsing the original text in another layer.
173
+ - Require full input consumption. Reject trailing garbage, multiple documents where one is expected,
174
+ warnings, recovery output, unknown encoding switches, and partial-prefix success.
175
+ - Reject duplicate object names and duplicate single-valued parameters before a map or framework
176
+ binding discards their multiplicity. Declare ordered multi-value fields explicitly.
177
+ - Disable implicit string-to-number, number-to-boolean, scalar-to-array, empty-to-null, and runtime
178
+ class binding unless each coercion is part of the public contract and tested at every consumer.
179
+ - Reject unknown fields, schema versions, discriminators, enums, and validation timeouts for
180
+ security-sensitive objects unless an explicit forward-compatibility contract proves they are
181
+ ignored by every downstream consumer.
182
+
183
+ ### 5. Separate syntax, semantics, and authority
184
+
185
+ - Validate syntax with a real parser, enum, or whole-string recognizer. Character allowlists do not
186
+ prove grammar, and substring matches do not prove whole-field validity.
187
+ - Validate semantics against business facts such as range, ordering, state, existence, and allowed
188
+ combinations. Do not turn a parse success into a business-valid claim.
189
+ - Perform authorization with trusted actor and tenant context against the final canonical resource
190
+ identity and action. A valid UUID, tenant id, path, or enum is not permission.
191
+ - Fail closed on unknown fields, unknown versions, missing context, parser disagreement, timeout,
192
+ and unavailable validation for security-sensitive decisions. Do not map validation failure to a
193
+ permissive default.
194
+
195
+ ### 6. Keep data out of executable grammar
196
+
197
+ - Use parameter binding for SQL values. Map dynamic identifiers, sort directions, operators, and
198
+ field selections from typed application enums to fixed code fragments.
199
+ - Build NoSQL, search, filter, and expression trees server-side from a bounded DTO. Do not pass a
200
+ client-owned object or raw query language to the driver.
201
+ - Prefer library APIs over child processes. When a process is unavoidable, fix the executable,
202
+ subcommand, options, environment, working directory, and resource limits in code; pass data as a
203
+ distinct argument, stdin stream, or already-open handle, and account for option injection.
204
+ - Prefer opaque resource IDs and opened handles over client path strings. Resolve under the owning
205
+ filesystem boundary and keep symlink, race, platform alias, and containment policy with the open
206
+ operation rather than a detached prefix check.
207
+ - Keep templates as trusted deployed code and user content as inert values. HTML escaping protects
208
+ an output context; it does not make untrusted template source safe.
209
+
210
+ ### 7. Budget hostile structure before materialization
211
+
212
+ Define a boundary budget with applicable counters for wire bytes, decoded bytes, expanded bytes,
213
+ scalar count, numeric digits, token count, node count, depth, container items, object keys, aliases,
214
+ attributes, text-node length, regular-expression work, output bytes, and deadline.
215
+
216
+ - Charge before allocation, object construction, external fetch, database write, or file effect.
217
+ - Bound breadth and scalar size as well as nesting depth. A shallow million-element array is still
218
+ hostile.
219
+ - Disable parser features that can fetch resources, instantiate runtime objects, execute tags or
220
+ callbacks, include other documents, or expand aliases when the input contract does not need them.
221
+ - Treat streaming as a memory strategy, not permission for unbounded total work or partial effects.
222
+
223
+ ### 8. Delay side effects until acceptance
224
+
225
+ - Do not mutate production state while a document, stream, archive, CSV import, or message is only
226
+ partially parsed or validated.
227
+ - For bounded inputs, parse and validate into an immutable intermediate value before one atomic
228
+ effect. For large inputs, use a bounded staging area and publish only after complete validation.
229
+ - Bind the authorized decision to the exact canonical identity, source version, schema version, and
230
+ typed operation executed. Revalidation against a different representation is not equivalent.
231
+
232
+ ### 9. Build a boundary-focused test matrix
233
+
234
+ Cover applicable pairs and transitions:
235
+
236
+ - valid raw bytes, malformed encoding, truncated escape, invalid BOM, and nested or double encoding;
237
+ - pre-normalized and canonically equivalent forms, compatibility forms, mixed scripts, default
238
+ ignorables, bidi controls, NUL, and length changes after normalization;
239
+ - duplicate keys and parameters, unknown fields, wrong types, coercion candidates, numeric extremes,
240
+ trailing data, multiple documents, and parser warnings;
241
+ - valid grammar positions and rejected attempts to supply operators, identifiers, options, paths,
242
+ templates, or query objects as data;
243
+ - limits immediately below, at, and above every raw, decoded, expanded, structural, numeric, and
244
+ output budget;
245
+ - syntactically valid but semantically invalid values, valid resource identifiers without
246
+ permission, and stale or mismatched schema versions;
247
+ - differential fixtures when gateways, frameworks, databases, caches, or downstream services may
248
+ parse, normalize, collate, or choose duplicates differently.
249
+
250
+ Assert the stable stage and error class, no side effect, and the exact structured sink shape. Do not
251
+ assert only that a generic 400 or exception occurred.
252
+
253
+ ### 10. Implement the narrowest complete correction
254
+
255
+ Fix the earliest owning layer that can make every downstream consumer observe the same accepted
256
+ value. Synchronize schemas, typed models, safe adapters, uniqueness rules, tests, docs, templates,
257
+ and error contracts that describe that boundary. Do not patch only the last sink while another
258
+ consumer still receives the ambiguous representation.
259
+
260
+ ### 11. Verify each claim
261
+
262
+ Use the narrowest configured intents that cover the changed decoder, parser, schema, sink adapter,
263
+ tests, documentation, and installed template. Separate directly executed evidence from code-supported
264
+ inference and unverified runtime behavior.
265
+
266
+ <!-- mustflow-section: postconditions -->
267
+ ## Postconditions
268
+
269
+ - Every transformation from raw input to sink has one owner, one failure policy, and explicit size
270
+ units.
271
+ - Validation, authorization, and execution consume the same canonical typed identity or a proven
272
+ lossless derivation of it.
273
+ - Duplicate, unknown, coercion, full-consumption, normalization, and parser-recovery policies are
274
+ explicit.
275
+ - Dynamic grammar positions are fixed or mapped from typed server-owned choices; user data remains
276
+ data.
277
+ - Hostile input work is bounded before side effects, and denial tests name the rejected stage.
278
+ - Verification records distinguish passed checks, supported inferences, skipped checks, and
279
+ remaining representation or sink risk.
280
+
281
+ <!-- mustflow-section: verification -->
282
+ ## Verification
283
+
284
+ Use configured oneshot command intents when available:
285
+
286
+ - `changes_status`
287
+ - `changes_diff_summary`
288
+ - `lint`
289
+ - `build`
290
+ - `test_related`
291
+ - `test`
292
+ - `test_audit`
293
+ - `docs_validate_fast`
294
+ - `test_release`
295
+ - `mustflow_check`
296
+
297
+ Prefer focused denial, differential, and resource-boundary tests. Use `security-regression-tests`
298
+ when creating abuse-case coverage, and `parser-engineering-review` when the parser implementation
299
+ itself changes.
300
+
301
+ <!-- mustflow-section: failure-handling -->
302
+ ## Failure Handling
303
+
304
+ - If two layers decode, normalize, parse, collate, or choose duplicate values differently, stop the
305
+ safety claim and identify which representation reaches authorization and the sink.
306
+ - If the accepted syntax, identity policy, schema version, collation, or forward-compatibility rule
307
+ is unknown, preserve current behavior and report the smallest missing decision.
308
+ - If a parser feature cannot be disabled or bounded, isolate or remove that input path rather than
309
+ claiming validation makes it safe.
310
+ - If a safe structured API cannot express the required operation, redesign the external DTO or
311
+ isolate a fixed compiler; do not fall back to escaping arbitrary executable text.
312
+ - If a configured verification fails, activate the applicable failure-triage procedure and do not
313
+ broaden the change until the failure is classified.
314
+ - If verification requires live attack traffic, production data, credentials, or an unconfigured
315
+ long-running scanner, skip it and report the remaining evidence gap.
316
+
317
+ <!-- mustflow-section: output-format -->
318
+ ## Output Format
319
+
320
+ - Input boundary and representation ledger
321
+ - Decoder, canonicalization, duplicate, coercion, parser, schema, and budget decisions
322
+ - Syntax, semantic, authorization, and sink separation
323
+ - Safe API or typed compiler decision
324
+ - Files changed and compatibility behavior preserved or intentionally changed
325
+ - Positive, malformed, equivalent, differential, denial, and resource-boundary evidence
326
+ - Configured command intents and results
327
+ - Skipped checks and reasons
328
+ - Remaining representation, parser, authorization-handoff, or sink risk
329
+