Skip to content

ui-server: core's internal entry is imported at five sites with a '*' peer range and no version check #2488

Open

Description

@schlessera

Context

The #696 package ruling (docs/decisions/index-query-api.md:80-92) makes @schlessera/brain an optional peer of ui-server that is used through the supported @schlessera/brain/queries entry. The edge table says it is resolved lazily "for the graph view and index-derived voice vocabulary only" (tests/allowed-edges.ts:112-115). That path checks the manifest and a version range before use (CORE_QUERIES_RANGE = ">=0.40.0 <1.0.0", packages/ui-server/src/core-queries.ts:40).

ui-server also does a bare await import("@schlessera/brain/internal") at five sites, for initContext, openDatabase, prepareIngest, indexAll, updateDocument, relevanceOnArchive and pruneScratch:

  • packages/ui-server/src/brain/application.ts:142, :151 (inProcessPlanner) and :274 (the application route)
  • packages/ui-server/src/brain/maintenance-entry.ts:45
  • packages/ui-server/src/brain/mask-application.ts:160

Core's ./internal entry carries "no compatibility guarantee, and consumers must use the same lockstep version" (packages/core/src/internal.ts:1-7). Nothing checks the version on this path, and the peer range is "@schlessera/brain": "*" (packages/ui-server/package.json, peerDependencies). A host that installs a different core release gets an unchecked internal API at capture, edit or index time, and fails there instead of at boot.

The #1345 ruling recorded on #1400 also lists the product groups that may share ./internal: "core with geo and render-template; ui-react, ui-sdk, ui-kit and ui-server". ui-server → core crosses two groups, so these imports are outside that rule as well. #1400's gate covers only module-* and ui-backend-*, and #1398 covers only pi.

Core is also loaded two more ways: coreReader checks the manifest name but not the version (packages/ui-server/src/storage/process.ts:8-14), and packages/ui-server/src/brain/maintenance-entry.ts:42 imports ./storage directly. The four loading styles make it hard to say which core versions a server release actually supports.

git grep -n '@schlessera/brain/internal"' packages/ui-server/src
jq .peerDependencies packages/ui-server/package.json

Decision (maintainer, 2026-10-22)

Option A selected: ui-server consumes supported core operations through one manifest-and-version-range-checked resolver. Preserve core as a lazily resolved optional peer. Existing internal-sharing product groups remain unchanged; no exception allowing ui-server to depend on core internals or exact-lockstep-only peer policy is selected.

Scope

  • Replace the five direct core internal imports with the narrow supported core operations they actually need, using existing public entries where suitable and adding a supported concrete operation entry where necessary. Do not publish the entire internal barrel. Exact operation/type signatures are implementation design within this bounded behavior-preserving migration.
  • Put all ui-server core loading paths (./queries, the replacement for ./internal, ./storage, and coreReader) through one resolver that verifies the package manifest identity, compatible version range and required supported entry before any operation runs. Keep lazy loading and existing graceful missing-peer behavior.
  • Derive and document accepted version ranges from the actual APIs each path requires and verified release availability. The old queries-only minimum must not authorize a release missing newly required operations. No arbitrary version floor or unverified compatibility claim.
  • Update tests/allowed-edges.ts, docs/decisions/index-query-api.md, relevant public API documentation and api-reports so they describe every supported core entry the server uses. Record this ruling durably during implementation.
  • Keep application, mask, maintenance, capture, edit and indexing behavior unchanged apart from clear early compatibility refusal on the selected path.

Out of scope

Acceptance criteria

  • Option A is recorded on this issue and incorporated into docs/decisions/index-query-api.md during implementation.
  • No ui-server source imports @schlessera/brain/internal; every core loading path goes through the single resolver and consumes supported entries.
  • A ui-server test that installs a core manifest outside the accepted version, through the resolver's test seam, gets a clear refusal on the capture/index path before any core function runs, and fails before the change.
  • Tests cover missing peer, wrong package identity, incompatible version and missing required entry without running a core operation, plus supported-version capture/index/query/storage paths. A missing optional peer retains the existing graceful behavior; no eager mandatory core dependency is introduced.
  • The tests/allowed-edges.ts comment for @schlessera/brain-ui-server names every core entry the server loads.
  • Record an intended failing-first compatibility test and a restored mutation removing the resolver check on an actual operation path; audit all sibling core loads before completion.

Verification

bun run test packages/ui-server tests/dependency-edges.test.ts
bun run typecheck

Contract impact

Selected A: any new supported core operation/entry or reachable public type is an additive package-API change, requiring a CONTRACT: commit, same-commit contract/API-report updates and an appropriate changeset. Preserve existing public signatures and optional-peer behavior; no breaking export change is approved. Load the release skill before changing package contents/dependencies during implementation.

Found by a repository review on 2026-10-22.

2026-10-22 triage at main ca8842828ed8634a84c4e8aa4a88e487238721b4: refreshed verified current-source pointers by their named anchors. Scope, recorded decisions and remaining prerequisites are unchanged; source inspection supplies no new runtime or epic-completion evidence.

Decision processing — 2026-10-22

The earlier recommendation is now approved as option A. The current brief specifies supported operations, one lazy optional-peer resolver, API-derived compatibility ranges and causal compatibility tests. Remove needs: decision, add agent-ready and contract, and preserve existing priority, milestone, assignment and parent. No implementation, package modification or new runtime qualification is claimed.

Activity

  1. added
    type: fix
    area: core
    area: ui-server
    priority: p2
    needs: decision
    on Oct 21, 2026
  2. schlessera commented on Oct 21, 2026

    @schlessera
    OwnerAuthor

    2026-10-22 triage at main ca8842828ed8634a84c4e8aa4a88e487238721b4: refreshed verified current-source pointers by their named anchors. Scope, recorded decisions and remaining prerequisites are unchanged; source inspection supplies no new runtime or epic-completion evidence. Added a separate unapproved recommendation and tradeoffs to the current decision brief; no ruling or implementation is inferred.

  3. added
    agent-ready
    contract
    and removed
    needs: decision
    on Oct 22, 2026
  4. schlessera commented on Oct 22, 2026

    @schlessera
    OwnerAuthor

    Decision (maintainer, 2026-10-22): Option A.

    Use supported core APIs with manifest/version-range validation through one resolver for every ui-server core load. Preserve lazy optional-peer behavior and existing product-group boundaries; no core-internal-sharing exception or exact-lockstep-only policy is selected. Publish only the narrow missing operations where necessary, with compatible-version evidence and normal contract/API-report/changeset review.

    The body now contains the bounded migration and compatibility proof criteria. Remove needs: decision, add agent-ready and contract; preserve existing ownership/release metadata. No implementation or verification pass is claimed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent-readyarea: corearea: ui-servercontractpriority: p2type: fix

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions