@openreachtech/hora-skills-ort-renchan 0.0.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 (126) hide show
  1. package/LICENSE +201 -0
  2. package/README.ja.md +135 -0
  3. package/README.md +135 -0
  4. package/dist/skills/hor-agent-loop/SKILL.md +123 -0
  5. package/dist/skills/hor-agent-loop/references/core.md +485 -0
  6. package/dist/skills/hor-agent-loop/references/graphql-integration.md +178 -0
  7. package/dist/skills/hor-agent-loop/references/renchan-job-integration.md +368 -0
  8. package/dist/skills/hor-agent-loop/references/testing.md +492 -0
  9. package/dist/skills/hor-ai-agent-structure/SKILL.md +403 -0
  10. package/dist/skills/hor-ai-agent-structure/references/loop-and-actions.md +100 -0
  11. package/dist/skills/hor-ai-prompt-document-store/SKILL.md +220 -0
  12. package/dist/skills/hor-ai-prompt-document-store/references/models-and-composition.md +156 -0
  13. package/dist/skills/hor-backend-testing/SKILL.md +118 -0
  14. package/dist/skills/hor-backend-testing/references/placement-and-ordering.md +89 -0
  15. package/dist/skills/hor-backend-testing/references/purity-and-mocks.md +82 -0
  16. package/dist/skills/hor-backend-testing/references/running-tests.md +186 -0
  17. package/dist/skills/hor-bank-id/SKILL.md +91 -0
  18. package/dist/skills/hor-build-e2e-test-environment/SKILL.md +609 -0
  19. package/dist/skills/hor-build-e2e-test-environment/references/compose-definition.md +368 -0
  20. package/dist/skills/hor-build-e2e-test-environment/references/edge-and-proxy.md +287 -0
  21. package/dist/skills/hor-build-e2e-test-environment/references/environment-and-ports.md +201 -0
  22. package/dist/skills/hor-build-e2e-test-environment/references/runner-and-lifecycle.md +330 -0
  23. package/dist/skills/hor-build-e2e-test-environment/references/seed-data.md +145 -0
  24. package/dist/skills/hor-build-e2e-test-environment/references/windows-runner.md +146 -0
  25. package/dist/skills/hor-constant-definition/SKILL.md +139 -0
  26. package/dist/skills/hor-cookie-authentication/SKILL.md +33 -0
  27. package/dist/skills/hor-cookie-authentication/references/auth-filter.md +55 -0
  28. package/dist/skills/hor-cookie-authentication/references/cookie-context.md +53 -0
  29. package/dist/skills/hor-cookie-authentication/references/dev-login-seeder.md +22 -0
  30. package/dist/skills/hor-cookie-authentication/references/environment.md +64 -0
  31. package/dist/skills/hor-cookie-authentication/references/error-codes.md +24 -0
  32. package/dist/skills/hor-cookie-authentication/references/migrations.md +18 -0
  33. package/dist/skills/hor-cookie-authentication/references/resolvers.md +97 -0
  34. package/dist/skills/hor-cookie-authentication/references/session-clerk.md +41 -0
  35. package/dist/skills/hor-cookie-authentication/references/token-models.md +125 -0
  36. package/dist/skills/hor-database-design/SKILL.md +54 -0
  37. package/dist/skills/hor-database-design/references/column-types.md +92 -0
  38. package/dist/skills/hor-database-design/references/datetimes.md +88 -0
  39. package/dist/skills/hor-database-design/references/master-tables.md +117 -0
  40. package/dist/skills/hor-database-design/references/normalization.md +40 -0
  41. package/dist/skills/hor-database-design/references/update-history.md +35 -0
  42. package/dist/skills/hor-execution-placement-pattern/SKILL.md +216 -0
  43. package/dist/skills/hor-external-api-client/SKILL.md +99 -0
  44. package/dist/skills/hor-external-api-client/references/architecture.md +127 -0
  45. package/dist/skills/hor-external-api-client/references/authorization.md +105 -0
  46. package/dist/skills/hor-external-api-client/references/capsule.md +130 -0
  47. package/dist/skills/hor-external-api-client/references/conventions.md +68 -0
  48. package/dist/skills/hor-external-api-client/references/launcher.md +138 -0
  49. package/dist/skills/hor-external-api-client/references/payload.md +176 -0
  50. package/dist/skills/hor-external-api-client/references/sdk-wrapper.md +291 -0
  51. package/dist/skills/hor-external-api-client/references/testing.md +130 -0
  52. package/dist/skills/hor-external-api-client/references/usage.md +152 -0
  53. package/dist/skills/hor-graphql-schema/SKILL.md +360 -0
  54. package/dist/skills/hor-graphql-server-engine/SKILL.md +356 -0
  55. package/dist/skills/hor-light-rag/SKILL.md +242 -0
  56. package/dist/skills/hor-light-rag/references/retrieval-internals.md +143 -0
  57. package/dist/skills/hor-multi-llm-provider/SKILL.md +288 -0
  58. package/dist/skills/hor-multi-llm-provider/references/provider-internals.md +153 -0
  59. package/dist/skills/hor-mutation-resolver/SKILL.md +360 -0
  60. package/dist/skills/hor-mutation-resolver/references/dependency-injection.md +148 -0
  61. package/dist/skills/hor-mutation-resolver/references/errors.md +120 -0
  62. package/dist/skills/hor-mutation-resolver/references/resolve-flow.md +275 -0
  63. package/dist/skills/hor-mutation-resolver/references/testing.md +125 -0
  64. package/dist/skills/hor-mutation-resolver/references/transaction.md +197 -0
  65. package/dist/skills/hor-post-worker/SKILL.md +320 -0
  66. package/dist/skills/hor-query-resolver/SKILL.md +246 -0
  67. package/dist/skills/hor-query-resolver/references/anatomy.md +384 -0
  68. package/dist/skills/hor-query-resolver/references/data-access.md +248 -0
  69. package/dist/skills/hor-query-resolver/references/errors-and-context.md +172 -0
  70. package/dist/skills/hor-query-resolver/references/testing.md +241 -0
  71. package/dist/skills/hor-renchan-job-bullmq/SKILL.md +178 -0
  72. package/dist/skills/hor-renchan-job-bullmq/references/daemon-and-scheduler.md +182 -0
  73. package/dist/skills/hor-renchan-job-bullmq/references/engine-and-infra.md +106 -0
  74. package/dist/skills/hor-renchan-job-bullmq/references/job-triple.md +189 -0
  75. package/dist/skills/hor-renchan-job-bullmq/references/queues.md +74 -0
  76. package/dist/skills/hor-renchan-job-bullmq/references/subscriptions.md +113 -0
  77. package/dist/skills/hor-resolver-share/SKILL.md +262 -0
  78. package/dist/skills/hor-resolver-validator/SKILL.md +194 -0
  79. package/dist/skills/hor-resolver-validator/references/inspector-api.md +115 -0
  80. package/dist/skills/hor-resolver-validator/references/validator-pattern.md +281 -0
  81. package/dist/skills/hor-restfulapi-architecture/SKILL.md +275 -0
  82. package/dist/skills/hor-restfulapi-architecture/references/engine-and-context.md +192 -0
  83. package/dist/skills/hor-restfulapi-architecture/references/renderers.md +204 -0
  84. package/dist/skills/hor-restfulapi-architecture/references/response-and-flusher.md +118 -0
  85. package/dist/skills/hor-restfulapi-architecture/references/validation.md +229 -0
  86. package/dist/skills/hor-security-audit/SKILL.md +110 -0
  87. package/dist/skills/hor-security-audit/references/application-surface.md +90 -0
  88. package/dist/skills/hor-security-audit/references/auth-and-transport.md +147 -0
  89. package/dist/skills/hor-security-audit/references/code-safety.md +74 -0
  90. package/dist/skills/hor-security-audit/references/dependencies.md +72 -0
  91. package/dist/skills/hor-security-audit/references/network-and-logging.md +56 -0
  92. package/dist/skills/hor-security-audit/references/secrets.md +95 -0
  93. package/dist/skills/hor-sequelize-migration/SKILL.md +336 -0
  94. package/dist/skills/hor-sequelize-migration/references/alter-table.md +147 -0
  95. package/dist/skills/hor-sequelize-migration/references/foreign-keys.md +107 -0
  96. package/dist/skills/hor-sequelize-migration/references/indexes.md +149 -0
  97. package/dist/skills/hor-sequelize-migration/references/notation.md +215 -0
  98. package/dist/skills/hor-sequelize-model/SKILL.md +69 -0
  99. package/dist/skills/hor-sequelize-model/references/associations.md +218 -0
  100. package/dist/skills/hor-sequelize-model/references/default-methods.md +244 -0
  101. package/dist/skills/hor-sequelize-model/references/mixins.md +247 -0
  102. package/dist/skills/hor-sequelize-model/references/notation.md +225 -0
  103. package/dist/skills/hor-sequelize-model/references/timestamps.md +74 -0
  104. package/dist/skills/hor-sequelize-seeder/SKILL.md +275 -0
  105. package/dist/skills/hor-sequelize-seeder/references/development-coverage.md +74 -0
  106. package/dist/skills/hor-sequelize-seeder/references/directory-structure.md +113 -0
  107. package/dist/skills/hor-sequelize-seeder/references/id-numbering.md +133 -0
  108. package/dist/skills/hor-sequelize-seeder/references/naming.md +59 -0
  109. package/dist/skills/hor-sequelize-seeder/references/notation.md +170 -0
  110. package/dist/skills/hor-sequelize-subquery/SKILL.md +369 -0
  111. package/dist/skills/hor-strategy-pattern/SKILL.md +371 -0
  112. package/dist/skills/hor-stub-api/SKILL.md +330 -0
  113. package/dist/skills/hor-subscription-resolver/SKILL.md +105 -0
  114. package/dist/skills/hor-subscription-resolver/references/authentication.md +99 -0
  115. package/dist/skills/hor-subscription-resolver/references/basic-notation.md +116 -0
  116. package/dist/skills/hor-subscription-resolver/references/design-philosophy.md +68 -0
  117. package/dist/skills/hor-type-interface/SKILL.md +200 -0
  118. package/docs/skills.ja.md +40 -0
  119. package/docs/skills.md +40 -0
  120. package/lib/equip/CommandLineArguments.js +178 -0
  121. package/lib/equip/HoraSkillsCli.js +590 -0
  122. package/lib/equip/SkillsInstaller.js +443 -0
  123. package/lib/equip/SkillsManifestFile.js +260 -0
  124. package/lib/equip/constants/CLI_COMMAND.js +8 -0
  125. package/lib/equip/hora-skills-ort-renchan.js +8 -0
  126. package/package.json +51 -0
@@ -0,0 +1,201 @@
1
+ # Environment values and ports
2
+
3
+ The E2E stack's dedicated environment name and standalone env file, which values must differ from
4
+ the other environments and why, and how host addresses differ from in-network ones. Referenced from
5
+ §3 and §4 of [SKILL.md](../SKILL.md). `<stack-env>` stands for the environment name that belongs to
6
+ the E2E stack alone — `live-local` is the recommended name.
7
+
8
+ > **One example stack's keys.** `KAFKA_BROKERS`, `ELASTICSEARCH_BASE_URL`, `CDC_DATABASE_NAME` and
9
+ > the rest are **illustrations**: each *role* ([SKILL.md §1](../SKILL.md)) needs its own address,
10
+ > name and scratch space for the run. Map each row onto the keys the project actually reads.
11
+
12
+ ## A dedicated environment, and a standalone env file
13
+
14
+ The stack runs under an environment name of its own (`NODE_ENV=<stack-env>`, recommended
15
+ `live-local`) and reads its own committed `.env.<stack-env>` at the repository root. The name is
16
+ derived from the real-dialect test environment (`live` in the backend testing convention): both
17
+ select the same database engine, but `live` exists for running the unit suite against the real
18
+ dialect, while `<stack-env>` describes a **running full stack**. A dedicated name means every
19
+ command that carries `NODE_ENV=<stack-env>` — the application, the schema tooling, a seeder run by
20
+ hand — resolves to the E2E stack's own values automatically, instead of relying on someone
21
+ remembering to set overrides.
22
+
23
+ Two rules govern the file:
24
+
25
+ - **It is complete and standalone.** Every key the application, the tooling and the background
26
+ processes read must be present — the facade returns `null` for a missing key instead of throwing
27
+ (see the last section), so a gap surfaces as a confusing failure deep inside a service call.
28
+ When authoring the file, start from the key set of the fullest existing env file and set every
29
+ value deliberately.
30
+ - **Shared values are independent copies, deliberately.** The database connection shape in
31
+ `.env.live` and in `.env.<stack-env>` may coincide today; they are still two environments' own
32
+ values, and each file is the source of truth for its own environment. Do not build one env file
33
+ out of another by reference, import or generation. When the stack gains a component or a key,
34
+ updating every environment's file is part of that change — a key added to only one of them shows
35
+ up as the `null` the other reads for it.
36
+
37
+ The **groups of comments** below are what to reproduce in `.env.<stack-env>`; the key names inside
38
+ them belong to the example stack:
39
+
40
+ ```bash
41
+ # .env.<stack-env> — the E2E stack's own environment, committed at the repository root.
42
+
43
+ # the E2E port block — only if this stack must run beside the developer's own (§ ports below)
44
+ DATABASE_PORT=13306
45
+ REDIS_PORT=16379
46
+ KAFKA_BROKERS=127.0.0.1:19092
47
+ ELASTICSEARCH_BASE_URL=http://127.0.0.1:19200
48
+ KAFKA_CONNECT_URL=http://127.0.0.1:18083
49
+
50
+ # a schema, an index and a topic namespace that belong to the E2E stack alone
51
+ DATABASE_NAME=<project>_e2e_db
52
+ # MUST equal DATABASE_NAME — see below. (No inline comments: some dotenv parsers keep them in the value)
53
+ CDC_DATABASE_NAME=<project>_e2e_db
54
+ SEARCH_INDEX_NAME=<index>_e2e
55
+ KAFKA_CONSUMER_GROUP_ID=<consumer-group>-e2e
56
+
57
+ # per-run scratch space, so uploads never land in the working tree
58
+ FILE_STORAGE_PATH=e2e/.storage
59
+
60
+ # a feature that needs a host-installed tool: decided explicitly, not by accident
61
+ <FEATURE>_ENABLED=false
62
+
63
+ # values the compose file substitutes into ${...} — reach compose via --env-file, see below
64
+ DATABASE_PASSWORD=<development-grade>
65
+ ELASTICSEARCH_PASSWORD=<development-grade>
66
+ ```
67
+
68
+ Three things about this file that are not obvious:
69
+
70
+ - **`docker compose` does not read `.env.<stack-env>` on its own.** For variable substitution it
71
+ reads the process environment and a `.env` sitting **next to the compose file** — so any `${...}`
72
+ the compose file interpolates has to reach it another way: point compose at the stack's file with
73
+ `--env-file .env.<stack-env>` in the runner, or export those values before invoking compose. A
74
+ password compose cannot see substitutes as an **empty string**, with only one warning line shown,
75
+ and the service starts with no password set: exactly the quiet half-built stack this skill is
76
+ about.
77
+ - **Anything run by hand against the environment has to carry `NODE_ENV=<stack-env>`.** A seeder or
78
+ migration invoked under the wrong environment name talks to that environment's stack — the
79
+ disaster the dedicated name exists to prevent. Bake the name into the npm scripts (as the seed
80
+ scripts in [seed-data.md](./seed-data.md) do) so it cannot be forgotten.
81
+ - **The file is committed, and a name beginning with `.env` may quietly prevent that.** Projects
82
+ routinely ignore `.env*`; check the repository's `.gitignore` before relying on the file being
83
+ tracked, because a silently untracked env file means the next developer's build reads `null` for
84
+ every key and fails somewhere deep. The file holds development-grade fixture values only, so
85
+ committing it is correct.
86
+
87
+ ## Exports still override the file
88
+
89
+ The environment resolver merges the dotenv file first and the process environment last:
90
+
91
+ ```js
92
+ // the resolver's merge — the exported variable wins
93
+ const assignedEnv = {
94
+ ...this.loadedDotenv,
95
+ ...this.processEnv,
96
+ }
97
+ ```
98
+
99
+ - An exported variable **wins** over the same key in the file, for **everything that reads through
100
+ the facade** — the application, the schema tooling, the seeders. Useful for a one-off tweak
101
+ (a different port for a single run) without editing the committed file.
102
+ - The same precedence is a **trap**: a stray variable left exported in the shell silently overrides
103
+ the committed value, with no warning. When the stack behaves as if the file said something else,
104
+ check the shell's environment first.
105
+ - Ordinary dotenv loaders do the opposite (the file leaves an existing variable alone, and the
106
+ variable likewise leaves alone any value the file *did* set into the same object). Verify the
107
+ direction in the resolver you actually have before relying on it; here it is the merge above.
108
+
109
+ ## The values that must differ, and which of them your project actually needs
110
+
111
+ Two questions decide the list (§3 of [SKILL.md](../SKILL.md)): **does this stack run beside the
112
+ developer's own**, and **may a build destroy or pollute what the developer already has**. The first
113
+ question owns the port block; the second owns every name. Even when both are answered no — the E2E
114
+ stack *replaces* the developer's stack rather than coexisting with it, and that stack is itself
115
+ disposable — the dedicated `.env.<stack-env>` still exists; the answers only decide whether its
116
+ values may coincide with the development environment's.
117
+
118
+ The left column names **what kind of value** it is; the key in parentheses is what the example stack
119
+ calls it.
120
+
121
+ | Value | What goes wrong when it is left equal to the development environment's |
122
+ | --- | --- |
123
+ | **the port block** (every `*_PORT` / `*_URL` / `*_BROKERS`) | the environment silently talks to the developer's own stack, and every screen shows that data instead of the seeded one |
124
+ | **the system of record's name** (`DATABASE_NAME` — a schema, database or namespace) | the schema step **drops and recreates** — pointed at the development database, a build destroys a day of work |
125
+ | **every identity a derived name is built from** (`CDC_DATABASE_NAME`) | the example's change topic is named `<prefix>.<database>.<table>`, so a stale value makes the consumer subscribe to topics nothing ever writes to. Nothing errors; nothing ever propagates, and the screen simply never updates. This is the single most confusing failure in this environment — and it recurs in any stack where a channel, slot, subscription or stream name is **composed** out of another value |
126
+ | **the read model's name** (`SEARCH_INDEX_NAME` — an index, view, table or key prefix) | the run **writes into** whatever it names, and the backfill step writes *every* row — so a stale name pollutes the developer's read model, and a screen can show a document this environment never created. (Setup itself only creates: a read model that already exists is left as it is, which is exactly why a stale name is not caught) |
127
+ | **the object storage location** (`FILE_STORAGE_PATH` — a directory, bucket or key prefix) | uploaded and derived files land in the working tree, so the run pollutes the repository and two runs see each other's files |
128
+
129
+ **A subscriber identity of its own** is worth adding too (`KAFKA_CONSUMER_GROUP_ID` here, a
130
+ replication slot name, a subscription name, a durable-consumer name elsewhere): if a run is ever
131
+ pointed at a shared transport, a shared identity means two subscribers split the stream and each sees
132
+ half its events.
133
+
134
+ ## Host addresses vs in-network addresses
135
+
136
+ The same service has **two addresses**, and which one a value needs depends on **who reads it**. The
137
+ rows are the example stack's values; the rule — *host process → `127.0.0.1` + published port,
138
+ container process → service name + container port* — holds for every component:
139
+
140
+ | Value | Read by | Address |
141
+ | --- | --- | --- |
142
+ | `DATABASE_HOST` / `DATABASE_PORT` | the application and tooling, on the **host** | `127.0.0.1` + the published port (`13306`) |
143
+ | `KAFKA_BROKERS` | the consumer, on the **host** | `127.0.0.1:19092` |
144
+ | `ELASTICSEARCH_BASE_URL`, `KAFKA_CONNECT_URL` | the runner and application, on the **host** | `127.0.0.1` + published port |
145
+ | `CDC_DATABASE_HOST` / `CDC_DATABASE_PORT` | the **connector, inside a container** | the service name (`mariadb`) and the **container's** port (`3306`) |
146
+ | Connect's own `BOOTSTRAP_SERVERS` | the **connector, inside a container** | `kafka:9092` |
147
+
148
+ - **The capture connector's database port stays `3306` even when the host publishes `13306`.** Inside
149
+ the compose network there is no port remapping — `127.0.0.1` there means the connector's own
150
+ container, and the published port does not exist.
151
+ - **Only the in-network values live in the compose file**; the host-facing ones live in
152
+ `.env.<stack-env>`. Mixing the two is the second most common wiring mistake after the broker's
153
+ advertised port.
154
+
155
+ ## The port block
156
+
157
+ One offset applied to every role the project has — the components named here are the example's:
158
+
159
+ | Role (example component) | Development | Test stack |
160
+ | --- | --- | --- |
161
+ | system of record (relational database) | `127.0.0.1:3306` | `127.0.0.1:13306` |
162
+ | cache and job queue (Redis) | `127.0.0.1:6379` | `127.0.0.1:16379` |
163
+ | event transport (Kafka) | `127.0.0.1:29092` | `127.0.0.1:19092` |
164
+ | read model (search cluster) | `127.0.0.1:9200` | `127.0.0.1:19200` |
165
+ | change propagation (Connect / capture API) | `127.0.0.1:8083` | `127.0.0.1:18083` |
166
+
167
+ - **`127.0.0.1` is part of the mapping, not a comment.** `ports: ['13306:3306']` binds every
168
+ interface on the machine, which puts an unauthenticated database, an unauthenticated queue and an
169
+ unauthenticated connector-registration API on whatever network the machine is attached to. With the
170
+ prefix they are reachable from this machine only.
171
+ - **No `ports:` at all for a service the host does not reach.** Container-to-container traffic uses
172
+ the compose network. Add a published port only when a host process — the build script, the
173
+ application, a developer's browser or inspection command — connects to it, and note in a comment
174
+ which one does.
175
+ - **A service that advertises its own address is the exception to free remapping**: its published port
176
+ must equal the port it binds and advertises, because the client is redirected to that advertised
177
+ address after connecting. The broker is the example; a clustered queue or a replica set that names
178
+ its own members behaves the same way ([compose-definition.md](./compose-definition.md)).
179
+ - **Passwords stay development-grade and never go into the repository in any other form.** A fixture
180
+ password committed beside a loopback-only stack is acceptable; the same value reused for anything
181
+ reachable is not.
182
+
183
+ ## A missing key reads as `null`
184
+
185
+ The environment facade wraps its hash in a proxy that returns `null` for a key it does not have,
186
+ rather than `undefined` or an error:
187
+
188
+ ```js
189
+ get (target, key) {
190
+ if (!Reflect.has(target, key)) {
191
+ return null
192
+ }
193
+
194
+ return Reflect.get(target, key)
195
+ }
196
+ ```
197
+
198
+ So a variable the env file never defined does not fail at startup — it becomes `null` and surfaces
199
+ much later, as a request to `null/_search`, a connection to port `null`, or a file written to a path
200
+ built from `null`. When the environment behaves strangely, **check that every key the code path
201
+ reads is actually present** before looking at the wiring.
@@ -0,0 +1,330 @@
1
+ # The runner and the environment's lifecycle
2
+
3
+ The one command that builds the environment, loads it, starts everything and hands it to the
4
+ operator — its step order, the reason each step sits where it does, and how the environment is torn
5
+ down. Referenced from §7 and §8 of [SKILL.md](../SKILL.md). Commands are the recommended shape and
6
+ the script names are **illustrative examples**; adapt them to your project. `<stack-env>` stands for
7
+ the E2E stack's own environment name — `live-local` is the recommended name.
8
+
9
+ > **The steps are named after roles, illustrated by one example stack.** "Create the search index"
10
+ > means *create the read model*; "create the change-log topics" means *create the transport's
11
+ > channels*; "register the capture connector" means *start change propagation, however your project
12
+ > propagates*. A role the project does not have deletes its step and every step that depended on it;
13
+ > a role the example does not name (a mail catcher, an identity stub) adds one. What does **not**
14
+ > change is the **order** — and the reason column is why.
15
+
16
+ ## The interface
17
+
18
+ ```bash
19
+ e2e/up.sh # rebuild: clean.sh, then start.sh, then seed.sh
20
+ e2e/up.sh --start-only # start without touching data at all (delegates to start.sh)
21
+
22
+ e2e/start.sh # bring the stack and the processes up. no data operation
23
+ e2e/seed.sh # load the seed set into a stack that is already up
24
+ e2e/clean.sh # delete the data in every store
25
+ e2e/down.sh # stop the processes and the stack, keep the data
26
+ ```
27
+
28
+ Scripted, because the value of this environment is that **it is not assembled by hand**. Nine manual
29
+ commands in a README become eight commands run and one forgotten, and the forgotten one is usually
30
+ the channel creation — whose absence looks like a product bug on screen.
31
+
32
+ **Each command owns one intention, and its effect on the data is fixed:**
33
+
34
+ | Command | Stack | Data | Processes |
35
+ | --- | --- | --- | --- |
36
+ | `start.sh` | up | untouched | started |
37
+ | `seed.sh` | must already be up | **loaded** | untouched |
38
+ | `clean.sh` | taken down | **deleted, everywhere** | stopped first |
39
+ | `down.sh` | down | untouched | stopped |
40
+ | `up.sh` | rebuilt | **deleted, then loaded** | started |
41
+ | `up.sh --start-only` | up | untouched | started |
42
+
43
+ - **Nothing here inspects the data to pick a branch.** No script asks "is this already seeded", keeps
44
+ a record of what it did, or reasons about a state it did not create. Such a check has to define what
45
+ "seeded" means, store that definition somewhere outside the data it describes, and be wrong at the
46
+ worst possible moment — a load that died halfway looks loaded, a hand-emptied table looks fresh.
47
+ **The operator knows which of these five things they want.** The command they type says so.
48
+ - **`up.sh` is a composition, not a fifth behaviour.** It is `clean.sh` → `start.sh` → `seed.sh` and
49
+ contains no logic of its own. Typing it *is* the request to rebuild from nothing, so it drops
50
+ without asking — that is what building the environment means. `--start-only` runs `start.sh` and
51
+ nothing else.
52
+ - **There is no "skip the clean but still seed" mode.** Seed rows carry fixed ids, so loading the set
53
+ onto rows that already exist collides on insert. The two useful intentions are *rebuild* and
54
+ *start*, and each has a command; anything between them is a request to corrupt the set.
55
+ - **`down.sh` is not a wipe.** Stopping and destroying are different intentions, and the operator who
56
+ types `down.sh` at the end of the day means the first one. `clean.sh` is the only script that
57
+ deletes, and deleting is all it does — not even the abort trap may call it.
58
+ - Nothing in this lifecycle is tied to `npm run test`, which builds nothing and starts nothing.
59
+
60
+ ## Which script a step belongs to
61
+
62
+ **A step goes in `seed.sh` if it depends on data, and in `start.sh` if it does not.** That single rule
63
+ decides every borderline case, including the ones that look like infrastructure:
64
+
65
+ - Creating the read model and creating the transport's channels are **provisioning**: they describe
66
+ shapes, not contents, so they belong to `start.sh` and run create-if-absent.
67
+ - Registering change propagation belongs to **`seed.sh` when its configuration is derived from data** —
68
+ in the example the capture connector's table list comes from the master rows, so registering it
69
+ before those rows exist produces a connector watching nothing. Where the configuration is static,
70
+ it is provisioning and moves to `start.sh`.
71
+ - The backfill belongs to `seed.sh`: it is the step that puts *this load's* rows into the read model.
72
+ - Put a data-derived step in `start.sh` and `up.sh --start-only` on an empty environment fails for a
73
+ reason that has nothing to do with starting — exactly the confusion this skill exists to prevent.
74
+
75
+ ## The step order
76
+
77
+ The order within each script is dependency, not preference. Every step in `start.sh` is **safe to run
78
+ again**, so `start.sh` against a stack that is already up succeeds instead of half-failing; `seed.sh`
79
+ is written for a single application to an empty schema and is not re-runnable, by design.
80
+
81
+ ### `start.sh` — the stack, the provisioning, the processes
82
+
83
+ | # | Step (role) | Example | Why here |
84
+ | --- | --- | --- | --- |
85
+ | 1 | start every service | `docker compose -f e2e/docker/compose.yaml up -d --build` | — |
86
+ | 2 | wait for **every** service's healthcheck | compose's own health status | a later step against a half-started service fails in a way that reads like a code bug |
87
+ | 3 | create the **read model** if absent | create the search index | must exist before anything writes into it — equally true of a materialized view or a denormalized table. Create-if-absent, never recreate: recreating would be a deletion, and deletions belong to `clean.sh` |
88
+ | 4 | create the **transport's channels** if absent | create the change-log topics | the transport does not auto-create, and **some channel properties (a partition count) cannot be reduced later** — so the channels must exist, in their final shape, before anything produces |
89
+ | 5 | register **change propagation**, if its configuration is static | register a connector whose watch list is fixed | after the channels, because it produces to them. If the configuration is derived from data, this step is not here — it is in `seed.sh` |
90
+ | 6 | start the background processes the product needs, recording their PIDs | the worker daemon and the change-log consumer | nothing propagates without them; the middleware being up is not enough. After the channels exist, or a subscriber exits on startup |
91
+ | 7 | start the **application** (and the UI's own server, if it is served separately), recording their PIDs | `npm run start` | there is no UI to operate until this runs |
92
+ | 8 | bring the **edge** up, once the application answers | the reverse proxy in front of the app | it has nothing to serve before then, and a proxy started first turns a slow application into a confusing 502. It holds no data, so `clean.sh` has nothing to do for it |
93
+ | 9 | wait until the edge answers **from the host**, then **print the hand-over** and clear the abort trap | poll the published edge port | starting is finished only when someone can actually open it — and only a poll from outside proves that |
94
+
95
+ Every step is idempotent, because `start.sh` runs against a stack that may already be up, may have
96
+ just been cleaned, or may hold a full session's data. It never learns which — it does not need to.
97
+
98
+ ### `seed.sh` — the schema and everything that depends on it
99
+
100
+ | # | Step (role) | Example | Why here |
101
+ | --- | --- | --- | --- |
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 |
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
+ | 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
+ | 5 | seed the **E2E fixture** set | `db:seed:<stack-env>` | after master, because fixtures reference master ids |
107
+ | 6 | generate the binary files the seeds refer to | write stand-in files under the storage path | after seeding, because it reads the seeded rows |
108
+ | 7 | register **change propagation** when its configuration is **derived from data** | register the capture connector, whose table list comes from the master rows | after the master seeds, or it watches nothing |
109
+ | 8 | backfill the read model | reindex every row | propagation only carries changes made **after** it was wired up, so the rows just seeded are missing from the read model without this |
110
+
111
+ **`seed.sh` is written for one application to an empty schema.** Run against a schema that already
112
+ holds the set, it collides on the fixed ids and stops — which is the correct answer: the operator
113
+ meant `up.sh`. Do not add `IGNORE`, upserts or existence checks to make it survive that; smoothing it
114
+ over trades a loud, accurate failure for rows that silently differ from the set the file describes.
115
+
116
+ **Step 8 has an alternative worth knowing.** Some propagation mechanisms can load the existing rows
117
+ themselves — in the example, setting the capture's snapshot mode to *initial* instead of
118
+ *schema-only*, so seeded rows arrive through the pipeline rather than through a backfill. Prefer
119
+ whichever mode production runs, because an environment should exercise the path production uses; where
120
+ that is the change-only mode, the backfill step is not optional.
121
+
122
+ **The steps that move with the stack** are `start.sh` 3-5 and `seed.sh` 7-8: they exist because the
123
+ example has a read model fed asynchronously through a transport. A product whose read path is served
124
+ straight from the system of record drops all five, and what remains keeps its order.
125
+
126
+ ### `up.sh` — the composition
127
+
128
+ ```bash
129
+ # e2e/up.sh — no logic of its own beyond the flag
130
+ if [ "${1:-}" = '--start-only' ]; then
131
+ exec e2e/start.sh
132
+ fi
133
+
134
+ e2e/clean.sh
135
+ e2e/start.sh
136
+ e2e/seed.sh
137
+ ```
138
+
139
+ - **Clean before start, seed after.** `clean.sh` takes the stack down, so it has to run first;
140
+ `seed.sh` needs the services healthy, so it has to run last. The order is forced, not chosen.
141
+ - **Seeding after the processes are already running is deliberate.** The consumer is up while the rows
142
+ land, so the seeded data propagates through the real pipeline rather than only through the backfill
143
+ — the environment exercises the path production uses, and the backfill at the end covers whatever
144
+ was missed.
145
+ - **`--start-only` delegates rather than branching.** One `exec` and no duplicated steps: the flag
146
+ cannot drift away from the script it stands for.
147
+
148
+ ## Cleaning: every store, in one command, processes first
149
+
150
+ `clean.sh` exists so that deleting is something the operator *asks for*. What makes it hard is that
151
+ the data is not in one place:
152
+
153
+ | Role | What `clean.sh` has to remove | What is left behind if it is forgotten |
154
+ | --- | --- | --- |
155
+ | system of record | the schema and its rows | — |
156
+ | read model | the index / view / table and its contents | screens answer with documents whose rows are gone — **deleted data on screen, which reads as a product bug** |
157
+ | event transport | the channels, their retained messages, **and the consumer offsets** | the next run replays old change events, or the consumer resumes from an offset in a channel that was recreated |
158
+ | change propagation | the registered connector and its stored offsets / slot / cursor | propagation resumes from a position that no longer means anything, and captures nothing |
159
+ | cache and job queue | queued and delayed jobs | a worker starts and immediately processes jobs about rows that no longer exist |
160
+ | object storage | the generated files | orphan files accumulate, and a re-load's stand-ins mix with the previous run's |
161
+ - **A partial clean is worse than none.** Every row above describes a stack that starts cleanly and
162
+ behaves wrongly. If the script cannot reach one of these stores, it must say so rather than report
163
+ success.
164
+ - **Stop the processes first.** A consumer or worker still running while the stores are emptied
165
+ repopulates them from the messages it is holding, and the environment ends up in a state neither
166
+ clean nor loaded. `clean.sh` calls the same stop the `down.sh` path uses, then deletes.
167
+ - **Prefer dropping the volumes to emptying the stores one by one.** `docker compose down --volumes`
168
+ cannot half-clean: it removes every store the compose file owns in a single operation. Per-store
169
+ deletion through each service's API is faster on a big environment, but it is a list that has to be
170
+ maintained as the stack grows — and the failure mode of forgetting an entry is silent. Whatever the
171
+ mechanism, **anything outside the volumes still has to be removed explicitly**: the object storage
172
+ directory on the host, and the process logs if they would otherwise mislead the next session.
173
+ - **Cleaning does not re-load, and does not restart.** `clean.sh` leaves nothing running and prints
174
+ the two ways forward: `up.sh` to come back with the seed set, `start.sh` to come back deliberately
175
+ empty.
176
+
177
+ ## Waiting on health, never on sleep
178
+
179
+ ```bash
180
+ COMPOSE_FILE=e2e/docker/compose.yaml # the scripts always name the definition explicitly
181
+ HEALTH_ATTEMPT_LIMIT=90
182
+ HEALTH_ATTEMPT_INTERVAL_SECONDS=2
183
+
184
+ function waitForHealthy () {
185
+ local service=$1
186
+ local attempt=0
187
+
188
+ echo -n "waiting for ${service} "
189
+
190
+ # compose reports each container's own healthcheck result; this only watches it
191
+ until [ "$(docker compose -f "${COMPOSE_FILE}" ps --format '{{.Health}}' "${service}")" = 'healthy' ]; do
192
+ attempt=$((attempt + 1))
193
+
194
+ if [ "${attempt}" -gt "${HEALTH_ATTEMPT_LIMIT}" ]; then
195
+ echo ''
196
+ echo "${service} did not become healthy. try: docker compose -f ${COMPOSE_FILE} logs ${service}" >&2
197
+
198
+ exit 1
199
+ fi
200
+
201
+ echo -n '.'
202
+ sleep "${HEALTH_ATTEMPT_INTERVAL_SECONDS}"
203
+ done
204
+
205
+ echo ' ok'
206
+ }
207
+ ```
208
+
209
+ - **A fixed `sleep 30` is a race**: it passes on a fast machine, fails on a loaded one, and wastes
210
+ half a minute when everything was ready in five seconds.
211
+ - **Failing names the next command.** The message says which service and which log to read; a script
212
+ that just says "timed out" makes every developer rediscover `docker compose logs`.
213
+ - **Whichever service is slowest sets the budget** — a search or database cluster that elects itself,
214
+ usually. One limit generous enough for it is simpler than a per-service budget.
215
+
216
+ ## The application and the background processes are part of the environment
217
+
218
+ Whatever processes actually move data — the worker daemon and the change-log consumer in the example,
219
+ an outbox poller or a scheduler elsewhere — plus the application itself, which is what there is to
220
+ operate. Start all of them from the script and own their lifetime:
221
+
222
+ ```bash
223
+ # the script names are the example's; the shape — one line per process, PID appended — is the point
224
+ mkdir -p "${LOG_DIR}"
225
+
226
+ NODE_ENV=<stack-env> npm run job:daemon > "${LOG_DIR}/daemon.log" 2>&1 &
227
+ echo $! >> "${PID_FILE}"
228
+
229
+ NODE_ENV=<stack-env> npm run cdc:consumer > "${LOG_DIR}/consumer.log" 2>&1 &
230
+ echo $! >> "${PID_FILE}"
231
+
232
+ NODE_ENV=<stack-env> npm run start > "${LOG_DIR}/app.log" 2>&1 &
233
+ echo $! >> "${PID_FILE}"
234
+ ```
235
+
236
+ - **Record the PIDs in a file, not just a shell variable.** `down.sh` is a different process from
237
+ `up.sh` and has no other way to find them; a PID file under `e2e/` (git-ignored) is what connects
238
+ the two.
239
+ - **Wait until each is actually working, not merely launched.** Poll for the readiness signal each one
240
+ prints, or for its effect — a consumer group registered on the broker, the application answering on
241
+ its port. A process that has started is not yet a process that has joined the group.
242
+ - **Capture their output to files.** When something does not appear on screen, the answer is in one of
243
+ these logs; a build that discarded them forces a rebuild to find out why.
244
+ - **A subscriber cannot start before the channel it subscribes to exists** — in the example the
245
+ consumer exits complaining that the broker does not host the topic-partition. If `start.sh` step 4
246
+ was skipped, this is where it shows up, whatever the transport is.
247
+
248
+ ## Hand over at the end
249
+
250
+ The last thing `start.sh` prints — and therefore the last thing `up.sh` prints — is what the
251
+ operator needs to start:
252
+
253
+ ```bash
254
+ cat <<EOF
255
+
256
+ the environment is up.
257
+
258
+ open ${APP_BASE_URL}
259
+ logs ${LOG_DIR}/{app,daemon,consumer}.log
260
+ seed e2e/seed.sh # loads the set into an empty schema
261
+ stop e2e/down.sh # keeps the data
262
+ wipe e2e/clean.sh # deletes it, everywhere
263
+
264
+ EOF
265
+ ```
266
+
267
+ - **An environment nobody can find their way into is not finished.** The URL, the logs and the exits
268
+ are the minimum; add whatever else a first-time operator would otherwise have to ask someone for.
269
+ - **Print the exits side by side, labelled by consequence.** `down.sh` and `clean.sh` differ only in
270
+ whether the afternoon's work survives; a hand-over that lists one command called "tear down" invites
271
+ the wrong one.
272
+ - **`start.sh` does not know whether there is data**, and does not try to find out — so it lists
273
+ `seed.sh` as an available action rather than reporting a state. An operator looking at empty screens
274
+ has the command right in front of them.
275
+ - **Say where the sign-in accounts come from** — they are seed rows ([seed-data.md](./seed-data.md)),
276
+ so the hand-over only has to point at them, not restate them.
277
+
278
+ ## Abort on failure, stay up on success
279
+
280
+ ```bash
281
+ set -euo pipefail
282
+
283
+ function abort () {
284
+ # only reached when start.sh did not complete.
285
+ # stop what was started — never clean: deleting data is not this script's decision to make.
286
+ e2e/down.sh
287
+ }
288
+
289
+ trap abort EXIT
290
+
291
+ # ... the start.sh steps ...
292
+
293
+ printHandover
294
+
295
+ trap - EXIT # it succeeded: leave everything running
296
+ ```
297
+
298
+ - **Trap while starting, clear the trap at the end.** A run that died at the provisioning step must
299
+ not leave containers and Node processes behind for the next attempt to inherit — but a run that
300
+ succeeded must leave exactly that, because that is the result.
301
+ - **The abort path stops; it does not wipe.** A failed run that also deleted the data would turn a
302
+ recoverable problem into a lost afternoon. If `seed.sh` is what failed, the schema is left
303
+ half-loaded and the operator is told so — `clean.sh` then `up.sh` is the way out, and it is their
304
+ call, not the script's.
305
+ - **Without `-e`, a failed seeding step is followed by a hand-over of a half-loaded environment**, and
306
+ the operator discovers it screen by screen. Without `pipefail` a failure inside a pipeline is hidden
307
+ by the success of the last command.
308
+ - **`down.sh` stops the processes before the containers.** A worker whose queue vanished spends its
309
+ shutdown retrying a connection and produces a page of noise around the real failure.
310
+ - **`down.sh` keeps the volumes; `clean.sh` is what drops them.** That is what makes `start.sh` after
311
+ a `down.sh` return the operator to the environment they left. `clean.sh` is also the answer when a
312
+ container-level thing (the database's init directory, the broker's stored connector config) needs
313
+ rebuilding, because those only re-run on volume creation.
314
+ - **Read connection values out of the env file** rather than restating them in the scripts: two places
315
+ saying different things is how a setup script rots. Read the key, fall back to a documented default.
316
+
317
+ ## The CI stance
318
+
319
+ **This is a developer's environment, not a pull-request check.** A stack of containers, an image build
320
+ and a real propagation wait turn a two-minute check into a long one, and the failure modes (a slow
321
+ runner, an image registry hiccup) are not about the code.
322
+
323
+ - Keep the fast check exactly as it is: the unit suite on the local file database. Nothing in `e2e/`
324
+ is discovered by it, so this environment cannot slow that workflow down or make it need Docker.
325
+ - If a scheduled job is wanted, let it run **`clean.sh`, `up.sh`, then `down.sh`** in a workflow of its
326
+ own — the signal is "the environment still builds *from nothing*", which is worth having daily, not
327
+ hourly. CI is the one place that should always start clean, because there is no operator's state to
328
+ protect there.
329
+ - CI runs the same scripts. That is the point of having them: the environment CI builds is the
330
+ environment a developer builds.