Skip to content

fix(core): emit recurrence summary to external logger (#234) - #237

Open
vinkdc wants to merge 1 commit into
stacktale:mainfrom
vinkdc:fix/234-emit-recurrence-summary
Open

vinkdc wants to merge 1 commit into
stacktale:mainfrom
vinkdc:fix/234-emit-recurrence-summary

Conversation

@vinkdc

@vinkdc vinkdc commented Sep 7, 2026

Copy link
Copy Markdown

The SUMMARY branch in ReportPipeline.process() was writing dedup summaries to the report file but not forwarding them to the external logger (stacktale.reports), unlike the BLOCK branch. This caused downstream aggregators to miss recurrence events.

  • Extract rendered summary into a local variable
  • Call host.emitReport(rendered) after confirmWritten, mirroring BLOCK
  • Add integration test: two identical errors -> assert second logger event contains 'repeated 2x' and is not a full block
  • Update README emitReportsToLogger description

What & why

Closes #

How it was verified

  • mvn verify is green (JDK 17+)
  • Documentation-only — nothing to build

Checklist

  • The issue was claimed with a comment before starting (see
    CONTRIBUTING
    — didn't claim it? Open the PR anyway, just say so)
  • One logical change (unrelated fixes belong in their own PR)
  • Behavior changes arrive with the test that demanded them; bug fixes start from a
    failing test
  • No golden-file test changed — st/1 is a public API. If a golden test did
    change, that is a deliberate format change: say so below, and update
    docs/FORMAT.md
  • New config property? It has a setter (Joran naming), a default that preserves
    current behavior, coverage in LogbackXmlConfigTest, and a row in the README
    config table

AI assistance (optional)

The SUMMARY branch in ReportPipeline.process() was writing dedup
summaries to the report file but not forwarding them to the external
logger (stacktale.reports), unlike the BLOCK branch. This caused
downstream aggregators to miss recurrence events.

- Extract rendered summary into a local variable
- Call host.emitReport(rendered) after confirmWritten, mirroring BLOCK
- Add integration test: two identical errors -> assert second logger
  event contains 'repeated 2x' and is not a full block
- Update README emitReportsToLogger description
@codecov

codecov Bot commented Sep 9, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 75.00000% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...ithub/gabrielbbaldez/stacktale/ReportPipeline.java 75.00% 0 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@GabrielBBaldez GabrielBBaldez left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The placement is the part that was easy to get wrong, and you got it right without being told: after writer.append and after confirmWritten, so a shipper that throws cannot undo dedup state. That is the contract the REPORT arm spells out two lines above, and this arm now honours it.

I ran it rather than reading it. Your test passes, and removing just the emission line makes it fail for the right reason:

Expected size: 2 but was: 1

One thing to settle first, and it is the README line rather than the code.

renderSummary is called from two places. The one you changed runs while events are flowing; the other is in close(), draining whatever the dedup window still had pending when the app shut down. Five identical errors, emitReportsToLogger=true:

file:    ━ #4359adb0 repeated 2× (last 16:44:34.646) ━
         ━ #4359adb0 repeated 5× (last 16:44:34.650) ━

logger:  ━━━ ERROR #4359adb0 ━━━ …
         ━ #4359adb0 repeated 2× (last 16:44:34.646) ━

The final count — the one that says this error happened five times, not twice — is the one that stays behind. So Also emit each report block and recurrence summary as ONE event promises more than the code delivers, which is the shape of the problem #234 was about to begin with.

Either way out is fine by me:

  • narrow the README sentence to the summaries emitted during the run, or
  • emit at the drain site as well. I measured that rather than assuming it — adding the call there took the probe from 2 events to 3, so a Logback context on its way down is not in the way. A JVM shutdown hook is a harder case and I have not measured that one.

The second is still one logical change — summaries reach the logger — so it belongs in this PR rather than a follow-up, if you want it.

Not yours, and mine to deal with: the storm: line has the same shape. Written to the file, never emitted, and it is the line that says reports are being dropped.

One small thing: the template's Closes # is still blank, so #234 will not close itself when this merges.

@GabrielBBaldez

Copy link
Copy Markdown
Member

Followed through on the storm line rather than leaving it as a remark: #238, measured the same way. It touches the arm right above yours, so it waits on this one.

@GabrielBBaldez

Copy link
Copy Markdown
Member

Still open on the one question from the review, so to make it concrete — either of these closes it and I am happy with both:

  1. Narrow the README line to the summaries emitted during the run, or
  2. add the emission to the close() drain as well. I measured that it lands (2 events → 3), so it works; it is just more code than option 1.

Nothing else is outstanding. The pipeline change is right and your test demands it.

No rush. If you have moved on, say so and I will take option 1 on top of your commits so it lands with your name on it.

@GabrielBBaldez

Copy link
Copy Markdown
Member

Heads up on a collision: #232 just landed and the new README Deployment section ends with

Only full reports are emitted through stacktale.reports. Recurrence summaries remain in the report file, so a stdout-only reader will not see later repeated N× follow-ups.

That is true on main today and becomes false with your change, so whichever way you go on the drain-site question, that paragraph needs to move with it. It is README.md, just above ## Guarantees.

Still happy to take it from here if you have moved on — the offer stands.

This branch has not been deployed

No deployments
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