← Back to Pull requests

feat(chat): report the partial turn when the authoring gate refuses a chat extraction (#3514) #3518

Open
unknown opened this pull request with 389 lines diff across 4 files
View on GitHub
unknown unknown commented on Nov 05, 2026 14:36 UTC
Author

Refs #3514 (the server symptom; leaves hadron-portal#916 open, the portal slice follows). Gate: CHECKED 6660454838 (T2), contract folded by Patrick.

Carrier (the PR names it, per the acceptance)


Typed error extensions, with the existing code, not nullable fields on ChatResponseResult. The call still fails exactly as before (AUTHORING_ATTESTATION_MISSING / AUTHOR_TASK_BROKEN keep code and role), so no client that treats an error as a failed turn changes behavior, and no success shape moves. A refused extraction now adds:

extensions.partialTurn = {
  persisted: ["ASSISTANT_MESSAGE", "MESSAGE_COUNTER"],
  refused:   [{ "component": "EXTRACTION", "code": "<the existing reason>" }],
  notRun:    ["STAGE_PROGRESSION"]
}

Fixed component names and the existing refusal code only: no id, task, revision or count, nothing the caller could not already read.

What changed


  • src/lib/chatPartialTurn.ts: the report and reportPartialTurn, which labels only AuthoringAttestationError; any other error (lock timeout, database fault) passes through as the same object.

  • resolvers.mutation.chat.ts: the extraction transaction ends .catch(reportPartialTurn). Nothing else moves: the assistant append and the target write stay separate transactions, the gate is untouched.

  • typeDefs.ts: the mutation's description says it is NOT atomic, names the report, and says repeating the call may append another assistant message. No retry-safety claim.
  • Tests (red first)


    resolvers.chatPartialTurn3514.test.ts, 9 pins. At the fix head, before the change, cases 2 and 3 and the disclosure, label and SDL pins fail for the missing report (re-verified there, not assumed from 410d5212); cases 1, 4 and 5 and the non-refusal error pass on main and stay green. Chip's matrix: case 2 (missing claim) and case 3 (not-runnable required task) each assert code, the full report, one more assistant row, counter +1, stage unchanged, target data and revisions untouched; cases 1, 4, 5 assert the success shape (exact key set) with no report.

    Mutants (each turns red): persisted/notRun swapped (3 pins), wrong refused component (3), wrong refused code (3), counter dropped from persisted (3), label every GraphQLError not only the attestation refusal (1), remove the .catch (3).

    Also green: 8 neighbouring chat/attestation/MCP files (216 tests), tsc, SDL/enum/hash-doc/loc-scope/cross-parent guards.

    Freeze condition (not met yet)


    Condition 6: Vera confirms cor:cht:020:01 step 2 and cor:acl:010:03 fit or rule n/a, and says whether step 2 needs a Proposed sentence on partial outcomes. I will not freeze until that is on the record.

    Limits


    No stack run (QA seat does the wire matrix). The report covers the typed attestation refusal only; a non-typed fault after the append is the generic internal error as before.

    Review plan T2: cross-family (non-Claude) LOCAL and BLIND, §10 scoped to "gate semantics unweakened, no disclosure leak in the partial report", QA on the wire matrix on a disposable stack; UX waived.

    🤖 Generated with Claude Code

    Diff: 389 lines (+291 / -98) across 4 files Reviewer: claude[bot] Review duration: 13m
    All Vouch review confidence checks passed
    Residual risk 0.35 = Change Risk (0.66) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.66 · 389 lines diff across 4 files
    0.66
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    46%
    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.357
    Shallow Review Depth shallow_review_depth
    0.344
    Sensitive Paths sensitive_paths
    0.066
    Real PR Conversation Timeline
    1 comments
    "Review active on #3518"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: medium confidence: 46.7% reviewed sensitive_module
    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: 66.3% (HIGH) · Higher = larger blast radius
    66.3%
    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: 46.7% · Lower = rushed or shallow review
    46.7%
    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: 35.3% · Moderate risk
    35.3%