Skip to content

Commit 42b5267

Browse files
mpstatonclaude
andcommitted
refactor(services): give each NATS service its own registerHandlers name
Five services each exported a function called registerHandlers. Every one is imported only inside its own service, so nothing was broken — but a tree-wide search for registerHandlers returned five unrelated definitions, and three of them ranked in the codebase graph's top ten by connectivity, which made the most-connected symbols in the system also the least searchable. Each is now service-qualified: registerPromptStoreHandlers, registerContentIngestHandlers, registerRecordResolverHandlers, registerResponseStoreHandlers, registerRowStoreHandlers. registerPersonHandlers in record-surrealdb-resolver is deliberately unchanged. It was already unique, and renaming an unambiguous symbol is churn. Corrects a count in the refactor backlog. That document said three, because three was what the graph's top-ten showed; there are five. God-node rankings report the top of a distribution, not a census — worth remembering the next time one is read as a complete list. The backlog now records that, along with the three other items that shipped without originally being scoped: the turbo removal, the React eviction, and the shell typecheck fix. Verified: all five services typecheck clean, 19 packages build, and every test suite passes including the end-to-end group, which now has Docker available. Files changed: - services/{prompt-store,content-ingest,record-surrealdb-resolver,response-store,row-store}/src/{handlers,server}.ts - context-v/refactors/Structural-Refactors-Surfaced-by-the-Codebase-Graph.md Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019a8tSPbFdvF1pKtADnWyDg
1 parent b295817 commit 42b5267

11 files changed

Lines changed: 44 additions & 22 deletions

File tree

context-v/refactors/Structural-Refactors-Surfaced-by-the-Codebase-Graph.md

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ errors, and every non-Docker test suite passing.
291291
| 3 — utility consolidation | ⬜ not started (and see the services caveat below) |
292292
| 4 — design system | ⬜ not started — the actual project |
293293
| 5 — `Actor` import cycle | ✅ shipped — moved to `services/workspace/src/types.ts` |
294-
| 5 — rename three `registerHandlers()` | not started |
294+
| 5 — rename `registerHandlers()` | ✅ shipped — **five**, not three; one per service |
295295

296296
**Why 1.2 was deferred rather than done.** "Hoist the identical deps to the
297297
root" is the wrong fix under pnpm. pnpm's strict resolution means a package
@@ -304,12 +304,34 @@ lockfile and touches all 17 manifests, so it wants its own commit and its own
304304
verification pass — and it collides with the root `package.json` change in the
305305
stranded design-system work (see below).
306306

307-
**Two things shipped that this document did not originally list:** removing
308-
`turbo.json` and repointing the root scripts at `pnpm -r`, which made
309-
`pnpm build` work for the first time in the repo's history (reasoning in
310-
[[Why-This-Monorepo-Does-Not-Need-Turbo]]); and flagging the root
311-
`tsconfig.json` as vestigial — it sets `jsx: "react-jsx"` in a repo where React
312-
is prohibited and nothing extends it. Removing it is a separate decision.
307+
**Four things shipped that this document did not originally list:**
308+
309+
1. **`turbo.json` removed**, root scripts repointed at `pnpm -r`, which made
310+
`pnpm build` work for the first time in the repo's history. Reasoning in
311+
[[Why-This-Monorepo-Does-Not-Need-Turbo]].
312+
2. **React evicted.** The root `tsconfig.json` set `jsx: "react-jsx"` — the
313+
only React reference anywhere in the repo, against a hard prohibition, with
314+
zero `.tsx` files and no `react` dependency to justify it. Now
315+
`jsx: "preserve"`: TSX stays legal, no runtime is bound. Target also raised
316+
ES2020 → ES2022 and three dead path aliases removed.
317+
3. **The shell's typecheck fixed** — it had *never* passed. A missing
318+
`css.d.ts` shim, compounded by a tsconfig that omitted `src/**/*.d.ts` from
319+
`include` so the shim would have been ignored anyway; plus a real type error
320+
(`stageEl` typed `HTMLDivElement` while bound to a `<main>`). This also
321+
revealed the shell as the **eighteenth** copy of the converged tsconfig.
322+
4. **`registerHandlers()` renamed** — see below.
323+
324+
The `registerHandlers()` count in this document was **wrong**. It said three,
325+
because three appeared in the graph's top-ten by connectivity. There are
326+
**five**, one per NATS service. All are now service-qualified
327+
(`registerPromptStoreHandlers`, `registerContentIngestHandlers`,
328+
`registerRecordResolverHandlers`, `registerResponseStoreHandlers`,
329+
`registerRowStoreHandlers`), so a tree-wide search for any one of them is
330+
unambiguous. `registerPersonHandlers` in `record-surrealdb-resolver` was left
331+
alone — it was already unique, which was the entire point.
332+
333+
A reminder that god-node rankings show the *top* of a distribution, not the
334+
whole of it. Read them as "look here," never as a census.
313335

314336
**Conflict surface with the stranded design-system work.** Phase 0 adds
315337
`design:drift` / `design:contrast` to the root `package.json`, which this work

services/content-ingest/src/handlers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ type PreviewResult = {
8585
error?: string;
8686
};
8787

88-
export function registerHandlers(nc: NatsConnection): void {
88+
export function registerContentIngestHandlers(nc: NatsConnection): void {
8989
// corpus.domain.write_index — internal (resolver → here): write a domain's
9090
// folder + index.md definition file (<type-plural>/<slug>/index.md). Not a
9191
// browser capability; the resolver's domain.create handler requests it so the

services/content-ingest/src/server.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import { connect } from '@nats-io/transport-node';
2-
import { registerHandlers } from './handlers';
2+
import { registerContentIngestHandlers } from './handlers';
33

44
const NATS_URL = process.env.NATS_URL ?? 'nats://localhost:4222';
55

66
async function main(): Promise<void> {
77
const nc = await connect({ servers: NATS_URL, name: 'content-ingest-service' });
88
console.log(JSON.stringify({ level: 'info', msg: 'nats connected', url: NATS_URL }));
9-
registerHandlers(nc);
9+
registerContentIngestHandlers(nc);
1010
console.log(JSON.stringify({ level: 'info', msg: 'content-ingest-service ready' }));
1111
}
1212

services/prompt-store/src/handlers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import {
2525
type RecordSetContext,
2626
} from './store';
2727

28-
export function registerHandlers(nc: NatsConnection): void {
28+
export function registerPromptStoreHandlers(nc: NatsConnection): void {
2929
// prompt.list.requested
3030
(async () => {
3131
const sub = nc.subscribe('prompt.list.requested');

services/prompt-store/src/server.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { connect } from '@nats-io/transport-node';
22
import { load } from './store';
3-
import { registerHandlers } from './handlers';
3+
import { registerPromptStoreHandlers } from './handlers';
44

55
const NATS_URL = process.env.NATS_URL ?? 'nats://localhost:4222';
66
const PROMPT_STORE_PATH = process.env.PROMPT_STORE_PATH ?? './data/prompts.json';
@@ -12,7 +12,7 @@ async function main(): Promise<void> {
1212
const nc = await connect({ servers: NATS_URL, name: 'prompt-store-service' });
1313
console.log(JSON.stringify({ level: 'info', msg: 'nats connected', url: NATS_URL }));
1414

15-
registerHandlers(nc);
15+
registerPromptStoreHandlers(nc);
1616
console.log(JSON.stringify({ level: 'info', msg: 'prompt-store-service ready' }));
1717
}
1818

services/record-surrealdb-resolver/src/handlers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ import {
4545
type OrgEntryRemoveInput,
4646
} from './resolver';
4747

48-
export function registerHandlers(nc: NatsConnection): void {
48+
export function registerRecordResolverHandlers(nc: NatsConnection): void {
4949
// resolver.candidates
5050
(async () => {
5151
const sub = nc.subscribe('resolver.candidates.requested');

services/record-surrealdb-resolver/src/server.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { connect } from '@nats-io/transport-node';
2-
import { registerHandlers } from './handlers';
2+
import { registerRecordResolverHandlers } from './handlers';
33
import { registerDomainHandlers } from './domains';
44
import { registerPersonHandlers } from './person-handlers';
55
import { registerOrgRelationHandlers } from './org-relations';
@@ -23,7 +23,7 @@ async function main(): Promise<void> {
2323
}
2424
const nc = await connect({ servers: NATS_URL, name: 'record-surrealdb-resolver-service' });
2525
console.log(JSON.stringify({ level: 'info', msg: 'nats connected', url: NATS_URL }));
26-
registerHandlers(nc);
26+
registerRecordResolverHandlers(nc);
2727
registerDomainHandlers(nc);
2828
registerPersonHandlers(nc);
2929
registerOrgRelationHandlers(nc);

services/response-store/src/handlers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import {
2929
type ResponseFlag,
3030
} from './store';
3131

32-
export function registerHandlers(nc: NatsConnection): void {
32+
export function registerResponseStoreHandlers(nc: NatsConnection): void {
3333
// response.create.requested — fire-and-forget from prompt-runner
3434
(async () => {
3535
const sub = nc.subscribe('response.create.requested');

services/response-store/src/server.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import { connect } from '@nats-io/transport-node';
88
import { load } from './store';
9-
import { registerHandlers } from './handlers';
9+
import { registerResponseStoreHandlers } from './handlers';
1010

1111
const NATS_URL = process.env.NATS_URL ?? 'nats://localhost:4222';
1212
const RESPONSE_STORE_PATH = process.env.RESPONSE_STORE_PATH ?? './data/responses.json';
@@ -18,7 +18,7 @@ async function main(): Promise<void> {
1818
const nc = await connect({ servers: NATS_URL, name: 'response-store-service' });
1919
console.log(JSON.stringify({ level: 'info', msg: 'nats connected', url: NATS_URL }));
2020

21-
registerHandlers(nc);
21+
registerResponseStoreHandlers(nc);
2222
console.log(JSON.stringify({ level: 'info', msg: 'response-store-service ready' }));
2323
}
2424

services/row-store/src/handlers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import {
3232
type RecordSet,
3333
} from './store';
3434

35-
export function registerHandlers(nc: NatsConnection): void {
35+
export function registerRowStoreHandlers(nc: NatsConnection): void {
3636
// record_set.list.requested
3737
(async () => {
3838
const sub = nc.subscribe('record_set.list.requested');

0 commit comments

Comments
 (0)