werkmeister-core 0.89.1 → 0.89.3

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 CHANGED
@@ -1,5 +1,23 @@
1
1
  # sandbox-core
2
2
 
3
+ ## 0.89.3
4
+
5
+ ### Patch Changes
6
+
7
+ - 857fbb4: `werkmeister pr gate` and `pr open` no longer test every service when the diff touches `pnpm-lock.yaml`. The gate compares the worktree's lockfile with the one at the diff's base and touches only the services at the `importers:` entries that differ, mapped through `path_mappings` like a file under that importer. The `tests` row says so (`lockfile: pnpm-lock.yaml changes importers <path> → <svc>`). A change to the root importer `.`, to an importer no mapping covers, to an existing `packages:`/`snapshots:` entry, or to a top-level setting (`overrides`, `settings`, …) still tests every service, and so does a lockfile with no copy on the base.
8
+
9
+ `with-fixture-workspace` takes `--change-base <file>` and `--change-branch <file>` (with `--change`), which give the changed file real text on main and on the branch, e.g. two lockfile copies.
10
+
11
+ ## 0.89.2
12
+
13
+ ### Patch Changes
14
+
15
+ - fedb19b: The ICM bug-fix exercise stage (after the review's fixes) and the feature and refactor implement stages (after a fix to the post-exercise review) rerun `werkmeister pr gate --tests` instead of one service's test command. These edits come after the gate's run, and the gate retests every service the diff touches, so a docs fix no longer skips docs-site's tests and fails the first `pr open`.
16
+ - 5e724a6: The ICM research and reproduce stages say that when a change adds or widens an input to a pre-approved command (an allow rule, or a wrapper one covers), the decision defaults to an allowlist of accepted values and lists what each can reach (files, env vars, network addresses, processes); a blocklist needs a stated reason.
17
+ - b811b93: `werkmeister-context.md` § Test commands prints each running service's `docker exec` test line with the repo's `lint:` appended (`… sh -c '<test> && <lint>'`), as the host test line already does. An implement stage that runs its tests in the container now catches a `docs:check` or format failure there, not first at `werkmeister pr gate`. The lint-tailed line is not pre-approved, since a service container can hold the Docker socket and the real `~/.werkmeister`: Claude Code asks before each run.
18
+ - 69877d8: Every ICM stage that exercises a change says that a filter, workaround or special case the exercise needs before the change passes is a finding: a `FAIL` row in `exercise.md` until the code is fixed, or until the row says why it reflects real use rather than a defect.
19
+ - 62dca50: The ICM research and reproduce stages name, before a recommended answer or proposed fix is written, how each acceptance criterion's stated verification runs on that design (which command, which platform or container), and turn a criterion whose verification cannot reach the design into an open question.
20
+
3
21
  ## 0.89.1
4
22
 
5
23
  ## 0.89.0
@@ -24,6 +24,11 @@ export declare class DaemonTimeout extends SandboxError {
24
24
  export declare const tookTheCall: (code: string) => boolean;
25
25
  /** Request: the build the CLI would start. Response: the build the daemon loaded (SW-306). */
26
26
  export declare const BUILD_HEADER = "x-werkmeister-build";
27
+ /**
28
+ * `/api/tool`, request `1`: answer with headers at once and the status in the body (SW-700).
29
+ * Response `1`: the daemon did; a daemon that leaves it out answers with status codes.
30
+ */
31
+ export declare const STREAM_HEADER = "x-werkmeister-stream";
27
32
  /** `claudeLauncher()` evaluated in the session's env, not the daemon's launchd env. */
28
33
  export declare const LAUNCHER_HEADER = "x-werkmeister-launcher";
29
34
  /** Comma-separated `io.modelcontextprotocol/ui` mime types the session's MCP client advertised. */
@@ -65,6 +65,11 @@ const restartGapMs = () => Number(envVar("DAEMON_RETRY_MS")) || 15_000;
65
65
  let gaveUp = false;
66
66
  /** The error *code* comes after the request reached the daemon; a connect timeout never got there. */
67
67
  export const tookTheCall = (code) => code === "TimeoutError" || (code.startsWith("UND_ERR_") && code !== "UND_ERR_CONNECT_TIMEOUT");
68
+ // fetch wraps ECONNREFUSED and timeouts as a TypeError/AbortError with a cause.
69
+ const codeOf = (e) => {
70
+ const err = e;
71
+ return err.cause?.code ?? err.name;
72
+ };
68
73
  /**
69
74
  * *retry*: wait out the daemon's own restart (SW-306) on a refused or reset connect,
70
75
  * which the daemon never saw, so resending is safe.
@@ -79,9 +84,7 @@ async function send(url, init, retry = true) {
79
84
  return res;
80
85
  }
81
86
  catch (e) {
82
- // fetch wraps ECONNREFUSED and timeouts as a TypeError/AbortError with a cause.
83
- const err = e;
84
- const code = err.cause?.code ?? err.name;
87
+ const code = codeOf(e);
85
88
  if (tookTheCall(code))
86
89
  throw new DaemonTimeout(code);
87
90
  if (!(code in NOT_LISTENING))
@@ -97,6 +100,11 @@ async function send(url, init, retry = true) {
97
100
  }
98
101
  /** Request: the build the CLI would start. Response: the build the daemon loaded (SW-306). */
99
102
  export const BUILD_HEADER = "x-werkmeister-build";
103
+ /**
104
+ * `/api/tool`, request `1`: answer with headers at once and the status in the body (SW-700).
105
+ * Response `1`: the daemon did; a daemon that leaves it out answers with status codes.
106
+ */
107
+ export const STREAM_HEADER = "x-werkmeister-stream";
100
108
  // Set by the session's stdio proxy (SW-344): facts only the session's own process can see.
101
109
  /** `claudeLauncher()` evaluated in the session's env, not the daemon's launchd env. */
102
110
  export const LAUNCHER_HEADER = "x-werkmeister-launcher";
@@ -166,6 +174,7 @@ export async function callTool(name, args = {}, opts = {}) {
166
174
  "Content-Type": "application/json",
167
175
  ...headers(opts.token),
168
176
  ...(build ? { [BUILD_HEADER]: build } : {}),
177
+ [STREAM_HEADER]: "1",
169
178
  },
170
179
  body: JSON.stringify({ name, arguments: args }),
171
180
  signal: opts.signal ? AbortSignal.any([opts.signal, timeout]) : timeout,
@@ -177,14 +186,21 @@ export async function callTool(name, args = {}, opts = {}) {
177
186
  res.status !== 403) {
178
187
  throw new DaemonUnavailable(`HTTP ${res.status}: the port is held by something that is not the werkmeister daemon`);
179
188
  }
180
- const body = (await res.json().catch(() => ({})));
181
- if (!res.ok) {
189
+ const streamed = res.headers.get(STREAM_HEADER) === "1";
190
+ const body = (await res.json().catch((e) => {
191
+ // Streamed headers mean the daemon is running the call: never let a caller run it again.
192
+ if (streamed)
193
+ throw new DaemonTimeout(codeOf(e));
194
+ return {};
195
+ }));
196
+ const status = streamed ? (body.status ?? 500) : res.status;
197
+ if (status < 200 || status > 299) {
182
198
  // SW-254: the daemon has no tool this CLI knows, so it runs older code; the MCP SDK's own words.
183
199
  if (body.error?.replace(/^MCP error -?\d+: /, "") === `Tool ${name} not found`) {
184
200
  throw new SandboxError(`The werkmeister daemon is older than this CLI: it has no \`${name}\` tool. ` +
185
201
  "Run `werkmeister daemon restart`.", "DAEMON_STALE");
186
202
  }
187
- throw new SandboxError(body.error ?? `daemon answered HTTP ${res.status} to ${name}`, body.code ?? `HTTP_${res.status}`);
203
+ throw new SandboxError(body.error ?? `daemon answered HTTP ${status} to ${name}`, body.code ?? `HTTP_${status}`);
188
204
  }
189
205
  return { data: body.structuredContent, text: body.text ?? "" };
190
206
  }
@@ -44,6 +44,9 @@ export interface FixtureOptions {
44
44
  slotsFull?: boolean;
45
45
  /** The first repo's `.werkmeister/services.yaml` on the branch, committed over a base fragment on main (`fragment`, else the default registry's), so the gate's fragment row compares the two (SW-664). */
46
46
  fragmentChange?: string;
47
+ /** The texts `change` holds on main and on the branch, instead of `base` and `changed`, e.g. two pnpm-lock.yaml copies (SW-696). */
48
+ changeBase?: string;
49
+ changeBranch?: string;
47
50
  /** Top-level keys added to the fixture's config.yaml, e.g. `{ budget: { host_load: 0.01 } }` (SW-670); fixturePreset refuses any key but CONFIG_KEYS. */
48
51
  config?: Record<string, unknown>;
49
52
  }
@@ -157,7 +157,7 @@ ${githubProject(repos.map((r) => r.name))}${opts.config ? YAML.stringify(opts.co
157
157
  const changed = [change, frag === undefined ? undefined : FRAGMENT_FILE].filter(Boolean);
158
158
  if (changed.length) {
159
159
  if (change)
160
- write(path.join(repo, change), "base\n");
160
+ write(path.join(repo, change), opts.changeBase ?? "base\n");
161
161
  if (frag !== undefined)
162
162
  write(path.join(repo, FRAGMENT_FILE), opts.fragment ?? BASE_FRAGMENT);
163
163
  git(repo, "add", ".");
@@ -176,7 +176,7 @@ ${githubProject(repos.map((r) => r.name))}${opts.config ? YAML.stringify(opts.co
176
176
  git(source, "switch", "-q", "-c", "fixture-source");
177
177
  if (changed.length) {
178
178
  if (change)
179
- write(path.join(repo, change), "changed\n");
179
+ write(path.join(repo, change), opts.changeBranch ?? "changed\n");
180
180
  if (frag !== undefined)
181
181
  write(path.join(repo, FRAGMENT_FILE), frag);
182
182
  git(repo, "commit", "-q", "-am", `change ${changed.join(", ")}`);
@@ -255,7 +255,7 @@ const SCRIPT = `#!/bin/sh
255
255
  # Generated by \`werkmeister workspace init\` (SW-292); rerun it to regenerate.
256
256
  # Runs this workspace's own built werkmeister CLI against a seeded fixture workspace, removed on exit:
257
257
  # temp HOME and registry, a local bare origin, logging fakes for gh and docker, dead Docker and daemon.
258
- # usage: with-fixture-workspace [--no-wait] [--gate] [--bare] [--daemon] [--exec-runs] [--merged] [--behind] [--slots-full] [--issue <ref>] [--pr-field <key>=<value>]... [--workspace <file>] [--config <file>] [--services <file>] [--fragment <file>] [--change <path>] [--fragment-change <file>] [--print <file>]... <werkmeister args> [--then <werkmeister args>]...
258
+ # usage: with-fixture-workspace [--no-wait] [--gate] [--bare] [--daemon] [--exec-runs] [--merged] [--behind] [--slots-full] [--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>]...
259
259
  # It only ever runs that CLI, never another command, so one allow rule can cover it (SW-172, SW-231);
260
260
  # --exec-runs, given first, also runs the registry's rows on the host, so the workspace asks before it (SW-473).
261
261
  ws=$(cd "$(dirname "$0")/../.." && pwd -P) || exit 1
@@ -253,13 +253,13 @@ Hit a bug, or need to log a feature or task, in the \`werkmeister\` tool or a re
253
253
  // ---------------------------------------------------------------------------
254
254
  // werkmeister-context.md generation
255
255
  // ---------------------------------------------------------------------------
256
- function testCommandLine(feature, svc, servicesConfig, archetypes) {
256
+ function testCommandLine(feature, svc, servicesConfig, archetypes, lint) {
257
257
  const cmd = serviceTestCommand(svc, servicesConfig[svc], archetypes);
258
258
  const noTests = serviceNoTests(servicesConfig[svc]);
259
259
  if (noTests)
260
260
  return `- \`${svc}\`: no tests (registry: ${noTests})`;
261
261
  return cmd
262
- ? `- \`${svc}\`: \`${containerTestCommand(feature, svc, cmd)}\``
262
+ ? `- \`${svc}\`: \`${containerTestCommand(feature, svc, lint ? `${cmd} && ${lint}` : cmd)}\``
263
263
  : `- \`${svc}\`: no test command registered (add \`test:\` to its registry entry)`;
264
264
  }
265
265
  /**
@@ -415,6 +415,8 @@ export function buildSandboxContextMd(feature, slot, portStart, portEnd, localSe
415
415
  let containerCommandsBlock;
416
416
  if (localServices.length > 0) {
417
417
  const svcs = [...localServices].sort();
418
+ // SW-688: the in-container line carries the repo's lint too, as the host line does (SW-219).
419
+ const svcLint = svcs.map((s) => lintOf(String(servicesConfig[s]?.["repo"] ?? "")));
418
420
  const containerList = svcs.map((s) => `\`${feature}-${s}\``).join(", ");
419
421
  const sampleSvc = svcs[0];
420
422
  containerCommandsBlock = `### Container Commands
@@ -434,9 +436,11 @@ docker compose restart ${sampleSvc}
434
436
 
435
437
  ### Test commands
436
438
 
437
- The registry's \`test:\` for each service (or its archetype's), run in its container — the worktree is mounted at \`/app\` with its \`node_modules\`; the host checkout has none. The pre-PR gate runs these (\`werkmeister pr gate\`).
439
+ The registry's \`test:\` for each service (or its archetype's), run in its container — the worktree is mounted at \`/app\` with its \`node_modules\`; the host checkout has none. The pre-PR gate runs these (\`werkmeister pr gate\`).${svcLint.some(Boolean)
440
+ ? " A line ending in `&& <lint>` also runs the repo's lint, the PR gate's lint row, so a `docs:check` or format failure shows here and not first at the gate."
441
+ : ""}
438
442
 
439
- ${svcs.map((s) => testCommandLine(feature, s, servicesConfig, archetypes ?? loadArchetypes())).join("\n")}
443
+ ${svcs.map((s, i) => testCommandLine(feature, s, servicesConfig, archetypes ?? loadArchetypes(), svcLint[i])).join("\n")}
440
444
 
441
445
  `;
442
446
  }
@@ -141,6 +141,17 @@ export declare function fragmentTouched(dir: string, files: string[], branch: Re
141
141
  all: string | null;
142
142
  services: string[];
143
143
  };
144
+ /**
145
+ * What a pnpm-lock.yaml change reaches (SW-696): the importers whose entries differ from the
146
+ * base's, or `all` naming a change that reaches every importer — a top-level setting, or a
147
+ * `packages:`/`snapshots:` key on both sides whose value changed (pnpm gives a new version or
148
+ * peer set a new key, so only an existing entry can change an unchanged importer's tree).
149
+ * `null` when either side is not a lockfile.
150
+ */
151
+ export declare function lockfileTouched(base: string, branch: string): {
152
+ all: string | null;
153
+ importers: string[];
154
+ } | null;
144
155
  /**
145
156
  * The pre-PR gate for one repo. A container it had to start for the repo's
146
157
  * tests is stopped again, pass or fail; what was running before stays (SW-34).
@@ -432,6 +432,38 @@ export function fragmentTouched(dir, files, branch, before) {
432
432
  .sort();
433
433
  return { all: reasons.length ? reasons.join(", ") : null, services };
434
434
  }
435
+ const LOCKFILE = "pnpm-lock.yaml";
436
+ /**
437
+ * What a pnpm-lock.yaml change reaches (SW-696): the importers whose entries differ from the
438
+ * base's, or `all` naming a change that reaches every importer — a top-level setting, or a
439
+ * `packages:`/`snapshots:` key on both sides whose value changed (pnpm gives a new version or
440
+ * peer set a new key, so only an existing entry can change an unchanged importer's tree).
441
+ * `null` when either side is not a lockfile.
442
+ */
443
+ export function lockfileTouched(base, branch) {
444
+ let m;
445
+ let b;
446
+ try {
447
+ m = YAML.parse(base);
448
+ b = YAML.parse(branch);
449
+ }
450
+ catch {
451
+ return null;
452
+ }
453
+ if (!m || !b || typeof m !== "object" || typeof b !== "object")
454
+ return null;
455
+ const changed = (x = {}, y = {}) => [...new Set([...Object.keys(x), ...Object.keys(y)])].filter((k) => !isDeepStrictEqual(x[k], y[k]));
456
+ const reasons = [
457
+ ...changed(m, b).filter((k) => !["importers", "packages", "snapshots"].includes(k)),
458
+ ...["packages", "snapshots"].flatMap((s) => changed(m[s], b[s])
459
+ .filter((k) => m[s]?.[k] !== undefined && b[s]?.[k] !== undefined)
460
+ .map((k) => `${s}: ${k}`)),
461
+ ];
462
+ const all = reasons.length
463
+ ? `${reasons.slice(0, 3).join(", ")}${reasons.length > 3 ? ", …" : ""}`
464
+ : null;
465
+ return { all, importers: changed(m["importers"], b["importers"]).sort() };
466
+ }
435
467
  function readEnv(ws, key) {
436
468
  try {
437
469
  for (const line of fs.readFileSync(path.join(ws, ".env"), "utf8").split(/\r?\n/)) {
@@ -806,15 +838,49 @@ testsOnly = false) {
806
838
  : null;
807
839
  // No base fragment (new, or unreadable): the file stays unmapped and every service runs.
808
840
  const fragment = own && before ? fragmentTouched(file.dir, diffed, own, before) : null;
809
- const files = fragment ? diffed.filter((f) => f !== FRAGMENT_REL) : diffed;
810
- const touched = fragment?.all
841
+ // The lockfile maps to the importers its diff changes, not to every service (SW-696).
842
+ // Against the worktree's copy: the gate's containers bind-mount the worktree, not HEAD.
843
+ const lockChange = async () => {
844
+ const mb = await deps.run("git", ["-C", dir, "merge-base", `origin/${base}`, "HEAD"]);
845
+ const show = mb.code
846
+ ? mb
847
+ : await deps.run("git", ["-C", dir, "show", `${mb.stdout.trim()}:${LOCKFILE}`]);
848
+ if (show.code)
849
+ return null;
850
+ try {
851
+ return lockfileTouched(show.stdout, fs.readFileSync(path.join(dir, LOCKFILE), "utf8"));
852
+ }
853
+ catch {
854
+ return null;
855
+ }
856
+ };
857
+ // No base lockfile, or either side unreadable: the file stays unmapped and every service runs.
858
+ const lock = diffed.includes(LOCKFILE) && mappingFor(LOCKFILE, repo) === undefined
859
+ ? await lockChange()
860
+ : null;
861
+ const files = diffed.filter((f) => !(fragment && f === FRAGMENT_REL) && !(lock && f === LOCKFILE));
862
+ // An importer maps like a file under it, so the root importer `.` touches every service.
863
+ const importerFile = (i) => path.posix.join(i, "package.json");
864
+ const lockImporters = lock && !lock.all ? lock.importers : [];
865
+ const lockServices = mapTouched(lockImporters.map(importerFile), repo);
866
+ // Named like an unmapped file (SW-563), so the importer gets mapped rather than every service started again.
867
+ const lockUnmapped = lockImporters.filter((i) => mappingFor(importerFile(i), repo) === undefined);
868
+ const touched = fragment?.all || lock?.all
811
869
  ? [...(repo["services"] ?? [])].sort()
812
- : [...new Set([...mapTouched(files, repo), ...(fragment?.services ?? [])])].sort();
870
+ : [
871
+ ...new Set([...mapTouched(files, repo), ...(fragment?.services ?? []), ...lockServices]),
872
+ ].sort();
813
873
  const skips = (file.fm["skip_tests"] ?? {});
814
874
  if (fragment)
815
875
  add("tests", true, fragment.all
816
876
  ? `every service: ${FRAGMENT_REL} changes ${fragment.all}`
817
877
  : `fragment: ${FRAGMENT_REL} changes ${fragment.services.join(", ") || "no service entry"}`);
878
+ if (lock)
879
+ add("tests", true, lock.all
880
+ ? `every service: ${LOCKFILE} changes ${lock.all}`
881
+ : lockUnmapped.length
882
+ ? `every service: ${LOCKFILE} changes importer ${lockUnmapped.join(", ")}, which no path_mappings or no_service_paths entry covers`
883
+ : `lockfile: ${LOCKFILE} changes importers ${lock.importers.join(", ") || "none"} → ${lockServices.join(", ") || "no service"}`);
818
884
  const unmapped = unmappedFiles(files, repo);
819
885
  const unmappedList = `${unmapped.slice(0, 5).join(", ")}${unmapped.length > 5 ? ", …" : ""}`;
820
886
  // Nothing touched yet unmapped files: the repo has no services to map to
@@ -18,6 +18,8 @@ const HOSTNAME_RULE = "If `werkmeister feature up` warns that a routed hostname
18
18
  // SW-143: a library or CLI has nothing to restart. How to exercise one is the service's (or its archetype's)
19
19
  // `validate:` text, so app-specific steps stay out of the generic templates.
20
20
  const NO_SERVICE_RULE = "A library or CLI has no service to restart: build it, then exercise the built artifact exactly as its Validation text in `werkmeister-context.md` § How to validate says.";
21
+ // SW-691: sw-681's replay filtered out the very lines that showed its bug, and recorded nothing.
22
+ const EXERCISE_WORKAROUND = "A filter, workaround or special case the exercise needs before the change passes is a finding: write it into `exercise.md` as a `FAIL` row until the code is fixed, or until the row says why it reflects real use rather than a defect.";
21
23
  const IMPLEMENT_STEPS = [
22
24
  "Confirm ponytail is active (see `_shared/standards.md`; invoke the skill only if it is not), then read the standards rows above. Restate the rule you are applying beside each edit.",
23
25
  ];
@@ -47,7 +49,8 @@ const HOST_TEST_STEP = `${HOST_TESTS}Record its exit code. ${TEST_TAIL}`;
47
49
  // SW-430: the gate runs once, on reviewed code; a Must fix found after it forced a rerun (SW-344).
48
50
  const GATE_STEP = "Once the review's fixes are in, run `werkmeister pr gate --tests` (from the workspace, detached when it may pass 10 minutes) and fix what it fails; record its exit code. A fix here reruns the host test step first.";
49
51
  // SW-534: sw-385's exercise on the real harness fixed ~40 lines after the review; they shipped unreviewed.
50
- const REVIEW_DELTA = "If the exercise below changes code, rerun the review on that delta: a fresh subagent with the same brief, over the commits and changes made since the first review. Fix its **Must fix** findings, rerun the host test step, and append the result as new rows to `output/review.md`; the gate's review row covers them.";
52
+ // SW-678: a docs fix rerun with one service's tests skipped docs-site's, and the first `pr open` failed on it.
53
+ const REVIEW_DELTA = "If the exercise below changes code, rerun the review on that delta: a fresh subagent with the same brief, over the commits and changes made since the first review. Fix its **Must fix** findings, rerun `werkmeister pr gate --tests` (not one service's test command: these edits come after the gate above, and the gate retests every service the diff touches), and append the result as new rows to `output/review.md`; the gate's review row covers them.";
51
54
  // SW-351: one of five parallel Edits reported success but never reached the file; tests did not cover it.
52
55
  const diffCheck = (doc) => `Before running tests, read \`git diff\` in each repo you touched and tick off each edit \`${doc}\` settled against it: an edit reported as applied can be missing.`;
53
56
  // SW-562: sw-499's two MANUAL rows (a real VS Code window) were approved unrun and shipped as MANUAL, never recorded.
@@ -91,12 +94,16 @@ const reviewStep = (rerun, group) => "Review the diff: for each code worktree yo
91
94
  `${REVIEW_FORMAT}, with one row per worktree (\`PASS\` means no Must fix left open). ` +
92
95
  "The PR gate refuses to open a PR while `review.md` is missing or has a row that is not `PASS`; a file of prose alone fails with `has no PASS row`.";
93
96
  const implementReview = (v) => reviewStep("rerun the host test step above", v.group);
97
+ // SW-687: sw-634 decided a blocklist for a pre-approved wrapper's input; one key it let through sent auth to any host.
98
+ const PREAPPROVED_INPUT = "When the change adds or widens an input to a pre-approved command (an allow rule, or a wrapper an allow rule covers), the decision defaults to an allowlist of accepted values and lists what each accepted value can reach: files, env vars, network addresses, processes. A blocklist needs a stated reason.";
94
99
  // SW-106 decision 7 renamed a legacy alias that `git log -S` would have shown was meant to be removed.
95
100
  const NAME_HISTORY_STEP = "For each decision that renames, keeps or removes a name, a fallback or an alias, record its definition site (file and line) and the commit that introduced it (`git log -S <name>`, in the repo that defines it). " +
96
101
  'When that commit marks it as a transition or legacy alias, list "remove" as an option beside rename and keep.';
97
102
  // SW-478: a stage gate must be a status line, so /check-in can flip it with its note and the waiting session acts on the file.
98
103
  const statusGate = (file, read) => `${read} Then change \`status: proposed\` at the top of \`output/${file}\` to \`status: decided\`: that flip is the approval, and the next session starts without asking again. ${CHAT_APPROVAL}`;
99
104
  const FIRST_LINE = ", its first line `status: proposed`";
105
+ // SW-709: sw-614's criterion was checked in the Linux container, where the decided macOS-only row never runs.
106
+ const CRITERION_REACH = "Before writing a recommended answer or proposed fix, name for each acceptance criterion in `BRIEF.md` how its stated verification runs on that design (which command, which platform or container). A criterion whose verification cannot reach the design is an open question, not a decided one.";
100
107
  // SW-517: a check left as a sentence at the end of a long reply is easy to miss; the question tool makes it a prompt.
101
108
  export const askLine = (tool) => tool
102
109
  ? `Ask this check through \`${tool}\`: at most 4 questions per call (more than 4: batches of 4, one call after another), each standing on its own (what was checked, 2–3 concrete options with the exact wording or behaviour, the recommended one first; "Other" takes edits). Write each answer into the output file as its status, noted \`${APPROVAL_NOTE.chat}\` (a PR file: \`${APPROVAL_NOTE.chatPr}\`). A check left as a sentence at the end of a reply is not asked.`
@@ -182,10 +189,11 @@ const feature = [
182
189
  // Moved from docs/harnesses.md: adapter runs kept deciding from a harness's docs, not its binary.
183
190
  "When a decision rests on how an external tool behaves (a CLI command or flag, a plugin API, an event name), check it against the installed tool, not only its docs: record `<bin> --version`, and confirm each fact with `<bin> <cmd> --help` or a real run or plugin load. `decisions.md` names the version and, beside each fact, the command that confirmed it; a fact only the docs support is marked `unverified: docs only`, and no decision rests on it. If the tool cannot be installed, say so and mark every such fact `unverified`. " +
184
191
  // SW-605: sw-583 recommended a GitHub API call as `unverified` only in the file; the person approved it and a read-only call later returned 403.
185
- "A recommended answer that rests on an external API, permission or platform behaviour (a token scope, a hosted API's response, a cloud permission) is checked live, read-only (a list, get, `--help` or dry run, never a write), before it goes into `decisions.md`, with the command and its result beside it. When it cannot be checked read-only, write `unverified` in the option text itself, so the question the person is asked carries the word, not only the file.",
192
+ "A recommended answer that rests on an external API, permission or platform behaviour (a token scope, a hosted API's response, a cloud permission) is checked live, read-only (a list, get, `--help` or dry run, never a write), before it goes into `decisions.md`, with the command and its result beside it. When it cannot be checked read-only, write `unverified` in the option text itself, so the question the person is asked carries the word, not only the file. " +
193
+ PREAPPROVED_INPUT,
186
194
  "Write `output/inventory.md`: steps 1–3.",
187
195
  NAME_HISTORY_STEP,
188
- "Write `output/decisions.md`: every open question in `BRIEF.md`, each as a heading with `status: proposed`, your recommended answer, and the evidence from steps 1–3 and 5. Leave the answer blank when only a person can give it (a ticket key, a preference).",
196
+ `Write \`output/decisions.md\`: every open question in \`BRIEF.md\`, each as a heading with \`status: proposed\`, your recommended answer, and the evidence from steps 1–3 and 5. Leave the answer blank when only a person can give it (a ticket key, a preference). ${CRITERION_REACH}`,
189
197
  ],
190
198
  outputs: ["`output/inventory.md`", "`output/decisions.md`"],
191
199
  humanCheck: `Open \`output/decisions.md\`. Edit each answer as needed and change its \`status: proposed\` to \`status: decided\`. The next stage must not start while any question is still \`proposed\`. When every question reads \`decided\`, that is the approval — the next session starts the next stage without asking for confirmation. ${CHAT_APPROVAL}`,
@@ -247,7 +255,7 @@ const feature = [
247
255
  implementReview(v),
248
256
  GATE_STEP,
249
257
  REVIEW_DELTA,
250
- `Reload the running code: ${v.restart}. ${RELOAD_RULE} ${HOSTNAME_RULE} Then exercise the change as the How-to-validate section of \`werkmeister-context.md\` describes for each service touched, and capture the output. ${NO_SERVICE_RULE}`,
258
+ `Reload the running code: ${v.restart}. ${RELOAD_RULE} ${HOSTNAME_RULE} Then exercise the change as the How-to-validate section of \`werkmeister-context.md\` describes for each service touched, and capture the output. ${NO_SERVICE_RULE} ${EXERCISE_WORKAROUND}`,
251
259
  `Write \`output/exercise.md\`: \`git diff --stat\` for each repo you touched, the host and \`pr gate --tests\` exit codes and summary lines, ${SKIPPED}, any deviation from \`spec.md\` with its reason, and the exercise checks as ${exerciseFormat("evidence")}.`,
252
260
  MANUAL_STEP,
253
261
  ],
@@ -289,11 +297,11 @@ const bugfix = [
289
297
  // SW-566: sw-545's fix changed a return shape its one caller treated as "stop"; only the exercise caught it.
290
298
  "List every other caller of the function at the root cause and what each does with the result (an early return, a printed value, a stored state), so the fix's return shape is checked against every caller before the fix stage — a fix there reaches them too. When the fix belongs in shared code, list its call sites through every helper or entry point that reaches that code, not one argument shape, and record the search commands (greps) you used in `repro.md`.",
291
299
  // SW-442: sessionBusy had two true cases; stage 01 listed callers, so only review caught the second (sw-418).
292
- "When the proposed fix branches on a predicate, list each condition that makes it true and give each one a test.",
300
+ `When the proposed fix branches on a predicate, list each condition that makes it true and give each one a test. ${PREAPPROVED_INPUT}`,
293
301
  NAME_HISTORY_STEP,
294
302
  // SW-564: sw-521's root cause was a permission rule; step 4 listed the callers of one builder and missed two other sources of a matching rule.
295
303
  "When the root cause is a permission rule (allow, deny, ask), step 4 lists every source of a matching rule: each builder, each rule derived from a registered command (its `&&` segments included), rules recorded in existing workspaces and how a refresh or migrate removes them, and the list a headless wake passes (`--allowedTools` / `--disallowedTools`). The failing test probes each source.",
296
- `Write \`output/repro.md\`: steps 1–7, and a proposed fix in one paragraph under a \`status: proposed\` line.${noCommitPlan(v.group)}`,
304
+ `Write \`output/repro.md\`: steps 1–7, and a proposed fix in one paragraph under a \`status: proposed\` line.${noCommitPlan(v.group)} ${CRITERION_REACH}`,
297
305
  ],
298
306
  outputs: ["`output/repro.md`", "One failing test, uncommitted"],
299
307
  humanCheck: `Read \`output/repro.md\`. Correct the root cause or the proposed fix if needed, then change \`status: proposed\` to \`status: decided\`. That is the approval — the next session starts the fix without asking again. ${CHAT_APPROVAL}`,
@@ -351,11 +359,12 @@ const bugfix = [
351
359
  process: [
352
360
  `Reload the running code: ${v.restart}. ${RELOAD_RULE} ${HOSTNAME_RULE} ${NO_SERVICE_RULE}`,
353
361
  "Rerun the reproduction steps from `repro.md` exactly. Capture the output.",
354
- "Exercise one neighbouring path through each caller `repro.md` listed. Capture the output.",
362
+ `Exercise one neighbouring path through each caller \`repro.md\` listed. Capture the output. ${EXERCISE_WORKAROUND}`,
355
363
  `Write \`output/exercise.md\`: steps 2–3 as ${exerciseFormat("detail")}.`,
356
364
  // SW-579: the review step rewrites exercise.md, so recorded MANUAL results come first.
357
365
  MANUAL_STEP,
358
- reviewStep("rerun the test command exactly as `../../.werkmeister/werkmeister-context.md` states it (through `.werkmeister/bin/with-temp-home`), rerun steps 2–3 and update `exercise.md`", v.group),
366
+ // SW-678: these edits come after the fix stage's gate; one service's test command missed docs-site's (sw-631, sw-669).
367
+ reviewStep("rerun `werkmeister pr gate --tests` (from the workspace, detached when it may pass 10 minutes), not one service's test command: it retests every service the diff touches, and these edits come after the fix stage's gate. Then rerun steps 2–3 and update `exercise.md`", v.group),
359
368
  ],
360
369
  outputs: [
361
370
  "`output/exercise.md`",
@@ -420,7 +429,7 @@ const refactor = [
420
429
  implementReview(v),
421
430
  GATE_STEP,
422
431
  REVIEW_DELTA,
423
- `After the last step, reload and exercise the service: ${v.restart}. ${RELOAD_RULE} ${HOSTNAME_RULE} ${NO_SERVICE_RULE}`,
432
+ `After the last step, reload and exercise the service: ${v.restart}. ${RELOAD_RULE} ${HOSTNAME_RULE} ${NO_SERVICE_RULE} ${EXERCISE_WORKAROUND}`,
424
433
  `Write \`output/exercise.md\`: \`git diff --stat\` per repo, the test result after each step, the \`pr gate --tests\` exit code, ${SKIPPED}, and the final exercise checks as ${exerciseFormat("evidence")}.`,
425
434
  MANUAL_STEP,
426
435
  ],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "werkmeister-core",
3
- "version": "0.89.1",
3
+ "version": "0.89.3",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "description": "werkmeister's shared library. Its public API is werkmeister-core/sdk; every other entry point is internal.",