{"record":{"id":"a05e84ea71296a5a","repo":"deepseek-ai/deepseek-harness","slug":"dsh-scope-scope-parent-link-would-form-a-cycle","errorCode":null,"errorMessage":"dsh-scope: scope parent link would form a cycle","messagePattern":"dsh-scope: scope parent link would form a cycle","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/core/scope/src/index.ts","lineNumber":56,"sourceCode":" */\nconst scopeParents = new WeakMap<ScopeKey, ScopeKey>()\n\n/** The privileged handle to move one scope key's parent link. */\nexport interface ScopeParentBinding {\n  /**\n   * Re-link the bound key to a different parent, with the same cycle check as\n   * the bind. Valid only while nothing produced under the old parent is\n   * retained — the blank-session recompose contract, which the holder upholds\n   * because this relation cannot see what a session logged.\n   * @param parent - the new enclosing scope key.\n   */\n  rebind(parent: ScopeKey): void\n}\n\n/** Cycle-checked write shared by the bind and every rebind. */\nfunction linkScopeParent(key: ScopeKey, parent: ScopeKey): void {\n  for (let cursor: ScopeKey | undefined = parent; cursor !== undefined; cursor = scopeParents.get(cursor)) {\n    if (cursor === key) throw new Error('dsh-scope: scope parent link would form a cycle')\n  }\n  scopeParents.set(key, parent)\n}\n\n/**\n * Bind `parent` as `key`'s enclosing scope, once.\n *\n * A key that already has a parent throws: there is no open re-link path, so a\n * scope's ancestry cannot be moved by anyone but the original binder, who\n * alone receives the {@link ScopeParentBinding}. A link that would close a\n * cycle is rejected, because every chain consumer walks parents to the root.\n * @param key - the child scope key.\n * @param parent - its enclosing scope key.\n * @returns the binding that alone may re-link this key.\n */\nexport function bindScopeParent(key: ScopeKey, parent: ScopeKey): ScopeParentBinding {\n  if (scopeParents.has(key)) {\n    throw new Error('dsh-scope: scope key is already bound to a parent; re-linking requires the binding returned by the original bind')","sourceCodeStart":38,"sourceCodeEnd":74,"githubUrl":"https://github.com/deepseek-ai/deepseek-harness/blob/b150a551b8d465e31e418e1b2eaf5e79bbb7d28e/packages/core/scope/src/index.ts#L38-L74","documentation":"Error \"dsh-scope: scope parent link would form a cycle\" thrown in deepseek-ai/deepseek-harness.","triggerScenarios":"Thrown at packages/core/scope/src/index.ts:56 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Restructure the scope hierarchy so the parent link does not form a cycle."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"b150a551b8d465e31e418e1b2eaf5e79bbb7d28e","analyzedAt":"2026-08-24T18:12:29.105Z","schemaVersion":2},"datasetVersion":"2026-08-24T22:17:12.610Z"}