@cassiomc1/forgeloop 1.12.0 → 1.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/.github/copilot-instructions.md +1 -1
  2. package/AGENTS.md +1 -1
  3. package/CLAUDE.md +1 -1
  4. package/CONTRIBUTING.md +90 -0
  5. package/DOCS_INDEX.md +13 -11
  6. package/ENG/c-development-eng.md +112 -0
  7. package/ENG/cpp-development-eng.md +109 -0
  8. package/ENG/dotnet-aspnetcore-development-eng.md +401 -0
  9. package/ENG/go-development-eng.md +103 -0
  10. package/ENG/java-development-eng.md +125 -0
  11. package/ENG/nodejs-backend-development-eng.md +605 -0
  12. package/ENG/php-development-eng.md +104 -0
  13. package/ENG/rust-development-eng.md +422 -0
  14. package/ENG/sql-development-eng.md +108 -0
  15. package/ENG/swift-development-eng.md +111 -0
  16. package/ENG/typescript-development-eng.md +108 -0
  17. package/GUIDE_ROUTER.md +418 -9
  18. package/QUALITY_SCORECARD.md +1 -0
  19. package/README.md +44 -33
  20. package/THIRD_PARTY_NOTICES.md +19 -7
  21. package/completions/_forgeloop +3 -3
  22. package/completions/forgeloop.bash +3 -3
  23. package/completions/forgeloop.fish +7 -0
  24. package/docs/AGENT_PROTOCOL_SUMMARY.md +55 -2
  25. package/docs/CLI_REFERENCE.md +28 -6
  26. package/docs/DOCUMENTATION_GUIDE.md +2 -1
  27. package/docs/GETTING_STARTED.md +59 -0
  28. package/docs/PACKAGE_CONTENTS.md +28 -14
  29. package/docs/RECIPES.md +23 -0
  30. package/docs/RELEASE_CHECKLIST.md +30 -2
  31. package/docs/TROUBLESHOOTING.md +100 -2
  32. package/docs/documentation-manifest.json +652 -0
  33. package/docs/protocol-requirements.json +77 -0
  34. package/package.json +19 -4
  35. package/schemas/routing-input.schema.json +1 -1
  36. package/scripts/CI_VALIDATORS.md +84 -11
  37. package/scripts/generate-agent-protocol-summary.mjs +36 -0
  38. package/src/commands/next.js +19 -7
  39. package/src/commands/task-create.js +84 -25
  40. package/src/commands/task-list.js +22 -2
  41. package/src/config/guides.json +44 -0
  42. package/src/core/build-script.js +151 -0
  43. package/src/core/c-cpp-project.js +143 -0
  44. package/src/core/cli-command-definitions.js +8 -1
  45. package/src/core/command-executors.js +5 -3
  46. package/src/core/command-input.js +140 -102
  47. package/src/core/contract-presets.js +82 -0
  48. package/src/core/error-codes.js +3 -3
  49. package/src/core/filesystem.js +1 -10
  50. package/src/core/go-project.js +206 -0
  51. package/src/core/java-project.js +403 -0
  52. package/src/core/multi-language-project.js +117 -0
  53. package/src/core/next-explanation.js +63 -0
  54. package/src/core/php-project.js +85 -0
  55. package/src/core/project-detection.js +1760 -52
  56. package/src/core/reconcile-closure.js +4 -1
  57. package/src/core/router.js +156 -3
  58. package/src/core/rust-project.js +400 -0
  59. package/src/core/sql-project.js +141 -0
  60. package/src/core/swift-project.js +200 -0
  61. package/src/core/typescript-project.js +349 -0
  62. package/src/core/xml-structure.js +123 -0
