mustflow 2.18.21 → 2.21.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/commands/classify.js +2 -3
- package/dist/cli/commands/doctor.js +46 -6
- package/dist/cli/commands/run/output.js +1 -1
- package/dist/cli/commands/run/receipt.js +1 -0
- package/dist/cli/commands/verify.js +7 -8
- package/dist/cli/i18n/en.js +1 -0
- package/dist/cli/i18n/es.js +1 -0
- package/dist/cli/i18n/fr.js +1 -0
- package/dist/cli/i18n/hi.js +1 -0
- package/dist/cli/i18n/ko.js +1 -0
- package/dist/cli/i18n/zh.js +1 -0
- package/dist/cli/lib/local-index/index.js +3 -3
- package/dist/cli/lib/repo-map.js +3 -2
- package/dist/cli/lib/run-plan.js +8 -4
- package/dist/core/check-issues.js +1 -1
- package/dist/core/command-contract-validation.js +24 -10
- package/dist/core/command-output-limits.js +2 -1
- package/dist/core/line-endings.js +12 -4
- package/dist/core/repeated-failure.js +3 -3
- package/dist/core/run-performance-history.js +4 -4
- package/dist/core/run-profile.js +2 -3
- package/dist/core/run-receipt.js +11 -3
- package/dist/core/run-write-drift.js +60 -12
- package/dist/core/safe-filesystem.js +155 -0
- package/package.json +1 -1
- package/schemas/commands.schema.json +1 -0
- package/schemas/doctor-report.schema.json +23 -1
- package/schemas/run-receipt.schema.json +6 -2
- package/templates/default/i18n.toml +13 -13
- package/templates/default/locales/en/.mustflow/skills/INDEX.md +13 -13
- package/templates/default/locales/en/.mustflow/skills/adapter-boundary/SKILL.md +72 -4
- package/templates/default/locales/en/.mustflow/skills/command-contract-authoring/SKILL.md +16 -10
- package/templates/default/locales/en/.mustflow/skills/command-pattern/SKILL.md +64 -7
- package/templates/default/locales/en/.mustflow/skills/database-change-safety/SKILL.md +249 -16
- package/templates/default/locales/en/.mustflow/skills/dependency-reality-check/SKILL.md +37 -7
- package/templates/default/locales/en/.mustflow/skills/migration-safety-check/SKILL.md +74 -10
- package/templates/default/locales/en/.mustflow/skills/performance-budget-check/SKILL.md +132 -5
- package/templates/default/locales/en/.mustflow/skills/pure-core-imperative-shell/SKILL.md +12 -5
- package/templates/default/locales/en/.mustflow/skills/result-option/SKILL.md +4 -2
- package/templates/default/locales/en/.mustflow/skills/security-privacy-review/SKILL.md +112 -29
- package/templates/default/locales/en/.mustflow/skills/state-machine-pattern/SKILL.md +17 -4
- package/templates/default/locales/en/.mustflow/skills/structure-discovery-gate/SKILL.md +193 -2
- package/templates/default/manifest.toml +1 -1
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
mustflow_doc: skill.security-privacy-review
|
|
3
3
|
locale: en
|
|
4
4
|
canonical: true
|
|
5
|
-
revision:
|
|
5
|
+
revision: 16
|
|
6
6
|
lifecycle: mustflow-owned
|
|
7
7
|
authority: procedure
|
|
8
8
|
name: security-privacy-review
|
|
9
|
-
description: Apply this skill when code, configuration, docs, templates, logs, telemetry, credentials, data flows, AI-generated code, authentication, authorization, network calls, dependencies, cryptography, secure transport, agent configuration, or release surfaces affect secrets, personal data, retention, or external disclosure.
|
|
9
|
+
description: Apply this skill when code, configuration, docs, templates, logs, telemetry, traces, baggage, behavior analytics, core events, credentials, data flows, data residency policy, region or processing-location claims, AI-generated code, AI prompts outputs usage cost records budgets policies or cache keys, authentication, authorization, server-side permission checks, admin operations, audit logs, file uploads or downloads, signed URLs, API responses, cache policy, cache-as-authority decisions, claim or policy data, comparison or affiliate data, user-generated content, webhooks, job queues, search logs, analytics SaaS exports, external API call records, network calls, dependencies, runtime security patch policy, third-party terms or data-use promises, cryptography, secure transport, agent configuration, or release surfaces affect secrets, personal data, retention, access control, vendor disclosure, or external disclosure.
|
|
10
10
|
metadata:
|
|
11
11
|
mustflow_schema: "1"
|
|
12
12
|
mustflow_kind: procedure
|
|
@@ -33,8 +33,25 @@ Catch security, privacy, and disclosure risks introduced by ordinary code, docum
|
|
|
33
33
|
- A change touches authentication, authorization, sessions, admin behavior, tenant boundaries, personal data, secrets, tokens, credentials, API keys, or private files.
|
|
34
34
|
- A change comes from AI-generated code, vibe-coded output, copied examples, or a broad assistant patch that may have optimized for the happy path without proving abuse boundaries.
|
|
35
35
|
- A change adds or modifies logging, telemetry, diagnostics, receipts, reports, caches, generated state, retention, redaction, export, or external transmission.
|
|
36
|
+
- A change adds or modifies behavior analytics events, event schemas, page views, clicks, searches, impressions, scroll data, experiments, attribution, request traces, or observability data that may include personal data or sensitive context.
|
|
37
|
+
- A change stores, forwards, exports, or relies on logs, search query logs, click logs, product events, billing events, job events, audit records, analytics SaaS events, email platform tags, or provider dashboard data to explain security, privacy, billing, entitlement, or customer-support behavior.
|
|
38
|
+
- A change propagates telemetry context, trace context, baggage, request ids, user ids, provider ids, job metadata, webhook metadata, or observability attributes across service, queue, worker, cron, webhook, browser, or external API boundaries.
|
|
39
|
+
- A tool, platform, model provider, analytics service, observability vendor, authentication provider, file store, or automation service has data retention, data training, commercial-use, export, API-limit, account-suspension, or unilateral terms-change implications for user data or service continuity.
|
|
40
|
+
- A cloud, database, file store, logging backend, analytics tool, support tool, payment system, or AI provider choice affects where customer content, personal data, backups, logs, prompts, usage metadata, billing metadata, or support-access data is stored or processed.
|
|
41
|
+
- A runtime, framework, dependency, or platform choice affects supported-version policy, end-of-life exposure, security patch timing, scanner coverage, deployment smoke tests, or rollback expectations.
|
|
42
|
+
- A change touches administrator operations such as publishing, slug or redirect changes, canonical or robots changes, SEO updates, filter definition updates, advertisement policy, cache purge, search reindexing, ranking refresh, role changes, or audit-log snapshots.
|
|
43
|
+
- A change touches legal, policy, privacy, finance, health, comparison, ranking, price, eligibility, affiliate, or high-risk factual claims that need source, reviewer, jurisdiction, effective-date, or human-approval boundaries.
|
|
44
|
+
- A change touches identity, consent, editorial, catalog, community, analytics, billing, messaging, or audit data ownership boundaries, including account deletion, anonymization, export, or retention behavior.
|
|
45
|
+
- A change touches comments, reviews, reports, user-submitted links, affiliate links, sponsored links, public rankings, or user-generated content moderation.
|
|
46
|
+
- A change touches shared caches, CDN caching, cache-control headers, cache keys, cache tags, private or personalized responses, admin responses, search endpoints, or public cache purge endpoints.
|
|
47
|
+
- A change uses cache, Redis, generated state, search documents, or read models to make authorization, ownership, subscription, entitlement, payment, inventory, or admin decisions.
|
|
36
48
|
- A change adds external URL fetching, webhook callbacks, redirects, browser previews, remote downloads, database-as-a-service rules, security headers, CORS, CSRF handling, or rate limits.
|
|
49
|
+
- A change stores webhook payloads, external API requests or responses, retry errors, dead-letter jobs, AI prompts or outputs, email bodies, or provider diagnostic data.
|
|
50
|
+
- A change records AI usage, model pricing, token counts, cache keys, feature metadata, prompt hashes, provider call metadata, retry cost, or failed AI calls that could include confidential content or identify users.
|
|
51
|
+
- A change records AI budgets, feature policies, policy decisions, blocked reasons, model downgrades, agent steps, tool calls, provider budget status, or emergency disables that could reveal customer behavior, sensitive feature use, or regulated processing.
|
|
37
52
|
- A change touches cookies, JWTs, reset tokens, invite tokens, OAuth callbacks, file upload or download, browser storage, business rules, pricing, entitlements, database queries, ORM bulk operations, or deployment configuration.
|
|
53
|
+
- A change relies on frontend role checks, hidden buttons, client-provided `userId`, `workspaceId`, `role`, `price`, `status`, or `isAdmin`, or direct API calls that need server-side resource authorization.
|
|
54
|
+
- A change returns API responses that may expose raw database rows, internal ids, storage keys, permanent private file URLs, password hashes, billing provider ids, internal notes, last login IPs, or other fields not required by the caller.
|
|
38
55
|
- A change touches cryptography, password hashing, token generation, random number generation, TLS/HTTPS, certificate validation, scanner gates, or a security invariant that could drift across architecture boundaries.
|
|
39
56
|
- A change adds, imports, recommends, or installs third-party dependencies that may affect the software supply chain.
|
|
40
57
|
- A change introduces or edits agent configuration, MCP/tool configuration, prompt files, model instructions, or repository-local rule files.
|
|
@@ -59,9 +76,24 @@ Catch security, privacy, and disclosure risks introduced by ordinary code, docum
|
|
|
59
76
|
- Changed files, diff summary, and the user goal.
|
|
60
77
|
- Sensitive data, actor, trust boundary, storage, logging, retention, export, or external disclosure surfaces involved.
|
|
61
78
|
- Actor, resource owner, tenant boundary, server-side authorization rule, state-changing route, external network target, dependency source, and agent/tool permission surface involved.
|
|
79
|
+
- Read, list, search, update, delete, upload, attach, download, invite, billing, and admin actions affected, including whether the server scopes each action by actor, owner, workspace, organization, team, role, or capability.
|
|
62
80
|
- Cookie, JWT, OAuth, file upload, file download, business-value, database mutation, ORM bulk operation, CI/CD permission, deployment setting, or secret-source surface involved.
|
|
63
81
|
- Cryptographic primitive, password hashing, random-token, secure transport, certificate validation, scanner gate, or security invariant involved.
|
|
64
82
|
- Existing project rules for secrets, privacy, generated state, public docs, package contents, and command output.
|
|
83
|
+
- Admin operation list, role or capability model, audit-log fields, cache visibility policy, and cache invalidation surface when those are involved.
|
|
84
|
+
- Behavior analytics event names, event versions, actor identifiers, anonymous identifiers, properties, retention period, deletion or anonymization policy, and whether event writes can be delayed or lost.
|
|
85
|
+
- Core event ownership, including which signup, login failure, account recovery, payment, refund, subscription, entitlement, permission, file, search, admin, webhook, queue, and security events must remain internally stored instead of only in a SaaS dashboard.
|
|
86
|
+
- Observability identifier policy, including request id, trace id, span id, user or anonymous id, tenant or organization id, job run id, webhook event id, baggage fields, retention period, external propagation, redaction, and whether identifiers can be tied back to direct personal data.
|
|
87
|
+
- Third-party data-use and operational terms that affect privacy or continuity, including retention, training use, export availability, commercial-use limits, API-limit changes, account suspension, deletion guarantees, and whether sensitive operational features are gated behind a plan.
|
|
88
|
+
- Data residency and processing-location policy, including home region, storage region, backup region, log region, analytics region, AI processing region, support-tool region, payment or tax data region, disaster-recovery replica region, deletion expectations, and whether provider system data is outside customer-content residency guarantees.
|
|
89
|
+
- Data classification policy when available, including sensitive personal data, ordinary personal data, product usage data, public content, AI prompts or outputs, and which classes may enter logs, analytics, support tools, AI providers, or cross-region backups.
|
|
90
|
+
- Runtime and dependency patch policy, including supported or LTS version requirement, end-of-life ban, lockfile expectation, vulnerability scan source, patch response target, smoke-test surface, canary or rollback route, and whether experimental runtime choices are kept off survival paths.
|
|
91
|
+
- Webhook and external-call record policy, including signature verification, processed-event deduplication, safe request hashes, redacted provider responses, unknown-result reconciliation, dead-letter retention, and whether raw payloads are needed or should be replaced by bounded metadata.
|
|
92
|
+
- AI record policy, including prompt and output retention, cache-key hashing, provider request id handling, feature-key properties, pricing snapshots, token usage, failed-call errors, user or account identifiers, and whether raw prompts or generated text are omitted, redacted, encrypted, or retained under a narrow rule.
|
|
93
|
+
- AI budget and gateway policy, including whether provider budgets are hard stops or only alerts, whether product-owned hard limits exist, which identifiers are recorded for user, organization, feature, model, request, provider call, policy decision, and whether blocked or downgraded decisions are logged without exposing prompt text.
|
|
94
|
+
- Cache authority boundary, including which data is final source of truth and which values are disposable, stale, private, or shared.
|
|
95
|
+
- Claim or policy registry fields, source reference, jurisdiction, risk tier, review owner, effective date, comparison methodology, affiliate relationship, user-generated link policy, and human approval path when those are involved.
|
|
96
|
+
- Data-domain owner for identity, consent, editorial, catalog, community, analytics, billing, messaging, and audit records, plus deletion, anonymization, export, and retention expectations when personal data is involved.
|
|
65
97
|
- Relevant command-intent contract entries for status, diff, docs, release, or mustflow validation.
|
|
66
98
|
- Any repository-controlled names, paths, symlinks, command strings, environment path entries, workflow actions, or package contents that cross a trust boundary.
|
|
67
99
|
- Scanner name, rule identifier, alert location, severity, data-flow evidence, and whether the alert is fixable in code or requires repository settings.
|
|
@@ -88,35 +120,71 @@ Catch security, privacy, and disclosure risks introduced by ordinary code, docum
|
|
|
88
120
|
1. Identify the sensitive surface: secret, personal data, actor, permission, storage location, log, generated artifact, package file, public document, or external recipient.
|
|
89
121
|
2. Decide whether the change creates, stores, reads, transforms, logs, exports, deletes, or reports sensitive information.
|
|
90
122
|
3. Check whether the changed surface is public, packaged, generated, cached, retained, user-visible, or sent outside the repository boundary.
|
|
91
|
-
4. Treat AI-generated code as untrusted until the protected resource, actor, ownership rule, and denied case are inspected. UI-only hiding, client-side role checks, and passing happy-path flows do not prove server-side authorization.
|
|
123
|
+
4. Treat AI-generated code as untrusted until the protected resource, actor, ownership rule, and denied case are inspected. UI-only hiding, client-side role checks, hidden buttons, and passing happy-path flows do not prove server-side authorization.
|
|
92
124
|
5. For each read, write, update, delete, export, or admin route, confirm the server-side query or policy binds the session actor to the target resource owner, tenant, role, or capability.
|
|
93
125
|
6. Do not stop at "is logged in". Separate authentication from authorization, then inspect tenant, workspace, organization, team, owner, role, and guest filters on both reads and writes.
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
126
|
+
- Treat client-provided actor ids, role names, workspace ids, plan names, prices, discounts, entitlement flags, and status values as untrusted input. Derive trusted actor and tenant context from server-side authentication and membership checks.
|
|
127
|
+
- Check list, search, detail, attachment, export, and download paths as carefully as mutation paths. Read access is still data access.
|
|
128
|
+
- Reject mass assignment. Server code should allowlist mutable fields instead of passing raw request bodies into database updates where privileged fields could be set by the client.
|
|
129
|
+
7. For high-impact admin operations, require a server-side capability or role check, actor attribution, target identity, reason or change note where useful, before/after evidence, and a rollback, preview, or recovery path proportionate to the impact.
|
|
130
|
+
High-impact examples include publish/unpublish, slug change, redirect change, canonical change, robots or sitemap change, filter definition change, advertisement slot or policy change, cache purge, search reindex, ranking refresh, bulk edit, and role or permission change.
|
|
131
|
+
8. For high-risk content claims, require source attribution, jurisdiction or market, effective date, verification date, risk tier, review owner, affected-content lookup, and human approval before publication when the domain is legal, privacy, finance, health, safety, eligibility, pricing, ranking, comparison, or compliance.
|
|
132
|
+
9. For comparison, ranking, review, affiliate, and sponsored content, check that methodology, evidence, affiliate relationship, outbound-link policy, and editorial responsibility are explicit. Do not let paid placement, sponsored links, or user-generated links look like ordinary editorial links.
|
|
133
|
+
10. For database and ORM changes, check for unscoped `findMany`, `updateMany`, `deleteMany`, mass assignment of `role`, `price`, `ownerId`, `isPaid`, or similar privileged fields, unsafe migration defaults, and missing row-level or policy-based access controls where the platform supports them.
|
|
134
|
+
11. For personal data ownership, confirm that analytics, content, community, billing, messaging, and audit records do not store direct identifiers they do not need. Prefer anonymous ids or internal ids, and keep email, phone, payment, and consent details inside their owning boundaries.
|
|
135
|
+
12. For behavior analytics, logs, traces, metrics, and event streams, check that direct identifiers, sensitive form values, raw request bodies, payment data, access tokens, cookies, session ids, and confidential user content are omitted unless a narrow product rule and retention path exist.
|
|
136
|
+
- For trace context and baggage, assume propagated fields can cross service and external API boundaries. Keep values to opaque internal ids, hashes, or low-sensitivity correlation data; do not propagate email, names, phone numbers, JWTs, session tokens, payment customer ids, raw provider ids, raw prompts, uploaded document text, or private file names.
|
|
137
|
+
- Keep request ids and trace ids useful for debugging without making them account identifiers. User, organization, and tenant ids should be internal or anonymized when they leave the protected boundary.
|
|
138
|
+
- Treat search queries, clicked result ids, failed login reasons, webhook errors, queue errors, and support diagnostic properties as sensitive by default when they can reveal private user intent, file names, customer state, security posture, or business disputes.
|
|
139
|
+
- Do not rely on analytics or observability SaaS as the only copy of events needed for security review, customer support, billing disputes, entitlement history, file deletion, or administrator accountability.
|
|
140
|
+
- Check storage and processing location separately for primary data, backups, logs, analytics events, support tools, AI prompts, AI outputs, AI usage metadata, payment metadata, and disaster-recovery copies. A database region alone does not prove the full privacy boundary.
|
|
141
|
+
- Treat provider data residency claims narrowly. Customer content location, inference location, logs, account metadata, usage metadata, billing metadata, abuse monitoring, and support access may follow different policies.
|
|
142
|
+
13. Separate behavior analytics from audit logs. Behavior analytics may be delayed, sampled, or partly lossy; audit logs for administrator, permission, payment, publication, privacy, security, and destructive operations should preserve actor, target, action, reason, bounded before/after evidence, and retention expectations.
|
|
143
|
+
14. For account deletion, export, anonymization, consent withdrawal, and retention behavior, check each data area separately. Billing, audit, community content, analytics, messaging, and identity records may need different deletion or retention actions; do not claim one delete flag covers them all.
|
|
144
|
+
15. For user-generated content, comments, reports, and public profile data, check moderation status, edit and delete history, parent-child deletion behavior, spam or abuse handling, report workflow, and whether user-submitted links are qualified safely.
|
|
145
|
+
16. For state-changing routes that rely on cookies or browser credentials, check CSRF, origin, CORS, same-site, and rate-limit behavior instead of assuming the framework default is active.
|
|
146
|
+
17. For session and token behavior, check cookie flags, JWT verification instead of decode-only logic, expiration, issuer and audience validation, reset or invite token entropy and lifetime, server-side revocation, logout invalidation, and reauthentication before sensitive account or payment changes.
|
|
147
|
+
18. For shared cache behavior, verify that admin, authenticated, personalized, tenant-scoped, or otherwise private responses cannot be stored in a shared cache. Prefer `no-store` for admin or sensitive responses and private-cache behavior only when the data is safe for the user's own browser cache.
|
|
148
|
+
19. For cache-backed decisions, verify that cache cannot become the only unchecked authority for permissions, ownership, subscription, entitlement, payment, inventory, or destructive admin actions unless it is intentionally operated as a durable state store with a fail-closed policy.
|
|
149
|
+
20. For cache purge, search reindex, ranking refresh, and generated-state rebuild endpoints, treat them as privileged state-changing operations with authorization, rate limiting, audit logs, idempotency, and bounded target selection.
|
|
150
|
+
21. For external URL, webhook, preview, redirect, download, or callback behavior, check allowlists, protocol restrictions, redirect handling, DNS/IP re-resolution, private network ranges, link-local metadata endpoints, webhook signatures, timeout limits, retry limits, and open redirect parameters such as `next` or `redirect`.
|
|
151
|
+
- For webhooks, verify the signature against the raw body before trusting parsed data. Store only the raw body reference or bounded raw payload when replay, verification, or support needs justify it.
|
|
152
|
+
- Store processed event identifiers to avoid duplicate effects. Keep provider event payloads, request bodies, and response bodies out of ordinary logs and dead-letter records unless they are redacted and have a retention rule.
|
|
153
|
+
22. For database-as-a-service, storage bucket, or realtime rules, check that server-side policies are default-deny, ownership-scoped, and not left in public read/write development mode.
|
|
154
|
+
23. For input sinks, check parameterized queries, ORM binding, static command maps, output encoding, HTML/Markdown rendering boundaries, unsafe dynamic evaluation, XML/YAML/Markdown parser options, redirect and sort parameters, page-size limits, and framework escape hatches.
|
|
155
|
+
24. For file upload and download, check MIME and content signatures, size limits, storage outside executable web roots, SVG/HTML/PDF rendering rules, image or document metadata, filename controls, Unicode confusion, path traversal, download authorization, and resource limits for resizing, archive extraction, or document conversion.
|
|
156
|
+
- Prefer server-generated asset ids or hash-like storage keys over user filenames in storage paths. Keep original filenames as metadata only.
|
|
157
|
+
- For private files, avoid returning permanent public URLs or raw storage keys. Recheck authorization before issuing a short-lived signed download URL.
|
|
158
|
+
- For direct-to-object-storage uploads, authorize the target resource before issuing the signed upload URL, confirm upload completion before making the asset usable, and keep pending, uploaded, processing, ready, failed, and deleted states separate.
|
|
159
|
+
- Inspect actual file bytes instead of trusting extension or `Content-Type`. Re-encode images and strip metadata when practical before serving user uploads.
|
|
160
|
+
25. For business logic, check that server code does not trust client-supplied prices, discounts, roles, owners, entitlement state, plan limits, usage counters, inventory, seats, refunds, credits, or coupon state. Inspect idempotency, transactions, uniqueness, and concurrent requests for repeated side effects.
|
|
161
|
+
26. For API responses, check that the response contains only fields the caller may see and needs for the use case. Do not expose password hashes, internal storage keys, permanent private URLs, raw billing provider ids, internal moderation notes, private IP data, privileged flags, or database columns merely because they are present on the model.
|
|
162
|
+
27. For dependency failure policy, distinguish fail-closed from degraded behavior. Authentication, authorization, payment, entitlement, and destructive admin decisions should usually fail closed; analytics, recommendation, statistics, AI summaries, and email should usually avoid exposing private data or blocking core state changes.
|
|
163
|
+
- For dead-letter queues, retry logs, and external API call records, check that errors contain safe codes and bounded metadata rather than full prompts, email bodies, payment details, tokens, private files, or personal data.
|
|
164
|
+
- For unknown provider outcomes, require reconciliation before repeating security-, money-, entitlement-, or privacy-impacting effects.
|
|
165
|
+
- For AI usage ledgers and cost records, store operational metadata such as feature key, model, token counts, cost unit, safe request id, and cache-hit type without storing raw prompts, confidential documents, personal data, or full model outputs unless a specific retention and access policy requires them.
|
|
166
|
+
- For AI cache keys, store hashes or opaque identifiers. Do not make prompts, uploaded document text, user messages, or personally identifying fields part of readable cache keys, logs, traces, metrics, or final reports.
|
|
167
|
+
- For AI budget and gateway records, store enough information to enforce limits and investigate abuse without retaining prompt text, uploaded document contents, full outputs, or personal data by default. Record blocked, downgraded, and emergency-disabled decisions as security-relevant events when they protect cost, privacy, or region policy.
|
|
168
|
+
28. For secrets, logs, and audit records, check hardcoded credentials, frontend bundle exposure, public versus secret key confusion, real-looking samples, raw request or session dumps, stack traces, error payloads, screenshots, receipts, generated reports, unbounded before/after snapshots, and whether leaked keys need revocation guidance.
|
|
169
|
+
29. Treat shell commands, copyable command text, executable names, workflow action references, publish identities, package manifests, lifecycle scripts, Dockerfiles, and environment path entries as disclosure and execution surfaces, not as harmless strings.
|
|
170
|
+
30. For dependency changes, activate `dependency-reality-check` to confirm the package is declared, real, necessary, locked when appropriate, and not an assistant-hallucinated or lookalike dependency.
|
|
171
|
+
- For third-party services used as core infrastructure, review whether the terms allow commercial use, export, backup, deletion, data retention control, model training opt-out, stable API limits, and service continuity. If the project cannot verify the terms under the current task, report the risk instead of claiming the provider is safe for sensitive or core data.
|
|
172
|
+
31. For agent configuration, MCP/tool setup, prompt files, external instructions, or AI context settings, activate `external-prompt-injection-defense` and check hidden instruction text, suspicious Unicode controls, broad filesystem or shell permissions, network egress, sensitive context inclusion, and over-privileged service tokens.
|
|
173
|
+
32. For filesystem changes, distinguish lexical containment from the real target. Check symlinks, generated state, package contents, and file APIs that may follow links before claiming a path stays inside the repository.
|
|
174
|
+
33. For code-scanning alerts, group findings by root cause and rule. Fix the underlying pattern, not only the exact flagged line, and separate repository-setting alerts such as branch protection or maintainer activity from code changes.
|
|
175
|
+
34. For workflow scanner alerts, check action pinning, `persist-credentials`, job-level permissions, reusable workflow permissions, fork pull-request secret exposure, artifact upload boundaries, and privileged identity timing before treating the warning as cosmetic.
|
|
176
|
+
35. For pinned action references, distinguish tag objects from the commit that implements the tag. Verify pinned SHAs against the action repository so scanner tooling does not report an imposter or non-member commit.
|
|
177
|
+
36. For dependency scanner alerts, separate production dependency manifests from fixtures, examples, generated test repositories, and intentionally vulnerable samples. Narrow the scan scope before treating fixture-only alerts as product vulnerabilities.
|
|
178
|
+
37. For deployment settings, check debug mode, sample admin accounts, default credentials, public admin panels, open metrics endpoints, public storage, root container users, HTTPS enforcement, and exposed GraphQL or development consoles.
|
|
179
|
+
38. For runtime and framework security updates, check that supported versions are documented, end-of-life versions are rejected, dependency locks exist where appropriate, security patches can be tested and deployed quickly, and rollback or redeploy can happen without manual dashboard memory. Do not treat a fashionable or high-performance runtime as safe unless the patch path is operationally credible.
|
|
180
|
+
39. For transport security, check HTTPS/TLS requirements, certificate validation, insecure HTTP downgrade paths, disabled verification flags, and whether sensitive traffic can bypass the secure channel.
|
|
181
|
+
40. For cryptography, reject custom cryptography and tutorial-grade shortcuts. Check password hashing uses a password-hashing primitive such as bcrypt, scrypt, or Argon2id where supported by the project; random tokens use secure randomness; keys are separated from encrypted data; and weak hashes such as MD5, SHA-1, or bare SHA-256 are not used for password storage.
|
|
182
|
+
41. For architecture drift, name the security invariant before accepting the generated structure. Confirm the invariant still holds across UI, handler, service, repository, database policy, workflow, and deployment boundaries.
|
|
183
|
+
42. For SAST, SCA, or scanner output, treat scanner output as evidence rather than command authority. Map the finding to a repository-owned boundary, configured verification intent, dependency metadata, or regression test before claiming the issue is fixed.
|
|
184
|
+
43. Verify that examples, fixtures, screenshots, command outputs, and final reports do not expose real-looking secrets or unnecessary personal data.
|
|
185
|
+
44. Prefer omission or minimal metadata over masking when the sensitive value is not needed for the user to understand the result.
|
|
186
|
+
45. If the change affects an authorization, SSRF, CSRF, rate-limit, upload, download, token, business-logic, injection, logging, telemetry, cache authority, cache disclosure, admin operation, agent permission, cryptography, transport, scanner, or abuse boundary, activate `security-regression-tests` for test selection instead of folding test generation into this review.
|
|
187
|
+
46. Run the narrowest configured verification that covers the changed docs, templates, package, or mustflow contract.
|
|
120
188
|
|
|
121
189
|
<!-- mustflow-section: postconditions -->
|
|
122
190
|
## Postconditions
|
|
@@ -124,6 +192,16 @@ Catch security, privacy, and disclosure risks introduced by ordinary code, docum
|
|
|
124
192
|
- Sensitive data and disclosure surfaces have been identified or explicitly reported as unknown.
|
|
125
193
|
- AI-generated or happy-path-only security assumptions have been replaced with inspected server-side, dependency, tool-permission, or test evidence.
|
|
126
194
|
- Public and packaged surfaces do not include unnecessary secrets, personal data, or misleading privacy guarantees.
|
|
195
|
+
- Admin operations, shared-cache behavior, generated-state rebuilds, and audit logs are treated as security-sensitive when they affect private data, permissions, public indexing, traffic, or monetization.
|
|
196
|
+
- Client-side permission displays, file upload or download flows, private asset URLs, and API response fields are treated as disclosure and access-control surfaces.
|
|
197
|
+
- Behavior analytics, observability, and audit logs are separated by durability, retention, attribution, personal-data, and loss-tolerance expectations.
|
|
198
|
+
- Core security, privacy, billing, entitlement, file, search, job, webhook, and administrator events are internally owned or explicitly reported as SaaS-only with the resulting export, retention, and incident-reconstruction risk.
|
|
199
|
+
- Trace context, baggage, request ids, user ids, tenant ids, job ids, and webhook ids are reviewed for sensitive data, external propagation, retention, and backend portability when those surfaces exist.
|
|
200
|
+
- Webhook receipts, retry logs, external API call records, and dead-letter records are bounded, redacted, deduplicated, and retained according to their sensitivity when those surfaces exist.
|
|
201
|
+
- Data residency, processing location, backup location, log location, analytics location, support-tool access, and AI provider location are separated or reported as unknown when those surfaces affect privacy, regulation, or customer commitments.
|
|
202
|
+
- Runtime and dependency patchability is reviewed when a stack choice or update policy affects security exposure.
|
|
203
|
+
- Cache-backed security, payment, entitlement, subscription, ownership, and inventory decisions fail closed or use a real source of truth instead of trusting disposable shared cache state.
|
|
204
|
+
- High-risk claims, comparison results, affiliate links, user-generated content, data ownership boundaries, and deletion or retention behavior are treated as security and privacy surfaces when they affect trust, disclosure, or personal data.
|
|
127
205
|
- The final report names remaining unverified security or privacy risks without revealing sensitive values.
|
|
128
206
|
|
|
129
207
|
<!-- mustflow-section: verification -->
|
|
@@ -156,6 +234,11 @@ Use a narrower configured test, build, or documentation intent when it better pr
|
|
|
156
234
|
- Sensitive surfaces reviewed
|
|
157
235
|
- AI-generated happy-path assumptions checked
|
|
158
236
|
- Disclosure or retention paths checked
|
|
237
|
+
- Behavior analytics, observability, webhook, external-call, dead-letter, admin, audit-log, cache-authority, cache-disclosure, and generated-state rebuild boundaries checked when relevant
|
|
238
|
+
- Core event ownership, SaaS-only analytics risk, search-log sensitivity, queue-error retention, and incident-reconstruction boundaries checked when relevant
|
|
239
|
+
- Trace context, baggage, third-party data-use terms, export gating, and account-suspension or unilateral-terms risks checked when relevant
|
|
240
|
+
- Data residency, data classification, AI processing location, runtime patch, and hard-limit policy checked when relevant
|
|
241
|
+
- Claim, comparison, affiliate, user-generated content, data-ownership, deletion, anonymization, export, and retention boundaries checked when relevant
|
|
159
242
|
- Authorization, session, token, input, file, network, business-logic, dependency, cryptography, transport, deployment, scanner, and agent-tool boundaries checked
|
|
160
243
|
- Redaction, omission, or wording changes made
|
|
161
244
|
- Related security-regression test need
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
mustflow_doc: skill.state-machine-pattern
|
|
3
3
|
locale: en
|
|
4
4
|
canonical: true
|
|
5
|
-
revision:
|
|
5
|
+
revision: 4
|
|
6
6
|
lifecycle: mustflow-owned
|
|
7
7
|
authority: procedure
|
|
8
8
|
name: state-machine-pattern
|
|
9
|
-
description: Apply this skill when domain objects have lifecycle state, allowed actions depend on state, status changes are scattered, or state transitions need explicit events, guards, effects, history, idempotency, and concurrency control.
|
|
9
|
+
description: Apply this skill when domain objects, jobs, external API calls, uploads, webhooks, or processing workflows have lifecycle state, deletion or restore flow, allowed actions depend on state, status changes are scattered, or state transitions need explicit events, guards, effects, history, idempotency, retry, reconciliation, and concurrency control.
|
|
10
10
|
metadata:
|
|
11
11
|
mustflow_schema: "1"
|
|
12
12
|
mustflow_kind: procedure
|
|
@@ -41,9 +41,12 @@ Use this skill to prevent scattered `if`, `switch`, direct assignment, silent no
|
|
|
41
41
|
- A domain object has three or more states, or fields named `status`, `state`, `phase`, `step`, or `stage`.
|
|
42
42
|
- State determines which actions, API calls, buttons, jobs, events, or commands are allowed.
|
|
43
43
|
- The lifecycle includes cancel, approve, reject, expire, retry, fail, refund, suspend, restore, archive, delete, publish, ship, or deliver flows.
|
|
44
|
+
- Delete, restore, purge, archive, deprecate, redirect, suspend, unsubscribe, revoke, or anonymize behavior has different access, retention, audit, search, support, or recovery consequences.
|
|
44
45
|
- State changes must produce history, audit records, domain events, outbox messages, or external effects.
|
|
45
46
|
- Multiple users, workers, queues, webhooks, or external systems can attempt transitions on the same entity.
|
|
46
47
|
- External service results change state and require pending, success, and failure states.
|
|
48
|
+
- Jobs, outbox deliveries, webhook processing, external API calls, AI processing, email delivery, imports, exports, or file conversions need queued, running, retrying, succeeded, failed, dead-letter, or unknown/reconciliation states.
|
|
49
|
+
- File uploads, asset processing, image resizing, virus scanning, document conversion, private download readiness, or storage deletion have pending, uploaded, processing, ready, failed, deleted, or purged states.
|
|
47
50
|
- Code repeatedly asks whether an action is possible from the current state.
|
|
48
51
|
- State rules are scattered across handlers, repositories, jobs, UI code, adapters, SQL queries, or broad services.
|
|
49
52
|
- Several booleans actually encode one lifecycle and can create impossible combinations.
|
|
@@ -55,7 +58,7 @@ Use this skill to prevent scattered `if`, `switch`, direct assignment, silent no
|
|
|
55
58
|
- The state is a simple two-value toggle with no lifecycle rules, history, side effects, concurrency risk, or irreversible transition.
|
|
56
59
|
- State does not affect allowed actions.
|
|
57
60
|
- The code is a pure calculation, formatter, mapper, parser, or local UI-only state update.
|
|
58
|
-
- A simple create, read, update, delete flow only distinguishes active and deleted and has no meaningful transition rules.
|
|
61
|
+
- A simple create, read, update, delete flow only distinguishes active and deleted and has no meaningful transition rules, recovery behavior, retention behavior, or audit need.
|
|
59
62
|
|
|
60
63
|
Two states can still require this skill when the lifecycle is meaningful, such as active to suspended to deleted, deleted being irreversible, or suspension requiring audit and authorization.
|
|
61
64
|
|
|
@@ -68,6 +71,7 @@ Two states can still require this skill when the lifecycle is meaningful, such a
|
|
|
68
71
|
- Current places that change state, validate actions, check state, or render available actions.
|
|
69
72
|
- Guards, authorization facts, time facts, external facts, and loaded domain data needed to decide transitions.
|
|
70
73
|
- Effects, domain events, outbox records, audit records, transition history, idempotency keys, and concurrency protections required by the lifecycle.
|
|
74
|
+
- Retry and reconciliation rules, including which states can retry, which states are terminal, which states require manual review, and which external outcomes are unknown rather than failed.
|
|
71
75
|
- Existing local patterns for `Result`, events, outbox, repositories, command handlers, pure core decisions, transition tables, tests, and documentation.
|
|
72
76
|
- Relevant command-intent contract entries for verification.
|
|
73
77
|
|
|
@@ -104,6 +108,8 @@ Two states can still require this skill when the lifecycle is meaningful, such a
|
|
|
104
108
|
- Make states mutually exclusive within one state machine.
|
|
105
109
|
3. Name states by domain meaning.
|
|
106
110
|
- Prefer states such as `DRAFT`, `PENDING_REVIEW`, `APPROVED`, `PAYMENT_PENDING`, `PAID`, `FULFILLMENT_PENDING`, `SHIPPED`, `DELIVERED`, `CANCELLED`, `REFUND_PENDING`, `REFUNDED`, `EXPIRED`, or `ARCHIVED`.
|
|
111
|
+
- For deletion-like lifecycles, distinguish states such as `ACTIVE`, `ARCHIVED`, `DEPRECATED`, `PRIVATE`, `SOFT_DELETED`, `PURGE_PENDING`, `PURGED`, `REDIRECTED`, `GONE`, `SUSPENDED`, and `ANONYMIZED` when those states differ in visibility, recovery, retention, indexing, or legal meaning.
|
|
112
|
+
- For uploaded assets, distinguish states such as `PENDING_UPLOAD`, `UPLOADED`, `SCANNING`, `PROCESSING`, `READY`, `FAILED`, `DELETE_PENDING`, and `DELETED` when storage, scanning, conversion, visibility, cleanup, or download access differs.
|
|
107
113
|
- Avoid UI or placeholder names such as `STEP_1`, `STEP_2`, `BUTTON_DISABLED`, `GRAY`, `READY2`, `TEMP`, and broad states such as `PROCESSING` when a more specific waiting state exists.
|
|
108
114
|
4. Name events as facts that happened.
|
|
109
115
|
- Prefer events such as `PAYMENT_STARTED`, `PAYMENT_SUCCEEDED`, `PAYMENT_FAILED`, `CANCEL_REQUESTED`, `REFUND_APPROVED`, `SHIPMENT_CREATED`, `DELIVERY_CONFIRMED`, `TIMEOUT_REACHED`, and `EMAIL_VERIFIED`.
|
|
@@ -113,6 +119,7 @@ Two states can still require this skill when the lifecycle is meaningful, such a
|
|
|
113
119
|
- Include every source state, allowed event, guard name, target state, and effect description.
|
|
114
120
|
- Include terminal states explicitly with no outgoing transitions when they are truly terminal.
|
|
115
121
|
- Do not hide transition rules inside handler branches, repository filters, database queries, adapter code, or UI code.
|
|
122
|
+
- Do not let direct `deleted_at` assignment bypass allowed archive, soft-delete, restore, purge, anonymize, or redirect transitions when deletion is a meaningful lifecycle.
|
|
116
123
|
6. Keep guards pure.
|
|
117
124
|
- Guards may inspect entity state, event data, context facts, loaded external facts, current time passed through context, and authorization facts passed through context.
|
|
118
125
|
- Guards must not query databases, call SDKs, send messages, write logs, mutate state, read current time directly, generate random values, or trigger external work.
|
|
@@ -120,6 +127,9 @@ Two states can still require this skill when the lifecycle is meaningful, such a
|
|
|
120
127
|
7. Model external work with pending, success, and failure events.
|
|
121
128
|
- Do not jump directly from request to success for payment, refund, shipment, email, file processing, AI processing, or other external operations.
|
|
122
129
|
- Use states such as `PAYMENT_PENDING`, `REFUND_PENDING`, `FULFILLMENT_PENDING`, or `ANALYSIS_PENDING`, then model provider success and failure as separate events.
|
|
130
|
+
- For files, model upload URL issuance, upload confirmation, scan success or failure, variant generation, ready publication, failed retry, and storage deletion as separate events when those steps can fail independently.
|
|
131
|
+
- For jobs and outbox delivery, model queued, claimed or running, retry scheduled, succeeded, failed, and dead-letter or manual-review states when attempts and worker ownership matter.
|
|
132
|
+
- For provider mutations, model unknown completion separately from failure. An unknown state means the provider call may have succeeded and must be reconciled before another attempt can safely run.
|
|
123
133
|
8. Model time as events.
|
|
124
134
|
- Expiration, scheduled cancellation, automatic approval, automatic archive, retry window elapsed, and timeout should enter the state machine as events.
|
|
125
135
|
- Do not scatter direct time checks that assign state outside the transition function.
|
|
@@ -140,9 +150,11 @@ Two states can still require this skill when the lifecycle is meaningful, such a
|
|
|
140
150
|
- Same key and same payload should return the prior result.
|
|
141
151
|
- Same key and different payload should return a duplicate conflict.
|
|
142
152
|
- Different key with an impossible current state should return invalid transition rather than silently succeeding.
|
|
153
|
+
- Duplicate queued jobs, webhook callbacks, provider events, and slow worker completions should either return the already-applied transition, conflict on changed payload, or be ignored as stale by version or expected-state checks.
|
|
143
154
|
13. Record transition history when the lifecycle matters operationally.
|
|
144
155
|
- History should include entity type, entity identifier, from state, event type, to state, actor identifier when known, idempotency key, payload hash, reason when safe, and timestamp from context.
|
|
145
156
|
- Use transition history for debugging, customer support, dispute handling, audit, and security review.
|
|
157
|
+
- Deletion and restore history should include actor, reason, recovery or purge deadline, and whether personal data was anonymized, hard-deleted, retained, or separated from the business record.
|
|
146
158
|
14. Derive available actions from the state machine.
|
|
147
159
|
- UI or API layers may display available actions, but they must not own an independent copy of transition rules.
|
|
148
160
|
- Prefer a server-side helper that evaluates possible events or exposes allowed actions derived from the transition table.
|
|
@@ -170,6 +182,7 @@ Two states can still require this skill when the lifecycle is meaningful, such a
|
|
|
170
182
|
- Impossible transitions return explicit errors instead of being ignored.
|
|
171
183
|
- Guards are pure and external facts are passed through context.
|
|
172
184
|
- External work is represented through pending, success, and failure events, with effects executed after persistence.
|
|
185
|
+
- Retryable work, dead-letter states, and unknown provider outcomes are represented explicitly when external work can be repeated or ambiguous.
|
|
173
186
|
- Durable state transitions use concurrency control and duplicate-event handling when needed.
|
|
174
187
|
- Important lifecycle changes leave transition history and outbox or effect records.
|
|
175
188
|
- Tests cover the transition table and the highest-risk invalid, duplicate, and concurrent paths.
|
|
@@ -208,7 +221,7 @@ Choose the narrowest configured verification that covers the changed state machi
|
|
|
208
221
|
- States, terminal states, and events introduced or changed
|
|
209
222
|
- Transition table location and source-of-truth note
|
|
210
223
|
- Guards and context facts
|
|
211
|
-
- Effects, outbox, history, idempotency, and concurrency choices
|
|
224
|
+
- Effects, outbox, history, idempotency, retry, reconciliation, dead-letter, and concurrency choices
|
|
212
225
|
- Direct state assignments removed or remaining bypasses
|
|
213
226
|
- Tests or verification evidence
|
|
214
227
|
- Skipped checks and remaining state-machine risk
|