← Back to Pull requests

fix(web): make the diagnostic manifest describe the archived sections #8085

Closed
unknown closed this pull request without merging on Oct 25, 2026 01:11 UTC
View on GitHub
unknown unknown commented on Oct 24, 2026 04:46 UTC
Author

Fixes #8023

<!--
Thank you for proposing a pull request. This template will guide you through the essential steps necessary for a pull request.
-->
Make sure that:

  • You have read the contribution guidelines.

  • You submit test cases (unit or integration tests) that back your changes.

  • Your local test passed ./mvnw clean install -Dmaven.javadoc.skip=true.
  • ---

    Problem

    DiagnosticBundleWriter serialised manifest.json before applying the archive-wide section budget, then cut section bytes with maxTotalBytes without updating the already-written manifest. For a small configured total:

  • a section could be archived truncated or empty while the manifest still reported OK with its original sizeBytes;

  • manifest.json itself was not counted against maxTotalBytes, although DiagnosticProperties#getMaxTotalBytes documents the value as the maximum total uncompressed bundle size.
  • Changes

    shenyu-web/.../diagnostics/DiagnosticBundleWriter.java

  • Plan the archive before writing it: cap each section at maxSectionBytes, render the manifest from that plan, trim the plan until manifest.json plus all sections fit maxTotalBytes, and re-plan until the plan and the manifest agree (a trimmed section changes its own summary).

  • Sections cut by the total budget are archived as TRUNCATED with reason total budget truncated; sections that receive no allowance are SKIPPED with reason total budget exhausted and an empty entry. Neither is ever reported OK. Every section keeps its deterministic entry name, so the manifest remains a complete index.

  • A section already cut by maxSectionBytes keeps that reason when the total budget cuts it further (section size cap; total budget truncated).

  • A budget too small to hold the mandatory manifest throws IllegalStateException naming the configured value instead of silently exceeding the advertised bound.

  • Trimming lands on UTF-8 sequence boundaries so a cut section is still decodable.
  • DiagnosticManifest.java: add withSections(List<DiagnosticSection>) so the writer can describe the planned sections without mutating the collected manifest.

    DiagnosticProperties.java: document that the bound covers every uncompressed entry including the manifest, and what happens when it is smaller than the manifest.

    Validation

    shenyu-web module, offline, with checkstyle enabled:

    mvn -pl shenyu-web test -Dtest='org.apache.shenyu.web.diagnostics.*Test' \
        -Djacoco.skip=true -Dmaven.javadoc.skip=true
    

  • Tests run: 25, Failures: 0, Errors: 0, Skipped: 0 — all diagnostics tests, including the untouched service, redactor, digest-collector and endpoint tests.

  • DiagnosticBundleWriterTest: 10 tests, up from 5. The five new ones cover total-budget truncation, full budget exhaustion across 8 sections, multibyte cuts, a complete bundle at exactly the budget, and a budget below the manifest.

  • Regression evidence: with only the new tests applied to the current master writer, 3 of them fail — manifestDescribesTheArchivedContentAfterTotalBudgetTruncation, exhaustedTotalBudgetSkipsSectionsInsteadOfReportingOk, budgetSmallerThanTheManifestFailsExplicitly. They pass with the fix.

  • The full clean install was not run locally (the module was built and tested directly); CI covers the reactor build.
  • Behaviour changes worth noting

  • An archive whose sections were previously silently short now reports TRUNCATED/SKIPPED, and its sizeBytes match the archived entry length. Consumers that treated every section as parseable JSON must check status — which the format already required.

  • A configuration whose max-total-bytes cannot hold the manifest now fails bundle export with IllegalStateException rather than returning an over-budget archive. The default is 4 MiB, so this only affects deliberately tiny values.
  • Out of scope

    Section collection timeout enforcement and the per-section cap semantics are unchanged; this PR only makes the archive and its manifest agree and enforces the documented total bound.

    Diff: 515 lines (+386 / -129) across 6 files Reviewer: yuluo-yx Review duration: 1224m
    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 · 515 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.374
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #8085"
    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.7% (MEDIUM) · Higher = larger blast radius
    47.7%
    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.6% · Safe to merge
    20.6%
    Repository