Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
433b30a
R06: bind updater direct invocation to its signed app sibling
Oleksii-debug Sep 29, 2026
9688f50
R06: qualify updater self-identity and confused-deputy rejection
Oleksii-debug Sep 29, 2026
b8285ee
R06: allowlist updater execution and post-restart health commands
Oleksii-debug Sep 29, 2026
ae21639
R06: isolate staged candidate in publisher rejection regression
Oleksii-debug Sep 29, 2026
b25ce18
R06: provision pytest for runtime integration suite
Oleksii-debug Sep 29, 2026
a617ea1
R06: align packaging fail-closed assertions with dual artifacts
Oleksii-debug Sep 29, 2026
798010a
R06: assert semantic initial install-button disable state
Oleksii-debug Sep 29, 2026
70cf117
R06: assert stale cleanup covers both packaged artifacts
Oleksii-debug Sep 29, 2026
4b282be
R06: repair exact-head update qualification contracts
Oleksii-debug Sep 29, 2026
6658c41
R06: make health regressions discoverable by unittest
Oleksii-debug Sep 29, 2026
620b459
R06: make parent-wait regressions discoverable by unittest
Oleksii-debug Sep 29, 2026
09e2b92
R06: make process regressions discoverable by unittest
Oleksii-debug Sep 29, 2026
2c89169
R06: make relaunch regressions discoverable by unittest
Oleksii-debug Sep 29, 2026
37eba77
R06: make updater runner regressions discoverable by unittest
Oleksii-debug Sep 29, 2026
afbd227
R06: keep runtime regression gates dependency-free
Oleksii-debug Sep 29, 2026
b5cd9f1
R06: keep updater qualification on canonical unittest runner
Oleksii-debug Sep 29, 2026
1f6b307
R06: align packaged artifact cleanup qualification
Oleksii-debug Sep 29, 2026
0ac5ba4
R06: lock update transport commands to empty payload
Oleksii-debug Sep 29, 2026
ae89b5a
R06: reconcile qualification successor onto current updater head
Oleksii-debug Sep 29, 2026
b448b40
R06 updater: carry atomic authority/resource repair into convergence
Oleksii-debug Sep 29, 2026
0446825
R06 updater: carry authority/resource regressions into convergence
Oleksii-debug Sep 29, 2026
c55bb27
R06 updater: align convergence success fixture with disarm contract
Oleksii-debug Sep 29, 2026
89bab26
Merge pull request #253 from Oleksii-debug/r06-update-qualification-c…
Oleksii-debug Sep 29, 2026
83cab45
Qualify #252 on literal pull-request head
Oleksii-debug Sep 29, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/r06-dev05-runtime.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,17 @@ jobs:
runtime:
runs-on: ubuntu-latest
timeout-minutes: 15
env:
EXPECTED_HEAD: ${{ github.event.pull_request.head.sha || github.sha }}
defaults:
run:
working-directory: runtime_engine
steps:
- uses: actions/checkout@v4
with:
ref: ${{ env.EXPECTED_HEAD }}
- name: Confirm exact source checkout
run: test "$(git rev-parse HEAD)" = "$EXPECTED_HEAD"
- uses: actions/setup-python@v5
with:
python-version: "3.11"
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/r06-dev06-memory.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,17 @@ jobs:
memory:
runs-on: ubuntu-latest
timeout-minutes: 15
env:
EXPECTED_HEAD: ${{ github.event.pull_request.head.sha || github.sha }}
defaults:
run:
working-directory: runtime_engine
steps:
- uses: actions/checkout@v4
with:
ref: ${{ env.EXPECTED_HEAD }}
- name: Confirm exact source checkout
run: test "$(git rev-parse HEAD)" = "$EXPECTED_HEAD"
- uses: actions/setup-python@v5
with:
python-version: "3.11"
Expand Down
13 changes: 13 additions & 0 deletions .github/workflows/r06-dev10-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ on:
permissions:
contents: read

env:
EXPECTED_HEAD: ${{ github.event.pull_request.head.sha || github.sha }}

