Skip to content

The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.

Harness OS: a developer's loopback feed still counts builds, so the update is exercised before release (#1530)

Bubu-Dudu-52hzf1a67cd2237c
diff --git a/os/release_update.py b/os/release_update.py
index 6d28c7e23..54e9593d9 100644
--- a/os/release_update.py
+++ b/os/release_update.py
@@ -69,6 +69,19 @@ def release(package_version):
return re.sub(r'\.r\d+\.g[0-9a-f]+$', '', package_version.rsplit('-', 1)[0] if '-' in package_version else package_version)
+def is_newer(candidate, installed, builds=False):
+ """Newer only as a release: 0.1.9 after 0.1.8. The same release built from a later commit
+ (0.1.8.r1792578870.gbefebc64d5-1 after the ISO's 0.1.8.r1792577066.g8df82cc2bc-1) is not an
+ update for anyone to take.
+
+ [builds]: a developer's loopback feed only (release_update_vm.py), whose package is a later
+ build of the very release its ISO installed — how the update path is exercised before release.
+ The official channel never counts builds."""
+ if not builds:
+ candidate, installed = release(candidate), release(installed)
+ return int(subprocess.check_output(['vercmp', candidate, installed], text=True)) > 0
+
+
def discover(feed=FEED):
fixture = feed != FEED
try:
@@ -93,10 +106,7 @@ def discover(feed=FEED):
current = subprocess.check_output(['pacman', '-Q', 'harness-os'], text=True).strip().split()
if len(current) != 2 or current[0] != 'harness-os' or not re.fullmatch(r'[0-9A-Za-z.+_-]+', current[1]):
raise ValueError('Cannot identify the installed Harness system package.')
- # Newer only as a release: 0.1.9 after 0.1.8. The same release built from a later commit
- # (0.1.8.r1792578870.gbefebc64d5-1 after the ISO's 0.1.8.r1792577066.g8df82cc2bc-1) is not an
- # update for anyone to take.
- newer = int(subprocess.check_output(['vercmp', release(value), release(current[1])], text=True)) > 0
+ newer = is_newer(value, current[1], builds=fixture)
if newer:
base = json.loads(LOCK.read_text())
load_runtime_updater().validate_base(manifest, base)
diff --git a/os/tests/test_release_update.py b/os/tests/test_release_update.py
index 662008a86..f2f9188b8 100644
--- a/os/tests/test_release_update.py
+++ b/os/tests/test_release_update.py
@@ -82,17 +82,18 @@ class ReleaseChannel(unittest.TestCase):
self.assertEqual(update.release('0.1.8.r1792577066.g8df82cc2bc-1'), '0.1.8')
self.assertEqual(update.release('0.1.9-1'), '0.1.9')
self.assertEqual(update.release('0.1.0pre4.r3-1'), '0.1.0pre4.r3')
- self.manifest['package']['version'] = '0.1.8.r1792578870.gbefebc64d5-1'
- self.publish()
+ later, iso = '0.1.8.r1792578870.gbefebc64d5-1', '0.1.8.r1792577066.g8df82cc2bc-1'
asked = []
- def commands(args, **_):
- if args[0] == 'pacman':
- return 'harness-os 0.1.8.r1792577066.g8df82cc2bc-1\n'
+ def vercmp(args, **_):
asked.append(args[1:])
- return '0\n'
- with patch.object(update.subprocess, 'check_output', side_effect=commands):
- self.assertFalse(update.discover(self.url + '/metadata.json')['available'])
- self.assertEqual(asked, [['0.1.8', '0.1.8']])
+ return '0\n' if args[1:] == ['0.1.8', '0.1.8'] else '1\n'
+ with patch.object(update.subprocess, 'check_output', side_effect=vercmp):
+ # The official channel: the release alone.
+ self.assertFalse(update.is_newer(later, iso))
+ self.assertTrue(update.is_newer('0.1.9.r1792642003.g2086a4ac66-1', iso))
+ # A developer's loopback feed exercises the update with a later build of the same release.
+ self.assertTrue(update.is_newer(later, iso, builds=True))
+ self.assertEqual(asked, [['0.1.8', '0.1.8'], ['0.1.9', '0.1.8'], [later, iso]])
def test_existing_feed_discovers_an_official_release_without_reconfiguring_the_client(self):
self.manifest['requires_os_version'] = '0.1.0'