Merge branch 'stack/agent-profiles-7-docs' into stack/agent-profiles-8-authoring
This commit is contained in:
@@ -17,9 +17,4 @@ export function apply(ctx, config) {
|
|||||||
order: 10,
|
order: 10,
|
||||||
text: `section for ${config.tool}`,
|
text: `section for ${config.tool}`,
|
||||||
}))
|
}))
|
||||||
// Reconfiguring a live row runs the Loader's `internal/update` waterfall,
|
|
||||||
// which persists the owning tree. That is the trigger reaching the preset
|
|
||||||
// tree's `write` while the subtree is still mounted; tearing the agent down
|
|
||||||
// instead stops earlier, in the loader's own "tree is being disposed" case.
|
|
||||||
globalThis.__RECONFIGURE__ = tool => ctx.fiber.update({ ...config, tool })
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -232,45 +232,6 @@ describe('a roster with nothing in it', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('attributing a service to a subtree', () => {
|
|
||||||
it('never writes the preset file back, however the subtree changes', async () => {
|
|
||||||
delete (globalThis as { __RECONFIGURE__?: unknown }).__RECONFIGURE__
|
|
||||||
const handle = await ctx.agents.create({
|
|
||||||
sessionId: SessionId('sess-write'),
|
|
||||||
setup: async (agentCtx: Context) => void await ctx.agentPresets.mount(agentCtx, 'standard'),
|
|
||||||
})
|
|
||||||
const file = join(FIXTURES, 'system', 'standard', 'agent.cordis.yml')
|
|
||||||
const before = await readFile(file, 'utf8')
|
|
||||||
|
|
||||||
// The inherited `write()` persists the whole tree whenever the Loader
|
|
||||||
// decides a row's config moved, so one row reconfiguring itself would
|
|
||||||
// rewrite the shipped composition — here, with the row's new tool name.
|
|
||||||
const reconfigure = (globalThis as { __RECONFIGURE__?: (tool: string) => Promise<void> }).__RECONFIGURE__
|
|
||||||
expect(reconfigure).toBeTypeOf('function')
|
|
||||||
await reconfigure!('rewritten')
|
|
||||||
|
|
||||||
expect(toolNames(ctx, handle.agent)).toContain('rewritten')
|
|
||||||
expect(await readFile(file, 'utf8')).toBe(before)
|
|
||||||
|
|
||||||
await handle.dispose()
|
|
||||||
})
|
|
||||||
|
|
||||||
it('attributes nothing to a subtree that is already torn down', async () => {
|
|
||||||
const handle = await ctx.agents.create({
|
|
||||||
sessionId: SessionId('sess-torn'),
|
|
||||||
setup: async (agentCtx: Context) => void await ctx.agentPresets.mount(agentCtx, 'standard'),
|
|
||||||
})
|
|
||||||
const [mount] = livePresetMounts().filter(entry => entry.presetId === 'standard')
|
|
||||||
expect(mount).toBeDefined()
|
|
||||||
|
|
||||||
await handle.dispose()
|
|
||||||
|
|
||||||
// A disposed subtree owns nothing, so it can never be blamed for a service
|
|
||||||
// some other subtree published under the same name afterwards.
|
|
||||||
expect(leakedServices(ctx, mount!.fiber)).toEqual([])
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
describe('the preset file is an input, never a persistence target', () => {
|
describe('the preset file is an input, never a persistence target', () => {
|
||||||
it('survives a row that disposes itself, which makes the Loader persist a tree', async () => {
|
it('survives a row that disposes itself, which makes the Loader persist a tree', async () => {
|
||||||
// The preset lives in a temp root, not under `fixtures/`: without the
|
// The preset lives in a temp root, not under `fixtures/`: without the
|
||||||
@@ -324,6 +285,23 @@ describe('the preset file is an input, never a persistence target', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe('attributing a service to a subtree', () => {
|
||||||
|
it('attributes nothing to a subtree that is already torn down', async () => {
|
||||||
|
const handle = await ctx.agents.create({
|
||||||
|
sessionId: SessionId('sess-torn'),
|
||||||
|
setup: async (agentCtx: Context) => void await ctx.agentPresets.mount(agentCtx, 'standard'),
|
||||||
|
})
|
||||||
|
const [mount] = livePresetMounts().filter(entry => entry.presetId === 'standard')
|
||||||
|
expect(mount).toBeDefined()
|
||||||
|
|
||||||
|
await handle.dispose()
|
||||||
|
|
||||||
|
// A disposed subtree owns nothing, so it can never be blamed for a service
|
||||||
|
// some other subtree published under the same name afterwards.
|
||||||
|
expect(leakedServices(ctx, mount!.fiber)).toEqual([])
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
describe('replacing a composition', () => {
|
describe('replacing a composition', () => {
|
||||||
it('swaps the agent\'s tools without touching another session', async () => {
|
it('swaps the agent\'s tools without touching another session', async () => {
|
||||||
const keeper = await agentOn(ctx, 'sess-keeper', 'standard')
|
const keeper = await agentOn(ctx, 'sess-keeper', 'standard')
|
||||||
|
|||||||
Reference in New Issue
Block a user