Spending Limits and Sleep at Night
Spending limits
Spending limits let you cap how much an AI agent can spend — in dollars and in tool-call volume — across five time windows. The feature is separate from governance rules; it operates at the accounting layer, tracking cost from the cost_ledger SQLite table, and enforcing caps before a rule is even evaluated.
Modes
| Mode | Behavior |
|---|---|
off | Caps are defined but not enforced. Spend accumulates silently. (Default) |
monitor | Caps defined; spend is tracked and displayed; no enforcement. |
warn | Agent receives a warning at warnAtPct of the cap (default 80%). No hard stop. |
enforce | Agent is blocked when any cap is reached. |
Set the mode from the dashboard Spending page, or by editing ~/.sigmashake/budget.json directly and restarting the daemon.
Cap windows
Each cap can be set globally (all agents combined) or per-client (by client identifier such as claude-code or cursor).
| Field | Window |
|---|---|
sessionUsd / sessionCalls | The current session (reset on daemon restart) |
hourlyUsd / hourlyCalls | Rolling 60-minute window |
dailyUsd / dailyCalls | Current calendar day (local timezone) |
weeklyUsd / weeklyCalls | Rolling 7-day window |
monthlyUsd / monthlyCalls | Current calendar month (local timezone) |
A null cap means no limit for that window.
Configuration file
Caps are stored at ~/.sigmashake/budget.json. Example:
{
"mode": "enforce",
"warnAtPct": 0.8,
"global": {
"dailyUsd": 5.00,
"monthlyUsd": 50.00,
"dailyCalls": 2000
},
"perClient": {
"claude-code": {
"hourlyUsd": 1.00
}
},
"updatedAt": 1748900000000
}
API
The daemon exposes the budget over its JSON API:
GET /api/json/budget— read the current config and live spend snapshot.POST /api/json/budget— update the config. Accepted body shape mirrorsbudget.json.
Sleep at Night
Sleep at Night is a one-click, zero-configuration maximum-protection state. It arms every available defense layer simultaneously so you can leave an autonomous agent running overnight without worrying about what it might do.
What it arms
Activating Sleep at Night writes and enables the following layers:
| Layer | What it does |
|---|---|
| Rules | Installs a 10-rule sleep-at-night bundle covering all 10 security categories (see below). |
| Self-protection | Ensures self-preservation.rules is active so the agent cannot remove ssg itself. |
| Fail-closed | Writes the fail-closed sentinel so that any tool call reaching the hook when the daemon is unreachable is blocked instead of allowed through. |
| Watch | Arms a continuous rule-reload loop so new rules take effect without a daemon restart. |
When you disarm Sleep at Night, self-protection is intentionally left on — it is an independent baseline, not a Sleep at Night exclusive.
The 10-rule bundle
The bundle covers all 10 security categories that ssg recognizes:
| Rule ID | Category | Decision | What it governs |
|---|---|---|---|
ssg_sleep_destructive_fs | destructive-ops | DENY | Mass-deletion and disk-overwrite shell commands |
ssg_sleep_reverse_shell | code-execution | DENY | Shell patterns that download and immediately execute remote code |
ssg_sleep_privilege_escalation | privilege-escalation | ASK | Privilege-escalation commands (sudo, world-writable chmod, chown root, setcap) |
ssg_sleep_credential_access | credential-access | ASK | Reads of common credential files (.env, .ssh/id_*, .aws/credentials, etc.) |
ssg_sleep_network_egress | network-egress | ASK | Outbound data-transfer commands (upload flags, scp, tunneling tools) |
ssg_sleep_supply_chain | supply-chain | ASK | Package installs across all major package managers |
ssg_sleep_process_persistence | process-control | ASK | Persistence installs and process-kill-all commands |
ssg_sleep_vcs_integrity | version-control | DENY | Destructive VCS operations (force-push, hard-reset, force-clean, branch force-delete) |
ssg_sleep_source_integrity | source-integrity | ASK | Writes to CI/CD files and governance config |
ssg_sleep_data_handling | data-handling | ASK | Bulk database mutations (schema drops, table truncations, unguarded mass deletes) |
Activating
Via the dashboard: click the Sleep at Night toggle on the main dashboard.
Via the API:
# Arm indefinitely
curl -X POST http://127.0.0.1:5599/api/json/sleep-mode \
-H "Content-Type: application/json" \
-H "X-SigmaShake-Token: <your-token>" \
-d '{"enabled": true}'
# Arm for 8 hours (28,800,000 ms), then auto-stand-down
curl -X POST http://127.0.0.1:5599/api/json/sleep-mode \
-H "Content-Type: application/json" \
-H "X-SigmaShake-Token: <your-token>" \
-d '{"enabled": true, "forMs": 28800000}'
# Disarm
curl -X POST http://127.0.0.1:5599/api/json/sleep-mode \
-H "Content-Type: application/json" \
-H "X-SigmaShake-Token: <your-token>" \
-d '{"enabled": false}'
# Check current state
curl http://127.0.0.1:5599/api/json/sleep-mode \
-H "X-SigmaShake-Token: <your-token>"
The forMs parameter accepts up to 30 days (2,592,000,000 ms). When the window elapses, the state is lazily marked inactive and the layers are torn down on the next API call.
State file
Sleep at Night state is persisted at ~/.sigmashake/sleep-mode.json. Do not edit it directly; use the API or dashboard toggle.
Limitations
The Go daemon implements the following layers: rules, selfProtection, failClosed, watch. Two layers from the TypeScript daemon are not yet ported to the Go runtime:
instructionFiles— writing a managed guardrail block into CLAUDE.md/AGENTS.md/GEMINI.mdmemory— recording a protective ssg ambient-memory note
Both are reported as 0/false in the API response when the Go daemon is active. The core protection (the 10-rule bundle + fail-closed + self-preservation) is fully operative on all platforms.
See also
- Policy Profiles — machine-wide named presets that complement project rules
- Plans and Limits — subscription requirements and usage reporting