Class: MilkTea::ModuleLoader

Inherits:
Object
  • Object
show all
Defined in:
lib/milk_tea/core/module_loader.rb

Defined Under Namespace

Classes: ImportResolution, ImportResolutionError, Program

Constant Summary collapse

PLATFORM_SUFFIXES =
{
  "linux" => :linux,
  "windows" => :windows,
  "wasm" => :wasm,
}.freeze

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(module_roots: [MilkTea.root], package_graph: nil, shared_cache: nil, source_overrides: nil, platform: nil) ⇒ ModuleLoader

Returns a new instance of ModuleLoader.



113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
# File 'lib/milk_tea/core/module_loader.rb', line 113

def initialize(module_roots: [MilkTea.root], package_graph: nil, shared_cache: nil, source_overrides: nil, platform: nil)
  @module_roots = module_roots.map { |root| File.expand_path(root.to_s) }
  @ast_cache = {}
  @parse_cache = {}
  @analysis_cache = {}
  @collecting_analysis_cache = {}
  @collecting_path_errors = {}
  @checking_paths = []
  @forward_bindings = {}
  @platform = self.class.normalize_platform_name(platform)
  @package_graph = package_graph
  @package_manifest_cache = {}
  @shared_cache = shared_cache # Hash or nil; mutated in-place to persist across calls
  @source_overrides = normalize_source_overrides(source_overrides)

  @path_resolver = ModulePathResolver.new(
    module_roots: @module_roots,
    platform: @platform,
    package_graph: @package_graph,
    source_overrides: @source_overrides,
    package_manifest_cache: @package_manifest_cache,
  )
  @binder = ModuleBinder.new
  @async_runtime_installer = AsyncRuntimeInstaller.new(
    resolve_module_path: @path_resolver.method(:resolve_module_path),
    check_block: ->(path, collecting) { collecting ? check_path_collecting_errors(path) : check_path(path) },
    bind_block: @binder.method(:module_binding),
  )
  @prelude_installer = PreludeInstaller.new(
    resolve_module_path: @path_resolver.method(:resolve_module_path),
    check_block: ->(path, collecting) { collecting ? check_path_collecting_errors(path) : check_path(path) },
    bind_block: @binder.method(:module_binding),
  )
end

Class Method Details

.check_file(path, platform: nil) ⇒ Object



33
34
35
# File 'lib/milk_tea/core/module_loader.rb', line 33

def self.check_file(path, platform: nil)
  new(platform:).check_file(path)
end

.check_program(path, platform: nil) ⇒ Object



37
38
39
# File 'lib/milk_tea/core/module_loader.rb', line 37

def self.check_program(path, platform: nil)
  new(platform:).check_program(path)
end

.default_host_platformObject



100
101
102
# File 'lib/milk_tea/core/module_loader.rb', line 100

def self.default_host_platform
  MilkTea.host_platform
end

.effective_platform_for_path(path, platform_override: nil, host_platform: nil) ⇒ Object



65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/milk_tea/core/module_loader.rb', line 65

def self.effective_platform_for_path(path, platform_override: nil, host_platform: nil)
  normalized_override = normalize_platform_name(platform_override)
  return normalized_override if normalized_override

  suffix_platform = platform_suffix_for_path(path)
  return suffix_platform if suffix_platform

  manifest_platform = PackageManifest.load(path).platform
  return manifest_platform if manifest_platform

  normalize_platform_name(host_platform || default_host_platform)
rescue PackageManifestError
  normalize_platform_name(host_platform || default_host_platform)
end

.load_file(path, platform: nil) ⇒ Object



29
30
31
# File 'lib/milk_tea/core/module_loader.rb', line 29

def self.load_file(path, platform: nil)
  new(platform:).load_file(path)
end

.normalize_platform_name(value) ⇒ Object



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/milk_tea/core/module_loader.rb', line 41

