Skip to content

The agent that grows with you

simplify update test

ethernet0ed49a0446b0
diff --git a/scripts/update-test/hermes-update-rehearsal.ps1 b/scripts/update-test/hermes-update-rehearsal.ps1
index 1fa084c55f4..f9ef561cdd1 100755
--- a/scripts/update-test/hermes-update-rehearsal.ps1
+++ b/scripts/update-test/hermes-update-rehearsal.ps1
@@ -5,14 +5,16 @@
.DESCRIPTION
Two steps:
- pre back up everything, then point the install's update source at a
- custom repo + ref so `hermes update` pulls it. Prints what to do next.
- post undo all of it: remove the redirect, wipe, and restore the backup.
+ pre back up your ENTIRE HERMES_HOME and the desktop app's Electron userData,
+ then point the install's update source at a custom repo + ref so
+ `hermes update` pulls it. Prints what to do next.
+ post wipe both trees and put the backup back exactly as it was.
Plus `status`, which only prints. This script never judges your install: it
reports what it did and stops. Whether the update worked is yours to see.
- Read PLAN.md (next to this script) first.
+ The backup is one plain tar per tree with nothing filtered out, and `post`
+ restores those tars over empty directories, so every file comes back as it was.
.PARAMETER Command
pre | post | status
@@ -35,8 +37,6 @@
./hermes-update-rehearsal.ps1 post
.NOTES
- The backup is the ENTIRE HERMES_HOME plus the desktop app's Electron userData,
- the `hermes` shims on PATH, your USER PATH value, and your global git config.
`pre` needs network access to -Source and a usable git on PATH.
#>
[CmdletBinding()]
@@ -57,25 +57,8 @@ Set-StrictMode -Version 2.0
$OfficialHttps = 'https://github.com/NousResearch/hermes-agent.git'
$OfficialSsh = '[email protected]:NousResearch/hermes-agent.git'
-# The durable state `post` reports on after restoring. Regenerable trees
-# (caches, logs, dependency dirs) are deliberately absent, and `skills/` is
-# reported but never judged: the product syncs the bundled library into it on
-# startup and after every update, so it changes legitimately.
-$DurableTop = @('config.yaml', '.env', 'auth.json', 'state.db', 'gateway_state.json',
- 'memories', 'skills', 'cron', 'plugins', 'photon', 'desktop-plugins',
- 'tui-widgets', 'skins', 'pets', 'sessions', 'profiles')
-
-$SkipDirs = @('node_modules', '.venv', 'venv', 'site-packages', '__pycache__', '.git',
- '.cache', '.tox', '.nox', '.pytest_cache', '.mypy_cache', '.ruff_cache',
- 'backups', 'state-snapshots', 'checkpoints', 'hermes-agent',
- 'browser-profiles', 'browser-profile', 'models', 'runtimes', 'node')
-$SkipSuffixes = @('.pyc', '.pyo', '.db-wal', '.db-shm', '.db-journal')
-
$script:Snap = ''
-$script:Armed = ''
$script:Tar = $null
-$script:DbCountPy = $null
-$script:LastGitExit = $null
function Say { param([string]$m) Write-Host $m }
function Ok { param([string]$m) Write-Host " OK $m" }
@@ -119,8 +102,6 @@ function Get-ResolvedPaths {
$base = if ($env:LOCALAPPDATA) { $env:LOCALAPPDATA } else { Join-Path $userProfile 'AppData\Local' }
$home_ = "$(Join-Path $base 'hermes')$suffix"
}
- $parent = Split-Path -Parent $home_
- if ((Split-Path -Leaf $parent) -ieq 'profiles') { $root = Split-Path -Parent $parent } else { $root = $home_ }
$install = Join-Path $home_ 'hermes-agent'
if ($env:HERMES_DESKTOP_USER_DATA_DIR) {
$ud = $env:HERMES_DESKTOP_USER_DATA_DIR
@@ -134,26 +115,12 @@ function Get-ResolvedPaths {
$userData = Join-Path $appData "Hermes$suffix"
$userDataSource = 'default'
}
- # install.ps1 publishes into <home>\bin and wires the USER PATH to it; the
- # store/venv launchers live in the checkout's .hermes\bin.
- $shims = @(
- (Join-Path $install '.hermes\bin\hermes.exe'), (Join-Path $install '.hermes\bin\hermes.cmd'),
- (Join-Path $install '.hermes\bin\hermes-acp.exe'), (Join-Path $install '.hermes\bin\hermes-acp.cmd'),
- (Join-Path $home_ 'bin\hermes.exe'), (Join-Path $home_ 'bin\hermes.cmd'),
- (Join-Path $home_ 'bin\hermes-acp.exe'), (Join-Path $home_ 'bin\hermes-acp.cmd'),
- (Join-Path $userProfile '.local\bin\hermes'), (Join-Path $root 'bin\hermes.exe'),
- (Join-Path $root 'bin\hermes.cmd')
- )
return [pscustomobject]@{
- Home = $home_; Root = $root; Install = $install
- UserData = $userData; UserDataOrigin = $userDataSource; Shims = $shims
+ Home = $home_; Install = $install
+ UserData = $userData; UserDataOrigin = $userDataSource
}
}
-function Get-UserPathValue {
- try { return [Environment]::GetEnvironmentVariable('Path', 'User') } catch { return $null }
-}
-
function Get-LatestSnapshot {
if (-not (Test-Path -LiteralPath $BackupRoot)) { return $null }
$dirs = Get-ChildItem -LiteralPath $BackupRoot -Directory -ErrorAction SilentlyContinue | Sort-Object Name
@@ -165,15 +132,13 @@ function Load-Snapshot {
$snap = Get-LatestSnapshot
if (-not $snap) { Fail "no backup found under $BackupRoot -- run 'pre' first" }
$script:Snap = $snap
- $script:Armed = Join-Path $snap 'armed'
- $manifestPath = Join-Path $snap 'manifest.json'
- if (-not (Test-Path -LiteralPath $manifestPath)) { Fail "$snap is not a rehearsal backup (no manifest.json)" }
- $manifest = Get-Content -LiteralPath $manifestPath -Raw | ConvertFrom-Json
+ $recordedPath = Join-Path $snap 'hermes-home.txt'
+ if (-not (Test-Path -LiteralPath $recordedPath)) { Fail "$snap is not a rehearsal backup (no hermes-home.txt)" }
$P = Get-ResolvedPaths
- if ($manifest.hermes_home -ne $P.Home) {
- Fail "that backup belongs to HERMES_HOME=$($manifest.hermes_home), not $($P.Home); pass -BackupRoot to pick the right one"
+ $recorded = ((Get-Content -LiteralPath $recordedPath -Raw) -replace "`r", '').Trim()
+ if ($recorded -ne $P.Home) {
+ Fail "that backup belongs to HERMES_HOME=$recorded, not $($P.Home); pass -BackupRoot to pick the right one"
}
- return $manifest
}
# ---------------------------------------------------------------------------
@@ -184,22 +149,7 @@ function Invoke-Git {
param($P, [string[]]$GitArgs)
$prev = $ErrorActionPreference
$ErrorActionPreference = 'Continue'
- try {
- $out = & git -C $P.Install @GitArgs 2>$null
- $script:LastGitExit = $LASTEXITCODE
- }
- finally { $ErrorActionPreference = $prev }
- return (($out | Out-String) -replace "`r", '').Trim()
-}
-
-function Get-GitConfigValue {
- param($P, [string]$Key)
- $prev = $ErrorActionPreference
- $ErrorActionPreference = 'Continue'
- try {
- $out = & git -C $P.Install config --get $Key 2>$null
- if ($LASTEXITCODE -ne 0) { return '' }
- }
+ try { $out = & git -C $P.Install @GitArgs 2>$null }
finally { $ErrorActionPreference = $prev }
return (($out | Out-String) -replace "`r", '').Trim()
}
@@ -211,166 +161,6 @@ function Invoke-GitCmd {
try { & git @GitArgs 2>$null } finally { $ErrorActionPreference = $prev }
}
-# ---------------------------------------------------------------------------
-# fingerprints (used only to report how exact a restore was)
-# ---------------------------------------------------------------------------
-
-function Find-SqlitePython {
- param($P)
- $cands = @(
- (Join-Path $P.Install 'venv\Scripts\python.exe'),
- (Join-Path $P.Install '.venv\Scripts\python.exe')
- )
- $store = Get-ChildItem -LiteralPath (Join-Path $P.Install '.hermes-runtime\tools') -Directory -ErrorAction SilentlyContinue |
- Where-Object { $_.Name -like 'python-*' }
- foreach ($s in $store) { $cands += (Join-Path $s.FullName 'python.exe') }
- $cands += (Get-Command python.exe -ErrorAction SilentlyContinue | Select-Object -ExpandProperty Source)
- foreach ($c in $cands) {
- if (-not $c) { continue }
- # The Store alias resolves to a stub PowerShell cannot launch.
- if ($c -like '*\Microsoft\WindowsApps\*') { continue }
- if (Test-Path -LiteralPath $c) {
- try { & $c -c 'import sqlite3' 2>&1 | Out-Null; if ($LASTEXITCODE -eq 0) { return $c } }
- catch { }
- }
- }
- return $null
-}
-
-function Get-DbCountsPythonPath {
- # A temp FILE, not `-c`: a multi-line -c argument gets reshaped by
- # PowerShell's native-argument handling and fails to parse.
- if (-not $script:DbCountPy) {
- $script:DbCountPy = Join-Path ([IO.Path]::GetTempPath()) 'hermes-rehearsal-dbcount.py'
- @'
-import sqlite3, sys
-try:
- con = sqlite3.connect("file:" + sys.argv[1].replace("\\", "/") + "?mode=ro", uri=True)
- tables = {r[0] for r in con.execute("SELECT name FROM sqlite_master WHERE type='table'")}
- parts = [f"{t}={con.execute('SELECT COUNT(*) FROM ' + t).fetchone()[0]}"
- for t in sorted(tables & {"sessions", "messages", "usage", "cron_jobs"})]
- con.close()
- print(";".join(parts) if parts else "")
-except Exception:
- print("")
-'@ | Set-Content -LiteralPath $script:DbCountPy -Encoding ASCII
- }
- return $script:DbCountPy
-}
-
-function Get-DbCounts {
- param([string]$Python, [string]$DbPath)
- if (-not $Python) { return $null }
- $prog = Get-DbCountsPythonPath
- try {
- $out = & $Python $prog $DbPath 2>$null
- if ($LASTEXITCODE -ne 0) { return $null }
- }
- catch { return $null }
- $text = ($out | Out-String).Trim()
- if ($text) { return $text }
- return $null
-}
-
-function Get-RelForward {
- param([string]$Root, [string]$Path)
- return $Path.Substring($Root.Length).TrimStart('\', '/').Replace('\', '/')
-}
-
-function Add-TreeEntries {
- param([string]$Root, [string]$Dir, $Lines, [string]$Python)
- $stack = New-Object System.Collections.Stack
- $stack.Push($Dir)
- while ($stack.Count -gt 0) {
- $cur = $stack.Pop()
- $kept = @()
- foreach ($it in @(Get-ChildItem -LiteralPath $cur -Force -ErrorAction SilentlyContinue)) {
- $rel = Get-RelForward -Root $Root -Path $it.FullName
- if ($it.PSIsContainer) {
- if ($SkipDirs -contains $it.Name) { continue }
- if ($it.Attributes -band [IO.FileAttributes]::ReparsePoint) {
- $Lines.Add("link`t$rel`t$($it.Target)") # record, never descend
- continue
- }
- $kept += $it
- }
- else {
- $skip = $false
- foreach ($sfx in $SkipSuffixes) { if ($it.Name.EndsWith($sfx)) { $skip = $true; break } }
- if ($skip) { continue }
- if ($it.Name -eq 'state.db') {
- $counts = Get-DbCounts -Python $Python -DbPath $it.FullName
- if ($counts) { $Lines.Add("db`t$counts`t$rel") }
- else { $Lines.Add("file`t$rel`t$((Get-FileHash -LiteralPath $it.FullName -Algorithm SHA256).Hash.ToLower())") }
- }
- else {
- $Lines.Add("file`t$rel`t$((Get-FileHash -LiteralPath $it.FullName -Algorithm SHA256).Hash.ToLower())")
- }
- $kept += $it
- }
- }
- if ($kept.Count -eq 0) { $Lines.Add("dir`t" + (Get-RelForward -Root $Root -Path $cur)) }
- foreach ($k in $kept) { if ($k.PSIsContainer) { $stack.Push($k.FullName) } }
- }
-}
-
-function Get-TreeFingerprint {
- param($P, [string]$Out)
- $python = Find-SqlitePython $P
- $lines = New-Object System.Collections.Generic.List[string]
- foreach ($entry in $DurableTop) {
- $topPath = Join-Path $P.Home $entry
- if (-not (Test-Path -LiteralPath $topPath)) { continue }
- $item = Get-Item -LiteralPath $topPath -Force
- if ($item.Attributes -band [IO.FileAttributes]::ReparsePoint) {
- $lines.Add("link`t$entry`t$($item.Target)"); continue
- }
- if ($item.PSIsContainer) {
- $lines.Add("dir`t$entry")
- Add-TreeEntries -Root $P.Home -Dir $topPath -Lines $lines -Python $python
- }
- elseif ($item.Name -eq 'state.db') {
- $counts = Get-DbCounts -Python $python -DbPath $item.FullName
- if ($counts) { $lines.Add("db`t$counts`t$entry") }
- else { $lines.Add("file`t$entry`t$((Get-FileHash -LiteralPath $item.FullName -Algorithm SHA256).Hash.ToLower())") }
- }
- else {
- $lines.Add("file`t$entry`t$((Get-FileHash -LiteralPath $item.FullName -Algorithm SHA256).Hash.ToLower())")
- }
- }
- Set-Content -LiteralPath $Out -Value ($lines | Sort-Object) -Encoding utf8
- Write-Host " $($lines.Count) state entries fingerprinted"
-}
-
-function Get-UserDataFingerprint {
- param($P, [string]$Out)
- $lines = New-Object System.Collections.Generic.List[string]
- if (Test-Path -LiteralPath $P.UserData) {
- $udSkip = @('Cache', 'Code Cache', 'GPUCache', 'DawnGraphiteCache', 'DawnWebGPUCache',
- 'ShaderCache', 'Crashpad', 'CachedData', 'blob_storage')
- $stack = New-Object System.Collections.Stack
- $stack.Push($P.UserData)
- while ($stack.Count -gt 0) {
- $cur = $stack.Pop()
- foreach ($it in @(Get-ChildItem -LiteralPath $cur -Force -ErrorAction SilentlyContinue)) {
- $rel = Get-RelForward -Root $P.UserData -Path $it.FullName
- if ($it.PSIsContainer) {
- if ($udSkip -contains $it.Name) { continue }
- if ($it.Attributes -band [IO.FileAttributes]::ReparsePoint) {
- $lines.Add("link`t$rel`t$($it.Target)"); continue
- }
- $stack.Push($it.FullName)
- }
- else {
- $lines.Add("file`t$rel`t$((Get-FileHash -LiteralPath $it.FullName -Algorithm SHA256).Hash.ToLower())")
- }
- }
- }
- }
- Set-Content -LiteralPath $Out -Value ($lines | Sort-Object) -Encoding utf8
- Write-Host " $($lines.Count) desktop-data entries fingerprinted"
-}
-
# ---------------------------------------------------------------------------
# pre
# ---------------------------------------------------------------------------
@@ -383,7 +173,7 @@ function Invoke-BackupTar {
$denied = $output | Where-Object { $_ -match 'Permission denied|Access is denied' }
if ($denied) {
$user = "$env:USERDOMAIN\$env:USERNAME"
- Warn "tar could not read $($denied.Count) path(s) under $Root`:"
+ Warn "tar could not read $($denied.Count) path(s) under $Root`:"
$denied | ForEach-Object { Write-Host " $_" }
Say ''
Say 'run this in an elevated (Run as Administrator) PowerShell, then re-run pre:'
@@ -421,33 +211,21 @@ function Invoke-Pre {
$stamp = (Get-Date).ToUniversalTime().ToString('yyyyMMddTHHmmssZ')
$script:Snap = Join-Path $BackupRoot $stamp
if (Test-Path -LiteralPath $script:Snap) { Fail "backup dir already exists: $($script:Snap)" }
- $script:Armed = Join-Path $script:Snap 'armed'
- New-Item -ItemType Directory -Force -Path (Join-Path $script:Snap 'shims'), $script:Armed | Out-Null
+ New-Item -ItemType Directory -Force -Path $script:Snap | Out-Null
- Step 'copying your entire HERMES_HOME'
+ Step 'backing up your entire HERMES_HOME'
$started = Get-Date
$homeTar = Join-Path $script:Snap 'hermes-home.tar'
# No excludes: checkout, venv, PM store and node_modules come too, so post is
- # a true rollback rather than a re-download. No -z: the backup root is
- # typically the same internal disk, so gzip costs ~5x the wall time for
- # nothing (measured on an M1).
+ # a true rollback rather than a re-download. SQLite sidecars travel WITH their
+ # db on purpose (a raw copy of db+wal+shm is consistent). No -z: the backup
+ # root is typically the same internal disk, so gzip costs ~5x the wall time
+ # for nothing (measured on an M1).
Invoke-BackupTar -TarExe $script:Tar -TarArgs @('-cf', $homeTar, '-C', $P.Home, '.') -Root $P.Home -Label 'HERMES_HOME'
$elapsed = [int]((Get-Date) - $started).TotalSeconds
Ok "hermes-home.tar ($([math]::Round((Get-Item $homeTar).Length / 1MB, 1)) MB, ${elapsed}s)"
- Step 'recording git facts'
- $head = Invoke-Git $P @('rev-parse', 'HEAD')
- $branch = Invoke-Git $P @('branch', '--show-current')
- Set-Content -LiteralPath (Join-Path $script:Snap 'checkout.txt') -Encoding utf8 -Value @("head`t$head", "branch`t$branch")
- $remotes = @()
- foreach ($r in @(& git -C $P.Install remote)) {
- if (-not $r) { continue }
- $remotes += "$r`t$(Get-GitConfigValue $P "remote.$r.url")"
- }
- Set-Content -LiteralPath (Join-Path $script:Snap 'remotes.txt') -Encoding utf8 -Value $remotes
- Ok "checkout at $head"
-
- Step "copying the desktop app's data"
+ Step "backing up the desktop app's data"
if (Test-Path -LiteralPath $P.UserData) {
$udTar = Join-Path $script:Snap 'electron-userdata.tar'
Invoke-BackupTar -TarExe $script:Tar -TarArgs @('-cf', $udTar, '-C', $P.UserData, '.') -Root $P.UserData -Label 'Electron userData'
@@ -455,62 +233,22 @@ function Invoke-Pre {
}
else { Warn "no Electron userData at $($P.UserData) (desktop app not installed?)" }
- Step 'copying the hermes shims on your PATH'
- $shimList = New-Object System.Collections.Generic.List[string]
- $shimLinks = New-Object System.Collections.Generic.List[string]
- foreach ($shim in $P.Shims) {
- if (-not (Test-Path -LiteralPath $shim)) { continue }
- $shimList.Add($shim)
- $item = Get-Item -LiteralPath $shim -Force
- if ($item.Attributes -band [IO.FileAttributes]::ReparsePoint) {
- $shimLinks.Add("$shim`t$($item.Target)")
- }
- else {
- Copy-Item -LiteralPath $shim -Destination (Join-Path (Join-Path $script:Snap 'shims') ($shim -replace '[:\\/]', '_')) -Force
- }
- }
- Set-Content -LiteralPath (Join-Path $script:Snap 'shims.txt') -Encoding utf8 -Value $shimList
- Set-Content -LiteralPath (Join-Path $script:Snap 'shims-links.txt') -Encoding utf8 -Value $shimLinks
- if ($shimList.Count) { Ok "$($shimList.Count) shim path(s) recorded" } else { Warn 'no shims found' }
- Set-Content -LiteralPath (Join-Path $script:Snap 'user-path-before.txt') -Encoding utf8 -Value @(Get-UserPathValue)
-
- Step 'copying your global git config'
- $globalCfg = Join-Path $env:USERPROFILE '.gitconfig'
- if (Test-Path -LiteralPath $globalCfg) {
- Copy-Item -LiteralPath $globalCfg -Destination (Join-Path $script:Snap 'gitconfig.bak') -Force
- Ok "saved $globalCfg"
- }
- else { Warn 'no global git config yet; we will create one and remove it again in post' }
-
- Step 'fingerprinting (so post can tell you how exact the restore was)'
- Get-TreeFingerprint -P $P -Out (Join-Path $script:Snap 'fingerprint-before.txt')
- Get-UserDataFingerprint -P $P -Out (Join-Path $script:Snap 'userdata-before.txt')
-
+ Step 'recording what this backup is'
+ # Plain text, not JSON: post compares this string byte-for-byte to decide
+ # whether the backup belongs to the home it is about to wipe.
+ Set-Content -LiteralPath (Join-Path $script:Snap 'hermes-home.txt') -Encoding utf8 -Value @($P.Home)
$manifest = [ordered]@{
- schema = 2
+ schema = 3
created = (Get-Date).ToUniversalTime().ToString('o')
hermes_home = $P.Home
- hermes_root = $P.Root
install_dir = $P.Install
userdata_dir = $P.UserData
userdata_dir_source = $P.UserDataOrigin
rehearsal_source = $Source
rehearsal_ref = $Ref
- env = [ordered]@{
- HERMES_HOME = $env:HERMES_HOME
- HERMES_DESKTOP_USER_DATA_DIR = $env:HERMES_DESKTOP_USER_DATA_DIR
- HERMES_DATA_DIR_SUFFIX = $env:HERMES_DATA_DIR_SUFFIX
- PHOTON_SIDECAR_DIR = $env:PHOTON_SIDECAR_DIR
- }
- checkout = [ordered]@{
- head = (Invoke-Git $P @('rev-parse', 'HEAD'))
- branch = (Invoke-Git $P @('branch', '--show-current'))
- origin = (Get-GitConfigValue $P 'remote.origin.url')
- upstream = (Get-GitConfigValue $P 'remote.upstream.url')
- }
}
- $manifest | ConvertTo-Json -Depth 6 | Set-Content -LiteralPath (Join-Path $script:Snap 'manifest.json') -Encoding utf8
- Ok 'manifest.json'
+ $manifest | ConvertTo-Json -Depth 4 | Set-Content -LiteralPath (Join-Path $script:Snap 'manifest.json') -Encoding utf8
+ Ok "manifest.json (backup of $($P.Home))"
# --- point the install at the rehearsal source ---------------------------
Step 'fetching the rehearsal source'
@@ -541,20 +279,17 @@ function Invoke-Pre {
# validates it against `git config --get remote.origin.url`. Repointing origin
# at a fork would make the update fail before any git work.
$fileUrl = 'file:///' + ($serve -replace '\\', '/')
- $armedLines = New-Object System.Collections.Generic.List[string]
- # REPO-LOCAL, like the POSIX script: the checkout's own config lives inside
- # the home this kit backs up and post restores, and it cannot be read-only or
- # ACL-denied (the install could not have written its own repo otherwise).
+ # REPO-LOCAL, like the POSIX script: the checkout's own config lives inside the
+ # home this kit backs up, so post's wipe+restore removes it for free and no
+ # writable GLOBAL git config is needed.
foreach ($url in @($OfficialHttps, $OfficialSsh)) {
# --add: the key is multi-valued; a plain set would drop the first URL.
$null = Invoke-GitCmd @('-C', $P.Install, 'config', '--local', '--add', "url.$fileUrl.insteadOf", $url)
if ($LASTEXITCODE -ne 0) { Fail "could not write the URL redirect into $($P.Install)\.git\config" }
- $armedLines.Add("$fileUrl`t$url`tlocal")
}
- Set-Content -LiteralPath (Join-Path $script:Armed 'armed.txt') -Encoding utf8 -Value $armedLines
New-Item -ItemType Directory -Force -Path $P.Home | Out-Null
Set-Content -LiteralPath (Join-Path $P.Home '.skip_upstream_prompt') -Encoding utf8 -Value @()
- Set-Content -LiteralPath (Join-Path $script:Armed 'target-sha') -Encoding utf8 -Value @($targetSha)
+ Set-Content -LiteralPath (Join-Path $script:Snap 'target-sha') -Encoding utf8 -Value @($targetSha)
Ok 'official repo URL now resolves to the rehearsal copy'
Ok "created $($P.Home)\.skip_upstream_prompt (stops the 'add upstream remote?' prompt)"
@@ -580,8 +315,7 @@ function Invoke-Status {
$snap = Get-LatestSnapshot
if (-not $snap) { Say "none -- nothing has been set up yet (run 'pre')"; return }
Say "latest $snap"
- $armed = Join-Path $snap 'armed'
- $ts = Join-Path $armed 'target-sha'
+ $ts = Join-Path $snap 'target-sha'
if (Test-Path -LiteralPath $ts) {
Say "prepared for $((Get-Content -LiteralPath $ts -Raw).Trim())"
$manifest = Get-Content -LiteralPath (Join-Path $snap 'manifest.json') -Raw | ConvertFrom-Json
@@ -590,7 +324,7 @@ function Invoke-Status {
else { Say 'prepared no' }
Say "marker $(if (Test-Path -LiteralPath (Join-Path $P.Home '.skip_upstream_prompt')) { 'present' } else { 'absent' })"
$n = @(Invoke-GitCmd @('config', '--global', '--get-regexp', '^url\.')).Count
- Say "git rewrites $n insteadOf entr(y/ies)"
+ Say "git rewrites $n global insteadOf entr(y/ies)"
if (Test-Path -LiteralPath (Join-Path $P.Install '.git')) {
Say "checkout now $(Invoke-Git $P @('rev-parse', '--short', 'HEAD')) ($(Invoke-Git $P @('branch', '--show-current')))"
}
@@ -607,66 +341,47 @@ function Confirm-Action {
if ($reply -notmatch '^(y|yes)$') { Fail 'aborted -- nothing was changed' }
}
-function Invoke-Unarm {
- Step 'removing the URL redirect'
- $armedFile = Join-Path $script:Armed 'armed.txt'
- if (Test-Path -LiteralPath $armedFile) {
- foreach ($line in @(Get-Content -LiteralPath $armedFile | Where-Object { $_ })) {
- $parts = $line -split "`t"
- $t = $parts[0]
- if (-not $t) { continue }
- $scope = if ($parts.Count -ge 3) { $parts[2] } else { 'global' }
- if ($scope -eq 'local') {
- $null = Invoke-GitCmd @('-C', $P.Install, 'config', '--local', '--unset-all', "url.$t.insteadOf")
- }
- else {
- $null = Invoke-GitCmd @('config', '--global', '--unset-all', "url.$t.insteadOf")
+function Remove-StaleGlobalRedirect {
+ # An earlier version of this kit wrote the insteadOf redirect into the GLOBAL
+ # git config. Those entries name THIS snapshot's serve.git, which post leaves
+ # behind, so they would keep hijacking `hermes update` forever. Remove only
+ # the entries that point at our own rehearsal copy.
+ $serve = Join-Path $script:Snap 'serve.git'
+ $prefix = 'file:///' + ($serve -replace '\\', '/')
+ $removed = 0
+ foreach ($url in @($OfficialHttps, $OfficialSsh)) {
+ $prev = $ErrorActionPreference
+ $ErrorActionPreference = 'Continue'
+ try {
+ $out = & git config --global --get "url.$prefix.insteadOf" 2>$null
+ if ($LASTEXITCODE -eq 0 -and $out) {
+ $null = Invoke-GitCmd @('config', '--global', '--unset-all', "url.$prefix.insteadOf")
+ $removed++
}
}
- # An earlier version of this kit wrote the redirect GLOBALLY; clear that too
- # so a machine that ran it is not left with a stale redirect.
- foreach ($t in @(Get-Content -LiteralPath $armedFile | Where-Object { $_ } |
- ForEach-Object { ($_ -split "`t")[0] } | Sort-Object -Unique)) {
- $null = Invoke-GitCmd @('config', '--global', '--unset-all', "url.$t.insteadOf")
- }
- Ok 'removed our insteadOf entries'
- }
- $cfgBackup = Join-Path $script:Snap 'gitconfig.bak'
- if (Test-Path -LiteralPath $cfgBackup) {
- Copy-Item -LiteralPath $cfgBackup -Destination (Join-Path $env:USERPROFILE '.gitconfig') -Force
- Ok 'restored your global git config'
+ finally { $ErrorActionPreference = $prev }
}
- $P = Get-ResolvedPaths
- $marker = Join-Path $P.Home '.skip_upstream_prompt'
- if (Test-Path -LiteralPath $marker) { Remove-Item -LiteralPath $marker -Force; Ok 'removed the upstream-prompt marker' }
+ if ($removed) { Ok "removed $removed stale global URL redirect(s) from an older run of this kit" }
}
function Invoke-Post {
- $manifest = Load-Snapshot
+ Load-Snapshot
$P = Get-ResolvedPaths
Step 'this will delete and restore:'
Say " $($P.Home) (all of it, including the checkout)"
Say " $($P.UserData)"
- Say " the shim files recorded in $($script:Snap)\shims.txt"
+ Say " from $($script:Snap)"
Confirm-Action "Put everything back from $($script:Snap)?"
- Invoke-Unarm
Step 'stopping Hermes'
foreach ($name in @('Hermes', 'hermes')) {
Get-Process -Name $name -ErrorAction SilentlyContinue | Stop-Process -Force -ErrorAction SilentlyContinue
}
Ok 'asked Hermes to stop (if anything was running)'
- Step 'clearing what the rehearsal touched'
+ Step 'clearing both trees'
if (Test-Path -LiteralPath $P.Home) { Remove-Item -LiteralPath $P.Home -Recurse -Force; Ok "removed $($P.Home)" }
if (Test-Path -LiteralPath $P.UserData) { Remove-Item -LiteralPath $P.UserData -Recurse -Force; Ok "removed $($P.UserData)" }
- $shimFile = Join-Path $script:Snap 'shims.txt'
- if (Test-Path -LiteralPath $shimFile) {
- foreach ($s in @(Get-Content -LiteralPath $shimFile | Where-Object { $_ })) {
- if (Test-Path -LiteralPath $s) { Remove-Item -LiteralPath $s -Force -ErrorAction SilentlyContinue }
- }
- Ok 'removed the recorded shim files'
- }
Step 'restoring your HERMES_HOME'
New-Item -ItemType Directory -Force -Path $P.Home | Out-Null
@@ -684,78 +399,13 @@ function Invoke-Post {
}
else { Warn 'there was no desktop app data to restore' }
- Step 'restoring the shims'
- $linkFile = Join-Path $script:Snap 'shims-links.txt'
- if (Test-Path -LiteralPath $shimFile) {
- foreach ($s in @(Get-Content -LiteralPath $shimFile | Where-Object { $_ })) {
- $saved = Join-Path (Join-Path $script:Snap 'shims') ($s -replace '[:\\/]', '_')
- if (Test-Path -LiteralPath $saved) {
- New-Item -ItemType Directory -Force -Path (Split-Path -Parent $s) | Out-Null
- Copy-Item -LiteralPath $saved -Destination $s -Force
- Ok "restored $s"
- }
- elseif ((Test-Path -LiteralPath $linkFile) -and ((Get-Content -LiteralPath $linkFile -Raw) -match [regex]::Escape($s))) {
- $target = (Get-Content -LiteralPath $linkFile | Where-Object { $_ -like "$s`t*" } | ForEach-Object { ($_ -split "`t", 2)[1] })
- New-Item -ItemType Directory -Force -Path (Split-Path -Parent $s) | Out-Null
- if (Test-Path -LiteralPath $s) { Remove-Item -LiteralPath $s -Force }
- # Symlinks need a privilege (or Developer Mode); a copy is close enough
- # and must never abort the restore.
- try {
- New-Item -ItemType SymbolicLink -Path $s -Target $target -Force -ErrorAction Stop | Out-Null
- Ok "restored symlink $s"
- }
- catch {
- Copy-Item -LiteralPath $target -Destination $s -Recurse -Force -ErrorAction SilentlyContinue
- Warn "could not create a symlink at $s (no privilege); restored a copy instead"
- }
- }
- }
- }
-
- Step 'putting your USER PATH back'
- $beforePath = Join-Path $script:Snap 'user-path-before.txt'
- if (Test-Path -LiteralPath $beforePath) {
- $old = (Get-Content -LiteralPath $beforePath -Raw)
- if ($old) { $old = $old.TrimEnd("`r", "`n") } else { $old = '' }
- if ($old) {
- [Environment]::SetEnvironmentVariable('Path', $old, 'User')
- Ok 'restored your USER PATH (open a new shell to pick it up)'
- }
- else { Warn 'your USER PATH was recorded empty; leaving it untouched' }
- }
-
- Step 'how exact was the restore'
- $diffCount = 0
- Get-TreeFingerprint -P $P -Out (Join-Path $script:Snap 'fingerprint-restored.txt') *> $null
- Get-UserDataFingerprint -P $P -Out (Join-Path $script:Snap 'userdata-restored.txt') *> $null
-
- function Compare-Files([string]$Before, [string]$After, [string]$Label) {
- $b = @{}; $a = @{}
- if (Test-Path -LiteralPath $Before) {
- foreach ($line in (Get-Content -LiteralPath $Before -ErrorAction SilentlyContinue)) {
- $parts = $line -split "`t"; if ($parts.Count -ge 2) { $b[$parts[1]] = $line }
- }
- }
- if (Test-Path -LiteralPath $After) {
- foreach ($line in (Get-Content -LiteralPath $After -ErrorAction SilentlyContinue)) {
- $parts = $line -split "`t"; if ($parts.Count -ge 2) { $a[$parts[1]] = $line }
- }
- }
- $diff = @($b.Keys | Where-Object { -not $a.ContainsKey($_) -or $b[$_] -ne $a[$_] })
- if ($diff.Count -eq 0) { Ok "all $($b.Count) $Label entries match your backup"; return 0 }
- Warn "$($diff.Count) $Label entr(y/ies) differ from the backup:"
- $diff | ForEach-Object { Write-Host " $_" }
- return 1
- }
- $diffCount += (Compare-Files (Join-Path $script:Snap 'fingerprint-before.txt') (Join-Path $script:Snap 'fingerprint-restored.txt') 'state')
- $diffCount += (Compare-Files (Join-Path $script:Snap 'userdata-before.txt') (Join-Path $script:Snap 'userdata-restored.txt') 'desktop data')
+ Remove-StaleGlobalRedirect
Step 'done'
- Say 'Your install, your data and your git config are back as they were.'
+ Say "Your HERMES_HOME and the desktop app's data are back exactly as they were."
Say "Open the desktop app once and run 'hermes doctor' to confirm."
Say "Nothing was judged or changed by this script; the backup at $($script:Snap)"
Say 'is yours to keep or delete.'
- if ($diffCount -gt 0) { Say '(The differences above are informational, not a failure.)' }
}
# ---------------------------------------------------------------------------
@@ -781,7 +431,7 @@ switch ($Command) {
Write-Host 'hermes-update-rehearsal.ps1 -- run against an EXISTING Hermes install.'
Write-Host ''
Write-Host ' pre back up everything, then point the update source at a custom repo+ref'
- Write-Host ' post undo all of it: remove the redirect, wipe, restore the backup'
+ Write-Host ' post wipe both trees and restore the backup exactly as it was'
Write-Host ' status print what is prepared (read-only; nothing is touched)'
Write-Host ''
Write-Host 'Options:'
@@ -794,8 +444,3 @@ switch ($Command) {
}
}
}
-
-# The db-count program is a temp file; do not leave it behind.
-if ($script:DbCountPy -and (Test-Path -LiteralPath $script:DbCountPy)) {
- Remove-Item -LiteralPath $script:DbCountPy -Force -ErrorAction SilentlyContinue
-}
diff --git a/scripts/update-test/hermes-update-rehearsal.sh b/scripts/update-test/hermes-update-rehearsal.sh
index d91968a7b6c..3cf4a334765 100755
--- a/scripts/update-test/hermes-update-rehearsal.sh
+++ b/scripts/update-test/hermes-update-rehearsal.sh
@@ -2,14 +2,16 @@
# hermes-update-rehearsal.sh — for an EXISTING Hermes install.
#
# Two steps:
-# pre back up everything, then point the install's update source at a
-# custom repo + ref so `hermes update` pulls it. Prints what to do next.
-# post undo all of it: remove the redirect, wipe, and restore the backup.
+# pre back up your ENTIRE HERMES_HOME and the desktop app's Electron
+# userData, then point the install's update source at a custom repo +
+# ref so `hermes update` pulls it. Prints what to do next.
+# post wipe both trees and put the backup back exactly as it was.
#
# Plus `status`, which only prints. This script never judges your install: it
# reports what it did and stops. Whether the update worked is for you to see.
#
-# Read PLAN.md (next to this script) first.
+# The backup is one plain tar per tree with nothing filtered out, and `post`
+# restores those tars over empty directories, so every file comes back as it was.
#
# ./hermes-update-rehearsal.sh pre --source <git-url> --ref <branch-or-tag>
# # ... run `hermes update`, use Hermes, test whatever you need ...
@@ -21,11 +23,7 @@
# --backup-root DIR where the backup lives (default ~/hermes-update-rehearsal)
# --yes post: skip the confirmation
#
-# The backup is the ENTIRE HERMES_HOME plus the desktop app's Electron userData,
-# the `hermes` shims on PATH, and your global git config. Expect it to be as
-# large as your install and to take a few minutes.
-#
-# Requires: python3, tar, git. `pre` needs network access to --source.
+# Requires: tar and git. `pre` needs network access to --source.
set -euo pipefail
@@ -52,7 +50,7 @@ usage() {
hermes-update-rehearsal.sh -- run against an EXISTING Hermes install.
pre back up everything, then point the update source at a custom repo+ref
- post undo all of it: remove the redirect, wipe, restore the backup
+ post wipe both trees and restore the backup exactly as it was
status print what is prepared (read-only; nothing is touched)
Options:
@@ -73,8 +71,6 @@ EOF
SELF="$0"
case "$(basename "$SELF")" in bash|sh|dash|zsh|-bash|-sh|'') SELF="" ;; esac
case "$SELF" in /dev/fd/*|/dev/stdin|/proc/self/fd/*) SELF="" ;; esac
-SELF_PIPED=""
-if [ -n "$SELF" ]; then SELF_CMD="$SELF"; else SELF_CMD="hermes-update-rehearsal.sh"; SELF_PIPED=1; fi
while [ "$#" -gt 0 ]; do
case "$1" in
@@ -89,37 +85,17 @@ while [ "$#" -gt 0 ]; do
done
[ -n "$SUBCMD" ] || usage
-# Probe, don't assume: on Windows `python3` is often the Microsoft Store alias
-# stub, which exits non-zero for every real invocation.
-PYTHON=""
-for cand in python3 python; do
- if command -v "$cand" >/dev/null 2>&1 && "$cand" -c 'pass' >/dev/null 2>&1; then
- PYTHON="$cand"; break
- fi
-done
-[ -n "$PYTHON" ] || die "python3 is required (fingerprints)"
command -v git >/dev/null 2>&1 || die "git is required"
command -v tar >/dev/null 2>&1 || die "tar is required"
SNAP=""
-ARMED=""
-
-# The durable state `post` reports on after restoring. Regenerable trees
-# (caches, logs, dependency dirs) are deliberately absent, and `skills/` is
-# reported but never judged: the product syncs the bundled library into it on
-# startup and after every update, so it changes legitimately.
-durable_tops() {
- printf '%s\n' config.yaml .env auth.json state.db gateway_state.json \
- memories skills cron plugins photon desktop-plugins tui-widgets skins pets \
- sessions profiles
-}
# ---------------------------------------------------------------------------
# paths
# ---------------------------------------------------------------------------
# Under git-bash/cygwin, POSIX paths are not translated for native tools
-# (git.exe, python.exe), so normalise them. On macOS cygpath is absent: no-op.
+# (git.exe, tar.exe), so normalise them. On macOS cygpath is absent: no-op.
native_path() {
if command -v cygpath >/dev/null 2>&1; then
cygpath -m "$1" 2>/dev/null || printf '%s' "$1"
@@ -135,51 +111,24 @@ resolve_paths() {
else
HERMES_HOME="$HOME/.hermes${suffix}"
fi
- # A profile home sits inside the shared root; both are protected.
- if [ "$(basename "$(dirname "$HERMES_HOME")")" = "profiles" ]; then
- HERMES_ROOT="$(dirname "$(dirname "$HERMES_HOME")")"
- else
- HERMES_ROOT="$HERMES_HOME"
- fi
INSTALL_DIR="$HERMES_HOME/hermes-agent"
if [ -n "${HERMES_DESKTOP_USER_DATA_DIR:-}" ]; then
USERDATA_DIR="$HERMES_DESKTOP_USER_DATA_DIR"; USERDATA_SOURCE="env"
else
USERDATA_DIR="$HOME/Library/Application Support/Hermes${suffix}"; USERDATA_SOURCE="default"
fi
- SHIM_CANDIDATES=(
- "$INSTALL_DIR/.hermes/bin/hermes" "$INSTALL_DIR/.hermes/bin/hermes-acp"
- "$INSTALL_DIR/.hermes/bin/hermes-agent"
- "$HOME/.local/bin/hermes" "$HOME/.local/bin/hermes-acp" "$HOME/.local/bin/hermes-agent"
- "$HERMES_ROOT/bin/hermes" "$HERMES_ROOT/bin/hermes-acp" "$HERMES_ROOT/bin/hermes-agent"
- "/usr/local/bin/hermes" "/usr/local/bin/hermes-acp"
- )
BACKUP_ROOT="$(native_path "$BACKUP_ROOT")"
HERMES_HOME="$(native_path "$HERMES_HOME")"
- HERMES_ROOT="$(native_path "$HERMES_ROOT")"
INSTALL_DIR="$(native_path "$INSTALL_DIR")"
USERDATA_DIR="$(native_path "$USERDATA_DIR")"
- local i
- for i in "${!SHIM_CANDIDATES[@]}"; do
- SHIM_CANDIDATES[i]="$(native_path "${SHIM_CANDIDATES[$i]}")"
- done
}
-global_git_config_paths() {
- printf '%s\n' "$HOME/.gitconfig"
- # git also reads the XDG path, and XDG_CONFIG_HOME DEFAULTS to ~/.config --
- # checking only when the var is exported misses every XDG-style setup, so the
- # backup silently captured nothing for those users.
- printf '%s\n' "${XDG_CONFIG_HOME:-$HOME/.config}/git/config"
- return 0
-}
-
-first_existing_global_config() {
- local cfg
- while IFS= read -r cfg; do
- [ -f "$cfg" ] && { printf '%s' "$cfg"; return 0; }
- done < <(global_git_config_paths)
- return 1
+# `file:///C:/x` on Windows, `file:///home/x` elsewhere.
+file_url() {
+ case "$1" in
+ [A-Za-z]:*) printf 'file:///%s' "$1" ;;
+ *) printf 'file://%s' "$1" ;;
+ esac
}
latest_backup_root() {
@@ -192,132 +141,17 @@ latest_backup_root() {
load_snapshot() {
SNAP="$(latest_backup_root)" || die "no backup found under $BACKUP_ROOT — run 'pre' first"
- ARMED="$SNAP/armed"
- [ -f "$SNAP/manifest.json" ] || die "$SNAP is not a rehearsal backup (no manifest.json)"
- local recorded
- recorded="$("$PYTHON" -c 'import json,sys;print(json.load(open(sys.argv[1]))["hermes_home"])' "$SNAP/manifest.json")"
- [ "$recorded" = "$HERMES_HOME" ] \
+ local recorded_path="$SNAP/hermes-home.txt"
+ [ -f "$recorded_path" ] || die "$SNAP is not a rehearsal backup (no hermes-home.txt)"
+ # Plain text, not JSON: this string is compared byte-for-byte to decide whether
+ # the backup belongs to the home post is about to wipe.
+ local recorded current
+ recorded="$(tr -d '\r' < "$recorded_path")"
+ current="$(printf '%s' "$HERMES_HOME" | tr '\\' '/')"
+ [ "$(printf '%s' "$recorded" | tr '\\' '/')" = "$current" ] \
|| die "that backup belongs to HERMES_HOME=$recorded, not $HERMES_HOME; pass --backup-root to pick the right one"
}
-# ---------------------------------------------------------------------------
-# fingerprints (used only to report how exact a restore was)
-# ---------------------------------------------------------------------------
-
-fingerprint_home() {
- local out="$1"
- REHEARSAL_TOPS="$(durable_tops | tr '\n' ' ')" "$PYTHON" - "$HERMES_HOME" "$out" <<'PY'
-import hashlib, os, sqlite3, sys
-
-root, out = sys.argv[1], sys.argv[2]
-SKIP_DIRS = {"node_modules", ".venv", "venv", "site-packages", "__pycache__", ".git",
- ".cache", ".tox", ".nox", ".pytest_cache", ".mypy_cache", ".ruff_cache",
- "backups", "state-snapshots", "checkpoints", "hermes-agent",
- "browser-profiles", "browser-profile", "models", "runtimes", "node"}
-SKIP_SUF = (".pyc", ".pyo", ".db-wal", ".db-shm", ".db-journal")
-TOP = os.environ.get("REHEARSAL_TOPS", "").split()
-
-def sha(path):
- h = hashlib.sha256()
- with open(path, "rb") as fh:
- for block in iter(lambda: fh.read(1 << 20), b""):
- h.update(block)
- return h.hexdigest()
-
-def db_counts(path):
- """Bytes are meaningless for a live SQLite db; count rows instead."""
- try:
- con = sqlite3.connect(f"file:{path}?mode=ro", uri=True)
- try:
- tables = {r[0] for r in con.execute(
- "SELECT name FROM sqlite_master WHERE type='table'")}
- parts = [f"{t}={con.execute(f'SELECT COUNT(*) FROM {t}').fetchone()[0]}"
- for t in sorted(tables & {"sessions", "messages", "usage", "cron_jobs"})]
- return "db\t" + ";".join(parts) if parts else None
- finally:
- con.close()
- except Exception:
- return None
-
-def render(path, rel):
- if os.path.islink(path):
- return f"link\t{rel}\t{os.readlink(path)}"
- if os.path.isdir(path):
- return f"dir\t{rel}"
- if os.path.basename(path) == "state.db":
- counts = db_counts(path)
- if counts:
- return f"{counts}\t{rel}"
- return f"file\t{rel}\t{sha(path)}"
-
-def walk(base):
- for cur, dirs, files in os.walk(base):
- keep = []
- for name in sorted(dirs):
- if name in SKIP_DIRS:
- continue
- full = os.path.join(cur, name)
- # os.walk lists a symlink-to-dir in `dirs` and refuses to descend,
- # so record it here or it vanishes from the fingerprint.
- if os.path.islink(full):
- yield full
- else:
- keep.append(name)
- dirs[:] = keep
- for name in sorted(files):
- if not name.endswith(SKIP_SUF):
- yield os.path.join(cur, name)
- if not files and not dirs:
- yield cur
-
-lines = []
-for entry in TOP:
- top = os.path.join(root, entry)
- if not os.path.lexists(top):
- continue
- lines.append(render(top, entry))
- if os.path.isdir(top) and not os.path.islink(top):
- for path in walk(top):
- lines.append(render(path, os.path.relpath(path, root).replace(os.sep, "/")))
-
-with open(out, "w", encoding="utf-8") as fh:
- fh.write("\n".join(sorted(lines)) + ("\n" if lines else ""))
-print(f"{len(lines)} state entries fingerprinted")
-PY
-}
-
-fingerprint_userdata() {
- local out="$1"
- [ -d "$USERDATA_DIR" ] || { : > "$out"; return 0; }
- "$PYTHON" - "$USERDATA_DIR" "$out" <<'PY'
-import hashlib, os, sys
-
-root, out = sys.argv[1], sys.argv[2]
-SKIP_DIRS = {"Cache", "Code Cache", "GPUCache", "DawnGraphiteCache", "DawnWebGPUCache",
- "ShaderCache", "Crashpad", "CachedData", "blob_storage"}
-
-def sha(path):
- h = hashlib.sha256()
- with open(path, "rb") as fh:
- for block in iter(lambda: fh.read(1 << 20), b""):
- h.update(block)
- return h.hexdigest()
-
-lines = []
-for cur, dirs, files in os.walk(root):
- dirs[:] = sorted(d for d in dirs if d not in SKIP_DIRS)
- for name in sorted(files):
- path = os.path.join(cur, name)
- rel = os.path.relpath(path, root).replace(os.sep, "/")
- lines.append(f"link\t{rel}\t{os.readlink(path)}" if os.path.islink(path)
- else f"file\t{rel}\t{sha(path)}")
-
-with open(out, "w", encoding="utf-8") as fh:
- fh.write("\n".join(sorted(lines)) + ("\n" if lines else ""))
-print(f"{len(lines)} userData entries fingerprinted")
-PY
-}
-
# ---------------------------------------------------------------------------
# pre: back up, then point the install at the rehearsal source
# ---------------------------------------------------------------------------
@@ -351,21 +185,19 @@ cmd_pre() {
SNAP="$BACKUP_ROOT/$(date -u +%Y%m%dT%H%M%SZ)"
[ ! -e "$SNAP" ] || die "backup dir already exists: $SNAP"
- mkdir -p "$SNAP/shims" "$SNAP/armed"
- ARMED="$SNAP/armed"
+ mkdir -p "$SNAP"
- step "copying your entire HERMES_HOME"
- local started elapsed
+ step "backing up your entire HERMES_HOME"
+ local started elapsed tar_pid
started="$SECONDS"
# No excludes: checkout, venv, PM store and node_modules come too, so `post`
# is a true rollback rather than a re-download. SQLite sidecars travel WITH
# their db on purpose (a raw copy of db+wal+shm is consistent).
# No -z: the backup root is typically the same internal disk, so the size
# saving buys nothing and gzip costs ~5x the wall time on a checkout-sized
- # tree (72s vs 14s measured on an M1). Rename to .tar to match the format.
- # bsdtar (macOS) and GNU tar differ on progress options, so poll the growing
- # archive instead — portable, and it doubles as a liveness signal.
- local tar_pid
+ # tree (72s vs 14s measured on an M1). bsdtar (macOS) and GNU tar differ on
+ # progress options, so poll the growing archive instead — portable, and it
+ # doubles as a liveness signal.
tar -cf "$SNAP/hermes-home.tar" -C "$HERMES_HOME" . &
tar_pid=$!
while kill -0 "$tar_pid" 2>/dev/null; do
@@ -377,22 +209,7 @@ cmd_pre() {
elapsed=$((SECONDS - started))
ok "hermes-home.tar ($(du -h "$SNAP/hermes-home.tar" | cut -f1), ${elapsed}s)"
- step "recording git facts"
- {
- printf 'head\t%s\n' "$(git -C "$INSTALL_DIR" rev-parse HEAD)"
- printf 'branch\t%s\n' "$(git -C "$INSTALL_DIR" branch --show-current || true)"
- printf 'stashes\t%s\n' "$(git -C "$INSTALL_DIR" stash list | wc -l | tr -d ' ')"
- } > "$SNAP/checkout.txt"
- : > "$SNAP/remotes.txt"
- local remote
- while IFS= read -r remote; do
- [ -n "$remote" ] || continue
- printf '%s\t%s\n' "$remote" "$(git -C "$INSTALL_DIR" config --get "remote.$remote.url")" \
- >> "$SNAP/remotes.txt"
- done < <(git -C "$INSTALL_DIR" remote)
- ok "checkout at $(awk -F'\t' '$1=="head"{print $2}' "$SNAP/checkout.txt")"
-
- step "copying the desktop app's data"
+ step "backing up the desktop app's data"
if [ -d "$USERDATA_DIR" ]; then
tar -cf "$SNAP/electron-userdata.tar" -C "$USERDATA_DIR" . || die "userData backup failed"
ok "electron-userdata.tar ($(du -h "$SNAP/electron-userdata.tar" | cut -f1))"
@@ -400,63 +217,21 @@ cmd_pre() {
warn "no Electron userData at $USERDATA_DIR (desktop app not installed?)"
fi
- step "copying the hermes shims on your PATH"
- : > "$SNAP/shims.txt"; : > "$SNAP/shims-links.txt"
- local shim
- for shim in "${SHIM_CANDIDATES[@]}"; do
- [ -e "$shim" ] || [ -L "$shim" ] || continue
- printf '%s\n' "$shim" >> "$SNAP/shims.txt"
- if [ -L "$shim" ]; then
- printf '%s\t%s\n' "$shim" "$(readlink "$shim")" >> "$SNAP/shims-links.txt"
- else
- cp -p "$shim" "$SNAP/shims/$(printf '%s' "$shim" | tr '/' '_')" 2>/dev/null || warn "could not copy $shim"
- fi
- done
- if [ -s "$SNAP/shims.txt" ]; then ok "$(wc -l < "$SNAP/shims.txt" | tr -d ' ') shim path(s) recorded"
- else warn "no shims found on PATH"; fi
-
- step "copying your global git config"
- local cfg
- if cfg="$(first_existing_global_config)"; then
- cp -p "$cfg" "$SNAP/gitconfig.bak"; ok "saved $cfg"
- else
- warn "no global git config yet; we will create one and remove it again in post"
- fi
-
- step "fingerprinting (so post can tell you how exact the restore was)"
- fingerprint_home "$SNAP/fingerprint-before.txt"
- fingerprint_userdata "$SNAP/userdata-before.txt"
-
- "$PYTHON" - "$SNAP" "$HERMES_HOME" "$HERMES_ROOT" "$INSTALL_DIR" \
- "$USERDATA_DIR" "$USERDATA_SOURCE" "$SOURCE" "$REF" <<'PY'
-import datetime, json, os, subprocess, sys
-snap, home, root, install, userdata, src, source, ref = sys.argv[1:9]
-def git(*args):
- try:
- return subprocess.run(["git", "-C", install, *args], capture_output=True,
- text=True, check=False).stdout.strip()
- except Exception:
- return ""
-json.dump({
- "schema": 2,
- "created": datetime.datetime.now(datetime.timezone.utc).isoformat(),
- "hermes_home": home,
- "hermes_root": root,
- "install_dir": install,
- "userdata_dir": userdata,
- "userdata_dir_source": src,
- "rehearsal_source": source,
- "rehearsal_ref": ref,
- "env": {k: os.environ.get(k) for k in
- ("HERMES_HOME", "HERMES_DESKTOP_USER_DATA_DIR", "HERMES_DATA_DIR_SUFFIX",
- "PHOTON_SIDECAR_DIR")},
- "checkout": {"head": git("rev-parse", "HEAD"),
- "branch": git("branch", "--show-current"),
- "origin": git("config", "--get", "remote.origin.url"),
- "upstream": git("config", "--get", "remote.upstream.url")},
-}, open(os.path.join(snap, "manifest.json"), "w", encoding="utf-8"), indent=2, sort_keys=True)
-PY
- ok "manifest.json"
+ step "recording what this backup is"
+ printf '%s\n' "$HERMES_HOME" > "$SNAP/hermes-home.txt"
+ cat > "$SNAP/manifest.json" <<EOF
+{
+ "schema": 3,
+ "created": "$(date -u +%Y-%m-%dT%H:%M:%SZ)",
+ "hermes_home": "$HERMES_HOME",
+ "install_dir": "$INSTALL_DIR",
+ "userdata_dir": "$USERDATA_DIR",
+ "userdata_dir_source": "$USERDATA_SOURCE",
+ "rehearsal_source": "$SOURCE",
+ "rehearsal_ref": "$REF"
+}
+EOF
+ ok "manifest.json (backup of $HERMES_HOME)"
# --- point the install at the rehearsal source ---------------------------
step "fetching the rehearsal source"
@@ -487,27 +262,20 @@ PY
# URL, which matters: `hermes update` resolves its channel from the archive
# and validates it against `git config --get remote.origin.url`. Repointing
# origin at a fork would make the update fail before any git work.
- case "$serve" in
- [A-Za-z]:*) REDIRECT="file:///$serve" ;;
- *) REDIRECT="file://$serve" ;;
- esac
- : > "$ARMED/armed.txt"
- local url
+ local redirect url
+ redirect="$(file_url "$serve")"
# The redirect belongs in the REPO-LOCAL config: it lives inside the checkout
- # this kit already owns and backs up, it cannot be root-owned or read-only
- # (the install could not have written its own repo otherwise), and `post`'s
- # wipe+restore removes it for free. A writable GLOBAL git config is a
- # dependency we do not need -- requiring it aborts on any machine whose
- # ~/.config/git/config is read-only or ACL-denied.
+ # this kit already backs up, so `post`'s wipe+restore removes it for free. A
+ # writable GLOBAL git config is a dependency we do not need -- requiring it
+ # aborts on any machine whose ~/.config/git/config is read-only or ACL-denied.
for url in "$OFFICIAL_HTTPS" "$OFFICIAL_SSH"; do
# --add: the key is multi-valued; a plain write would drop the first URL.
- git -C "$INSTALL_DIR" config --local --add "url.$REDIRECT.insteadOf" "$url" \
+ git -C "$INSTALL_DIR" config --local --add "url.$redirect.insteadOf" "$url" \
|| die "could not write the URL redirect into $INSTALL_DIR/.git/config"
- printf '%s\t%s\t%s\n' "$REDIRECT" "$url" local >> "$ARMED/armed.txt"
done
mkdir -p "$HERMES_HOME"
touch "$HERMES_HOME/.skip_upstream_prompt"
- printf '%s\n' "$target_sha" > "$ARMED/target-sha"
+ printf '%s\n' "$target_sha" > "$SNAP/target-sha"
ok "official repo URL now resolves to the rehearsal copy"
ok "created $HERMES_HOME/.skip_upstream_prompt (stops the 'add upstream remote?' prompt)"
@@ -534,11 +302,10 @@ cmd_status() {
say "none — nothing has been set up yet (run 'pre')"
return 0
fi
- ARMED="$SNAP/armed"
say "latest $SNAP"
- if [ -f "$ARMED/target-sha" ]; then
- say "prepared for $(cat "$ARMED/target-sha")"
- say "source $(cat "$SNAP/manifest.json" 2>/dev/null | "$PYTHON" -c 'import json,sys;d=json.load(sys.stdin);print(d.get("rehearsal_source","?"),"@",d.get("rehearsal_ref","?"))' 2>/dev/null || echo '?')"
+ if [ -f "$SNAP/target-sha" ]; then
+ say "prepared for $(tr -d '\r' < "$SNAP/target-sha")"
+ say "source $(sed -n 's/.*"rehearsal_source": "\(.*\)",/\1/p' "$SNAP/manifest.json" 2>/dev/null | head -1) @ $(sed -n 's/.*"rehearsal_ref": "\(.*\)"/\1/p' "$SNAP/manifest.json" 2>/dev/null | head -1)"
else
say "prepared no"
fi
@@ -553,7 +320,7 @@ cmd_status() {
}
# ---------------------------------------------------------------------------
-# post: undo everything
+# post: wipe both trees, then put the backup back
# ---------------------------------------------------------------------------
confirm() {
@@ -573,34 +340,20 @@ confirm() {
case "$reply" in y|Y|yes|YES) return 0 ;; *) die "aborted — nothing was changed (re-run with --yes to skip this prompt)" ;; esac
}
-unarm() {
- step "removing the URL redirect"
- if [ -f "$ARMED/armed.txt" ]; then
- local scope target
- while IFS=$'\t' read -r target _url scope; do
- [ -n "$target" ] || continue
- case "${scope:-global}" in
- local) git -C "$INSTALL_DIR" config --local --unset-all "url.$target.insteadOf" 2>/dev/null || true ;;
- *) git config --global --unset-all "url.$target.insteadOf" 2>/dev/null || true ;;
- esac
- done < "$ARMED/armed.txt"
- # An earlier version of this kit wrote the redirect GLOBALLY; clear that too
- # so a machine that ran it is not left with a stale redirect.
- while IFS= read -r target; do
- [ -n "$target" ] || continue
- git config --global --unset-all "url.$target.insteadOf" 2>/dev/null || true
- done < <(cut -f1 "$ARMED/armed.txt" | sort -u)
- ok "removed our insteadOf entries"
- fi
- if [ -f "$SNAP/gitconfig.bak" ]; then
- local cfg
- if cfg="$(first_existing_global_config)"; then
- cp -p "$SNAP/gitconfig.bak" "$cfg" && ok "restored your global git config"
+# An earlier version of this kit wrote the insteadOf redirect into the GLOBAL git
+# config. Those entries name THIS snapshot's serve.git, which post leaves behind,
+# so they would keep hijacking `hermes update` forever. Remove only the entries
+# that point at our own rehearsal copy.
+remove_stale_global_redirect() {
+ local prefix url removed=0
+ prefix="$(file_url "$SNAP/serve.git")"
+ for url in "$OFFICIAL_HTTPS" "$OFFICIAL_SSH"; do
+ if git config --global --get "url.$prefix.insteadOf" >/dev/null 2>&1; then
+ git config --global --unset-all "url.$prefix.insteadOf" 2>/dev/null || true
+ removed=$((removed + 1))
fi
- fi
- if [ -f "$HERMES_HOME/.skip_upstream_prompt" ]; then
- rm -f "$HERMES_HOME/.skip_upstream_prompt" && ok "removed the upstream-prompt marker"
- fi
+ done
+ [ "$removed" = 0 ] || ok "removed $removed stale global URL redirect(s) from an older run of this kit"
}
cmd_post() {
@@ -609,23 +362,17 @@ cmd_post() {
step "this will delete and restore:"
say " $HERMES_HOME (all of it, including the checkout)"
say " $USERDATA_DIR"
- say " the shim files recorded in $SNAP/shims.txt"
+ say " from $SNAP"
confirm "Put everything back from $SNAP?"
- unarm
step "stopping Hermes"
pkill -f "Hermes.app/Contents/MacOS" 2>/dev/null || true
pkill -f "hermes gateway" 2>/dev/null || true
ok "asked Hermes to stop (if anything was running)"
- step "clearing what the rehearsal touched"
+ step "clearing both trees"
rm -rf "$HERMES_HOME"; ok "removed $HERMES_HOME"
rm -rf "$USERDATA_DIR"; ok "removed $USERDATA_DIR"
- local shim
- if [ -s "$SNAP/shims.txt" ]; then
- while IFS= read -r shim; do rm -f "$shim" 2>/dev/null || true; done < "$SNAP/shims.txt"
- ok "removed the recorded shim files"
- fi
step "restoring your HERMES_HOME"
mkdir -p "$HERMES_HOME"
@@ -641,48 +388,13 @@ cmd_post() {
warn "there was no desktop app data to restore"
fi
- step "restoring the shims"
- if [ -s "$SNAP/shims.txt" ]; then
- while IFS= read -r shim; do
- local saved="$SNAP/shims/$(printf '%s' "$shim" | tr '/' '_')"
- if [ -f "$saved" ]; then
- mkdir -p "$(dirname "$shim")"; cp -p "$saved" "$shim"; ok "restored $shim"
- elif grep -qF "$shim" "$SNAP/shims-links.txt" 2>/dev/null; then
- local target; target="$(awk -v s="$shim" -F'\t' '$1==s{print $2}' "$SNAP/shims-links.txt")"
- mkdir -p "$(dirname "$shim")"; rm -f "$shim"; ln -s "$target" "$shim"
- ok "restored symlink $shim"
- fi
- done < "$SNAP/shims.txt"
- fi
-
- step "how exact was the restore"
- fingerprint_home "$SNAP/fingerprint-restored.txt" >/dev/null
- fingerprint_userdata "$SNAP/userdata-restored.txt" >/dev/null
- local diffs=0
- if diff -q "$SNAP/fingerprint-before.txt" "$SNAP/fingerprint-restored.txt" >/dev/null 2>&1; then
- ok "all $(wc -l < "$SNAP/fingerprint-before.txt" | tr -d ' ') state entries match your backup"
- else
- diffs=$((diffs + 1))
- diff -u "$SNAP/fingerprint-before.txt" "$SNAP/fingerprint-restored.txt" \
- > "$SNAP/fingerprint-restore.diff" 2>/dev/null || true
- warn "some state differs from the backup — details in $SNAP/fingerprint-restore.diff"
- fi
- if [ -f "$SNAP/userdata-before.txt" ] \
- && ! diff -q "$SNAP/userdata-before.txt" "$SNAP/userdata-restored.txt" >/dev/null 2>&1; then
- diffs=$((diffs + 1))
- diff -u "$SNAP/userdata-before.txt" "$SNAP/userdata-restored.txt" \
- > "$SNAP/userdata-restore.diff" 2>/dev/null || true
- warn "some desktop app data differs — details in $SNAP/userdata-restore.diff"
- else
- ok "desktop app data matches"
- fi
+ remove_stale_global_redirect
step "done"
- say "Your install, your data and your git config are back as they were."
+ say "Your HERMES_HOME and the desktop app's data are back exactly as they were."
say "Open the desktop app once and run 'hermes doctor' to confirm."
say "Nothing was judged or changed by this script; the backup at $SNAP is"
say "yours to keep or delete."
- [ "$diffs" = 0 ] || say "(The differences reported above are informational — see the diff files.)"
}
case "$SUBCMD" in
diff --git a/scripts/update-test/smoke-test.ps1 b/scripts/update-test/smoke-test.ps1
index 1ffb08ec994..3fde90407e2 100755
--- a/scripts/update-test/smoke-test.ps1
+++ b/scripts/update-test/smoke-test.ps1
@@ -108,6 +108,30 @@ Write-Host "fixture under $Root"
$pass = 0; $fail = 0
function Check { param([string]$Msg, [bool]$Ok) if ($Ok) { Write-Host " PASS $Msg"; $script:pass++ } else { Write-Host " FAIL $Msg"; $script:fail++ } }
+# Every path, file size and content hash under a tree, so post can be checked
+# for exactness against the tree as it was before pre.
+function Get-TreeListing {
+ param([string]$Root)
+ if (-not (Test-Path -LiteralPath $Root)) { return '' }
+ $lines = New-Object System.Collections.Generic.List[string]
+ $stack = New-Object System.Collections.Stack
+ $stack.Push($Root)
+ while ($stack.Count -gt 0) {
+ $cur = $stack.Pop()
+ foreach ($it in @(Get-ChildItem -LiteralPath $cur -Force -ErrorAction SilentlyContinue)) {
+ $rel = $it.FullName.Substring($Root.Length).TrimStart('\')
+ if ($it.PSIsContainer) {
+ if ($it.Attributes -band [IO.FileAttributes]::ReparsePoint) { $lines.Add("link`t$rel`t$($it.Target)") }
+ else { $lines.Add("dir`t$rel"); $stack.Push($it.FullName) }
+ }
+ else {
+ $lines.Add("file`t$rel`t$($it.Length)`t$((Get-FileHash -LiteralPath $it.FullName -Algorithm SHA256).Hash)")
+ }
+ }
+ }
+ return (($lines | Sort-Object) -join "`n")
+}
+
function Invoke-Rehearsal {
param([string[]]$Arguments, [switch]$AllowFailure)
# PS 5.1 turns a child's stderr into a TERMINATING error record when EAP is
@@ -188,18 +212,21 @@ try {
Write-Host "`n--- pre (source = the fixture repo, so no network) ---"
$statusBefore = (& git -C $Install status --porcelain | Out-String)
+ # Both trees as they are right now: post is checked against this for exactness.
+ $homeBefore = Get-TreeListing $H
+ $userDataBefore = Get-TreeListing $env:HERMES_DESKTOP_USER_DATA_DIR
$r = Invoke-Rehearsal -Arguments @('pre', '-Source', $Install, '-Ref', 'main', '-BackupRoot', $Backups)
Check 'pre exits 0' ($r.Code -eq 0)
$Snap = (Get-ChildItem -LiteralPath $Backups -Directory | Sort-Object Name)[-1].FullName
- foreach ($f in @('hermes-home.tar', 'electron-userdata.tar', 'fingerprint-before.txt', 'userdata-before.txt', 'manifest.json', 'shims.txt', 'checkout.txt', 'remotes.txt')) {
+ foreach ($f in @('hermes-home.tar', 'electron-userdata.tar', 'manifest.json', 'hermes-home.txt', 'target-sha')) {
Check "backup artifact $f" (Test-Path -LiteralPath (Join-Path $Snap $f))
}
$tarList = (& tar.exe -tf (Join-Path $Snap 'hermes-home.tar') | Out-String)
Check 'whole home: checkout .git in the tar' ($tarList -match '(?m)^\./hermes-agent/\.git/config\s*$')
Check 'whole home: PM store in the tar' ($tarList -match '(?m)^\./hermes-agent/\.hermes-runtime/python/interpreter\.bin\s*$')
Check 'whole home: config.yaml in the tar' ($tarList -match '(?m)^\./config\.yaml\s*$')
- $fp = Get-Content -LiteralPath (Join-Path $Snap 'fingerprint-before.txt') -Raw
- Check 'state.db row counts fingerprinted' ($fp -match 'sessions=2')
+ $udList = (& tar.exe -tf (Join-Path $Snap 'electron-userdata.tar') | Out-String)
+ Check 'whole userData: nothing filtered out of the tar' ($udList -match '(?m)^\./Cache/data\.bin\s*$')
Write-Host "`n--- pre points the install at the rehearsal copy ---"
$served = (& git -C (Join-Path $Snap 'serve.git') rev-parse refs/heads/main | Out-String).Trim()
@@ -240,10 +267,18 @@ try {
Check 'upstream-prompt marker removed' (-not (Test-Path -LiteralPath (Join-Path $H '.skip_upstream_prompt')))
Check 'origin resolves officially again' (((& git -C $Install remote get-url origin | Out-String).Trim()) -match 'NousResearch')
Check 'bin shim restored' (Test-Path -LiteralPath (Join-Path $H 'bin\hermes.cmd'))
- Check 'post reports an exact state restore' ($r.Out -match 'entries match your backup')
- if ($r.Out -notmatch 'entries match your backup') {
- Write-Host '--- report section ---'
- Write-Host (($r.Out -split "`n" | Select-String -Pattern 'how exact was the restore' -Context 0, 12 | Out-String))
+ Write-Host "`n--- the acceptance criterion: every file identical before/after ---"
+ $homeAfter = Get-TreeListing $H
+ Check 'HERMES_HOME identical to before pre' ($homeAfter -eq $homeBefore)
+ if ($homeAfter -ne $homeBefore) {
+ Compare-Object ($homeBefore -split "`n") ($homeAfter -split "`n") |
+ ForEach-Object { Write-Host " $($_.SideIndicator) $($_.InputObject)" }
+ }
+ $userDataAfter = Get-TreeListing $env:HERMES_DESKTOP_USER_DATA_DIR
+ Check 'userData identical to before pre' ($userDataAfter -eq $userDataBefore)
+ if ($userDataAfter -ne $userDataBefore) {
+ Compare-Object ($userDataBefore -split "`n") ($userDataAfter -split "`n") |
+ ForEach-Object { Write-Host " $($_.SideIndicator) $($_.InputObject)" }
}
}
finally {
diff --git a/scripts/update-test/smoke-test.sh b/scripts/update-test/smoke-test.sh
index 29320afebb9..61e33148920 100755
--- a/scripts/update-test/smoke-test.sh
+++ b/scripts/update-test/smoke-test.sh
@@ -81,17 +81,22 @@ check_out() { local n="$1" m="$2"; shift 2; local out; out="$("$@" 2>&1 || true)
echo
echo "--- pre (source = the fixture repo, so no network) ---"
STATUS_BEFORE="$(git -C "$INSTALL" status --porcelain)"
+# A pristine copy of both trees: post is checked against it for exactness.
+mkdir -p "$ROOT/pristine/home" "$ROOT/pristine/userdata"
+cp -a "$H/." "$ROOT/pristine/home/"
+cp -a "$HERMES_DESKTOP_USER_DATA_DIR/." "$ROOT/pristine/userdata/"
"${RUN[@]}" pre --source "$INSTALL" --ref main --backup-root "$BACKUPS" > "$ROOT/pre.log" 2>&1
check $? "pre exits 0"
SNAP="$(ls -1d "$BACKUPS"/*/ | head -1)"; SNAP="${SNAP%/}"
-for f in hermes-home.tar electron-userdata.tar fingerprint-before.txt userdata-before.txt manifest.json shims.txt checkout.txt remotes.txt; do
+for f in hermes-home.tar electron-userdata.tar manifest.json hermes-home.txt target-sha; do
[ -e "$SNAP/$f" ]; check $? "backup artifact $f"
done
TARLIST="$(tar -tf "$SNAP/hermes-home.tar" 2>&1 || true)"
grep -qE '^\./hermes-agent/\.git/config$' <<< "$TARLIST"; check $? "whole home: checkout .git in the tar"
grep -qE '^\./hermes-agent/\.hermes-runtime/python/interpreter\.bin$' <<< "$TARLIST"; check $? "whole home: PM store in the tar"
grep -qE '^\./config\.yaml$' <<< "$TARLIST"; check $? "whole home: config.yaml in the tar"
-grep -q 'sessions=2' "$SNAP/fingerprint-before.txt"; check $? "state.db row counts fingerprinted"
+UDLIST="$(tar -tf "$SNAP/electron-userdata.tar" 2>&1 || true)"
+grep -qE '^\./Cache/data\.bin$' <<< "$UDLIST"; check $? "whole userData: nothing filtered out of the tar"
echo
echo "--- pre points the install at the rehearsal copy ---"
@@ -129,16 +134,19 @@ check $? "post exits 0"
[ ! -f "$H/.skip_upstream_prompt" ]; check $? "upstream-prompt marker removed"
git -C "$INSTALL" remote get-url origin | grep -q 'NousResearch'; check $? "origin resolves officially again"
if [ "$SYMLINKS_OK" = 1 ]; then
- [ -L "$HOME/.local/bin/hermes" ]; check $? "user-bin shim restored as a symlink"
+ [ -L "$HOME/.local/bin/hermes" ]; check $? "shim outside the two trees left untouched"
else
echo " SKIP user-bin shim symlink (host cannot create symlinks)"
fi
-grep -q 'entries match your backup' "$ROOT/post.log"; check $? "post reports an exact state restore"
-if ! grep -q 'entries match your backup' "$ROOT/post.log"; then
- echo " --- report section of post.log ---"
- sed -n '/how exact was the restore/,$p' "$ROOT/post.log" | sed 's/^/ /' | head -20
- [ -e "$SNAP/fingerprint-restore.diff" ] && sed 's/^/ /' "$SNAP/fingerprint-restore.diff" | head -30
-fi
+
+echo
+echo "--- the acceptance criterion: every file identical before/after ---"
+diff -r --no-dereference "$ROOT/pristine/home" "$H" > "$ROOT/home.diff" 2>&1
+check $? "HERMES_HOME identical to before pre"
+[ -s "$ROOT/home.diff" ] && sed 's/^/ /' "$ROOT/home.diff" | head -30
+diff -r --no-dereference "$ROOT/pristine/userdata" "$HERMES_DESKTOP_USER_DATA_DIR" > "$ROOT/userdata.diff" 2>&1
+check $? "userData identical to before pre"
+[ -s "$ROOT/userdata.diff" ] && sed 's/^/ /' "$ROOT/userdata.diff" | head -30
echo
echo "=== smoke: $pass passed, $fail failed ==="