Просмотр исходного кода

Merge branch 'stack/agent-profiles-3-wire' into stack/agent-profiles-4-settings

# Conflicts:
#	packages/preset/agent-presets/tests/mount.spec.ts
Yichen Jiang 2 месяцев назад
Родитель
Сommit
a0194bdab2

+ 1 - 0
packages/core/session/tests/session.spec.ts

@@ -1319,6 +1319,7 @@ describe('SessionStore', () => {
       { meta: { delegationDepth: '1' }, error: /delegationDepth must be a non-negative safe integer/ },
       { meta: { delegationDepth: 0.5 }, error: /delegationDepth must be a non-negative safe integer/ },
       { meta: { delegationDepth: -1 }, error: /delegationDepth must be a non-negative safe integer/ },
+      { meta: { agentPreset: 1 }, error: /agentPreset must be a string/ },
     ]
 
     for (const [index, { meta, error }] of cases.entries()) {

+ 19 - 0
packages/preset/agent-presets/tests/mount.spec.ts

@@ -219,6 +219,25 @@ 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 () => {
+    const handle = await ctx.agents.create({
+      sessionId: SessionId('sess-write'),
+      setup: async (agentCtx: Context) => void await ctx.agentPresets.mount(agentCtx, 'standard'),
+    })
+    const [mount] = livePresetMounts().filter(entry => entry.presetId === 'standard')
+    expect(mount).toBeDefined()
+    const file = join(FIXTURES, 'system', 'standard', 'agent.cordis.yml')
+    const before = await readFile(file, 'utf8')
+
+    // The inherited `write()` persists the tree whenever the Loader thinks the
+    // config moved, and disposing an agent disposes its whole subtree — which
+    // is enough to trigger it. Inheriting that truncates the shipped preset to
+    // `[]` the first time a session ends.
+    await handle.dispose()
+
+    expect(await readFile(file, 'utf8')).toBe(before)
+  })
+
   it('attributes nothing to a subtree that is already torn down', async () => {
     const handle = await ctx.agents.create({
       sessionId: SessionId('sess-torn'),