Repair exact tooling recovery and adaptive deadlines - #346
Merged
Merged
Conversation
JVNAUTOSCI-2623
There was a problem hiding this comment.
Pull request overview
Repairs the model-led Internal MCP tooling path by making concept fetches strictly bounded (exact ID / virtual concept / alias only), improving scoped-assertion recovery behaviour for denied canonical relationship writes, and replacing fixed timeouts with adaptive advisory/hard windows seeded by observed successful durations.
Changes:
- Tightens
fetch_conceptto avoid fuzzy/name resolution on misses, returning a typedconcept_not_foundresponse instead. - Adds adaptive deadline history to Internal MCP gateway execution, including seeding long-running tool windows and preserving timing policy through dynamic tool proxies.
- Refines scoped-assertion recovery eligibility for denied relationship writes by using canonical predicate typing (text vs concept) and reconciling successful recoveries more robustly.
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/backend/test_internal_mcp_transport_deadlines.py | Expands coverage for adaptive advisory/hard timeout learning, clamping, and late-success training. |
| tests/backend/test_internal_mcp_scoped_assertion_authority.py | Updates monkeypatch target to the new exact concept lookup API. |
| tests/backend/test_internal_mcp_fetch_concept_bounded.py | Adds new tests asserting bounded fetch_concept behaviour (exact hit, alias, virtual concept, typed miss). |
| tests/backend/test_internal_mcp_dynamic_tool_registration.py | Verifies dynamic proxies preserve target timing policy (bootstrap + derived windows). |
| tests/backend/test_internal_mcp_catalogue_builds.py | Updates catalogue timing assertions to the new adaptive/bootstrap policy and extends advisory-only coverage. |
| tests/backend/test_blocked_thing_parent_type.py | Updates monkeypatch target to the new exact concept lookup API. |
| tests/backend/test_adaptive_turn_service.py | Adds/adjusts tests for scoped-assertion recovery gating based on canonical predicate typing and object matching. |
| src/backend/services/relationship_write_service.py | Introduces canonical predicate object-kind resolution (text vs concept) for exact predicates. |
| src/backend/services/concept_external_identity_service.py | Removes stale max-time query wiring tied to the legacy fixed Mongo deadline. |
| src/backend/services/adaptive_turn_service.py | Tightens relationship-denial recovery affordances to require canonical predicate typing and improves recovery reconciliation keys. |
| src/backend/integrations/internal_mcp/gateway.py | Implements adaptive deadline history (successful max duration) and uses it to derive next advisory/hard windows. |
| src/backend/integrations/internal_mcp/dynamic_tool_loader.py | Ensures dynamic tool proxies inherit advisory timing and adaptive window seeds unless explicitly overridden. |
| src/backend/integrations/internal_mcp/catalogue.py | Makes fetch_concept bounded (exact/virtual/alias only) and returns typed not-found responses. |
Comment on lines
+444
to
+453
| resolved_id = resolve_concept_by_alias(concept_id) | ||
| if resolved_id and resolved_id != concept_id: | ||
| try: | ||
| concept = get_concept_by_concept_id_exact( | ||
| concept_id=resolved_id | ||
| ) | ||
| except ConceptNotFoundError: | ||
| concept = None | ||
| else: | ||
| concept = None |
Comment on lines
828
to
847
| @@ -665,15 +847,35 @@ def _record_failure( | |||
| metrics.saturations += 1 | |||
Comment on lines
+792
to
+807
| def _record_success( | ||
| self, | ||
| method_name: str, | ||
| duration_ms: float | None, | ||
| *, | ||
| include_in_adaptive_history: bool = True, | ||
| ) -> None: | ||
| self._total_calls += 1 | ||
| metrics = self._method_metrics[method_name] | ||
| metrics.calls += 1 | ||
| metrics.last_duration_ms = duration_ms | ||
| metrics.last_error = None | ||
| metrics.last_outcome = "completed" | ||
| if include_in_adaptive_history and duration_ms is not None: | ||
| self._record_successful_duration(method_name, duration_ms) | ||
|
|
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.
Outcome
Repairs the general model-led path behind JVNAUTOSCI-2623 without adding Gmail-, student-, email-address-, or arXiv-specific routing.
fetch_conceptnow performs bounded exact ID, registered virtual-concept, and exact CODE-alias lookup; misses return typedconcept_not_foundinstead of falling into broad lexical resolution.Evidence
git diff --checkpassed.#V#timothy_pistotti, reused the existing#V#has_emailassertion, and created no duplicate or mailbox mutation.Boundaries
not_indexedwith pending work; this change fixes its deterministic stale-import failure, not index population.