macro-agent 0.1.8 → 0.1.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CLAUDE.md +263 -33
- package/README.md +781 -131
- package/dist/acp/claude-code-replay.d.ts +11 -0
- package/dist/acp/claude-code-replay.d.ts.map +1 -0
- package/dist/acp/claude-code-replay.js +190 -0
- package/dist/acp/claude-code-replay.js.map +1 -0
- package/dist/acp/macro-agent.d.ts.map +1 -1
- package/dist/acp/macro-agent.js +192 -7
- package/dist/acp/macro-agent.js.map +1 -1
- package/dist/acp/types.d.ts +9 -0
- package/dist/acp/types.d.ts.map +1 -1
- package/dist/acp/types.js.map +1 -1
- package/dist/adapters/tasks-adapter.d.ts.map +1 -1
- package/dist/adapters/tasks-adapter.js +3 -0
- package/dist/adapters/tasks-adapter.js.map +1 -1
- package/dist/adapters/types.d.ts +1 -0
- package/dist/adapters/types.d.ts.map +1 -1
- package/dist/agent/agent-manager-v2.d.ts +21 -0
- package/dist/agent/agent-manager-v2.d.ts.map +1 -1
- package/dist/agent/agent-manager-v2.js +308 -54
- package/dist/agent/agent-manager-v2.js.map +1 -1
- package/dist/agent/agent-manager.d.ts +12 -0
- package/dist/agent/agent-manager.d.ts.map +1 -1
- package/dist/agent/agent-manager.js.map +1 -1
- package/dist/agent/agent-store.d.ts +10 -0
- package/dist/agent/agent-store.d.ts.map +1 -1
- package/dist/agent/agent-store.js +22 -0
- package/dist/agent/agent-store.js.map +1 -1
- package/dist/agent/types.d.ts +15 -2
- package/dist/agent/types.d.ts.map +1 -1
- package/dist/agent/types.js.map +1 -1
- package/dist/boot-v2.d.ts +129 -1
- package/dist/boot-v2.d.ts.map +1 -1
- package/dist/boot-v2.js +359 -8
- package/dist/boot-v2.js.map +1 -1
- package/dist/cli/acp.js +4 -0
- package/dist/cli/acp.js.map +1 -1
- package/dist/cli/index.js +56 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/cognitive/macro-agent-backend.d.ts.map +1 -1
- package/dist/cognitive/macro-agent-backend.js +40 -22
- package/dist/cognitive/macro-agent-backend.js.map +1 -1
- package/dist/integrations/skilltree.d.ts.map +1 -1
- package/dist/integrations/skilltree.js +1 -0
- package/dist/integrations/skilltree.js.map +1 -1
- package/dist/lifecycle/cascade.d.ts +25 -2
- package/dist/lifecycle/cascade.d.ts.map +1 -1
- package/dist/lifecycle/cascade.js +70 -2
- package/dist/lifecycle/cascade.js.map +1 -1
- package/dist/lifecycle/cleanup.d.ts +33 -2
- package/dist/lifecycle/cleanup.d.ts.map +1 -1
- package/dist/lifecycle/cleanup.js +28 -6
- package/dist/lifecycle/cleanup.js.map +1 -1
- package/dist/lifecycle/handlers-v2.d.ts +7 -0
- package/dist/lifecycle/handlers-v2.d.ts.map +1 -1
- package/dist/lifecycle/handlers-v2.js +28 -2
- package/dist/lifecycle/handlers-v2.js.map +1 -1
- package/dist/lifecycle/types.d.ts +11 -0
- package/dist/lifecycle/types.d.ts.map +1 -1
- package/dist/lifecycle/types.js.map +1 -1
- package/dist/map/acp-bridge.d.ts +9 -0
- package/dist/map/acp-bridge.d.ts.map +1 -1
- package/dist/map/acp-bridge.js +15 -2
- package/dist/map/acp-bridge.js.map +1 -1
- package/dist/map/cascade-action-handler.d.ts +24 -0
- package/dist/map/cascade-action-handler.d.ts.map +1 -0
- package/dist/map/cascade-action-handler.js +170 -0
- package/dist/map/cascade-action-handler.js.map +1 -0
- package/dist/map/cascade-bridge.d.ts +44 -0
- package/dist/map/cascade-bridge.d.ts.map +1 -0
- package/dist/map/cascade-bridge.js +294 -0
- package/dist/map/cascade-bridge.js.map +1 -0
- package/dist/map/coordination-handler.d.ts.map +1 -1
- package/dist/map/coordination-handler.js +12 -1
- package/dist/map/coordination-handler.js.map +1 -1
- package/dist/map/lifecycle-bridge.d.ts +1 -1
- package/dist/map/lifecycle-bridge.d.ts.map +1 -1
- package/dist/map/lifecycle-bridge.js +58 -23
- package/dist/map/lifecycle-bridge.js.map +1 -1
- package/dist/map/server.d.ts.map +1 -1
- package/dist/map/server.js +219 -7
- package/dist/map/server.js.map +1 -1
- package/dist/map/sidecar.d.ts.map +1 -1
- package/dist/map/sidecar.js +49 -2
- package/dist/map/sidecar.js.map +1 -1
- package/dist/map/types.d.ts +22 -0
- package/dist/map/types.d.ts.map +1 -1
- package/dist/mcp/tools/done-v2.d.ts.map +1 -1
- package/dist/mcp/tools/done-v2.js +8 -0
- package/dist/mcp/tools/done-v2.js.map +1 -1
- package/dist/teams/team-manager-v2.d.ts.map +1 -1
- package/dist/teams/team-manager-v2.js +26 -0
- package/dist/teams/team-manager-v2.js.map +1 -1
- package/dist/teams/team-runtime-v2.d.ts.map +1 -1
- package/dist/teams/team-runtime-v2.js +16 -3
- package/dist/teams/team-runtime-v2.js.map +1 -1
- package/dist/workspace/config.d.ts +10 -10
- package/dist/workspace/config.d.ts.map +1 -1
- package/dist/workspace/config.js +4 -4
- package/dist/workspace/config.js.map +1 -1
- package/dist/workspace/git-cascade-adapter.d.ts +510 -0
- package/dist/workspace/git-cascade-adapter.d.ts.map +1 -0
- package/dist/workspace/git-cascade-adapter.js +934 -0
- package/dist/workspace/git-cascade-adapter.js.map +1 -0
- package/dist/workspace/index.d.ts +3 -3
- package/dist/workspace/index.d.ts.map +1 -1
- package/dist/workspace/index.js +4 -4
- package/dist/workspace/index.js.map +1 -1
- package/dist/workspace/landing/direct-push.d.ts +20 -0
- package/dist/workspace/landing/direct-push.d.ts.map +1 -0
- package/dist/workspace/landing/direct-push.js +74 -0
- package/dist/workspace/landing/direct-push.js.map +1 -0
- package/dist/workspace/landing/index.d.ts +29 -0
- package/dist/workspace/landing/index.d.ts.map +1 -0
- package/dist/workspace/landing/index.js +37 -0
- package/dist/workspace/landing/index.js.map +1 -0
- package/dist/workspace/landing/merge-to-parent.d.ts +41 -0
- package/dist/workspace/landing/merge-to-parent.d.ts.map +1 -0
- package/dist/workspace/landing/merge-to-parent.js +186 -0
- package/dist/workspace/landing/merge-to-parent.js.map +1 -0
- package/dist/workspace/landing/optimistic-push.d.ts +16 -0
- package/dist/workspace/landing/optimistic-push.d.ts.map +1 -0
- package/dist/workspace/landing/optimistic-push.js +27 -0
- package/dist/workspace/landing/optimistic-push.js.map +1 -0
- package/dist/workspace/landing/queue-to-branch.d.ts +24 -0
- package/dist/workspace/landing/queue-to-branch.d.ts.map +1 -0
- package/dist/workspace/landing/queue-to-branch.js +79 -0
- package/dist/workspace/landing/queue-to-branch.js.map +1 -0
- package/dist/workspace/merge-queue/merge-queue.d.ts +10 -0
- package/dist/workspace/merge-queue/merge-queue.d.ts.map +1 -1
- package/dist/workspace/merge-queue/merge-queue.js +10 -0
- package/dist/workspace/merge-queue/merge-queue.js.map +1 -1
- package/dist/workspace/merge-queue/types.d.ts +16 -2
- package/dist/workspace/merge-queue/types.d.ts.map +1 -1
- package/dist/workspace/merge-queue/types.js +9 -0
- package/dist/workspace/merge-queue/types.js.map +1 -1
- package/dist/workspace/pool/types.d.ts +1 -0
- package/dist/workspace/pool/types.d.ts.map +1 -1
- package/dist/workspace/pool/worktree-pool.d.ts.map +1 -1
- package/dist/workspace/pool/worktree-pool.js +1 -0
- package/dist/workspace/pool/worktree-pool.js.map +1 -1
- package/dist/workspace/recovery/abandon.d.ts +15 -0
- package/dist/workspace/recovery/abandon.d.ts.map +1 -0
- package/dist/workspace/recovery/abandon.js +45 -0
- package/dist/workspace/recovery/abandon.js.map +1 -0
- package/dist/workspace/recovery/auto-resolve.d.ts +27 -0
- package/dist/workspace/recovery/auto-resolve.d.ts.map +1 -0
- package/dist/workspace/recovery/auto-resolve.js +99 -0
- package/dist/workspace/recovery/auto-resolve.js.map +1 -0
- package/dist/workspace/recovery/defer.d.ts +15 -0
- package/dist/workspace/recovery/defer.d.ts.map +1 -0
- package/dist/workspace/recovery/defer.js +16 -0
- package/dist/workspace/recovery/defer.js.map +1 -0
- package/dist/workspace/recovery/escalate.d.ts +16 -0
- package/dist/workspace/recovery/escalate.d.ts.map +1 -0
- package/dist/workspace/recovery/escalate.js +24 -0
- package/dist/workspace/recovery/escalate.js.map +1 -0
- package/dist/workspace/recovery/index.d.ts +32 -0
- package/dist/workspace/recovery/index.d.ts.map +1 -0
- package/dist/workspace/recovery/index.js +45 -0
- package/dist/workspace/recovery/index.js.map +1 -0
- package/dist/workspace/recovery/spawn-resolver.d.ts +45 -0
- package/dist/workspace/recovery/spawn-resolver.d.ts.map +1 -0
- package/dist/workspace/recovery/spawn-resolver.js +118 -0
- package/dist/workspace/recovery/spawn-resolver.js.map +1 -0
- package/dist/workspace/recovery/types.d.ts +63 -0
- package/dist/workspace/recovery/types.d.ts.map +1 -0
- package/dist/workspace/recovery/types.js +12 -0
- package/dist/workspace/recovery/types.js.map +1 -0
- package/dist/workspace/topology/index.d.ts +9 -0
- package/dist/workspace/topology/index.d.ts.map +1 -0
- package/dist/workspace/topology/index.js +8 -0
- package/dist/workspace/topology/index.js.map +1 -0
- package/dist/workspace/topology/no-workspace.d.ts +18 -0
- package/dist/workspace/topology/no-workspace.d.ts.map +1 -0
- package/dist/workspace/topology/no-workspace.js +25 -0
- package/dist/workspace/topology/no-workspace.js.map +1 -0
- package/dist/workspace/topology/types.d.ts +97 -0
- package/dist/workspace/topology/types.d.ts.map +1 -0
- package/dist/workspace/topology/types.js +20 -0
- package/dist/workspace/topology/types.js.map +1 -0
- package/dist/workspace/topology/yaml-driven.d.ts +69 -0
- package/dist/workspace/topology/yaml-driven.d.ts.map +1 -0
- package/dist/workspace/topology/yaml-driven.js +273 -0
- package/dist/workspace/topology/yaml-driven.js.map +1 -0
- package/dist/workspace/types-v3.d.ts +117 -0
- package/dist/workspace/types-v3.d.ts.map +1 -0
- package/dist/workspace/types-v3.js +20 -0
- package/dist/workspace/types-v3.js.map +1 -0
- package/dist/workspace/types.d.ts +162 -17
- package/dist/workspace/types.d.ts.map +1 -1
- package/dist/workspace/workspace-manager.d.ts +101 -13
- package/dist/workspace/workspace-manager.d.ts.map +1 -1
- package/dist/workspace/workspace-manager.js +416 -13
- package/dist/workspace/workspace-manager.js.map +1 -1
- package/dist/workspace/yaml-schema.d.ts +254 -0
- package/dist/workspace/yaml-schema.d.ts.map +1 -0
- package/dist/workspace/yaml-schema.js +170 -0
- package/dist/workspace/yaml-schema.js.map +1 -0
- package/docs/conflict-recovery.md +472 -0
- package/docs/design/task-dispatcher.md +880 -0
- package/docs/git-cascade-integration-gaps.md +678 -0
- package/docs/workspace-interfaces.md +731 -0
- package/docs/workspace-redesign-plan.md +302 -0
- package/package.json +6 -5
- package/src/__tests__/boot-v2.test.ts +435 -0
- package/src/__tests__/e2e/acp-over-map.e2e.test.ts +92 -0
- package/src/__tests__/e2e/auto-sync.e2e.test.ts +257 -0
- package/src/__tests__/e2e/bootstrap.e2e.test.ts +319 -0
- package/src/__tests__/e2e/cascade-rebase.e2e.test.ts +254 -0
- package/src/__tests__/e2e/cli-run.e2e.test.ts +167 -0
- package/src/__tests__/e2e/dispatch-coordination.e2e.test.ts +495 -0
- package/src/__tests__/e2e/dispatch-live.e2e.test.ts +564 -0
- package/src/__tests__/e2e/dispatch-opentasks.e2e.test.ts +496 -0
- package/src/__tests__/e2e/dispatch-phase2-live.e2e.test.ts +456 -0
- package/src/__tests__/e2e/dispatch-phase2.e2e.test.ts +386 -0
- package/src/__tests__/e2e/dispatch.e2e.test.ts +376 -0
- package/src/__tests__/e2e/self-driving-v3.e2e.test.ts +197 -0
- package/src/__tests__/e2e/spawn-resolver.e2e.test.ts +200 -0
- package/src/__tests__/e2e/workspace-lifecycle.e2e.test.ts +30 -22
- package/src/__tests__/e2e/workspace-v3.e2e.test.ts +413 -0
- package/src/acp/__tests__/claude-code-replay.test.ts +225 -0
- package/src/acp/__tests__/macro-agent.test.ts +39 -1
- package/src/acp/claude-code-replay.ts +208 -0
- package/src/acp/macro-agent.ts +203 -10
- package/src/acp/types.ts +10 -0
- package/src/adapters/__tests__/tasks-adapter.test.ts +1 -0
- package/src/adapters/tasks-adapter.ts +3 -0
- package/src/adapters/types.ts +1 -0
- package/src/agent/__tests__/agent-manager-topology.test.ts +73 -0
- package/src/agent/__tests__/agent-manager-v2.test.ts +66 -0
- package/src/agent/__tests__/agent-store.test.ts +52 -0
- package/src/agent/__tests__/task-ref-resolution.test.ts +231 -0
- package/src/agent/agent-manager-v2.ts +372 -59
- package/src/agent/agent-manager.ts +14 -0
- package/src/agent/agent-store.ts +24 -0
- package/src/agent/types.ts +16 -2
- package/src/boot-v2.ts +589 -35
- package/src/cli/acp.ts +4 -0
- package/src/cli/index.ts +61 -0
- package/src/cognitive/macro-agent-backend.ts +45 -29
- package/src/integrations/skilltree.ts +1 -0
- package/src/lifecycle/__tests__/cascade-consolidation.test.ts +240 -0
- package/src/lifecycle/cascade.ts +77 -2
- package/src/lifecycle/cleanup.ts +52 -3
- package/src/lifecycle/handlers-v2.ts +40 -3
- package/src/lifecycle/types.ts +12 -0
- package/src/map/__tests__/cascade-bridge.test.ts +229 -0
- package/src/map/__tests__/emit-event.test.ts +71 -0
- package/src/map/__tests__/lifecycle-bridge.test.ts +86 -10
- package/src/map/acp-bridge.ts +26 -3
- package/src/map/cascade-action-handler.ts +205 -0
- package/src/map/cascade-bridge.ts +339 -0
- package/src/map/coordination-handler.ts +13 -1
- package/src/map/lifecycle-bridge.ts +52 -17
- package/src/map/server.ts +225 -7
- package/src/map/sidecar.ts +48 -1
- package/src/map/types.ts +23 -0
- package/src/mcp/tools/done-v2.ts +9 -0
- package/src/teams/team-manager-v2.ts +37 -0
- package/src/teams/team-runtime-v2.ts +23 -3
- package/src/workspace/__tests__/{dataplane-adapter.test.ts → git-cascade-adapter.test.ts} +209 -14
- package/src/workspace/__tests__/land-dispatch.test.ts +214 -0
- package/src/workspace/__tests__/self-driving-yaml.test.ts +114 -0
- package/src/workspace/__tests__/shared-worktree-refcount.test.ts +154 -0
- package/src/workspace/__tests__/standalone-mode.test.ts +118 -0
- package/src/workspace/__tests__/workspace-manager-v3.test.ts +245 -0
- package/src/workspace/__tests__/yaml-schema.test.ts +210 -0
- package/src/workspace/config.ts +11 -11
- package/src/workspace/git-cascade-adapter.ts +1213 -0
- package/src/workspace/index.ts +11 -11
- package/src/workspace/landing/__tests__/strategies.test.ts +184 -0
- package/src/workspace/landing/direct-push.ts +91 -0
- package/src/workspace/landing/index.ts +40 -0
- package/src/workspace/landing/merge-to-parent.ts +229 -0
- package/src/workspace/landing/optimistic-push.ts +36 -0
- package/src/workspace/landing/queue-to-branch.ts +108 -0
- package/src/workspace/merge-queue/merge-queue.ts +10 -0
- package/src/workspace/merge-queue/types.ts +16 -2
- package/src/workspace/pool/__tests__/worktree-pool.integration.test.ts +5 -5
- package/src/workspace/pool/types.ts +1 -0
- package/src/workspace/pool/worktree-pool.ts +1 -0
- package/src/workspace/recovery/__tests__/auto-resolve-integration.test.ts +127 -0
- package/src/workspace/recovery/__tests__/spawn-resolver.test.ts +139 -0
- package/src/workspace/recovery/__tests__/strategies.test.ts +145 -0
- package/src/workspace/recovery/abandon.ts +51 -0
- package/src/workspace/recovery/auto-resolve.ts +119 -0
- package/src/workspace/recovery/defer.ts +23 -0
- package/src/workspace/recovery/escalate.ts +30 -0
- package/src/workspace/recovery/index.ts +58 -0
- package/src/workspace/recovery/spawn-resolver.ts +152 -0
- package/src/workspace/recovery/types.ts +54 -0
- package/src/workspace/topology/__tests__/yaml-driven.test.ts +345 -0
- package/src/workspace/topology/index.ts +18 -0
- package/src/workspace/topology/no-workspace.ts +39 -0
- package/src/workspace/topology/types.ts +116 -0
- package/src/workspace/topology/yaml-driven.ts +316 -0
- package/src/workspace/types-v3.ts +162 -0
- package/src/workspace/types.ts +211 -20
- package/src/workspace/workspace-manager.ts +533 -19
- package/src/workspace/yaml-schema.ts +216 -0
- package/dist/workspace/dataplane-adapter.d.ts +0 -260
- package/dist/workspace/dataplane-adapter.d.ts.map +0 -1
- package/dist/workspace/dataplane-adapter.js +0 -416
- package/dist/workspace/dataplane-adapter.js.map +0 -1
- package/src/workspace/dataplane-adapter.ts +0 -546
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* GitCascadeAdapter Tests
|
|
3
3
|
*
|
|
4
|
-
* Tests for the
|
|
4
|
+
* Tests for the git-cascade integration adapter.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
|
|
@@ -9,17 +9,17 @@ import * as fs from 'fs';
|
|
|
9
9
|
import * as path from 'path';
|
|
10
10
|
import * as os from 'os';
|
|
11
11
|
import { execSync } from 'child_process';
|
|
12
|
-
import {
|
|
12
|
+
import { GitCascadeAdapter, createGitCascadeAdapter } from '../git-cascade-adapter.js';
|
|
13
13
|
|
|
14
|
-
describe('
|
|
14
|
+
describe('GitCascadeAdapter', () => {
|
|
15
15
|
let tempDir: string;
|
|
16
16
|
let repoPath: string;
|
|
17
17
|
let dbPath: string;
|
|
18
|
-
let adapter:
|
|
18
|
+
let adapter: GitCascadeAdapter | null = null;
|
|
19
19
|
|
|
20
20
|
beforeEach(() => {
|
|
21
21
|
// Create temp directory
|
|
22
|
-
tempDir = fs.mkdtempSync(path.join(os.tmpdir(), '
|
|
22
|
+
tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'git-cascade-test-'));
|
|
23
23
|
repoPath = path.join(tempDir, 'repo');
|
|
24
24
|
dbPath = path.join(tempDir, 'test.db');
|
|
25
25
|
fs.mkdirSync(repoPath);
|
|
@@ -50,7 +50,7 @@ describe('DataplaneAdapter', () => {
|
|
|
50
50
|
|
|
51
51
|
describe('initialization', () => {
|
|
52
52
|
it('should create adapter with default config', () => {
|
|
53
|
-
adapter =
|
|
53
|
+
adapter = createGitCascadeAdapter({
|
|
54
54
|
enabled: true,
|
|
55
55
|
repoPath,
|
|
56
56
|
dbPath,
|
|
@@ -61,7 +61,7 @@ describe('DataplaneAdapter', () => {
|
|
|
61
61
|
});
|
|
62
62
|
|
|
63
63
|
it('should create adapter with custom table prefix', () => {
|
|
64
|
-
adapter =
|
|
64
|
+
adapter = createGitCascadeAdapter({
|
|
65
65
|
enabled: true,
|
|
66
66
|
repoPath,
|
|
67
67
|
dbPath,
|
|
@@ -73,7 +73,7 @@ describe('DataplaneAdapter', () => {
|
|
|
73
73
|
|
|
74
74
|
it('should use provided database path', () => {
|
|
75
75
|
const dbPath = path.join(tempDir, 'custom.db');
|
|
76
|
-
adapter =
|
|
76
|
+
adapter = createGitCascadeAdapter({
|
|
77
77
|
enabled: true,
|
|
78
78
|
repoPath,
|
|
79
79
|
dbPath,
|
|
@@ -85,7 +85,7 @@ describe('DataplaneAdapter', () => {
|
|
|
85
85
|
|
|
86
86
|
describe('stream operations', () => {
|
|
87
87
|
beforeEach(() => {
|
|
88
|
-
adapter =
|
|
88
|
+
adapter = createGitCascadeAdapter({
|
|
89
89
|
enabled: true,
|
|
90
90
|
repoPath,
|
|
91
91
|
dbPath,
|
|
@@ -138,7 +138,7 @@ describe('DataplaneAdapter', () => {
|
|
|
138
138
|
let streamId: string;
|
|
139
139
|
|
|
140
140
|
beforeEach(() => {
|
|
141
|
-
adapter =
|
|
141
|
+
adapter = createGitCascadeAdapter({
|
|
142
142
|
enabled: true,
|
|
143
143
|
repoPath,
|
|
144
144
|
dbPath,
|
|
@@ -197,7 +197,7 @@ describe('DataplaneAdapter', () => {
|
|
|
197
197
|
|
|
198
198
|
describe('health check', () => {
|
|
199
199
|
beforeEach(() => {
|
|
200
|
-
adapter =
|
|
200
|
+
adapter = createGitCascadeAdapter({
|
|
201
201
|
enabled: true,
|
|
202
202
|
repoPath,
|
|
203
203
|
dbPath,
|
|
@@ -217,7 +217,7 @@ describe('DataplaneAdapter', () => {
|
|
|
217
217
|
|
|
218
218
|
describe('event subscription', () => {
|
|
219
219
|
beforeEach(() => {
|
|
220
|
-
adapter =
|
|
220
|
+
adapter = createGitCascadeAdapter({
|
|
221
221
|
enabled: true,
|
|
222
222
|
repoPath,
|
|
223
223
|
dbPath,
|
|
@@ -252,7 +252,7 @@ describe('DataplaneAdapter', () => {
|
|
|
252
252
|
let worktreePath: string;
|
|
253
253
|
|
|
254
254
|
beforeEach(() => {
|
|
255
|
-
adapter =
|
|
255
|
+
adapter = createGitCascadeAdapter({
|
|
256
256
|
enabled: true,
|
|
257
257
|
repoPath,
|
|
258
258
|
dbPath,
|
|
@@ -365,4 +365,199 @@ describe('DataplaneAdapter', () => {
|
|
|
365
365
|
expect(checkpoints.length).toBeGreaterThanOrEqual(2);
|
|
366
366
|
});
|
|
367
367
|
});
|
|
368
|
+
|
|
369
|
+
// ───────────────────────────────────────────────────────────────────
|
|
370
|
+
// Phase 0 additive expansion — new surface coverage
|
|
371
|
+
// ───────────────────────────────────────────────────────────────────
|
|
372
|
+
|
|
373
|
+
describe('stream stacking (Phase 0)', () => {
|
|
374
|
+
beforeEach(() => {
|
|
375
|
+
adapter = createGitCascadeAdapter({
|
|
376
|
+
enabled: true,
|
|
377
|
+
repoPath,
|
|
378
|
+
dbPath,
|
|
379
|
+
skipRecovery: true,
|
|
380
|
+
});
|
|
381
|
+
});
|
|
382
|
+
|
|
383
|
+
it('forks a child stream off a parent', () => {
|
|
384
|
+
const parent = adapter!.createStream({ name: 'parent', agentId: 'agent-1' });
|
|
385
|
+
const child = adapter!.forkStream({
|
|
386
|
+
parentStreamId: parent,
|
|
387
|
+
name: 'child',
|
|
388
|
+
agentId: 'agent-2',
|
|
389
|
+
});
|
|
390
|
+
|
|
391
|
+
const childStream = adapter!.getStream(child);
|
|
392
|
+
expect(childStream?.parentStream).toBe(parent);
|
|
393
|
+
});
|
|
394
|
+
|
|
395
|
+
it('emits stream:forked on forkStream', () => {
|
|
396
|
+
const parent = adapter!.createStream({ name: 'parent', agentId: 'agent-1' });
|
|
397
|
+
const events: Array<{ type: string }> = [];
|
|
398
|
+
adapter!.onEvent((e) => events.push(e));
|
|
399
|
+
|
|
400
|
+
adapter!.forkStream({ parentStreamId: parent, name: 'child', agentId: 'agent-2' });
|
|
401
|
+
|
|
402
|
+
expect(events.some((e) => e.type === 'stream:forked')).toBe(true);
|
|
403
|
+
});
|
|
404
|
+
|
|
405
|
+
it('pauses and resumes a stream', () => {
|
|
406
|
+
const streamId = adapter!.createStream({ name: 'feat', agentId: 'a' });
|
|
407
|
+
adapter!.pauseStream(streamId, 'manual pause');
|
|
408
|
+
expect(adapter!.getStream(streamId)?.status).toBe('paused');
|
|
409
|
+
adapter!.resumeStream(streamId);
|
|
410
|
+
expect(adapter!.getStream(streamId)?.status).toBe('active');
|
|
411
|
+
});
|
|
412
|
+
|
|
413
|
+
it('tracks stream dependencies', () => {
|
|
414
|
+
const a = adapter!.createStream({ name: 'a', agentId: 'agent-1' });
|
|
415
|
+
const b = adapter!.createStream({ name: 'b', agentId: 'agent-1' });
|
|
416
|
+
adapter!.addDependency(b, a); // b depends on a
|
|
417
|
+
|
|
418
|
+
expect(adapter!.getDependencies(b)).toContain(a);
|
|
419
|
+
expect(adapter!.getDependents(a)).toContain(b);
|
|
420
|
+
|
|
421
|
+
adapter!.removeDependency(b, a);
|
|
422
|
+
expect(adapter!.getDependencies(b)).not.toContain(a);
|
|
423
|
+
});
|
|
424
|
+
|
|
425
|
+
it('returns stream hierarchy as tree', () => {
|
|
426
|
+
const root = adapter!.createStream({ name: 'root', agentId: 'a' });
|
|
427
|
+
const child = adapter!.forkStream({ parentStreamId: root, name: 'child', agentId: 'a' });
|
|
428
|
+
|
|
429
|
+
const hier = adapter!.getStreamHierarchy(root);
|
|
430
|
+
// Single root → StreamNode
|
|
431
|
+
const node = Array.isArray(hier) ? hier[0] : hier;
|
|
432
|
+
expect(node.stream.id).toBe(root);
|
|
433
|
+
expect(node.children.some((c) => c.stream.id === child)).toBe(true);
|
|
434
|
+
});
|
|
435
|
+
});
|
|
436
|
+
|
|
437
|
+
describe('merge queue (Phase 0, delegates to git-cascade built-in)', () => {
|
|
438
|
+
let streamId: string;
|
|
439
|
+
beforeEach(() => {
|
|
440
|
+
adapter = createGitCascadeAdapter({
|
|
441
|
+
enabled: true,
|
|
442
|
+
repoPath,
|
|
443
|
+
dbPath,
|
|
444
|
+
skipRecovery: true,
|
|
445
|
+
});
|
|
446
|
+
streamId = adapter!.createStream({ name: 'feat-q', agentId: 'agent-1' });
|
|
447
|
+
});
|
|
448
|
+
|
|
449
|
+
it('adds a stream to the queue and assigns a position', () => {
|
|
450
|
+
const entryId = adapter!.addToMergeQueue({ streamId, targetBranch: 'main', agentId: 'agent-1' });
|
|
451
|
+
expect(entryId).toBeDefined();
|
|
452
|
+
|
|
453
|
+
const pos = adapter!.getMergeQueuePosition(streamId, 'main');
|
|
454
|
+
expect(pos).not.toBeNull();
|
|
455
|
+
|
|
456
|
+
const entry = adapter!.getMergeQueueEntry(entryId);
|
|
457
|
+
expect(entry?.streamId).toBe(streamId);
|
|
458
|
+
});
|
|
459
|
+
|
|
460
|
+
it('lists entries filtered by status', () => {
|
|
461
|
+
adapter!.addToMergeQueue({ streamId, targetBranch: 'main', agentId: 'agent-1' });
|
|
462
|
+
const pending = adapter!.listMergeQueue({ targetBranch: 'main', status: 'pending' });
|
|
463
|
+
expect(pending.length).toBeGreaterThan(0);
|
|
464
|
+
});
|
|
465
|
+
|
|
466
|
+
it('marks an entry ready and cancels it', () => {
|
|
467
|
+
const entryId = adapter!.addToMergeQueue({ streamId, targetBranch: 'main', agentId: 'agent-1' });
|
|
468
|
+
adapter!.markMergeQueueReady(entryId);
|
|
469
|
+
expect(adapter!.getMergeQueueEntry(entryId)?.status).toBe('ready');
|
|
470
|
+
|
|
471
|
+
adapter!.cancelMergeQueueEntry(entryId);
|
|
472
|
+
expect(adapter!.getMergeQueueEntry(entryId)?.status).toBe('cancelled');
|
|
473
|
+
});
|
|
474
|
+
|
|
475
|
+
it('emits mergeQueue:added / :ready / :cancelled events', () => {
|
|
476
|
+
const seen: string[] = [];
|
|
477
|
+
adapter!.onEvent((e) => seen.push(e.type));
|
|
478
|
+
|
|
479
|
+
const entryId = adapter!.addToMergeQueue({ streamId, targetBranch: 'main', agentId: 'agent-1' });
|
|
480
|
+
adapter!.markMergeQueueReady(entryId);
|
|
481
|
+
adapter!.cancelMergeQueueEntry(entryId);
|
|
482
|
+
|
|
483
|
+
expect(seen).toContain('mergeQueue:added');
|
|
484
|
+
expect(seen).toContain('mergeQueue:ready');
|
|
485
|
+
expect(seen).toContain('mergeQueue:cancelled');
|
|
486
|
+
});
|
|
487
|
+
});
|
|
488
|
+
|
|
489
|
+
describe('conflicts (Phase 0)', () => {
|
|
490
|
+
let streamId: string;
|
|
491
|
+
beforeEach(() => {
|
|
492
|
+
adapter = createGitCascadeAdapter({
|
|
493
|
+
enabled: true,
|
|
494
|
+
repoPath,
|
|
495
|
+
dbPath,
|
|
496
|
+
skipRecovery: true,
|
|
497
|
+
});
|
|
498
|
+
streamId = adapter!.createStream({ name: 'feat-c', agentId: 'agent-1' });
|
|
499
|
+
});
|
|
500
|
+
|
|
501
|
+
const dummyCommit = '0000000000000000000000000000000000000000';
|
|
502
|
+
|
|
503
|
+
it('creates and retrieves a conflict record', () => {
|
|
504
|
+
const id = adapter!.createConflict({
|
|
505
|
+
streamId,
|
|
506
|
+
conflictingCommit: dummyCommit,
|
|
507
|
+
targetCommit: dummyCommit,
|
|
508
|
+
conflictedFiles: ['a.ts', 'b.ts'],
|
|
509
|
+
});
|
|
510
|
+
const record = adapter!.getConflict(id);
|
|
511
|
+
expect(record?.streamId).toBe(streamId);
|
|
512
|
+
expect(record?.conflictedFiles).toEqual(['a.ts', 'b.ts']);
|
|
513
|
+
});
|
|
514
|
+
|
|
515
|
+
it('gets the active conflict for a stream', () => {
|
|
516
|
+
adapter!.createConflict({
|
|
517
|
+
streamId,
|
|
518
|
+
conflictingCommit: dummyCommit,
|
|
519
|
+
targetCommit: dummyCommit,
|
|
520
|
+
conflictedFiles: ['x.ts'],
|
|
521
|
+
});
|
|
522
|
+
const record = adapter!.getConflictForStream(streamId);
|
|
523
|
+
expect(record).not.toBeNull();
|
|
524
|
+
});
|
|
525
|
+
|
|
526
|
+
it('emits conflict:created event', () => {
|
|
527
|
+
const events: Array<{ type: string }> = [];
|
|
528
|
+
adapter!.onEvent((e) => events.push(e));
|
|
529
|
+
adapter!.createConflict({
|
|
530
|
+
streamId,
|
|
531
|
+
conflictingCommit: dummyCommit,
|
|
532
|
+
targetCommit: dummyCommit,
|
|
533
|
+
conflictedFiles: ['x.ts'],
|
|
534
|
+
});
|
|
535
|
+
expect(events.some((e) => e.type === 'conflict:created')).toBe(true);
|
|
536
|
+
});
|
|
537
|
+
});
|
|
538
|
+
|
|
539
|
+
describe('reconcile (Phase 0)', () => {
|
|
540
|
+
beforeEach(() => {
|
|
541
|
+
adapter = createGitCascadeAdapter({
|
|
542
|
+
enabled: true,
|
|
543
|
+
repoPath,
|
|
544
|
+
dbPath,
|
|
545
|
+
skipRecovery: true,
|
|
546
|
+
});
|
|
547
|
+
});
|
|
548
|
+
|
|
549
|
+
it('checkStreamSync reports in-sync for a just-created stream', () => {
|
|
550
|
+
const streamId = adapter!.createStream({ name: 'feat-s', agentId: 'a' });
|
|
551
|
+
const status = adapter!.checkStreamSync(streamId);
|
|
552
|
+
expect(status).toBeDefined();
|
|
553
|
+
// Fresh stream should be in sync (no divergence yet)
|
|
554
|
+
expect(status.inSync).toBe(true);
|
|
555
|
+
});
|
|
556
|
+
|
|
557
|
+
it('reconcile runs without error on a healthy db', () => {
|
|
558
|
+
adapter!.createStream({ name: 'feat-r', agentId: 'a' });
|
|
559
|
+
const result = adapter!.reconcile({ dryRun: true });
|
|
560
|
+
expect(result).toBeDefined();
|
|
561
|
+
});
|
|
562
|
+
});
|
|
368
563
|
});
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WorkspaceManager.land() dispatcher tests (A2 follow-up).
|
|
3
|
+
*
|
|
4
|
+
* Closes the gap where `registerLandingStrategy` existed but no caller
|
|
5
|
+
* invoked `.land(ctx)` at `done()` time. Verifies the dispatcher:
|
|
6
|
+
* - resolves strategy by name (internal or YAML form)
|
|
7
|
+
* - respects `strategyName: 'none'` (short-circuits to success)
|
|
8
|
+
* - errors out on unknown names
|
|
9
|
+
* - fills in `ctx.workspaceManager` before invoking the strategy
|
|
10
|
+
* - rejects when `canLand` returns false
|
|
11
|
+
*
|
|
12
|
+
* Unit-only — doesn't spin up git. The end-to-end path (strategy fires
|
|
13
|
+
* tracker events → hub projects) is covered by OpenHive's
|
|
14
|
+
* live-emission-e2e.test.ts.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import { describe, it, expect, vi } from 'vitest';
|
|
18
|
+
import type { GitCascadeAdapter } from '../git-cascade-adapter.js';
|
|
19
|
+
import { DefaultWorkspaceManager, resolveLandingStrategyName } from '../workspace-manager.js';
|
|
20
|
+
import type { LandingStrategy, LandingContext } from '../types-v3.js';
|
|
21
|
+
|
|
22
|
+
// A no-op adapter stub that satisfies the DefaultWorkspaceManager constructor
|
|
23
|
+
// without touching git. Every method the dispatcher path might hit throws so
|
|
24
|
+
// accidental delegation is loud.
|
|
25
|
+
function stubAdapter(): GitCascadeAdapter {
|
|
26
|
+
const throwing = (name: string) => () => {
|
|
27
|
+
throw new Error(`stub adapter: ${name} should not be called in this test`);
|
|
28
|
+
};
|
|
29
|
+
return {
|
|
30
|
+
close: vi.fn(),
|
|
31
|
+
reconcile: throwing('reconcile'),
|
|
32
|
+
listWorktrees: vi.fn(() => []),
|
|
33
|
+
getWorktree: vi.fn(() => null),
|
|
34
|
+
} as unknown as GitCascadeAdapter;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function makeTestStrategy(
|
|
38
|
+
name: string,
|
|
39
|
+
impl: (ctx: LandingContext) => ReturnType<LandingStrategy['land']>,
|
|
40
|
+
canLand?: (ctx: LandingContext) => boolean,
|
|
41
|
+
): LandingStrategy {
|
|
42
|
+
return { name, land: impl, canLand };
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
describe('WorkspaceManager.land() dispatcher', () => {
|
|
46
|
+
it('dispatches to an internal-named strategy', async () => {
|
|
47
|
+
const wm = new DefaultWorkspaceManager(stubAdapter());
|
|
48
|
+
const land = vi.fn(async () => ({ success: true, newHead: 'abc' } as never));
|
|
49
|
+
wm.registerLandingStrategy(makeTestStrategy('merge-to-parent', land));
|
|
50
|
+
|
|
51
|
+
const result = await wm.land({
|
|
52
|
+
agentId: 'a1',
|
|
53
|
+
streamId: 's1',
|
|
54
|
+
sourceWorktree: '/tmp/wt',
|
|
55
|
+
strategyName: 'merge-to-parent',
|
|
56
|
+
workspaceManager: wm,
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
expect(result.success).toBe(true);
|
|
60
|
+
expect(land).toHaveBeenCalledOnce();
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
it('accepts YAML-style strategy names and maps them', async () => {
|
|
64
|
+
const wm = new DefaultWorkspaceManager(stubAdapter());
|
|
65
|
+
const land = vi.fn(async () => ({ success: true } as never));
|
|
66
|
+
wm.registerLandingStrategy(makeTestStrategy('queue-to-branch', land));
|
|
67
|
+
|
|
68
|
+
await wm.land({
|
|
69
|
+
agentId: 'a1',
|
|
70
|
+
streamId: 's1',
|
|
71
|
+
sourceWorktree: '/tmp/wt',
|
|
72
|
+
strategyName: 'queue_to_branch', // YAML form
|
|
73
|
+
workspaceManager: wm,
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
expect(land).toHaveBeenCalledOnce();
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
it('defaults to merge-to-parent when strategyName is unset', async () => {
|
|
80
|
+
const wm = new DefaultWorkspaceManager(stubAdapter());
|
|
81
|
+
const land = vi.fn(async () => ({ success: true } as never));
|
|
82
|
+
wm.registerLandingStrategy(makeTestStrategy('merge-to-parent', land));
|
|
83
|
+
|
|
84
|
+
await wm.land({
|
|
85
|
+
agentId: 'a1',
|
|
86
|
+
streamId: 's1',
|
|
87
|
+
sourceWorktree: '/tmp/wt',
|
|
88
|
+
workspaceManager: wm,
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
expect(land).toHaveBeenCalledOnce();
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
it('short-circuits on strategyName: "none" without invoking any strategy', async () => {
|
|
95
|
+
const wm = new DefaultWorkspaceManager(stubAdapter());
|
|
96
|
+
const land = vi.fn(async () => ({ success: false } as never));
|
|
97
|
+
wm.registerLandingStrategy(makeTestStrategy('merge-to-parent', land));
|
|
98
|
+
|
|
99
|
+
const result = await wm.land({
|
|
100
|
+
agentId: 'a1',
|
|
101
|
+
streamId: 's1',
|
|
102
|
+
sourceWorktree: '/tmp/wt',
|
|
103
|
+
strategyName: 'none',
|
|
104
|
+
workspaceManager: wm,
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
expect(result.success).toBe(true);
|
|
108
|
+
expect(land).not.toHaveBeenCalled();
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
it('throws on an unknown strategy name', async () => {
|
|
112
|
+
const wm = new DefaultWorkspaceManager(stubAdapter());
|
|
113
|
+
await expect(
|
|
114
|
+
wm.land({
|
|
115
|
+
agentId: 'a1',
|
|
116
|
+
streamId: 's1',
|
|
117
|
+
sourceWorktree: '/tmp/wt',
|
|
118
|
+
strategyName: 'nonexistent-strategy',
|
|
119
|
+
workspaceManager: wm,
|
|
120
|
+
}),
|
|
121
|
+
).rejects.toThrow(/No landing strategy registered/);
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
it('fills ctx.workspaceManager with the dispatcher instance', async () => {
|
|
125
|
+
const wm = new DefaultWorkspaceManager(stubAdapter());
|
|
126
|
+
let seenManager: unknown = null;
|
|
127
|
+
wm.registerLandingStrategy(
|
|
128
|
+
makeTestStrategy('merge-to-parent', async (ctx) => {
|
|
129
|
+
seenManager = ctx.workspaceManager;
|
|
130
|
+
return { success: true } as never;
|
|
131
|
+
}),
|
|
132
|
+
);
|
|
133
|
+
|
|
134
|
+
await wm.land({
|
|
135
|
+
agentId: 'a1',
|
|
136
|
+
streamId: 's1',
|
|
137
|
+
sourceWorktree: '/tmp/wt',
|
|
138
|
+
// Deliberately pass a non-matching value to prove the dispatcher overrides.
|
|
139
|
+
workspaceManager: { bogus: true },
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
expect(seenManager).toBe(wm);
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
it('rejects when strategy.canLand(ctx) returns false', async () => {
|
|
146
|
+
const wm = new DefaultWorkspaceManager(stubAdapter());
|
|
147
|
+
wm.registerLandingStrategy(
|
|
148
|
+
makeTestStrategy(
|
|
149
|
+
'merge-to-parent',
|
|
150
|
+
async () => ({ success: true } as never),
|
|
151
|
+
() => false,
|
|
152
|
+
),
|
|
153
|
+
);
|
|
154
|
+
|
|
155
|
+
await expect(
|
|
156
|
+
wm.land({
|
|
157
|
+
agentId: 'a1',
|
|
158
|
+
streamId: 's1',
|
|
159
|
+
sourceWorktree: '/tmp/wt',
|
|
160
|
+
workspaceManager: wm,
|
|
161
|
+
}),
|
|
162
|
+
).rejects.toThrow(/rejected context/);
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
it('propagates strategy return values including conflicts', async () => {
|
|
166
|
+
const wm = new DefaultWorkspaceManager(stubAdapter());
|
|
167
|
+
wm.registerLandingStrategy(
|
|
168
|
+
makeTestStrategy(
|
|
169
|
+
'merge-to-parent',
|
|
170
|
+
async () => ({
|
|
171
|
+
success: false,
|
|
172
|
+
conflicts: ['foo.ts'],
|
|
173
|
+
} as never),
|
|
174
|
+
),
|
|
175
|
+
);
|
|
176
|
+
|
|
177
|
+
const result = await wm.land({
|
|
178
|
+
agentId: 'a1',
|
|
179
|
+
streamId: 's1',
|
|
180
|
+
sourceWorktree: '/tmp/wt',
|
|
181
|
+
workspaceManager: wm,
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
expect(result.success).toBe(false);
|
|
185
|
+
expect((result as { conflicts?: string[] }).conflicts).toEqual(['foo.ts']);
|
|
186
|
+
});
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
describe('resolveLandingStrategyName()', () => {
|
|
190
|
+
it('maps every YAML name to its internal counterpart', () => {
|
|
191
|
+
expect(resolveLandingStrategyName('merge_to_parent_stream')).toBe('merge-to-parent');
|
|
192
|
+
expect(resolveLandingStrategyName('queue_to_branch')).toBe('queue-to-branch');
|
|
193
|
+
expect(resolveLandingStrategyName('direct_push')).toBe('direct-push');
|
|
194
|
+
expect(resolveLandingStrategyName('optimistic_push')).toBe('optimistic-push');
|
|
195
|
+
expect(resolveLandingStrategyName('cherry_pick_stack')).toBe('cherry-pick-stack');
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
it('passes internal names through unchanged', () => {
|
|
199
|
+
expect(resolveLandingStrategyName('merge-to-parent')).toBe('merge-to-parent');
|
|
200
|
+
expect(resolveLandingStrategyName('queue-to-branch')).toBe('queue-to-branch');
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
it('passes unknown names through (lets the dispatcher throw with a useful message)', () => {
|
|
204
|
+
expect(resolveLandingStrategyName('my-custom-strategy')).toBe('my-custom-strategy');
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
it('defaults to merge-to-parent on undefined', () => {
|
|
208
|
+
expect(resolveLandingStrategyName(undefined)).toBe('merge-to-parent');
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
it('preserves "none" so the dispatcher can short-circuit', () => {
|
|
212
|
+
expect(resolveLandingStrategyName('none')).toBe('none');
|
|
213
|
+
});
|
|
214
|
+
});
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Regression test: self-driving team.yaml parses cleanly under the V3
|
|
3
|
+
* workspace schema.
|
|
4
|
+
*
|
|
5
|
+
* Guards against YAML drift — if someone edits the team config in a way
|
|
6
|
+
* that breaks schema validation, this test fails loudly.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { describe, it, expect } from 'vitest';
|
|
10
|
+
import * as fs from 'fs';
|
|
11
|
+
import * as path from 'path';
|
|
12
|
+
import * as yaml from 'js-yaml';
|
|
13
|
+
import {
|
|
14
|
+
parseTeamWorkspaceConfig,
|
|
15
|
+
extractWorkspaceConfig,
|
|
16
|
+
} from '../yaml-schema.js';
|
|
17
|
+
import { YamlDrivenTopology } from '../topology/yaml-driven.js';
|
|
18
|
+
import type { WorkspaceManager } from '../types.js';
|
|
19
|
+
import { vi } from 'vitest';
|
|
20
|
+
|
|
21
|
+
describe('self-driving team YAML (V3 migration)', () => {
|
|
22
|
+
const yamlPath = path.join(
|
|
23
|
+
process.cwd(),
|
|
24
|
+
'.multiagent/teams/self-driving/team.yaml'
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
it('exists on disk', () => {
|
|
28
|
+
expect(fs.existsSync(yamlPath)).toBe(true);
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it('parses and validates against TeamWorkspaceConfigSchema', () => {
|
|
32
|
+
const raw = fs.readFileSync(yamlPath, 'utf-8');
|
|
33
|
+
const manifest = yaml.load(raw) as { macro_agent?: Record<string, unknown> };
|
|
34
|
+
const config = extractWorkspaceConfig(manifest);
|
|
35
|
+
|
|
36
|
+
expect(config).not.toBeNull();
|
|
37
|
+
expect(config!.roles.planner).toBeDefined();
|
|
38
|
+
expect(config!.roles.grinder).toBeDefined();
|
|
39
|
+
expect(config!.roles.judge).toBeDefined();
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it('planner role maps to attach_to_team_root', () => {
|
|
43
|
+
const raw = fs.readFileSync(yamlPath, 'utf-8');
|
|
44
|
+
const manifest = yaml.load(raw) as { macro_agent?: Record<string, unknown> };
|
|
45
|
+
const config = extractWorkspaceConfig(manifest)!;
|
|
46
|
+
|
|
47
|
+
expect(config.roles.planner.workspace).toBe('attach_to_team_root');
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it('grinder forks from team root with direct_push landing', () => {
|
|
51
|
+
const raw = fs.readFileSync(yamlPath, 'utf-8');
|
|
52
|
+
const manifest = yaml.load(raw) as { macro_agent?: Record<string, unknown> };
|
|
53
|
+
const config = extractWorkspaceConfig(manifest)!;
|
|
54
|
+
|
|
55
|
+
expect(config.roles.grinder.workspace).toBe('new_stream');
|
|
56
|
+
expect(config.roles.grinder.stream_lineage).toBe('fork_from_team_root');
|
|
57
|
+
expect(config.roles.grinder.landing).toBe('direct_push');
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
it('judge has no workspace (read-only role)', () => {
|
|
61
|
+
const raw = fs.readFileSync(yamlPath, 'utf-8');
|
|
62
|
+
const manifest = yaml.load(raw) as { macro_agent?: Record<string, unknown> };
|
|
63
|
+
const config = extractWorkspaceConfig(manifest)!;
|
|
64
|
+
|
|
65
|
+
expect(config.roles.judge.workspace).toBe('none');
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
it('YamlDrivenTopology compiles the config into valid spawn decisions', async () => {
|
|
69
|
+
const raw = fs.readFileSync(yamlPath, 'utf-8');
|
|
70
|
+
const manifest = yaml.load(raw) as { macro_agent?: Record<string, unknown> };
|
|
71
|
+
const config = extractWorkspaceConfig(manifest)!;
|
|
72
|
+
|
|
73
|
+
const topology = new YamlDrivenTopology(config);
|
|
74
|
+
const mockWs = {
|
|
75
|
+
createStreamV3: vi.fn(() => 'team-stream-1'),
|
|
76
|
+
} as unknown as WorkspaceManager;
|
|
77
|
+
|
|
78
|
+
// Team start should create a team root (planner attaches to it)
|
|
79
|
+
await topology.onTeamStart({
|
|
80
|
+
teamName: 'self-driving',
|
|
81
|
+
teamInstanceId: 'sd-1',
|
|
82
|
+
workspaceConfig: config,
|
|
83
|
+
workspaceManager: mockWs,
|
|
84
|
+
});
|
|
85
|
+
expect(mockWs.createStreamV3).toHaveBeenCalled();
|
|
86
|
+
|
|
87
|
+
// Planner → attach-to-stream
|
|
88
|
+
const plannerDecision = await topology.onAgentSpawn({
|
|
89
|
+
agentId: 'agent-planner',
|
|
90
|
+
role: 'planner',
|
|
91
|
+
workspaceManager: mockWs,
|
|
92
|
+
});
|
|
93
|
+
expect(plannerDecision.kind).toBe('attach-to-stream');
|
|
94
|
+
|
|
95
|
+
// Grinder → new-stream (forked from team root)
|
|
96
|
+
const grinderDecision = await topology.onAgentSpawn({
|
|
97
|
+
agentId: 'agent-grinder-1',
|
|
98
|
+
role: 'grinder',
|
|
99
|
+
workspaceManager: mockWs,
|
|
100
|
+
});
|
|
101
|
+
expect(grinderDecision.kind).toBe('new-stream');
|
|
102
|
+
if (grinderDecision.kind === 'new-stream') {
|
|
103
|
+
expect(grinderDecision.streamSpec.parent).toBe('team-stream-1');
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// Judge → none
|
|
107
|
+
const judgeDecision = await topology.onAgentSpawn({
|
|
108
|
+
agentId: 'agent-judge',
|
|
109
|
+
role: 'judge',
|
|
110
|
+
workspaceManager: mockWs,
|
|
111
|
+
});
|
|
112
|
+
expect(judgeDecision.kind).toBe('none');
|
|
113
|
+
});
|
|
114
|
+
});
|