Skip to content

Deepen Run metrics Session evidence attribution #2082

Todo

Description

@JacobStephens2

Strength: Worth exploring · Dependencies: local-substitutable

Files: src/logs/run_metrics.rs, src/logs/metrics/trends.rs, src/logs/command_record.rs, src/session/recording.rs, tests/run_metrics.rs, tests/metrics.rs

Before

flowchart LR
  C[Completion metrics] -.-> R[Command records]
  W[Weekly trends] -.-> R
  C -.-> E[Session evidence]
  W -.-> E
  classDef leak stroke:#dc2626,stroke-width:2px;
  class C,W leak
Loading

After — opportunity to investigate

flowchart LR
  C[Completion metrics] --> A[Run metrics Session attribution]
  W[Weekly trends] --> A
  A --> R[Command records]
  A --> E[Session evidence]
  classDef deep stroke-width:3px;
  class A deep
Loading

Problem: Completion metrics and weekly trends independently associate Sessions with stages and evidence, spreading identity, first-stage ownership and setup knowledge across their implementations.

Evidence:

  • Completion metrics zip recorded stages with metric stages and deduplicate Session signals by normalized Session identity; review findings instead deduplicate literal paths.
  • Weekly trends independently reconnect metric stages to recorded stages by index, deduplicate normalized Session identities, read exact-Command Model evidence, and track Security review/Resume setup fallback.

Solution: Investigate a deep Run metrics module whose interface owns Session-to-stage attribution and evidence selection at one seam, retaining completion and weekly trends as distinct projections.

Wins

  • Locality: one attribution policy
  • Leverage: completion and weekly trends
  • Tests cross one shared interface

Why not Strong: Some rules serve different projections; the deletion test has not established that consolidation would concentrate meaningful complexity rather than move it into another shallow module.

Investigation: Prototype the attribution seam against shared Session references, former/current filename aliases, repeated Repairs, missing evidence and Security review Resumes; reject a helper that merely returns a normalized path or relocates the existing loops.

Testing: The interface is the test surface; existing completion and CLI trend regressions should survive, with temporary-file test adapters exercising attribution and evidence together and replacing duplicated private-helper tests where applicable.

Constraints: Preserve retained metric formats, read-only historical reconstruction, missing-evidence coverage, exact owning-Command Model evidence and ADR 0019/0021; the Trace ancestry module owns display ancestry and should retain that responsibility.

Priority and overlap: Recent Run metrics work expanded completion recording to Review, Triage and Fix runs (#2047); this seam now affects more callers. All 186 open issue titles and bodies were checked. No open issue proposes this deepening; #2036/#2066 change aggregation and presentation rather than concentrating Session attribution policy.

Activity

  1. added
    needs-triage
    architect-idea
    in-progress
    and removed
    needs-triage
    on Nov 12, 2026
  2. JacobStephens2 commented on Nov 12, 2026

    @JacobStephens2
    OwnerAuthor

    This was generated by AI during triage.

    Investigation summary

    Investigated #2082 against selected Base commit 287d9a9. Code inspection confirms duplicated attribution policy, but does not establish that the proposed consolidation earns its interface cost. Recommend separating the interface proof from production migration.

    Confirmed evidence

    • src/logs/recording.rs:527-543 carries the last Session reference into subsequent stages. Repeated references therefore occur by design.
    • src/logs/run_metrics.rs:54-75 pairs recorded stages with metric stages positionally and assigns Session signals once per normalized identity. Review findings instead deduplicate literal paths at lines 138-143, although src/logs/effects.rs:57-58 resolves their sidecar through the normalized identity. Former/current filename aliases can therefore pass the review deduplication independently; this is a code-derived observation, not a reproduced incident.
    • src/logs/metrics/trends.rs:282-335 independently joins stage evidence by index, deduplicates normalized Session identities, tracks Security review/Resume setup fallback, and counts each Command once per complete Session grouping.
    • These projections have meaningful differences: completion considers all recorded stage references; trends handles Session rows separately from Delivery stages and records missing observations even when a Session stage has no path. A shared interface must distinguish unreferenced, missing and duplicate evidence.
    • src/session/recording.rs:427-430 accepts Model evidence only for the exact owning Command log. Trends applies that evidence, then lets recorded Session signals refine Harness/version. Unknown Security review, its Resume, and orphan Resume setups must remain unknown where evidence is absent.
    • src/logs/run_metrics.rs:95-96 and src/logs/reading.rs:414-429,521-522 preserve historical reconstruction and retained evidence. Historical review counts and Usual ranges are not inferred from current sidecars/history.

    Proposed split

    A. Prove a Run metrics attribution interface using temporary-file evidence adapters and a behavior matrix. Explore ordered stage observations that hide positional matching, normalized identity, first-stage ownership, evidence selection and setup fallback without exposing those algorithms to both callers. Exercise shared references, former/current filename aliases, repeated Repairs, absent/corrupt evidence, no-path stages, mismatched retained stage arrays, wrong-owner Model evidence, Security review Resumes and orphan Resumes. Demonstrate which caller responsibilities disappear; reject a normalization helper or pass-through extraction.
    B. Only after A establishes depth and settles the alias policy, migrate completion and weekly trends through that interface. Keep timing, aggregation, grouping and serialization in their existing projections. Preserve retained formats, saved metrics, historical read-only behavior, missing coverage, requested-versus-observed Model distinctions and ADR 0019/0021. Trace ancestry remains responsible for display attachment and descendant ownership.

    Existing regression anchors include tests/run_metrics.rs:226,271 and tests/metrics.rs:397,465,641,660,715,1151,1267,1358. Future implementation validation should run the focused Run metrics/metrics suites and scripts/affected-tests against its Base branch.

    No matching open issue was found among 186 open issues searched by title/body. #2036 and its related Tickets address aggregation/presentation rather than this interface. Tests were inspected, not executed: this investigation confirms an architectural observation, not a reported runtime failure. No source, Git-history or GitHub changes were made.

    Questionnaire

    For the Day shift deciding how to advance #2082:

    Code inspection confirms repeated Session attribution logic, but the issue's deletion test remains unproven. The proposed scope also contains a potential behavior change: completion review counts deduplicate literal paths while Session signals normalize former/current filenames.

    1. Approve the proposed split into A, an interface prototype with the behavior matrix and explicit evidence of caller simplification, followed by B, production migration blocked on reviewing A's result? Recommended: proceed with A first and authorize B only if the prototype demonstrates depth; otherwise retain the current implementations.
    2. For former/current filenames naming the same Session, should review findings count once under normalized identity, or must literal-path behavior remain compatible? Recommended: count once, consistent with the existing first-Session ownership comment, while preserving already saved metrics. This settles whether B includes an intentional behavior correction or only structural changes.
  3. added
    enhancement
    ready-for-human
    needs-triage
    and removed
    in-progress
    on Nov 12, 2026
  4. added
    in-progress
    and removed
    ready-for-human
    needs-triage
    on Nov 25, 2026
  5. JacobStephens2 commented on Nov 25, 2026

    @JacobStephens2
    OwnerAuthor

    This was generated by AI during triage.

    Investigation summary

    Re-investigated #2082 against current Base HEAD 0d205f0; the issue cites 287d9a9. The duplicated Session attribution is still present and has grown since the cited base, but the deletion test remains unproven and consolidation must now settle observable divergences between projections. Recommend approving the split below rather than treating this as one agent-ready Ticket.

    Confirmed on current Base

    • src/logs/run_metrics.rs is unchanged since the cited commit (git diff 287d9a9..HEAD). add_session_signals (lines 54-75) zips recorded stages with metric stages positionally and deduplicates by normalized identity via super::session::original; calculate instead deduplicates review findings by literal path at lines 138-143 (sessions.insert(log.to_path_buf())), while src/logs/effects.rs:69-71 reads the review sidecar through original(log). The same Session referenced under former (.jsonl) and current (.logs.jsonl/.spans.jsonl) filenames can therefore attach review counts twice, contrary to the documented intent at run_metrics.rs:32 (only the first stage referencing a Session holds its review counts). Code-derived observation, not a reproduced incident; already-saved metrics are read back unchanged, so any correction would affect only future RunMetrics::of calculations (historical() at lines 93-97 never infers review counts).
    • src/logs/metrics/trends.rs:345-399 independently rejoins metric stages to recorded stages by index, deduplicates normalized identities (line 390), reads exact owning-Command Model evidence via SessionModels::for_session (src/session/recording.rs:427-431, rejects evidence whose command_log differs), and carries stateful Security review/Resume setup fallback (lines 348-366, ADR 0021). No-path Session stages still record a missing observation (lines 386-393).
    • src/logs/recording.rs:646-670 carries the last Session reference into subsequent stages, so repeated references occur by design; src/logs/trace/ancestry.rs owns display ancestry and first-stage attachment (Attachment, lines 35-44) and should keep that responsibility per the issue constraints.

    New since the cited base and prior triage

    • A third independent attribution implementation landed with the signal groups (Survivorship-safe efficiency, session friction, kept PR survival, and post-merge quality signals #2066, not an ancestor of the cited base): src/logs/metrics/groups.rs:1016-1042 sessions() repeats the index join, is_session filter and normalized-identity dedup. This strengthens the leverage claim (three projections, plus two variants inside run_metrics) but also adds a divergence: groups filters recorded.name == stage.name before dedup, so a name mismatch at an index counts the Session again, whereas trends dedup (lines 386-390) applies no name filter (only its setup lookup at lines 367-372 does). A shared seam must pick one mismatch semantics.
    • CommandRecord stages now record per-stage harness/model/effort for the stage's latest session (src/logs/command_record.rs:233-249, written by session_choice in src/logs/recording.rs:675-684, added 2026-11-14 after the prior triage). Trends does not use these fields and still resolves setup from the exact-owner models.json sidecar; the fields are latest-session-only and absent (serde default) on older records, so the seam design must state their precedence relative to Model evidence rather than assuming either source.

    Proposed split

    A. Prototype the attribution seam first, with temporary-file evidence adapters and a behavior matrix: shared Session references, former/current filename aliases, repeated Repairs, absent/corrupt evidence, no-path stages, mismatched retained stage arrays (including the trends-vs-groups name-mismatch divergence), wrong-owner Model evidence, Security review Resumes and orphan Resumes. The interface must hide positional matching, normalized identity, first-stage ownership, evidence selection and setup fallback, and demonstrate which responsibilities disappear from run_metrics, trends and groups; reject a normalization helper or pass-through extraction.
    B. Only if A demonstrates depth, migrate completion metrics, weekly trends and signal groups through the seam as distinct projections, keeping timing, aggregation, grouping and serialization in place. Preserve retained metric formats, read-only historical reconstruction, missing-evidence coverage, requested-versus-observed Model distinctions and ADR 0019/0021. Regression anchors: tests/run_metrics.rs:226-271 (first-stage review counts, missing summaries) and tests/metrics.rs:397,465,641,660,715,1151,1267,1358-1362; validate with the focused run_metrics/metrics suites and scripts/affected-tests against the implementing Base.

    Decisions for the Day shift

    1. Approve A as a standalone prototype and gate B on reviewing its result (recommended), or authorize A+B together?
    2. Alias policy: count review findings once per normalized Session identity (recommended, matching run_metrics.rs:32 and trace ancestry first-stage attachment; affects only future calculations), or preserve literal-path counting as compatible behavior?
    3. Mismatched retained stage arrays: adopt the groups name-check semantics, the trends index-only dedup, or treat mismatch as missing evidence in the seam?
    4. Should the seam read the new per-Stage harness/model/effort as setup evidence, and with what precedence versus exact owning-Command models.json on records that have both or neither?

    No duplicate found: all 203 open issue titles were listed and searched for attribution/session-evidence/metrics terms; #2087 (Fleet signal groups across machines), #1655 and #1639 touch neighbouring metrics behaviour but do not propose this attribution seam. Tests were inspected, not executed - this confirms an architectural observation and code-level divergences, not a reproduced runtime failure.

  6. added
    ready-for-human
    and removed
    in-progress
    on Nov 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-ideaenhancementready-for-human

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions