SOW-0047: reduce adapter tailer complexity#56
Merged
Conversation
Split the session tailer event loop, flush path, metadata repair, deferral state, watch handling, transcript reconstruction, and parser decode path into focused helpers. Preserve runtime behavior with focused tailer/parser tests, direct aliasing coverage for transcript session dirs, and the existing benchmark guard. Record validation and review convergence in the SOW.
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 149 |
| Duplication | -29 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
There was a problem hiding this comment.
1 issue found across 17 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="internal/adapters/claude_code/tailer_loop.go">
<violation number="1" location="internal/adapters/claude_code/tailer_loop.go:161">
P1: Tail swallows catch-up discovery failures instead of returning them, so a fatal root/discovery error is reported via OnError but not surfaced to the caller.</violation>
</file>
Tip: cubic can generate docs of your entire codebase and keep them up to date. Try it here.
Re-trigger cubic
| if rt.dirty.any() { | ||
| resetDebounce(rt.debounce) | ||
| } | ||
| return nil |
There was a problem hiding this comment.
P1: Tail swallows catch-up discovery failures instead of returning them, so a fatal root/discovery error is reported via OnError but not surfaced to the caller.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At internal/adapters/claude_code/tailer_loop.go, line 161:
<comment>Tail swallows catch-up discovery failures instead of returning them, so a fatal root/discovery error is reported via OnError but not surfaced to the caller.</comment>
<file context>
@@ -0,0 +1,217 @@
+ if rt.dirty.any() {
+ resetDebounce(rt.debounce)
+ }
+ return nil
+}
+
</file context>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Validation
./scripts/gates.shpassed in 552s after final review convergence.Summary by cubic
Refactors the Claude Code adapter to split the tailer and parser into focused helpers, reducing complexity while keeping behavior and performance unchanged. Adds targeted tests, expanded fuzz seeds, and benchmark guard integration to prevent regressions.
parser_decode.go(includingparseLineand envelope/record helpers) and trimmedparser.go.tailer_loop.go(event loop),tailer_flush.go(flush + deferral),tailer_events.go(fsnotify event classification),tailer_watch.go(dir watch and dirty marking),tailer_meta.go(meta repair),tailer_transcript.go(transcript reconstruction), andtailer_deferral.go(deferral state).tailer.goby removing inlined logic and delegating to the new helpers.newTailFlush(...).flushDirty(...)and added focused tests (deferral, helpers, parser) with expanded fuzz seeds and transcript aliasing coverage.Written for commit eff7cf9. Summary will update on new commits.