Skip to content

Documentation / @etherfold/core / processorCodeFingerprint

Function: processorCodeFingerprint()

processorCodeFingerprint(processor): string | undefined

Defined in: packages/core/src/utils/fingerprint.ts:54

What a code fingerprint is, and what it is deliberately NOT

getVersionHash() is the identity of a processor's LOGIC, and the core discards persisted state when it changes. That identity is author-declared: an author who edits a handler and forgets to bump version gets state computed by the previous logic, served forever, silently. The fingerprint is the second opinion, derived from the handler implementations themselves, so that "declared version unchanged but the code underneath it changed" becomes something the core can SAY rather than something nobody can see.

It is advisory and stays out of getVersionHash(). Folding it in would be safer in principle and unusable in practice: a bundler or minifier that re-emits the same behaviour differently would invalidate every deployment's state and force a full replay with no logic change. Advisory makes that false positive a log line instead of a multi-hour rebuild. (This deviates from docs/adr/0008, which asks for the folding-in; see the task record.)

What it survives, and what it does not

The source is Function.prototype.toString(), normalised by collapsing every run of whitespace to a single space. Measured against this repo's own toolchain (tsc 6.0.3, esbuild 0.28 as vitest uses it):

  • Survives: process restarts (the string is a pure function of the loaded source), re-indentation and reformatting, and re-ordering the handlers on the object (the payload is keyed and sorted by property name).
  • Does NOT survive: minification (identifiers are renamed), a change of transpiler or target (tsc keeps comments and indents with four spaces, esbuild strips comments and indents with two), or editing a COMMENT inside a handler under a toolchain that keeps comments. Each of those reports drift with no logic change.

Why it is tagged fp-

So that a value found in a stored cursor says what it is. The structural protection it used to provide (a fingerprint must never read as a "123n" BigInt to the storage adapters that revive them) now lives one level down, in simple_hash, which prefixes every digest for that reason and so protects context.processor and context.config too. See utils/bigint.ts for the bug that motivated both.

Comments

Comments are left in rather than stripped, and that is a choice about which way to be wrong. Stripping them from arbitrary source text needs a JS lexer that gets regex-vs-division right; a lexer that gets it wrong deletes real code from the payload, and a change inside the deleted region then reads as NO drift. Over-reporting is recoverable by bumping the version; under-reporting is the exact failure this exists to prevent.

Parameters

processor

unknown

Returns

string | undefined