← Back to Pull requests

spec(draft): reduce required hook context (proposal and implementation) #270

Open
unknown opened this pull request with 544 lines diff across 6 files
View on GitHub
unknown unknown commented on Dec 02, 2026 00:09 UTC
Author

<!-- copilot-assessment:v1 -->

Agent assessment

Self-reported assessment, not an independent review.

Assessed revision: 7aaa64474ba8b5b1e46f08079b42b733e5a7aa05

| Dimension | Assessment | Rationale |
|---|---|---|
| Change confidence | 8.5/10 | ↑ Local .NET restore, format check, warnings-as-errors build, 101 required tests, and 211 draft tests pass.<br>↑ Fork and upstream CI pass, including .NET cross-platform, schema generation, draft tests, and SDK checks.<br>↑ Released spec/0.1/ and conformance/0.1/ remain unchanged.<br>↓ Shared CTK vectors AH-CTK-001/003 still assert the removed context.sequence; .NET identifies them as stale rather than rewriting the shared suite. |
<!-- /copilot-assessment -->

Summary

Combines the required-context proposal and its draft schema implementation (previously split across CaitieM20/agent-hooks#16 and CaitieM20/agent-hooks#18 on the fork).

Re-evaluate common hook context so implementers do not have to invent values that their execution layer cannot meaningfully provide:

  • Remove sequence, agent.id, agent.name, session., tenant., actor., budgets., and the unused ActorKind enum. No separate identity object, token field, or replacement claims are introduced.

  • Keep authenticated agent, caller/user, and tenant identity, roles, claims, and credentials outside hook context. When needed, identity is established through verified tokens handled by the host or remote endpoint's authentication layer—not request metadata.

  • Retain spec, interception_point, timestamp, agent.framework, optional agent.version, and optional trace identifiers. Framework/version describe the invoking runtime; runtime and trace metadata are not authentication or authorization evidence. extensions remains on HooksRequest; budgets remain an extension concern without a defined namespace in this change.

  • Remove session_id and sequence from the draft InterceptionRecord as well, rather than inventing host-assigned substitutes.
  • Included implementation

  • Proposal: docs/proposals/P-270-hooks-required-context.md.

  • Draft TypeSpec context and interception-record sources, regenerated JSON Schemas and C# draft contracts, and updated draft examples.

  • Normative draft text: §3.1 sequence invariant removed; §4.1 core reduced; §10.2 required-context projection updated; §10.3 record fields and projection-failure rule updated; §12.2 atomic-sequence ordering rule removed.

  • The jcs-sha256 projection changes for every draft context because agent.id, session.id, and sequence no longer participate.
  • spec/0.1/ and conformance/0.1/ remain unchanged. Authentication integration, token profiles, and configured hook failure handling are not redesigned here.

    .NET SDK migration and remaining follow-up

    The .NET SDK and its tests now match the reduced draft context. RecordHostFailure no longer accepts sessionId or sequence; emitted records no longer carry those fields. The reference harness stamps only the required context, and context identity no longer requires sequence.

    Draft CTK vectors AH-CTK-001 and AH-CTK-003 still assert context.sequence. The .NET conformance suite records them as stale for that specific reason; the shared vectors were left unchanged to avoid expanding this focused PR across SDK conformance fixtures. The docs-site record guide and other handwritten SDK adaptations remain follow-up work.

    Open design considerations

  • Without session_id/sequence, the draft no longer defines a total audit order or session-level record correlation. Timestamp and optional trace remain; a replacement mechanism or record-sink responsibility is not defined here.

  • "Session" remains a lifecycle concept in §3 and §12.2 without a wire identifier.

  • Budgets are removed from core metadata; a standardized extension namespace remains future work.
  • Checks

  • dotnet restore, dotnet format --no-restore --verify-no-changes, and dotnet build --no-restore -warnaserror pass.

  • .NET tests pass: 101 required and 211 draft tests.

  • Fork and upstream CI pass on this head, including .NET (Linux/macOS/Windows), draft tests, schema checks, and all SDK checks.

  • check-file-headers.py passes (184 files checked); released 0.1 spec and conformance files are unchanged.
  • Diff: 544 lines (+408 / -136) across 6 files Reviewer: MohammadHaroonAbuomar Review duration: 3895m
    All Vouch review confidence checks passed
    Residual risk 0.30 = Change Risk (0.53) × (1 − Review Confidence (0.43)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.53 · 544 lines diff across 6 files
    0.53
    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%
    42%
    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.377
    Shallow Review Depth shallow_review_depth
    0.344
    Ai Authored ai_authored
    0.050
    Real PR Conversation Timeline
    1 comments
    "Review active on #270"
    general weight: 0.35
    Assignees
    Unassigned
    Labels
    risk: low confidence: 43.0% 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: 53% (MEDIUM) · Higher = larger blast radius
    53%
    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: 43.0% · Lower = rushed or shallow review
    43.0%
    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: 30.2% · Safe to merge
    30.2%