Skip to content

feat(dsh): send the prompt's Scope to the gateway provider - #2965

Open
Fengzdadi wants to merge 4 commits into
oceanbase:masterfrom
Fengzdadi:feat/dsh-gateway-scope-header
Open

Fengzdadi wants to merge 4 commits into
oceanbase:masterfrom
Fengzdadi:feat/dsh-gateway-scope-header

Conversation

@Fengzdadi

@Fengzdadi Fengzdadi commented Dec 2, 2026 •

Copy link
Copy Markdown
Collaborator

Which issue or RFC does this PR close?

Part of #2250.

Follows #2873 (merged), which lets DeepSeek Harness (DSH) leave prompt-time context to the PowerContext gateway.

Rationale for this change

Behind the gateway, DSH's turns are prepared, checked, and captured in the one Scope set by PC_GATEWAY_DEFAULT_SCOPE, while the plugin already resolves a Scope for each workspace and uses it for prompt capture and MCP tools. Sending that Scope as X-PowerContext-Scope-ID lets the gateway work in the same Scope as the rest of the plugin, so one gateway serves several workspaces. This follows Pi (#2893, POWERCONTEXT_PI_GATEWAY_PROVIDER) and OpenCode (#2903).

Recall replay, Core's checks, and capture all follow the Scope header, so every model request of a prompt must select the same Scope. The header therefore comes from the prompt's own Scope resolution and nothing else.

A failed, timed-out, or empty resolution is not a resolution to the gateway's default Scope. Omitting the header in that case would let the gateway recall from and capture into PC_GATEWAY_DEFAULT_SCOPE instead of the workspace's Scope, as noted on RFC #3003 (review comment). Without a usable Scope the plugin therefore marks the request internal, which matches its own path: it skips recall and capture when nothing resolves.

What changes are included in this PR?

  • Setting. A new setting names the llm-pi-ai provider that routes through the gateway: the patch setting gatewayProvider (a string), or POWERCONTEXT_DSH_GATEWAY_PROVIDER, which takes precedence. Only requests whose provider equals it get the headers below, so a provider that DSH calls directly never receives them.

  • When the header is sent. Only while prompt recall is off, through the same llm-pi-ai/request-headers hook that sends the conversation and internal-turn headers. With recall on, the hook is not registered, as before.

  • Which Scope. The header carries the Scope that the prompt's pre-step resolved.

    • Gateway routing keeps its own snapshot per session. DSH runs agent/pre-step before every step of the agent loop, but only the step that brings the prompt's messages resolves the Scope. That resolution resets the snapshot and records its result, an unresolved result included.
    • Nothing else changes the snapshot: not a later step of the prompt, such as a tool continuation, and not an MCP tool call's resolution. A tool call's resolution may succeed after a failed pre-step, use another cwd, or fail.
    • The request hook is synchronous and makes no network call.
  • Internal requests. Compaction, session-title, and auto-review requests also carry the Scope header, as in Pi, so Core checks them in the same Scope as the session's turns. They still carry X-PowerContext-Turn: internal and no conversation header.

  • Fallback. A request to the gateway provider carries X-PowerContext-Turn: internal and no Scope or conversation header in these cases:

    • the prompt resolved no Scope;
    • it resolved a Scope whose ID the header cannot carry;
    • the request cannot be matched to a prompt, because it has no session ID or no prompt of the session has resolved yet.

    Every request to the gateway provider therefore either carries the prompt's Scope or is internal.

    • What the gateway does with it. It does not prepare, inject, replay, steer, or capture an internal request. Core still runs both checks, before_send and before_release, in PC_GATEWAY_DEFAULT_SCOPE.
    • ID syntax. The gateway accepts one ID of 1–256 visible ASCII characters without a comma and answers HTTP 400 invalid_scope_id otherwise. Scopes from early releases can have other IDs, and a non-Latin-1 ID would also make Headers.set throw inside the hook. This follows _scope_headers in the prefixed extraction (feat(gateway): bind model requests to an explicit Scope #2810).
    • No reuse. A prompt whose resolution fails does not reuse an earlier prompt's Scope.
    • Diagnostic. The plugin logs one content-free gateway_scope diagnostic per such prompt, not one per request: outcome: skipped, reason: scope_unresolved or scope_id_unsupported, never the ID.
    • Rest of the plugin. Scope resolution, prompt capture, /pc, and MCP tools still use the resolved Scope.
  • Other providers. Requests to other providers are unchanged. The conversation header and the internal marker work as before.

  • Docs. The DSH guide (en and zh) and the plugin README document:

    • the setting, and which requests carry the Scope header;
    • that each prompt keeps its own resolution, even when an MCP tool call resolves the Scope again later in the prompt;
    • the internal fallback, what the gateway does with such a request, and in which Scope Core checks it;
    • that, when Core enforces authentication, the gateway's Core credential needs scope.contributor on each workspace Scope the plugin sends. This is in the grant list the guide already gives for PC_GATEWAY_DEFAULT_SCOPE and every Scope a request selects;
    • that the gateway key does not limit which Scope a request selects: any client that can call the gateway can select any Scope that the gateway's Core credential can access. This links to the Server guide's "Gateway request Scope".
  • Bundle. lib/index.js and lib/index.d.ts are rebuilt.

Are there any user-facing changes?

Yes. POWERCONTEXT_DSH_GATEWAY_PROVIDER / gatewayProvider is new and unset by default. While it is unset, DSH sends no Scope header, as before.

Once it is set and prompt recall is off, the gateway prepares, checks, and captures in each workspace's Scope. When Core enforces authentication, the gateway's Core credential therefore needs scope.contributor on every such Scope as well as on PC_GATEWAY_DEFAULT_SCOPE.

A prompt without a usable Scope gets no recall from the gateway and is not captured by it. Core still checks its requests in PC_GATEWAY_DEFAULT_SCOPE.

No breaking changes.

How was this change tested?

The plugin has two kinds of evidence: behavior tests that drive its registered DSH hooks with fixtures, and real-host runs.

Behavior tests

New behavior tests in integrations/dsh/plugins/powercontext/tests/automatic-path.spec.ts drive the registered agent/pre-step, MCP tools/pre-execute, and llm-pi-ai/request-headers hooks.

  • Named provider. With recall off, requests to the named provider carry the Scope, internal requests included. The setting works from both the patch and the environment, and the environment overrides the patch.

  • Other providers. Requests to any other provider carry no Scope header, and the prompt makes only Scope resolution and capture requests.

  • Unnamed or recall on. Without a named provider, or with recall on, no request carries the Scope header.

  • Snapshot. The gateway Scope stays the pre-step's for the rest of the prompt in each of these cases:

    • an MCP call resolves the Scope after the pre-step failed;
    • a later step of the agent loop runs the pre-step with no new messages;
    • an MCP call from another cwd resolves another Scope;
    • an MCP call from another cwd fails to resolve.

    The next prompt takes what its own pre-step resolves. The first and the last two cases fail against the plugin source before this fix.

  • Unresolved prompt. Its gateway requests, session-title included, carry X-PowerContext-Turn: internal and nothing else from the plugin. A direct provider still gets the conversation header. The plugin logs exactly one gateway_scope diagnostic per prompt, with no prompt text in it.

  • Unmatched request. A gateway request before any prompt resolved, or without a session ID, is internal and reported.

  • Unsupported IDs. A Scope ID with a comma, a space, non-ASCII Latin-1 text, non-Latin-1 text, or more than 256 characters marks the gateway requests internal and raises no exception. The plugin's capture still uses the Scope, and the plugin logs one scope_id_unsupported diagnostic per prompt without the ID. IDs at the edges of the accepted syntax (!, ~, 256 characters) are still sent.

  • Failed resolution. A later prompt whose resolution fails drops the previous prompt's Scope.

  • Config. A non-string gatewayProvider is rejected.

Commands

Commands run on dc990368a, offline, macOS:

npm_config_offline=true pnpm --dir integrations/dsh/plugins/powercontext test        # 1228 passed
npm_config_offline=true pnpm --dir integrations/dsh/plugins/powercontext test:e2e    # 9 passed
npm_config_offline=true pnpm --dir integrations/dsh/plugins/powercontext build       # no diff to lib/, dsh-pet/lib/ or operations.generated.ts
node --test integrations/dsh/plugins/dsh-pet/tests/adapter.test.mjs integrations/dsh/plugins/dsh-pet/tests/package.test.mjs   # 5 passed
(cd integrations/dsh/plugins/powercontext && ./node_modules/.bin/tsdown --config ../../../cindy/tsdown.config.ts)   # Cindy worker.cjs unchanged
node --test integrations/cindy/tests/*.test.cjs                                     # 26 passed
uv run python integrations/cindy/scripts/package.py                                  # exit 0
.venv/bin/python scripts/generate_integration_lifecycle.py --check                   # passed
uv run pytest tests/test_integration_manifest.py tests/test_ci_changes.py tests/test_dsh_profiles.py tests/test_dsh_cli.py   # 307 passed, 1 skipped
uv run prek run --files <changed files>                                              # passed, ty check included

tests/companion-memory.spec.ts passed in each of five separate runs on this commit.

The plugin has no typecheck target. tsc --noEmit over its tsconfig.json reports only errors that exist on master, none on the lines this PR adds.

tests/e2e has no test of DSH behind the gateway.

Gateway handling of the fallback headers

Setup:

  • A Server and a pc-gateway built from this branch (cargo build --locked --offline). The two plugin commits do not touch gateway/.
  • Core: SQLite over UDS, access enforced, protection enforcing.
  • Gateway: PC_GATEWAY_SEDIMENT=on, and PC_GATEWAY_DEFAULT_SCOPE set to a Scope other than the workspace Scope, each Scope holding a distinct synthetic fact.
  • Upstream: a local stub Responses upstream.

Responses requests sent with curl, with the Server's log of each Core operation and its Scope:

Headers Gateway Core Upstream
X-PowerContext-Turn: internal only (the plugin's fallback) 200 two check_context calls in the default Scope; no prepare, no capture no prepared block, no steering text, no X-PowerContext-* header
none 200 prepare, two checks and a capture in the default Scope the default Scope's fact injected
the workspace Scope and a conversation ID 200 prepare, two checks and a capture in the workspace Scope the workspace fact injected
internal and the workspace Scope 200 two checks in the workspace Scope; no prepare, no capture —

A second gateway was set up with PC_GATEWAY_DEFAULT_SCOPE set to a valid ID that names no Scope:

  • internal alone: Core's check_context failed with ScopeNotFoundError for that ID, and the gateway answered 503 gate_paused (gate rejected: HTTP 404).
  • internal with the workspace Scope: 200.

The gateway source agrees. request_scope falls back to PC_GATEWAY_DEFAULT_SCOPE. internal turns off steering, injection, replay, prefix capture, and sediment, but not the checks. Core's check_context authorizes scope.read on the request's Scope when access is enforced, and authorizes nothing when access control is off.

Real-host run

Real-host run with the plugin's lib/ as committed in dc990368a. The client was DSH 0.2.2-rc.5 (--profile headless, @deepseek-ai/dsh-llm-pi-ai 0.2.2-rc.5). It went through the Server and gateway above, set up as the guide shows (PC_GATEWAY_UPSTREAM_URL_RESPONSES at the stub, PC_GATEWAY_UPSTREAM_PROFILE naming the target), to the stub upstream. No model provider was called.

  • Credentials. PC_GATEWAY_CORE_TOKEN was the Server's bootstrap token.
  • Plugin. POWERCONTEXT_DSH_PROMPT_RECALL=false, POWERCONTEXT_DSH_CAPTURE_PROMPTS=false, and POWERCONTEXT_DSH_GATEWAY_PROVIDER=powercontext-gateway, using the guide's provider entry.

Three prompts went to powercontext-gateway in one session: a new session, a follow-up, and a prompt that the stub answered with an mcp__powercontext__search_memory call. The call's scope_id was copied from the Scope routing in DSH's runtime context. A recording proxy in front of the gateway showed:

  • Gateway provider. All five model requests carried X-PowerContext-Scope-ID with the workspace Scope that binding resolution returned. That includes the request that continued after the tool call, whose pre-step resolved nothing. In rc.5, request.provider in llm-pi-ai/request-headers is the provider's key under providers.
  • Agent loop. The four agent-loop requests also carried X-PowerContext-Conversation-ID. The session-title request carried X-PowerContext-Turn: internal and no conversation header.
  • Gateway behavior.
    • Core prepared the three prompts in the workspace Scope and ran every check there.
    • The gateway injected the workspace fact into the first and third prompts, including the tool continuation, and sent no default-Scope fact upstream.
    • It captured the three turns in the workspace Scope.
    • The search call returned the workspace fact.

One more prompt ran in a new session with the plugin's Server credential replaced by an invalid one, so that its Scope resolution failed:

  • binding resolution returned 401;
  • the agent-loop request and the session-title request both carried only X-PowerContext-Turn: internal;
  • Core ran their four checks in PC_GATEWAY_DEFAULT_SCOPE;
  • nothing was prepared or captured;
  • the runtime context carried no Scope routing;
  • the turn completed.

Not covered by a real run

  • Compaction and auto-review. None occurred, so the headers on them are covered only by the tests.
  • Unsupported IDs. A Scope ID that the header cannot carry is covered only by the tests.
  • Diagnostics. The plugin's gateway_scope diagnostic is covered only by the tests; DSH's headless output does not show plugin diagnostics.
  • Direct provider. A provider that DSH calls directly while the gateway provider is named is covered by the tests. It was also checked in a real run of this change on an older base, with a gateway set up for feat(gateway): bind Core-approved target to upstream sends #2630's model destination, which revert(gateway): fully revert #2630 upstream target binding #2920 reverted.
  • Restricted credential. A gateway Core credential that holds only the listed roles, and what a request that selects a Scope without them receives: these runs used the Server's bootstrap token.
  • Other modes. Core with access control off, Web mode (dsh web), and a real model provider.

AI usage statement

Claude Code (Claude Opus 5.5) wrote the change, ran the checks and runs listed above, and wrote this description. It reviewed the diff twice, once for the implementation and once for users and the documented contract, and checked each claim in this description against the diff, the tests, the gateway and Server source, and the runs' recorded requests and Server logs. Another Claude Code session (Claude Opus 5.5) reviewed the change and this description, checked the gateway claims against ingress.rs, and reran the plugin's tests (1228 passed), the bundle rebuild (no diff to lib/), and the new tests against the source before the fix and after the first commit.

@hidb4ai hidb4ai added module:core Core: PR changes under src/ module:gateway Primary module: model gateway, protocols and context injection and removed module:core Core: PR changes under src/ labels Dec 2, 2026

@hidb4ai hidb4ai left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 504179c. The provider-scoped header and documented fallback are reasonable; no new database tables. Focused tests, plugin HTTP acceptance, and a real DSH 0.2.2-rc.5 → current Gateway → OceanBase/real-provider run passed, with workspace Scope routing and capture isolated from the default Scope. The real run used disabled protection and did not exercise compaction, auto-review, or a successful MCP tool call. Merge score: 80/100.

@hireview001

Copy link
Copy Markdown
Collaborator

The affected modules are Gateway. @frf12, please coordinate follow-up. Gateway: @frf12 @happy-v587 @NeverENG. Please coordinate the review of the affected changes.

@hireview001
hireview001 requested a review from frf12 December 2, 2026 18:41
// A request without a session ID cannot be matched to a prompt's resolution.
if (!sessionId) return { scopeId: undefined, attempt: 0 }
const key = keyFor(sessionId, undefined)
return { scopeId: cache.get(key)?.scopeId, attempt: attempts.get(key) ?? 0 }

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] Keep the gateway Scope fixed to the prompt resolution

If pre-step Scope resolution fails but a later MCP tool retry succeeds, forTool repopulates this cache and subsequent gateway requests for the same prompt switch from PC_GATEWAY_DEFAULT_SCOPE to the workspace Scope. Snapshot the pre-step result separately so tool retries cannot change the Scope used for that prompt's preparation, checks, and capture.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review of 504179c2cbb974fe8e7379e2d5f4ed38197ba301: this P2 remains in the current source and published bundle. The concrete state transition is:

  1. forPreStep increments the prompt attempt, deletes the cache entry, and fails to resolve a Scope. forGateway then returns no Scope, so the first model request uses the gateway default.
  2. registerMcpPolicy later calls forTool for the same session. A successful retry writes the workspace Scope into that same cache without starting a new prompt attempt.
  3. forGateway at lines 126–130 now returns the workspace Scope, so the next model request of the same prompt selects a different Scope.

This splits recall replay, admission checks, and turn capture across Scopes within one tool loop. Please retain an independent pre-step snapshot for gateway routing, including an unresolved result, and add a regression covering failed pre-step resolution followed by successful MCP resolution. The tool's recovery must not mutate the prompt's gateway snapshot. This is a source-level execution trace; I did not rerun a host reproduction in this re-review.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Executed this at 504179c. A regression through the registered pre-step, MCP policy, and request-header hooks fails: failed pre-step resolution produces no Scope header; successful MCP recovery then changes the header to the workspace Scope without another pre-step. I sent those emitted headers through the gateway built from this head, authenticated real Core/SQLite, and a real model provider using a service principal granted only the two test Scopes. Both requests returned 200, but Core before_send/before_release used the default Scope for the first and the workspace Scope for the second. An ungranted Scope was rejected by Core (403; gateway 503). Please keep the gateway snapshot separate from the tool-resolution cache. Hook scheduling was driven by a test fixture; this is not a full native DSH-host reproduction, and injection/capture were disabled for this focused authorization check.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the trace and for the reproduction through the registered hooks. Fixed in 5f7e68b. The fallback for an unresolved prompt also changes, in its own commit dc99036, so you can take the fix without it. Both commits sit on a merge of master (fd1aef2).

5f7e68b: snapshot fix

  • Gateway routing no longer reads the resolution cache that MCP tool calls write. It keeps its own snapshot per session.
  • Only the pre-step's resolution writes it. That resolution runs on the step that brings the prompt's messages, resets the snapshot, and records its result, an unresolved result included.
  • MCP tool resolutions never touch it. Neither do later steps of the same prompt: DSH runs the pre-step before every step, and a tool continuation brings no new messages, so it resolves nothing.

Regressions in tests/automatic-path.spec.ts drive the registered agent/pre-step, MCP tools/pre-execute, and llm-pi-ai/request-headers hooks:

  • a failed pre-step followed by a successful MCP resolution, which is the case you reproduced;
  • a successful pre-step followed by an MCP resolution from another cwd that returns another Scope;
  • a successful pre-step followed by an MCP resolution from another cwd that fails.

All three fail against the source of 504179c and pass now.

A fourth test covers a pre-step with no new messages, such as the step that continues after a tool call. It resolves nothing and leaves the snapshot as it is.

dc99036: fallback

A prompt with no usable Scope no longer falls back to the gateway's default Scope. That covers an unresolved prompt, an ID the header cannot carry, and a request that cannot be matched to a prompt. Such a request to the gateway provider now carries X-PowerContext-Turn: internal and no Scope or conversation header. Every gateway request therefore either carries the prompt's Scope or is internal.

This follows frf12's point on #3003 (r4789222611): a failed or timed-out resolution is not a resolution to the default Scope, and omitting the header lets the gateway recall and capture there.

What the gateway does with an internal request without a Scope header, from the source and a run against this branch's gateway and an enforced Core:

  • it does not prepare, inject, replay, steer, or capture;
  • Core still runs check_context twice (before_send and before_release) in PC_GATEWAY_DEFAULT_SCOPE;
  • with a default Scope ID that names no Scope, Core's check fails and the gateway answers 503.

The DSH guide (en and zh) and the plugin README describe this. The gateway_scope diagnostic is unchanged.

What ran

Offline on dc99036:

  • the plugin's tests (1228) and test:e2e (9);
  • bundle rebuild with no diff;
  • dsh-pet and Cindy tests;
  • lifecycle --check;
  • the Python tests that read the DSH guide (307 passed, 1 skipped);
  • prek, including ty check.

Real DSH 0.2.2-rc.5 run with the plugin's lib/ as committed in dc99036, through a Server and gateway built from this branch to a stub upstream (no model provider), with the bootstrap token:

  • three prompts, including an MCP call and its tool continuation: all five model requests carried the workspace Scope, and prepare, checks, and capture all ran in it;
  • a prompt whose Scope resolution failed (401 from an invalid plugin credential): both of its requests were internal, with checks in the default Scope and nothing prepared or captured.

Not run

  • a Core credential restricted to the listed Scopes;
  • compaction and auto-review behind the gateway;
  • an unsupported Scope ID on a real host;
  • a real model provider.

hidb4ai's run with a service principal limited to two Scopes remains the only restricted-credential evidence.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified fixed at dc99036 and in its merge with master eb0a354. The registered-hook regression now keeps identical internal headers before and after successful MCP recovery; only the next prompt selects the resolved workspace Scope. I ran those emitted headers through a real authenticated Core/SQLite, the compiled Gateway, and a real Qwen provider with injection and capture enabled: both internal requests returned 200 but created no Source in either Scope; the next prompt returned 200 and created one Source in the workspace while the default Scope remained empty. An ungranted Scope returned Core 403 / Gateway 503 with no model choices. Both runs stopped their child processes. Host hook scheduling was fixture-driven; this is not a native DSH-host acceptance claim.

@NeverENG NeverENG left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review report — host integration

Reviewed head: 504179c2cbb974fe8e7379e2d5f4ed38197ba301.

Result: one P2 finding remains; fix and re-review recommended.

Gateway routing still reads the same mutable Scope cache that MCP tool recovery populates. If pre-step resolution fails, the first model request uses the gateway default Scope; a successful MCP resolution can then move subsequent requests of that prompt to the workspace Scope. Preserve a separate pre-step routing snapshot, including failure. Details and the exact execution trace are in the existing finding thread.

Reviewed configuration, Scope resolution and MCP callers, provider header filtering, published bundle, documentation, and relevant tests. Existing CI for this head passed 1,223 package tests and runtime/package checks. Those checks do not establish a real DSH-to-Gateway acceptance for the newly added Scope header.

Validation scope: I inspected the current source, complete PR diff, existing review threads, and CI logs for this head. No new local test run was performed in this re-review. The cited CI ran a test merge with its then-current base; it is not proof of a merge with the latest master. This is a comment-only report, not an approval or an unconditional merge recommendation.

@hidb4ai hidb4ai left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The existing Scope-snapshot defect is reproduced at this head; the thread now includes registered-hook reproduction and real Gateway/Core/model evidence. Tool recovery can switch the Scope used by later requests of the same prompt. Holding approval until gateway routing retains its own pre-step snapshot. A separate local companion-memory cancellation test timed out on this head while passing on the base; its test and implementation are unchanged, so I have not attributed that failure to this change.

The gateway Scope header read the session's resolution cache, which MCP tool
calls also write. After a failed pre-step, a later successful tool resolution
moved the rest of the prompt's model requests from the gateway's default Scope
to the workspace Scope, splitting recall replay, Core's checks and capture
across Scopes within one tool loop. A tool resolution for another cwd, or a
failed tool refresh, could likewise change or drop the prompt's Scope.

Gateway routing now keeps its own snapshot per session. The pre-step's Scope
resolution, which runs on the step that brings the prompt's messages, starts
it as unresolved and fills it; later steps of the prompt and tool resolutions
leave it unchanged.
…le Scope

Without a Scope header the gateway prepares, injects and captures a turn in
its default Scope, not the workspace's. A failed, timed-out or empty Scope
resolution is not a resolution to that Scope, so a prompt that resolved no
Scope, or one whose ID the header cannot carry, now sends its requests to the
gateway provider with X-PowerContext-Turn: internal and no Scope or
conversation header. A request that cannot be matched to a prompt is treated
the same way. Every gateway request then either carries the prompt's Scope or
is internal; Core still checks internal requests, in the gateway's default
Scope. Requests to other providers are unchanged.

The gateway_scope diagnostic keeps its event, outcome and reasons. The DSH
guide (en and zh) and the plugin README describe the fallback.

@hidb4ai hidb4ai left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-reviewed dc99036. The independent prompt snapshot fixes the reported Scope drift, including failed resolutions; marking unresolved requests internal prevents default-Scope preparation/capture. Provider-specific routing and the documented default-Scope authorization checks are reasonable. Real Core/SQLite -> Gateway -> Qwen verification passed on both this head and the current master merge with injection/capture enabled: internal requests create no Sources, the next resolved prompt captures in the workspace, and an ungranted Scope is denied. The merged automatic-path suite passes all 71 tests. Full plugin run: 1224 passed, 2 skipped, 2 timeouts; both timeout cases also fail on the declared base, so they are not attributed to this change. Plugin rebuild matches checked-in output; Rust 1.95.0 locked build passes. Current CI: 14 success, 35 skipped. Merge with master eb0a354 is clean (tree adc8a10fd34a6f98571eb37f656a7847370c6f78). No new table or migration; the new configuration option is acceptable. Merge score: 82/100. Native DSH host scheduling, non-SQLite backend acceptance, and actual recalled-context quality were not established by these focused tests.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

module:gateway Primary module: model gateway, protocols and context injection

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants