Skip to content

fix(deps): preflight runtime dependencies - #2557

Open
kongche-jbw wants to merge 1 commit into
alibaba:mainfrom
kongche-jbw:fix/sec-core/preflight-runtime-deps
Open

fix(deps): preflight runtime dependencies#2557
kongche-jbw wants to merge 1 commit into
alibaba:mainfrom
kongche-jbw:fix/sec-core/preflight-runtime-deps

Conversation

@kongche-jbw

@kongche-jbw kongche-jbw commented Aug 14, 2026

Copy link
Copy Markdown
Collaborator

Why

build-all.sh could build or begin installation before discovering missing runtime
dependencies such as bwrap. It also checked only sec-core, so users could hit
the same one-at-a-time failure pattern in other selected components.

What changed

  • Read runtime dependencies from every selected component manifest by TOML key
    and report all missing capabilities together.
  • Adapt packaged contracts for source builds, including excluding sec-core systemd
    and mapping source-specific Node and OpenSSL requirements.
  • In user mode, check platform blockers first, preserve user-local source setup
    such as nvm, then re-probe every runtime and report remaining gaps once.
  • In system mode, reject platform and language-runtime blockers before package
    mutation, refresh APT indexes for DEB hosts, install native packages in one
    deduplicated transaction, and re-probe.
  • Require Node >=20 on the fixed system PATH for system installs; an installing
    user nvm never satisfies the system contract, and no external repository is added.
  • Preserve user PATH priority in user mode while adding standard system directories
    for host tools such as mkfs.btrfs and modprobe.
  • Emit absolute retry commands and preserve --deps-only and --ignore-deps.

Related issue

Related to #2520. The direct linux-sandbox diagnostic remains separate.

User / Agent impact

Default user builds retain automatic Node setup through nvm. Missing runtime
dependencies are still reported together before component files are installed.
System installs require language runtimes to be present in the fixed system PATH;
ordinary native packages may be installed automatically after all blockers pass.

Risk and compatibility

  • Public CLI, API, configuration, or documented behavior changed
  • Privileged or security-sensitive behavior changed
  • Cross-component contract changed

System mode may refresh APT metadata and invoke the detected package manager once
for missing native runtime packages, but it never configures NodeSource or another
external repository. User mode never invokes privileged runtime package
installation; its existing user-local source dependency installers remain available.

Validation

  • bash -n scripts/build-all.sh tests/test-build-all-runtime-deps.sh
  • ./tests/test-build-all-runtime-deps.sh (28/28)
  • cargo test -p anolisa-core manifest --locked (93 passed)
  • Reordered TOML fields and reversed deb / rpm inline-table keys
  • sec-core source dependencies exclude the packaged systemd requirement
  • Source-build CI no longer preinstalls or verifies systemd
  • APT refresh precedes the aggregated DEB install and failure stops before mutation
  • User deps-only Node setup runs before the full runtime re-probe
  • User-local nvm provisioning selects Node 24 and remains ahead of system PATH
  • System Node 18 plus current-shell/nvm Node 24 is rejected
  • Language runtimes never enter the system package transaction
  • Restricted user PATH discovers loadable btrfs and system mkfs.btrfs
  • ws-ckpt rejects a btrfs-progs probe when mkfs.btrfs is unavailable
  • Absolute retry commands preserve deps-only and ignore-deps modes
  • User and system cosh deps-only dry runs
  • git diff --check

Documentation and rollback

No documentation changes are required. Revert commit 35746f1d to restore the
previous component-specific behavior.

@kongche-jbw
kongche-jbw force-pushed the fix/sec-core/preflight-runtime-deps branch from 37bdd24 to 796dd4d Compare August 14, 2026 10:12
@github-actions github-actions Bot added scope:ci ./.github/ scope:scripts ./scripts/ labels Aug 14, 2026
@kongche-jbw
kongche-jbw force-pushed the fix/sec-core/preflight-runtime-deps branch from 796dd4d to b437ae7 Compare August 14, 2026 10:42
@kongche-jbw kongche-jbw changed the title fix(sec-core): preflight runtime deps fix(deps): preflight runtime dependencies Aug 14, 2026
@kongche-jbw
kongche-jbw force-pushed the fix/sec-core/preflight-runtime-deps branch 8 times, most recently from 95e98b9 to 05f48a5 Compare August 14, 2026 23:56
@kongche-jbw
kongche-jbw marked this pull request as ready for review August 15, 2026 02:03
@kongche-jbw

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 05f48a5ee2

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread scripts/build-all.sh
# source build requires the same Node version as copilot-shell.
echo 'sec-core|node|language-runtime|node --version|nodejs|nodejs||>=20|'
else
echo "$record"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Exclude systemd from sec-core source dependencies

