ensemble-review 1.0.35 → 1.0.37
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/dist/api/plugins/rate-limit.js +22 -0
- package/dist/api/routes/releases.js +181 -0
- package/dist/app.js +3 -0
- package/dist/coding/story-build/base-refs.js +10 -2
- package/dist/coding/story-build/loop/driver.js +1 -1
- package/dist/coding/story-build/loop/routes.js +9 -1
- package/dist/coding/story-build/persist.js +53 -7
- package/dist/coding/story-build/plan-persist.js +1 -1
- package/dist/coding/story-build/push-hotfix.js +293 -0
- package/dist/coding/story-build/push.js +5 -0
- package/dist/coding/story-build/routes-build.js +25 -3
- package/dist/db/erase-account.js +14 -0
- package/dist/db/hotfix-bases.js +31 -0
- package/dist/db/migrations/0195_releases.sql +128 -0
- package/dist/db/migrations/0196_story_build_hotfix.sql +54 -0
- package/dist/db/migrations/0197_release_items_live_tag.sql +11 -0
- package/dist/db/migrations/0198_story_build_port_report.sql +7 -0
- package/dist/db/migrations/meta/_journal.json +28 -0
- package/dist/db/queries.js +21 -0
- package/dist/db/release-check.js +378 -0
- package/dist/db/release-settings.js +94 -0
- package/dist/db/repo-tags.js +82 -0
- package/dist/db/schema.sqlite.js +246 -0
- package/dist/github/mutations.js +67 -0
- package/dist/github/queries.js +5 -0
- package/dist/github/settle-query.js +11 -1
- package/dist/github/tag-queries.js +101 -0
- package/dist/releases/create.js +539 -0
- package/dist/releases/github.js +78 -0
- package/dist/releases/notes.js +152 -0
- package/dist/releases/refresh.js +43 -0
- package/dist/sandbox/session/manager.js +207 -12
- package/dist/sandbox/session/plan.js +19 -7
- package/dist/sandbox/session/routes.js +12 -2
- package/dist/sandbox/workspace/hotfix.js +30 -0
- package/dist/sandbox/workspace/index.js +38 -2
- package/dist/sandbox/workspace/port-report.js +137 -0
- package/dist/sandbox/workspace/seed.js +40 -0
- package/dist/shared/hotfix.js +165 -0
- package/dist/shared/index.js +4 -0
- package/dist/shared/release-check.js +528 -0
- package/dist/shared/release-write.js +264 -0
- package/dist/shared/releases.js +89 -0
- package/dist/shared/story-build.js +2 -0
- package/dist/sync/repo-tags.js +368 -0
- package/dist/sync/settle-sweep.js +47 -2
- package/dist/sync/sync-repo.js +12 -0
- package/dist/sync/tag-ranges.js +350 -0
- package/dist/sync/tags-step.js +77 -0
- package/dist/sync/upsert.js +23 -0
- package/package.json +5 -2
- package/public/assets/{AiFixTab-CVIZl9I8.js → AiFixTab-BC3tDZ3z.js} +1 -1
- package/public/assets/{PrBotBehaviourTab-q0M7RU1e.js → PrBotBehaviourTab-C5j5uhLn.js} +1 -1
- package/public/assets/index-BrjUDY3j.js +138 -0
- package/public/assets/index-D1zhsqSF.css +1 -0
- package/public/index.html +2 -2
- package/dist/ai/check-tool.js +0 -6
- package/dist/api/routes/auth.js +0 -194
- package/dist/api/routes/billing.js +0 -209
- package/dist/api/routes/claude-review.js +0 -522
- package/dist/api/routes/contact.js +0 -318
- package/dist/api/routes/feed.js +0 -21
- package/dist/api/routes/inbox.js +0 -45
- package/dist/api/routes/mentions.js +0 -22
- package/dist/api/routes/teams.js +0 -150
- package/dist/api/routes/webhooks.js +0 -181
- package/dist/coding/activity.js +0 -80
- package/dist/coding/agent.js +0 -147
- package/dist/coding/ai-fix/checks-preview.js +0 -58
- package/dist/coding/ai-fix/comment-seed.js +0 -519
- package/dist/coding/ai-fix/prompts.js +0 -283
- package/dist/coding/ai-resolve/prompt.js +0 -161
- package/dist/coding/ai-resolve/routes.js +0 -97
- package/dist/coding/ai-resolve/run.js +0 -343
- package/dist/coding/ai-resolve/schema.js +0 -26
- package/dist/coding/ai-resolve/validate.js +0 -136
- package/dist/coding/checks/deny-scan.js +0 -75
- package/dist/coding/checks/discover.js +0 -541
- package/dist/coding/checks/docker.js +0 -38
- package/dist/coding/checks/env.js +0 -88
- package/dist/coding/checks/hooks.js +0 -91
- package/dist/coding/checks/index.js +0 -8
- package/dist/coding/checks/local.js +0 -40
- package/dist/coding/checks/sandbox.js +0 -206
- package/dist/coding/checks/session.js +0 -518
- package/dist/coding/checks/spawn.js +0 -123
- package/dist/coding/checks/spec.js +0 -140
- package/dist/coding/checks/types.js +0 -6
- package/dist/coding/partial-spend.js +0 -19
- package/dist/coding/safe-path.js +0 -75
- package/dist/coding/story-build/build-prompts.js +0 -178
- package/dist/coding/story-build/build.js +0 -332
- package/dist/coding/story-build/checkouts.js +0 -66
- package/dist/coding/story-build/docs-runner.js +0 -178
- package/dist/coding/story-build/docs.js +0 -334
- package/dist/coding/story-build/manager.js +0 -999
- package/dist/coding/story-build/plan-agent.js +0 -190
- package/dist/coding/story-build/plan.js +0 -338
- package/dist/coding/story-build/prompts.js +0 -147
- package/dist/coding/story-build/routes-docs.js +0 -113
- package/dist/coding/story-build/routes.js +0 -295
- package/dist/coding/story-build/schema.js +0 -53
- package/dist/db/automation-output.js +0 -349
- package/dist/db/credits.js +0 -79
- package/dist/db/schema.js +0 -321
- package/dist/db/schema.pg.js +0 -2197
- package/dist/db/sprint-repo-suggest.js +0 -257
- package/dist/db/sprint-stories.js +0 -42
- package/dist/db/sprint-story.js +0 -505
- package/dist/db/sprint-ticket-repos.js +0 -195
- package/dist/db/story-selection.js +0 -270
- package/dist/db/team-comparison.js +0 -124
- package/dist/db/workspace-comparison.js +0 -98
- package/dist/feed/fyi-provider.js +0 -10
- package/dist/github/local-user.js +0 -92
- package/dist/github/repo-files.js +0 -26
- package/dist/ml/worker.js +0 -31
- package/dist/platform/advisor/discovery/tier2.js +0 -88
- package/dist/platform/advisor/discovery/tier3.js +0 -57
- package/dist/platform/advisor/emitters/adapter.js +0 -5
- package/dist/platform/advisor/emitters/coderabbit.js +0 -175
- package/dist/platform/advisor/emitters/copilot-prose.js +0 -118
- package/dist/platform/advisor/emitters/greptile.js +0 -176
- package/dist/platform/advisor/emitters/lint.js +0 -37
- package/dist/platform/advisor/emitters/manifest.js +0 -239
- package/dist/platform/advisor/emitters/prose.js +0 -183
- package/dist/platform/advisor/emitters/registry.js +0 -20
- package/dist/platform/advisor/emitters/yaml-doc.js +0 -95
- package/dist/platform/advisor/evidence.js +0 -79
- package/dist/platform/advisor/findings.js +0 -15
- package/dist/platform/advisor/intents.js +0 -269
- package/dist/platform/advisor/measure/effect.js +0 -18
- package/dist/platform/advisor/outputs/brief.js +0 -68
- package/dist/platform/advisor/outputs/config-pr.js +0 -156
- package/dist/platform/advisor/refine/diff-guard.js +0 -38
- package/dist/platform/advisor/refine/refine.js +0 -35
- package/dist/platform/advisor/retro-check.js +0 -98
- package/dist/platform/advisor/routes.js +0 -648
- package/dist/platform/advisor/store.js +0 -321
- package/dist/platform/advisor/taxonomy.js +0 -67
- package/dist/platform/annotations/prompts.js +0 -84
- package/dist/platform/annotations/routes.js +0 -86
- package/dist/platform/annotations/runner.js +0 -234
- package/dist/platform/annotations/targets.js +0 -203
- package/dist/platform/insights/grounded-figures.js +0 -162
- package/dist/platform/insights/period-questions.js +0 -235
- package/dist/platform/work-plan/hash.js +0 -99
- package/dist/platform/work-plan/prompt.js +0 -209
- package/dist/platform/work-plan/routes.js +0 -350
- package/dist/pro/bind.js +0 -309
- package/dist/pro/contract.js +0 -36
- package/dist/pro/event-hooks.js +0 -37
- package/dist/pro/migrate.js +0 -64
- package/dist/review/events.js +0 -24
- package/dist/review/local-settings.js +0 -78
- package/dist/review/memory/capture.js +0 -0
- package/dist/review/memory/retrieval.js +0 -272
- package/dist/review/memory/routes.js +0 -78
- package/dist/review/persist.js +0 -203
- package/dist/review/plugin-providers.js +0 -12
- package/dist/review/prompt.js +0 -264
- package/dist/review/review-manager.js +0 -259
- package/dist/review/routing.js +0 -164
- package/dist/review/sprint-assess/agent.js +0 -145
- package/dist/review/sprint-assess/manager.js +0 -382
- package/dist/review/sprint-assess/prompts.js +0 -99
- package/dist/review/sprint-assess/routes.js +0 -109
- package/dist/review/sprint-assess/schema.js +0 -70
- package/dist/review/sprint-assess/validate.js +0 -180
- package/dist/review/sprint-story/manager.js +0 -98
- package/dist/review/sprint-story/prompt.js +0 -45
- package/dist/review/sprint-story/validate.js +0 -127
- package/dist/review/story-docs/build-prompts.js +0 -153
- package/dist/review/story-docs/build-validate.js +0 -162
- package/dist/review/story-report/agent.js +0 -203
- package/dist/review/story-report/fingerprint.js +0 -45
- package/dist/review/story-report/manager.js +0 -287
- package/dist/review/story-report/routes.js +0 -154
- package/dist/review/story-report/story-detail.js +0 -148
- package/dist/review/story-report/validate.js +0 -105
- package/dist/review/ticket-review/sweep-waits.js +0 -20
- package/dist/review/write-deny.js +0 -170
- package/dist/shared/conflict-ai.js +0 -24
- package/dist/sync/benchmark-rollup.js +0 -50
- package/public/assets/index-CbEfmqOD.css +0 -1
- package/public/assets/index-DBK4RWQu.js +0 -136
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BUILD_PLAN_API, BUILD_PLAN_LIMITS, DEFAULT_CLAUDE_REVIEW_MODEL, SANDBOX_MESSAGE_MAX, SANDBOX_SESSION_API, STORY_BUILD_API, TICKET_IDENT_MAX_CHARS, parseTicketIdent, } from '../../shared/index.js';
|
|
1
|
+
import { BUILD_PLAN_API, HOTFIX_NOT_OFFERED_LINE, HOTFIX_NO_LOOP_LINE, BUILD_PLAN_LIMITS, DEFAULT_CLAUDE_REVIEW_MODEL, SANDBOX_MESSAGE_MAX, SANDBOX_SESSION_API, STORY_BUILD_API, TICKET_IDENT_MAX_CHARS, parseTicketIdent, } from '../../shared/index.js';
|
|
2
2
|
import { preflightFor, resolveManualRunChoice } from '../../ai/run-choice.js';
|
|
3
3
|
import { getStoryBuildRow, listStoryBuildRepoRows, listStoryBuildRowsFor, storyBuildRepoNames, toStoryBuildSummary } from '../../coding/story-build/persist.js';
|
|
4
4
|
import { registerStoryBuildBuildRoutes } from '../../coding/story-build/routes-build.js';
|
|
@@ -8,7 +8,7 @@ import { toStoryBuildTeamClaim } from '../../coding/story-build/build-claim.js';
|
|
|
8
8
|
import { noteBuildClaimAttempted, workspaceRepoNames } from '../../coding/story-build/build-claim-release.js';
|
|
9
9
|
import { AGENTIC_AI_ENABLED } from '../../review/claude-review/manager.js';
|
|
10
10
|
import { resolveSandboxAgentChoice } from '../drivers/index.js';
|
|
11
|
-
import { allowSessionHost, approveSessionPlan, decideSessionPlan, replySessionPlan, sessionPlanRevision, discardSession, interruptSession, resumeSession, sendSessionMessage, sessionDocsAvailable, sessionStoryInputs, sessionWire, startSession, startSessionBuild, subscribeSession, } from './manager.js';
|
|
11
|
+
import { allowSessionHost, approveSessionPlan, decideSessionPlan, replySessionPlan, sessionPlanRevision, discardSession, interruptSession, resumeSession, sendSessionMessage, sessionDocsAvailable, sessionHotfixBases, sessionStoryInputs, sessionWire, startSession, startSessionBuild, subscribeSession, } from './manager.js';
|
|
12
12
|
const fail = (reply, status, error, message) => {
|
|
13
13
|
reply.status(status);
|
|
14
14
|
return { error, message };
|
|
@@ -215,6 +215,8 @@ export function registerSandboxSessionRoutes(app, ctx) {
|
|
|
215
215
|
autoApprovePlan: { type: 'boolean' },
|
|
216
216
|
// "Build end to end" (docs/STORY-BUILD.md § Build end to end): implies the two above + the ticket step.
|
|
217
217
|
endToEnd: { type: 'boolean' },
|
|
218
|
+
// "Treat as a hotfix" (docs/STORY-BUILD.md § Hotfix builds): refused with autoPush / endToEnd.
|
|
219
|
+
hotfix: { type: 'boolean' },
|
|
218
220
|
},
|
|
219
221
|
},
|
|
220
222
|
},
|
|
@@ -238,6 +240,13 @@ export function registerSandboxSessionRoutes(app, ctx) {
|
|
|
238
240
|
const code = picked.error === 'ModelNotOnProvider' || picked.error === 'NoClaudeAuth' ? picked.error : 'BadRequest';
|
|
239
241
|
return fail(reply, 400, code, picked.message);
|
|
240
242
|
}
|
|
243
|
+
// HOTFIX: the review loop and Build end to end are off for it (v1), and it needs a release to start from.
|
|
244
|
+
const hotfix = body.hotfix === true;
|
|
245
|
+
if (hotfix && (body.autoPush === true || body.endToEnd === true))
|
|
246
|
+
return fail(reply, 400, 'HotfixNoLoop', HOTFIX_NO_LOOP_LINE);
|
|
247
|
+
if (hotfix && !(await sessionHotfixBases(accountId, scope.workspaceId, scope.repoIds)).offered) {
|
|
248
|
+
return fail(reply, 400, 'HotfixNotOffered', HOTFIX_NOT_OFFERED_LINE);
|
|
249
|
+
}
|
|
241
250
|
// The cheap DB check first (the fresh tracker read happens in the boot): no story ⇒ no sandbox.
|
|
242
251
|
const inputs = await sessionStoryInputs(ctx, accountId, scope.workspaceId, body.ident);
|
|
243
252
|
if (inputs == null || inputs.empty)
|
|
@@ -269,6 +278,7 @@ export function registerSandboxSessionRoutes(app, ctx) {
|
|
|
269
278
|
...(body.loopRounds !== undefined ? { loopRounds: body.loopRounds } : {}),
|
|
270
279
|
autoApprovePlan: body.autoApprovePlan === true || body.endToEnd === true,
|
|
271
280
|
endToEnd: body.endToEnd === true,
|
|
281
|
+
...(hotfix ? { hotfix: true } : {}),
|
|
272
282
|
choice: resolveSandboxAgentChoice({ provider: picked.provider, model: picked.model }),
|
|
273
283
|
});
|
|
274
284
|
if (r.outcome === 'no_runtime')
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// A HOTFIX BUILD'S SECOND CHECKOUT (docs/STORY-BUILD.md § Hotfix builds; docs/SANDBOX.md § The workspace
|
|
2
|
+
// mirror). Each repository with a latest release is mirrored TWICE: the release checkout at its layout path
|
|
3
|
+
// (at the release commit) and a MAIN checkout beside it (at the default branch's head), so the agent ports the
|
|
4
|
+
// fix in the same sandbox. Both are ordinary mirrored repositories (mirror.ts): their own `refs/limn/base`,
|
|
5
|
+
// their own patch. Pure.
|
|
6
|
+
import { posix } from 'node:path';
|
|
7
|
+
/** The suffix of a main checkout's folder: `<release path>.main`. */
|
|
8
|
+
export const MAIN_CHECKOUT_SUFFIX = '.main';
|
|
9
|
+
/**
|
|
10
|
+
* The main checkout's path for each of `repoIds`: `<path>.main` beside the release checkout (inside the same
|
|
11
|
+
* session volume), or `<path>.main-2`, `-3`, … when that path is taken by — or sits inside, or holds — another
|
|
12
|
+
* repository of the layout. Pure.
|
|
13
|
+
*/
|
|
14
|
+
export function mainCheckoutPaths(layout, repoIds) {
|
|
15
|
+
const taken = new Set(layout.repos.map((r) => posix.normalize(r.path)));
|
|
16
|
+
const clashes = (p) => [...taken].some((t) => t === p || t.startsWith(`${p}/`) || p.startsWith(`${t}/`));
|
|
17
|
+
const out = new Map();
|
|
18
|
+
for (const r of layout.repos) {
|
|
19
|
+
if (!repoIds.has(r.repoId))
|
|
20
|
+
continue;
|
|
21
|
+
const base = `${posix.normalize(r.path)}${MAIN_CHECKOUT_SUFFIX}`;
|
|
22
|
+
let p = base;
|
|
23
|
+
for (let n = 2; clashes(p); n += 1)
|
|
24
|
+
p = `${base}-${n}`;
|
|
25
|
+
taken.add(p);
|
|
26
|
+
out.set(r.repoId, p);
|
|
27
|
+
}
|
|
28
|
+
return out;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=hotfix.js.map
|
|
@@ -11,12 +11,14 @@ import { posix } from 'node:path';
|
|
|
11
11
|
import { readSmallFile } from './memories.js';
|
|
12
12
|
import { mirrorRepos, prepareSandboxGit, readerFiles } from './mirror.js';
|
|
13
13
|
import { buildSeed } from './seed.js';
|
|
14
|
+
import { mainCheckoutPaths } from './hotfix.js';
|
|
14
15
|
import { folderClaudeMdPath } from './check.js';
|
|
15
16
|
import { STORE_MOUNT } from '../runtime/labels.js';
|
|
16
17
|
export { resolveWorkspaceLayout, toFolderCheck, defaultLayoutPlaces, folderClaudeMdPath } from './check.js';
|
|
17
18
|
export { readSessionTicket } from './ticket.js';
|
|
18
19
|
export { buildSeed, sessionBranch, fixSessionBranch, SANDBOX_HOME } from './seed.js';
|
|
19
20
|
export { SANDBOX_BASE_REF } from './mirror.js';
|
|
21
|
+
export { mainCheckoutPaths, MAIN_CHECKOUT_SUFFIX } from './hotfix.js';
|
|
20
22
|
export const FOLDER_CLAUDE_MD_MAX_BYTES = 64 * 1024;
|
|
21
23
|
/**
|
|
22
24
|
* The session volume at the layout's ROOT, and the container's working folder. ⚠ The working folder is
|
|
@@ -51,6 +53,22 @@ export async function prepareSessionWorkspace(runtime, container, a) {
|
|
|
51
53
|
for (const f of mirror.failed)
|
|
52
54
|
notes.push(`${f.fullName} could not be cloned: ${f.reason}`);
|
|
53
55
|
notes.push(...mirror.notes);
|
|
56
|
+
// HOTFIX: the main checkouts, beside the release checkouts that cloned.
|
|
57
|
+
let mainMirror;
|
|
58
|
+
if (a.hotfix != null && a.hotfix.mainBases.size > 0) {
|
|
59
|
+
const want = new Set(mirror.repos.map((r) => r.repoId).filter((id) => a.hotfix.mainBases.has(id)));
|
|
60
|
+
const paths = mainCheckoutPaths(layout, want);
|
|
61
|
+
const mainLayout = { ...layout, repos: layout.repos.filter((r) => paths.has(r.repoId)).map((r) => ({ ...r, path: paths.get(r.repoId) })) };
|
|
62
|
+
a.onProgress?.('Loading the main checkouts');
|
|
63
|
+
mainMirror = await mirrorRepos(runtime, container, mainLayout, a.hotfix.mainBases, a.branch, {
|
|
64
|
+
seams: a.seams,
|
|
65
|
+
signal: a.signal,
|
|
66
|
+
store: a.store ?? null,
|
|
67
|
+
localClones: localClonesOf(a.resolved),
|
|
68
|
+
});
|
|
69
|
+
for (const f of mainMirror.failed)
|
|
70
|
+
notes.push(`The main checkout of ${f.fullName} could not be cloned: ${f.reason}`);
|
|
71
|
+
}
|
|
54
72
|
const docs = a.docs ? await a.docs(mirror) : null;
|
|
55
73
|
const services = typeof a.services === 'function' ? await a.services(mirror) : a.services;
|
|
56
74
|
const seedNotes = [...notes];
|
|
@@ -93,9 +111,27 @@ export async function prepareSessionWorkspace(runtime, container, a) {
|
|
|
93
111
|
};
|
|
94
112
|
if (a.fix == null && a.ticket == null)
|
|
95
113
|
throw new Error('A session needs a ticket or a fix to seed.');
|
|
96
|
-
const
|
|
114
|
+
const hotfix = a.hotfix != null ? hotfixSeedOf(mirror, mainMirror ?? null, a.hotfix) : null;
|
|
115
|
+
const seed = a.fix != null
|
|
116
|
+
? buildSeed({ ...common, kind: 'fix', fix: a.fix })
|
|
117
|
+
: buildSeed({ ...common, ticket: a.ticket, mode: a.mode ?? 'implement', planFirst: a.planFirst === true, docs, ...(hotfix ? { hotfix } : {}) });
|
|
97
118
|
await runtime.copyIn(container, seed.files);
|
|
98
|
-
return { mirror, seed, notes };
|
|
119
|
+
return { mirror, seed, notes, ...(mainMirror ? { mainMirror } : {}) };
|
|
120
|
+
}
|
|
121
|
+
/** The seed's hotfix facts: every cloned repository, its release (or read only) and its main checkout. Pure. */
|
|
122
|
+
export function hotfixSeedOf(mirror, mainMirror, h) {
|
|
123
|
+
return {
|
|
124
|
+
repos: mirror.repos.map((r) => {
|
|
125
|
+
const rel = h.releases.get(r.repoId);
|
|
126
|
+
const main = mainMirror?.repos.find((m) => m.repoId === r.repoId);
|
|
127
|
+
return {
|
|
128
|
+
repoId: r.repoId,
|
|
129
|
+
fullName: r.fullName,
|
|
130
|
+
release: rel ? { tagName: rel.tagName, path: r.path, hotfixBranch: rel.hotfixBranch } : null,
|
|
131
|
+
main: rel && main ? { path: main.path, label: h.mainLabels.get(r.repoId) ?? 'the default branch', sha: main.sha } : null,
|
|
132
|
+
};
|
|
133
|
+
}),
|
|
134
|
+
};
|
|
99
135
|
}
|
|
100
136
|
/** The cloned repositories' own skills, read from Limn's clone cache at each repository's base commit. */
|
|
101
137
|
async function cachedProjectSkills(repos) {
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
// A HOTFIX BUILD'S PORT REPORT, INSIDE THE SANDBOX (docs/STORY-BUILD.md § Hotfix builds → The port report;
|
|
2
|
+
// docs/RELEASES.md § Port report). A hotfix build fixes each repository's release checkout, then ports the fix
|
|
3
|
+
// to its main checkout. Before porting the agent reads the main checkout, and it ends every build turn with
|
|
4
|
+
// ONE JSON file, `<root>/.limn/port-report.json`: per repository it changed, what the port came to —
|
|
5
|
+
//
|
|
6
|
+
// { "repos": [ { "repo": "owner/name", "outcome": "same" | "adapted" | "not_needed",
|
|
7
|
+
// "reason": "one plain sentence", "evidence": ["path or commit", …] } ] }
|
|
8
|
+
//
|
|
9
|
+
// `reason` is required for `adapted` (what differs on main) and `not_needed` (why main does not need it).
|
|
10
|
+
// The agent checks the file with `node ~/.limn/port-report-check.cjs`; after every build turn the HOST reads it
|
|
11
|
+
// out and checks it AGAIN with the SAME validator text, against its own list of the build's hotfix
|
|
12
|
+
// repositories (never the sandbox's copy). The same file and checker for Claude and Codex.
|
|
13
|
+
//
|
|
14
|
+
// ⚠ ONE VALIDATOR (the build-report.ts pattern): `PORT_REPORT_VALIDATOR_SOURCE` is plain JavaScript text the
|
|
15
|
+
// checker embeds as it is and the host compiles. Our own constant, never data; ES2019, nothing outside it.
|
|
16
|
+
// ⚠ A SELF-REPORT and UNTRUSTED TEXT: an entry that fails the check is dropped (named in one notice), every
|
|
17
|
+
// kept reason is one clipped line (shared `hotfixPortClaimOf`), and the push defangs it for GitHub. The host
|
|
18
|
+
// checks the claim against the patches it extracted (shared `hotfixPortOf`); it never infers one.
|
|
19
|
+
import { posix } from 'node:path';
|
|
20
|
+
import { HOTFIX_PORT_EVIDENCE_ITEM_MAX, HOTFIX_PORT_EVIDENCE_MAX, HOTFIX_PORT_REASON_MAX, hotfixPortClaimOf, } from '../../shared/index.js';
|
|
21
|
+
/** The report file and the checker's context, relative to the layout root. */
|
|
22
|
+
export const PORT_REPORT_FILE = '.limn/port-report.json';
|
|
23
|
+
export const PORT_CONTEXT_FILE = '.limn/port-context.json';
|
|
24
|
+
/** The checker script, as the agent's own file (seed.ts `SANDBOX_HOME`). */
|
|
25
|
+
export const PORT_REPORT_CHECKER = '/home/agent/.limn/port-report-check.cjs';
|
|
26
|
+
export const PORT_REPORT_MAX_BYTES = 64 * 1024;
|
|
27
|
+
/** THE validator, as text. `(raw, ctx) → { entries, problems }`. */
|
|
28
|
+
export const PORT_REPORT_VALIDATOR_SOURCE = String.raw `function validatePortReport(raw, ctx) {
|
|
29
|
+
var p = [];
|
|
30
|
+
var REASON_MAX = ${HOTFIX_PORT_REASON_MAX};
|
|
31
|
+
var EVIDENCE_MAX = ${HOTFIX_PORT_EVIDENCE_MAX};
|
|
32
|
+
var ITEM_MAX = ${HOTFIX_PORT_EVIDENCE_ITEM_MAX};
|
|
33
|
+
if (raw === null || typeof raw !== 'object' || Array.isArray(raw)) return { entries: null, problems: ['The report must be one JSON object.'] };
|
|
34
|
+
if (!Array.isArray(raw.repos) || raw.repos.length > 50) return { entries: null, problems: ['"repos" must be a list of at most 50 entries.'] };
|
|
35
|
+
var known = Object.create(null);
|
|
36
|
+
for (var k = 0; k < ctx.repos.length; k++) known[ctx.repos[k]] = true;
|
|
37
|
+
var seen = Object.create(null);
|
|
38
|
+
var out = [];
|
|
39
|
+
for (var i = 0; i < raw.repos.length; i++) {
|
|
40
|
+
var e = raw.repos[i];
|
|
41
|
+
var at = '"repos"[' + i + ']';
|
|
42
|
+
if (e === null || typeof e !== 'object' || Array.isArray(e)) { p.push(at + ' must be an object.'); continue; }
|
|
43
|
+
var bad = false;
|
|
44
|
+
if (typeof e.repo !== 'string' || !known[e.repo]) { p.push(at + '.repo must be one of ' + (ctx.repos.length > 0 ? ctx.repos.join(', ') : '(no repository)') + '.'); bad = true; }
|
|
45
|
+
else if (seen[e.repo]) { p.push(at + '.repo ' + e.repo + ' is listed twice.'); bad = true; }
|
|
46
|
+
if (['same', 'adapted', 'not_needed'].indexOf(e.outcome) < 0) { p.push(at + '.outcome must be same, adapted or not_needed.'); bad = true; }
|
|
47
|
+
var hasReason = typeof e.reason === 'string' && e.reason.trim() !== '';
|
|
48
|
+
if (e.reason !== undefined && e.reason !== null && (typeof e.reason !== 'string' || e.reason.length > REASON_MAX)) { p.push(at + '.reason must be a string of at most ' + REASON_MAX + ' characters.'); bad = true; }
|
|
49
|
+
else if ((e.outcome === 'adapted' || e.outcome === 'not_needed') && !hasReason) { p.push(at + '.reason is required for ' + e.outcome + ': say in one sentence ' + (e.outcome === 'adapted' ? 'what is different on main.' : 'why main does not need the fix.')); bad = true; }
|
|
50
|
+
if (e.evidence !== undefined && e.evidence !== null) {
|
|
51
|
+
if (!Array.isArray(e.evidence) || e.evidence.length > EVIDENCE_MAX) { p.push(at + '.evidence must be a list of at most ' + EVIDENCE_MAX + ' entries.'); bad = true; }
|
|
52
|
+
else for (var j = 0; j < e.evidence.length; j++) if (typeof e.evidence[j] !== 'string' || e.evidence[j].length > ITEM_MAX) { p.push(at + '.evidence[' + j + '] must be a path or commit of at most ' + ITEM_MAX + ' characters.'); bad = true; }
|
|
53
|
+
}
|
|
54
|
+
if (bad) continue;
|
|
55
|
+
seen[e.repo] = true;
|
|
56
|
+
out.push({ repo: e.repo, outcome: e.outcome, reason: hasReason ? e.reason : null, evidence: Array.isArray(e.evidence) ? e.evidence : [] });
|
|
57
|
+
}
|
|
58
|
+
return { entries: out, problems: p };
|
|
59
|
+
}`;
|
|
60
|
+
let compiled = null;
|
|
61
|
+
/** The host's run of THE validator (the same text the checker embeds). Pure. */
|
|
62
|
+
export function validatePortReport(raw, ctx) {
|
|
63
|
+
// eslint-disable-next-line @typescript-eslint/no-implied-eval -- our own constant (see the header).
|
|
64
|
+
compiled ??= new Function(`return (${PORT_REPORT_VALIDATOR_SOURCE});`)();
|
|
65
|
+
return compiled(raw, { repos: [...ctx.repos] });
|
|
66
|
+
}
|
|
67
|
+
/** The kept entries as the host stores them, by `owner/name` (pure): reason and evidence one clipped line each. */
|
|
68
|
+
export function portClaimsOf(check) {
|
|
69
|
+
const out = new Map();
|
|
70
|
+
for (const e of check.entries ?? [])
|
|
71
|
+
out.set(e.repo, hotfixPortClaimOf({ outcome: e.outcome, reason: e.reason ?? null, evidence: e.evidence ?? [] }));
|
|
72
|
+
return out;
|
|
73
|
+
}
|
|
74
|
+
/** The checker the agent runs (CommonJS, Node only): reads the report and the context, prints OK or the problems. */
|
|
75
|
+
export function portReportCheckerSource(o) {
|
|
76
|
+
return [
|
|
77
|
+
'#!/usr/bin/env node',
|
|
78
|
+
'// Ensemble: checks the hotfix port report. Run: node ~/.limn/port-report-check.cjs',
|
|
79
|
+
"'use strict';",
|
|
80
|
+
"const fs = require('fs');",
|
|
81
|
+
`const REPORT = ${JSON.stringify(o.reportFile)};`,
|
|
82
|
+
`const CONTEXT = ${JSON.stringify(o.contextFile)};`,
|
|
83
|
+
`const MAX = ${PORT_REPORT_MAX_BYTES};`,
|
|
84
|
+
`const validatePortReport = ${PORT_REPORT_VALIDATOR_SOURCE};`,
|
|
85
|
+
'function fail(lines) { for (const l of lines) console.log(l); process.exit(1); }',
|
|
86
|
+
'let text;',
|
|
87
|
+
"try { text = fs.readFileSync(REPORT, 'utf8'); } catch (e) { fail(['No report: write ' + REPORT + ' first.']); }",
|
|
88
|
+
"if (Buffer.byteLength(text, 'utf8') > MAX) fail(['The report is larger than ' + MAX + ' bytes.']);",
|
|
89
|
+
'let raw;',
|
|
90
|
+
"try { raw = JSON.parse(text); } catch (e) { fail(['The report is not valid JSON: ' + e.message]); }",
|
|
91
|
+
'let ctx = { repos: [] };',
|
|
92
|
+
"try { ctx = JSON.parse(fs.readFileSync(CONTEXT, 'utf8')); } catch (e) { /* the shape rules still apply */ }",
|
|
93
|
+
'const r = validatePortReport(raw, ctx);',
|
|
94
|
+
"if (r.problems.length > 0) fail(['Fix these problems, then run this check again:'].concat(r.problems.map((p) => '- ' + p)));",
|
|
95
|
+
"console.log('OK');",
|
|
96
|
+
'',
|
|
97
|
+
].join('\n');
|
|
98
|
+
}
|
|
99
|
+
/** What the hotfix seed copies in: the context (the hotfix repositories) and the checker. */
|
|
100
|
+
export function portReportFiles(root, ctx) {
|
|
101
|
+
const contextFile = posix.join(root, PORT_CONTEXT_FILE);
|
|
102
|
+
return [
|
|
103
|
+
{ path: contextFile, content: `${JSON.stringify(ctx)}\n` },
|
|
104
|
+
{ path: PORT_REPORT_CHECKER, content: portReportCheckerSource({ reportFile: posix.join(root, PORT_REPORT_FILE), contextFile }), mode: 0o755 },
|
|
105
|
+
];
|
|
106
|
+
}
|
|
107
|
+
/** The report out of the sandbox (as the agent), parsed and checked against the HOST's context. Never throws. */
|
|
108
|
+
export async function readPortReport(runtime, container, layoutRoot, ctx) {
|
|
109
|
+
const file = posix.join(layoutRoot, PORT_REPORT_FILE);
|
|
110
|
+
const unreadable = { kind: 'unreadable', reason: 'The port report could not be read from the sandbox.' };
|
|
111
|
+
try {
|
|
112
|
+
const r = await runtime.run(container, ['sh', '-c', 'test -f "$1" || exit 4; head -c "$2" "$1"', 'sh', file, String(PORT_REPORT_MAX_BYTES + 1)], { timeoutMs: 30_000 });
|
|
113
|
+
if (r.code === 4)
|
|
114
|
+
return { kind: 'missing' };
|
|
115
|
+
if (r.code !== 0)
|
|
116
|
+
return unreadable;
|
|
117
|
+
const text = r.stdout.toString('utf8');
|
|
118
|
+
if (Buffer.byteLength(text, 'utf8') > PORT_REPORT_MAX_BYTES)
|
|
119
|
+
return { kind: 'unreadable', reason: `The port report is larger than ${PORT_REPORT_MAX_BYTES / 1024} KB.` };
|
|
120
|
+
let raw;
|
|
121
|
+
try {
|
|
122
|
+
raw = JSON.parse(text);
|
|
123
|
+
}
|
|
124
|
+
catch {
|
|
125
|
+
return { kind: 'unreadable', reason: 'The port report is not valid JSON.' };
|
|
126
|
+
}
|
|
127
|
+
return { kind: 'ok', check: validatePortReport(raw, ctx) };
|
|
128
|
+
}
|
|
129
|
+
catch {
|
|
130
|
+
return unreadable;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
/** The build turn's line for a hotfix build (plan first or not): finish with the port report. */
|
|
134
|
+
export function portReportInstructionLine(root) {
|
|
135
|
+
return `Finish with the port report ("Hotfix" in CLAUDE.md and AGENTS.md): write \`${posix.join(root, PORT_REPORT_FILE)}\` with one entry per repository you fixed (outcome same / adapted / not_needed, and the reason for adapted or not_needed). Check it with \`node ${PORT_REPORT_CHECKER}\` until it prints OK.`;
|
|
136
|
+
}
|
|
137
|
+
//# sourceMappingURL=port-report.js.map
|
|
@@ -18,6 +18,7 @@ import { acSectionText, criterionIsGap, describeTicketLayout, findAcSection, tic
|
|
|
18
18
|
import { WRITING_RULES } from '../../ai/writing-rules.js';
|
|
19
19
|
import { FIX_REFS_FILE, FIX_REPORT_CHECKER, FIX_REPORT_FILE, fixReportCheckerSource } from './fix-report.js';
|
|
20
20
|
import { PLAN_CHECKER, PLAN_CONTEXT_FILE, planCheckerSource } from './plan-check.js';
|
|
21
|
+
import { PORT_REPORT_CHECKER, PORT_REPORT_FILE, portReportFiles } from './port-report.js';
|
|
21
22
|
/** The agent's home folder in the sandbox image. */
|
|
22
23
|
export const SANDBOX_HOME = '/home/agent';
|
|
23
24
|
export const SEED_FILES = ['CLAUDE.md', 'AGENTS.md', 'TICKET.md'];
|
|
@@ -167,6 +168,40 @@ function rules(i, provider) {
|
|
|
167
168
|
'8. Finish the build with a report: for each acceptance criterion (AC1, AC2, …), met or not, and how. Then the open points you hit, the checks you ran, and what you could not do.',
|
|
168
169
|
].join('\n');
|
|
169
170
|
}
|
|
171
|
+
/**
|
|
172
|
+
* HOTFIX: the release checkouts (fix there first), the main checkouts (port the fix there), the read-only
|
|
173
|
+
* repositories, and the order of work. Only a hotfix build's seed has it.
|
|
174
|
+
*/
|
|
175
|
+
function hotfixSection(i, h) {
|
|
176
|
+
const fixable = h.repos.filter((r) => r.release != null);
|
|
177
|
+
const readOnly = h.repos.filter((r) => r.release == null);
|
|
178
|
+
const out = [
|
|
179
|
+
'## Hotfix',
|
|
180
|
+
'',
|
|
181
|
+
'This is a HOTFIX build. Fix the problem on the latest release first. Then port the same fix to the default branch.',
|
|
182
|
+
'',
|
|
183
|
+
'Release checkouts (fix here first):',
|
|
184
|
+
'',
|
|
185
|
+
list(fixable.map((r) => `${r.fullName}: \`${r.release.path}\` at the release ${r.release.tagName}.`)),
|
|
186
|
+
'',
|
|
187
|
+
'Main checkouts (port the fix here):',
|
|
188
|
+
'',
|
|
189
|
+
list(fixable.map((r) => r.main != null ? `${r.fullName}: \`${r.main.path}\` at ${r.main.label} (${short(r.main.sha)}).` : `${r.fullName}: no main checkout could be cloned. Fix the release checkout only.`)),
|
|
190
|
+
];
|
|
191
|
+
if (readOnly.length > 0) {
|
|
192
|
+
out.push('', 'Read only (no release yet). Read them, but do not change them: Ensemble refuses their changes.', '', list(readOnly.map((r) => `${r.fullName}: \`${i.layout.repos.find((x) => x.repoId === r.repoId)?.path ?? r.fullName}\``)));
|
|
193
|
+
}
|
|
194
|
+
out.push('', 'The order of work:', '', numbered([
|
|
195
|
+
'Fix the release checkout of each repository you change. Run its checks and fix what fails.',
|
|
196
|
+
'Before you port, read the main checkout of the same repository. Find the code the release fix changes. The default branch can be far from the release: that code can be the same, moved, rewritten or removed. Passing tests do not show that main needs the fix.',
|
|
197
|
+
`If main needs the fix, port it to the main checkout. For example, fetch the commits from the release checkout (\`git -C <main checkout> fetch <release checkout> ${i.branch}\`) and cherry-pick them, or make the change by hand. Resolve the differences where the code moved. Run the checks again and fix what fails. If main does not need the fix (for example, the code was removed), do not change the main checkout.`,
|
|
198
|
+
`Commit in both checkouts on the branch \`${i.branch}\`. Ensemble makes a pull request into the release's \`hotfix/<tag>\` branch for each repository, and one into the default branch when the main checkout changed.`,
|
|
199
|
+
'In the plan, put ONE pull request per repository you change in `stack`. The port to the main checkout is part of that pull request.',
|
|
200
|
+
'In the report, say for each repository what the port changed and the result of the checks in both checkouts.',
|
|
201
|
+
`Finish with the port report: write \`${posix.join(i.layout.root, PORT_REPORT_FILE)}\` with one entry per repository you fixed: \`{ "repos": [ { "repo": "owner/name", "outcome": "same" | "adapted" | "not_needed", "reason": "…", "evidence": ["path or commit", …] } ] }\`. \`same\`: the same fix on the release and on main. \`adapted\`: main needed a materially different fix; the reason says what is different. \`not_needed\`: main does not need the fix and the main checkout is unchanged; the reason says why (for example, "the code was removed in src/billing/"). \`evidence\` lists the paths or commits you read. Check it with \`node ${PORT_REPORT_CHECKER}\` until it prints OK.`,
|
|
202
|
+
]));
|
|
203
|
+
return out.join('\n');
|
|
204
|
+
}
|
|
170
205
|
function agentFile(i, provider) {
|
|
171
206
|
const ticketPath = posix.join(i.layout.root, 'TICKET.md');
|
|
172
207
|
const what = i.mode === 'fill_gaps' ? 'close the gaps the ticket check found in this ticket' : 'implement this ticket';
|
|
@@ -179,6 +214,7 @@ function agentFile(i, provider) {
|
|
|
179
214
|
'',
|
|
180
215
|
reposSection(i),
|
|
181
216
|
'',
|
|
217
|
+
...(i.hotfix ? [hotfixSection(i, i.hotfix), ''] : []),
|
|
182
218
|
memoriesSection(i, provider),
|
|
183
219
|
'',
|
|
184
220
|
servicesSection(i),
|
|
@@ -303,6 +339,7 @@ function systemPromptOf(i, provider) {
|
|
|
303
339
|
`You are in an Ensemble workspace session for the ticket ${i.ticket.key}. Read \`${own}\` and \`${posix.join(i.layout.root, 'TICKET.md')}\` before anything else.`,
|
|
304
340
|
i.planFirst ? 'Until the reader approves the plan, read and plan only: do not change files.' : 'Until the reader starts the build, read and plan only: do not change files.',
|
|
305
341
|
`Never push or add a remote. Commit your work on \`${i.branch}\`. Report per acceptance criterion at the end of the build.`,
|
|
342
|
+
...(i.hotfix ? ['This is a hotfix build: fix each release checkout first, then read its main checkout and port the fix there when main needs it ("Hotfix" in that file). End with the port report. Never change a read-only repository.'] : []),
|
|
306
343
|
].join(' ');
|
|
307
344
|
}
|
|
308
345
|
/** The refs a plan must cover (the checker's and the host's `ctx.criteria` / `ctx.gaps`). Pure. */
|
|
@@ -404,6 +441,9 @@ export function buildSeed(i) {
|
|
|
404
441
|
const contextFile = posix.join(i.layout.root, PLAN_CONTEXT_FILE);
|
|
405
442
|
files.push({ path: contextFile, content: `${JSON.stringify(planContextFor(i, []))}\n` }, { path: PLAN_CHECKER, content: planCheckerSource({ contextFile }), mode: 0o755 });
|
|
406
443
|
}
|
|
444
|
+
// A HOTFIX build's port report: its checker and the repositories it may name (the release checkouts).
|
|
445
|
+
if (i.hotfix)
|
|
446
|
+
files.push(...portReportFiles(i.layout.root, { repos: i.hotfix.repos.filter((r) => r.release != null).map((r) => r.fullName) }));
|
|
407
447
|
return { files, claudeMd, agentsMd, ticketMd, systemPrompts: { claude: systemPromptOf(i, 'claude'), codex: systemPromptOf(i, 'codex') } };
|
|
408
448
|
}
|
|
409
449
|
// ---- AI FIX (docs/SANDBOX.md § AI Fix sessions) ----------------------------------------------------------
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
// HOTFIX BUILDS — the pure half (docs/RELEASES.md § Hotfix, docs/STORY-BUILD.md § Hotfix builds).
|
|
2
|
+
//
|
|
3
|
+
// "Treat as a hotfix" is an Implement option. Each workspace repository with a LATEST RELEASE (the newest
|
|
4
|
+
// release OR hotfix tag, `latestReleaseTag`) gets a RELEASE checkout at that tag's commit and a MAIN checkout
|
|
5
|
+
// at the default branch's head, in the same sandbox; a repository without one is READ ONLY for the build.
|
|
6
|
+
// Push opens two pull requests per changed repository:
|
|
7
|
+
//
|
|
8
|
+
// PR 1 `<KEY>` → `hotfix/<latest release tag>` (made at the release commit when it is missing)
|
|
9
|
+
// PR 2 `<KEY>-main` → the default branch
|
|
10
|
+
//
|
|
11
|
+
// Both titled `<KEY>: <title>`, each body linking the other. The review loop and "Build end to end" are
|
|
12
|
+
// off for a hotfix build (v1). Nothing here reads the clock or fetches.
|
|
13
|
+
import { latestReleaseTag } from './release-check.js';
|
|
14
|
+
import { releaseSettingsConfigured } from './releases.js';
|
|
15
|
+
/** The prefix of the branch a release's hotfixes target. */
|
|
16
|
+
export const HOTFIX_BRANCH_PREFIX = 'hotfix/';
|
|
17
|
+
/** `hotfix/<tag>` — the branch PR 1 targets. */
|
|
18
|
+
export function hotfixBranchName(tagName) {
|
|
19
|
+
return `${HOTFIX_BRANCH_PREFIX}${tagName}`;
|
|
20
|
+
}
|
|
21
|
+
/** PR 2's head branch: the build's branch (the ticket key) plus `-main`. */
|
|
22
|
+
export function hotfixMainBranchName(branch) {
|
|
23
|
+
return `${branch}-main`;
|
|
24
|
+
}
|
|
25
|
+
/** The one sentence a refused review loop / end-to-end start on a hotfix build answers. */
|
|
26
|
+
export const HOTFIX_NO_LOOP_LINE = 'A hotfix build opens its pull requests when you press Push. The review loop and Build end to end are off for it.';
|
|
27
|
+
/** The one sentence a hotfix start answers when the option is not offered. */
|
|
28
|
+
export const HOTFIX_NOT_OFFERED_LINE = 'A hotfix needs the release and hotfix suffixes in Settings → Releases and at least one repository with a release.';
|
|
29
|
+
/** The line a read-only repository's refused change gets (the session goes on). */
|
|
30
|
+
export const hotfixReadOnlyLine = (fullName) => `${fullName} has no release yet, so it is read only in this hotfix build. Its changes were not kept.`;
|
|
31
|
+
/**
|
|
32
|
+
* THE BASES of a hotfix build (pure): per repository its latest release (release checkout at that commit),
|
|
33
|
+
* else read only. `offered` only when both suffixes are set and at least one repository has a release.
|
|
34
|
+
* Repositories are ordered by name.
|
|
35
|
+
*/
|
|
36
|
+
export function hotfixBasesOf(repos, settings) {
|
|
37
|
+
const configured = releaseSettingsConfigured(settings);
|
|
38
|
+
const out = [...repos]
|
|
39
|
+
.sort((a, b) => (a.fullName < b.fullName ? -1 : a.fullName > b.fullName ? 1 : a.repoId - b.repoId))
|
|
40
|
+
.map((r) => {
|
|
41
|
+
const hit = configured ? latestReleaseTag(r.tags, settings) : null;
|
|
42
|
+
return {
|
|
43
|
+
repoId: r.repoId,
|
|
44
|
+
fullName: r.fullName,
|
|
45
|
+
defaultBranch: r.defaultBranch,
|
|
46
|
+
release: hit ? { tagName: hit.tag.name, sha: hit.tag.sha, kind: hit.kind, committedAt: hit.tag.committedAt?.toISOString() ?? null } : null,
|
|
47
|
+
hotfixBranch: hit ? hotfixBranchName(hit.tag.name) : null,
|
|
48
|
+
};
|
|
49
|
+
});
|
|
50
|
+
return { configured, offered: configured && out.some((r) => r.release != null), repos: out };
|
|
51
|
+
}
|
|
52
|
+
// ── The patch, at extraction ───────────────────────────────────────────────────────────────────────
|
|
53
|
+
/**
|
|
54
|
+
* What extraction does with one checkout's work (pure). A READ-ONLY repository's change is REFUSED (never
|
|
55
|
+
* stored, so never pushed); no change ⇒ `empty`; otherwise `store`.
|
|
56
|
+
*/
|
|
57
|
+
export function hotfixPatchVerdict(o) {
|
|
58
|
+
if (o.patch === '')
|
|
59
|
+
return 'empty';
|
|
60
|
+
return o.readOnly ? 'refused' : 'store';
|
|
61
|
+
}
|
|
62
|
+
/** PR 1 `<branch>` → `hotfix/<tag>`; PR 2 `<branch>-main` → the default branch. */
|
|
63
|
+
export function hotfixPushTargets(o) {
|
|
64
|
+
return {
|
|
65
|
+
release: { head: o.branch, base: hotfixBranchName(o.tagName) },
|
|
66
|
+
main: { head: hotfixMainBranchName(o.branch), base: o.defaultBranch },
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
/** Where `hotfix/<tag>` stands against the release commit (pure): absent, at it, or moved past it. */
|
|
70
|
+
export function hotfixBranchState(liveSha, releaseSha) {
|
|
71
|
+
if (liveSha == null)
|
|
72
|
+
return 'missing';
|
|
73
|
+
return liveSha === releaseSha ? 'at_release' : 'moved';
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* The line each PR body ends with, linking its pair (pure). `other` null ⇒ the pair is not open yet (PR 1's
|
|
77
|
+
* body before PR 2 opens: it is edited once PR 2 exists).
|
|
78
|
+
*/
|
|
79
|
+
export function hotfixPairLine(self, o) {
|
|
80
|
+
const where = self === 'release' ? o.defaultBranch : `the release ${o.tagName}`;
|
|
81
|
+
const fix = o.adapted === true ? 'the fix' : 'the same fix';
|
|
82
|
+
if (o.other == null)
|
|
83
|
+
return `**Hotfix:** ${fix} for ${where} follows in its own pull request.`;
|
|
84
|
+
const link = o.other.url != null && /^https?:\/\/[^\s<>()]+$/i.test(o.other.url) ? `[#${o.other.number}](${o.other.url})` : `#${o.other.number}`;
|
|
85
|
+
return `**Hotfix:** ${fix} for ${where} is ${link}.`;
|
|
86
|
+
}
|
|
87
|
+
export const HOTFIX_PORT_OUTCOMES = ['same', 'adapted', 'not_needed'];
|
|
88
|
+
/** A reason is clipped to this many characters (one plain sentence or two). */
|
|
89
|
+
export const HOTFIX_PORT_REASON_MAX = 600;
|
|
90
|
+
/** At most this many evidence entries (paths or commits the agent looked at), each at most `…_ITEM_MAX`. */
|
|
91
|
+
export const HOTFIX_PORT_EVIDENCE_MAX = 10;
|
|
92
|
+
export const HOTFIX_PORT_EVIDENCE_ITEM_MAX = 200;
|
|
93
|
+
/** One line of untrusted text: whitespace collapsed, control characters dropped, clipped. Pure. */
|
|
94
|
+
export function hotfixPortText(text, max) {
|
|
95
|
+
// eslint-disable-next-line no-control-regex -- dropping control characters is the point.
|
|
96
|
+
const one = text.replace(/[\u0000-\u001f\u007f]+/g, ' ').replace(/\s+/g, ' ').trim();
|
|
97
|
+
return one.length <= max ? one : `${one.slice(0, max - 1).trimEnd()}…`;
|
|
98
|
+
}
|
|
99
|
+
/** The host's form of a claim (pure): reason and evidence as one-line, clipped text; empty ⇒ null / dropped. */
|
|
100
|
+
export function hotfixPortClaimOf(o) {
|
|
101
|
+
const reason = o.reason != null ? hotfixPortText(o.reason, HOTFIX_PORT_REASON_MAX) : '';
|
|
102
|
+
const evidence = (o.evidence ?? [])
|
|
103
|
+
.map((e) => hotfixPortText(e, HOTFIX_PORT_EVIDENCE_ITEM_MAX))
|
|
104
|
+
.filter((e) => e !== '')
|
|
105
|
+
.slice(0, HOTFIX_PORT_EVIDENCE_MAX);
|
|
106
|
+
return { outcome: o.outcome, reason: reason === '' ? null : reason, evidence };
|
|
107
|
+
}
|
|
108
|
+
/** Which files the two fixes change, compared (pure). null when either changes nothing. */
|
|
109
|
+
export function hotfixPortFilesOf(releaseFiles, mainFiles) {
|
|
110
|
+
if (releaseFiles.length === 0 || mainFiles.length === 0)
|
|
111
|
+
return null;
|
|
112
|
+
const rel = new Set(releaseFiles);
|
|
113
|
+
const main = new Set(mainFiles);
|
|
114
|
+
const common = [...rel].filter((f) => main.has(f)).length;
|
|
115
|
+
if (common === 0)
|
|
116
|
+
return 'none_in_common';
|
|
117
|
+
return common === rel.size && common === main.size ? 'same' : 'some_differ';
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* THE PORT REPORT of one repository (pure): the agent's claim, checked against the stored patches.
|
|
121
|
+
* `not_needed` with a main change, or `same` / `adapted` with none, is FLAGGED. No claim ⇒ no flag (nothing
|
|
122
|
+
* is inferred). `mainChanged` = the main fix's patch is not empty.
|
|
123
|
+
*/
|
|
124
|
+
export function hotfixPortOf(o) {
|
|
125
|
+
const c = o.claim;
|
|
126
|
+
const flag = c == null ? null : c.outcome === 'not_needed' ? (o.mainChanged ? 'not_needed_but_changed' : null) : o.mainChanged ? null : 'ported_but_unchanged';
|
|
127
|
+
return { claim: c, flag, files: hotfixPortFilesOf(o.releaseFiles, o.mainFiles) };
|
|
128
|
+
}
|
|
129
|
+
/** The outcome in words. */
|
|
130
|
+
export const HOTFIX_PORT_OUTCOME_WORDS = {
|
|
131
|
+
same: 'Applied to both',
|
|
132
|
+
adapted: 'Applied to both, adapted for main',
|
|
133
|
+
not_needed: 'Not applied to main',
|
|
134
|
+
};
|
|
135
|
+
/** The line when the agent gave no report for a repository. */
|
|
136
|
+
export const HOTFIX_PORT_NO_REPORT = 'No report from the agent';
|
|
137
|
+
/** The tab's line (pure): "Applied to both", "Applied to both, adapted for main — <reason>", … */
|
|
138
|
+
export function hotfixPortLine(claim) {
|
|
139
|
+
if (claim == null)
|
|
140
|
+
return HOTFIX_PORT_NO_REPORT;
|
|
141
|
+
const words = HOTFIX_PORT_OUTCOME_WORDS[claim.outcome];
|
|
142
|
+
return claim.reason != null && claim.outcome !== 'same' ? `${words} — ${claim.reason}` : words;
|
|
143
|
+
}
|
|
144
|
+
/** A contradiction in words. */
|
|
145
|
+
export const HOTFIX_PORT_FLAG_WORDS = {
|
|
146
|
+
not_needed_but_changed: 'Says main does not need it, but changed main.',
|
|
147
|
+
ported_but_unchanged: 'Says it was ported, but main is unchanged.',
|
|
148
|
+
};
|
|
149
|
+
/** The files compared, in words. */
|
|
150
|
+
export const HOTFIX_PORT_FILES_WORDS = {
|
|
151
|
+
same: 'Both fixes change the same files.',
|
|
152
|
+
some_differ: 'Some files differ between the two fixes.',
|
|
153
|
+
none_in_common: 'The two fixes have no file in common.',
|
|
154
|
+
};
|
|
155
|
+
/**
|
|
156
|
+
* The one line both PR bodies carry (pure; the caller defangs it for GitHub). Null when there is no claim or
|
|
157
|
+
* the claim is FLAGGED: a claim the patches contradict is not sent to GitHub.
|
|
158
|
+
*/
|
|
159
|
+
export function hotfixPortBodyLine(port) {
|
|
160
|
+
if (port?.claim == null || port.flag != null)
|
|
161
|
+
return null;
|
|
162
|
+
const c = port.claim;
|
|
163
|
+
const words = HOTFIX_PORT_OUTCOME_WORDS[c.outcome];
|
|
164
|
+
return `**Port:** ${c.reason != null && c.outcome !== 'same' ? `${words}: ${c.reason}` : `${words}.`}`;
|
|
165
|
+
}
|
package/dist/shared/index.js
CHANGED
|
@@ -62,4 +62,8 @@ export * from './sandbox-session.js';
|
|
|
62
62
|
export * from './build-plan.js';
|
|
63
63
|
export * from './ai-fix-session.js';
|
|
64
64
|
export * from './auto-fix-queue.js';
|
|
65
|
+
export * from './releases.js';
|
|
66
|
+
export * from './release-check.js';
|
|
67
|
+
export * from './release-write.js';
|
|
68
|
+
export * from './hotfix.js';
|
|
65
69
|
export * from './story-chat.js';
|