@happyvertical/smrt-vitest 0.61.3 → 0.61.5

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/AGENTS.md CHANGED
@@ -245,6 +245,51 @@ beforeEach(async () => {
245
245
  afterEach(async () => { await cleanup(); }); // rolls back transaction
246
246
  ```
247
247
 
248
+ ## Minimal rows (#4924)
249
+
250
+ `@happyvertical/smrt-vitest/minimal-row` is a test-only subpath. It imports
251
+ Vitest; the main entry does not import it. Each model package keeps this file
252
+ at `src/__tests__/minimal-row.generated.test.ts`:
253
+
254
+ ```typescript
255
+ import { registerMinimalRowTests } from '@happyvertical/smrt-vitest/minimal-row';
256
+
257
+ await registerMinimalRowTests();
258
+ ```
259
+
260
+ The active test manifest loads real models and collections. ObjectRegistry
261
+ drives one create/save/get/list test per model. Each attempt owns a fresh SQLite
262
+ database, including required parent rows. Optional inputs are omitted and
263
+ readback must be empty/default. Required tenant fields are populated. Required
264
+ parents share the tenant even when their own tenancy is optional. Repeated named
265
+ relationship targets share one persisted parent identity within a fixture graph;
266
+ distinct roles retain distinct rows.
267
+ Framework bases, abstract models, test fixtures and collections are reported
268
+ with their skip reasons. Missing constructors fail; metadata stubs are not tests.
269
+
270
+ `buildMinimalRow(modelName, { db })` returns required input and creates required
271
+ parents on that database. Reuse it as service seed data. The touched-package
272
+ gate in `TESTING_STANDARD.md` also requires one minimal-row run per service.
273
+
274
+ `src/minimal-row-expected-failures.ts` records known defects by qualified model,
275
+ field, kind, stable error excerpt and reason. Kinds are `optional-field`
276
+ (the original default), `service-only`, `needs-domain-value` and
277
+ `undeclared-parent`. A field path
278
+ can identify a required parent's finding; comma-separated fields identify
279
+ combined guards. Entries can only shrink. Service-only entries use
280
+ `(service-only write)` and name the owning service/command in the reason.
281
+ Each such owner must run once against a minimal row under the per-service
282
+ release requirement, asserting its supported write/result or documented refusal.
283
+ Domain-value entries describe the concrete registered value or domain context
284
+ that field metadata cannot generate. Findings are reported separately by kind.
285
+ Parents resolve only inside the package under test and the `@happyvertical/smrt-*`
286
+ packages it declares, transitively (dependencies, peer, dev), which is what a
287
+ Turbo `^build` shard has built. A required parent elsewhere is refused whether or
288
+ not that package happens to be built; when it cannot be declared (a dependency
289
+ cycle), record it as `undeclared-parent`, field = the required reference.
290
+ Every listed model still runs; a newly passing model fails with “remove this entry”. A changed failure also fails.
291
+ `src/__tests__/minimal-row-workspace.test.ts` guards package coverage.
292
+
248
293
  ## Singleton Cache Gotcha
249
294
 
250
295
  Module-level singleton caches (common in SMRT collections) persist across tests, ignoring new mocks.
package/README.md CHANGED
@@ -124,6 +124,42 @@ Measured on a 333-file, 3,259-test unit suite, 16 cores (#2897, follow-up to #28
124
124
 
125
125
  ## API
126
126
 
127
+ ### Minimal-row contracts
128
+
129
+ Every package declaring models keeps this generated test in
130
+ `src/__tests__/minimal-row.generated.test.ts`:
131
+
132
+ ```typescript
133
+ import { registerMinimalRowTests } from '@happyvertical/smrt-vitest/minimal-row';
134
+
135
+ await registerMinimalRowTests();
136
+ ```
137
+
138
+ The shared test loads real models and collections from the active test manifest.
139
+ ObjectRegistry supplies the model list. Each model gets its own SQLite database
140
+ and a create/save/get/list round trip. Required parents are created first.
141
+ Optional inputs stay empty or at their defaults. Failures identify the model
142
+ and optional field when the error or a single-field probe can identify it.
143
+ Framework bases, abstract models, test fixtures and collection classes report
144
+ their skip reasons. Known findings stay in a shared shrinking ledger by model,
145
+ field, stable error excerpt and kind: optional-field, service-only or
146
+ needs-domain-value. Service-only tests assert the owning service's exact direct
147
+ write refusal; domain-value entries describe the value/context metadata cannot
148
+ supply. A changed error fails. A listed model that passes fails with an
149
+ instruction to remove its entry.
150
+
151
+ The same subpath exports `buildMinimalRow(modelName, { db })` for service seed
152
+ data. It returns required input only and saves required parents on `db`.
153
+ Required tenant fields are filled; optional tenant fields on the model under
154
+ test are omitted. Required parents inherit the same tenant, including optionally
155
+ scoped parents. Repeated named relationships reuse the same ancestor identity;
156
+ different roles retain different rows. The `TESTING_STANDARD.md` release gate
157
+ requires each touched package's services to run once against these minimal rows,
158
+ including the named owner of every service-only model.
159
+
160
+ This subpath imports Vitest and belongs in test code. The main package entry
161
+ does not import Vitest globals.
162
+
127
163
  ### Plugin
128
164
 
129
165
  | Export | Description |