Skip to content

Commit 17bccad

Browse files
refactor: simplify re-estimation entrypoint [code:qws] [system:MiyabiG]
1 parent 2847f8d commit 17bccad

7 files changed

Lines changed: 79 additions & 103 deletions

File tree

‎.gitlab-ci.yml‎

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,7 @@ variables:
2828
benchpark: "false"
2929
park_only: "false"
3030
park_send: "false"
31-
estimate_uuid: ""
3231
estimate_result_uuid: ""
33-
result_uuid: ""
3432
reestimation_reason: ""
3533
reestimation_trigger: ""
3634

@@ -78,7 +76,7 @@ generate_matrix:
7876
- .gitlab-ci.generated.yml
7977
expire_in: 1 hour
8078
rules:
81-
- if: '$estimate_uuid != "" || $estimate_result_uuid != "" || $result_uuid != ""'
79+
- if: '$estimate_result_uuid != ""'
8280
when: never # 推定モードでは通常パイプラインを無効化
8381
- if: '$park_only == "true"'
8482
when: never # park_onlyモードでは無効
@@ -115,7 +113,7 @@ trigger_child_pipeline:
115113
- job: generate_matrix
116114
optional: true
117115
rules:
118-
- if: '$estimate_uuid != "" || $estimate_result_uuid != "" || $result_uuid != ""'
116+
- if: '$estimate_result_uuid != ""'
119117
when: never # 推定モードでは通常パイプラインを無効化
120118
- if: '$park_only == "true"'
121119
when: never # park_onlyモードでは無効
@@ -152,7 +150,7 @@ generate_benchpark_matrix:
152150
- .gitlab-ci.benchpark.yml
153151
expire_in: 1 hour
154152
rules:
155-
- if: '$estimate_uuid != "" || $estimate_result_uuid != "" || $result_uuid != ""'
153+
- if: '$estimate_result_uuid != ""'
156154
when: never # 推定モードではBenchParkパイプラインも無効化
157155
- if: '$code != "" && $benchpark != "true" && $park_only != "true" && $park_send != "true"'
158156
when: never # BenchKit専用のcode指定時はBenchParkを実行しない
@@ -186,7 +184,7 @@ trigger_benchpark_pipeline:
186184
- job: generate_benchpark_matrix
187185
optional: true
188186
rules:
189-
- if: '$estimate_uuid != "" || $estimate_result_uuid != "" || $result_uuid != ""'
187+
- if: '$estimate_result_uuid != ""'
190188
when: never # 推定モードではBenchParkパイプラインも無効化
191189
- if: '$code != "" && $benchpark != "true" && $park_only != "true" && $park_send != "true"'
192190
when: never # BenchKit専用のcode指定時はBenchParkを実行しない
@@ -219,7 +217,7 @@ generate_estimate_matrix:
219217
- .gitlab-ci.estimate.yml
220218
expire_in: 1 hour
221219
rules:
222-
- if: '$estimate_uuid != "" || $estimate_result_uuid != "" || $result_uuid != ""'
220+
- if: '$estimate_result_uuid != ""'
223221
when: always
224222
- when: never
225223

@@ -238,6 +236,6 @@ trigger_estimate_pipeline:
238236
- job: generate_estimate_matrix
239237
optional: true
240238
rules:
241-
- if: '$estimate_uuid != "" || $estimate_result_uuid != "" || $result_uuid != ""'
239+
- if: '$estimate_result_uuid != ""'
242240
when: always
243241
- when: never

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ python -m pytest tests/ -v
247247
- UUID指定による再推定もサポート
248248
- `estimate_result_uuid` を指定すると、その estimate から `source_result_uuid` を引いて再推定
249249
- docs 上の正式な入口は `estimate_result_uuid` に統一する
250-
- `result_uuid` は内部処理や互換のために残りうるが、利用者向け入口としては扱わない
250+
- 入口を 1 本に絞ることで、比較・履歴・UI の意味付けを単純に保つ
251251

252252
### 5. BenchPark統合パイプライン
253253
- `benchpark-bridge/config/apps.csv` で監視対象を定義

