feat(invariants): implement package runtime checks
This commit is contained in:
@@ -1,14 +1,7 @@
|
||||
/**
|
||||
* Generated invariant ownership companion for `@deepseek-ai/dsh-acp-demo`.
|
||||
* Replace this file with package-owned checks while preserving its registration.
|
||||
*
|
||||
* @generated scripts/gen-package-invariants.ts
|
||||
* @module @deepseek-ai/dsh-acp-demo/invariant
|
||||
*/
|
||||
/** Package-owned runtime contract checks for `@deepseek-ai/dsh-acp-demo`. @module @deepseek-ai/dsh-acp-demo/invariant */
|
||||
|
||||
/* jscpd:ignore-start */
|
||||
import type { Context } from 'cordis'
|
||||
import type { InvariantInstaller } from '@deepseek-ai/dsh-invariants'
|
||||
import { observePluginInvariant, type InvariantInstaller } from '@deepseek-ai/dsh-invariants'
|
||||
|
||||
const PACKAGE_NAME = '@deepseek-ai/dsh-acp-demo'
|
||||
|
||||
@@ -17,8 +10,15 @@ export const name = 'acp-demo-invariant'
|
||||
/** Services required before the companion can register. */
|
||||
export const inject = ['invariants']
|
||||
|
||||
/** Reserve this package's invariant ownership until it adds relational checks. */
|
||||
const install: InvariantInstaller = () => {}
|
||||
/** Install checks for this package's active plugin fibers. */
|
||||
const install: InvariantInstaller = (ctx, fail) => {
|
||||
observePluginInvariant(ctx, fail, {
|
||||
name: 'acp-demo',
|
||||
effects: [
|
||||
'ctx.plugin()',
|
||||
],
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Register this package's invariant companion.
|
||||
@@ -27,4 +27,3 @@ const install: InvariantInstaller = () => {}
|
||||
*/
|
||||
export const apply = (ctx: Context): Promise<() => void> =>
|
||||
Promise.resolve(ctx.invariants.register(PACKAGE_NAME, install))
|
||||
/* jscpd:ignore-end */
|
||||
|
||||
@@ -21,7 +21,14 @@ import * as acpAgent from '../src/index.ts'
|
||||
*/
|
||||
async function mount(config: acpAgent.Config, withBash = false): Promise<Context> {
|
||||
const ctx = new Context()
|
||||
if (withBash) ctx.provide('bash', { sandboxMode: undefined })
|
||||
if (withBash) {
|
||||
ctx.provide('bash', {
|
||||
sandboxMode: undefined,
|
||||
resolve() { throw new Error('composition test does not execute bash') },
|
||||
run() { throw new Error('composition test does not execute bash') },
|
||||
start() { throw new Error('composition test does not execute bash') },
|
||||
})
|
||||
}
|
||||
await ctx.plugin(acpAgent, config)
|
||||
// The bundle mounts its children inside apply() (not awaited there); let their
|
||||
// fibers settle so the spine services are ready.
|
||||
|
||||
@@ -1,14 +1,7 @@
|
||||
/**
|
||||
* Generated invariant ownership companion for `@deepseek-ai/dsh-agent-spine-demo`.
|
||||
* Replace this file with package-owned checks while preserving its registration.
|
||||
*
|
||||
* @generated scripts/gen-package-invariants.ts
|
||||
* @module @deepseek-ai/dsh-agent-spine-demo/invariant
|
||||
*/
|
||||
/** Package-owned runtime contract checks for `@deepseek-ai/dsh-agent-spine-demo`. @module @deepseek-ai/dsh-agent-spine-demo/invariant */
|
||||
|
||||
/* jscpd:ignore-start */
|
||||
import type { Context } from 'cordis'
|
||||
import type { InvariantInstaller } from '@deepseek-ai/dsh-invariants'
|
||||
import { observePluginInvariant, type InvariantInstaller } from '@deepseek-ai/dsh-invariants'
|
||||
|
||||
const PACKAGE_NAME = '@deepseek-ai/dsh-agent-spine-demo'
|
||||
|
||||
@@ -17,8 +10,15 @@ export const name = 'agent-spine-demo-invariant'
|
||||
/** Services required before the companion can register. */
|
||||
export const inject = ['invariants']
|
||||
|
||||
/** Reserve this package's invariant ownership until it adds relational checks. */
|
||||
const install: InvariantInstaller = () => {}
|
||||
/** Install checks for this package's active plugin fibers. */
|
||||
const install: InvariantInstaller = (ctx, fail) => {
|
||||
observePluginInvariant(ctx, fail, {
|
||||
name: 'agent-spine-demo',
|
||||
effects: [
|
||||
'ctx.plugin()',
|
||||
],
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Register this package's invariant companion.
|
||||
@@ -27,4 +27,3 @@ const install: InvariantInstaller = () => {}
|
||||
*/
|
||||
export const apply = (ctx: Context): Promise<() => void> =>
|
||||
Promise.resolve(ctx.invariants.register(PACKAGE_NAME, install))
|
||||
/* jscpd:ignore-end */
|
||||
|
||||
@@ -48,7 +48,14 @@ async function mount(config: agentCore.Config, withBash = false): Promise<Contex
|
||||
process.env.DSH_HOME = await mkdtemp(join(tmpdir(), 'dsh-agent-spine-demo-home-'))
|
||||
process.env.DSH_AGENTS_HOME = await mkdtemp(join(tmpdir(), 'dsh-agent-spine-demo-agents-'))
|
||||
const ctx = new Context()
|
||||
if (withBash) ctx.provide('bash', { sandboxMode: undefined })
|
||||
if (withBash) {
|
||||
ctx.provide('bash', {
|
||||
sandboxMode: undefined,
|
||||
resolve() { throw new Error('composition test does not execute bash') },
|
||||
run() { throw new Error('composition test does not execute bash') },
|
||||
start() { throw new Error('composition test does not execute bash') },
|
||||
})
|
||||
}
|
||||
try {
|
||||
await ctx.plugin(agentCore, config)
|
||||
// The bundle mounts its children inside apply() (not awaited there); let their
|
||||
|
||||
@@ -1,14 +1,7 @@
|
||||
/**
|
||||
* Generated invariant ownership companion for `@deepseek-ai/dsh-cli-demo`.
|
||||
* Replace this file with package-owned checks while preserving its registration.
|
||||
*
|
||||
* @generated scripts/gen-package-invariants.ts
|
||||
* @module @deepseek-ai/dsh-cli-demo/invariant
|
||||
*/
|
||||
/** Package-owned runtime contract checks for `@deepseek-ai/dsh-cli-demo`. @module @deepseek-ai/dsh-cli-demo/invariant */
|
||||
|
||||
/* jscpd:ignore-start */
|
||||
import type { Context } from 'cordis'
|
||||
import type { InvariantInstaller } from '@deepseek-ai/dsh-invariants'
|
||||
import { observePluginInvariant, type InvariantInstaller } from '@deepseek-ai/dsh-invariants'
|
||||
|
||||
const PACKAGE_NAME = '@deepseek-ai/dsh-cli-demo'
|
||||
|
||||
@@ -17,8 +10,15 @@ export const name = 'cli-demo-invariant'
|
||||
/** Services required before the companion can register. */
|
||||
export const inject = ['invariants']
|
||||
|
||||
/** Reserve this package's invariant ownership until it adds relational checks. */
|
||||
const install: InvariantInstaller = () => {}
|
||||
/** Install checks for this package's active plugin fibers. */
|
||||
const install: InvariantInstaller = (ctx, fail) => {
|
||||
observePluginInvariant(ctx, fail, {
|
||||
name: 'cli-demo',
|
||||
effects: [
|
||||
'ctx.plugin()',
|
||||
],
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Register this package's invariant companion.
|
||||
@@ -27,4 +27,3 @@ const install: InvariantInstaller = () => {}
|
||||
*/
|
||||
export const apply = (ctx: Context): Promise<() => void> =>
|
||||
Promise.resolve(ctx.invariants.register(PACKAGE_NAME, install))
|
||||
/* jscpd:ignore-end */
|
||||
|
||||
@@ -22,7 +22,14 @@ async function skillConfig(catalogDescriptionMaxLength?: number): Promise<NonNul
|
||||
|
||||
async function mount(config: cliDemo.Config, withBash = false): Promise<Context> {
|
||||
const ctx = new Context()
|
||||
if (withBash) ctx.provide('bash', { sandboxMode: undefined })
|
||||
if (withBash) {
|
||||
ctx.provide('bash', {
|
||||
sandboxMode: undefined,
|
||||
resolve() { throw new Error('composition test does not execute bash') },
|
||||
run() { throw new Error('composition test does not execute bash') },
|
||||
start() { throw new Error('composition test does not execute bash') },
|
||||
})
|
||||
}
|
||||
contexts.push(ctx)
|
||||
await ctx.plugin(cliDemo, config)
|
||||
await new Promise(resolve => setTimeout(resolve, 80))
|
||||
|
||||
@@ -1,14 +1,8 @@
|
||||
/**
|
||||
* Generated invariant ownership companion for `@deepseek-ai/dsh-jsonrpc-demo`.
|
||||
* Replace this file with package-owned checks while preserving its registration.
|
||||
*
|
||||
* @generated scripts/gen-package-invariants.ts
|
||||
* @module @deepseek-ai/dsh-jsonrpc-demo/invariant
|
||||
*/
|
||||
/** Package-owned runtime contract for @deepseek-ai/dsh-jsonrpc-demo. @module @deepseek-ai/dsh-jsonrpc-demo/invariant */
|
||||
|
||||
/* jscpd:ignore-start */
|
||||
import type { Context } from 'cordis'
|
||||
import type { InvariantInstaller } from '@deepseek-ai/dsh-invariants'
|
||||
import { assertInvariant, type InvariantInstaller } from '@deepseek-ai/dsh-invariants'
|
||||
|
||||
const PACKAGE_NAME = '@deepseek-ai/dsh-jsonrpc-demo'
|
||||
|
||||
@@ -17,8 +11,15 @@ export const name = 'jsonrpc-demo-invariant'
|
||||
/** Services required before the companion can register. */
|
||||
export const inject = ['invariants']
|
||||
|
||||
/** Reserve this package's invariant ownership until it adds relational checks. */
|
||||
const install: InvariantInstaller = () => {}
|
||||
/** Assert that Loader configuration, rather than a hidden root plugin, owns composition. */
|
||||
const install: InvariantInstaller = (ctx, fail) => {
|
||||
ctx.effect(async () => {
|
||||
const packageEntry = await import('./index.ts')
|
||||
assertInvariant(fail, Object.keys(packageEntry).length === 0,
|
||||
'the JSON-RPC demo library entrypoint must remain empty because cordis.yml owns composition')
|
||||
return () => {}
|
||||
}, 'jsonrpc-demo: validate bin-only entrypoint')
|
||||
}
|
||||
|
||||
/**
|
||||
* Register this package's invariant companion.
|
||||
|
||||
@@ -1,14 +1,7 @@
|
||||
/**
|
||||
* Generated invariant ownership companion for `@deepseek-ai/dsh-stdio-demo`.
|
||||
* Replace this file with package-owned checks while preserving its registration.
|
||||
*
|
||||
* @generated scripts/gen-package-invariants.ts
|
||||
* @module @deepseek-ai/dsh-stdio-demo/invariant
|
||||
*/
|
||||
/** Package-owned runtime contract checks for `@deepseek-ai/dsh-stdio-demo`. @module @deepseek-ai/dsh-stdio-demo/invariant */
|
||||
|
||||
/* jscpd:ignore-start */
|
||||
import type { Context } from 'cordis'
|
||||
import type { InvariantInstaller } from '@deepseek-ai/dsh-invariants'
|
||||
import { observePluginInvariant, type InvariantInstaller } from '@deepseek-ai/dsh-invariants'
|
||||
|
||||
const PACKAGE_NAME = '@deepseek-ai/dsh-stdio-demo'
|
||||
|
||||
@@ -17,8 +10,15 @@ export const name = 'stdio-demo-invariant'
|
||||
/** Services required before the companion can register. */
|
||||
export const inject = ['invariants']
|
||||
|
||||
/** Reserve this package's invariant ownership until it adds relational checks. */
|
||||
const install: InvariantInstaller = () => {}
|
||||
/** Install checks for this package's active plugin fibers. */
|
||||
const install: InvariantInstaller = (ctx, fail) => {
|
||||
observePluginInvariant(ctx, fail, {
|
||||
name: 'stdio-demo',
|
||||
effects: [
|
||||
'ctx.plugin()',
|
||||
],
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Register this package's invariant companion.
|
||||
@@ -27,4 +27,3 @@ const install: InvariantInstaller = () => {}
|
||||
*/
|
||||
export const apply = (ctx: Context): Promise<() => void> =>
|
||||
Promise.resolve(ctx.invariants.register(PACKAGE_NAME, install))
|
||||
/* jscpd:ignore-end */
|
||||
|
||||
@@ -18,7 +18,14 @@ import * as stdioAgent from '../src/index.ts'
|
||||
*/
|
||||
async function mount(config: stdioAgent.Config, withBash = false): Promise<Context> {
|
||||
const ctx = new Context()
|
||||
if (withBash) ctx.provide('bash', { sandboxMode: undefined })
|
||||
if (withBash) {
|
||||
ctx.provide('bash', {
|
||||
sandboxMode: undefined,
|
||||
resolve() { throw new Error('composition test does not execute bash') },
|
||||
run() { throw new Error('composition test does not execute bash') },
|
||||
start() { throw new Error('composition test does not execute bash') },
|
||||
})
|
||||
}
|
||||
await ctx.plugin(stdioAgent, config)
|
||||
// The app mounts its children inside apply() (not awaited there); let their
|
||||
// fibers settle so the spine services + the pre-created agent are ready.
|
||||
|
||||
Reference in New Issue
Block a user