Files
splinter/tests/test_planner.c
T
lotherk 0576d21924 open points: tables, counted site, and the tests the list asked for
Markdown tables are drawn as columns now (src/md.c, test_md, and a case in
test_ui.sh that checks the screen). The site counts lines, tools, tests,
plugins and palettes from the tree instead of naming them; the binary-size
figure is gone because it aged with every build.

The delegate panel cycle has a test (host + tasks plugin, widget says
delegate:panel exit 0), and the turn loop is driven with lcm at 8 KiB and
32 KiB budgets, so compaction is measured rather than claimed.

swarm, provstate and planner get smoke tests. TODO.md is rewritten against
the tree: the step limit was the old default (8 -> 150), skills and memory
were already built, and the open points are claude exit 2, a real Telegram
approval, A2A, the npm leftovers and the scheduler/job tests.
2026-11-09 22:46:25 +00:00

108 lines
2.8 KiB
C

/*
* splinter -- planner plugin smoke test.
*
* The plan belongs to the session: the tools add, list and update tasks, the
* list is on disk, and a second reader sees the same file. This is not the
* background-task store; that one owns processes.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "splinter.h"
#include "splinter_plugin.h"
static int failures;
#define CHECK(cond) do { \
if (!(cond)) { \
fprintf(stderr, "FAIL %s:%d: %s\n", __FILE__, __LINE__, #cond); \
failures++; \
} \
} while (0)
int
main(void)
{
struct sp_session_info sess;
struct sp_registry reg;
struct sp_agent ag;
struct sp_host *host;
struct sp_buf out, err;
const struct sp_tool *t;
char dir[] = "/tmp/splinter-plan-XXXXXX";
char path[600], snap[512], text[2048];
FILE *f;
size_t n;
CHECK(mkdtemp(dir) != NULL);
memset(&sess, 0, sizeof(sess));
snprintf(sess.dir, sizeof(sess.dir), "%s", dir);
memset(&reg, 0, sizeof(reg));
memset(&ag, 0, sizeof(ag));
CHECK(sp_buf_init(&out) == 0);
CHECK(sp_buf_init(&err) == 0);
host = sp_host_new(&reg, &ag, &sess);
CHECK(host != NULL);
CHECK(sp_plugin_load(host, "plugins/planner/planner.so", &err) == 0);
t = sp_registry_find(&reg, "plan_task_add");
CHECK(t != NULL);
if (t != NULL)
(void)t->run("{\"description\":\"write the planner test\"}",
&out, t->ctx);
CHECK(out.p != NULL && strstr(out.p, "added plan task #1") != NULL);
sp_buf_clear(&out);
t = sp_registry_find(&reg, "plan_task_list");
CHECK(t != NULL);
if (t != NULL)
(void)t->run("{}", &out, t->ctx);
CHECK(out.p != NULL &&
strstr(out.p, "write the planner test") != NULL);
CHECK(out.p != NULL && strstr(out.p, "[todo]") != NULL);
sp_buf_clear(&out);
t = sp_registry_find(&reg, "plan_task_update");
CHECK(t != NULL);
if (t != NULL)
(void)t->run("{\"id\":\"1\",\"status\":\"doing\"}", &out,
t->ctx);
CHECK(out.p != NULL && strstr(out.p, "[doing]") != NULL);
/* the command path is the same store */
sp_buf_clear(&out);
CHECK(sp_host_command(host, "tasks", "ls", &out) == 0);
CHECK(out.p != NULL &&
strstr(out.p, "write the planner test") != NULL);
/* the file is the contract: a second reader sees it */
snprintf(path, sizeof(path), "%s/plan_tasks.json", dir);
f = fopen(path, "r");
CHECK(f != NULL);
if (f != NULL) {
n = fread(text, 1, sizeof(text) - 1, f);
text[n] = '\0';
fclose(f);
CHECK(strstr(text, "write the planner test") != NULL);
CHECK(strstr(text, "\"doing\"") != NULL);
}
n = sp_host_widget_snapshot(host, snap, sizeof(snap));
CHECK(n > 0);
CHECK(strstr(snap, "plan:") != NULL);
sp_host_free(host);
sp_registry_free(&reg);
sp_buf_free(&out);
sp_buf_free(&err);
snprintf(path, sizeof(path), "rm -rf '%s'", dir);
(void)system(path);
if (failures == 0)
printf("test_planner: ok\n");
return failures == 0 ? 0 : 1;
}