Skip to content

resolve_field_owners/resolve_relationships: uncached, sequential per-hop, duplicated chain-flatten logic #2830

Closed

Description

@mstomar125

Context

Surfaced during review of PR #2817 (core#2769 — get_workflow_state/classify_failure now merge fields and relationships across the ADR-078 extends chain via NodeService::resolve_field_owners/resolve_relationships).

Problem

Three related efficiency/reuse gaps in the new extends-chain-merge calls, none of them correctness bugs — get_workflow_state is a diagnostic, out-of-band query path, not a hot or live-trigger path:

  1. Uncached. resolve_field_owners/resolve_relationships re-walk the extends chain and re-fetch every schema in it from the store on every call, with no cache. PlaybookLifecycleManager already has an established cache for exactly this kind of data (ancestor_cache, populated by PlaybookEngine::refresh_ancestor_cache) — the new calls don't reuse it (and structurally can't as written, since NodeService doesn't have access to the lifecycle manager's cache).
  2. Sequential, not concurrent, per hop. walk_path_against_schema calls resolve_field_owners and resolve_relationships one after another (two full chain-walks) at every hop of every path, for every condition, for every candidate rule. They're independent of each other and could run concurrently via tokio::try_join! rather than sequentially.
  3. resolve_relationships hand-rolls chain-walk+dedup instead of generalizing the existing helper. resolve_field_owners uses crate::schema::extends_chain::flatten_chain_fields to flatten+dedup the per-schema field lists it collects walking the chain. resolve_relationships (added in this PR) walks the same chain shape but reimplements the dedup loop inline (a HashSet<String> of seen names) rather than generalizing flatten_chain_fields (or introducing a shared chain-flattening helper parameterized over "what has a .name") that both could call.

Impact

None of these affect correctness. get_workflow_state is explicitly a diagnostic/out-of-band query (see its module doc), not the live engine's trigger-dispatch path, so the extra DB round-trips are a performance/code-quality concern under interactive use (an AI agent calling this tool repeatedly), not a functional one.

Suggested approach

Not prescribed — options include: an in-memory cache on NodeService (or a request-scoped one threaded through get_workflow_state) for the resolved chain per node_type, per-hop tokio::try_join! for the two independent resolve calls, and either generalizing flatten_chain_fields to work over both SchemaField and SchemaRelationship (both have a .name) or extracting a small shared dedup_by_name-style helper in extends_chain.rs.

Non-goals

No change to PlaybookLifecycleManager::ancestor_cache's existing scope (graph-event/scheduled trigger matching) or to the live engine's trigger-dispatch path.

Activity

  1. mstomar125 commented on Sep 23, 2026

    @mstomar125
    ContributorAuthor

    Frontend: 5264 passed

  2. self-assigned this
    on Sep 23, 2026
  3. added a commit that references this issue on Sep 23, 2026
    c518ea3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions