Skip to content

Deepen retained pull request attribution across Scoring and Run metrics #1311

Closed

Description

@JacobStephens2

What to build

Make Scoring samples, Bug-origin proposals and settlements, and read-time Run metrics use one retained pull-request attribution module. They must agree on which retained Command a pull request belongs to, including across Continuations and nested Ticket runs.

The current Scoring lookup compares timestamps as text and pull-request URLs exactly, while Run metrics compares actual times and normalized URLs. For example, a Command started at 11:00Z must be selected ahead of one started at 12:00+02:00 on the same date. Changing a repository URL's letter case or adding a trailing slash must not change attribution. A saved local Command identity must continue to select that exact Command.

Review evidence on main e48adc9e: two throwaway tests through the existing retained lookup both failed as expected. With 2026-10-19T12:00:00+02:00 and 2026-10-19T11:00:00Z, it selected the former, older Command; querying https://github.com/ACME/WIDGETS/pull/23/ for a retained lowercase URL returned no match. The temporary tests were removed after verification. The guide already promises that latest-local selection agrees between Scoring and metrics.

Acceptance criteria

  • One module owns retained pull-request matching, chronological latest selection, and exact saved identity selection. Scoring's sampled record links, Bug-origin proposal/settlement attribution, and Run metrics all delegate to it; the independent tree scan and selection rules in metrics are removed.
  • Latest selection compares parsed RFC 3339 instants, including different UTC offsets. Matching ignores ASCII letter case and trailing slashes. Equal instants are resolved by greatest lexical record path, then greatest record name; an unparseable start time sorts before every valid time.
  • Exact selection requires both the saved lexical record path and record name under the matching pull request. A missing or mismatched saved identity returns no match and never falls back to another Continuation. Absent local attribution and cross-host attribution continue to use latest selection.
  • Root Commands, embedded dispatched Commands, nested Ticket runs and Base fixes retain their existing membership and exact identities. Commands sharing a record path remain distinct by name. No new kind or outcome filter is introduced, and orphaned or unmatched child records are not admitted.
  • Scoring's existing capture timing, Built-with fallback, retained JSON fields and write behavior remain intact. Metrics reuse their captured Commands, keep latest-Scoring-window settlement rules and their lightweight Scoring decoding, and neither contact GitHub nor rewrite records.
  • Tests through the shared selection interface cover normalization, offset-aware ordering, equal-time ordering, invalid times, exact pins, and nested/dispatched ownership. Command regressions show that Scoring attribution and Run metrics agree, including one Bug-origin count across Continuations and no fallback for an unavailable local pin. Existing Scoring, Bug-origin and metrics coverage stays green; run the repository's affected-test selector against main.
  • Update the domain-to-code navigation to name the shared owner. Document matching and chronological selection where the guide and hand-written site describe Scoring and Bug-origin counts, correcting all affected claims in the same change.

Blocked by

None (can start immediately).

Decisions

