agent-orchestration-process 0.6.2__tar.gz → 0.6.3__tar.gz

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.
Files changed (29) hide show
  1. {agent_orchestration_process-0.6.2 → agent_orchestration_process-0.6.3}/PKG-INFO +1 -1
  2. {agent_orchestration_process-0.6.2 → agent_orchestration_process-0.6.3}/pyproject.toml +1 -1
  3. {agent_orchestration_process-0.6.2 → agent_orchestration_process-0.6.3}/pyproject.toml.orig +1 -1
  4. {agent_orchestration_process-0.6.2 → agent_orchestration_process-0.6.3}/src/agent_orchestration_process/cli.py +21 -0
  5. {agent_orchestration_process-0.6.2 → agent_orchestration_process-0.6.3}/src/agent_orchestration_process/models.py +5 -0
  6. {agent_orchestration_process-0.6.2 → agent_orchestration_process-0.6.3}/src/agent_orchestration_process/runner.py +247 -0
  7. {agent_orchestration_process-0.6.2 → agent_orchestration_process-0.6.3}/src/agent_orchestration_process/worktrees.py +8 -0
  8. {agent_orchestration_process-0.6.2 → agent_orchestration_process-0.6.3}/LICENSE +0 -0
  9. {agent_orchestration_process-0.6.2 → agent_orchestration_process-0.6.3}/README.md +0 -0
  10. {agent_orchestration_process-0.6.2 → agent_orchestration_process-0.6.3}/src/agent_orchestration_process/__init__.py +0 -0
  11. {agent_orchestration_process-0.6.2 → agent_orchestration_process-0.6.3}/src/agent_orchestration_process/__main__.py +0 -0
  12. {agent_orchestration_process-0.6.2 → agent_orchestration_process-0.6.3}/src/agent_orchestration_process/batch.py +0 -0
  13. {agent_orchestration_process-0.6.2 → agent_orchestration_process-0.6.3}/src/agent_orchestration_process/codex_auth.py +0 -0
  14. {agent_orchestration_process-0.6.2 → agent_orchestration_process-0.6.3}/src/agent_orchestration_process/codex_routes.py +0 -0
  15. {agent_orchestration_process-0.6.2 → agent_orchestration_process-0.6.3}/src/agent_orchestration_process/dsh_runner.mjs +0 -0
  16. {agent_orchestration_process-0.6.2 → agent_orchestration_process-0.6.3}/src/agent_orchestration_process/egress.py +0 -0
  17. {agent_orchestration_process-0.6.2 → agent_orchestration_process-0.6.3}/src/agent_orchestration_process/egress_bridge.py +0 -0
  18. {agent_orchestration_process-0.6.2 → agent_orchestration_process-0.6.3}/src/agent_orchestration_process/integration.py +0 -0
  19. {agent_orchestration_process-0.6.2 → agent_orchestration_process-0.6.3}/src/agent_orchestration_process/isolation.py +0 -0
  20. {agent_orchestration_process-0.6.2 → agent_orchestration_process-0.6.3}/src/agent_orchestration_process/locks.py +0 -0
  21. {agent_orchestration_process-0.6.2 → agent_orchestration_process-0.6.3}/src/agent_orchestration_process/migration.py +0 -0
  22. {agent_orchestration_process-0.6.2 → agent_orchestration_process-0.6.3}/src/agent_orchestration_process/model_catalog.py +0 -0
  23. {agent_orchestration_process-0.6.2 → agent_orchestration_process-0.6.3}/src/agent_orchestration_process/model_listing.py +0 -0
  24. {agent_orchestration_process-0.6.2 → agent_orchestration_process-0.6.3}/src/agent_orchestration_process/pricing.py +0 -0
  25. {agent_orchestration_process-0.6.2 → agent_orchestration_process-0.6.3}/src/agent_orchestration_process/prompt_transport.py +0 -0
  26. {agent_orchestration_process-0.6.2 → agent_orchestration_process-0.6.3}/src/agent_orchestration_process/provider_versions.py +0 -0
  27. {agent_orchestration_process-0.6.2 → agent_orchestration_process-0.6.3}/src/agent_orchestration_process/sandbox_launch.py +0 -0
  28. {agent_orchestration_process-0.6.2 → agent_orchestration_process-0.6.3}/src/agent_orchestration_process/zcode.py +0 -0
  29. {agent_orchestration_process-0.6.2 → agent_orchestration_process-0.6.3}/src/agent_orchestration_process/zcode_protocol.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: agent-orchestration-process
