chainAwareId
chainAwareId(
contentHash,parent):Promise<string>
Defined in: packages/core/src/kernel/layer.ts:417
Derive a chain-aware layer id: sha256(parent + ':' + contentHash).
Parameters
Section titled “Parameters”contentHash
Section titled “contentHash”string
Content hash from computeLayerHash.
parent
Section titled “parent”string | undefined
Parent layer id, or undefined for the base layer.
Returns
Section titled “Returns”Promise<string>
Hex SHA-256 suitable for Layer.id.
Remarks
Section titled “Remarks”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).
Example
Section titled “Example”import { chainAwareId, computeLayerHash } from '@fishnet/core'
const content = await computeLayerHash(frozenFs)const id = await chainAwareId(content, parentLayer?.id)