{"record":{"id":"f7e07b377a2dc468","repo":"affaan-m/ECC","slug":"no-memory-root-is-configured-for-scope-scope","errorCode":null,"errorMessage":"No memory root is configured for scope \"${scope}\".","messagePattern":"No memory root is configured for scope \"(.+?)\"\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/lib/memory-vault.js","lineNumber":103,"sourceCode":"        : projectRoot,\n      user: env.ECC_MEMORY_USER_ROOT\n        ? realpathNearestExisting(userVault)\n        : homeDir,\n    }),\n    enumerable: false,\n    configurable: false,\n    writable: false,\n  });\n  return Object.freeze(roots);\n}\n\nfunction assertMemoryRootSafe(roots, scope) {\n  if (!roots || typeof roots !== 'object' || Array.isArray(roots)) {\n    throw new Error('Memory roots must include a trusted boundary policy.');\n  }\n  const root = roots[scope];\n  if (typeof root !== 'string' || root.length === 0) {\n    throw new Error(`No memory root is configured for scope \"${scope}\".`);\n  }\n  const boundary = roots[VAULT_ROOT_BOUNDARIES]?.[scope];\n  if (typeof boundary !== 'string' || boundary.length === 0) {\n    throw new Error(`No trusted boundary policy is configured for memory scope \"${scope}\".`);\n  }\n  assertWithinTrustedRoot(root, boundary, 'access memory through a symlink');\n  if (fs.existsSync(root) && fs.lstatSync(root).isSymbolicLink()) {\n    throw new Error(`Refusing to access memory through symlink root: ${root}`);\n  }\n  return root;\n}\n\nfunction assertMemoryDirectorySafe(directory, root) {\n  assertWithinTrustedRoot(directory, root, 'access memory directory');\n  if (fs.existsSync(directory) && fs.lstatSync(directory).isSymbolicLink()) {\n    throw new Error(`Refusing to access memory through symlink directory: ${directory}`);\n  }\n  return directory;","sourceCodeStart":85,"sourceCodeEnd":121,"githubUrl":"https://github.com/affaan-m/ECC/blob/01e15490f04e29cfefe3896951f43db46994d8ee/scripts/lib/memory-vault.js#L85-L121","documentation":"Thrown by assertMemoryRootSafe() when roots[scope] is not a non-empty string. The three valid scopes are 'project', 'team', and 'user' (the keys produced by resolveVaultRoots()). A scope typo, a scope that the roots object was not built to handle, or a roots object missing a key triggers this. The error includes the bad scope in the message.","triggerScenarios":"readMemoryFiles({scopes: ['projct']}) (typo), assertMemoryRootSafe(roots, 'org') when 'org' is not a configured scope, calling saveMemory({scope: 'workspace'}) with an unsupported scope, or a custom roots object built without the 'team' key when team scope is requested.","commonSituations":"Caller uses a different taxonomy of scopes than the library expects. Configuration drift where a custom roots builder omitted a key. Test fixture that only set up 'project' and 'user' but the test ran over 'team'.","solutions":["Use one of the exported MEMORY_SCOPES: 'project', 'team', or 'user'.","When constructing scopes, use normalizeScopes() — it validates against MEMORY_SCOPES.","Pass options.scopes as MEMORY_SCOPES or DEFAULT_RECALL_SCOPES rather than hard-coding.","Inspect the scope value printed in the error message and align it with the canonical names."],"exampleFix":"// before\nreadMemoryFiles({ scopes: ['projct'] }); // typo\nsaveMemory({ scope: 'workspace', body: '...' }); // unknown scope\n\n// after\nconst { MEMORY_SCOPES } = require('./scripts/lib/memory-vault');\nreadMemoryFiles({ scopes: MEMORY_SCOPES });\nsaveMemory({ scope: 'project', body: '...' });","handlingStrategy":"validation","validationCode":"const { MEMORY_SCOPES } = require('./scripts/lib/memory-vault');\nconst scope = input.scope;\nif (!MEMORY_SCOPES.includes(scope)) {\n  throw new Error(`scope must be one of ${MEMORY_SCOPES.join(', ')}; got ${scope}`);\n}\nsaveMemory(input);","typeGuard":"const MEMORY_SCOPES = ['project','team','user'] as const;\nfunction isMemoryScope(value): value is typeof MEMORY_SCOPES[number] {\n  return MEMORY_SCOPES.includes(value);\n}","tryCatchPattern":null,"preventionTips":["Use the exported MEMORY_SCOPES array as the source of truth for valid scopes.","In forms, render scope as a dropdown bounded by MEMORY_SCOPES, not free text.","Run scopes through normalizeScopes() before passing them into the library."],"tags":["validation","memory-vault","roots","scope"],"backgroundTag":null,"analyzedSha":"01e15490f04e29cfefe3896951f43db46994d8ee","analyzedAt":"2026-08-13T00:31:08.655Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}