feat(adapter-claude-local): session-exhaustion backoff helpers (AIP-5933) - #9989
feat(adapter-claude-local): session-exhaustion backoff helpers (AIP-5933)#9989yaverabbas wants to merge 12 commits into
Conversation
…IP-5933) - Add nextDailyResetUtc(now, resetHourUtc=22) to parse.ts — fallback reset time when session exhaustion gives no explicit clock in the error text - Export isClaudeSessionExhaustionError as alias for isClaudeProviderQuotaError - Extend extractClaudeRetryNotBefore to accept opts.sessionExhaustionFallbackResetHourUtc; falls back to nextDailyResetUtc when a provider-quota error has no reset clock - Make toAdapterResult async in execute.ts; pass sessionExhaustionFallbackResetHourUtc:22 on provider-quota paths; emit structured [paperclip] log when retry is scheduled Co-Authored-By: Paperclip <noreply@paperclip.ing>
|
Hey @yaverabbas! Before this PR can be reviewed, a few things need attention: Missing or incomplete:
Informational:
Once updated, push a new commit and these checks will re-run automatically. — commitperclip |
Greptile SummaryThis PR ships two independent changes: session-exhaustion backoff helpers for the
Confidence Score: 5/5
|
| Filename | Overview |
|---|---|
| packages/adapters/claude-local/src/server/parse.ts | Adds nextDailyResetUtc, isClaudeSessionExhaustionError alias, CLAUDE_SESSION_EXHAUSTION_RE alias, and extends extractClaudeRetryNotBefore with a fallback reset hour. The fallback fires on any isClaudeProviderQuotaError hit (which includes weekly, 5-hour, and generic cap errors, not just session/daily ones), and neither new alias is re-exported from the package's server/index.ts entry point. |
| packages/adapters/claude-local/src/server/execute.ts | toAdapterResult is made async to allow awaiting the new informational onLog call when a provider-quota backoff is scheduled. If the caller-provided onLog rejects, the awaited log call propagates the rejection and aborts the function before returning the structured provider_quota result with retryNotBefore, so recovery receives a thrown error instead of the backoff schedule. |
| packages/adapters/deflector/src/server/execute.ts | New deflector adapter execute function. Logic is clear and conservative (only auto-resolves on high-confidence KB match + terminal origin). Synchronous appendAudit calls block the event loop on each invocation; DB is properly closed in a finally block. |
| packages/adapters/deflector/src/server/audit.ts | Audit logger using synchronous appendFileSync/mkdirSync, which blocks the event loop on every call. Should use async equivalents to avoid stalling concurrent adapter runs. |
| packages/adapters/deflector/src/server/match.ts | Pattern matching logic is straightforward and conservative: only high-confidence patterns fire, malformed regexes are caught and skipped, and origin-terminal checks guard against premature resolution. |
| .github/workflows/deflector-docker-smoke.yml | New smoke-test workflow that builds the deflector Docker image and validates Node.js + better-sqlite3 resolve correctly inside it. Well scoped with paths filter and timeout-minutes: 60. |
Reviews (4): Last reviewed commit: "Merge pull request #2 from yaverabbas/fe..." | Re-trigger Greptile
| } | ||
|
|
||
| /** Alias for {@link isClaudeProviderQuotaError} — session/daily-limit exhaustion check. */ | ||
| export const isClaudeSessionExhaustionError = isClaudeProviderQuotaError; |
There was a problem hiding this comment.
Alias Missing From Package Entry Point
The package's server/index.ts uses an explicit named export list and does not re-export this new alias. A consumer importing isClaudeSessionExhaustionError from @paperclipai/adapter-claude-local/server therefore gets a TypeScript export error, despite the alias being declared as exported here.
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/adapters/claude-local/src/server/parse.ts
Line: 529
Comment:
**Alias Missing From Package Entry Point**
The package's `server/index.ts` uses an explicit named export list and does not re-export this new alias. A consumer importing `isClaudeSessionExhaustionError` from `@paperclipai/adapter-claude-local/server` therefore gets a TypeScript export error, despite the alias being declared as exported here.
How can I resolve this? If you propose a fix, please make it concise.…me (AIP-5933) Named export alias so callers can reference the session-exhaustion regex by the canonical name specified in the AIP-5933 acceptance criteria. Backed by CLAUDE_PROVIDER_QUOTA_RE (same pattern set). Co-Authored-By: Paperclip <noreply@paperclip.ing>
Adds a non-AI adapter that matches issues against a SQLite pattern KB and auto-resolves only high-confidence stranded recovery duplicates, with audit logging and pass-through release when uncertain.
Replace node:sqlite with lazy better-sqlite3 (Node 20 / Coolify image compatible) and make unmatched issues a true no-op so assignee clearing cannot orphan tickets outside heartbeat routing.
feat(adapters): add deflector_local deterministic pre-check adapter
Add deflector package.json to the Dockerfile deps COPY list, CI smoke that builds the image and loads better-sqlite3 on Linux, and Coolify cutover docs for pointing goc-paperclip at this fork's Dockerfile.
node:lts-trixie-slim currently lands on Node 24 with no better-sqlite3 prebuild; add make/g++ so the native module can compile during pnpm install.
Docker image build already succeeds; smoke verify must createRequire from packages/adapters/deflector so pnpm's nested better-sqlite3 is found.
chore(docker): deflector Dockerfile deps + Coolify cutover docs
Summary
Permanent upstream source fix for AIP-5916 session-exhaustion backoff guard.
Changes to
src/server/parse.tsnextDailyResetUtc(now, resetHourUtc=22)— fallback reset time when session exhaustion gives no explicit clock in the error textisClaudeSessionExhaustionErroras alias forisClaudeProviderQuotaErrorextractClaudeRetryNotBeforeto acceptopts.sessionExhaustionFallbackResetHourUtc; falls back tonextDailyResetUtcwhen a provider-quota error has no reset clockChanges to
src/server/execute.tstoAdapterResultasyncsessionExhaustionFallbackResetHourUtc: 22on provider-quota paths[paperclip]log when retry is scheduled for session exhaustionTracked in AIP-5933. Supersedes the in-place dist patch from AIP-5916.