diff --git a/.github/workflows/deployment-experiments.yml b/.github/workflows/deployment-experiments.yml new file mode 100644 index 0000000..6ebf8da --- /dev/null +++ b/.github/workflows/deployment-experiments.yml @@ -0,0 +1,82 @@ +name: Deployment experiments +on: + pull_request: + paths: + - 'scripts/deployment_experiments.py' + - '.github/workflows/deployment-experiments.yml' + workflow_dispatch: +permissions: + contents: read +concurrency: + group: deployment-experiments-${{ github.ref }} + cancel-in-progress: true +jobs: + investigate: + strategy: + fail-fast: false + matrix: + os: [windows-latest, ubuntu-latest, macos-latest] + runs-on: ${{ matrix.os }} + timeout-minutes: 25 + env: + SIDEPULSE_NATIVE_VAULT_TESTS: '1' + SIDEPULSE_INSTALL_SYSTEM_TESTS: '1' + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7 + with: + persist-credentials: false + - uses: actions/setup-dotnet@a98b56852c35b8e3190ac28c8c2271da59106c68 # v6 + with: + dotnet-version: 10.0.x + - name: Prepare isolated native credential vault + if: runner.os != 'Windows' + shell: bash + run: | + if [ "$RUNNER_OS" = 'Linux' ]; then + sudo apt-get update -qq -o Acquire::Retries=1 -o Acquire::http::Timeout=30 -o Acquire::https::Timeout=30 + sudo apt-get install -y --no-install-recommends libsecret-tools gnome-keyring dbus-x11 + bus_address=$(dbus-daemon --session --fork --print-address=1) + export DBUS_SESSION_BUS_ADDRESS="$bus_address" + echo "DBUS_SESSION_BUS_ADDRESS=$bus_address" >> "$GITHUB_ENV" + printf '%s' 'sidepulse-ci-only' | gnome-keyring-daemon --unlock --components=secrets + else + security default-keychain -d user > "$RUNNER_TEMP/sidepulse-previous-keychain" + security list-keychains -d user > "$RUNNER_TEMP/sidepulse-previous-search-list" + security create-keychain -p 'sidepulse-ci-only' "$RUNNER_TEMP/sidepulse-ci.keychain-db" + security default-keychain -d user -s "$RUNNER_TEMP/sidepulse-ci.keychain-db" + security list-keychains -d user -s "$RUNNER_TEMP/sidepulse-ci.keychain-db" + security unlock-keychain -p 'sidepulse-ci-only' "$RUNNER_TEMP/sidepulse-ci.keychain-db" + security set-keychain-settings -lut 21600 "$RUNNER_TEMP/sidepulse-ci.keychain-db" + fi + - name: Evaluate native publishing modes without changing releases + shell: pwsh + run: | + $destination = Join-Path $env:RUNNER_TEMP 'spn-deployment-experiments' + python scripts/deployment_experiments.py --output $destination --samples 5 + if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } + dotnet --info > "$destination/sdk-info.log" + - name: Upload diagnostic reports only + if: always() + uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 + with: + name: deployment-experiments-${{ runner.os }} + path: | + ${{ runner.temp }}/spn-deployment-experiments/*.json + ${{ runner.temp }}/spn-deployment-experiments/*.log + retention-days: 30 + - name: Remove temporary macOS keychain + if: always() && runner.os == 'macOS' + shell: bash + run: | + if [ -f "$RUNNER_TEMP/sidepulse-previous-keychain" ]; then + previous=$(cat "$RUNNER_TEMP/sidepulse-previous-keychain" | tr -d '"' | xargs) + security default-keychain -d user -s "$previous" + fi + if [ -f "$RUNNER_TEMP/sidepulse-previous-search-list" ]; then + keychains=() + while IFS= read -r keychain; do keychains+=("$keychain"); done < <(python3 -c 'import shlex,sys; print("\n".join(shlex.split(sys.stdin.read())))' < "$RUNNER_TEMP/sidepulse-previous-search-list") + security list-keychains -d user -s "${keychains[@]}" + fi + if [ -f "$RUNNER_TEMP/sidepulse-ci.keychain-db" ]; then + security delete-keychain "$RUNNER_TEMP/sidepulse-ci.keychain-db" + fi diff --git a/docs/performance/2026-10-26-deployment.md b/docs/performance/2026-10-26-deployment.md new file mode 100644 index 0000000..6f3d966 --- /dev/null +++ b/docs/performance/2026-10-26-deployment.md @@ -0,0 +1,111 @@ +# Trimming, ReadyToRun and Native AOT investigation + +Date: 2026-10-26. Tracks [#26](https://github.com/Anheledir/SidePulse.NET/issues/26). +Baseline application source: `db69bedd20f6711ac2e4bf83dabf6b090aab6a54`. +Local toolchain: .NET SDK 10.0.100/runtime 10.0.0, linux-x64, GCC, Linux 6.18.55, +Intel Xeon Platinum 8573C, three logical CPUs. Other native platforms are evaluated +by the Deployment experiments workflow; do not infer six-runtime certification +from one Linux run. + +## Decision + +Keep the existing untrimmed self-contained release as the supported default. +**Partial trimming plus ReadyToRun is a promising smaller/faster candidate**, but +clean analysis still exposes reflection-based JSON and CLI metadata risks. Neither +successful compilation nor a successful bare version probe is release acceptance. +Do not lower production warning policy to ship the prototype. + +- [#60](https://github.com/Anheledir/SidePulse.NET/issues/60): typed JSON contracts, + source generation and format/IPC/schema compatibility (P1). +- [#61](https://github.com/Anheledir/SidePulse.NET/issues/61): trimming/AOT-safe + command/settings registration and third-party metadata handling (P2). + +Re-evaluate promotion after these fixes, strict analysis, native credentials and +full package lifecycle acceptance. Native AOT needs platform-native toolchains; +JIT bundle cross-publishing support does not imply AOT cross-compilation support. + +## Local results + +| Variant | Executable | gzip executable | Full CLI / lifecycle smoke | +|---|---:|---:|---| +| Existing self-contained bundle | about 76.6 MB | about 33.2 MB | Supported baseline | +| Unrestricted trimming | 18.05 MB | not used as a candidate | Full command startup crashes | +| Native AOT | 13.73 MB | not used as a candidate | Full command startup crashes | +| Partial trimming / retained app metadata | 23.13 MB | see raw report | All seven local smokes pass with metadata retained | +| Partial trimming + ReadyToRun | 39.46 MB | 16.98 MB | All seven local smokes pass; analysis warnings remain | + +MB is decimal. Gzip measurements are executable-only, not complete release archives. +Native AOT used `CppCompilerAndLinker=gcc` because this local machine has no clang; +Windows/macOS use their native toolchains in the workflow. Debug symbols are not +counted as executable bytes. Native AOT does not require the .NET runtime at launch. + +Nine paired empty/reused bundle-cache launches with no simultaneous build: + +| Variant | Warm version | Warm state preview | Warm Home (Unix PTY) | +|---|---:|---:|---:| +| Untrimmed reference from startup investigation | 29.15 ms | 169.04 ms | 187.99 ms | +| Partial trimming, clean measurement | 73.37 ms | 384.06 ms | 399.23 ms | +| Partial trimming + ReadyToRun | 26.93 ms | 79.79 ms | 75.63 ms | + +These runs are shared-machine observations, not cold OS/antivirus measurements. +The untrimmed numbers come from the preceding startup report, not an interleaved +same-job pair; the native workflow rebuilds and measures a full baseline in the +same environment. ReadyToRun restores precompiled code after trimming; the plain +trimmed runtime does considerably more startup/JIT work here. All tested Linux +commands observed zero extracted cache bytes. No Windows Home timing is inferred +from redirected execution. + +## Compatibility evidence + +Unrestricted trimming and raw AOT both retain a working bare `--version`, but +`--version --no-interactive` and state preview abort during Spectre.Console.Cli +configuration: `Could not get settings type for command ... PreferencesCommand`. +Preserving application/third-party metadata repairs this first failure in the JIT +prototype. The supported `TrimMode=partial` retains unannotated application code; +`JsonSerializerIsReflectionEnabledByDefault=true` is also needed for current JSON. +An exploratory assembly-root prototype produced the same 23.13 MB executable. + +The initial incremental partial build emitted no new diagnostics. A fresh combined +build surfaced the existing IL2026 JSON and IL2104 Spectre warnings; incremental +silence is **not** a strict compatibility result. The experiment runner uses rebuild +and records analysis diagnostics and diagnostic-only warning overrides explicitly. +The ReadyToRun diagnostic run recorded 64 IL2026 occurrences and one IL2104 +assembly warning. Counts include compile/link phases, not unique bugs. Raw AOT +also reports IL3050 dynamic-code diagnostics. JSON is used in protected link +storage, preferences/profiles, manifests/plans, provider ownership, IPC, HTTP bridge +payloads, diagnostics and anonymous CLI output, so the fix is a shared contract +change rather than one serializer switch. + +The smaller JIT/ReadyToRun prototype passed CLI/config/profile/host tests, Unix PTY +navigation/cancellation and active-host Home, animation/offline licenses, +install/PATH/conflicts/owned uninstall, updater replacement/startup-failure rollback, +four generated agent wrappers and native OpenCode plugin-to-host smoke. Local +vault import is conditional on the configured native-vault test environment; +the workflow provisions isolated Windows/macOS/Linux vault checks. Actual phone +and physical Dot/Pro behavior remain separate acceptance in #2/#3/#4. + +## Reproduction + +```bash +python3 scripts/deployment_experiments.py --output /tmp/spn-deployment --samples 7 +``` + +Use a fresh output directory. The script builds `full`, `raw-trim`, `partial-strict`, +`partial`, `partial-r2r` and `aot` separately, records exact properties/build logs, +checks real command initialization and JSON/docs/licenses, and runs existing native +smokes and benchmarks only for functioning variants. Expected candidate failures +remain visible in `report.json`; a broken full baseline fails the investigation. +Diagnostic variants explicitly permit warnings to collect evidence, never to +produce normal release assets. Only reports/logs are uploaded by the workflow. +The script suppresses crash core dumps from deliberately broken prototypes. + +The default publisher, six package formats, credential identities, updater and +normal warnings-as-errors settings are unchanged. Offline docs/license resources +remain part of each candidate and are verified by existing smoke tests. + +Raw local evidence: + +- [Partial-trim startup](2026-10-26-partial-trim.json) +- [ReadyToRun build/probes/smokes/startup](2026-10-26-partial-r2r.json) +- [Raw trim/AOT failures and sizes](2026-10-26-trim-aot-failures.json) +- [Earlier startup baseline and method](2026-10-26-startup.md) diff --git a/docs/performance/2026-10-26-partial-r2r.json b/docs/performance/2026-10-26-partial-r2r.json new file mode 100644 index 0000000..97bf48e --- /dev/null +++ b/docs/performance/2026-10-26-partial-r2r.json @@ -0,0 +1,226 @@ +{ + "schema_version": 1, + "runtime": "linux-x64", + "platform": "Linux-6.18.55-x86_64-with-glibc2.41", + "version": "0.1.0-beta.2", + "decision": "Experimental evidence only. Ordinary release settings are not changed by this script.", + "variants": { + "partial-r2r": { + "properties": [ + "PublishTrimmed=true", + "TrimMode=partial", + "JsonSerializerIsReflectionEnabledByDefault=true", + "PublishReadyToRun=true", + "TreatWarningsAsErrors=false", + "ILLinkTreatWarningsAsErrors=false", + "IlcTreatWarningsAsErrors=false" + ], + "diagnostic_warnings_allowed": true, + "publish_exit_code": 0, + "analysis_warnings": { + "IL2026": 64, + "IL2104": 1 + }, + "probes": [ + { + "arguments": [ + "--version" + ], + "exit_code": 0, + "passed": true, + "stdout_bytes": 13, + "stderr_excerpt": "" + }, + { + "arguments": [ + "--version", + "--no-interactive" + ], + "exit_code": 0, + "passed": true, + "stdout_bytes": 13, + "stderr_excerpt": "" + }, + { + "arguments": [ + "state", + "working", + "--dry-run", + "--json" + ], + "exit_code": 0, + "passed": true, + "stdout_bytes": 98, + "stderr_excerpt": "" + }, + { + "arguments": [ + "settings", + "show", + "--json" + ], + "exit_code": 0, + "passed": true, + "stdout_bytes": 246, + "stderr_excerpt": "" + }, + { + "arguments": [ + "docs", + "--offline" + ], + "exit_code": 0, + "passed": true, + "stdout_bytes": 73721, + "stderr_excerpt": "" + }, + { + "arguments": [ + "about", + "licenses", + "--full" + ], + "exit_code": 0, + "passed": true, + "stdout_bytes": 260543, + "stderr_excerpt": "" + } + ], + "smokes": { + "cli_smoke": 0, + "terminal_smoke": 0, + "animation_smoke": 0, + "install_smoke": 0, + "update_smoke": 0, + "agent_smoke": 0, + "opencode_smoke": 0 + }, + "executable_bytes": 39458004, + "executable_gzip_bytes": 16977751, + "manifest_exit_code": 0, + "benchmark": { + "schema_version": 1, + "label": "partial-r2r", + "platform": "Linux-6.18.55-x86_64-with-glibc2.41", + "architecture": "x86_64", + "processor": "", + "logical_cpus": 3, + "python": "3.12.14", + "executable_sha256": "30a5b728df539ed996ca13f00e66b139f2022c4c28952fb1eb3b026a13a4ab2f", + "executable_bytes": 39458004, + "executable_gzip_bytes": 16977751, + "extracted_bytes": 0, + "extracted_files": [], + "samples_per_mode": 9, + "results": { + "version": { + "empty_bundle_cache": { + "samples_ms": [ + 24.78, + 24.31, + 24.84, + 24.32, + 24.11, + 27.28, + 27.24, + 24.77, + 26.95 + ], + "median_ms": 24.78, + "min_ms": 24.11, + "max_ms": 27.28 + }, + "cached_bundle": { + "samples_ms": [ + 28.42, + 27.92, + 25.36, + 26.93, + 26.5, + 26.95, + 27.17, + 25.02, + 26.91 + ], + "median_ms": 26.93, + "min_ms": 25.02, + "max_ms": 28.42 + } + }, + "state_preview": { + "empty_bundle_cache": { + "samples_ms": [ + 84.49, + 80.57, + 82.96, + 76.85, + 85.9, + 85.25, + 81.65, + 80.78, + 86.98 + ], + "median_ms": 82.96, + "min_ms": 76.85, + "max_ms": 86.98 + }, + "cached_bundle": { + "samples_ms": [ + 74.79, + 82.8, + 77.13, + 83.71, + 80.56, + 76.23, + 80.94, + 78.55, + 79.79 + ], + "median_ms": 79.79, + "min_ms": 74.79, + "max_ms": 83.71 + } + }, + "home": { + "empty_bundle_cache": { + "samples_ms": [ + 81.27, + 75.52, + 77.1, + 80.26, + 73.15, + 73.6, + 73.59, + 73.1, + 73.25 + ], + "median_ms": 73.6, + "min_ms": 73.1, + "max_ms": 81.27 + }, + "cached_bundle": { + "samples_ms": [ + 75.72, + 78.56, + 72.7, + 72.41, + 78.25, + 75.63, + 73.88, + 79.04, + 72.48 + ], + "median_ms": 75.63, + "min_ms": 72.41, + "max_ms": 79.04 + } + } + }, + "home_measurement": "Unix PTY at 100x30, first complete Home input guide", + "limits": "Empty bundle cache is not cold OS page cache. Alternating cold/warm runs; no hardware or bridge delivery. Times include process startup, not just managed Main. gzip bytes are executable-only, not the complete release archive." + }, + "functional_pass": true, + "eligible_for_review": false + } + } +} diff --git a/docs/performance/2026-10-26-partial-trim.json b/docs/performance/2026-10-26-partial-trim.json new file mode 100644 index 0000000..3320703 --- /dev/null +++ b/docs/performance/2026-10-26-partial-trim.json @@ -0,0 +1,121 @@ +{ + "schema_version": 1, + "label": "partial-trim-clean", + "platform": "Linux-6.18.55-x86_64-with-glibc2.41", + "architecture": "x86_64", + "processor": "", + "logical_cpus": 3, + "python": "3.12.14", + "executable_sha256": "203e9ff41ff4e276ccf0585f37c7a92c0a79aba9e0eb70004adfffb22011443c", + "executable_bytes": 23131237, + "executable_gzip_bytes": 9589749, + "extracted_bytes": 0, + "extracted_files": [], + "samples_per_mode": 9, + "results": { + "version": { + "empty_bundle_cache": { + "samples_ms": [ + 74.31, + 75.36, + 72.05, + 72.45, + 70.91, + 77.36, + 73.92, + 75.46, + 72.64 + ], + "median_ms": 73.92, + "min_ms": 70.91, + "max_ms": 77.36 + }, + "cached_bundle": { + "samples_ms": [ + 72.58, + 84.66, + 72.04, + 73.74, + 78.66, + 72.46, + 73.37, + 71.86, + 82.46 + ], + "median_ms": 73.37, + "min_ms": 71.86, + "max_ms": 84.66 + } + }, + "state_preview": { + "empty_bundle_cache": { + "samples_ms": [ + 381.2, + 378.8, + 380.7, + 380.02, + 373.72, + 375.72, + 373.74, + 373.15, + 378.74 + ], + "median_ms": 378.74, + "min_ms": 373.15, + "max_ms": 381.2 + }, + "cached_bundle": { + "samples_ms": [ + 383.91, + 391.26, + 379.93, + 384.18, + 386.36, + 383.16, + 380.0, + 384.06, + 470.82 + ], + "median_ms": 384.06, + "min_ms": 379.93, + "max_ms": 470.82 + } + }, + "home": { + "empty_bundle_cache": { + "samples_ms": [ + 765.57, + 430.83, + 391.94, + 413.16, + 392.2, + 404.94, + 395.45, + 397.98, + 394.52 + ], + "median_ms": 397.98, + "min_ms": 391.94, + "max_ms": 765.57 + }, + "cached_bundle": { + "samples_ms": [ + 532.68, + 391.64, + 404.35, + 395.49, + 393.26, + 395.56, + 399.58, + 401.34, + 399.23 + ], + "median_ms": 399.23, + "min_ms": 391.64, + "max_ms": 532.68 + } + } + }, + "home_measurement": "Unix PTY at 100x30, first complete Home input guide", + "limits": "Empty bundle cache is not cold OS page cache. Alternating cold/warm runs; no hardware or bridge delivery. Times include process startup, not just managed Main. gzip bytes are executable-only, not the complete release archive." +} diff --git a/docs/performance/2026-10-26-startup.md b/docs/performance/2026-10-26-startup.md index effb5c7..165ec81 100644 --- a/docs/performance/2026-10-26-startup.md +++ b/docs/performance/2026-10-26-startup.md @@ -97,3 +97,9 @@ Raw local reports: - [Baseline](2026-10-26-linux-baseline.json) - [Optimized](2026-10-26-linux-optimized.json) - [Compressed experiment](2026-10-26-linux-compressed.json) + +## Follow-up publishing investigation + +[Trimming, ReadyToRun and Native AOT results](2026-10-26-deployment.md) compare +smaller candidates, full-command failures, lifecycle smoke and the required +JSON/command-metadata fixes before a release-mode change. diff --git a/docs/performance/2026-10-26-trim-aot-failures.json b/docs/performance/2026-10-26-trim-aot-failures.json new file mode 100644 index 0000000..e0d618b --- /dev/null +++ b/docs/performance/2026-10-26-trim-aot-failures.json @@ -0,0 +1,81 @@ +{ + "raw-trim": { + "executable_bytes": 18049412, + "analysis_diagnostics": { + "IL2026": 40, + "IL2104": 1 + }, + "probes": [ + { + "arguments": [ + "--version" + ], + "exit_code": 0, + "stderr_first_line": "", + "stdout": "0.1.0-beta.2\n" + }, + { + "arguments": [ + "--version", + "--no-interactive" + ], + "exit_code": -6, + "stderr_first_line": "Unhandled exception. Spectre.Console.Cli.CommandRuntimeException: Could not get settings type for command of type 'SidePulse.Cli.PreferencesCommand'.", + "stdout": "" + }, + { + "arguments": [ + "state", + "working", + "--dry-run", + "--json" + ], + "exit_code": -6, + "stderr_first_line": "Unhandled exception. Spectre.Console.Cli.CommandRuntimeException: Could not get settings type for command of type 'SidePulse.Cli.PreferencesCommand'.", + "stdout": "" + } + ], + "functional": false + }, + "aot": { + "executable_bytes": 13734648, + "analysis_diagnostics": { + "IL2026": 62, + "IL3050": 66, + "IL2104": 1, + "IL3000": 1, + "IL3053": 1 + }, + "probes": [ + { + "arguments": [ + "--version" + ], + "exit_code": 0, + "stderr_first_line": "", + "stdout": "0.1.0-beta.2\n" + }, + { + "arguments": [ + "--version", + "--no-interactive" + ], + "exit_code": -6, + "stderr_first_line": "Unhandled exception. Spectre.Console.Cli.CommandRuntimeException: Could not get settings type for command of type 'SidePulse.Cli.PreferencesCommand'.", + "stdout": "" + }, + { + "arguments": [ + "state", + "working", + "--dry-run", + "--json" + ], + "exit_code": -6, + "stderr_first_line": "Unhandled exception. Spectre.Console.Cli.CommandRuntimeException: Could not get settings type for command of type 'SidePulse.Cli.PreferencesCommand'.", + "stdout": "" + } + ], + "functional": false + } +} diff --git a/scripts/deployment_experiments.py b/scripts/deployment_experiments.py new file mode 100644 index 0000000..0b0c2f4 --- /dev/null +++ b/scripts/deployment_experiments.py @@ -0,0 +1,136 @@ +"""Isolated publishing experiment. Diagnostic failures are reported, never release assets.""" +import argparse +import collections +import gzip +import json +import os +from pathlib import Path +import platform +import re +import shutil +import subprocess +import sys +import tempfile +import xml.etree.ElementTree as ET + +from benchmark_startup import benchmark + +MODES = { + 'full': [], + 'raw-trim': ['PublishTrimmed=true'], + 'partial-strict': ['PublishTrimmed=true', 'TrimMode=partial', 'JsonSerializerIsReflectionEnabledByDefault=true'], + 'partial': ['PublishTrimmed=true', 'TrimMode=partial', 'JsonSerializerIsReflectionEnabledByDefault=true'], + 'partial-r2r': ['PublishTrimmed=true', 'TrimMode=partial', 'JsonSerializerIsReflectionEnabledByDefault=true', 'PublishReadyToRun=true'], + 'aot': ['PublishAot=true', 'PublishSingleFile=false', 'DebugType=None', 'StripSymbols=true'], +} + + +def run_logged(arguments, path, cwd, environment=None, timeout=600): + with path.open('w', encoding='utf-8') as log: + try: + result = subprocess.run(arguments, cwd=cwd, env=environment, stdout=log, + stderr=subprocess.STDOUT, timeout=timeout) + return result.returncode + except subprocess.TimeoutExpired: + log.write('\nExperiment timed out.\n') + return 124 + + +def probe(executable, arguments, environment, expected=None, json_field=None): + try: + result = subprocess.run([str(executable), *arguments], env=environment, + capture_output=True, text=True, timeout=20) + except subprocess.TimeoutExpired: + return {'arguments': arguments, 'exit_code': 124, 'passed': False, 'stderr_excerpt': 'Probe timed out.'} + passed = result.returncode == 0 + if passed and expected is not None: + passed = result.stdout.strip() == expected + if passed and json_field is not None: + try: + passed = json_field in json.loads(result.stdout) + except (ValueError, TypeError): + passed = False + return {'arguments': arguments, 'exit_code': result.returncode, 'passed': passed, + 'stdout_bytes': len(result.stdout.encode()), 'stderr_excerpt': result.stderr[:1200]} + + +def main(): + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument('--output', type=Path, required=True) + parser.add_argument('--modes', nargs='+', choices=list(MODES), default=list(MODES)) + parser.add_argument('--samples', type=int, default=7) + args = parser.parse_args() + if not 1 <= args.samples <= 100: + parser.error('--samples must be 1..100') + if os.name != 'nt': + import resource + resource.setrlimit(resource.RLIMIT_CORE, (0, 0)) + source = Path(__file__).resolve().parents[1] + output = args.output.resolve() + output.mkdir(parents=True, exist_ok=True) + system = {'Windows': 'win', 'Darwin': 'osx', 'Linux': 'linux'}[platform.system()] + architecture = {'amd64': 'x64', 'x86_64': 'x64', 'arm64': 'arm64', 'aarch64': 'arm64'}[platform.machine().lower()] + rid = system + '-' + architecture + version = ET.parse(source / 'src/SidePulse.Cli/SidePulse.Cli.csproj').findtext('./PropertyGroup/Version') + report = {'schema_version': 1, 'runtime': rid, 'platform': platform.platform(), 'version': version, + 'decision': 'Experimental evidence only. Ordinary release settings are not changed by this script.', 'variants': {}} + for mode in args.modes: + destination = output / 'builds' / mode + if destination.exists(): + raise SystemExit('Use a fresh output directory; refusing stale experiment binaries: ' + str(destination)) + destination.mkdir(parents=True) + properties = list(MODES[mode]) + diagnostic = mode not in ('full', 'partial-strict') + if diagnostic: + # Intentionally broken prototypes must reach execution so warnings can + # be correlated with failures. Never use these overrides for release. + properties += ['TreatWarningsAsErrors=false', 'ILLinkTreatWarningsAsErrors=false', 'IlcTreatWarningsAsErrors=false'] + if mode == 'aot' and system == 'linux' and not shutil.which('clang') and shutil.which('gcc'): + properties += ['CppCompilerAndLinker=gcc'] + publish_log = output / (mode + '-publish.log') + command = ['dotnet', 'publish', 'src/SidePulse.Cli', '-t:Rebuild', '-c', 'Release', '-r', rid, + '--self-contained', 'true', '-p:NuGetLockFilePath=obj/packages.experiment.' + mode + '.lock.json', + '-o', str(destination), *['-p:' + p for p in properties]] + code = run_logged(command, publish_log, source) + text = publish_log.read_text(encoding='utf-8', errors='replace') + warnings = dict(collections.Counter(re.findall(r'(?:warning|error) (IL\d+)', text))) + entry = {'properties': properties, 'diagnostic_warnings_allowed': diagnostic, + 'publish_exit_code': code, 'analysis_diagnostics': warnings, 'probes': [], 'smokes': {}} + report['variants'][mode] = entry + executable = destination / ('spn.exe' if system == 'win' else 'spn') + if code == 0 and executable.exists(): + data = executable.read_bytes() + entry.update(executable_bytes=len(data), executable_gzip_bytes=len(gzip.compress(data, compresslevel=6, mtime=0))) + with tempfile.TemporaryDirectory(prefix='spn deployment probe ') as temporary: + environment = dict(os.environ, SIDEPULSE_NET_HOME=temporary) + for arguments, expected, field in [ + (['--version'], version, None), + (['--version', '--no-interactive'], version, None), + (['state', 'working', '--dry-run', '--json'], None, 'program'), + (['settings', 'show', '--json'], None, 'preferences'), + (['docs', '--offline'], None, None), + (['about', 'licenses', '--full'], None, None), + ]: + entry['probes'].append(probe(executable, arguments, environment, expected, field)) + if all(p['passed'] for p in entry['probes']): + manifest = run_logged([sys.executable, str(source / 'scripts/package_manifest.py'), str(destination), rid, version], output / (mode + '-manifest.log'), source) + entry['manifest_exit_code'] = manifest + if manifest == 0: + for script in ['cli_smoke', 'terminal_smoke', 'animation_smoke', 'install_smoke', 'update_smoke', 'agent_smoke', 'opencode_smoke']: + status = run_logged([sys.executable, str(source / 'scripts' / (script + '.py')), str(executable)], output / (mode + '-' + script + '.log'), source, timeout=180) + entry['smokes'][script] = status + if status != 0: + break + if all(v == 0 for v in entry['smokes'].values()): + entry['benchmark'] = benchmark(executable, args.samples, mode) + entry['functional_pass'] = bool(entry['smokes']) and all(v == 0 for v in entry['smokes'].values()) + entry['eligible_for_review'] = code == 0 and entry.get('functional_pass', False) and not warnings and not diagnostic + (output / 'report.json').write_text(json.dumps(report, indent=2) + '\n', encoding='utf-8') + print(mode, json.dumps({k: entry.get(k) for k in ['publish_exit_code', 'executable_bytes', 'analysis_diagnostics', 'functional_pass', 'eligible_for_review']}), flush=True) + baseline = report['variants'].get('full') + if baseline is not None and not baseline['eligible_for_review']: + raise SystemExit('Unmodified baseline failed; experiment environment/results need investigation.') + + +if __name__ == '__main__': + main()