werkmeister-core 0.92.1 → 0.93.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # sandbox-core
2
2
 
3
+ ## 0.93.0
4
+
5
+ ## 0.92.2
6
+
3
7
  ## 0.92.1
4
8
 
5
9
  ## 0.92.0
@@ -50,7 +50,7 @@ import { info } from "../../reporter.js";
50
50
  import { repoDirs } from "../../standards.js";
51
51
  import { tempHomeWrapper } from "../../temp_home.js";
52
52
  // biome-ignore lint/suspicious/noImportCycles: jira→harness→…→issue_tracker (SW-188); SW-411
53
- import { readAutonomous, readAutoStop, readModel } from "../../workspace_prompts.js";
53
+ import { readAutonomous, readAutoStop, readGrants, readModel } from "../../workspace_prompts.js";
54
54
  import { AUTONOMOUS_DENY, cli, pluginTool } from "../autonomous_deny.js";
55
55
  import { CODEX_HOOKS_FILE, CODEX_LAUNCH, writeCodexConfig } from "../codex/index.js";
56
56
  // biome-ignore lint/suspicious/noImportCycles: jira→harness→…→issue_tracker (SW-188); SW-411
@@ -505,6 +505,7 @@ export function workspaceAllowRules(workspaceRoot, autonomous = readAutonomous(w
505
505
  const extra = hostServices.filter((s) => !services.includes(s));
506
506
  const any = services.length > 0 || extra.length > 0;
507
507
  const rules = buildAllowRules(any ? feature : "", services, any ? loadServices() : {}, any ? loadArchetypes() : {}, wrapper, builtClis, extra, reposConfig);
508
+ rules.push(...readGrants(workspaceRoot).flatMap(cli));
508
509
  if (!autonomous)
509
510
  return rules;
510
511
  // Exact: `--prefix`, `--dir`/`-C` reach another workspace, `--script-shell` runs any file.
@@ -527,8 +528,8 @@ function builtCliWrappers(workspaceRoot) {
527
528
  export function workspaceAskRules(workspaceRoot) {
528
529
  const tempHome = tempHomeWrapper(workspaceRoot);
529
530
  const nodeTest = [
530
- `Bash(${tempHome} env WERKMEISTER_ROOT=* node --test:*)`,
531
- `Bash(${tempHome} --no-wait env WERKMEISTER_ROOT=* node --test:*)`,
531
+ `Bash(${tempHome} env WERKMEISTER_ROOT=* node --test*)`,
532
+ `Bash(${tempHome} --no-wait env WERKMEISTER_ROOT=* node --test*)`,
532
533
  // SW-720: the probe form werkmeister-context.md names; an ask, so auto mode prompts instead of denying it.
533
534
  `Bash(${tempHome} node --test*)`,
534
535
  `Bash(${tempHome} --no-wait node --test*)`,
@@ -980,6 +980,16 @@ testsOnly = false) {
980
980
  earlier.detail = `started on the second attempt (first: ${earlier.detail})`;
981
981
  }
982
982
  };
983
+ // Running containers come from compose.yml, rendered from the machine registry; a
984
+ // touched service whose branch settings render differently runs from compose.gate.yml (SW-118).
985
+ let changed = [];
986
+ if (own)
987
+ try {
988
+ changed = deps.gateCompose(ws, feature, services).filter((s) => touched.includes(s));
989
+ }
990
+ catch (e) {
991
+ add("containers", false, `branch compose: ${e instanceof Error ? e.message : String(e)}`);
992
+ }
983
993
  const withCommand = touched.filter((s) => !reason(skips[s]) && serviceTestCommand(s, services[s], deps.archetypes));
984
994
  const covers = coveredRows(Object.fromEntries(withCommand.map((s) => [
985
995
  s,
@@ -988,9 +998,11 @@ testsOnly = false) {
988
998
  coveredBy: services[s]?.["test_covered_by"],
989
999
  },
990
1000
  ])));
991
- // A local api/web service's baseline row needs its own container, so covering it would save no start.
1001
+ // A local api/web service's baseline needs its own container, and a changed one starts from compose.gate.yml
1002
+ // anyway: covering either saves no start, and the changed one's branch settings would go untested (SW-808).
992
1003
  for (const s of Object.keys(covers))
993
- if (local.has(s) && ["api", "web"].includes(services[s]?.["type"] ?? ""))
1004
+ if (changed.includes(s) ||
1005
+ (local.has(s) && ["api", "web"].includes(services[s]?.["type"] ?? "")))
994
1006
  delete covers[s];
995
1007
  // Out of the release pick and the starts too, so a covered service's container never starts (SW-574).
996
1008
  const tested = withCommand.filter((s) => !covers[s]);
@@ -1035,16 +1047,6 @@ testsOnly = false) {
1035
1047
  });
