MCPcopy Create free account
hub / github.com/compozy/agh / workspaceObservabilitySource

Method workspaceObservabilitySource

internal/memory/observability.go:140–182  ·  view source on GitHub ↗
(
	ctx context.Context,
	workspace string,
)

Source from the content-addressed store, hash-verified

138}
139
140func (s *Store) workspaceObservabilitySource(
141 ctx context.Context,
142 workspace string,
143) (observabilitySource, bool, error) {
144 workspaceRoot := canonicalWorkspaceRoot(workspace)
145 if workspaceRoot == "" {
146 return observabilitySource{}, false, nil
147 }
148 identity, err := aghworkspace.EnsureIdentity(ctx, workspaceRoot)
149 if err != nil {
150 return observabilitySource{}, false, fmt.Errorf(
151 "memory: resolve workspace identity for %q: %w",
152 workspaceRoot,
153 err,
154 )
155 }
156 dbPath := filepath.Clean(filepath.Join(filepath.Dir(identity.Path), storepkg.GlobalDatabaseName))
157 if _, err := os.Stat(dbPath); err != nil {
158 if errors.Is(err, os.ErrNotExist) {
159 return observabilitySource{}, false, nil
160 }
161 return observabilitySource{}, false, fmt.Errorf(
162 "memory: stat workspace observability database %q: %w",
163 dbPath,
164 err,
165 )
166 }
167 store := s.ForWorkspace(workspaceRoot)
168 store.catalog = newCatalog(dbPath, func() time.Time {
169 return time.Now().UTC()
170 })
171 return observabilitySource{
172 id: "workspace-" + identity.WorkspaceID,
173 path: dbPath,
174 store: store,
175 catalog: store.catalog,
176 filters: []catalogFilter{{
177 scope: memcontract.ScopeWorkspace,
178 workspaceRoot: workspaceRoot,
179 workspaceID: identity.WorkspaceID,
180 }},
181 }, true, nil
182}
183
184func filterCatalogFiltersByWorkspaceID(filters []catalogFilter, workspaceID string) []catalogFilter {
185 trimmed := strings.TrimSpace(workspaceID)

Callers 1

observabilitySourcesMethod · 0.95

Calls 5

ForWorkspaceMethod · 0.95
canonicalWorkspaceRootFunction · 0.85
newCatalogFunction · 0.85
IsMethod · 0.45
NowMethod · 0.45

Tested by

no test coverage detected