From c8063b5f2afe420df8f920a52364ea73e3f2e513 Mon Sep 17 00:00:00 2001 From: Hermes Agent Date: Sat, 24 Oct 2026 16:31:29 +0000 Subject: [PATCH] fix(ci): admit exact installed runner evidence in ownership preflight --- scripts/editorial-ownership.py | 8 +++++++- scripts/test_editorial_runtime_state.py | 13 +++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 scripts/test_editorial_runtime_state.py diff --git a/scripts/editorial-ownership.py b/scripts/editorial-ownership.py index 8dcd9f6f..12ca1d7f 100644 --- a/scripts/editorial-ownership.py +++ b/scripts/editorial-ownership.py @@ -6,6 +6,7 @@ Caller must serialize with deployment; never run alongside an editorial runner. """ import json import os +import re from pathlib import Path import stat @@ -20,7 +21,12 @@ def allowed(relative,isdir): if relative in DIRS if isdir else relative in LEAVES:return True # Runner-created state is limited to immediate regular files, never subtrees. p=Path(relative) - return not isdir and str(p.parent) in STATE_ROOTS and p.name in ('lock','proposal.json') + if not isdir and str(p.parent) in STATE_ROOTS and p.name in ('lock','proposal.json'):return True + # Installed runner persists allowlisted timing evidence for task/run/profile. + # Admit only that exact immediate-file grammar, not arbitrary JSON or trees. + profiles='|'.join(re.escape(profile) for profile in PROFILES) + return not isdir and str(p.parent)=='editorial-v4/runner-state' and re.fullmatch( + r'[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12}-[0-9a-f]{32}-(?:'+profiles+r')\.json',p.name) is not None def scan(home,uid,gid): if not home.is_absolute() or home.is_symlink():raise ValueError('Canonical home required') diff --git a/scripts/test_editorial_runtime_state.py b/scripts/test_editorial_runtime_state.py new file mode 100644 index 00000000..a1d2b417 --- /dev/null +++ b/scripts/test_editorial_runtime_state.py @@ -0,0 +1,13 @@ +import importlib.util +from pathlib import Path +import unittest +s=importlib.util.spec_from_file_location('ownership',Path(__file__).with_name('editorial-ownership.py')) +m=importlib.util.module_from_spec(s);s.loader.exec_module(m) +class RuntimeStateTests(unittest.TestCase): + def test_installed_runner_evidence_is_reviewed_but_arbitrary_state_is_not(self): + prefix='editorial-v4/runner-state/' + good='1a00bc08-3ca4-4519-ae1e-9eec7b098756-efcc15cd7b824198abc4f85abcfb0730-canina-competitor-worker.json' + self.assertTrue(m.allowed(prefix+good,False)) + for name in ['anything.json',good.replace('canina-competitor-worker','unreviewed'),good+'/nested',good.replace('efcc15cd7b824198abc4f85abcfb0730','oops')]: + self.assertFalse(m.allowed(prefix+name,False)) + self.assertFalse(m.allowed(prefix+good,True))