3
- Version: 0.6.2
3
+ Version: 0.6.3
4
4
  Summary: Run bounded, non-interactive jobs across agent harnesses with isolation, exact resume, and provenance
5
5
  Keywords: agent-orchestration,ai-agents,autoresearch,coding-agents,git-worktrees
6
6
  Author: AOP contributors
@@ -4,7 +4,7 @@ build-backend = "uv_build"
4
4
 
5
5
  [project]
6
6
  name = "agent-orchestration-process"
7
- version = "0.6.2"
7
+ version = "0.6.3"
8
8
  description = "Run bounded, non-interactive jobs across agent harnesses with isolation, exact resume, and provenance"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.11"
@@ -4,7 +4,7 @@ build-backend = "uv_build"
4
4
 
5
5
  [project]
6
6
  name = "agent-orchestration-process"
7
- version = "0.6.2"
7
+ version = "0.6.3"
8
8
  description = "Run bounded, non-interactive jobs across agent harnesses with isolation, exact resume, and provenance"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.11"
@@ -33,6 +33,7 @@ from .runner import (
33
33
  )
34
34
  from .migration import migrate_archive, migrate_runs, migration_roots, print_counts
35
35
  from .worktrees import (
36
+ AdmissionRefused,
36
37
  AOPError,
37
38
  WorktreeManager,
38
39
  compact_state_roots,
@@ -229,6 +230,7 @@ def build_parser() -> argparse.ArgumentParser:
229
230
  "instead of a task worktree; TASK becomes optional and AOP keeps its "
230
231
  "records in the current directory",
231
232
  )
233
+ _add_admit_argument(run)
232
234
  run.add_argument(
233
235
  "--native-state",
234
236
  action="store_true",
@@ -271,6 +273,7 @@ def build_parser() -> argparse.ArgumentParser:
271
273
  "--json", action="store_true", help="print the normalized result as JSON"
272
274
  )
273
275
  _add_artifact_arguments(resume)
276
+ _add_admit_argument(resume)
274
277
  _add_input_arguments(resume, default=None, resume=True)
275
278
  _add_prompt_arguments(resume)
276
279
 
@@ -522,6 +525,7 @@ def main(argv: Sequence[str] | None = None) -> int:
522
525
  writable_workspace=args.writable_workspace,
523
526
  thinking_display=args.thinking_display,
524
527
  reminders=args.reminders,
528
+ admit_command=args.admit_command,
525
529
  )
526
530
  return _report_run(result, manager, json_output=args.json)
527
531
 
@@ -534,6 +538,7 @@ def main(argv: Sequence[str] | None = None) -> int:
534
538
  timeout_seconds=args.timeout,
535
539
  artifacts=args.artifact,
536
540
  input_paths=args.input_paths,
541
+ admit_command=args.admit_command,
537
542
  )
538
543
  return _report_run(result, manager, json_output=args.json)
539
544
 
@@ -553,6 +558,12 @@ def main(argv: Sequence[str] | None = None) -> int:
553
558
  return 0
554
559
 
555
560
  raise AOPError("unsupported command")
561
+ except AdmissionRefused as error:
562
+ # Standard output would carry the answer; a refused run has none, so
563
+ # it carries this line, which callers can tell from a result.
564
+ print(json.dumps({"admitted": False, "reason": str(error), **error.decision}))
565
+ print(f"aop: {error}", file=sys.stderr)
566
+ return 2
556
567
  except AOPError as error:
557
568
  print(f"aop: {error}", file=sys.stderr)
558
569
  return 2
@@ -581,6 +592,16 @@ def _add_prompt_arguments(parser: argparse.ArgumentParser) -> None:
581
592
  )
582
593
 
583
594
 
595
+ def _add_admit_argument(parser: argparse.ArgumentParser) -> None:
596
+ parser.add_argument(
597
+ "--admit-command",
598
+ metavar="CMD",
599
+ help="command that must exit 0 before the harness starts; it receives "
600
+ "the run as JSON on stdin and AOP_ADMIT_* variables (default: "
601
+ "AOP_ADMIT_COMMAND; empty for none)",
602
+ )
603
+
604
+
584
605
  def _add_artifact_arguments(parser: argparse.ArgumentParser) -> None:
585
606
  parser.add_argument(
586
607
  "--artifact",
@@ -121,6 +121,8 @@ class RunRequest:
121
121
  # Which Muse reminder agents run: "all", "none", or a comma-separated
122
122
  # subset such as "goal,verify"; None leaves Muse's own settings in charge.
123
123
  reminders: str | None = None
124
+ # The admission command that allowed this run and what it answered.
125
+ admission: dict[str, Any] | None = None
124
126
  # How `aop migrate-results` converted an older record, if it did.
125
127
  migration: dict[str, Any] | None = None
126
128
 
@@ -214,6 +216,9 @@ class RunResult:
214
216
  # when reported, the models that refused, the messages the harness
215
217
  # withdrew, and the line of events.jsonl where the refusal begins.
216
218
  refusal: dict[str, Any] | None = None
219
+ # The run's admission decision: the command and its answer, or how it
220
+ # was skipped; None when no admission command was configured.
221
+ admission: dict[str, Any] | None = None
217
222
  accounting_status: str = "complete"
218
223
  usage_schema: str = TOKEN_USAGE_SCHEMA
219
224
  # The .aop state directory the run was recorded in, as listed in the
@@ -12,11 +12,13 @@ import re
12
12
  import shutil
13
13
  import stat
14
14
  import sqlite3
15
+ import shlex
15
16
  import subprocess
16
17
  import sys
17
18
  import tempfile
18
19
  import threading
19
20
  import time
21
+ import tomllib
20
22
  import urllib.parse
21
23
  import uuid
22
24
  from contextlib import contextmanager
@@ -62,6 +64,7 @@ from .pricing import (
62
64
  from .provider_versions import require_supported_agy
63
65
  from . import egress, sandbox_launch
64
66
  from .worktrees import (
67
+ AdmissionRefused,
65
68
  AOPError,
66
69
  Worktree,
67
70
  WorktreeManager,
@@ -266,6 +269,7 @@ def _build_run_result(
266
269
  provider_status=provider_status,
267
270
  provider_error=provider_error,
268
271
  refusal=refusal,
272
+ admission=request.admission,
269
273
  )
270
274
 
271
275
 
@@ -1364,8 +1368,15 @@ class ClaudeAdapter:
1364
1368
  run_dir: Path,
1365
1369
  environment: dict[str, str],
1366
1370
  ) -> RunResult:
1371
+ login = None
1367
1372
  if not request.native_state:
1373
+ source_config, _ = _claude_source(environment)
1368
1374
  _prepare_claude_environment(environment)
1375
+ login = _ClaudeLogin(
1376
+ source_config,
1377
+ Path(environment["AOP_PROVIDER_STATE_DIR"]) / "claude" / "home" / ".claude",
1378
+ )
1379
+ login.start()
1369
1380
  if request.provider_base_url is not None:
1370
1381
  environment["ANTHROPIC_BASE_URL"] = request.provider_base_url
1371
1382
  environment["AOP_PROVIDER_BASE_URL_ENV"] = "ANTHROPIC_BASE_URL"
@@ -1385,7 +1396,10 @@ class ClaudeAdapter:
1385
1396
  timeout_seconds=request.timeout_seconds,
1386
1397
  is_response=self._is_response,
1387
1398
  live_dir=run_dir,
1399
+ stop_when=None if login is None else lambda _lines: login.sync(),
1388
1400
  )
1401
+ if login is not None:
1402
+ login.sync()
1389
1403
  previous_total_cost_usd = (
1390
1404
  self._reported_total_cost_usd(
1391
1405
  run_dir.parent / request.parent_run_id / "events.jsonl"
@@ -6161,6 +6175,88 @@ def _seed_claude_home(
6161
6175
  shutil.copy2(source_settings, destination / ".claude.json")
6162
6176
 
6163
6177
 
6178
+ class _ClaudeLogin:
6179
+ """Keep a task's private Claude sign-in in step with the user's.
6180
+
6181
+ A Claude sign-in refreshes with a rotating refresh token: each refresh
6182
+ returns a new one and invalidates the old. Claude processes that share one
6183
+ credentials file follow each other's refreshes, but a task's private copy
6184
+ does not, so a refresh on either side used to break the other: the run
6185
+ failed with "OAuth session expired", or the user's own sessions did. AOP
6186
+ therefore copies whichever side refreshed onto the other, before the run,
6187
+ every few seconds while it runs, and after it ends.
6188
+ """
6189
+
6190
+ def __init__(self, source_config: Path, private_config: Path):
6191
+ self.source = source_config / ".credentials.json"
6192
+ self.private = private_config / ".credentials.json"
6193
+ self.shared: str | None = None
6194
+
6195
+ def start(self) -> None:
6196
+ """Give the private copy the user's sign-in unless it holds a newer one."""
6197
+ source, private = self._token(self.source), self._token(self.private)
6198
+ if source is not None and (
6199
+ private is None
6200
+ or _claude_login_expiry(self.source) > _claude_login_expiry(self.private)
6201
+ ):
6202
+ _replace_private_file(self.source, self.private)
6203
+ private = source
6204
+ self.shared = private
6205
+
6206
+ def sync(self) -> None:
6207
+ """Copy a refresh made on one side to the other."""
6208
+ if self.shared is None:
6209
+ return
6210
+ source, private = self._token(self.source), self._token(self.private)
6211
+ try:
6212
+ if private is not None and private != self.shared and source == self.shared:
6213
+ # The run refreshed, which invalidated the user's refresh token.
6214
+ _replace_private_file(self.private, self.source)
6215
+ self.shared = private
6216
+ elif source is not None and source != self.shared:
6217
+ # The user's sessions refreshed, or the user signed in again.
6218
+ _replace_private_file(self.source, self.private)
6219
+ self.shared = source
6220
+ except AOPError:
6221
+ pass # A later check, or the next run, tries again.
6222
+
6223
+ @staticmethod
6224
+ def _token(credentials: Path) -> str | None:
6225
+ """The sign-in's refresh token, or None when there is no usable one."""
6226
+ try:
6227
+ token = json.loads(credentials.read_text())["claudeAiOauth"]["refreshToken"]
6228
+ except (OSError, ValueError, KeyError, TypeError):
6229
+ return None
6230
+ return token if isinstance(token, str) and token else None
6231
+
6232
+
6233
+ def _replace_private_file(source: Path, target: Path) -> None:
6234
+ """Replace `target` with a copy of `source` atomically, readable by the user only."""
6235
+ temporary = target.with_name(f".{target.name}.{uuid.uuid4().hex}.tmp")
6236
+ try:
6237
+ shutil.copyfile(source, temporary)
6238
+ temporary.chmod(0o600)
6239
+ os.replace(temporary, target)
6240
+ except OSError as error:
6241
+ raise AOPError(f"could not update a Claude sign-in: {error}") from error
6242
+ finally:
6243
+ temporary.unlink(missing_ok=True)
6244
+
6245
+
6246
+ def _claude_login_expiry(credentials: Path) -> float:
6247
+ """When a Claude credentials file's login expires, or else when it was written."""
6248
+ try:
6249
+ expires = json.loads(credentials.read_text())["claudeAiOauth"]["expiresAt"]
6250
+ if isinstance(expires, (int, float)) and not isinstance(expires, bool):
6251
+ return expires / 1000
6252
+ except (OSError, ValueError, KeyError, TypeError):
6253
+ pass
6254
+ try:
6255
+ return credentials.stat().st_mtime
6256
+ except OSError:
6257
+ return 0.0
6258
+
6259
+
6164
6260
  def _copy_unless_removed(source: str, target: str) -> None:
6165
6261
  """Copy a file, skipping one that a running Claude removed after listing."""
6166
6262
  try:
@@ -6709,6 +6805,80 @@ def _hermes_runtime_environment(
6709
6805
  _write_hermes_auth(shared_auth, task_auth)
6710
6806
 
6711
6807
 
6808
+ ADMIT_TIMEOUT_SECONDS = 60.0
6809
+
6810
+
6811
+ def admission_config_path() -> Path:
6812
+ base = os.environ.get("XDG_CONFIG_HOME") or Path.home() / ".config"
6813
+ return Path(base) / "aop" / "config.toml"
6814
+
6815
+
6816
+ def _admit_command(explicit: str | None) -> tuple[str | None, str | None]:
6817
+ """The admission command and where it was set, most specific first.
6818
+
6819
+ --admit-command, then AOP_ADMIT_COMMAND, then admit_command in the user's
6820
+ AOP config. An empty value at any level turns admission off from there.
6821
+ """
6822
+ if explicit is not None:
6823
+ return explicit, "--admit-command"
6824
+ if "AOP_ADMIT_COMMAND" in os.environ:
6825
+ return os.environ["AOP_ADMIT_COMMAND"], "AOP_ADMIT_COMMAND"
6826
+ path = admission_config_path()
6827
+ try:
6828
+ config = tomllib.loads(path.read_text())
6829
+ except FileNotFoundError:
6830
+ return None, None
6831
+ except (OSError, tomllib.TOMLDecodeError) as error:
6832
+ raise AdmissionRefused(
6833
+ f"admission refused: could not read {path}: {error}",
6834
+ {"by": os.fspath(path), "exit_code": None},
6835
+ ) from error
6836
+ unknown = set(config) - {"admit_command"}
6837
+ command = config.get("admit_command")
6838
+ if unknown or (command is not None and not isinstance(command, str)):
6839
+ raise AdmissionRefused(
6840
+ f"admission refused: {path} may set only admit_command, as a string",
6841
+ {"by": os.fspath(path), "exit_code": None},
6842
+ )
6843
+ return command, (None if command is None else os.fspath(path))
6844
+
6845
+
6846
+ def _backend(request: RunRequest) -> str | None:
6847
+ """The inference provider a run will spend, where AOP can tell."""
6848
+ if request.provider == "hermes":
6849
+ try:
6850
+ return _hermes_inference_provider(request)
6851
+ except AOPError:
6852
+ return None
6853
+ if request.provider == "opencode":
6854
+ prefix, separator, _ = (request.model or "").partition("/")
6855
+ return prefix if separator else None
6856
+ if request.provider == "dsh":
6857
+ return request.inference_provider or "deepseek-official"
6858
+ return request.inference_provider
6859
+
6860
+
6861
+ def _credential_home(provider: str, environment: dict[str, str]) -> str | None:
6862
+ """The harness home a run's credentials come from, for admission commands."""
6863
+ homes: dict[str, Callable[[], Path | None]] = {
6864
+ "claude": lambda: _claude_source(environment)[0],
6865
+ "codex": lambda: _codex_source_home(environment),
6866
+ "cursor": lambda: _cursor_source_home(environment),
6867
+ "devin": lambda: _devin_source_data(environment),
6868
+ "grok": lambda: _grok_source_home(environment),
6869
+ "agy": lambda: _agy_source_dir(environment),
6870
+ "hermes": lambda: _hermes_source_home(environment),
6871
+ "muse": lambda: _muse_source_config(environment),
6872
+ "opencode": lambda: _opencode_source_config(environment),
6873
+ "zcode": lambda: zcode.source_home(environment),
6874
+ }
6875
+ try:
6876
+ home = homes[provider]() if provider in homes else None
6877
+ except (AOPError, OSError):
6878
+ return None
6879
+ return None if home is None else os.fspath(home)
6880
+
6881
+
6712
6882
  def adapter_for(agent: str) -> AgentAdapter:
6713
6883
  if agent == "codex":
6714
6884
  return CodexAdapter()
@@ -6775,6 +6945,7 @@ class AgentRunner:
6775
6945
  workdir: str | os.PathLike[str] | None = None,
6776
6946
  native_state: bool = False,
6777
6947
  reminders: str | None = None,
6948
+ admit_command: str | None = None,
6778
6949
  ) -> RunResult:
6779
6950
  self._validate_mode(mode)
6780
6951
  workdir = self._validated_workdir(workdir, profile)
@@ -6852,6 +7023,7 @@ class AgentRunner:
6852
7023
  native_state=native_state,
6853
7024
  reminders=reminders,
6854
7025
  )
7026
+ request = self._admitted(request, admit_command)
6855
7027
  worktree = (
6856
7028
  Worktree(task=task, path=Path(workdir), head="")
6857
7029
  if workdir is not None
@@ -6886,6 +7058,7 @@ class AgentRunner:
6886
7058
  artifacts: Sequence[str] = (),
6887
7059
  input_paths: Sequence[str | os.PathLike[str]] | None = None,
6888
7060
  prompt_parts: Sequence[PromptPart] | None = None,
7061
+ admit_command: str | None = None,
6889
7062
  _task_lock_held: bool = False,
6890
7063
  ) -> RunResult:
6891
7064
  parent_request = self.store.load_request(run_id)
@@ -6995,6 +7168,7 @@ class AgentRunner:
6995
7168
  native_state=parent_request.native_state,
6996
7169
  reminders=parent_request.reminders,
6997
7170
  )
7171
+ request = self._admitted(request, admit_command)
6998
7172
  return self._execute(
6999
7173
  request,
7000
7174
  worktree,
@@ -7003,6 +7177,79 @@ class AgentRunner:
7003
7177
  task_lock_held=_task_lock_held,
7004
7178
  )
7005
7179
 
7180
+ def _admitted(self, request: RunRequest, command: str | None) -> RunRequest:
7181
+ """Ask the admission command whether this run may start.
7182
+
7183
+ The command comes from --admit-command or AOP_ADMIT_COMMAND; an empty
7184
+ value means no admission. It receives the run as JSON on stdin and as
7185
+ AOP_ADMIT_* variables, and exit status 0 admits the run. Anything
7186
+ else, including a command that cannot run or does not finish in time,
7187
+ refuses it before any task state exists.
7188
+ """
7189
+ command, source = _admit_command(command)
7190
+ if command is None:
7191
+ return request
7192
+ if not command.strip():
7193
+ # An explicit opt-out stays visible in the run's records.
7194
+ return replace(request, admission={"skipped": True, "by": source})
7195
+ route = {
7196
+ "run_id": request.run_id,
7197
+ "parent_run_id": request.parent_run_id,
7198
+ "session_id": request.session_id,
7199
+ "agent": request.provider,
7200
+ "model": request.model,
7201
+ "effort": request.effort,
7202
+ "inference_provider": request.inference_provider,
7203
+ "profile": request.profile,
7204
+ "task": request.task,
7205
+ "workdir": request.workdir,
7206
+ # The run's environment is a copy of this one, and its credentials
7207
+ # are seeded from this home.
7208
+ "credential_home": _credential_home(request.provider, dict(os.environ)),
7209
+ "backend": _backend(request),
7210
+ "timeout_seconds": request.timeout_seconds,
7211
+ }
7212
+ environment = {
7213
+ **os.environ,
7214
+ # stdin carries every field in full; the variables are a
7215
+ # convenience, bounded so no value can exceed the exec limits.
7216
+ **{
7217
+ f"AOP_ADMIT_{key.upper()}": "" if value is None else str(value)[:4096]
7218
+ for key, value in route.items()
7219
+ },
7220
+ }
7221
+ try:
7222
+ argv = shlex.split(command)
7223
+ completed = subprocess.run(
7224
+ argv,
7225
+ input=json.dumps(route),
7226
+ capture_output=True,
7227
+ text=True,
7228
+ env=environment,
7229
+ timeout=ADMIT_TIMEOUT_SECONDS,
7230
+ )
7231
+ exit_code, stdout, stderr = (
7232
+ completed.returncode, completed.stdout, completed.stderr
7233
+ )
7234
+ except (OSError, ValueError) as error:
7235
+ exit_code, stdout, stderr = None, "", str(error)
7236
+ except subprocess.TimeoutExpired:
7237
+ exit_code, stdout = None, ""
7238
+ stderr = f"did not finish within {ADMIT_TIMEOUT_SECONDS:g} seconds"
7239
+ decision = {
7240
+ "by": source,
7241
+ "command": command,
7242
+ "exit_code": exit_code,
7243
+ "stdout": stdout.strip()[-4000:],
7244
+ "stderr": stderr.strip()[-4000:],
7245
+ }
7246
+ if exit_code != 0:
7247
+ reason = decision["stdout"] or decision["stderr"] or f"exit status {exit_code}"
7248
+ raise AdmissionRefused(
7249
+ f"admission refused by {command!r}: {reason.splitlines()[-1]}", decision
7250
+ )
7251
+ return replace(request, admission=decision)
7252
+
7006
7253
  def _execute(
7007
7254
  self,
7008
7255
  request: RunRequest,
@@ -88,6 +88,14 @@ class AOPError(RuntimeError):
88
88
  """A user-actionable orchestration error."""
89
89
 
90
90
 
91
+ class AdmissionRefused(AOPError):
92
+ """The run's admission command declined it, so the harness never started."""
93
+
94
+ def __init__(self, message: str, decision: dict[str, object]):
95
+ super().__init__(message)
96
+ self.decision = decision
97
+
98
+
91
99
  @dataclass(frozen=True)
92
100
  class Worktree:
93
101
  task: str