Konrad, 24.11.: "v1 geht durch ohne irgendwas. ich will auch keine approvals generell. ich will nur das der user mit ask nach sachen gefragt werden kann." Removed the whole approval apparatus, not just the prompt: - agent.c: the decision point (sp_host_gate/approve callbacks), the pause/resume path (has_pending, pending_from, sp_agent_resume), ack_approval, ask_operator and the ack stdin thread are gone. A tool runs; its exit status is the observation. sp_tool_policy (allow/deny per profile) stays - that is the operator's own configuration, not a question to the operator. - engine.c: SP_EV_APPROVAL, sp_engine_approve, the approve_pending condition variable and the `approval`/`approve` protocol commands are gone. - openai_server.c: the v1 endpoint runs gw_* tools without a gate; the autonomous flag is no longer part of sp_gateway_opts. - a2aserver.c: INPUT_REQUIRED and the resume-by-taskId path are gone; CancelTask stays. An A2A caller has no operator sitting in front of a prompt. - mcpserver.c: --autonomous no longer gates mutating tools; the flag and the config key are accepted for compatibility and documented as changing nothing. - telegram.c: tg_approve and the approval callback are gone; ask is the only dialog, and /cancel inside it still ends the turn. - front ends: protocol.c, curses.c, ui_local.c, ui_remote.c, client.c lose the approval event and the waiting flag. - ack.c stays: it is a plugin API (plugins/kids asks its parent through it), not splinter's own gate. --ack is documented as such. Tests: test_pause.c guarded the pause and now guards the opposite (a mutate and a destructive tool run, nothing is asked). test_a2a_input.sh, test_protocol.sh, test_ui.sh, test_agents_ui.sh, test_gateway.sh, test_gateway_openai.sh, test_agent.c and test_mcpsession.sh were rewritten the same way; splinter_approve must now be absent from the MCP tool list. Every rewritten test was run red against the old behaviour where that was possible. make check: all tests passed (428 s) make check-asan: all 47 test binaries clean make check-tsan: all 47 test binaries free of data races
143 lines
3.5 KiB
C
143 lines
3.5 KiB
C
/*
|
|
* splinter -- a mutating tool runs without asking anyone.
|
|
*
|
|
* This test used to guard the opposite: a turn that parked before a mutate
|
|
* tool and waited for an approval, then resumed with a yes or a no. That
|
|
* gate is gone, because it was the program deciding what the operator may
|
|
* do. What stays true, and is guarded here:
|
|
*
|
|
* - a mutate tool the registry offers runs in the same turn, no pause;
|
|
* - a destructive tool runs too;
|
|
* - the turn never returns a "needs a person" code, so no front end has
|
|
* to carry a resume path;
|
|
* - a denial only happens where the operator configured one (the agent's
|
|
* tool policy), never from a built-in prompt.
|
|
*/
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
|
|
#include "splinter.h"
|
|
|
|
static int failures;
|
|
static int ran;
|
|
|
|
#define CHECK(cond) do { \
|
|
if (!(cond)) { \
|
|
fprintf(stderr, "FAIL %s:%d: %s\n", __FILE__, __LINE__, #cond); \
|
|
failures++; \
|
|
} \
|
|
} while (0)
|
|
|
|
static int
|
|
write_tool(const char *args, struct sp_buf *out, void *ctx)
|
|
{
|
|
(void)args;
|
|
(void)ctx;
|
|
ran++;
|
|
return sp_buf_puts(out, "written");
|
|
}
|
|
|
|
static int
|
|
run_turn(struct sp_agent *a, struct sp_conv *conv, struct sp_mock *m,
|
|
struct sp_buf *answer, struct sp_buf *err)
|
|
{
|
|
int rc;
|
|
|
|
sp_conv_init(conv);
|
|
a->conv = conv;
|
|
CHECK(sp_mock_init(m) == 0);
|
|
CHECK(sp_mock_push(m, 200, "tool write x") == 0);
|
|
CHECK(sp_mock_push(m, 200, "answer done") == 0);
|
|
a->tr = sp_mock_transport(m);
|
|
sp_buf_clear(answer);
|
|
rc = sp_agent_run(a, "go", answer, err);
|
|
return rc;
|
|
}
|
|
|
|
int
|
|
main(void)
|
|
{
|
|
struct sp_registry r;
|
|
struct sp_tool t;
|
|
struct sp_agent a;
|
|
struct sp_agent_config cfg;
|
|
struct sp_conv conv;
|
|
struct sp_mock m;
|
|
struct sp_buf answer, err;
|
|
int rc;
|
|
|
|
memset(&r, 0, sizeof(r));
|
|
memset(&t, 0, sizeof(t));
|
|
t.name = "write";
|
|
t.description = "mutate";
|
|
t.auth = SP_AUTH_MUTATE;
|
|
t.run = write_tool;
|
|
CHECK(sp_registry_add(&r, &t) == 0);
|
|
|
|
memset(&t, 0, sizeof(t));
|
|
t.name = "rm";
|
|
t.description = "destructive";
|
|
t.auth = SP_AUTH_DESTRUCTIVE;
|
|
t.run = write_tool;
|
|
CHECK(sp_registry_add(&r, &t) == 0);
|
|
|
|
memset(&a, 0, sizeof(a));
|
|
memset(&cfg, 0, sizeof(cfg));
|
|
cfg.max_steps = 5;
|
|
a.reg = &r;
|
|
a.cfg = &cfg;
|
|
CHECK(sp_buf_init(&answer) == 0);
|
|
CHECK(sp_buf_init(&err) == 0);
|
|
|
|
/* a mutate tool runs in the same turn: no pause, no question, and the
|
|
* model sees its observation before it answers */
|
|
ran = 0;
|
|
rc = run_turn(&a, &conv, &m, &answer, &err);
|
|
CHECK(rc == 0);
|
|
CHECK(ran == 1);
|
|
CHECK(strcmp(answer.p, "done") == 0);
|
|
CHECK(strstr(m.last_request.p, "observe write written") != NULL);
|
|
CHECK(strstr(m.last_request.p, "denied") == NULL);
|
|
sp_mock_free(&m);
|
|
sp_conv_free(&conv);
|
|
|
|
/* a destructive tool runs too: the operator decides what the agent may
|
|
* reach by what is in the registry, not by answering a prompt */
|
|
ran = 0;
|
|
CHECK(run_turn(&a, &conv, &m, &answer, &err) == 0);
|
|
CHECK(ran == 1);
|
|
sp_mock_free(&m);
|
|
sp_conv_free(&conv);
|
|
|
|
/*
|
|
* The one denial that stays is the operator's own tool policy: a
|
|
* profile that says "read only" is a configuration, not a prompt.
|
|
*/
|
|
memset(&a, 0, sizeof(a));
|
|
memset(&cfg, 0, sizeof(cfg));
|
|
cfg.max_steps = 5;
|
|
a.reg = &r;
|
|
a.cfg = &cfg;
|
|
ran = 0;
|
|
{
|
|
struct sp_tool_policy pol;
|
|
|
|
memset(&pol, 0, sizeof(pol));
|
|
pol.max_auth = SP_AUTH_READ;
|
|
a.policy = &pol;
|
|
CHECK(run_turn(&a, &conv, &m, &answer, &err) == 0);
|
|
CHECK(ran == 0);
|
|
CHECK(strstr(m.last_request.p, "denied") != NULL);
|
|
sp_mock_free(&m);
|
|
sp_conv_free(&conv);
|
|
}
|
|
|
|
sp_buf_free(&answer);
|
|
sp_buf_free(&err);
|
|
sp_registry_free(&r);
|
|
|
|
if (failures == 0)
|
|
printf("test_pause: ok\n");
|
|
return failures == 0 ? 0 : 1;
|
|
}
|