context-recorder-edge-cases

context-recorder-edge-cases is a cursor rule for Cursor from Mr-chen-05/rules-2.1-optimized. It costs 0 tokens per session (2,740 once invoked), scanned A, original, MIT.

A set of rules for handling unusual cases when recording context, including text encodings, timestamps, special characters, and recovery from errors.

In plain words
What is it for?
It is for checking and converting file encodings, validating timestamps, handling special characters, and responding to recording failures.
Why use it?
It helps prevent unreadable text, inconsistent times, and damaged records when inputs contain unexpected data.

Cursor rule for Cursor

Written for Cursor: a Cursor rule (.mdc).

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/mr-chen-05/rules-2.1-optimized/context-recorder-edge-cases
Clone the repo
git clone --depth 1 https://github.com/Mr-chen-05/rules-2.1-optimized

Made for: Cursor.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for context-recorder-edge-cases

README.md
[![agentmods](https://agentmods.dev/badge/rules/mr-chen-05/rules-2.1-optimized/context-recorder-edge-cases.svg)](https://agentmods.dev/rules/mr-chen-05/rules-2.1-optimized/context-recorder-edge-cases)
Your own site
<a href="https://agentmods.dev/rules/mr-chen-05/rules-2.1-optimized/context-recorder-edge-cases"><img src="https://agentmods.dev/badge/rules/mr-chen-05/rules-2.1-optimized/context-recorder-edge-cases.svg" alt="Measured on agentmods" height="20"></a>
Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 2,740 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. 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.1 $0.00000 $0.02740
Opus 5 $0.00000 $0.01370
Sonnet 5 $0.00000 $0.00548
Haiku 4.5 $0.00000 $0.00274

Measured 6d ago against content hash e2790a57f02c, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-06, from the pricing page.

Security

Grade A, and why

context-recorder-edge-cases scanned grade A with 0 findings 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 6d 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.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

global-rules/context-recorder-edge-cases.mdc · 439 lines

How it starts

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

🛡️ Context Recorder Edge Cases (记录员边界情况处理)

模块说明: 本文件包含边界情况处理、异常恢复和极端场景应对

相关模块

  • context-recorder-core.mdc - 核心定义和主要规则
  • context-recorder-templates.mdc - 模板定义
  • context-recorder-advanced.mdc - 高级功能

字符编码处理

编码支持

```yaml 支持的编码格式:

  • UTF-8 (默认推荐)
  • UTF-16
  • ISO-8859-1
  • GBK/GB18030 (中文)
  • ASCII ```

编码检测和转换

```yaml 自动检测流程:

  1. 读取文件首字节检查BOM
  2. 分析文本特征确定编码
  3. 尝试UTF-8解码
  4. 若失败,尝试其他编码
  5. 最后使用 ISO-8859-1

编码转换规则: 输入时: - 自动检测输入编码 - 转换为UTF-8内部表示 - 保留原始编码信息

输出时: - 统一使用UTF-8输出 - 对特殊字符进行转义 - 保持可读性

错误处理:

  • 编码错误时使用替代字符 (U+FFFD)
  • 记录编码错误到日志
  • 提示用户检查文件编码 ```

时间戳精度

时间戳格式

```yaml 标准格式: YYYY-MM-DD HH:MM:SS.mmm ±TIMEZONE 示例: 2025-01-31 14:30:45.123 +08:00

精度要求: 秒级: 正常操作 (标准) 毫秒级: 高精度需求 (可选) 微秒级: 性能敏感操作 (不推荐) ```

时间戳验证

```yaml 检查项:

  • 格式是否符合标准
  • 年月日是否有效
  • 小时分钟秒是否有效
  • 时区偏移是否正确

时间戳顺序检查:

  • 同一操作内时间戳必须递增
  • 不同操作的时间戳应合理
  • 检测到时间逆转时发出警告

系统时间校准:

  • 定期与NTP服务器同步
  • 检测到系统时间跳跃时告警
  • 时间异常时使用递增逻辑时间 ```

特殊字符处理

特殊字符分类

```yaml 控制字符 (ASCII 0-31, 127):

  • 处理: 转义或删除
  • 示例: \n, \t, \r

Unicode 补充字符:

  • 处理: 使用代理对表示
  • 范围: U+10000 到 U+10FFFF

零宽字符:

  • 零宽空格 (U+200B)
  • 零宽连接符 (U+200D)
  • 处理: 删除或标记

方向标记:

  • RTL标记 (U+202E)
  • LTR标记 (U+202D)
  • 处理: 保留,用于多语言支持 ```

特殊字符转义

```yaml 在JSON中:

  • " → \"
  • \ → \\
  • \n → \\n
  • \t → \\t

在URL中:

  • 使用百分比编码 (%XX)

在Markdown中:

    • → \*
  • [ → \[
  • _ → \_ ```

大文件处理

大文件定义

```yaml 文件分类:

  • 普通文件: < 10MB
  • 大文件: 10MB - 100MB
  • 超大文件: > 100MB ```

处理策略

```yaml 分块处理: 块大小: 512KB 处理流程: 1. 打开文件流 2. 逐块读取数据 3. 处理每个块 4. 累积结果 5. 关闭文件流

内存优化:

  • 不一次性加载整个文件
  • 使用流式处理
  • 及时释放已处理数据

进度跟踪:

  • 显示处理进度百分比
  • 估计剩余时间
  • 允许用户取消操作 ```

并发访问处理

并发场景

```yaml 常见场景:

  1. 多个用户同时写入
  2. 一个用户读,另一个用户写
  3. 多个AI实例同时操作
  4. 系统维护与用户操作冲突 ```

锁机制

```yaml 文件锁:

  • 共享锁 (读操作)
  • 独占锁 (写操作)
  • 获取时间: 操作开始
  • 释放时间: 操作完成

Read the full file on GitHub · 439 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. 6d ago First seen · 439 lines · 0 tokens per session scan A e2790a57f02c

Subscribe to this mod's changes

context-recorder-edge-cases is a cursor rule published in the GitHub repository Mr-chen-05/rules-2.1-optimized (172 stars, last pushed 10mo ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 2,740 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.