def self.normalize_platform_name(value)
  return nil if value.nil? || value.to_s.strip.empty?

  case value.to_s.strip.downcase
  when "linux"
    :linux
  when "windows", "win", "win32"
    :windows
  when "wasm", "web", "html5", "browser"
    :wasm
  when "darwin", "macos", "osx"
    :darwin
  else
    raise ArgumentError, "unknown platform #{value}; expected linux|windows|wasm|darwin"
  end
end

.platform_suffix_for_path(path) ⇒ Object



58
59
60
61
62
63
# File 'lib/milk_tea/core/module_loader.rb', line 58

def self.platform_suffix_for_path(path)
  match = File.basename(path.to_s).match(/\.(linux|windows|wasm)\.mt\z/)
  return nil unless match

  PLATFORM_SUFFIXES.fetch(match[1])
end

.raise_platform_conflict!(path, pinned_platform, active_platform, error_class: nil) ⇒ Object

Raises:

  • (error_class || ArgumentError)


104
105
106
107
108
109
110
111
# File 'lib/milk_tea/core/module_loader.rb', line 104

def self.raise_platform_conflict!(path, pinned_platform, active_platform, error_class: nil)
  if error_class == ModuleLoadError
    raise ModuleLoadError.new("source file targets platform #{pinned_platform}; active platform is #{active_platform}", path:)
  end

  message = "source file #{path} targets platform #{pinned_platform}; active platform is #{active_platform}"
  raise(error_class || ArgumentError, message)
end

.resolve_source_path(path, platform: nil, error_class: nil) ⇒ Object



80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/milk_tea/core/module_loader.rb', line 80

def self.resolve_source_path(path, platform: nil, error_class: nil)
  expanded_path = File.expand_path(path.to_s)
  normalized_platform = platform.nil? ? nil : normalize_platform_name(platform)
  pinned_platform = platform_suffix_for_path(expanded_path)

  if pinned_platform
    if normalized_platform && normalized_platform != pinned_platform
      raise_platform_conflict!(expanded_path, pinned_platform, normalized_platform, error_class:)
    end
    return expanded_path
  end

  return expanded_path unless normalized_platform && expanded_path.end_with?(".mt")

  variant_path = expanded_path.sub(/\.mt\z/, ".#{normalized_platform}.mt")
  return variant_path if File.file?(variant_path)

  expanded_path
end

Instance Method Details

#build_global_import_index(ast) ⇒ Object



338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
# File 'lib/milk_tea/core/module_loader.rb', line 338

def build_global_import_index(ast)
  index = {}
  current_imports = ast.imports.map { |import| import.path.to_s }.to_set

  @analysis_cache.each_value do |analysis|
    next unless analysis
    next unless analysis.module_name

    mod_name = analysis.module_name.to_s
    next if current_imports.include?(mod_name)
    next if mod_name == ast.module_name.to_s

    types = analysis.respond_to?(:types) ? analysis.types : {}
    types.each_key do |type_name|
      type_str = type_name.to_s
      index[type_str] ||= []
      index[type_str] << mod_name unless index[type_str].include?(mod_name)
    end
  end

  index
end

#check_file(path) ⇒ Object



153
154
155
# File 'lib/milk_tea/core/module_loader.rb', line 153

def check_file(path)
  check_program(path).root_analysis
end

#check_level_parallel(paths) ⇒ Object



299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
# File 'lib/milk_tea/core/module_loader.rb', line 299

def check_level_parallel(paths)
  threads = paths.map do |resolved_path|
    Thread.new do
      Thread.current[:resolved_path] = resolved_path
      begin
        analysis = check_path(resolved_path)
        Thread.current[:analysis] = analysis
      rescue ModuleLoadError, PackageLockError, SemanticError => e
        Thread.current[:error] = e
      end
    end
  end

  threads.each(&:join)

  paths.zip(threads).each do |resolved_path, t|
    raise t[:error] if t[:error]
  end
end

#check_module_cache(path, extra_cache: nil) ⇒ Object



443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
# File 'lib/milk_tea/core/module_loader.rb', line 443

def check_module_cache(path, extra_cache: nil)
  resolved_path = self.class.resolve_source_path(path, platform: @platform, error_class: ModuleLoadError)

  return [resolved_path, nil, @analysis_cache[resolved_path]] if @analysis_cache.key?(resolved_path)
  return [resolved_path, nil, extra_cache[resolved_path]] if extra_cache&.key?(resolved_path)

  if use_shared_cache?
    entry = @shared_cache[resolved_path]
    if entry
      mtime = File.mtime(resolved_path).to_f rescue nil
      if mtime && entry[:mtime] == mtime
        @analysis_cache[resolved_path] = entry[:analysis]
        return [resolved_path, nil, entry[:analysis]]
      end
    end
  end

  ast = load_file(resolved_path)
  [resolved_path, ast, nil]
end

#check_path(path) ⇒ Object



403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
# File 'lib/milk_tea/core/module_loader.rb', line 403

def check_path(path)
  resolved_path, ast, cached = check_module_cache(path)
  return cached if cached

  if @checking_paths.include?(resolved_path) && !@forward_bindings.key?(resolved_path)
    raise ModuleLoadError.new("circular import not resolvable: module #{@parse_cache[resolved_path]&.module_name || File.basename(path)}", path: resolved_path)
  end

  @checking_paths << resolved_path
  imported_modules = imported_modules_for_ast(ast, importer_path: resolved_path)
  global_index = build_global_import_index(ast)
  analysis = SemanticAnalyzer.check(ast, imported_modules:, path: resolved_path, global_import_index: global_index)
  @analysis_cache[resolved_path] = analysis
  update_shared_cache(resolved_path, analysis)
  analysis
ensure
  @checking_paths.pop
end

#check_path_collecting_errors(path) ⇒ Object



422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
# File 'lib/milk_tea/core/module_loader.rb', line 422

def check_path_collecting_errors(path)
  resolved_path, ast, cached = check_module_cache(path, extra_cache: @collecting_analysis_cache)
  return cached if cached

  if @checking_paths.include?(resolved_path) && !@forward_bindings.key?(resolved_path)
    raise ModuleLoadError.new("circular import not resolvable: module #{@parse_cache[resolved_path]&.module_name || File.basename(path)}", path: resolved_path)
  end

  @checking_paths << resolved_path
  imported_modules = imported_modules_for_ast_collecting_errors(ast, importer_path: resolved_path).modules
  result = SemanticAnalyzer.check_collecting_errors(ast, imported_modules:, path: resolved_path)
  analysis = result[:analysis]
  raise(result[:errors].first || ModuleLoadError.new("module analysis unavailable", path: resolved_path)) unless analysis

  @collecting_path_errors[resolved_path] = result[:errors]
  @collecting_analysis_cache[resolved_path] = analysis
  analysis
ensure
  @checking_paths.pop
end

#check_program(path) ⇒ Object



157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
# File 'lib/milk_tea/core/module_loader.rb', line 157

def check_program(path)
  Types::Registry.reset!
  requested_path = File.expand_path(path)
  previous_platform = @platform
  @platform ||= self.class.platform_suffix_for_path(requested_path)
  root_path = self.class.resolve_source_path(requested_path, platform: @platform, error_class: ModuleLoadError)

  check_program_parallel(root_path)

  root_analysis = @analysis_cache.fetch(root_path)
  analyses_by_module_name = @analysis_cache.each_value.each_with_object({}) do |analysis, modules|
    next unless analysis.module_name

    modules[analysis.module_name] = analysis
  end

  Program.new(
    root_path:,
    root_analysis:,
    analyses_by_path: @analysis_cache.dup.freeze,
    analyses_by_module_name: analyses_by_module_name.freeze,
  )
ensure
  @platform = previous_platform
end

#check_program_parallel(root_path) ⇒ Object



183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
# File 'lib/milk_tea/core/module_loader.rb', line 183

