feat: parliament seat collaboration loop (0.9.19)

Seats publish via parliament_note, sync pushes on write, member join without
stealing the chair, and worker tools are hard-gated when parliament is active.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
WHC
2026-10-29 11:29:38 +08:00
co-authored by Cursor
parent 1605d74f17
commit 812e3ee265
15 changed files with 532 additions and 83 deletions
+29
View File
@@ -8,6 +8,7 @@
#include "cst_tools.h"
#include "cst_clipboard.h"
#include "cst_parliament.h"
#include "cst_util.h"
#include "tools_internal.h"
@@ -86,6 +87,34 @@ int cst_tool_todo_write(const cst_tool_ctx_t *ctx, const ctl_tool_call_t *c,
return tool_take_buf(r, &b, 0);
}
int cst_tool_parliament_note(const cst_tool_ctx_t *ctx, const ctl_tool_call_t *c,
cst_tool_result_t *r) {
(void)ctx;
if (!cst_parliament_is_active())
return tool_set_result(r, "error: parliament collaboration is not active",
1);
const char *body = tool_arg(c, "note");
if (!body || !body[0])
body = tool_arg(c, "text");
if (!body || !body[0])
return tool_set_result(r, "error: missing note", 1);
const char *kind = tool_arg(c, "kind");
if (!kind || !kind[0])
kind = "status";
char seat[64] = {0};
if (!cst_parliament_session_ok(seat, sizeof(seat)))
snprintf(seat, sizeof(seat), "%s", "anonymous");
if (cst_parliament_context_append(seat, kind, body) != 0)
return tool_set_result(r, "error: failed to append parliament note", 1);
cst_parliament_meta_t m;
memset(&m, 0, sizeof(m));
cst_parliament_load(&m);
return tool_set_resultf(r, 0,
"parliament note published (kind=%s seat=%s rev=%lu); "
"peers will sync on the sealed channel",
kind, seat, m.revision);
}
int cst_tool_ask_user(const cst_tool_ctx_t *ctx, const ctl_tool_call_t *c,
cst_tool_result_t *r) {
const char *q = tool_arg(c, "question");
+19
View File
@@ -10,6 +10,7 @@
#include "cJSON.h"
#include "cst_clipboard.h"
#include "cst_parliament.h"
#include "cst_runtime.h"
#include "cst_tools.h"
#include "cst_util.h"
@@ -166,6 +167,15 @@ static const cst_tool_def_t TOOLS[] = {
NULL,
{{"todos", S, 1, "the whole list, one item per line"}},
CST_TP_META, 0, cst_tool_todo_write, NULL, NO_DYN, NO_META},
{"parliament_note",
"Publish a short note into the shared parliament context so other seats "
"see progress (synced over the sealed peer channel). Use after finishing "
"a block of cross-seat work, when posting agenda, or when handing over. "
"kind: status | agenda | result | handover | note.",
NULL,
{{"note", S, 1, "short note body for other seats"},
{"kind", S, 0, "status|agenda|result|handover|note (default status)"}},
CST_TP_META, 0, cst_tool_parliament_note, NULL, NO_DYN, NO_META},
{"web_search",
"Search the live web through the current Kimi or DeepSeek provider and "
"return titles, URLs and snippets. Use web_fetch to read a result.",
@@ -580,6 +590,15 @@ int cst_tool_active(const cst_agent_config_t *cfg, const cst_tool_def_t *t) {
return 0;
if (cfg->depth > 0 && (!strcmp(t->owner ? t->owner : "", "builtin:runtime") ||
!strncmp(t->name, "worker_", 7))) return 0;
/* Parliament seats coordinate via sealed peer sync, not in-process workers. */
if (cst_parliament_is_active()) {
if (!strcmp(t->name, "task") || !strncmp(t->name, "worker_", 7))
return 0;
if (t->owner && !strcmp(t->owner, "builtin:runtime"))
return 0;
} else if (!strcmp(t->name, "parliament_note")) {
return 0;
}
if (cfg->tools_only[0]) {
char key[CTL_MAX_NAME + 2];
snprintf(key, sizeof(key), ",%s,", t->name);
+2
View File
@@ -44,6 +44,8 @@ int cst_tool_move_file(const cst_tool_ctx_t *ctx, const ctl_tool_call_t *c,
cst_tool_result_t *r);
int cst_tool_todo_write(const cst_tool_ctx_t *ctx, const ctl_tool_call_t *c,
cst_tool_result_t *r);
int cst_tool_parliament_note(const cst_tool_ctx_t *ctx, const ctl_tool_call_t *c,
cst_tool_result_t *r);
int cst_tool_ask_user(const cst_tool_ctx_t *ctx, const ctl_tool_call_t *c,
cst_tool_result_t *r);
/* Clipboard text (system clipboard, not the workspace). */