fix(invariants): assert runtime relationships, not API shapes
This commit is contained in:
124 files changed
+2923
-2334
No files matched your search
@@ -1,29 +1,24 @@
|
||||
/** Package-owned runtime contract checks for `@deepseek-ai/dsh-code-runtime`. @module @deepseek-ai/dsh-code-runtime/invariant */
|
||||
/**
|
||||
* Package-owned invariant companion for `@deepseek-ai/dsh-code-runtime`.
|
||||
* @module @deepseek-ai/dsh-code-runtime/invariant
|
||||
*/
|
||||
|
||||
/* jscpd:ignore-start */
|
||||
import type { Context } from 'cordis'
|
||||
import { observeServiceInvariant, serviceShapeViolation, type InvariantInstaller } from '@deepseek-ai/dsh-invariants'
|
||||
import type { InvariantInstaller } from '@deepseek-ai/dsh-invariants'
|
||||
|
||||
const PACKAGE_NAME = '@deepseek-ai/dsh-code-runtime'
|
||||
|
||||
/** Cordis companion plugin name. */
|
||||
export const name = 'code-runtime-invariant'
|
||||
/** Services required before the companion can register. */
|
||||
/** Service required before the companion can reserve package ownership. */
|
||||
export const inject = ['invariants']
|
||||
|
||||
/** Validate every implementation bound to this package's service seam. */
|
||||
const install: InvariantInstaller = (ctx, fail) => {
|
||||
observeServiceInvariant(ctx, fail, 'codeRuntime', (value) => {
|
||||
const violation = serviceShapeViolation(value, {
|
||||
methods: ['run'],
|
||||
stringProperties: ['language', 'isolation'],
|
||||
})
|
||||
if (violation !== undefined) return violation
|
||||
const service = value as { language: string; isolation: string }
|
||||
return /^[a-z][a-z0-9-]*$/.test(service.language) && /^[a-z][a-z0-9-]*$/.test(service.isolation)
|
||||
? undefined
|
||||
: 'code runtime language and isolation must be lowercase identifiers'
|
||||
})
|
||||
}
|
||||
/**
|
||||
* No runtime invariant: this package exposes no independent event sequence or mutable data relation
|
||||
* beyond contracts enforced at its owning seam.
|
||||
*/
|
||||
const install: InvariantInstaller = () => {}
|
||||
|
||||
/**
|
||||
* Register this package's invariant companion.
|
||||
@@ -32,3 +27,4 @@ const install: InvariantInstaller = (ctx, fail) => {
|
||||
*/
|
||||
export const apply = (ctx: Context): Promise<() => void> =>
|
||||
Promise.resolve(ctx.invariants.register(PACKAGE_NAME, install))
|
||||
/* jscpd:ignore-end */
|
||||
Reference in New Issue
Block a user