Skip to content

Commit 1ce835d

Browse files
DOC-6026 Augment's lessons learned from the tree implementation
1 parent e4212cf commit 1ce835d

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed

build/render_hook_docs/DECISION_TREE_FORMAT.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,29 @@ Each answer (`yes` or `no`) contains:
7272

7373
- **`label`** (required): The recommendation text
7474
- **`id`** (required): Unique identifier (e.g., `jsonOutcome`, `hashOutcome`)
75+
- **`sentiment`** (optional): Indicates the nature of the outcome for visual styling
76+
- `"positive"`: Renders with green styling (e.g., "Use this option")
77+
- `"negative"`: Renders with red styling (e.g., "Don't use this option")
78+
- Omitted: Defaults to red (neutral/warning styling)
79+
80+
**Note**: The `sentiment` field is particularly useful for **suitability trees** (where outcomes are binary: suitable vs. unsuitable) as opposed to **selection trees** (where all outcomes are valid options). See [Tree Types](#tree-types) below.
81+
82+
## Tree Types
83+
84+
Decision trees can serve different purposes, which affects how you structure outcomes:
85+
86+
### Selection Trees
87+
All paths lead to valid recommendations. Users choose between options.
88+
- **Example**: "Which data type should I use?" → JSON, Hash, or String (all valid)
89+
- **Outcome styling**: Typically all neutral (no sentiment field needed)
90+
- **Use case**: Helping users choose among alternatives
91+
92+
### Suitability Trees
93+
Paths lead to binary outcomes: suitable or unsuitable for the use case.
94+
- **Example**: "Should I use RDI?" → Yes (good fit) or No (various reasons why not)
95+
- **Outcome styling**: Use `sentiment: "positive"` for suitable outcomes and `sentiment: "negative"` for unsuitable ones
96+
- **Use case**: Determining if a technology/approach is appropriate
97+
- **Benefit**: Visual distinction (green vs. red) helps users quickly understand if something is recommended
7598

7699
## Multi-line Text
77100

@@ -112,6 +135,8 @@ scope: documents
112135
5. **Consistent naming**: Use camelCase for IDs, end question IDs with "Question"
113136
6. **Match fence and YAML IDs**: The `id` in the code block fence should match the `id` field in the YAML for consistency
114137
7. **Use meaningful scopes**: Choose scope values that clearly indicate the tree's domain (e.g., `documents`, `collections`, `sequences`)
138+
8. **Add sentiment for suitability trees**: If your tree determines whether something is suitable (not just choosing between options), use `sentiment: "positive"` and `sentiment: "negative"` to provide visual feedback
139+
9. **Be consistent with sentiment**: In a suitability tree, ensure all positive outcomes have `sentiment: "positive"` and all negative outcomes have `sentiment: "negative"` for clarity
115140
116141
## Example: Redis Data Type Selection
117142

build/render_hook_docs/DECISION_TREE_IMPLEMENTATION_NOTES.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,3 +140,30 @@ const maxCharsPerLine = Math.floor(maxBoxWidth / charWidth);
140140

141141
**Benefit**: Helps future implementers and enables AI agents to understand the format.
142142

143+
## 11. Sentiment-Based Styling for Suitability Trees
144+
145+
**Discovery**: Not all decision trees are "selection trees" (choose between options). Some are "suitability trees" (determine if something is appropriate).
146+
147+
**Problem**: Selection trees and suitability trees have fundamentally different semantics:
148+
- **Selection trees**: All outcomes are valid recommendations (e.g., "Use JSON" vs. "Use Hash" vs. "Use String")
149+
- **Suitability trees**: Outcomes are binary (suitable vs. unsuitable) (e.g., "RDI is a good fit" vs. "RDI won't work")
150+
151+
**Solution**: Add optional `sentiment` field to outcomes:
152+
```yaml
153+
outcome:
154+
label: "✅ RDI is a good fit for your use case"
155+
id: goodFit
156+
sentiment: "positive" # Green styling
157+
```
158+
159+
**Implementation Details**:
160+
- Extract `sentiment` field during YAML parsing in JavaScript
161+
- Apply conditional styling in SVG rendering:
162+
- `sentiment: "positive"` → Green background (`#0fa869`) and border
163+
- `sentiment: "negative"` → Red background (`#d9534f`) and border
164+
- No sentiment → Red (default, maintains backward compatibility)
165+
166+
**Key Insight**: Explicit metadata is better than heuristics. Don't try to infer sentiment from emoji (✅/❌) or label text. Use explicit fields for reliability and AI agent compatibility.
167+
168+
**Backward Compatibility**: Existing trees without sentiment fields continue to work with default red styling. This allows gradual adoption.
169+

0 commit comments

Comments
 (0)