← Back to Pull requests

fix(step): report diagnostic paths relative to the repository root for steps that run in a subdirectory #1638

Closed
unknown closed this pull request without merging on Oct 04, 2026 00:24 UTC
View on GitHub
unknown unknown commented on Oct 03, 2026 23:23 UTC
Author

<!-- entire-trail-link-start -->
https://entire.io/gh/jdx/hk/trails/214
<!-- entire-trail-link-end -->

Problem

A step with diagnostic_format that runs in a directory (dir = "{{workspace}}" or an explicit dir) reports the paths its tool printed, which are relative to that directory. In a repo with several modules, SARIF, --format json and MCP diagnostics then name the wrong file. This is why #1630 had to drop diagnostic_format from go_vet and golangci_lint.

# services/api/ has a go.mod; the tool runs there and prints:
./main.go:5:2: ...

# before (SARIF uri / JSON path)
./main.go

# after
services/api/main.go

Change

hk now records each check command's output together with the directory it ran in, parses each command separately, and rebases the parsed diagnostic paths (and fix paths) onto the repository root:

  • relative paths are prefixed with the directory; ./ and .. segments are resolved

  • \ is treated as a separator

  • absolute paths, Windows drive paths and URIs are left as printed

  • steps without dir are unchanged
  • Parsing per command also means a batch or workspace step with several jobs no longer has to parse their concatenated output as one document. check/fix commands are not changed. The diagnostic_format docs in pkl/Config.pkl mention the rebasing.

    Not included (follow-up)

    go_vet and golangci_lint do not get diagnostic_format here. With the gcc parser on main, go vet type errors print as vet: ./main.go:3:8: ..., which parses with vet: ./main.go as the path, and the # pkg header lines become parse warnings. Those builtins should follow once #1629/#1630 (the gcc shape work) land. I did not run golangci-lint locally (no version set in mise), so its output shape is unchecked.

    Validation

  • Rust unit tests for rebasing (relative, ./, .., escaping the root, Windows separators, absolute/drive/URI paths, no-op for root and absolute dirs, fix paths, per-directory segments): pass.

  • test/diagnostics.bats: two new tests (a two-module repo with dir = "{{workspace}}" whose SARIF URIs become services/api/..., services/web/... and services/shared/util.c from ../shared; and an explicit dir via --format json). All 17 of 17 planned tests ran and passed.

  • cargo fmt --check and cargo clippy --all-targets -- -D warnings are clean.

  • Full cargo test has 16 failures, all in cli::init::detector, none touching diagnostics. I did not investigate them or confirm they also fail on main; my local pkl/Builtins.pkl was copied from the main checkout and may be stale.

  • Not verified: the x86_64-pc-windows-gnu check could not build here (the C dependencies libz-sys and aws-lc-sys fail without a cross C toolchain), so Windows behavior is covered only by the unit tests.
  • 🤖 Generated with Claude Code

    AI-assisted — Tool: Claude Code; model: anthropic/claude-sonnet-5-5; version: unavailable.

    <!-- CURSOR_SUMMARY -->
    ---

    [!NOTE]

    Medium Risk

    Touches diagnostic parsing and structured output for all steps with diagnostic_format, but behavior is additive with a fallback when segments are missing and is covered by new unit and bats tests.

    > Overview

    Fixes diagnostic file paths when a step runs with dir (including dir = "{{workspace}}"): tools still print paths relative to that directory, but hk now rebases them to the repository root in SARIF, JSON, and MCP output.

    > Each check command’s output is stored with its run directory (DiagnosticSegment), parsed per segment (so batched/workspace jobs are not merged into one invalid JSON/SARIF blob), then paths on diagnostics and fix suggestions are prefixed and normalized (./, .., \); absolute paths, drive letters, and URIs are unchanged. Steps without dir behave as before.

    > pkl/Config.pkl documents this; integration tests cover workspace SARIF and explicit sub/pkg JSON paths.

    > <sup>Reviewed by Cursor Bugbot for commit 8c6fd4db183f6a9ed8af38574a00ff7d12b07735. Bugbot is set up for automated code reviews on this repo. Configure here.</sup>

    <!-- /CURSOR_SUMMARY -->

    Diff: 528 lines (+396 / -132) across 6 files Reviewer: jdx Review duration: 61m
    All Vouch review confidence checks passed
    Residual risk 0.21 = Change Risk (0.48) × (1 − Review Confidence (0.57)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.48 · 528 lines diff across 6 files
    0.48
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    56%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.375
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #1638"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 56.8% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 47.8% (MEDIUM) · Higher = larger blast radius
    47.8%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 56.8% · Lower = rushed or shallow review
    56.8%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 20.7% · Safe to merge
    20.7%
    Repository