Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
e3d0839
feat(acp): add supervised delegated session client
fffonion Nov 29, 2026
c395465
fix(acp): bind delegation ingress and cleanup to owned state
fffonion Nov 29, 2026
5b25c2c
fix(acp): confirm delegated cleanup and release consumed replies
fffonion Nov 29, 2026
ee2bb92
fix(acp): require trusted group evidence and linearize prompt publica…
fffonion Nov 29, 2026
9d5bea9
fix(acp): prove group absence in the kernel and arbitrate prompts at …
fffonion Nov 30, 2026
14b33ec
feat(acp): add durable delegation policy and session pins
fffonion Nov 30, 2026
b207dae
fix(acp): re-arbitrate parked prompt writes and close stdin on cleanup
fffonion Nov 30, 2026
3cbacf2
fix(acp): arbitrate caller withdrawal before the first prompt byte
fffonion Nov 30, 2026
db4833d
fix(acp): notify supervised cleanup when the actor exits
fffonion Nov 30, 2026
93979e9
fix(acp): bind manual delegation approvals and durable CAS
fffonion Nov 30, 2026
d35be5b
docs(acp): add ACP harness delegation documentation
fffonion Nov 30, 2026
fd1725f
test(acp): add two-process gateway restart harness
fffonion Nov 30, 2026
73bd8f5
fix(acp): bind delegation approval and settlement to the live gateway…
fffonion Nov 30, 2026
2646ed2
Merge commit 'db4833dea6fe05eca700813430693898821f0883' into feat/rss…
fffonion Nov 30, 2026
cd676c0
Fix ACP gateway harness source selection and startup reclamation
fffonion Nov 30, 2026
e8d890f
Bound ACP harness child reclamation and drive the startup-failure Dro…
fffonion Nov 30, 2026
b6a9e29
Bound ACP test-child reclamation to one window and one signal
fffonion Nov 30, 2026
f7067ca
test(acp-e2e): reap an exact child that exits during the identity probe
fffonion Nov 30, 2026
c8472d9
test(acp-e2e): wait for an exiting child under the shared reclaim dea…
fffonion Nov 30, 2026
a4050a2
test(acp-e2e): refuse fallback side effects once the window is spent
fffonion Nov 30, 2026
755342d
fix(acp): unify delegation approval, spawn and process ownership
fffonion Nov 30, 2026
1fc159d
test(acp-e2e): exercise three ordinary RSS runs across Gateway restart
fffonion Nov 30, 2026
abb0c5b
fix(acp): complete gateway delegation approval and cleanup policy
fffonion Nov 30, 2026
b4a0959
Merge reviewed ACP gateway policy
fffonion Nov 30, 2026
d723f1e
Merge upstream master into ACP delegation candidate
fffonion Nov 30, 2026
e8b7616
Wire approved ACP delegation into the bundled RSS Gateway loop
fffonion Nov 30, 2026
8f9b6c3
Verify cancellation fences the old ACP pin and permits a fresh session
fffonion Nov 30, 2026
b2c8fc1
test: fix ACP fixtures for all-target Clippy
fffonion Nov 30, 2026
9ef869c
test: rendezvous before the approval session fence
fffonion Nov 30, 2026
4508ac6
test(acp): verify durable session pin isolation
fffonion Nov 30, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
353 changes: 353 additions & 0 deletions docs/acp-delegation.md

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions docs/acp-mode.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,19 @@ harness grandchildren or other processes started outside RustScript's control.
Keep protocol frames on stdout and diagnostics on stderr for both the ACP and
MCP stdio connections.

## Delegation from a gateway run

This page describes the editor-facing direction: an ACP client starts the
proxy, and the harness calls RustScript's tools. The reverse direction is a
separate, opt-in feature: a normal bundled coding Gateway run can
hand one task to a configured local harness with `delegate_acp`, keep its own
main session and model, and resume the same external ACP session on later
calls. That path sends `mcpServers: []`, exposes no RustScript tools to the
harness, and owns its own approval and durable session pin. It does not change
this proxy, its tool profile, or the MCP six-tool list. See
[ACP delegation](acp-delegation.md) for its configuration, recovery, and
permission rules.

