R1: Prompt Cache Boundary
Tier 1 Planned Split ~4,000 tokens of static instruction from per-turn dynamic context. API applies cache_control at the boundary.
Identity
Agent persona, name, version
Tool Policy
Edit protocol, bash restrictions
Risk Taxonomy
R4 decision tree (Phase 4)
Length Anchors
R8 numeric limits (Phase 1)
Safety Rules
OWASP, security constraints
Git Workflow
Commit, PR, branch patterns
<env> Block
CWD, platform, shell, OS
Workspace
Folder structure, git state
AGENTS.md
Project-specific instructions
Skills Context
Loaded skills + MCP servers
Memory (R5)
Persistent facts from prior sessions
Model Variant (R7)
Per-family prompt patches
R12: Feature Flag Infrastructure
Tier 3 Exists Already built in apps/cli/src/feature-flags/. Extended with 10 new flags gating all Phase 2–6 features.
~/.subq/settings.json. Remote flag alone cannot enable these features.
R8: Numeric Length Anchors
Tier 3 Promoted to Phase 1 Three-line change in factory.ts with zero risk and immediate measurable savings.
R2 → R18: Hooks → Extension API
Tier 1 Supersession Composable lifecycle hooks (R2) evolving into full Extension API (R18) with 30+ events and tool/command registration.
CRITICAL-1
Hook Command Injection
Unsanitized file paths become shell metacharacters. Fix: pass context via stdin as JSON, user-level hooks only, strip API keys from child process env.
R17: Cross-Agent Rule Discovery
Tier 4 Novel Discover rules from 7 agent config formats. Normalize, deduplicate, priority-based injection.
.subq/rules/
Native SubQ rules. Highest priority. First-wins dedup.
.claude/
CLAUDE.md + commands. Second priority.
.cursor/rules/
Cursor rule files. Third priority.
.codex/ .gemini/ .windsurf/ .cline/
Additional formats. Added based on demand.
alwaysApply Rules
Injected into dynamic prompt. 2KB per rule, 10KB total limit.
Glob-Scoped Rules
Injected only when agent works on matching files.
TTSR-Triggered Rules
Rules with ttsrTrigger registered as stream monitors.
CRITICAL-2
Rule Prompt Injection
Repo ships crafted alwaysApply: true rules. Fix: project-level rules untrusted, user-level only for alwaysApply. Reject project-level ttsrTrigger regexes.
R13: TTSR — Streamed Rules
Tier 4 Novel Zero-context-cost rules monitoring output stream via regex. Abort, inject <system-interrupt>, retry.
Zero Context Cost
Stream-Level Enforcement
TTSR rules consume no prompt tokens until triggered. Rules exist only in the stream monitor—never injected into context unless a violation occurs.
Safety Guard
Correction Content
Correction content must come from the rule definition, not from triggering context. All corrections logged for audit.