Skip to content

SOW-0047: reduce adapter tailer complexity#56

Merged
ktsaou merged 1 commit into
masterfrom
codex/sow-0047-claude-tailer-parser-refactor
Jun 6, 2026
Merged

SOW-0047: reduce adapter tailer complexity#56
ktsaou merged 1 commit into
masterfrom
codex/sow-0047-claude-tailer-parser-refactor

Conversation

@ktsaou

@ktsaou ktsaou commented Jun 6, 2026

Copy link
Copy Markdown
Member

Summary

  • Split the adapter tailer event loop, flush path, metadata repair, deferral state, watch handling, transcript reconstruction, and parser decode path into focused helpers.
  • Preserved runtime behavior with focused parser/tailer tests, direct transcript path aliasing coverage, fuzz seeds, and benchmark guard coverage.
  • Recorded the implementation evidence, validation runs, and review convergence in the active SOW.

Validation

  • ./scripts/gates.sh passed in 552s after final review convergence.
  • Local Codacy Analysis CLI reported 0 issues across the changed adapter files.
  • Independent review converged with no actionable findings remaining.

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.

  • Refactors
    • Moved JSONL decode into parser_decode.go (including parseLine and envelope/record helpers) and trimmed parser.go.
    • Decomposed tailing into helpers: 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), and tailer_deferral.go (deferral state).
    • Simplified tailer.go by removing inlined logic and delegating to the new helpers.
    • Updated benchmarks/tests to use 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.

Review in cubic

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.
@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 149 complexity · -29 duplication

Metric Results
Complexity 149
Duplication -29

View in Codacy

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.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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>

@ktsaou ktsaou merged commit 1be01c9 into master Jun 6, 2026
14 checks passed
@ktsaou ktsaou deleted the codex/sow-0047-claude-tailer-parser-refactor branch June 6, 2026 08:38
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.

1 participant