fix(typert): address remote gateway review

This commit is contained in:
imccyu
2026-08-07 11:05:55 +08:00
parent da1ebd2b68
commit 2e1f9a5cea
19 changed files with 275 additions and 58 deletions

View File

@@ -7,6 +7,7 @@
import { Context, Service } from 'cordis'
import { z } from 'zod'
import { isTypeRTRemoteSegment } from '@deepseek-ai/dsh-type-meta'
import type {
InvocationDescriptor,
TypeRTClientContextBinder,
@@ -600,8 +601,9 @@ function validateCodec(codec: InvocationDescriptor['result'], subject: string):
}
function validateWireName(subject: string, value: string): void {
validateSegment(subject, value)
if (value.includes('/')) throw new Error(`typert: invalid ${subject} "${value}" — must not contain "/"`)
if (!isTypeRTRemoteSegment(value)) {
throw new Error(`typert: invalid ${subject} "${value}" — must contain only RPC endpoint segment characters`)
}
}
function validateSegment(subject: string, value: string): void {

View File

@@ -247,6 +247,14 @@ describe('TypertRegistry', () => {
})).toThrow('endpoint "goals/create" is already registered')
})
it.each(['create#v2', 'create goal'])('rejects untransportable invocation method %s', async (method) => {
const ctx = await makeCtx()
expect(() => ctx.typert.remotes.register({
package: '@fixture/invalid-endpoint',
descriptors: [{ ...invocation(), method }],
})).toThrow('RPC endpoint segment characters')
})
it('mounts Remote contributions in the calling fiber and withdraws them exactly', async () => {
const ctx = await makeCtx()
const descriptor = invocation()