本書は日本語を正本とし、英語は参照用の補助訳とする。 解釈に差異がある場合は日本語版を優先する。
This document uses Japanese as the authoritative version. The English text is provided as a supporting reference translation. If any discrepancy exists, the Japanese version takes precedence.
本書は CX_FRAMEWORK.md の読み方のルールに従う。
must: 必須要件should generally: 基本原則should: 推奨may later: 将来拡張
This document follows the reading conventions defined in CX_FRAMEWORK.md.
本書は ESTIMATION_PACKAGE_SPEC.md の下位仕様であり、BenchKit と推定パッケージの間でやり取りする shell API の最小規約を定義する。
This document is a lower-level specification under ESTIMATION_PACKAGE_SPEC.md. It defines the minimum shell API conventions between BenchKit and estimation packages.
本 API の目的は、推定パッケージごとの差を吸収しつつ、estimate_common.sh や app 側 estimate.sh から一貫した呼び出しができるようにすることである。
The purpose of this API is to allow consistent invocation from estimate_common.sh and application-side estimate.sh while absorbing differences among estimation packages.
shell API は最初から複雑にしすぎない。 初期段階では、以下の 4 段階を明示できればよい。
- metadata 公開
- 適用可能性判定
- 推定実行
- Estimate JSON への反映
The shell API should not be made overly complex from the start. At the initial stage, it is sufficient to make the following four phases explicit:
- metadata exposure
- applicability evaluation
- estimation execution
- propagation into Estimate JSON
また、この shell API は推定パッケージの実装本体が常にリポジトリ内 shell ファイルであることを前提にしない。 package の実体は、リポジトリ内 shell、ローカルファイル、ベンダー指定ラッパー、外部サービス呼び出しのいずれであってもよく、shell API はそれらを BenchKit から統一的に扱うための境界面として定義する。
This shell API also does not assume that the implementation body of a package is always a shell file inside the repository. The package body may instead be a repository shell file, a local file, a vendor-specified wrapper, or an external service call, and the shell API is defined as the interface boundary through which BenchKit handles them uniformly.
推定パッケージの metadata を返す。
返り値は、少なくとも ESTIMATION_PACKAGE_METADATA_SPEC.md に沿った情報を表現できることが望ましい。
Returns the metadata of the estimation package.
The return value should preferably be able to express at least the information defined in ESTIMATION_PACKAGE_METADATA_SPEC.md.
現在の入力に対して、適用可能かどうかを判定する。
少なくとも以下の状態を返せることが望ましい。
applicablefallbacknot_applicableneeds_remeasurement
Evaluates whether the package is applicable to the current inputs.
It should preferably be able to return at least:
applicablefallbacknot_applicableneeds_remeasurement
推定本体を実行する。
この関数は、少なくとも以下を設定できることが望ましい。
est_current_*est_future_*est_current_fom_breakdownest_future_fom_breakdownest_measurement_jsonest_model_jsonest_assumptions_jsonest_confidence_json
Runs the estimation itself.
This function should preferably be able to set at least:
est_current_*est_future_*est_current_fom_breakdownest_future_fom_breakdownest_measurement_jsonest_model_jsonest_assumptions_jsonest_confidence_json
Estimate JSON に必要な metadata を共通変数へ反映する。
少なくとも以下を設定できることが望ましい。
est_estimation_idest_estimation_timestampest_method_classest_detail_levelest_estimation_packageest_estimation_package_version- 必要に応じて
est_applicability_json
Applies metadata required by Estimate JSON into shared variables.
It should preferably be able to set at least:
est_estimation_idest_estimation_timestampest_method_classest_detail_levelest_estimation_packageest_estimation_package_versionest_applicability_jsonwhen needed
初期段階では、以下の順を推奨する。
bk_estimation_package_metadatabk_estimation_package_check_applicability- 必要ならフォールバック選択
bk_estimation_package_runbk_estimation_package_apply_metadataprint_json
At the initial stage, the following order is recommended:
bk_estimation_package_metadatabk_estimation_package_check_applicability- fallback selection if needed
bk_estimation_package_runbk_estimation_package_apply_metadataprint_json
app 側 estimate.sh は、将来的には少なくとも以下だけで済むことが望ましい。
- package の選択
- package の読み込み
- 必要なら app 固有パラメータの設定
- 共通の呼び出し順序に従った実行
In the future, application-side estimate.sh should preferably be limited to:
- selecting the package
- loading the package
- setting app-specific parameters if needed
- executing according to the common invocation order
BK_ESTIMATION_PACKAGE=lightweight_fom_scaling
source scripts/estimate_common.sh
source scripts/estimation/packages/${BK_ESTIMATION_PACKAGE}.sh
read_values "$1"
bk_estimation_package_metadata
bk_estimation_package_check_applicability
bk_estimation_package_run
bk_estimation_package_apply_metadata
print_json > "$output_file"上記はリポジトリ内 shell package の例である。 ローカル配置やベンダー提供 package の場合も、最終的に同等の shell API 規約を満たすアダプタを介して呼び出せればよい。
The example above shows a repository-local shell package. For local or vendor-provided packages, it is sufficient to invoke them through an adapter that satisfies the same shell API conventions.
本書は以下をまだ固定しない。
- 関数の返り方を標準出力にするか変数設定にするか
- 失敗時終了コードの詳細
- package 読み込み規約の詳細
- 共通 fallback 選択器の有無
This document does not yet fix:
- whether functions return via stdout or shared variables
- detailed exit-code behavior on failure
- the details of package-loading conventions
- whether a common fallback selector exists
- the exact adapter style for local, vendor-provided, or service-backed packages