feat: add driving flag to relationship query responses
Add computed driving flag to all relationship queries (list_relationships, get_predecessors, get_successors). A relationship is marked as driving when the predecessor's early end date plus lag determines the successor's early start date. Changes: - Add early_start_date and early_end_date columns to activities schema - Parse early dates from TASK table in XER files - Implement is_driving_relationship() helper with 24hr tolerance for calendar gaps - Update all relationship queries to compute and return driving flag - Add contract and unit tests for driving flag functionality - Update spec, contracts, and documentation
This commit is contained in:
@@ -198,3 +198,80 @@ class PaginationMetadata:
|
||||
| -32004 | PROJECT_SELECTION_REQUIRED | Multi-project file without selection |
|
||||
| -32005 | ACTIVITY_NOT_FOUND | Requested activity ID doesn't exist |
|
||||
| -32006 | INVALID_PARAMETER | Bad filter/pagination parameters |
|
||||
|
||||
## Driving Relationship Flag
|
||||
|
||||
**Research Date**: 2026-01-06
|
||||
|
||||
### Question: What field in the XER TASKPRED table contains the driving relationship flag?
|
||||
|
||||
**Finding**: The TASKPRED table in P6 XER files does NOT contain a direct `driving_flag` field.
|
||||
|
||||
**Evidence**: Analysis of sample XER file (S48019R - Proposal Schedule):
|
||||
```
|
||||
%F task_pred_id task_id pred_task_id proj_id pred_proj_id pred_type lag_hr_cnt comments float_path aref arls
|
||||
```
|
||||
|
||||
Fields available:
|
||||
- `task_pred_id` - Unique relationship identifier
|
||||
- `task_id` - Successor activity ID
|
||||
- `pred_task_id` - Predecessor activity ID
|
||||
- `proj_id` / `pred_proj_id` - Project identifiers
|
||||
- `pred_type` - Relationship type (PR_FS, PR_SS, PR_FF, PR_SF)
|
||||
- `lag_hr_cnt` - Lag duration in hours
|
||||
- `comments` - User comments
|
||||
- `float_path` - Float path indicator (contains dates, not boolean)
|
||||
- `aref` / `arls` - Activity reference dates
|
||||
|
||||
### Question: Where is driving/critical path information stored in P6 XER files?
|
||||
|
||||
**Finding**: The `driving_path_flag` is stored at the ACTIVITY level on the TASK table, not on individual relationships.
|
||||
|
||||
**Evidence**:
|
||||
```
|
||||
TASK table includes: driving_path_flag (Y/N)
|
||||
```
|
||||
|
||||
This flag indicates whether an activity is on the driving/critical path, but does not indicate which specific predecessor relationship is driving that activity's dates.
|
||||
|
||||
### Question: Can driving relationships be derived from available data?
|
||||
|
||||
**Finding**: Yes, driving relationships can be computed using schedule date comparison logic.
|
||||
|
||||
A relationship is "driving" when the successor activity's early start is constrained by the predecessor's completion. For a Finish-to-Start (FS) relationship:
|
||||
|
||||
```
|
||||
driving = (predecessor.early_end_date + lag_hours ≈ successor.early_start_date)
|
||||
```
|
||||
|
||||
### Decision: Compute driving flag at query time using early dates
|
||||
|
||||
**Rationale**:
|
||||
1. P6 does not export a pre-computed driving flag per relationship
|
||||
2. The driving relationship determination can be computed from activity dates
|
||||
3. This matches how P6 itself determines driving relationships in the UI
|
||||
|
||||
**Implementation Approach**:
|
||||
1. Early dates (`early_start_date`, `early_end_date`) are already parsed from TASK table
|
||||
2. When querying relationships, compute `driving` by comparing dates
|
||||
3. For FS: Compare `pred.early_end_date + lag` to `succ.early_start_date`
|
||||
4. Use 1-hour tolerance for floating point date arithmetic
|
||||
|
||||
**Alternatives Considered**:
|
||||
1. **Static flag from XER**: Not available in standard exports
|
||||
2. **Always false**: Would not provide value to users
|
||||
3. **Require user to specify**: Adds complexity, not aligned with P6 behavior
|
||||
|
||||
### Schema Impact
|
||||
|
||||
No schema changes needed for relationships table. Required activity date columns are already present:
|
||||
- `activities.early_start_date` - Already in schema ✓
|
||||
- `activities.early_end_date` - Already in schema ✓
|
||||
|
||||
The driving flag will be computed at query time via JOIN on activity dates.
|
||||
|
||||
### Validation Plan
|
||||
|
||||
- [ ] Verify early_start_date and early_end_date are parsed correctly from TASK table
|
||||
- [ ] Test driving computation against known P6 schedules
|
||||
- [ ] Confirm results match P6 "show driving" feature where possible
|
||||
|
||||
Reference in New Issue
Block a user