Skip to content

fix(responses): scope tool authority to current turn - #796

Closed
luvs01 wants to merge 6 commits into
devfrom
codex/fix-tool-reauthorization-in-zed-relay
Closed

luvs01 wants to merge 6 commits into
devfrom
codex/fix-tool-reauthorization-in-zed-relay

Conversation

@luvs01

@luvs01 luvs01 commented Oct 30, 2026 •

Copy link
Copy Markdown
Owner

Current integration at f136afb920669752f9f7fa2b754dcaf682970e92

Integrated upstream dev 86b72a689c21b97b0a425303e64b54ccceeb530a. The original twelve-file change is preserved alongside dev's item-provenance filter, Advisor admission policy, max-output completion settings, and new test registrations. Independent read-only comparison found no lost change or blocking conflict. Current declarations narrow the selection-filtered bridge names; replayed declarations cannot widen authority. Omitted/partial Chat and Messages catalogs retain their deferred-delivery contract, and the direct Messages path does not translate signed history twice.

Native Windows with pinned Bun1.4.4 and isolated homes: seven related direct/namespace/continuation/explicit-empty/undeclared-tool files pass 421 cases / 2,699 assertions; both test-layout guards pass 29 cases / 579 assertions. Typecheck covers 2,253 source files; structure/privacy/file-size gates and diff whitespace checks pass. No new production edit was required after integration. Exact-head Cross-platform CI41132164875 and Catalog41132164723 succeeded; all required checks pass and no unresolved review thread remains. Ready is verified separately; upstream publication remains with Duri. Historical CI and the original 70-failure attempt below are not carried forward as this head's result. Maintainer/security and native application acceptance remain separate.

Motivation

Responses continuations must not gain tool authority or namespace identity from declarations prepended while expanding previous_response_id. The first implementation also made omitted/partial Chat and Messages catalogs strict, widened an existing named tool selection at delivery, and translated direct Messages history a second time. Its original CI run failed 70 existing cases.

Description

  • Snapshot current-turn names for normalization on every wire, while preserving deferred Chat/Messages delivery for omitted and partial catalogs.
  • Keep the additional membership guard for actual explicit-empty catalogs and Responses replay boundaries. Ordinary Responses delivery retains its existing validation and diagnostics; initial hosted-sidecar deferred behavior remains intact.
  • Intersect delivery names with the existing tool_choice selection and require mapped canonical identities to belong to the current catalog. Ambiguous historical bare aliases fail safely; current canonical spellings remain callable.
  • Project current function names from direct decoders, including legacy Chat functions, without calling bridgeConversation() or releasing live decode charges.
  • Expand continuation coverage and add real direct-Messages shared-budget and namespace-identity regressions. Register both new files in the explicit domain map and independent golden.

Verification for current HEAD 5910d062eb02ff72fab9fd416a47f207b6a297f3

The product source and tests at this HEAD are unchanged from the tested source commit ec4bc25901fae21f715f57cd2b5e338d9081a0f5. The final additive commit only reorders two registrations to avoid dev's independent insertion at the same location; no branch merge or history rewrite was used. Layout/golden tests were rerun (29 passed), and read-only integration previews preserve the two dev names and both new names exactly once, without duplicate keys.

Native Linux, repository-pinned Bun 1.4.4 (38afee6c8), isolated fixture homes and synthetic suppliers.

Focused file Passed
protocol-antigravity-direct-chat.test.ts 16
protocol-antigravity-direct-messages.test.ts 16
advisor-responses-wiring.test.ts 55
server-anthropic-billing.test.ts 68
responses-required-chat-tool.test.ts 16
explicit-empty-tool-catalog.test.ts 132
explicit-empty-tool-catalog-history.test.ts 118
current-turn-tool-catalog-direct.test.ts 2
current-turn-tool-catalog-namespace.test.ts 8

431 passed, 0 failed, 3,378 assertions. Every one of the 70 failures from the original CI job was matched by test name to a passing final local result. The six original failing files and their expectations were not edited.

Red-to-green evidence:

  • Direct planner/delivery under one shared signed-history budget: original HEAD returned HTTP 413 in both JSON/SSE cases; the final code passes with zero bridge calls, zero premature decode-charge releases and zero budget overflows.
  • Historical bare versus current namespaced identity: after the initial fixes, four of eight cases emitted the historical identity. Canonical provenance filtering makes all eight pass, including positive current-canonical controls and refusal-not-cached checks.
  • Continuation tests cover strict Responses and explicit-empty refusal, deferred Chat/Messages behavior, normalization, adapter/runTurn and JSON/SSE.

