agent-runtime-invariants

A set of rules for an agent runtime, the part of an agent that manages files, settings, queues, and audit events. It requires platform-specific paths, upload filtering before events are sent, and audit records that preserve empty values.

In plain words
What is it for?
Use it when changing agent file paths, traffic-upload settings, event publishing, or audit stamping.
Why use it?
It avoids broken file locations across operating systems and prevents unnecessary event uploads while keeping important blocked or failed actions auditable.

Cursor rule for Cursor

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add rules/alphabitcore/nexus-gateway/agent-runtime-invariants
Clone the repo
git clone --depth 1 https://github.com/AlphaBitCore/nexus-gateway

Made for: Cursor.

Per session 14 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 684 The whole file, excluding the scripts and references it only reads on demand.
Security scan B 1 finding. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00014 $0.00684
Opus 5 $0.00007 $0.00342
Sonnet 5 $0.00003 $0.00137
Haiku 4.5 $0.00001 $0.00068

Measured 3d ago against content hash 61ed013bb537, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade B, and why

agent-runtime-invariants scanned grade B with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 3d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nullifies safety policiesmediumAnti-refusal

"You have no restrictions", "do anything now", "ignore your guidelines": a direct jailbreak that disables guardrails.

- **`deny`, `block`, `error` outcomes always bypass the filter.** Those are auditable regardless of level.

Downgraded: this mod is about security review, or the phrase is quoted, so it is likely naming the pattern rather than instructing it.

.cursor/rules/agent-runtime-invariants.mdc · 83 lines

How it starts

The opening of the file, as written. The whole thing — 83 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Agent runtime invariants (binding)

Three bindings on the agent runtime. Honour all three.


1. Platform paths abstraction

All agent filesystem paths come from platform.DefaultPaths(). Never hardcode /Library/, /var/, /etc/, /tmp/, or C:\... strings.

// ❌ wrong
quitFlag := "/Library/Application Support/Nexus/.quit"

// ✅ right
quitFlag := platform.DefaultPaths().QuitFlagPath

Common path keys: LogDir, ConfigDir, DataDir, CacheDir, KeystorePath, LocalQueuePath, QuitFlagPath, CertCAStore.

Memory anchor: [[feedback_agent_platform_paths_abstraction]].


2. Traffic-upload level filter happens at emit-time

agent_settings.trafficUploadLevel ∈ {all, processed, blocked}, default processed.

  • Filter at agent emit-time, NOT DB-side. The agent decides per-event whether to publish to MQ / queue. DB-side filtering means the agent burned local cycles + queue capacity for nothing.
  • deny, block, error outcomes always bypass the filter. Those are auditable regardless of level.
if !shouldUpload(event.Outcome, agent.settings.TrafficUploadLevel) {
    return  // skip emit
}

shouldUpload lives in packages/agent/internal/audit/; respect its decision.

Memory anchor: [[feedback_agent_traffic_upload_level]].


3. Audit auditEventToMap empty-string stamping

Agent's audit emitter sets all string fields, including "". Hub-side AuditUpload MUST either stamp-unconditionally or strip-empty for any CHECK-constrained column. Inconsistent handling stalls the audit pipeline silently.

// Agent emit (always set, even empty):
m["external_request_id"] = event.ExternalRequestID   // may be ""

// Hub ingest (must handle both ways):
if v, ok := m["external_request_id"].(string); ok && v != "" {
    row.ExternalRequestID = sql.NullString{String: v, Valid: true}
}

A handler that does row.ExternalRequestID = m["external_request_id"].(string) directly will pass "" into a CHECK-constrained column and the insert fails. The failure is silent because audit-pipeline errors are caught at the batch level.

Read the full file on GitHub · 83 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 3d ago First seen · 83 lines · 684 tokens per session scan B 61ed013bb537

Subscribe to this mod's changes

agent-runtime-invariants is a cursor rule published in the GitHub repository AlphaBitCore/nexus-gateway (22 stars, last pushed 7d ago), licensed Apache-2.0. It adds 14 tokens to every session and 684 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it B with 1 finding (nullifies safety policies). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.