refactor: untangle the codebase so a typical change lands in one place #60
Loading…
Reference in a new issue
No description provided.
Delete branch "feature/untangle-codebase"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
A pass over the whole repo asking "should these pieces change together?": every place a change had to land in several files, a module depended on something more volatile, or a special case stood in for the design. Plus removing comments that restate the code, and rewriting tests that could not catch a real bug.
Where things live now (new modules marked
+):Events now say what changed, and listeners own the reaction (services no longer call
upstreams.invalidate*):A server context carries typed
blockers; status, the adminsetupNeeded, the gateway's not-ready text and the Test button only word them. The SPA refreshes centrally after every write, and a remove endpoint declares the id it deletes.Bugs fixed along the way:
Evidence
npm test: shared 7, api 366, runner 53 (+2 skipped), web 170.After:
nix develop -c ./scripts/ci.shpasses: lint, typecheck, shared 19, api 370, runner 55 (+2 skipped, network-only), web 175, build,npm audit0 vulnerabilities. drizzle-kit reports no schema drift from the shared enums./mcp,/mcprecording grant activity,/readyz503, registration and password rate limits. New tests were checked by breaking the matching production code and watching them fail.s256.Merge Danger
Door: two-way, apart from the two data migrations.
0013_command_namesrewritesmcp_servers.commandfrom absolute paths to binary names (what a protocol 1 runner stored).0014_last_error_install_onlyclearslast_erroron servers whose install did not fail: connect errors now live only in the tool-list row.Blast Radius: deployment
INSTALL_TIMEOUT_SECONDSnow bounds the whole install, not each command.PUT /api/admin/servers/:id/values(new admin MCP toolset_server_values),RunnerProcess.kind,AuthState.adminMcpUrl.DELETE /api/me/servers/:id/oauthon a server without per-user sign-in answers 400. With OIDC off its routes are not registered (generic 404). A few error texts changed.trail checkreports 7 hits, all word matches inside drizzle snapshot JSON and migration SQL, not conflicts with the learnings.Left on purpose: splitting ServerForm into create/edit, reserving the
mcphubslug (needs a data migration first), a full encrypted-column registry (a test now fails if key rotation misses an*_encryptedcolumn).🤖 Generated with Claude Code
Process and runner keys were built in access.ts and taken apart by string slicing in the pool, by a separate regex in reconcile, by split(".") in the runner admin route and server logs, and by slice(0, 36) in the runner. The probe's nil UUID was copied in three places. packages/shared/src/runner.ts now owns the format: processKey, installerKey, parseRunnerKey, processOwner and PROBE_USER_ID. A server context carries its typed owner, so the pool, gateway, portal and refresher no longer re-derive it. Fixes the runner admin page listing the probe process as a user with the nil UUID as its id. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>The duplicate-key, unknown {{KEY}}, args, URL-host and client-id rules were written in the API's validation, again in the SPA's form check and template panel, and a third time in the pool's args backstop. They now live in packages/shared/src/server-rules.ts (serverRuleIssues and templateUse) and all four places call them. Behaviour: the form now refuses unknown and misplaced keys before sending instead of after the API answers; the API also refuses an update that blanks the client id while a stored client secret stays (the form already did); a duplicate key reads 'KEY is already defined above'. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>PageQuery and PAGE_SIZE serve the three paged queries and the SPA; ToolName the two tool path params and isValidToolName; VariableValue the user and test value bodies and the spawn env; ServerName, ServerDescription and ServerVariables both the create and the update body. VariableKey and the {{KEY}} template share one pattern and VARIABLE_KEY_MAX, which normalize.ts imports. PortalServer.oauth.mode is UpstreamOAuthMode without none, and RunnerStatus takes its health fields from RunnerHealth. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>The exit log now reads a process's last stderr lines from ProcessLogs instead of a second 200-line buffer per child; a short-lived run's lines may include the end of the run before it under the same key. An invalid key on attach closes with RunnerCloseCode.policy (still 1008). InstallerIdentity and proc.ts's RunAs were the same {uid, gid}; RunAs is the one type and ProcessIdentity extends it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>