@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,105 @@
1
+ ---
2
+ name: hor-subscription-resolver
3
+ description: >
4
+ Implement a GraphQL subscription resolver — a class extending the framework's base subscription
5
+ resolver that declares the subscription operation, scopes its channel per subscriber, and gates
6
+ who may subscribe. Use this skill whenever the user asks to add or change a subscription, scope
7
+ or authorize a subscription channel, or wire the publish side that pushes events to subscribers.
8
+ ---
9
+
10
+ # Subscription Resolver
11
+
12
+ A skill for **GraphQL subscription resolvers**: the class that lets a client **subscribe to a
13
+ channel** and receive a **stream of pushed events**. It declares the operation, decides **which
14
+ channel** a caller listens on, and **whether they may**. The events themselves are **published** by
15
+ whatever changes state (a mutation or a background worker), through a PubSub **broker** — the
16
+ subscription resolver and the publisher meet on a named channel, never calling each other directly.
17
+
18
+ This overview maps each topic to a section; the details are in the detail files under `references/`.
19
+
20
+ > This skill states a **general, project-independent rule** — a refined best practice, not a
21
+ > description of any one project's code, so it need not match a given repo's existing notation. The
22
+ > class and field names (`OnReceiveMessageSubscriptionResolver`, `onReceiveMessage`, `roomId`, …) are
23
+ > **illustrative fakes**; use your project's own names and never bake its domain or file paths into
24
+ > the rule. The framework base is shown as `BaseSubscriptionResolver`; treat it as "your framework's
25
+ > base subscription resolver". Sample code follows the project's lint style (no semicolons, 2-space
26
+ > indent, a space before the parameter parenthesis, trailing commas).
27
+
28
+ ## Grand principle: the resolver owns the channel; the state-changer publishes to it
29
+
30
+ A subscription resolver is a **read-only push endpoint**. It does two things: **name and scope the
31
+ channel** a subscriber listens on, and **decide if that subscriber is allowed**. It never mutates
32
+ state and it does not produce the events — a **mutation or worker publishes** them onto the same
33
+ channel, and the broker fans them out to every matching subscriber.
34
+
35
+ - **The subscription resolver is the single source of truth for the channel contract.** The channel
36
+ name is derived from the resolver's `schema` (the prefix) plus its `generateChannelQuery` (the
37
+ scope). The publisher builds its message via the **same class** (`buildTopic`), so the two sides
38
+ can never disagree on the channel — that is why a publisher imports the subscription resolver.
39
+ - **The broker decouples the two sides.** Subscriber and publisher share only a channel string; they
40
+ can live in **different processes** (e.g. a background worker publishes; the API process serves the
41
+ subscription).
42
+ - **Keep it thin.** Scope, authorize, unwrap. No business logic, no writes.
43
+
44
+ ## 1. Basic notation
45
+
46
+ A subscription resolver extends the framework base and overrides a small, fixed set of members. Every
47
+ per-call method receives the **same four arguments** — `{ variables, context, information, parent }`
48
+ (destructure what you need). The essential members:
49
+
50
+ | Member | Override? | Role |
51
+ | --- | --- | --- |
52
+ | `static get schema ()` | **required** | the subscription operation name — also the **channel prefix** and the **message key** |
53
+ | `generateChannelQuery ({ variables, context, … })` | usually | key/value hash that **scopes** the channel per subscriber; default `{}` = broadcast to all |
54
+ | `async canSubscribe ({ variables, context, … })` | for auth ([§2](#2-adding-authentication)) | boolean subscribe-time gate; default `true` |
55
+ | `static get errorCodeHash ()` | when adding auth | merge `...super.errorCodeHash` + the subscribe-denied code |
56
+ | `resolve (payload)` | rarely | maps the published message to the returned value; the base unwraps `payload[schema]` |
57
+ | `static get operation` / `channelPrefix` / `subscribe` / `buildTopic` / `publishTopic` | **no** | provided by the base — the subscribe flow, channel building, and publish helpers |
58
+
59
+ The class skeleton, the common-arguments table, the full example, and the `@typedef` shapes are in
60
+ [basic-notation.md](./references/basic-notation.md).
61
+
62
+ ## 2. Adding authentication
63
+
64
+ Authorization happens **once, at subscribe time**, in **`canSubscribe`** — a boolean gate. Returning
65
+ `false` makes the base throw the subscribe-denied error, so also declare that error code in
66
+ `errorCodeHash`. Authenticated-only is `return context.hasAuthenticated()`; resource-scoped access
67
+ combines the principal with the input; private streams are additionally scoped by principal in
68
+ `generateChannelQuery`.
69
+
70
+ The full `canSubscribe` / `errorCodeHash` example, the authenticated / resource-scoped / identity
71
+ patterns, and the once-per-subscribe note are in [authentication.md](./references/authentication.md).
72
+
73
+ ## 3. Design philosophy
74
+
75
+ - **Read-only push; the state-changer publishes.** The resolver opens a scoped, authorized channel;
76
+ the mutation/worker that changes state publishes to it after the change commits.
77
+ - **One channel contract, one owner.** Both sides derive the channel from the same subscription
78
+ resolver class — the subscriber via `generateChannelQuery`, the publisher via `buildTopic` — so the
79
+ prefix and scope can never drift.
80
+ - **Scoping = per-subscriber isolation**, and the **broker** lets the publisher run in a separate
81
+ process from the API. Keep the payload minimal and `resolve` thin.
82
+
83
+ The publish-side example and the full rationale are in
84
+ [design-philosophy.md](./references/design-philosophy.md).
85
+
86
+ ## Finishing checklist
87
+
88
+ - [ ] `static get schema` returns the subscription operation name (= channel prefix = message key) ([§1](#1-basic-notation)).
89
+ - [ ] `generateChannelQuery` scopes the channel per subscriber (or `{}` only for a true broadcast).
90
+ - [ ] The resolver does **no** writes and **no** business logic — it scopes, authorizes, and unwraps.
91
+ - [ ] If access is restricted: `canSubscribe` returns the boolean gate and `errorCodeHash` declares the subscribe-denied code ([§2](#2-adding-authentication)); private channels are also scoped by principal.
92
+ - [ ] The publisher (mutation/worker) builds its topic via **this class's** `buildTopic` and publishes through the broker — no hand-written channel string ([§3](#3-design-philosophy)).
93
+ - [ ] The published payload is minimal; `resolve` is left to the base unless a reshape is needed.
94
+
95
+ ## Detail files
96
+
97
+ - [basic-notation.md](./references/basic-notation.md) — the class skeleton, the common
98
+ `{ variables, context, information, parent }` arguments, the member table in full, the example, and
99
+ the `@typedef` input/response shapes (§1)
100
+ - [authentication.md](./references/authentication.md) — `canSubscribe` as the boolean gate,
101
+ `errorCodeHash`, the authenticated / resource-scoped / identity-scoping patterns, subscribe-time
102
+ timing (§2)
103
+ - [design-philosophy.md](./references/design-philosophy.md) — read-only push, the single channel
104
+ contract and the publish-side example, per-subscriber isolation, broker decoupling, minimal payload
105
+ (§3)
@@ -0,0 +1,99 @@
1
+ # Adding authentication
2
+
3
+ How a subscription decides who may subscribe. Referenced from §2 of [SKILL.md](../SKILL.md). Names are
4
+ illustrative fakes — use your project's own.
5
+
6
+ ## The gate: `canSubscribe`
7
+
8
+ Authorization happens **once, at subscribe time**, in **`canSubscribe`** — a boolean predicate.
9
+ Returning `false` makes the base throw the subscribe-denied error, so also declare that error code in
10
+ `errorCodeHash`.
11
+
12
+ ```js
13
+ /** @override */
14
+ static get errorCodeHash () {
15
+ return {
16
+ ...super.errorCodeHash,
17
+
18
+ CanNotSubscribe: '102.S001.001',
19
+ }
20
+ }
21
+
22
+ /**
23
+ * Whether the caller may subscribe to this channel.
24
+ *
25
+ * @override
26
+ * @param {{
27
+ * variables: OnReceiveMessageVariables
28
+ * context: GraphqlType.ResolverInputContext
29
+ * }} params - Parameters.
30
+ * @returns {Promise<boolean>}
31
+ */
32
+ async canSubscribe ({
33
+ variables,
34
+ context,
35
+ }) {
36
+ return context.hasAuthenticated()
37
+ }
38
+ ```
39
+
40
+ ## Patterns
41
+
42
+ - **Authenticated-only** — the caller must be a valid principal:
43
+
44
+ ```js
45
+ async canSubscribe ({
46
+ context,
47
+ }) {
48
+ return context.hasAuthenticated()
49
+ }
50
+ ```
51
+
52
+ - **Resource-scoped** — the caller must own or belong to what they subscribe to. Combine the
53
+ principal with the input, and keep `canSubscribe` a predicate by doing the lookup in a separate
54
+ method:
55
+
56
+ ```js
57
+ async canSubscribe ({
58
+ variables,
59
+ context,
60
+ }) {
61
+ if (!context.hasAuthenticated()) {
62
+ return false
63
+ }
64
+
65
+ return this.isMemberOfRoom({
66
+ variables,
67
+ context,
68
+ })
69
+ }
70
+ ```
71
+
72
+ - **Identity-scoped channel** — for a private stream, also derive the channel from the principal in
73
+ `generateChannelQuery` (e.g. include `context.userId`), so a subscriber can only *build* a channel
74
+ for their own data. Authorization and channel scoping then reinforce each other: even a caller who
75
+ passes `canSubscribe` receives only events on their own channel.
76
+
77
+ ```js
78
+ generateChannelQuery ({
79
+ context: {
80
+ userId,
81
+ },
82
+ }) {
83
+ return {
84
+ userId,
85
+ }
86
+ }
87
+ ```
88
+
89
+ ## Timing
90
+
91
+ - `canSubscribe` runs **when the subscription is established, not per message** — it is a cheap,
92
+ one-time gate. Do not put per-message filtering here.
93
+ - This is the subscription's **own** gate. It is in addition to any endpoint-wide authentication
94
+ filter the server applies before a resolver runs; the two are independent — the endpoint filter
95
+ decides "may this caller reach this operation at all", `canSubscribe` decides "may this caller open
96
+ this specific channel".
97
+ - Because the decision is a plain boolean derived from `context` (and optionally `variables`),
98
+ `canSubscribe` is trivial to unit-test: feed a context with and without an authenticated principal
99
+ and assert the boolean.
@@ -0,0 +1,116 @@
1
+ # Basic notation — members & common arguments
2
+
3
+ The class skeleton, the arguments every method receives, and the member contract. Referenced from §1
4
+ of [SKILL.md](../SKILL.md). Class and field names (`OnReceiveMessageSubscriptionResolver`,
5
+ `onReceiveMessage`, `roomId`, …) are illustrative fakes — use your project's own names.
6
+
7
+ ## Common arguments
8
+
9
+ Every per-call method on a subscription resolver receives the **same four arguments**. Destructure
10
+ only what the method needs.
11
+
12
+ | Argument | What it is |
13
+ | --- | --- |
14
+ | `variables` | the subscription's input arguments |
15
+ | `context` | the per-request context — the auth principal, and the PubSub broker (`context.broker`) |
16
+ | `information` | GraphQL resolve info (the operation/field name) |
17
+ | `parent` | the parent resolver's output (typically absent at the subscription root) |
18
+
19
+ ## Members
20
+
21
+ A subscription resolver extends the framework base and overrides a small, fixed set of members. The
22
+ rest of the subscribe flow (channel building, the async iterable, the publish helpers) is provided by
23
+ the base and is **not** overridden.
24
+
25
+ | Member | Override? | Role |
26
+ | --- | --- | --- |
27
+ | `static get schema ()` | **required** | the subscription operation name — also the **channel prefix** and the **message key** |
28
+ | `generateChannelQuery ({ variables, context, … })` | usually | key/value hash that **scopes** the channel per subscriber; default `{}` = broadcast to all |
29
+ | `async canSubscribe ({ variables, context, … })` | for auth ([authentication.md](./authentication.md)) | boolean subscribe-time gate; default `true` |
30
+ | `static get errorCodeHash ()` | when adding auth | merge `...super.errorCodeHash` + the subscribe-denied code |
31
+ | `resolve (payload)` | rarely | maps the published message to the returned value; the base unwraps `payload[schema]` |
32
+ | `static get operation` | **no** | fixed to the subscription operation kind |
33
+ | `static get channelPrefix` | **no** | defaults to `schema` |
34
+ | `subscribe` / `generateChannel` / `generateAsyncIterable` | **no** | the base subscribe flow |
35
+ | `static buildTopic` / `static publishTopic` | **no** (call, don't override) | the publish-side helpers used by the state-changer ([design-philosophy.md](./design-philosophy.md)) |
36
+
37
+ ## The skeleton
38
+
39
+ ```js
40
+ import {
41
+ BaseSubscriptionResolver,
42
+ } from '@openreachtech/renchan'
43
+
44
+ /**
45
+ * Subscription resolver: push new messages of a room to its subscribers.
46
+ *
47
+ * @extends {BaseSubscriptionResolver<OnReceiveMessageVariables, OnReceiveMessageResponse>}
48
+ */
49
+ export default class OnReceiveMessageSubscriptionResolver extends BaseSubscriptionResolver {
50
+ /** @override */
51
+ static get schema () {
52
+ return 'onReceiveMessage'
53
+ }
54
+
55
+ /** @override */
56
+ static get errorCodeHash () {
57
+ return {
58
+ ...super.errorCodeHash,
59
+ }
60
+ }
61
+
62
+ /**
63
+ * Scope the channel per subscriber (here: by room).
64
+ *
65
+ * @override
66
+ * @param {{
67
+ * variables: OnReceiveMessageVariables
68
+ * }} params - Parameters.
69
+ * @returns {Record<string, string | number>} Channel query.
70
+ */
71
+ generateChannelQuery ({
72
+ variables: {
73
+ input: {
74
+ roomId,
75
+ },
76
+ },
77
+ }) {
78
+ return {
79
+ roomId,
80
+ }
81
+ }
82
+ }
83
+
84
+ /**
85
+ * @typedef {{
86
+ * input: {
87
+ * roomId: number
88
+ * }
89
+ * }} OnReceiveMessageVariables
90
+ */
91
+
92
+ /**
93
+ * @typedef {{
94
+ * onReceiveMessage: {
95
+ * message: {
96
+ * id: number
97
+ * content: string
98
+ * }
99
+ * }
100
+ * }} OnReceiveMessageResponse
101
+ */
102
+ ```
103
+
104
+ ## Notes on each member
105
+
106
+ - **`schema`** is the one required member: it is the operation name **and** the channel prefix **and**
107
+ the key the payload is wrapped under. Keep it identical to the GraphQL field.
108
+ - **`generateChannelQuery`** returns the values that narrow the channel. Return `{}` only when every
109
+ subscriber genuinely wants every event. The base calls it inside `subscribe`; you never call
110
+ `subscribe` yourself.
111
+ - **`errorCodeHash`** starts as a spread of `super.errorCodeHash`; add codes only when the resolver
112
+ introduces its own errors (e.g. the subscribe-denied code once you add `canSubscribe`).
113
+ - **`resolve (payload)`** is left to the base unless the pushed message must be reshaped before it
114
+ reaches the client; the default returns `payload[schema]`.
115
+ - The `@typedef` blocks give the input (`Variables`) and pushed-message (`Response`) shapes — the
116
+ `Response` object is keyed by `schema`.
@@ -0,0 +1,68 @@
1
+ # Design philosophy
2
+
3
+ Why a subscription is split into a channel-owning resolver and a separate publisher. Referenced from
4
+ §3 of [SKILL.md](../SKILL.md). Names are illustrative fakes — use your project's own.
5
+
6
+ ## Read-only push; the state-changer publishes
7
+
8
+ The subscription resolver only opens a **scoped, authorized channel** and streams from it. The event
9
+ is produced by whatever **changes state** — a mutation, or a background worker — which **publishes**
10
+ to the channel **after the change commits**. Never publish from inside the subscription resolver, and
11
+ never mutate state there.
12
+
13
+ - **Why**: publishing before the write commits would push an event that a later failure rolls back.
14
+ Making the state-changer own the publish keeps "the change happened" and "subscribers were told"
15
+ in the same place, in the right order.
16
+
17
+ ## One channel contract, one owner
18
+
19
+ Both sides derive the channel from the **same subscription resolver class**: the subscriber via
20
+ `subscribe` → `generateChannelQuery`, the publisher via the class's `buildTopic`. The publisher
21
+ therefore **imports the subscription resolver** and never hand-writes a channel string — so the
22
+ prefix and scope can never drift apart.
23
+
24
+ ```js
25
+ // In the state-changer (a mutation or a worker): build the topic from the SAME subscription resolver,
26
+ // then publish it through the broker on the context. The channel is never hand-written.
27
+ const topic = OnReceiveMessageSubscriptionResolver.buildTopic({
28
+ payload: {
29
+ message,
30
+ },
31
+ channelQuery: {
32
+ roomId,
33
+ },
34
+ })
35
+
36
+ await this.publishTopic({
37
+ context,
38
+ topic,
39
+ })
40
+ ```
41
+
42
+ - The publisher's `channelQuery` **must match** the subscriber's `generateChannelQuery` output for
43
+ the event to arrive. Because both come from one class, a change to the scope updates both sides at
44
+ once.
45
+
46
+ ## Scoping = per-subscriber isolation
47
+
48
+ `generateChannelQuery` narrows the channel so a subscriber receives only its own events:
49
+
50
+ - **By input** (`roomId`) — topic selection: the caller chooses which stream to listen to.
51
+ - **By principal** (`userId`) — privacy: the caller can only listen to their own stream
52
+ ([authentication.md](./authentication.md)).
53
+
54
+ A broadcast channel (`generateChannelQuery` returns `{}`) is correct only when every subscriber
55
+ genuinely wants every event.
56
+
57
+ ## Broker decoupling enables cross-process push
58
+
59
+ Subscriber and publisher share only a **channel string**, exchanged through the PubSub **broker**
60
+ (reached via the context / the app's shared instances). They never call each other. This is what lets
61
+ the publisher run in a **separate process** from the API that serves the subscription — for example a
62
+ background worker publishing progress that a client subscribed to in the API process.
63
+
64
+ ## Minimal payload, thin `resolve`
65
+
66
+ Publish only what the client needs; the default `resolve` merely unwraps `payload[schema]`. Override
67
+ `resolve` only to reshape the pushed message, never to fetch or compute — keeping the payload small
68
+ and the resolver thin keeps the push path fast and the contract obvious.
@@ -0,0 +1,200 @@
1
+ ---
2
+ name: hor-type-interface
3
+ description: >
4
+ Define TypeScript type interfaces in .d.ts declaration files: model interfaces (one file per
5
+ model/table under types/models/, in the global `model` namespace) and resolver input/output
6
+ types (one file per resolver under types/resolvers/<category>/, in the global
7
+ `graphql.<category>` namespace, as <Resolver>Input and <Resolver>Result). Use this skill
8
+ whenever the user asks to add or change a model interface, a resolver's Input/Result types, or
9
+ another shared global type.
10
+ ---
11
+
12
+ # Type Interface Definition
13
+
14
+ A skill for the **`.d.ts` type declarations** that describe an app's data shapes: the **model
15
+ interfaces** (one per table) and the **resolver input/output types** (one per resolver). Both are
16
+ declared as **ambient global namespaces**, so any JSDoc can reference them (`model.User`,
17
+ `graphql.user.CreateOrderInput`) without an import. The core rule is **one file per entity** — one
18
+ model, one resolver — merged into a single namespace by TypeScript's declaration merging.
19
+
20
+ > This skill states a **general, project-independent rule** — a refined best practice, not a
21
+ > description of any one project's code, so it need not match a given repo's existing notation. The
22
+ > directory names, namespaces (`model`, `graphql.<category>`), and example type names (`User`,
23
+ > `Order`, `CreateOrderInput`, …) are the **recommended convention with illustrative fakes**; use your
24
+ > project's own model and resolver names and never bake its domain concepts or file paths into the
25
+ > rule.
26
+
27
+ ## Grand principle: one file per entity, merged into one global namespace
28
+
29
+ Every model and every resolver gets its **own `.d.ts` file**, each declaring types into a **shared
30
+ global namespace**. TypeScript's **declaration merging** combines the same-named `namespace` blocks
31
+ from every file into one, so the split costs nothing at the access site.
32
+
33
+ - **Why one file per entity.** A monolithic `model.d.ts` / `graphql.d.ts` is a constant merge-conflict
34
+ point — every model or resolver change touches the same file. Splitting to `types/models/<ModelName>.d.ts`
35
+ and `types/resolvers/<category>/<resolverName>.d.ts` means two changes collide **only when they
36
+ touch the same entity**. Adding a model = adding a file.
37
+ - **Why it still reads as one namespace.** `declare global { namespace model { … } }` in
38
+ `User.d.ts` and the same block in `Order.d.ts` **merge** into a single `model` namespace. Consumers
39
+ write `model.User` / `model.Order` regardless of which file declared them — the file split is
40
+ invisible to readers.
41
+ - **Why global (ambient).** Declared under `declare global`, the types need **no import** to be used
42
+ in a JSDoc annotation anywhere in the codebase. That is the point of the namespaces — a resolver's
43
+ JSDoc just writes `@returns {Promise<graphql.user.CreateOrderResult>}`.
44
+ - **Wiring**: the project's `tsconfig` / `jsconfig` `include` must cover the `types/**` directory so
45
+ these ambient declarations are picked up project-wide.
46
+
47
+ **Sample code follows the project's lint style**: `.d.ts` uses no semicolons, 2-space indent, and
48
+ interface members are one-per-line (no trailing comma or semicolon). Comments in the files you
49
+ generate are English for structural notes; domain notes match the surrounding language.
50
+
51
+ ## 1. The `.d.ts` scaffold
52
+
53
+ Every declaration file has the same three-line envelope: an `export {}` module marker, then a
54
+ `declare global` block, then the `namespace`. The interfaces go inside the namespace.
55
+
56
+ ```ts
57
+ export {}
58
+
59
+ declare global {
60
+ namespace model {
61
+ // interfaces here
62
+ }
63
+ }
64
+ ```
65
+
66
+ - **`export {}`** makes the file a module (so `declare global` is legal). It exports nothing itself.
67
+ - **`declare global { … }`** puts the namespace in the ambient global scope — visible everywhere with
68
+ no import.
69
+ - The **namespace name is fixed by kind**: `model` for model interfaces ([§2](#2-model-interfaces-one-file-per-table)),
70
+ `graphql.<category>` for resolver types ([§3](#3-resolver-inputoutput-types-one-file-per-resolver)).
71
+
72
+ ## 2. Model interfaces (one file per table)
73
+
74
+ A model interface maps **1:1 to a table**. Put each in its own file
75
+ `types/models/<ModelName>.d.ts`, declaring one interface `<ModelName>` into `namespace model`.
76
+
77
+ ```ts
78
+ // types/models/User.d.ts
79
+ export {}
80
+
81
+ declare global {
82
+ namespace model {
83
+ interface User {
84
+ id: number
85
+ email: string
86
+ displayName: string | null
87
+ registeredAt: Date
88
+ OrganizationId: number
89
+ }
90
+ }
91
+ }
92
+ ```
93
+
94
+ ```ts
95
+ // types/models/Order.d.ts — a second model, its own file, same namespace
96
+ export {}
97
+
98
+ declare global {
99
+ namespace model {
100
+ interface Order {
101
+ id: number
102
+ UserId: number
103
+ totalAmount: number
104
+ placedAt: Date
105
+ canceledAt: Date | null
106
+ }
107
+ }
108
+ }
109
+ ```
110
+
111
+ - **One interface per file**, named exactly for the model, so it is reachable as `model.User` /
112
+ `model.Order`.
113
+ - **Fields mirror the table's columns.** Use the precise scalar type (`number` / `string` / `Date` /
114
+ `boolean`); a nullable column is `<type> | null`.
115
+ - **A field holding another model's id starts with an uppercase initial** (`UserId`,
116
+ `OrganizationId`), mirroring how the ORM's associations are named — this distinguishes a foreign-key
117
+ field from a plain scalar at a glance.
118
+ - Optionally, a model interface may `extend` a framework base-model interface (if the architecture
119
+ provides one for the common columns); keep that base generic, not a hard-coded app path.
120
+
121
+ ## 3. Resolver input/output types (one file per resolver)
122
+
123
+ A resolver's types map **1:1 to the resolver**. Put them in
124
+ `types/resolvers/<category>/<resolverName>.d.ts`, declaring into `namespace graphql.<category>` —
125
+ where `<category>` is the API/endpoint group (`user`, `admin`, `portal`, …). Each resolver declares
126
+ its **`<Resolver>Input`** and its **`<Resolver>Result`** (the output / response).
127
+
128
+ ```ts
129
+ // types/resolvers/user/createOrder.d.ts
130
+ export {}
131
+
132
+ declare global {
133
+ namespace graphql.user {
134
+ interface CreateOrderInput {
135
+ productId: number
136
+ quantity: number
137
+ }
138
+
139
+ interface CreateOrderResult {
140
+ order: model.Order
141
+ }
142
+ }
143
+ }
144
+ ```
145
+
146
+ - **Input** is the resolver's argument shape; **Result** is what it returns (the response). A
147
+ query uses the same `Input` / `Result` pairing.
148
+ - **Reuse model interfaces in the output** — a Result field is typed as `model.<ModelName>`
149
+ (`order: model.Order`). The `model` and `graphql.<category>` namespaces are both global, so one
150
+ references the other with no import.
151
+ - **Resolver-local helper types** (a nested filter input, a row sub-shape) live in the **same file**
152
+ as the resolver they belong to — they are part of that resolver's 1:1 slice, not shared globals.
153
+ - **Category = the resolver's endpoint group.** The same resolver name under a different endpoint is a
154
+ different file and a different namespace (`graphql.user.FooInput` vs `graphql.admin.FooInput`).
155
+
156
+ ## 4. Accessing the types
157
+
158
+ Because the namespaces are global, JSDoc references them directly — no import:
159
+
160
+ ```js
161
+ /**
162
+ * @param {{
163
+ * variables: {
164
+ * input: graphql.user.CreateOrderInput
165
+ * }
166
+ * }} params
167
+ * @returns {Promise<graphql.user.CreateOrderResult>}
168
+ */
169
+ async resolve ({
170
+ variables: {
171
+ input,
172
+ },
173
+ }) {
174
+ // input is typed as graphql.user.CreateOrderInput
175
+ }
176
+ ```
177
+
178
+ - Model shapes are referenced the same way: `@param {model.User} user`.
179
+ - This global access is the reason the types are ambient — the split into many files never forces an
180
+ import.
181
+
182
+ ## 5. Naming & placement (quick reference)
183
+
184
+ | Kind | File | Namespace | Interface names | Access |
185
+ | --- | --- | --- | --- | --- |
186
+ | Model | `types/models/<ModelName>.d.ts` | `model` | `<ModelName>` | `model.<ModelName>` |
187
+ | Resolver | `types/resolvers/<category>/<resolverName>.d.ts` | `graphql.<category>` | `<Resolver>Input`, `<Resolver>Result` | `graphql.<category>.<Resolver>Input` |
188
+
189
+ - File base names match the entity: `<ModelName>` (PascalCase) for models, `<resolverName>`
190
+ (matching the resolver, camelCase) for resolvers.
191
+ - Avoid the denied vague identifiers in field names (`data` / `info` / `list` / …); name a field for
192
+ what it holds.
193
+
194
+ ## Finishing checklist
195
+
196
+ - [ ] The type lives in its **own file** — one model → `types/models/<ModelName>.d.ts`; one resolver → `types/resolvers/<category>/<resolverName>.d.ts` ([§1](#1-the-dts-scaffold)).
197
+ - [ ] File envelope is `export {}` → `declare global` → the correct `namespace` (`model` or `graphql.<category>`).
198
+ - [ ] Model interface is 1:1 with a table; fields mirror columns; nullable is `| null`; a foreign-key field starts uppercase ([§2](#2-model-interfaces-one-file-per-table)).
199
+ - [ ] Resolver file declares `<Resolver>Input` + `<Resolver>Result`, reuses `model.<ModelName>` in outputs, and keeps resolver-local helper types in the same file ([§3](#3-resolver-inputoutput-types-one-file-per-resolver)).
200
+ - [ ] The `types/**` directory is included in the project's TS config so the ambient declarations resolve.
@@ -0,0 +1,40 @@
1
+ # スキル
2
+
3
+ このパッケージに収録された全 31 スキルのカタログです。各スキルに 1〜2 行の概要を添えています。
4
+
5
+ 各スキルは `kit/skills/backend/<name>/` に、ドメインディレクトリの直下 1 階層で置かれます。そのフォルダ名がスキルの `name:` であり、インストール後のフォルダ名でもあります。したがって下表の **スキル** だけで足ります。`/name` として呼び出す名前、インストール後に `.claude/skills/` に現れる名前、ソースの置き場所が、すべて同じ 1 つの文字列です。先頭 3 文字はドメインを表します。配置と命名の規則は [flatten ビルド規約](https://github.com/openreachtech/hora-skills-ort-renchan/blob/main/.claude/skills/flatten/SKILL.md) を参照してください。各スキルの詳細は、それぞれの `SKILL.md` にあります。
6
+
7
+ | スキル (= コマンド) | 概要 |
8
+ | :-- | :-- |
9
+ | `hor-agent-loop` | `@openreachtech/mentsu-agent-loop` の 3 パッケージで LLM エージェントループを構築します。core(反復エンジン)、BullMQ ジョブ実行、GraphQL の起動 mutation と進捗 subscription。 |
10
+ | `hor-ai-agent-structure` | `mentsu-agent-loop-core` 上にアプリ側 AI エージェントを構成します。`app/agents/<name>/` に `ProceduralAgentLoop` サブクラスとステップごとの `BaseAgentAction` サブクラスを置きます。 |
11
+ | `hor-ai-prompt-document-store` | エージェントの設定・指示文・ドキュメント・ツールスキーマをコードに埋め込まず DB に保持し、リクエスト時にプロンプトへ組み立て、バックアップテーブルでバージョン管理します。 |
12
+ | `hor-backend-testing` | テストファイルの配置(DB 書き込みなしは `tests/__tests__`、ありは `tests/_orders`)、DB 書き込みテストの実行順の保証、実行方法、テストとダブルの純粋性ルール。 |
13
+ | `hor-bank-id` | 1 つのバックエンドリポジトリ内で、依頼者ごとに排他的で衝突しない行 id プレフィックスを割り当てる。シーダーやテストフィクスチャで 2 人の書き手が同じ明示 id を選ばないようにする。 |
14
+ | `hor-build-e2e-test-environment` | `e2e/docker/` 配下の手動操作用ローカル E2E 環境の構築・実行・デバッグ。コンテナ構成、本番にリバースプロキシがある場合はその層、専用シードセット、`up`/`start`/`seed`/`clean`/`down` スクリプト。 |
15
+ | `hor-constant-definition` | アプリ定数は必ず 2 ファイルで定義します。`constants/` の CommonJS マスター(単一の情報源)と、それを再 export する `app/constants/` の ESM ブリッジ。 |
16
+ | `hor-cookie-authentication` | renchan バックエンドのアクター別 Cookie 認証。認証情報とトークンのモデル、アクセストークンとローテーションするリフレッシュトークン(再利用検知つき)、HttpOnly のリフレッシュ Cookie、signIn / signUp / signOut / renewAccessToken の各リゾルバー。 |
17
+ | `hor-database-design` | マイグレーションやモデルを書く前に決めるスキーマの論理設計。正規化の判断、ステータス/カテゴリの表現、カラム型、時刻の保持、読み取りのスケール、履歴とバージョン管理。 |
18
+ | `hor-execution-placement-pattern` | 処理(特に書き込み)をどこに実装するかの判断。同期的な GraphQL/REST 操作か、API ハンドラ・post-worker・スケジュールから起動するバックグラウンドワーカーか。 |
19
+ | `hor-external-api-client` | `@openreachtech/mentsu-rocket-client` で外部 HTTP/REST API クライアントを実装します。`app/<serviceName>Client/` 配下の Launcher / Payload / Capsule の 3 クラス構成。 |
20
+ | `hor-graphql-schema` | renchan サーバの GraphQL SDL(`.graphql`)を書きます。オーディエンス別スキーマ、ドメイン別の番号付きファイル、カスタムスカラー、命名・null 許容・enum・ページネーションの規約。 |
21
+ | `hor-graphql-server-engine` | エンドポイントごとの `*GraphqlServerEngine` を実装・起動します。URL、スキーマパス、リゾルバディレクトリ、Share/Context の DI、認証フィルタ、ミドルウェア、スカラー、エラーコード。 |
22
+ | `hor-light-rag` | ベクタ DB なしで AI エージェント向けの軽量 RAG を追加します。ローカル埋め込みによる vector-first / LLM フォールバックのランキングと、MySQL の n-gram 全文検索インデックス。 |
23
+ | `hor-multi-llm-provider` | Claude / OpenAI / Gemini を 1 つの抽象の下で扱います。抽象モデルプロセッサ、ベンダーごとの基底、モデルごとの具象クラス、モデル名で選択するローダー。 |
24
+ | `hor-mutation-resolver` | `BaseMutationResolver` を継承した GraphQL Mutation リゾルバを実装します。状態を変更する操作と、それが動く単一トランザクション。 |
25
+ | `hor-post-worker` | post-worker を実装します。リゾルバが解決してレスポンス送信後に発火し、API の本処理に含めない副作用(通知メール、監査ログ、キャッシュ無効化)を実行するフックです。 |
26
+ | `hor-query-resolver` | `BaseQueryResolver` を継承した GraphQL Query リゾルバを書きます。ページネーション、関連の include、ドメインエラーの throw、actual と stub のペア。 |
27
+ | `hor-renchan-job-bullmq` | `@openreachtech/renchan-job-bullmq` でバックグラウンドジョブを実装・配線します。Manifest / Worker / Dispatcher の 3 点セット、繰り返しジョブ、enqueue、進捗配信、並列数とリトライ。 |
28
+ | `hor-resolver-share` | Share クラスを実装します。サーバ起動時に一度作られ `context.share` として全リゾルバに渡されるプロセス単位のシングルトン置き場で、Share と Context の使い分けも扱います。 |
29
+ | `hor-resolver-validator` | リゾルバの入力検証クラス(`*InputValidator`)を実装します。`BaseInputValidator` を継承し、値の検査は `mentsu-value-inspector` に委譲します。 |
30
+ | `hor-restfulapi-architecture` | renchan バックエンドの REST 層。`server/restfulapi/` 配下のレンダラーアーキテクチャ、ルートとバージョン、`render()`、レスポンス/エラーハッシュ、認証フィルタ、フラッシャー。 |
31
+ | `hor-security-audit` | Node プロジェクト全体を読み取り専用でセキュリティ監査し、所見リストを出します。インジェクション、認証漏れ、ポート/データストア露出、シークレット、依存、CORS、レート制限、PII、アップロード。 |
32
+ | `hor-sequelize-migration` | renchan/Sequelize のマイグレーションを書きます。`createTable`、`addColumn`/`removeColumn`、`addIndex`、インデックス命名、外部キーカラムを持たせるかの判断。 |
33
+ | `hor-sequelize-model` | renchan/Sequelize のモデル定義を書きます。属性、`createOptions`、アソシエーション、スコープ、フック、`MixinModel` の配線。 |
34
+ | `hor-sequelize-seeder` | renchan/Sequelize のシーダーを書きます。master / dev-master / development の 3 ディレクトリ分割、ファイル雛形、ファイル名の採番、ファイルごとの ID ブロック採番。 |
35
+ | `hor-sequelize-subquery` | `this.addSubquery` で名前付きサブクエリを定義し、`Model.subquery(name, params)` で使います。関連テーブルの条件による絞り込みは JOIN ではなくサブクエリで行います。 |
36
+ | `hor-strategy-pattern` | 型文字列で分岐する else-if / switch を、基底プロセッサ・バリアントごとのサブクラス・ディレクトリから自動発見して選ぶ一括ローダーの 3 点構成に置き換えます。 |
37
+ | `hor-stub-api` | DB アクセスもビジネスロジックも持たず、スキーマどおりの固定データを返す stub リゾルバを実装します。実装前の API 契約に対してフロントエンドが開発できます。 |
38
+ | `hor-subscription-resolver` | GraphQL subscription リゾルバを実装します。操作の宣言、購読者ごとのチャンネルのスコープ、購読可否のゲート、イベントを push する publish 側の配線。 |
39
+ | `hor-type-interface` | `.d.ts` で型インターフェースを定義します。`types/models/` のモデルインターフェース(global `model`)と、`types/resolvers/<category>/` のリゾルバ Input/Result 型。 |
40
+