1036
1048
  return done();
1037
1049
  }
1038
- // Running containers come from compose.yml, rendered from the machine registry; a
1039
- // touched service whose branch settings render differently runs from compose.gate.yml (SW-118).
1040
- let changed = [];
1041
- if (own)
1042
- try {
1043
- changed = deps.gateCompose(ws, feature, services).filter((s) => touched.includes(s));
1044
- }
1045
- catch (e) {
1046
- add("containers", false, `branch compose: ${e instanceof Error ? e.message : String(e)}`);
1047
- }
1048
1050
  let release;
1049
1051
  const runRelease = async (container) => {
1050
1052
  const res = await execCheck("release", container, String(repo["release_check"]), 5);
@@ -177,6 +177,10 @@ function renderContract(dir, stage, v, step0 = "") {
177
177
  "## Outputs",
178
178
  ...c.outputs.map((o) => `- ${o}`),
179
179
  "",
180
+ "## Pre-approved",
181
+ ...(stage.grants ?? []).map((g) => g.endsWith(":*") ? `- \`werkmeister ${g.slice(0, -2)} …\`` : `- \`werkmeister ${g}\``),
182
+ "- Every other command asks. Read and edit files with Read, Edit and Write, never a `python3` heredoc or `python3 -c`, which no run pre-approves (SW-807).",
183
+ "",
180
184
  ...(v.autonomous
181
185
  ? ["## Self-check", c.selfCheck ?? SELF_CHECK]
182
186
  : ["## Human check", c.humanCheck, "", askLine(v.questionTool)]),
@@ -46,6 +46,8 @@ export interface Stage {
46
46
  gate?: string;
47
47
  /** Which _shared/standards.md rows the contract names. */
48
48
  standards: "none" | "all";
49
+ /** SW-807: `werkmeister` subcommands this stage runs, pre-approved for the whole run; init reads them from here, never from the rendered CONTEXT.md, which the agent can edit. */
50
+ grants?: string[];
49
51
  contract(v: IcmVars): Contract;
50
52
  }
51
53
  export declare const askLine: (tool?: string) => string;
@@ -58,3 +60,5 @@ export declare function stageDirs(stages: Stage[]): string[];
58
60
  export declare function proposeDir(stages: Stage[]): string | null;
59
61
  /** The stage dir whose output holds PR files: propose, else the last stage (spike, SW-83). */
60
62
  export declare function prDir(stages: Stage[]): string;
63
+ /** Every stage's grants for *workType*, once each: granted for the whole run (SW-807). */
64
+ export declare function stageGrants(workType: string): string[];
@@ -128,6 +128,9 @@ const exerciseFormat = (col) => `a \`| check | result | ${col} |\` table whose r
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
  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.";
130
130
  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
+ // SW-807: exact, this workspace's own issue only. The feature, gate and status commands keep asking:
132
+ // each can reach shared infra, another workspace or the real ~/.werkmeister from agent-editable input.
133
+ const START_GRANTS = ["issue start", "issue view"];
131
134
  const propose = {
132
135
  name: "propose",
133
136
  job: "acceptance walk and PR files",
@@ -180,6 +183,7 @@ const noCommitPlan = (group) => group.length
180
183
  const feature = [
181
184
  {
182
185
  name: "research",
186
+ grants: START_GRANTS,
183
187
  job: "inventory the code, surface decisions",
184
188
  writes: "`output/inventory.md`, `output/decisions.md`",
185
189
  check: "answer every open question in `decisions.md`",
@@ -293,6 +297,7 @@ const feature = [
293
297
  const bugfix = [
294
298
  {
295
299
  name: "reproduce",
300
+ grants: START_GRANTS,
296
301
  job: "reproduce and locate the root cause",
297
302
  writes: "`output/repro.md`",
298
303
  check: "agree the root cause",
@@ -398,6 +403,7 @@ const bugfix = [
398
403
  const refactor = [
399
404
  {
400
405
  name: "scope",
406
+ grants: START_GRANTS,
401
407
  job: "fix the boundary and the invariants",
402
408
  writes: "`output/scope.md`",
403
409
  check: "agree what must not change",
@@ -465,6 +471,7 @@ const refactor = [
465
471
  const spike = [
466
472
  {
467
473
  name: "questions",
474
+ grants: START_GRANTS,
468
475
  job: "frame what the spike must answer",
469
476
  writes: "`output/questions.md`",
470
477
  check: "agree the questions and what settles them",
@@ -536,3 +543,7 @@ export function proposeDir(stages) {
536
543
  export function prDir(stages) {
537
544
  return proposeDir(stages) ?? stageDirs(stages)[stages.length - 1];
538
545
  }
546
+ /** Every stage's grants for *workType*, once each: granted for the whole run (SW-807). */
547
+ export function stageGrants(workType) {
548
+ return [...new Set(templateFor(workType).flatMap((s) => s.grants ?? []))];
549
+ }
@@ -28,6 +28,8 @@ export declare function isTrue(value: unknown): boolean;
28
28
  * through `loadConfigFile`, which logs — the same reason as `readContextStrategy`.
29
29
  */
30
30
  export declare function readAutonomous(workspaceRoot: string): boolean;
31
+ /** SW-807: an ICM workspace's stage grants, for the whole run and either mode; none for another strategy. */
32
+ export declare function readGrants(workspaceRoot: string): string[];
31
33
  /** The workspace's `auto_stop` input (#231); unset follows `autonomous` (SW-39). */
32
34
  export declare function readAutoStop(workspaceRoot: string): boolean;
33
35
  /**
@@ -25,6 +25,7 @@ import { resolveModel } from "./model_tiers.js";
25
25
  import { ProcError, run as procRun } from "./proc.js";
26
26
  import { loadProjects } from "./projects.js";
27
27
  import { info, warn } from "./reporter.js";
28
+ import { stageGrants } from "./strategies/icm_templates.js";
28
29
  import { STRATEGY_IDS } from "./strategies/types.js";
29
30
  function isDir(p) {
30
31
  try {
@@ -136,6 +137,12 @@ export function isTrue(value) {
136
137
  export function readAutonomous(workspaceRoot) {
137
138
  return isTrue(readWorkspaceField(workspaceRoot, "autonomous"));
138
139
  }
140
+ /** SW-807: an ICM workspace's stage grants, for the whole run and either mode; none for another strategy. */
141
+ export function readGrants(workspaceRoot) {
142
+ if (String(readWorkspaceField(workspaceRoot, "context_strategy") ?? "").trim() !== "icm")
143
+ return [];
144
+ return stageGrants(String(readWorkspaceField(workspaceRoot, "work_type") ?? ""));
145
+ }
139
146
  /** The workspace's `auto_stop` input (#231); unset follows `autonomous` (SW-39). */
140
147
  export function readAutoStop(workspaceRoot) {
141
148
  const value = readWorkspaceField(workspaceRoot, "auto_stop");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "werkmeister-core",
3
- "version": "0.92.1",
3
+ "version": "0.93.0",
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.",