Repository navigation
Description
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:
- Uncached.
resolve_field_owners/resolve_relationshipsre-walk theextendschain and re-fetch every schema in it from the store on every call, with no cache.PlaybookLifecycleManageralready has an established cache for exactly this kind of data (ancestor_cache, populated byPlaybookEngine::refresh_ancestor_cache) — the new calls don't reuse it (and structurally can't as written, sinceNodeServicedoesn't have access to the lifecycle manager's cache). - Sequential, not concurrent, per hop.
walk_path_against_schemacallsresolve_field_ownersandresolve_relationshipsone 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 viatokio::try_join!rather than sequentially. resolve_relationshipshand-rolls chain-walk+dedup instead of generalizing the existing helper.resolve_field_ownersusescrate::schema::extends_chain::flatten_chain_fieldsto 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 (aHashSet<String>of seen names) rather than generalizingflatten_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
mstomar125 commentedon Sep 23, 2026
Frontend: 5264 passed
Generalize flatten_chain_fields for relationships, run per-hop resolv…