@devtrack-solution/codesdd 1.2.4-rc3 → 1.2.4

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 (128) hide show
  1. package/.sdd/skills/curated/devtrack-api/SKILL.md +91 -12
  2. package/.sdd/skills/curated/devtrack-api/agents/claude-code.yaml +2 -0
  3. package/.sdd/skills/curated/devtrack-api/agents/codex.yaml +2 -0
  4. package/.sdd/skills/curated/devtrack-api/agents/cursor.yaml +2 -0
  5. package/.sdd/skills/curated/devtrack-api/agents/gemini.yaml +2 -0
  6. package/.sdd/skills/curated/devtrack-api/agents/kimi.yaml +2 -0
  7. package/.sdd/skills/curated/devtrack-api/agents/openai.yaml +3 -3
  8. package/.sdd/skills/curated/devtrack-api/agents/opencode.yaml +2 -0
  9. package/.sdd/skills/curated/devtrack-api/references/application-presentation.md +59 -3
  10. package/.sdd/skills/curated/devtrack-api/references/consumer-sync-policy.md +15 -3
  11. package/.sdd/skills/curated/devtrack-api/references/contract-pack.yaml +1898 -2
  12. package/.sdd/skills/curated/devtrack-api/references/domain-modeling.md +3 -1
  13. package/.sdd/skills/curated/devtrack-api/references/field-validation-protocol.md +40 -0
  14. package/.sdd/skills/curated/devtrack-api/references/foundation-layout.md +20 -2
  15. package/.sdd/skills/curated/devtrack-api/references/generated-artifact-invalidation.md +97 -0
  16. package/.sdd/skills/curated/devtrack-api/references/implementation-checklist.md +30 -1
  17. package/.sdd/skills/curated/devtrack-api/references/portable-agent-contract.md +4 -3
  18. package/.sdd/skills/curated/devtrack-api/references/testing-validation.md +22 -1
  19. package/.sdd/skills/curated/devtrack-api/references/typeorm-infrastructure.md +9 -5
  20. package/README.md +122 -25
  21. package/dist/cli/program.js +180 -11
  22. package/dist/commands/config.js +27 -1
  23. package/dist/commands/sdd/execution.js +64 -2
  24. package/dist/commands/sdd.js +119 -4
  25. package/dist/core/cli/command-matrix.d.ts +18 -0
  26. package/dist/core/cli/command-matrix.js +148 -0
  27. package/dist/core/cli-command-quality.js +2 -0
  28. package/dist/core/config-schema.d.ts +14 -1
  29. package/dist/core/config-schema.js +32 -1
  30. package/dist/core/config.d.ts +1 -0
  31. package/dist/core/config.js +11 -0
  32. package/dist/core/global-config.d.ts +13 -0
  33. package/dist/core/init.d.ts +2 -2
  34. package/dist/core/init.js +13 -14
  35. package/dist/core/sdd/agent-binding.d.ts +9 -9
  36. package/dist/core/sdd/agent-runtime-contract.d.ts +4 -4
  37. package/dist/core/sdd/allocator-recovery.d.ts +14 -0
  38. package/dist/core/sdd/allocator-recovery.js +30 -0
  39. package/dist/core/sdd/allocator-security.d.ts +18 -0
  40. package/dist/core/sdd/allocator-security.js +36 -0
  41. package/dist/core/sdd/api-foundation-baseline.d.ts +111 -0
  42. package/dist/core/sdd/api-foundation-baseline.js +151 -0
  43. package/dist/core/sdd/api-foundation-parity.d.ts +114 -0
  44. package/dist/core/sdd/api-foundation-parity.js +131 -0
  45. package/dist/core/sdd/api-profile-catalog.d.ts +36 -0
  46. package/dist/core/sdd/api-profile-catalog.js +132 -0
  47. package/dist/core/sdd/api-profile-dry-run-projection.d.ts +93 -0
  48. package/dist/core/sdd/api-profile-dry-run-projection.js +370 -0
  49. package/dist/core/sdd/api-profile-recipes.d.ts +82 -0
  50. package/dist/core/sdd/api-profile-recipes.js +484 -0
  51. package/dist/core/sdd/artifact-id-allocator.d.ts +368 -0
  52. package/dist/core/sdd/artifact-id-allocator.js +510 -0
  53. package/dist/core/sdd/check.d.ts +50 -1
  54. package/dist/core/sdd/check.js +286 -9
  55. package/dist/core/sdd/deepagent-contracts.d.ts +4 -4
  56. package/dist/core/sdd/deepagents/reversa-subagents.d.ts +3 -3
  57. package/dist/core/sdd/default-bootstrap-files.d.ts +1 -1
  58. package/dist/core/sdd/default-bootstrap-files.js +0 -2
  59. package/dist/core/sdd/default-skills.js +7 -5
  60. package/dist/core/sdd/devtrack-api-appliance.d.ts +34 -0
  61. package/dist/core/sdd/devtrack-api-appliance.js +138 -34
  62. package/dist/core/sdd/devtrack-api-architecture.d.ts +16 -0
  63. package/dist/core/sdd/devtrack-api-architecture.js +86 -0
  64. package/dist/core/sdd/docs-sync.js +3 -3
  65. package/dist/core/sdd/enterprise-mutating-command-gate.d.ts +27 -0
  66. package/dist/core/sdd/enterprise-mutating-command-gate.js +104 -0
  67. package/dist/core/sdd/enterprise-provenance-gates.d.ts +20 -0
  68. package/dist/core/sdd/enterprise-provenance-gates.js +63 -0
  69. package/dist/core/sdd/enterprise-provisioning-policy.d.ts +26 -0
  70. package/dist/core/sdd/enterprise-provisioning-policy.js +104 -0
  71. package/dist/core/sdd/governance-schemas.d.ts +2 -2
  72. package/dist/core/sdd/governance-schemas.js +11 -2
  73. package/dist/core/sdd/json-schema.js +4 -0
  74. package/dist/core/sdd/legacy-operations.js +93 -4
  75. package/dist/core/sdd/package-security-gates.js +2 -0
  76. package/dist/core/sdd/package-structure-gate.d.ts +85 -3
  77. package/dist/core/sdd/package-structure-gate.js +386 -8
  78. package/dist/core/sdd/parallel-feat-automation.d.ts +6 -6
  79. package/dist/core/sdd/plugin-policy.js +6 -1
  80. package/dist/core/sdd/plugin-registry.d.ts +3 -3
  81. package/dist/core/sdd/quality-validation.d.ts +5 -5
  82. package/dist/core/sdd/release-readiness.d.ts +49 -0
  83. package/dist/core/sdd/release-readiness.js +303 -8
  84. package/dist/core/sdd/reversa-architecture-extractor.d.ts +13 -0
  85. package/dist/core/sdd/reversa-architecture-extractor.js +89 -0
  86. package/dist/core/sdd/reversa-artifact-writer.d.ts +18 -0
  87. package/dist/core/sdd/reversa-artifact-writer.js +40 -0
  88. package/dist/core/sdd/reversa-command-policy.d.ts +136 -0
  89. package/dist/core/sdd/reversa-command-policy.js +361 -0
  90. package/dist/core/sdd/reversa-data-extractor.d.ts +11 -0
  91. package/dist/core/sdd/reversa-data-extractor.js +73 -0
  92. package/dist/core/sdd/reversa-equivalence.d.ts +20 -0
  93. package/dist/core/sdd/reversa-equivalence.js +34 -0
  94. package/dist/core/sdd/reversa-evidence.d.ts +298 -0
  95. package/dist/core/sdd/reversa-evidence.js +118 -0
  96. package/dist/core/sdd/reversa-reconstruction.d.ts +29 -0
  97. package/dist/core/sdd/reversa-reconstruction.js +32 -0
  98. package/dist/core/sdd/reversa-rules-extractor.d.ts +12 -0
  99. package/dist/core/sdd/reversa-rules-extractor.js +86 -0
  100. package/dist/core/sdd/reversa-source-safety.d.ts +19 -0
  101. package/dist/core/sdd/reversa-source-safety.js +105 -0
  102. package/dist/core/sdd/reversa-surface-scout.d.ts +13 -0
  103. package/dist/core/sdd/reversa-surface-scout.js +85 -0
  104. package/dist/core/sdd/reversa-ux-mapper.d.ts +11 -0
  105. package/dist/core/sdd/reversa-ux-mapper.js +73 -0
  106. package/dist/core/sdd/sdk-agent-plugin-quality-gates.d.ts +1 -1
  107. package/dist/core/sdd/services/archive-quality-coherence.service.d.ts +17 -0
  108. package/dist/core/sdd/services/archive-quality-coherence.service.js +141 -0
  109. package/dist/core/sdd/services/decide.service.js +1 -1
  110. package/dist/core/sdd/services/finalize.service.d.ts +2 -0
  111. package/dist/core/sdd/services/finalize.service.js +48 -2
  112. package/dist/core/sdd/services/historical-quality-regression.service.d.ts +35 -0
  113. package/dist/core/sdd/services/historical-quality-regression.service.js +228 -0
  114. package/dist/core/sdd/services/ingest-deposito.service.js +1 -1
  115. package/dist/core/sdd/services/planning-execution-coherence.service.d.ts +45 -0
  116. package/dist/core/sdd/services/planning-execution-coherence.service.js +225 -0
  117. package/dist/core/sdd/state.js +15 -5
  118. package/dist/core/sdd/types.d.ts +3 -3
  119. package/dist/core/sdd/workspace-schemas.d.ts +45 -4
  120. package/dist/core/sdd/workspace-schemas.js +27 -6
  121. package/dist/core/shared/skill-generation.d.ts +2 -0
  122. package/dist/core/shared/skill-generation.js +19 -2
  123. package/dist/core/shared/tool-detection.d.ts +19 -0
  124. package/dist/core/shared/tool-detection.js +89 -0
  125. package/package.json +6 -5
  126. package/schemas/sdd/5-quality.schema.json +43 -0
  127. package/schemas/sdd/reversa-evidence-bundle.schema.json +466 -0
  128. package/schemas/sdd/workspace-catalog.schema.json +511 -0
@@ -198,7 +198,8 @@ export class Example
198
198
  Rules:
199
199
 
200
200
  - Extend `GenericBusinessObject<T>` when the object owns invariants.
201
- - Implement `IValidator` when following the canonical BO pattern.
201
+ - Implement the BO interface first and `IValidator` second: `implements <Name>Interface, IValidator`.
202
+ - Keep the class declaration ordered as `extends GenericBusinessObject<T>` before `implements ...`.
202
203
  - Validate before transform through `GenericBusinessObject` constructor behavior.
203
204
  - Normalize data in `loadData` or `transform`.
204
205
  - Expose read-only getters; clone arrays/objects/dates to avoid external mutation.
@@ -207,6 +208,7 @@ Rules:
207
208
  - Throw domain exceptions, usually `BusinessValidationException`, not HTTP exceptions.
208
209
  - Do not inject repositories, services, loggers, config, SDKs, or framework dependencies into domain objects.
209
210
  - Do not publish events, send messages, call providers, or persist data from the domain object directly.
211
+ - The observed `src/domain/auth/business-objects/api-keys.bo.ts` static utility is a named Foundation exception. Do not use it as the model for new aggregate BO files.
210
212
 
211
213
  ## Value Objects: `.vo.ts`
212
214
 
@@ -93,3 +93,43 @@ CodeSDD may close the field-validation expectation only when:
93
93
  - the evidence remains in the consumer repository, with only a summary and reference retained here.
