[KongchangAI]
Productpreflight 脚本

preflight.sh

A shell validation script executed before an AI agent runs. It checks the environment lock (lockfile hash) and whether the Git working tree is clean, preventing failures caused by running in a drifted environment.

Timeline (last 90 days)

Oct 19

The core logic of the preflight script preflight.sh is to assert the five assumptions and print the results line by line, exiting with a non-zero code on any failure; implementation details include: the workspace check uses mkdir -p plus a touch probe and gets available MB with df -Pm (default threshold 512MB), the clock check compares the Date header of the first outbound host with local UTC time (default tolerance 120 seconds), the credential check outputs only the first 10 characters of sha256, and the run lock uses exec 9>"$LOCK" plus flock -n 9.

Unverified50%
Oct 17

The way to prevent Runner environment drift is: generate a baseline on a clean code tree with sha256sum package-lock.json > env.lock, and write preflight.sh to verify the environment lock and whether the Git working tree is clean before each attempt.

Unverified50%
Oct 17

Preflight should run before the prompt, not after the diff.

Unverified50%
Oct 17

Preflight can catch three types of failures: a stale lockfile, uncommitted changes, and rerunning on an old state, each of which costs more than an hour.

Unverified50%

All Facts (4)

Source Articles