From c6329ec91e0be0dade3813696828b8778e77c82c Mon Sep 17 00:00:00 2001 From: be-coder-07 Date: Wed, 5 Aug 2026 13:24:12 -0500 Subject: [PATCH] test(installer): preregister durable brain P7 integration --- .../brain-installer-integration.spec.ts | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 packages/mosaic/src/commands/brain-installer-integration.spec.ts diff --git a/packages/mosaic/src/commands/brain-installer-integration.spec.ts b/packages/mosaic/src/commands/brain-installer-integration.spec.ts new file mode 100644 index 00000000..27732585 --- /dev/null +++ b/packages/mosaic/src/commands/brain-installer-integration.spec.ts @@ -0,0 +1,54 @@ +import { describe, expect, it } from 'vitest'; +import { readFileSync } from 'node:fs'; +import { join } from 'node:path'; + +function installerSource(): string { + return readFileSync(join(process.cwd(), '..', '..', 'tools', 'install.sh'), 'utf8'); +} + +describe('root installer P7 durable-brain integration', (): void => { + it('records the configured source repository in the committed manifest for doctor derivation', (): void => { + const installer = installerSource(); + + expect(installer).toContain('sourceRepo:'); + expect(installer).toMatch(/sourceRepo:\s*process\.argv\[/); + expect(installer).toMatch(/MANIFEST_SOURCE_REPO/); + }); + + it('invokes the broker-only provision command in P7 with explicit owner and refusal controls', (): void => { + const installer = installerSource(); + const provision = installer.indexOf('__brain-provision'); + const p7 = installer.indexOf('state_phase_begin P7'); + + expect(provision).toBeGreaterThan(-1); + expect(p7).toBeGreaterThan(-1); + expect(provision).toBeGreaterThan(p7); + for (const flag of [ + '--identity', + '--target-url', + '--owner', + '--refusal-identity', + '--lane', + '--owner-policy', + ]) { + expect(installer).toContain(flag); + } + expect(installer).not.toMatch(/__brain-provision[^\n]*(?:token|password|authorization)/i); + }); + + it('journals ~/.mosaic and the owner policy as P7 mutations and checks the resulting object', (): void => { + const installer = installerSource(); + + expect(installer).toContain('state_record_mutation P7 "$HOME/.mosaic"'); + expect(installer).toContain('state_record_mutation P7 "$MOSAIC_HOME/brain/owners.json"'); + expect(installer).toMatch(/P7\)[\s\S]*\.mosaic[\s\S]*(?:remote|get-url)[\s\S]*main/); + }); + + it('discovers every legacy lane directory rather than silently migrating only one lane', (): void => { + const installer = installerSource(); + + expect(installer).toMatch(/memory\/lanes/); + expect(installer).toMatch(/for\s+[^\n]*lane/); + expect(installer).toMatch(/__brain-provision[\s\S]*--lane/); + }); +});