ace-herdr 0.9.0 → 0.11.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f3c832e03a65b1e294f84d843966554e2018db81ec39a13ed508d4f68bb8ae07
4
- data.tar.gz: 2c7170d346c932c50c2d881fb528733bee63b2fa79073340ad64a8c2036f8e9e
3
+ metadata.gz: 8d943e508273e1c9dfc0bd77d83a0e9330ae304a6cd61fcae7bf087a0af68b69
4
+ data.tar.gz: 2249f16cb6ac3c97d8eec2bbdd08824c2677ef78308999ab8ccbc1e929ca6eb6
5
5
  SHA512:
6
- metadata.gz: c9c513a7de5c8224c73e597f133b70ed6a99aa70f70292d7c1774b789ac3a2b570f5452f19e35cbd780c29fb392edd683da46ddf2a3256035bd911bc16533cbd
7
- data.tar.gz: 071d1908f3bd701b9b516d5d7100f68a830b7eb2cd153129660c66afb08730e2f135127daf68326186479c93e6a58d4de294361293f07d561fb156aa6d19881a
6
+ metadata.gz: f60685eece841a9cd687aa7919f202bba69420ef98e9f267777ac671f309446d72e564154b0e882a8789827f5240820b9c6671efe508ed11432691ff95842600
7
+ data.tar.gz: 7df3e0ceade17e6a326971f4ada8bb591822422d0b50449a74bc96732ca8629f1ac77abbffe1b3725ffca41a89a682de02581ecd1ab3825e1ab5e83f83f5f5df
data/CHANGELOG.md CHANGED
@@ -5,6 +5,20 @@ All notable changes to `ace-herdr` will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [Unreleased]
9
+
10
+ ## [0.11.0] - 2026-11-11
11
+
12
+ ### Added
13
+
14
+ - Add ace-herdr start using native configuration; apply configured binary, socket, native config and toolchain consistently to startup and agent dispatch, including managed Pi extensions.
15
+
16
+ ## [0.10.0] - 2026-11-10
17
+
18
+ ### Added
19
+
20
+ - Launch ordinary agents with an explicit private JSON environment file, without exposing credentials in terminal commands. Preserve real pane/session identity and refuse cold auto-resume without the original environment. Retain protected installed extensions and package reproducible native source builds for Linux ARM64, including cross-building on macOS.
21
+
8
22
  ## [0.9.0] - 2026-10-30
9
23
 
10
24
  ### Changed
@@ -0,0 +1,44 @@
1
+ # Building the selected native Herdr
2
+
3
+ `ace-herdr native-source selection` reports the source commit, tree and patch
4
+ digest packaged with this gem. The patch retains ordinary prompt/terminal
5
+ identity fixes and adds explicit process environments. It does not install an
6
+ issuer, systemd session launcher or separate operating-system identity.
7
+
8
+ Build with the public owner command:
9
+
10
+ ```sh
11
+ ace-herdr native-source build --source /absolute/clean/herdr-checkout \
12
+ --output /absolute/new/artifact-directory --target aarch64-unknown-linux-musl
13
+ ace-herdr native-source verify --artifact /absolute/new/artifact-directory
14
+ ```
15
+
16
+ The build runs as a nonroot user on Linux or macOS. Install the selected Rust
17
+ toolchain, its target standard library, and the selected Zig version first.
18
+ Use actual tool executables in `PATH`, rather than shims which resolve another
19
+ version. The packaged linker invokes that same pinned Zig for the selected
20
+ Linux target; a VM and a separate cross compiler are unnecessary. Output
21
+ contains the ELF executable and its source/toolchain/byte provenance. A failed
22
+ build retains its output directory for diagnosis and never overwrites it.
23
+
24
+ The selected native CLI accepts `herdr agent start … --env-file /absolute/env.json`.
25
+ The file must be a regular, non-symlink file owned by the process user with mode
26
+ `0600`, containing a JSON object of environment variable names and string values.
27
+ The ordinary child process receives that environment, plus native terminal
28
+ identity (`HERDR_*` pane/workspace/socket fields and the ACE pane/session aliases).
29
+ Ambient credentials are cleared. File contents are never submitted to the
30
+ terminal or returned in the start response. The caller removes the file after
31
+ startup returns. With `ACE_SESSION_CREDENTIALS_DIRECTORY` equal to
32
+ `PI_CODING_AGENT_DIR`, a same-user `0700` directory named `ace-session-*`, the
33
+ ordinary helper waits for the child and removes only `auth.json` on exit or
34
+ failed startup. Session evidence remains. TERM/HUP are forwarded to the child;
35
+ terminal Ctrl-C reaches its existing foreground process group. An uncatchable
36
+ kill can leave credentials behind, so the assignment/coordinator owner must
37
+ reconcile them before replacing a dead session. This is cleanup between trusted
38
+ processes, not isolation between hostile processes sharing the same user.
39
+
40
+ Cold server restoration keeps such a pane visibly unavailable until its
41
+ coordinator supplies a fresh environment. It never resumes an agent through
42
+ an ambient shell. Live terminal handoff preserves the already-running process.
43
+
44
+ Host tests and a cross-built ELF do not establish live ARM64 lab acceptance.
data/docs/start.md ADDED
@@ -0,0 +1,37 @@
1
+ # Start from configuration
2
+
3
+ `ace-herdr start` starts or attaches to the native persistent Herdr terminal.
4
+ It replaces the invoking process, retaining the terminal and native exit status.
5
+ Native Herdr owns its server lifecycle and terminal state.
6
+
7
+ Configure the existing `herdr` namespace, for example in `~/.ace/herdr/config.yml`:
8
+
9
+ ```yaml
10
+ binary: /opt/ace/runtime/bin/herdr
11
+ socket: /home/mo/.config/herdr/herdr.sock
12
+ toolchain: installed
13
+ ```
14
+
15
+ `native_config` optionally selects the native TOML configuration file. Omit it
16
+ to use Herdr's normal configuration path. `binary` defaults to `herdr` on PATH.
17
+ The same configuration is applied by ACE's native executor, including commands
18
+ issued by the overseer. An inherited `ACE_TOOLCHAIN=installed` cannot be downgraded
19
+ by configuration. Installed Linux starts check the declared managed Pi extension
20
+ paths before launching; a missing extension is an error, not a source fallback.
21
+
22
+ ```sh
23
+ ace-herdr start
24
+ ```
25
+
26
+ No shell profile needs to be sourced manually. In the terminal, run the configured
27
+ overseer. For a lab coordinator started from a separate operator terminal:
28
+
29
+ ```sh
30
+ cd /lab
31
+ ace-overseer start --scope lab --format json
32
+ ```
33
+
34
+ Overseer configuration should declare `toolchain: installed`; its existing
35
+ `start`, `profiles` and instruction configuration still select the role/model.
36
+ Session credentials and child runtime paths come from the lab's existing role
37
+ configuration. The configured session-runtime socket must match Herdr's socket.
data/docs/usage.md CHANGED
@@ -70,6 +70,24 @@ by the number of deliveries.
70
70
 
71
71
  ## Dispatch, send, capture, wait, close
72
72
 
