From ee441f5db4ac015512ae9caaeed7c29dfd24bac7 Mon Sep 17 00:00:00 2001 From: Michael Hughes Date: Wed, 30 Sep 2026 21:39:13 -0700 Subject: [PATCH] Always report same-source Python UI and image qualification --- .github/workflows/ci.yml | 7 +- .github/workflows/linux-image.yml | 9 +- .github/workflows/os-release-candidate.yml | 9 +- .github/workflows/phishell.yml | 13 +-- .github/workflows/release-qualification.yml | 65 ++++++++++++ README.md | 9 +- docs/os/BUILD_AND_QUALIFY.md | 39 ++++++- docs/os/RELEASE_ARTIFACTS.md | 3 + docs/os/RELEASE_HANDOFF.md | 3 + scripts/os_ci_gate.py | 106 ++++++++++++++++++++ tests/test_os_ci_gate_v01.py | 105 +++++++++++++++++++ 11 files changed, 335 insertions(+), 33 deletions(-) create mode 100644 .github/workflows/release-qualification.yml create mode 100644 scripts/os_ci_gate.py create mode 100644 tests/test_os_ci_gate_v01.py diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c57d5a7e..a8de6a7a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,8 +1,11 @@ name: CI on: - push: - pull_request: + workflow_call: + workflow_dispatch: + +permissions: + contents: read jobs: test: diff --git a/.github/workflows/linux-image.yml b/.github/workflows/linux-image.yml index e2109eff..29dd60f7 100644 --- a/.github/workflows/linux-image.yml +++ b/.github/workflows/linux-image.yml @@ -1,14 +1,7 @@ name: Linux development image on: - pull_request: - paths: - - 'packaging/**' - - 'build/build_iso.sh' - - 'phishell/**' - - 'phios/**' - - 'pyproject.toml' - - '.github/workflows/linux-image.yml' + workflow_call: workflow_dispatch: permissions: diff --git a/.github/workflows/os-release-candidate.yml b/.github/workflows/os-release-candidate.yml index 10cff015..8ff669d4 100644 --- a/.github/workflows/os-release-candidate.yml +++ b/.github/workflows/os-release-candidate.yml @@ -1,14 +1,7 @@ name: Fixture-free OS candidate (unpublished) on: - pull_request: - paths: - - 'packaging/**' - - 'phios/**' - - 'phishell/**' - - 'pyproject.toml' - - 'build/build_iso.sh' - - '.github/workflows/os-release-candidate.yml' + workflow_call: workflow_dispatch: permissions: diff --git a/.github/workflows/phishell.yml b/.github/workflows/phishell.yml index d7b258b9..007299ea 100644 --- a/.github/workflows/phishell.yml +++ b/.github/workflows/phishell.yml @@ -1,18 +1,7 @@ name: PhiShell on: - pull_request: - paths: - - "phishell/**" - - "docs/PHISHELL_*.md" - - ".github/workflows/phishell.yml" - push: - branches: - - main - paths: - - "phishell/**" - - "docs/PHISHELL_*.md" - - ".github/workflows/phishell.yml" + workflow_call: workflow_dispatch: permissions: diff --git a/.github/workflows/release-qualification.yml b/.github/workflows/release-qualification.yml new file mode 100644 index 00000000..241067ba --- /dev/null +++ b/.github/workflows/release-qualification.yml @@ -0,0 +1,65 @@ +name: PhiOS qualification + +on: + pull_request: + push: + branches: [main] + tags: ['phios-linux-v*'] + workflow_dispatch: + +permissions: + contents: read + +concurrency: + group: phios-qualification-${{ github.ref }} + cancel-in-progress: true + +jobs: + changes: + runs-on: ubuntu-latest + timeout-minutes: 5 + outputs: + image: ${{ steps.scope.outputs.image }} + ui: ${{ steps.scope.outputs.ui }} + steps: + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 + with: + fetch-depth: 0 + persist-credentials: false + - id: scope + name: Determine required qualification from the complete local diff + run: python3 scripts/os_ci_gate.py plan + + python-tests: + needs: changes + uses: ./.github/workflows/ci.yml + + phishell: + needs: changes + if: ${{ needs.changes.outputs.ui == 'true' }} + uses: ./.github/workflows/phishell.yml + + normal-image: + needs: changes + if: ${{ needs.changes.outputs.image == 'true' }} + uses: ./.github/workflows/os-release-candidate.yml + + qa-image: + needs: changes + if: ${{ needs.changes.outputs.image == 'true' }} + uses: ./.github/workflows/linux-image.yml + + release-gate: + name: release-gate + if: ${{ always() }} + needs: [changes, python-tests, phishell, normal-image, qa-image] + runs-on: ubuntu-latest + timeout-minutes: 5 + steps: + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 + with: + persist-credentials: false + - name: Require actual success for every requested job + env: + PHIOS_CI_NEEDS: ${{ toJSON(needs) }} + run: python3 scripts/os_ci_gate.py check diff --git a/README.md b/README.md index 251a0731..36de7a8b 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,14 @@ platform, memory/ledger system, and constrained agent runtime built around one r The project is under active development and should be treated as **alpha software**. -The Python package release is separate from the Linux OS effort. The Linux target is an x86_64 UEFI Arch-based Wayfire/PhiShell development preview. Installation, whole-OS recovery, Secure Boot, hardware support and Linux desktop effects are not yet qualified. See [the OS release contract](docs/os/RELEASE_CONTRACT.md) and [implementation status](docs/os/IMPLEMENTATION_STATUS.md). +The Python package release is separate from the Linux OS effort. The Linux target +is an unpublished x86_64 UEFI Arch-based Wayfire/PhiShell development preview. +The exact normal candidate passed VM live/installed boot, persistent data, +matched OS recovery and one restricted Linux proof effect. A separate QA image +passed bounded signed-package update/interruption tests. Physical hardware, +the actual final signed transition, source/license delivery and public release +remain open; Secure Boot is unsupported. See the [OS release contract](docs/os/RELEASE_CONTRACT.md), +[exact evidence](docs/os/IMPLEMENTATION_STATUS.md) and [release handoff](docs/os/RELEASE_HANDOFF.md). ## What PhiOS is diff --git a/docs/os/BUILD_AND_QUALIFY.md b/docs/os/BUILD_AND_QUALIFY.md index ffc06a70..f19451d1 100644 --- a/docs/os/BUILD_AND_QUALIFY.md +++ b/docs/os/BUILD_AND_QUALIFY.md @@ -1,6 +1,7 @@ # Build and qualify the Linux development preview -Use the `Linux development image` pull-request workflow. It builds in a pinned +Use the always-triggered `PhiOS qualification` workflow. Its reusable +`Linux development image` job builds the separate QA artifact in a pinned x86_64 Arch container, downgrades/synchronizes to the fixed Arch repository snapshot in `packaging/linux/release.json`, checks the Archiso package version, and builds the Python and UI packages from a hashed archive of the exact source @@ -64,4 +65,38 @@ A fixture pass is evidence for the checks it performs. Review the screenshot and session behavior. It does not prove installation, persisted receipts, crash recovery, whole-OS updates, hardware compatibility or a Linux effect executor. Those remain explicit gates in RELEASE_CONTRACT.md. CI never tags, -signs, publishes or automatically promotes this candidate. +signs, publishes or automatically promotes this candidate. The later installed +and normal-image gates have their own scopes and receipts in IMPLEMENTATION_STATUS.md. + +## Always-reported qualification gate + +`release-qualification.yml` runs for every pull request, every main push, +OS `phios-linux-v*` tag and manual invocation. It calls the existing Python, +PhiShell, normal image and QA image workflows from the same source revision; +it does not poll or borrow another commit's successful runs. The called +workflows retain independent manual entrypoints and their existing tests and +artifact retention. Automatic calls are centralized to avoid duplicate builds. + +Python tests, installed wheel, native vector and ledger-report checks always +run. Only a complete observed documentation-only PR may omit the expensive +image jobs. PhiShell contract docs still request UI checks. Unknown files, +deleted runtime files, build/test/workflow inputs, unreadable diff, main pushes, +OS tags and manual runs require both images and UI. The classifier uses the +complete local Git trees, including deletions, without an API pagination or +300-file workflow-path cutoff. + +The final job is named **`release-gate`**, with `if: always()`. It fails when +scope determination fails, any required result is missing/failed/cancelled/ +skipped, or scope outputs disagree. A skipped image is acceptable only when +explicitly unrequested for that documentation-only PR; this is not a new image +qualification. The job reports `release_ready: false` and no publication authority. +All jobs have read-only contents permissions and inherit no release secrets. + +After reviewing this change and observing a successful run, the maintainer +should configure **`release-gate`** from GitHub Actions as the required status +on protected main and the applicable release rules. Require current-branch +checks and review, restrict bypass/force push/deletion and protect the OS tag +namespace as appropriate to the chosen release ownership. Those repository +settings are not changed by a workflow commit. A green aggregate does not +replace hardware evidence, authentic signing, final transition qualification, +source/license delivery or explicit release authorization. diff --git a/docs/os/RELEASE_ARTIFACTS.md b/docs/os/RELEASE_ARTIFACTS.md index 32cdd2e8..2d8f7896 100644 --- a/docs/os/RELEASE_ARTIFACTS.md +++ b/docs/os/RELEASE_ARTIFACTS.md @@ -71,6 +71,9 @@ All generated reports remain `release_ready: false`; they do not grant execution, signing, adapter-promotion or publication authority. Main/release branch protection and required-check settings have not been changed by this candidate workflow. Protecting them remains a maintainer repository setting. +The always-reported `release-gate` aggregates the same-source Python/UI/normal/ +QA jobs; see BUILD_AND_QUALIFY.md for its required-status configuration and +explicit documentation-only scope. It cannot attest to hardware or sign/publish. The builder also captures actual Rollup chunk participants before npm pruning, including Vite-generated runtime helpers. Bundled supplier metadata and license diff --git a/docs/os/RELEASE_HANDOFF.md b/docs/os/RELEASE_HANDOFF.md index bb889e7a..3a42a7d7 100644 --- a/docs/os/RELEASE_HANDOFF.md +++ b/docs/os/RELEASE_HANDOFF.md @@ -44,6 +44,9 @@ Review and merge only in stack order after assessing each stated boundary: | [276](https://github.com/MichaelWave369/PhiOS/pull/276) | Restricted Linux proof broker, hardware handoff and bundled frontend inventory | | [277](https://github.com/MichaelWave369/PhiOS/pull/277) | Exact normal-image installed/recovery gate and explicit serial password login | +Review the follow-on always-reported qualification gate after this stack; its +normal and QA jobs reuse the existing exact-image procedures. See +BUILD_AND_QUALIFY.md for the `release-gate` required-status handoff. Review source and tests, not just a green check. Main and OS release-tag protection still require maintainer configuration. Keep publication separate from the existing Python `v*`/PyPI workflow. Evidence never promotes an adapter, enrolls a diff --git a/scripts/os_ci_gate.py b/scripts/os_ci_gate.py new file mode 100644 index 00000000..a61c758d --- /dev/null +++ b/scripts/os_ci_gate.py @@ -0,0 +1,106 @@ +"""Always-reported CI aggregation; a passing result is not release authority.""" +from __future__ import annotations + +import argparse +import json +import os +import re +import subprocess +from pathlib import Path +from typing import Any + +JOBS = ('changes', 'python-tests', 'phishell', 'normal-image', 'qa-image') +SHA = re.compile(r'[0-9a-f]{40}') + + +def documentation(path: str) -> bool: + parts = path.split('/') + if any(part in ('', '.', '..') for part in parts) or '\\' in path: + return False + if len(parts) == 1: + return path.endswith('.md') + if parts[0] == 'docs' and path.endswith('.md'): + return True + return path.startswith('docs/os/evidence/') and path.endswith('.json') + + +def plan(event_name: str, paths: list[str] | None) -> dict[str, str]: + # Every final main push, OS tag and manual run exercises both exact images. + # Only an observed documentation-only PR can omit their expensive jobs. + image = event_name != 'pull_request' or not paths or any(not documentation(p) for p in paths) + ui = image or any(p.startswith('docs/PHISHELL_') for p in paths or []) + return {'image': str(image).lower(), 'ui': str(ui).lower()} + + +def changed_paths(event: dict[str, Any], root: Path) -> list[str] | None: + request = event.get('pull_request') + if not isinstance(request, dict): + raise ValueError('missing pull-request context') + base = request.get('base', {}).get('sha') + head = request.get('head', {}).get('sha') + if not isinstance(base, str) or not isinstance(head, str) or not SHA.fullmatch(base) or not SHA.fullmatch(head): + raise ValueError('invalid diff identities') + try: + # Two complete trees include deletions and changes introduced by a moved + # base. No API pagination/300-file path filter or rename omission applies. + data = subprocess.check_output( + ['git', 'diff', '--no-ext-diff', '--no-renames', '--name-only', '-z', base, head, '--'], + cwd=root, + ) + if data and not data.endswith(b'\0'): + raise ValueError('incomplete changed-path output') + return [p.decode('utf-8') for p in data.split(b'\0') if p] + except (subprocess.CalledProcessError, UnicodeDecodeError): + # An unavailable/unreadable diff requires full image qualification. + return None + + +def verify(needs: dict[str, Any]) -> dict[str, str]: + if set(needs) != set(JOBS) or any(not isinstance(needs[k], dict) for k in JOBS): + raise ValueError('incomplete required job results') + if needs['changes'].get('result') != 'success': + raise ValueError('qualification scope did not succeed') + scope = needs['changes'].get('outputs') + if not isinstance(scope, dict) or set(scope) != {'image', 'ui'} or any(v not in ('true', 'false') for v in scope.values()): + raise ValueError('invalid qualification scope outputs') + if scope['image'] == 'true' and scope['ui'] != 'true': + raise ValueError('image qualification requires UI qualification') + expected = {'changes': 'success', 'python-tests': 'success', + 'phishell': 'success' if scope['ui'] == 'true' else 'skipped', + 'normal-image': 'success' if scope['image'] == 'true' else 'skipped', + 'qa-image': 'success' if scope['image'] == 'true' else 'skipped'} + for job, result in expected.items(): + if needs[job].get('result') != result: + raise ValueError(f'required qualification result held: {job}') + return expected + + +def main() -> int: + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument('command', choices=('plan', 'check')) + args = parser.parse_args() + try: + if args.command == 'plan': + event_name = os.environ['GITHUB_EVENT_NAME'] + paths = None + if event_name == 'pull_request': + event = json.loads(Path(os.environ['GITHUB_EVENT_PATH']).read_text()) + paths = changed_paths(event, Path.cwd()) + scope = plan(event_name, paths) + with Path(os.environ['GITHUB_OUTPUT']).open('a') as stream: + for key, value in scope.items(): + stream.write(f'{key}={value}\n') + print(json.dumps({'required': scope, 'complete_diff_observed': paths is not None}, sort_keys=True)) + else: + results = verify(json.loads(os.environ['PHIOS_CI_NEEDS'])) + print(json.dumps({'schema_version': 'phios.ci-qualification.v1', + 'source_commit': os.environ['GITHUB_SHA'], 'job_results': results, + 'release_ready': False, 'publication_authority': False}, sort_keys=True)) + return 0 + except (KeyError, OSError, ValueError, TypeError, AttributeError) as exc: + print(f'::error::PhiOS qualification held: {exc}') + return 1 + + +if __name__ == '__main__': + raise SystemExit(main()) diff --git a/tests/test_os_ci_gate_v01.py b/tests/test_os_ci_gate_v01.py new file mode 100644 index 00000000..c7620f62 --- /dev/null +++ b/tests/test_os_ci_gate_v01.py @@ -0,0 +1,105 @@ +from __future__ import annotations + +import importlib.util +import subprocess +from pathlib import Path + +import pytest + +SPEC = importlib.util.spec_from_file_location('os_ci_gate', Path(__file__).parents[1] / 'scripts/os_ci_gate.py') +assert SPEC is not None and SPEC.loader is not None +gate = importlib.util.module_from_spec(SPEC) +SPEC.loader.exec_module(gate) + + +def results(image: str = 'true', ui: str = 'true') -> dict: + return {'changes': {'result': 'success', 'outputs': {'image': image, 'ui': ui}}, + 'python-tests': {'result': 'success'}, + 'phishell': {'result': 'success' if ui == 'true' else 'skipped'}, + 'normal-image': {'result': 'success' if image == 'true' else 'skipped'}, + 'qa-image': {'result': 'success' if image == 'true' else 'skipped'}} + + +@pytest.mark.parametrize('job', ['python-tests', 'phishell', 'normal-image', 'qa-image']) +@pytest.mark.parametrize('result', ['failure', 'cancelled', 'skipped']) +def test_requested_failure_cancellation_or_skip_never_passes(job, result): + needs = results() + needs[job]['result'] = result + with pytest.raises(ValueError): + gate.verify(needs) + + +def test_only_explicitly_unrequested_jobs_may_skip(): + assert gate.verify(results('false', 'false'))['normal-image'] == 'skipped' + assert gate.verify(results('false', 'true'))['phishell'] == 'success' + assert gate.verify(results())['normal-image'] == 'success' + needs = results('false', 'false') + needs['python-tests']['result'] = 'skipped' + with pytest.raises(ValueError): + gate.verify(needs) + + +@pytest.mark.parametrize('scope', [{}, {'image': 'false'}, {'image': True, 'ui': 'true'}, + {'image': 'true', 'ui': 'false'}]) +def test_missing_or_inconsistent_scope_holds(scope): + needs = results() + needs['changes']['outputs'] = scope + with pytest.raises(ValueError): + gate.verify(needs) + + +def test_failed_scope_or_missing_job_holds(): + needs = results('false', 'false') + needs['changes']['result'] = 'failure' + with pytest.raises(ValueError): + gate.verify(needs) + del needs['qa-image'] + with pytest.raises(ValueError): + gate.verify(needs) + + +@pytest.mark.parametrize('path', ['packaging/linux/build-linux.sh', 'phios/__init__.py', + '.github/workflows/ci.yml', 'tests/new.py', 'new-build-input', + 'docs/schema.json', 'packaging/README.md', 'docs/../payload.md']) +def test_unknown_or_executable_inputs_require_both_images(path): + assert gate.plan('pull_request', ['docs/os/RELEASE_HANDOFF.md', path]) == {'image': 'true', 'ui': 'true'} + + +def test_complete_documentation_scope_and_final_runs(): + paths = ['README.md', 'docs/os/RELEASE_HANDOFF.md', 'docs/os/evidence/receipt.json'] + assert gate.plan('pull_request', paths) == {'image': 'false', 'ui': 'false'} + assert gate.plan('pull_request', ['docs/PHISHELL_V0.1.md']) == {'image': 'false', 'ui': 'true'} + for event in ['push', 'workflow_dispatch']: + assert gate.plan(event, paths) == {'image': 'true', 'ui': 'true'} + for unobserved in [None, []]: + assert gate.plan('pull_request', unobserved) == {'image': 'true', 'ui': 'true'} + + +def test_complete_local_diff_includes_deleted_runtime_after_many_documents(tmp_path): + def git(*args): + return subprocess.check_output(['git', '-c', 'user.name=Test', '-c', 'user.email=test@example.invalid', *args], cwd=tmp_path, text=True).strip() + + git('init', '-q') + runtime = tmp_path / 'phios/runtime.py' + runtime.parent.mkdir() + runtime.write_text('runtime\n') + git('add', '.') + git('commit', '-qm', 'base') + base = git('rev-parse', 'HEAD') + documents = tmp_path / 'docs' + documents.mkdir() + for i in range(350): + (documents / f'{i:03}.md').write_text('document\n') + runtime.unlink() + git('add', '.') + git('commit', '-qm', 'remove runtime after many documents') + head = git('rev-parse', 'HEAD') + paths = gate.changed_paths({'pull_request': {'base': {'sha': base}, 'head': {'sha': head}}}, tmp_path) + assert paths is not None and len(paths) == 351 and 'phios/runtime.py' in paths + assert gate.plan('pull_request', paths)['image'] == 'true' + + +def test_unavailable_diff_requires_full_scope(tmp_path): + paths = gate.changed_paths({'pull_request': {'base': {'sha': 'a' * 40}, 'head': {'sha': 'b' * 40}}}, tmp_path) + assert paths is None + assert gate.plan('pull_request', paths)['image'] == 'true'