-
Notifications
You must be signed in to change notification settings - Fork 0
fix(p0): realign Bridge–TUI JSON schema with PRD-mandated minimum fields #25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -113,4 +113,49 @@ def calculate_session_reward(self, session: Session) -> Dict[str, int]: | |
|
|
||
| def handle_redirect(self, session: Session) -> None: | ||
| """Handle a redirect event by resetting momentum to 0.""" | ||
| session.momentum = 0 | ||
| session.momentum = 0 | ||
|
|
||
| def calculate_session_breakdown(self, session: Session) -> Dict[str, int]: | ||
| """Returns the PRD §"Bridge–TUI Interface Contract" per-session breakdown. | ||
|
|
||
| Decomposes the aggregated reward into the named components the | ||
| PRD's binding contract enumerates: base_value_this_turn, | ||
| token_bonus, plan_bonus, goal_bonus, net_payout. Sessions that | ||
| contribute zero (WAITING/INACTIVE/COMPLETED/SUSPENDED) return | ||
| all zeros. | ||
| """ | ||
| breakdown = { | ||
| "base_value_this_turn": 0, | ||
| "token_bonus": 0, | ||
| "plan_bonus": 0, | ||
| "goal_bonus": 0, | ||
| "net_payout": 0, | ||
| "momentum_multiplier": 0, | ||
| } | ||
| if session.status not in (SessionStatus.ACTIVE, SessionStatus.REDIRECTED): | ||
| return breakdown | ||
|
|
||
| # Base reward (production + gold). | ||
| breakdown["base_value_this_turn"] = 10 + 5 | ||
|
|
||
| # Token bonus (gold + science applied per token, capped at 10). | ||
| token_units = min(session.tokens, 10) | ||
| breakdown["token_bonus"] = token_units * 2 # +1 gold + +1 science per unit | ||
|
|
||
| # Plan bonus (production, capped at 2 plans). | ||
| breakdown["plan_bonus"] = min(len(session.plans), 2) * 15 | ||
|
|
||
| # Goal completion bonus (gold + science). | ||
| breakdown["goal_bonus"] = session.goals_completed * 60 # +40 gold + +20 science | ||
|
|
||
| # Momentum multiplier — culture/10 from current momentum. | ||
| breakdown["momentum_multiplier"] = session.momentum // 10 | ||
|
|
||
| breakdown["net_payout"] = ( | ||
| breakdown["base_value_this_turn"] | ||
| + breakdown["token_bonus"] | ||
| + breakdown["plan_bonus"] | ||
| + breakdown["goal_bonus"] | ||
| + breakdown["momentum_multiplier"] | ||
| ) | ||
| return breakdown | ||
|
Comment on lines
+118
to
+161
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The scoring logic implemented in |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Performing an inline import of
datetimeinside thefeedmethod is inefficient, as this method is invoked for every hook event processed by the bridge. While Python's import system is optimized, the lookup still occurs on every call. It is better practice to move this import to the top of the module to follow standard Python conventions and improve performance.