94
94
 
95
95
  If this evidence is not yet available, CodeSDD should keep a follow-up SDD item or formal exception instead of claiming field adoption is proven.
96
+
97
+ ## FEAT-0378 Consumer Evidence Summary
98
+
99
+ FEAT-0378 records the EPIC-0080 consumer-field validation boundary without importing private consumer ledgers into this repository.
100
+
101
+ Summary reference packet:
102
+
103
+ ```yaml
104
+ devtrack_api_field_validation_summary:
105
+ protocol: devtrack-api-field-validation-v1
106
+ feature_ref: FEAT-0378
107
+ governing_decision_ref: ADR-FEAT-0378
108
+ profile: foundation-compatible
109
+ codesdd_source_ref: FEAT-0378 active workspace
110
+ foundation_source_ref: devtrack-foundation-api audited projection via FEAT-0373 through FEAT-0376
111
+ sync_evidence_ref: consumer-sync-policy.md#feat-0378-consumer-evidence-sync-rule
112
+ private_ledger_boundary: consumer-held evidence only; do not copy ledgers into CodeSDD
113
+ consumer_evidence_refs:
114
+ - ref: consumer-owned-devtrack-api-deb-1
115
+ kind: approved_owner_reference
116
+ ledger_location: consumer CodeSDD quality ledger or handoff
117
+ status: accepted_exception
118
+ - ref: consumer-owned-devtrack-api-deb-2
119
+ kind: approved_owner_reference
120
+ ledger_location: consumer CodeSDD quality ledger or handoff
121
+ status: accepted_exception
122
+ divergence_matrix:
123
+ D-01: accepted_exception
124
+ D-02: accepted_exception
125
+ D-03: accepted_exception
126
+ D-04: accepted_exception
127
+ D-05: accepted_exception
128
+ D-06: accepted_exception
129
+ D-07: accepted_exception
130
+ D-08: accepted_exception
131
+ accepted_exception_ref: ADR-FEAT-0378
132
+ open_policy_findings: []
133
+ ```
134
+
135
+ The `accepted_exception` status above is a privacy-preserving governance closure, not a copy of consumer evidence. Operators must resolve each opaque `consumer-owned-*` reference in the consumer repository before using the packet to claim field adoption for that consumer. If either reference cannot be resolved, the consuming project remains blocked or excepted under its own CodeSDD quality ledger.
@@ -58,6 +58,18 @@ Folders forbidden in BO-pattern:
58
58
  - `events/` — emit domain events from application use cases, not domain artifacts, when the context is BO-pattern. Foundation emits events from application handlers.
