fix(invariants): assert runtime relationships, not API shapes
This commit is contained in:
@@ -1,29 +1,24 @@
|
||||
/** Package-owned runtime contracts for @deepseek-ai/dsh-helper. @module @deepseek-ai/dsh-helper/invariant */
|
||||
/**
|
||||
* Package-owned invariant companion for `@deepseek-ai/dsh-helper`.
|
||||
* @module @deepseek-ai/dsh-helper/invariant
|
||||
*/
|
||||
|
||||
/* jscpd:ignore-start */
|
||||
import type { Context } from 'cordis'
|
||||
import { assertInvariant, type InvariantInstaller } from '@deepseek-ai/dsh-invariants'
|
||||
import type { InvariantInstaller } from '@deepseek-ai/dsh-invariants'
|
||||
|
||||
const PACKAGE_NAME = '@deepseek-ai/dsh-helper'
|
||||
|
||||
/** Cordis companion plugin name. */
|
||||
export const name = 'helper-invariant'
|
||||
/** Services required before the companion can register. */
|
||||
/** Service required before the companion can reserve package ownership. */
|
||||
export const inject = ['invariants']
|
||||
|
||||
/** Assert FeatureId's zero-cost representation and boundary validation. */
|
||||
const install: InvariantInstaller = async (_ctx, fail) => {
|
||||
const { featureId } = await import('./ids.ts')
|
||||
assertInvariant(fail, featureId('local-plugin') === 'local-plugin',
|
||||
'a valid feature id must preserve its runtime string value')
|
||||
let rejected = false
|
||||
try {
|
||||
featureId('Invalid Feature')
|
||||
} catch (error) {
|
||||
rejected = error instanceof Error
|
||||
}
|
||||
assertInvariant(fail, rejected, 'feature ids must reject values outside lowercase kebab-case')
|
||||
}
|
||||
/**
|
||||
* No runtime invariant: this SDK build-time package owns no live event stream or mutable data;
|
||||
* generated output and consumer tests cover its contract.
|
||||
*/
|
||||
const install: InvariantInstaller = () => {}
|
||||
|
||||
/**
|
||||
* Register this package's invariant companion.
|
||||
|
||||
Reference in New Issue
Block a user