The design tree is settled in three rounds: ownership and inputs; selection rules and identity; integration, compatibility and verification. No human decision remains.

  1. Own selection in the log-reading module. Its interface offers latest attribution for a pull request and exact attribution for a pull request plus a saved identity. A private in-process index absorbs traversal, normalization and ordering. Scoring owns its packets and origin settlements; metrics owns joining those settlements to counts. This gives depth without moving unrelated Scoring storage rules.
  2. Use the existing captured Commands as input. Build the index from a Snapshot, retaining only the pull-request identity, exact Command identity and parsed start needed for selection. The existing single-pull-request lookup is the filesystem adapter: it captures at its current call point and delegates. Metrics builds the index from its existing Snapshot. This preserves freshness and avoids a second reader or repeated filesystem work within the metrics projection.
  3. Preserve acquisition and membership. Reuse Snapshot's existing root, child and dispatch assembly rather than flattening discovered files. Keep all currently eligible Command kinds and outcomes, including Spec runs and Base fixes. This preserves real ownership rules and avoids admitting orphaned children. A metadata-only loader and batching captures across long Grader or Bug-origin sessions are outside this Ticket.
  4. Represent exact identity with lexical record path and record name. Neither field alone suffices because dispatched Commands share their outer record path. Do not canonicalize paths or infer identity from timestamps, issue numbers or pull-request URLs. Keep the existing serialized local-attribution shape.
  5. Normalize only pull-request identity for this selection. Remove trailing slash characters and fold ASCII case, matching the existing metrics rule. Do not add network resolution, redirects or filesystem canonicalization. The existing metrics rule already defines the required matching behavior.
  6. Make latest mean chronological latest. Order by parsed RFC 3339 time, then lexical record path, then record name, taking the greatest tuple. Invalid times sort before valid ones and still have deterministic path/name ordering. This adopts metrics' existing behavior and fulfills the documented promise that metrics and Scoring choose the same latest local Command.
  7. Keep an exact saved identity authoritative. Exact selection must also belong to the normalized pull request. If its path/name pair is unavailable or belongs to another pull request, return no match. Do not substitute the latest Command: doing so would move a confirmed Bug origin to another Continuation. Only absent or nonlocal attribution uses latest selection.
  8. Preserve caller behavior around selection. Keep Scoring's current capture points, packet and assessment checkpoints, and Built-with fallback. Keep metrics' partial Scoring decoder, latest-window origin decisions, and error behavior. Existing single-lookup convenience functions may delegate to the new module; callers must not retain their own selection implementation. This change does not require new flags, persisted data, locks or a global cache.
  9. Test the interface, using existing adapters. Selection tests exercise captured Command fixtures; temporary filesystem fixtures exercise the existing reader adapter and exact parent/dispatch membership. No new dependency trait is justified. Replace any isolated selection-helper tests with interface tests rather than adding duplicate verification of the same implementation.
  10. Keep command tests for integration. Extend the existing fake-Harness Scoring/Bug-origin regressions and read-only metrics regressions to prove both callers choose the same identity. Include mixed offsets, URL variants, multiple Continuations, two dispatched names sharing a path, a missing local pin and a local pin attached to the wrong pull request. Assert saved attribution and displayed counts rather than inspecting the private index; metrics reads must leave record bytes unchanged and make no remote reads.
  11. Keep the work to one Ticket. Selection, its two integrations, documentation and focused regressions form one verifiable change that fits one fresh session. There are no blocking edges. Existing glossary concepts suffice; no glossary definition or ADR change is required because this is a reversible consolidation consistent with exact Command ownership and the Console's read-only rule.

Architecture review

Strength: Strong · Dependencies: in-process

Files: src/logs/reading.rs, new private attribution module under src/logs/reading/, src/logs.rs, src/logs/metrics/bug_origins.rs, src/scoring.rs, src/scoring/origins.rs, src/scoring/origins/settlement.rs, src/logs/reading/tests.rs, tests/scoring.rs, tests/bug_origins/settlement.rs, tests/metrics.rs, docs/code-navigation.md, docs/guide.md, site/index.html, site/how-it-works/index.html, site/architecture/index.html.

Before

flowchart LR
  S[Scoring] --> A[Scoring attribution]
  O[Bug origins] --> A
  M[Run metrics] --> B[Metrics attribution]
  A --> C[Captured Commands]
  B --> C
  A -. divergent selection .-> B
  classDef leak stroke:#dc2626,stroke-width:2px;
  class A,B leak;
Loading

After

flowchart LR
  S[Scoring] --> D
  O[Bug origins] --> D
  M[Run metrics] --> D
  subgraph D[Retained pull-request attribution]
    A[Latest selection]
    B[Exact selection]
  end
  D --> C[Captured Commands]
  classDef deep stroke-width:3px;
  class D deep;
Loading

Problem: Shallow attribution modules leak traversal, URL identity and contradictory time ordering across the same seam, although the guide promises agreement.

Solution: One deep module gives both callers a shared selection interface; its implementation owns matching and ordering while the existing filesystem adapter supplies captured Commands.

Deletion test: Removing this module would scatter identity, traversal and ordering knowledge back across Scoring, Bug origins and metrics; its depth concentrates real behavior.

Wins

  • Locality: selection changes together
  • Leverage: one interface across callers
  • Exact identities survive Continuations
  • Tests cross the shared seam

Covered by: None among 111 open issue title/body pairs checked.

ADR compatibility: Existing Command ownership, stored kinds and read-only views are preserved.

Activity

  1. added
    needs-triage
    ready-for-agent
    architect-plan
    in-progress
    and removed
    needs-triage
    ready-for-agent
    on Oct 25, 2026
  2. removed
    in-progress
    on Oct 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    architect-plan

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions