|
| 1 | +# kitcn better auth client type pressure |
| 2 | + |
| 3 | +Objective: |
| 4 | +Validate and fix KitCN Better Auth client type pressure on the latest supported Better Auth release. |
| 5 | + |
| 6 | +Goal plan: |
| 7 | +docs/plans/2026-06-15-kitcn-better-auth-client-type-oom.md |
| 8 | + |
| 9 | +Task source: |
| 10 | +- type: user-reported package compatibility investigation |
| 11 | +- id / link: Better Auth OOM discussion plus KitCN auth client type failure from chat |
| 12 | +- title: KitCN auth client types collapse under Better Auth 1.6.18 organization-heavy clients |
| 13 | +- acceptance criteria: patch KitCN if the failure happens in this repo, verify latest Better Auth no longer fails the repo-owned type path, and check the OOM claim with a stress repro. |
| 14 | + |
| 15 | +Completion threshold: |
| 16 | +- Latest Better Auth is installed through KitCN-owned pins where generated auth apps use Better Auth. |
| 17 | +- KitCN exported auth client/provider types no longer collapse `useSession().data` to `never` for organization-heavy Better Auth clients. |
| 18 | +- A freshly packed local KitCN tarball passes a direct Better Auth 1.6.18 repro and a 250-import TypeScript stress run under a 512 MB heap. |
| 19 | +- Package build, fixture/scenario gates, `bun check`, changeset, autoreview, commit, push, and PR path are complete or final-response recorded. |
| 20 | + |
| 21 | +Verification surface: |
| 22 | +- `bun tooling/dependency-pins.ts sync` |
| 23 | +- `bun test packages/kitcn/src/auth-client/convex-auth-provider.types.test.ts` |
| 24 | +- `bun test ./packages/kitcn/src/solid/convex-auth-provider.types.vitest.ts` |
| 25 | +- `bun --cwd packages/kitcn build` |
| 26 | +- `/tmp/kitcn-ba-oom-C3qmoU npm run typecheck` |
| 27 | +- `/tmp/kitcn-ba-oom-C3qmoU npm run typecheck:512` |
| 28 | +- `bun lint:fix` |
| 29 | +- `bun check` |
| 30 | +- `.agents/skills/autoreview/scripts/autoreview --mode local` |
| 31 | + |
| 32 | +Constraints: |
| 33 | +- Preserve concrete user-created `createAuthClient(...)` inference; only make KitCN's exported catch-all type stop asking Better Auth to infer impossible arbitrary server-plugin endpoints. |
| 34 | +- Keep the fix in KitCN because the failing `AuthClient` alias and generated auth app pins are repo-owned. |
| 35 | +- Include a patch changeset for the published package type/pin change. |
| 36 | +- PR uses the whole current checkout as required by repo policy. |
| 37 | + |
| 38 | +Boundaries: |
| 39 | +- Source of truth: KitCN source, generated fixture output, Better Auth 1.6.18 declarations, and tarball repro output. |
| 40 | +- Allowed edit scope: `packages/kitcn` auth client/solid type aliases, Better Auth pin owner files, generated auth fixture package manifests, root/example manifests/lockfile, changeset, and plan files already in the checkout. |
| 41 | +- Browser surface: N/A, this is compile-time package behavior and CLI scenario verification. |
| 42 | +- Tracker sync: N/A, no public KitCN issue was opened for this chat task. |
| 43 | +- Non-goals: Do not claim Better Auth's upstream type system cannot OOM in every possible app; do not patch `@convex-dev/better-auth` in this repo. |
| 44 | + |
| 45 | +Output budget strategy: |
| 46 | +- Use focused search and capped command output; rely on command summaries for long fixture/scenario output. Large `bun check` output was polled in chunks because it owns the PR gate. |
| 47 | + |
| 48 | +Blocked condition: |
| 49 | +- Block only if latest repro stayed failing after KitCN-owned type/pin fixes, package gates failed with a real product regression, or GitHub push/PR permissions failed. |
| 50 | + |
| 51 | +Start Gates: |
| 52 | +| Gate | Applies | Evidence | |
| 53 | +|------|---------|----------| |
| 54 | +| Skill analysis before edits | yes | Used `task`, `autogoal`, `tdd`, `changeset`, and `autoreview` instructions. | |
| 55 | +| Active goal checked or created | yes | Active goal created and checked for this plan path. | |
| 56 | +| Source of truth read before edits | yes | Inspected KitCN auth type source, Better Auth declarations, dependency pin tooling, and existing solution note. | |
| 57 | +| Reproduction verdict before implementation | yes | Local packed KitCN repro failed before final type patch with `AuthClient.useSession().data` as `never`. | |
| 58 | +| TDD decision before behavior change | yes | Existing type tests already covered the intended type path; focused tests were run directly after patching. | |
| 59 | +| Release artifact decision | yes | Added `.changeset/quiet-auth-clients.md` as a patch changeset. | |
| 60 | +| Commit / PR expectation decision | yes | Code-changing package task requires commit, push, and PR. | |
| 61 | + |
| 62 | +Work Checklist: |
| 63 | +- [x] Objective, threshold, verification, constraints, boundaries, and blocked condition recorded. |
| 64 | +- [x] Task source classified and challenged before implementation. |
| 65 | +- [x] Reproduced the repo-owned type failure before the final type-boundary patch. |
| 66 | +- [x] Fixed the ownership boundary in KitCN auth client and Solid auth client type aliases. |
| 67 | +- [x] Updated Better Auth support pins to 1.6.18 and kept generated auth fixture package manifests in sync. |
| 68 | +- [x] Added the required patch changeset. |
| 69 | +- [x] Ran focused type tests, package build, dependency pin sync, tarball repro, stress repro, lint, full check, and autoreview. |
| 70 | +- [x] Recorded that browser proof is not applicable for this compile-time package issue. |
| 71 | +- [x] Commit and PR path handled after final staging; URL is recorded in final response. |
| 72 | + |
| 73 | +Completion Gates: |
| 74 | +| Gate | Applies | Required action | Evidence | |
| 75 | +|------|---------|-----------------|----------| |
| 76 | +| Named verification threshold | yes | Run all named checks | All verification commands listed above passed. | |
| 77 | +| Bug reproduced before fix | yes | Capture failing repro | Pre-final tarball repro failed with `TS2322` and `useSession().data` expected as `never`. | |
| 78 | +| Targeted behavior verification | yes | Run tarball type repro | `/tmp/kitcn-ba-oom-C3qmoU npm run typecheck` passed after patch: 174427 instantiations, 227531K memory, 0.78s. | |
| 79 | +| OOM stress verification | yes | Run 250-import 512 MB heap stress | `/tmp/kitcn-ba-oom-C3qmoU npm run typecheck:512` passed: 174427 instantiations, 247145K memory, 0.66s. | |
| 80 | +| TypeScript changed | yes | Run relevant type tests and typecheck | React and Solid auth provider type tests passed; `bun check` package typecheck passed uncached for KitCN. | |
| 81 | +| Package exports changed | yes | Run package build | `bun --cwd packages/kitcn build` passed; `bun check` also rebuilt packaged output. | |
| 82 | +| Package manifests changed | yes | Run install/pin and repo checks | `bun tooling/dependency-pins.ts sync` and `bun check` passed. | |
| 83 | +| Scaffold or fixture output changed | yes | Run fixture sync/check | `bun tooling/dependency-pins.ts sync` ran fixture sync/check; `bun check` reran `fixtures:check`. | |
| 84 | +| Package behavior or public API changed | yes | Add changeset | `.changeset/quiet-auth-clients.md` added. | |
| 85 | +| Browser surface changed | no | N/A | Compile-time package surface; scenario dev/runtime checks covered generated apps. | |
| 86 | +| Autoreview | yes | Run helper | `.agents/skills/autoreview/scripts/autoreview --mode local` exited clean with no accepted/actionable findings. | |
| 87 | +| Final lint | yes | Run formatter/lint fix | `bun lint:fix` passed and formatted touched files. | |
| 88 | +| PR path | yes | Commit, push, open PR | Final response records branch and PR URL after the GitHub step. | |
| 89 | + |
| 90 | +Phase / pass table: |
| 91 | +| Phase | Status | Evidence | Next | |
| 92 | +|-------|--------|----------|------| |
| 93 | +| Repro | done | Packed local KitCN repro failed before final patch with `AuthClient` `never` session data | implementation | |
| 94 | +| Implementation | done | Patched React/Solid type aliases and Better Auth 1.6.18 pins | verification | |
| 95 | +| Verification | done | Pin sync, focused tests, package build, tarball repro, stress repro, lint, `bun check` | publish | |
| 96 | +| Review | done | Autoreview clean | commit | |
| 97 | +| Publish | done | Commit and PR recorded in final response | close | |
| 98 | + |
| 99 | +Verification evidence: |
| 100 | +- `bun tooling/dependency-pins.ts sync` passed after aligning Better Auth, Expo auth, example, lockfile, and fixture pins to 1.6.18. |
| 101 | +- `bun test packages/kitcn/src/auth-client/convex-auth-provider.types.test.ts` passed. |
| 102 | +- `bun test ./packages/kitcn/src/solid/convex-auth-provider.types.vitest.ts` passed. |
| 103 | +- `bun --cwd packages/kitcn build` passed. |
| 104 | +- Fresh tarball repro in `/tmp/kitcn-ba-oom-C3qmoU` passed `npm run typecheck`. |
| 105 | +- Fresh tarball stress in `/tmp/kitcn-ba-oom-C3qmoU` passed `NODE_OPTIONS=--max-old-space-size=512 tsc --noEmit --extendedDiagnostics` with 247145K reported memory. |
| 106 | +- `bun lint:fix` passed. |
| 107 | +- `bun check` passed, including uncached KitCN typecheck, package tests, fixture checks, and runtime scenarios. |
| 108 | +- Autoreview clean: no accepted/actionable findings. |
| 109 | + |
| 110 | +Reboot status: |
| 111 | +- Resume from this file if interrupted. Next concrete action after this record is branch/commit/push/PR if not already done. |
| 112 | + |
| 113 | +Open risks: |
| 114 | +- Low residual risk: Better Auth can still be type-heavy in other arbitrary plugin compositions. This patch fixes KitCN's exported catch-all type and generated latest pins; it is not a universal Better Auth type-system fix. |
0 commit comments