Skip to content

feat(sim): demonstrate offline admission at two gates - #12

Merged
TN019 merged 15 commits into
mainfrom
feat/offline-admission-demo
Dec 1, 2026
Merged

TN019 merged 15 commits into
mainfrom
feat/offline-admission-demo

Conversation

@TN019

@TN019 TN019 commented Dec 1, 2026

Copy link
Copy Markdown

Why

Field staff need to see what happens when a gate loses the venue network: it keeps admitting from its local list, and the hub does not learn about those admissions. The page should label each decision as local or hub, and the documentation should show the case where one ticket gets in twice.

What changed

  • bridge/src/state.ts: when a gate reports LIGHT GREEN or LIGHT RED, log a decision event HUB ACCEPT|REJECT if the gate's last network LED report was ON, otherwise LOCAL ACCEPT|REJECT. New test labels admissions by the network LED reported with the decision.
  • e2e/real-offline-double-admission.spec.ts: scan GP-000000000001 at Gate 1 and wait for its network LED, unplug Gate 2 from the page, scan GP-000000000002 at Gate 2 (LOCAL ACCEPT), then at Gate 1 (HUB ACCEPT), check both lights are green, and save the offline-double-admission pair with the ticket panel hidden.
  • scripts/e2e-gatepost.sh offline-double-admission runs it; scripts/screenshots.sh requires OFFLINE_ADMISSION_REF and captures the pair after the Gate 3 pair.
  • Add docs/screenshots/offline-double-admission.png and .dark.png, describe the scene in both READMEs and both screenshot READMEs, and retake the Gate 3 and offline pairs with the current Gatepost checkout.

How to verify

pnpm test

With Docker and a Gatepost revision that has the hub client and network LED:

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

The test prints offline double admission: GP-000000000002; gate2 LOCAL ACCEPT, gate1 HUB ACCEPT.


背景

现场工作人员需要看到闸机断开场馆网络后会发生什么:它会继续按本地票单放行,而 hub 对这些放行一无所知。页面应标出每个决策来自本地还是 hub,文档也应展示同一张票被放行两次的情形。

改动

  • bridge/src/state.ts:闸机报告 LIGHT GREEN 或 LIGHT RED 时记录一条 decision 事件;如果这台闸机最近一次报告的网络灯为 ON,记为 HUB ACCEPT|REJECT,否则记为 LOCAL ACCEPT|REJECT。新增测试 labels admissions by the network LED reported with the decision。
  • e2e/real-offline-double-admission.spec.ts:先在 Gate 1 扫 GP-000000000001 并等它的网络灯亮起,在页面上拔掉 Gate 2 的网线,在 Gate 2 扫 GP-000000000002(LOCAL ACCEPT),再到 Gate 1 扫同一张票(HUB ACCEPT),确认两台都亮绿灯,然后隐藏票据面板,保存 offline-double-admission 截图对。
  • 用 scripts/e2e-gatepost.sh offline-double-admission 运行该用例;scripts/screenshots.sh 新增必填的 OFFLINE_ADMISSION_REF,在 Gate 3 截图对之后拍摄这一对。
  • 新增 docs/screenshots/offline-double-admission.png 和 .dark.png,在两份 README 和两份截图说明中描述这个场景,并用当前的 Gatepost 检出重拍 Gate 3 和离线放行两对截图。

怎么验证

pnpm test

安装 Docker,并准备带 hub 客户端和网络灯的 Gatepost 版本:

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

测试会打印 offline double admission: GP-000000000002; gate2 LOCAL ACCEPT, gate1 HUB ACCEPT。

@TN019

TN019 commented Dec 1, 2026

Copy link
Copy Markdown
Author

Ben Carter · reviewer

The label comes from the network LED, not from the hub. Can a gate show HUB ACCEPT for a decision it made locally?


标签依据的是网络灯,而不是 hub 本身。闸机在本地做出的决策,会不会被标成 HUB ACCEPT?

@TN019

TN019 commented Dec 1, 2026

Copy link
Copy Markdown
Author

Mateo Rossi · author

The label reports what the gate told us, not a confirmed hub round trip: receive uses the last LED NET line the gate sent before the light. If a gate kept its LED on while deciding locally, the page would show HUB. The state test covers both labels.


标签反映的是闸机自己报告的状态,并不代表确认过与 hub 的往返:receive 依据闸机在亮灯之前最后发来的 LED NET 行。如果某台闸机在本地决策时仍让网络灯亮着,页面就会显示 HUB。状态测试覆盖了两种标签。

@TN019

TN019 commented Dec 1, 2026

Copy link
Copy Markdown
Author

Yuki Tanaka · reviewer

Gate 2 is unplugged with the page button. Does the spec confirm Docker actually took it off the venue network?


Gate 2 是用页面按钮拔的网线。这个用例有没有确认 Docker 真的把它从场馆网络上断开了?

@TN019

TN019 commented Dec 1, 2026

Copy link
Copy Markdown
Author

Noah Williams · author

This spec waits for the snapshot to show network: false and the LED off. The Docker-level check of the venue network lives in real-controls.mjs.


这个用例只等到快照显示 network: false 且网络灯熄灭。Docker 层面对场馆网络的检查在 real-controls.mjs 里。

@TN019
TN019 merged commit fae4d50 into main Dec 1, 2026
1 check failed
@TN019
TN019 deleted the feat/offline-admission-demo 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