Skip to content

Hide AI: a usage limit for background requests - #1019

Merged
yansfil merged 7 commits into
mainfrom
spec/hide-ai-usage-limit
Oct 12, 2026
Merged

yansfil merged 7 commits into
mainfrom
spec/hide-ai-usage-limit

Conversation

@yansfil

@yansfil yansfil commented Oct 12, 2026

Copy link
Copy Markdown
Contributor

Related: PRD agents/prd/hide-ai-usage-limit/prd.md

Summary

  • Settings > Hide AI gets a Usage limit of 80%, 90%, 95% or No limit, one value for all of Hide AI.
  • Background requests Hide starts itself (agent labels, Memory analysis, card recheck, pre-promotion check) skip an agent at or past it in its week and move to the next agent in the existing list.
  • If every listed agent is past the limit, nothing is sent: labels show the session's own text, Memory shows its dimmed state, and both resume on their own.
  • Runs on and fallback rows show 86% this week, or Past your limit with the reset time; an agent with no figure shows none and is never held back.
  • Default change: the limit is 90% for every install. Memory's fixed 80% weekly hold is removed (so Memory now analyzes between 80% and 90%), and labels are newly limited.

Runs on shows the week (86% under the 90% limit) and the new Usage limit row

Claude Code is past the limit: Grok answers, and the line says why

Every agent past the limit: Memory keeps its dimmed state and says Hide AI is paused

Review

  • Judge this: the 90% default and the wording ("Past your limit", "Hide AI is paused"); the Memory change from 80% to 90% is a product decision the PRD made, worth a second look.
  • D-03 readings: Factory judgments and hide memory add are not limited (an operator or agent waits on them), as is worktree naming and issue review; no figure means not limited (D-07).
  • Watch herdr-core/src/runtime/usage_limit.rs - snapshot wire fields and the pause state; hide-ai/src/router.rs - the per-request judgment on worker threads; herdr-core/src/runtime/memory_analysis.rs - the deleted 80% hold and weekly judgment.
  • Cost: the gate is one small mutex (UsageLimits) written only when the limit or a reading changes, and read per request on worker threads; no blocking under Mutex<Runtime>. agent_summary() reads a cached pause. With no window attached the usage reader also runs, at most once per agent every 5 minutes, while the order is paused or an agent worked in the last 30 minutes; none on a quiet machine.
  • Question: a signed-out fallback beside a past-limit Runs on is not an all-past pause (Memory then reports NoProvider as today); is that the wanted reading?

Evidence

  • Confirmed: hide-ai lane 103 unit and 43 integration tests; herdr-core 2107 tests including 11 runtime tests for the limit (event, figures, refusal, pause, resume on raise and on a new week, logs, unchanged read publishes nothing); clippy --workspace -D warnings; web typecheck, lint and 1473 unit tests; a new e2e spec (3 tests) on an isolated hided and Herdr with a scripted usage shim, never the operator's quota.
  • Publish frequency: idle 60 s with a figure present: 14 frames, 3 carrying rest, all 3 with an identical background_ai; one limit change: 3 frames. Compared by construction and unit test, not against a main build.
  • Not confirmed: no packaged Electron window capture (Chromium on the isolated daemon instead); other-device window (D-08) and zh/ja wording not captured; check-design-contract not run (no design part touched); the first Memory pass before the first usage read (about one second after launch) asks Runs on at any usage.
More captures

All twelve state captures (runs, fallback, paused; Settings and Memory; light and dark) and a Korean 560 px capture were taken from the same spec and are listed in the Verification record.

Verification record
  • PRD: agents/prd/hide-ai-usage-limit/prd.md (sha256 08f6a9baf3e39e76f3bb35964a661c0c6f757a4ff365b3d6d17b03635fe9f1b4)
  • Base 5993a59 → head 772bc92, verified 2026-10-12T15:48:09.868Z: PASS
  • Verification report: agents/runs/hide-ai-usage-limit/verification-report.json and agents/runs/hide-ai-usage-limit/verification-report.md; source fingerprint 5f0f161e383c9c722c4a9b187ff995b52c74297be921cef6434053d799858644
  • Suites:
    • S1: GREEN bash scripts/verify-cargo.sh test (exit 0)
    • S2: GREEN bash scripts/verify-cargo.sh lint (exit 0)
  • Reviews (advisory, run on a non-default model for cost; the GPT agents returned model_not_found, so Sonnet reviewed):
    • Code, head 98101df: Fix now 2, both fixed (f8e5439). The headless usage reader did not run while paused or with only labels active, so a pause could not lift without a window; the per-tick label switch rebuilt the order and cloned readings every wake. Follow-ups: Memory backoff reset on any limit change, a malformed usage_limit drops the whole settings choice, startup ordering before settings load, one log line per past-limit agent per request.
    • Fidelity, head 98101df: Fix now 1 (the same reader gap, fixed). Follow-ups: first Memory pass before the first read asks Runs on (D-07 reading, named in Review), pause log carries per-agent usage (added), other-device window and zh/ja captures not exercised, a signed-out fallback beside a past-limit Runs on is not an all-past pause.
    • Follow-up, head f8e5439: Fix now 1, fixed (772bc92): the coordinator's headless gate consulted only Memory's hint, and the pet's idle clock starts at launch. Closure review on 772bc92: closed, nothing new. Nits left: rename read_memory_reads_usage, a refresh_pet test for the new clock.
    • A self-found deadlock (a guard in a match scrutinee in handle.rs, hung Core::create) was fixed before any review.
  • Evidence: 13 registered (13 screenshot); paths are local to the run directory
    • agents/runs/hide-ai-usage-limit/captures/usage-limit-runs-settings-light.png
    • agents/runs/hide-ai-usage-limit/captures/usage-limit-runs-memory-light.png
    • agents/runs/hide-ai-usage-limit/captures/usage-limit-fallback-settings-light.png
    • agents/runs/hide-ai-usage-limit/captures/usage-limit-fallback-memory-light.png
    • agents/runs/hide-ai-usage-limit/captures/usage-limit-paused-settings-light.png
    • agents/runs/hide-ai-usage-limit/captures/usage-limit-paused-memory-light.png
    • agents/runs/hide-ai-usage-limit/captures/usage-limit-runs-settings-dark.png
    • agents/runs/hide-ai-usage-limit/captures/usage-limit-runs-memory-dark.png
    • agents/runs/hide-ai-usage-limit/captures/usage-limit-fallback-settings-dark.png
    • agents/runs/hide-ai-usage-limit/captures/usage-limit-fallback-memory-dark.png
    • agents/runs/hide-ai-usage-limit/captures/usage-limit-paused-settings-dark.png
    • agents/runs/hide-ai-usage-limit/captures/usage-limit-paused-memory-dark.png
    • agents/runs/hide-ai-usage-limit/captures/usage-limit-fallback-settings-ko-narrow.png
  • Changed paths: 37 (see Files changed)
  • Delivery: mode pr, branch spec/hide-ai-usage-limit, base main

A usage limit setting (default 90%, or none) and a shared cell of weekly
readings let the router skip an agent that is at or past the limit and ask
the next agent of the order instead. An agent with no reading is never
limited, requests that name their own agent and routers built without the
cell are not judged, and every skip is logged with the agent, its usage and
the limit.
…agent is past it

The runtime keeps the shared usage cell current from the weekly rows and the
setting, folds the pause into labels and Memory analysis, and publishes the
limit, each agent's week and the past_limit refusal only when they change.
Memory's fixed 80% hold and its weekly judgment are removed; the daily cap
stays. Worktree names move to a router that is never limited.
…te the pause from one cached read, and log each agent's usage when paused

Review follow-ups: the headless usage reader also runs while the order is paused
or an agent worked in the last 30 minutes, so a pause can lift without a window;
the per-tick label switch reads the cached pause instead of rebuilding the order;
the cell clones its readings only when they change; an all-past order outranks the
label analyzer's older record on the screen; an unreachable degraded arm is gone.
…it, and time an agent's last work apart from the pet's clock
@yansfil
yansfil merged commit 441e46b into main Oct 12, 2026
21 checks passed
@yansfil
yansfil deleted the spec/hide-ai-usage-limit branch October 12, 2026 23:48
yansfil added a commit that referenced this pull request Oct 13, 2026
Related: #1019, #1021

## Summary

Account usage now shows five-hour and weekly windows in up to three
sidebar chips and a shared popover.
Settings > Usage controls shared pins and visibility, with explicit
reasons for unsupported agents.
Long values wrap while switches stay in one column; the expanded
navigation fits the minimum window at default text size.
The node keeps credentials private; typed readings drive both the
display and background admission decisions.

![Five-hour and weekly usage in the isolated Electron renderer, English
at maximum text
size.](https://github.com/yansfil/pr-assets/blob/main/hide/usage-limits/613e371/usage-popover-en-electron.png?raw=true)

## Review

- Judge the window labels, localized reason lines and chip density in
the screenshots.
- Watch `hide-host/src/usage.rs` for credential boundaries and
`herdr-core/src/usage.rs` for failure and refresh state.
- Two bounded readers poll off the runtime lock; visible reads use a
five-minute cadence and shutdown cancels/joins them.
- The core publishes changed readings only; an open popover updates its
countdown once per minute.

## Evidence

- Shared pin/hide browser flow, parser states, backoff, late-event
rejection and restart persistence passed.
- Isolated Electron: 720x480, maximum text, English light/Korean dark;
footer and Settings reason lines fit; the navigation scrolls at maximum
text.
- Screenshots use an external Claude CLI fixture and signed-out Codex;
they capture the renderer, excluding native chrome.
- Real Codex five-hour output and Windows/Linux native visuals were not
observed locally; five-hour data uses a documented fixture.
- `design/hide-ui.lib.pen` and regenerated `design/hide-screens.pen`
passed the design contract and export inspection.

<details><summary>Settings screenshots</summary>

![English maximum text: switches stay aligned while values wrap;
navigation remains
scrollable.](https://github.com/yansfil/pr-assets/blob/main/hide/usage-limits/613e371/usage-settings-en-electron.png?raw=true)

![Korean maximum text: aligned switches and readable refusal
copy.](https://github.com/yansfil/pr-assets/blob/main/hide/usage-limits/613e371/usage-settings-ko-electron.png?raw=true)

</details>

## Breaking change

Node protocol 30 removes credential-returning calls; core and device
helpers must use compatible builds.

<details><summary>Verification record</summary>

- PRD: `agents/prd/usage-limits/prd.md` (sha256
8cfe5dc081853e73a09563660509648a18a8a68db94e10d9660510b17416c604)
- Base 441e46b → head 613e371, verified 2026-10-13T01:12:26.851Z: PASS
- Verification report:
`agents/runs/usage-limits/verification-report.json` and
`agents/runs/usage-limits/verification-report.md`; source fingerprint
6fa101ddf764c36241f59d20d62ec72824c1665f2b9153eae37cabe50973365b
- Suites:
  - S1: GREEN `bash scripts/verify-cargo.sh test` (exit 0)
  - S2: GREEN `bash scripts/verify-cargo.sh lint` (exit 0)
- Fidelity review: 613e371; all 22 requirements covered and current
findings closed, including switch alignment and minimum-window
navigation.
- Code review: 613e371; prior complete review plus navigation spacing,
preserved row targets and updated tab-order/keyboard regression
coverage.
- Security review: 613e371; no blocking findings. Existing redirect
account-header handling and concurrent-growth tail bounds remain
follow-ups.
- Fixes: queued reads after Hide/backoff, invisible pins including
delayed events, unreadable responses, narrow switch alignment, and the
23 px minimum-window Settings navigation overflow.
- Checks: Rust full suite 4413 passed/96 ignored; web unit 1478 passed/1
skipped; desktop unit 184 passed/4 skipped; Settings browser suite 3
passed; targeted usage browser and Electron geometry flows passed.
- Electron geometry covers four switch right edges and first-label-line
centers in EN/KO maximum text, including unavailable/refused-fourth-pin
rows; navigation fit without scrolling is checked at default text.
- Previous CI found navigation overflow and obsolete tab-order
expectations; both were reproduced or identified and corrected. An
unrelated project-row focus test passed its retry and remains a flaky
follow-up.
- Earlier credential request fixtures were updated to the current
protocol; this report supersedes earlier heads and source-moved
verification.
- Delivery follows the approved prerequisite rebase; current-main
merge-tree was conflict-free before PR creation.
- CI: 613e371 passed all 19 applicable checks, including required
`verify`; 2 planned skips.
[Run](https://github.com/modakbul-gongbang/hide/actions/runs/38331172563).
- Evidence: 32 registered (12 log, 10 screenshot, 10 file); paths are
local to the run directory
  - agents/runs/usage-limits/usage-e2e.log
  - agents/runs/usage-limits/web-suite.log
  - agents/runs/usage-limits/review-fixes-tests.log
  - agents/runs/usage-limits/pin-reconcile-test.log
  - agents/runs/usage-limits/host-reproduction.log
  - agents/runs/usage-limits/design-contract-final.log
  - agents/runs/usage-limits/late-pin-test.log
  - agents/runs/usage-limits/web-switch-tests.log
  - agents/runs/usage-limits/usage-footer-en-electron.png
  - agents/runs/usage-limits/usage-footer-en-electron.json
  - agents/runs/usage-limits/usage-footer-ko-electron.png
  - agents/runs/usage-limits/usage-footer-ko-electron.json
  - agents/runs/usage-limits/usage-popover-en-electron.png
  - agents/runs/usage-limits/usage-popover-en-electron.json
  - agents/runs/usage-limits/usage-popover-ko-electron.png
  - agents/runs/usage-limits/usage-popover-ko-electron.json
  - agents/runs/usage-limits/usage-settings-bottom-en-electron.png
  - agents/runs/usage-limits/usage-settings-bottom-en-electron.json
  - agents/runs/usage-limits/usage-settings-bottom-ko-electron.png
  - agents/runs/usage-limits/usage-settings-bottom-ko-electron.json
  - agents/runs/usage-limits/usage-settings-en-electron.png
  - agents/runs/usage-limits/usage-settings-en-electron.json
  - agents/runs/usage-limits/usage-settings-ko-electron.png
  - agents/runs/usage-limits/usage-settings-ko-electron.json
  - agents/runs/usage-limits/usage-settings-unsupported-en-electron.png
  - agents/runs/usage-limits/usage-settings-unsupported-en-electron.json
  - agents/runs/usage-limits/usage-settings-unsupported-ko-electron.png
  - agents/runs/usage-limits/usage-settings-unsupported-ko-electron.json
  - agents/runs/usage-limits/native-usage-renderer.log
  - agents/runs/usage-limits/settings-nav-repro.log
  - agents/runs/usage-limits/settings-nav-fixed.log
  - agents/runs/usage-limits/nav-design-contract.log
- Changed paths: 78 (see Files changed)
- Delivery: mode pr, branch `gen-prd/usage-limits`, base `main`

</details>
yansfil added a commit that referenced this pull request Oct 13, 2026
Closes #1013
Related: #1019

## Summary

- 재동의가 필요하면 기존 스위치 아래에서 분석·주입이 멈춘 이유를 알립니다.
- 실행 카드만 `확인 중`으로 표시하고, 대기 카드는 흐리게 표시하며 이유는 목록 위에서 한 번만 설명합니다.
- 총 1,000회 중 확인은 최대 500회이며, 재확인과 promotion 확인이 due일 때 필요한 만큼 분석에서 예약합니다.
- 통과한 카드는 바로 다시 쓰며, 예산 재개 시각은 보는 사람의 현지 날짜와 시간으로 표시합니다.

| 이전 | 변경 후 |
| --- | --- |
| ![예산 소진을 확인 중으로
표시](https://github.com/yansfil/pr-assets/blob/main/hide/1013/memory-before-budget.png?raw=true)
| ![예산 이유는 한 번, 대기 카드는 흐리게
표시](https://github.com/yansfil/pr-assets/blob/main/hide/1013/review-check_budget_exhausted-ko-light.png?raw=true)
|

예산 때문에 멈춘 카드를 실행 중처럼 보이지 않게 하고, 현지 재개 시각을 알려 줍니다.

## Review

- **판단해 주세요**: 260px 도구 영역에서 대기 카드의 흐림과 현지 재개 시각 안내가 읽기 편한지 확인해 주세요.
- **조심해서 볼 파일**: `hide-memory/src/store.rs` - schema 11, 동시 호출의 원자적 예약과
두 종류의 due 확인.
- **조심해서 볼 파일**: `memory_analysis.rs`, `memory_verify.rs` - 초기화·사용량
중단·실패 때 진행 상태 정리.
- **조심해서 볼 파일**: `model.rs`, `snapshot.ts` - core 소유 상태·사용 가능 수·재개 시각의
wire 계약.
- **비용 검토**: 기존 worker에서 호출당 SQLite 트랜잭션 하나이며, 분석 예약은 최대 500개 일치 행을 셉니다.
- **비용 검토**: 후보 스캔 수 자체에 새 상한은 없으며, Project별 기존 10,000개 카드 상한 안에서
source·receipt를 조회합니다.
- **비용 검토**: 입력 경로의 추가 작업은 없고, 기존 4+3회 확인의 상태 변경만 알립니다. 새
worker·timer·queue는 없습니다.
- **사용량 제한**: 병합된 #1019 위로 rebase했습니다. router의 `past_limit`을 기존
`ai_not_ready`와 Settings 연결로 그립니다.

## Evidence

- **확인한 것**: 날짜 초기화+사용량 중단의 stale hold와 promotion 확인 예약 누락을 실패 재현 후 회귀
테스트로 검증했습니다.
- **확인한 것**: 꺼진 Project의 usable_cards=0, 한 번의 안내, 실행 카드만 표시, 서울·LA의 서로
다른 날짜를 검증했습니다.
- **확인한 것**: 격리된 실제 브라우저의 260px 화면에서 4언어·2테마의 안내와 줄바꿈을 확인했습니다.
- **로컬 재확인**: 처음 hook 한 건의 timeout과 잘못된 로케일로 실패했습니다. hook 단독·스크립트 325개는
재실행 통과했습니다.
- **로컬 검사**: Rust 전체 4,419개, web 1,483개·desktop 184개 unit,
typecheck/lint/build, 디자인·구조 검사 통과.
- **원격 CI**: 최종 `573bb39d2`의 verify attempt 2와 디자인 계약이 통과했습니다.
- **기존 flaky**: 첫 CI는 sidebar #1022로 실패. 같은 SHA의 Linux 2/4는 65 passed·1
flaky이며 기본 retry에 통과했습니다.
- **확인하지 못한 것**: 실제 계정의 모델 호출·사용량에 따른 provider 선택과 설치 앱의 Memory native
화면은 확인하지 않았습니다.

<details><summary>카드별 진행과 재동의</summary>

m17만 확인 중이고 m12는 기다립니다.

![실행 카드만 확인
중](https://github.com/yansfil/pr-assets/blob/main/hide/1013/review-checking-ko-dark.png?raw=true)

쓸 수 있는 카드가 섞여 있어도 대기 이유는 목록 위 한 번만 표시합니다.

![대기 안내 한 번과 카드별
흐림](https://github.com/yansfil/pr-assets/blob/main/hide/1013/review-verifying-ko-light.png?raw=true)

재동의는 기존 스위치로만 받습니다.

![재동의
안내](https://github.com/yansfil/pr-assets/blob/main/hide/1013/review-reconsent-ko-light.png?raw=true)

병합된 #1019의 사용량 제한은 기존 안내와 Settings 연결로 표시합니다.

![기존 사용량 제한 표시와
Settings](https://github.com/yansfil/pr-assets/blob/main/hide/1013/review-past-limit-ko-light.png?raw=true)

</details>

<details><summary>원격 검증과 기존 flaky</summary>

[최종 verify attempt
2](https://github.com/modakbul-gongbang/hide/actions/runs/38326269463/attempts/2)와
[디자인
계약](https://github.com/modakbul-gongbang/hide/actions/runs/38326268769)은
같은 HEAD에서 통과했습니다.
verify의 18개 job이 성공했고, plan이 요구하지 않은 package와 단일 Windows web shard의 별도
build job은 skipped입니다.
Rust workspace, web·desktop 검사, Linux 4개 web shard, Windows web,
macOS·Windows desktop, 3시스템 OS 계약과 remote mailbox를 실행했습니다.

[첫 CI
실패](https://github.com/modakbul-gongbang/hide/actions/runs/38326269463/attempts/1)는
기존 [sidebar flaky
#1022](https://github.com/modakbul-gongbang/hide/issues/1022)의 포커스
검사입니다.
main의 같은 Linux shard에서도 실패 후 기본 retry에 통과한 이슈이며, 현재 SHA의 attempt 2도 동일하게
첫 실패 후 retry PASS했습니다.
이 sidebar flow를 첫 실행부터 확인된 PASS로 보고하지 않습니다.
범위를 유지하여 이 PR에는 sidebar 수정이나 assertion 완화를 포함하지 않았습니다.

전체 로컬 Rust는 `225df081d`에서 4,419 passed·96 ignored였습니다.
최종 delta는 promotion 테스트 fixture의 불필요한 clone을 borrow로 바꾼 것이며 최종
fmt/clippy와 해당 회귀 검사를 다시 통과했습니다.
web 1 skipped와 desktop 4 skipped도 기존 suite 결과에 포함되어 있습니다.

</details>

## Breaking change

- Memory DB를 schema 11로 올린 뒤 이전 바이너리로 돌아가면 `WrongSchema`로 Memory를 읽지
못합니다.
- DB는 보존됩니다. 다시 schema 11을 지원하는 버전을 사용해야 하며 DB를 삭제하는 롤백은 하지 않습니다.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant