Skip to content

Add a decision tree solution kit#84

Draft
akasper wants to merge 11 commits into
devfrom
akasper/decision-tree-solution-kit
Draft

Add a decision tree solution kit#84
akasper wants to merge 11 commits into
devfrom
akasper/decision-tree-solution-kit

Conversation

@akasper
Copy link
Copy Markdown
Collaborator

@akasper akasper commented Jun 2, 2026

Summary

This PR adds a first-draft TigerGraph solution kit for graph-native decision trees in manufacturing maintenance triage. The kit models deterministic policy versions, decision nodes, condition groups, lookup/reference data, policy scopes, outcomes, and execution audit traces in the Decision_Engine_Manufacturing graph.

Validation

  • Verified local JSON/YAML syntax where possible.
  • Verified sample CSV files include headers and data rows.
  • Verified loading-job file references all sample CSV files.
  • Verified query install script targets Decision_Engine_Manufacturing.
  • Added README examples for expected sample decisions.

Known Limitations

  • The first draft uses a finite condition vocabulary rather than arbitrary expression evaluation.
  • The evaluation query may use bounded traversal and deterministic priority selection for clarity.
  • Additional governance checks such as full reachability and duplicate-priority analysis can be expanded in follow-up work.

Follow-ups

  • Validate against a live TigerGraph instance.
  • Add richer GraphStudio/Insights assets if required by maintainers.
  • Add additional manufacturing policies or model versions to demonstrate version promotion and scope matching.

@akasper akasper marked this pull request as draft June 2, 2026 13:07
@akasper akasper requested a review from Copilot June 2, 2026 13:08
Copy link
Copy Markdown

Copilot AI left a comment

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 introduces a new TigerGraph solution kit (agile_operations/decision_tree_maintenance) that models and demonstrates a deterministic, graph-native decision-tree policy for manufacturing maintenance triage, including versioning, scoping, lookup/reference data, and explainability/validation queries.

Changes:

  • Adds the Decision_Engine_Manufacturing graph schema (vertices/edges) for policy versions, nodes/branches, conditions, lookups, outcomes, and audits.
  • Adds an S3-backed loading job plus sample CSV policy data (model/version, tree structure, conditions, lookups, outcomes).
  • Adds queries and scripts to install/trace/validate/evaluate the sample policy, plus README/docs and reset/setup helpers.

Reviewed changes

Copilot reviewed 36 out of 36 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
agile_operations/decision_tree_maintenance/setup.sh Runs schema creation, loads sample data, and installs queries.
agile_operations/decision_tree_maintenance/schema/schema.gsql Defines the Decision_Engine_Manufacturing graph schema (policy/version/tree/condition/lookups/outcomes/audits).
agile_operations/decision_tree_maintenance/reset/reset.gsql Resets the kit by dropping jobs/data source/queries/graph.
agile_operations/decision_tree_maintenance/README.md Kit overview, setup steps, and example RUN QUERY commands with expected outcomes.
agile_operations/decision_tree_maintenance/queries/install_queries.sh Installs the kit queries into Decision_Engine_Manufacturing.
agile_operations/decision_tree_maintenance/queries/list_available_models.gsql Lists ACTIVE models/versions/scopes.
agile_operations/decision_tree_maintenance/queries/trace_policy_graph.gsql Prints a traced view of the policy graph (nodes/branches/conditions/lookups/outcomes).
agile_operations/decision_tree_maintenance/queries/validate_policy_structure.gsql Performs structural validation checks on the loaded policy.
agile_operations/decision_tree_maintenance/queries/evaluate_maintenance_policy.gsql Executes the sample maintenance triage decision and prints decision + trace.
agile_operations/decision_tree_maintenance/loading_job/load_jobs.gsql Loads sample kit data from S3 into vertices/edges, then cleans up the loading job/data source.
agile_operations/decision_tree_maintenance/docs/IMPLEMENTATION_NOTES.md Documents evaluator/validator design constraints and intended conservatism.
agile_operations/decision_tree_maintenance/meta/meta.yml Declares kit metadata and query ordering for kit packaging/UX.
agile_operations/decision_tree_maintenance/meta/schema.json Captures the schema inventory metadata (vertex/edge type names).
agile_operations/decision_tree_maintenance/meta/style.json Provides GraphStudio styling for vertex/edge types.
agile_operations/decision_tree_maintenance/data/decision_models.csv Sample DecisionModel vertex data.
agile_operations/decision_tree_maintenance/data/decision_model_versions.csv Sample DecisionModelVersion vertex data.
agile_operations/decision_tree_maintenance/data/decision_nodes.csv Sample decision tree nodes (root/decision/terminal).
agile_operations/decision_tree_maintenance/data/condition_groups.csv Sample ConditionGroup vertices for branch guarding.
agile_operations/decision_tree_maintenance/data/conditions.csv Sample Condition vertices (DEFAULT/BOOL_EQ/RANGE_INT/LOOKUP_*).
agile_operations/decision_tree_maintenance/data/attribute_defs.csv Sample governed attribute definitions used by conditions.
agile_operations/decision_tree_maintenance/data/lookup_tables.csv Sample lookup table definitions for evaluation reference data.
agile_operations/decision_tree_maintenance/data/lookup_rows.csv Sample lookup table rows (allow/deny/score) for evaluation.
agile_operations/decision_tree_maintenance/data/policy_scopes.csv Sample PolicyScope vertices (asset_model/region/criticality/priority).
agile_operations/decision_tree_maintenance/data/outcomes.csv Sample terminal outcomes (decision_code/severity/message/next_action).
agile_operations/decision_tree_maintenance/data/execution_audits.csv Sample audit vertex data with a pre-populated trace.
agile_operations/decision_tree_maintenance/data/has_versions.csv Edges linking model -> version.
agile_operations/decision_tree_maintenance/data/has_roots.csv Edges linking version -> root node.
agile_operations/decision_tree_maintenance/data/has_branches.csv Edges linking node -> node with branch metadata (priority/default).
agile_operations/decision_tree_maintenance/data/guarded_by.csv Edges linking node -> condition group.
agile_operations/decision_tree_maintenance/data/group_contains.csv Edges linking condition group -> condition.
agile_operations/decision_tree_maintenance/data/uses_attributes.csv Edges linking condition -> attribute definition.
agile_operations/decision_tree_maintenance/data/uses_lookups.csv Edges linking condition -> lookup table.
agile_operations/decision_tree_maintenance/data/has_rows.csv Edges linking lookup table -> lookup row.
agile_operations/decision_tree_maintenance/data/applies_to_scopes.csv Edges linking version -> policy scopes.
agile_operations/decision_tree_maintenance/data/yields.csv Edges linking terminal node -> outcome.
agile_operations/decision_tree_maintenance/data/audited_by.csv Edges linking version -> audit record.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread agile_operations/decision_tree_maintenance/setup.sh Outdated
Comment thread agile_operations/decision_tree_maintenance/queries/trace_policy_graph.gsql Outdated
Comment thread agile_operations/decision_tree_maintenance/queries/validate_policy_structure.gsql Outdated
Comment thread agile_operations/decision_tree_maintenance/data/conditions.csv Outdated
Comment thread agile_operations/decision_tree_maintenance/data/conditions.csv Outdated
akasper and others added 8 commits June 2, 2026 09:39
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@akasper akasper changed the base branch from main to dev June 2, 2026 13:41
Copy link
Copy Markdown

Copilot AI left a comment

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 38 out of 38 changed files in this pull request and generated 7 comments.

Comment on lines +131 to +133
ListAccum<STRING> @@rids;
_ = SELECT n FROM root_nodes:n ACCUM @@rids += n.node_id;
current_node_id = @@rids.get(0);
Comment on lines +7 to +9
ListAccum<STRING> @@trace;
ListAccum<STRING> @@rejected_conditions;

Comment on lines +74 to +78
active_scopes = SELECT s
FROM versions:v -(APPLIES_TO_SCOPE)-> PolicyScope:s
WHERE (s.applies_to == applies_to_val OR s.applies_to == "robotic_palletizing_cell" OR s.applies_to == "ANY" OR s.applies_to == "*" OR s.applies_to == "GLOBAL")
AND (s.region == region_val OR s.region == "GLOBAL" OR region_val == "ANY" OR region_val == "*")
AND (s.criticality == criticality_val OR s.criticality == "ANY" OR s.criticality == "*");
Comment thread decision_engine/README.md
Comment on lines +142 to +145
- `list_available_models()` — active models, versions, scopes.
- `trace_policy_graph(version_id)` — full traversable structure for explainability (now walks arbitrary depth).
- `validate_policy_structure(version_id)` — structural governance checks (missing outcomes/branches/defaults, empty non-default groups, orphan lookup refs). Now walks full reachable tree.
- `evaluate_decision(request_id, model_id, context_json, event_time)` — the generic engine. Returns decision + rich trace + outcome.
Comment thread decision_engine/README.md
Comment on lines +74 to +76
1. Select the highest-priority ACTIVE `DecisionModelVersion` whose effective window contains event_time (fallback to latest ACTIVE if no time match).
2. Resolve matching `PolicyScope`s using the context (applies_to / region / criticality) with wildcard support (ANY / GLOBAL / * plus fallback matching for legacy keys).
3. Start at the HAS_ROOT node and walk:
Comment thread decision_engine/README.md
Comment on lines +83 to +87
- DEFAULT → true
- BOOL_EQ → context bool == expected_bool
- RANGE_INT → min <= context int <= max
- LOOKUP_DENY / LOOKUP_ALLOW → row exists in the linked LookupTable for the lookup_key value from context, with matching allowed flag
- STRING_EQ / INT_EQ (extensible)
Comment thread decision_engine/README.md

After setup you can explore in GraphStudio or via GSQL shell / REST.

> **Graph name:** `Decision_Engine`
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.

3 participants