‎docs/cx/BENCHKIT_GAP_ANALYSIS.md‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ Once the estimation specification is clarified, many other design decisions beco
193193
| 詳細推定 package | `instrumented_app_sections` など取得方式別 package を持てること | `instrumented_app_sections_dummy` を `qws` 向け参照実装として実装済み | 実測区間時間や外部ツール区間時間を使う本格 package は未実装 | 最優先 |
194194
| 複合推定 | section ごとに異なる方式を合成できること | `qws` と `instrumented_app_sections_dummy` で section ごとの package 指定、artifact 参照、section package dispatch、section-level fallback を実装済み | 複数実アプリへの適用、本格 package 実装、より一般的な合成規則は未着手 | 高 |
195195
| 推定 provenance | 推定元 result と推定結果自体の出自情報を保持すること | 推定元 result の UUID / timestamp、requested/applied package、推定結果自体の UUID / timestamp を Estimate JSON に保持できる。result JSON 側にも server UUID / timestamp を保持できる | compare UI や再推定導線での活用は未整理 | 中 |
196-
| 再推定 | UUID 起点で再推定し比較可能にすること | shell フローはある | UUID 取得 API 仕様と比較表示の整理が未完 | 高 |
196+
| 再推定 | `estimate_result_uuid` 起点で再推定し比較可能にすること | 再推定専用 trigger、child pipeline、result / estimate / estimation input の再取得、`reestimation` ブロック付与、CI 上での保存完了まで動作する | compare UI、portal からの起動導線、表示上の差分把握が未完 | 高 |
197197
| 推定結果表示 | model / assumptions / applicability を表示できること | estimated 画面で requested/applied package、applicability、estimate UUID などの基本表示は可能 | section / overlap 単位の詳細表示、比較表示、`not_applicable` の説明補助は未整備 | 中 |
198198

199199
この表から、現在の最小核は以下と整理できる。
@@ -205,8 +205,8 @@ Once the estimation specification is clarified, many other design decisions beco
205205

206206
逆に、まだ核ではないが後で効くものは以下である。
207207

208-
- UUID 比較 UI
209-
- 再推定要求フロー
208+
- 再推定比較 UI
209+
- portal からの再推定要求フロー
210210
- 複合推定の本格化
211211
- counter / trace / overlap の本格活用
212212
- section / overlap 単位の詳細 UI 表示
@@ -218,7 +218,7 @@ Once the estimation specification is clarified, many other design decisions beco
218218
1. `qws` 以外の app へ推定方式を横展開する
219219
2. section / overlap 単位の package applicability と `not_applicable` 詳細を portal で見やすくする
220220
3. 複数 detailed package 間の fallback と discovery を整理する
221-
4. その後に UUID 再推定と比較表示へ進む
221+
4. その後に再推定比較 UI と portal 起動導線へ進む
222222

223223
ここでいう区間時間ダミー package は、すでに最初の参照実装として導入済みである。
224224
今後は、少なくとも以下を満たす方向へ育てる必要がある。

‎docs/cx/REESTIMATION_SPEC.md‎

Lines changed: 48 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,11 @@ Typical use cases include:
5454

5555
再推定では、入力となる benchmark result を明示的に固定しなければならない。
5656
この識別には、少なくとも result の UUID を用いることを基本とする。
57-
ただし、実運用では estimate result UUID を入口にし、その estimate が保持する `source_result_uuid` から元 result を辿れることが望ましい。
57+
再推定の利用者向け入口は `estimate_result_uuid` に統一する。BenchKit はその estimate が保持する `source_result_uuid` を内部的に解決し、元 result を辿る。
5858

5959
In re-estimation, the input benchmark result must be explicitly fixed.
60-
At minimum, the UUID of the result should be used as the primary identifier.
61-
In practical workflows, however, it is desirable to allow an estimate-result UUID as the entry point and resolve the original result through `source_result_uuid`.
60+
The documented user-facing entrypoint is `estimate_result_uuid`.
61+
BenchKit internally resolves the original benchmark result through the `source_result_uuid` stored in that estimate.
6262

6363
### 3.2 比較可能性 / Comparability
6464

@@ -100,17 +100,17 @@ It must not silently ignore missing inputs and still report a successful estimat
100100

101101
BenchKit における再推定の典型フローは以下である。
102102

103-
1. 利用者またはワークフローが `estimate_result_uuid` または `result_uuid` を指定する
104-
2. `estimate_result_uuid` の場合、BenchKit は estimate JSON を取得し、そこから `source_result_uuid` を解決する
103+
1. 利用者またはワークフローが `estimate_result_uuid` を指定する
104+
2. BenchKit は estimate JSON を取得し、そこから `source_result_uuid` を解決する
105105
3. BenchKit が対応する Result JSON を取得する
106106
4. 対象 app の `estimate.sh` を起動する
107107
5. `Estimate JSON` を生成する
108108
6. 生成結果を保存し、ポータルで参照可能にする
109109

