Guard System
Input validation and protection for your context storage.
What It Protects
The write guard validates all inputs before saving context. Enable or disable it in your config:
.opencontext.jsonc
{
"guard": {
"enabled": true,
"maxFileSizeKb": 50,
"strictPatternCheck": true
}
}Validations
Empty Content
Prevents saving blank or whitespace-only files
Payload Too Large
Configurable max file size (default 50KB)
Invalid Topics
Enforces snake_case or kebab-case naming
Path Traversal
Blocks "..", absolute paths, and directory escapes
Reserved Topics
Prevents overwriting system files like index.md
Prompt Injection
Detects and blocks common injection patterns
Error Codes
| Code | Description |
|---|---|
| EMPTY_CONTENT | Content is empty or whitespace only |
| PAYLOAD_TOO_LARGE | Content exceeds maxFileSizeKb |
| INVALID_TOPIC | Topic name doesn't match required pattern |
| PATH_TRAVERSAL | Topic contains path traversal attempts |
| RESERVED_TOPIC | Topic is reserved by the system |
| FORBIDDEN_PATTERN | Content contains prompt injection patterns |
Forbidden Patterns
When strictPatternCheck is enabled, the guard detects these prompt injection patterns:
ignore (all) (previous|prior) instructionssystem: overridebypass (safety|guardrails?|system prompt)