Skip to content

JVNAUTOSCI-2614: simplify capability discovery and relation coverage - #333

Merged
witbrock merged 16 commits into
mainfrom
codex/JVNAUTOSCI-2614-minimal-final
Aug 1, 2026
Merged

witbrock merged 16 commits into
mainfrom
codex/JVNAUTOSCI-2614-minimal-final

Conversation

@witbrock

@witbrock witbrock commented Aug 1, 2026 •

Copy link
Copy Markdown
Member

User outcome

Let the model choose the smallest dependable authorised plan for ordinary work, with direct tools, small compositions, and represented workflows compared as peers. Do this without adding a universal selector, task-specific route, authority gate, readiness gate, or finality mechanism.

Root cause

The existing live prompt and capability descriptions already told the model to prefer the smallest adequate path. The failure was in the interface actually shown to the model:

  • Luna hydrated several alternatives together.
  • The correlated result batch fitted within the 24 KB model-context budget.
  • The result bounder nevertheless divided that budget equally per result.
  • The larger direct relation tool was compressed to a schema-only projection, losing its canonical description and planner guidance, while the competing workflows retained theirs.

That made “equal footing” false in the model-visible context. Another prompt or selection gate would have compensated for, rather than corrected, that defect.

What changed

  • Preserve a complete correlated tool-result batch whenever the aggregate already fits the context budget; compact individual results only when the aggregate genuinely exceeds it.
  • Tell the model to hydrate all alternatives being compared in one exact-name capability request.
  • Expose every delegated registered tool through a complete alphabetical purpose index; exact-name discovery hydrates canonical descriptions, planner hints, effect metadata, and argument schemas.
  • Keep direct tools, small compositions, and represented workflows as peers on the existing adaptive surface.
  • Remove the persisted semantic registered-tool index/prewarmer and the superseded workflow-first selector fragments.
  • Put general relation-coverage and reified-role guidance on the relation tool interface, not in a task-specific prompt.
  • Make predicate incidence page-first and give the model an explicitly cheap default query shape: limit 20, previews/snippets/type counts off.
  • Defer structural preview hydration until after deduplication, sorting, and paging.
  • Narrow the represented entity-information workflow to genuinely multi-source work.
  • Remove the AgentTest capability-grant path and Jira metadata that existed only to exercise it.

No supervision-specific prompt, noun route, person route, selector stage, workflow, retry policy, authority override, or finality patch was added. A contemplated read-only-workflow finality exception was deliberately removed because it did not cause the demonstrated choice failure and would have been compensating machinery.

Across src/ and docs/, the final diff is a net 98 lines smaller than current main; the larger additions are regression tests.

Validation

Deterministic

  • 20 focused adaptive-context/capability tests passed.
  • 224 affected backend tests passed (9 dependency deprecation warnings).
  • The two final review-only simplifications were followed by a 31-test relation-suite rerun: 31 passed.
  • Ruff F,E9 and git diff --check passed.
  • Static MCP manifest parity was regenerated and checked.
  • All review threads are addressed.

Exact gpt-5.6-luna real paths

The accepted read campaign used commit 656c70ad; final head differs only by the two test-only callable simplifications in 7e7dd30d.

  • 75/75 observed model calls across read and effect campaigns used OpenAI Responses with gpt-5.6-luna, profile #V#openai_gpt_5_6_luna_responses_profile, cache off, and store=false.
  • Relation family: 6/6 complete across exact wording, nearby paraphrases, and a named-entity variant. Every answer returned Timothy Pistotti, Rebecca Allcock, Minjung Kim, and Bin Zhang.
  • Each relation run used one non-exact discovery followed by one batched exact hydration of all alternatives. None launched a workflow.
  • Exact three-run median: 61.583 s, 89,113 prompt tokens, 7 tool calls. This remains expensive, but improved from the immediately preceding candidate’s 63.519 s, 98,357 tokens, and 10 tool calls while preserving 3/3 correctness.
  • Genuine multi-step read: a useful bounded multilingual person dossier completed by direct composition.
  • Trivial control: “capital of France” returned Paris in 12.537 s with one model call and no tools.
  • Jira control: the ordinary turn honestly reported Jira unavailable because the deployment-global Jira account is excluded from ordinary-turn delegation; it did not claim success or mutate Jira.
  • Reversible authorised effect: Luna created one private user-scoped hasNote assertion, read back exactly one match, retracted it, and read back absence.
  • Independent canonical cleanup verification found zero exact marker matches and zero assertion-ID matches; canonical_publication=false.

Scope and remaining observation

The change fixes the evidenced discovery/context inequality and the measured incidence-query cost. It does not bundle context projection, deadline/finality repair, workflow-worker readiness machinery, or a generic answer fallback. Relation retrieval is now correct on the accepted exact-Luna corpus, but its ~89k median prompt-token cost is still a material economy target for future measured simplification.

Jira: JVNAUTOSCI-2614

Copilot AI review requested due to automatic review settings August 1, 2026 06:18

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR removes the registered-tool semantic retrieval/reranking machinery and replaces capability discovery with a complete, unranked “purpose index” so the adaptive model can select tools/workflows by name and hydrate full schemas on demand. It also reworks predicate-incidence and relation preview hydration to be page-first to reduce measured latency, and updates prompts/metadata to clarify relation coverage and reified-role reasoning.

Changes:

  • Replace ranked capability retrieval with an alphabetical, compact purpose index plus exact-name schema hydration.
  • Make predicate incidence aggregate/sort over a cheap skeleton first, then hydrate only the selected page (previews/type counts/role expansion).
  • Add scoped AgentTest “trusted capability grants” (only when canonical server scope matches) and extend Jira update metadata to be ordinary-turn effect-gated.

Reviewed changes

Copilot reviewed 23 out of 23 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tests/backend/test_von_generate_workflow_instances.py Adds coverage for resolving AgentTest trusted capabilities from canonical scope.
tests/backend/test_tool_metadata_service.py Updates expectations for revised tool descriptions/planner hints and new default payloads.
tests/backend/test_registered_tool_capability_retrieval_service.py Removes tests for the deleted registered-tool semantic retrieval index.
tests/backend/test_predicate_incidence_page_first.py New tests asserting page-first predicate-incidence hydration and preview defaults.
tests/backend/test_internal_mcp_jira_tools.py Verifies jira_update_issue ordinary-turn exclusion/effect defaults.
tests/backend/test_internal_mcp_catalogue_builds.py Asserts updated predicate-incidence description in the default catalogue.
tests/backend/test_entity_information_retrieval_workflow_vontology_service.py Updates workflow purpose/discovery exemplars away from person/role-specific phrasing.
tests/backend/test_concept_relation_service_uncertainty.py Adjusts incidence calls for include_concept_preview default change.
tests/backend/test_concept_relation_service_extent_index.py Adds batching/paging tests for relation preview hydration.
tests/backend/test_agent_test_replay_mode_service.py New unit tests for trusted capability grant scope/name validation.
tests/backend/test_adaptive_turn_service.py Updates adaptive-turn messaging and validates the new complete purpose index behaviour.
src/backend/workflows/repo_seed_bundles/entity_information_retrieval_workflow_seed_bundle.json Bumps seed_version and revises workflow description/content/exemplars.
src/backend/services/tool_metadata_service.py Revises schema-discovery vs incidence guidance; updates defaults (previews/type counts).
src/backend/services/registered_tool_capability_retrieval_service.py Deletes the registered-tool semantic retrieval/index implementation.
src/backend/services/concept_relation_service.py Implements page-first incidence hydration; adjusts relation preview batching and materialisation paths.
src/backend/services/agent_test_replay_mode_service.py Adds trusted capability grant env parsing with exact scope matching and name validation.
src/backend/services/adaptive_turn_service.py Introduces compact purpose index output; removes registered-tool semantic retrieval ranking.
src/backend/server/utils_flask.py Removes prewarm of the deleted registered-tool semantic index.
src/backend/server/routes/von_routes.py Wires AgentTest trusted capability resolution into /von/generate adaptive turns.
src/backend/mcp_server/vontology_mcp.json Updates tool descriptions/input docs to reflect new coverage/incidence guidance and defaults.
src/backend/mcp_server/mcp_stdio_server.py Aligns include_concept_preview default to False for predicate incidence.
src/backend/integrations/internal_mcp/catalogue.py Aligns catalogue definitions/schemas and Jira update ordinary-turn effect metadata.
docs/engineering/von_workflow_language_manual.md Updates documentation to describe purpose-index discovery (no semantic reranker).

Comment thread src/backend/services/concept_relation_service.py Outdated
Copilot AI review requested due to automatic review settings August 1, 2026 07:01

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 18 out of 18 changed files in this pull request and generated no new comments.

Suppressed comments (2)

src/backend/services/concept_relation_service.py:1609

  • Setting _materialise_all_hits=True forces find_relations_with_argument onto the unbounded query_relationship_extent_index path even when there is no predicate filter. If the extent index is unavailable or times out, the current incoming-relations logic can fall back to a broad canonical aggregation, which is the high-cardinality scan this tool generally tries to avoid for deadline safety. This makes predicate-incidence/coverage discovery much more sensitive to transient extent-index outages.

Recommendation: when _materialise_all_hits=True and there is no exact predicate filter, treat an extent-index failure as a bounded/partial result (complete=False) rather than attempting the broad canonical aggregation fallback.

        payload = find_relations_with_argument(
            concept_id=concept_id,
            argument_index=query_argument_index,
            predicate_filter=predicate_filter,
            relation_kind=query_relation_kind,
            include_text_snippets=include_text_snippets,
            # Incidence aggregation only exposes bounded sample groundings, so
            # resolve previews there instead of for every raw relation hit.
            include_concept_preview=False,
            include_uncertain=include_uncertain,
            uncertainty_mode=uncertainty_mode,
            uncertainty_statuses=uncertainty_statuses,
            _materialise_all_hits=True,
        )

src/backend/services/tool_metadata_service.py:707

  • default_payload here implies include_concept_preview defaults to False, but the actual MCP entrypoints for find_relations_with_argument still default include_concept_preview to True when the argument is omitted (e.g. internal MCP catalogue and stdio handler). This means the system is not actually “default expensive previews off” for relation reads unless the caller explicitly passes the flag, and it makes default_payload misleading as a representation of runtime defaults.

To match the PR goal and the guidance in the planner hint, the runtime defaults should also be flipped to False (or default_payload should avoid claiming a default it doesn’t control).

        "default_payload": {"include_concept_preview": False, "limit": 20},
        "planner_hint": (
            "Use for content-bearing relationships after resolving the anchor. "
            "Start predicate-filtered around limit 20 with previews off; hydrate "
            "selected concepts only when needed. A hit proves existence, not list "

Copilot AI review requested due to automatic review settings August 1, 2026 08:13
Comment thread tests/backend/test_concept_relation_service_extent_index.py Fixed
Comment thread tests/backend/test_concept_relation_service_uncertainty.py Fixed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 21 out of 21 changed files in this pull request and generated no new comments.

Suppressed comments (1)

src/backend/services/adaptive_turn_service.py:647

  • _bounded_capability_catalogue_output() always emits capability_page_projection. The updated tests indicate that projection should be omitted for non-exact discovery pages (where results are already compacted via purpose_index + per-capability discovery references), and only kept for exact-name pages where schema omission needs explaining. Keeping it unconditionally increases output size and contradicts the intended bounded output shape.
            **base,
            "next_offset": next_offset,
            "capabilities": [dict(item) for item in entries],
            "capability_page_projection": projection,
        }

Copilot AI review requested due to automatic review settings August 1, 2026 08:44

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 21 out of 21 changed files in this pull request and generated no new comments.

Copilot AI review requested due to automatic review settings August 1, 2026 09:07
@witbrock
witbrock marked this pull request as ready for review August 1, 2026 09:13
@witbrock
witbrock merged commit 571c827 into main Aug 1, 2026
5 checks passed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 21 out of 21 changed files in this pull request and generated no new comments.

Suppressed comments (1)

src/backend/services/concept_relation_service.py:1636

  • _collect_all_argument_hits_for_incidence currently copies every hit via dict(hit) even though find_relations_with_argument is being called with _materialise_all_hits=True. For large relation sets (e.g. the 12k+ row cases covered in tests), this doubles peak memory by keeping both payload['hits'] and all_hits copies alive at once. Since these hit dicts are created locally by find_relations_with_argument and are only used for incidence aggregation, you can append dicts directly and only copy non-dict Mapping instances defensively.
        batch_hits = payload.get("hits")
        if isinstance(batch_hits, list):
            all_hits.extend(
                dict(hit) for hit in batch_hits if isinstance(hit, Mapping)
            )

@witbrock
witbrock deleted the codex/JVNAUTOSCI-2614-minimal-final branch August 1, 2026 14:15
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.

2 participants