Skip to content

Commit b0360ea

Browse files
committed
fix(agent-spec): carry required resource reason through bundled declarations and docs
Codex review (P1): requiring reason invalidated the repository's own examples — validate.rs/status_agents.rs fixtures parse-errored into empty rosters, and README/vrs spec still documented a name+uri-only envelope. Add reason to every bundled declaration and update the contract prose to name+uri+reason with optional inactive-reason.
1 parent a1931fb commit b0360ea

4 files changed

Lines changed: 17 additions & 14 deletions

File tree

README.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ The compact declaration shape is:
187187
agent "<identity>" {
188188
host "<host>"
189189
workspace "<workspace>"
190-
resource "work" uri="github-issue://example/project/123"
190+
resource "work" uri="github-issue://example/project/123" reason="release work item"
191191
// Optional metadata:
192192
// role "worker"
193193
// supervisor "<supervisor-bus-id>"
@@ -250,12 +250,13 @@ It neither registers schemes, owns profile schemas, nor resolves targets.
250250
Binding order is irrelevant and names must be unique within the agent:
251251

252252
```kdl
253-
resource "work" uri="github-issue://example/project/123"
254-
resource "source" uri="worktree://github.com/example/project/change"
255-
resource "delivery" uri="ding://host/agent"
253+
resource "work" uri="github-issue://example/project/123" reason="release work item"
254+
resource "source" uri="worktree://github.com/example/project/change" reason="primary checkout"
255+
resource "delivery" uri="ding://host/agent" reason="notification channel for this agent"
256256
```
257257

258-
The envelope is intentionally only `name` + `uri`. It carries no required/optional,
258+
The envelope is `name` + `uri` + a required human-facing `reason`, plus an optional
259+
`inactive-reason` that preserves a retired binding without deleting it. It carries no
259260
access, readiness, or lifecycle policy, and URI possession conveys no authority. A Resource URI may
260261
be referenced by any number of agent declarations. Resource-only declaration edits do not stop,
261262
replace, or relaunch a live task. Resource profiles and resolvers remain opaque to st2; catalog

docs/vrs/spec.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,10 +191,11 @@ the drift is fenced by
191191
An agent may directly declare zero or more generic Resource bindings:
192192

193193
```kdl
194-
resource "work" uri="github-issue://example/project/123"
194+
resource "work" uri="github-issue://example/project/123" reason="release work item"
195195
```
196196

197-
The positional name is an agent-local semantic role. `uri` is the exact RFC 3986 absolute resource
197+
The positional name is an agent-local semantic role. `reason` explains why the reference belongs
198+
to this agent (required; optional `inactive-reason` retains inactive bindings). `uri` is the exact RFC 3986 absolute resource
198199
identity, preserved byte-for-byte without normalization, and its scheme selects the open,
199200
downstream-owned Resource profile.
200201
Declaration order has no meaning and binding names are unique within one

tests/status_agents.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ fn write(root: &Path, rel: &str, contents: &str) {
2323
fn agent_kdl(identity: &str, host: &str) -> String {
2424
format!(
2525
"agent \"{identity}\" {{\n identity \"{identity}\"\n host \"{host}\"\n \
26-
type \"service\"\n resource \"work\" uri=\"issue://example/{identity}\"\n \
26+
type \"service\"\n resource \"work\" uri=\"issue://example/{identity}\" reason=\"example work item\"\n \
2727
pty \"agent\" {{ command \"exec claude boot\" }}\n}}\n"
2828
)
2929
}
@@ -218,7 +218,8 @@ fn roster_json_and_human_output_distinguish_retirement_from_presence() {
218218
rows[0]["resources"],
219219
serde_json::json!([{
220220
"name": "work",
221-
"uri": "issue://example/live"
221+
"uri": "issue://example/live",
222+
"reason": "example work item"
222223
}])
223224
);
224225
assert_eq!(rows[1]["identity"], "h.retired");

tests/validate.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ fn opaque_resource_bindings_are_structurally_valid() {
7272
"Silber/cos/agent.kdl",
7373
r#"agent "cos" {
7474
host "Silber"
75-
resource "work" uri="vendor+thing://authority/exact%20identity"
75+
resource "work" uri="vendor+thing://authority/exact%20identity" reason="example vendor work item"
7676
command "codex"
7777
}"#,
7878
)]);
@@ -88,15 +88,15 @@ fn active_agents_may_share_an_opaque_resource_uri() {
8888
"h/reviewer/agent.kdl",
8989
r#"agent "reviewer" {
9090
host "h"
91-
resource "subject" uri="git-commit://github.com/example/project/0123456789abcdef"
91+
resource "subject" uri="git-commit://github.com/example/project/0123456789abcdef" reason="reviewed example commit"
9292
command "true"
9393
}"#,
9494
),
9595
(
9696
"h/integrator/agent.kdl",
9797
r#"agent "integrator" {
9898
host "h"
99-
resource "subject" uri="git-commit://github.com/example/project/0123456789abcdef"
99+
resource "subject" uri="git-commit://github.com/example/project/0123456789abcdef" reason="reviewed example commit"
100100
command "true"
101101
}"#,
102102
),
@@ -114,15 +114,15 @@ fn duplicate_bus_ids_remain_an_error_when_resources_are_shared() {
114114
"h/one/agent.kdl",
115115
r#"agent "worker" {
116116
host "h"
117-
resource "subject" uri="git-commit://github.com/example/project/0123456789abcdef"
117+
resource "subject" uri="git-commit://github.com/example/project/0123456789abcdef" reason="reviewed example commit"
118118
command "true"
119119
}"#,
120120
),
121121
(
122122
"h/two/agent.kdl",
123123
r#"agent "worker" {
124124
host "h"
125-
resource "subject" uri="git-commit://github.com/example/project/0123456789abcdef"
125+
resource "subject" uri="git-commit://github.com/example/project/0123456789abcdef" reason="reviewed example commit"
126126
command "true"
127127
}"#,
128128
),

0 commit comments

Comments
 (0)