## Troubleshooting

| Symptom | What to check |
Expand Down
37 changes: 37 additions & 0 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,43 @@ provider settings. Configure authentication, model selection, and permissions
in the external harness. See [ACP mode](acp-mode.md) for editor launch examples,
compatibility, and troubleshooting.

## ACP delegation harnesses (`config.yaml`)

The current development tree accepts this optional table in the existing
agent-home `config.yaml`. A non-empty table enables the `delegate_acp` tool
for the bundled coding Gateway with a durable store. It introduces no new
file, flag, or environment variable and does not change the default catalog,
the ACP proxy, or the MCP six-tool list.

```yaml
version: 1
agent:
source: bundled:coding
acp_harnesses:
- id: opencode
command: /opt/bin/opencode
args: [acp]
```

| Field | Type | Required | Notes |
| --- | --- | --- | --- |
| `acp_harnesses` | list, absent or empty by default | no | Local stdio harnesses eligible for `delegate_acp`. Empty or absent registers no delegation tool. |
| `id` | string | yes | Unique logical ID shown in the tool input and approval preview; not a model or credential. |
| `command` | absolute path | yes | Executable started directly, without a shell. |
| `args` | list of strings | no | At most 32 literal arguments, 8 KiB in total. The task text is never inserted here. |

At most 8 entries are accepted. Duplicate IDs, a relative `command`, more than
32 arguments, or more than 8 KiB of arguments are configuration errors. The
table carries no account, model, timeout, or storage setting for the harness
and no secret; the program's own configuration and credentials stay its own.
Only the native launcher reads the table. The public configuration snapshot
and RSS keep their original fields and do not receive `command` or `args`.

Delegation itself is opt-in per run and off by default. See
[ACP delegation](acp-delegation.md) for the tool input and result, approval
requirements, durable session pin and resume rules, restart behavior, and the
operating-system permissions that remain with a trusted local harness.

## CLI arguments (runner binary)

In single-run mode, `rustscript-agent` compiles one script and drives its
Expand Down
2 changes: 1 addition & 1 deletion docs/deployment.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ manifest binaries. After the `v0.2.0` tag workflow succeeds, the downloadable

- executable binaries at `bin/rustscript-agent` and
`bin/rustscript-agent-gateway`;
- all 82 required production RSS files, with relative imports preserved, at
- all 83 required production RSS files, with relative imports preserved, at
`share/rustscript-agent/rss/`;
- YAML schemas at `share/rustscript-agent/schemas/` and production examples at
`share/rustscript-agent/examples/`;
Expand Down
1 change: 1 addition & 0 deletions docs/status.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ project is pre-v1, and absent routes or adapters are listed explicitly.
| Parallel tool calls | Not implemented; rejected as `unsupported_parallel`. |
| Parallel subagents/fan-out | Not implemented and excluded from the current milestone. The interrupt compatibility route only cancels a run handle by ID. |
| General-purpose harness beyond the implemented tool approval/pinned-tool paths | Excluded from the current product claim. |
| ACP delegation from a gateway run (`delegate_acp`) | Development feature, off by default. The bundled coding Gateway can opt in via `acp_harnesses` with a durable store. Each new call requires explicit human approval; the same external session can be restored after a Gateway restart. The ACP proxy and MCP tool list are unchanged. See [ACP delegation](acp-delegation.md). |

## Plugin graphs and state