110110
The typical re-estimation flow in BenchKit is:
111111

112-
1. a user or workflow specifies either an `estimate_result_uuid` or a `result_uuid`
113-
2. if an `estimate_result_uuid` is given, BenchKit fetches the estimate JSON and resolves `source_result_uuid`
112+
1. a user or workflow specifies an `estimate_result_uuid`
113+
2. BenchKit fetches the estimate JSON and resolves `source_result_uuid`
114114
3. BenchKit fetches the corresponding Result JSON
115115
4. the app-specific `estimate.sh` is invoked
116116
5. an `Estimate JSON` is generated
@@ -120,7 +120,7 @@ The typical re-estimation flow in BenchKit is:
120120

121121
再推定では少なくとも以下を入力として扱う。
122122

123-
- `estimate_result_uuid` または `result_uuid`
123+
- `estimate_result_uuid`
124124
- `code`
125125

126126
必要に応じて以下を追加で与えてよい。
@@ -133,7 +133,7 @@ The typical re-estimation flow in BenchKit is:
133133

134134
At minimum, re-estimation uses the following inputs:
135135

136-
- `estimate_result_uuid` or `result_uuid`
136+
- `estimate_result_uuid`
137137
- `code`
138138

139139
Optionally, the following may also be supplied:
@@ -164,29 +164,39 @@ In the current implementation, the following already exist:
164164
- a distinction between `requested_estimation_package` and the actually applied `estimation_package`
165165
- final-state applicability recording through `applicable`, `partially_applicable`, `fallback`, and `not_applicable`
166166

167-
現時点では、re-estimation で再取得できるのは source result JSON までであり、
168-
server 側に保存された detailed estimation-input artifact の復元はまだ未実装である。
169-
そのため現状では、
167+
現時点では、re-estimation で
168+
- source result JSON の再取得
169+
- server 側に保存された detailed estimation-input artifact の復元
170+
- 復元 artifact を用いた detailed 再推定
171+
まで実装済みである。
170172

173+
ただし、artifact が server 側に存在しない場合は、
171174
- artifact 不要な lightweight 再推定は成立しうる
172175
- artifact を要求する detailed 再推定は `not_applicable` で終わりうる
173176

174-
At present, re-estimation can re-fetch the source result JSON itself, but restoration of stored detailed estimation-input artifacts is not yet implemented.
175-
Therefore:
177+
At present, re-estimation can:
178+
179+
- re-fetch the source result JSON
180+
- restore stored detailed estimation-input artifacts
181+
- execute detailed re-estimation using the restored artifacts
182+
183+
However, when those artifacts do not exist on the server:
176184

177185
- lightweight or artifact-free re-estimation may succeed
178186
- detailed re-estimation that depends on missing artifacts may terminate as `not_applicable`
179187

180188
## 7. 現行実装と仕様のギャップ / Gaps Between Current Implementation and the Intended Specification
181189

182-
### 7.1 UUID 取得 API の仕様 / UUID-Based Result Retrieval API
190+
### 7.1 再推定取得口の仕様 / Re-Estimation Retrieval Interfaces
183191

184-
再推定を UUID 起点で運用するには、少なくとも次の取得口が必要である。
192+
再推定を `estimate_result_uuid` 起点で運用するには、少なくとも次の取得口が必要である。
185193

186194
- estimate result UUID で estimate JSON を返す取得 API
187-
- result UUID で Result JSON を返す取得 API
195+
- estimate JSON に記録された `source_result_uuid` に基づいて Result JSON を返す取得 API
196+
- `source_result_uuid` に対応する estimation input artifact を返す取得 API
188197

189-
現時点では、再推定の shell フロー自体は存在しても、その取得口の公開仕様や認証条件は文書としてまだ十分に固定されていない。
198+
現時点では、再推定の shell フローと取得口自体は実装済みである。
199+
一方で、取得 API の公開方針、認証条件、portal や compare UI からの見せ方は文書としてまだ十分に整理されていない。
190200

191201
したがって、以下を明確化する必要がある。
192202

@@ -195,13 +205,17 @@ Therefore:
195205
- confidential 結果の扱い
196206
- 取得失敗時の振る舞い
197207

