fix: strip every Astra directive from streamed chat deltas, not only metrics - #494
Conversation
|
Approach\n\nI will define the complete supported directive list once in the existing stream filter path, generalize its matching and partial suffix retention across that list, and keep matching case insensitive.\n\nThe implementation will land in src/Orbit.Application/Chat/Commands/ProcessUserChatCommand.Ai.cs. Behavior coverage will land in tests/Orbit.Application.Tests/Commands/Chat/ProcessUserChatCommandHandlerTests.cs for each directive, a split habit token, uppercase input, mixed directives with both final cards, and unchanged ordinary deltas.\n\nThis keeps one filter and one directive list. I rejected separate filters per card because that recreates the divergence behind this defect. I also rejected changing final extraction or card builders because they already provide the required final event behavior and are outside #357. |
There was a problem hiding this comment.
Important
This PR contains no implementation, so the advertised directive leak remains unchanged and must be fixed before merge.
Reviewed changes Compared the sole commit with main and traced the existing chat streaming and final card extraction paths.
- Tracked changes: The commit
81371f1changes no files. - Current directive path: The existing stream filter only suppresses
[[orbit:metrics]]; final response processing separately extracts habit, goal, and metrics directives. - Verification: No focused tests were added for habit, goal, multiple, or chunk-split directives.
⚠️ The advertised fix is absent
The branch is identical to main, so it still allows habit and goal directive text to reach streamed chat deltas. Merging this PR would close without changing the reported behavior.
Technical details
# Implement directive filtering before merge
## Affected sites
- `src/Orbit.Application/Chat/Commands/ProcessUserChatCommand.Ai.cs:159-225`: `MetricsDirectiveStreamFilter` only recognizes `MetricsCardBuilder.Directive`.
- `src/Orbit.Application/Chat/Commands/ProcessUserChatCommand.cs:215-245`: final response processing already extracts habit, goal, and metrics directives and must continue doing so.
- `tests/Orbit.Application.Tests/Commands/Chat/ProcessUserChatCommandHandlerTests.cs:973-1005`: existing stream coverage only exercises a metrics directive split across chunks.
## Required outcome
- Suppress every supported Astra response directive from all emitted chat deltas, including directives split across chunks, while preserving final card extraction.
- Add focused unit coverage that fails under the current metrics-only filter.GPT Sol | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes Reviewed the directive filtering implementation and regression coverage added since the prior Pullfrog review.
- Generalized stream filtering: Replaced the metrics-only filter with case-insensitive removal of every currently supported habit, goal, and metrics directive.
- Preserved streaming semantics: Retained partial directive prefixes across chunk boundaries while preserving resets, ordinary deltas, multiple directive removal, and final flushing.
- Expanded regression coverage: Added exact assertions for every directive, mixed directives, split chunks, uppercase tokens, unchanged ordinary chunks, and final card construction.
GPT Sol | 𝕏
The red CI is not this pull request.
|
OpenAI version on main |
result |
|---|---|
| 2.13.0 (current) | Failed 9, Passed 7 |
| 2.12.0 | Failed 0, Passed 16 |
The pin was reverted; the checkout is clean and still on 2.13.0.
Filed as thomasluizon/orbit-tickets#364, which blocks every open pull request against this repository, not just this one.
Where that leaves this pull request
Delivery verified: clean tree, 2 commits, pushed, head matches, ticket linked, 2 files, +187/-28. The verdict from verify-delivery.mjs is CI_FAILING, and the cause is inherited.
It should not merge while main is red, because the standing rule is that every required check passes. #364 lands first, this branch takes main, and its checks re-run clean.
|




Ticket: #357 in the ticket repository, https://github.com/thomasluizon/orbit-tickets/issues/357
Summary
Testing
Closes #357