Additional checks passed: layout + golden (29 cases, 579 assertions); native typecheck (2,236 files); structure SSOT; file-size ratchet; privacy scan; staged diff check; isolated GUI build.

The import-graph bun run test:changed reached the actual dev merge base 8a6cea9c168666733d97dd8172cbe6296b1b0104, then waited before any test lane on a pre-existing user-scoped lock. Its recorded process identity matches an unrelated live sites-preview process, so the guard cannot safely reclaim it. The waiting wrapper was cancelled (exit 130) before any test lane. This run is unexecuted, not passing evidence. The queue guard, lock and owner process remain unchanged; no OCX_TEST_NO_QUEUE bypass was used. Hosted Cross-platform CI 41009836383 completed successfully on this exact HEAD: all four Linux shards actually ran and passed, along with the requested gates and final aggregate. Catalog async contracts also passed. The 11 conditional skips, including Windows/macOS and the alternative test changed lane, are not execution evidence. Devin resolved both original review findings after checking the fixes; final PR approval remains separate. No Windows, macOS or live-provider execution is claimed. The PR remains draft.


Codex Task


Devin Review

Summary by CodeRabbit

  • Bug Fixes
    • Tool calls are now checked against the tools available in the current request, so tools mentioned only in earlier responses can’t authorize a call.
    • Namespaced tools are matched to their current identity, preventing calls from being executed under a previous namespace.
    • Direct Messages requests now retain tool names correctly across JSON and streaming responses, without duplicate processing or translation-budget charges.
  • Tests
    • Added coverage for current-request tool catalogs, response continuations, and namespaced tool handling.

@coderabbitai

coderabbitai Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between 3ea8965 and 5910d06.

Files selected for processing: 12
  • scripts/test-layout/layout-responses.json
  • src/lib/empty-tool-catalog.ts
  • src/server/responses-undeclared-tool-guard.ts
  • src/server/responses/adapter-delivery.ts
  • src/server/responses/request-prepare.ts
  • src/server/responses/run-turn-execution.ts
  • structure/transports/response-turn-membership.md
  • structure/transports/responses-wire-shapes.md
  • tests/fixtures/test-layout-expected.json
  • tests/responses/current-turn-tool-catalog-direct.test.ts
  • tests/responses/current-turn-tool-catalog-namespace.test.ts
  • tests/responses/explicit-empty-tool-catalog-history.test.ts

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

Walkthrough

Responses requests now capture current-turn tool names and filter tool bridge maps against catalog membership before delivery. The changes cover direct Messages decoding, replayed history, and namespace identity, with tests for JSON and SSE responses.

Changes: Current-turn tool catalog

Layer / File(s) Summary
Capture current-turn catalog membership
src/lib/empty-tool-catalog.ts, src/server/responses-undeclared-tool-guard.ts, src/server/responses/request-prepare.ts, structure/transports/response-turn-membership.md, structure/transports/responses-wire-shapes.md
Request preparation records declared and canonical tool names. Canonical-only wire-name collection and catalog restrictions define current-turn membership. The transport documentation describes the membership rules.
Filter tool maps during execution
src/server/responses/adapter-delivery.ts, src/server/responses/run-turn-execution.ts
Adapter delivery and run-turn execution derive tool bridge maps from the current catalog restriction.
Validate direct, continuation, and namespace cases
tests/responses/current-turn-tool-catalog-direct.test.ts, tests/responses/current-turn-tool-catalog-namespace.test.ts, tests/responses/explicit-empty-tool-catalog-history.test.ts, tests/fixtures/test-layout-expected.json, scripts/test-layout/layout-responses.json
Tests cover direct Messages catalog capture, replayed tool names, namespace changes, and omitted or partial catalogs in JSON and SSE responses.

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

Change: Bug fix

Suggested reviewers: lidge-jun

Merge Risk: Minimal · previous review 5910d

No actionable merge-blocking risk is established by the supplied evidence.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 45.45% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documenta… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: limiting Responses tool authority to the current turn. It matches the implementation and stated objectives.
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.
Full details: Docstring Coverage

