Repository navigation
Description
What to build
Deepen the existing Security finding record module so a Security audit, Security review, reproduction session, and Security fix publishing session use semantic record operations instead of knowing the persistent description format. Existing private findings remain readable, reproduction updates keep their original evidence and dispatched fix, and fix completion keeps intervening Day shift edits.
This is a behavior-preserving refactor, sized for one session: one standalone Ticket, with no parent or blocking edges. It concentrates the description implementation behind the existing record interface and migrates its callers together.
Acceptance criteria
- One record module owns fingerprint and audited-commit headers, reproduction and fix markers, reproduction rendering, fix-ending interpretation, and the copied-private-line interpretation used during fix publishing. Audit, review, reproduction, and publishing callers no longer construct or parse these conventions themselves. The exported fix-marker constant and reproduction-owned description renderer disappear.
- Audit and review draft construction uses semantic source information, validated finding fields, evidence, and package identity. Rendered headers, source wording, review issue link, JSON evidence, whitespace, and ordering remain compatible with current output.
- Existing records retain exact fingerprint matching, first reproduction-marker/outcome selection, last fix-marker/ending selection, and current missing/malformed-field behavior. Native identity and notification metadata decoding remains lazy; an unused malformed historical record does not start failing an otherwise valid Run.
- Reproduction still validates the recorded audited commit before acquiring its Worktree; 40- and 64-character ASCII hexadecimal commits are accepted. Replacement preserves original evidence, ordinary Markdown headings, safe proof-of-concept fences, and the entire existing fix suffix.
- Fix linking still checks the current remote description against the original before dispatch. Completion still rereads the remote description, checks the dispatched Ticket's exact link, and preserves private edits before appending its ending. A pending or failed fix still pauses later Security runs, including when the ending write fails.
- The copied-private-line check preserves its current exclusions and acceptance behavior; private-record linking, public text checks, and sanitized failure reporting remain in force.
- Tests cross the record interface through composed creation/read/update scenarios, including audit and review sources, legacy records, repeated reproduction, long backtick fences, fix suffix preservation, and pending-to-completed endings. Add missing coverage for a changed fix link and malformed/missing audited commits before Worktree acquisition. Existing tests for both GitHub storage adapters, Day shift triage, lazy decoding, and private edits remain green.
- No storage migration, prompt contract change, triage-policy change, or informational-severity decision is introduced. Use the existing Security finding vocabulary; no new glossary concept or ADR is needed for this reversible implementation change.
- Run formatting, linting, and the test suite using the repository's pinned toolchain, including the Security run and Security review scenarios.
Blocked by
None (can start immediately).
Decisions
The design tree has three rounds. Scope and the seam settle first; reads, writes, and caller migration depend on them; testing depends on those settled operations. Every branch is settled below.
Round 1 — scope and seam
- Deepen the existing record module, with an internal description implementation. Keep semantic operations on the existing record and draft types, with a private description implementation owning parsing and rendering. Do not expose a second general-purpose text toolkit. Reason: callers should learn domain operations, and deleting this module would redistribute substantial format knowledge across them; merely extracting string helpers would add no depth.
- Keep the description seam in-process. The description implementation takes text and semantic values and returns observations or replacement text. GitHub advisory and private issue adapters continue to select storage, observe remote state, check triage and concurrent edits, and perform writes; sessions continue to own their Worktrees and final-line parsing. Reason: description computation has no varying external dependency, so it needs no new trait or adapter. ADR 0015's disclosure and grading decisions remain intact.
- Preserve the stored format and current tolerance. Do not eagerly require a complete description or change parsing rules. Reason: historical records and Day shift edits are already supported, and a refactor must not turn an unselected malformed record into a global failure. No migration, new domain term, or ADR is justified.
Round 2 — semantic operations and migration
- Construct drafts from semantic source information. Give audit and review callers record-owned construction operations receiving their captured commit, review Issue URL when applicable, validated fingerprint/title/write-up, serialized evidence, and package identity. Retain their distinct finding validation. Reason: both sources need the same persistent headers, while their report contracts differ; sharing description construction must not merge those contracts or infer package versions.
- Make reads semantic and lazy. The record interface supplies exact fingerprint matching, validated audited commit, reproduced severity/fix size, fix presence, linked Ticket, and latest fix ending. Internally retain the current selection rules: any exact fingerprint line; first syntactically matching audited-commit line; first exact reproduction marker and first subsequent outcome; last exact fix marker, its first link line, and last
Fix Run:line. Validate the commit only when requested. Malformed reproduction outcomes remain absent; any fix marker still excludes another fix selection. Reason: these are existing gate and session invariants, including behaviors that cannot be replaced by one eager parse result. - Keep URL validation at its current observation points. Loading production records still parses every marked fix URL, checks its repository, and observes whether that issue is closed. Failed-fix selection still validates its selected pending/failed URL. Reuse the existing Issue URL parser, preserving exact link text without trimming. Reason: moving format knowledge must neither hide malformed links nor change when remote observations and failures occur.
- Own reproduction replacement as a complete operation. Retain the last fix suffix verbatim, remove the old reproduction at its first marker in the preceding text, and render the new outcome, notes, and test. Preserve current trailing-whitespace normalization and ensure a final test newline. Choose at least three backticks, and one more than the longest leading backtick run in the test. Reason: the caller must not learn section ordering or escaping, and replacing evidence must preserve the existing dispatched fix and original write-up.
- Own pending-link and ending text transformations. The adapter supplies freshly observed text to record-owned operations. Linking compares the original text exactly before appending pending state; completion checks the last marked link against the dispatched Ticket and appends succeeded/failed state to the current text. Retain append-only ending history and exact latest-ending interpretation. Reason: private edits must survive completion, while a changed Ticket must prevent writing to another fix. Keep triage rechecks, informational-advisory handling, interruption policy, and read-before-write ordering in the adapters.
- Move copied-line interpretation, keep publishing checks with publishing. The record owns whether proposed public text contains any currently prohibited description line. Preserve the existing per-line predicates exactly: trim, require alphanumeric content, skip bare identifiers and the existing fence/header/metadata/comment prefixes, then test containment. Publishing still fetches title/body and requires the private-record URL. Reason: metadata exclusions are format knowledge; issue observation and the requirement to link the private record are publishing behavior. This change adds no stronger disclosure detector or new policy.
Round 3 — testing and completion
- Use the record interface as the test surface. Test composed draft construction, observation, reproduction replacement, pending link, and completion rather than private parsing helpers. Include literal legacy fixtures so construction and parsing cannot silently agree on a changed format. Check ordinary headings, nested fences, unrelated text, repeated markers, no final newline, missing/malformed fields, and the whole fix suffix. Reason: composition verifies the preservation rules that isolated string-helper tests miss; in-process fixtures need no mock adapter.
- Retain tests for effects at the existing GitHub and Command seams. Keep both advisory/private issue scenarios for triage during reproduction, changed remote descriptions, failed ending writes, private edits, notification privacy, and loading malformed fix URLs. Add a changed fix-link scenario that asserts no completion PATCH, and commit-validation scenarios that assert no reproduction Worktree/session starts. Replace superseded helper-only tests if any, retaining independent transport and orchestration coverage. Reason: a text-only test cannot verify observation order, remote write refusal, or scheduling outcomes.
- Land the complete migration in one Ticket. The affected callers and description rules are a small, connected change; no intermediate compatibility interface or multi-session Spec is needed. Reason: migrating them together removes leaked knowledge immediately and fits one fresh context window. Keep unrelated open work untouched, including incomplete Security review reporting and informational advisory grading.
Review evidence: Reviewed main at f488b670eff68dd42d77e505a81c35464e60acba. Header rendering is duplicated in audit and review; reproduction owns both commit parsing and description replacement; the GitHub adapters separately interpret fingerprint, reproduction, fix-link, and ending markers; publishing separately classifies description metadata. Preservation rules repeatedly changed in e6f0e5b (#542), 41332f1 (#544), and 249899e (#552).
Issue coverage: Read all 68 open issues, including bodies and comments, and rechecked before publishing; none proposes this deepening. The merged #610 concentrates duplicate recording and native-response decoding, which this Ticket retains. Open #567 concerns informational advisory grading, and #607 concerns incomplete review reporting; neither covers description ownership.
Review validation: Ten existing tests passed with cargo +stable test --locked: original reproduction-heading/evidence preservation, private edits during failed-fix completion, Security review record reuse across both storage adapters and record states, and all seven record-module tests. These establish the current behavior; this review implements no refactor. The pinned 1.99.0 toolchain fails before compilation because its rustc binary is unavailable here; the installed stable compiler is 1.95.0. The full pinned-toolchain suite remains implementation acceptance work. Both Mermaid blocks were checked against flowchart syntax. No tracked repository files were changed, committed, or pushed.
Architecture review
Strength: Strong · Dependencies: in-process
Files: src/github/advisories.rs, src/github/advisories_tests.rs, src/github.rs, src/security/audit.rs, src/security/review.rs, src/security/reproduction.rs, src/security/fixing.rs, tests/security_run.rs, tests/security_review.rs
Before
flowchart LR
A[Security audit module] -. headers .-> D[Security finding record module]
R[Security review module] -. headers .-> D
P[Reproduction module] -. commit and replacement .-> D
F[Security fix publishing module] -. description interpretation .-> D
G[GitHub storage adapters] -. markers and endings .-> D
classDef leak stroke:#dc2626,stroke-width:2px;
class A,R,P,F,G leak;
After
flowchart LR
A[Security audit module] --> D[Security finding record module]
R[Security review module] --> D
P[Reproduction module] --> D
F[Security fix publishing module] --> D
G[GitHub storage adapters] --> D
classDef deep stroke-width:3px;
class D deep;
Problem: The record's shallow text interface spreads persistent-format knowledge across five callers, reducing locality whenever evidence or fix preservation changes.
Solution: Deepen the record module with semantic operations behind its existing seam, concentrating description implementation while each storage adapter retains remote effects.
Wins
- Locality: one description implementation
- Leverage: five callers share invariants
- Interface owns preservation behavior
- Depth replaces leaked format knowledge
- Tests compose record operations
Activity