59
59
  - `validators/` — present only in legacy entity-pattern; BO-pattern validates inside the BO (`validate()` method).
60
60
 
61
+ Canonical BO class shape for new aggregate/business objects:
62
+
63
+ ```text
64
+ export class <Name>
65
+ extends GenericBusinessObject<<Name>Type.Output>
66
+ implements <Name>Interface, IValidator
67
+ ```
68
+
69
+ Order matters: `extends GenericBusinessObject<T>` first, then `implements <Name>Interface, IValidator`. The BO interface declares read-only getters, behavior methods, and `toPersistenceObject()`. The class validates through `public validate(...)`, normalizes through `protected transform(...)` or `static loadData(...)`, exposes read-only getters, and returns domain persistence data from `toPersistenceObject()`.
70
+
71
+ Observed exception in the current Foundation tree: `src/domain/auth/business-objects/api-keys.bo.ts` is a static domain utility named `ApiKeysDomain`; do not use it as the template for new aggregate BOs.
72
+
61
73
  Contexts currently using BO-pattern in Foundation:
62
74
 
63
75
  | Context | Path | Notes |
@@ -206,12 +218,17 @@ src/infrastructure/adapters/orm/entities/<name>.orm-entity.ts
206
218
  src/infrastructure/adapters/orm/repositories/<name>.typeorm-repository.ts
207
219
  src/infrastructure/adapters/orm/mappers/<name>.mapper.ts
208
220
  src/infrastructure/adapters/orm/migrations/<timestamp>-<action>.migration.ts
209
- src/infrastructure/adapters/orm/orm.module.ts
221
+ src/infrastructure/adapters/orm/typeorm.module.ts
222
+ src/infrastructure/adapters/orm/<context>-orm.module.ts
210
223
  src/infrastructure/adapters/orm/typeorm.config.ts
211
224
  src/infrastructure/adapters/orm/typeorm-cli.datasource.ts