concurrency:
group: r06-dev10-${{ github.ref }}
cancel-in-progress: true
Expand All @@ -28,6 +31,11 @@ jobs:
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
with:
ref: ${{ env.EXPECTED_HEAD }}
- name: Confirm exact source checkout
shell: bash
run: test "$(git rev-parse HEAD)" = "$EXPECTED_HEAD"
- uses: actions/setup-python@v5
with:
python-version: '3.13'
Expand All @@ -43,6 +51,11 @@ jobs:
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
with:
ref: ${{ env.EXPECTED_HEAD }}
- name: Confirm exact source checkout
shell: bash
run: test "$(git rev-parse HEAD)" = "$EXPECTED_HEAD"
- uses: actions/setup-python@v5
with:
python-version: '3.13'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,38 +1,79 @@
from __future__ import annotations

from collections.abc import Callable, Sequence
from pathlib import Path
import stat
import sys
from typing import Any

from scripture_archive_platform.desktop_host.authenticode import (
verify_same_publisher_authenticode,
)
from scripture_archive_platform.desktop_host.version import CURRENT_APPLICATION_VERSION
from runtime_engine.scripture_archive_runtime.application_update_process import (
parse_trusted_updater_argv,
)
from runtime_engine.scripture_archive_runtime.application_update_runner import (
execute_trusted_updater,
)


UPDATER_OK = 0
UPDATER_FAILED = 2
_UPDATER_SUFFIX = "-Updater.exe"


def _resolve_packaged_installed_sibling(
argv: Sequence[str],
*,
updater_executable: Path,
) -> tuple[Path, Path]:
"""Bind direct invocation to the exact app sibling of this updater executable."""

_, installed_argument, _ = parse_trusted_updater_argv(tuple(argv))
updater = Path(updater_executable)
updater_meta = updater.lstat()
if stat.S_ISLNK(updater_meta.st_mode) or not stat.S_ISREG(updater_meta.st_mode):
raise ValueError("packaged updater executable identity is invalid")
updater = updater.resolve(strict=True)
if not updater.name.casefold().endswith(_UPDATER_SUFFIX.casefold()):
raise ValueError("packaged updater executable name is invalid")

installed_name = updater.name[: -len(_UPDATER_SUFFIX)] + ".exe"
expected_installed = updater.with_name(installed_name)
installed_meta = installed_argument.lstat()
if stat.S_ISLNK(installed_meta.st_mode) or not stat.S_ISREG(installed_meta.st_mode):
raise ValueError("installed application identity is invalid")
installed = installed_argument.resolve(strict=True)
if installed != expected_installed:
raise ValueError("installed application is not the canonical updater sibling")
return installed, updater


def run_updater(
argv: Sequence[str],
*,
execute: Callable[..., Any] = execute_trusted_updater,
verifier: Callable[..., bool] = verify_same_publisher_authenticode,
updater_executable: Path | None = None,
) -> int:
"""Run one fixed updater command with packaged trust authorities.

The semantic current version and Authenticode verifier are imported from the
packaged native host. No browser/web payload can select either authority. Error
details are intentionally not echoed because argv contains local filesystem paths.
Direct invocation is bound to the exact application sibling mechanically derived
from this updater's own executable identity. That installed app and this updater
must also share a valid publisher before the runner can consume any apply handoff.
The runner independently verifies installed app versus staged candidate again.
"""

if not callable(execute) or not callable(verifier):
return UPDATER_FAILED
try:
installed, updater = _resolve_packaged_installed_sibling(
tuple(argv),
updater_executable=Path(sys.executable if updater_executable is None else updater_executable),
)
if not verifier(installed, updater):
return UPDATER_FAILED
execute(
tuple(argv),
current_version=CURRENT_APPLICATION_VERSION,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"authoring.undo","authoring.redo","authoring.publish_version","authoring.list_versions","authoring.rollback_version",
"keymap.list","keymap.rebind","keymap.clear","keymap.reset_context","keymap.reset_all",
"keymap.export","keymap.import","settings.get","settings.set",
"speech.status","speech.synthesize_prompt","application_update.select_verify","application_update.select_verify_stage","application_update.pending_status","application_update.prepare_apply","application_update.cancel_pending","dossier.get","diagnostics.get_report"
"speech.status","speech.synthesize_prompt","application_update.select_verify","application_update.select_verify_stage","application_update.pending_status","application_update.prepare_apply","application_update.apply_and_restart","application_update.cancel_pending","application_update.commit_post_restart_health","dossier.get","diagnostics.get_report"
})

_PLAYER_TRUTH_OWNERS = frozenset({"D5/runtime", "REFERENCE_TEST_ONLY"})
Expand Down Expand Up @@ -102,7 +102,7 @@ def validate_request_shape(request:Any)->tuple[str,str,dict[str,Any]]:
raise ValueError('authoring.pack_compatibility accepts an empty payload')
if cmd=='speech.status' and payload:
raise ValueError('speech.status accepts an empty payload')
if cmd in {'application_update.pending_status','application_update.prepare_apply','application_update.cancel_pending'} and payload:
if cmd in {'application_update.pending_status','application_update.prepare_apply','application_update.apply_and_restart','application_update.cancel_pending','application_update.commit_post_restart_health'} and payload:
raise ValueError(f'{cmd} accepts an empty payload')
if cmd=='speech.synthesize_prompt':
allowed={'provider_id','voice_id','speed','allow_network'}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
from __future__ import annotations

import unittest

from scripture_archive_platform.transport.contracts import validate_request_shape


API_VERSION = "scripture.transport.v1"
UPDATE_COMMANDS = (
"application_update.apply_and_restart",
"application_update.commit_post_restart_health",
)


def request(command: str, payload=None, *, request_id: str = "update-contract-rid"):
return {
"api_version": API_VERSION,
"request_id": request_id,
"command": command,
"payload": {} if payload is None else payload,
}


class ApplicationUpdateTransportContractTests(unittest.TestCase):
def test_host_owned_update_commands_are_allowlisted_with_empty_payload(self) -> None:
for command in UPDATE_COMMANDS:
with self.subTest(command=command):
rid, parsed_command, payload = validate_request_shape(request(command))
self.assertEqual(rid, "update-contract-rid")
self.assertEqual(parsed_command, command)
self.assertEqual(payload, {})

def test_browser_cannot_supply_update_process_path_or_identity_authority(self) -> None:
injected_payloads = (
{"pid": 1},
{"path": r"C:\attacker.exe"},
{"version": "9.9.9"},
{"sha256": "0" * 64},
)
for command in UPDATE_COMMANDS:
for payload in injected_payloads:
with self.subTest(command=command, payload=payload):
with self.assertRaisesRegex(ValueError, "empty payload"):
validate_request_shape(request(command, payload))


if __name__ == "__main__":
unittest.main()
21 changes: 16 additions & 5 deletions lanes/dev1/repair_overlay/tests/test_packaged_diagnostics.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,22 +166,33 @@ def test_builder_fails_closed_on_native_failure_and_stale_artifact(self):
'Assert-NativeSuccess "pip upgrade"',
'Assert-NativeSuccess "build dependency install"',
'Assert-NativeSuccess "Windows release diagnostics"',
'Assert-NativeSuccess "PyInstaller build"',
'Assert-NativeSuccess "PyInstaller application build"',
'Assert-NativeSuccess "PyInstaller updater build"',
'Assert-NativeSuccess "Python version query"',
'Assert-NativeSuccess "artifact verification"',
'Assert-NativeSuccess "application artifact verification"',
'Assert-NativeSuccess "updater artifact verification"',
):
self.assertIn(step, build)
stale_cleanup = "Remove-Item -LiteralPath $Out -Force"
stale_cleanup = "Remove-Item -LiteralPath $artifact -Force"
self.assertIn("foreach ($artifact in @($Out, $UpdaterOut))", build)
self.assertIn(stale_cleanup, build)
self.assertLess(build.index(stale_cleanup), build.index("pyinstaller.exe"))
self.assertLess(
build.index('Assert-NativeSuccess "PyInstaller build"'),
build.index('Assert-NativeSuccess "PyInstaller application build"'),
build.index('if (-not (Test-Path -LiteralPath $Out -PathType Leaf))'),
)
self.assertLess(
build.index('Assert-NativeSuccess "artifact verification"'),
build.index('Assert-NativeSuccess "PyInstaller updater build"'),
build.index('if (-not (Test-Path -LiteralPath $UpdaterOut -PathType Leaf))'),
)
self.assertLess(
build.index('Assert-NativeSuccess "application artifact verification"'),
build.index('Write-Output "Built $Out'),
)
self.assertLess(
build.index('Assert-NativeSuccess "updater artifact verification"'),
build.index('Write-Output "Built $UpdaterOut'),
)

def test_desktop_host_wraps_update_layer_with_read_only_diagnostics(self):
platform = Path(__file__).resolve().parents[1]
Expand Down
Loading
Loading