Explanation

Docstring coverage is 45.45% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 11 functions across 8 files. (4 skipped: 4 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · 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.

@github-actions

github-actions Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

✅ Deterministic PR hygiene checks passed.

@github-actions github-actions Bot added the bug Something isn't working label Oct 30, 2026
devin-ai-integration[bot]

This comment was marked as resolved.

luvs01 commented Oct 30, 2026

Copy link
Copy Markdown
Owner Author

Taking ownership of the requested Linux/code follow-up at 8da8dbae401d7d23599449f111815f200ce200e2. I have read the current reviews and the failed affected-tests log (70 assertion failures). First priority is restoring the documented omitted/partial Chat and Messages deferred-tool contract while preserving strict Responses and explicit-empty enforcement; the direct-Messages translation-budget review will be checked as part of the same boundary. The original linked Codex Task and its commit remain the handoff source.

Current remote head, reviews, CI, and visible activity are being checked in isolated workspaces. The old task's unpublished workspace is not accessible from this session, so I am not claiming that it is idle or empty. Any publication will preserve the current commit ancestry and re-check the remote head before a normal fast-forward update. These PRs stay separate; this ACK does not authorize a merge, force push, installed-app replacement, or security/permission setting change.

Separate current-turn normalization from explicit-empty and replay enforcement.
Keep tool-choice filtering and canonical namespace provenance at delivery.
Read direct decoded tool names without bridging signed history a second time.

Restore the 70 existing regressions and add direct-budget and namespace
continuation coverage while retaining historical-tool refusal.
Place the two current-turn test registrations after the existing entries.
This preserves the same mapping while allowing dev's independent graceful
output registrations to integrate without a textual conflict. The explicit
map and independent golden previews retain all four names exactly once.

luvs01 commented Oct 30, 2026

Copy link
Copy Markdown
Owner Author

Current HEAD: 5910d062eb02ff72fab9fd416a47f207b6a297f3 (additive child of ec4bc25901fae21f715f57cd2b5e338d9081a0f5). The source/test fix is unchanged. GitHub initially could not start PR CI because both this PR and dev inserted independent entries at the start of the same test-layout shard. Moved only this PR's two entries to the bottom; this keeps the mapping identical and avoids the textual conflict without merging branches or rewriting history.

Layout + independent golden tests pass (29 cases / 579 assertions). Read-only integration previews with exact dev 3ea89653f5727aea41948ddbd5e833f74afe3e36 contain both graceful-output registrations and both current-turn registrations exactly once, with no duplicate JSON keys. All four corresponding files are present in the integration preview. The 431-case focused result remains evidence for the unchanged product source/tests; new-head CI is checked separately.

@luvs01

luvs01 commented Oct 30, 2026 •

Copy link
Copy Markdown
Owner Author

No description provided.

lidge-jun and others added 3 commits October 31, 2026 04:42
…ly suite (lidge-jun#8016)

* test(claude): report the hardened local-CA ACL in the first-party apply suite

The local-CA ACL inspection spawns PowerShell under the shared 30 s principal budget, which a loaded hosted Windows runner exhausted (windows 1/11 of lane=all run 41073826161: local_ca_path_unsafe after 30095 ms). This suite covers first-party apply; inject the private ACL for the real current SID through the existing seam. Native inspection stays covered by claude-intercept-local-ca-windows.test.ts.

* test(claude): read the cached SID inside the injected ACL runner and reset it in finally

Review: no separate principal lookup before the environment snapshot; reset the seam even if the hardening drain throws.

---------

Co-authored-by: JUN <[email protected]>
* fix: compare file identity with bigint stat

NTFS file IDs can exceed 2^53, where adjacent IDs are equal as JS numbers. Take dev/ino from stat calls made with { bigint: true } wherever a module compares file identity, and add a shared FileIdentity helper.

* test: register file-identity tests in a layout shard and scan stat calls with balanced parentheses

* test: resolve guard scopes by declaration and ignore strings and comments

* test: mask template text and regex literals, require same-line method bodies and an exact bigint options argument

* test: recognize regex literals after keywords in the identity tripwire

* fix(oauth): name the best-effort catches on the rewritten lock line

* fix(oauth): name the best-effort metadata parse catch beside the lock line

---------

Co-authored-by: JUN <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

aardvark bug Something isn't working codex

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants