MCPcopy Create free account
hub / github.com/github/gh-aw / loadPriorManifestFile

Function loadPriorManifestFile

pkg/cli/compile_compiler_setup.go:278–307  ·  view source on GitHub ↗

loadPriorManifestFile reads a JSON file containing pre-cached manifests and registers each entry with the compiler. The file must contain a JSON object mapping lock-file paths to serialised GHAWManifest objects, as written by writePriorManifestFile in the MCP server startup path.

(compiler *workflow.Compiler, filePath string)

Source from the content-addressed store, hash-verified

276// mapping lock-file paths to serialised GHAWManifest objects, as written by
277// writePriorManifestFile in the MCP server startup path.
278func loadPriorManifestFile(compiler *workflow.Compiler, filePath string) error {
279 data, err := os.ReadFile(filePath)
280 if err != nil {
281 return fmt.Errorf("read prior manifest file: %w", err)
282 }
283
284 var raw map[string]*json.RawMessage
285 if err := json.Unmarshal(data, &raw); err != nil {
286 return fmt.Errorf("unmarshal prior manifest file: %w", err)
287 }
288
289 manifests := make(map[string]*workflow.GHAWManifest, len(raw))
290 for lockFile, msg := range raw {
291 if msg == nil {
292 // nil entry means "treat as empty manifest" (new workflow with no prior lock file)
293 manifests[lockFile] = nil
294 continue
295 }
296 var m workflow.GHAWManifest
297 if err := json.Unmarshal(*msg, &m); err != nil {
298 compileCompilerSetupLog.Printf("Skipping malformed manifest for %s: %v", lockFile, err)
299 continue
300 }
301 manifests[lockFile] = &m
302 }
303
304 compiler.SetPriorManifests(manifests)
305 compileCompilerSetupLog.Printf("Loaded %d pre-cached manifest(s) from %s", len(manifests), filePath)
306 return nil
307}

Callers 1

configureCompilerFlagsFunction · 0.85

Calls 3

SetPriorManifestsMethod · 0.80
ErrorfMethod · 0.45
PrintfMethod · 0.45

Tested by

no test coverage detected