Skip to content

refactor: split hot TypeScript modules and add LOC ratchet#105894

Merged
steipete merged 5 commits into
mainfrom
codex/refactor-hot-god-files
Jul 13, 2026
Merged

refactor: split hot TypeScript modules and add LOC ratchet#105894
steipete merged 5 commits into
mainfrom
codex/refactor-hot-god-files

Conversation

@steipete

Copy link
Copy Markdown
Contributor

Closes #105825

AI-assisted change; implementation and review decisions were verified against the touched code paths and tests.

What Problem This Solves

Resolves a maintenance problem where the hottest gateway and agent modules combine separable concerns in files thousands of lines long, increasing conflict and review cost. It also closes the process gap where the repository's existing TypeScript file-size check was not part of normal checks or CI, allowing the oversized-file backlog to grow.

Why This Change Was Made

The change splits chat history/display/routing/telemetry helpers, decomposes embedded-attempt setup/stream/finalize phases, and separates OpenAI Responses from Completions behind the stable transport facade. It also adds a current-size baseline and a downward-only 500-line ratchet to normal checks and CI, including base-ref protection against raising the baseline in the same PR or push.

session-accessor.sqlite.ts remains unchanged because it is cohesive and low churn.

User Impact

No user-visible runtime or public API behavior changes. Maintainers get smaller ownership surfaces, lower merge-conflict pressure, and automated prevention of new or growing oversized TypeScript files.

Evidence

  • Partitioned autoreview completed with no accepted/actionable findings; the final LOC and tooling-test passes were clean.
  • AWS Crabbox run_5fa5981c9a25: full pnpm check:changed and pnpm build passed, including formatting, production/test/scripts typechecks, full core lint, SDK API/surface guards, import-cycle guards, and the production bundle.
  • AWS Crabbox run_db9151737503: test/scripts/changed-lanes.test.ts passed 99/99 after adding LOC-plan expectations.
  • Focused LOC proof: check:loc, nine check-ts-max-loc tests, and scripts typecheck passed on Testbox.
  • Focused gateway, embedded-runner, and OpenAI transport suites passed before the conflict-free latest-main rebases; the production split content did not change during those rebases.
  • Current branch: node scripts/check-ts-max-loc.ts and git diff --check pass. Exact-head GitHub CI is the final landing gate.

@openclaw-barnacle openclaw-barnacle Bot added app: web-ui App: web-ui gateway Gateway runtime scripts Repository scripts agents Agent runtime and tooling size: XL maintainer Maintainer-authored PR labels Jul 13, 2026
@steipete

steipete commented Jul 13, 2026

Copy link
Copy Markdown
Contributor Author

Land-ready proof for head 4edb697a21cb86090ad00e829fe8e44fbcd1c641:

  • Fresh pre-land autoreview completed with no accepted or actionable findings; review artifacts validate with zero findings.
  • AWS Crabbox run_5fa5981c9a25: pnpm check:changed and pnpm build passed.
  • AWS Crabbox run_db9151737503: test/scripts/changed-lanes.test.ts passed 99/99 plus formatting.
  • Focused transport, attempt, and chat suites passed 727 tests; the OpenAI transport rerun passed 371 tests.
  • The LOC ratchet's focused suite passes 9/9, including same-PR baseline raise rejection, stale entries, non-.ts extensions, invalid refs, and test-support exclusions.

The head was rebased without conflicts onto 2186cdf36ef98cb2780fbaa8095ff67bdbbb3c21, which contains the unrelated iOS localization fix required by the full CI lane. Exact-head GitHub CI remains the merge gate. No user-visible behavior or compatibility surface changed; changelog entry is not required.

@steipete
steipete force-pushed the codex/refactor-hot-god-files branch from 2de96fe to 4edb697 Compare July 13, 2026 02:49
@steipete
steipete merged commit c3dbaf4 into main Jul 13, 2026
114 checks passed
@steipete
steipete deleted the codex/refactor-hot-god-files branch July 13, 2026 02:57
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 13, 2026
…105894)

* refactor: split high-churn agent and chat modules

* ci: enforce TypeScript LOC ratchet

* ci: anchor LOC baseline updates to merge base

* test: cover LOC ratchet check plans

* chore: refresh TypeScript LOC baseline
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling app: web-ui App: web-ui gateway Gateway runtime maintainer Maintainer-authored PR scripts Repository scripts size: XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Refactor hot TypeScript modules and enforce the LOC ratchet

1 participant