Compare commits

..
Author SHA1 Message Date
skylartaylor 9d2c493e49 nightly: a refused launch exits 2 on macOS instead of hanging
A refused launch profile printed its reason and then, on a macOS desktop
session, opened rfd's message box before eframe's event loop existed.
That alert needs the AppKit run loop this start never reaches, so the
process sat in an invisible modal and had to be killed instead of
exiting (GridCraft Mac smoke of run 45749038918: refused without `--`,
no window, killed with SIGTERM).

The refusal now adds the box only where one renders without the app's
event loop (Windows' MessageBox, GTK on X11/Wayland) and otherwise
leaves the reason on standard error, so the caller's exit(2) is
reached. The rule is a pure function with a unit test.
2026-11-26 05:25:13 +01:00
skylar taylor-barrick b0562cbce0 Switch on supervised nightlies on the nightly-signer branch (#1800)
Supervised nightly switch-on, merged under Skylar's explicit Nightly 758 override after green CI, CodeRabbit on this head with no open threads, Sonar passing, and an independent adversarial review with no blockers.
2026-11-25 20:45:15 -06:00
skylar taylor-barrick 97e38ba3c3 Use the shared nightly launcher template (#1787)
Renders the plain nightly tar's launcher from craft-common-actions' shared template.

Independent check: dylanmtaylor compared all 14 app launcher PRs byte for byte with the template rendered from the registry (https://github.com/storytold/craft-common-actions/pull/367#issuecomment-7172085284); this head was re-checked against craft-common-actions main 88148a5.
2026-11-25 16:17:35 -06:00
Dylan M. Taylor 768c0f972d packaging(linux): support co-installable nightly packages (#1740)
Linux nightly packaging by @dylanmtaylor, with the per-app Nightly flavor commits stacked on his branch.

Co-authored-by: Dylan M. Taylor <dylan@dylanmtaylor.com>
2026-11-24 18:55:08 -06:00
9 changed files with 501 additions and 101 deletions
+16
View File
@@ -0,0 +1,16 @@
-----BEGIN PGP PUBLIC KEY BLOCK-----
mDMEaulK1xYJKwYBBAHaRw8BAQdAqHJeDCjY6Hx5FTn/hW+aqu6V394ubLk0Zj3C
bftDwFm0IkFydENyYWZ0IExpbnV4IFJlbGVhc2UgU2lnbmluZyBLZXmIkwQTFgoA
OxYhBCt2dBtBSq1s0z5jEhOgBcC518PtBQJq6UrXAhsBBQsJCAcCAiICBhUKCQgL
AgQWAgMBAh4HAheAAAoJEBOgBcC518PtGeUA/RjvULBTLlccc+2wtJkfjSnCV+cf
PUMEGmW7XkZWkk51AP9w2A/WLv+79nREWEpZzI8LGK5EjrNazP+sY0l7j5rFCLgz
BGrpStcWCSsGAQQB2kcPAQEHQPl7XkQ1gWsvSPf/T9b4m/UHcjJjBpSOtpYlWR56
er5RiO8EGBYKACAWIQQrdnQbQUqtbNM+YxIToAXAudfD7QUCaulK1wIbAgCBCRAT
oAXAudfD7XYgBBkWCgAdFiEEVo3B9o+Prsx5fzx7AG2va7DvM04FAmrpStcACgkQ
AG2va7DvM07taQEA4d2VFkKRIP0g9TrE86KpnuXPap+LKqe0tfIxpdf9YxIA/0Wo
9H/iG8nH++nxC087p3HE0S+0UovxqkhXJLSr8B4JDOoA/iLRpqTdYmk6fVXMyPJo
SkOVuwZIGS6VgBdSQP0e2P2YAP41L5OoSvwdQIG3/uNrM+ieqpYeM597/hCLFs5A
ga/qCA==
=3wGQ
-----END PGP PUBLIC KEY BLOCK-----
+13 -11
View File
@@ -2,13 +2,13 @@
"schema": "craft-nightly-release-policy/v3",
"repository": "storytold/soundcraft",
"repository_id": 1408486424,
"producer_workflow_id": null,
"producer_workflow_id": 429730684,
"producer_workflow_path": ".github/workflows/nightly.yml",
"producer_tooling_revision": "605d58766e8f536564da8fc81d3676ac86816dea",
"producer_workflow_ref": "storytold/craft-common-actions/.github/workflows/nightly-unsigned.yml@605d58766e8f536564da8fc81d3676ac86816dea",
"producer_tooling_revision": "be00e5ccd18b68e950c8a08532f2230e7c3d0cba",
"producer_workflow_ref": "storytold/craft-common-actions/.github/workflows/nightly-unsigned.yml@be00e5ccd18b68e950c8a08532f2230e7c3d0cba",
"signer_workflow_path": ".github/workflows/nightly-sign.yml",
"signer_tooling_revision": "605d58766e8f536564da8fc81d3676ac86816dea",
"release_branch": "release",
"signer_tooling_revision": "be00e5ccd18b68e950c8a08532f2230e7c3d0cba",
"release_branch": "nightly-signer",
"manual_actors": [
"bflatastic",
"dylanmtaylor",
@@ -44,18 +44,20 @@
"issue_types": [
"VULNERABILITY"
],
"accepted_conditions": [],
"accepted_conditions": [
{
"metric": "new_security_rating",
"comparator": "GT",
"error_threshold": "1",
"maximum": "5"
}
],
"required_conditions": [
{
"metric": "new_reliability_rating",
"comparator": "GT",
"error_threshold": "1"
},
{
"metric": "new_security_rating",
"comparator": "GT",
"error_threshold": "1"
},
{
"metric": "new_maintainability_rating",
"comparator": "GT",
+10 -7
View File
@@ -1,7 +1,8 @@
name: SoundCraft release-ref nightly signer
# Enabled for supervised manual dispatch on release. Main/release contents must match.
# A reusable callee does not change context; this must be a real top-level release dispatch.
# Enabled for supervised manual dispatch on the dedicated nightly-signer branch, which only ever
# fast-forwards to reviewed main commits (never the stable release branch).
# A reusable callee does not change context; this must be a real top-level signer-branch dispatch.
on:
workflow_dispatch:
inputs:
@@ -22,21 +23,23 @@ concurrency:
jobs:
release:
# Actual context guards: official repository, manual dispatch, real release branch.
# Actual context guards: official repository, manual dispatch, real nightly-signer branch.
if: >-
github.repository == 'storytold/soundcraft' &&
github.event_name == 'workflow_dispatch' &&
github.ref == 'refs/heads/release' && github.ref_type == 'branch'
github.ref == 'refs/heads/nightly-signer' && github.ref_type == 'branch'
permissions:
contents: write
actions: read
checks: read
attestations: write
id-token: write
uses: storytold/craft-common-actions/.github/workflows/nightly-release.yml@605d58766e8f536564da8fc81d3676ac86816dea
uses: storytold/craft-common-actions/.github/workflows/nightly-release.yml@be00e5ccd18b68e950c8a08532f2230e7c3d0cba
with:
tooling-revision: 605d58766e8f536564da8fc81d3676ac86816dea
tooling-revision: be00e5ccd18b68e950c8a08532f2230e7c3d0cba
app-name: soundcraft
producer_run_id: ${{ inputs.producer_run_id }}
producer_run_attempt: ${{ inputs.producer_run_attempt }}
# No secrets: inherit or raw platform values in this caller. Only the isolated native
# callee job may bind the existing release environment and export keys in its signing step.
# callee job may bind the release environment and export its keys; that environment must
# admit nightly-signer alongside release before the first dispatch.
+6 -6
View File
@@ -1,7 +1,7 @@
name: SoundCraft unsigned nightly
# Enabled for supervised manual runs by the reviewed manual actor only; no schedule yet.
# A later explicit opt-in may add a cadence (and turn on nightly-dispatch.yml with it).
# Enabled for supervised manual runs by the reviewed manual actors only; no schedule yet.
# A later explicit opt-in may add a cadence (and a reviewed dispatcher with it).
on:
workflow_dispatch:
@@ -22,13 +22,13 @@ jobs:
actions: read
attestations: write
id-token: write
uses: storytold/craft-common-actions/.github/workflows/nightly-unsigned.yml@605d58766e8f536564da8fc81d3676ac86816dea
uses: storytold/craft-common-actions/.github/workflows/nightly-unsigned.yml@be00e5ccd18b68e950c8a08532f2230e7c3d0cba
with:
tooling-revision: 605d58766e8f536564da8fc81d3676ac86816dea
tooling-revision: be00e5ccd18b68e950c8a08532f2230e7c3d0cba
app-name: soundcraft
manual-actors: '["bflatastic","dylanmtaylor","echelon","FredApps","skylartaylor"]'
craft-fonts-ref: cc9269cd8d8258785dac603fba3122e5d2556795
# One producer run builds every listed platform for one all-or-nothing release. The pin is the
# craft-common-actions main commit that merged #339 (bounded lineage compares), on top of the
# Linux/macOS signer (#342).
# craft-common-actions main commit that merged the exact-analysis admission (#371, after #370,
# #369 and #364).
platforms: '["windows-x86_64","linux-x86_64","macos-aarch64"]'
+26 -3
View File
@@ -213,14 +213,23 @@ fn initialize_nightly_process_identity() -> Result<(), process_identity::Identit
)
}
/// Report a refused launch profile on standard error, and in a dialog on a desktop session: a
/// Nightly build started from a file manager has no console to read.
/// Whether a refusal may also open a native message box. Standard error always carries the reason;
/// this only adds a box where one renders without the app's event loop. Never on macOS: rfd's alert
/// there needs the AppKit run loop this start has not reached, so a refused nightly launch hung in
/// an invisible modal instead of exiting (GridCraft Mac smoke, 2026-11-26).
fn refusal_dialog(flavor: build_flavor::BuildFlavor, desktop_session: bool, macos: bool) -> bool {
build_flavor::needs_native_error(flavor, desktop_session) && !macos
}
/// Report a refused launch profile on standard error, and in a dialog on a Windows or X11/Wayland
/// desktop session: a Nightly build started from a file manager has no console to read. macOS keeps
/// the console line, because a modal before its event loop never appears.
fn report_launch_profile_error(error: &str) {
eprintln!("SoundCraft launch profile: {error}");
let desktop_session = cfg!(windows)
|| cfg!(target_os = "macos")
|| (cfg!(target_os = "linux") && ["DISPLAY", "WAYLAND_DISPLAY"].into_iter().any(|key| std::env::var_os(key).is_some_and(|v| !v.is_empty())));
if build_flavor::needs_native_error(build_flavor::COMPILED, desktop_session) {
if refusal_dialog(build_flavor::COMPILED, desktop_session, cfg!(target_os = "macos")) {
if let Err(error) = initialize_nightly_process_identity() {
eprintln!("SoundCraft launch profile: {error}");
return;
@@ -449,3 +458,17 @@ mod tests {
assert_eq!(titles("Song * — SoundCraft"), 1);
}
}
#[cfg(test)]
mod refusal_dialog_tests {
use super::refusal_dialog;
use crate::build_flavor::BuildFlavor;
#[test]
fn a_refusal_never_blocks_on_a_modal_before_the_event_loop_on_macos() {
assert!(refusal_dialog(BuildFlavor::NightlyV1, true, false), "a desktop refusal still shows the box where one renders");
assert!(!refusal_dialog(BuildFlavor::NightlyV1, true, true), "macOS has no run loop yet: the modal would hang");
assert!(!refusal_dialog(BuildFlavor::NightlyV1, false, false), "a headless session has no box");
assert!(!refusal_dialog(BuildFlavor::Stable, true, false), "only a nightly refusal explains itself in a box");
}
}
+50 -25
View File
@@ -1,12 +1,11 @@
# Windows, Linux and macOS release-ref nightly: supervised manual go-live
**Enabled for supervised manual runs, not yet qualified.** The producer (`nightly.yml`, main) and the
signer (`nightly-sign.yml`, release) keep only their exact context guards and run when one of the reviewed
manual actors dispatches them. There is no schedule yet. The installed policy
[`.github/nightly-signing-policy.json`](../.github/nightly-signing-policy.json) is the v3 policy for
SoundCraft. Its `producer_workflow_id` is currently `null` until `nightly.yml` is registered on `main`;
once merged to `main`, read the workflow ID and populate `producer_workflow_id` before promoting the
policy to `release`:
signer (`nightly-sign.yml`, on the dedicated `nightly-signer` branch) keep only their exact context
guards and run when one of the reviewed manual actors dispatches them. There is no schedule yet. The
installed policy [`.github/nightly-signing-policy.json`](../.github/nightly-signing-policy.json) is the
v3 policy for SoundCraft; its `producer_workflow_id` is the registration ID of `nightly.yml` on `main`
(`429730684`), read with:
```bash
gh api repos/storytold/soundcraft/actions/workflows/nightly.yml --jq .id
@@ -15,17 +14,37 @@ gh api repos/storytold/soundcraft/actions/workflows/nightly.yml --jq .id
The callers pass no platform secrets. The unsigned reusable caller's maximum OIDC/attestation
permissions are for its isolated attester; its compiler narrows to contents and Actions read
only, with no OIDC, attestation write, release environment or platform signing secrets.
Shared tooling is pinned to `605d58766e8f536564da8fc81d3676ac86816dea`, the `craft-common-actions`
main commit that merged [#339](https://github.com/storytold/craft-common-actions/pull/339) (bounded
lineage compares and an issue reread at the end of candidate admission) on top of
[#342](https://github.com/storytold/craft-common-actions/pull/342) (policy v3, the `platforms` input
and the Linux and macOS legs). Both callers name it in `uses` and `tooling-revision`. A pin is reviewed
source availability, not provider, queue, native signing or crypto qualification.
Shared tooling is pinned to `be00e5ccd18b68e950c8a08532f2230e7c3d0cba`, the craft-common-actions
main commit that merged [#371](https://github.com/storytold/craft-common-actions/pull/371) (the
candidate is admitted on the built commit's own Sonar analysis, not main's latest) after
[#370](https://github.com/storytold/craft-common-actions/pull/370) (the Windows and macOS nightly
registry rows for the 14 apps) and
[#369](https://github.com/storytold/craft-common-actions/pull/369) (shared helper checkouts kept out
of the app's clean-source check, and macOS on `macos-15`), following
[#364](https://github.com/storytold/craft-common-actions/pull/364) (the signer may run on the
policy's signer branch) and [#363](https://github.com/storytold/craft-common-actions/pull/363) (the
multi-app pipeline, which makes the signer's `app-name` input required and admits any reviewed
registry app), with #342 (`a4f6fd51`, policy v3 and the `platforms` input) and #339 (`605d5876`)
earlier. Both callers name it in `uses` and `tooling-revision`. A pin is reviewed source
availability, not provider, queue, native signing or crypto qualification.
Existing stable workflows are unchanged.
**First runs.** The first runs are manual dispatches in this order: `nightly.yml` on `main` (only a
listed manual actor passes the producer's plan step), then `nightly-sign.yml` on `release` with that
producer run ID and attempt, by a listed manual actor.
listed manual actor passes the producer's plan step), then `nightly-sign.yml` on `nightly-signer` with
that producer run ID and attempt, by a listed manual actor.
**Signer branch.** The signer runs on `refs/heads/nightly-signer`, not on the stable `release` branch,
so nightly signer files never need a stable release sync. The policy's `release_branch` names it and
the signer's guard requires it; this app has no `nightly-dispatch.yml` at all, so nothing transports
a run automatically. The branch only fast-forwards to reviewed main commits, through the settings
script's `advance` (no queued signer run, a trust-closure scan, then the full diff of `.github/` and
`packaging/`), and the existing `release` environment must admit `nightly-signer` alongside
`release` before the first dispatch (a repository settings change, not a workflow one). Its trust
closure is all of `.github/` and `packaging/`, including `packaging/env.sh`, which `import-cert.sh`
sources with the Apple keys. On that branch only the pinned `nightly-sign.yml` caller may reach an
environment: no app workflow binds one and nothing else calls `nightly-release.yml`.
`packaging/nightly-release-tests.py` checks that in-repo part on every main PR. Stable releases
still come only from `refs/heads/release`.
**Manual actors.** `bflatastic`, `dylanmtaylor`, `echelon`, `FredApps` and `skylartaylor`, in the
producer's `manual-actors` and the policy's `manual_actors`. The list mirrors the `release-managers`
@@ -46,19 +65,20 @@ the signer caller has no platform input.
## Installed policy values and their sources
Read on 2026-11-24; re-read anything that may have moved (and populate `producer_workflow_id` after `nightly.yml` lands on `main`) before the policy is promoted to `release`.
Read on 2026-11-24; re-read anything that may have moved before `nightly-signer` is advanced to it.
| Field | Value | Source |
|---|---|---|
| `repository_id` | `1408486424` | `gh api repos/storytold/soundcraft --jq .id` |
| `producer_workflow_id` | `null` (pending registration) | Read via `gh api repos/storytold/soundcraft/actions/workflows/nightly.yml --jq .id` once `nightly.yml` lands on `main` |
| `producer_tooling_revision`, `signer_tooling_revision`, `producer_workflow_ref` | `605d5876…` (`craft-common-actions` #339) | The callers' pin |
| `producer_workflow_id` | `429730684` | `gh api repos/storytold/soundcraft/actions/workflows/nightly.yml --jq .id` (path `.github/workflows/nightly.yml`, state `active`) |
| `producer_tooling_revision`, `signer_tooling_revision`, `producer_workflow_ref` | `be00e5cc…` (`craft-common-actions` exact-analysis admission, #371 after #370 and #369, following #364) | The callers' pin |
| `release_branch` | `nightly-signer` | The shared validator allows `release` or `nightly-signer`; the signer guard names the same ref |
| `manual_actors` / `automatic_signer_actors` | the five release managers / `[]` | `release-managers` team (id `19837241`); equals the producer caller's `manual-actors` |
| `max_age_seconds`, `max_artifact_bytes` | `86400`, `2147483648` | Go-live checklist |
| `platforms` | three rows | Storytold stable signing identities (`windows-x86_64`, `linux-x86_64`, `macos-aarch64`) |
| `candidate_policy.required_workflows` | CI (`ci.yml`, workflow `380135771`), `gate / gate (ubuntu-24.04)` | Workflow list API and recent `main` push runs |
| `candidate_policy.sonar` | `storytold` / `storytold_soundcraft`, app `12526` | `sonar-project.properties`; the SonarCloud check on `main` commits |
| Sonar conditions | All six quality-gate conditions required (`accepted_conditions: []`) | Quality gate of `storytold_soundcraft` `main` (all OK) |
| Sonar conditions | `new_security_rating` accepted (GT 1, maximum 5); the other five required | Quality gate of `storytold_soundcraft` `main`: the same six conditions, and a failing rating is admitted up to the reviewed A..E bound |
| Sonar `issue_types` / `debt` | `VULNERABILITY`; `[]` (0 unresolved vulnerabilities on `main`) | `api/issues/search` on `main` |
## Ownership and interface
@@ -66,21 +86,26 @@ Read on 2026-11-24; re-read anything that may have moved (and populate `producer
- `.github/workflows/nightly.yml`: default-main registration of the unsigned producer, named
`SoundCraft unsigned nightly`, enabled for manual dispatch by `manual-actors`; no signing secrets
may be passed or inherited.
- `.github/workflows/nightly-sign.yml`: top-level release registration, enabled for manual dispatch,
and identical on `main` and `release` after reviewed promotion. It rejects wrong repository/event/actual branch,
- `.github/workflows/nightly-sign.yml`: top-level signer registration, enabled for manual dispatch on
`nightly-signer`, which carries a reviewed main commit. It rejects wrong repository/event/actual branch,
including same-name tags. Its constant whole-run concurrency is distinct from stable,
cancellation is off and `queue: max` must be hosted-qualified. The caller itself passes no
credentials; only the shared callee's sign jobs bind the `release` environment.
cancellation is off. The caller itself passes no credentials and names the registry `app-name`;
only the shared callee's sign jobs bind the `release` environment.
- Shared reusable entrypoints are `nightly-unsigned.yml` and `nightly-release.yml` in
`storytold/craft-common-actions`. Both must resolve to a **real reviewed public immutable
commit**; the defining workflow SHA and tooling input must match.
**Every Linux Nightly format starts the app the flavor's way.** The `.deb`/`.rpm` wrapper, the
AppImage's `AppRun`, the Arch launcher, the Flatpak wrapper, the launcher inside the plain
`nightly.tar.gz` and the FHS tree in `package.sh`'s `.tar.gz` all exec the real GUI with the literal
AppImage's `AppRun`, the Arch launcher and the Flatpak wrapper all exec the real GUI with the literal
`--launch-profile nightly-v1 --profile-root <${XDG_CONFIG_HOME:-~/.config}/soundcraft-nightly> --`,
and pass a Launcher protocol or a `--version`/`-V` query through untouched, so `soundcraft --version`,
the Launcher's version query and the smoke checks still answer without a profile. The profile holds
the Launcher's version query and the smoke checks still answer without a profile. The plain
`nightly.tar.gz` (and `package.sh`'s tree tarball, which installs the same file) is the exception: its
`soundcraft` is craft-common-actions' shared launcher template
(#363, rendered for this app), which execs `soundcraft-bin` beside it with
`--profile-root <${XDG_DATA_HOME:-~/.local/share}/ai.storyteller.soundcraft.nightly> --`, forwards a
first-argument `--launch-profile` pair unchanged, and asks a bare `--version`/`-V` in the Launcher's
own form. The profile holds
`ui.json`, `Autosave/`, `Presets/` and `logs/`; it is outside stable's settings folder and outside
the unpacked or installed copy, which the flavor's fence would otherwise refuse. The Nightly tarballs
therefore ship `soundcraft` as the launcher next to `soundcraft-bin`, and the Nightly Flatpak — the
+48 -30
View File
@@ -1,8 +1,8 @@
#!/usr/bin/env bash
# The launcher inside the plain Nightly tarball (packaging/linux/nightly-launch.sh): a launch adds
# the Launcher's private profile, a version query or an already-formed protocol passes through, and
# the profile has the shape the app's fence accepts (absolute, no parent traversal, outside this
# unpacked copy).
# The launcher inside the plain Nightly tarball (packaging/linux/nightly-launch.sh): craft-common-actions'
# template rendered for SoundCraft. Every argument follows the profile tokens, the profile root is the
# package identity under the XDG data home (or HOME), and a version query is asked in the Launcher's
# own form so the GUI answers before any profile is read.
set -euo pipefail
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
@@ -19,43 +19,61 @@ chmod 755 "$work/tree/soundcraft-bin"
cp "$HERE/nightly-launch.sh" "$work/tree/soundcraft"
chmod 755 "$work/tree/soundcraft"
profile="${XDG_CONFIG_HOME:-${HOME:-}/.config}/soundcraft-nightly"
case "$profile" in
/*) ;;
*) echo "FAIL: the launcher profile is not absolute: $profile" >&2; exit 1 ;;
esac
case "/$profile/" in
*/../*) echo "FAIL: the launcher profile contains parent traversal" >&2; exit 1 ;;
esac
case "$profile/" in
"$work/tree/"*) echo "FAIL: the launcher profile is inside the unpacked copy" >&2; exit 1 ;;
esac
# The bytes are the shared template rendered for this app, not a local script.
sha256sum "$HERE/nightly-launch.sh" | cut -d' ' -f1 | grep -qx \
bdaa899cedd4ef71c77f21af8eb61cca4d62d585fe4d16662c4ef36ff8ed82a2 || {
echo "FAIL: nightly-launch.sh is not the shared template rendered for soundcraft" >&2
exit 1
}
head -n 1 "$work/tree/soundcraft" | grep -qx '#!/bin/sh' || { echo "FAIL: soundcraft is not a script" >&2; exit 1; }
expect_launch() {
expected="$(printf '<%s>\n' --launch-profile nightly-v1 --profile-root "$profile" -- "$@")"
# A hand-unpacked tar has to start the private profile even when nobody passes a flag.
export HOME="$work/home with space"
unset XDG_DATA_HOME
identity="ai.storyteller.soundcraft.nightly"
expect() {
local root="$1"
shift
expected="$(printf '<%s>\n' --launch-profile nightly-v1 --profile-root "$root" -- "$@")"
actual=$("$work/tree/soundcraft" "$@")
[[ "$actual" == "$expected" ]] || {
printf 'profile root %s\nexpected:\n%s\nactual:\n%s\n' "$root" "$expected" "$actual" >&2
exit 1
}
}
expect_query() {
local root="$1"
expected="$(printf '<%s>\n' --launch-profile nightly-v1 --profile-root "$root" --version)"
actual=$("$work/tree/soundcraft" --version)
[[ "$actual" == "$expected" ]] || {
printf 'expected:\n%s\nactual:\n%s\n' "$expected" "$actual" >&2
exit 1
}
}
expect_forwarded() {
expected="$(printf '<%s>\n' "$@")"
actual=$("$work/tree/soundcraft" "$@")
actual=$("$work/tree/soundcraft" -V)
[[ "$actual" == "$expected" ]] || {
printf 'expected:\n%s\nactual:\n%s\n' "$expected" "$actual" >&2
exit 1
}
}
expect_launch
expect_launch 'session with spaces.sc' '--other-name.sc'
expect_forwarded --version
expect_forwarded -V
expect_forwarded --launch-profile nightly-v1 --profile-root /launcher/profile --version
expect "$HOME/.local/share/$identity"
expect "$HOME/.local/share/$identity" 'session with spaces.sc' '--other-name.sc'
export XDG_DATA_HOME="$work/xdg with space"
expect "$XDG_DATA_HOME/$identity" 'session.sc'
expect_query "$XDG_DATA_HOME/$identity"
unset XDG_DATA_HOME
expect_query "$HOME/.local/share/$identity"
# The launcher must be a script, not the GUI under its own name: an unpacked tar has to start the
# private profile even when nobody passes a flag.
head -n 1 "$work/tree/soundcraft" | grep -qx '#!/bin/sh' || { echo "FAIL: soundcraft is not the launcher" >&2; exit 1; }
# The ArtCraft Launcher names its own profile and per-install root: the argv goes through unchanged.
actual=$("$work/tree/soundcraft" --launch-profile nightly-v1 --profile-root "$work/launcher profile with space" -- file.doc)
[[ "$actual" == "$(printf '<%s>\n' --launch-profile nightly-v1 --profile-root "$work/launcher profile with space" -- file.doc)" ]] || {
printf 'expected the Launcher argv unchanged\nactual:\n%s\n' "$actual" >&2
exit 1
}
echo "PASS: tarball Nightly launcher starts the GUI with the Launcher profile and forwards files"
# The launcher itself writes nothing: the profile folder is the GUI's to create.
[[ ! -e "$HOME/.local/share/$identity" ]] || { echo "FAIL: the launcher created the profile" >&2; exit 1; }
echo "PASS: the tarball launcher is the shared template and starts the GUI through the channel's profile"
+12 -17
View File
@@ -1,21 +1,16 @@
#!/bin/sh
# The entry point inside the plain Nightly tarball (packaging/linux/nightly.sh installs it as
# `soundcraft`, beside the GUI as `soundcraft-bin`; package.sh's Nightly tar ships the same pair
# under bin).
#
# A Nightly build only starts with its private profile, and every package format passes the
# Launcher's literal protocol: `--launch-profile nightly-v1 --profile-root <dir> -- <files>`. The
# profile holds ui.json, Autosave/, Presets/ and logs/ outside stable's settings folder, and outside
# this unpacked copy, which the app's own fence would refuse.
# Nightly launcher generated by craft-common-actions scripts/nightly-launcher.sh.in. Do not edit:
# the shared nightly producer accepts this file only byte for byte as rendered for the app.
set -eu
here="$(dirname "$(readlink -f "$0")")"
bin="$here/soundcraft-bin"
profile="${XDG_CONFIG_HOME:-${HOME:-}/.config}/soundcraft-nightly"
# The Launcher's protocol, and a bare version query, pass through untouched: the first already
# names its profile, and the second must answer without one.
dir=$(CDPATH='' cd -- "$(dirname -- "$0")" && pwd -P)
readonly dir
target="$dir/soundcraft-bin"
readonly target
profile_root="${XDG_DATA_HOME:-$HOME/.local/share}/ai.storyteller.soundcraft.nightly"
readonly profile_root
case "${1-}" in
--launch-profile | --profile-root | --version | -V) exec "$bin" "$@" ;;
# The ArtCraft Launcher passes its own profile and per-install root; the app validates the pair.
--launch-profile) exec "$target" "$@" ;;
--version | -V) exec "$target" --launch-profile nightly-v1 --profile-root "$profile_root" --version ;;
esac
exec "$bin" --launch-profile nightly-v1 --profile-root "$profile" -- "$@"
exec "$target" --launch-profile nightly-v1 --profile-root "$profile_root" -- "$@"
+320 -2
View File
@@ -228,7 +228,7 @@ class NightlyEnabledCallers(unittest.TestCase):
"github.ref_type == 'branch' && (github.event_name == 'schedule' || "
"github.event_name == 'workflow_dispatch')",
"nightly-sign.yml": "github.repository == 'storytold/soundcraft' && github.event_name == 'workflow_dispatch' && "
"github.ref == 'refs/heads/release' && github.ref_type == 'branch'",
"github.ref == 'refs/heads/nightly-signer' && github.ref_type == 'branch'",
}
def test_enabled_jobs_keep_exact_context_guards(self):
@@ -300,7 +300,7 @@ class NightlyInstalledPolicy(unittest.TestCase):
self.assertEqual(set(self.policy), expected)
self.assertEqual(self.policy["schema"], "craft-nightly-release-policy/v3")
self.assertEqual(self.policy["repository"], "storytold/soundcraft")
self.assertEqual(self.policy["release_branch"], "release")
self.assertEqual(self.policy["release_branch"], SIGNER_BRANCH, "the signer runs on its dedicated branch")
self.assertIs(type(self.policy["repository_id"]), int)
self.assertGreater(self.policy["repository_id"], 0)
# producer_workflow_id is None until nightly.yml is registered on main, then a positive int.
@@ -392,6 +392,324 @@ class NightlyInstalledPolicy(unittest.TestCase):
self.assertIn(item["type"], sonar["issue_types"])
self.assertRegex(item["hash"], r"^[0-9a-f]{32}$")
def test_sonar_policy_keeps_the_shared_candidate_contract(self):
"""The Sonar shape craft-common-actions' candidate contract() admits, refused here first.
An empty issue scope, an accepted condition outside the reviewed issue types, a metric in both
lists, a missing live gate condition or a widened security bound is refused at admission, so
this suite must catch it before a nightly run can. `debt` stays empty, so any unresolved
vulnerability on main is still refused; accepting the new-code rating only records the
reviewed A threshold instead of demanding a clean rating the live gate does not.
"""
sonar = self.policy["candidate_policy"]["sonar"]
accepted = {"bugs": "BUG", "vulnerabilities": "VULNERABILITY", "code_smells": "CODE_SMELL",
"security_rating": "VULNERABILITY", "new_security_rating": "VULNERABILITY"}
gate = {"new_reliability_rating", "new_security_rating", "new_maintainability_rating",
"new_coverage", "new_duplicated_lines_density", "new_security_hotspots_reviewed"}
self.assertTrue(sonar["issue_types"], "an empty issue scope is refused as unreviewed")
self.assertEqual(len(sonar["issue_types"]), len(set(sonar["issue_types"])))
metrics = {}
for field in ("accepted_conditions", "required_conditions"):
for condition in sonar[field]:
with self.subTest(field=field, metric=condition.get("metric")):
expected = {"metric", "comparator", "error_threshold"}
if field == "accepted_conditions":
expected.add("maximum")
self.assertEqual(set(condition), expected)
self.assertNotIn(condition["metric"], metrics, "one condition per gate metric")
metrics[condition["metric"]] = condition
self.assertIn(condition["comparator"], ("GT", "LT"))
self.assertRegex(condition["error_threshold"], r"^(?:0|[1-9][0-9]*)(?:\.[0-9]+)?$")
if field != "accepted_conditions":
continue
self.assertIn(condition["metric"], accepted, "an accepted metric outside the reviewed map")
self.assertIn(accepted[condition["metric"]], sonar["issue_types"],
"an accepted failure must lie inside the reviewed issue scope")
self.assertEqual(condition["comparator"], "GT")
self.assertRegex(condition["maximum"], r"^(?:0|[1-9][0-9]*)(?:\.[0-9]+)?$")
maximum = float(condition["maximum"])
if condition["metric"] in ("security_rating", "new_security_rating"):
self.assertEqual(int(maximum), maximum, "the A..E bound is a whole rating")
self.assertTrue(1 <= maximum <= 5, "the security bound stays A..E")
self.assertEqual(condition["error_threshold"], "1", "the reviewed A threshold stays")
else:
self.assertLessEqual(maximum, len(sonar["debt"]), "accepted failures exceed the reviewed debt")
self.assertEqual({accepted[c["metric"]] for c in sonar["accepted_conditions"]}, set(sonar["issue_types"]),
"accepted conditions and reviewed issue types must cover the same scope")
self.assertEqual(set(metrics), gate, "every live gate condition stays gated exactly once")
SIGNER_BRANCH = "nightly-signer"
SHARED = "storytold/craft-common-actions/.github/workflows/"
# App workflows reviewed to call the shared stable release.yml. That callee must carry the
# stable-only environment guard (dry runs and non-release refs bind no environment); the
# nightly-signer settings scan checks the resolved callee before creating or advancing the branch.
REVIEWED_STABLE_RELEASE_CALLERS = {"release.yml"}
def app_workflows():
return {path.name: path.read_text() for path in sorted((ROOT / ".github/workflows").glob("*.y*ml"))}
WORKFLOW_KEY = re.compile(r'''("(?:[^"\\]|\\.)*"|'(?:[^']|'')*'|[^\s'"#{}\[\],:&*!|>%@`?-][^:#,{}]*?|-[^\s:#][^:#,{}]*?)\s*:(?:\s+(.*))?$''')
def _workflow_key(text):
if text.startswith('"'):
return None if "\\" in text else text[1:-1]
if text.startswith("'"):
return text[1:-1].replace("''", "'")
return text
def _workflow_value(text):
"""A one-line scalar value without its comment and quotes; None when escaped or unterminated."""
text = text.strip()
if text.startswith('"'):
quoted = re.match(r'"((?:[^"\\]|\\.)*)"\s*(?:#.*)?$', text)
return None if quoted is None or "\\" in quoted.group(1) else quoted.group(1)
if text.startswith("'"):
quoted = re.match(r"'((?:[^']|'')*)'\s*(?:#.*)?$", text)
return None if quoted is None else quoted.group(1).replace("''", "'")
return re.split(r"\s+#", text, maxsplit=1)[0].strip()
def _strip_comment(text):
"""(text without its comment, unterminated) using a quote-aware scan.
As in YAML, a quote opens a quoted scalar only where a scalar starts (line start or after
`:`, `-`, `,`, `{` or `[`), and a `#` starts a comment only outside quotes, at the start or
after whitespace.
"""
quote, index = None, 0
while index < len(text):
char = text[index]
if quote == '"':
if char == "\\":
index += 2
continue
if char == '"':
quote = None
elif quote == "'":
if char == "'":
if text[index + 1:index + 2] == "'":
index += 2
continue
quote = None
elif char in "\"'" and text[:index].rstrip()[-1:] in ("", ":", "-", ",", "{", "["):
quote = char
elif char == "#" and (index == 0 or text[index - 1] in " \t"):
return text[:index].rstrip(), False
index += 1
return text.rstrip(), quote is not None
FLOW_QUOTED = re.compile(r"\"(?:[^\"\\]|\\.)*\"|'(?:[^']|'')*'")
FLOW_FORBIDDEN_KEYS = {"environment", "uses"}
def workflow_entries(source):
"""Every mapping entry in a workflow, plus the YAML forms this reader refuses.
A narrow reader, not a YAML parser (none ships with the runner's Python). Each entry is
(line, key, value, multiline): plain, single- and double-quoted keys and one-line values in
block and simple one-line flow mappings. Block scalar bodies are skipped, and an entry whose
value is a block scalar or continues on the next lines is marked multiline. It refuses whatever
could hide a key from it: escaped double-quoted keys, explicit `?` keys, merge keys, anchors,
aliases, tags, tab indentation and nested or multi-line flow.
"""
lines = source.splitlines()
entries, refused, block = [], [], None
def continues(index, indent):
for follow in lines[index + 1:]:
stripped = follow.strip()
if not stripped or stripped.startswith("#"):
continue
deeper = len(follow) - len(follow.lstrip(" ")) > indent
return deeper and not stripped.startswith("- ") and WORKFLOW_KEY.match(stripped) is None
return False
for index, raw in enumerate(lines):
number = index + 1
stripped = raw.strip()
indent = len(raw) - len(raw.lstrip(" "))
if block is not None:
if not stripped or indent > block:
continue
block = None
if not stripped or stripped.startswith("#"):
continue
if "\t" in raw[:indent + 1]:
refused.append(f"line {number}: tab indentation"); continue
body, unterminated = _strip_comment(stripped)
if unterminated:
refused.append(f"line {number}: unterminated or multi-line quoted scalar"); continue
if not body:
continue
while body.startswith("- "):
body = body[2:].lstrip()
if body == "?" or body.startswith("? "):
refused.append(f"line {number}: explicit key"); continue
match = WORKFLOW_KEY.match(body)
value = body
if match is not None:
key, value = _workflow_key(match.group(1)), match.group(2) or ""
if key is None:
refused.append(f"line {number}: escaped double-quoted key"); continue
if key == "<<":
refused.append(f"line {number}: merge key"); continue
plain = re.sub(r"\$\{\{.*?\}\}", "", value).strip()
bare = re.sub(r"\"(?:[^\"\\]|\\.)*\"|'(?:[^']|'')*'", "''", plain)
if re.match(r"[&*!]", plain):
refused.append(f"line {number}: anchor, alias or tag")
is_block = re.fullmatch(r"[|>][0-9+-]*", plain) is not None
if match is not None:
entries.append((number, key, _workflow_value(value),
is_block or ((value == "" or not is_block) and continues(index, indent))))
if "{" in bare and bare != "{}":
masked = re.fullmatch(r"\{([^{}\[\]]*)\}", FLOW_QUOTED.sub("''", value.strip()))
flow = re.fullmatch(r"\{([^{}\[\]]*)\}", value.strip())
if any(set(scalar[1:-1]) & set("#{}[],") for scalar in FLOW_QUOTED.findall(value)):
refused.append(f"line {number}: flow mapping quoted scalar with # or flow punctuation")
elif masked is None or flow is None:
refused.append(f"line {number}: nested or multi-line flow mapping")
else:
# The masked text only proves the shape: a quoted key ("uses", 'environment') keeps
# its identity, so the entries are read from the original mapping text, never ''.
for item in flow.group(1).split(","):
entry = WORKFLOW_KEY.match(item.strip())
key = _workflow_key(entry.group(1)) if entry else None
if key is None:
refused.append(f"line {number}: unreadable flow mapping entry")
elif key in FLOW_FORBIDDEN_KEYS:
refused.append(f"line {number}: {key} in a flow mapping (must be block style)")
else:
entries.append((number, key, _workflow_value(entry.group(2) or ""), False))
if match is not None and is_block:
block = indent
return entries, refused
def workflow_keys(source):
"""(line, key) for every mapping entry, plus the refused YAML forms."""
entries, refused = workflow_entries(source)
return [(number, key) for number, key, _, _ in entries], refused
SHARED_CALLEE = re.compile(r"storytold/craft-common-actions/\.github/workflows/([\w.-]+\.ya?ml)@(\S+)", re.IGNORECASE)
INSPECTED_KEYS = {"environment", "uses"}
def trust_closure_problems(workflows):
"""The nightly-signer trust-closure scan over app workflow sources; empty when the tree is safe.
Every key it inspects comes from workflow_entries(), never a regex over the raw text.
"""
problems, stable_callers, signer_calls = [], set(), 0
for name, source in workflows.items():
entries, refused = workflow_entries(source)
problems.extend(name + " uses YAML the scan cannot read (" + reason + ")" for reason in refused)
for number, key, value, multiline in entries:
if key not in INSPECTED_KEYS:
continue
if key == "environment":
problems.append(f"{name} binds an environment directly (line {number})")
continue
if value is None or multiline:
problems.append(f"{name} has a uses value the scan cannot read (line {number})")
continue
callee = SHARED_CALLEE.fullmatch(value)
if callee is None:
if re.search(r"craft-common-actions", value, re.IGNORECASE) and re.search(r"workflows/(nightly-)?release\.ya?ml", value, re.IGNORECASE):
problems.append(f"{name} has an unrecognised shared release caller (line {number})")
continue
workflow, ref = callee.group(1), callee.group(2)
if workflow.lower() in ("nightly-release.yml", "nightly-release.yaml"):
if name == "nightly-sign.yml":
signer_calls += 1
if name != "nightly-sign.yml" or not re.fullmatch(r"[0-9a-f]{40}", ref):
problems.append(name + " calls nightly-release.yml@" + ref)
if workflow.lower() in ("release.yml", "release.yaml"):
stable_callers.add(name)
if ref != "main" and not re.fullmatch(r"[0-9a-f]{40}", ref):
problems.append(name + " calls release.yml@" + ref + "; use @main or a reviewed full SHA")
if stable_callers != REVIEWED_STABLE_RELEASE_CALLERS:
problems.append("shared release.yml callers are " + ", ".join(sorted(stable_callers)))
if signer_calls != 1:
problems.append("nightly-sign.yml must call nightly-release.yml exactly once")
return problems
class NightlySignerBranchTrustClosure(unittest.TestCase):
"""On refs/heads/nightly-signer, only the pinned signer caller may reach an environment."""
def test_trust_closure_scan_passes_on_this_tree(self):
self.assertEqual(trust_closure_problems(app_workflows()), [])
def test_trust_closure_scan_refuses_each_route_into_an_environment(self):
tree = app_workflows()
bad = {
"a workflow binds an environment": {**tree, "extra.yml": "jobs:\n x:\n runs-on: ubuntu-latest\n environment: release\n"},
"a double-quoted environment key": {**tree, "extra.yml": 'jobs:\n x:\n runs-on: ubuntu-latest\n "environment": release\n'},
"a single-quoted environment key": {**tree, "extra.yml": "jobs:\n x:\n runs-on: ubuntu-latest\n 'environment' : release\n"},
"an environment mapping": {**tree, "extra.yml": "jobs:\n x:\n runs-on: ubuntu-latest\n environment:\n name: release\n"},
"an environment in a flow mapping": {**tree, "extra.yml": "jobs:\n x: {runs-on: ubuntu-latest, environment: release}\n"},
"an escaped key": {**tree, "extra.yml": 'jobs:\n x:\n runs-on: ubuntu-latest\n "environ\\u006dent": release\n'},
"a merge key": {**tree, "extra.yml": "base: &b\n runs-on: ubuntu-latest\njobs:\n x:\n <<: *b\n"},
"an explicit key": {**tree, "extra.yml": "jobs:\n x:\n ? environment\n : release\n"},
"a nested flow mapping": {**tree, "extra.yml": "jobs:\n x: {steps: [{run: a}]}\n"},
"a double-quoted uses key copying the signer": {**tree, "extra.yml": 'jobs:\n x:\n "uses": ' + SHARED + "nightly-release.yml@" + "a" * 40 + "\n"},
"a single-quoted uses key": {**tree, "extra.yml": "jobs:\n x:\n 'uses': " + SHARED + "nightly-release.yml@" + "a" * 40 + "\n"},
"a quoted uses value": {**tree, "extra.yml": 'jobs:\n x:\n uses: "' + SHARED + "nightly-release.yml@" + "a" * 40 + '"\n'},
"uses in a flow mapping": {**tree, "extra.yml": "jobs:\n x: {uses: " + SHARED + "nightly-release.yml@" + "a" * 40 + "}\n"},
"a differently cased owner": {**tree, "extra.yml": "jobs:\n x:\n uses: Storytold/Craft-Common-Actions/.github/workflows/nightly-release.yml@" + "a" * 40 + "\n"},
"a folded uses value": {**tree, "extra.yml": "jobs:\n x:\n uses: >-\n " + SHARED + "nightly-release.yml@" + "a" * 40 + "\n"},
"a continued uses value": {**tree, "extra.yml": "jobs:\n x:\n uses: " + SHARED + "\n nightly-release.yml@" + "a" * 40 + "\n"},
"a quoted second signer call": {**tree, "nightly-sign.yml": tree["nightly-sign.yml"] + " again:\n \"uses\": " + SHARED + "nightly-release.yml@" + "a" * 40 + "\n"},
"a hash inside a quoted flow scalar": {**tree, "extra.yml": 'jobs:\n x: {name: "a} # b", runs-on: ubuntu-latest, environment: release, steps: []}\n'},
"a single-quoted hash in a flow scalar": {**tree, "extra.yml": "jobs:\n x: {name: 'a # b', runs-on: ubuntu-latest}\n"},
"a comma inside a quoted flow scalar": {**tree, "extra.yml": 'jobs:\n x: {name: "a, environment: release", runs-on: ubuntu-latest}\n'},
"a bracket inside a quoted flow scalar": {**tree, "extra.yml": 'jobs:\n x: {name: "[a]", runs-on: ubuntu-latest}\n'},
"an unterminated quote": {**tree, "extra.yml": 'jobs:\n x:\n name: "a\n b"\n runs-on: ubuntu-latest\n'},
"environment in any flow mapping": {**tree, "extra.yml": "jobs:\n x:\n runs-on: ubuntu-latest\n with: {environment: release}\n"},
"a double-quoted environment key in a flow mapping": {**tree, "extra.yml": 'jobs:\n x:\n runs-on: ubuntu-latest\n with: {"environment": release}\n'},
"a single-quoted environment key in a flow mapping": {**tree, "extra.yml": "jobs:\n x:\n runs-on: ubuntu-latest\n with: {'environment': release}\n"},
"a double-quoted uses key in a flow mapping": {**tree, "extra.yml": 'jobs:\n x: {"uses": ' + SHARED + "nightly-release.yml@" + "a" * 40 + "}\n"},
"uses in any flow mapping": {**tree, "extra.yml": "jobs:\n x:\n steps:\n - {uses: actions/checkout@v4}\n"},
"another caller of the signer": {**tree, "extra.yml": "jobs:\n x:\n uses: " + SHARED + "nightly-release.yml@" + "a" * 40 + "\n"},
"a mutable signer pin": {**tree, "nightly-sign.yml": re.sub(r"nightly-release\.yml@[0-9a-f]{40}", "nightly-release.yml@main", tree["nightly-sign.yml"])},
"a new stable release caller": {**tree, "extra.yml": "jobs:\n x:\n uses: " + SHARED + "release.yml@main\n"},
"a stable caller on a branch or tag ref": {**tree, "release.yml": tree["release.yml"].replace(SHARED + "release.yml@main", SHARED + "release.yml@v1")},
}
for label, workflows in bad.items():
with self.subTest(case=label):
self.assertTrue(trust_closure_problems(workflows))
def test_quoted_keys_in_a_flow_mapping_are_read_not_masked(self):
entries, refused = workflow_entries('jobs:\n x: {runs-on: ubuntu-latest, "name": build}\n')
self.assertEqual(refused, [])
self.assertIn((2, "name", "build", False), entries, "a quoted key keeps its identity")
self.assertIn((2, "runs-on", "ubuntu-latest", False), entries)
_, refused = workflow_entries("jobs:\n x: {runs-on: ubuntu-latest, 'environment': release}\n")
self.assertEqual(refused, ["line 2: environment in a flow mapping (must be block style)"])
def test_signer_guard_and_policy_name_the_same_branch(self):
sign = (ROOT / ".github/workflows/nightly-sign.yml").read_text()
(_, guard), = job_conditions(sign.split("\njobs:\n", 1)[1])
expected = ("github.repository == 'storytold/soundcraft' && github.event_name == 'workflow_dispatch'"
" && github.ref == 'refs/heads/" + SIGNER_BRANCH + "' && github.ref_type == 'branch'")
self.assertEqual(" ".join(guard.split()), expected,
"the signer guard is exactly the reviewed repository, dispatch and signer-branch expression")
self.assertEqual(re.findall(r"(?m)^ app-name: (\S+)$", sign), ["soundcraft"],
"the shared signer needs the reviewed registry app")
self.assertFalse((ROOT / ".github/workflows/nightly-dispatch.yml").exists(),
"this app has no automatic transport; adding one needs its own reviewed PR")
policy = json.loads(INSTALLED_POLICY.read_text())
self.assertEqual(policy["release_branch"], SIGNER_BRANCH)
self.assertEqual(policy["automatic_signer_actors"], [], "no automatic signer without a schedule")
if __name__ == "__main__":
unittest.main(verbosity=2)