73
+ `dispatch` starts an ordinary process in `--cwd`. For an explicitly selected
74
+ environment, pass `--env-file` with an absolute path to a private (`0600`) JSON
75
+ object of string variables. The native launcher clears ambient variables and
76
+ reads this file without placing its values in terminal commands or prompts.
77
+ `--role` labels the commission; it does not grant operating-system privileges.
78
+
79
+ ```sh
80
+ ace-herdr dispatch --label review-task --role verifier --cwd /lab/ace/.ace-wt/task-1 --env-file /private/role-environment.json --prompt-file commission.md
81
+ ```
82
+
83
+ Installed Linux deployments use the protected extensions configured by
84
+ `ace-lab`. Missing required runtime or extension files block startup. Sessions
85
+ of the same user are trusted peers, not a hostile-code sandbox. For task work,
86
+ use `ace-overseer work-on` or `handoff`: these own commission identity, duplicate
87
+ protection and report-driven retirement. A low-level dispatch alone is not an
88
+ assignment lifecycle.
89
+
90
+
73
91
  ```bash
74
92
  ace-herdr dispatch --label t.123 --kind pi --prompt-file prompt.md
75
93
  ace-herdr dispatch --label review --pane p7 --cwd /Users/me/project
@@ -87,6 +105,11 @@ prompt semantics: text becomes one self-submitting agent prompt, and a single
87
105
  trailing Enter is dropped and reported. A command must be declared before any
88
106
  key.
89
107
 
108
+ For the native `herdr agent prompt` command, `--wait` without `--until`
109
+ waits for a settled state. Use `--wait --until working --until blocked` to
110
+ wait for observed activity instead. A stalled or timed-out prompt has an
111
+ uncertain delivery outcome; inspect the existing agent before retrying.
112
+
90
113
  ## Workspaces, tabs, and presets
91
114
 
92
115
  Presets resolve through the ADR-022 cascade (`.ace/herdr/` > `~/.ace/herdr/` >
@@ -26,6 +26,8 @@ module Ace
26
26
  ]
27
27
 
28
28
  option :label, type: :string, desc: "Agent and pane label (typically the task id)"
29
+ option :role, type: :string, desc: "Executor role label"
30
+ option :env_file, type: :string, desc: "Private JSON file containing the executor environment"
29
31
  option :kind, type: :string, desc: "Agent kind (default: config default_agent_kind)"
30
32
  option :workspace, type: :string, desc: "Target workspace (default: caller's workspace)"
31
33
  option :pane, type: :string, desc: "Existing pane (default: create a new tab)"
@@ -50,7 +52,7 @@ module Ace
50
52
  outcome = dispatcher.dispatch(
51
53
  label: options.fetch(:label), prompt: prompt,
52
54
  kind: options[:kind], workspace_id: options[:workspace],
53
- pane: options[:pane], cwd: options[:cwd]
55
+ pane: options[:pane], cwd: options[:cwd], role: options[:role], env_file: options[:env_file]
54
56
  )
55
57
  puts JSON.generate(outcome.to_h)
56
58
  end
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "ace/support/cli"
4
+ require_relative "support"
5
+
6
+ module Ace
7
+ module Herdr
8
+ module CLI
9
+ module Commands
10
+ # Native Herdr owns its configuration and persistent terminal lifecycle.
11
+ # Replace this process so the caller retains the terminal and exit status.
12
+ class Start < Ace::Support::Cli::Command
13
+ include Ace::Support::Cli::Base
14
+ include Runtime
15
+
16
+ desc "Start or attach to Herdr using its native configuration"
17
+
18
+ def initialize(launcher: nil, configuration: nil)
19
+ @launcher = launcher || ->(environment, binary) { Kernel.exec(environment, binary) }
20
+ @configuration = configuration
21
+ end
22
+
23
+ def call(**)
24
+ configuration = @configuration || config
25
+ binary = configuration.fetch("binary", "herdr")
26
+ unless binary.is_a?(String) && !binary.empty? && !binary.include?("\0")
27
+ cli_error("herdr binary must be a nonempty executable path")
28
+ end
29
+ environment = Molecules::HerdrExecutor.environment(configuration)
30
+ Molecules::InstalledPiExtensions.arguments(env: ENV.to_h.merge(environment))
31
+ @launcher.call(environment, binary)
32
+ rescue SystemCallError, Ace::Herdr::ExecutorError => e
33
+ cli_error("Cannot start Herdr: #{e.message}")
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
data/lib/ace/herdr/cli.rb CHANGED
@@ -11,6 +11,7 @@ require_relative "cli/commands/close"
11
11
  require_relative "cli/commands/tidy"
12
12
  require_relative "cli/commands/list"
13
13
  require_relative "cli/commands/status"
14
+ require_relative "cli/commands/start"
14
15
  require_relative "cli/commands/send"
15
16
  require_relative "cli/commands/capture"
16
17
  require_relative "cli/commands/workspace"
@@ -28,6 +29,7 @@ module Ace
28
29
 
29
30
  # Application commands with descriptions (for help output)
30
31
  REGISTERED_COMMANDS = [
32
+ ["start", "Start or attach to Herdr using its native configuration"],
31
33
  ["deliver", "Push an answer to an agent pane (ace-hitl delivery contract)"],
32
34
  ["inbox", "Durable agent message queue and reconciliation"],
33
35
  ["dispatch", "Start an agent in one command: tab + agent + prompt"],
@@ -77,6 +79,7 @@ module Ace
77
79
  register "native-source", CLI::Commands::NativeSource.new
78
80
  register "list", CLI::Commands::List.new
79
81
  register "status", CLI::Commands::Status.new
82
+ register "start", CLI::Commands::Start.new
80
83
  register "send", CLI::Commands::Send.new
81
84
  register "capture", CLI::Commands::Capture.new
82
85
  register "wait", CLI::Commands::Wait.new
@@ -5,6 +5,7 @@ require "open3"
5
5
  require "json"
6
6
  require "timeout"
7
7
  require_relative "bounded_process"
8
+ require_relative "installed_pi_extensions"
8
9
 
9
10
  module Ace
10
11
  module Herdr
@@ -18,11 +19,33 @@ module Ace
18
19
  WAKE_OUTPUT_LIMIT = 65_536
19
20
  DEFAULT_PROBE_TIMEOUT_S = 60
20
21
 
21
- def initialize(binary: DEFAULT_BINARY, process: BoundedProcess)
22
- @binary = binary
22
+ def self.environment(config)
23
+ {"socket" => "HERDR_SOCKET_PATH", "native_config" => "HERDR_CONFIG_PATH", "toolchain" => "ACE_TOOLCHAIN"}
24
+ .each_with_object({}) do |(key, variable), environment|
25
+ next unless config.key?(key)
26
+ value = config.fetch(key)
27
+ unless value.is_a?(String) && !value.empty? && !value.include?("\0")
28
+ raise ExecutorUnavailableError, "invalid Herdr configuration: #{key}"
29
+ end
30
+ if key == "toolchain"
31
+ raise ExecutorUnavailableError, "toolchain must be auto or installed" unless %w[auto installed].include?(value)
32
+ value = "installed" if ENV["ACE_TOOLCHAIN"] == "installed"
33
+ end
34
+ environment[variable] = value
35
+ end
36
+ end
37
+
38
+ def initialize(binary: nil, process: BoundedProcess, config: nil)
39
+ config ||= Ace::Herdr.config
40
+ @binary = binary || config.fetch("binary", DEFAULT_BINARY)
41
+ @environment = self.class.environment(config)
23
42
  @process = process
24
43
  end
25
44
 
45
+ def agent_list
46
+ run!([@binary, "agent", "list"])
47
+ end
48
+
26
49
  # Probe the agent living in a pane (raises AgentNotFoundError when none)
27
50
  def agent_get(pane)
28
51
  run!([@binary, "agent", "get", pane])
@@ -33,7 +56,7 @@ module Ace
33
56
  # killed at the deadline and the timeout classifies as a retryable
34
57
  # pre-submission failure.
35
58
  def pane_get_bounded(pane, timeout_s: DEFAULT_PROBE_TIMEOUT_S)
36
- result = @process.call([@binary, "pane", "get", pane], stdin_data: "",
59
+ result = @process.call(native_command([@binary, "pane", "get", pane]), stdin_data: "",
37
60
  timeout_s: timeout_s, output_limit: WAKE_OUTPUT_LIMIT)
38
61
  execution = ExecutionResult.new(
39
62
  stdout: result.stdout.strip, stderr: result.stderr.strip,
@@ -55,9 +78,13 @@ module Ace
55
78
  # `args` are harness passthrough arguments forwarded verbatim
56
79
  # after `--` (e.g. pi's --model/--thinking/--append-system-prompt;
57
80
  # the overseer start contract, 8xs.t.pu0.1).
58
- def agent_start(name:, kind:, pane:, timeout_ms:, args: [])
81
+ def agent_start(name:, kind:, pane:, timeout_ms:, args: [], env_file: nil)
82
+ managed = kind == "pi" ? InstalledPiExtensions.arguments(env: ENV.to_h.merge(@environment)) : []
83
+ InstalledPiExtensions.reject_override!(args) unless managed.empty?
84
+ args = managed + args
59
85
  cmd = [@binary, "agent", "start", name, "--kind", kind,
60
86
  "--pane", pane, "--timeout", timeout_ms.to_s]
87
+ cmd += ["--env-file", env_file] if env_file
61
88
  cmd += ["--", *args] unless args.empty?
62
89
  run!(cmd)
63
90
  end
@@ -66,12 +93,14 @@ module Ace
66
93
  # rejects blocked agents pre-send with agent_blocked. With
67
94
  # wait: herdr's activity gate applies — a prompt sent from a
68
95
  # non-working state must produce observed working/blocked
69
- # activity, so success confirms the turn actually began
70
- # (agent_prompt_stalled / timeout otherwise; timeout_ms bounds
71
- # the wait).
72
- def agent_prompt(pane:, text:, wait: false, timeout_ms: nil)
96
+ # activity before waiting for the requested state. With no explicit
97
+ # states the native default waits for idle, done or blocked.
98
+ def agent_prompt(pane:, text:, wait: false, timeout_ms: nil, until_states: nil)
99
+ raise ArgumentError, "until_states requires wait" if until_states && !wait
100
+
73
101
  cmd = [@binary, "agent", "prompt", pane, text]
74
102
  cmd += ["--wait"] if wait
103
+ Array(until_states).each { |state| cmd += ["--until", state] }
75
104
  cmd += ["--timeout", timeout_ms.to_s] if timeout_ms
76
105
  run!(cmd)
77
106
  end
@@ -81,7 +110,7 @@ module Ace
81
110
  # keep the inbox event lock through Open3.capture3 cleanup.
82
111
  def agent_prompt_bounded(pane:, text:, timeout_ms:)
83
112
  cmd = [@binary, "agent", "prompt", pane, text]
84
- result = @process.call(cmd, stdin_data: "",
113
+ result = @process.call(native_command(cmd), stdin_data: "",
85
114
  timeout_s: timeout_ms / 1000.0, output_limit: WAKE_OUTPUT_LIMIT)
86
115
  execution = ExecutionResult.new(
87
116
  stdout: result.stdout.strip, stderr: result.stderr.strip,
@@ -246,6 +275,11 @@ module Ace
246
275
 
247
276
  private
248
277
 
278
+ def native_command(command)
279
+ return command if @environment.empty?
280
+ ["env", *@environment.map { |key, value| "#{key}=#{value}" }, *command]
281
+ end
282
+
249
283
  def run!(cmd)
250
284
  result = run(cmd)
251
285
  raise classify(result, cmd) unless result.success?
@@ -263,7 +297,7 @@ module Ace
263
297
  end
264
298
 
265
299
  def run(cmd)
266
- stdout, stderr, status = Open3.capture3(*cmd)
300
+ stdout, stderr, status = Open3.capture3(*native_command(cmd))
267
301
  ExecutionResult.new(
268
302
  stdout: stdout.strip, stderr: stderr.strip,
269
303
  success: status.success?, exit_code: status.exitstatus || -1
@@ -273,7 +307,7 @@ module Ace
273
307
  end
274
308
 
275
309
  def run_raw_stdout(cmd)
276
- stdout, stderr, status = Open3.capture3(*cmd)
310
+ stdout, stderr, status = Open3.capture3(*native_command(cmd))
277
311
  ExecutionResult.new(
278
312
  stdout: stdout, stderr: stderr.strip,
279
313
  success: status.success?, exit_code: status.exitstatus || -1
@@ -0,0 +1,60 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "find"
4
+ require "yaml"
5
+ require "ace/runtime"
6
+ require "ace/runtime/molecules/protected_socket"
7
+ require_relative "../errors"
8
+
9
+ module Ace
10
+ module Herdr
11
+ module Molecules
12
+ # Installed Linux lab agents load only host-managed Pi extensions.
13
+ # The existing root-owned lab manifest declares their location; no
14
+ # second registry or agent-writable discovery path is introduced.
15
+ module InstalledPiExtensions
16
+ MANIFEST_DIR = "/etc/lab/ace-lab"
17
+ MANIFEST = "#{MANIFEST_DIR}/install.yml"
18
+ module_function
19
+
20
+ def arguments(env: ENV, manifest: MANIFEST, manifest_dir: MANIFEST_DIR, platform: RUBY_PLATFORM)
21
+ return [] unless env["ACE_TOOLCHAIN"] == "installed" && platform.include?("linux")
22
+ return [] unless File.exist?(manifest_dir) || File.symlink?(manifest_dir)
23
+
24
+ guard = Ace::Runtime::Molecules::ProtectedSocket
25
+ guard.root_path!(manifest, directory: false)
26
+ raise ExecutorUnavailableError, "installed lab manifest is not a regular file" unless File.file?(manifest)
27
+ document = YAML.safe_load(File.read(manifest), permitted_classes: [], aliases: false)
28
+ rows = document.is_a?(Hash) && document.dig("gemset", "extensions")
29
+ matches = rows.is_a?(Array) ? rows.select { |row| row.is_a?(Hash) && row["gem"] == "ace-wake" } : []
30
+ raise ExecutorUnavailableError, "installed lab must declare exactly one ace-wake extension path" unless matches.size == 1
31
+ root = matches.fetch(0)["path"]
32
+ guard.root_path!(root, directory: true)
33
+ wake = File.join(root, "ace-wake")
34
+ guard.root_path!(wake, directory: true)
35
+ Find.find(wake) do |path|
36
+ stat = File.lstat(path)
37
+ unless (stat.file? || stat.directory?) && !stat.symlink? && stat.uid.zero? && (stat.mode & 0o022).zero?
38
+ raise ExecutorUnavailableError, "installed ace-wake contains an unsafe path"
39
+ end
40
+ end
41
+ entry = File.join(wake, "index.js")
42
+ integration = File.join(root, "herdr-agent-state.ts")
43
+ [entry, integration].each do |path|
44
+ guard.root_path!(path, directory: false)
45
+ raise ExecutorUnavailableError, "installed Pi extension is not a regular file" unless File.file?(path)
46
+ end
47
+ ["--no-extensions", "--extension", entry, "--extension", integration]
48
+ rescue Ace::Runtime::Error, SystemCallError, Psych::Exception, TypeError, ArgumentError
49
+ raise ExecutorUnavailableError, "installed Pi extension configuration is unavailable or unsafe"
50
+ end
51
+
52
+ def reject_override!(args)
53
+ return if args.none? { |arg| arg.is_a?(String) && (arg == "--no-extensions" || arg == "-ne" || arg.start_with?("--extension=") || arg == "--extension" || arg.start_with?("-e")) }
54
+
55
+ raise ExecutorUnavailableError, "installed lab Pi extension arguments cannot be overridden"
56
+ end
57
+ end
58
+ end
59
+ end
60
+ end