Expand Down
1 change: 1 addition & 0 deletions release/rss-production.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ rss/storage/plugins.rss
rss/storage/runs.rss
rss/storage/schema.rss
rss/storage/sessions.rss
rss/tools/delegate_acp.rss
rss/tools/dispatch.rss
rss/tools/dispatch_entry.rss
rss/tools/patch.rss
Expand Down
8 changes: 7 additions & 1 deletion rss/agent/main.rss
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use agent;
use agent_runtime;
use json;
use super::tools::dispatch as tools;
use super::tools::delegate_acp as delegate_acp;
use super::agent::guardian as guardian;
use super::agent::provider_body;
use super::llm::tool_descriptor;
Expand Down Expand Up @@ -817,7 +818,12 @@ fn dispatch_reviewed(context: map, call: map) -> map {
};
let facts: map = tools::approval_context(dispatch_input);
let mut result: map = {};
if ctx_bool(facts, "ok", false) == false {
if ctx_string(call, "name", "") == "delegate_acp" && delegate_acp::admitted(native_tools_from_context(context)) {
result = delegate_acp::invoke(
call, call_arguments_json(call), ctx_string(call, "id", ""),
ctx_string(context, "run_id", ""), identity
);
} else if ctx_bool(facts, "ok", false) == false {
result = tools::dispatch(dispatch_input);
} else {
let tool_metadata: map = ctx_map(facts, "metadata");
Expand Down
2 changes: 2 additions & 0 deletions rss/storage/debug.rss
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,8 @@ fn storage_dispatch(db_id: resource<sqlite.connection>, command: StorageCommand)
result = storage_raw_ok(request_id, op, sessions::storage_session_list(db_id, input.profile, input.platform, command.max_rows, command.max_bytes));
} else if command.op == "session.touch" {
result = storage_raw_ok(request_id, op, sessions::storage_session_touch(db_id, command.payload_json, command.max_rows, command.max_bytes));
} else if command.op == "session.acp_delegation_cas" {
result = storage_unwrap(request_id, op, sessions::storage_session_acp_delegation_cas(db_id, command.payload_json, command.max_rows, command.max_bytes));
} else if command.op == "message.append" {
result = storage_unwrap(request_id, op, messages::storage_message_append(db_id, command.payload_json, command.max_rows, command.max_bytes));
} else if command.op == "message.get" {
Expand Down
2 changes: 2 additions & 0 deletions rss/storage/main.rss
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,8 @@ fn storage_dispatch(db_id: resource<sqlite.connection>, command: StorageCommand)
result = storage_raw_ok(request_id, op, sessions::storage_session_list(db_id, input.profile, input.platform, command.max_rows, command.max_bytes));
} else if command.op == "session.touch" {
result = storage_raw_ok(request_id, op, sessions::storage_session_touch(db_id, command.payload_json, command.max_rows, command.max_bytes));
} else if command.op == "session.acp_delegation_cas" {
result = storage_unwrap(request_id, op, sessions::storage_session_acp_delegation_cas(db_id, command.payload_json, command.max_rows, command.max_bytes));
} else if command.op == "session.workspace_bind" {
result = storage_unwrap(request_id, op, sessions::storage_session_workspace_bind(db_id, command.payload_json, command.max_rows, command.max_bytes));
} else if command.op == "message.append" {
Expand Down
49 changes: 49 additions & 0 deletions rss/storage/sessions.rss
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,17 @@ struct SessionWorkspaceBindInput {
now_ms: int
}

struct SessionAcpDelegationCasInput {
session_id: string,
owner: string,
created_at_ms: int,
expected_version: int,
lease_path: string,
lease_call: string,
document_json: string,
now_ms: int
}

fn session_tx_rows_affected(entry: SqliteTransactionResult) -> int {
let mut affected: int = 0;
if entry.kind == "execute" {
Expand Down Expand Up @@ -146,6 +157,44 @@ pub fn storage_session_touch(db_id: resource<sqlite.connection>, payload_json: s
storage_session_get(db_id, input.session_id, max_rows, max_bytes)
}

/// Compare-and-swap of the private `$.acp_delegation` document.
///
/// The whole read-check-write is one UPDATE whose predicates are enforced by
/// SQLite: the session identity (id, owner and durable `created_at_ms`), the
/// expected document version and, when `lease_path` is non-empty, the exact
/// call that currently owns that pin's lease. A zero-row update is an explicit
/// "not committed" response (`applied = 0`), never a silent success. The
/// matching row is returned in the same transaction so a caller can retry
/// from the authoritative document without a separate read.
pub fn storage_session_acp_delegation_cas(db_id: resource<sqlite.connection>, payload_json: string, max_rows: int, max_bytes: int) -> map {
let input: SessionAcpDelegationCasInput = json::decode::<SessionAcpDelegationCasInput>(payload_json);
let params: array<SqliteValue> = [sql_text(input.document_json.copy()), sql_int(input.now_ms.copy()), sql_text(input.session_id.copy()), sql_text(input.owner.copy()), sql_int(input.created_at_ms.copy()), sql_int(input.expected_version.copy()), sql_text(input.lease_path.copy()), sql_text(input.lease_path.copy()), sql_text(input.lease_call.copy())];
let update: SqliteStatement = {
sql: "UPDATE sessions SET metadata_json = json_set(CASE WHEN json_valid(metadata_json) AND json_type(metadata_json) = 'object' THEN metadata_json ELSE '{}' END, '$.acp_delegation', json(?)), updated_at_ms = ? WHERE id = ? AND user_id = ? AND created_at_ms = ? AND COALESCE(json_extract(metadata_json, '$.acp_delegation.version'), -1) = ? AND (? = '' OR COALESCE(json_extract(metadata_json, ?), '') = ?)",
params: Some(params),
query: Some(false),
limits: Some(sql_limits(1000, 4194304))
};
let get: SqliteStatement = storage_session_get_statement(input.session_id.copy(), max_rows, max_bytes);
let statements: array<SqliteStatement> = [update, get];
let results: array<SqliteTransactionResult> = sqlite::transaction(&db_id, statements);
let mut applied: int = 0;
if results.length > 0 {
applied = session_tx_rows_affected(results[0].copy());
}
let mut queried: SqliteQueryResult = {columns: [], rows: [], truncated: false, next_cursor: no_int()};
if results.length > 1 {
let second: SqliteTransactionResult = results[1].copy();
queried = match second.query { Some(value) => value, None => {columns: [], rows: [], truncated: false, next_cursor: no_int()} };
}
{
ok: true,
code: "ok",
message: "",
result: { applied: applied == 1, columns: queried.columns, rows: queried.rows, truncated: queried.truncated }
}
}

/// Atomically binds a validated workspace to an idle session. The workspace
/// selector policy and native authority are resolved by the agent RSS entry;
/// this command only merges its display metadata and guards active runs.
Expand Down
37 changes: 37 additions & 0 deletions rss/tools/delegate_acp.rss
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// The native bridge is present only for the ordinary bundled Gateway run.
// A descriptor alone never authorizes external execution.
use agent_runtime;
use self::dispatch as tools;
use self::types as types;

pub fn admitted(registry: array) -> bool {
let mut i: int = 0;
let mut found: bool = false;
while i < registry.length && found == false {
let candidate: map = registry[i];
found = types::map_string(candidate, "name", "") == "delegate_acp";
i += 1;
}
found
}

pub fn invoke(call: map, canonical: string, call_id: string, run_id: string, registry_identity: string) -> map {
let invoked: PinnedToolInvokeResult = agent_runtime::invoke_pinned_tool({
tool_name: "delegate_acp",
call_id: call_id,
canonical_arguments: canonical.copy(),
canonical_input: "",
run_id: run_id,
registry_identity: registry_identity,
argument_digest: canonical,
risk_class: "execute",
summary: "delegate_acp",
untrusted_graph_id: ""
});
let canonical_result: string = invoked.canonical_result.copy();
if canonical_result.length == 0 => {
tools::approval_failure({ call: call }, invoked.code.copy(), invoked.message.copy())
} else => {
tools::result_envelope(call, invoked)
}
}
Loading
Loading