feat: parliament daemon, login gate, peer context sync (0.9.13)

Login claims the chair, writes a session ticket, and starts a background
service for discovery plus revision-based context sync. Password Realm
opens require --login (or CST_REALM_PASSWORD); --service/--service-stop
manage the resident agent.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
WHC
2026-10-28 23:11:23 +08:00
co-authored by Cursor
parent de9ee28773
commit e853abac5e
13 changed files with 769 additions and 12 deletions
+22
View File
@@ -44,6 +44,28 @@ int cst_parliament_new_project(const char *project_id);
int cst_parliament_context_put(const char *text);
char *cst_parliament_context_get(void);
/* Local login ticket: opens require a fresh chair session (or password env). */
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);
/* Apply a peer sync bundle (higher revision already selected by caller). */
int cst_parliament_apply_sync(unsigned long revision, const char *parliament_id,
const char *project_id, const char *chair,
const char *context);
/* Background parliament service: discover + peer listen + context sync. */
int cst_parliament_daemon_pidfile(char *out, size_t n);
int cst_parliament_daemon_running(void);
/* Start in background (Unix fork). password unlocks Realm in the child.
* Returns 0 and writes pid. If already running, returns 0. */
int cst_parliament_daemon_start(const char *password, const char *instance_id,
int peer_port, char *err, size_t err_sz);
int cst_parliament_daemon_stop(void);
/* Foreground service loop (used by --service and the forked child). */
int cst_parliament_daemon_run(const char *password, const char *instance_id,
int peer_port, char *err, size_t err_sz);
#ifdef __cplusplus
}
#endif