Files
2026-02-24 12:10:13 +01:00

96 lines
5.8 KiB
Plaintext

{
"batch": "Cross-cutting Sweep",
"batch_index": 1,
"assessments": {
"error_consistency": 74.0
},
"dimension_notes": {
"error_consistency": {
"evidence": [
"HTTP RPC path collapses response write failures to generic `http.Error(..., \"rpc write error\", ...)`, while stdio path returns wrapped encode errors (`encode parse-error response: %w`) in the same server module.",
"Batch scrape aggregates per-source failures but returns only `one or more sources failed`, while other command paths return joined/wrapped causes (`errors.Join(...)` in ask flow).",
"Quality scan loop logs detector failures and continues, while detector implementations mix per-file silent skips (`continue` on file read/count errors) and fail-fast returns for parse errors, yielding inconsistent failure visibility.",
"Ask fallback persistence/reindex errors are explicitly ignored (`_, _ = storage.SaveDocuments`, `_, _ = engine.Rebuild`) whereas push/scrape treat analogous save/reindex failures as returned errors."
],
"impact_scope": "subsystem",
"fix_scope": "multi_file_refactor",
"confidence": "high"
}
},
"findings": [
{
"dimension": "error_consistency",
"identifier": "rpc_transport_error_detail_divergence",
"summary": "HTTP and stdio RPC transports expose write/encode failures with different fidelity.",
"related_files": [
"internal/server/server.go",
"cmd/serve.go"
],
"evidence": [
"In `internal/server/server.go`, HTTP `/rpc` writes generic `rpc write error` on writeRPC failure (lines ~132-140), dropping underlying encode context.",
"In the same file, stdio transport returns wrapped encode errors (line ~218) and raw encode failures (line ~224), preserving actionable context.",
"`cmd/serve.go` uses one server abstraction for both modes, so callers see transport-dependent error behavior for equivalent failure classes."
],
"suggestion": "Unify transport error contract: introduce a shared helper that classifies encode/write failures and records structured context (operation, transport, cause). Keep client-facing RPC payload stable, but log/return wrapped internal causes consistently for both HTTP and stdio.",
"confidence": "high",
"impact_scope": "module",
"fix_scope": "multi_file_refactor"
},
{
"dimension": "error_consistency",
"identifier": "batch_scrape_error_cause_loss",
"summary": "Batch scrape returns a generic terminal error after printing detailed source failures.",
"related_files": [
"cmd/scrape.go",
"cmd/ask.go"
],
"evidence": [
"`cmd/scrape.go` records per-source failures, prints each error, then returns `one or more sources failed` (lines ~187-207), losing machine-readable causes.",
"`cmd/ask.go` returns joined upstream causes when retrieval fails (`errors.Join(fetchErrors...)`, lines ~149-154), preserving aggregate failure detail.",
"This creates inconsistent caller behavior across commands: some flows expose causal chains, others require scraping stdout logs."
],
"suggestion": "Accumulate per-source errors in `scrapeFromConfig` and return `fmt.Errorf(\"...: %w\", errors.Join(errs...))` while still printing the summary; this keeps CLI UX and provides consistent programmatic error chains.",
"confidence": "high",
"impact_scope": "module",
"fix_scope": "single_edit"
},
{
"dimension": "error_consistency",
"identifier": "quality_scan_detector_failure_semantics_mixed",
"summary": "Quality scanning mixes swallowed detector failures with fail-fast detector behavior.",
"related_files": [
"internal/quality/scanner.go",
"internal/quality/plugins/go/analyzers/detectors.go",
"internal/quality/plugins/go/analyzers/advanced.go"
],
"evidence": [
"`internal/quality/scanner.go` logs detector errors and continues (lines ~76-79), so scan succeeds even when detectors fail.",
"`detectors.go` has inconsistent per-file policy: `LargeFileDetector` silently `continue`s on count errors (lines ~44-47), while `GodStructDetector` returns wrapped errors and aborts detector run (lines ~102-105).",
"This produces non-uniform failure propagation: some analysis gaps are silent, some are surfaced, and scanner-level behavior masks both as successful scans."
],
"suggestion": "Define a uniform detector error policy (e.g., collect per-file errors + thresholded hard-fail) and enforce it via shared helper APIs so scanner output includes a structured `partial_failures` section instead of ad-hoc continue/abort choices.",
"confidence": "high",
"impact_scope": "subsystem",
"fix_scope": "architectural_change"
},
{
"dimension": "error_consistency",
"identifier": "ask_fallback_ignores_persistence_errors",
"summary": "Ask fallback suppresses save/reindex failures that analogous command flows propagate.",
"related_files": [
"cmd/ask.go",
"cmd/push.go",
"cmd/scrape.go"
],
"evidence": [
"`cmd/ask.go` ignores persistence/index maintenance errors with blank identifier assignments (lines ~369-377).",
"`cmd/push.go` and `cmd/scrape.go` both return save/reindex failures (`save docs failed`, `reindex failed`, `reindex after scrape...`) instead of suppressing them.",
"Equivalent storage/index boundary failures therefore produce different observability depending on command path."
],
"suggestion": "Handle ask fallback persistence/reindex errors explicitly: either return them when they invalidate guarantees, or attach them to response metadata/logged warnings with a consistent typed error category used across commands.",
"confidence": "high",
"impact_scope": "module",
"fix_scope": "multi_file_refactor"
}
]
}