Skip to content

Fix get_workflow_state property-key lookup to use namespaced keys - #2767

Merged
mstomar125 merged 1 commit into
mainfrom
issue-2763-workflow-state-namespaced-key
Sep 21, 2026
Merged

mstomar125 merged 1 commit into
mainfrom
issue-2763-workflow-state-namespaced-key

Conversation

@mstomar125

Copy link
Copy Markdown
Contributor

Summary

get_workflow_state built its property-changed-trigger candidate lookup keys from bare schema field names (e.g. "status"). Since #2762 (#2753's save-time enforcement), a property_changed trigger's property_key is always stored type-namespaced (<node_type>.<field>, e.g. "task.status") — the only spelling validate_play's UnnamespacedPropertyChangedKey check accepts, and the exact key trigger_keys_for_graph_event indexes it under.

The bare lookup key could therefore never match a real trigger's index entry: a rule scoped to a specific property key was silently absent from get_workflow_state's response even when its condition was currently satisfied. The wildcard (property_key: None) lookup path was unaffected.

Fix

Build the candidate lookup key as format!("{}.{}", node.node_type, field.name) instead of the bare field.name, matching the shape enforced at save time and indexed by trigger_keys_for_graph_event.

Verification

  • Confirmed via grep that this was the only property_key: Some(...) lookup-key construction site in get_workflow_state/its helpers.
  • Added a regression test (namespaced_property_changed_trigger_is_returned_as_candidate) that registers a Play with a correctly namespaced property_changed trigger, calls get_workflow_state for a node whose state satisfies the rule's condition, and asserts the rule is returned. Verified this test fails against the pre-fix bare-key code (left: 0, right: 1) and passes after the fix.
  • Updated an existing test (trigger_property_reference_reports_unresolvable) whose trigger fixture relied on the same bare-key coincidence (bare "status" in both trigger registration and the old buggy lookup) — now uses the correctly namespaced "wf_task3.status", and was confirmed to also fail against the pre-fix code for the same reason.
  • Checked the rest of get_workflow_state and its helpers for sibling bare-key assumptions the A bare property_key on a property_changed trigger never matches a real event #2753 namespacing change might have broken — none found; the wildcard lookup path and all other logic are untouched.
  • cargo test -p nodespace-core --lib playbook::workflow_state: 8/8 passed.
  • Full pre-push gate (test:all, cargo build --bin nodespaced, test:e2e, Tauri-seam integration tests): all green.

Non-goals

Scoped narrowly per the issue — does not touch the stored property format or the namespaced event key shape.

Closes #2763

Co-Authored-By: Claude Sonnet 5 [email protected]

get_workflow_state built property-changed lookup keys from bare schema
field names (e.g. "status"), but a property_changed trigger's
property_key is always stored type-namespaced (<node_type>.<field>,
e.g. "task.status") since validate_play started rejecting the bare
form. The bare lookup key could never match a real trigger's index
entry, so a rule scoped to a specific property key was silently
absent from get_workflow_state's response even when its condition was
currently satisfied.

Build the lookup key as "<node_type>.<field>" to match the shape
trigger_keys_for_graph_event indexes under. Also updates an existing
test whose trigger fixture relied on the same bare-key coincidence,
and adds a regression test that fails against the bare-key lookup and
passes against the namespaced one.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@mstomar125

Copy link
Copy Markdown
Contributor Author

Review Type: Initial Review

Requirements Check:

  • ✅ Lookup key construction fixed to use format!("{}.{}", node.node_type, field.name), exactly matching issue get_workflow_state builds property_changed lookup keys from bare field names, never matching a real rule #2763's suggested fix and the namespaced shape validate_play's UnnamespacedPropertyChangedKey check enforces and trigger_keys_for_graph_event indexes under (verified directly in packages/core/src/playbook/validation.rs:459-477 and packages/core/src/playbook/lifecycle.rs:351-369).
  • ✅ Scope respected — issue's stated non-goal ("no change to the stored property format or the namespaced event key shape") is honored; diff touches only the candidate-key builder in get_workflow_state plus tests.
  • ✅ Grepped packages/core/src/ for other property_key: Some(...) construction sites myself — the only other production site is lifecycle.rs:475 (property_key: Some(prop.key.clone())), which consumes an already-real event's key rather than deriving one from a bare schema field name, so it isn't a sibling instance of this bug. Confirms the PR description's "only lookup-key construction site" claim.
  • ✅ Regression test genuinely exercises the bug — I independently reverted the one-line fix locally (back to field.name.clone()), reran cargo test -p nodespace-core --lib playbook::workflow_state, and confirmed both namespaced_property_changed_trigger_is_returned_as_candidate and trigger_property_reference_reports_unresolvable fail (left: 0, right: 1) on the pre-fix code, then restored the fix and confirmed all 8/8 pass again. Matches the PR description's verification claim exactly.
  • ✅ No stray GitHub issue numbers embedded in the new comments/docs (checked via git diff origin/main...HEAD | grep -E '^\+' | grep -iE '#[0-9]{3,}' — no hits); cross-references are to function/check names (validate_play, trigger_keys_for_graph_event, UnnamespacedPropertyChangedKey), consistent with the repo's documentation rule.
  • ✅ No lint suppression, no #[allow(...)], no backward-compat shims — consistent with CLAUDE.md's pre-release/no-migration standards. cargo clippy -p nodespace-core --lib is clean.

Code Review Findings:

  • No 🔴 Critical or 🟡 Important findings.
  • 🟢 Suggestion — 📁 packages/core/src/playbook/lifecycle.rs:475: Not a defect, just a note for anyone reading this PR later — this is the only other property_key: Some(...) construction site in the playbook module, and it builds its key from a real event's already-existing property key rather than a bare schema field name, so it's a structurally different (and correct) case, not a sibling of the bug this PR fixes. Worth a one-line mental footnote in case a future refactor conflates the two paths, but no action needed here.
  • 🟢 Suggestion — the new doc comment on get_workflow_state's candidate-key loop (workflow_state.rs:142-147) and the regression test's doc comment both explain why the namespaced shape is required, not just what changed — good practice for a bug whose failure mode (silently-empty results, no error) is otherwise easy to reintroduce by accident.

Recommendation: APPROVE

@mstomar125 mstomar125 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Automated pragmatic-code-review: APPROVE (posted as a comment — GitHub blocks self-approval). Full findings in the review comment above.

@mstomar125

Copy link
Copy Markdown
Contributor Author

Address Review

Reviewed the pragmatic-code-review findings above (Initial Review, verdict: APPROVE, 0 🔴 Critical, 0 🟡 Important, 2 🟢 Suggestions).

Recommendations addressed: 0/2
Recommendations skipped: 2/2

  • ⏭️ Skip: note on lifecycle.rs:475 not being a sibling of this bug — the reviewer's own text says "not a defect... no action needed here." It's an observation for future readers, not a change request.
  • ⏭️ Skip: praise for the existing doc comments on the candidate-key loop and regression test — already implemented as part of the fix itself, nothing further to add.

No code changes made in this pass; working tree is clean.

Re-Review Decision

Decision: NO RE-REVIEW NEEDED

Rationale: The review returned APPROVE with zero Critical or Important findings, and both Suggestions were explicitly informational with no action requested. No code was changed as a result of this pass, so there is nothing new for a re-review to evaluate.

The PR is ready for merge (pending any other approvals).

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.

get_workflow_state builds property_changed lookup keys from bare field names, never matching a real rule

1 participant