Skip to content

Commit 8321cd4

Browse files
fix(docs): make the reference schema actually valid
Validated the schema block with prisma@7.9.0 instead of trusting it by inspection. It reported 182 errors; the causes were three: - Prisma enums require one value per line. Writing them compactly produced 146 cascading errors, including bogus "attribute not known" reports on perfectly good @@index lines. - Organization declared assets, alerts, risks, incidents and documents, but those models had no inverse relation field. Prisma needs both sides, so the FK that guarantees a record cannot outlive its tenant was missing. - Prisma 7 removed url from the datasource block: the connection string now belongs to prisma.config.ts and to a driver adapter passed to PrismaClient. Documented, with the consequence for our env variables. The schema now validates. Also corrected two internal inconsistencies: ScoreBreakdown is generic over its band, because a vessel is READY while an organization is NORMAL and neither vocabulary should be assignable to the other; and the Phase 6 acceptance criterion no longer promises a band transition that the formula does not produce (100 to 85 is still Ready) — it asserts the arithmetic instead. A test that demanded a band change would push someone to inflate the asset weight to make it pass. Documenting a schema that does not compile is the same failure this project criticises elsewhere, so DATABASE.md now records that it was verified.
1 parent 652b010 commit 8321cd4

6 files changed

Lines changed: 217 additions & 39 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ real commands, verified, and not before.
123123

124124
From Phase 1 onward, no phase is considered done until all of these pass in CI:
125125

126-
```
126+
```text
127127
lint · typecheck · unit + integration tests · build · secret scan
128128
```
129129

docs/API.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ Rules:
3838
depend on the schema's shape, and a Prisma type leaking into a component takes fields with it
3939
that were never meant to be rendered.
4040
* Reads are never cached across tenants. Cache tags always include the organization id:
41-
`revalidateTag(\`org:${ctx.organizationId}:vessels\`)`.
41+
``revalidateTag(`org:${ctx.organizationId}:vessels`)``.
4242
* Pagination is mandatory on list queries.
4343

4444
```ts

docs/ARCHITECTURE.md

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ flowchart TB
106106

107107
### 3.2 The dependency rule
108108

109-
```
109+
```text
110110
presentation → application → domain
111111
112112
infrastructure
@@ -231,7 +231,7 @@ Two scores, one formula family, always returned **with a breakdown**.
231231
232232
**Vessel Readiness Score (VRS), 0–100** — weighted mean of four sub-scores:
233233
234-
```
234+
```text
235235
VRS = round(0.30·W + 0.30·A + 0.20·R + 0.20·O)
236236
```
237237
@@ -256,10 +256,19 @@ status panel: `≥85 Normal`, `70–84 Attention`, `50–69 Warning`, `<50 Criti
256256
257257
Every score returns:
258258
259+
The two scores share the formula machinery but **not** their band vocabulary: a vessel is
260+
`READY / ATTENTION / RESTRICTED / CRITICAL`, while the organization-level panel reads
261+
`NORMAL / ATTENTION / WARNING / CRITICAL`. Same numeric cut-offs, different words, because "this
262+
vessel is restricted" and "the operation is in warning" are different statements. The type is
263+
generic over the band so neither set can be assigned where the other belongs:
264+
259265
```ts
260-
type ScoreBreakdown = {
266+
type VesselBand = 'READY' | 'ATTENTION' | 'RESTRICTED' | 'CRITICAL'
267+
type OperationalStatus = 'NORMAL' | 'ATTENTION' | 'WARNING' | 'CRITICAL'
268+
269+
type ScoreBreakdown<Band extends string> = {
261270
total: number
262-
band: 'READY' | 'ATTENTION' | 'RESTRICTED' | 'CRITICAL'
271+
band: Band
263272
degraded: boolean // some input was missing
264273
factors: Array<{
265274
key: 'weather' | 'assets' | 'risks' | 'alerts'
@@ -287,7 +296,7 @@ server-side. Illegal transitions return a typed error; every accepted transition
287296
288297
**Read (Server Component):**
289298
290-
```
299+
```text
291300
page.tsx (RSC) → features/x/queries/getX(ctx, params)
292301
tenant-scoped Prisma query (+ provider call if external)
293302
domain projection (scores, verdicts)
@@ -296,7 +305,7 @@ page.tsx (RSC) → features/x/queries/getX(ctx, params)
296305
297306
**Write (Server Action):**
298307
299-
```
308+
```text
300309
client formserver action
301310
1. getSessionContext() → { userId, organizationId, role } — never trust client input
302311
2. Zod parse of the payloadtyped input or field errors
@@ -420,7 +429,7 @@ written against a concrete implementation.
420429
421430
## 9. Directory structure
422431
423-
```
432+
```text
424433
ocean-command/
425434
├── prisma/
426435
│ ├── schema.prisma
@@ -528,7 +537,7 @@ non-optional** — they are the tests that stop a security regression from shipp
528537
529538
GitHub Actions on every push and PR:
530539
531-
```
540+
```text
532541
linttypecheckunit + integration tests (Postgres service container) → build
533542
534543
secret scan

0 commit comments

Comments
 (0)