@amsterdamdatalabs/adl-agent-control-darwin-arm64 0.1.65 → 0.1.68

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/bin/adl CHANGED
@@ -1,4 +1,4 @@
1
1
  [diffend] Oversized file quarantined before diffing.
2
2
  name: package/bin/adl
3
3
  size: 63720304 bytes
4
- sha256: e6b9fa4a2ee88006c2b0a2c6fae20159f82e3ab78c3f9840b4c9018c00ba3551
4
+ sha256: 81064361d791d1f29a18197e54fa65bf96c82cbdbd56600c2501e824d9047816
package/bin/job-watchdog CHANGED
@@ -39,6 +39,7 @@ fix_mode() {
39
39
  fix_mode "$log_dir" 755
40
40
  fix_mode "$log_dir/stdout.log" 644
41
41
  fix_mode "$log_dir/stderr.log" 644
42
+ fix_mode "$log_dir/pool-reaper.log" 644
42
43
 
43
44
  os="$(uname -s)"
44
45
  cause=""
@@ -54,6 +55,21 @@ if [ "$os" = Linux ] && [ -f "$systemd_dir/$pool_unit" ]; then
54
55
  fi
55
56
  fi
56
57
 
58
+ # services.pool_reaper (mac): report-only check of the Hetzner dead-man switch; see docs/operations/agent-pool.md.
59
+ reaper_label=com.adl.pool-reaper
60
+ if [ "$os" = Darwin ] && [ -f "$root/Library/LaunchDaemons/$reaper_label.plist" ]; then
61
+ if reaper_printed="$(launchctl print "system/$reaper_label" 2>&1)"; then
62
+ reaper_exit="$(printf '%s\n' "$reaper_printed" | sed -n 's/^[[:space:]]*last exit code = \([0-9][0-9]*\).*/\1/p' | head -n 1)"
63
+ if [ -n "$reaper_exit" ] && [ "$reaper_exit" != 0 ]; then
64
+ log "WARN watchdog: $reaper_label last run failed (exit $reaper_exit); the Hetzner dead-man switch may not be reaping: see /var/log/adl/pool-reaper.log"
65
+ else
66
+ log "INFO watchdog: $reaper_label is loaded"
67
+ fi
68
+ else
69
+ log "WARN watchdog: $reaper_label is not loaded; the Hetzner dead-man switch is off; run: sudo adl fleet setup NAME --rearm"
70
+ fi
71
+ fi
72
+
57
73
  case "$os" in
58
74
  Darwin)
59
75
  [ -f "$plist" ] || fail "$plist is missing; run: sudo adl fleet setup NAME --rearm"
package/bin/setup CHANGED
@@ -204,8 +204,8 @@ install_watchdog_script() {
204
204
  # before launchd has finished unloading, and a bootstrap in that window fails
205
205
  # with an I/O error, so wait until the label is really gone, bounded, and fail
206
206
  # loud if it is not.
207
- launchd_rearm() {
208
- local label="$1" job_plist="$2" unloaded
207
+ launchd_unload() {
208
+ local label="$1" unloaded
209
209
  if launchctl print "system/$label" >/dev/null 2>&1; then
210
210
  launchctl bootout "system/$label"
211
211
  unloaded=0
@@ -214,11 +214,15 @@ launchd_rearm() {
214
214
  sleep 0.5
215
215
  done
216
216
  [[ "$unloaded" -eq 1 ]] || {
217
- echo "ERROR adl fleet setup: $label is still loaded after bootout (waited 5s); not bootstrapping. Run: sudo launchctl bootout system/$label" >&2
217
+ echo "ERROR adl fleet setup: $label is still loaded after bootout (waited 5s); not continuing. Run: sudo launchctl bootout system/$label" >&2
218
218
  exit 1
219
219
  }
220
220
  fi
221
- launchctl bootstrap system "$job_plist"
221
+ }
222
+
223
+ launchd_rearm() {
224
+ launchd_unload "$1"
225
+ launchctl bootstrap system "$2"
222
226
  }
223
227
 
224
228
  install_watchdog_script
@@ -274,6 +278,68 @@ case "$fleet_host_platform" in
274
278
  chmod 0644 "$watchdog_plist"
275
279
  plutil -lint "$watchdog_plist"
276
280
  launchd_rearm com.adl.global-tools-watchdog "$watchdog_plist"
281
+
282
+ # services.pool_reaper => com.adl.pool-reaper runs `adl pool reap --host POOL_HOST`
283
+ # every interval_minutes: the dead-man switch for Hetzner spend. The poller on the
284
+ # pool host is the only thing that deletes servers; if that host or poller dies, a
285
+ # created server bills until this job deletes it. It runs as the device administrator,
286
+ # not root: the agent identity (adl-agent-id passport) belongs to that account, the
287
+ # way reconcile runs git and adl as the owner. launchd gives a daemon only
288
+ # /usr/bin:/bin:/usr/sbin:/sbin, and the reap must find adl and adl-agent-id, so the
289
+ # job carries PATH (the owner's, bin/lib/adl-package.sh) and nothing else. A host whose
290
+ # block is gone has the job booted out and its plist deleted.
291
+ reaper_label=com.adl.pool-reaper
292
+ reaper_plist="$launch_daemons_dir/$reaper_label.plist"
293
+ reaper_json="$(jq -c --arg host "$host" '.mac.devices[$host].services.pool_reaper // empty' "$package_dir/packages/fleet/manifest.json")" || {
294
+ echo "ERROR adl fleet setup: cannot read services.pool_reaper from $package_dir/packages/fleet/manifest.json" >&2
295
+ exit 1
296
+ }
297
+ if [[ -n "$reaper_json" ]]; then
298
+ reaper_pool_host="$(jq -r '.pool_host' <<<"$reaper_json")"
299
+ reaper_minutes="$(jq -r '.interval_minutes' <<<"$reaper_json")"
300
+ [[ "$reaper_pool_host" =~ ^[A-Za-z0-9][A-Za-z0-9._-]*$ ]] || {
301
+ echo "ERROR adl fleet setup: services.pool_reaper.pool_host is not a host name: $reaper_pool_host" >&2
302
+ exit 1
303
+ }
304
+ [[ "$reaper_minutes" =~ ^[1-9][0-9]*$ ]] || {
305
+ echo "ERROR adl fleet setup: services.pool_reaper.interval_minutes is not a positive integer: $reaper_minutes" >&2
306
+ exit 1
307
+ }
308
+ reaper_path="$(adl_owner_path "$os_name" "$owner_home")" || exit 1
309
+ # launchd opens StandardOutPath as UserName: the root-owned fleet logs would fail the spawn (EX_CONFIG).
310
+ reaper_log="$system_root/var/log/adl/pool-reaper.log"
311
+ touch "$reaper_log"
312
+ chown "$owner:$log_group" "$reaper_log"
313
+ chmod 0644 "$reaper_log"
314
+ {
315
+ printf '%s\n' '<?xml version="1.0" encoding="UTF-8"?>'
316
+ printf '%s\n' '<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">'
317
+ printf '%s\n' '<plist version="1.0"><dict>'
318
+ printf '<key>Label</key><string>%s</string>\n' "$reaper_label"
319
+ printf '%s\n' '<key>ProgramArguments</key><array>'
320
+ printf '<string>%s</string>\n' "$adl_bin"
321
+ printf '%s\n' '<string>pool</string>'
322
+ printf '%s\n' '<string>reap</string>'
323
+ printf '<string>--host</string><string>%s</string>\n' "$reaper_pool_host"
324
+ printf '%s\n' '</array>'
325
+ printf '<key>UserName</key><string>%s</string>\n' "$owner"
326
+ printf '<key>EnvironmentVariables</key><dict><key>PATH</key><string>%s</string></dict>\n' "$reaper_path"
327
+ printf '<key>StartInterval</key><integer>%s</integer>\n' "$((reaper_minutes * 60))"
328
+ printf '%s\n' '<key>RunAtLoad</key><true/>'
329
+ printf '%s\n' '<key>ProcessType</key><string>Background</string>'
330
+ printf '%s\n' '<key>StandardOutPath</key><string>/var/log/adl/pool-reaper.log</string>'
331
+ printf '%s\n' '<key>StandardErrorPath</key><string>/var/log/adl/pool-reaper.log</string>'
332
+ printf '%s\n' '</dict></plist>'
333
+ } >"$reaper_plist"
334
+ chown root:wheel "$reaper_plist"
335
+ chmod 0644 "$reaper_plist"
336
+ plutil -lint "$reaper_plist"
337
+ launchd_rearm "$reaper_label" "$reaper_plist"
338
+ elif [[ -e "$reaper_plist" ]]; then
339
+ launchd_unload "$reaper_label"
340
+ rm -f -- "$reaper_plist"
341
+ echo "adl fleet setup: removed $reaper_label: $host no longer declares services.pool_reaper"
342
+ fi
277
343
  ;;
278
344
  linux)
279
345
  mkdir -p "$systemd_dir"
@@ -21,19 +21,25 @@ if ! jq -e '
21
21
  def nonneg: type == "number" and . >= 0 and floor == .;
22
22
  def nes: type == "string" and length > 0;
23
23
  def agent_pool: type == "object" and
24
- (keys | sort) == ["agents_per_server", "capabilities", "hour_end_window_minutes", "identity", "location", "max_lifetime_minutes", "max_servers", "org", "poll_seconds", "project", "queue_id", "queue_threshold", "register_timeout_minutes", "server_type", "snapshot_label_selector", "sp_client_id", "sp_tenant_id", "trigger_ticks", "vault_env_file"] and
24
+ (keys | sort) == ["agents_per_server", "capabilities", "hour_end_window_minutes", "identity", "location", "max_lifetime_minutes", "max_servers", "org", "poll_seconds", "project", "queue_id", "queue_threshold", "register_timeout_minutes", "server_type", "snapshot_label_selector", "sp_client_id", "sp_tenant_id", "trigger_ticks"] and
25
25
  (.org | nes) and (.project | nes) and (.queue_id | posint) and
26
26
  (.identity | . == "agent-tarun" or . == "agent-vivek" or . == "agent-reviewer") and
27
27
  (.server_type | nes) and (.location | nes) and (.snapshot_label_selector | nes) and
28
28
  (.agents_per_server | posint) and (.max_servers | posint) and (.max_lifetime_minutes | posint) and
29
29
  (.register_timeout_minutes | posint) and (.poll_seconds | posint) and (.queue_threshold | nonneg) and
30
30
  (.trigger_ticks | posint) and (.hour_end_window_minutes | nonneg and . <= 59) and
31
- (.vault_env_file | type == "string" and test("^/[A-Za-z0-9._/-]+$") and (split("/") | index("..") | not)) and
32
31
  (.capabilities | type == "object" and all(.[]; type == "string")) and
33
32
  (.sp_client_id | type == "string" and (. == "UNSET" or test("^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$"))) and
34
33
  (.sp_tenant_id | type == "string" and test("^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$"));
35
34
  def agent_pool_services: type == "object" and (keys - ["agent_pool"] | length) == 0 and
36
35
  ((has("agent_pool") | not) or (.agent_pool | agent_pool));
36
+ # services.pool_reaper (mac devices): the backup reaper of the linux pool host. pool_host must be a linux device
37
+ # that declares agent_pool; $m is the whole manifest, so the reference is checked here, not in the schema.
38
+ def pool_reaper($m): type == "object" and (keys | sort) == ["interval_minutes", "pool_host"] and
39
+ (.interval_minutes | posint) and (.pool_host | nes) and
40
+ (($m.linux.devices[.pool_host].services.agent_pool // null) != null);
41
+ def pool_reaper_services($m): type == "object" and (keys - ["pool_reaper"] | length) == 0 and
42
+ ((has("pool_reaper") | not) or (.pool_reaper | pool_reaper($m)));
37
43
  keys == ["config", "linux", "mac"] and
38
44
  .config.schema == 1 and
39
45
  (.config.repository | type == "string" and test("^https://dev\\.azure\\.com/[A-Za-z0-9._-]+/[A-Za-z0-9._-]+/_git/[A-Za-z0-9._-]+$")) and
@@ -68,7 +74,8 @@ if ! jq -e '
68
74
  (.mac.devices | type == "object") and
69
75
  (.linux.common.tools | type == "object") and
70
76
  (.linux.devices | type == "object") and
71
- ([.mac.devices[] | has("services")] | any | not) and
77
+ (. as $m | [.mac.devices[] | (.services // {}) | pool_reaper_services($m)] | all) and
78
+ ([.linux.devices[] | (.services // {}) | agent_pool_services] | all) and
72
79
  ([.mac.devices[], .linux.devices[]] |
73
80
  all(.minimum_free_gib >= 1) and
74
81
  all((.home | type) == "string" and (.home | startswith("/"))) and
@@ -92,9 +99,8 @@ if ! jq -e '
92
99
  all((.repo_location // "/ok") | type == "string" and startswith("/") and . != "/" and
93
100
  (endswith("/") | not) and (contains("..") | not) and (test("\\s") | not) and
94
101
  (ascii_downcase | contains("azagent") | not) and (ascii_downcase | contains("vsts.agent") | not)) and
95
- # services (Feature 758): long-running systemd units, Linux devices only. agent_pool maps 1:1 onto
96
- # PoolConfig (packages/agent-pool/src/types.ts); every field is required, none is defaulted.
97
- all((.services // {}) | agent_pool_services) and
102
+ # services: checked per platform above (agent_pool, Feature 758: Linux systemd unit, maps 1:1 onto
103
+ # PoolConfig in packages/agent-pool/src/types.ts, every field required; pool_reaper: mac launchd job).
98
104
  all((.brew_upgrade_all // false) | type == "boolean") and
99
105
  all(
100
106
  (.surface_clis // []) as $surfaces |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@amsterdamdatalabs/adl-agent-control-darwin-arm64",
3
- "version": "0.1.65",
3
+ "version": "0.1.68",
4
4
  "description": "adl CLI binary for darwin/arm64 (agent identity + Azure DevOps front door — see docs/architecture/cli-design.md)",
5
5
  "license": "UNLICENSED",
6
6
  "os": [
@@ -95,6 +95,9 @@
95
95
  "repo_location": "/Users/tarunrana/workspace",
96
96
  "brew_upgrade_all": true,
97
97
  "brew_accept_eula": ["msodbcsql18", "mssql-tools18"],
98
+ "services": {
99
+ "pool_reaper": {"pool_host": "strato-vps-1", "interval_minutes": 10}
100
+ },
98
101
  "surface_clis": [
99
102
  {"name": "claude", "manager": "native", "command": "claude", "update_args": ["update"]},
100
103
  {"name": "codex", "manager": "brew", "command": "brew", "update_args": ["upgrade", "--cask", "codex"]},
@@ -226,7 +229,6 @@
226
229
  "queue_threshold": 1,
227
230
  "trigger_ticks": 3,
228
231
  "hour_end_window_minutes": 10,
229
- "vault_env_file": "/etc/adl/agent-pool-vault.env",
230
232
  "capabilities": {"Agent.OS": "Linux", "docker": "present"},
231
233
  "sp_client_id": "f34d1cd9-4fa1-47bb-9e82-ad9f5cb78a11",
232
234
  "sp_tenant_id": "49d4be4b-06f2-42b7-91bc-a17ccde6f0ce"
@@ -293,14 +293,14 @@
293
293
  },
294
294
  "services": {
295
295
  "type": "object",
296
- "description": "Long-running systemd services this device runs (Linux only; `adl fleet setup` renders and enables one unit per entry and removes a unit whose entry is gone). Declared here, never passed as environment variables.",
296
+ "description": "Services this device runs; `adl fleet setup` renders one job per entry and removes a job whose entry is gone. `agent_pool` is a long-running systemd unit (Linux devices only); `pool_reaper` is a launchd interval job (mac devices only), enforced by bin/validate-manifest. Declared here, never passed as environment variables.",
297
297
  "additionalProperties": false,
298
298
  "properties": {
299
299
  "agent_pool": {
300
300
  "type": "object",
301
- "description": "Feature 758: `adl pool run --host NAME`, the elastic Hetzner Azure Pipelines agent poller. Maps 1:1 onto PoolConfig (packages/agent-pool/src/types.ts) in snake_case, plus `project` (the Azure DevOps project of the queue), `vault_env_file` (root-only Agent Vault env file), `sp_client_id` and `sp_tenant_id` (the service principal agents register with).",
301
+ "description": "Feature 758: `adl pool run --host NAME`, the elastic Hetzner Azure Pipelines agent poller. Maps 1:1 onto PoolConfig (packages/agent-pool/src/types.ts) in snake_case, plus `project` (the Azure DevOps project of the queue), `sp_client_id` and `sp_tenant_id` (the service principal agents register with).",
302
302
  "additionalProperties": false,
303
- "required": ["org", "project", "queue_id", "identity", "server_type", "location", "snapshot_label_selector", "agents_per_server", "max_servers", "max_lifetime_minutes", "register_timeout_minutes", "poll_seconds", "queue_threshold", "trigger_ticks", "hour_end_window_minutes", "vault_env_file", "capabilities", "sp_client_id", "sp_tenant_id"],
303
+ "required": ["org", "project", "queue_id", "identity", "server_type", "location", "snapshot_label_selector", "agents_per_server", "max_servers", "max_lifetime_minutes", "register_timeout_minutes", "poll_seconds", "queue_threshold", "trigger_ticks", "hour_end_window_minutes", "capabilities", "sp_client_id", "sp_tenant_id"],
304
304
  "properties": {
305
305
  "org": {"type": "string", "minLength": 1},
306
306
  "project": {"type": "string", "minLength": 1},
@@ -317,11 +317,20 @@
317
317
  "queue_threshold": {"type": "integer", "minimum": 0},
318
318
  "trigger_ticks": {"type": "integer", "minimum": 1},
319
319
  "hour_end_window_minutes": {"type": "integer", "minimum": 0, "maximum": 59},
320
- "vault_env_file": {"description": "Absolute path of the root-only (0600) agent-mode Agent Vault env file on the poller host (AGENT_VAULT_ADDR/TOKEN/VAULT, same format as /etc/enact/agent-vault.env); vault-curl.ts refuses it when missing, not 0600 or not root-owned.", "type": "string", "pattern": "^/[A-Za-z0-9._/-]+$"},
321
320
  "capabilities": {"type": "object", "additionalProperties": {"type": "string"}},
322
321
  "sp_client_id": {"description": "Application (client) id of the identity's Entra service principal, used by `config.sh --auth SP`; the literal UNSET until Tarun fills it (`pool run` refuses while UNSET).", "type": "string", "pattern": "^(UNSET|[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$"},
323
322
  "sp_tenant_id": {"description": "Entra tenant id of that service principal (AGENT_TENANTS in apps/cli/src/ado-token.ts).", "type": "string", "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$"}
324
323
  }
324
+ },
325
+ "pool_reaper": {
326
+ "type": "object",
327
+ "description": "Dead-man switch for Hetzner spend: a launchd job (`com.adl.pool-reaper`, run as the device administrator) that runs `adl pool reap --host POOL_HOST` every `interval_minutes`. `adl pool reap` deletes only expired, unregistered or broken pool servers and orphan agents, so a dead poller cannot leave a server billing. `pool_host` must name a linux device that declares `services.agent_pool` (checked by bin/validate-manifest).",
328
+ "additionalProperties": false,
329
+ "required": ["pool_host", "interval_minutes"],
330
+ "properties": {
331
+ "pool_host": {"type": "string", "minLength": 1},
332
+ "interval_minutes": {"type": "integer", "minimum": 1}
333
+ }
325
334
  }
326
335
  }
327
336
  },
@@ -461,6 +461,9 @@ Three pipelines (CI on PRs into `integration`, Promote on `integration`, CD on
461
461
  push is rejected and the script fails loud; the next merge's run bumps. The
462
462
  old `--pr-source` mode is gone: it is an unknown argument.
463
463
 
464
+ The bump script uses Bun for manifest handling. Promotion descriptions identify
465
+ the build and source commit without asserting that development was deployed.
466
+
464
467
  ### `release.pre_bump` — multi-language version bumps
465
468
 
466
469
  `version-bump.sh` only knows how to write to one JSON file's `version` field
@@ -248,7 +248,7 @@ export async function ensurePromotionPullRequest({
248
248
  sourceRefName: sourceRef,
249
249
  targetRefName: targetRef,
250
250
  title: promotionTitle(sourceBranch, targetBranch),
251
- description: `Development deployment succeeded in build ${pipelineBuildId}.\n\n${sourceBranch} commit: ${commit}`,
251
+ description: `Promotion build: ${pipelineBuildId}.\n\n${sourceBranch} commit: ${commit}`,
252
252
  }),
253
253
  },
254
254
  )
@@ -47,7 +47,7 @@ repo_root="$(git rev-parse --show-toplevel)" || die 'cannot resolve the reposito
47
47
  [[ -f "$version_file" ]] || die "manifest not found: $version_file"
48
48
 
49
49
  read_version() {
50
- node -e 'const version = JSON.parse(require("node:fs").readFileSync(0, "utf8")).version; if (typeof version !== "string") process.exit(1); process.stdout.write(version)'
50
+ bun -e 'const version = JSON.parse(require("node:fs").readFileSync(0, "utf8")).version; if (typeof version !== "string") process.exit(1); process.stdout.write(version)'
51
51
  }
52
52
 
53
53
  current_version="$(read_version < "$version_file")" || die "cannot read a string version from $version_file"
@@ -56,7 +56,7 @@ if [[ ! "$current_version" =~ ^([0-9]+)\.([0-9]+)\.([0-9]+)$ ]]; then
56
56
  fi
57
57
  next_version="${BASH_REMATCH[1]}.${BASH_REMATCH[2]}.$((BASH_REMATCH[3] + 1))"
58
58
 
59
- node -e '
59
+ bun -e '
60
60
  const fs = require("node:fs")
61
61
  const [file, version] = process.argv.slice(1)
62
62
  const manifest = JSON.parse(fs.readFileSync(file, "utf8"))