Files
cindy/docs/dev-rules
Dash 48bfca40df feat(usage-limit): 账号用量上限重置后自动继续,覆盖更多订阅套餐 (#5540)
* feat(usage-limit): 账号用量上限重置后自动继续,覆盖更多订阅套餐

- 普通任务撞上 5 小时 / 周用量上限时照常报错,同时等额度重置;到点仍无人处理
  就自动继续(有产出发续跑指令、零产出重发原文)。横幅显示「将于 X 自动继续 ·
  取消」,手机端同步;替换原「恢复后继续」一次性自动化入口。仅本次运行有效。
- 重置时刻统一按会话所用账号求:错误自带 → 报错原文(Codex try again at、Pi
  ~N min、ChatGPT resets_at)→ 订阅用量快照(ChatGPT / Claude / SuperGrok 按
  provider 的 auth.native)。目标模式共用同一套来源。
- 新增 maker:input:cancel-usage-limit-wait 与可选投影字段 usageLimitWait;
  账号限额不再进入秒级中断重连。

Signed-off-by: Dash <125997726+dashhuang@users.noreply.github.com>

* fix(usage-limit): scope waits to the session model and subscription, tighten lifecycle

- Read only the Codex bucket / Claude scoped window that limits the session model
- Never wait on non-subscription providers even when the error text has a retry time
- Bind waits to the candidate recovery issued at the terminal error; drop in-flight
  resolutions on user action or close; withdraw the hint when eligibility lapses
- Check the renderer sender on the cancel IPC; renderer no longer clears the hint
  optimistically

Signed-off-by: Dash <125997726+dashhuang@users.noreply.github.com>

* fix(usage-limit): only trust reliable reset times of the limited subscription window

- Goal mode reads error-text reset times through the host, only for subscription sessions
- An exhausted window without a reset time yields no reset time instead of borrowing another
- Ignore windows already past their reset and stale SuperGrok snapshots

Signed-off-by: Dash <125997726+dashhuang@users.noreply.github.com>

* fix(usage-limit): restore the error when a reset continuation is dropped before dispatch

- Keep a pre-dispatch rollback record for usage-limit continuations (no interrupted-turn token)
- Restore the original error and manual retry from the existing discard / undispatched hooks
- Document that scheduler-origin inputs, including hook channel messages, are not covered

Signed-off-by: Dash <125997726+dashhuang@users.noreply.github.com>

* fix(usage-limit): withdraw a fired wait when the continuation does not start

Signed-off-by: Dash <125997726+dashhuang@users.noreply.github.com>

* fix(usage-limit): recognise built-in subscription accounts, commit unconfirmed continuations

- Map the built-in default providers (openai / anthropic / xai) to their subscription family
- Treat a usage-limit continuation as current while its pre-dispatch rollback record exists,
  so an unconfirmed dispatch is committed instead of being restored as retryable
- Do not pass the usage-limit sessionTotal (0) to interrupted-turn bookkeeping

Signed-off-by: Dash <125997726+dashhuang@users.noreply.github.com>

* fix(usage-limit): only use snapshot reset times when the snapshot confirms the limit

- Return a snapshot reset time only when a window is exhausted; goal's reactive path checks limited too
- Void the snapshot-level reached flag once any window has rolled over

Signed-off-by: Dash <125997726+dashhuang@users.noreply.github.com>

* fix(usage-limit): judge snapshots by exhausted windows only, withdraw waits on model switch

- Drop snapshot-level reached flags (stale or credits depleted); only an exhausted live window counts
- A user model / source switch withdraws the pending usage-limit wait
- Document that goal mode keeps its persisted usageLimited resume across restarts

Signed-off-by: Dash <125997726+dashhuang@users.noreply.github.com>

* docs(usage-limit): scope the model-switch withdrawal rule to ordinary tasks

Signed-off-by: Dash <125997726+dashhuang@users.noreply.github.com>

* fix(usage-limit): match usage windows against the model the session actually runs

Runtime overrides (set_session_runtime / automatic fallback) take precedence over the saved
session model and provider for both ordinary tasks and goal mode.

Signed-off-by: Dash <125997726+dashhuang@users.noreply.github.com>

* fix(usage-limit): never auto-continue a shared-task guest turn

The guest's access may be revoked while waiting; re-sending their instruction hours later is
unsafe, so the error stays for the owner to handle.

Signed-off-by: Dash <125997726+dashhuang@users.noreply.github.com>

* test(usage-limit): pin that guest steers never leave a usage-limit wait

Covers both orderings (steer ack before / after the terminal error); docs mention guest steers.

Signed-off-by: Dash <125997726+dashhuang@users.noreply.github.com>

* fix(usage-limit): goal mode skips local subscription snapshots for SSH sessions

Signed-off-by: Dash <125997726+dashhuang@users.noreply.github.com>

* fix(usage-limit): withdraw the wait before a user model switch starts

Cancelling after handleSetModel could lose to a continuation that fired during the switch.

Signed-off-by: Dash <125997726+dashhuang@users.noreply.github.com>

* fix(usage-limit): never treat billing depletion as a periodic usage limit

Share the billing-depletion check between the usage-limit classifier (goal and ordinary tasks)
and the reset-time parser, so quota wording on a billing error no longer schedules a wait.

Signed-off-by: Dash <125997726+dashhuang@users.noreply.github.com>

* fix(usage-limit): ignore zone-less clock times from SSH session errors

Remote Codex reports 'try again at 3:05 PM' in the remote host's local time; only relative,
zoned or structured reset times are used for SSH sessions.

Signed-off-by: Dash <125997726+dashhuang@users.noreply.github.com>

* fix(usage-limit): never auto-wait on a usage limit while the task is shared

Per Dash (2026-10-08): ordinary tasks and goal mode stay on the error / usageLimited for the
owner to resume when the task is currently shared; a wait that becomes shared does not resume
at the reset time. Goal overload retries are unaffected.

Signed-off-by: Dash <125997726+dashhuang@users.noreply.github.com>

---------

Signed-off-by: Dash <125997726+dashhuang@users.noreply.github.com>
2026-10-08 08:40:08 +08:00
..

开发规则

这里存放 Cindy 客户端仓的工程约束、实现规则、开发流程和验证方法。

收录标准

  • 规则说明“代码怎样实现、怎样验证或哪些技术操作被禁止”。
  • 每条规则应写清触发条件、必须做什么、禁止做什么、验证方法和例外条件。
  • 只适用于单个目录或模块的规则,优先放到对应目录的嵌套 AGENTS.md;需要跨目录 复用或需要较长解释的规则放在这里。
  • 可以由 lint、测试、类型检查或脚本强制的要求,应同时落实到自动化检查,不能只靠 Agent 阅读文字。

当前文档

  • repo-map.md:仓库地图——apps、packages 与顶层目录的定位导航。
  • environment-setup.md:公共开发环境、依赖安装与 submodule 准备。
  • model-catalog-maintenance.md:模型配置与下发统一入口——架构图、字段职责、覆盖顺序、修改位置、代码导航与发布验收。
  • model-catalog-runtime.md:模型窗口、压缩预算、原生缓存、参考价与显示细则;从架构入口按需进入。
  • desktop-development.md:Desktop 的 Agent 安全启动入口与 分层验证命令。
  • electron-security-and-process-boundaries.md: Electron 进程职责、Renderer 信任模型、BrowserWindow、独立辅助窗口统一生命周期、 preload、IPC 与远程内容安全边界。
  • credentials-and-local-storage.md:凭证不入仓、 用户持久数据、临时文件与测试目录的安全边界。
  • media-storage-and-protocols.md:Desktop 媒体总仓、 cindy-media:// 协议、引用生命周期与历史兼容边界。
  • database-and-migrations.md:Desktop SQLite schema、 append-only migration、companion script、隔离运行与异步数据库访问规则。
  • mobile-development.md:Mobile 的模拟器开发、分层验证与 专项文档入口。
  • orca-team-architecture.md:Orca 多 Agent 协同架构与运行时约束。
  • maker-core-and-agent-behavior.md:packages/maker-core 的 Agent 能力归属、代码优先确定性、缓存率/性能/准确性指标不可回退,以及 system prompt 改动门禁。
  • plugin-security-and-authoring.md:插件(.cindy) 运行时沙箱与进程隔离、权限即授权边界、网络/凭证/资源交接、存量插件向下兼容红线 (升级不得要求用户重装或重新确认),以及作者契约与编写手册(FORGE_GUIDE)同步。
  • cindy-updater.md:客户端自动更新链路的 owner 确认门禁与高风险 约束。
  • engineering-conventions.md:统一日志、IPC 错误协议 (throwIpcError)、main 侧默认带测试、macOS/Windows 双端兼容,以及 UI 文案的 i18n 落地与 pnpm check:i18n 门禁。
  • log-upload-and-redaction.md:客户端日志采集/脱敏/上报的 三条不变量(记录边界、白名单方向 deny-by-default、标记代次 + 原子清除)、四层收窄管道、 授权闸、区域绑定与崩溃时序。
  • protocol-compatibility.md:两仓本地协议实现、device-link relay 层、插件来源与 wire protocol 兼容。
  • architecture-invariants.md:package 与 render/main 解耦、 main 进程静态依赖,以及主界面布局树不变量。
  • configuration-and-overrides.md:配置可见性分层、默认值 与用户 override 分离、默认值迁移与恢复默认语义。
  • remote-and-mobile-adaptation.md:SSH 远程工作区、 device-link allowlist、手机版入口与功能类 PR 的远程/手机三选一门禁。
  • development-workflow.md:worktree dogfooding 会话契约、提 PR 与直推 main 门禁,以及 Review P0/P1/P2 严重度口径。