@openreachtech/hora-skills-ort-renchan 0.3.0 → 0.5.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 (50) hide show
  1. package/dist/skills/hor-backend-testing/SKILL.md +4 -3
  2. package/dist/skills/hor-backend-testing/references/running-tests.md +9 -1
  3. package/dist/skills/hor-build-e2e-test-environment/SKILL.md +17 -8
  4. package/dist/skills/hor-build-e2e-test-environment/references/compose-definition.md +11 -7
  5. package/dist/skills/hor-build-e2e-test-environment/references/runner-and-lifecycle.md +1 -1
  6. package/dist/skills/hor-cookie-authentication/SKILL.md +4 -2
  7. package/dist/skills/hor-cookie-authentication/references/environment.md +4 -2
  8. package/dist/skills/hor-database-design/references/column-types.md +25 -9
  9. package/dist/skills/hor-database-design/references/datetimes.md +7 -3
  10. package/dist/skills/hor-graphql-schema/SKILL.md +10 -8
  11. package/dist/skills/hor-graphql-server-engine/SKILL.md +544 -45
  12. package/dist/skills/hor-light-rag/SKILL.md +6 -1
  13. package/dist/skills/hor-light-rag/references/retrieval-internals.md +3 -1
  14. package/dist/skills/hor-multi-llm-provider/SKILL.md +158 -20
  15. package/dist/skills/hor-multi-llm-provider/references/access-routes.md +230 -0
  16. package/dist/skills/hor-multi-llm-provider/references/provider-internals.md +9 -3
  17. package/dist/skills/hor-mutation-resolver/SKILL.md +6 -2
  18. package/dist/skills/hor-mutation-resolver/references/resolve-flow.md +10 -6
  19. package/dist/skills/hor-oidc-sign-in/SKILL.md +61 -0
  20. package/dist/skills/hor-oidc-sign-in/references/environment.md +94 -0
  21. package/dist/skills/hor-oidc-sign-in/references/id-token-verification.md +98 -0
  22. package/dist/skills/hor-oidc-sign-in/references/resolvers.md +134 -0
  23. package/dist/skills/hor-oidc-sign-in/references/storage.md +118 -0
  24. package/dist/skills/hor-query-resolver/SKILL.md +2 -0
  25. package/dist/skills/hor-query-resolver/references/anatomy.md +7 -7
  26. package/dist/skills/hor-query-resolver/references/data-access.md +17 -0
  27. package/dist/skills/hor-renchan-job-bullmq/SKILL.md +15 -6
  28. package/dist/skills/hor-renchan-job-bullmq/references/daemon-and-scheduler.md +4 -2
  29. package/dist/skills/hor-renchan-job-bullmq/references/engine-and-infra.md +39 -5
  30. package/dist/skills/hor-renchan-job-bullmq/references/job-triple.md +57 -0
  31. package/dist/skills/hor-resolver-validator/SKILL.md +5 -6
  32. package/dist/skills/hor-resolver-validator/references/validator-pattern.md +5 -5
  33. package/dist/skills/hor-restfulapi-architecture/SKILL.md +33 -7
  34. package/dist/skills/hor-restfulapi-architecture/references/behind-iap.md +116 -0
  35. package/dist/skills/hor-restfulapi-architecture/references/credential-routes.md +173 -0
  36. package/dist/skills/hor-restfulapi-architecture/references/engine-and-context.md +11 -5
  37. package/dist/skills/hor-restfulapi-architecture/references/renderers.md +4 -0
  38. package/dist/skills/hor-sequelize-migration/SKILL.md +30 -15
  39. package/dist/skills/hor-sequelize-migration/references/alter-table.md +26 -13
  40. package/dist/skills/hor-sequelize-migration/references/foreign-keys.md +5 -2
  41. package/dist/skills/hor-sequelize-migration/references/indexes.md +41 -2
  42. package/dist/skills/hor-sequelize-migration/references/notation.md +1 -1
  43. package/dist/skills/hor-sequelize-model/references/associations.md +2 -1
  44. package/dist/skills/hor-sequelize-model/references/notation.md +1 -1
  45. package/dist/skills/hor-sequelize-seeder/SKILL.md +9 -4
  46. package/dist/skills/hor-sequelize-seeder/references/notation.md +59 -0
  47. package/dist/skills/hor-type-interface/SKILL.md +48 -32
  48. package/docs/skills.ja.md +6 -5
  49. package/docs/skills.md +6 -5
  50. package/package.json +1 -1
