@moretea-labs/forge 1.5.0-rc.1 → 1.5.0
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/AGENTS.md +9 -11
- package/CHANGELOG.md +19 -0
- package/CLAUDE.md +8 -10
- package/DESIGN.md +278 -0
- package/README.md +70 -90
- package/README.zh-CN.md +50 -55
- package/SKILL.md +8 -11
- package/THIRD_PARTY_NOTICES.md +9 -3
- package/assets/branding/README.md +4 -2
- package/assets/hooks/lib/workflow-state.sh +19 -18
- package/assets/hooks/post-edit-guard.sh +6 -75
- package/assets/hooks/prompt-guard.sh +24 -12
- package/assets/hooks/session-start-context.sh +17 -17
- package/assets/hooks/stop-orchestrator.sh +2 -2
- package/assets/partials/04-project-structure.partial.md +6 -6
- package/assets/partials/05-workflow.partial.md +6 -6
- package/assets/partials/07-footer.partial.md +1 -1
- package/assets/partials/08-orchestration.partial.md +2 -2
- package/assets/partials-agents/02-operating-mode.partial.md +5 -5
- package/assets/partials-agents/03-orchestration.partial.md +3 -3
- package/assets/partials-agents/04-task-protocol.partial.md +3 -3
- package/assets/partials-agents/08-deep-docs.partial.md +1 -1
- package/assets/reference-configs/agentic-development-flow.md +49 -86
- package/assets/reference-configs/external-tooling.md +21 -61
- package/assets/reference-configs/handoff-protocol.md +25 -20
- package/assets/reference-configs/harness-overview.md +8 -8
- package/assets/templates/helpers/archive-workflow.sh +0 -1
- package/assets/templates/helpers/capture-plan.sh +3 -3
- package/assets/templates/helpers/check-task-workflow.sh +2 -2
- package/assets/templates/helpers/codex-handoff-resume.sh +5 -5
- package/assets/templates/helpers/ensure-task-workflow.sh +37 -35
- package/assets/templates/helpers/new-plan.sh +1 -1
- package/assets/templates/helpers/plan-to-todo.sh +2 -2
- package/assets/templates/helpers/prepare-codex-handoff.sh +2 -2
- package/assets/templates/helpers/prepare-handoff.sh +9 -9
- package/assets/templates/helpers/refresh-current-status.sh +2 -2
- package/assets/templates/helpers/ship-worktrees.sh +1 -1
- package/assets/templates/helpers/sprint-backlog.sh +1 -1
- package/assets/templates/helpers/verify-sprint.sh +7 -7
- package/assets/templates/helpers/workstream-sync.sh +1 -1
- package/assets/templates/plan.template.md +1 -1
- package/assets/workflow-contract.v1.json +6 -3
- package/docs/architecture/current/README.md +10 -9
- package/docs/architecture/current/approved-target-architecture.zh-CN.md +2 -2
- package/docs/architecture/current/architecture-invariants.md +2 -2
- package/docs/architecture/current/automation-and-schedule-engine.md +15 -15
- package/docs/architecture/current/codegraph-context-provider.md +2 -2
- package/docs/architecture/current/control-plane-authority-inventory.md +12 -0
- package/docs/architecture/current/dispatch-and-agent-strategy.md +11 -11
- package/docs/architecture/current/entity-model.md +0 -27
- package/docs/architecture/current/failure-recovery.md +0 -24
- package/docs/architecture/current/governance.md +1 -1
- package/docs/architecture/current/implementation-status.md +1 -1
- package/docs/architecture/current/legacy-governance.md +58 -0
- package/docs/architecture/current/multi-repository-execution.md +1 -1
- package/docs/architecture/current/peer-supercontroller-runtime.md +1 -1
- package/docs/architecture/current/personal-assistant-plugin-baseline.md +4 -5
- package/docs/architecture/current/scheduler-and-resource-claims.md +0 -10
- package/docs/architecture/current/target-requirements-traceability.md +2 -2
- package/docs/architecture/current/thin-harness-governance-policy.md +1 -1
- package/docs/architecture/current/thin-harness-v1.md +9 -11
- package/docs/architecture/domains/runtime-harness.md +1 -1
- package/docs/forge-autonomous-goal-loop.md +3 -1
- package/docs/forge-chatgpt-mcp-setup.md +51 -184
- package/docs/images/forge-banner-cn.svg +26 -1
- package/docs/images/forge-banner.svg +26 -1
- package/docs/operations/features.md +1 -1
- package/docs/operations/homebrew.md +3 -3
- package/docs/operations/mcp-tool-exposure.md +5 -5
- package/docs/operations/platform-support.md +45 -37
- package/docs/operations/platform-support.zh-CN.md +40 -38
- package/docs/operations/releasing.md +3 -3
- package/docs/operations/releasing.zh-CN.md +3 -3
- package/docs/operations/troubleshooting.md +11 -6
- package/docs/operations/troubleshooting.zh-CN.md +11 -6
- package/docs/public-usage-guide.md +28 -21
- package/docs/public-usage-guide.zh-CN.md +28 -21
- package/docs/tutorials/01-install-and-start.md +56 -35
- package/docs/tutorials/01-install-and-start.zh-CN.md +56 -35
- package/docs/tutorials/02-connect-chatgpt.md +112 -46
- package/docs/tutorials/02-connect-chatgpt.zh-CN.md +113 -45
- package/docs/wiki/Architecture.md +1 -1
- package/docs/wiki/Installation.md +2 -2
- package/docs/wiki/Quick-Start.md +1 -1
- package/docs/wiki/Work-Lifecycle.md +1 -1
- package/install.ps1 +4 -5
- package/install.sh +4 -6
- package/package.json +15 -5
- package/scripts/archive-workflow.sh +0 -1
- package/scripts/benchmark-thin-harness-mcp-e2e.ts +27 -14
- package/scripts/build-controller-ui.ts +28 -0
- package/scripts/capture-plan.sh +4 -4
- package/scripts/check-agent-tooling.sh +12 -1
- package/scripts/check-platform-support.mjs +2 -2
- package/scripts/check-public-docs.sh +16 -5
- package/scripts/check-release-readiness.sh +5 -11
- package/scripts/check-runtime-architecture.mjs +14 -22
- package/scripts/check-tarball-install-smoke.sh +3 -2
- package/scripts/check-task-workflow.sh +2 -2
- package/scripts/codex-handoff-resume.sh +5 -5
- package/scripts/create-project-dirs.sh +3 -3
- package/scripts/ensure-task-workflow.sh +45 -35
- package/scripts/init-project.sh +4 -4
- package/scripts/install-desktop-operator-registration.ts +2 -2
- package/scripts/lib/project-init-lib.sh +46 -44
- package/scripts/migrate-project-template.sh +7 -4
- package/scripts/new-plan.sh +1 -1
- package/scripts/plan-to-todo.sh +2 -2
- package/scripts/prepare-codex-handoff.sh +2 -2
- package/scripts/prepare-handoff.sh +9 -9
- package/scripts/refresh-current-status.sh +2 -2
- package/scripts/setup-plugins.sh +3 -3
- package/scripts/ship-worktrees.sh +1 -1
- package/scripts/sprint-backlog.sh +5 -5
- package/scripts/sync-codex-installed-copies.sh +2 -3
- package/scripts/verify-sprint.sh +7 -7
- package/scripts/workstream-sync.sh +1 -1
- package/src/cli/chatgpt-browser/bridge-extension.ts +1 -1
- package/src/cli/chatgpt-browser/bridge-provider.ts +29 -0
- package/src/cli/chatgpt-browser/file-policy.ts +3 -1
- package/src/cli/commands/chatgpt.ts +51 -0
- package/src/cli/commands/doctor.ts +1 -1
- package/src/cli/commands/init-hook.ts +211 -70
- package/src/cli/commands/init.ts +5 -6
- package/src/cli/commands/mcp.ts +29 -5
- package/src/cli/commands/runtime.ts +60 -8
- package/src/cli/commands/setup-profile.ts +441 -0
- package/src/cli/controller/check-runner.ts +20 -3
- package/src/cli/controller/codex-continuation.ts +4 -7
- package/src/cli/controller/context-pack.ts +118 -14
- package/src/cli/controller/operational-plan.ts +4 -4
- package/src/cli/controller/task-ledger.ts +10 -10
- package/src/cli/controller/work-mode.ts +6 -13
- package/src/cli/index.ts +14 -35
- package/src/cli/local-bridge/connector-freshness.ts +1 -1
- package/src/cli/local-bridge/console-automations.ts +160 -0
- package/src/cli/local-bridge/dashboard.ts +8 -1303
- package/src/cli/local-bridge/facade-api.ts +16 -7
- package/src/cli/local-bridge/frontend/src/App.tsx +10 -0
- package/src/cli/local-bridge/frontend/src/components/Button.tsx +1 -0
- package/src/cli/local-bridge/frontend/src/components/DetailPane.tsx +3 -0
- package/src/cli/local-bridge/frontend/src/components/SearchField.tsx +1 -0
- package/src/cli/local-bridge/frontend/src/components/SectionHeader.tsx +1 -0
- package/src/cli/local-bridge/frontend/src/components/Segmented.tsx +1 -0
- package/src/cli/local-bridge/frontend/src/components/StatusText.tsx +3 -0
- package/src/cli/local-bridge/frontend/src/design/icons.tsx +11 -0
- package/src/cli/local-bridge/frontend/src/design/tokens.css +8 -0
- package/src/cli/local-bridge/frontend/src/features/automations/AutomationsView.tsx +3 -0
- package/src/cli/local-bridge/frontend/src/features/capabilities/CapabilitiesView.tsx +4 -0
- package/src/cli/local-bridge/frontend/src/features/overview/OverviewView.tsx +3 -0
- package/src/cli/local-bridge/frontend/src/features/repositories/RepositoriesView.tsx +2 -0
- package/src/cli/local-bridge/frontend/src/features/settings/SettingsView.tsx +2 -0
- package/src/cli/local-bridge/frontend/src/features/system/SystemView.tsx +2 -0
- package/src/cli/local-bridge/frontend/src/features/work/WorkView.tsx +3 -0
- package/src/cli/local-bridge/frontend/src/lib/api.ts +23 -0
- package/src/cli/local-bridge/frontend/src/lib/format.ts +4 -0
- package/src/cli/local-bridge/frontend/src/lib/routes.ts +7 -0
- package/src/cli/local-bridge/frontend/src/main.tsx +1 -0
- package/src/cli/local-bridge/frontend/src/shell/AppShell.tsx +1 -0
- package/src/cli/local-bridge/frontend/src/shell/CommandBar.tsx +2 -0
- package/src/cli/local-bridge/frontend/src/shell/Sidebar.tsx +3 -0
- package/src/cli/local-bridge/frontend/src/styles.css +12 -0
- package/src/cli/local-bridge/frontend/src/types.ts +14 -0
- package/src/cli/local-bridge/frontend/src/vite-env.d.ts +1 -0
- package/src/cli/local-bridge/frontend/vite.config.ts +27 -0
- package/src/cli/local-bridge/server.ts +44 -0
- package/src/cli/local-bridge/ui-dist/app.css +1 -0
- package/src/cli/local-bridge/ui-dist/app.js +11094 -0
- package/src/cli/mcp/instructions.ts +3 -3
- package/src/cli/mcp/legacy-tool-service.ts +27 -23
- package/src/cli/mcp/multi-repository.ts +2 -0
- package/src/cli/mcp/policy.ts +7 -5
- package/src/cli/mcp/repository-tools.ts +53 -14
- package/src/cli/mcp/server.ts +5 -10
- package/src/cli/mcp/setup.ts +211 -275
- package/src/cli/mcp/tool-capability-cache.ts +1 -1
- package/src/cli/mcp/toolset-names.ts +1 -1
- package/src/cli/mcp/toolset.ts +0 -1
- package/src/cli/mcp/transports/http.ts +24 -4
- package/src/cli/repositories/branch-name-policy.ts +0 -7
- package/src/cli/repositories/controller-home.ts +110 -3
- package/src/cli/repositories/safe-patch.ts +1 -1
- package/src/cli/repositories/selected-path-actions.ts +26 -24
- package/src/core/adoption/gitignore-plan.ts +2 -3
- package/src/core/adoption/plan.ts +4 -1
- package/src/runtime/control-plane/execution/edit-validation-coordinator.ts +556 -0
- package/src/runtime/control-plane/execution/work-handle-store.ts +128 -1
- package/src/runtime/control-plane/execution/work-validation-reconciler.ts +277 -0
- package/src/runtime/control-plane/execution/work-verification-snapshot.ts +169 -0
- package/src/runtime/control-plane/facade/capability-registry.ts +0 -10
- package/src/runtime/control-plane/facade/handoff-inbox-store.ts +44 -25
- package/src/runtime/control-plane/facade/suggested-actions.ts +7 -1
- package/src/runtime/control-plane/facade/types.ts +0 -1
- package/src/runtime/control-plane/global-scheduler/scheduler.ts +30 -8
- package/src/runtime/control-plane/launcher/chatgpt-work-binding-store.ts +114 -0
- package/src/runtime/control-plane/launcher/chatgpt-work-continuation.ts +175 -0
- package/src/runtime/control-plane/launcher/launch-reservation-store.ts +161 -0
- package/src/runtime/control-plane/launcher/provider-mcp-bootstrap.ts +64 -0
- package/src/runtime/control-plane/launcher/thin-launcher.ts +117 -24
- package/src/runtime/control-plane/routing/route-policy.ts +14 -14
- package/src/runtime/control-plane/runtime-cleanup.ts +0 -1
- package/src/runtime/evidence/event-ledger.ts +1 -1
- package/src/runtime/{workflow/campaigns/workspace.ts → execution/managed-workspace.ts} +41 -43
- package/src/runtime/execution/process-runtime/check-facade.ts +6 -0
- package/src/runtime/execution/process-runtime/check-result.ts +45 -0
- package/src/runtime/execution/process-runtime/check-runner-sidecar.ts +42 -16
- package/src/runtime/execution/process-runtime/command-facade.ts +4 -2
- package/src/runtime/execution/process-runtime/gc.ts +1 -1
- package/src/runtime/execution/process-runtime/index.ts +3 -0
- package/src/runtime/execution/process-runtime/interactive-admission.ts +14 -5
- package/src/runtime/execution/process-runtime/persisted-check.ts +285 -0
- package/src/runtime/execution/process-runtime/resource-claims.ts +30 -0
- package/src/runtime/execution/process-runtime/runtime.ts +18 -1
- package/src/runtime/execution/process-runtime/store.ts +1 -19
- package/src/runtime/execution/process-runtime/types.ts +4 -0
- package/src/runtime/execution/thin-harness/execution-router.ts +0 -1
- package/src/runtime/execution/thin-harness/fast-executor.ts +1 -1
- package/src/runtime/execution/thin-harness/lightweight-lanes.ts +1 -2
- package/src/runtime/execution/thin-harness/types.ts +0 -1
- package/src/runtime/execution/workers/executor.ts +1 -1
- package/src/runtime/gateway/mcp/execution-tools.ts +1 -1
- package/src/runtime/gateway/mcp/persisted-check-process.ts +3 -255
- package/src/runtime/gateway/mcp/process-tools.ts +16 -3
- package/src/runtime/gateway/mcp/resource-policy.ts +0 -9
- package/src/runtime/gateway/mcp/router.ts +117 -182
- package/src/runtime/gateway/mcp/runtime-tools.ts +331 -409
- package/src/runtime/gateway/mcp/work-validation-reconciler.ts +1 -219
- package/src/runtime/plugins/browser-adapter.ts +5 -0
- package/src/runtime/plugins/desktop-operator-registration.ts +1 -1
- package/src/runtime/plugins/store.ts +14 -6
- package/src/runtime/plugins/types.ts +1 -1
- package/src/runtime/projections/materialized-view.ts +1 -23
- package/src/runtime/recovery/maintenance-executor.ts +9 -0
- package/src/runtime/resources/ownership.ts +0 -1
- package/src/runtime/root/gateway-adapter.ts +2 -0
- package/src/runtime/root/mcp-transport.ts +10 -2
- package/src/runtime/root/package-runtime-release.ts +161 -0
- package/src/runtime/root/package-runtime-service.ts +172 -0
- package/src/runtime/root/runtime.ts +2 -1
- package/src/runtime/root/scheduler.ts +5 -0
- package/src/runtime/root/service.ts +18 -5
- package/src/runtime/standalone-recovery/core.ts +65 -16
- package/src/runtime/workflow/findings/store.ts +145 -106
- package/src/runtime/workflow/findings/types.ts +22 -0
- package/src/runtime/workflow/schedules/engine.ts +132 -2
- package/src/runtime/workflow/schedules/pending-activation.ts +139 -0
- package/src/runtime/workflow/schedules/work-continuation.ts +218 -0
- package/docs/CHANGELOG.md +0 -978
- package/docs/README.zh-CN.md +0 -58
- package/scripts/smoke-chatgpt-supervised-automation.ts +0 -208
- package/src/cli/commands/controller.ts +0 -680
- package/src/runtime/workflow/campaigns/cleanup.ts +0 -263
- package/src/runtime/workflow/campaigns/engine.ts +0 -112
- package/src/runtime/workflow/campaigns/normalize.ts +0 -100
- package/src/runtime/workflow/campaigns/review.ts +0 -315
- package/src/runtime/workflow/campaigns/store.ts +0 -526
- package/src/runtime/workflow/campaigns/supervisor.ts +0 -112
- package/src/runtime/workflow/campaigns/types.ts +0 -290
- /package/src/runtime/{workflow/campaigns → execution}/workspace-agent.ts +0 -0
package/docs/README.zh-CN.md
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
# Forge 中文文档
|
|
2
|
-
|
|
3
|
-
> 这里维护 Forge 当前产品与 Runtime 的公开文档。可执行代码与 [`architecture/current/`](architecture/current/) 是当前事实来源;历史设计与研究文档只提供背景,不覆盖当前契约。
|
|
4
|
-
|
|
5
|
-
[English docs](README.md) · [GitHub](https://github.com/moretea-labs/forge) · [版本发布](https://github.com/moretea-labs/forge/releases) · [支持](../SUPPORT.md)
|
|
6
|
-
|
|
7
|
-
## 从这里开始
|
|
8
|
-
|
|
9
|
-
| 目标 | 先读 | 接着读 |
|
|
10
|
-
| --- | --- | --- |
|
|
11
|
-
| 安装 Forge | [安装并启动](tutorials/01-install-and-start.zh-CN.md) | [平台支持](operations/platform-support.zh-CN.md) |
|
|
12
|
-
| 连接 ChatGPT | [连接 ChatGPT](tutorials/02-connect-chatgpt.zh-CN.md) | [MCP 配置](forge-chatgpt-mcp-setup.md) |
|
|
13
|
-
| 完成第一个任务 | [第一个仓库任务](tutorials/03-first-repository-task.zh-CN.md) | [公开使用指南](public-usage-guide.zh-CN.md) |
|
|
14
|
-
| 安装官方 Provider | [插件管理](forge-plugin-management.md) | [Provider 配置](operations/provider-configuration.md) |
|
|
15
|
-
| 理解 Forge | [核心概念](wiki/Core-Concepts.md) | [架构](wiki/Architecture.md) |
|
|
16
|
-
| 运维与恢复 | [Operations](wiki/Operations.md) | [故障排查](operations/troubleshooting.zh-CN.md) |
|
|
17
|
-
| 贡献与发布 | [贡献指南](../CONTRIBUTING.md) | [发布流程](operations/releasing.zh-CN.md) |
|
|
18
|
-
|
|
19
|
-
## 当前产品面
|
|
20
|
-
|
|
21
|
-
普通 ChatGPT Connector 默认暴露 **19 个 MCP 工具**。`rh_status`、`rh_access`、`rh_inbox`、`rh_context`、`rh_work` 五个 facade 覆盖主要控制循环,其余默认工具负责仓库、源码/补丁、check、Process、插件分发与结果读取。
|
|
22
|
-
|
|
23
|
-
Forge 默认 Direct-first:仅调查不会创建 durable Work;只有真正需要隔离时才建立 worktree。长命令由同一个 Process 生命周期管理,并返回有界摘要与可继续读取的引用。
|
|
24
|
-
|
|
25
|
-
## 文档地图
|
|
26
|
-
|
|
27
|
-
### 学习与使用
|
|
28
|
-
- [教程目录](tutorials/README.zh-CN.md)
|
|
29
|
-
- [公开使用指南](public-usage-guide.zh-CN.md)
|
|
30
|
-
- [功能与配置层级](operations/features.zh-CN.md)
|
|
31
|
-
- [平台支持](operations/platform-support.zh-CN.md)
|
|
32
|
-
|
|
33
|
-
### 理解架构
|
|
34
|
-
- [核心概念](wiki/Core-Concepts.md)
|
|
35
|
-
- [架构](wiki/Architecture.md)
|
|
36
|
-
- [Runtime 架构](wiki/Runtime-Architecture.md)
|
|
37
|
-
- [工作生命周期](wiki/Work-Lifecycle.md)
|
|
38
|
-
- [实现地图](wiki/Implementation.md)
|
|
39
|
-
|
|
40
|
-
### 集成能力
|
|
41
|
-
- [插件管理](forge-plugin-management.md)
|
|
42
|
-
- [Provider 配置](operations/provider-configuration.md)
|
|
43
|
-
- [桌面 Provider](operations/controller-desktop-plugin.md)
|
|
44
|
-
- [本地系统助手](operations/local-system-assistant.zh-CN.md)
|
|
45
|
-
- [iOS 开发助手](forge-ios-development-assistant.md)
|
|
46
|
-
|
|
47
|
-
### 运维与维护
|
|
48
|
-
- [故障排查](operations/troubleshooting.zh-CN.md)
|
|
49
|
-
- [发布流程](operations/releasing.zh-CN.md)
|
|
50
|
-
- [GitHub 仓库基线](operations/github-repository.md)
|
|
51
|
-
- [版本策略](versioning.md)
|
|
52
|
-
- [安全策略](../SECURITY.md)
|
|
53
|
-
|
|
54
|
-
## 当前事实与历史
|
|
55
|
-
|
|
56
|
-
Controller 是全局多仓库服务,但执行始终由稳定 `repoId` 和必要时的 `checkoutId` 明确限定。Controller Home 保存服务配置、认证、Provider、持久状态与发布元数据;公网 MCP 与仅本机可见的 Controller UI 相互分离。
|
|
57
|
-
|
|
58
|
-
当前架构以 [`architecture/current/`](architecture/current/) 为准;[`architecture/history.md`](architecture/history.md) 与 [`researches/`](researches/) 用于追溯历史和证据,不是当前运行契约。
|
|
@@ -1,208 +0,0 @@
|
|
|
1
|
-
import assert from 'node:assert/strict';
|
|
2
|
-
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs';
|
|
3
|
-
import { tmpdir } from 'node:os';
|
|
4
|
-
import { join } from 'node:path';
|
|
5
|
-
import { execFileSync } from 'node:child_process';
|
|
6
|
-
import { acquireControllerLock, releaseControllerLock } from '../src/cli/repositories/locks';
|
|
7
|
-
import { createCampaign, getCampaign, updateCampaign } from '../src/runtime/workflow/campaigns/store';
|
|
8
|
-
import { reconcileCampaign } from '../src/runtime/workflow/campaigns/engine';
|
|
9
|
-
import { submitCampaignReview } from '../src/runtime/workflow/campaigns/review';
|
|
10
|
-
import { createExecutionJob, listExecutionJobs, transitionExecutionJob } from '../src/runtime/execution/jobs/store';
|
|
11
|
-
import { listActiveLeases } from '../src/runtime/resources/leases/store';
|
|
12
|
-
import { getRepository, registerRepository, selectRepositoryCheckout } from '../src/cli/repositories/registry';
|
|
13
|
-
import { ensureCampaignWorkspace } from '../src/runtime/workflow/campaigns/workspace';
|
|
14
|
-
import { executeExecutionJob } from '../src/runtime/execution/workers/executor';
|
|
15
|
-
|
|
16
|
-
const controllerHome = mkdtempSync(join(tmpdir(), 'forge-supervised-smoke-'));
|
|
17
|
-
const repoId = 'smoke-repo';
|
|
18
|
-
const workspaceFixtureRoot = mkdtempSync(join(tmpdir(), 'forge-supervised-workspace-smoke-'));
|
|
19
|
-
|
|
20
|
-
function forceReconcile(campaignId: string) {
|
|
21
|
-
const current = getCampaign(controllerHome, repoId, campaignId);
|
|
22
|
-
if (current.nextReconcileAt) {
|
|
23
|
-
updateCampaign(controllerHome, repoId, campaignId, `force:${campaignId}:${current.revision}`, (campaign) => {
|
|
24
|
-
campaign.nextReconcileAt = undefined;
|
|
25
|
-
return campaign;
|
|
26
|
-
}, { wakeScheduler: false, requestFingerprint: `force:${campaignId}:${current.revision}` });
|
|
27
|
-
}
|
|
28
|
-
return reconcileCampaign(controllerHome, repoId, campaignId);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
function finish(jobId: string, status: 'succeeded' | 'failed') {
|
|
32
|
-
transitionExecutionJob(controllerHome, repoId, jobId, 'running');
|
|
33
|
-
transitionExecutionJob(controllerHome, repoId, jobId, status, status === 'failed'
|
|
34
|
-
? { error: { code: 'SMOKE_FAILURE', message: 'intentional failure', retryable: false } }
|
|
35
|
-
: { result: { ok: true } });
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
try {
|
|
39
|
-
const campaign = createCampaign(controllerHome, {
|
|
40
|
-
repoId,
|
|
41
|
-
checkoutId: 'checkout-smoke',
|
|
42
|
-
requestId: 'smoke-campaign',
|
|
43
|
-
semanticKey: 'smoke:campaign',
|
|
44
|
-
title: 'ChatGPT supervised smoke',
|
|
45
|
-
goal: 'Reach human acceptance without blocking unrelated work.',
|
|
46
|
-
acceptanceCriteria: ['Independent work continues after one failure'],
|
|
47
|
-
reviewPolicy: 'every_task',
|
|
48
|
-
budget: { maxParallelTasks: 2, defaultTaskMaxAttempts: 1 },
|
|
49
|
-
tasks: [
|
|
50
|
-
{ taskId: 'T1', title: 'Fail independently', operation: 'record_candidate_finding', maxAttempts: 1 },
|
|
51
|
-
{ taskId: 'T2', title: 'Succeed independently', operation: 'record_candidate_finding', maxAttempts: 1 },
|
|
52
|
-
{ taskId: 'T3', title: 'Continue after failure', operation: 'record_candidate_finding', maxAttempts: 1 },
|
|
53
|
-
],
|
|
54
|
-
}).campaign;
|
|
55
|
-
|
|
56
|
-
const first = reconcileCampaign(controllerHome, repoId, campaign.campaignId);
|
|
57
|
-
assert.equal(first.dispatched, 2);
|
|
58
|
-
assert.equal(reconcileCampaign(controllerHome, repoId, campaign.campaignId).dispatched, 0);
|
|
59
|
-
let current = getCampaign(controllerHome, repoId, campaign.campaignId);
|
|
60
|
-
finish(current.tasks[0].jobId!, 'failed');
|
|
61
|
-
finish(current.tasks[1].jobId!, 'succeeded');
|
|
62
|
-
assert.equal(forceReconcile(campaign.campaignId).dispatched, 1);
|
|
63
|
-
current = getCampaign(controllerHome, repoId, campaign.campaignId);
|
|
64
|
-
assert.equal(current.tasks[2].status, 'queued');
|
|
65
|
-
assert.equal(listActiveLeases(controllerHome, repoId).length, 0);
|
|
66
|
-
|
|
67
|
-
const taskReview = current.checkpoints.find((checkpoint) => checkpoint.kind === 'task_review' && checkpoint.taskId === 'T2');
|
|
68
|
-
assert.ok(taskReview);
|
|
69
|
-
const reviewed = submitCampaignReview(controllerHome, {
|
|
70
|
-
repoId,
|
|
71
|
-
campaignId: current.campaignId,
|
|
72
|
-
checkpointId: taskReview.checkpointId,
|
|
73
|
-
nonce: taskReview.nonce,
|
|
74
|
-
goalRevision: taskReview.goalRevision,
|
|
75
|
-
expectedCampaignRevision: current.revision,
|
|
76
|
-
requestId: 'smoke-accept-t2',
|
|
77
|
-
decision: { action: 'accept', summary: 'Aligned.', submittedBy: 'chatgpt' },
|
|
78
|
-
});
|
|
79
|
-
const duplicate = submitCampaignReview(controllerHome, {
|
|
80
|
-
repoId,
|
|
81
|
-
campaignId: current.campaignId,
|
|
82
|
-
checkpointId: taskReview.checkpointId,
|
|
83
|
-
nonce: taskReview.nonce,
|
|
84
|
-
goalRevision: taskReview.goalRevision,
|
|
85
|
-
requestId: 'smoke-accept-t2',
|
|
86
|
-
decision: { action: 'accept', summary: 'Aligned.', submittedBy: 'chatgpt' },
|
|
87
|
-
});
|
|
88
|
-
assert.equal(duplicate.revision, reviewed.revision);
|
|
89
|
-
|
|
90
|
-
const second = createCampaign(controllerHome, {
|
|
91
|
-
repoId,
|
|
92
|
-
requestId: 'smoke-lock-campaign',
|
|
93
|
-
semanticKey: 'smoke:lock',
|
|
94
|
-
title: 'Lock isolation',
|
|
95
|
-
goal: 'Prove per-campaign locking.',
|
|
96
|
-
tasks: [{ taskId: 'L1', title: 'Lock test', operation: 'record_candidate_finding' }],
|
|
97
|
-
}).campaign;
|
|
98
|
-
const lock = acquireControllerLock(controllerHome, {
|
|
99
|
-
scope: 'task', repoId, taskId: `campaign-${campaign.campaignId}`,
|
|
100
|
-
}, 'smoke-lock-owner', 60_000);
|
|
101
|
-
try {
|
|
102
|
-
assert.doesNotThrow(() => reconcileCampaign(controllerHome, repoId, second.campaignId));
|
|
103
|
-
assert.throws(() => reconcileCampaign(controllerHome, repoId, campaign.campaignId), /LOCK_HELD/);
|
|
104
|
-
} finally {
|
|
105
|
-
releaseControllerLock(controllerHome, { scope: 'task', repoId, taskId: `campaign-${campaign.campaignId}` }, lock.lockId);
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
const agentCampaign = createCampaign(controllerHome, {
|
|
109
|
-
repoId,
|
|
110
|
-
requestId: 'smoke-agent-campaign',
|
|
111
|
-
semanticKey: 'smoke:agent',
|
|
112
|
-
title: 'Agent isolation',
|
|
113
|
-
goal: 'Dispatch Codex in an isolated worktree.',
|
|
114
|
-
tasks: [{
|
|
115
|
-
taskId: 'A1',
|
|
116
|
-
title: 'Implement safely',
|
|
117
|
-
operation: 'dispatch_task',
|
|
118
|
-
arguments: { issue_id: 'ISS-SMOKE', task_id: 'A1', agent: 'codex' },
|
|
119
|
-
}],
|
|
120
|
-
}).campaign;
|
|
121
|
-
reconcileCampaign(controllerHome, repoId, agentCampaign.campaignId);
|
|
122
|
-
const agentState = getCampaign(controllerHome, repoId, agentCampaign.campaignId);
|
|
123
|
-
const agentJob = listExecutionJobs(controllerHome, repoId, 100).find((job) => job.jobId === agentState.tasks[0].jobId)!;
|
|
124
|
-
assert.equal(agentJob.payload.arguments?.isolate, true);
|
|
125
|
-
assert.deepEqual(agentJob.resourceClaims, [{ resourceKey: 'worktree:ISS-SMOKE-A1', mode: 'write' }]);
|
|
126
|
-
|
|
127
|
-
const workspaceSupervisorCampaign = createCampaign(controllerHome, {
|
|
128
|
-
repoId,
|
|
129
|
-
requestId: 'smoke-workspace-supervisor',
|
|
130
|
-
semanticKey: 'smoke:workspace-supervisor',
|
|
131
|
-
title: 'Workspace Agent supervisor',
|
|
132
|
-
goal: 'Trigger ChatGPT without holding repository resources.',
|
|
133
|
-
supervisor: { mode: 'workspace_agent', workspaceAgentId: 'agtch_smoke_supervisor' },
|
|
134
|
-
tasks: [{ taskId: 'W1', title: 'Prepare review', operation: 'record_candidate_finding' }],
|
|
135
|
-
}).campaign;
|
|
136
|
-
reconcileCampaign(controllerHome, repoId, workspaceSupervisorCampaign.campaignId);
|
|
137
|
-
let workspaceState = getCampaign(controllerHome, repoId, workspaceSupervisorCampaign.campaignId);
|
|
138
|
-
finish(workspaceState.tasks[0].jobId!, 'succeeded');
|
|
139
|
-
forceReconcile(workspaceState.campaignId);
|
|
140
|
-
workspaceState = getCampaign(controllerHome, repoId, workspaceState.campaignId);
|
|
141
|
-
const workspaceCheckpoint = workspaceState.checkpoints.find((checkpoint) => checkpoint.kind === 'task_review')!;
|
|
142
|
-
const workspaceTrigger = listExecutionJobs(controllerHome, repoId, 100).find((job) => job.jobId === workspaceCheckpoint.triggerJobId)!;
|
|
143
|
-
assert.equal(workspaceTrigger.payload.target, 'workspace-agent');
|
|
144
|
-
assert.equal(workspaceTrigger.payload.arguments?.idempotency_key, `${workspaceCheckpoint.checkpointId}:1`);
|
|
145
|
-
assert.equal(workspaceTrigger.resourceClaims.length, 0);
|
|
146
|
-
transitionExecutionJob(controllerHome, repoId, workspaceTrigger.jobId, 'running');
|
|
147
|
-
transitionExecutionJob(controllerHome, repoId, workspaceTrigger.jobId, 'failed', {
|
|
148
|
-
error: { code: 'WORKSPACE_AGENT_OUTCOME_AMBIGUOUS', message: 'network outcome is uncertain', retryable: false },
|
|
149
|
-
});
|
|
150
|
-
forceReconcile(workspaceState.campaignId);
|
|
151
|
-
workspaceState = getCampaign(controllerHome, repoId, workspaceState.campaignId);
|
|
152
|
-
assert.equal(workspaceState.status, 'paused');
|
|
153
|
-
|
|
154
|
-
const workspaceRepoRoot = join(workspaceFixtureRoot, 'repo');
|
|
155
|
-
mkdirSync(workspaceRepoRoot, { recursive: true });
|
|
156
|
-
const git = (...args: string[]) => execFileSync('git', ['-C', workspaceRepoRoot, ...args], { encoding: 'utf8' }).trim();
|
|
157
|
-
git('init', '-q');
|
|
158
|
-
git('config', 'user.email', 'smoke@example.com');
|
|
159
|
-
git('config', 'user.name', 'Smoke Test');
|
|
160
|
-
writeFileSync(join(workspaceRepoRoot, '.gitignore'), '.ai/\n');
|
|
161
|
-
writeFileSync(join(workspaceRepoRoot, 'marker.txt'), 'source checkout\n');
|
|
162
|
-
git('add', '.');
|
|
163
|
-
git('commit', '-q', '-m', 'base');
|
|
164
|
-
const registered = registerRepository({ path: workspaceRepoRoot, controllerHome });
|
|
165
|
-
const campaignWorkspace = ensureCampaignWorkspace(controllerHome, registered, {
|
|
166
|
-
requestId: 'smoke-campaign-workspace',
|
|
167
|
-
title: 'Campaign workspace isolation',
|
|
168
|
-
});
|
|
169
|
-
const repeatedWorkspace = ensureCampaignWorkspace(controllerHome, registered, {
|
|
170
|
-
requestId: 'smoke-campaign-workspace',
|
|
171
|
-
title: 'Campaign workspace isolation',
|
|
172
|
-
});
|
|
173
|
-
assert.deepEqual(repeatedWorkspace, campaignWorkspace);
|
|
174
|
-
const repositoryAfterWorkspace = getRepository(registered.repoId, controllerHome);
|
|
175
|
-
assert.equal(repositoryAfterWorkspace.activeCheckoutId, registered.activeCheckoutId);
|
|
176
|
-
assert.equal(repositoryAfterWorkspace.checkouts.length, 2);
|
|
177
|
-
assert.equal(selectRepositoryCheckout(repositoryAfterWorkspace, campaignWorkspace.checkoutId).canonicalRoot, campaignWorkspace.root);
|
|
178
|
-
writeFileSync(join(campaignWorkspace.root!, 'marker.txt'), 'campaign checkout\n');
|
|
179
|
-
const checkoutJob = createExecutionJob(controllerHome, {
|
|
180
|
-
repoId: registered.repoId,
|
|
181
|
-
checkoutId: campaignWorkspace.checkoutId,
|
|
182
|
-
type: 'mcp-tool',
|
|
183
|
-
requestId: 'smoke-checkout-routing',
|
|
184
|
-
semanticKey: 'smoke:checkout-routing',
|
|
185
|
-
origin: { surface: 'system', actor: 'smoke' },
|
|
186
|
-
payload: {
|
|
187
|
-
operation: 'read_repository_file',
|
|
188
|
-
arguments: { path: 'marker.txt', start_line: 1, end_line: 2 },
|
|
189
|
-
target: 'mcp-tool',
|
|
190
|
-
profile: 'controller',
|
|
191
|
-
},
|
|
192
|
-
resourceClaims: [],
|
|
193
|
-
});
|
|
194
|
-
const checkoutResult = await executeExecutionJob(controllerHome, checkoutJob.job);
|
|
195
|
-
assert.equal(checkoutResult.ok, true);
|
|
196
|
-
assert.equal(checkoutResult.repoRoot, campaignWorkspace.root);
|
|
197
|
-
assert.match(JSON.stringify(checkoutResult.result), /campaign checkout/);
|
|
198
|
-
|
|
199
|
-
console.log(JSON.stringify({
|
|
200
|
-
ok: true,
|
|
201
|
-
campaigns: 4,
|
|
202
|
-
jobs: listExecutionJobs(controllerHome, repoId, 100).length,
|
|
203
|
-
invariants: ['idempotency', 'per-campaign-locking', 'failure-isolation', 'task-worktree-isolation', 'campaign-workspace-isolation', 'checkout-routing', 'lease-free-review', 'workspace-agent-trigger', 'ambiguous-trigger-stop'],
|
|
204
|
-
}, null, 2));
|
|
205
|
-
} finally {
|
|
206
|
-
rmSync(controllerHome, { recursive: true, force: true });
|
|
207
|
-
rmSync(workspaceFixtureRoot, { recursive: true, force: true });
|
|
208
|
-
}
|