Skip to content

[Rust port] relayburn-analyze: findings + quality #268

@willwashburn

Description

@willwashburn

Parent: #244
Depends on: #242, #266 (analyze foundation)

Context

The shared WasteFinding model and per-session quality outcome inference. Both are leaf modules — every hotspot detector and the patterns module emit WasteFindings through this surface, and compare / hotspots consume QualityResult to gate severity. They land together so the downstream detector PRs (#TODO ghost-surface, #TODO tool-call-patterns, #TODO patterns) can depend on a settled finding type.

Scope

findings.rs (port of findings.ts, ~313 LoC)

  • Port WasteSeverity (info | warn | high), WasteAction (string-literal union — model as a string-newtype or a closed enum; either works, but emit identical strings at serialization), EstimatedSavings, WasteFinding.
  • Port the *ToFinding adapters: retryLoopToFinding, failureRunToFinding, cancellationRunToFinding, compactionLossToFinding, editRevertToFinding, editHeavyToFinding, skillRecallDupToFinding, skillPruningProtectionToFinding, systemPromptTaxToFinding.
  • Port findingsFromPatterns(result) and sortFindings(findings).
  • The pattern types referenced (RetryLoop, FailureRun, etc.) live in patterns.ts (separate sub-issue). To avoid a circular-dep blocker, define those concrete struct types in findings.rs (or a shared patterns_types module) and have the patterns sub-issue depend on this one. Either layout is acceptable as long as findings doesn't depend on patterns (which is the larger, later module).

quality.rs (port of quality.ts, ~291 LoC)

  • Port OutcomeLabel (completed | abandoned | errored | unknown), OutcomeConfidence (high | medium | low), SessionOutcome, OneShotMetrics, QualityResult, ComputeQualityOptions.
  • Port inferOutcome(), computeOneShotRate(), computeQuality().

Conformance gate

  • packages/analyze/src/findings.test.ts (322 lines)
  • packages/analyze/src/quality.test.ts (259 lines)

Equivalent Rust tests; severity/action labels and outcome labels emit byte-identical strings.

Acceptance

  • cargo test -p relayburn-analyze green for findings + quality.
  • Public surface: WasteFinding, WasteSeverity, WasteAction, EstimatedSavings, all *ToFinding adapters, findingsFromPatterns, sortFindings, OutcomeLabel, OutcomeConfidence, SessionOutcome, OneShotMetrics, QualityResult, ComputeQualityOptions, inferOutcome, computeOneShotRate, computeQuality.
  • sortFindings ordering matches TS — by (severity desc, savings desc, kind, sessionId, ts) tuple. Include a fixture-driven test.
  • Pattern struct definitions placed so the patterns sub-issue can import without a circular dep.

Files

  • packages/analyze/src/findings.ts + findings.test.ts
  • packages/analyze/src/quality.ts + quality.test.ts

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions