The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(build): hash the desktop stamp's identity, not its build clock (#123308)
Halldrixff28c475e362
diff --git a/scripts/build/README.md b/scripts/build/README.mdindex eebdb223c20..7362d7b6545 100644--- a/scripts/build/README.md+++ b/scripts/build/README.md@@ -126,8 +126,12 @@ shared compiler helpers. Tests, workspace documentation, dependency-providerrecipes, and other products' compiler recipes do not invalidate the TUI.It records product/host identity, content hashes of workspace/shared sources andbuild inputs, and the exact supplied icon directory, desktop install stamp, and-native-dependency tree. Inputs are checked again before publication: a concurrent-input change fails the build and preserves the previous output. Output validation+native-dependency tree. The desktop stamp is hashed as its provenance identity+rather than its raw bytes: `write-build-stamp.mjs` rewrites the `builtAt` clock on+every build, so hashing it byte-for-byte let the build's own first step invalidate+the receipt it was about to write (#123308). Inputs are checked again before+publication: a concurrent input change fails the build and preserves the previous+output. Output validationchecks renderer/main/preload/public bytes and the native file inventory; nativebytes may change through signing after compilation. Native ABI verification remainswith the native provider and desktop compiler.diff --git a/scripts/build/freshness.mjs b/scripts/build/freshness.mjsindex 5d9e244054c..5318e90b010 100644--- a/scripts/build/freshness.mjs+++ b/scripts/build/freshness.mjs@@ -64,11 +64,33 @@ function outputHash(out) {name => !name.split('/').includes('node_modules') && !name.startsWith('native/'))}+// The desktop install stamp is a real prepared input — buildDesktop bakes its bytes+// into electron-main.mjs — but write-build-stamp.mjs rewrites `builtAt` on every build+// (#123308). Hashing the whole file made the build's own first step invalidate the+// receipt it was about to write, so a second build racing the first killed it on+// "inputs changed". Hash the identity the output actually depends on instead:+// the baked bytes change only when provenance does, never when the clock moves.+const stampClockFields = new Set(['builtAt'])++// An unreadable/non-JSON stamp is not an identity loss: its bytes still feed the hash,+// so the file's content keeps deciding freshness and only the clock is ignored.+function stampContentHash(path) {+ let raw = readFileSync(path)+ let identity+ try {+ identity = JSON.parse(raw)+ } catch { return treeHash(resolve(path), ['.'], () => false) }+ if (!identity || typeof identity !== 'object' || Array.isArray(identity)) return treeHash(resolve(path), ['.'], () => false)+ return createHash('sha256').update(JSON.stringify(+ Object.fromEntries(Object.entries(identity).filter(([key]) => !stampClockFields.has(key))),+ )).digest('hex')+}+export function buildInputs(source, product, prepared = {}) {return {sourceHash: sourceHash(source, product),prepared: Object.entries(prepared).sort().map(([name, path]) => ({- name, path: resolve(path), hash: treeHash(resolve(path), ['.'], () => false),+ name, path: resolve(path), hash: name === 'stamp' ? stampContentHash(resolve(path)) : treeHash(resolve(path), ['.'], () => false),})),}}