198-
UUID-based re-estimation requires an API or equivalent retrieval path that can fetch Result JSON by UUID.
199-
At present, the shell-side re-estimation flow exists, but the retrieval endpoint, exposure rules, and authentication conditions are not yet fixed clearly enough in the documents.
208+
Re-estimation from `estimate_result_uuid` requires retrieval paths for:
209+
210+
- Estimate JSON by estimate-result UUID
211+
- Result JSON through the resolved `source_result_uuid`
212+
- estimation-input artifacts associated with that source result
213+
214+
At present, the shell-side re-estimation flow and these retrieval endpoints exist, but the exposure rules, authentication conditions, and portal-facing documentation are not yet fixed clearly enough in the documents.
200215

201216
The following therefore need to be clarified:
202217

203-
- a retrieval API that returns Estimate JSON by estimate-result UUID
204-
- a retrieval API that returns Result JSON by result UUID
218+
- the exposure policy of the retrieval APIs
205219
- whether authentication is required
206220
- how confidential results are handled
207221
- behavior on retrieval failure
@@ -260,7 +274,7 @@ At least the following need to be clarified:
260274

261275
BenchKit における再推定は、少なくとも以下を満たすことが望ましい。
262276

263-
1. `estimate_result_uuid` または `result_uuid` 指定で benchmark result を再取得できること
277+
1. `estimate_result_uuid` 指定で benchmark result を再取得できること
264278
2. app ごとの `estimate.sh` を同じ入力に対して繰り返し実行できること
265279
3. 再推定結果に、元 benchmark result UUID を残せること
266280
4. 異なる推定方式を同じ benchmark result に対して併存させられること
@@ -269,7 +283,7 @@ BenchKit における再推定は、少なくとも以下を満たすことが
269283

270284
Re-estimation in BenchKit should preferably satisfy at least:
271285

272-
1. the benchmark result can be re-fetched from either `estimate_result_uuid` or `result_uuid`
286+
1. the benchmark result can be re-fetched from `estimate_result_uuid`
273287
2. app-specific `estimate.sh` can be run repeatedly for the same input
274288
3. the re-estimation result can retain the original benchmark-result UUID
275289
4. different estimation methods can coexist for the same benchmark result
@@ -281,8 +295,8 @@ Re-estimation in BenchKit should preferably satisfy at least:
281295

282296
当面の再推定では、artifact 復元を次の流れで扱う。
283297

284-
1. `estimate_result_uuid` から開始する場合は、estimate JSON から `source_result_uuid` を解決する
285-
2. `result_uuid` から開始する場合は、そのまま source result JSON を取得する
298+
1. `estimate_result_uuid` から開始し、estimate JSON から `source_result_uuid` を解決する
299+
2. source result JSON を取得する
286300
3. `received_estimation_inputs/<result-stem>/` が存在する場合は、その内容を `results/estimation_inputs/` に復元する
287301
4. server 側に estimation input artifact が無い場合は、artifact 不要な推定のみを許可し、必要な推定は `not_applicable` とする
288302

@@ -297,18 +311,17 @@ Current restoration should follow this flow:
297311

298312
次に候補となる実装は以下である。
299313

300-
1. estimate/result の UUID 指定取得 API の仕様化と実装確認
301-
2. 再推定向けに UUID 指定取得口と認証条件を文書化する
302-
3. 同一 `source_result_uuid` を軸にした比較表示仕様を定義する
314+
1. 再推定向け取得 API の公開方針と認証条件を文書化する
315+
2. 同一 `source_result_uuid` を軸にした比較表示仕様を定義する
316+
3. `reestimation` ブロックを portal / compare UI で活かす
303317
4. portal から再推定を起動する要求フローを定義する
304318

305319
Candidate next steps include:
306320

307-
1. specify and verify the UUID-based estimate/result retrieval APIs
308-
2. document the retrieval endpoint and authentication conditions for re-estimation
309-
3. persist estimation-input artifacts under `received_estimation_inputs/` and restore them during re-estimation fetch
310-
4. define a display specification for comparing re-estimation results using `source_result_uuid`
311-
5. define a portal-driven request flow for starting re-estimation
321+
1. document the exposure policy and authentication conditions of the re-estimation retrieval APIs
322+
2. define a display specification for comparing re-estimation results using `source_result_uuid`
323+
3. surface the `reestimation` block in portal / compare UI
324+
4. define a portal-driven request flow for starting re-estimation
312325

313326
## 10. 現在の実装状態の補遺 / Addendum on Current Status
314327

@@ -330,8 +343,7 @@ Candidate next steps include:
330343
- compare UI や portal からの起動とも整合しやすい
331344
- どの estimate を起点にした再推定かを明示しやすい
332345

333-
`result_uuid` は内部処理や正規化のために使うことがあっても、利用者向けの正式入口としては扱わない。
334-
また、`estimate_uuid` は文書上の正式入口とはしない。
346+
再推定の入口として文書化するのは `estimate_result_uuid` のみとする。
335347

336348
## 12. 再推定トリガ例 / Re-Estimation Trigger Example
337349

‎scripts/estimation/generate_reestimate_pipeline.sh‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,8 @@
55
# of a specific benchmark result identified by UUID.
66
#
77
# Required CI variables:
8-
# result_uuid - UUID of the benchmark result to re-estimate directly
98
# estimate_result_uuid - UUID of the estimate result to re-estimate from
10-
# estimate_uuid - legacy alias for result_uuid
11-
# code - Program code name (e.g., "qws")
9+
# code - Program code name (e.g., "qws")
1210
# Optional CI variables:
1311
# reestimation_reason - e.g. package-update, model-tuning, manual-rerun
1412
# reestimation_trigger - e.g. ci-reestimation, portal, local-test
@@ -18,8 +16,8 @@
1816
set -euo pipefail
1917

2018
# Validate required variables
21-
if [[ -z "${result_uuid:-}" && -z "${estimate_result_uuid:-}" && -z "${estimate_uuid:-}" ]]; then
22-
echo "ERROR: result_uuid or estimate_result_uuid must be specified" >&2
19+
if [[ -z "${estimate_result_uuid:-}" ]]; then
20+
echo "ERROR: estimate_result_uuid must be specified" >&2
2321
exit 1
2422
fi
2523

‎scripts/estimation/test_reestimate.sh‎

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,18 @@
11
#!/bin/bash
22
set -euo pipefail
33

4-
if [[ $# -lt 2 || $# -gt 3 ]]; then
5-
echo "Usage: $0 <code> <result_uuid|estimate_result_uuid> [kind]"
4+
if [[ $# -ne 2 ]]; then
5+
echo "Usage: $0 <code> <estimate_result_uuid>"
66
echo " <code>: program name (directory under programs/)"
7-
echo " <result_uuid|estimate_result_uuid>: UUID to use as the re-estimation entry point"
8-
echo " [kind]: result | estimate (default: estimate)"
7+
echo " <estimate_result_uuid>: UUID to use as the re-estimation entry point"
98
echo ""
109
echo "Examples:"
1110
echo " $0 qws 11111111-2222-3333-4444-555555555555"
12-
echo " $0 qws 11111111-2222-3333-4444-555555555555 estimate"
13-
echo " $0 qws 11111111-2222-3333-4444-555555555555 result"
1411
exit 1
1512
fi
1613

1714
code="$1"
1815
input_uuid="$2"
19-
kind="${3:-estimate}"
2016

2117
if [[ ! "$input_uuid" =~ ^[0-9a-fA-F-]{36}$ ]]; then
2218
echo "ERROR: UUID format looks invalid: $input_uuid" >&2
@@ -36,28 +32,12 @@ fi
3632
rm -f results/result*.json results/estimate*.json results/source_estimate.json
3733
mkdir -p results
3834

39-
case "$kind" in
40-
estimate)
41-
export estimate_result_uuid="$input_uuid"
42-
unset result_uuid 2>/dev/null || true
43-
unset estimate_uuid 2>/dev/null || true
44-
;;
45-
result)
46-
export result_uuid="$input_uuid"
47-
unset estimate_result_uuid 2>/dev/null || true
48-
unset estimate_uuid 2>/dev/null || true
49-
;;
50-
*)
51-
echo "ERROR: kind must be one of: estimate, result" >&2
52-
exit 1
53-
;;
54-
esac
35+
export estimate_result_uuid="$input_uuid"
5536

5637
export code
5738

5839
echo "Re-estimation test"
5940
echo " code: $code"
60-
echo " kind: $kind"
6141
echo " uuid: $input_uuid"
6242
echo ""
6343

0 commit comments

Comments
 (0)