Skip to content

fix(infra): generate event-statuses.ts from Python at build time - #264

Open
rezabekf wants to merge 1 commit into
mainfrom
rezabekf/event-status-single-source
Open

rezabekf wants to merge 1 commit into
mainfrom
rezabekf/event-status-single-source

Conversation

@rezabekf

@rezabekf rezabekf commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

Issue number: N/A (found during an architecture review; fix predates the issue-first workflow introduced in #263)

Summary

Changes

  • src/shared/event_statuses.py (7 statuses) and infra/constants/event-statuses.ts (hand-mirrored subset of 2) held independently maintained copies of the same status strings, with no compiler or test link between them.
  • Adds scripts/generate-event-statuses.py, which imports the real EventStatus class and mirrors all statuses into TypeScript (as const + derived type), wired into infra's existing prebuild step (npm runs it automatically before build/test/synth/deploy).
  • infra/constants/event-statuses.ts becomes a gitignored generated artifact, same as dist/.
  • Adds tests/test_generate_event_statuses.py covering the generator (full mirror of the real class, order preservation, generated-file header).

User experience

Before: the Step Functions workflow polls DynamoDB by comparing against the TypeScript copy of a status string, while the agent writes the Python copy. Renaming a status on the Python side produced no build error — the workflow's Choice silently fell through to its .otherwise() branch and polled until the 60-minute state-machine timeout.

After: the TypeScript constants are generated from the Python source of truth on every build. A Python-side rename propagates automatically; drift is structurally impossible.

Verified: cd infra && npm run build regenerates + compiles clean; 26/26 vitest and 142/142 pytest pass.


By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

🤖 Generated with Claude Code

@rezabekf
rezabekf requested a review from a team as a code owner September 18, 2026 10:57
@github-actions

Copy link
Copy Markdown

Coverage report

This PR does not seem to contain any modification to coverable code.

src/shared/event_statuses.py and infra/constants/event-statuses.ts held
independently maintained copies of the same status strings, with no
compiler or test link between them. The Step Functions workflow polls
DynamoDB by comparing against the TypeScript copy while Lambda writes
the Python copy, so a rename on the Python side wasn't a build error -
it was a silent 60-minute poll timeout.

Add scripts/generate-event-statuses.py, which mirrors the Python
EventStatus class into TypeScript, and wire it into infra's existing
prebuild step (alongside prepare-lambda/package-agent) so the generated
file can never drift. The generated file is gitignored, like dist/.
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.

2 participants