The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
test(install-e2e): match historical inputs and preserve authored profile state
ethernet77987dba8e42
diff --git a/package-lock.json b/package-lock.jsonindex c9fbcdafc2c..7d4c852902f 100644--- a/package-lock.json+++ b/package-lock.json@@ -35,7 +35,7 @@},"apps/bootstrap-installer": {"name": "@hermes/bootstrap-installer",- "version": "0.21.1",+ "version": "1.0.0","dependencies": {"@nous-research/ui": "0.18.2","@tailwindcss/typography": "0.5.20",@@ -19260,6 +19260,7 @@},"devDependencies": {"@types/plist": "3.0.5",+ "jsdom": "29.1.1","plist": "3.1.1","typescript": "6.0.3","vitest": "4.1.10"diff --git a/tests-js/package.json b/tests-js/package.jsonindex 34dafd459d0..5d041096fdd 100644--- a/tests-js/package.json+++ b/tests-js/package.json@@ -12,6 +12,7 @@},"devDependencies": {"@types/plist": "3.0.5",+ "jsdom": "29.1.1","plist": "3.1.1","typescript": "6.0.3","vitest": "4.1.10"diff --git a/tests-js/scripts/desktop-chat-smoke.ts b/tests-js/scripts/desktop-chat-smoke.tsindex 4d70111c925..f5cc88a2786 100644--- a/tests-js/scripts/desktop-chat-smoke.ts+++ b/tests-js/scripts/desktop-chat-smoke.ts@@ -34,6 +34,8 @@ interface SmokeWindow extends Window {export interface TranscriptMessage {id: string+ /** Historical user roots omit the message ID; label their content identity honestly. */+ idSource?: 'legacy-user-text'role: stringtext: stringstreaming: boolean@@ -136,16 +138,30 @@ export async function composerText(composer: Locator): Promise<string> {node instanceof HTMLTextAreaElement ? node.value : node.textContent ?? '')}+export function transcriptMessages(viewports: Element[]): TranscriptMessage[] {+ return viewports.flatMap((viewport: Element): TranscriptMessage[] =>+ [...viewport.querySelectorAll('[data-message-id][data-role], [data-slot="aui_user-message-root"][data-role="user"]')]+ .map((node: Element): TranscriptMessage => {+ const id = node.getAttribute('data-message-id') ?? ''+ const role = node.getAttribute('data-role') ?? ''+ const text = node.textContent ?? ''+ // v2026.6.19's sticky user wrapper drops MessagePrimitive.Root's ID.+ // Its full text is stable across remounts, unlike a DOM index/handle.+ // The new nonce and ordered, fresh assistant ID remain mandatory.+ const legacyUser = !id && role === 'user' && node.getAttribute('data-slot') === 'aui_user-message-root'+ const message: TranscriptMessage = {+ id: legacyUser ? `legacy-user-text:${text}` : id,+ role, text,+ streaming: node.getAttribute('data-streaming') === 'true' || Boolean(node.querySelector('[data-message-streaming="true"]')),+ error: Boolean(node.querySelector('[role="alert"]')),+ }+ if (legacyUser) { message.idSource = 'legacy-user-text' }+ return message+ }))+}+async function readTranscript(page: Page): Promise<TranscriptMessage[]> {- return page.locator('[data-slot="aui_thread-viewport"]:visible [data-message-id][data-role]').evaluateAll(- (nodes: Element[]): TranscriptMessage[] => nodes.map((node: Element): TranscriptMessage => ({- id: node.getAttribute('data-message-id') ?? '',- role: node.getAttribute('data-role') ?? '',- text: node.textContent ?? '',- streaming: node.getAttribute('data-streaming') === 'true' || Boolean(node.querySelector('[data-message-streaming="true"]')),- error: Boolean(node.querySelector('[role="alert"]')),- })),- )+ return page.locator('[data-slot="aui_thread-viewport"]:visible').evaluateAll(transcriptMessages)}/** Match an ordered new pair, never a reply carried over from an earlier checkpoint. */diff --git a/tests-js/scripts/desktop-transcript.test.ts b/tests-js/scripts/desktop-transcript.test.tsnew file mode 100644index 00000000000..7b7d3d0a17e--- /dev/null+++ b/tests-js/scripts/desktop-transcript.test.ts@@ -0,0 +1,85 @@+// @vitest-environment jsdom+import { expect, test } from 'vitest'++import { newCompletedPair, type TranscriptMessage, transcriptMessages } from './desktop-chat-smoke.ts'+import { MOCK_REPLY } from './mock-server.ts'++interface TranscriptFixture {+ viewport: HTMLElement+ user: HTMLElement+ assistant: HTMLElement+}++function transcript(legacy: boolean): TranscriptFixture {+ const viewport = document.createElement('div')+ const user = document.createElement('div')+ user.dataset.slot = 'aui_user-message-root'+ user.dataset.role = 'user'+ user.textContent = 'new checkpoint nonce'+ // v2026.6.19 StickyHumanMessageContainer drops MessagePrimitive.Root's ID.+ if (!legacy) { user.dataset.messageId = 'new-user' }+ const assistant = document.createElement('div')+ assistant.dataset.role = 'assistant'+ assistant.dataset.messageId = 'new-assistant'+ assistant.textContent = MOCK_REPLY+ viewport.append(user, assistant)+ return { viewport, user, assistant }+}++test('historical and current user bubbles retain ordered fresh-turn proof', (): void => {+ for (const legacy of [true, false]) {+ const { viewport, user, assistant } = transcript(legacy)+ const read = (): TranscriptMessage[] => transcriptMessages([viewport])+ const pair = newCompletedPair(read(), [], 'new checkpoint nonce')+ expect(pair?.user.text).toBe(user.textContent)+ expect(pair?.assistant.id).toBe('new-assistant')+ if (legacy) {+ expect(pair?.user.id).toBe(`legacy-user-text:${user.textContent}`)+ expect(pair?.user.idSource).toBe('legacy-user-text')+ } else {+ expect(pair?.user.id).toBe('new-user')+ expect(pair?.user.idSource).toBeUndefined()+ }+ // Remounting preserved history cannot turn it into a new checkpoint.+ const before = read().map((message: TranscriptMessage): string => message.id)+ const remounted = transcript(legacy)+ expect(newCompletedPair(transcriptMessages([remounted.viewport]), before, 'new checkpoint nonce')).toBeNull()+ user.textContent = 'next checkpoint nonce'+ if (!legacy) { user.dataset.messageId = 'next-user' }+ // A fresh user still cannot reuse the previous assistant's real ID.+ expect(newCompletedPair(read(), before, 'next checkpoint nonce')).toBeNull()+ assistant.dataset.messageId = 'next-assistant'+ expect(newCompletedPair(read(), before, 'next checkpoint nonce')).not.toBeNull()+ }+})++test('legacy extraction never invents an assistant identity or accepts incomplete replies', (): void => {+ const { viewport, user, assistant } = transcript(true)+ const pair = (): ReturnType<typeof newCompletedPair> => newCompletedPair(transcriptMessages([viewport]), [], 'new checkpoint nonce')+ delete assistant.dataset.messageId+ expect(pair()).toBeNull()+ assistant.dataset.messageId = 'new-assistant'+ assistant.dataset.streaming = 'true'+ expect(pair()).toBeNull()+ delete assistant.dataset.streaming+ const marker = document.createElement('span')+ marker.dataset.messageStreaming = 'true'+ assistant.append(marker)+ expect(pair()).toBeNull()+ marker.remove()+ const alert = document.createElement('span')+ alert.setAttribute('role', 'alert')+ assistant.append(alert)+ expect(pair()).toBeNull()+ alert.remove()+ assistant.textContent = 'The full boot chain is working.'+ expect(pair()).toBeNull()+ assistant.textContent = MOCK_REPLY+ const interveningUser = user.cloneNode(true)+ viewport.insertBefore(interveningUser, assistant)+ expect(pair()).toBeNull()+ viewport.removeChild(interveningUser)+ expect(pair()).not.toBeNull()+ delete user.dataset.slot+ expect(pair()).toBeNull()+})diff --git a/tests/install/e2e-assets/user-state-actions.sh b/tests/install/e2e-assets/user-state-actions.shindex ac5595c8b19..0a655c725b7 100644--- a/tests/install/e2e-assets/user-state-actions.sh+++ b/tests/install/e2e-assets/user-state-actions.sh@@ -1,10 +1,10 @@#!/usr/bin/env bash# Produce the user state that preserve-user-state.sh verifies — through the-# ORDINARY user surface, never by writing files ourselves.+# ORDINARY user surface, including editing a profile's user-owned SOUL.md.## Why this exists: an upgrade-preservation check over fixtures the harness wrote-# proves only that the harness can write files. Everything here is a real-# command a user would run, against the leg's real installed CLI, with a real+# proves only that the harness can write files. Profiles and sessions come from+# commands a user would run, against the leg's real installed CLI, with a real# (mocked-inference) provider configured:## hermes chat -q ... a real turn -> sessions/ transcripts + state.db rows@@ -115,6 +115,10 @@ user_state_produce() {"$hermes" profile create e2e-second > "$LOG_DIR/user-state-profile.log" 2>&1 \|| fail "hermes profile create failed; see $LOG_DIR/user-state-profile.log"[ -d "$HERMES_HOME/profiles/e2e-second" ] || fail "hermes profile create produced no profile dir"+ # Untouched factory templates migrate intentionally. Customize the real+ # profile before snapshotting so byte preservation protects user authorship.+ printf '\nUser preference: preserve my e2e-second profile identity across upgrades.\n' \+ >> "$HERMES_HOME/profiles/e2e-second/SOUL.md"ok "a second profile exists (profiles/e2e-second)"elseok "the second profile already exists"diff --git a/tests/install/macos-desktop-e2e.sh b/tests/install/macos-desktop-e2e.shindex 710a47207e1..ab0b8f2f42a 100755--- a/tests/install/macos-desktop-e2e.sh+++ b/tests/install/macos-desktop-e2e.sh@@ -8,7 +8,9 @@# GIT_CONFIG_GLOBAL. The published dmg carries no commit pin - it installs# whatever `main` serves - so parking serve.git's main at OLD stages the# "user on the current release" start, and advancing it to HEAD makes an-# update available exactly the way it does for a real user.+# update available exactly the way it does for a real user. Its separately+# resolved install.sh must come from OLD too: git's redirect does not cover+# raw.githubusercontent.com. The published GUI still owns every install stage.## Phases (state shared via the workroot, mirroring the windows driver):# stage bare-clone this checkout to serve.git, park main at OLD@@ -179,6 +181,18 @@ phase_install() {arm_redirectstep "installing OLD ($OLD_REF) via the published Hermes-Setup.dmg"+ # Pair both historical inputs. Today's downloaded install.sh can call helpers+ # absent from OLD (e.g. ensure-rolldown-binding.mjs). Use the published+ # bootstrap's script-source override, not a patched script or prebuilt app.+ local bootstrap_root="$WORK_ROOT/bootstrap-source"+ mkdir -p "$bootstrap_root/scripts"+ git -C "$SERVE_REPO" show "$OLD_SHA:scripts/install.sh" > "$bootstrap_root/scripts/install.sh"+ cp "$bootstrap_root/scripts/install.sh" "$LOG_DIR/bootstrap-install-script.sh"+ printf 'source_commit=%s\nscript_blob=%s\n' "$OLD_SHA" \+ "$(git -C "$SERVE_REPO" rev-parse "$OLD_SHA:scripts/install.sh")" \+ > "$LOG_DIR/bootstrap-install-script.txt"+ ok "bootstrap script is unmodified scripts/install.sh from $OLD_REF ($OLD_SHA)"+local dmg="$WORK_ROOT/Hermes-Setup.dmg"[ -f "$dmg" ] || curl -fsSL -o "$dmg" "$DMG_URL"[ "$(stat -f%z "$dmg")" -gt 1000000 ] || fail "dmg download too small: $(stat -f%z "$dmg") bytes"@@ -203,14 +217,20 @@ phase_install() {# `open`: launchd inherits NONE of the redirect env) and drive the# "Install Hermes" button with native input.local rc=0- source_build_env bash "$ASSETS/drive-dmg-install.sh" \+ HERMES_SETUP_DEV_REPO_ROOT="$bootstrap_root" source_build_env bash "$ASSETS/drive-dmg-install.sh" \--app-bin "$app_bin" \--install-dir "$INSTALL_DIR" \--proof-dir "$LOG_DIR" 2>&1 \| ts_prefix > "$LOG_DIR/bootstrap-install.log" || rc=$?log_group "Hermes-Setup (dmg bootstrap) transcript" "$LOG_DIR/bootstrap-install.log"+ local bootstrap_log="$LOG_DIR/bootstrap-logs/bootstrap-installer.log"+ if [ -f "$bootstrap_log" ]; then+ log_group "Hermes-Setup inner installer log" "$bootstrap_log"+ fihdiutil detach "$mount" >/dev/null 2>&1 || true[ "$rc" -eq 0 ] || fail "dmg bootstrap exited $rc; transcript above"+ grep -Fq "[bootstrap] script $bootstrap_root/scripts/install.sh via dev checkout" "$bootstrap_log" \+ || fail "bootstrap did not confirm using the historical install script"[ -d "$INSTALL_DIR/.git" ] || fail "no checkout landed at $INSTALL_DIR"local gotdiff --git a/tests/install/windows-e2e.ps1 b/tests/install/windows-e2e.ps1index 9bc1e8de4ee..0cf9208a083 100644--- a/tests/install/windows-e2e.ps1+++ b/tests/install/windows-e2e.ps1@@ -1089,6 +1089,9 @@ function Invoke-UserStateActions {if (-not (Test-Path -LiteralPath (Join-Path $HermesHome 'profiles\e2e-second'))) {throw 'hermes profile create produced no profile dir'}+ # Factory templates migrate intentionally; preserve an authored profile instead.+ Add-Content -LiteralPath (Join-Path $HermesHome 'profiles\e2e-second\SOUL.md') `+ -Encoding UTF8 -Value "`nUser preference: preserve my e2e-second profile identity across upgrades."Write-Host ' a second profile exists (profiles/e2e-second)'}}