Skip to content

fix(ai): claim chat approvals before executing writes - #1072

Merged
izadoesdev merged 3 commits into
mainfrom
codex/ai-approval-dedup
Oct 6, 2026
Merged

izadoesdev merged 3 commits into
mainfrom
codex/ai-approval-dedup

Conversation

@izadoesdev

@izadoesdev izadoesdev commented Oct 5, 2026 •

Copy link
Copy Markdown
Member

When two tabs approve the same chat write, the API now claims the approval in Redis before running the agent. Claims include caller, organization, chat and approval identity with a24-hour lifetime; duplicate approvals become denied tool results. Existing Redis failure behavior is preserved.

Validation: formatting, root lint/types,20native route tests,10conversation tests and101memory tests on current main after #1067. The rebase preserves allthree owned patches and four reviewed source files exactly. Actual CodeRabbit source coverage is the completed four-file baseline plus the completed two-file namespace fix review; the final head has fresh Greptile and CI requests. Historical failed checks are not carried as passes.

Independent slice against main. Maintainer contribution with AI assistance; all review findings have supported fixes or dispositions. Merge waits for final-head checks and every configured reviewer to finish.

@vercel

vercel Bot commented Oct 5, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
databuddy-status Ready Ready Preview Oct 6, 2026 6:10am UTC
2 Skipped Deployments
Project Deployment Actions Updated
dashboard Skipped Skipped Oct 6, 2026 6:10am UTC
documentation Skipped Skipped Oct 6, 2026 6:10am UTC

@unkey-deploy

unkey-deploy Bot commented Oct 5, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Unkey Deploy

Name Status Preview Inspect Updated (UTC)
links (preview) Ready Visit Preview Inspect Oct 6, 2026 6:10am

@coderabbitai

coderabbitai Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 1ac44238-f0f1-48db-b559-5203a4470a5b
📥 Commits

Reviewing files that changed from the base of the PR and between 9ba2c14 and f50ab5c.

📒 Files selected for processing (2)
  • apps/api/src/routes/agent-business-context.test.ts
  • apps/api/src/routes/agent.ts

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 0 remain after this review.

📜 Recent review details
⚠️ CI failures not shown inline (6)

GitHub Actions: CI / 1_Check Types.txt: fix(ai): claim chat approvals before executing writes

Conclusion: failure

View job details

Current runner version: '2.337.0'
 Runner name: 'blacksmith-4vcpu-ubuntu-2404-Runner-cc1f44991d'
 Runner group name: 'blacksmith scale sets - blacksmith-4vcpu-ubuntu-2404'
 Machine name: 'ip-172-31-64-123'
 ##[group]GITHUB_TOKEN Permissions
 Contents: read
 Metadata: read
 ##[endgroup]
 Secret source: Actions
 Cache mode: write
 Prepare workflow directory
 Prepare all required actions
 Getting action download info
 Download action repository 'actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1' (SHA:3d3c42e5aac5ba805825da76410c181273ba90b1)
 Download action repository 'oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6' (SHA:0c5077e51419868618aeaa5fe8019c62421857d6)
 Download action repository 'actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9' (SHA:55cc8345863c7cc4c66a329aec7e433d2d1c52a9)
 Setting BLACKSMITH_ACTIONS_RESULTS_URL to https://results-receiver.actions.githubusercontent.com/
 Complete job name: Check Types
 A job started hook has been configured by the self-hosted runner administrator
 ##[group]Run '/setup.sh'
 shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
 env:
   BLACKSMITH_RUNNER_MESSAGE_WAIT_MS: 260
   BLACKSMITH_RUNNER_ACQUIRE_JOB_MS: 834
   BLACKSMITH_CHECK_RUN_ID: 111894712291
   BLACKSMITH_JOB_DISPLAY_NAME: Check Types
   GITHUB_ACTIONS_CACHE_MODE: write
 ##[endgroup]
 Logging daemon started (blacksmithd for logs)
 Results daemon started (blacksmithd for results)
 Background adoption and SSH setup started (PID: 3431)
 ----------------------------------------
 View this job: https://app.blacksmith.sh/databuddy-analytics/runs/37348977761/jobs/111894712291
 SSH Access (using your GitHub SSH key):
   ssh -p 64003 runner@blacksmith-4vcpu-ubuntu-2404-runner-cc1f44991d.vm.blacksmith.sh
 No GitHub SSH key? Add one at:
 https://docs.github.com/en/authentication/connecting-to-github-with-ssh/adding-a-new-ssh-key-to-your-github-account
 ----------------------------------------
 VM ID: blacksmith-4vcpu-ubuntu-2404-Runner-c...

