MCPcopy Index your code
hub / github.com/dagger/dagger / DebugEGraphSnapshot

Method DebugEGraphSnapshot

dagql/cache_debug.go:908–1063  ·  view source on GitHub ↗

nolint:gocyclo // intrinsically long state machine; refactoring would hurt clarity

()

Source from the content-addressed store, hash-verified

906
907//nolint:gocyclo // intrinsically long state machine; refactoring would hurt clarity
908func (c *Cache) DebugEGraphSnapshot() *EGraphDebugSnapshot {
909 c.egraphMu.RLock()
910 defer c.egraphMu.RUnlock()
911
912 snap := &EGraphDebugSnapshot{
913 TraceFormatVersion: egraphTraceFormatV1,
914 BootID: c.traceBootID,
915 CapturedAtSeq: atomic.LoadUint64(&c.traceSeq),
916 CapturedAtTime: time.Now().UTC().Format(time.RFC3339Nano),
917 }
918
919 resultIDs := make([]sharedResultID, 0, len(c.resultsByID))
920 for resultID := range c.resultsByID {
921 resultIDs = append(resultIDs, resultID)
922 }
923 slices.Sort(resultIDs)
924 for _, resultID := range resultIDs {
925 res := c.resultsByID[resultID]
926 if res == nil {
927 continue
928 }
929 depIDs := make([]uint64, 0, len(res.deps))
930 for depID := range res.deps {
931 depIDs = append(depIDs, uint64(depID))
932 }
933 slices.Sort(depIDs)
934 outputEqIDs := make([]uint64, 0, len(c.resultOutputEqClasses[resultID]))
935 for outputEqID := range c.outputEqClassesForResultLocked(resultID) {
936 outputEqIDs = append(outputEqIDs, uint64(outputEqID))
937 }
938 slices.Sort(outputEqIDs)
939 links := res.loadSnapshotOwnerLinks()
940 slices.SortFunc(links, func(a, b PersistedSnapshotRefLink) int {
941 switch {
942 case a.RefKey < b.RefKey:
943 return -1
944 case a.RefKey > b.RefKey:
945 return 1
946 case a.Role < b.Role:
947 return -1
948 case a.Role > b.Role:
949 return 1
950 default:
951 return 0
952 }
953 })
954 state := res.loadPayloadState()
955 typeName := sharedResultObjectTypeName(res, state)
956 if typeName == "" && state.self != nil && state.self.Type() != nil {
957 typeName = state.self.Type().Name()
958 }
959
960 payloadState := "uninitialized"
961 switch {
962 case state.persistedEnvelope != nil && !state.hasValue:
963 payloadState = "imported_lazy_envelope"
964 case state.hasValue && state.self == nil:
965 payloadState = "nil"

Callers 1

DagqlDebugSnapshotMethod · 0.80

Calls 11

findEqClassLockedMethod · 0.95
loadPayloadStateMethod · 0.80
TypeMethod · 0.65
NameMethod · 0.65
StringMethod · 0.65
FormatMethod · 0.45
SortMethod · 0.45

Tested by

no test coverage detected