Skip to content

feat(sim): compare double admission before and after the hub race fix - #13

Merged
TN019 merged 19 commits into
mainfrom
feat/double-admission-scenarios
Dec 1, 2026
Merged

TN019 merged 19 commits into
mainfrom
feat/double-admission-scenarios

Conversation

@TN019

@TN019 TN019 commented Dec 1, 2026

Copy link
Copy Markdown

Why

Gatepost fixed a hub race in which two gates scanning the same ticket at the same moment could both admit it. The simulator should be able to show that race on a revision before the fix and show exactly one admission on a revision with the fix.

What changed

  • e2e/real-double-admission.spec.ts: with ADMISSION_SCENARIO=before-fix it sends Two gates at once with fresh tickets from GP-000000000100 for up to 200 tries and stops at the first try where Gate 1 and Gate 2 both turn green; with fixed it runs 30 tries and requires exactly one green each time. Each try also waits for both network LEDs to be on. The spec saves the double-admission-before-fix or double-admission-fixed pair.
  • scripts/e2e-gatepost.sh adds double-admission-before-fix and double-admission-fixed; controls requires GATEPOST_REF again.
  • scripts/screenshots.sh requires DOUBLE_ADMISSION_BEFORE_REF and DOUBLE_ADMISSION_FIXED_REF, starts an entrance for each, and captures all four pairs.
  • Add the four double-admission PNGs, light and dark, and extend the screenshot table and both READMEs.

How to verify

With Docker and the two Gatepost revisions:

scripts/venue.sh up --gatepost ../gatepost --ref <before-fix-rev> --mode devices
scripts/e2e-gatepost.sh double-admission-before-fix
scripts/venue.sh down
scripts/venue.sh up --gatepost ../gatepost --ref <fixed-rev> --mode devices
scripts/e2e-gatepost.sh double-admission-fixed
scripts/venue.sh down

Each run ends with a double-green count: 1 before the fix, 0 after it.


背景

Gatepost 修复了 hub 的一个竞态:两台闸机同时扫同一张票时,可能都会放行。模拟器应能在修复前的版本上重现这个竞态,并在修复后的版本上展示每次只有一台放行。

改动

  • e2e/real-double-admission.spec.ts:ADMISSION_SCENARIO=before-fix 时,从 GP-000000000100 开始每次换一张新票点 Two gates at once,最多尝试 200 次,一旦 Gate 1 和 Gate 2 同时亮绿灯就停止;fixed 时尝试 30 次,要求每次恰好一个绿灯。每次尝试还会等两台闸机的网络灯都亮起。用例保存 double-admission-before-fix 或 double-admission-fixed 截图对。
  • scripts/e2e-gatepost.sh 新增 double-admission-before-fix 和 double-admission-fixed 两个模式;controls 重新要求必须设置 GATEPOST_REF。
  • scripts/screenshots.sh 新增必填的 DOUBLE_ADMISSION_BEFORE_REF 和 DOUBLE_ADMISSION_FIXED_REF,分别启动入口,共拍摄四对截图。
  • 新增四张双闸机放行截图(浅色和深色),并扩充截图表格和两份 README。

怎么验证

安装 Docker,准备好两个 Gatepost 版本:

scripts/venue.sh up --gatepost ../gatepost --ref <before-fix-rev> --mode devices
scripts/e2e-gatepost.sh double-admission-before-fix
scripts/venue.sh down
scripts/venue.sh up --gatepost ../gatepost --ref <fixed-rev> --mode devices
scripts/e2e-gatepost.sh double-admission-fixed
scripts/venue.sh down

每次运行最后都会输出 double-green 计数:修复前为 1,修复后为 0。

@TN019

TN019 commented Dec 1, 2026

Copy link
Copy Markdown
Author

Ben Carter · reviewer

The before-fix run stops at the first double green. What if the race doesn't show within 200 tries?


修复前的那组在第一次两台都亮绿灯时就停下。如果 200 次内都没出现竞态呢?

@TN019

TN019 commented Dec 1, 2026

Copy link
Copy Markdown
Author

Noah Williams · author

Then both stays 0 and expect(both).toBe(1) fails the run, so there is never a before-fix screenshot of a race that did not happen.


那 both 会保持为 0,expect(both).toBe(1) 让这次运行失败,所以不会出现一张没有真正发生竞态的修复前截图。

@TN019

TN019 commented Dec 1, 2026

Copy link
Copy Markdown
Author

Ingrid Larsen · reviewer

controls requires GATEPOST_REF again. Why drop the main default?


controls 又要求必须设置 GATEPOST_REF 了,为什么去掉 main 这个默认值?

@TN019

TN019 commented Dec 1, 2026

Copy link
Copy Markdown
Author

Mateo Rossi · author

The scripts now run several Gatepost revisions in a row, before and after the race fix. Asking for the ref makes it explicit which one the controls check runs against.


现在脚本会先后运行竞态修复前后的多个 Gatepost 版本。要求显式给出版本,就能明确 controls 检查针对的是哪一个。

@TN019
TN019 merged commit dc6b585 into main Dec 1, 2026
1 check failed
@TN019
TN019 deleted the feat/double-admission-scenarios branch December 1, 2026 00:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant