Skip to content

get_workflow_state silently omits candidates for property_changed triggers on inherited (extends-chain) fields #2769

Closed

Description

@mstomar125

Context

Surfaced by independent multi-angle review of PR #2767 (#2763 — namespaced property-key lookup fix), which itself is correct for fields a node's own schema declares directly. This is a distinct, deeper gap in the same function, not introduced by that PR.

Problem

`get_workflow_state` (`packages/core/src/playbook/workflow_state.rs`) builds its `PropertyChanged` candidate keys by iterating `schema.fields`, where `schema` comes from `get_schema_with_relationships(&node.node_type)` → `get_schema_node`, a single-row fetch of that literal schema's own declared fields (confirmed: `get_schema_with_relationships` is a thin wrapper around `get_schema_node`, no extends-chain merge). This is a different, narrower field set than `NodeService::resolve_field_owners` in `services/node_service/schema.rs`, which explicitly walks the ADR-078 `extends` chain and merges each ancestor's fields.

So for a subtype node whose triggering field is declared only on an ancestor schema (the normal, intended `extends` usage — not redeclaring inherited fields), `get_workflow_state` never builds a candidate key for that field at all. `lookup_rules`'s ancestor fan-out (`ancestor_keys`/`renamespace_property_key` in `lifecycle.rs`) is correct and would resolve the key properly if given the chance — but it's never asked, because the candidate-key loop skips the field entirely.

The same gap independently affects `classify_failure`'s `walk_path_against_schema` (same file, ~line 346), which also builds `known_fields` from a single schema's own-declared fields at every hop — so a CEL condition referencing an inherited field is misclassified as `Unresolvable` ("likely a typo") instead of `NotYetMet`, and the AI-agent skill pipeline explicitly tells the LLM to treat `Unresolvable` as "likely misauthored."

Impact

  • `get_workflow_state` (used by the `GetWorkflowState` gRPC RPC and the local-agent's `get_workflow_state` tool) silently under-reports: a Play that is genuinely active and satisfied on a subtype node, triggering on an inherited field, is missing from the response with zero indication anything was skipped.
  • The local AI agent, using this as its "why hasn't my play fired" diagnostic tool, will incorrectly tell a user their Play references a nonexistent/misspelled field when it in fact correctly references a real inherited field that just hasn't changed value yet.
  • Not on the live-trigger dispatch path (`engine.rs`/`cel.rs`) — this is a diagnostic-only regression, not a functional break of the playbook engine itself. Real property_changed events still fire correctly regardless of this bug.

Suggested fix

Replace the `schema.fields`-only enumeration in both `get_workflow_state`'s candidate-key loop and `walk_path_against_schema`'s `known_fields` with the effective/merged field set (`resolve_field_owners` or equivalent, already used elsewhere in `schema.rs` for exactly this purpose).

Also found, worth bundling into the same fix

  • Scheduled/cron candidates use exact-string `node_type` match only (~line 166), no ancestor fan-out — inconsistent with the graph-event candidates a few lines above, which get fan-out for free via `lookup_rules`. A scheduled Play registered on a base type may be silently absent from `get_workflow_state` for a subtype node.
  • No shared helper for the `<node_type>.` namespaced-key format — now duplicated inline in at least 3 places (`workflow_state.rs`, `validation.rs`'s `UnnamespacedPropertyChangedKey` check, `lifecycle.rs`'s `renamespace_property_key`), plus a fourth near-identical (but semantically distinct, do not unify) copy in `node_service/conflicts.rs` for conflict-id discriminators. Extract `fn namespaced_property_key(node_type: &str, field: &str) -> String` (e.g. near `TriggerKey` in `types.rs`) and have the three playbook-domain sites share it.
  • Test coverage gap: the new regression test in get_workflow_state builds property_changed lookup keys from bare field names, never matching a real rule #2763's PR uses a flat `{"status": "done"}` property shape rather than the real `{"<node_type>": {"": value}}` nested storage shape — passes today only because `GraphResolver` has a fallback that checks both shapes. Worth a test using the realistic nested shape so a future narrowing of that fallback would be caught.

Non-goals

No change to the stored property format, the namespaced event key shape, or the live engine's trigger-dispatch path (`engine.rs`/`cel.rs`) — this is scoped to `get_workflow_state`'s and `classify_failure`'s read-only diagnostic candidate enumeration.

Activity

  1. added
    bug
    on Sep 21, 2026
  2. mstomar125 commented on Sep 22, 2026

    @mstomar125
    ContributorAuthor

    Frontend baseline: 260 test files passed, 5240 tests passed (68.64s). Starting implementation.

  3. self-assigned this
    on Sep 22, 2026
  4. mstomar125 commented on Sep 22, 2026

    @mstomar125
    ContributorAuthor

    Merged via PR #2817 (squash commit 1f15ace). Fixed get_workflow_state's PropertyChanged candidate-key loop, the scheduled/cron candidate loop, and classify_failure/walk_path_against_schema to merge fields and relationships across the ADR-078 extends chain via NodeService::resolve_field_owners/resolve_relationships, instead of a single schema's own directly-declared fields. Extracted namespaced_property_key as the shared <node_type>. builder across workflow_state.rs, validation.rs, lifecycle.rs, and node_service/mod.rs's compute_property_changes. Added WorkflowState.degraded_reasons so a schema/extends-chain resolution error during the query is visible on the response instead of a silent warn. Fixed the #2763 regression test to use the real nested property storage shape and added 6 new regression tests. Two deep review rounds surfaced and fixed 4 real issues in the new code (silent-degrade fallback going to an empty set instead of the pre-fix field/relationship set, two overclaiming degraded_reasons messages, duplicated warn+push logic, a missed 4th namespaced_property_key duplicate site, and resolve_relationships exposing the extends/extended_by type-system relationship as if it were a real traversable one) — all fixed and covered by tests. Non-blocking follow-ups filed from the same review rounds: #2828 (extends-chain consistency/staleness), #2829 (ADR-078 shadowing/collision not enforced for relationships or add-fields-only updates), #2830 (resolve_field_owners/resolve_relationships caching/efficiency), #2837 (GraphResolver::is_declared_many_relationship has the same own-schema-only gap), #2838 (local agent guidance doesn't mention degraded_reasons yet). #2819 (validate_play's write-time analog of the primary bug) was already filed separately and remains open.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

backendbug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions