Localize history selection to affected paths

This commit is contained in:
2026-10-27 03:10:07 +00:00
parent 9ff873f54c
commit 731149fc6d
4 changed files with 26 additions and 19 deletions

View File

@@ -69,7 +69,7 @@ type historyModel struct {
shapesByPointer map[string][]Path
shapeOrder []Path
observationsByPointer map[string][]int
reportedPathIndex pathPrefixIndex
affectedPathIndex pathPrefixIndex
documentLookup *documentLookup
frozen bool
@@ -127,14 +127,14 @@ func (builder *historyBuilder) addObservation(observation historyObservation) in
builder.model.observations = append(builder.model.observations, observation)
builder.addShape(observation.path)
switch observation.role {
case historyRoleDefinition, historyRoleContribution, historyRoleCompositeDefinition, historyRoleCheckpoint:
case historyRoleDefinition, historyRoleContribution, historyRoleCompositeDefinition, historyRoleCheckpoint, historyRoleOperation, historyRoleControl:
pointer := observation.path.String()
builder.model.observationsByPointer[pointer] = append(builder.model.observationsByPointer[pointer], observationID)
if observation.role == historyRoleContribution {
builder.model.reportedPathIndex.insert(pointer, observationID)
if observation.role == historyRoleContribution || observation.role == historyRoleOperation || observation.role == historyRoleControl {
// Index the concrete affected path, not the common reported ancestor.
// A leaf query must not enumerate every sibling fact of one operation.
builder.model.affectedPathIndex.insert(pointer, observationID)
}
case historyRoleOperation, historyRoleControl:
builder.model.reportedPathIndex.insert(observation.reportedPath.String(), observationID)
}
return observationID
}