Skip to content

chainAwareId

chainAwareId(contentHash, parent): Promise<string>

Defined in: packages/core/src/kernel/layer.ts:417

Derive a chain-aware layer id: sha256(parent + ':' + contentHash).

string

Content hash from computeLayerHash.

string | undefined

Parent layer id, or undefined for the base layer.

Promise<string>

Hex SHA-256 suitable for Layer.id.

Content hash alone collides when two identical diffs sit at different positions in the chain (e.g. two empty .run() steps). Folding the parent id in disambiguates them — mirrors Docker’s “chain ID” concept. An undefined parent is hashed as the empty string, so the base layer’s id is sha256(':' + contentHash).

import { chainAwareId, computeLayerHash } from '@fishnet/core'
const content = await computeLayerHash(frozenFs)
const id = await chainAwareId(content, parentLayer?.id)