Skip to content

ui-server: remove the constant runtime witness for descriptor type compatibility #2970

Closed

Description

@schlessera

Context

Part of #2963. Source-verified finding from the 2026-10-25 multi-agent test-value audit at c670449d3bf1b0639e50ce554d728961f4313add. Broad inventory screening was followed by detailed inspection of this finding; this is not a claim of exhaustive manual review or measured CI savings.

Classification: confirmed tautology at runtime; low cost.
Suggested issue title: Replace the descriptor compilation smoke assertion with explicit type-only proof ownership.

Evidence:

  • The type assertions are declared at packages/ui-server/tests/declaration-surface.test.ts:126-143, anchored by type Assert and type _descriptorMembers.
  • Test “the type-level compatibility assertions above compiled” at packages/ui-server/tests/declaration-surface.test.ts:146-149 assigns the literal true to a type-annotated witness and then expects it to be true.
  • The relevant production descriptor contract is imported as BackendModule; the actual compiler checks the type relationships, not the test body.
  • tsconfig.json:18-29 includes package test TypeScript; package.json:25 declares typecheck as tsc --noEmit. Existing type-only convention: packages/ui-sdk/tests/tool-contracts.test-d.ts:1-65, with equality helpers in packages/ui-sdk/tests/type-equality.ts.

What can pass while broken:
Bun strips the three type aliases/imports and the witness annotation. The emitted test is effectively const witness = true; expect(witness).toBe(true). An incompatible backend descriptor, wrong member union or explicitly false compatibility type cannot make this Bun assertion fail. Strict TypeScript can fail separately.

Read-only verification performed:

  • Focused existing test passed: 1 test, 1 expect, 0.03 ms reported case time; total Bun output reported 156 ms.
  • An IN-MEMORY variant changed only type _piDescriptorCompat to false; Bun.Transpiler output for the entire file remained byte-identical to the original. No source was written or executed as a mutant. This directly verifies type erasure, not a complete compiler-mutation receipt.

Alternate proof and value to keep:
Retain the actual type aliases under the strict typecheck, including BackendModule's exact member union and both backend assignability checks. Retain both nontrivial tests in declaration-surface.test.ts:58-118: actual declaration emission plus the source AST scan protect distinct types/default and Bun-source optional-peer boundaries. Do not remove those as “static duplication.”

Safe change:
Delete only the runtime witness test, leaving type assertions in a file included by strict typecheck, or move them into an explicitly included *.test-d.ts following the SDK convention. Add an explanatory comment identifying the strict typecheck as owner. Do not add a whole extra compiler invocation for each alias.

Acceptance criteria:

  1. The constant assertion no longer counts as runtime contract proof.
  2. Both backend compatibility checks and the exact descriptor member check still participate in strict typecheck.
  3. Declaration emit/source optional-peer scans remain unchanged.
  4. A temporary incompatible type in an isolated worktree fails strict typing on the intended relationship; restoring it passes.

Focused verification/mutation proposal:
Run the strict type command required by the project once, and focused declaration-surface tests for the two runtime source/declaration boundaries. In an isolated checkout, make one backend descriptor incompatible or set the compatibility assertion to false; show the compiler rejects the relationship. No shared-checkout mutation was done here.

Count/cost:
One trivial Bun test invocation is removable. Its measured case time is tiny; this is proof clarity, not a runtime-optimization claim.

Scope

Remove the constant Bun assertion and leave descriptor compatibility/member relationships owned explicitly by strict TypeScript proof.

Out of scope

Changing product behavior, public contracts, required proof gates, offline guards, runtime pins or unrelated tests. Every distinct native, security, lifecycle and adapter obligation identified above remains. This issue does not authorize deleting the surviving owner named by another audit issue.

Acceptance criteria

  • The constant runtime test disappears; both backend compatibility assertions and the exact descriptor member union remain included by strict typecheck.
  • The two independent declaration-emission and optional-peer source-boundary tests remain; an incompatible relationship fails strict typing.
  • Record an assertion-to-owner mapping for every moved or removed case, including shared-helper obligations; do not count matching test names as proof of equivalence.
  • Run the proposed focused production mutation(s), observe failure on the intended assertion, restore, and record passing focused proof. A module-load error is not a behavioral receipt.
  • Any performance claim separates scenario/body cost, setup and total elapsed time and uses comparable observations; structural counts alone are not a speedup.

Verification

bun run typecheck
bun run test ./packages/ui-server/tests/declaration-surface.test.ts
bun run check:pr --base origin/main

Preserve the existing offline/keyless harness. Browser/native commands require the documented real runtime and OS-offline prerequisites; missing prerequisites are not passing or skipped proof. The mutation proposals and retained boundary checks are detailed above.

Contract impact

No integration-contract or product-behavior change is selected. This is test/proof maintenance; retain the current CLI/MCP/wire/schema/frontmatter envelopes. No release-content change is selected.

Activity

  1. added
    type: test
    area: ui-server
    on Oct 25, 2026
  2. added
    priority: p2
    agent-ready
    on Oct 25, 2026
  3. schlessera commented on Oct 25, 2026

    @schlessera
    OwnerAuthor

    2026-10-26 triage at main c670449d3bf1b0639e50ce554d728961f4313add: verified the cited current test/production boundary and native #2963 parent. The scope names the retained proof, exclusions, checkable acceptance criteria, focused verification and mutation requirements; no unresolved design, decision, access or reproduction prerequisite prevents starting this test-maintenance task. Set priority p2 for wanted, unscheduled work and add agent-ready. Keep native/browser/SDK qualification required by the brief as implementation proof; this source/readiness review supplies no completed repair, post-change equivalence or measured CI saving.

  4. added this to the 0.44.0 milestone on Oct 29, 2026
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: ui-serverpriority: p2type: test

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions