@revisium/orchestrator 0.0.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/LICENSE +21 -0
- package/README.md +20 -0
- package/bin/revo.js +2 -0
- package/control-plane/bootstrap.config.json +931 -0
- package/dist/app.module.js +28 -0
- package/dist/app.module.js.map +1 -0
- package/dist/cli/commands/bootstrap.js +39 -0
- package/dist/cli/commands/bootstrap.js.map +1 -0
- package/dist/cli/commands/dev.js +143 -0
- package/dist/cli/commands/dev.js.map +1 -0
- package/dist/cli/commands/inbox.js +288 -0
- package/dist/cli/commands/inbox.js.map +1 -0
- package/dist/cli/commands/mcp.js +16 -0
- package/dist/cli/commands/mcp.js.map +1 -0
- package/dist/cli/commands/playbook.js +74 -0
- package/dist/cli/commands/playbook.js.map +1 -0
- package/dist/cli/commands/poll-workflow-state.js +144 -0
- package/dist/cli/commands/poll-workflow-state.js.map +1 -0
- package/dist/cli/commands/revisium-context.js +23 -0
- package/dist/cli/commands/revisium-context.js.map +1 -0
- package/dist/cli/commands/revisium-helpers.js +61 -0
- package/dist/cli/commands/revisium-helpers.js.map +1 -0
- package/dist/cli/commands/revisium.js +89 -0
- package/dist/cli/commands/revisium.js.map +1 -0
- package/dist/cli/commands/run.js +426 -0
- package/dist/cli/commands/run.js.map +1 -0
- package/dist/cli/commands/work.js +149 -0
- package/dist/cli/commands/work.js.map +1 -0
- package/dist/cli/config.js +2 -0
- package/dist/cli/config.js.map +1 -0
- package/dist/cli/index.js +32 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/live-guard.js +49 -0
- package/dist/cli/live-guard.js.map +1 -0
- package/dist/cli/needs-host.js +78 -0
- package/dist/cli/needs-host.js.map +1 -0
- package/dist/cli/program.js +37 -0
- package/dist/cli/program.js.map +1 -0
- package/dist/config.js +102 -0
- package/dist/config.js.map +1 -0
- package/dist/control-plane/client-transport.js +146 -0
- package/dist/control-plane/client-transport.js.map +1 -0
- package/dist/control-plane/data-access.js +99 -0
- package/dist/control-plane/data-access.js.map +1 -0
- package/dist/control-plane/definitions.js +120 -0
- package/dist/control-plane/definitions.js.map +1 -0
- package/dist/control-plane/errors.js +13 -0
- package/dist/control-plane/errors.js.map +1 -0
- package/dist/control-plane/inbox.js +261 -0
- package/dist/control-plane/inbox.js.map +1 -0
- package/dist/control-plane/index.js +6 -0
- package/dist/control-plane/index.js.map +1 -0
- package/dist/control-plane/json-fields.js +68 -0
- package/dist/control-plane/json-fields.js.map +1 -0
- package/dist/control-plane/resolve-cwd.js +75 -0
- package/dist/control-plane/resolve-cwd.js.map +1 -0
- package/dist/control-plane/steps.js +381 -0
- package/dist/control-plane/steps.js.map +1 -0
- package/dist/control-plane/tables.js +13 -0
- package/dist/control-plane/tables.js.map +1 -0
- package/dist/control-plane/versioned-meaning.js +53 -0
- package/dist/control-plane/versioned-meaning.js.map +1 -0
- package/dist/engine/dbos.module.js +18 -0
- package/dist/engine/dbos.module.js.map +1 -0
- package/dist/engine/dbos.service.js +296 -0
- package/dist/engine/dbos.service.js.map +1 -0
- package/dist/engine/ensure-postgres.js +80 -0
- package/dist/engine/ensure-postgres.js.map +1 -0
- package/dist/engine/types.js +2 -0
- package/dist/engine/types.js.map +1 -0
- package/dist/host/ensure-revisium.js +269 -0
- package/dist/host/ensure-revisium.js.map +1 -0
- package/dist/host/host.lifecycle.js +75 -0
- package/dist/host/host.lifecycle.js.map +1 -0
- package/dist/mcp/mcp-capabilities.js +47 -0
- package/dist/mcp/mcp-capabilities.js.map +1 -0
- package/dist/mcp/mcp-facade.service.js +130 -0
- package/dist/mcp/mcp-facade.service.js.map +1 -0
- package/dist/mcp/mcp-stdio.service.js +48 -0
- package/dist/mcp/mcp-stdio.service.js.map +1 -0
- package/dist/mcp/mcp-tools.js +264 -0
- package/dist/mcp/mcp-tools.js.map +1 -0
- package/dist/mcp/mcp.module.js +21 -0
- package/dist/mcp/mcp.module.js.map +1 -0
- package/dist/package-info.js +10 -0
- package/dist/package-info.js.map +1 -0
- package/dist/pipeline/await-human.js +62 -0
- package/dist/pipeline/await-human.js.map +1 -0
- package/dist/pipeline/develop-task.workflow.js +497 -0
- package/dist/pipeline/develop-task.workflow.js.map +1 -0
- package/dist/pipeline/pipeline.module.js +34 -0
- package/dist/pipeline/pipeline.module.js.map +1 -0
- package/dist/playbook/catalog-loader.js +145 -0
- package/dist/playbook/catalog-loader.js.map +1 -0
- package/dist/playbook/errors.js +14 -0
- package/dist/playbook/errors.js.map +1 -0
- package/dist/playbook/import-mapper.js +186 -0
- package/dist/playbook/import-mapper.js.map +1 -0
- package/dist/playbook/manifest.js +60 -0
- package/dist/playbook/manifest.js.map +1 -0
- package/dist/playbook/playbook-installer.js +51 -0
- package/dist/playbook/playbook-installer.js.map +1 -0
- package/dist/playbook/prompt-composer.js +34 -0
- package/dist/playbook/prompt-composer.js.map +1 -0
- package/dist/playbook/source-resolver.js +105 -0
- package/dist/playbook/source-resolver.js.map +1 -0
- package/dist/poller/pr-readiness-core.js +656 -0
- package/dist/poller/pr-readiness-core.js.map +1 -0
- package/dist/poller/pr-readiness.js +91 -0
- package/dist/poller/pr-readiness.js.map +1 -0
- package/dist/revisium/inbox.service.js +67 -0
- package/dist/revisium/inbox.service.js.map +1 -0
- package/dist/revisium/playbooks.service.js +99 -0
- package/dist/revisium/playbooks.service.js.map +1 -0
- package/dist/revisium/revisium.module.js +55 -0
- package/dist/revisium/revisium.module.js.map +1 -0
- package/dist/revisium/roles.service.js +79 -0
- package/dist/revisium/roles.service.js.map +1 -0
- package/dist/revisium/run.service.js +182 -0
- package/dist/revisium/run.service.js.map +1 -0
- package/dist/revisium/tokens.js +7 -0
- package/dist/revisium/tokens.js.map +1 -0
- package/dist/run/append-event.js +112 -0
- package/dist/run/append-event.js.map +1 -0
- package/dist/run/cancel-run.js +47 -0
- package/dist/run/cancel-run.js.map +1 -0
- package/dist/run/create-run.js +208 -0
- package/dist/run/create-run.js.map +1 -0
- package/dist/run/fail-run.js +20 -0
- package/dist/run/fail-run.js.map +1 -0
- package/dist/run/inspect-run.js +287 -0
- package/dist/run/inspect-run.js.map +1 -0
- package/dist/run/terminal-run-status.js +45 -0
- package/dist/run/terminal-run-status.js.map +1 -0
- package/dist/runners/claude-code.service.js +48 -0
- package/dist/runners/claude-code.service.js.map +1 -0
- package/dist/runners/gh-identity.js +108 -0
- package/dist/runners/gh-identity.js.map +1 -0
- package/dist/runners/integrator.js +417 -0
- package/dist/runners/integrator.js.map +1 -0
- package/dist/runners/runner.module.js +40 -0
- package/dist/runners/runner.module.js.map +1 -0
- package/dist/runners/tokens.js +7 -0
- package/dist/runners/tokens.js.map +1 -0
- package/dist/task-control-plane/pr-readiness.service.js +33 -0
- package/dist/task-control-plane/pr-readiness.service.js.map +1 -0
- package/dist/task-control-plane/task-control-plane-api.service.js +440 -0
- package/dist/task-control-plane/task-control-plane-api.service.js.map +1 -0
- package/dist/task-control-plane/task-control-plane.module.js +23 -0
- package/dist/task-control-plane/task-control-plane.module.js.map +1 -0
- package/dist/worker/build-context.js +39 -0
- package/dist/worker/build-context.js.map +1 -0
- package/dist/worker/claude-code-runner.js +135 -0
- package/dist/worker/claude-code-runner.js.map +1 -0
- package/dist/worker/git-worktree-manager.js +84 -0
- package/dist/worker/git-worktree-manager.js.map +1 -0
- package/dist/worker/loop.js +122 -0
- package/dist/worker/loop.js.map +1 -0
- package/dist/worker/process-executor.js +62 -0
- package/dist/worker/process-executor.js.map +1 -0
- package/dist/worker/result-envelope.js +134 -0
- package/dist/worker/result-envelope.js.map +1 -0
- package/dist/worker/runner-dispatch.js +20 -0
- package/dist/worker/runner-dispatch.js.map +1 -0
- package/dist/worker/runner.js +2 -0
- package/dist/worker/runner.js.map +1 -0
- package/dist/worker/script-runner.js +28 -0
- package/dist/worker/script-runner.js.map +1 -0
- package/dist/worker/stub-runner.js +59 -0
- package/dist/worker/stub-runner.js.map +1 -0
- package/dist/worker/worker-id.js +18 -0
- package/dist/worker/worker-id.js.map +1 -0
- package/dist/worker/worktree-manager.js +7 -0
- package/dist/worker/worktree-manager.js.map +1 -0
- package/package.json +66 -0
- package/revisium.config.json +10 -0
|
@@ -0,0 +1,417 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* integrator.ts — deterministic, replay-safe code integrator.
|
|
12
|
+
*
|
|
13
|
+
* DBOS-SEALED: zero @dbos-inc imports. Registration happens in PipelineService ctor.
|
|
14
|
+
*
|
|
15
|
+
* Exposes:
|
|
16
|
+
* - integrate(input, deps) — REAL integrator (live only); git/gh side effects; resumable.
|
|
17
|
+
* - stubIntegrate(input) — STUB (script only); ZERO external effects; pure + deterministic.
|
|
18
|
+
* - preflightLive(taskId, base, deps) — LIVE PREFLIGHT; clean check + base invariant; one-shot.
|
|
19
|
+
* - IntegratorService — @Injectable wrapper with bound arrow properties.
|
|
20
|
+
* - resolveExecutable(name) — resolve a bare executable name to an absolute PATH entry.
|
|
21
|
+
*/
|
|
22
|
+
import { Injectable } from '@nestjs/common';
|
|
23
|
+
import { existsSync, statSync } from 'node:fs';
|
|
24
|
+
import { join, delimiter } from 'node:path';
|
|
25
|
+
import { execFileSync } from 'node:child_process';
|
|
26
|
+
import { RunService } from '../revisium/run.service.js';
|
|
27
|
+
import { resolveGhAccount, resolvePinnedGh } from './gh-identity.js';
|
|
28
|
+
// ─── resolveExecutable ────────────────────────────────────────────────────────
|
|
29
|
+
/**
|
|
30
|
+
* Resolve a bare executable name to its first absolute path on PATH.
|
|
31
|
+
* Uses only node:fs + node:path — no child_process, no spawning.
|
|
32
|
+
*
|
|
33
|
+
* @param name - bare executable name, e.g. "git"
|
|
34
|
+
* @param pathEnv - override for PATH (defaults to process.env.PATH); injectable for tests
|
|
35
|
+
* @returns absolute path to the executable
|
|
36
|
+
* @throws Error if not found on PATH
|
|
37
|
+
*/
|
|
38
|
+
export function resolveExecutable(name, pathEnv = process.env['PATH'] ?? '') {
|
|
39
|
+
if (!pathEnv) {
|
|
40
|
+
throw new Error(`cannot resolve executable "${name}" on PATH: PATH is empty or unset`);
|
|
41
|
+
}
|
|
42
|
+
const dirs = pathEnv.split(delimiter);
|
|
43
|
+
// On win32 also check common executable extensions; on posix the plain name suffices.
|
|
44
|
+
const candidates = process.platform === 'win32'
|
|
45
|
+
? [name, `${name}.exe`, `${name}.cmd`, `${name}.bat`]
|
|
46
|
+
: [name];
|
|
47
|
+
for (const dir of dirs) {
|
|
48
|
+
if (!dir)
|
|
49
|
+
continue;
|
|
50
|
+
for (const candidate of candidates) {
|
|
51
|
+
const full = join(dir, candidate);
|
|
52
|
+
try {
|
|
53
|
+
if (existsSync(full) && statSync(full).isFile()) {
|
|
54
|
+
return full;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
catch {
|
|
58
|
+
// dir may be unreadable — skip silently
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
throw new Error(`cannot resolve executable "${name}" on PATH`);
|
|
63
|
+
}
|
|
64
|
+
// Lazily resolved once per process — avoids resolving on module load (safe for tests).
|
|
65
|
+
let _gitAbsPath;
|
|
66
|
+
function gitAbsPath() {
|
|
67
|
+
if (_gitAbsPath === undefined) {
|
|
68
|
+
_gitAbsPath = resolveExecutable('git');
|
|
69
|
+
}
|
|
70
|
+
return _gitAbsPath;
|
|
71
|
+
}
|
|
72
|
+
// ─── slug helper ─────────────────────────────────────────────────────────────
|
|
73
|
+
const SLUG_MAX = 40;
|
|
74
|
+
/** Deterministic branch-name slug from title: lowercase, non-alnum runs → '-', trim/truncate. */
|
|
75
|
+
function slugify(title) {
|
|
76
|
+
return title
|
|
77
|
+
.toLowerCase()
|
|
78
|
+
.replace(/[^a-z0-9]+/g, '-')
|
|
79
|
+
.split('-')
|
|
80
|
+
.filter((seg) => seg.length > 0)
|
|
81
|
+
.join('-')
|
|
82
|
+
.slice(0, SLUG_MAX);
|
|
83
|
+
}
|
|
84
|
+
/** Derive deterministic feature branch name from taskId + title. */
|
|
85
|
+
function branchName(taskId, title) {
|
|
86
|
+
const slug = slugify(title) || slugify(taskId) || 'task';
|
|
87
|
+
return `feat/${taskId}-${slug}`;
|
|
88
|
+
}
|
|
89
|
+
// ─── owner/repo derivation ────────────────────────────────────────────────────
|
|
90
|
+
// Owner and repo: GitHub-safe chars only ([A-Za-z0-9._-]); trailing .git stripped; no trailing paths.
|
|
91
|
+
// Non-greedy repo segment (+?) allows the (?:\.git)? suffix to back-trim a trailing ".git".
|
|
92
|
+
const GITHUB_SSH_RE = /^git@github\.com:([A-Za-z0-9._-]+\/[A-Za-z0-9._-]+?)(?:\.git)?$/;
|
|
93
|
+
const GITHUB_HTTPS_RE = /^https?:\/\/github\.com\/([A-Za-z0-9._-]+\/[A-Za-z0-9._-]+?)(?:\.git)?$/;
|
|
94
|
+
export function parseOwnerRepo(remoteUrl) {
|
|
95
|
+
const ssh = GITHUB_SSH_RE.exec(remoteUrl.trim());
|
|
96
|
+
if (ssh?.[1])
|
|
97
|
+
return ssh[1];
|
|
98
|
+
const https = GITHUB_HTTPS_RE.exec(remoteUrl.trim());
|
|
99
|
+
if (https?.[1])
|
|
100
|
+
return https[1];
|
|
101
|
+
return null;
|
|
102
|
+
}
|
|
103
|
+
function resolveOwnerRepo(execGit, cwd) {
|
|
104
|
+
let remoteUrl;
|
|
105
|
+
try {
|
|
106
|
+
remoteUrl = execGit(['remote', 'get-url', 'origin'], cwd).trim();
|
|
107
|
+
}
|
|
108
|
+
catch {
|
|
109
|
+
return {
|
|
110
|
+
needsHuman: true,
|
|
111
|
+
lesson: 'target repo has no parseable github remote — cannot open a PR (config gap: add a github origin remote)',
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
const ownerRepo = parseOwnerRepo(remoteUrl);
|
|
115
|
+
if (!ownerRepo) {
|
|
116
|
+
return {
|
|
117
|
+
needsHuman: true,
|
|
118
|
+
lesson: `target repo has no parseable github remote — cannot open a PR (remote url: ${remoteUrl})`,
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
return { ownerRepo };
|
|
122
|
+
}
|
|
123
|
+
function findOrCreatePr(ownerRepo, branch, base, title, execGh) {
|
|
124
|
+
const raw = execGh([
|
|
125
|
+
'pr',
|
|
126
|
+
'list',
|
|
127
|
+
'--repo',
|
|
128
|
+
ownerRepo,
|
|
129
|
+
'--head',
|
|
130
|
+
branch,
|
|
131
|
+
'--state',
|
|
132
|
+
'open',
|
|
133
|
+
'--json',
|
|
134
|
+
'number,url,baseRefName',
|
|
135
|
+
]);
|
|
136
|
+
let entries;
|
|
137
|
+
try {
|
|
138
|
+
entries = JSON.parse(raw);
|
|
139
|
+
}
|
|
140
|
+
catch {
|
|
141
|
+
throw new Error(`gh pr list returned non-JSON: ${raw.slice(0, 200)}`);
|
|
142
|
+
}
|
|
143
|
+
const matching = entries.filter((p) => p.baseRefName === base);
|
|
144
|
+
if (matching.length === 1) {
|
|
145
|
+
const pr = matching[0];
|
|
146
|
+
if (!pr)
|
|
147
|
+
throw new Error('unexpected empty match');
|
|
148
|
+
return { prUrl: pr.url, prNumber: pr.number };
|
|
149
|
+
}
|
|
150
|
+
if (matching.length > 1) {
|
|
151
|
+
const candidates = matching.map((p) => `#${p.number}`).join(', ');
|
|
152
|
+
return {
|
|
153
|
+
needsHuman: true,
|
|
154
|
+
lesson: `Ambiguous: ${matching.length} open PRs for branch "${branch}" targeting "${base}" in ${ownerRepo} — candidates ${candidates} — manual review needed`,
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
// 0 matches — create
|
|
158
|
+
const createOut = execGh([
|
|
159
|
+
'pr',
|
|
160
|
+
'create',
|
|
161
|
+
'--repo',
|
|
162
|
+
ownerRepo,
|
|
163
|
+
'--draft',
|
|
164
|
+
'--base',
|
|
165
|
+
base,
|
|
166
|
+
'--head',
|
|
167
|
+
branch,
|
|
168
|
+
'--title',
|
|
169
|
+
title,
|
|
170
|
+
'--body',
|
|
171
|
+
'',
|
|
172
|
+
]);
|
|
173
|
+
// gh pr create prints the PR url on stdout
|
|
174
|
+
const createdUrl = createOut.trim();
|
|
175
|
+
// Fetch back number from the URL
|
|
176
|
+
const viewRaw = execGh([
|
|
177
|
+
'pr',
|
|
178
|
+
'view',
|
|
179
|
+
'--repo',
|
|
180
|
+
ownerRepo,
|
|
181
|
+
branch,
|
|
182
|
+
'--json',
|
|
183
|
+
'number,url',
|
|
184
|
+
]);
|
|
185
|
+
let viewData;
|
|
186
|
+
try {
|
|
187
|
+
viewData = JSON.parse(viewRaw);
|
|
188
|
+
}
|
|
189
|
+
catch {
|
|
190
|
+
// gh pr view returned non-JSON after create — cannot determine real PR url/number.
|
|
191
|
+
// A live integrator must NEVER emit a stub:// url; surface as needsHuman for human review.
|
|
192
|
+
return {
|
|
193
|
+
needsHuman: true,
|
|
194
|
+
lesson: `gh pr view returned non-JSON after create (url=${createdUrl || 'empty'}); ` +
|
|
195
|
+
'check if the PR was created and update the run manually',
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
return { prUrl: viewData.url, prNumber: viewData.number };
|
|
199
|
+
}
|
|
200
|
+
// ─── Preflight (B5+B7) ────────────────────────────────────────────────────────
|
|
201
|
+
/**
|
|
202
|
+
* preflightLive — clean check + base invariant, evaluated ONCE as a memoized DBOS step.
|
|
203
|
+
* Only called on live runs; script/stub runs skip this entirely.
|
|
204
|
+
*
|
|
205
|
+
* 1. git fetch origin <base> (idempotent — the only mutation)
|
|
206
|
+
* 2. git status --porcelain → non-empty → block (repo not clean)
|
|
207
|
+
* 3. Verify HEAD === <base> AND HEAD sha === origin/<base> sha → mismatch → block
|
|
208
|
+
*
|
|
209
|
+
* Returns { ok: true } when the repo is clean and on fresh origin/<base>.
|
|
210
|
+
* Returns IntegratorBlocked on ANY failure — no throw, so DBOS does NOT retry.
|
|
211
|
+
*/
|
|
212
|
+
export async function preflightLive(taskId, base, deps) {
|
|
213
|
+
const { execGit, resolveTaskCwd } = deps;
|
|
214
|
+
const cwd = await resolveTaskCwd(taskId);
|
|
215
|
+
// 1. Fetch (only mutation; idempotent; ignore errors — fetch failure handled as mismatch)
|
|
216
|
+
try {
|
|
217
|
+
execGit(['fetch', 'origin', base], cwd);
|
|
218
|
+
}
|
|
219
|
+
catch (err) {
|
|
220
|
+
return {
|
|
221
|
+
needsHuman: true,
|
|
222
|
+
lesson: `live preflight: git fetch origin ${base} failed — base branch may not exist on remote: ${String(err)}`,
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
// 2. Clean check
|
|
226
|
+
const porcelain = execGit(['status', '--porcelain'], cwd).trim();
|
|
227
|
+
if (porcelain !== '') {
|
|
228
|
+
const lineCount = porcelain.split('\n').length;
|
|
229
|
+
return {
|
|
230
|
+
needsHuman: true,
|
|
231
|
+
lesson: `target repo ${cwd} is not clean (${lineCount} uncommitted change${lineCount === 1 ? '' : 's'}); commit/stash and retry --live`,
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
// 3. Base invariant: HEAD branch name === base AND HEAD sha === origin/<base> sha
|
|
235
|
+
let headBranch;
|
|
236
|
+
let headSha;
|
|
237
|
+
let originSha;
|
|
238
|
+
try {
|
|
239
|
+
headBranch = execGit(['rev-parse', '--abbrev-ref', 'HEAD'], cwd).trim();
|
|
240
|
+
headSha = execGit(['rev-parse', 'HEAD'], cwd).trim();
|
|
241
|
+
originSha = execGit(['rev-parse', `origin/${base}`], cwd).trim();
|
|
242
|
+
}
|
|
243
|
+
catch (err) {
|
|
244
|
+
return {
|
|
245
|
+
needsHuman: true,
|
|
246
|
+
lesson: `live preflight: cannot verify base invariant — ${String(err)}`,
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
if (headBranch !== base || headSha !== originSha) {
|
|
250
|
+
return {
|
|
251
|
+
needsHuman: true,
|
|
252
|
+
lesson: `target repo is not on a fresh origin/${base} ` +
|
|
253
|
+
`(HEAD=${headBranch}@${headSha.slice(0, 8)}, expected ${base}@${originSha.slice(0, 8)}); ` +
|
|
254
|
+
`checkout ${base} and pull, then retry --live`,
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
return { ok: true };
|
|
258
|
+
}
|
|
259
|
+
// ─── STUB integrator (script only) ───────────────────────────────────────────
|
|
260
|
+
/**
|
|
261
|
+
* stubIntegrate — PURE, zero side effects; returns a placeholder result.
|
|
262
|
+
* Used by `script` mode (default + --stub). Makes NO execGit/execGh calls.
|
|
263
|
+
*/
|
|
264
|
+
export function stubIntegrate(input) {
|
|
265
|
+
return {
|
|
266
|
+
prUrl: 'stub://pr/placeholder',
|
|
267
|
+
branch: `feat/${input.taskId}-stub`,
|
|
268
|
+
prNumber: 0,
|
|
269
|
+
};
|
|
270
|
+
}
|
|
271
|
+
// ─── REAL integrator (live only) ─────────────────────────────────────────────
|
|
272
|
+
/** Branch existence check — returns true if the branch exists locally. */
|
|
273
|
+
function branchExists(execGit, cwd, branch) {
|
|
274
|
+
try {
|
|
275
|
+
execGit(['rev-parse', '--verify', branch], cwd);
|
|
276
|
+
return true;
|
|
277
|
+
}
|
|
278
|
+
catch {
|
|
279
|
+
return false;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
/**
|
|
283
|
+
* Count commits on branch ahead of origin/<base>.
|
|
284
|
+
* Returns 0 only for expected "no upstream / unknown revision / ambiguous argument" errors
|
|
285
|
+
* (these mean the branch is not ahead). Rethrows other errors so DBOS can retry transient failures.
|
|
286
|
+
*/
|
|
287
|
+
function countAhead(execGit, cwd, branch, base) {
|
|
288
|
+
try {
|
|
289
|
+
const raw = execGit(['rev-list', '--count', `origin/${base}..${branch}`], cwd).trim();
|
|
290
|
+
return Number.parseInt(raw, 10) || 0;
|
|
291
|
+
}
|
|
292
|
+
catch (err) {
|
|
293
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
294
|
+
// Expected: branch or upstream not yet known to git (not a transient failure).
|
|
295
|
+
if (msg.includes('unknown revision') ||
|
|
296
|
+
msg.includes('ambiguous argument') ||
|
|
297
|
+
msg.includes('no upstream') ||
|
|
298
|
+
msg.includes('does not have any commits yet')) {
|
|
299
|
+
return 0;
|
|
300
|
+
}
|
|
301
|
+
// Transient failure (network, lock, etc.) — rethrow so DBOS retries.
|
|
302
|
+
throw err;
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
/**
|
|
306
|
+
* integrate — REAL integrator (live only).
|
|
307
|
+
* Replay-safe: branch create-if-absent (no clobber); commit only if staged diff;
|
|
308
|
+
* push + find-or-create PR even if commit already happened (ahead guard).
|
|
309
|
+
*/
|
|
310
|
+
export async function integrate(input, deps) {
|
|
311
|
+
const { execGit: git, execGh: gh, resolveTaskCwd: resolveCwd } = deps;
|
|
312
|
+
const cwd = await resolveCwd(input.taskId);
|
|
313
|
+
const branch = branchName(input.taskId, input.title);
|
|
314
|
+
// 1. Derive owner/repo
|
|
315
|
+
const ownerRepoResult = resolveOwnerRepo(git, cwd);
|
|
316
|
+
if ('needsHuman' in ownerRepoResult)
|
|
317
|
+
return ownerRepoResult;
|
|
318
|
+
const { ownerRepo } = ownerRepoResult;
|
|
319
|
+
// 2. Fetch base
|
|
320
|
+
git(['fetch', 'origin', input.base], cwd);
|
|
321
|
+
// 3. Branch create-if-absent; never clobber a prior commit
|
|
322
|
+
if (branchExists(git, cwd, branch)) {
|
|
323
|
+
git(['switch', branch], cwd);
|
|
324
|
+
}
|
|
325
|
+
else {
|
|
326
|
+
git(['switch', '-c', branch, `origin/${input.base}`], cwd);
|
|
327
|
+
}
|
|
328
|
+
// 4. Stage all changes (safe: clean-repo precondition from preflight)
|
|
329
|
+
git(['add', '-A'], cwd);
|
|
330
|
+
// 5. Commit decision (B4 replay safety)
|
|
331
|
+
let hasStagedDiff;
|
|
332
|
+
try {
|
|
333
|
+
git(['diff', '--cached', '--quiet'], cwd);
|
|
334
|
+
hasStagedDiff = false; // exit 0 → nothing staged
|
|
335
|
+
}
|
|
336
|
+
catch {
|
|
337
|
+
hasStagedDiff = true; // exit 1 → staged diff present
|
|
338
|
+
}
|
|
339
|
+
if (hasStagedDiff) {
|
|
340
|
+
// Commit — NO Co-Authored-By, NO summary footer (MEMORY)
|
|
341
|
+
const commitMsg = `feat: ${input.title}`;
|
|
342
|
+
git(['commit', '-m', commitMsg], cwd);
|
|
343
|
+
}
|
|
344
|
+
else {
|
|
345
|
+
// No staged diff — check if branch is ahead of origin/<base>
|
|
346
|
+
const ahead = countAhead(git, cwd, branch, input.base);
|
|
347
|
+
if (ahead === 0) {
|
|
348
|
+
// Nothing to integrate — no commit, not ahead
|
|
349
|
+
return {
|
|
350
|
+
needsHuman: true,
|
|
351
|
+
lesson: 'nothing to integrate — no staged changes and branch is not ahead of origin/' + input.base,
|
|
352
|
+
};
|
|
353
|
+
}
|
|
354
|
+
// Ahead but no staged diff → commit happened on a prior attempt; fall through to push
|
|
355
|
+
}
|
|
356
|
+
// 6. Push (idempotent — no force)
|
|
357
|
+
git(['push', '-u', 'origin', branch], cwd);
|
|
358
|
+
// 7. Find-or-create PR
|
|
359
|
+
const prResult = findOrCreatePr(ownerRepo, branch, input.base, input.title, gh);
|
|
360
|
+
if ('needsHuman' in prResult)
|
|
361
|
+
return prResult;
|
|
362
|
+
return { prUrl: prResult.prUrl, branch, prNumber: prResult.prNumber };
|
|
363
|
+
}
|
|
364
|
+
// ─── IntegratorService ─────────────────────────────────────────────────────────
|
|
365
|
+
/** Default execGit implementation wrapping execFileSync with a resolved absolute path. */
|
|
366
|
+
function defaultExecGit(args, cwd) {
|
|
367
|
+
return execFileSync(gitAbsPath(), args, { encoding: 'utf8', cwd, timeout: 60_000 });
|
|
368
|
+
}
|
|
369
|
+
/**
|
|
370
|
+
* IntegratorService — @Injectable wrapper over integrate / stubIntegrate / preflightLive.
|
|
371
|
+
* Exposes bound arrow properties so they survive being passed to registerStep unbound.
|
|
372
|
+
* DBOS-SEALED: zero @dbos-inc imports; PipelineService registers these as steps.
|
|
373
|
+
*/
|
|
374
|
+
let IntegratorService = class IntegratorService {
|
|
375
|
+
runService;
|
|
376
|
+
deps;
|
|
377
|
+
constructor(runService) {
|
|
378
|
+
this.runService = runService;
|
|
379
|
+
// execGh is resolved per-run inside runIntegrate (fail-loud on an unresolved pinned identity),
|
|
380
|
+
// so it is NOT built here — only the git + cwd deps are stable at construction.
|
|
381
|
+
this.deps = {
|
|
382
|
+
execGit: defaultExecGit,
|
|
383
|
+
resolveTaskCwd: this.runService.makeResolveTaskCwd(),
|
|
384
|
+
};
|
|
385
|
+
}
|
|
386
|
+
/**
|
|
387
|
+
* Real integrator — live path. Arrow property: safe to pass unbound to registerStep.
|
|
388
|
+
*
|
|
389
|
+
* 0008 #1 (fail-loud, 2026-06-12 dogfood): resolve the PINNED gh identity first. If its token
|
|
390
|
+
* cannot be resolved we REFUSE to fall back to the ambient gh account (which would open the PR
|
|
391
|
+
* as the wrong user) and block as needsHuman instead. Only on success do we run the integrator
|
|
392
|
+
* with the pinned execGh.
|
|
393
|
+
*/
|
|
394
|
+
runIntegrate = (input) => {
|
|
395
|
+
const pinned = resolvePinnedGh();
|
|
396
|
+
if ('needsHuman' in pinned) {
|
|
397
|
+
console.warn(`[integrator] ${pinned.lesson}`);
|
|
398
|
+
return Promise.resolve(pinned);
|
|
399
|
+
}
|
|
400
|
+
console.log(`[integrator] gh pinned to account '${resolveGhAccount()}' (GH_TOKEN, not ambient)`);
|
|
401
|
+
return integrate(input, { ...this.deps, execGh: pinned.execGh });
|
|
402
|
+
};
|
|
403
|
+
/** Stub integrator — script path; zero external effects. */
|
|
404
|
+
runStub = (input) => {
|
|
405
|
+
return stubIntegrate(input);
|
|
406
|
+
};
|
|
407
|
+
/** Live preflight — clean check + base invariant. Arrow property for safe unbound registration. */
|
|
408
|
+
runPreflight = (taskId, base) => {
|
|
409
|
+
return preflightLive(taskId, base, this.deps);
|
|
410
|
+
};
|
|
411
|
+
};
|
|
412
|
+
IntegratorService = __decorate([
|
|
413
|
+
Injectable(),
|
|
414
|
+
__metadata("design:paramtypes", [RunService])
|
|
415
|
+
], IntegratorService);
|
|
416
|
+
export { IntegratorService };
|
|
417
|
+
//# sourceMappingURL=integrator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"integrator.js","sourceRoot":"","sources":["../../src/runners/integrator.ts"],"names":[],"mappings":";;;;;;;;;AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC/C,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAErE,iFAAiF;AAEjF;;;;;;;;GAQG;AACH,MAAM,UAAU,iBAAiB,CAAC,IAAY,EAAE,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE;IACjF,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,8BAA8B,IAAI,mCAAmC,CAAC,CAAC;IACzF,CAAC;IAED,MAAM,IAAI,GAAG,OAAO,CAAC,KAAK,CAAC,SAA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AG,CAAC,sCAAsC,gBAAgB,EAAE,2BAA2B,CAAC,CAAC;QACjG,OAAO,SAAS,CAAC,KAAK,EAAE,EAAE,GAAG,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;IACnE,CAAC,CAAC;IAEF,4DAA4D;IAC5D,OAAO,GAAG,CAAC,KAAsB,EAAoB,EAAE;QACrD,OAAO,aAAa,CAAC,KAAK,CAAC,CAAC;IAC9B,CAAC,CAAC;IAEF,mGAAmG;IACnG,YAAY,GAAG,CAAC,MAAc,EAAE,IAAY,EAA6C,EAAE;QACzF,OAAO,aAAa,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;IAChD,CAAC,CAAC;CACH,CAAA;AAvCY,iBAAiB;IAD7B,UAAU,EAAE;qCAI8B,UAAU;GAHxC,iBAAiB,CAuC7B"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* RunnerModule — provides RUN_AGENT and IntegratorService.
|
|
9
|
+
*
|
|
10
|
+
* Default PROCESS_EXECUTOR = spawnExecutor (real). Tests override with a fake.
|
|
11
|
+
* DBOS-SEALED: zero @dbos-inc imports.
|
|
12
|
+
*/
|
|
13
|
+
import { Module } from '@nestjs/common';
|
|
14
|
+
import { RevisiumModule } from '../revisium/revisium.module.js';
|
|
15
|
+
import { ClaudeCodeService } from './claude-code.service.js';
|
|
16
|
+
import { IntegratorService } from './integrator.js';
|
|
17
|
+
import { PROCESS_EXECUTOR, RUN_AGENT } from './tokens.js';
|
|
18
|
+
import { spawnExecutor } from '../worker/process-executor.js';
|
|
19
|
+
import { stubRunAgent } from '../worker/stub-runner.js';
|
|
20
|
+
import { createRunAgent } from '../worker/runner-dispatch.js';
|
|
21
|
+
let RunnerModule = class RunnerModule {
|
|
22
|
+
};
|
|
23
|
+
RunnerModule = __decorate([
|
|
24
|
+
Module({
|
|
25
|
+
imports: [RevisiumModule],
|
|
26
|
+
providers: [
|
|
27
|
+
ClaudeCodeService,
|
|
28
|
+
IntegratorService,
|
|
29
|
+
{ provide: PROCESS_EXECUTOR, useValue: spawnExecutor },
|
|
30
|
+
{
|
|
31
|
+
provide: RUN_AGENT,
|
|
32
|
+
useFactory: (cc) => createRunAgent({ claudeCode: cc.run, script: stubRunAgent }),
|
|
33
|
+
inject: [ClaudeCodeService],
|
|
34
|
+
},
|
|
35
|
+
],
|
|
36
|
+
exports: [RUN_AGENT, IntegratorService],
|
|
37
|
+
})
|
|
38
|
+
], RunnerModule);
|
|
39
|
+
export { RunnerModule };
|
|
40
|
+
//# sourceMappingURL=runner.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runner.module.js","sourceRoot":"","sources":["../../src/runners/runner.module.ts"],"names":[],"mappings":";;;;;;AAAA;;;;;GAKG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAiBvD,IAAM,YAAY,GAAlB,MAAM,YAAY;CAAG,CAAA;AAAf,YAAY;IAfxB,MAAM,CAAC;QACN,OAAO,EAAE,CAAC,cAAc,CAAC;QACzB,SAAS,EAAE;YACT,iBAAiB;YACjB,iBAAiB;YACjB,EAAE,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,aAAa,EAAE;YACtD;gBACE,OAAO,EAAE,SAAS;gBAClB,UAAU,EAAE,CAAC,EAAqB,EAAE,EAAE,CACpC,cAAc,CAAC,EAAE,UAAU,EAAE,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,YAAY,EAAE,CAAC;gBAC9D,MAAM,EAAE,CAAC,iBAAiB,CAAC;aAC5B;SACF;QACD,OAAO,EAAE,CAAC,SAAS,EAAE,iBAAiB,CAAC;KACxC,CAAC;GACW,YAAY,CAAG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tokens.js","sourceRoot":"","sources":["../../src/runners/tokens.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,MAAM,CAAC,WAAW,CAAC,CAAC;AAC7C,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAC,kBAAkB,CAAC,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { Injectable } from '@nestjs/common';
|
|
8
|
+
import { collectPrReadiness, } from '../poller/pr-readiness-core.js';
|
|
9
|
+
let PrReadinessService = class PrReadinessService {
|
|
10
|
+
getPrReadiness(input) {
|
|
11
|
+
return collectPrReadiness(this.toCoreInput(input));
|
|
12
|
+
}
|
|
13
|
+
async listPrFeedback(input) {
|
|
14
|
+
const readiness = await this.getPrReadiness(input);
|
|
15
|
+
return readiness.feedback;
|
|
16
|
+
}
|
|
17
|
+
toCoreInput(input) {
|
|
18
|
+
return {
|
|
19
|
+
repo: input.repo,
|
|
20
|
+
prNumber: input.prNumber,
|
|
21
|
+
headBranch: input.headBranch,
|
|
22
|
+
baseBranch: input.baseBranch ?? 'master',
|
|
23
|
+
sonarProject: input.sonarProject,
|
|
24
|
+
includeComments: input.includeComments ?? true,
|
|
25
|
+
includeReviewThreads: input.includeReviewThreads ?? true,
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
PrReadinessService = __decorate([
|
|
30
|
+
Injectable()
|
|
31
|
+
], PrReadinessService);
|
|
32
|
+
export { PrReadinessService };
|
|
33
|
+
//# sourceMappingURL=pr-readiness.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pr-readiness.service.js","sourceRoot":"","sources":["../../src/task-control-plane/pr-readiness.service.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EACL,kBAAkB,GAGnB,MAAM,gCAAgC,CAAC;AAuBjC,IAAM,kBAAkB,GAAxB,MAAM,kBAAkB;IAC7B,cAAc,CAAC,KAA0B;QACvC,OAAO,kBAAkB,CAAC,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC;IACrD,CAAC;IAED,KAAK,CAAC,cAAc,CAAC,KAA0B;QAC7C,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;QACnD,OAAO,SAAS,CAAC,QAAQ,CAAC;IAC5B,CAAC;IAEO,WAAW,CAAC,KAA0B;QAC5C,OAAO;YACL,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,QAAQ,EAAE,KAAK,CAAC,QAAQ;YACxB,UAAU,EAAE,KAAK,CAAC,UAAU;YAC5B,UAAU,EAAE,KAAK,CAAC,UAAU,IAAI,QAAQ;YACxC,YAAY,EAAE,KAAK,CAAC,YAAY;YAChC,eAAe,EAAE,KAAK,CAAC,eAAe,IAAI,IAAI;YAC9C,oBAAoB,EAAE,KAAK,CAAC,oBAAoB,IAAI,IAAI;SACzD,CAAC;IACJ,CAAC;CACF,CAAA;AArBY,kBAAkB;IAD9B,UAAU,EAAE;GACA,kBAAkB,CAqB9B"}
|