werkmeister-core 0.93.5 → 0.93.6
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/CHANGELOG.md +14 -0
- package/dist/agent_state.js +3 -2
- package/dist/archetypes.js +1 -1
- package/dist/fixture_workspace.d.ts +5 -1
- package/dist/fixture_workspace.js +37 -8
- package/dist/issue_tracker.d.ts +2 -0
- package/dist/issue_tracker.js +7 -3
- package/dist/lifecycle.js +21 -6
- package/dist/pr_lifecycle.d.ts +4 -1
- package/dist/pr_lifecycle.js +49 -4
- package/dist/sandbox.d.ts +8 -1
- package/dist/sandbox.js +11 -3
- package/dist/strategies/icm_templates.js +2 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# sandbox-core
|
|
2
2
|
|
|
3
|
+
## 0.93.6
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 4db8b7b: SW-665: `pr gate` tests every service again when a branch changes an `infrastructure:` or `caches:` entry in the repo's own `.werkmeister/services.yaml` (`every service: … infrastructure: <name>`); since SW-573 such a change touched no service and ran no tests.
|
|
8
|
+
- cccc0ce: SW-721: the container test line in `werkmeister-context.md` and its allow rule escape a `'` in the test or lint command (`'\''`), so both run the registered command instead of a different word split.
|
|
9
|
+
- 44c12ab: SW-809: `with-fixture-workspace --queue <feature>:<waitedMin>[:<service>,...]` (and `withFixtureWorkspace({ queue })`) seeds a waiter's workspace, compose.yml, lease and `waiting.json`, not only its name, so a starved, whole-feature or service queue head runs through the built CLI. `--queue` now repeats; a bare name still seeds only the name.
|
|
10
|
+
- df3c3d0: SW-825: the generated propose-stage contract says to start the release check's container with `werkmeister feature up --service <name>` first, since an earlier `pr gate --tests` stopped the containers it started.
|
|
11
|
+
- 5f85455: SW-829: `pr gate` (and so `pr open`) adds a `group` row to a grouped workspace's gate. It warns about each `group:` member whose key is in no commit subject in `origin/<base>..HEAD`, since that member would ship as Done with the PR, and prints the fix: remove it from `group:` and move it back to To Do with `werkmeister issue update <KEY> --status "To Do" --comment …`.
|
|
12
|
+
- 166fb6d: SW-831: when preemption fails to stop a victim and some of its containers still run, the victim is no longer queued, so its agent's container and test commands are not held over live containers. The start that asked still waits at the head of the queue. A victim with nothing left running is queued to come back, as before.
|
|
13
|
+
- 855cb69: SW-832: while a workspace waits for capacity, the hook now also holds the MCP `test` tool and `workspace-pr` with `gate` or `open`, as it holds their Bash forms. `workspace-pr` `status` still runs.
|
|
14
|
+
- 6ff3082: SW-833: `runWorkspaceAction` takes an optional `{ byPerson }` that says a person, not an agent, asked for an `up`. The workspaces pane's Up passes `byPerson: true`, so a person's Up on a full machine can stop agents' features instead of queueing behind them, in a workspace that is not autonomous. An autonomous workspace's Up still queues as an agent's. Before this, the pane ran inside Claude Code and inherited `CLAUDECODE=1`, so its Up always counted as an agent's start.
|
|
15
|
+
- b6108f6: SW-840: when a workspace is started from the waiting queue and some of its containers are still stopped, the message that resumes its session now names each one and the command that starts it (`werkmeister feature up --service <name>`). Before this, it said the containers were up. Preemption stops on-demand containers too, and the grant's `up` starts only the default set.
|
|
16
|
+
|
|
3
17
|
## 0.93.5
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
package/dist/agent_state.js
CHANGED
|
@@ -642,7 +642,8 @@ function leftOver(root) {
|
|
|
642
642
|
// Starts containers or runs tests. A list of what is held, not of what passes: the ticket names the held
|
|
643
643
|
// set, and an allowlist would hold `werkmeister feature stop`, the command that frees room (SW-768).
|
|
644
644
|
const NEEDS_CAPACITY = /(^|[\s;&|(`/'"])(docker|pnpm|npm|npx|node|turbo|vitest|with-temp-home|with-fixture-workspace)(\s|$)|\b(werkmeister|w9r)\s+(feature\s+(up|restart)|pr\s+(gate|open))\b/;
|
|
645
|
-
|
|
645
|
+
// The MCP forms of the held commands (SW-832); `workspace-pr` `status` passes like `pr status`.
|
|
646
|
+
const NEEDS_CAPACITY_TOOL = /^mcp__.*werkmeister.*__(up|restart|test|workspace-pr)$/;
|
|
646
647
|
function needsCapacity(input) {
|
|
647
648
|
if (input["hook_event_name"] !== "PreToolUse")
|
|
648
649
|
return false;
|
|
@@ -652,7 +653,7 @@ function needsCapacity(input) {
|
|
|
652
653
|
const command = String(input["tool_input"]?.["command"] ?? "").replace(/(\s(?:-m|--message)[= ]?\s*)('[^']*'|"[^"]*")/g, "$1''");
|
|
653
654
|
if (tool === "Bash")
|
|
654
655
|
return NEEDS_CAPACITY.test(command);
|
|
655
|
-
return NEEDS_CAPACITY_TOOL.test(tool);
|
|
656
|
+
return NEEDS_CAPACITY_TOOL.test(tool) && input["tool_input"]?.["action"] !== "status";
|
|
656
657
|
}
|
|
657
658
|
/**
|
|
658
659
|
* The hook's stdout while the workspace is paused or waiting for capacity, or null. `continue: false` ends
|
package/dist/archetypes.js
CHANGED
|
@@ -81,7 +81,7 @@ export function serviceNoTests(svcDef) {
|
|
|
81
81
|
* `permissions.allow` rule both use it, so the rule matches what the agent runs.
|
|
82
82
|
*/
|
|
83
83
|
export function containerTestCommand(feature, svc, cmd) {
|
|
84
|
-
return `docker exec ${feature}-${svc} sh -c '${cmd}'`;
|
|
84
|
+
return `docker exec ${feature}-${svc} sh -c '${cmd.split("'").join(`'\\''`)}'`;
|
|
85
85
|
}
|
|
86
86
|
/** True when *cmd* is simple commands joined only by `&&`: no group, pipe, `||`, `;`, `&`, newline or substitution. */
|
|
87
87
|
export function isPlainChain(cmd) {
|
|
@@ -51,7 +51,11 @@ export interface FixtureOptions {
|
|
|
51
51
|
config?: Record<string, unknown>;
|
|
52
52
|
/** Containers the fake docker shows the scheduler as running, so a start can wait for capacity (SW-685). */
|
|
53
53
|
containers?: FixtureContainer[];
|
|
54
|
-
/**
|
|
54
|
+
/**
|
|
55
|
+
* The waiting queue, `scheduler/queue.json` (SW-685), one `<feature>[:<waitedMin>[:<service>,...]]` each.
|
|
56
|
+
* With a wait, the waiter also gets a workspace with a compose.yml, a lease and a waiting.json whose
|
|
57
|
+
* `since` is that many minutes back (and `services`, a service start), so admission prices and ages it (SW-809).
|
|
58
|
+
*/
|
|
55
59
|
queue?: string[];
|
|
56
60
|
}
|
|
57
61
|
/** One running container as `docker inspect` reports it to the scheduler. */
|
|
@@ -8,6 +8,8 @@ import { execFileSync } from "node:child_process";
|
|
|
8
8
|
import * as fs from "node:fs";
|
|
9
9
|
import * as path from "node:path";
|
|
10
10
|
import YAML from "yaml";
|
|
11
|
+
import { waitingPath } from "./agent_state.js";
|
|
12
|
+
import { COMPOSE_FILE } from "./compose_file.js";
|
|
11
13
|
import { containerOf } from "./config.js";
|
|
12
14
|
import { dotDir } from "./dot_dir.js";
|
|
13
15
|
import { writeFakes } from "./fixture_fakes.js";
|
|
@@ -15,6 +17,7 @@ import { gitEnv } from "./proc.js";
|
|
|
15
17
|
import { prDir, stageDirs, templateFor } from "./strategies/icm_templates.js";
|
|
16
18
|
// Names become folders under the fixture and lines in the fakes, from a pre-approved wrapper's input.
|
|
17
19
|
const NAME = /^[a-z0-9][a-z0-9-]*$/;
|
|
20
|
+
const QUEUE_ENTRY = /^([a-z0-9][a-z0-9-]*)(?::(\d+)(?::([a-z0-9][a-z0-9-]*(?:,[a-z0-9][a-z0-9-]*)*))?)?$/;
|
|
18
21
|
// The only config.yaml keys --config may add: others (jira, github_ingest, paths…) reach real services or repos from a pre-approved run.
|
|
19
22
|
const CONFIG_KEYS = ["budget"];
|
|
20
23
|
export const FIXTURE_FEATURE = "demo";
|
|
@@ -89,9 +92,9 @@ export function fixturePreset({ gate, bare, change, ...opts }) {
|
|
|
89
92
|
if (bad !== undefined)
|
|
90
93
|
throw new Error(`--running: bad value ${JSON.stringify(bad)}: feature and workspace are lowercase names, startedAt a date, memory and nanoCpus whole numbers`);
|
|
91
94
|
}
|
|
92
|
-
const
|
|
93
|
-
if (
|
|
94
|
-
throw new Error(`--queue: bad
|
|
95
|
+
const badEntry = opts.queue?.find((q) => !QUEUE_ENTRY.test(q));
|
|
96
|
+
if (badEntry !== undefined)
|
|
97
|
+
throw new Error(`--queue: bad entry ${JSON.stringify(badEntry)}: <feature>[:<waitedMin>[:<service>,...]], lowercase names and whole minutes`);
|
|
95
98
|
const libChange = "packages/lib/index.js";
|
|
96
99
|
const gateChange = change ?? (opts.fragmentChange === undefined ? libChange : undefined);
|
|
97
100
|
if (gate && opts.services && gateChange === libChange) {
|
|
@@ -213,18 +216,44 @@ ${githubProject(repos.map((r) => r.name))}${opts.config ? YAML.stringify(opts.co
|
|
|
213
216
|
git(workspace, "commit", "-q", "-m", "record");
|
|
214
217
|
git(workspace, "remote", "add", "origin", record);
|
|
215
218
|
git(workspace, "push", "-q", "-u", "origin", FIXTURE_BRANCH);
|
|
219
|
+
const leases = {};
|
|
216
220
|
if (opts.slotsFull) {
|
|
217
|
-
const leases = {};
|
|
218
221
|
for (let slot = 1; slot <= YAML.parse(PORTS).feature_slots.count; slot++) {
|
|
219
222
|
const other = path.join(root, "ws", `other-${slot}`);
|
|
220
223
|
fs.mkdirSync(other, { recursive: true });
|
|
221
224
|
leases[`other-${slot}`] = { slot, workspace: other };
|
|
222
225
|
}
|
|
223
|
-
// leasesPath() beside configFile: the env that points it here isn't set yet in this process.
|
|
224
|
-
write(path.join(path.dirname(configFile), "scheduler", "leases.json"), JSON.stringify(leases));
|
|
225
226
|
}
|
|
227
|
+
const now = Date.now();
|
|
228
|
+
const queue = (opts.queue ?? []).map((entry, i) => {
|
|
229
|
+
const [feature = entry, waitedMin, services] = QUEUE_ENTRY.exec(entry)?.slice(1) ?? [];
|
|
230
|
+
if (waitedMin === undefined)
|
|
231
|
+
return feature;
|
|
232
|
+
const ws = path.join(root, "ws", feature);
|
|
233
|
+
const names = services?.split(",");
|
|
234
|
+
// 1 CPU and 1 GiB each, so `budget status` and admission have a cost to show and price.
|
|
235
|
+
const compose = Object.fromEntries((names ?? ["app"]).map((s) => [
|
|
236
|
+
s,
|
|
237
|
+
{
|
|
238
|
+
image: "fixture",
|
|
239
|
+
deploy: { resources: { limits: { cpus: "1" }, reservations: { memory: "1g" } } },
|
|
240
|
+
},
|
|
241
|
+
]));
|
|
242
|
+
write(path.join(ws, COMPOSE_FILE), YAML.stringify({ services: compose }));
|
|
243
|
+
leases[feature] = { slot: Object.keys(leases).length + 1, workspace: ws };
|
|
244
|
+
write(waitingPath(ws), JSON.stringify({
|
|
245
|
+
position: i + 1,
|
|
246
|
+
reason: "waiting for capacity",
|
|
247
|
+
...(names && { services: names }),
|
|
248
|
+
since: new Date(now - Number(waitedMin) * 60_000).toISOString(),
|
|
249
|
+
}));
|
|
250
|
+
return feature;
|
|
251
|
+
});
|
|
252
|
+
// leasesPath() beside configFile: the env that points it here isn't set yet in this process.
|
|
253
|
+
if (Object.keys(leases).length)
|
|
254
|
+
write(path.join(path.dirname(configFile), "scheduler", "leases.json"), JSON.stringify(leases));
|
|
226
255
|
if (opts.queue)
|
|
227
|
-
write(path.join(path.dirname(configFile), "scheduler", "queue.json"), JSON.stringify(
|
|
256
|
+
write(path.join(path.dirname(configFile), "scheduler", "queue.json"), JSON.stringify(queue));
|
|
228
257
|
const containers = (opts.containers ?? []).map((c) => {
|
|
229
258
|
const ws = path.join(root, "ws", c.workspace);
|
|
230
259
|
fs.mkdirSync(ws, { recursive: true });
|
|
@@ -291,7 +320,7 @@ const SCRIPT = `#!/bin/sh
|
|
|
291
320
|
# Generated by \`werkmeister workspace init\` (SW-292); rerun it to regenerate.
|
|
292
321
|
# Runs this workspace's own built werkmeister CLI against a seeded fixture workspace, removed on exit:
|
|
293
322
|
# temp HOME and registry, a local bare origin, logging fakes for gh and docker, dead Docker and daemon.
|
|
294
|
-
# usage: with-fixture-workspace [--no-wait] [--gate] [--bare] [--daemon] [--exec-runs] [--merged] [--behind] [--slots-full] [--running <file>] [--queue <feature>[,<feature>]...] [--issue <ref>] [--pr-field <key>=<value>]... [--workspace <file>] [--config <file>] [--services <file>] [--fragment <file>] [--change <path>] [--change-base <file>] [--change-branch <file>] [--fragment-change <file>] [--print <file>]... <werkmeister args> [--then <werkmeister args>]...
|
|
323
|
+
# usage: with-fixture-workspace [--no-wait] [--gate] [--bare] [--daemon] [--exec-runs] [--merged] [--behind] [--slots-full] [--running <file>] [--queue <feature>[,<feature>]... | --queue <feature>:<waitedMin>[:<service>,...]]... [--issue <ref>] [--pr-field <key>=<value>]... [--workspace <file>] [--config <file>] [--services <file>] [--fragment <file>] [--change <path>] [--change-base <file>] [--change-branch <file>] [--fragment-change <file>] [--print <file>]... <werkmeister args> [--then <werkmeister args>]...
|
|
295
324
|
# It only ever runs that CLI, never another command, so one allow rule can cover it (SW-172, SW-231);
|
|
296
325
|
# --exec-runs, given first, also runs the registry's rows on the host, so the workspace asks before it (SW-473).
|
|
297
326
|
ws=$(cd "$(dirname "$0")/../.." && pwd -P) || exit 1
|
package/dist/issue_tracker.d.ts
CHANGED
|
@@ -95,6 +95,8 @@ export declare function projectForIssue(issueId: string, named?: string): Projec
|
|
|
95
95
|
export declare function projectOf(data: Record<string, unknown> | null | undefined): string;
|
|
96
96
|
/** A workspace.yml's issue ref: `issue_id`, else the pre-rename `jira_id` / `github_issue`; "" when none. */
|
|
97
97
|
export declare function issueIdOf(data: Record<string, unknown> | null | undefined): string;
|
|
98
|
+
/** A workspace.yml's `group:` members, from a list or a comma-separated string (SW-500). */
|
|
99
|
+
export declare function groupOf(data: Record<string, unknown> | null | undefined): string[];
|
|
98
100
|
/** The issue refs a workspace's status moves cover: its issue, then each `group:` member (SW-500). */
|
|
99
101
|
export declare function issueRefsOf(data: Record<string, unknown> | null | undefined): string[];
|
|
100
102
|
/** A workspace .env's issue ref: `ISSUE_ID`, else the pre-rename `JIRA_ID` / `GITHUB_ISSUE`; "" when none. */
|
package/dist/issue_tracker.js
CHANGED
|
@@ -146,14 +146,18 @@ export function projectOf(data) {
|
|
|
146
146
|
export function issueIdOf(data) {
|
|
147
147
|
return str(data?.issue_id) || str(data?.jira_id) || str(data?.github_issue);
|
|
148
148
|
}
|
|
149
|
+
/** A workspace.yml's `group:` members, from a list or a comma-separated string (SW-500). */
|
|
150
|
+
export function groupOf(data) {
|
|
151
|
+
const group = data?.group;
|
|
152
|
+
const members = Array.isArray(group) ? group : String(group ?? "").split(",");
|
|
153
|
+
return members.map((m) => String(m).trim()).filter(Boolean);
|
|
154
|
+
}
|
|
149
155
|
/** The issue refs a workspace's status moves cover: its issue, then each `group:` member (SW-500). */
|
|
150
156
|
export function issueRefsOf(data) {
|
|
151
157
|
const lead = issueIdOf(data);
|
|
152
158
|
if (!lead)
|
|
153
159
|
return [];
|
|
154
|
-
|
|
155
|
-
const members = Array.isArray(group) ? group : String(group ?? "").split(",");
|
|
156
|
-
return [...new Set([lead, ...members.map((m) => String(m).trim()).filter(Boolean)])];
|
|
160
|
+
return [...new Set([lead, ...groupOf(data)])];
|
|
157
161
|
}
|
|
158
162
|
/** A workspace .env's issue ref: `ISSUE_ID`, else the pre-rename `JIRA_ID` / `GITHUB_ISSUE`; "" when none. */
|
|
159
163
|
export function issueIdOfMeta(meta) {
|
package/dist/lifecycle.js
CHANGED
|
@@ -32,7 +32,7 @@ import { Colors } from "./colors.js";
|
|
|
32
32
|
import {
|
|
33
33
|
// Both spellings: `up`/`down` take an AbortSignal and use the async pair;
|
|
34
34
|
// `remove`/`clean` are not signal verbs (spec D4) and keep the sync ones.
|
|
35
|
-
composeDown, composeDownAsync, composeRestart, composeStop, composeUp, composeUpAsync, composeUpServiceAsync, dependencyOrder, getContainerStatus, liveProject, workspaceForFeature, } from "./compose.js";
|
|
35
|
+
composeDown, composeDownAsync, composeRestart, composeStop, composeUp, composeUpAsync, composeUpServiceAsync, dependencyOrder, getContainerStatus, isOneShotService, liveProject, workspaceForFeature, } from "./compose.js";
|
|
36
36
|
import { COMPOSE_FILE, migrateWorkspaceCompose } from "./compose_file.js";
|
|
37
37
|
import { getVolumeBaseNames, loadPorts, loadServices, needsCluster, sharedProxySkipReason, } from "./config.js";
|
|
38
38
|
import { docker, listVolumeNames, projectContainers, removeVolume } from "./docker.js";
|
|
@@ -729,6 +729,18 @@ export function idleStopFeature(input) {
|
|
|
729
729
|
return feature;
|
|
730
730
|
}
|
|
731
731
|
const GRANTED_NUDGE = "Capacity freed: this workspace's containers are up. Continue where you left off.";
|
|
732
|
+
/**
|
|
733
|
+
* The granted session's nudge. Preemption stops on-demand containers too, and the grant's `up` starts
|
|
734
|
+
* only the default set, so name each one left stopped and how to start it (SW-840).
|
|
735
|
+
*/
|
|
736
|
+
async function grantedNudge(feature) {
|
|
737
|
+
const stopped = (await getContainerStatus(feature)).filter((c) => c.status !== "running" && !isOneShotService(c.service, c.role));
|
|
738
|
+
if (!stopped.length)
|
|
739
|
+
return GRANTED_NUDGE;
|
|
740
|
+
return (`Capacity freed: this workspace started, but these containers are still stopped: ${stopped.map((c) => c.name).join(", ")}. ` +
|
|
741
|
+
`Start them with ${stopped.map((c) => `\`werkmeister feature up --service ${c.service}\``).join(", ")}, ` +
|
|
742
|
+
"then continue where you left off.");
|
|
743
|
+
}
|
|
732
744
|
/**
|
|
733
745
|
* Every running feature as the scheduler sees it, read from Docker now (never a
|
|
734
746
|
* pid: `up` exits once containers start). Longest-inactive first, so ties in
|
|
@@ -809,10 +821,13 @@ async function admitOrQueueHere(feature, workspace, byPerson, starting) {
|
|
|
809
821
|
}
|
|
810
822
|
catch (e) {
|
|
811
823
|
// A failed stop can still have killed it (SW-738): queue it to come back, and wait rather than
|
|
812
|
-
// start over budget; this start had the head's turn, so it keeps it.
|
|
813
|
-
|
|
824
|
+
// start over budget; this start had the head's turn, so it keeps it. A victim that still runs
|
|
825
|
+
// stays out of the queue, or the hook holds its agent over live containers (SW-831).
|
|
826
|
+
const stillRuns = (await getContainerStatus(victim)).some((c) => c.status === "running");
|
|
827
|
+
if (victimWs && !stillRuns)
|
|
814
828
|
await enqueue(victim, victimWs);
|
|
815
|
-
warn(`Could not stop '${victim}' to make room (${e.message}); waiting instead`
|
|
829
|
+
warn(`Could not stop '${victim}' to make room (${e.message}); waiting instead` +
|
|
830
|
+
(stillRuns ? `, and '${victim}' keeps running` : ""));
|
|
816
831
|
return requeueFirst(feature, workspace, starting);
|
|
817
832
|
}
|
|
818
833
|
if (victimWs)
|
|
@@ -859,7 +874,7 @@ async function grantWaitersNow() {
|
|
|
859
874
|
if (await startParked(feature, workspace, waiting.parked.service)) {
|
|
860
875
|
started.push(feature);
|
|
861
876
|
if (liveSessions(workspace).length)
|
|
862
|
-
writeNudge(workspace,
|
|
877
|
+
writeNudge(workspace, await grantedNudge(feature));
|
|
863
878
|
}
|
|
864
879
|
continue;
|
|
865
880
|
}
|
|
@@ -883,7 +898,7 @@ async function grantWaitersNow() {
|
|
|
883
898
|
continue;
|
|
884
899
|
started.push(feature);
|
|
885
900
|
if (liveSessions(workspace).length)
|
|
886
|
-
writeNudge(workspace,
|
|
901
|
+
writeNudge(workspace, await grantedNudge(feature));
|
|
887
902
|
}
|
|
888
903
|
return started;
|
|
889
904
|
}
|
package/dist/pr_lifecycle.d.ts
CHANGED
|
@@ -168,11 +168,14 @@ type Rendered = {
|
|
|
168
168
|
services: ServicesConfig;
|
|
169
169
|
repos: Record<string, RepoEntry>;
|
|
170
170
|
setup_services: ServicesConfig;
|
|
171
|
+
infrastructure?: Record<string, unknown>;
|
|
172
|
+
caches?: Record<string, unknown>;
|
|
171
173
|
};
|
|
172
174
|
/**
|
|
173
175
|
* What the repo's own fragment changes for its gate (SW-573): its services whose rendered
|
|
174
176
|
* entries differ from the base's (*before*), or `all` naming the change that reaches every
|
|
175
|
-
* service (a `repo:` key, its own `setup_services
|
|
177
|
+
* service (a `repo:` key, its own `setup_services`, an `infrastructure:` or `caches:` entry,
|
|
178
|
+
* SW-665). A mapping change counts only when it
|
|
176
179
|
* moves a file of this diff: otherwise it changes no test.
|
|
177
180
|
*/
|
|
178
181
|
export declare function fragmentTouched(dir: string, files: string[], branch: Rendered, before: Rendered): {
|
package/dist/pr_lifecycle.js
CHANGED
|
@@ -18,7 +18,7 @@ import { containerOf, dotDir, IDLE_SERVICE_TYPES, isFixture, loadArchetypes, loa
|
|
|
18
18
|
import { GATE_COMPOSE_FILE, renderGateCompose } from "./generate.js";
|
|
19
19
|
import { updateNoteStatus } from "./graduate.js";
|
|
20
20
|
import { eachIssue, issueStatuses, moveIssue } from "./issue_status.js";
|
|
21
|
-
import { issueRefsOf, issueTracker, projectOf } from "./issue_tracker.js";
|
|
21
|
+
import { groupOf, issueIdOf, issueRefsOf, issueTracker, projectOf } from "./issue_tracker.js";
|
|
22
22
|
import { grantWaiters, idleStopMinutes, lastExecMarker, liveSessions, readServicesFromWorkspace, runningFeatures, startService, stop as stopFeature, stopIdle, } from "./lifecycle.js";
|
|
23
23
|
import { originSlug, prWatchScheduleState, } from "./machine_setup.js";
|
|
24
24
|
import { openDecisions } from "./notes.js";
|
|
@@ -409,7 +409,8 @@ export function unmappedFiles(files, repo) {
|
|
|
409
409
|
/**
|
|
410
410
|
* What the repo's own fragment changes for its gate (SW-573): its services whose rendered
|
|
411
411
|
* entries differ from the base's (*before*), or `all` naming the change that reaches every
|
|
412
|
-
* service (a `repo:` key, its own `setup_services
|
|
412
|
+
* service (a `repo:` key, its own `setup_services`, an `infrastructure:` or `caches:` entry,
|
|
413
|
+
* SW-665). A mapping change counts only when it
|
|
413
414
|
* moves a file of this diff: otherwise it changes no test.
|
|
414
415
|
*/
|
|
415
416
|
export function fragmentTouched(dir, files, branch, before) {
|
|
@@ -429,6 +430,14 @@ export function fragmentTouched(dir, files, branch, before) {
|
|
|
429
430
|
for (const n of setup.sort())
|
|
430
431
|
if (!isDeepStrictEqual(branch.setup_services[n], before.setup_services[n]))
|
|
431
432
|
reasons.push(`setup_services: ${n}`);
|
|
433
|
+
// Entries carry no repo:, but both sides hold the same other fragments, so a difference is this repo's (SW-665).
|
|
434
|
+
for (const section of ["infrastructure", "caches"]) {
|
|
435
|
+
const b = branch[section] ?? {};
|
|
436
|
+
const m = before[section] ?? {};
|
|
437
|
+
for (const n of [...new Set([...Object.keys(b), ...Object.keys(m)])].sort())
|
|
438
|
+
if (!isDeepStrictEqual(b[n], m[n]))
|
|
439
|
+
reasons.push(`${section}: ${n}`);
|
|
440
|
+
}
|
|
432
441
|
const services = (br["services"] ?? [])
|
|
433
442
|
.filter((s) => !isDeepStrictEqual(branch.services[s], before.services[s]))
|
|
434
443
|
.sort();
|
|
@@ -594,6 +603,40 @@ async function mergeCheck(dir, file, deps) {
|
|
|
594
603
|
}
|
|
595
604
|
return `rebase allowed on ${base}`;
|
|
596
605
|
}
|
|
606
|
+
/**
|
|
607
|
+
* SW-829: `pr open` and the ship move every `group:` member with the lead, so a member no commit
|
|
608
|
+
* subject on the branch names would ship as Done. A warning like SW-457's: dropping it is the
|
|
609
|
+
* person's call. Reads every PR file's worktree, since a member's commit may sit in another repo.
|
|
610
|
+
*/
|
|
611
|
+
async function groupCheck(ws, cfg, file, deps) {
|
|
612
|
+
const lead = issueIdOf(cfg);
|
|
613
|
+
const members = groupOf(cfg).filter((m) => m !== lead);
|
|
614
|
+
const ranges = new Map();
|
|
615
|
+
for (const f of readPrFiles(ws))
|
|
616
|
+
ranges.set(f.dir, `origin/${String(f.fm["base"] ?? "main")}..HEAD`);
|
|
617
|
+
const subjects = [];
|
|
618
|
+
for (const [d, range] of ranges) {
|
|
619
|
+
const r = await deps.run("git", ["-C", path.join(ws, d), "log", "--format=%s", range]);
|
|
620
|
+
if (r.code !== 0)
|
|
621
|
+
return `warning: could not read ${d}'s commits in ${range} — ${(r.stderr || r.stdout).trim() || `exit ${r.code}`}`;
|
|
622
|
+
subjects.push(...r.stdout.split("\n"));
|
|
623
|
+
}
|
|
624
|
+
// A whole key, any case: SW-3 is not named by SW-30 or XSW-3; sw-3 is.
|
|
625
|
+
const named = (key) => {
|
|
626
|
+
const re = new RegExp(`(^|[^A-Za-z0-9-])${key.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}(?![0-9])`, "i");
|
|
627
|
+
return subjects.some((s) => re.test(s));
|
|
628
|
+
};
|
|
629
|
+
const missing = members.filter((m) => !named(m));
|
|
630
|
+
if (!missing.length)
|
|
631
|
+
return `every group: member has a commit: ${members.join(", ")}`;
|
|
632
|
+
const where = [...ranges].map(([d, range]) => `${range} (${d})`).join(", ");
|
|
633
|
+
const branch = String(file.fm["branch"] ?? "");
|
|
634
|
+
const comment = `Dropped from ${lead ? `${lead}'s` : "the"} grouped PR${branch ? ` (branch ${branch})` : ""}: no commit for it`;
|
|
635
|
+
// shortcut: "To Do" is Jira's default; a GitHub tracker or a renamed status needs its own name, add a todo point if that bites.
|
|
636
|
+
return missing
|
|
637
|
+
.map((m) => `warning: ${m} has no commit in ${where}, so it would ship as Done with this PR — remove it from group: in .werkmeister/workspace.yml, then put it back: werkmeister issue update ${m} --status "To Do" --comment ${JSON.stringify(comment)}`)
|
|
638
|
+
.join("\n");
|
|
639
|
+
}
|
|
597
640
|
// Moved beside hostLoadLimit so lifecycle's container starts can use it without an import cycle (SW-630).
|
|
598
641
|
export { waitForHostLoadNow };
|
|
599
642
|
function filterSplit(cmd) {
|
|
@@ -749,9 +792,11 @@ testsOnly = false) {
|
|
|
749
792
|
: `all PASS${manual.length ? `; MANUAL, for the reviewer: ${manual.map((r) => cellsOf(r.row)[0]).join("; ")}` : ""}`);
|
|
750
793
|
add("approved", statusOf(file) === "approved", `status: ${statusOf(file)}`);
|
|
751
794
|
add("repo", ...(await repoCheck(path.join(ws, file.dir), file, deps)));
|
|
752
|
-
const
|
|
753
|
-
if (
|
|
795
|
+
const wsCfg = loadConfigFile(ws, null);
|
|
796
|
+
if (groupOf(wsCfg).length) {
|
|
754
797
|
add("merge", true, await mergeCheck(dir, file, deps));
|
|
798
|
+
add("group", true, await groupCheck(ws, wsCfg, file, deps));
|
|
799
|
+
}
|
|
755
800
|
// exercise.md is a file read too, so a malformed table fails before the tests (SW-286).
|
|
756
801
|
const skipExercise = reason(file.fm["skip_exercise"]);
|
|
757
802
|
if (skipExercise)
|
package/dist/sandbox.d.ts
CHANGED
|
@@ -1365,6 +1365,11 @@ export type WorkspaceAction = (typeof WORKSPACE_ACTIONS)[number];
|
|
|
1365
1365
|
* - `pause`: freezes the running containers and holds the workspace's Claude session.
|
|
1366
1366
|
* - `resume`: brings back what `pause` froze, releases the session, and tells it to
|
|
1367
1367
|
* continue if it was mid-turn.
|
|
1368
|
+
* @param options - `byPerson: true` says a person asked for an `up`, not an agent. In a
|
|
1369
|
+
* workspace that is not autonomous it then starts as a person's: on a full machine it may
|
|
1370
|
+
* stop agents' features instead of queueing behind them. An autonomous workspace's start
|
|
1371
|
+
* still counts as an agent's. Left out, a workspace that is not autonomous starts as a
|
|
1372
|
+
* person's unless it runs under Claude Code (`CLAUDECODE` set).
|
|
1368
1373
|
* @returns `command`, a label for what ran (e.g. `werkmeister up (in my-workspace)`);
|
|
1369
1374
|
* `output`, the progress transcript without ANSI colours; and `path`, the workspace folder.
|
|
1370
1375
|
* @throws {@link WorkspaceError} when `name` is not a workspace, its `.env` has no
|
|
@@ -1385,7 +1390,9 @@ export type WorkspaceAction = (typeof WORKSPACE_ACTIONS)[number];
|
|
|
1385
1390
|
* }
|
|
1386
1391
|
* ```
|
|
1387
1392
|
*/
|
|
1388
|
-
export declare function runWorkspaceAction(name: string, action: WorkspaceAction
|
|
1393
|
+
export declare function runWorkspaceAction(name: string, action: WorkspaceAction, { byPerson }?: {
|
|
1394
|
+
byPerson?: boolean;
|
|
1395
|
+
}): Promise<{
|
|
1389
1396
|
/** A label for what ran, e.g. `werkmeister up (in <name>)`; it ran in-process, not as a CLI. */
|
|
1390
1397
|
command: string;
|
|
1391
1398
|
/** Its progress output, ANSI colours stripped. */
|
package/dist/sandbox.js
CHANGED
|
@@ -66,7 +66,7 @@ import { abandonWorkspace, commitsAhead, lifecycleOf, originBase, removalBlocker
|
|
|
66
66
|
import { collectingReporter, info, warn, withReporter } from "./reporter.js";
|
|
67
67
|
import { DASHBOARD, status as webStatus } from "./web_servers.js";
|
|
68
68
|
import { provisionWorkspace, WorkspaceInitError } from "./workspace_init.js";
|
|
69
|
-
import { computePromptSpec, isTrue, loadConfigFile, resolveInputs } from "./workspace_prompts.js";
|
|
69
|
+
import { computePromptSpec, isTrue, loadConfigFile, readAutonomous, resolveInputs, } from "./workspace_prompts.js";
|
|
70
70
|
import { legacyAgent, prNeeds, workspaceState, } from "./workspace_state.js";
|
|
71
71
|
import { revokeWorkspaceToken } from "./workspace_token.js";
|
|
72
72
|
import { hasGit, listRepoWorktrees } from "./worktrees.js";
|
|
@@ -2730,6 +2730,11 @@ export const WORKSPACE_ACTIONS = ["up", "stop", "restart", "down", "pause", "res
|
|
|
2730
2730
|
* - `pause`: freezes the running containers and holds the workspace's Claude session.
|
|
2731
2731
|
* - `resume`: brings back what `pause` froze, releases the session, and tells it to
|
|
2732
2732
|
* continue if it was mid-turn.
|
|
2733
|
+
* @param options - `byPerson: true` says a person asked for an `up`, not an agent. In a
|
|
2734
|
+
* workspace that is not autonomous it then starts as a person's: on a full machine it may
|
|
2735
|
+
* stop agents' features instead of queueing behind them. An autonomous workspace's start
|
|
2736
|
+
* still counts as an agent's. Left out, a workspace that is not autonomous starts as a
|
|
2737
|
+
* person's unless it runs under Claude Code (`CLAUDECODE` set).
|
|
2733
2738
|
* @returns `command`, a label for what ran (e.g. `werkmeister up (in my-workspace)`);
|
|
2734
2739
|
* `output`, the progress transcript without ANSI colours; and `path`, the workspace folder.
|
|
2735
2740
|
* @throws {@link WorkspaceError} when `name` is not a workspace, its `.env` has no
|
|
@@ -2750,7 +2755,7 @@ export const WORKSPACE_ACTIONS = ["up", "stop", "restart", "down", "pause", "res
|
|
|
2750
2755
|
* }
|
|
2751
2756
|
* ```
|
|
2752
2757
|
*/
|
|
2753
|
-
export async function runWorkspaceAction(name, action) {
|
|
2758
|
+
export async function runWorkspaceAction(name, action, { byPerson } = {}) {
|
|
2754
2759
|
if (!WORKSPACE_ACTIONS.includes(action)) {
|
|
2755
2760
|
throw new WorkspaceError(`Invalid action: ${JSON.stringify(action)}`);
|
|
2756
2761
|
}
|
|
@@ -2770,7 +2775,10 @@ export async function runWorkspaceAction(name, action) {
|
|
|
2770
2775
|
await withReporter(collector, async () => {
|
|
2771
2776
|
switch (action) {
|
|
2772
2777
|
case "up": {
|
|
2773
|
-
|
|
2778
|
+
// A person's press in an agent's (autonomous) workspace must not stop other agents (SW-833).
|
|
2779
|
+
const result = await up(feature, target, {
|
|
2780
|
+
byPerson: byPerson && !readAutonomous(target),
|
|
2781
|
+
});
|
|
2774
2782
|
// The only fact the CLI's summary block carried that the transcript
|
|
2775
2783
|
// does not: `up()` reports the slot and ports, never the hostnames.
|
|
2776
2784
|
if (result.urls.length) {
|
|
@@ -126,7 +126,8 @@ export const SELF_CHECK = "Review `output/` once against `../../BRIEF.md` and th
|
|
|
126
126
|
// The gate reads every `result` column and rejects any other cell text (SW-247, SW-286).
|
|
127
127
|
const exerciseFormat = (col) => `a \`| check | result | ${col} |\` table whose result cell is exactly \`PASS\` or \`FAIL\` — nothing else in the cell — with the captured output in the ${col} column. The rule holds for every table in \`exercise.md\`; describe a superseded run in prose, not as a \`FAIL\` row`;
|
|
128
128
|
// SW-736: `changeset status --since` reads git history, so before the commit it failed on an entry just written (sw-699, sw-755).
|
|
129
|
-
|
|
129
|
+
// SW-825: the gate stops what it started (SW-34), so sw-798's check hit "container … is not running".
|
|
130
|
+
const RELEASE_AFTER_COMMIT = "Run the repo's release check (the `Release check:` command in `werkmeister-context.md`) after the commit, not before: a check that compares the branch with its base in git history does not see an uncommitted release entry. When it runs in a service's container, an earlier `werkmeister pr gate --tests` stopped the containers it started: start the one it runs in with `werkmeister feature up --service <name>` first.";
|
|
130
131
|
const LINT = "the repo's lint command (the `<lint> &&` head of the test command in `werkmeister-context.md`, when it has one, which the PR gate's lint row runs) and fix what it fails, release entry included.";
|
|
131
132
|
// SW-807: exact, this workspace's own issue only. The feature, gate and status commands keep asking:
|
|
132
133
|
// each can reach shared infra, another workspace or the real ~/.werkmeister from agent-editable input.
|
package/package.json
CHANGED