GitHub Actions: CI / Check Types: fix(ai): claim chat approvals before executing writes

Conclusion: failure

View job details

##[group]Run bun run check-types
 �[36;1mbun run check-types�[0m
 shell: /usr/bin/bash -e {0}
 env:
   BLACKSMITH_RUNNER_MESSAGE_WAIT_MS: 260
   BLACKSMITH_RUNNER_ACQUIRE_JOB_MS: 834
   GITHUB_REPO_NAME: databuddy-analytics/Databuddy
   TURBO_***REDACTED_SECRET_ASSIGNMENT***
   TURBO_TEAM: databuddy-oss
 ##[endgroup]
 $ dotenv -- turbo run check-types
 Attention:
 Turborepo now collects completely anonymous telemetry regarding usage.
 This information is used to shape the Turborepo roadmap and prioritize features.
 You can learn more, including how to opt-out if you'd not like to participate in this anonymous program, by visiting the following URL:
 https://turborepo.dev/docs/telemetry
    • Packages in scope: @databuddy/ai, @databuddy/api, @databuddy/api-keys, @databuddy/auth, @databuddy/basket, @databuddy/dashboard, @databuddy/db, @databuddy/devtools, @databuddy/docs, @databuddy/email, @databuddy/encryption, @databuddy/env, @databuddy/insights, @databuddy/links, @databuddy/mapper, @databuddy/migrate, @databuddy/notifications, @databuddy/nuxt, @databuddy/pulumi, @databuddy/redis, @databuddy/rpc, @databuddy/scan, @databuddy/sdk, @databuddy/services, @databuddy/shared, @databuddy/slack, @databuddy/status, @databuddy/test, @databuddy/tracker, @databuddy/ui, @databuddy/uptime, @databuddy/validation
    • Running check-types in 32 packages
    • Remote caching enabled
 ##[group]@databuddy/email:check-types
 cache hit, replaying logs ad144098c379337e
 $ tsc --noEmit
 ##[endgroup]
 ##[group]@databuddy/encryption:check-types
 cache hit, replaying logs 5db1532e42b2ea67
 $ tsc --noEmit
 ##[endgroup]
 ##[group]@databuddy/shared:check-types
 cache hit, replaying logs 143547c2d9b3bc51
 $ tsc --noEmit
 ##[endgroup]
 ##[group]@databuddy/migrate:check-types
 cache hit, replaying logs 7a857c9bc0d2bcf3
 $ tsc --noEmit
 ##[endgroup]
 ##[group]@databuddy/devtools:check-types
 cache hit, replaying logs 9d57da359e7fd4c1
 $ tsc --noEmit
 ##[endgroup]
 ##[group]@databuddy/devtools:buil...

GitHub Actions: CI / 2_Test.txt: fix(ai): claim chat approvals before executing writes

Conclusion: failure

View job details

##[group]src/query/simple-builder.test.ts:
 (pass) SimpleQueryBuilder.compile > compiles summary_metrics with its required filters [0.42ms]
 (pass) SimpleQueryBuilder.compile > compiles today_metrics with its required filters [0.23ms]
 (pass) SimpleQueryBuilder.compile > compiles events_by_date with its required filters [0.13ms]
 (pass) SimpleQueryBuilder.compile > compiles active_stats with its required filters [0.15ms]
 (pass) SimpleQueryBuilder.compile > compiles top_pages with its required filters [0.17ms]
 (pass) SimpleQueryBuilder.compile > compiles entry_pages with its required filters [0.08ms]
 (pass) SimpleQueryBuilder.compile > compiles exit_pages with its required filters [0.05ms]
 (pass) SimpleQueryBuilder.compile > compiles page_performance with its required filters [0.11ms]
 (pass) SimpleQueryBuilder.compile > compiles page_time_analysis with its required filters [0.06ms]
 (pass) SimpleQueryBuilder.compile > compiles top_referrers with its required filters [0.18ms]
 (pass) SimpleQueryBuilder.compile > compiles utm_sources with its required filters [0.15ms]
 (pass) SimpleQueryBuilder.compile > compiles utm_mediums with its required filters [0.07ms]
 (pass) SimpleQueryBuilder.compile > compiles utm_campaigns with its required filters [0.06ms]
 (pass) SimpleQueryBuilder.compile > compiles utm_terms with its required filters [0.08ms]
 (pass) SimpleQueryBuilder.compile > compiles utm_content with its required filters [0.05ms]
 (pass) SimpleQueryBuilder.compile > compiles traffic_sources with its required filters [0.08ms]
 (pass) SimpleQueryBuilder.compile > compiles browser_name with its required filters [0.08ms]
 (pass) SimpleQueryBuilder.compile > compiles os_name with its required filters [0.03ms]
 (pass) SimpleQueryBuilder.compile > compiles screen_resolution with its required filters [0.03ms]
 (pass) SimpleQueryBuilder.compile > compiles browsers_grouped with its required filters [0.04ms]
 (pass) SimpleQueryBuilder.compile > compiles device_types wi...

GitHub Actions: CI / Test: fix(ai): claim chat approvals before executing writes

Conclusion: failure

View job details

##[group]src/query/simple-builder.test.ts:
 (pass) SimpleQueryBuilder.compile > compiles summary_metrics with its required filters [0.42ms]
 (pass) SimpleQueryBuilder.compile > compiles today_metrics with its required filters [0.23ms]
 (pass) SimpleQueryBuilder.compile > compiles events_by_date with its required filters [0.13ms]
 (pass) SimpleQueryBuilder.compile > compiles active_stats with its required filters [0.15ms]
 (pass) SimpleQueryBuilder.compile > compiles top_pages with its required filters [0.17ms]
 (pass) SimpleQueryBuilder.compile > compiles entry_pages with its required filters [0.08ms]
 (pass) SimpleQueryBuilder.compile > compiles exit_pages with its required filters [0.05ms]
 (pass) SimpleQueryBuilder.compile > compiles page_performance with its required filters [0.11ms]
 (pass) SimpleQueryBuilder.compile > compiles page_time_analysis with its required filters [0.06ms]
 (pass) SimpleQueryBuilder.compile > compiles top_referrers with its required filters [0.18ms]
 (pass) SimpleQueryBuilder.compile > compiles utm_sources with its required filters [0.15ms]
 (pass) SimpleQueryBuilder.compile > compiles utm_mediums with its required filters [0.07ms]
 (pass) SimpleQueryBuilder.compile > compiles utm_campaigns with its required filters [0.06ms]
 (pass) SimpleQueryBuilder.compile > compiles utm_terms with its required filters [0.08ms]
 (pass) SimpleQueryBuilder.compile > compiles utm_content with its required filters [0.05ms]
 (pass) SimpleQueryBuilder.compile > compiles traffic_sources with its required filters [0.08ms]
 (pass) SimpleQueryBuilder.compile > compiles browser_name with its required filters [0.08ms]
 (pass) SimpleQueryBuilder.compile > compiles os_name with its required filters [0.03ms]
 (pass) SimpleQueryBuilder.compile > compiles screen_resolution with its required filters [0.03ms]
 (pass) SimpleQueryBuilder.compile > compiles browsers_grouped with its required filters [0.04ms]
 (pass) SimpleQueryBuilder.compile > compiles device_types wi...

GitHub Actions: CI / Test: fix(ai): claim chat approvals before executing writes

Conclusion: failure

View job details

m �[36m[api]�[0m
   �[2m├─�[0m �[36mflag_found:�[0m true
   �[2m├─�[0m �[36mflag_type:�[0m boolean
   �[2m├─�[0m �[36mflag_enabled:�[0m false
   �[2m└─�[0m �[36mflag_reason:�[0m BOOLEAN_DEFAULT
 �[90mstdout�[2m | src/integration/public-flags-http.test.ts�[2m > �[22m�[2mpublic flags HTTP integration�[2m > �[22m�[2madmin definitions and mutations�[2m > �[22m�[2mrequires manage:flags and returns private cache headers for definitions
 �[22m�[39m�[2m17:36:11.040�[0m �[36mINFO�[0m �[36m[api]�[0m
   �[2m├─�[0m �[36mflag_client_id:�[0m website-16
   �[2m├─�[0m �[36mflag_environment:�[0m
   �[2m└─�[0m �[36mflag_definitions:�[0m true
 �[90mstdout�[2m | src/integration/public-flags-http.test.ts�[2m > �[22m�[2mpublic flags HTTP integration�[2m > �[22m�[2madmin definitions and mutations�[2m > �[22m�[2mrequires manage:flags and returns private cache headers for definitions
 �[22m�[39m�[2m17:36:11.040�[0m �[36mINFO�[0m �[36m[api]�[0m
   �[2m└─�[0m �[36mflag_error:�[0m auth_401
 �[90mstdout�[2m | src/integration/public-flags-http.test.ts�[2m > �[22m�[2mpublic flags HTTP integration�[2m > �[22m�[2madmin definitions and mutations�[2m > �[22m�[2mrequires manage:flags and returns private cache headers for definitions
 �[22m�[39m�[2m17:36:11.040�[0m �[36mINFO�[0m �[36m[api]�[0m
   �[2m├─�[0m �[36mflag_client_id:�[0m website-16
   �[2m├─�[0m �[36mflag_environment:�[0m
   �[2m└─�[0m �[36mflag_definitions:�[0m true
 �[90mstdout�[2m | src/integration/public-flags-http.test.ts�[2m > �[22m�[2mpublic flags HTTP integration�[2m > �[22m�[2madmin definitions and mutations�[2m > �[22m�[2mrequires manage:flags and returns private cache headers for definitions
 �[22m�[39m�[2m17:36:11.043�[0m �[36mINFO�[0m �[36m[api]�[0m
   �[2m└─�[0m �[36mflag_error:�[0m auth_403
 �[90mstdout�[2m | src/integration/public-flags-http.test.ts�[2m > �[22m�[2mpublic flags HTTP integration�[2m > �[22m�[2madmin definitions and mutations�[2m > �[22m�[2mrequires manage:flags and returns private cache headers for definitio...

GitHub Actions: CI / Test: fix(ai): claim chat approvals before executing writes

Conclusion: failure

View job details

Print service container logs: 49358eb75d9148cf9ce42e3d7860a727_redis7alpine_ff18fd
 ##[command]/usr/bin/docker logs --details ***REDACTED_HIGH_ENTROPY_STRING***
  1:C 05 Oct 2026 17:31:06.352 # WARNING Memory overcommit must be enabled! Without it, a background save or replication may fail under low memory condition. Being disabled, it can also cause failures without low memory condition, see https://github.com/jemalloc/jemalloc/issues/1328. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
  1:C 05 Oct 2026 17:31:06.353 * oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
  1:C 05 Oct 2026 17:31:06.353 * Redis version=7.4.11, bits=64, commit=00000000, modified=0, pid=1, just started
  1:C 05 Oct 2026 17:31:06.353 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
  1:M 05 Oct 2026 17:31:06.353 * monotonic clock: POSIX clock_gettime
  1:M 05 Oct 2026 17:31:06.355 * Running mode=standalone, port=6379.
  1:M 05 Oct 2026 17:31:06.355 * Server initialized
  1:M 05 Oct 2026 17:31:06.357 * Ready to accept connections tcp
  1:M 05 Oct 2026 17:36:07.054 * 100 changes in 300 seconds. Saving...
  1:M 05 Oct 2026 17:36:07.055 * Background saving started by pid 188
  188:C 05 Oct 2026 17:36:07.057 * DB saved on disk
  188:C 05 Oct 2026 17:36:07.057 * Fork CoW for RDB: current 0 MB, peak 0 MB, average 0 MB
  1:M 05 Oct 2026 17:36:07.155 * Background saving terminated with success
 Stop and remove container: 49358eb75d9148cf9ce42e3d7860a727_redis7alpine_ff18fd
 ##[command]/usr/bin/docker rm --force ***REDACTED_HIGH_ENTROPY_STRING***
 ***REDACTED_HIGH_ENTROPY_STRING***
 Print service container logs: 6dfe3ca96eff4867821a4c30a76888a9_postgres17alpine_329efd
 ##[command]/usr/bin/docker logs --details ***REDACTED_HIGH_ENTROPY_STRING***
  sh: locale: not found
  .792 UTC [35] WARNING:  no usable s...
🧰 Additional context used
📓 Path-based instructions (3)
Source excerpt: When you discover a new performance improvement, optimization pattern, or fix a performance regression, add a concise bullet to the relevant section below in the same session.

📄 CodeRabbit inference engine (.cursor/rules/performance.mdc)

Files:

  • apps/api/src/routes/agent.ts
  • apps/api/src/routes/agent-business-context.test.ts
Source excerpt: MUST use Tailwind CSS defaults unless custom values already exist or are explicitly requested Source excerpt: MUST use motion/react (formerly framer-motion) when JavaScript animation is required Source excerpt: SHOULD use tw...

📄 CodeRabbit inference engine (.cursor/rules/ui-guidelines.mdc)

Files:

  • apps/api/src/routes/agent.ts
  • apps/api/src/routes/agent-business-context.test.ts
Source excerpt: description: Basic guidelines for the project so vibe coders don't fuck it up globs: alwaysApply: true when using 'text-right', always add 'text-balance' so its not ugly Source excerpt: description: Basic guidelines for the...

📄 CodeRabbit inference engine (.cursor/rules/01-MUST-DO.mdc)

Files:

  • apps/api/src/routes/agent.ts
  • apps/api/src/routes/agent-business-context.test.ts

Walkthrough

Approved tool calls now pass through a claim check before processing. The API route uses Redis claims scoped by user, organization, chat, and approval ID. Tests cover repeated approvals, concurrent requests, identity scope, model failure after a write, and Redis claim rejection.

Changes

Tool approval claims

Layer / File(s) Summary
Claim and deny repeated approvals
packages/ai/src/ai/agents/conversation.ts, packages/ai/src/ai/agents/conversation.test.ts
claimToolApprovals checks eligible approved tool parts in the latest message. If a claim fails, it marks the part denied and sets approval to false. Tests verify that resubmitting an approval does not execute the write again.
Redis-backed API route claims
apps/api/src/routes/agent.ts, apps/api/src/routes/agent-business-context.test.ts
The route claims approvals with Redis SET NX and a one-day expiry, using a key scoped by user, organization, chat, and approval ID. Redis errors are captured and allow the approval through. Route tests cover identity scope, concurrent requests, model failure after a write, and Redis claim rejection.

Priority: ⬇️ Low

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant AgentRoute
  participant claimToolApprovals
  participant Redis
  participant ToolExecution
  AgentRoute->>claimToolApprovals: Pass validated messages and claim callback
  claimToolApprovals->>Redis: Claim scoped approval key with NX and one-day expiry
  Redis-->>claimToolApprovals: Return claim result
  claimToolApprovals-->>AgentRoute: Return messages with duplicate approval denied
  AgentRoute->>ToolExecution: Process approved tool call
Loading

Merge Risk: ⚪ Minimal · up to f50ab

Approved tool actions now claim their approval once, so retries and concurrent dashboard requests cannot repeat the same approved write. A caller who deliberately changes the approval identifier could rerun an action they are already allowed to approve, but this does not grant extra access. The change appears ready to merge once its outstanding CI checks pass.

Security Architecture Review

Security architecture risk: 🟡 Moderate · up to f50ab

Identity-scoped atomic claims reduce duplicate writes without expanding caller permissions. Replay using a different approval identifier remains possible, however, and duplicate protection is unavailable during Redis failures. Claims also record an execution attempt rather than its outcome.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The supported replay path requires an authenticated caller able to submit an approved mutation message. Organization membership or API-key organization matching, accessible-website checks, and persisted-chat ownership constrain the route. The PR does not establish cross-tenant reachability or increase tool privileges; exact downstream resource limits were not fully inspected.

Security Findings and Attack Paths

  • observed — The retained reportable finding concerns altered-ID replay: a caller changes the submitted approval ID to obtain a fresh claim for the mutation payload. This condition predates the PR, whose base already accepted client approval messages without server-side approval binding. The new gate reduces identical-ID replay but does not resolve that existing finding.

Trust Boundaries and Controls

  • observed — Strong counterevidence limits the finding to replay rather than new authority: authorization precedes claiming, message validation remains, unsuccessful claims become denied approvals before conversion, and mutation tools retain confirmation checks and forward the original request headers into RPC context.

Resilience and Maintainability Implications

  • observed — Test assertions cover one write under concurrent identical claims and claim retention after a model failure following a write. Redis errors deliberately permit execution, and expiry ends duplicate protection. These controls provide bounded deduplication, not exactly-once mutation semantics or outcome reconciliation.

Hardening Proposals

  • proposed — For stronger replay protection, bind approvals to authoritative server-issued records containing caller, organization, tool, and payload identity. Track execution outcomes for reconciliation, preserve reservations for uncertain writes, and explicitly choose the failure policy for mutations when claim storage is unavailable.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 9 functions across 4 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: claiming chat approvals before executing writes to prevent duplicate actions.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 2
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🛠️ Fix failing CI checks 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@greptile-apps

greptile-apps Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[Medium risk] Adds approval deduplication to prevent duplicate write execution.

The PR appears safe to merge; the remaining forget-request issue is non-blocking.

Summary

Dashboard chat claims approved tool writes before sending messages to the model, so duplicate requests can be denied instead of repeating a write. The claim is scoped to the caller, organization, chat, and approval, and lasts 24 hours.

  • Dashboard chat denies a tool write when its approval was already used.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Validate chat and messages] --> B[Claim each approved action]
  B --> C{Claim won?}
  C -->|Yes| D[Run approved write]
  C -->|No| E[Deny repeated approval]
Loading

Reviews (5) · Last reviewed commit: "fix(api): scope approval claims to calle..."

Comment thread apps/api/src/routes/agent.ts
Comment thread apps/api/src/routes/agent.ts
Comment thread packages/ai/src/ai/agents/conversation.test.ts
@izadoesdev

Copy link
Copy Markdown
Member Author

@greptileai

Please re-review final head 9ba2c147ddd6b2f872213a8b989b538aa84ca522. Valid findings have been fixed and validated; intentional copy choices and optional refactors are explained in their resolved threads. Please check the final diff for remaining actionable issues.

@izadoesdev

Copy link
Copy Markdown
Member Author

@coderabbitai review

Please re-review final head 9ba2c147ddd6b2f872213a8b989b538aa84ca522. Valid findings have been fixed and validated; intentional copy choices and optional refactors are explained in their resolved threads. Please check the final diff for remaining actionable issues.

@coderabbitai

coderabbitai Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@izadoesdev

Copy link
Copy Markdown
Member Author

Fixed the general review's claim-namespace finding in f50ab5c633f819cadf1eca56eeaeb8a701b12028. The Redis key now includes the existing authenticated caller identity (including API-key identity) and the already authorized organization. Three native regressions reproduce interference without a saved chat on the old source and pass for separate session callers, separate API-key callers and separate organizations after this fix. The original scope still suppresses a retry, and concurrent requests still produce one write. Formatting, lint/types, 20 native tests and 10 conversation tests passed.

Retaining a consumed claim after a model/stream failure is deliberate: a write may already have happened. Releasing that claim without a durable execution outcome would allow duplicate writes. The existing 24-hour lifetime and logged Redis fail-open policy are preserved; an execution outcome ledger would be a separate behavior change.

Declining the optional 80% docstring advisory. There is no corresponding required repository coverage gate; the small claim helper and its behavioral tests express this slice's contract. Adding generic documentation to otherwise unchanged functions would expand its scope. The changed source still needs fresh configured review and exact-head CI before merging.

@izadoesdev

Copy link
Copy Markdown
Member Author

@greptileai

Please re-review final head f50ab5c633f819cadf1eca56eeaeb8a701b12028. Valid findings have been fixed and validated; intentional copy choices and optional refactors are explained in their resolved threads. Please check the final diff for remaining actionable issues.

@izadoesdev

Copy link
Copy Markdown
Member Author

@coderabbitai review

Please re-review final head f50ab5c633f819cadf1eca56eeaeb8a701b12028. Valid findings have been fixed and validated; intentional copy choices and optional refactors are explained in their resolved threads. Please check the final diff for remaining actionable issues.

@coderabbitai

coderabbitai Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@izadoesdev

Copy link
Copy Markdown
Member Author

@greptileai

Please re-review final head c977b90fac072bdfa6decf5715380897b80c28b7. Valid findings have been fixed and validated; intentional copy choices and optional refactors are explained in their resolved threads. Please check the final diff for remaining actionable issues.

…wo tabs

An approval card open in two tabs could be approved twice, and each
request ran the write. The chat route now claims every approved call in
Redis (per chat and approval id, for a day) before the agent runs; a
second claim turns that call into a denial saying it was already used,
so the model reports it instead of writing again. A Redis failure lets
the approval through and is logged, since the user did approve it.
@izadoesdev

Copy link
Copy Markdown
Member Author

@greptileai

Please re-review final head 1b10597b3d5df4916c7902adf14d71cffddb119e. Valid findings have been fixed and validated; intentional copy choices and optional refactors are explained in their resolved threads. Please check the final diff for remaining actionable issues.

@izadoesdev
izadoesdev merged commit a0d6116 into main Oct 6, 2026
25 checks passed
@izadoesdev
izadoesdev deleted the codex/ai-approval-dedup branch October 6, 2026 06:20

This branch was successfully deployed

2 active and 2 inactive deployments
Preview – databuddy-status — 1b10597b Deployed Oct 6, 2026 by vercel[bot]
links - preview — 1b10597b Deployed Oct 6, 2026 by unkey-deploy[bot]
Preview – documentation — 1b10597b Deployed Oct 6, 2026 by vercel[bot]
Preview – dashboard — 1b10597b Deployed Oct 6, 2026 by vercel[bot]
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