Skip to content

ci: catch every dev-trigger name in a release binary, not just one witness - #154

Merged
GLinnik21 merged 1 commit into
mainfrom
fix/release-trigger-names
Sep 19, 2026
Merged

GLinnik21 merged 1 commit into
mainfrom
fix/release-trigger-names

Conversation

@GLinnik21

Copy link
Copy Markdown
Collaborator

Background

A RELEASE build (--no-default-features, no devtriggers/devtools) must not carry dev-trigger names. #138 added dev.rs's CONTROLLED array (gated #[cfg(any(feature = "devtriggers", test))]) plus controlled_trigger()/listed() accessors, and ci/check-package.py grades a packaged binary against a single witness: DEV_WITNESS = b"plxnative-noidle". Any other plxnative-* name could leak into release unseen, and several did.

Inventory

Built the release lib (cargo +nightly build --lib --release --target arm-unknown-linux-gnueabi --no-default-features) and scanned the resulting archive for every dev.rs CONTROLLED/DIAG name.

Leaked dev-trigger names, now gated behind #[cfg(feature = "devtriggers")]:

  • ui/anim.rs's log() helper (plxnative-anim.log path)
  • dev/scenarios.rs's arm_profile_hwcnt() (plxnative-profile / plxnative-hwcnt)
  • person.rs's seed_dev_credits() log line (plxnative-personcredits)
  • doc comments in shaders/dither.glsl, fs_ambient.frag, fs_hero.frag, fs_src.frag, vs_ambient.vert naming plxnative-hwcnt, plxnative-overdraw, plxnative-anim, plxnative-heroground, plxnative-drawmask — reworded to drop the literal names (GLSL source is embedded verbatim as a runtime string via include_str!, comments included)

Legitimate release bytes, allowlisted in check-package.py rather than changed:

  • the four unconditional log sinks (events/crash/stderr logs)
  • plxnative-remote (production remote-key FIFO)
  • ui/rec.rs's own erasure list: rec, recplay, app-init, and its recordings-directory entry — deleting a co-resident devtriggers install's leftovers from the shared /tmp is correct in every build
  • app/input.rs's delete_all_local_data erasure list (gputime.jsonl, gst.log, hwcnt.jsonl, anim.log) — same rationale

Deliberately out of scope: the ~80 bare names read via dev::flag/dev::read outside CONTROLLED/DIAG (e.g. plxnative-play, plxnative-login, plxnative-url). Some are parsed by tests/run.py as a harness contract; others live inside dev::scenarios functions too deeply coupled to core App state to gate without a much larger refactor. CONTROLLED ∪ DIAG is dev.rs's own explicit, already-gated "trigger identity" vocabulary — its own doc comment says this is exactly what ci/check-package.py grades as "dev triggers compiled in" — so that is the catalog this check now audits.

Mechanism

ci/check-package.py now derives its catalog from dev.rs's own CONTROLLED and DIAG arrays via parse_dev_trigger_catalog() (regex over the source text), instead of a hand-copied list that would rot the way DEV_WITNESS itself did. dev_trigger_catalog() is the parsed set minus RELEASE_LEGITIMATE_TRIGGER_NAMES, each entry commented with why it's allowed.

Matching a catalog name against the binary can't be a plain substring test: Rust &str constants aren't NUL-terminated, so unrelated string literals pack back-to-back in .rodata with no separator at all — a real ARM release build was observed to contain one contiguous byte run where an allowlisted longer log filename was immediately followed by an unrelated word, no gap anywhere. That means a legitimate, allowlisted longer name can contain a real catalog name as its own byte-prefix — a naive "name in blob" check would misgrade that catalog name as "found" forever, with no source change able to turn it green. _catalog_name_in_binary() walks every occurrence of a name and only counts one that is not explained by an allowlisted longer name sitting at that exact byte position.

Red to green

Built --lib --release --target arm-unknown-linux-gnueabi --no-default-features and scanned the resulting archive with the actual check-package.py functions, before and after the source fixes above:

RED (pre-fix source, new catalog-based check):

  • catalog size: 23
  • dev-trigger hits found in the release binary: plxnative-hwcnt, plxnative-overdraw, plxnative-personcredits, plxnative-profile
  • check result: FAIL

GREEN (post-fix source, same catalog and matcher):

  • catalog size: 23
  • dev-trigger hits found in the release binary: none
  • check result: PASS

Test plan

  • ci/check-package.py --selftest — new fixture-based tests for parse_dev_trigger_catalog(), a live sanity check of dev_trigger_catalog() against the real dev.rs, and a boundary-matching regression test pinned to the exact byte adjacency found in the real binary
  • cargo +nightly check --manifest-path rust-modules/Cargo.toml --lib --no-default-features — clean
  • make check — green (one curlio::tests failure on the first run was a pre-existing flake unrelated to this change — reproduced in isolation as passing, and confirmed by a clean full rerun)
  • RED to GREEN evidence above against a real cross-compiled ARM release archive

🤖 Generated with Claude Code

Copilot AI lite review requested due to automatic review settings September 19, 2026 11:06

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

…tness

PR #138 gated dev::CONTROLLED's trigger vocabulary behind devtriggers/test,
but ci/check-package.py only ever grepped a packaged binary for a single
DEV_WITNESS ("plxnative-noidle"). Any other plxnative-* name that leaked
into a --no-default-features release build compile-time-unrelated to that
witness would go undetected. It happened: ui/anim.rs's log() sink,
dev/scenarios.rs's arm_profile_hwcnt(), person.rs's seed_dev_credits() log
line, and five shader files' GLSL comments (embedded verbatim via
include_str!) all shipped dev-trigger names into release bytes.

Inventory (release lib, arm-unknown-linux-gnueabi, --no-default-features):
  (a) leaked dev-trigger names, now gated behind #[cfg(feature = "devtriggers")]:
      - ui/anim.rs: log() helper (plxnative-anim.log path)
      - dev/scenarios.rs: arm_profile_hwcnt() (plxnative-profile/-hwcnt)
      - person.rs: seed_dev_credits()'s log line (plxnative-personcredits)
      - shaders/{dither.glsl,fs_ambient.frag,fs_hero.frag,fs_src.frag,
        vs_ambient.vert}: doc comments naming plxnative-hwcnt/-overdraw/
        -anim/-heroground/-drawmask, reworded to drop the literal names
  (b) legitimate release bytes, allowlisted in check-package.py rather
      than changed: the four unconditional log sinks, plxnative-remote,
      ui/rec.rs's and app/input.rs's erasure lists (deleting a stale
      devtriggers install's leftovers from the shared /tmp is correct in
      every build), and plxnative-anim.log (input.rs deletes this one too)

Mechanism: ci/check-package.py now derives its catalog from dev.rs's own
CONTROLLED and DIAG arrays via parse_dev_trigger_catalog() (regex over the
source text) rather than hand-copying a list that would rot the way
DEV_WITNESS itself did. dev_trigger_catalog() is the parsed set minus
RELEASE_LEGITIMATE_TRIGGER_NAMES, each entry commented with why.

Matching a catalog name against the binary can't be a plain substring
test: Rust &str constants aren't NUL-terminated, so unrelated literals
pack back-to-back with no separator, and a legitimate longer name (e.g.
"plxnative-hwcnt.jsonl") can contain a real catalog name (bare
"plxnative-hwcnt") as its own byte-prefix. _catalog_name_in_binary()
walks every occurrence and only counts one that isn't explained by an
allowlisted name sitting at that exact position, so it can't misgrade a
legitimate log filename as a compiled-in trigger forever.

Verified by building --lib --release --target arm-unknown-linux-gnueabi
--no-default-features and scanning the resulting archive with the actual
check-package.py functions, RED then GREEN:

  RED (pre-fix source):
    dev-trigger hits: ['plxnative-hwcnt', 'plxnative-overdraw',
                       'plxnative-personcredits', 'plxnative-profile']
    check result: FAIL

  GREEN (post-fix source, same catalog and matcher):
    dev-trigger hits: []
    check result: PASS

make check and `cargo +nightly check --lib --no-default-features` both
pass; ci/check-package.py --selftest covers the new parser, the live
catalog, and the boundary-matching regression case directly.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@GLinnik21
GLinnik21 force-pushed the fix/release-trigger-names branch from 063259a to 0db656c Compare September 19, 2026 11:18
@GLinnik21
GLinnik21 merged commit 5ac3dea into main Sep 19, 2026
10 checks passed
@GLinnik21
GLinnik21 deleted the fix/release-trigger-names branch September 19, 2026 11:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants