{"record":{"id":"21a422c8a9a6d8d8","repo":"abhigyanpatwari/GitNexus","slug":"task-asset-snapshot-key-collision-digest","errorCode":null,"errorMessage":"task asset snapshot key collision: {digest}","messagePattern":"task asset snapshot key collision: (.+?)","errorType":"exception","errorClass":"SandboxError","httpStatus":null,"severity":"error","filePath":"eval/workflow_bench/task_assets.py","lineNumber":323,"sourceCode":"            dependencies = tuple(dependency_snapshots)\n            dependency_content_digest, dependency_manifest_digest = _dependency_digests(dependencies)\n            if expected_dependency_binding is not None:\n                _validate_dependency_binding_values(\n                    expected_dependency_binding,\n                    content_digest=dependency_content_digest,\n                    manifest_digest=dependency_manifest_digest,\n                )\n            digest = _snapshot_digest(\n                repo_identity=repo_identity,\n                resolved_sha=resolved_sha,\n                declarations=declarations,\n                manifest_digest=manifest_digest,\n                dependency_content_digest=dependency_content_digest,\n                dependency_manifest_digest=dependency_manifest_digest,\n            )\n            destination = self.root / digest\n            if destination.exists():\n                raise SandboxError(f\"task asset snapshot key collision: {digest}\")\n            os.replace(building, destination)\n            _freeze_snapshot(destination)\n            snapshot = TaskAssetSnapshot(\n                root=destination,\n                digest=digest,\n                manifest_digest=manifest_digest,\n                repo_identity=repo_identity,\n                resolved_sha=resolved_sha,\n                declarations=declarations,\n                entries=entries,\n                dependency_declarations=dependency_identity,\n                dependencies=dependencies,\n                dependency_content_digest=dependency_content_digest,\n                dependency_manifest_digest=dependency_manifest_digest,\n                total_bytes=budget.total_bytes,\n            )\n            self._by_definition[definition] = snapshot\n            return snapshot","sourceCodeStart":305,"sourceCodeEnd":341,"githubUrl":"https://github.com/abhigyanpatwari/GitNexus/blob/d540b00184d71a896261ee02670da9a92d59d8f7/eval/workflow_bench/task_assets.py#L305-L341","documentation":"After computing the snapshot digest and atomically building into a temp dir, the destination self.root/digest already exists. The _by_definition memo already returns identical definitions, so reaching this branch means either a genuine SHA-256 collision (astronomically unlikely) or a stray directory left in the cache root.","triggerScenarios":"Two distinct (repo, sha, declarations, dependencies) tuples hash to the same digest, or a previous run/leak left a directory at that exact digest path before os.replace.","commonSituations":"The cache root was pre-populated or shared with another process; a prior run crashed leaving state and a manual copy was dropped in; _snapshot_digest regressed to truncate its inputs.","solutions":["Inspect the existing self.root/digest: if it is a prior valid snapshot, the harness invariant is violated - report it.","Ensure the cache root is exclusive to one TaskAssetCache and empty on construction (mkdir uses exist_ok=False).","Verify _snapshot_digest inputs are complete (no truncation) and that schema_version is bumped whenever digest inputs change."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"import os\n\ndef assert_cache_root_unused(root):\n    if os.path.exists(root) and any(os.scandir(root)):\n        raise RuntimeError(f\"cache root not empty: {root}\")","typeGuard":null,"tryCatchPattern":"from workflow_bench.proposer_sandbox import SandboxError\n\ntry:\n    snapshot = cache.prepare(task, repo=repo, resolved_sha=sha)\nexcept SandboxError as exc:\n    if \"snapshot key collision\" in str(exc):\n        log.error(\"digest collision or stray cache entry - investigate %s\", exc)\n    raise","preventionTips":["Give each TaskAssetCache an exclusive, empty root (mkdir exist_ok=False already enforces this).","Bump _snapshot_digest schema_version whenever digest inputs change.","Never manually drop directories into the cache root."],"tags":["integrity","workflow-bench","caching"],"backgroundTag":null,"analyzedSha":"d540b00184d71a896261ee02670da9a92d59d8f7","analyzedAt":"2026-08-12T19:50:25.132Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}