Skip to content

Deepen Security fix publication behind one testable interface #716

Closed

Description

@JacobStephens2

What to build

Deepen the Security fix publication module so its complete protocol can be exercised through one internal interface: from an existing private finding or a publishing session's raw final message to the validated, labelled Issue URL. Keep the Security run's existing publishing interface and observable behavior.

Today production already gets one useful publishing interface, but local tests mostly call private parsers and a validation callback. Checking how validation, creation, native links, sweeps and readiness interact requires the whole CLI fixture. The recently changed publication protocol should have one place to change and verify those interactions.

Acceptance criteria

  • Both private Single reuse and the post-session path call one private publication operation. It handles all four existing flows: private Single, private Spec, public Single and public Spec. The existing caller still receives the same Issue URL/error and optional Session log.
  • The operation owns proposal parsing, public-text checks, issue observations, staged creation, native sub-issue and blocking links, publication-window sweeps, child checks and readiness edits. Production and scripted in-memory adapters supply its GitHub effects and interruption observations through one private seam.
  • Existing proposal grammar and errors remain: public Single and Spec require staged text; a bare issue URL is rejected; titles and bodies must be nonempty; Spec blockers name earlier Tickets only, retain deduplication, and reject malformed multiline trailers, self, forward and cyclic edges. Every staged title/body is checked before any staged issue is created.
  • Preserve parent and child eligibility checks, repository identity, creation-time comparisons and case-insensitive label rules. Every child passes validation before any child receives security-fix; the parent readiness edit remains last.
  • Preserve the public precreation sweep and the additional public Spec postlinking sweep. Staged Spec issues are excluded from that second sweep. Side-effect issues are closed in order; a close failure stops and propagates immediately; successful closes are followed by the existing error naming their issue numbers.
  • Preserve interruption and partial-failure behavior: the check immediately before parent readiness stays after child tagging; failed reads, creation, linking and label edits stop further work and retain already completed effects. In particular, a failed postlinking sweep does not introduce rollback or closing of the validated staged Spec and its Tickets.
  • Worktree acquisition/disposal, Session policy and lifetime, Resume, log attribution, credential handling and the existing clock sampling remain in the publishing shell. Private Single still creates no Worktree or publishing session; a failed publishing session performs no publication sweep.
  • Replace helper-only publication tests with tests through the common operation using raw proposals and real record/label rules. Cover successful flows, malformed input, rejection before creation, invalid children before tagging, interruption, sweep exclusions and failures during creation, linking, closing and readiness. Assert returned outcomes, issue/graph/label state and meaningful ordering of effects.
  • Retain the CLI regression coverage for all Harnesses' unauthenticated publishing and Resume, staged Single/Spec publishing and dispatch, private Single/Spec reuse and Session logs. The focused publication tests and full Security run integration suite pass; formatting and clippy checks pass for the implementation.

Blocked by

None (can start immediately).

Decisions

The design tree is settled in three prerequisite rounds. Each entry records a decision and its reason; no branch requires a Day shift decision.

Round 1: scope and responsibility

  1. Scope: one standalone Ticket. Deliver the complete raw-input-to-ready-issue path, including the real adapter and tests, in one session. The production protocol is roughly 425 lines and has one caller, so a Spec and migration Tickets would add no useful independence.
  2. Keep the external publishing interface. It already gives its caller leverage and contains no leaked publication protocol. Add depth at the internal interface shared by production and tests, because the friction is in verifying the implementation together.
  3. Separate lifetime ownership from publication policy. The publishing shell continues decoding reproduced Fix size before acquisition, selecting private Single reuse versus a publishing session, owning Worktree/Sessions, and returning the last Session log. A private publication module owns the full decision and mutation sequence, because those are the interactions the helper tests cannot currently exercise together. Deletion test: removing it puts parsing, validation, linking, sweeps and readiness knowledge back into both shell paths; extracting only parsers would merely move complexity.
  4. Preserve policy rather than settle adjacent issues. Decide staged-issue fate when the post-linking spec sweep fails #655 asks what to do with staged issues after a sweep failure; Decide how to stop a disobedient publishing session from leaking unvalidated public issues #637 and Decide enforced credential isolation for Security fix publishing #691 concern publishing authority. They do not propose this deepening, and this Ticket changes none of those policies. ADR 0013's Harness trust and ADR 0015's private-record/public-fix distinction remain in force; no ADR is reopened.

Round 2: interface and implementation

  1. Use one internal publication operation for both shell paths. Its input is the repository, selected Security finding, private-record URL, reproduced Fix size, and a source describing either existing-finding reuse or the raw optional final message with the captured session start time. Its result is the published/reused Issue URL or the existing error. Keep these types private to publication: callers and tests should not manually run parse/check/link/tag phases.
  2. Keep session facts as values. Sample the start time in its current location, after Worktree acquisition and log setup and before starting the publishing session, and retain second-resolution creation comparisons. Run the post-session operation inside the existing Sessions lifetime. This preserves attribution, cleanup timing and freshness without inventing clock or Session adapters.
  3. Put one private effects seam beneath the operation. It supplies issue and Ticket observations, issue text, issues created since the captured time, issue creation/closing, native sub-issue/dependency writes, label-edit application and interruption checks. Use the existing GitHub types and a production adapter delegating to existing GitHub operations; do not add a crate-wide GitHub abstraction. The scripted in-memory adapter is the second concrete adapter, so the seam is real.
  4. Keep existing rules authoritative. Use the SecurityRecord public-text checker and the Labels/Edit module through an edit-application operation, following the existing Pass pattern. Absorb the parsing and child-check helper choreography into the publication implementation instead of creating independently callable phases or duplicating those rules in adapters.
  5. Keep each flow's current eligibility. Private Single reuses its matching open finding with no sub-issues and no other Unready Ticket label, permits needs-triage and skips freshness/public-text checks. Private Spec must reuse the finding's parent, which may predate the session and need not have needs-triage. Public parents must be new, open and carry needs-triage with no other Unready Ticket label. Spec children must be same-repository, new, open, ready-for-agent, otherwise ready, and without sub-issues; retain their existing text checks in both private and public Specs. This avoids accidentally making four different contracts uniform.
  6. Keep the mutation sequence and failures. Validate all staged text before creation; create all proposed issues, then link children, then add blocking edges, then perform the public Spec sweep and reread validation. Validate every child before tagging any; reread each child's labels for its edit; check interruption and edit the parent last. Preserve the public Single's existing single-sweep behavior. Do not catch errors to continue, retry or roll back: earlier creates/links/child edits can remain after a later failure, and a failed session never reaches sweeps.

Round 3: verification and completion

  1. The interface is the test surface. Use the same private publication operation in production and protocol tests. Feed raw final messages and native record fixtures, script changed observations and failures, and assert outcomes and externally meaningful effects. This tests the real parser/validator/mutation interplay rather than a prepared proposal or an isolated callback.
  2. Replace local helper tests; retain adapter coverage. Move their malformed-proposal and repository-identity cases to the operation-level suite, then delete tests that only inspect parser structures or helper results. Keep existing CLI tests because they verify real process, Harness, credential, native-link, dispatch and logging integration that the in-memory adapter cannot establish. Prior art is the CI and Repair loop's private production/scripted adapters and Pass label edits.
  3. Use existing domain language. Security finding, Ticket, Spec, Worktree and Session already describe the responsibilities; no new domain term or sharper definition is introduced. No CONTEXT or ADR change is needed: this reversible internal seam neither changes domain behavior nor makes a hard-to-reverse decision.
  4. Complete only when the protocol and adapter agree. Run the focused protocol tests, the full existing Security run integration suite and the repository's formatting/clippy checks. The Architecture review's own baseline results are recorded below; they verify existing behavior, not the future refactor.

Review evidence

Evidence and coverage: reviewed main checkout 6d03378969b8138afcbe3002bfee9e929f89d860; origin advanced to 53bb9c6 during the review with only installed skill changes and no change to this protocol. Publication has 18 behavior-touching commits in its history, including staged publishing, sweep, identity and credential changes. All 87 open issue titles and bodies were checked; none proposes this module deepening. #655, #637 and #691 remain separate policy decisions.

Baseline validation: the eight existing publication helper tests passed (cargo test security::fixing::tests -- --nocapture). All four staged-publication integration tests also passed (cargo test --test security_run staged -- --nocapture). These are baseline checks, not verification of the future refactor; the full Security run suite and implementation checks remain this Ticket's work. No repository files were edited, and no commits or pushes were made by the review.

Architecture review

Strength: Strong · Dependencies: mock

Files: src/security/fixing.rs, new private src/security/fixing/publication.rs and its tests, tests/security_run.rs; unchanged caller src/pass.rs and reused rules src/github/advisories/description.rs, src/labels.rs.

Before

flowchart LR
  S["Publishing shell"] --> P["Proposal parsing"]
  S --> V["Ticket validation"]
  S --> L["Spec links and sweeps"]
  S --> R["Readiness edits"]
  V --> G["GitHub"]
  L --> G
  R --> G
  T["Publication tests"] -.-> P
  T -.-> V
Loading

After

flowchart LR
  S["Publishing shell"] --> I["Publication interface"]
  T["Publication tests"] --> I
  subgraph M["Security fix publication module"]
    I --> P["Proposal parsing"]
    I --> V["Ticket validation"]
    I --> L["Spec links and sweeps"]
    I --> R["Readiness edits"]
  end
  M --> A["Private effects seam"]
  A --> G["GitHub adapter"]
  A --> F["In-memory adapter"]
  classDef deep stroke-width:3px;
  class M deep;
Loading

Problem: shallow parser and callback test interfaces omit the publication implementation's sequencing, forcing changes through a full CLI fixture.

Solution: deepen publication behind one interface with a private effects seam, preserving the publishing shell and making the whole protocol the test surface.

Wins

  • Depth: raw proposal to ready issue
  • Locality: publication rules tested together
  • Leverage: four flows, one interface
  • Real seam: production and test adapters
  • Delete shallow helper test interfaces

Activity

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