ShellFlow — Script Reduction Playbook

Most container entry points eventually execute a shell script. ShellFlow is the Stella Ops static analyser that resolves these scripts to their real exec target without executing user code, producing deterministic, explainable reductions. This guide documents its scope, architecture, and the idioms it recognises. Audience: engineers maintaining the shell parser or debugging a script reduction. ShellFlow is invoked from the static reducer; see the documentation index for the full subsystem map.

1) Scope

2) Architecture

ShellFlow/
  Parser/           // POSIX sh lexer + recursive descent parser
  Ast/              // nodes for lists, pipelines, conditionals, functions
  Evaluator/        // partial evaluation & taint tracking
  Idioms/           // pattern library for common Docker entrypoints
  Planner/          // emits CommandPlan[]

2.1 CommandPlan

public sealed record CommandPlan(
  string[] Argv,
  double   HeuristicScore,
  IReadOnlyList<string> Evidence,
  IReadOnlyList<ReductionEdge> Chain,
  bool     IsFallback = false
);

Plans feed directly into the static reducer, which selects the highest-confidence plan but keeps alternates as evidence.

3) Parsing & AST

4) Partial evaluation

5) Exec sink detection

6) Idiom library

PatternAction
if [ "${1:0:1}" = '-' ]; then set -- server "$@"; fiRewrite argv to prepend default command.
if [ "$1" = "bash" ]; then exec "$@"; fiPass-through for manual shells.
exec "$@" + non-empty CMDSubstitute CMD vector into plan.
exec java -jar "$APP_JAR" "$@"Resolve JAR via env or filesystem.
set -- gosu "$APP_USER" "$@"Collapse into wrapper plan.

Idioms are implemented as AST visitors; each adds evidence strings when triggered.

7) Confidence scoring

8) Failure modes

ShellFlow keeps the static reducer explainable: every inferred command is accompanied by the script span and reasoning used to reach it.