@@ -67,9 +67,10 @@ Details, the barrel example, and the per-category workflow snippet are in
67
67
  `NODE_OPTIONS="--experimental-vm-modules" NODE_ENV=development npx jest <path>` (add `--runInBand`
68
68
  for DB-writing/order-sensitive tests). It runs against the DB **as it currently is**, so prepare the
69
69
  DB once and reset it piecemeal (migrations-only / one-seeder-set) instead of a full rebuild.
70
- - **Live (real-dialect) run**: running against MariaDB instead of SQLite **requires a MariaDB
71
- running locally**, selected with `NODE_ENV=live`. How that database is stood up is not part of this
72
- convention.
70
+ - **Live (real-dialect) run**: running against the database the project's specification names
71
+ (MariaDB, MySQL or PostgreSQL) instead of SQLite **requires that database running locally**,
72
+ selected with `NODE_ENV=live`. Test against the one the specification names, never another
73
+ database of the same family. How that database is stood up is not part of this convention.
73
74
  - **Parallelism × per-worker heap must fit in real memory.** Jest runs one worker per core by
74
75
  default, and `--max-old-space-size` is **not a reservation — it is how far the GC may be
75
76
  deferred**, so a value the machine cannot actually give lets every worker grow until it crashes
@@ -178,9 +178,17 @@ The three standard sets, and the npm wrappers the project provides for the commo
178
178
  ## A live (real-dialect) run
179
179
 
180
180
  Everything above runs on **SQLite**, the local default. A test that depends on real-dialect behavior
181
- SQLite does not emulate has to run against **MariaDB**, and that means **a MariaDB running locally**;
181
+ SQLite does not emulate has to run against **the database the project's specification names**
182
+ (MariaDB, MySQL or PostgreSQL), and that means **that database running locally**;
182
183
  `NODE_ENV=live` selects its connection config, and the same test files run unchanged — only the
183
184
  dialect differs.
184
185
 
186
+ - **Run against the named database, not a neighbour.** MariaDB passing says nothing about
187
+ PostgreSQL, because the two differ on exactly what SQLite hides: identifier quoting, index name
188
+ limits, `JSON` against `JSONB`, id sequences after explicit ids, `BIGINT` returned as a string,
189
+ and case sensitivity of `LIKE`. A project on PostgreSQL runs its live tests on PostgreSQL.
190
+ - **Read the dialect off the specification, not off this skill.** The live connection config
191
+ carries it, so switching the database is a config change and the test files stay as they are.
192
+
185
193
  Standing that database up is deliberately **not covered here**: this skill governs where tests go and
186
194
  how they are run, not how a database is provisioned.
@@ -1,12 +1,12 @@
1
1
  ---
2
2
  name: hor-build-e2e-test-environment
3
3
  description: >
4
- Build, run and debug the manual local E2E environment under `e2e/docker/` — a
5
- container-compose stack of the product's real middleware (system of record, cache and job queue,
6
- event transport, read model, object storage, the reverse-proxy edge), its own seed set, and the
7
- `up` / `start` / `seed` / `clean` / `down` scripts that drive it. Stated per component role, so
8
- any stack maps onto it. Use also when adding E2E seed data. Verifying behavior inside the
9
- environment is out of scope.
4
+ Build, run and debug the manual local E2E environment under `e2e/docker/`, a compose stack of the
5
+ product's real middleware (system of record, cache and job queue, event transport, read model,
6
+ object storage, edge, identity provider, IAP stand-in, cloud API), its own seed set, and the `up`
7
+ / `start` / `seed` / `clean` / `down` scripts that drive it. Stated per component role, so any
8
+ stack maps onto it. Use also when adding E2E seed data. Verifying behavior inside it is out of
9
+ scope.
10
10
  ---
11
11
 
12
12
  # Build E2E Test Environment
@@ -93,16 +93,25 @@ of the skill apply to a stack it was not written in.
93
93
  | **read model / search** — the derived store screens read from | a search cluster with an analyzer plugin baked in | another search engine, a materialized view, a denormalized table, a cache the read path is served from |
94
94
  | **object storage** — where uploaded and derived files live | a per-run directory on the filesystem | an S3-compatible object server, a cloud-storage emulator, a bucket with a per-run prefix |
95
95
  | **edge** — what the browser actually connects to | nginx as a reverse proxy in front of the application | Apache httpd, Caddy, Traefik, HAProxy, or a managed load balancer / API gateway whose behaviour the product depends on |
96
+ | **identity provider** (what the product signs people in through) | a local OpenID Connect server that serves discovery, authorization, token and key endpoints and signs in a fixed set of test accounts | Keycloak or Dex in development mode, a mock OIDC server, the provider's own local emulator where one exists |
97
+ | **IAP stand-in** (what signs a request in before it reaches the application, where production sits behind IAP) | a small proxy in front of the application that adds `x-goog-iap-jwt-assertion`, signed with a local test key whose public half it serves as a key set | any reverse proxy with a signing step, an auth-proxy container set to inject a signed header |
98
+ | **fake cloud API** (a managed cloud service the application calls) | a local emulator of that service, started with the stack and seeded by `seed.sh` | the vendor's emulator, a stub server that answers with recorded responses |
96
99
  | **the application and its own processes** — the product itself | the API server, a worker daemon, a change-log consumer | whatever process set has to be running for a request to be answered end to end |
97
100
 
98
101
  - **A role your product does not have simply drops out.** No read model means no index-creation step,
99
102
  no backfill and none of the propagation traps — and every other rule still holds. Two roles filled
100
103
  by one component (a database that is both system of record and job queue) collapse into one service
101
104
  and one set of values.
102
- - **Roles the example does not name join the same list.** A mail catcher, an identity-provider stub, a
103
- payment sandbox, a headless browser: if the product genuinely talks to it, it belongs in the
105
+ - **Roles the example does not name join the same list.** A mail catcher, a payment sandbox, a
106
+ headless browser: if the product genuinely talks to it, it belongs in the
104
107
  environment, or the environment is not end-to-end. Give it the same treatment — loopback-only port
105
108
  on the E2E block, healthcheck, started by the runner.
109
+ - **A stand-in replaces where a service lives, never what the application checks.** The identity
110
+ provider stub has its own local issuer, which `OIDC_ISSUER` points at, and the IAP stand-in
111
+ presents the real IAP issuer value, signed with keys the test environment supplies. Both use the
112
+ claims the real ones use, and `.env.<stack-env>` points the application at their local key set and
113
+ audience, values that reach only this machine. No verification in the application is relaxed so the stack can run. Where
114
+ production sits behind IAP, the stand-in is the edge of this stack ([§5](#5-the-edge-what-the-browser-actually-connects-to)).
106
115
  - **What is universal and what is example.** These hold for any stack: one command in dependency
107
116
  order with idempotent steps; loopback-only publishing on a port block and compose project name of
108
117
  its own; an environment name and env file of the stack's own; a seed set of its own in a reserved id band;
@@ -91,7 +91,7 @@ room for the developer's own stack beside it:
91
91
  | Role (example component) | `mem_limit` | Heap flag (≈ half) | Note |
92
92
  | --- | --- | --- | --- |
93
93
  | system of record (MariaDB) | `768m` | — (buffer pool, not a heap) | cap the InnoDB buffer pool below this in `command:` if the default is generous |
94
- | cache and job queue (Redis) | `256m` | `--maxmemory 192mb` | set `--maxmemory` under the cap so Redis evicts instead of being OOM-killed |
94
+ | cache and job queue (Redis) | `256m` | `--maxmemory 192mb` | set `--maxmemory` under the cap so Redis rejects writes instead of being OOM-killed |
95
95
  | event transport (Kafka) | `1g` | `-Xmx512m` | JVM: cap is ~2× heap |
96
96
  | change propagation (Kafka Connect) | `768m` | `-Xmx384m` | JVM: cap is ~2× heap |
97
97
  | read model (Elasticsearch) | `1g` | `-Xms512m -Xmx512m` | JVM: cap is ~2× heap; the heaviest single service |
@@ -191,8 +191,8 @@ services:
191
191
  redis:
192
192
  image: redis:7-alpine
193
193
  mem_limit: 256m # hard container cap (§ Memory)
194
- # --maxmemory sits under the cap so Redis evicts rather than being OOM-killed at the cap
195
- command: ['redis-server', '--save', '', '--appendonly', 'no', '--maxmemory', '192mb', '--maxmemory-policy', 'allkeys-lru']
194
+ # --maxmemory sits under the cap so Redis rejects writes rather than being OOM-killed at the cap
195
+ command: ['redis-server', '--save', '', '--appendonly', 'no', '--maxmemory', '192mb', '--maxmemory-policy', 'noeviction']
196
196
  ports: ['127.0.0.1:16379:6379']
197
197
  healthcheck:
198
198
  test: ['CMD', 'redis-cli', 'ping']
@@ -206,10 +206,14 @@ services:
206
206
  means a worker waking up to process a job whose context has moved on. **General rule:** the roles
207
207
  that must survive a restart are the ones holding authored state; the queue is not one of them, so
208
208
  turn its durability off rather than reasoning about stale jobs later.
209
- - **`--maxmemory` set below the `mem_limit`, with an eviction policy.** Reach the `mem_limit` and the
210
- container is OOM-killed outright; reach `--maxmemory` first and the cache evicts a key instead — a
211
- graceful degradation rather than a dead service. Keep `--maxmemory` a margin under the cap so the
212
- cache stays inside the container ceiling (§ Memory).
209
+ - **`--maxmemory` set below the `mem_limit`, with `noeviction`.** Reach the `mem_limit` and the
210
+ container is OOM-killed outright; reach `--maxmemory` first and Redis rejects writes with an error
211
+ instead, a failure the application can report rather than a dead service. Keep `--maxmemory` a
212
+ margin under the cap so Redis stays inside the container ceiling (§ Memory).
213
+ - **`noeviction`, never an evicting policy such as `allkeys-lru`.** A job queue keeps each job's
214
+ state in several keys, and the queue library breaks when Redis drops one of them. **General rule:**
215
+ a Redis that holds a queue evicts nothing, so size `--maxmemory` for the queue instead of leaning
216
+ on eviction to stay under it.
213
217
 
214
218
  ### Event transport — example: Kafka in single-node mode
215
219
 
@@ -100,7 +100,7 @@ just been cleaned, or may hold a full session's data. It never learns which —
100
100
  | # | Step (role) | Example | Why here |
101
101
  | --- | --- | --- | --- |
102
102
  | 1 | verify the stack is up and healthy | the same health wait | seeding against a half-started store fails in a way that reads like a code bug. `seed.sh` **starts nothing**: if the stack is down it says to run `start.sh` |
103
- | 2 | create the schema, with the **same collation settings as production** | create database | a different collation changes string comparison, and the environment then behaves unlike every other one |
103
+ | 2 | create the schema, with the **same collation settings as production** | create database (MariaDB `CHARACTER SET` / `COLLATE`, PostgreSQL `LC_COLLATE`) | a different collation changes string comparison, and the environment then behaves unlike every other one |
104
104
  | 3 | apply migrations | `sequelize-cli db:migrate` | before rows exist, and it is also what lets a long-lived environment follow the code |
105
105
  | 4 | seed the **E2E master** set | `db:seed:<stack-env>-master` | the metadata is what later steps derive from: which tables are propagated, which fields are in the read model |
106
106
  | 5 | seed the **E2E fixture** set | `db:seed:<stack-env>` | after master, because fixtures reference master ids |
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: hor-cookie-authentication
3
- description: "Cookie-based authentication for a renchan backend, per actor: the credential and token models (password hash, access + rotating refresh tokens with reuse detection), the refresh-token HttpOnly cookie, the signIn / signUp / signOut / renewAccessToken resolvers, and the engine's public-operation policy. Use when adding cookie auth to an actor/role. Boundary: models, migrations and seeders follow their own conventions; this replaces the older access-token-only flow."
3
+ description: "Password sign-in with cookie-based sessions for a renchan backend, per actor: the credential and token models (password hash, access + rotating refresh tokens with reuse detection), the refresh-token HttpOnly cookie, the signIn / signUp / signOut / renewAccessToken resolvers, and the engine's public-operation policy. Use when adding password auth to an actor/role. Boundary: external identity provider sign-in and other credential routes have their own conventions."
4
4
  metadata:
5
5
  author: OpenReachTech
6
6
  version: "2026.08.18"
@@ -8,10 +8,12 @@ metadata:
8
8
 
9
9
  # Cookie Authentication (Backend)
10
10
 
11
- Use this skill when adding cookie-based authentication to a renchan backend — storing an actor's credential and tokens, the sign-in / sign-out / renew operations, the refresh-token cookie, and deciding which operations are public.
11
+ Use this skill when adding **password sign-in** with cookie-based sessions to a renchan backend: storing an actor's credential and tokens, the sign-in / sign-out / renew operations, the refresh-token cookie, and deciding which operations are public.
12
12
 
13
13
  An authenticated actor (a role such as `user`, `customer`, `admin`, or `tenant`) keeps its password as a hash and authenticates with two tokens: a short-lived **access token** the client sends as a header, and a long-lived **refresh token** kept in the DB and handed to the browser as an **HttpOnly cookie**. `signIn` issues both; `renewAccessToken` reads the cookie, rotates the refresh token (detecting reuse of a retired one), and returns a fresh access token; `signOut` revokes the series and clears the cookie. Only `renewAccessToken` and `signOut` authenticate by the cookie — every other operation authenticates by the access-token header.
14
14
 
15
+ This skill covers the password route only. An actor who signs in at an external OpenID Connect provider follows `/hor-oidc-sign-in`, which ends where this skill's session begins and reuses it unchanged. A request that carries its credential in a cookie, a Bearer header, an IAP JWT or an HMAC signature instead of `x-renchan-access-token`, and an application behind IAP that has no sign-in of its own, are in `/hor-restfulapi-architecture`.
16
+
15
17
  You build this **per actor**, on top of the boilerplate's base classes — it is not shipped in the boilerplate; each app builds it for the actors its spec declares. Design the actor entity and its profile first with [[hor-database-design]] / [[hor-sequelize-model]]; this skill adds the credential, tokens, operations, and cookie to it. It says what the auth cluster contains and how the pieces fit — writing each piece follows its own convention ([[hor-sequelize-model]], [[hor-sequelize-seeder]], [[hor-mutation-resolver]], [[hor-type-interface]]), and the engine is [[hor-graphql-server-engine]].
16
18
 
17
19
  > **This replaces the older access-token-only flow.** In the old flow the access token was the durable credential — stored on the client and sent on every request, with no refresh cookie. Here the access token is short-lived and held only in memory on the client; durability comes from the refresh cookie. Do not mix the two: when this skill applies, there is no long-lived access token. The frontend half is [[hof-cookie-authentication]].
@@ -22,10 +22,12 @@ AUTH_COOKIE_PATH=
22
22
  AUTH_COOKIE_DOMAIN=
23
23
  ```
24
24
 
25
- Declare them on the env-facade typedef (`app/globals/env.js` + `env.cjs`) and read them **through the facade** (`env.AUTH_*`), never `process.env` directly. The refresh-token model reads the TTL from it, with a fallback default:
25
+ Declare them on the env-facade typedef (`app/globals/env.js` + `env.cjs`) and read them **through the facade** (`env.AUTH_*`), never `process.env` directly. Only the Share imports `env`, so the refresh-token model receives it as an argument (`share.env`) and reads the TTL with a fallback default. A getter calls no method, so the read is a method:
26
26
 
27
27
  ```js
28
- static get ttlDays () {
28
+ static generateTtlDays ({
29
+ env,
30
+ }) {
29
31
  return Number(env.AUTH_REFRESH_TOKEN_TTL_DAYS)
30
32
  || DEFAULT_REFRESH_TOKEN_TTL_DAYS // 14
31
33
  }
@@ -6,15 +6,18 @@ belong to `hor-sequelize-migration`.
6
6
 
7
7
  ## Pick the column type from the shape of the data
8
8
 
9
- Type each column to what it actually holds:
10
-
11
- | Data | Type | Note |
12
- | --- | --- | --- |
13
- | Genuinely dynamic / schemaless values | `JSON` | only for values never queried or joined relationally |
14
- | URL | `TEXT` | not `STRING(n)` — real URLs have no reliable length bound |
15
- | Long content (article body, description) | `TEXT('medium')` (MEDIUMTEXT) | size the column to the content |
16
- | Datetime | `DATE(3)` (UTC) | [datetimes.md](./datetimes.md) |
17
- | Status / category | master-table key column | [master-tables.md](./master-tables.md) |
9
+ Type each column to what it actually holds. The Type column is Sequelize notation, written for
10
+ MariaDB (the reference live database); the PostgreSQL column is what the same declaration becomes
11
+ on PostgreSQL.
12
+
13
+ | Data | Type | PostgreSQL | Note |
14
+ | --- | --- | --- | --- |
15
+ | Genuinely dynamic / schemaless values | `JSON` | `JSONB` (`jsonb`) | only for values never queried or joined relationally |
16
+ | URL | `TEXT` | `TEXT` | not `STRING(n)`, because real URLs have no reliable length bound |
17
+ | Long content (article body, description) | `TEXT('medium')` (MEDIUMTEXT) | `TEXT` | size the column to the content |
18
+ | Short string (name, code) | `STRING(n)` | `STRING(n)` (`varchar(n)`) | pick `n` by use |
19
+ | Datetime | `DATE(3)` (UTC) | `DATE(3)` (`timestamptz`) | [datetimes.md](./datetimes.md) |
20
+ | Status / category | master-table key column | master-table key column | [master-tables.md](./master-tables.md) |
18
21
 
19
22
  - **Why `JSON` only for truly dynamic data**: `JSON` is the right home for a value whose structure
20
23
  varies per row and is never the target of a relational query (a settings blob, a captured
@@ -23,11 +26,24 @@ Type each column to what it actually holds:
23
26
  and directly violates the
24
27
  [grand principle](../SKILL.md#grand-principle-the-database-holds-canonical-normalized-truth).
25
28
  Normalize relational facts into tables; reserve `JSON` for the genuinely schemaless.
29
+ - **On PostgreSQL, default a JSON column to `JSONB`.** PostgreSQL's `json` type has no equality
30
+ operator, so `DISTINCT`, `GROUP BY`, `UNION` and `=` over a table that holds one fail with
31
+ `could not identify an equality operator for type json`. `jsonb` has the operator and can carry a
32
+ GIN index; it does not keep key order or whitespace, which a schemaless blob never needs. Only
33
+ PostgreSQL declares `JSONB` in Sequelize, so MariaDB, MySQL and SQLite keep `JSON`. Files that
34
+ run on PostgreSQL and on another dialect choose with
35
+ `queryInterface.sequelize.getDialect() === 'postgres'`.
26
36
  - **Why URL as `TEXT`**: URLs (signed storage links, tracking-laden redirects) routinely exceed any
27
37
  `STRING(n)` you would guess, and a too-short limit truncates silently and corrupts the reference.
28
38
  `TEXT` removes the guess.
29
39
  - **Why long content as `TEXT('medium')`**: plain `TEXT` can be too small for real article bodies;
30
40
  choose the width from the expected content rather than discovering the ceiling in production.
41
+ This is a MariaDB and MySQL concern: `TEXT` is capped near 64KB there. PostgreSQL has one `TEXT`
42
+ type with no such cap (about 1GB), so Sequelize drops the `'medium'` option with a warning and
43
+ you write plain `TEXT`.
44
+ - **Why `STRING(n)` is sized by use**: a `STRING(191)` default comes from MariaDB and MySQL, where
45
+ 191 is the longest utf8mb4 column that fits an older index-key limit of 767 bytes. PostgreSQL has
46
+ no such limit, so there `n` only has to fit the data.
31
47
 
32
48
  ```
33
49
  -- Good: type matches the data's shape
@@ -73,16 +73,20 @@ Every datetime column is **UTC** and typed `DATETIME(3)` (Sequelize `DATE(3)`, w
73
73
  `hor-sequelize-migration`), which keeps time to the **millisecond**. Timezone conversion is the
74
74
  **application layer's** responsibility, never the database's.
75
75
 
76
+ - **On PostgreSQL** the same `DATE(3)` becomes `TIMESTAMP WITH TIME ZONE`. Sequelize ignores the
77
+ precision argument there, because that type already keeps microseconds, and it stores one
78
+ absolute instant, so the UTC and millisecond rules below hold unchanged.
76
79
  - **Why (UTC)**: a timezone is a *presentational* concern (the
77
80
  [grand principle](../SKILL.md#grand-principle-the-database-holds-canonical-normalized-truth)), so
78
81
  it does not belong in the canonical store. One unambiguous instant per row means comparisons,
79
82
  sorting, and range queries are always correct, and the data survives being served to clients in
80
- any region or migrated across environments (dev SQLite / staging MySQL / live MariaDB). Mixing
81
- local times in the DB makes every `ORDER BY time` and `BETWEEN` subtly wrong.
83
+ any region or migrated across environments (for example dev SQLite / staging MySQL / live
84
+ MariaDB, or any of them with PostgreSQL). Mixing local times in the DB makes every
85
+ `ORDER BY time` and `BETWEEN` subtly wrong.
82
86
  - **Why (ms precision)**: high-frequency writes within the same second must still order
83
87
  deterministically; second precision collapses them and makes "latest row" ambiguous.
84
88
 
85
89
  ```
86
90
  -- Good: UTC instant, millisecond precision; the app renders it in the user's timezone
87
- DataTypes.DATE(3) // stored as UTC DATETIME(3)
91
+ DataTypes.DATE(3) // stored as UTC DATETIME(3) (PostgreSQL: TIMESTAMP WITH TIME ZONE)
88
92
  ```
@@ -312,18 +312,18 @@ enum SortDirection {
312
312
  enum SortDirection { ASC DESC }
313
313
  ```
314
314
 
315
- ## 9. Mirror every SDL type into `types/<Audience>GraphQL.d.ts`
315
+ ## 9. Mirror every SDL type into `types/graphql.d.ts`
316
316
 
317
317
  Defining a type in the SDL is **only half the job** — declare the matching TypeScript
318
- interface in the audience's `types/<Audience>GraphQL.d.ts` in the same change. Resolvers
319
- reference these via JSDoc
320
- (`@param {{ input: server.graphql.customer.CancelOrderInput }}`,
321
- `@returns {Promise<server.graphql.customer.OrdersResult>}`), so a type present in
322
- the SDL but missing from the `.d.ts` fails type-check.
318
+ interface in the one file `types/graphql.d.ts` in the same change, under the audience's
319
+ namespace. Resolvers reference these via JSDoc
320
+ (`@param {{ input: graphql.customer.CancelOrderInput }}`,
321
+ `@returns {Promise<graphql.customer.OrdersResult>}`), so a type present in
322
+ the SDL but missing from `types/graphql.d.ts` fails type-check.
323
323
 
324
324
  ```typescript
325
325
  declare global {
326
- namespace server.graphql.customer {
326
+ namespace graphql.customer {
327
327
  interface CancelOrderInput {
328
328
  orderId: number
329
329
  }
@@ -336,6 +336,8 @@ declare global {
336
336
  ```
337
337
 
338
338
  - Name the interfaces exactly `<Operation>Input` / `<Operation>Result`.
339
+ - Every audience shares that one file, each in its own namespace block, so a type is never declared
340
+ in another audience's block.
339
341
  - Keep fields in sync field-for-field: GraphQL `!` → required property, nullable → `?`.
340
342
 
341
343
  ## 10. Match the surrounding file's style
@@ -356,5 +358,5 @@ uses**, including any stated ordering rule.
356
358
  - [ ] Is `!` the default, with every nullable field genuinely optional (and commented why)? Lists `[T!]!` unless the whole list is optional?
357
359
  - [ ] Are money/decimal fields `String!` (emitted via `toFixed(2)`), with `BigNumber` reserved for non-money large integers?
358
360
  - [ ] Do list operations use the audience's `Pagination` / `PaginationInput` shape (nullable `sort`, non-null `limit`/`offset`/`totalRecords`)?
359
- - [ ] Did you mirror every added/changed SDL type into `types/<Audience>GraphQL.d.ts`, field-for-field, in the same change?
361
+ - [ ] Did you mirror every added/changed SDL type into `types/graphql.d.ts`, field-for-field, in the same change?
360
362
  - [ ] Did you match the surrounding file's banner style and any stated ordering rule?