1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
//! `lernie prompt` — root-conversation backend (ARCH §2.3).
//!
//! Each prompt spawns an `agents/<conv-id>` branch off the ref the
//! start names ([`fork_point`] — a config lineage's head by default,
//! any ref with `--from`; §2.2–§2.3, there is no `main`), commits the
//! dispatch commit (§2.10) — which also removes the harness-facing
//! control files from the agent's tree (§2.2) and derives its
//! `descriptions/**` from the governing config commit (§3.3) — drives
//! the step loop through brazen's `bz` (§4.4), and lands each step's
//! response as attempt segments. Merge-back is gone: the root branch
//! persists on its own ref (§2.4), and a child returns by depositing a
//! result message into its parent's inbox (§2.6).
//!
//! Provider plumbing follows ARCH §4.4: every model call execs `bz`
//! (`bz --json --provider <row>`, canonical request on stdin, `v=1`
//! events on stdout) once per attempt, with the harness owning the retry
//! loop (§2.10). Auth and endpoints are entirely brazen's; the harness
//! references a provider *row* by name and never sees credential
//! material (§4.1). Config: the global `<harness-root>/models.yaml`
//! carries only the optional `adapter:` override (§4.2, bl-35e2); the
//! config commit's `providers.yaml` carries the whole
//! role → (provider row, model, tools) mapping (§4.3), read from the
//! governing config commit (§2.2). Retry policy (attempt cap + backoff)
//! is `workflow.yaml`'s (§6).
//!
//! [`run`] is orchestrated against injected [`AdapterRunner`],
//! [`Sleeper`], [`GitRunner`], [`Clock`], and [`IdGen`] so every branch
//! of the flow is exercisable without a live provider or on-disk side
//! effects.
pub use ;
pub use ChildDispatchRequest;
pub use ;
pub use ;
pub use Error;
pub use brazen_pin;
pub use ;
pub use ;
use crateGitRunner;
use crateagent_name as name_fact;
use Path;
/// Role name resolved from the config commit's `providers.yaml`
/// (`roles:` block, ARCH §4.3) to drive the root conversation.
pub const WORKER_ROLE: &str = "worker";
/// Directory in the config commit's tree holding the role souls (ARCH
/// §4.3 — soul = `souls/<role>.md` in the governing config commit).
pub const SOULS_DIR: &str = "souls";
/// Control file naming the role → (provider row, model, tools)
/// assignments (ARCH §4.3). Read from the governing config commit's
/// tree (§2.2), never from a worktree file.
const PER_REPO_PROVIDERS_FILE: &str = "providers.yaml";
/// Control file carrying the §6 event bindings, retry policy and
/// budgets. Read from the governing config commit's tree (§2.2) by both
/// the worker resolution ([`resolve`]) and the dispatch budget gate
/// ([`child_dispatch`]) — one name, one home.
pub const WORKFLOW_FILE: &str = "workflow.yaml";
/// Global control file naming the optional `adapter:` override (ARCH
/// §4.2, bl-35e2 — no models table). Lives at the harness root.
const GLOBAL_MODELS_FILE: &str = "models.yaml";
/// Dependencies [`run`] orchestrates over. Held as `&dyn` so the
/// struct itself carries no generic parameters and tests can pass
/// stubs inline. `config_root` is the config-lifetime harness root
/// (ARCH §2.2), which holds the global `models.yaml` (ARCH §4.2);
/// production passes [`crate::harness_root::Roots::config`], tests pass
/// a temp dir. The data-lifetime root reaches [`run`] only through
/// `tool_executor`, which already carries it.
/// Drive one root conversation against the workspace at `repo`: check
/// the layout (§2.2 — pre-v1 clean break on the retired
/// per-conversation layout), resolve the fork point the start names
/// (`--from` / `--config`, [`fork_point`], §2.3), pre-flight the
/// display name (§2.3), resolve the worker role against that fork
/// point's governing config commit, run the load-time version guard,
/// spawn the agent branch off it, and drive the step loop through `bz`.
/// Returns the agent id (the full hyphenated descent — the branch ref is
/// `agents/<id>`, ARCH §2.3). `pins` are the caller-supplied pinned
/// documents ([`pinned_doc`], §2.5) the dispatch commit snapshots beside
/// `goal.md` and `soul.md`; a pin-less start passes
/// [`PinnedDocs::none`].