← Back to Pull requests

Let reference resolvers choose their trigger character (0.4.0) #13

Closed
unknown closed this pull request without merging on Nov 05, 2026 16:54 UTC
View on GitHub
unknown unknown commented on Nov 05, 2026 16:36 UTC
Author

Summary

Users of the package can now designate the character that starts a reference and which resolver(s) it is used for.

  • ReferenceResolver.trigger: ClassVar[str] = "#". Set trigger = "!" and that kind is typed as !0004. Defaults to #, so existing hosts are unchanged.

  • Validation at registry build time: one character that is not a word character or whitespace (InvalidReferenceTriggerError), and not @ / < / > (ReservedReferenceTriggerError). Both carry resolver / trigger in context.

  • Several resolvers may share a trigger. ReferenceRegistry.triggers lists them. search(..., trigger=) and resolve_codes(..., trigger=) ask only resolvers with that trigger; settings order still breaks ties within a trigger.

  • Stored tokens stay <#kind:id>, so there's no migration, old messages keep rendering, and a host can change a trigger later.

  • Reference gains trigger and typed (!0004). The REST API and websocket JSON include trigger. label() defaults to trigger + code. The unavailable placeholder uses the kind's trigger (!unavailable, !unavailable-N when editing), so ADR-0011's keep-on-edit works for every trigger.

  • Composer: composer_fields.html renders data-reference-triggers, huddle.js builds its pattern from it (character-class escaping, u flag), sends ?trigger= to the search view, and inserts picks with data-trigger. The search view and API references/ endpoint accept ?trigger= (absent means every resolver, as before).

  • Example project: Milestone model and a !M1 MilestoneResolver.

  • Version 0.4.0, CHANGELOG, README section "Choosing the trigger character", ADR-0014.
  • Internal shape change (not documented API): MessageMarkup takes the registry, reference_codes() became typed_references() (returns #T1), and encode()'s references are keyed by the typed form, because #T1 and !T1 can name different objects.

    Tests

    tests/test_reference_triggers.py covers: unchanged defaults; invalid and reserved triggers; validation from settings; shared triggers; each trigger resolving only its own kind; the same code under two triggers; picks with a custom trigger; prose with ! (done!, !!!, really?!, wow!M1, ! M1, …) never reaching resolve_code; forged tokens; placeholders and keep-on-edit with !; changing a trigger after messages exist; HTML escaping of the trigger; the composer attribute; and per-trigger search in the view and API.

    pytest (221 passed), tox -f py314 (Django 6.0 + 6.1), pre-commit run --all-files.

    Release

    Do not merge until approved. After merging: tag v0.4.0 to publish. Comply 100 has a draft PR that depends on 0.4.0.

    Diff: 337 lines (+252 / -85) across 4 files Reviewer: BenA-SA Review duration: 17m
    All Vouch review confidence checks passed
    Residual risk 0.17 = Change Risk (0.42) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.42 · 337 lines diff across 4 files
    0.42
    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%
    60%
    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.348
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #13"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% 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: 42.2% (MEDIUM) · Higher = larger blast radius
    42.2%
    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: 60.5% · Lower = rushed or shallow review
    60.5%
    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: 16.7% · Safe to merge
    16.7%