#6391 [Other] verify the context patch on reused desktop Harness stages

open · @Held0fTheWelt · 0 comments · View on GitHub

Setup & installServer & APIModels & quantsWindowsLinux

Description

## Problem and result

Packaging may reuse an already staged copy of the Harness. The context-safety patch is applied during staging, which a later desktop build does not have to repeat. A reused stage can therefore carry stale bytes or a provenance entry that no longer matches the bundled file. The build hook now checks the stage before bundling.

## Related discussion

The larger Harness changes are tracked in #6342. This PR extracts the packaging check from fork commit `cfed7201`.

## Approach

Apply the known patch and record its provenance if a matching legacy stage lacks the entry. If the entry exists, verify the patch metadata and the staged source bytes. Refuse drift before packaging. An ordinary development build without a bundled Harness still proceeds through the hook.

## Validation

**Passed:**
- Windows, Node v24.15.0, commit `11e218a57`. `node --test app/host/tests/harness-budget.test.mjs app/host/tests/harness-search-partial.test.mjs app/host/tests/harness-mcp-session.test.mjs` passed 24 tests, with one skipped.
- The new fixture upgrades an old stage, records provenance, verifies a second run and rejects later source drift.
- From `app/desktop`, `node scripts/prepare-harness-bundle.mjs` exited successfully with no staged Harness.
- `git diff --check upstream/main...HEAD` passed.

**Failed:**
- None observed in the checks above.

**Not run:**
- Tauri installer builds on Windows, Linux and macOS, and execution of an installed Harness.

## Limits

The hook covers the known staged pi-ai budget patch. It is not a general installer integrity check.

Related on this site

Quick links to related pages.