delegates and cli_env: hardcoded environment per cli program; swarm, provider, planner, scheduler, tmux
env=NAME=VALUE on a delegate line (repeatable) is set in the child right before exec and beats what the parent exported, so two delegates can run the same cli with two accounts. Remotely it goes in front as `env 'NAME=VALUE'`, quoted like the rest. cli_env = NAME=VALUE does the same for the main cli transport. A bad name is an error with the line. Also in this commit, the work in progress from the tree: swarm and provider state, the provider/scheduler/planner/tmux plugins, the ui test, whose tmux session name is now per run so parallel runs do not collide. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
25a616a87f
commit
75d8beeaa4
44 files changed
+5721
-1674
No files matched your search
@@ -150,6 +150,14 @@ int sp_host_add_gate(struct sp_host *, const struct sp_gate *);
|
||||
int sp_host_add_status(struct sp_host *, const struct sp_status *);
|
||||
const struct sp_meter *sp_host_meter(struct sp_host *);
|
||||
void sp_host_set_meter(struct sp_host *, const struct sp_meter *);
|
||||
/*
|
||||
* Thread-safe: a copy under the host lock, and a change of only the caller's
|
||||
* fields under the lock. Use these from any thread but the UI's; the two above
|
||||
* remain for the UI thread and for reading a single field.
|
||||
*/
|
||||
void sp_host_meter_get(struct sp_host *, struct sp_meter *out);
|
||||
void sp_host_meter_update(struct sp_host *,
|
||||
void (*fn)(struct sp_meter *, void *), void *ctx);
|
||||
size_t sp_host_status_text(struct sp_host *, char *buf, size_t len);
|
||||
void sp_host_set_task_ops(struct sp_host *, const struct sp_task_ops *);
|
||||
int sp_host_task_begin(struct sp_host *, const char *label, const char *detail);
|
||||
@@ -166,6 +174,46 @@ size_t sp_host_command_help(struct sp_host *, struct sp_buf *out);
|
||||
int sp_host_add_transport(struct sp_host *, const char *name,
|
||||
struct sp_transport);
|
||||
struct sp_transport *sp_host_transport(struct sp_host *, const char *name);
|
||||
|
||||
/* ---- provider: quota/usage/burst policy, pluggable (per key, shared state) ---- */
|
||||
enum sp_prov_decision { SP_PROV_ADMIT = 0, SP_PROV_DELAY, SP_PROV_WAIT_QUOTA, SP_PROV_DENY };
|
||||
struct sp_prov_result {
|
||||
enum sp_prov_decision decision;
|
||||
long retry_after_s; /* seconds to wait (DELAY) */
|
||||
long ready_at; /* unix timestamp when quota/backoff ends (WAIT_QUOTA) */
|
||||
char reason[256];
|
||||
};
|
||||
struct sp_provider_ops {
|
||||
void *ctx;
|
||||
int (*preflight)(void *ctx, const char *provider, const char *key_id,
|
||||
struct sp_prov_result *out);
|
||||
void (*account)(void *ctx, const char *provider, const char *key_id,
|
||||
long http_status, size_t tokens_in, size_t tokens_out);
|
||||
};
|
||||
void sp_host_set_provider(struct sp_host *, const struct sp_provider_ops *);
|
||||
enum sp_prov_decision sp_host_provider_preflight(struct sp_host *, const char *provider,
|
||||
const char *key_id, struct sp_prov_result *out);
|
||||
void sp_host_provider_account(struct sp_host *, const char *provider, const char *key_id,
|
||||
long http_status, size_t tokens_in, size_t tokens_out);
|
||||
|
||||
/* shared per-(provider,key_id) usage/quota state (~/.splinter/providers/...), flock+atomic.
|
||||
* Provider plugins use this for cross-instance, per-key tracking. */
|
||||
struct sp_prov_state {
|
||||
long quota_ready_at; long backoff_until;
|
||||
unsigned req_count; unsigned long tok_in, tok_out;
|
||||
long last_status, last_update, last_429_at;
|
||||
char note[128];
|
||||
};
|
||||
int sp_provstate_load(const char *provider, const char *key_id, struct sp_prov_state *out);
|
||||
int sp_provstate_update(const char *provider, const char *key_id,
|
||||
void (*fn)(struct sp_prov_state *s, void *ctx), void *ctx);
|
||||
void sp_provstate_account(const char *provider, const char *key_id,
|
||||
long http_status, size_t tok_in, size_t tok_out, long retry_after_s);
|
||||
int sp_provstate_preflight(const char *provider, const char *key_id,
|
||||
long now, long *ready_at, char *reason, size_t reason_cap);
|
||||
/* Stable fingerprint of a secret key (never stores/returns the secret). */
|
||||
char *sp_key_fingerprint(const char *secret, char *buf, size_t cap);
|
||||
|
||||
int sp_host_compact(struct sp_host *, struct sp_conv *, size_t budget);
|
||||
size_t sp_host_compaction_stats(struct sp_host *, size_t *compactions,
|
||||
size_t *failed, unsigned *turns);
|
||||
@@ -180,6 +228,11 @@ struct sp_registry *sp_host_registry(struct sp_host *);
|
||||
struct sp_host *sp_host_new(struct sp_registry *, struct sp_agent *,
|
||||
struct sp_session_info *);
|
||||
void sp_host_free(struct sp_host *);
|
||||
const char *sp_host_session_dir(struct sp_host *);
|
||||
/* Retry a durable delegation job (scheduler/worker). 0 on handled (see out). */
|
||||
int sp_delegate_retry_job(const char *id, int force, struct sp_buf *out);
|
||||
/* Scheduler tick: retry one due waiting_quota/waiting_poll job if any. */
|
||||
int sp_delegate_tick(struct sp_buf *out);
|
||||
int sp_plugin_load(struct sp_host *, const char *path,
|
||||
struct sp_buf *err);
|
||||
size_t sp_host_widget_snapshot(struct sp_host *, char *buf, size_t len);
|
||||
|
||||
Reference in new issue
Block a user