Skip to main content

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

ModeBehavior
offCaps are defined but not enforced. Spend accumulates silently. (Default)
monitorCaps defined; spend is tracked and displayed; no enforcement.
warnAgent receives a warning at warnAtPct of the cap (default 80%). No hard stop.
enforceAgent 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).

FieldWindow
sessionUsd / sessionCallsThe current session (reset on daemon restart)
hourlyUsd / hourlyCallsRolling 60-minute window
dailyUsd / dailyCallsCurrent calendar day (local timezone)
weeklyUsd / weeklyCallsRolling 7-day window
monthlyUsd / monthlyCallsCurrent 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 mirrors budget.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:

LayerWhat it does
RulesInstalls a 10-rule sleep-at-night bundle covering all 10 security categories (see below).
Self-protectionEnsures self-preservation.rules is active so the agent cannot remove ssg itself.
Fail-closedWrites the fail-closed sentinel so that any tool call reaching the hook when the daemon is unreachable is blocked instead of allowed through.
WatchArms 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 IDCategoryDecisionWhat it governs
ssg_sleep_destructive_fsdestructive-opsDENYMass-deletion and disk-overwrite shell commands
ssg_sleep_reverse_shellcode-executionDENYShell patterns that download and immediately execute remote code
ssg_sleep_privilege_escalationprivilege-escalationASKPrivilege-escalation commands (sudo, world-writable chmod, chown root, setcap)
ssg_sleep_credential_accesscredential-accessASKReads of common credential files (.env, .ssh/id_*, .aws/credentials, etc.)
ssg_sleep_network_egressnetwork-egressASKOutbound data-transfer commands (upload flags, scp, tunneling tools)
ssg_sleep_supply_chainsupply-chainASKPackage installs across all major package managers
ssg_sleep_process_persistenceprocess-controlASKPersistence installs and process-kill-all commands
ssg_sleep_vcs_integrityversion-controlDENYDestructive VCS operations (force-push, hard-reset, force-clean, branch force-delete)
ssg_sleep_source_integritysource-integrityASKWrites to CI/CD files and governance config
ssg_sleep_data_handlingdata-handlingASKBulk 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.md
  • memory — 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