werkmeister-core 0.93.10 → 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 CHANGED
@@ -1,5 +1,11 @@
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
+
3
9
  ## 0.93.10
4
10
 
5
11
  ### 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";
@@ -117,6 +117,7 @@ export declare function workspaceAllowRules(workspaceRoot: string, autonomous?:
117
117
  * SW-473: `--exec-runs` runs the registry's rows on the host, so its forms of the pre-approved fixture
118
118
  * wrapper and built CLI ask first. The CLI takes it only as the first fixture option, so a prefix catches it.
119
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.
120
121
  */
121
122
  export declare function workspaceAskRules(workspaceRoot: string): string[];
122
123
  /** The deny rules this workspace should have: AUTONOMOUS_DENY while `autonomous` is on. */
@@ -47,6 +47,7 @@ import { parse as parseYaml } from "yaml";
47
47
  import { candidateServiceNames, containerTestCommand, isPlainChain, serviceTestCommand, wrappedTestCommand, } from "../../archetypes.js";
48
48
  import { dotDir, expandUser, getReposRoot, loadArchetypes, loadReposConfig, loadServices, sandboxHome, sandboxRoot, } from "../../config.js";
49
49
  import { frozenInstalls } from "../../fragment_detect/workspace.js";
50
+ import { load as loadGlobalConfig } from "../../global_config.js";
50
51
  import { workspaceServices } from "../../registry_sync.js";
51
52
  import { info } from "../../reporter.js";
52
53
  import { repoDirs } from "../../standards.js";
@@ -585,19 +586,24 @@ function builtCliWrappers(workspaceRoot) {
585
586
  * SW-473: `--exec-runs` runs the registry's rows on the host, so its forms of the pre-approved fixture
586
587
  * wrapper and built CLI ask first. The CLI takes it only as the first fixture option, so a prefix catches it.
587
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.
588
590
  */
589
591
  export function workspaceAskRules(workspaceRoot) {
590
592
  const tempHome = tempHomeWrapper(workspaceRoot);
591
- const nodeTest = [
592
- `Bash(${tempHome} env WERKMEISTER_ROOT=* node --test*)`,
593
- `Bash(${tempHome} --no-wait env WERKMEISTER_ROOT=* node --test*)`,
594
- // SW-720: the probe form werkmeister-context.md names; an ask, so auto mode prompts instead of denying it.
595
- `Bash(${tempHome} node --test*)`,
596
- `Bash(${tempHome} --no-wait node --test*)`,
597
- // The same form in the service's container, where a host without node_modules runs it.
598
- `Bash(docker exec * ${tempHome} node --test*)`,
599
- `Bash(docker exec * ${tempHome} --no-wait node --test*)`,
600
- ];
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
+ ];
601
607
  const builtClis = builtCliWrappers(workspaceRoot);
602
608
  if (!builtClis.length)
603
609
  return nodeTest;
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
- const workspace = readLeases()[feature]?.workspace;
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
- warn(`Could not start '${feature}' from the waiting queue: ${e.message}`);
891
- // Admission already dropped it from the queue; its session is the only one that can act (SW-682).
892
- if (e instanceof SandboxError && e.code === "NEVER_FITS")
893
- writeNudge(workspace, e.message);
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 recorded = readJson(path.join(dotDir(dir), "claude-permissions.json"))?.["allow"] ?? [];
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
- workspaceAskRules(dir).some((r) => !ask.has(r)) ||
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "werkmeister-core",
3
- "version": "0.93.10",
3
+ "version": "0.93.11",
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.",