refactor: codebase simplification sweep (25-agent parallel cleanup)#520
Merged
Conversation
Removes the @deprecated `defaultScoringConfig: ScoringConfig` field on `IFeed`/`BaseFeed` and the `ScoringConfig` interface itself. The non-deprecated `defaultScoringFormula: string` (SQL formula) has been the only path used internally for some time; no monorepo callers referenced the old config object. BREAKING CHANGE: External `@lobu/connector-sdk` consumers that still implement `defaultScoringConfig` or import `ScoringConfig` must remove those references and rely on `defaultScoringFormula` instead.
The index.ts was a 6-line pass-through re-exporting EgressJudge from ./judge and JudgeClient/JudgeDecision/JudgeVerdict types from ./types. Point the four importers (http-proxy.ts plus two test files) directly at judge.js / types.js and delete the wrapper. https://claude.ai/code/session_01BF6nuiNmJ48tihWiU244rd
Drop 5 unused fixture factories from `test-fixtures.ts` (createTestWatcher, createTestWatcherTemplate, createTestWatcherWindow, createTestActionRun, createTestClassifier — zero importers) and merge `test-workspace.ts` into `test-mcp-client.ts` since the workspace builder is just a thin wrapper over TestApiClient. Net -323 lines, one fewer file in `__tests__/setup/`. https://claude.ai/code/session_01BF6nuiNmJ48tihWiU244rd
The five @lobu/owletto-* packages were re-export shims kept around so existing npm consumers could migrate to the canonical package names (@lobu/connector-sdk, @lobu/connector-worker, @lobu/connectors, @lobu/embeddings, @lobu/openclaw-plugin). Nothing inside the monorepo imports them, and the v6.0.1 npm releases already carry permanent "renamed to ..." deprecation messages. Drop the source dirs plus the release-please / publish / bump tooling that referenced them.
Extend `retryWithBackoff` in `@lobu/core` with `shouldRetry` predicate, `maxDelay` cap, and `jitter: "full"` (multiplicative) mode so it can serve HTTP-aware retry needs. Rewrite `withHttpRetry` in `@lobu/connector-sdk` as a thin wrapper that supplies the HTTP retry-on/abort-on predicates and matches the previous p-retry-based timing exactly. Drop the `p-retry` dependency from `@lobu/connector-sdk` in favor of a workspace dep on `@lobu/core`. The public `withHttpRetry(fn, options)` signature in connector-sdk is unchanged, including the `onRetry(error, attempt)` callback shape.
Drop the standalone pino instance and have sdkLogger delegate to
createLogger("connector-sdk"). Output now flows through the same
formatter, level resolution (LOG_LEVEL), and Sentry transport as the
rest of the platform, removing one of three parallel logger stacks.
The server-side utils/logger pino singleton is intentionally left in
place: it reads globalThis.ENVIRONMENT (not LOG_LEVEL), emits Pino JSON
that production log shipping parses, and is used in 50+ files where
the output schema is observable in production.
Remove three single-purpose barrel files (chatgpt/, gemini/, settings/) and update importers to point at the underlying modules directly.
Each of these index.ts files re-exported a single symbol from one neighbour module, adding an unnecessary indirection layer. Importers now reach for the implementation file directly.
Delete the connections/index.ts barrel (only re-exported from two call sites) and inline the single-call-site platform-auth-methods.ts wrapper into agent-ownership.ts as a small OAUTH_PLATFORMS allowlist. Importers (gateway/index.ts, lobu/gateway.ts, cli/gateway.ts) now reference chat-instance-manager.ts, chat-response-bridge.ts, and types.ts directly.
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
The `notify` tool was previously exposed via the legacy `ReactionSDK` surface (reaction scripts could call `sdk.notify(...)`). That surface is gone — reactions now run on the typed `ClientSDK` (see `reaction-executor.ts`) — and `notify` was never wired into the internal REST tools registry in `tools/admin/index.ts`. Knip flagged it as orphaned; the stale knip ignore entry is cleared as well.
Remove unused src/index.ts barrel — no internal callers and the package's CLI bin is the actual consumer entry. Drop matching package.json "." export, "main", "types" and tsconfig path alias. The "./daemon" and "./embeddings" subpath exports remain intact.
Merge `utils/oauth-scopes.ts` into `auth/oauth/scopes.ts` so OAuth-specific helpers live next to the scope constants/`filterScopeByRole` they belong with. The two files had no symbol overlap — `auth/oauth/scopes.ts` owned constants + role filtering, `utils/oauth-scopes.ts` owned auth_data serialization helpers — so this is a pure move with no behavior changes. Importers updated to point at `auth/oauth/scopes`: - packages/server/src/utils/oauth-connection-state.ts - packages/server/src/connect/routes.ts - packages/server/src/auth/social-login-provisioning.ts - packages/server/src/tools/admin/helpers/connection-helpers.ts The existing test (oauth-scope-filter.test.ts) already imported from the canonical path and is unchanged.
The single-line side-effect barrel (with a load-time registry-empty assertion) was imported by exactly two callers. Inline the only side-effect import (`./connectors/google`) into both, keep the registry-empty assertion at `auth/index.tsx` module load, and remove the barrel.
The packages/server/src/lobu/stores/index.ts barrel only re-exported from postgres-secret-store and postgres-stores. Retarget the three direct importers (mcp-handler, lobu/gateway, lobu/agent-routes) at the concrete files and delete the barrel. https://claude.ai/code/session_01BF6nuiNmJ48tihWiU244rd
Collapse the duplicated reserved-slug declarations (RESERVED_PATHS in utils/reserved.ts and RESERVED_SLUGS in auth/personal-org-provisioning.ts) into a single canonical list under utils/reserved.ts, exported as RESERVED_PATHS plus a RESERVED_PATHS_SET for O(1) membership checks. The unified list is the union of the two — entries that lived only in RESERVED_PATHS (agents, connectors, events, members, watchers, sources, contents, entity-types) plus the infrastructure subdomains that lived only in RESERVED_SLUGS (www, mcp, static, assets, cdn, docs, mail). Losing any one silently could let a user squat on a route or an infrastructure subdomain, so the conservative union is preserved. The application-level set is now an intentional superset of the DB org_slug_not_reserved CHECK constraint; the test that previously required exact size equality is reframed to require superset containment.
Knip flagged six re-exports in packages/cli/src/internal/index.ts with no in-monorepo callers: DEFAULT_MEMORY_URL, findContextByUrl, ResolvedContext, OrganizationInfo, ApiClient, ApiClientError. The internal/ barrel is purely in-repo (no ./internal subpath in package.json exports), so trimming these is not a public-API change. Definitions stay where they are still used (internally inside context.ts / api-client.ts and their tests). https://claude.ai/code/session_01BF6nuiNmJ48tihWiU244rd
Move bigint-safe `toJsonSafe` and `parseJsonObject` from packages/server/src/utils/json.ts into packages/core/src/utils/json.ts and delete the server copy. Server importers now pull all four helpers (safeJsonParse, safeJsonStringify, toJsonSafe, parseJsonObject) from `@lobu/core`. https://claude.ai/code/session_01BF6nuiNmJ48tihWiU244rd
Remove the local copy in @lobu/connector-worker and import from @lobu/embeddings, the natural owner. The two implementations were byte-identical, so behavior is unchanged.
The packages/server/src/gateway/index.ts barrel had no importers. All consumers (e.g. packages/server/src/lobu/gateway.ts) already import from concrete subfiles. Verified by searching for imports of the gateway directory or gateway/index across the monorepo — the only matches were either inner gateway/gateway/index.ts references (a separate barrel) or sibling files like gateway-integration. https://claude.ai/code/session_01BF6nuiNmJ48tihWiU244rd
The mcp-install-targets test imported through `packages/web` (a git submodule) and the use-case-data script type-imported from a sibling `../../owletto` checkout. Both paths are absent on fresh clones and forks without the deploy key, breaking the integration vitest run and making the script untyped. - Guard the test with an existsSync check so it skips when the submodule isn't initialized instead of failing module resolution. - Inline the minimal Owletto YAML field shapes the script actually reads so it stops depending on a sibling repo.
knip flagged these named exports as unused. After verifying no external references (whole-repo rg across ts/js/json/sh, scripts/, package.json bin fields), the export keyword was dropped or — for findMemberEntityIdByIdentities — the function and its sole helper TRUSTED_ADOPTION_SOURCES were deleted entirely. - findMemberEntityIdByIdentities + TRUSTED_ADOPTION_SOURCES (auth/subject-identities.ts) — deleted (zero refs anywhere) - loadRepairConfigFromEnv (connectors/repair-agent.ts) — de-exported (only self-call) - getRawDb (db/client.ts) — de-exported (only same-file callers) - buildLobuMemoryScopedMcpUrl (gateway/auth/mcp/config-service.ts) — de-exported - DEFAULT_JUDGE_MODEL (gateway/proxy/egress-judge/judge.ts) — de-exported - SdkError (sandbox/client-sdk.ts) — de-exported (still extended by sibling errors in-file) - DeleteContentSchema (tools/delete_content.ts) — de-exported - startGatewayServer (gateway/cli/gateway.ts) — de-exported. Despite the entry-point-sounding name, the only external reference was the gateway/index.ts barrel which was deleted in d3a4f46. Confirmed no scripts/, no package.json bin field, no dynamic import references. https://claude.ai/code/session_01BF6nuiNmJ48tihWiU244rd
Drop 14 root scripts that have zero references outside package.json (verified against .github/workflows, Makefile, .husky, scripts/, docs/, packages/*/package.json, and CLI invocations): - owletto:bench, owletto:bench:prepare:locomo, owletto:bench:prepare:longmemeval - owletto:guidance:sync, owletto:connectors:install, owletto:connectors:dry-run - gitleaks (never invoked; config/gitleaks.toml stays for ad-hoc use) - depcruise (also broken: config/dependency-cruiser.config.cjs does not exist) - jscpd (never invoked) - typecheck:owletto (never invoked; CI typecheck is bun run typecheck + per-package tsc loop) - dev:gateway, dev:worker (never invoked; bun run dev / Makefile owns dev orchestration) - version:bump, publish:packages (never invoked; release-please + publish-packages.yml call scripts/*.mjs directly) Kept owletto:feeds:sync (live, used via sync-local.ts) and build:owletto (referenced by scripts/publish-packages.mjs).
smol-toml was declared in packages/server but never imported by any file under packages/server/src. The actual users are packages/cli (which already declares it) and scripts/gen-use-case-data.ts (root-level script). Move the dep to root devDependencies so the script keeps resolving and remove the false declaration from server. https://claude.ai/code/session_01BF6nuiNmJ48tihWiU244rd
Drop dead exports flagged by knip in packages/cli/src/: - PLATFORM_LABELS (no callers anywhere) - internal/index.ts re-exports of DEFAULT_MEMORY_URL, findContextByUrl, ResolvedContext, ApiClient, ApiClientError, OrganizationInfo (no consumers; the underlying source exports are reached directly where needed) - Demote ApiClientOptions / ResolvedApiClient / OrganizationInfo / ApiClientError in api-client.ts to module-private (only used inside that file) - Demote TokenResponse / UserInfo / DevicePollResult in oauth.ts to module-private (only used inside that file) Knip's other cli flags are false positives caused by config/knip.ts not declaring src/index.ts as a workspace entry — the dynamically imported command modules and OAuth helpers in login.ts are still in use.
Bun marks Math.random as non-configurable after the first Object.defineProperty, so the test failed when run alongside other suites. Assert the jittered delay falls within the expected [base, 2*base) range instead of pinning Math.random to a fixed value.
…ase-OH6Rc # Conflicts: # bun.lock # packages/cli/package.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two-round coordinated parallel simplification across the monorepo.
Round 1: 9 commits (10 agents — 1 no-op).
Round 2: 12 commits (15 agents — 3 no-ops where targets turned out to be live code or public API).
Net diff: ~99 files, +612 / -1922 (-1310 net).
Round 1 commits
refactor!: drop deprecated ScoringConfig from connector-sdk—@deprecatedinterface removed; replacement was already the live path. Breaking for external consumers (release-please picks up!for major bump).refactor: inline gateway/proxy/egress-judge index re-exportrefactor: consolidate test setup fixtures in packages/server— 5 dead factories deleted,test-workspace.tsmerged.refactor: remove deprecated owletto-* compatibility shim packages— 5 deprecated npm shims gone (still published at v6.0.1 with deprecation notices).refactor: consolidate retry utilities in @lobu/core—withHttpRetryis now a thin wrapper; droppedp-retrydep.refactor: route @lobu/connector-sdk logger through @lobu/core— dropped standalonepinodep.refactor: inline trivial gateway/auth index re-exportsrefactor: inline trivial gateway/{channels,api,spaces} index re-exportsrefactor: simplify gateway/connections re-exports— barrel +platform-auth-methodswrapper inlined.chore: regenerate bun.lock after consolidationRound 2 commits
refactor: remove unused notify admin tool—tools/admin/notify.tswas reachable only via the legacyReactionSDKsurface (already removed); 156 lines + stale knip entry.refactor: simplify @lobu/connector-worker barrel— barrel had 0 callers; dropped package.json.export,main,types, tsconfig path alias. Subpath exports./daemon/./embeddingspreserved.refactor: consolidate OAuth scope utilities—utils/oauth-scopes.ts→auth/oauth/scopes.ts(zero symbol overlap, pure move).refactor: inline orchestration/impl barrelrefactor: inline apply command wrapper— clicommands/apply.tswas a 5-line re-export.refactor: simplify identity/connectors barrel— preserved the registry-empty assertion inauth/index.tsx.refactor: inline lobu/stores barrel— 3 importers retargeted atpostgres-stores/postgres-secret-store.refactor: unify reserved-slug list— merged 27-item union ofRESERVED_PATHS+RESERVED_SLUGS; existing parity test reframed from equality to superset containment (DB CHECK constraint stays a subset).refactor: remove unused cli/internal exports— 6 dead re-exports;./internalis not part of the public API surface.refactor: consolidate JSON utilities in @lobu/core—toJsonSafeandparseJsonObjectlifted into@lobu/core(additive — no breakage).refactor: inline connector-worker types barrel—Envre-export → import directly from@lobu/connector-sdk.refactor: deduplicate validateEmbeddingDimensions— duplicate removed from connector-worker; canonical home is@lobu/embeddings.What was investigated but not changed
feed-sync.tsis reachable fromscripts/owletto/sync-local.ts(npm scriptowletto:feeds:sync); knip's flag was a false positive —config/knip.tsalready declares the cross-workspace import.@lobu/embeddings/{server,openai}.tsare alive:start-local.tsforksserver.tsas a child process;openai.tsis imported byserver.ts.@lobu/connectorsbarrel is a documented public npm API (package.jsonmain/types/exports[\".\"]).packages/server/src/utils/{run-statuses,pg-errors,csp,race-abort,ttl-cache}.tsall have ≥3 importers — leaving them.packages/server/src/utils/logger.ts— diverges from core in load-bearing ways (Pino JSON output for log shippers).Test plan
bun installcleanmake build-packages— all packages built, 0 warnings/errorsbun run typecheck— cleanrefactor!:for major bump on@lobu/connector-sdkhttps://claude.ai/code/session_01BF6nuiNmJ48tihWiU244rd