Repository navigation
Sync upstream DB data exports (#7554) - #255
Merged
Merged
Conversation
`packages/db/src/data/index.ts` re-exported every public data function, type, and constant by name: 582 lines, 512 names across 38 modules. Adding or renaming any data function meant editing that list, and 82 commits touched it in the last 60 days, so two open PRs that each add a data function usually conflicted there. The list also served as the public/private filter for `@bb/db`. It hid 11 helper modules entirely and, inconsistently, about 20 helpers in otherwise-public modules. Only one of those hidden groups was deliberate: the environment-lifecycle writers, which `apps/server` reaches through `@bb/db/internal-environment-lifecycle`. - `packages/db/src/data/index.ts` is now one `export * from "./<module>.js"` line per public module (38 lines). A module is public if and only if it is listed there; unlisted modules stay package-private. Adding, renaming, or deleting a function in a public module no longer touches a shared file. Only a new public module adds one line. That happened in 9 of the 82 commits, and a sorted one-line-per-module list conflicts only on adjacent insertions. - The deliberately internal environment writers moved out of `environments.ts` into a new private module, `packages/db/src/data/environment-lifecycle.ts`: `applyEnvironmentLifecycleEvent`, `applyEnvironmentLifecycleEventInTransaction`, `recordProvisionedEnvironmentWorkspace`, and the shared `updateEnvironmentMetadataRecord`. So the root `@bb/db` still does not expose them. `updateEnvironmentMetadata` and `recordEnvironmentCurrentBranch` share the private record writer, and every writer reads through `getEnvironment`, so those three live in that module too. `environments.ts` imports and re-exports them, so they stay public. The private module imports nothing from `environments.ts`, so the dependency runs one way and the data modules still have no value-import cycles, as on main. `@bb/db/internal-environment-lifecycle` now re-exports from the new module and exports the same 4 values and 2 types as before. - `CreateProjectSourceInput` was declared, with different shapes, in both `projects.ts` and `project-sources.ts`. Star exports reject that (TS2308), and no code outside the two files used either alias, so both aliases are deleted and their one use each now names the underlying type. - The old barrel also re-exported `COMPLETED_EVENT_OUTPUT_RETENTION_MS` and `RETAINED_EVENT_OUTPUT_TARGETS` from `src/retained-event-output.ts` (not a data module). That re-export moved to `src/index.ts`. - Query-cost cases for the six moved functions are now keyed `packages/db/src/data/environment-lifecycle.ts#…`, because `listQueryFunctions` keys functions by their declaring file. Relative imports in `environments.test.ts`, `environment-lifecycle.test.ts`, and `hosts-environments-cases.ts` point at the new file. Export surface change (computed with the TypeScript checker over `src/index.ts` and `src/internal-environment-lifecycle.ts`, before vs after): - Removed: none. Every existing `@bb/db` and `@bb/db/internal-environment-lifecycle` import keeps working, so no caller changed. - Added to `@bb/db`: 230 types and 20 values that their modules already exported but the list left out. Most of the types already appear in public signatures, for example `CreateThreadInput` and `ListThreadsOptions`. The values: `ACTIVE_PENDING_INTERACTION_STATUSES`, `ACTIVE_THREAD_STATUSES`, `appendStoredThreadEventInTransaction`, `bumpThreadEventRewriteGeneration`, `copyRetainedEventOutputs`, `getContextWindowUsagePruningBoundarySequence`, `listActiveVisiblePinnedThreadRoots`, `markHostSeen`, `MAX_COMPLETED_EVENT_OUTPUT_MIGRATION_EVENT_DATA_BYTES`, `NON_TERMINAL_SESSION_STATUSES`, `prepareLegacyImageGenerationOutputData`, `PRUNABLE_THREAD_EVENT_TYPES`, `pruneContextWindowUsageEventsInTransaction`, `pruneTokenUsageEventsInTransaction`, `resolveStoredProviderSessions`, `THREAD_PRUNING_ADVANCE_WORK_BUDGET_MS`, `ThreadLifecycleEventNotAppliedError`, `toProjectSource`, `upsertThreadSearchSegmentBatch`, `upsertThreadSearchSegments`. Each is a sibling of names that were already public (for example, the plural `appendStoredThreadEventsInTransaction` and `getStoredProviderSession` were public), so hiding them was incidental, not a boundary. Alternatives rejected: - Delete the barrel and use a `@bb/db/data/*` subpath: this would rewrite imports in 451 files, conflict with every open PR, and expose the private helper modules. - Generate the barrel: this would add a Turbo task and a gitignored artifact to produce the same thing `export *` already gives. - Keep named exports but split them per module: the central-list conflicts would remain. No wire, CLI, or plugin-API change. - Export-surface diff before vs after with the TypeScript checker, over `src/index.ts` and `src/internal-environment-lifecycle.ts`: 0 names removed; the additions are listed above. - Import cycles: a scan of value imports among `packages/db/src/data/*.ts` finds none on main and none on this branch. - Collision safety: temporarily re-adding a duplicate type name made `tsrs --noEmit` fail with `TS2308: Module "./project-sources.js" has already exported a member named ...`, so a future clash fails typecheck instead of silently dropping a name. - `pnpm exec turbo run typecheck --filter='...@bb/db'` passed (`@bb/db`, `@bb/server`, `@bb/host-daemon`, `@bb/scripts`, `@bb/integration-tests`). - `vitest run` on `test/data/environments`, `environment-lifecycle`, `projects`, `project-sources`, and `prompt-history`: 50/50 passed. - Query-cost coverage (`listQueryFunctions` vs `QUERY_COST_CASES`): no missing cases, no stale cases. - `oxlint` on the changed files: clean. `lint:type-aware --filter=@bb/db`: passed. - CI runs the full suites. 🤖 Generated with [Claude Code](https://claude.com/claude-code) > AGENT GENERATED --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
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.
Sync upstream 49982f7 (get-bb#7554) after the five-commit range merged in #254. Bead mk-8lcd6.161. Main was merged into this branch; the PR now contains only the get-bb#7554 resolution, ledger and export-boundary tests (14 files). Version strings stay unchanged.
Conflicts and ledger patches
Tests per Aleph patch
Checks at final head4959274dfc3f898131899a7fe407564bcb1de17f
Base main43b0f7fdb0228fede34ff32cca8e8d5a6818877f. Fresh full-diff packaged cross-lab review PASS WITH NOTES; P3 notes tracked in mk-8lcd6.163/.165.
Historical benchmark evidence, retained: prior PR255 full-suite ratio4.186141317924069 with samples1846.2,1805.9,1964,1633,1715ms; its only isolated rerun ratio4.067413258778364 with samples1173.9,1122.1,1284.7,1093.9,1204.9ms. Baseline at PR254 head821df77bf7 also failed ratio4.455694110876139, samples1055.2,1070.8,1124.9,1467.3,1752.5ms, CPU pressure some avg10 before14.42/after22.80. No isolated PR255 pressure snapshot recorded. Coordinator classified these as known load flake mk-8lcd6.164, with no test/threshold change. Final-head run passed without applying a failure exception.
The intermediate3d1accd9 suite slot was withdrawn when main advanced; stopped by recorded PIDs (including subsequently identified orphan worker). Its partial output does not count. Main was merged normally; no rebase/force-push.
Rest of the upstream range
51 first-parent commits remain through 1320c88. The next six merge cleanly through 6a6ac8a. Next conflict e46c91c (get-bb#7601): .github/workflows/ci.yml (build-config) and pnpm-lock.yaml (design-wiki). Workflow changes must remain omitted under the independent-CI policy. No third PR is taken here. The later get-bb#7641 AbortSignal fix has not been reached; Aleph PR240 remains unchanged.