Skip to content

Deepen Security finding recording behind one interface #610

Closed

Description

@JacobStephens2

What to build

Deepen the Security finding record module so a Security run and a Security review record or reuse a finding through one interface. That module owns fingerprint matching, storage-specific decoding, creation, remembering the created record, and notification-safe metadata. Callers receive a typed record and whether it was created; they no longer assemble lookup/create/decode/remember themselves.

The observable behavior stays the same: one private record per fingerprint within the loaded record collection, the Day shift's grades and write-ups survive repeated findings, and notifications contain only severity, title, and private link.

Acceptance criteria

  • One record-or-reuse operation owns the complete fingerprint lookup, optional creation, validation, and successful cache insertion protocol. Both Security run recording and Security review recording use it; the separate caller-facing lookup/conversion/remember protocol is removed.
  • Security runs, Security reviews, and the production Pass interface exchange typed records and metadata instead of raw JSON records. Advisory/issue field names and metadata decoding live in the record module and its adapter implementation. Storage identity remains opaque to callers, with a typed private-issue-number query for the existing fix-publication behavior.
  • Duplicate fingerprints in a single report invoke creation once. Existing records match in every state and are returned unchanged. The created/existing result drives the existing counters and progress messages. Successful creation is cached only after its record and notification metadata validate; a failed lookup, create, or decode returns an error without claiming successful insertion or rolling back remote effects.
  • Preserve the caller distinction: a Security run may reproduce a reused untriaged record once per fingerprint, while a Security review updates reproduction evidence only for a newly created record. Keep the audit's per-fingerprint reproduction deduplication and notification list ordering/counts.
  • Preserve storage selection, pagination and all-state matching, fingerprint marker format, grading and disclosure rules, fix selection and links, repository ownership checks, update reobservation checks, informational-grade handling, partial-failure notifications, and safe diagnostics. Unused malformed historical records do not gain eager validation failures.
  • Tests through the shared interface cover both storage formats, new and repeated fingerprints, every existing state, Day shift grade preservation, safe metadata, and creation/decoding failures. Retain existing end-to-end Security run and Security review coverage, including a review-created record consumed by a later Security run; replace tests that only assert deleted lookup/create/remember choreography.
  • Formatting, Clippy with warnings denied, and the full test suite pass. No new domain term or ADR is required by this design.

Blocked by

None (can start immediately).

Decisions

The design tree is settled in three rounds. Each round settles the frontier whose prerequisites are complete; no design decision remains for the Day shift.

Round 1 — scope and constraints

  1. Deepen the existing Security finding record module, rather than redesign Pass or session execution. The friction is two callers assembling the same recording protocol, plus storage decoding reaching back into Security run metadata. Concentrating those responsibilities gives locality and leverage at the existing seam. Audit sessions, reproduction sessions, review report validation, and fix dispatch remain caller responsibilities because they have different policies.
  2. Preserve existing behavior and ADR 0015. Public repositories still use draft advisories; issue fallback still requires confirmed repository privacy after the existing unavailable-advisory response. Keep fingerprint and reproduction text formats, Day shift authority, late update checks, and diagnostic privacy. This is a refactor of recording knowledge, with no new grading or disclosure decision. Open issue Decide how informational Security findings map to repository advisories #567 still owns the informational advisory-grade question; Security review: surface the session's reason when it deliberately ends incomplete #607 owns incomplete-review reporting. Neither proposes this deepening.
  3. Publish one standalone Ticket. The change is one shared operation and typed data migration across two recording callers and their existing adapters/tests, which fits one fresh context window. It has no blockers, requires no separate prefactoring Ticket, and yields a complete verifiable change. Creating a Spec would add scheduling overhead without an independently useful slice.

Round 2 — interface and implementation, depending on decisions 1–2

  1. Use opaque record collection and record snapshots. Keep transport JSON, storage identity, and existing lazy decoding behind the record module. A successfully resolved record exposes the description, untriaged status, display name, reproduced fix size, and safe metadata that current callers actually need. Expose a typed optional private-issue number for fix publication. Keep the existing collection gate/fix-selection operations. Validate notification fields at recording and fix-selection points that already need them; update reobservations retain their existing identity/description/triage checks. This removes storage layout from callers without introducing eager rejection of unrelated historical entries or a new domain concept.
  2. Make record-or-reuse the recording interface. It takes a candidate draft and a creation callback. First search all loaded records by the exact existing fingerprint marker. Return a validated typed snapshot and existing on a match without invoking creation or altering it. Otherwise invoke creation using the collection's selected storage, validate the resulting snapshot and safe metadata, remember it, and return created. Cache reuse is local to the loaded collection, as today; there is no new cross-process uniqueness guarantee. This replaces caller ordering constraints with one implementation.
  3. Keep creation as a narrow internal seam, using existing adapters. The production callback delegates to the existing GitHub/gh creation adapter; Pass tests supply their existing in-memory adapter. Change their creation result to a typed record snapshot, with native-response decoding owned by the record module. Test fixture construction may use native JSON inside the adapter fixture, but production caller interfaces may not. A callback avoids another public trait or tracker abstraction; the production and test adapters already justify this seam.
  4. Move notification metadata projection into the record module. The projection contains only severity, title, and URL, preserving the current advisory-summary/private-issue-title rules. Keep the existing outward metadata type name available through a re-export if needed. Fix selection applies its existing current-grade precedence to this projection. This removes the record module's dependency on Security run decoding and keeps private descriptions out of notification data.
  5. Retain failure ordering and remote effects. Validation precedes cache insertion and successful counters; errors stop the current caller through its existing failure path. A failed create/decode is never treated as reused or successful, and remote records already created are not deleted. Continue delivering metadata for findings successfully reached before a later failure. Existing update operations still reobserve the record before writing. These choices preserve the factory's current recovery and privacy contracts.

Round 3 — callers, verification, and documentation, depending on decisions 4–8

  1. Migrate both callers while keeping their distinct reproduction policies. The Security run uses the result for its created/existing counters, then preserves untriaged checks, per-fingerprint reproduction deduplication, progress, and metadata updates. The Security review writes reproduction evidence only on created; existing leaves evidence and grade unchanged even if still untriaged. Reproduction and fixing consume typed queries instead of inspecting storage variants. Sharing recording policy must not merge these intentionally different caller decisions.
  2. Use the interface as the test surface. At record-or-reuse, scripted creation callbacks assert observable results and creation count for advisory and private-issue fixtures, including repeated drafts in one collection, existing records in every state, preserved grades/write-ups, safe metadata, malformed selected records, and create/decode failures. Include an unused malformed historical entry to verify lazy behavior survives. These tests exercise the invariant callers rely on rather than private JSON helpers or internal container layout.
  3. Retain end-to-end adapter and caller verification. Keep the real-Git/fake-gh/fake-Harness scenarios for audit reuse, review reuse, privacy fallback, triage during reproduction, partial failure metadata, informational advisory rejection, and review-to-Security-run handoff. Extend only gaps exposed by the shared interface and delete tests solely coupled to removed choreography. The existing gh adapter and CLI fixture prove the interface is wired into both entry paths.
  4. Use existing domain language and require no documentation migration. Security finding, Security run, Security review, and Day shift already name this responsibility in the domain model. The refactor is reversible, introduces no new policy, and contradicts no ADR, so it needs neither a new domain term nor a new ADR. Any incidental documentation correction discovered during implementation belongs in this Ticket's pull request; this review changes no domain documents.

Review validation: At detached main commit d2f2faf7fe4a7586d4f15118891a2220791a6736, CARGO_BUILD_JOBS=2 cargo test --test security_run --test security_review fingerprints passed both existing fingerprint-reuse tests (2 passed, 0 failed). They exercise advisory and private-issue review reuse across states, grade preservation, and repeated audit creation. This verifies the current contracts; the shared interface is planned work, not an implemented or tested refactor.

Architecture review

Strength: Strong · Dependencies: mock

Files: src/github/advisories.rs, src/github.rs, src/security.rs, src/security/review.rs, src/security/fixing.rs, src/pass.rs, tests/security_run.rs, tests/security_review.rs

Before

flowchart LR
  Run[Security run] --> Records[Security finding records]
  Review[Security review] --> Records
  Run -. lookup create decode remember .-> Records
  Review -. lookup create decode remember .-> Records
  Records -. metadata decoding .-> Run
  Records --> Adapter[GitHub adapter]
  classDef leak stroke:#dc2626,stroke-width:2px;
  class Run,Review leak
Loading

After

flowchart LR
  Run[Security run] --> Records
  Review[Security review] --> Records
  subgraph Records[Security finding records]
    Resolve[Record or reuse] --> Decode[Typed record and safe metadata]
    Resolve --> Remember[Remember successful creation]
  end
  Resolve --> Adapter[GitHub adapter]
  classDef deep stroke-width:3px;
  class Records deep
Loading

Problem: The recording interface is shallow because Security runs and Security reviews repeat its ordering constraints, while record metadata leaks across the seam.

Solution: Deepen the Security finding record module by moving lookup, creation, decoding, remembering, and safe metadata into its implementation behind one recording interface and the existing adapter seam.

Wins

  • Depth: one recording interface
  • Locality: storage knowledge stays together
  • Leverage: both callers share recording
  • Tests cross the recording seam

Deletion test: Deleting the separate lookup/conversion/remember interface concentrates complexity in one implementation; deleting that deep implementation would force the recording protocol back into both callers.

Activity

  1. added
    needs-triage
    ready-for-agent
    architect-plan
    in-progress
    and removed
    needs-triage
    ready-for-agent
    on Oct 10, 2026
  2. removed
    in-progress
    on Oct 10, 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