Route native service commands and configure fresh authoring role

Select native installs only via explicit PIPELINES_PREFIX or the matching owned prefix/bin/pipelines executable. Route enable/status/disable to the existing native supervisor; validate registration ownership, label and command, keep preview read-only, and disable login registration before stopping. Never fall back to a standalone service for an invalid explicit prefix.

Fresh native installs explicitly enable authoring, while reinstalls preserve false or missing legacy role settings. Add explicit --allow-authoring/--no-authoring overrides and pass the server flag only for manifest true. Print a copyable native enable command and update installation help/docs. No Docker configuration changes.

Checks: 54 mocked native installer/lifecycle tests; 8 entrypoint tests; offline Go installation/CLI tests and vet; gofmt clean; shell syntax and diff checks. No live install, restart, deployment, permission/config changes, or native Linux verification.
This commit is contained in:
2026-10-20 21:41:05 +01:00
parent d58b3f49fc
commit bb32383bbe
11 changed files with 508 additions and 18 deletions
+41
View File
@@ -250,6 +250,46 @@ class SetupNativeTests(unittest.TestCase):
installer = setup_native.Setup(directory, runner=Recorder(), environ={"PIPELINES_PREFIX": str(custom)})
self.assertEqual(installer.resolve_prefix(), custom.resolve())
def test_authoring_role_defaults_only_fresh_install_to_enabled(self):
with tempfile.TemporaryDirectory() as directory:
installer = self.installer(directory, Recorder())
prefix = Path(directory) / "prefix"
self.assertTrue(installer.authoring_role(prefix, None))
prefix.mkdir()
for previous, expected in (({}, False), ({"allow_authoring": False}, False),
({"allow_authoring": True}, True)):
with self.subTest(previous=previous):
manifest = prefix / setup_native.MARKER
manifest.write_text(json.dumps(previous))
before = manifest.read_bytes()
self.assertIs(installer.authoring_role(prefix, None), expected)
self.assertTrue(installer.authoring_role(prefix, True))
self.assertFalse(installer.authoring_role(prefix, False))
self.assertEqual(manifest.read_bytes(), before)
manifest.write_text('{"allow_authoring":"true"}')
with self.assertRaisesRegex(ValueError, "Invalid existing authoring role"):
installer.authoring_role(prefix, None)
def test_authoring_flags_are_explicit_optional_overrides(self):
self.assertIsNone(setup_native.arguments([]).allow_authoring)
self.assertTrue(setup_native.arguments(["--allow-authoring"]).allow_authoring)
self.assertFalse(setup_native.arguments(["--no-authoring"]).allow_authoring)
def test_full_run_keeps_existing_execution_only_and_accepts_fresh_opt_out(self):
for previous, arguments in (({}, []), ({"allow_authoring": False}, []), (None, ["--no-authoring"])):
with self.subTest(previous=previous), tempfile.TemporaryDirectory() as directory:
installer = self.installer(directory, Recorder())
prefix = Path(directory) / "prefix"
if previous is not None:
prefix.mkdir()
(prefix / setup_native.MARKER).write_text(json.dumps(previous))
with patch.object(setup_native.shutil, "which", side_effect=self.which_all()), \
patch.object(setup_native.lan, "detect_lan", return_value="192.168.1.20"), \
patch.object(setup_native.configure, "host_timezone", return_value="UTC"), \
redirect_stdout(io.StringIO()):
installer.run(setup_native.arguments(arguments))
self.assertFalse(manage.load(prefix)["allow_authoring"])
def test_missing_opencode_fails_actionably(self):
with tempfile.TemporaryDirectory() as directory:
installer = self.installer(directory, Recorder())
@@ -268,6 +308,7 @@ class SetupNativeTests(unittest.TestCase):
installer.run(setup_native.arguments([]))
config = manage.load(prefix)
self.assertEqual(config["format"], 1)
self.assertTrue(config["allow_authoring"])
self.assertEqual(config["prefix"], str(prefix.resolve()))
self.assertEqual(config["server_port"], 8080)
self.assertEqual(config["bind_address"], "127.0.0.1")