@@ -0,0 +1,104 @@
1
+ ---
2
+ name: php-development-eng
3
+ language: en
4
+ description: "Specialist guidance for production PHP applications, Composer packages, web services, and command-line workers."
5
+ version: "2026.09"
6
+ last-reviewed: "2026-09-12"
7
+ guide-id: php
8
+ requires-gates:
9
+ - threat-boundary
10
+ completion-evidence:
11
+ - php-validation
12
+ ---
13
+
14
+ # PHP Development Engineering Guide
15
+
16
+ ## Mission and activation
17
+
18
+ Use this guide for PHP applications, web services, packages, workers, and
19
+ command-line tools. A valid bounded `composer.json` with package, requirement,
20
+ or autoload identity is primary evidence. A directly claimed executable PHP
21
+ file may provide bounded fallback evidence. `composer.lock`, `vendor/`, a PHP
22
+ version string, an extension package, Docker/CI setup, static HTML, a README,
23
+ and dependency names alone do not establish a PHP project.
24
+
25
+ ForgeLoop parses Composer JSON and checks a claimed source file conservatively;
26
+ the standard `<?php` and short echo `<?=` tags provide executable-source
27
+ evidence. It never runs PHP, Composer scripts/plugins, autoload generation,
28
+ package resolution, or project code, and it does not access the network.
29
+
30
+ ## Authority and precedence
31
+
32
+ Repository PHP/Composer constraints, runtime platform, extensions, deployment
33
+ model, and compatibility policy win over generic advice. Then use the matching
34
+ official PHP manual/migration guide, Composer documentation, and
35
+ version-matched framework documentation. The 2026-09 plan snapshot records PHP
36
+ 8.5.10 as a current reference and supported branches 8.2–8.5; neither changes
37
+ the repository runtime constraint automatically.
38
+
39
+ Keep PHP language version, engine/runtime, extensions, Composer platform
40
+ requirements, production SAPI, CLI runtime, framework minimum, and deployment
41
+ image separate. A Composer package is not necessarily a web application.
42
+
43
+ ## Composer and project discovery
44
+
45
+ Review `name`, `type`, `require`, `autoload`, `autoload-dev`, and package
46
+ identity structurally. Composer scripts, plugins, installers, generated
47
+ autoload files, `vendor/`, registry packages, VCS repositories, and platform
48
+ resolution remain execution/dependency context. Preserve lockfile policy and
49
+ do not edit generated/vendor content as if it were application source.
50
+
51
+ PHP extensions deserve special care: an extension or C-extension package may
52
+ compose with the C specialist, but does not imply PHP implementation. Keep
53
+ Composer-less source fallback limited to owned files with an executable
54
+ `<?php` opening tag and do not promote generated/vendor trees.
55
+
56
+ ## Architecture and language semantics
57
+
58
+ Keep HTTP/CLI transport, domain, persistence, templates, jobs, and external
59
+ service adapters separate where the repository does. Review namespaces,
60
+ autoloading, visibility, traits, interfaces, inheritance, attributes,
61
+ generators, closures, strict comparisons, coercion, nullability, union/intersection
62
+ types, exceptions, serialization, and backward compatibility.
63
+
64
+ `declare(strict_types=1)` is a per-file call-site rule, not a repository-wide
65
+ runtime validation guarantee. Validate decoded JSON, requests, environment,
66
+ database rows, files, and queue messages at runtime before use.
67
+
68
+ ## Errors, I/O, and security
69
+
70
+ Preserve exception causes and distinguish retryable, validation, authorization,
71
+ operational, and terminal failures. Bound uploads, request bodies, output,
72
+ queues, database connections, queries, transactions, subprocesses, and worker
73
+ concurrency. Treat templates, SQL, filesystem paths, commands, serialized
74
+ objects, sessions, cookies, credentials, and user input as hostile. Keep
75
+ authentication, authorization, CSRF, secret handling, SSRF, deserialization,
76
+ and log redaction explicit and tested.
77
+
78
+ ## Performance, portability, and dependencies
79
+
80
+ Measure request latency, memory, opcode/cache behavior, queueing, database
81
+ plans, and worker throughput before optimizing. Keep timezone, locale, charset,
82
+ filesystem, SAPI, process model, extension ABI, and container assumptions
83
+ explicit. Review Composer licenses, lockfile reproducibility, update scripts,
84
+ and production-install behavior without executing hooks during routing.
85
+
86
+ ## Verification and Definition of Done
87
+
88
+ Run focused PHPUnit or repository tests, static analysis, coding standards,
89
+ security checks, migration/database compatibility checks, and clean production
90
+ installation for the exact PHP, extensions, Composer lockfile, and SAPI.
91
+ Record commands and unavailable tools as `NOT_VERIFIED`. Completion requires
92
+ tested trust boundaries, failure paths, resource limits, compatibility, and
93
+ observability. ForgeLoop performs bounded structural Composer/PHP analysis; it
94
+ does not implement PHP execution, Composer resolution, autoload generation, or
95
+ plugin behavior.
96
+
97
+ ## Official sources
98
+
99
+ - [PHP manual](https://www.php.net/manual/en/)
100
+ - [PHP supported versions](https://www.php.net/supported-versions.php)
101
+ - [PHP migration guides](https://www.php.net/migration85)
102
+ - [Composer documentation](https://getcomposer.org/doc/)
103
+ - [Composer schema](https://getcomposer.org/doc/04-schema.md)
104
+ - [OWASP PHP security guidance](https://owasp.org/www-project-top-ten/)
@@ -0,0 +1,422 @@
1
+ ---
2
+ name: rust-development-eng
3
+ language: en
4
+ description: "Specialist guidance for architecture, implementation, testing, security, performance, and release of production Rust applications, services, libraries, and workers."
5
+ version: "2026.09"
6
+ last-reviewed: "2026-09-11"
7
+ guide-id: rust
8
+ requires-gates:
9
+ - threat-boundary
10
+ completion-evidence:
11
+ - rust-validation
12
+ ---
13
+
14
+ # Rust Development Engineering Guide
15
+
16
+ > Production-oriented guidance for Rust applications, services, libraries,
17
+ > command-line tools, workers, and systems components.
18
+ >
19
+ > This guide is activated only by a valid, structurally parsed `Cargo.toml`
20
+ > with a `[package]` and/or `[workspace]` table in the affected project scope.
21
+ > A Rust source file, `Cargo.lock`, toolchain file, rustfmt or Clippy config,
22
+ > Docker image, CI setup, or a dependency name alone is not project identity.
23
+ > The detector reads manifests and bounded project metadata without invoking
24
+ > Cargo, rustc, build scripts, procedural macros, package scripts, or network
25
+ > services. Build and test tooling around another stack is not backend/runtime
26
+ > evidence for that stack.
27
+
28
+ This guide complements [`clean-code-eng.md`](./clean-code-eng.md) for
29
+ maintainability, [`test-code-eng.md`](./test-code-eng.md) for verification,
30
+ [`sec-code-eng.md`](./sec-code-eng.md) for trust boundaries,
31
+ [`perf-code-eng.md`](./perf-code-eng.md) for measured optimization, and
32
+ [`documentation-quality-eng.md`](./documentation-quality-eng.md) for public
33
+ technical documentation.
34
+
35
+ Tooling policy: inspect the repository and use already-available tools first.
36
+ Do not install a Rust toolchain, target, linker, dependency, database,
37
+ container, browser, or global utility merely to satisfy a check. If a required
38
+ check cannot run, record `NOT_VERIFIED` or `BLOCKED`; never claim it passed.
39
+
40
+ ## 1. Mission and activation contract
41
+
42
+ The Rust specialist exists to make changes that are:
43
+
44
+ - correct for the repository's active toolchain, edition, target, and MSRV;
45
+ - explicit about ownership, borrowing, concurrency, cancellation, and process
46
+ boundaries;
47
+ - safe when input, dependencies, unsafe code, FFI, build scripts, and network
48
+ peers are untrusted;
49
+ - testable with the narrowest check that proves the changed behavior and with
50
+ broader checks where integration risk requires it;
51
+ - observable under success, error, timeout, retry, cancellation, and shutdown;
52
+ - reproducible from the exact workspace, lockfile, features, and toolchain that
53
+ will ship.
54
+
55
+ Do not select Tokio, Axum, Actix Web, Rocket, Hyper, Tower, Tonic, Serde, an
56
+ allocator, an async runtime, or a deployment model because it is fashionable.
57
+ Use repository evidence and the smallest coherent change. These technologies
58
+ may enrich context inside this single Rust guide, but they are not public
59
+ specialist IDs.
60
+
61
+ ### Cargo-first evidence
62
+
63
+ The project detector treats these as primary identity signals:
64
+
65
+ 1. A bounded, valid `Cargo.toml` containing a structurally valid `[package]`
66
+ table.
67
+ 2. A bounded, valid `Cargo.toml` containing a structurally valid `[workspace]`
68
+ table with at least one resolvable, in-repository package member. An empty
69
+ or unresolved virtual workspace fails closed; a package workspace remains
70
+ valid through its `[package]` identity.
71
+
72
+ A package workspace may contain both `[package]` and `[workspace]` tables. The
73
+ `package.workspace` key is mutually exclusive with a `[workspace]` table; it is
74
+ the association form for a package that belongs to another workspace. A virtual
75
+ workspace has no package root of its own; its confirmed package members are the
76
+ public project roots. Workspace `members`, `exclude`, `package.workspace`, known
77
+ local package `path` dependencies, and explicitly used inherited workspace
78
+ dependencies are used conservatively for claims and shared-file ownership.
79
+ `[workspace.dependencies]` declarations alone do not create active package
80
+ dependency edges. A valid `package.workspace` association may point to a known
81
+ workspace outside the package's directory subtree, but never outside the
82
+ repository. Workspace globs are bounded path patterns: `*` and `?` do not cross
83
+ path separators, while `**` may; absolute paths and parent-directory escapes
84
+ are rejected. Only already discovered manifests participate; the detector does
85
+ not traverse dependency paths or execute Cargo to resolve workspace semantics.
86
+
87
+ Cargo package metadata may inherit `edition` and `rust-version` through
88
+ `edition.workspace = true` and `rust-version.workspace = true`. The detector
89
+ records those inheritance flags as supporting context, and may retain direct
90
+ `[workspace.package]` values for guidance. It does not require inherited values
91
+ to classify a package.
92
+
93
+ The following are supporting context only:
94
+
95
+ - `edition`, `rust-version`, `resolver`, features, dependency categories, and
96
+ recognized runtime or server libraries in `Cargo.toml`;
97
+ - `Cargo.lock`, `rust-toolchain`, `rust-toolchain.toml`, `.cargo/config`,
98
+ `.cargo/config.toml`, `rustfmt.toml`, `.rustfmt.toml`, `clippy.toml`, and
99
+ `.clippy.toml`;
100
+ - `src/**/*.rs`, `build.rs`, proc-macro crates, generated code, Dockerfiles,
101
+ CI configuration, documentation, and repository prose.
102
+
103
+ Source-only context does not replace Cargo identity. `target/` and `vendor/`
104
+ are ignored during bounded discovery; `.cargo/` remains visible as Rust
105
+ configuration. Confirmed nested Rust, Node.js, Flutter, and .NET roots remain
106
+ ownership boundaries. A parent project must not claim a nested child's
107
+ manifest, lockfile, configuration, source, or generated output.
108
+
109
+ ## 2. Authority, discovery, and version truth
110
+
111
+ Resolve conflicts in this order:
112
+
113
+ 1. Platform and safety rules.
114
+ 2. The user's latest explicit request.
115
+ 3. Repository-local instructions, including `AGENTS.md`, `PROJECT_PROFILE.md`,
116
+ `LOOP_ENGINEERING.md`, and nested instructions.
117
+ 4. Actual Cargo manifests, source, tests, CI, deployment configuration, and
118
+ release metadata.
119
+ 5. Existing public contracts and established architecture.
120
+ 6. This guide.
121
+ 7. Version-matched official Rust and Cargo documentation.
122
+ 8. Community examples.
123
+
124
+ Use the official Rust documentation as the authority: the [Rust
125
+ Documentation](https://doc.rust-lang.org/stable/), [The Cargo
126
+ Book](https://doc.rust-lang.org/cargo/), [The Rust
127
+ Reference](https://doc.rust-lang.org/reference/), [The Edition
128
+ Guide](https://doc.rust-lang.org/edition-guide/), [The rustup
129
+ Book](https://rust-lang.github.io/rustup/), [The Rustonomicon](https://doc.rust-lang.org/nomicon/),
130
+ and official [Rust release and security
131
+ information](https://www.rust-lang.org/).
132
+
133
+ Rust does not have a Node-style LTS channel. Stable, beta, and nightly are
134
+ different release channels; a repository may additionally pin a toolchain or
135
+ target. The plan's observation of a current stable version is dated evidence,
136
+ not a universal migration target. Verify the current channel and support
137
+ policy before changing one.
138
+
139
+ Keep these four decisions separate:
140
+
141
+ - **Active toolchain:** the compiler and Cargo selected by `rust-toolchain`,
142
+ `rust-toolchain.toml`, `rustup`, CI, or the build environment.
143
+ - **MSRV:** the oldest Rust version supported by the package, usually declared
144
+ as `package.rust-version` and tested by the project policy.
145
+ - **Edition:** language and standard-library behavior selected by
146
+ `package.edition`; it is not the compiler version or the MSRV.
147
+ - **Target:** the compilation and deployment target, linker, C ABI, OS, CPU,
148
+ and cross-compilation environment.
149
+
150
+ Do not silently upgrade the active toolchain, MSRV, edition, target, lockfile,
151
+ or resolver while making an unrelated feature change. Record an intentional
152
+ compatibility change and validate it in the same environment used by CI and
153
+ release.
154
+
155
+ ## 3. Cargo packages, crates, and workspaces
156
+
157
+ Treat Cargo structure as a set of explicit ownership boundaries:
158
+
159
+ - A **package** is described by a `Cargo.toml` `[package]` table and may contain
160
+ one or more library, binary, example, test, or benchmark crates.
161
+ - A **crate** is a compilation unit; its crate type and entry point do not
162
+ change package ownership.
163
+ - A **workspace** coordinates packages and can be a package workspace or a
164
+ virtual workspace. Workspace dependencies, resolver settings, profiles,
165
+ members, excludes, and lockfile placement affect reproducibility.
166
+ - A package may belong to a workspace while retaining its own package
167
+ identity. Do not treat the virtual workspace root as a deliverable package.
168
+
169
+ Before editing a workspace:
170
+
171
+ - read the nearest package manifest and the workspace root manifest;
172
+ - determine whether membership is explicit, glob-based, or excluded;
173
+ - identify the lockfile and toolchain/config files that apply to the affected
174
+ package;
175
+ - check whether a nested workspace is an independent boundary;
176
+ - preserve feature resolver and workspace dependency intent;
177
+ - avoid rewriting unrelated members or normalizing the whole workspace.
178
+
179
+ Do not edit `Cargo.lock` by hand. Use the repository's documented Cargo
180
+ command and review the resulting graph, features, checksums, and MSRV impact.
181
+ For applications, a committed lockfile is normally part of reproducibility;
182
+ for published libraries, follow the repository's established policy.
183
+
184
+ ## 4. Architecture and ownership
185
+
186
+ Prefer modules that own a coherent capability. Make ownership visible in the
187
+ types and interfaces rather than hiding it behind global mutable state.
188
+
189
+ - Keep transport, application, domain, persistence, and external-service
190
+ adapters separate where those boundaries are real.
191
+ - Let the composition root construct configuration, logging, pools, clients,
192
+ channels, and servers explicitly.
193
+ - Keep domain code independent of HTTP, database, queue, and framework types
194
+ when the repository's architecture permits it.
195
+ - Use traits at a meaningful substitution or ownership boundary; do not create
196
+ traits only to make a concrete function look abstract.
197
+ - Prefer a small error type at each boundary and preserve the cause for logs
198
+ without exposing secrets, tokens, SQL, paths, or topology to callers.
199
+ - Make startup failure visible and shutdown bounded. Handle termination and
200
+ cancellation in the same design as the happy path.
201
+
202
+ ### Ownership and borrowing
203
+
204
+ Use ownership as a design tool:
205
+
206
+ - pass borrowed data when the callee does not need to retain it;
207
+ - move values when the callee becomes the clear owner;
208
+ - avoid unnecessary `clone`, `Arc`, `Mutex`, and `'static` requirements;
209
+ - name lifetime parameters only when they communicate a real relationship;
210
+ - keep mutable aliases short-lived and local;
211
+ - model resource ownership with types that make invalid states difficult.
212
+
213
+ Do not fight the borrow checker by adding broad clones or locks without
214
+ examining the data flow. Conversely, do not contort a clear boundary into a
215
+ complex lifetime design when an owned value is the safer contract.
216
+
217
+ ### Libraries, services, and workers
218
+
219
+ Libraries must keep public types, feature flags, MSRV, and error behavior
220
+ intentional. Services and workers additionally need:
221
+
222
+ - bounded request, message, body, queue, and concurrency limits;
223
+ - timeouts for network, database, and shutdown operations;
224
+ - cancellation propagation and no work acknowledged before durable success;
225
+ - idempotent retry and explicit dead-letter or partial-failure behavior;
226
+ - stable exit status, structured logs, and health/readiness semantics;
227
+ - graceful drain behavior for in-flight tasks and connections.
228
+
229
+ Do not describe a CLI, library, worker, or protocol implementation as an HTTP
230
+ backend unless its actual runtime boundary warrants that claim. The same Rust
231
+ guide covers all of these runtime surfaces.
232
+
233
+ ## 5. Error handling and observability
234
+
235
+ Use `Result` for recoverable failure and `Option` for absence. Avoid `unwrap`,
236
+ `expect`, and panic-driven control flow at request, message, file, database,
237
+ configuration, and startup boundaries unless the invariant is local,
238
+ documented, and tested.
239
+
240
+ - Preserve error context at the boundary where it becomes actionable.
241
+ - Do not log secrets, credentials, personal data, full request bodies, or
242
+ untrusted values without bounded redaction.
243
+ - Separate user-safe errors from operator diagnostics.
244
+ - Include correlation or operation identity where it helps trace a request
245
+ across async tasks and external services.
246
+ - Record latency, queue depth, retry count, saturation, and failure class when
247
+ those measures define service health.
248
+ - Test timeout, cancellation, retry exhaustion, malformed input, dependency
249
+ failure, and shutdown paths—not only success.
250
+
251
+ ## 6. Async, concurrency, and resources
252
+
253
+ Choose synchronous or asynchronous execution from measured workload and
254
+ dependency requirements. An async runtime is not automatically an architecture.
255
+
256
+ - Do not hold a blocking mutex, database transaction, file handle, or other
257
+ scarce resource across an `.await` unless the ownership and contention are
258
+ explicit and tested.
259
+ - Do not perform blocking filesystem, process, compression, or CPU-heavy work
260
+ on an async executor thread without a deliberate boundary.
261
+ - Bound spawned tasks, channels, queues, retries, and connection pools.
262
+ - Propagate cancellation; do not leave detached tasks that outlive their
263
+ owner without an explicit lifecycle contract.
264
+ - Understand `Send`, `Sync`, `Unpin`, executor affinity, and `Arc` ownership at
265
+ the boundary where they matter.
266
+ - Close or drain streams and pools on shutdown; make the deadline observable.
267
+ - Prefer backpressure over unbounded buffering.
268
+
269
+ For network services, validate request sizes, framing, headers, encodings,
270
+ timeouts, redirects, peer identity, and response limits. For protocol code,
271
+ test partial reads, reordered input, duplicate messages, version skew, and
272
+ connection loss.
273
+
274
+ ## 7. Input, configuration, and security
275
+
276
+ Treat command-line arguments, environment variables, configuration files,
277
+ HTTP requests, messages, files, database results, dependency metadata, and
278
+ FFI values as untrusted until validated.
279
+
280
+ - Parse at the boundary into a constrained type.
281
+ - Reject unknown or dangerous configuration where the contract requires it.
282
+ - Keep defaults explicit and safe; distinguish absent, empty, and invalid.
283
+ - Avoid path traversal, shell injection, unsafe deserialization, SSRF, and
284
+ unbounded allocation.
285
+ - Use least-privilege credentials and avoid secrets in source, logs, lockfile
286
+ comments, examples, generated artifacts, or error messages.
287
+ - Validate authorization in the application boundary, not only in a router or
288
+ command wrapper.
289
+ - Keep cryptographic and protocol decisions tied to the repository's security
290
+ requirements and official documentation.
291
+
292
+ ### Unsafe, FFI, build scripts, and procedural macros
293
+
294
+ Treat `unsafe`, C/C++ FFI, `build.rs`, proc-macro crates, generated bindings,
295
+ linker flags, and native dependencies as explicit trust boundaries.
296
+
297
+ - Minimize the unsafe region and state the invariant it relies on.
298
+ - Validate ownership, alignment, initialization, aliasing, thread safety, and
299
+ lifetime assumptions at the boundary.
300
+ - Audit both sides of an FFI call and test failure, ABI, and cleanup behavior.
301
+ - Keep build scripts deterministic, bounded, and free of undeclared network or
302
+ environment assumptions.
303
+ - Review proc macros and generated code as build-time code with supply-chain
304
+ impact; do not assume generated output is safe because it is generated.
305
+ - Use the repository's established lint policy; do not add a blanket unsafe
306
+ prohibition or a blanket allow merely to make a check green.
307
+
308
+ ## 8. Dependencies, features, and reproducibility
309
+
310
+ Before adding or upgrading a crate, inspect repository policy, MSRV, license,
311
+ advisories, maintenance, transitive graph, feature defaults, native build
312
+ requirements, and target support.
313
+
314
+ - Prefer the smallest dependency and feature set that satisfies the contract.
315
+ - Understand workspace dependency inheritance and resolver behavior.
316
+ - Avoid enabling a large default feature set for a small capability.
317
+ - Keep application builds reproducible with the intended lockfile policy.
318
+ - Use `--locked`, `--frozen`, or `--offline` when the repository or CI requires
319
+ those guarantees; do not weaken them to hide a missing lockfile or network.
320
+ - Do not make network access part of detection or ordinary validation unless
321
+ the repository explicitly requires it and the authority is clear.
322
+
323
+ Document a new dependency's role and runtime/build-time boundary. A Tokio,
324
+ Axum, Actix, Rocket, Hyper, Tower, Tonic, Serde, or database crate may provide
325
+ useful contextual guidance, but it does not create a new public framework
326
+ classification or specialist guide.
327
+
328
+ ## 9. Framework and runtime overlays
329
+
330
+ Apply framework-specific advice only after Cargo and repository evidence have
331
+ confirmed the Rust project. Keep all overlays inside this guide:
332
+
333
+ - **Axum, Actix Web, Rocket, Poem:** validate extraction and serialization,
334
+ middleware order, state ownership, rejection/error mapping, graceful
335
+ shutdown, and route-level authorization.
336
+ - **Hyper and Tower:** preserve service composition, readiness, backpressure,
337
+ body limits, timeout layers, and error semantics.
338
+ - **Tonic:** validate protobuf evolution, metadata/authentication, deadlines,
339
+ streaming cancellation, status mapping, and compatibility.
340
+ - **Tokio or another async runtime:** configure worker behavior deliberately,
341
+ keep blocking work off the executor, bound tasks and channels, and test
342
+ cancellation and shutdown.
343
+ - **Serde and schema-facing code:** make unknown-field, numeric, enum, and
344
+ versioning behavior explicit at the trust boundary.
345
+ - **Database or message clients:** use bounded pools, transaction ownership,
346
+ cancellation, retry/idempotency rules, and migration compatibility.
347
+
348
+ The overlay never overrides the repository's active versions, security policy,
349
+ public contracts, or measured evidence.
350
+
351
+ ## 10. Testing and validation
352
+
353
+ Run the repository's exact commands first. A conventional Cargo validation
354
+ sequence may include:
355
+
356
+ ```text
357
+ cargo fmt --all -- --check
358
+ cargo check --workspace --all-targets --all-features
359
+ cargo clippy --workspace --all-targets --all-features -- -D warnings
360
+ cargo test --workspace --all-features
361
+ cargo doc --workspace --no-deps
362
+ ```
363
+
364
+ Use only the subset that matches repository policy and the changed surface.
365
+ For a library, include public API and doctest coverage. For a service or
366
+ worker, include integration, protocol, shutdown, timeout, and operational
367
+ smoke checks. For a cross-compiled target, validate with the pinned linker and
368
+ target rather than claiming host validation is equivalent.
369
+
370
+ Tests should cover:
371
+
372
+ - valid, missing, malformed, and boundary configuration;
373
+ - ownership, concurrency, cancellation, timeout, retry, and shutdown;
374
+ - authorization and untrusted input rejection;
375
+ - feature combinations and MSRV-sensitive APIs;
376
+ - serialization compatibility and protocol version changes;
377
+ - FFI/build/proc-macro failure and cleanup paths where applicable;
378
+ - generated output and clean-room packaging where those artifacts ship.
379
+
380
+ Do not silence Clippy, skip a workspace member, remove a test, or broaden a
381
+ threshold to make a check green. Diagnose the failure and make the smallest
382
+ coherent correction. If a toolchain or target is unavailable, report the
383
+ exact command as `NOT_VERIFIED`.
384
+
385
+ ## 11. Release and operational readiness
386
+
387
+ Before release, verify the exact commit, active toolchain, MSRV, edition,
388
+ target, feature set, lockfile, generated artifacts, package contents, and
389
+ release notes. For crates.io publication, follow the repository's trusted
390
+ publication workflow and confirm package metadata, README links, license,
391
+ included files, and provenance requirements.
392
+
393
+ For deployed applications and services, also verify:
394
+
395
+ - startup and readiness fail safely when configuration or dependencies are
396
+ unavailable;
397
+ - logs and metrics are useful without exposing sensitive data;
398
+ - timeouts, limits, retries, and graceful shutdown are configured;
399
+ - rollback and schema/protocol compatibility are understood;
400
+ - the exact release artifact was built and tested with the intended target.
401
+
402
+ Do not confuse a green host build with production readiness, or local package
403
+ inspection with publication. Rust channel choice, release cadence, and target
404
+ support remain repository decisions; there is no universal Rust LTS target.
405
+
406
+ ## 12. Definition of done
407
+
408
+ - Cargo structure and affected package/workspace ownership are confirmed.
409
+ - Active toolchain, MSRV, edition, target, resolver, features, and lockfile
410
+ implications are recorded when relevant.
411
+ - The implementation preserves clear ownership, bounded resources, errors,
412
+ cancellation, and shutdown behavior.
413
+ - Untrusted inputs, unsafe/FFI/build boundaries, secrets, and dependencies
414
+ receive explicit controls.
415
+ - Focused regression tests pass, with broader workspace checks proportional to
416
+ the changed risk.
417
+ - Formatting, compiler, lint, test, documentation, and packaging checks are
418
+ run or honestly marked `NOT_VERIFIED`.
419
+ - Documentation and public contracts describe the actual behavior and version
420
+ compatibility.
421
+ - Evidence is tied to the exact revision and no publication or deployment is
422
+ claimed without its trusted external receipt.
@@ -0,0 +1,108 @@
1
+ ---
2
+ name: sql-development-eng
3
+ language: en
4
+ description: "Specialist overlay guidance for SQL schemas, queries, migrations, and database-boundary changes."
5
+ version: "2026.09"
6
+ last-reviewed: "2026-09-12"
7
+ guide-id: sql
8
+ requires-gates:
9
+ - threat-boundary
10
+ completion-evidence:
11
+ - sql-validation
12
+ ---
13
+
14
+ # SQL Development Engineering Guide
15
+
16
+ ## Mission and activation
17
+
18
+ Use this guide as an overlay for a directly affected meaningful SQL artifact,
19
+ or a bounded SQL statement in an owned `db`, `database`, `migration`,
20
+ `migrations`, `schema`, or `sql` directory. SQL has no universal package
21
+ manifest and normally composes with the host specialist: Java + SQL, Go + SQL,
22
+ PHP + SQL, Node.js + SQL, and Rust + SQL are valid same-root outcomes.
23
+
24
+ Comments, quoted string literals, prose, connection strings, driver
25
+ dependencies, database images, empty files, generated output, and vendored SQL
26
+ do not activate this guide. Detection masks single-quoted string values while
27
+ preserving double-quoted, backtick-quoted, and bracket-quoted identifiers as
28
+ internal neutral identifier tokens. It masks `--` and block comments while
29
+ preserving dialect tokens such as PostgreSQL `#>` and `#>>`; it recognizes only
30
+ bounded statement families with structural object/operand tokens and common
31
+ CTE shapes, not complete SQL syntax. It reads
32
+ bounded text and never connects to a database, executes a query, applies a
33
+ migration, reads credentials, or introspects a schema.
34
+
35
+ ## Authority and precedence
36
+
37
+ The repository's database engine, version, migration policy, transaction model,
38
+ compatibility window, and deployment process win over generic SQL advice. Use
39
+ the matching engine's official reference first, then ISO/IEC 9075:2023 for
40
+ portable semantics. The research snapshot covers PostgreSQL 18.6, MySQL 9.7
41
+ Innovation and 8.4 LTS, SQL Server 17 T-SQL, Oracle AI Database 26, and
42
+ SQLite; these are reference points, not automatic upgrade targets.
43
+
44
+ Never infer a dialect, isolation guarantee, identifier rule, timestamp
45
+ behavior, JSON extension, or migration capability from a file extension.
46
+
47
+ ## Schema and query architecture
48
+
49
+ Keep schema ownership, migrations, queries, repositories, domain rules, and
50
+ transport boundaries explicit. Parameterize values and allowlist identifiers,
51
+ sort directions, and dynamic clauses. Review joins, NULL semantics, collation,
52
+ encoding, numeric precision, time zones, recursive queries, constraints,
53
+ indexes, views, triggers, stored procedures, and query result cardinality.
54
+
55
+ Treat query output as untrusted input to application code. Preserve a clear
56
+ mapping between database types and application types and record compatibility
57
+ when a rolling deployment observes old and new schemas simultaneously.
58
+
59
+ ## Transactions, errors, and operations
60
+
61
+ Define transaction ownership, isolation, locking, deadlock/retry behavior,
62
+ timeouts, savepoints, idempotency, and commit boundaries. Do not retry a
63
+ non-idempotent mutation without a durable operation key. Preserve database
64
+ error causes while redacting credentials, connection details, user data, and
65
+ queries from logs and responses.
66
+
67
+ Migrations must be reviewed for locking, backfill cost, indexes, constraints,
68
+ data loss, rollback or roll-forward strategy, concurrent deploys, long-lived
69
+ readers, and observability. A migration that parses successfully is not proof
70
+ that it is safe to run in production.
71
+
72
+ ## Security and performance
73
+
74
+ Prevent injection through parameters and strict identifier composition. Apply
75
+ authorization at the domain boundary, least-privilege database roles, secret
76
+ rotation, TLS policy, audit controls, and data-retention rules. Bound query
77
+ time, rows, result bytes, connections, concurrency, retries, and transaction
78
+ duration. Measure query plans and representative workloads before adding
79
+ indexes, hints, denormalization, caching, or batching.
80
+ Treat `EXPLAIN ANALYZE` as potentially executing the statement; use a safe
81
+ transaction or a representative read-only environment when the engine allows.
82
+
83
+ ## Portability and dependencies
84
+
85
+ Keep dialect-specific syntax explicitly marked and test the actual production
86
+ engine/version. Do not replace a repository's migration tool, driver, schema
87
+ policy, or transaction abstraction incidentally. Database drivers, ORM names,
88
+ package managers, containers, and CI setup are supporting context, not public
89
+ SQL framework IDs.
90
+
91
+ ## Verification and Definition of Done
92
+
93
+ Run SQL lint/parser checks, unit and integration tests against the declared
94
+ engine/version, migration dry runs, compatibility checks, rollback or
95
+ roll-forward tests, query-plan review, and security checks as applicable.
96
+ Record exact dialect, version, schema state, fixtures, and command results.
97
+ Production migration execution and database readiness require separate
98
+ operator evidence. ForgeLoop performs bounded structural SQL-overlay analysis,
99
+ not dialect parsing, query planning, schema introspection, or migration
100
+ execution.
101
+
102
+ ## Official sources
103
+
104
+ - [SQLite SQL language](https://www.sqlite.org/lang.html)
105
+ - [PostgreSQL documentation](https://www.postgresql.org/docs/)
106
+ - [MySQL reference manuals](https://docs.oracle.com/cd/E17952_01/mysql-8.0-en/)
107
+ - [Microsoft T-SQL reference](https://learn.microsoft.com/sql/t-sql/)
108
+ - [Oracle Database SQL Language Reference](https://docs.oracle.com/en/database/oracle/oracle-database/)