def check_program_parallel(root_path)
  # Phase 1: Parse all transitive modules (sequential)
  parse_all(root_path)

  # Phase 2: Build dependency graph from parsed ASTs
  graph = {}
  @parse_cache.each_key do |resolved_path|
    ast = @parse_cache[resolved_path]
    deps = ast.imports.map do |import|
      @path_resolver.resolve_module_path(import.path.to_s, importer_path: resolved_path, importer_module_name: ast.module_name.to_s)
    end
    graph[resolved_path] = deps
  end

  # Phase 3: Topological sort into independent levels
  levels = topo_sort_levels(graph)

  # Pre-register forward bindings for cycle members
  all_checked = levels.flatten.to_set
  cycle_members = graph.keys.reject { |p| all_checked.include?(p) }
  cycle_members.each do |resolved_path|
    ast = @parse_cache[resolved_path]
    @forward_bindings[resolved_path] = create_forward_binding(ast)
  end

  # Phase 4: Check cycle members with iterative refinement
  # Pass 1: Check with forward bindings — registers type declarations.
  # SemanticError is expected (forward types lack fields/constructors)
  # but ModuleLoadError indicates a broken dependency graph.
  cycle_members.each do |resolved_path|
    check_path(resolved_path)
  rescue SemanticError
    # Forward types can't satisfy constructors. Pass 2 will retry.
  end

  # Update forward type objects in-place with field/arm info from the
  # real analyses. This way, all references to forward types (function
  # return types, struct field types, etc.) automatically see the full
  # type information without needing to replace the objects themselves.
  cycle_members.each do |resolved_path|
    analysis = @analysis_cache[resolved_path]
    next unless analysis

    fw_binding = @forward_bindings[resolved_path]
    next unless fw_binding

    analysis.types.each do |name, real_type|
      fw_type = fw_binding.types[name]
      next unless fw_type

      if real_type.respond_to?(:fields) && fw_type.respond_to?(:define_fields)
        fw_type.define_fields(real_type.fields) unless real_type.fields.empty?
      end
      if real_type.respond_to?(:arms) && fw_type.respond_to?(:define_arms)
        fw_type.define_arms(real_type.arms) unless real_type.arms.empty?
      end
    end
  end

  # Pass 2: Re-check with populated types — now cycle members see
  # complete type information for each other.
  cycle_members.each do |resolved_path|
    previous = @analysis_cache.delete(resolved_path)
    check_path(resolved_path)
  rescue SemanticError
    @analysis_cache[resolved_path] = previous if previous
  end
  @forward_bindings.clear

  # Phase 5: Check acyclic modules (they see fully-checked analyses for all imports)
  levels.each do |level_paths|
    if level_paths.length == 1
      check_path(level_paths.first)
    else
      check_level_parallel(level_paths)
    end
  end
end

#collecting_path_errorsObject

Errors collected per analyzed import path during collecting-mode checks. Populated by #check_path_collecting_errors; used by the CLI check command to surface errors in a single file's imported modules (otherwise only reported when that module is checked directly).



399
400
401
# File 'lib/milk_tea/core/module_loader.rb', line 399

def collecting_path_errors
  @collecting_path_errors
end

#create_forward_binding(ast) ⇒ Object



530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
# File 'lib/milk_tea/core/module_loader.rb', line 530

def create_forward_binding(ast)
  module_name = ast.module_name.to_s
  types = {}

  ast.declarations.each do |decl|
    case decl
    when AST::StructDecl
      types[decl.name] = Types::Struct.new(decl.name, module_name:)
    when AST::VariantDecl
      types[decl.name] = Types::Variant.new(decl.name, module_name:)
    when AST::EnumDecl
      types[decl.name] = Types::Enum.new(decl.name, module_name:)
    when AST::FlagsDecl
      types[decl.name] = Types::Flags.new(decl.name, module_name:)
    when AST::OpaqueDecl
      types[decl.name] = Types::Opaque.new(decl.name, module_name:, external: false)
    end
  end

  ModuleBinding.new(
    name: module_name, types:, type_declarations: {},
    interfaces: {}, attributes: {}, attribute_applications: {},
    values: {}, functions: {}, methods: {},
    implemented_interfaces: {}, imports: {},
    private_types: {}, private_interfaces: {}, private_attributes: {},
    private_values: {}, private_functions: {}, private_methods: {},
    private_implemented_interfaces: {},
  )
end

#imported_modules_for_ast(ast, importer_path: nil) ⇒ Object



319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
# File 'lib/milk_tea/core/module_loader.rb', line 319

def imported_modules_for_ast(ast, importer_path: nil)
  modules = {}

  ast.imports.each do |import|
    import_path = @path_resolver.resolve_module_path(import.path.to_s, importer_path:, importer_module_name: ast.module_name.to_s)

    if @forward_bindings.key?(import_path)
      modules[import.path.to_s] = @forward_bindings[import_path]
    else
      import_analysis = check_path(import_path)
      modules[import.path.to_s] = @binder.module_binding(import_analysis)
    end
  end

  @async_runtime_installer.install_async_runtime_dependency!(ast, modules, importer_path:, collecting_errors: false)
  @prelude_installer.install_prelude_modules!(ast, modules, importer_path:, collecting_errors: false)
  modules.freeze
end

#imported_modules_for_ast_collecting_errors(ast, importer_path: nil) ⇒ Object



361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
# File 'lib/milk_tea/core/module_loader.rb', line 361

def imported_modules_for_ast_collecting_errors(ast, importer_path: nil)
  modules = {}
  errors = []

  ast.imports.each do |import|
    begin
      import_path = @path_resolver.resolve_module_path(import.path.to_s, importer_path:, importer_module_name: ast.module_name.to_s)

      if @forward_bindings.key?(import_path)
        modules[import.path.to_s] = @forward_bindings[import_path]
      else
        import_analysis = check_path_collecting_errors(import_path)
        modules[import.path.to_s] = @binder.module_binding(import_analysis)
      end
    rescue ModuleLoadError, PackageLockError, SemanticError => e
      errors << ImportResolutionError.new(import:, error: e)
    end
  end

  begin
    @async_runtime_installer.install_async_runtime_dependency!(ast, modules, importer_path:, collecting_errors: true)
  rescue ModuleLoadError, PackageLockError => e
    errors << ImportResolutionError.new(import: nil, error: e)
  end

  begin
    @prelude_installer.install_prelude_modules!(ast, modules, importer_path:, collecting_errors: true)
  rescue ModuleLoadError, PackageLockError => e
    errors << ImportResolutionError.new(import: nil, error: e)
  end

  ImportResolution.new(modules: modules.freeze, errors: errors.freeze)
end

#inferred_module_name_for_path(path) ⇒ Object



498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
# File 'lib/milk_tea/core/module_loader.rb', line 498

def inferred_module_name_for_path(path)
  manifest = begin
    PackageManifest.load(path)
  rescue PackageManifestError
    nil
  end

  if manifest && path_within_root?(path, manifest.source_root)
    return module_name_for_path(path, manifest.source_root)
  end

  matching_root = @module_roots
    .select { |root| path_within_root?(path, root) }
    .max_by(&:length)
  return module_name_for_path(path, matching_root) if matching_root

  File.basename(path).sub(/\.(linux|windows|wasm)\.mt\z/, ".mt").sub(/\.mt\z/, "")
end

#load_file(path) ⇒ Object



148
149
150
151
# File 'lib/milk_tea/core/module_loader.rb', line 148

def load_file(path)
  resolved_path = self.class.resolve_source_path(path, platform: @platform, error_class: ModuleLoadError)
  @ast_cache[resolved_path] ||= parse_file(resolved_path)
end

#module_name_for_path(path, root) ⇒ Object



517
518
519
520
521
522
# File 'lib/milk_tea/core/module_loader.rb', line 517

def module_name_for_path(path, root)
  relative_path = path.delete_prefix(File.expand_path(root) + File::SEPARATOR)
  relative_path = File.basename(path) if relative_path == path
  relative_path = relative_path.sub(/\.(linux|windows|wasm)\.mt\z/, '.mt')
  relative_path.sub(/\.mt\z/, '').split(File::SEPARATOR).join('.')
end

#normalize_source_overrides(source_overrides) ⇒ Object



490
491
492
493
494
495
496
# File 'lib/milk_tea/core/module_loader.rb', line 490

def normalize_source_overrides(source_overrides)
  return {} unless source_overrides

  source_overrides.each_with_object({}) do |(path, source), overrides|
    overrides[File.expand_path(path.to_s)] = source.to_s
  end
end

#parse_all(resolved_path) ⇒ Object



262
263
264
265
266
267
268
269
270
271
272
273
274
275
# File 'lib/milk_tea/core/module_loader.rb', line 262

def parse_all(resolved_path)
  return if @parse_cache.key?(resolved_path)

  @checking_paths << resolved_path
  ast = load_file(resolved_path)
  @parse_cache[resolved_path] = ast

  ast.imports.each do |import|
    import_path = @path_resolver.resolve_module_path(import.path.to_s, importer_path: resolved_path, importer_module_name: ast.module_name.to_s)
    parse_all(import_path)
  end
ensure
  @checking_paths.pop
end

#parse_file(path) ⇒ Object



471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
# File 'lib/milk_tea/core/module_loader.rb', line 471

def parse_file(path)
  source = @source_overrides.fetch(path) { File.read(path) }
  ast = Parser.parse(source, path: path)
  inferred_module_name = inferred_module_name_for_path(path)
  AST::SourceFile.new(
    module_name: AST::QualifiedName.new(inferred_module_name.split(".")),
    module_kind: ast.module_kind,
    imports: ast.imports,
    directives: ast.directives,
    declarations: ast.declarations,
    line: ast.line,
    node_ids: ast.node_ids,
  )
rescue Errno::ENOENT
  raise ModuleLoadError.new("source file not found", path: path)
rescue Errno::EISDIR
  raise ModuleLoadError.new("expected a source file, got a directory", path: path)
end

#path_within_root?(path, root) ⇒ Boolean

Returns:

  • (Boolean)


524
525
526
527
528
# File 'lib/milk_tea/core/module_loader.rb', line 524

def path_within_root?(path, root)
  normalized_path = File.expand_path(path)
  normalized_root = File.expand_path(root)
  normalized_path == normalized_root || normalized_path.start_with?(normalized_root + File::SEPARATOR)
end

#topo_sort_levels(graph) ⇒ Object



277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
# File 'lib/milk_tea/core/module_loader.rb', line 277

def topo_sort_levels(graph)
  in_degree = {}
  graph.each_key { |node| in_degree[node] = 0 }
  graph.each_value do |deps|
    deps.each { |dep| in_degree[dep] = (in_degree[dep] || 0) + 1 }
  end

  levels = []
  remaining = graph.keys.to_set
  until remaining.empty?
    level = remaining.select { |node| (in_degree[node] || 0) == 0 }
    break if level.empty?

    levels << level
    level.each do |node|
      remaining.delete(node)
      (graph[node] || []).each { |dep| in_degree[dep] -= 1 }
    end
  end
  levels
end

#update_shared_cache(resolved_path, analysis) ⇒ Object



464
465
466
467
468
469
# File 'lib/milk_tea/core/module_loader.rb', line 464

def update_shared_cache(resolved_path, analysis)
  return unless use_shared_cache?

  mtime = File.mtime(resolved_path).to_f rescue nil
  @shared_cache[resolved_path] = { mtime:, analysis: } if mtime
end

#use_shared_cache?Boolean

Returns:

  • (Boolean)


560
561
562
# File 'lib/milk_tea/core/module_loader.rb', line 560

def use_shared_cache?
  @shared_cache && @source_overrides.empty?
end