fix(witan): route inject-context through the deployment for a remote target - #272
Open
blarghmatey wants to merge 1 commit into
Open
fix(witan): route inject-context through the deployment for a remote target#272blarghmatey wants to merge 1 commit into
blarghmatey wants to merge 1 commit into
Conversation
…target `witan hook context` handed cfg.graph_uri straight to OmnigraphClient without ever consulting load_remote_config(). A remote_url-only target has no server field, so graph_uri fell through to the local default — the same split-brain #261 fixed for `witan serve`, still live on the context-injection path. Every new agent session on a deployed target opened with context read off the laptop while its own tool calls wrote the deployment. Route the remote case through the same tool-calling proxy _srv() builds (workflow_project_list/task_ready/workflow_session_list), matching how session-checkpoint already reaches the deployment. Branch-linked task association and stale-repo-case detection have no remote tool equivalent yet, so they degrade to empty/false for a remote target rather than lie — recorded via --debug, per tk-witan-hook-context- reads-the-local-store-on-a-de-dfb2c9. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Chdha3LCrycxhHUhTq2teK
Contributor
There was a problem hiding this comment.
Pull request overview
Routes context injection through the remote deployment, preventing accidental reads from the local graph.
Changes:
- Adds remote context retrieval through MCP tools.
- Selects remote or local context paths from configuration.
- Updates unreachable-deployment coverage.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
witan/context.py |
Adds shared rendering and remote reads. |
witan/cli/hooks.py |
Routes remote targets through the proxy. |
tests/test_context.py |
Updates remote failure-path coverage. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| return output | ||
|
|
||
|
|
||
| def inject_context_remote(server, remote_url: str, debug: bool = False) -> str: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What are the relevant tickets?
N/A — tracked internally as
tk-witan-hook-context-reads-the-local-store-on-a-de-dfb2c9in the witan multi-user service deployment project.Description (What does it do?)
witan hook context(theUserPromptSubmithook every agent session runs) calledcfg_module.load()and handedgraph_uristraight to a rawOmnigraphClient, never consultingload_remote_config().remote_url-only deployment target has noserverfield, sograph_urifell through to the local default (~/.local/share/witan/graph.omni) — the same split-brain agent-kit#261 fixed forwitan serve, still live on this path._srv()already builds (workflow_project_list/task_ready/workflow_session_list), matching howsession-checkpointalready reaches the deployment.## In-Flight Branchsection) and stale-repo-case detection have no remote-tool equivalent yet, so they degrade to empty/false for a remote target rather than lie about it — recorded via--debug, never silently.How can this be tested?
pytest tests/test_context.py: 27/27 pass. Updatedtest_inject_context_cli_survives_an_unreachable_deployment, which had pinned the old local-store-read behavior as expected — it now exercises the new tool-calling proxy's failure path instead, asserting the hook still degrades to empty output rather than raising.witansuite: 887 passed, 6 failed on this branch. Ran the identical suite on a cleanmainworktree (same shared venv) as a baseline: also 887 passed, 6 failed — same total, and 5 of the 6 failing tests are identical (test_contracts.pyx4,test_setup_cmd.pyx1; a known shared-venv witan-code import contamination, unrelated to these files). The 6th differs per run on both branches —test_elicit.py::test_supersede_confirmed_linksfailed here,test_event_loop_blocking.py::test_the_known_async_tools_are_still_async_and_still_covered[workflow_project_advance]failed on themainbaseline run — each passes in isolation on both branches, so this is pre-existing order-dependent flakiness, not something this diff introduced.ruff check/ruff format: no new lint debt vsmain(8 pre-existing errors, unchanged).witan hook context --debugfrom a checkout matching a deployed target, then confirm the correspondingworkflow_project_list/task_readycalls appear in that target's data-tier log under the caller's own actor.Additional Context
Part of the
wp-witan-multi-user-service-deployment-dcf6eeproject's phase-exit hardening — this is the same class of split-brain bug as #261, found while re-verifying that project's multi-user readiness.