Skip to content

Sync upstream DB data exports (#7554) - #255

Merged
mistakeknot merged 3 commits into
mainfrom
sync/upstream-49982f7fbd
Nov 17, 2026
Merged

mistakeknot merged 3 commits into
mainfrom
sync/upstream-49982f7fbd

Conversation

@mistakeknot

@mistakeknot mistakeknot commented Nov 17, 2026 •

Copy link
Copy Markdown
Owner

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

  • fork-owned-migrations: resolve packages/db/src/data/index.ts with upstream module exports, retaining the six Aleph-only module export blocks (install requests, cold tier, idempotent operations, roles, learned search and transfers). No migrations change.
  • queue-transfer and event-cold-tier: keep named exports in queued-thread-messages and maintenance so five Aleph helpers remain internal: getLastQueuedThreadMessage, claimQueuedThreadMessageIdsInTransaction, sweepStaleQueuedMessageClaims, countQueuedThreadMessagesInTransaction, isThreadMaintenanceBusy.
  • Upstream moves lifecycle writers to its private environment-lifecycle module; the public internal-environment-lifecycle subpath keeps its original exports. Cold-history guards in environments.ts remain.
  • No generated API index or workflow changes. Ledger note and export-test path added.

Tests per Aleph patch

  • Public-root export audit: all 619 prior runtime exports retained; 17 upstream runtime additions, with no Aleph-private helper exposed. aleph-public-exports.test.ts tests fork entry points and private boundaries.
  • Fork migrations/environment lifecycle: environments, environment-lifecycle, projects, project-sources, prompt-history tests.
  • Queue-transfer: queued-thread-messages and transfer-operations tests.
  • Cold tier and maintenance: event-cold-tier and maintenance tests.
  • Roles, learned search, install requests: their data-layer tests.
  • PR254 split-panes and other upstream fixes: 214 app tests and 11 server thread-event tests passed at that parent.

Checks at final head4959274dfc3f898131899a7fe407564bcb1de17f

Base main43b0f7fdb0228fede34ff32cca8e8d5a6818877f. Fresh full-diff packaged cross-lab review PASS WITH NOTES; P3 notes tracked in mk-8lcd6.163/.165.

  • Full server:7819 passed,0 failed,4 skipped (460 passed files,0 failed,3 skipped).
  • Full bb-guide:25 passed,0 failed,0 skipped (3 files passed).
  • No failing tests. Both native commands exited0, serial/niced/maxWorkers2.
  • Timeline benchmark passed ratio3.4159; installer file54/54 passed.
  • Changed-file oxfmt/diff checks passed under repo config. Data paths are excluded by that config; new export test formatted through stdin. Frozen install and explicit SDK build:types completed.
  • DB/downstream typechecks passed at prior head61a54235f2; historical targeted DB195/196 with sole retire10k timing failure3025ms vs<2500. Its authorized isolated rerun passed unchanged (whole test2483ms; inner passing value not logged).

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.

AGENT GENERATED

ymichael and others added 2 commits November 17, 2026 01:03
`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]>
@mistakeknot mistakeknot changed the title Sync upstream DB data exports (stacked on #254) Sync upstream DB data exports (#7554) Nov 17, 2026
@mistakeknot
mistakeknot merged commit 80530d2 into main Nov 17, 2026
6 checks passed
@mistakeknot
mistakeknot deleted the sync/upstream-49982f7fbd branch November 17, 2026 08:31
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.

2 participants