werkmeister-core 0.93.8 → 0.93.11
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 +15 -0
- package/dist/fixture_workspace.js +1 -1
- package/dist/generated_file_check.d.ts +2 -0
- package/dist/generated_file_check.js +7 -0
- package/dist/harness/claude/hooks_gen.d.ts +6 -2
- package/dist/harness/claude/hooks_gen.js +86 -19
- package/dist/issues_report.d.ts +1 -1
- package/dist/issues_report.js +4 -1
- package/dist/lifecycle.js +13 -5
- package/dist/migrate.js +7 -2
- package/dist/strategies/icm.js +1 -1
- package/dist/strategies/icm_templates.js +9 -5
- package/dist/strategies/jit.js +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# sandbox-core
|
|
2
2
|
|
|
3
|
+
## 0.93.11
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- cbf52b7: The waiting queue no longer drops a queued feature without telling its session. When the grant's start fails after admission (a failed `compose up`, for example), the session's waiting state is cleared and it is told to rerun `werkmeister feature up`. A waiter whose slot lease is gone is started from its workspace instead of being dequeued (SW-848).
|
|
8
|
+
|
|
9
|
+
## 0.93.10
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 5db8d8a: Autonomous workspaces no longer pre-approve `werkmeister feature up --service:*` or `feature up <feature> --service:*`, which let an agent start another workspace's service (`feature up --service x <other>`, or `-w <path>`). Both forms are now allowed exactly, once for each of the workspace's own services (SW-843).
|
|
14
|
+
- 2e91d10: A service whose volumes mount the docker socket or the werkmeister home (or a parent of either) no longer gets a pre-approved `docker exec <feature>-<svc> sh -c '<test>'` rule: its test code would run with the host's docker and the real `~/.werkmeister`. Those runs ask; `werkmeister pr gate` still runs them (SW-845).
|
|
15
|
+
|
|
16
|
+
## 0.93.9
|
|
17
|
+
|
|
3
18
|
## 0.93.8
|
|
4
19
|
|
|
5
20
|
### Patch Changes
|
|
@@ -19,7 +19,7 @@ import { prDir, stageDirs, templateFor } from "./strategies/icm_templates.js";
|
|
|
19
19
|
const NAME = /^[a-z0-9][a-z0-9-]*$/;
|
|
20
20
|
const QUEUE_ENTRY = /^([a-z0-9][a-z0-9-]*)(?::(\d+)(?::([a-z0-9][a-z0-9-]*(?:,[a-z0-9][a-z0-9-]*)*))?)?$/;
|
|
21
21
|
// The only config.yaml keys --config may add: others (jira, github_ingest, paths…) reach real services or repos from a pre-approved run.
|
|
22
|
-
const CONFIG_KEYS = ["budget"];
|
|
22
|
+
const CONFIG_KEYS = ["budget", "workspace_ask_rules"];
|
|
23
23
|
export const FIXTURE_FEATURE = "demo";
|
|
24
24
|
export const FIXTURE_BRANCH = "me/demo";
|
|
25
25
|
export const FIXTURE_REPO_SLUG = "o/app";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** The three checks a run makes before filing a bug about a generated file; a leaf module so the issues guide and the ICM review step can share it without an import cycle. */
|
|
2
|
+
import { COMPOSE_FILE } from "./compose_file.js";
|
|
3
|
+
// SW-844: sw-773 filed SW-835 against werkmeister for a settings.json edit the person had made by hand.
|
|
4
|
+
export const generatedFileCheck = (tool) => `Before filing a bug about a generated file (\`.claude/settings.json\`, \`.werkmeister/*\`, \`${COMPOSE_FILE}\`, \`.env\`) that changed outside this run's own edits, check three things and file only if they still point at werkmeister: ` +
|
|
5
|
+
"(1) compare it with its record where one exists (`.werkmeister/claude-permissions.json` for the permission rules and model werkmeister merges in; hook entries are not recorded) and say whether the record changed too — werkmeister rewrites the record whenever it changes what it merges in, so a recorded rule or model missing from the file while the record is unchanged was not removed by werkmeister; " +
|
|
6
|
+
"(2) compare the file's mtime with this session's own activity: was any of its commands running then? " +
|
|
7
|
+
`(3) Ask the person${tool ? ` through \`${tool}\`` : ""} whether they edited it, before naming a werkmeister writer.`;
|
|
@@ -90,8 +90,11 @@ export declare function removeWorkspaceHooks(workspaceRoot: string): string[];
|
|
|
90
90
|
export declare function writeAutoStopHook(workspaceRoot: string, on: boolean): string;
|
|
91
91
|
export declare const READ_ONLY_GIT_RULES: string[];
|
|
92
92
|
export declare const AUTONOMOUS_RULES: string[];
|
|
93
|
-
/**
|
|
94
|
-
|
|
93
|
+
/**
|
|
94
|
+
* AUTONOMOUS_RULES plus the `werkmeister` and `docker` commands that name this feature or its containers.
|
|
95
|
+
* *repoServices*: the workspace's repos' other services (on-demand ones), which only `feature up --service` starts.
|
|
96
|
+
*/
|
|
97
|
+
export declare function autonomousRules(feature: string, services: string[], repoServices?: string[]): string[];
|
|
95
98
|
/**
|
|
96
99
|
* Allow rules for each local service's registered test command, then read-only
|
|
97
100
|
* git. Each command gets the container form the agent is told to run, plus the
|
|
@@ -114,6 +117,7 @@ export declare function workspaceAllowRules(workspaceRoot: string, autonomous?:
|
|
|
114
117
|
* SW-473: `--exec-runs` runs the registry's rows on the host, so its forms of the pre-approved fixture
|
|
115
118
|
* wrapper and built CLI ask first. The CLI takes it only as the first fixture option, so a prefix catches it.
|
|
116
119
|
* SW-510: `node --test <file>` through the temp-HOME wrapper runs any file, one the agent just wrote too.
|
|
120
|
+
* SW-842: config.yaml `workspace_ask_rules: false` drops the node --test asks; the --exec-runs ones always stay.
|
|
117
121
|
*/
|
|
118
122
|
export declare function workspaceAskRules(workspaceRoot: string): string[];
|
|
119
123
|
/** The deny rules this workspace should have: AUTONOMOUS_DENY while `autonomous` is on. */
|
|
@@ -43,9 +43,12 @@
|
|
|
43
43
|
*/
|
|
44
44
|
import * as fs from "node:fs";
|
|
45
45
|
import * as path from "node:path";
|
|
46
|
+
import { parse as parseYaml } from "yaml";
|
|
46
47
|
import { candidateServiceNames, containerTestCommand, isPlainChain, serviceTestCommand, wrappedTestCommand, } from "../../archetypes.js";
|
|
47
|
-
import { dotDir, getReposRoot, loadArchetypes, loadReposConfig, loadServices, } from "../../config.js";
|
|
48
|
+
import { dotDir, expandUser, getReposRoot, loadArchetypes, loadReposConfig, loadServices, sandboxHome, sandboxRoot, } from "../../config.js";
|
|
48
49
|
import { frozenInstalls } from "../../fragment_detect/workspace.js";
|
|
50
|
+
import { load as loadGlobalConfig } from "../../global_config.js";
|
|
51
|
+
import { workspaceServices } from "../../registry_sync.js";
|
|
49
52
|
import { info } from "../../reporter.js";
|
|
50
53
|
import { repoDirs } from "../../standards.js";
|
|
51
54
|
import { tempHomeWrapper } from "../../temp_home.js";
|
|
@@ -349,8 +352,6 @@ export const AUTONOMOUS_RULES = [
|
|
|
349
352
|
// No-arg forms act on the cwd's FEATURE; `autonomousRules` adds the named ones.
|
|
350
353
|
// Each pre-SW-186 spelling keeps its rule until the CLI drops it, beside its new one.
|
|
351
354
|
...["up", "restart", "feature up", "feature restart"].flatMap(cli),
|
|
352
|
-
// SW-132: one of its own services, on-demand ones included, the way the PR gate starts them.
|
|
353
|
-
...cli("feature up --service:*"),
|
|
354
355
|
...[
|
|
355
356
|
"status",
|
|
356
357
|
"feature status",
|
|
@@ -386,15 +387,20 @@ export const AUTONOMOUS_RULES = [
|
|
|
386
387
|
"k8s-forwards-status",
|
|
387
388
|
].flatMap(pluginTool),
|
|
388
389
|
];
|
|
389
|
-
/**
|
|
390
|
-
|
|
390
|
+
/**
|
|
391
|
+
* AUTONOMOUS_RULES plus the `werkmeister` and `docker` commands that name this feature or its containers.
|
|
392
|
+
* *repoServices*: the workspace's repos' other services (on-demand ones), which only `feature up --service` starts.
|
|
393
|
+
*/
|
|
394
|
+
export function autonomousRules(feature, services, repoServices = []) {
|
|
391
395
|
if (!feature)
|
|
392
396
|
return AUTONOMOUS_RULES;
|
|
393
397
|
return [
|
|
394
398
|
...AUTONOMOUS_RULES,
|
|
395
399
|
// Exact: `werkmeister feature restart <f> infra` and `docker restart <f>-a <other>` stay out.
|
|
396
400
|
...["up", "restart", "feature up", "feature restart"].flatMap((cmd) => cli(`${cmd} ${feature}`)),
|
|
397
|
-
|
|
401
|
+
// SW-132: one of its own services, the way the PR gate starts them. SW-843: exact, since a
|
|
402
|
+
// trailing `<other>` or `-w <path>` would start another workspace's container.
|
|
403
|
+
...[...services, ...repoServices].flatMap((svc) => [`feature up --service ${svc}`, `feature up ${feature} --service ${svc}`].flatMap(cli)),
|
|
398
404
|
...["logs", "test", "services", "feature logs", "feature test", "feature services"].flatMap((cmd) => cli(`${cmd} ${feature}:*`)),
|
|
399
405
|
// SW-560: no `docker exec <f>-<svc>:*`: any container reaches the host daemon over
|
|
400
406
|
// host.docker.internal, and some mount the docker socket; its exact registered test still runs.
|
|
@@ -428,7 +434,8 @@ hostServices = [], reposConfig = {}) {
|
|
|
428
434
|
const cmd = serviceTestCommand(svc, servicesConfig[svc], archetypes);
|
|
429
435
|
if (!cmd)
|
|
430
436
|
continue;
|
|
431
|
-
|
|
437
|
+
// SW-845: a container holding the docker socket or the real werkmeister home asks each run.
|
|
438
|
+
if (services.includes(svc) && !hostAccess(servicesConfig[svc])) {
|
|
432
439
|
rules.push(`Bash(${containerTestCommand(feature, svc, cmd)})`);
|
|
433
440
|
// Splitting a `{ …; }` group or `||` on `&&` gives rules no shell command matches.
|
|
434
441
|
if (isPlainChain(cmd))
|
|
@@ -457,6 +464,61 @@ hostServices = [], reposConfig = {}) {
|
|
|
457
464
|
.map((r) => `${wrapped}--no-wait ${r.slice(wrapped.length)}`));
|
|
458
465
|
return [...new Set([...rules, ...READ_ONLY_GIT_RULES])];
|
|
459
466
|
}
|
|
467
|
+
/**
|
|
468
|
+
* True when one of *entry*'s host binds is a docker socket (any path ending `docker.sock`, e.g. OrbStack's)
|
|
469
|
+
* or the werkmeister home, or a parent of either; symlinks resolved (`/var` → `/private/var` on macOS).
|
|
470
|
+
*/
|
|
471
|
+
function hostAccess(entry) {
|
|
472
|
+
const real = (p) => {
|
|
473
|
+
try {
|
|
474
|
+
return fs.realpathSync(p);
|
|
475
|
+
}
|
|
476
|
+
catch {
|
|
477
|
+
return path.resolve(p);
|
|
478
|
+
}
|
|
479
|
+
};
|
|
480
|
+
const targets = ["/var/run/docker.sock", sandboxHome()].map(real);
|
|
481
|
+
return (entry?.extra_volumes ?? []).some((spec) => {
|
|
482
|
+
const src = spec.split(":")[0];
|
|
483
|
+
if (!src.includes("/"))
|
|
484
|
+
return false; // a named volume
|
|
485
|
+
const host = real(expandUser(src));
|
|
486
|
+
if (path.basename(host) === "docker.sock")
|
|
487
|
+
return true;
|
|
488
|
+
return targets.some((t) => t === host || t.startsWith(`${host}${path.sep}`) || host === "/");
|
|
489
|
+
});
|
|
490
|
+
}
|
|
491
|
+
/**
|
|
492
|
+
* SW-845: *registry* with each entry's `extra_volumes` widened to every bind compose mounts: the
|
|
493
|
+
* branch's own fragment and the workspace's `dev_links` too (both agent-editable), variables
|
|
494
|
+
* substituted as generate.ts does. Only the mounts: test commands stay the registry's.
|
|
495
|
+
*/
|
|
496
|
+
function withComposeMounts(registry, workspaceRoot) {
|
|
497
|
+
const branch = workspaceServices(registry, workspaceRoot);
|
|
498
|
+
// generate.ts's loadDevLinks reads the same field; importing it closes a cycle (generate → claude_md → jira → here).
|
|
499
|
+
let devLinks = {};
|
|
500
|
+
try {
|
|
501
|
+
const yml = parseYaml(fs.readFileSync(path.join(dotDir(workspaceRoot), "workspace.yml"), "utf8"));
|
|
502
|
+
devLinks = yml?.["dev_links"] ?? {};
|
|
503
|
+
}
|
|
504
|
+
catch {
|
|
505
|
+
// No workspace.yml (or unreadable): no dev_links, as generate.ts reads it.
|
|
506
|
+
}
|
|
507
|
+
return Object.fromEntries(Object.entries(registry).map(([id, entry]) => {
|
|
508
|
+
const repo = path.join(workspaceRoot, String(branch[id]?.["repo"] ?? entry["repo"] ?? ""));
|
|
509
|
+
const specs = [
|
|
510
|
+
...(entry.extra_volumes ?? []),
|
|
511
|
+
...(branch[id]?.extra_volumes ?? []),
|
|
512
|
+
...(devLinks[id] ?? []),
|
|
513
|
+
].map((s) => {
|
|
514
|
+
const out = s.split("${WORKSPACE}").join(workspaceRoot).split("${REPO}").join(repo);
|
|
515
|
+
return out.includes("${WERKMEISTER_ROOT}")
|
|
516
|
+
? out.split("${WERKMEISTER_ROOT}").join(sandboxRoot())
|
|
517
|
+
: out;
|
|
518
|
+
});
|
|
519
|
+
return [id, { ...entry, extra_volumes: specs }];
|
|
520
|
+
}));
|
|
521
|
+
}
|
|
460
522
|
function _readEnv(workspaceRoot) {
|
|
461
523
|
let text;
|
|
462
524
|
try {
|
|
@@ -504,7 +566,7 @@ export function workspaceAllowRules(workspaceRoot, autonomous = readAutonomous(w
|
|
|
504
566
|
}
|
|
505
567
|
const extra = hostServices.filter((s) => !services.includes(s));
|
|
506
568
|
const any = services.length > 0 || extra.length > 0;
|
|
507
|
-
const rules = buildAllowRules(any ? feature : "", services, any ? loadServices() : {}, any ? loadArchetypes() : {}, wrapper, builtClis, extra, reposConfig);
|
|
569
|
+
const rules = buildAllowRules(any ? feature : "", services, any ? withComposeMounts(loadServices(), workspaceRoot) : {}, any ? loadArchetypes() : {}, wrapper, builtClis, extra, reposConfig);
|
|
508
570
|
rules.push(...readGrants(workspaceRoot).flatMap(cli));
|
|
509
571
|
if (!autonomous)
|
|
510
572
|
return rules;
|
|
@@ -513,7 +575,7 @@ export function workspaceAllowRules(workspaceRoot, autonomous = readAutonomous(w
|
|
|
513
575
|
// `yarnPath` would otherwise grant itself an install that runs its own file.
|
|
514
576
|
const reposRoot = getReposRoot();
|
|
515
577
|
const installs = repoNames.flatMap((name) => frozenInstalls((f) => fs.existsSync(path.join(reposRoot, name, f))).map((c) => `Bash(${c})`));
|
|
516
|
-
return [...new Set([...rules, ...autonomousRules(feature, services), ...installs])];
|
|
578
|
+
return [...new Set([...rules, ...autonomousRules(feature, services, extra), ...installs])];
|
|
517
579
|
}
|
|
518
580
|
function builtCliWrappers(workspaceRoot) {
|
|
519
581
|
return repoDirs(workspaceRoot)
|
|
@@ -524,19 +586,24 @@ function builtCliWrappers(workspaceRoot) {
|
|
|
524
586
|
* SW-473: `--exec-runs` runs the registry's rows on the host, so its forms of the pre-approved fixture
|
|
525
587
|
* wrapper and built CLI ask first. The CLI takes it only as the first fixture option, so a prefix catches it.
|
|
526
588
|
* SW-510: `node --test <file>` through the temp-HOME wrapper runs any file, one the agent just wrote too.
|
|
589
|
+
* SW-842: config.yaml `workspace_ask_rules: false` drops the node --test asks; the --exec-runs ones always stay.
|
|
527
590
|
*/
|
|
528
591
|
export function workspaceAskRules(workspaceRoot) {
|
|
529
592
|
const tempHome = tempHomeWrapper(workspaceRoot);
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
593
|
+
// Only the boolean turns them off: a typo or string keeps the asks. Every settings writer and migrate read them here.
|
|
594
|
+
const nodeTestOff = loadGlobalConfig()["workspace_ask_rules"] === false;
|
|
595
|
+
const nodeTest = nodeTestOff
|
|
596
|
+
? []
|
|
597
|
+
: [
|
|
598
|
+
`Bash(${tempHome} env WERKMEISTER_ROOT=* node --test*)`,
|
|
599
|
+
`Bash(${tempHome} --no-wait env WERKMEISTER_ROOT=* node --test*)`,
|
|
600
|
+
// SW-720: the probe form werkmeister-context.md names; an ask, so auto mode prompts instead of denying it.
|
|
601
|
+
`Bash(${tempHome} node --test*)`,
|
|
602
|
+
`Bash(${tempHome} --no-wait node --test*)`,
|
|
603
|
+
// The same form in the service's container, where a host without node_modules runs it.
|
|
604
|
+
`Bash(docker exec * ${tempHome} node --test*)`,
|
|
605
|
+
`Bash(docker exec * ${tempHome} --no-wait node --test*)`,
|
|
606
|
+
];
|
|
540
607
|
const builtClis = builtCliWrappers(workspaceRoot);
|
|
541
608
|
if (!builtClis.length)
|
|
542
609
|
return nodeTest;
|
package/dist/issues_report.d.ts
CHANGED
|
@@ -10,4 +10,4 @@
|
|
|
10
10
|
*/
|
|
11
11
|
import { type IssueTrackerStrategy } from "./issue_tracker.js";
|
|
12
12
|
export declare const WERKMEISTER_ISSUES_REPO = "jbbz-sandbox/werkmeister";
|
|
13
|
-
export declare function buildIssuesReportMd(workspaceName: string, issueId?: string, tracker?: IssueTrackerStrategy): string;
|
|
13
|
+
export declare function buildIssuesReportMd(workspaceName: string, issueId?: string, tracker?: IssueTrackerStrategy, questionTool?: string): string;
|
package/dist/issues_report.js
CHANGED
|
@@ -9,9 +9,10 @@
|
|
|
9
9
|
* `.werkmeister/issues-report.md`; each strategy's CLAUDE.md points at its copy.
|
|
10
10
|
*/
|
|
11
11
|
import { COMPOSE_FILE } from "./compose_file.js";
|
|
12
|
+
import { generatedFileCheck } from "./generated_file_check.js";
|
|
12
13
|
import { issueTracker } from "./issue_tracker.js";
|
|
13
14
|
export const WERKMEISTER_ISSUES_REPO = "jbbz-sandbox/werkmeister";
|
|
14
|
-
export function buildIssuesReportMd(workspaceName, issueId = "", tracker = issueTracker()) {
|
|
15
|
+
export function buildIssuesReportMd(workspaceName, issueId = "", tracker = issueTracker(), questionTool) {
|
|
15
16
|
const { row: appRow, search: searchStep, werkmeister, } = tracker.filingGuide(issueId.trim(), workspaceName);
|
|
16
17
|
const sandboxWhere = werkmeister ?? {
|
|
17
18
|
where: `https://github.com/${WERKMEISTER_ISSUES_REPO}/issues`,
|
|
@@ -45,6 +46,8 @@ Decide this first.
|
|
|
45
46
|
|
|
46
47
|
Not sure? Check whether it happens on the base branch. If you still can't tell, ask the person — don't guess.
|
|
47
48
|
|
|
49
|
+
${generatedFileCheck(questionTool)}
|
|
50
|
+
|
|
48
51
|
## Features and tasks
|
|
49
52
|
|
|
50
53
|
File one when the person asks for it, or when you find work outside this workspace's task. Work inside the task is done here, not filed.
|
package/dist/lifecycle.js
CHANGED
|
@@ -864,7 +864,8 @@ export function grantInBackground() {
|
|
|
864
864
|
async function grantWaitersNow() {
|
|
865
865
|
const started = [];
|
|
866
866
|
for (const feature of readQueue()) {
|
|
867
|
-
|
|
867
|
+
// A lease pruned by a process that can't see the folder must not cost the waiter its start (SW-848).
|
|
868
|
+
const workspace = readLeases()[feature]?.workspace || workspaceForFeature(feature);
|
|
868
869
|
if (!workspace) {
|
|
869
870
|
await dequeue(feature);
|
|
870
871
|
continue;
|
|
@@ -887,10 +888,17 @@ async function grantWaitersNow() {
|
|
|
887
888
|
}
|
|
888
889
|
catch (e) {
|
|
889
890
|
// One waiter's failed re-up (HOST_LOAD, NO_COMPOSE, ...) must not end the pass for the rest (SW-737).
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
891
|
+
const message = `Could not start '${feature}' from the waiting queue: ${e.message}`;
|
|
892
|
+
warn(message);
|
|
893
|
+
// Admission already dropped it (never fits, or a start that failed after admit): only its session can act (SW-682, SW-848).
|
|
894
|
+
if (!readQueue().includes(feature)) {
|
|
895
|
+
clearWaiting(workspace);
|
|
896
|
+
// A never-fits rerun would fail the same way; its message already says what to change.
|
|
897
|
+
const neverFits = e instanceof SandboxError && e.code === "NEVER_FITS";
|
|
898
|
+
writeNudge(workspace, neverFits
|
|
899
|
+
? message
|
|
900
|
+
: `${message}\nIt left the queue: run \`werkmeister feature up\` to queue it again.`);
|
|
901
|
+
}
|
|
894
902
|
continue;
|
|
895
903
|
}
|
|
896
904
|
// Backfill (SW-675): a later waiter may fit; admission itself holds the room for a starved head.
|
package/dist/migrate.js
CHANGED
|
@@ -320,13 +320,18 @@ function workspaceStale(dir) {
|
|
|
320
320
|
AGENT_STATE_EVENTS.some((e) => !agentState(e));
|
|
321
321
|
const wanted = workspaceAllowRules(dir);
|
|
322
322
|
// SW-521: a rule werkmeister recorded but no longer generates (`Bash(node:*)`) stays allowed until a refresh.
|
|
323
|
-
const
|
|
323
|
+
const record = readJson(path.join(dotDir(dir), "claude-permissions.json"));
|
|
324
|
+
const recorded = record?.["allow"] ?? [];
|
|
325
|
+
const askWanted = workspaceAskRules(dir);
|
|
326
|
+
// SW-842: an ask the machine opt-out no longer wants is stale too, so migrate removes it.
|
|
327
|
+
const recordedAsk = record?.["ask"] ?? [];
|
|
324
328
|
return (missingEvents ||
|
|
325
329
|
PRE_SW186_HOOK.test(fs.readFileSync(settingsFile, "utf8")) ||
|
|
326
330
|
wanted.some((r) => !allow.has(r)) ||
|
|
327
331
|
recorded.some((r) => !wanted.includes(r)) ||
|
|
328
332
|
workspaceDenyRules(dir).some((r) => !deny.has(r)) ||
|
|
329
|
-
|
|
333
|
+
askWanted.some((r) => !ask.has(r)) ||
|
|
334
|
+
recordedAsk.some((r) => !askWanted.includes(r)) ||
|
|
330
335
|
(fs.existsSync(wrapper) && fs.readFileSync(wrapper, "utf8").includes(PRE_SW186_WAIT)));
|
|
331
336
|
}
|
|
332
337
|
/**
|
package/dist/strategies/icm.js
CHANGED
|
@@ -340,7 +340,7 @@ function render(ctx) {
|
|
|
340
340
|
const base = vars(ctx, stages);
|
|
341
341
|
const files = {
|
|
342
342
|
"_shared/standards.md": renderStandards(r),
|
|
343
|
-
"_shared/issues-report.md": buildIssuesReportMd(ctx.workspaceName, issueIdOfMeta(ctx.meta), issueTracker({ project: ctx.inputs["project"], text: issueIdOfMeta(ctx.meta) })),
|
|
343
|
+
"_shared/issues-report.md": buildIssuesReportMd(ctx.workspaceName, issueIdOfMeta(ctx.meta), issueTracker({ project: ctx.inputs["project"], text: issueIdOfMeta(ctx.meta) }), base.questionTool),
|
|
344
344
|
};
|
|
345
345
|
files["_shared/pr-rules.md"] = buildPrRulesMd(`stages/${prDir(stages)}/output/`, base.autonomous);
|
|
346
346
|
stages.forEach((stage, i) => {
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
* restated.
|
|
8
8
|
*/
|
|
9
9
|
import { COMPOSE_FILE } from "../compose_file.js";
|
|
10
|
+
import { generatedFileCheck } from "../generated_file_check.js";
|
|
10
11
|
import { APPROVAL_NOTE, CHAT_APPROVAL, HOST_SCRIPT_RULE } from "../pr_rules.js";
|
|
11
12
|
// SW-135: a container that never started has no `pnpm` in /opt/werkmeister-tools until `werkmeister feature up`
|
|
12
13
|
// bootstraps it, so `docker restart` on it loops on "pnpm: not found".
|
|
@@ -33,11 +34,13 @@ const baseCheck = (doc) => `Before writing code, fetch the base and list \`git l
|
|
|
33
34
|
// SW-547: sw-526's over-width test lines surfaced only at the lint chain, after 7 commits.
|
|
34
35
|
const HOST_TESTS =
|
|
35
36
|
// SW-646: the command is the repo's `format:` (registry `repo:`), so no toolchain is named here.
|
|
36
|
-
"If `../../.werkmeister/werkmeister-context.md` gives the repo a format command (`Format:` under its repo commands), first run it on the files you touched (never a folder), so formatting lands in the ticket's own commit. " +
|
|
37
|
+
"If `../../.werkmeister/werkmeister-context.md` gives the repo a format command (`Format:` under its repo commands), first run it on the files you touched (never a folder), where the service's tests run (its container when its How-to-validate text says so), so formatting lands in the ticket's own commit. " +
|
|
37
38
|
"Run the test command exactly as `../../.werkmeister/werkmeister-context.md` states it: through `.werkmeister/bin/with-temp-home`, which gives it a fresh temporary HOME — never hand-roll `HOME=…`. " +
|
|
38
39
|
"That run is on the host, without the container's env (`HOST`, `WERKMEISTER_SLOT`, `NODE_ENV`, `<SVC>_URL`, …), and the PR gate runs the same commands in the workspace container. " +
|
|
39
40
|
// SW-506: werkmeister's host checkout has no node_modules; the recipe is its services.yaml text (SW-190), not this generic step.
|
|
40
|
-
"When a service's How-to-validate text in `werkmeister-context.md` says to run in its container (`docker exec`), follow that text instead: starting this workspace's own container with `werkmeister feature up --service <name>` is expected for it and allowed. "
|
|
41
|
+
"When a service's How-to-validate text in `werkmeister-context.md` says to run in its container (`docker exec`), follow that text instead: starting this workspace's own container with `werkmeister feature up --service <name>` is expected for it and allowed. " +
|
|
42
|
+
// SW-846: sw-829 ran only a one-file fast route in the container; the gate's lint row then failed on formatting.
|
|
43
|
+
"Before `werkmeister pr gate --tests`, run the repo's whole lint chain there too (every command the test command in `werkmeister-context.md` runs ahead of the service's own tests, when it has any; one `&&` segment alone is not it) and fix what it fails: a fast route that runs one test file skips it, and the gate's lint row then fails on it. ";
|
|
41
44
|
const TEST_TAIL = "A subagent you brief to run tests or the CLI gets that wrapped command verbatim in its brief. " +
|
|
42
45
|
// SW-125: a host-skipped test still asserted removed behaviour; only the gate's container run found it.
|
|
43
46
|
"A skipped test is not a pass: name each one with its skip reason, and run it where it can run (the workspace container) or say where it will (the gate, CI). " +
|
|
@@ -86,7 +89,7 @@ const groupStep = (v) => v.group.length
|
|
|
86
89
|
// SW-388: in sw-386 a must-fix passed the tests, the exercise and the gate; only a separate review caught it.
|
|
87
90
|
// SW-505: sw-469 wrote review.md as prose and lost a gate pass; the gate reads the `result` column of every table.
|
|
88
91
|
const REVIEW_FORMAT = "a `| criterion | result | evidence |` table whose result cell is exactly `PASS` or `FAIL` — nothing else in the cell — with the proof in the evidence column";
|
|
89
|
-
const reviewStep = (rerun, group) => "Review the diff: for each code worktree you touched, start a fresh subagent and brief it with only the worktree path and " +
|
|
92
|
+
const reviewStep = (rerun, { group, questionTool }) => "Review the diff: for each code worktree you touched, start a fresh subagent and brief it with only the worktree path and " +
|
|
90
93
|
`"run the \`ponytail:ponytail-review\` skill over this worktree's ${group.length
|
|
91
94
|
? "commits in `origin/main...HEAD` (the PR's base in place of `main` when it differs), plus any uncommitted changes and untracked files"
|
|
92
95
|
: "uncommitted changes, untracked files included"}" — not how you built it, so the review is not anchored on your reasoning. ` +
|
|
@@ -99,10 +102,11 @@ const reviewStep = (rerun, group) => "Review the diff: for each code worktree yo
|
|
|
99
102
|
// SW-449: a left Should fix shipped a false "every key is checked" in a changeset (sw-412).
|
|
100
103
|
"Fix every **Must fix** finding in place, and any **Should fix** finding that shows the change's own docs, comments, help text or release entry state something false (fix the code, or reword that text so it is true), " +
|
|
101
104
|
`${group.length ? `fold each fix into the commit of the ticket it belongs to (${FOLD}), ` : ""}then ${rerun}. Leave the other **Should fix** and **Nice to have** findings as they are. ` +
|
|
105
|
+
`${generatedFileCheck(questionTool)} ` +
|
|
102
106
|
"Write `output/review.md`: per worktree, the findings as the review grouped them, each marked `fixed` or `left: <why>`, then " +
|
|
103
107
|
`${REVIEW_FORMAT}, with one row per worktree (\`PASS\` means no Must fix left open). ` +
|
|
104
108
|
"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`.";
|
|
105
|
-
const implementReview = (v) => reviewStep("rerun the host test step above", v
|
|
109
|
+
const implementReview = (v) => reviewStep("rerun the host test step above", v);
|
|
106
110
|
// SW-687: sw-634 decided a blocklist for a pre-approved wrapper's input; one key it let through sent auth to any host.
|
|
107
111
|
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.";
|
|
108
112
|
// SW-789: sw-751 named the build chain as the critical path from task start/end times; the row held all 3 CPUs for ~170 s, so only a CPU cut shortens it.
|
|
@@ -404,7 +408,7 @@ const bugfix = [
|
|
|
404
408
|
// SW-579: the review step rewrites exercise.md, so recorded MANUAL results come first.
|
|
405
409
|
MANUAL_STEP,
|
|
406
410
|
// SW-678: these edits come after the fix stage's gate; one service's test command missed docs-site's (sw-631, sw-669).
|
|
407
|
-
reviewStep("rerun `werkmeister pr gate --tests` (from the workspace, as a background job with its log, as rule 3 of `_shared/pr-rules.md` shows), 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
|
|
411
|
+
reviewStep("rerun `werkmeister pr gate --tests` (from the workspace, as a background job with its log, as rule 3 of `_shared/pr-rules.md` shows), 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),
|
|
408
412
|
],
|
|
409
413
|
outputs: [
|
|
410
414
|
"`output/exercise.md`",
|
package/dist/strategies/jit.js
CHANGED
|
@@ -176,7 +176,7 @@ function init(ctx) {
|
|
|
176
176
|
// CLAUDE.md's "## Issues" section points here.
|
|
177
177
|
const issuesReportPath = path.join(dotDir(workspaceRoot), "issues-report.md");
|
|
178
178
|
fs.mkdirSync(path.dirname(issuesReportPath), { recursive: true });
|
|
179
|
-
fs.writeFileSync(issuesReportPath, buildIssuesReportMd(workspaceName, issueIdOfMeta(meta), issueTracker({ project: inputs["project"], text: issueIdOfMeta(meta) })));
|
|
179
|
+
fs.writeFileSync(issuesReportPath, buildIssuesReportMd(workspaceName, issueIdOfMeta(meta), issueTracker({ project: inputs["project"], text: issueIdOfMeta(meta) }), layout.questionTool));
|
|
180
180
|
success(`Wrote ${issuesReportPath}`);
|
|
181
181
|
const prRulesPath = path.join(dotDir(workspaceRoot), "pr-rules.md");
|
|
182
182
|
fs.writeFileSync(prRulesPath, buildPrRulesMd(".werkmeister/notes/"));
|
package/package.json
CHANGED