Skip to content

refactor: codebase simplification sweep (25-agent parallel cleanup)#520

Merged
buremba merged 32 commits into
mainfrom
claude/simplify-codebase-OH6Rc
May 4, 2026
Merged

refactor: codebase simplification sweep (25-agent parallel cleanup)#520
buremba merged 32 commits into
mainfrom
claude/simplify-codebase-OH6Rc

Conversation

@buremba
Copy link
Copy Markdown
Member

@buremba buremba commented May 4, 2026

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

  1. refactor!: drop deprecated ScoringConfig from connector-sdk@deprecated interface removed; replacement was already the live path. Breaking for external consumers (release-please picks up ! for major bump).
  2. refactor: inline gateway/proxy/egress-judge index re-export
  3. refactor: consolidate test setup fixtures in packages/server — 5 dead factories deleted, test-workspace.ts merged.
  4. refactor: remove deprecated owletto-* compatibility shim packages — 5 deprecated npm shims gone (still published at v6.0.1 with deprecation notices).
  5. refactor: consolidate retry utilities in @lobu/corewithHttpRetry is now a thin wrapper; dropped p-retry dep.
  6. refactor: route @lobu/connector-sdk logger through @lobu/core — dropped standalone pino dep.
  7. refactor: inline trivial gateway/auth index re-exports
  8. refactor: inline trivial gateway/{channels,api,spaces} index re-exports
  9. refactor: simplify gateway/connections re-exports — barrel + platform-auth-methods wrapper inlined.
  10. chore: regenerate bun.lock after consolidation

Round 2 commits

  1. refactor: remove unused notify admin tooltools/admin/notify.ts was reachable only via the legacy ReactionSDK surface (already removed); 156 lines + stale knip entry.
  2. refactor: simplify @lobu/connector-worker barrel — barrel had 0 callers; dropped package.json . export, main, types, tsconfig path alias. Subpath exports ./daemon / ./embeddings preserved.
  3. refactor: consolidate OAuth scope utilitiesutils/oauth-scopes.tsauth/oauth/scopes.ts (zero symbol overlap, pure move).
  4. refactor: inline orchestration/impl barrel
  5. refactor: inline apply command wrapper — cli commands/apply.ts was a 5-line re-export.
  6. refactor: simplify identity/connectors barrel — preserved the registry-empty assertion in auth/index.tsx.
  7. refactor: inline lobu/stores barrel — 3 importers retargeted at postgres-stores / postgres-secret-store.
  8. refactor: unify reserved-slug list — merged 27-item union of RESERVED_PATHS + RESERVED_SLUGS; existing parity test reframed from equality to superset containment (DB CHECK constraint stays a subset).
  9. refactor: remove unused cli/internal exports — 6 dead re-exports; ./internal is not part of the public API surface.
  10. refactor: consolidate JSON utilities in @lobu/coretoJsonSafe and parseJsonObject lifted into @lobu/core (additive — no breakage).
  11. refactor: inline connector-worker types barrelEnv re-export → import directly from @lobu/connector-sdk.
  12. refactor: deduplicate validateEmbeddingDimensions — duplicate removed from connector-worker; canonical home is @lobu/embeddings.

What was investigated but not changed

  • feed-sync.ts is reachable from scripts/owletto/sync-local.ts (npm script owletto:feeds:sync); knip's flag was a false positive — config/knip.ts already declares the cross-workspace import.
  • @lobu/embeddings/{server,openai}.ts are alive: start-local.ts forks server.ts as a child process; openai.ts is imported by server.ts.
  • @lobu/connectors barrel is a documented public npm API (package.json main/types/exports[\".\"]).
  • packages/server/src/utils/{run-statuses,pg-errors,csp,race-abort,ttl-cache}.ts all 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 install clean
  • make build-packages — all packages built, 0 warnings/errors
  • bun run typecheck — clean
  • CI smoke: connector-sdk consumers (retry + logger surface unchanged)
  • CI smoke: gateway boot path after barrel removals
  • release-please picks up refactor!: for major bump on @lobu/connector-sdk

https://claude.ai/code/session_01BF6nuiNmJ48tihWiU244rd

claude added 10 commits May 4, 2026 14:56
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.
@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@codecov-commenter
Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 93.75000% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
packages/core/src/utils/retry.ts 93.75% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

claude added 12 commits May 4, 2026 15:41
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.
@buremba buremba changed the title refactor: codebase simplification sweep (10-agent parallel cleanup) refactor: codebase simplification sweep (25-agent parallel cleanup) May 4, 2026
claude added 5 commits May 4, 2026 16:08
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).
claude added 5 commits May 4, 2026 16:11
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
@buremba buremba merged commit dd7449f into main May 4, 2026
9 of 15 checks passed
@buremba buremba deleted the claude/simplify-codebase-OH6Rc branch May 4, 2026 21:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants