You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: charter.default.yaml
+7-1Lines changed: 7 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -28,6 +28,9 @@ core_competencies:
28
28
- name: write_post
29
29
description: Draft social posts for platforms (X/LinkedIn/etc.) with variations and CTA
30
30
priority: 6
31
+
- name: help_docs
32
+
description: "Help center and product docs: FAQ entries, in-app tooltips, getting started guides; tone helpful, no jargon"
33
+
priority: 6
31
34
- name: meeting_minutes
32
35
description: "Turn transcripts into meeting minutes: decisions, action items, risks, open questions"
33
36
priority: 6
@@ -56,17 +59,20 @@ core_competencies:
56
59
description: Review code for issues, style, and best practices; output only, no execution
57
60
priority: 6
58
61
62
+
# CFO profitability: reject jobs where estimated cost would exceed (1 - min_job_margin_ratio) of revenue.
63
+
# 0.2 = 20% minimum gross margin (cost must be <= 80% of job price). Set to 0 to disable.
59
64
fiscal_boundaries:
60
65
daily_burn_max_usd: 50.00
61
66
max_budget_usd: 2000.00
62
67
currency: USD
68
+
min_job_margin_ratio: 0.2
63
69
64
70
success_kpis:
65
71
- name: task_completion_rate
66
72
metric: tasks_verified_ok
67
73
target_value: 0.95
68
74
unit: ratio
69
-
verification_prompt: "Did the output satisfy the task success criteria?"
75
+
verification_prompt: "Is the output non-empty, on-topic, and a reasonable response to the task? Pass (true) unless the output is clearly off-topic, empty, or nonsensical."
Sovereign-OS applies **top-company CEO/CFO practices** so the system has real economic discipline: it rejects unprofitable jobs and respects margin floors.
4
+
5
+
## Principles (from top-company practice)
6
+
7
+
-**Unit economics**: Every paid job has revenue (job price) and cost (estimated task execution). Gross margin = (revenue - cost) / revenue. Top companies (e.g. SaaS, hyperscalers) target high gross margins and enforce **minimum margin floors** so they do not accept loss-making deals.
8
+
-**CFO guardrails**: CFOs use metrics like gross margin, runway, and burn rate. Here, the CFO enforces:
9
+
-**Budget**: Balance and daily burn cap (existing behavior).
10
+
-**Profitability**: For each paid job, estimated cost must not exceed `revenue × (1 - min_job_margin_ratio)`. So a 20% margin floor means cost ≤ 80% of revenue; otherwise the job is rejected.
11
+
-**CEO–CFO alignment**: The CEO (Strategist) produces the plan and cost estimate; the CFO (Treasury) checks both liquidity and **per-job unit economics**. If the plan would make the job unprofitable, the CFO aborts before any spend.
12
+
13
+
## How it works in Sovereign-OS
14
+
15
+
1.**Charter** (`fiscal_boundaries.min_job_margin_ratio`): Optional, 0–1. Example: `0.2` = 20% minimum gross margin (cost must be ≤ 80% of job revenue). Set to `0` to disable (only balance/daily cap apply).
16
+
2.**When a job runs**: The app passes `job.amount_cents` (revenue) into `run_mission_with_audit(..., job_revenue_cents=job.amount_cents)`.
17
+
3.**After the CEO plan**: The engine sums `total_estimated_cents` (cost). The CFO then runs `approve_job_profitability(job_revenue_cents, total_estimated_cents)`. If `total_estimated_cents > job_revenue_cents × (1 - min_job_margin_ratio)`, it raises `UnprofitableJobError` and the job is not executed.
18
+
4.**UI**: If the job is rejected for profitability, the Decision stream shows a CFO message and the job status is set to failed with a clear error.
19
+
20
+
## Configuration
21
+
22
+
In your Charter YAML (e.g. `charter.default.yaml`):
23
+
24
+
```yaml
25
+
fiscal_boundaries:
26
+
daily_burn_max_usd: 50.00
27
+
max_budget_usd: 2000.00
28
+
currency: USD
29
+
min_job_margin_ratio: 0.2# 20% min margin; reject job if cost > 80% of revenue
30
+
```
31
+
32
+
- `min_job_margin_ratio: 0` — profitability check disabled; only balance and daily cap apply.
33
+
- `min_job_margin_ratio: 0.2` — 20% margin floor (typical for many B2B / services).
- CEO plan: 2 tasks, total estimated cost 7000 cents.
40
+
- Margin = (8000 - 7000) / 8000 = 12.5%.
41
+
- If `min_job_margin_ratio: 0.2`, then 12.5% < 20% → CFO rejects the job as unprofitable.
42
+
43
+
So the system **only runs paid jobs that meet the configured margin floor**, giving it a real “economic brain” aligned with how top-company CEOs and CFOs think about profitability.
Copy file name to clipboardExpand all lines: docs/CONFIG.md
+21-3Lines changed: 21 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -19,6 +19,7 @@ All optional unless noted. Set in the shell, `.env`, or your process manager (e.
19
19
|`SOVEREIGN_JOB_RATE_LIMIT_PER_MIN`| If set (e.g. `60`), limits how many `POST /api/jobs` requests each client IP can make per minute; returns 429 when exceeded. |
20
20
|`SOVEREIGN_JOB_MAX_RETRIES`| Max retries for a single job via `POST /api/jobs/{id}/retry` (default `2`). Only `failed` / `payment_failed` jobs are retryable. |
21
21
|`SOVEREIGN_JOB_WORKER_CONCURRENCY`| Max jobs run in parallel by the worker (default `1`). Set to `2` or more for higher throughput. |
22
+
|`SOVEREIGN_JOB_WORKER_ENABLED`| When set to `false` (or `0`/`off`/`no`), the job worker thread is **not** started. No jobs run until you set it back to `true` and restart. Use to pause execution and avoid API cost. Default `true`. |
22
23
|`SOVEREIGN_JOB_IP_WHITELIST`| Optional. Comma-separated IPs allowed to call `POST /api/jobs` and `POST /api/jobs/batch`; others get 403. |
23
24
| (none) | Web UI: `GET /` (dashboard), `GET /health`, `GET /docs` (FastAPI Swagger). Dashboard shows “Auto-approve ON” / “Compliance auto ON” when those env vars are set. |
24
25
@@ -32,8 +33,11 @@ The Web process is designed for **24/7** operation: a background thread continuo
32
33
33
34
| Variable | Description |
34
35
|----------|-------------|
35
-
|`SOVEREIGN_INGEST_URL`| JSON URL to poll for new jobs. Response: array or `{ "jobs": [...] }` with `goal`, optional `charter`, `amount_cents`, `currency`. |
36
-
|`SOVEREIGN_INGEST_INTERVAL_SEC`| Polling interval in seconds (default `60`). |
36
+
|`SOVEREIGN_INGEST_URL`| JSON URL to poll for new jobs. Response: array or `{ "jobs": [...] }` with `goal`, optional `charter`, `amount_cents`, `currency`. For demo: run `python scripts/serve_demo_orders.py` and set `http://localhost:8765/jobs?limit=3` to pull only 3 jobs from `examples/ingest_demo_orders.json`. If unset, no automatic intake. |
37
+
|`SOVEREIGN_INGEST_ENABLED`| When set to `false` (or `0`/`off`/`no`), the ingest poller is **not** started even if `SOVEREIGN_INGEST_URL` is set. Use to stop automatic "接单" and reduce API cost. Default `true` when URL is set. |
38
+
|`SOVEREIGN_INGEST_ONCE`| When set to `true` (or `1`/`yes`), the poller **fetches once** and then stops (no repeated polling). Use for demo: one pull, no loop. |
39
+
|`SOVEREIGN_INGEST_INTERVAL_SEC`| Polling interval in seconds (default `60`). Ignored when `SOVEREIGN_INGEST_ONCE=true`. |
40
+
|`SOVEREIGN_INGEST_MAX_JOBS_PER_POLL`| If set (e.g. `1` or `2`), at most this many jobs are enqueued per poll. Use to cap token rate when the ingest URL returns many jobs (see [TOKEN_SPIKE_INVESTIGATION.md](TOKEN_SPIKE_INVESTIGATION.md)). Default `0` = no cap. |
37
41
|`SOVEREIGN_INGEST_DEDUP_SEC`| If set (e.g. `300`), the ingest poller will not enqueue a job when one with the same `goal` and `amount_cents` was already created within this many seconds. Reduces duplicate jobs from repeated polling. |
38
42
39
43
## Audit trail (verifiable)
@@ -49,11 +53,21 @@ The Web process is designed for **24/7** operation: a background thread continuo
49
53
|`SOVEREIGN_COMPLIANCE_SPEND_THRESHOLD_CENTS`| If set to a positive number, the Web UI engine uses `ThresholdComplianceHook`: when a task’s estimated cost (cents) is ≥ this value, the job is put back to `pending` with “Human approval required” until a second approval. See [MONETIZATION.md](MONETIZATION.md) and [PHASE6.md](PHASE6.md). |
50
54
|`SOVEREIGN_COMPLIANCE_AUTO_PROCEED`| When set to `true` (or `1`/`yes`), the CFO does **not** require human approval when the compliance hook returns “request human approval” for spend above the threshold; the task is allowed to proceed (human-out-of-loop for high spend). Use only when you accept the risk. |
51
55
56
+
## Controlling API cost (avoid jobs running / 接单 non-stop)
57
+
58
+
To avoid high LLM/API usage:
59
+
60
+
1.**Turn off auto-approve** – Do **not** set `SOVEREIGN_AUTO_APPROVE_JOBS=true`. New jobs stay `pending` until you click Approve in the Dashboard, so you control when each job runs.
61
+
2.**Stop automatic intake** – Unset `SOVEREIGN_INGEST_URL`, or set `SOVEREIGN_INGEST_ENABLED=false` so the ingest poller does not start. Otherwise the system keeps pulling jobs from the URL.
62
+
3.**Pause all job execution** – Set `SOVEREIGN_JOB_WORKER_ENABLED=false`. The job worker thread will not start; no jobs run until you set it back to `true` and restart.
63
+
64
+
Startup logs will warn when auto-approve or ingest is on so you can adjust.
65
+
52
66
## Human out of loop
53
67
54
68
| Variable | Description |
55
69
|----------|-------------|
56
-
|`SOVEREIGN_AUTO_APPROVE_JOBS`| When set to `true` (or `1`/`yes`), every new job (from `POST /api/jobs` or ingest) is immediately set to `approved` so the worker runs it without a human clicking Approve. Full **human-out-of-loop**: ingest → auto-approve → run → charge → webhook. |
70
+
|`SOVEREIGN_AUTO_APPROVE_JOBS`| When set to `true` (or `1`/`yes`), every new job (from `POST /api/jobs` or ingest) is immediately set to `approved` so the worker runs it without a human clicking Approve. Full **human-out-of-loop**: ingest → auto-approve → run → charge → webhook. **Leave unset/false to approve manually and control cost.**|
57
71
|`SOVEREIGN_COMPLIANCE_AUTO_PROCEED`| See Compliance above. Together with `SOVEREIGN_AUTO_APPROVE_JOBS`, both gates can be automated. |
@@ -64,6 +78,9 @@ The Web process is designed for **24/7** operation: a background thread continuo
64
78
|`SOVEREIGN_WEBHOOK_SECRET`| If set, the request body is signed with HMAC-SHA256 and sent in header `X-Sovereign-Signature: sha256=<hex>`. Receivers should verify this. |
65
79
|`SOVEREIGN_WEBHOOK_LOG_PATH`| If set (default `data/webhook_log.jsonl` when logging is enabled), failed webhook deliveries (after all retries) are appended as one JSONL line per failure (url, job_id, status, error, ts). |
66
80
| Per-job `callback_url`| In `POST /api/jobs` body you can pass `callback_url`; when that job completes, the webhook is sent to this URL instead of (or in addition to) the global `SOVEREIGN_WEBHOOK_URL`. |
81
+
| Per-job `delivery_contact`| Optional. Dict e.g. `{"platform":"reddit","username":"x","post_id":"y","permalink":"/r/..."}`. When the job completes, the result can be posted back (e.g. Reddit comment on the post). See [DEMO_TASK_POSTS.md](DEMO_TASK_POSTS.md). |
82
+
|`REDDIT_CLIENT_ID`, `REDDIT_CLIENT_SECRET`, `REDDIT_USER_AGENT`| Required for Reddit delivery (post comment with result). Same app as ingest or any Reddit app. |
83
+
|`REDDIT_REFRESH_TOKEN`**or**`REDDIT_USERNAME` + `REDDIT_PASSWORD`| Reddit OAuth2 refresh token (preferred) or script-app credentials so the process can post the delivery comment. |
67
84
| (payload) | Each job gets a `request_id` (trace id) at creation; it is included in the webhook payload when set, for correlating logs and delivery. |
68
85
69
86
Payload format and retries: see [OPEN_SOURCE_READY_PLAN.md](OPEN_SOURCE_READY_PLAN.md) (Webhook payload spec). Typical use: your backend receives the webhook and then notifies the customer (email, Slack, etc.).
@@ -104,6 +121,7 @@ For **real** orders from Reddit, scraped sites, or Shopify/WooCommerce, run the
104
121
105
122
- **Bridge:** `python -m sovereign_os.ingest_bridge` (optional deps: `pip install praw requests beautifulsoup4` or `pip install -e ".[bridge]"`).
106
123
- **Sovereign-OS:** Set `SOVEREIGN_INGEST_URL=http://<bridge>:9000/jobs?take=true` and optional `SOVEREIGN_INGEST_INTERVAL_SEC`, `SOVEREIGN_AUTO_APPROVE_JOBS=true`.
124
+
- **Bridge config:** Optional `BRIDGE_CONFIG_PATH` points to a YAML file to overlay env (see [INGEST_BRIDGE.md](INGEST_BRIDGE.md)).
0 commit comments