When a user-mode source install runs on a supported minimal Debian/RPM host without systemctl, this unchanged manifest record makes the full preflight abort before installing sec-core. However, src/agent-sec-core/Makefile's install-all target does not include install-systemd-user; that unit is only installed by install-all-for-rpmbuild, so the source-installed files do not require systemd. Adapt or omit this system-only dependency for the source-build path instead of blocking ./scripts/build-all.sh --component sec-core.

Useful? React with 👍 / 👎.

@kongche-jbw kongche-jbw Aug 15, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed in 35746f1d. The source-build dependency adapter now omits the sec-core systemd manifest entry because make install neither installs nor manages that unit. Source-build CI no longer preinstalls or verifies systemd, and a regression assertion covers the filtered dependency.

Comment thread scripts/build-all.sh
as_root $PKG_INSTALL jq || warn "jq not installed (sec-core helper/signing dependency)"

info "Installing runtime dependencies: ${packages[*]}"
if ! as_root "${install_command[@]}" "${packages[@]}"; then

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Refresh APT indexes before installing runtime packages

On a fresh or cleaned Debian/Ubuntu system install, the first package mutation is now apt-get install without a preceding apt-get update, so missing dependencies can fail with “Unable to locate package” even though the configured repositories provide them; the subsequent re-probe then aborts the install. apt-get --help describes update as “Retrieve new lists of packages,” so run it before this aggregated deb transaction, as the existing Node and CI setup paths already do.

Useful? React with 👍 / 👎.

@kongche-jbw kongche-jbw Aug 15, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed in 35746f1d. DEB system preflight now runs one apt-get update before the aggregated install and exits before package mutation if the refresh fails. Tests cover both call ordering and the failure short-circuit.

@kongche-jbw
kongche-jbw force-pushed the fix/sec-core/preflight-runtime-deps branch from 05f48a5 to 899421a Compare August 15, 2026 02:15
- Aggregate manifests and block system changes before dependency setup.
- Preserve user-local source provisioning, then re-probe every runtime.
- Parse manifest keys safely and batch native system package installs.

Fixes: 6e4a741 ("refactor(build): introduce unified build workflow")
Signed-off-by: kongche-jbw <kongche.jbw@alibaba-inc.com>
@kongche-jbw
kongche-jbw force-pushed the fix/sec-core/preflight-runtime-deps branch from 899421a to 35746f1 Compare August 15, 2026 02:22

@Forrest-ly Forrest-ly left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Code review for commit 35746f1 — approving.

What I verified

  • Ran tests/test-build-all-runtime-deps.sh locally against this commit: 28/28 pass.
  • Ran runtime_dependencies_for_manifest against all 8 real component manifests: emits exactly the expected 15 records; agent-memory and os-skills correctly contribute zero.
  • Preflight ordering confirmed in code and tests: platform capabilities are checked before user source setup; system mode blocks platform-capability / language-runtime blockers before any package mutation; one deduplicated APT transaction preceded by apt-get update (failure stops before mutation); re-probe after install; install phase re-verifies before any component file lands.
  • The two earlier automated findings (sec-core systemd exclusion for source builds, APT refresh before the aggregated install) are both addressed in this commit with regression tests.
  • User mode never calls as_root for runtime packages; system probes use the fixed RUNTIME_SYSTEM_PATH, so a user-local nvm Node cannot satisfy the system contract; the emitted retry command is absolute and preserves --system / --deps-only / --ignore-deps (covered for --component memory).
  • agent-memory code is untouched; it participates via the generic manifest-driven preflight (it declares no dependencies), so no new requirements are introduced for memory installs.
  • The ws-ckpt probe change (btrfs versionmkfs.btrfs --version) matches what the removed installer actually required (cmd_exists mkfs.btrfs).

Non-blocking suggestions

  1. scripts/build-all.sh:2128,2150 — the local -n namerefs are the script's first bash ≥ 4.3 dependency. On bash 4.2 hosts (CentOS/Anolis 7 era) the preflight would error out instead of reporting. Likely acceptable given the ws-ckpt/sight kernel floors and EL7 EOL, but worth confirming EL7 is out of support scope, or documenting a minimum bash version.
  2. User-visible behavior change worth a release note: missing runtime dependencies now hard-fail user-mode installs, where bwrap/gpg/jq previously only warned. Intentional per the PR body, but users will notice.
  3. The awk TOML reader assumes single-line packages = { ... } inline tables and no | character in any field. Current manifests comply and the 15-record assertion guards against drift, but consider a one-line comment near runtime_dependencies_for_manifest spelling out these constraints so future manifest edits don't silently drop records.

Nice work on the aggregated reporting, the strict order-of-operations guarantees, and the test coverage.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope:ci ./.github/ scope:scripts ./scripts/

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants