/** * A FLOW THAT BELONGS TO AN ORGAN SAYS SO. * * Herald's reply flow is stored where the owner's own automations are, so it already appeared on the * Automation tab — as an anonymous card that looked hand-drawn, whose trigger read "manual" (nobody * presses it; Herald does), and which offered a Delete that would have silently stopped every reply * the desk sends, with nothing on screen to say what broke. * * `owner` is who shipped it. Editing stays open on purpose — the owner may want to see or tune what * her desk runs, and the organ reconciles by name on its next restart. */ import { describe, it, expect, afterAll } from 'vitest'; import fs from 'node:fs'; import os from 'node:os'; import path from 'node:path'; const TMP = fs.mkdtempSync(path.join(os.tmpdir(), 'gb-owner-')); process.env.PROFILE_DIR = TMP; const wf = await import('../src/workflows.js'); afterAll(() => { try { fs.rmSync(TMP, { recursive: true, force: true }); } catch { /* gone */ } }); const flow = (extra = {}) => ({ name: 'a flow with an owner', nodes: [{ id: 'start', type: 'trigger' }, { id: 'a', type: 'agent', role: 'general', goal: 'do it' }], edges: [{ from: 'start', to: 'a' }], ...extra, }); describe('a flow records who shipped it', () => { it('an organ signs its own', () => { expect(wf.save(flow({ owner: 'herald', name: 'organ flow' }), ['general']).owner).toBe('herald'); }); it('one the owner drew has none', () => { expect(wf.save(flow({ name: 'hand drawn' }), ['general']).owner).toBe(''); }); /* Editing must never orphan a flow from the organ that maintains it. */ it('and editing it does not lose the owner', () => { const saved = wf.save(flow({ owner: 'herald', name: 'kept owner' }), ['general']); const edited = wf.save({ ...saved, name: 'kept owner, renamed', owner: undefined }, ['general']); expect(edited.owner).toBe('herald'); }); it('the name is cleaned, because it is shown on a card', () => { expect(wf.save(flow({ owner: ' Herald