212
225
  ```
213
226
 
214
- The ORM subsystem has one Nest module only: `src/infrastructure/adapters/orm/orm.module.ts`. It registers TypeORM entities, concrete `*.typeorm-repository.ts` providers, mapper dependencies when needed, and exports the repository providers/tokens required by application ports. Do **not** create per-context or per-entity modules such as `auth-orm.module.ts`, `pessoas-orm.module.ts`, `wallets-orm.module.ts`, or `sync-engine-orm.module.ts`. Do **not** create `src/infrastructure/<context>/persistence/typeorm/`.
227
+ Observed ORM modules in Foundation: `auth-orm.module.ts`, `pessoas-orm.module.ts`, `sync-engine-orm.module.ts`, `typeorm.module.ts`, `wallets-orm.module.ts`.
228
+
229
+ `typeorm.module.ts` is the root TypeORM module. It calls `TypeOrmModule.forRootAsync`, references `typeorm.config.ts`, and registers base entities through `TypeOrmModule.forFeature`.
230
+
231
+ `<context>-orm.module.ts` files are context-level provider modules. They import `TypeOrmModule.forFeature([...])`, register concrete `*.typeorm-repository.ts` adapters, bind the owning repository/service port symbols with `useExisting`, and export those port symbols. Do **not** create entity-specific modules such as `category-entity-orm.module.ts` or any `src/infrastructure/<context>/persistence/typeorm/` tree.
215
232
 
216
233
  ### 5.2 Adapter ports (shared)
217
234
 
@@ -275,6 +292,7 @@ Aliases are mandatory in `src/` and tests. Same-folder relative imports are forb
275
292
  | `src/infrastructure/<context>/persistence/typeorm/` | `src/infrastructure/adapters/orm/` |
276
293
  | `src/infrastructure/<context>/adapters/` | `src/infrastructure/adapters/<subsystem>/` |
277
294
  | `src/infrastructure/<context>/repositories/` | `src/infrastructure/adapters/orm/repositories/` |
295
+ | `src/infrastructure/adapters/orm/<entity>-orm.module.ts` | `src/infrastructure/adapters/orm/<context>-orm.module.ts` |
278
296
  | `src/presentation/<context>/` (no transport) | `src/presentation/rest/<context>/` (or other transport) |
279
297
  | `entities/` in new domain context | `business-objects/` |
280
298
  | `repository-ports/` in new domain context | application `ports/out/<name>-repository.port.ts` |
@@ -0,0 +1,97 @@
1
+ # devtrack-api Generated Artifact Invalidation
2
+
3
+ ## Scope
4
+
5
+ This policy governs generated `devtrack-api` previews, scaffold dry-runs, caches, artifact maps, validation manifests, and evidence bundles created before the EPIC-0080 Foundation-compatible gates became active.
6
+
7
+ It applies to artifacts produced or consumed by:
8
+
9
+ - `codesdd sdd plugin devtrack-api scaffold-dry-run`;
10
+ - package-structure previews and `human_validation_gate` payloads;
11
+ - Foundation artifact maps and semantic validator results;
12
+ - generated evidence stored in `.sdd/plugin-evidence/`, `.sdd/active/`, `.sdd/archived/`, `outputs/`, or disposable `~/.codesdd/cache` entries.
13
+
14
+ ## Default Rule
15
+
16
+ Pre-charter generated artifacts are noncanonical by default. They are evidence only until revalidated against the active `foundation-compatible` contract.
17
+
18
+ An artifact must not be treated as Foundation-compatible when it lacks any of the following:
19
+
20
+ - selected derivation profile;
21
+ - artifact-map validation result;
22
+ - package preview material signature;
23
+ - `human_validation_gate.status` using only `approved`, `corrected`, `pending`, or `rejected`;
24
+ - semantic validator profile outcome for `foundation-compatible`;
25
+ - sync evidence for the `devtrack-api` skill copy when the artifact came from a consumer repository;
26
+ - D-01 through D-08 field-validation summary or formal exception when the artifact claims consumer adoption.
27
+
28
+ ## Classification
29
+
30
+ Use exactly one classification per generated artifact:
31
+
32
+ | Classification | Meaning | Required action |
33
+ | --- | --- | --- |
34
+ | `revalidated` | The artifact was regenerated or checked against the active contract and passed the applicable profile gates. | Record command, profile, validator output, material signature, and approval state in the owning FEAT quality ledger. |
35
+ | `invalidated` | The artifact predates active gates, fails P0 validation, has stale approval, or cannot be traced to current sources. | Mark noncanonical, exclude from Foundation-compatible claims, and regenerate before use. |
36
+ | `grandfathered` | The artifact remains useful as historical evidence but is not used as an executable or compatibility claim. | Record owner, scope, reason, review deadline, rollback trigger, and governing ADR/FEAT quality entry. |
37
+ | `not_applicable` | The artifact is unrelated to `devtrack-api` generated output or is disposable cache without governance value. | Keep disposable or ignore; do not promote to CodeSDD state. |
38
+
39
+ ## Revalidation Procedure
40
+
41
+ Before reusing a legacy generated artifact:
42
+
43
+ 1. Identify the artifact owner, path, generator command, source commit or release, selected profile, and creation time when available.
44
+ 2. Re-run the active non-mutating generator or validator for the same intent.
45
+ 3. Compare the current artifact map and preview material signature with the legacy artifact.
46
+ 4. Run semantic validation for the selected profile.
47
+ 5. Reset any prior `approved` or `corrected` `human_validation_gate.status` to `pending` when source material, profile, exception refs, artifact map, preview structure, or validator scope changed.
48
+ 6. Record the classification in the owning FEAT quality ledger.
49
+
50
+ Minimum validation commands:
51
+
52
+ ```bash
53
+ codesdd sdd plugin devtrack-api scaffold-dry-run
54
+ codesdd sdd check --render
55
+ codesdd sdd diagnose --json
56
+ ```
57
+
58
+ When source code or TypeScript validator contracts changed, also run the targeted validator tests:
59
+
60
+ ```bash
61
+ pnpm exec vitest run test/core/sdd/devtrack-api-appliance.test.ts test/core/sdd/foundation-artifact-map-validator.test.ts test/core/sdd/package-structure-gate.test.ts test/core/sdd/devtrack-api-architecture.test.ts
62
+ ```
63
+
64
+ ## Invalidation Triggers
65
+
66
+ Invalidate or reset approval for a generated artifact when any trigger applies:
67
+
68
+ - artifact predates `ADR-FEAT-0373`;
69
+ - artifact predates artifact-map gate evidence from `ADR-FEAT-0374`;
70
+ - package preview lacks the FEAT-0375 material signature or Foundation `tests/` projection;
71
+ - semantic validator output lacks FEAT-0376 drift classes or profile outcomes;
72
+ - consumer field-validation references changed after `ADR-FEAT-0378`;
73
+ - artifact uses plural CodeSDD roots as `devtrack-api` output;
74
+ - artifact uses forbidden Foundation alias shapes or omits `@tests/*`;
75
+ - artifact lacks provenance for source refs, decision refs, profile, or exception refs;
76
+ - disposable cache cannot be tied to the current project fingerprint.
77
+
78
+ ## Grandfathering Rule
79
+
80
+ Grandfathering never means compatible. It means the artifact remains useful for history, comparison, or rollback only.
81
+
82
+ A grandfathered artifact must record:
83
+
84
+ - owner;
85
+ - artifact path or opaque reference;
86
+ - reason;
87
+ - accepted risk;
88
+ - compensating control;
89
+ - review deadline;
90
+ - rollback trigger;
91
+ - governing ADR, DEB, or FEAT quality entry.
92
+
93
+ ## Closure Rule
94
+
95
+ EPIC-0080 closure may cite legacy generated artifacts only when every cited artifact is `revalidated`, `invalidated`, `grandfathered`, or `not_applicable`.
96
+
97
+ Any uncategorized legacy artifact blocks the compatibility claim it supports. Disposable cache may be ignored only when it is not referenced by a FEAT quality ledger, ADR, preview, artifact map, validator result, or consumer evidence summary.
@@ -20,6 +20,22 @@
20
20
  - Keep the scope narrow; do not repair unrelated architecture unless it blocks the requested work.
21
21
  - Prefer local patterns over generic best practices when both are valid.
22
22
 
23
+ ## Tool-Level API Baseline Pass
24
+
25
+ - For API, backend, scaffold, CRUD, or route work, infer the minimum operational API baseline unless the user explicitly selected a prototype/docs-only exception.
26
+ - The plan asks whether authentication is required and which mechanism applies: JWT bearer, API key, session, machine-to-machine credential, or public route.
27
+ - The plan asks whether authorization is required and which role, permission, policy, ownership, or tenancy rule applies.
28
+ - Public routes are explicitly named; lack of auth/authz discussion is not treated as public by default.
29
+ - New API projects/scaffolds include `package.json`, `.env.example`, `tsconfig.json`, Nest CLI config, lint/test config, and validation commands.
30
+ - Root scripts include build, start, development start, production start, lint, unit tests, coverage, e2e tests, and migrations when persistent schema changes exist.
31
+ - Root scripts include `cleanup` and `cleanup:install`; cleanup removes dependency installs, build output, caches, lockfiles, and TypeScript compilation residue unless an ADR preserves a canonical lockfile.
32
+ - `start` and `start:dev` invoke `node scripts/kill-port.js` before Nest starts and continue after terminating any process bound to the configured port.
33
+ - Scripts can be invoked with `npm run` and `pnpm run`; nested package-script calls use `npm run` and `npm install` so Docker builds do not need pnpm by default.
34
+ - `.env.example` uses placeholders for new variables and includes Swagger server settings when OpenAPI is configured.
35
+ - REST APIs include root Swagger/OpenAPI bootstrap with `DocumentBuilder`, `SwaggerModule.createDocument`, and `SwaggerModule.setup("docs", app, document)`.
36
+ - Each user-facing route has an application input port plus use case before controller wiring is considered complete.
37
+ - Protected routes include route guards/decorators and Swagger security documentation.
38
+
23
39
  ## Design Slice
24
40
 
25
41
  - Identify touched layers.
@@ -29,6 +45,7 @@
29
45
  - Decide whether persistence needs a domain repository port or an application output port.
30
46
  - Decide whether a public endpoint is appropriate. Internal AWS lifecycle work should not get public endpoints.
31
47
  - Decide whether the change affects API contracts, migrations, environment variables, queues, LLM tools, prompts, or security-sensitive behavior.
48
+ - For each route, name the input port, use case, controller/transport, request DTO/presentation validator, response DTO when applicable, guard/decorator, and Swagger operation/response docs.
32
49
 
33
50
  ## Domain Pass
34
51
 
@@ -78,7 +95,7 @@
78
95
  - Mapper ends with `.mapper.ts`.
79
96
  - Repository implements a port.
80
97
  - Mapper is stateless and maps domain <-> ORM only.
81
- - New entity is added to TypeORM config, CLI datasource, the single `orm.module.ts`, and infrastructure module as needed.
98
+ - New entity is added to TypeORM config, CLI datasource, `typeorm.module.ts`, the owning `<context>-orm.module.ts`, and infrastructure module as needed.
82
99
  - Migration SQL matches entity decorators.
83
100
  - Unique violations are translated to domain/shared exceptions.
84
101
  - No Prisma artifacts.
@@ -98,12 +115,24 @@
98
115
  - No unhandled promises.
99
116
  - No broad lint disables without a narrow reason.
100
117
 
118
+ ## Root Package And Runtime Pass
119
+
120
+ - `package.json` contains scripts needed to build, run, lint, test, collect coverage, run e2e, cleanup, cleanup:install, and execute migrations when applicable.
121
+ - `scripts/cleanup.sh` removes dependency installs, build outputs, caches, lockfiles, and compilation residue unless a FEAT/ADR records a narrower cleanup contract.
122
+ - `scripts/kill-port.js` supports explicit script arguments and `PORT`/`APP_PORT`, covers Unix and Windows termination paths, and is wired before `start` and `start:dev`.
123
+ - Script composition uses `npm run` and `npm install` internally so `npm` and `pnpm` entrypoints remain valid without requiring pnpm in Docker.
124
+ - `package.json` includes `@nestjs/swagger` for REST APIs with OpenAPI docs.
125
+ - `.env.example` exists and documents every new runtime variable with safe placeholder values.
126
+ - `src/main.ts` wires global validation and Swagger/OpenAPI when REST is present.
127
+ - Runtime configuration reads Swagger server settings through typed config instead of hard-coded secrets or deployment URLs.
128
+
101
129
  ## Security And Data Pass
102
130
 
103
131
  - No secrets, tokens, private keys, cookies, credentials, or connection strings are added to code, tests, docs, logs, prompts, or handoff.
104
132
  - `.env.example` is updated when variable names change; `.env` real values are not copied.
105
133
  - Logs avoid sensitive payloads, raw prompts, full provider responses, and personal data unless existing policy allows it.
106
134
  - Auth, authorization, tenancy, encryption, PII, retention, and audit behavior are unchanged unless the task requires it.
135
+ - Auth/authz planning decisions are not left pending for new routes; protected routes have guards/decorators and public routes have explicit exceptions.
107
136
  - Destructive operations are not executed unless explicitly requested and scoped.
108
137
  - Public endpoints do not expose internal lifecycle envelopes or infrastructure payloads.
109
138
 
@@ -1,12 +1,13 @@
1
1
  # Portable Agent Contract
2
2
 
3
- Use this reference when adapting `devtrack-api` for Codex, Claude Code, Cursor, Gemini, Kimi, OpenCode, or any markdown/CLI coding agent.
3
+ Use this reference when adapting the CodeSDD API profile family through the `devtrack-api` compatibility skill for Codex, Claude Code, Cursor, Gemini, Kimi, OpenCode, or any markdown/CLI coding agent.
4
4
 
5
5
  ## Common Rules
6
6
 
7
- - The `SKILL.md` frontmatter is the trigger surface; keep `name: devtrack-api` and a direct description of NestJS, TypeORM, DDD, Clean Architecture, CodeSDD, and Foundation-compatible API work.
7
+ - The `SKILL.md` frontmatter is the compatibility trigger surface; keep `name: devtrack-api`, but public API work should name one of `minimal-rest`, `rest-auth-rbac`, `rest-crud-typeorm`, `evented-api`, `ai-agent-api`, or `full-foundation-compatible`.
8
8
  - The body is the runtime contract; detailed Foundation rules live in `references/`.
9
9
  - Agent-specific files in `agents/` are adapters, not separate sources of truth.
10
+ - `devtrack-api` is a compatibility-only alias and must not be presented as the normal public profile for new API projects.
10
11
  - CodeSDD state remains canonical for planning, quality, and finalize evidence.
11
12
  - `devtrack-foundation-api` source and the Foundation layout reference win over generated assumptions.
12
13
  - Do not persist hidden memory or parallel backlog outside `.sdd`.
@@ -30,7 +31,7 @@ Use this reference when adapting `devtrack-api` for Codex, Claude Code, Cursor,
30
31
  Every agent must leave enough evidence for another agent to continue:
31
32
 
32
33
  - files changed and why;
33
- - selected derivation profile from `contract-pack.yaml`;
34
+ - selected CodeSDD API profile id and selected derivation governance profile from `contract-pack.yaml`;
34
35
  - Foundation source/layout evidence used;
35
36
  - relevant DTAPI rule ids checked;
36
37
  - validation commands run, skipped, or unavailable;
@@ -28,10 +28,31 @@ pnpm migration:show
28
28
  pnpm migration:run
29
29
  ```
30
30
 
31
- Use `pnpm` because the repo is configured around it.
31
+ Use `pnpm` for this CodeSDD repository because the repo is configured around it.
32
32
 
33
33
  Before using a script for a version-sensitive claim, confirm it exists in `package.json`.
34
34
 
35
+ For generated or linked DevTrack API projects, package scripts must also be
36
+ valid through `npm run`. When runtime scripts are touched, validate or inspect
37
+ both entrypoints:
38
+
39
+ ```bash
40
+ npm run build
41
+ npm run start -- --help
42
+ npm run start:dev -- --help
43
+ npm run cleanup
44
+ npm run cleanup:install
45
+ pnpm run build
46
+ pnpm run start:dev -- --help
47
+ ```
48
+
49
+ Generated package-script composition must use `npm run` and `npm install`
50
+ internally so Docker images do not require pnpm by default. `start` and
51
+ `start:dev` must run `node scripts/kill-port.js` before Nest starts, and
52
+ `cleanup` must remove dependency installs, build outputs, caches, lockfiles,
53
+ and TypeScript compilation residue unless a FEAT/ADR records a narrower
54
+ cleanup contract.
55
+
35
56
  ## Test Selection
36
57
 
37
58
  Choose the smallest useful validation:
@@ -32,11 +32,14 @@ src/infrastructure/adapters/orm/entities/<name>.orm-entity.ts
32
32
  src/infrastructure/adapters/orm/mappers/<name>.mapper.ts
33
33
  src/infrastructure/adapters/orm/repositories/<name>.typeorm-repository.ts
34
34
  src/infrastructure/adapters/orm/migrations/<timestamp>-<action>.migration.ts
35
- src/infrastructure/adapters/orm/orm.module.ts
35
+ src/infrastructure/adapters/orm/typeorm.module.ts
36
+ src/infrastructure/adapters/orm/<context>-orm.module.ts
36
37
  src/infrastructure/adapters/orm/typeorm.config.ts
37
38
  src/infrastructure/adapters/orm/typeorm-cli.datasource.ts
38
39
  ```
39
40
 
41
+ Observed ORM modules in Foundation: `auth-orm.module.ts`, `pessoas-orm.module.ts`, `sync-engine-orm.module.ts`, `typeorm.module.ts`, `wallets-orm.module.ts`.
42
+
40
43
  ## ORM Entities
41
44
 
42
45
  Pattern:
@@ -180,7 +183,7 @@ Rules:
180
183
  - Do not leak `Repository`, `QueryRunner`, `DataSource`, or ORM entities through ports.
181
184
  - Keep transaction ownership explicit and aligned with existing repository/unit-of-work patterns.
182
185
 
183
- ## ORM Module
186
+ ## ORM Modules
184
187
 
185
188
  Pattern:
186
189
 
@@ -203,10 +206,10 @@ import { ExampleTypeOrmRepository } from '@infrastructure/adapters/orm/repositor
203
206
  ],
204
207
  exports: [ExampleRepositoryPortSymbol],
205
208
  })
206
- export class OrmModule {}
209
+ export class ExampleOrmModule {}
207
210
  ```
208
211
 
209
- The ORM subsystem must have one Nest module only: `src/infrastructure/adapters/orm/orm.module.ts`. Do not create `*-orm.module.ts` files per entity, context, or feature. Add every new `*.typeorm-repository.ts` provider to this module and export the repository provider and/or its application port token from this module.
212
+ Foundation uses `src/infrastructure/adapters/orm/typeorm.module.ts` for root TypeORM configuration and `src/infrastructure/adapters/orm/<context>-orm.module.ts` for repository provider modules. Add a new context module when a new persisted context introduces repositories. Do not create per-entity modules; module ownership is by context.
210
213
 
211
214
  ## TypeORM Root Wiring
212
215
 
@@ -214,7 +217,8 @@ When adding a new ORM entity, update all relevant places:
214
217
 
215
218
  - `src/infrastructure/adapters/orm/typeorm.config.ts`
216
219
  - `src/infrastructure/adapters/orm/typeorm-cli.datasource.ts`
217
- - `src/infrastructure/adapters/orm/orm.module.ts`
220
+ - `src/infrastructure/adapters/orm/typeorm.module.ts`
221
+ - `src/infrastructure/adapters/orm/<context>-orm.module.ts`
218
222
  - `src/infrastructure/infrastructure.module.ts`
219
223
 
220
224
  Do not rely on glob entity discovery for new application entities unless the repo switches to that pattern.