﻿# A hard-linked model workspace shares the cache inode

A hard link creates another name for the same file, including ownership and permissions. Review writable workspace preparation before sharing a retained cache artifact.

Author: Retrivium team
Updated: 2026-11-06
Canonical URL: https://retrivium.ai/journal/model-cache-hardlink-ownership/
Language: en

## A fast workspace can modify its source

A model-preparation step hard-links cached weights into a job directory to avoid copying. The job then rewrites a header or changes file permissions, expecting a private workspace. Both names refer to the same file, so the retained cache artifact can be changed through the supposedly separate job path.

The [link interface reference](https://man7.org/linux/man-pages/man2/link.2.html) explicitly defines a hard link as another equivalent name for the same file, with the same ownership and permissions. It does not provide copy-on-write separation.

## Inspect the actual preparation operation

Distinguish hard link, symbolic link, reflink clone and data copy. They have different identity and mutation contracts even when they create a similarly named path quickly. Preserve the actual operation and file identity rather than classifying the result from its appearance in the workspace.

For a hard-linked file, compare device and inode identity across the relevant names. Do not use a matching content hash to establish independence: identical contents can belong either to independent files or to several names for one mutable object.

## Review the writer's full authority

Determine whether the job can write the file or change its permissions under the actual credentials and ownership. Treat an in-place mutation as affecting the common object. Making a workspace directory private does not by itself make a referenced inode private.

Also inspect auxiliary tools that normalize permissions, rewrite metadata inside a file or repair partially prepared artifacts. A workload described as read-only can still include a preparation step with mutation authority. The acceptance boundary must cover those operations, not only the final model reader.

## Keep cache implementations distinct

The [Hub cache guide](https://huggingface.co/docs/huggingface_hub/en/guides/manage-cache) describes snapshots using symbolic links to stored blobs. That is not evidence that an arbitrary job preparer creates hard links, nor does it authorize modifying shared cached data through a resolved path.

Review the actual cache and preparation version in use. A generic claim that every model cache uses hard links would be wrong. The issue here is the explicitly observed hard-link preparation policy and its compatibility with the job's mutation requirements.

## Acceptance for workspace isolation

Use disposable files to confirm that the selected preparation method provides the intended isolation. A hard-link fixture should demonstrate shared identity and reject unsafe mutation policy. If an independent writable artifact is required, choose a supported copy or clone path and validate its separate contract.

[Reliable artifact copying](/journal/guide-storage-copy-file-range-short/) explains completeness when preparing a real copy. [Artifact checksum scope](/journal/guide-storage-object-checksum/) explains why equality checks do not establish isolation or authority.

## Cleanup is not ownership transfer

The [unlink reference](https://man7.org/linux/man-pages/man2/unlink.2.html) explains that removing one name does not reclaim the file while other links or open references retain it. Workspace deletion therefore does not prove cache-byte reclamation or undo prior mutation. Accept preparation and cleanup only with an explicit shared-object ownership policy, preserving the distinction between deleting a name and retiring the underlying artifact.
