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
+22 -1
View File
@@ -31,26 +31,47 @@ int cst_parliament_save(const cst_parliament_meta_t *m);
char *cst_parliament_login(const char *password, const char *instance_id,
const char *device_label, char *err, size_t err_sz);
/* Join as a peer seat without stealing the chair (claims only if vacant).
* Returns JOIN_OK summary (malloc'd) or NULL. */
char *cst_parliament_seat_join(const char *password, const char *instance_id,
const char *device_label, char *err,
size_t err_sz);
/* Only one chair: previous chair is demoted; handover notes left in meta. */
int cst_parliament_claim_chair(const char *instance_id, const char *device_label);
/* Probe local environment as device-private context (malloc'd text). */
char *cst_parliament_device_context(void);
/* Prefer CST_INSTANCE_ID, else sanitized hostname (never empty). */
int cst_parliament_default_instance(char *out, size_t n);
/* New project: wipe shared parliament context; keep Realm keys. */
int cst_parliament_new_project(const char *project_id);
/* Resolve collaboration mode: env CST_COLLABORATION, then settings,
* then password-Realm with an open parliament → "parliament". */
int cst_parliament_is_active(void);
/* 1 when the local seat ticket matches the current chair. */
int cst_parliament_is_chair(void);
/* Short status lines for TUI/CLI (malloc'd; caller frees). */
char *cst_parliament_status_text(void);
/* Append/replace synchronized context blob (all agents share this file). */
int cst_parliament_context_put(const char *text);
char *cst_parliament_context_get(void);
/* Append a structured seat note and bump revision (triggers peer sync).
* kind: status | agenda | result | handover | note */
int cst_parliament_context_append(const char *seat_id, const char *kind,
const char *body);
/* Local login ticket: opens require a fresh chair session (or password env). */
/* Ask the local parliament service to dial peers soon (best-effort). */
void cst_parliament_sync_request(void);
int cst_parliament_sync_pending(void);
void cst_parliament_sync_ack(void);
/* Local login ticket: opens require a fresh seat session (or password env).
* Any enrolled seat may hold a ticket; chair is tracked separately in meta. */
int cst_parliament_session_write(const char *instance_id);
int cst_parliament_session_ok(char *instance_id_out, size_t n);
void cst_parliament_session_clear(void);