Skip to content

refactor(cli): split findings.ts + consolidate render surface - #20

Merged
bx33661 merged 3 commits into
mainfrom
refactor/findings-ts-validate-split
Jul 6, 2026
Merged

refactor(cli): split findings.ts + consolidate render surface#20
bx33661 merged 3 commits into
mainfrom
refactor/findings-ts-validate-split

Conversation

@bx33661

@bx33661 bx33661 commented Jul 6, 2026

Copy link
Copy Markdown
Owner

Context

src/cli/findings.ts grew to 1603 lines — the project's largest file, mixing validation, scoring, CRUD, workflow policy, threatmap read/write/render, and repro artifact logic in one place. Rendering helpers were duplicated between commands/findings.ts and render.ts, creating confusion about where display logic lives.

Changes

Extract workflow.ts

Move all workflow-policy functions out of findings.ts into a dedicated src/cli/workflow.ts:

  • workflowMissingFields, workflowBlockers, workflowNextAction, workflowPriority, workflowPriorityReason
  • extractFieldRefs, classifyWarning, warningNextAction, dedupeIssues

findings.ts imports these from ./workflow.js. Behavior unchanged.

Extract repro.ts and threatmap.ts (prepared for future use)

These files are created with the functions extracted from findings.ts but are not yet imported (findings.ts still has local copies). This keeps the extraction commit scope manageable:

  • repro.ts: initReproArtifacts, checkReportArtifacts, and all helper functions (merge/collect/existing/artifact helpers)
  • threatmap.ts: writeThreatMap, readThreatMap, renderThreatMap, describeThreatNode, threatMapTemplate

Consolidate rendering in render.ts

commands/findings.ts had 10 print* functions that duplicated (or nearly duplicated) the exported ones in render.ts. Deleted all local print* functions from commands/findings.ts, importing them from ../render.js instead. Also added printDeleteResult to render.ts (which commands/findings.ts was calling but that was only locally defined in the command file).

File size impact

File Before After Delta
findings.ts 1603 1477 -126
workflow.ts (new) 152 +152
repro.ts (new) 290 +290
threatmap.ts (new) 184 +184
commands/findings.ts 549 331 -218
render.ts 454 485 +31
Total CLI 2606 2919 +313 (new files)

Verification

  • npm run build — clean
  • npm test — 37/37 pass
  • Note: validateFinding / computeEvidenceScore / computeSubmissionScore and all validation/score constants stay in findings.ts for now. A follow-up (next PR) will extract validate.ts for these.

Follow-up

Next PR: extract validate.ts (validation + scoring) from findings.ts, and wire up repro.ts/threatmap.ts imports so findings.ts truly becomes CRUD + types only (~600 lines).

bx33661 added 3 commits July 5, 2026 01:43
…s + add submission_score section

Break the single ambiguous 'CVE readiness score' concept into two
explicitly documented scores:

- evidence_score (field completeness, 0-100, never penalized)
- submission_score (evidence_score minus deductions/clamping, 0-100,
  the actual gate at >=75)

Changes:
- contracts/evidence.v1.yaml: rename cve_readiness_scoring →
  evidence_score_weights, add full submission_score block with all 8
  deductions + cvss_confidence_penalty
- SPEC.md: replace all 10 references to cve_readiness_score with
  evidence_score/submission_score; fix divergent weights block
  (impact_fields_complete:10 and different points were never
  implemented)
- skills/omv-report/SKILL.md: add inline term mapping
  submissionScore = submission_score in contract
- skills/omv-report/scripts/render_template.py: re-implement
  _compute_scores() to exactly mirror CLI submissionsDeductions
  logic (was off by 4 deduction values + missing 3 deductions +
  unused 'missing tested version' deduction)
Move workflowMissingFields, workflowBlockers, workflowNextAction,
workflowPriority, workflowPriorityReason, extractFieldRefs,
classifyWarning, warningNextAction, dedupeIssues into a dedicated
workflow.ts module. findings.ts now imports them; behavior unchanged.

Tests: 37/37 pass, build clean.
…ings.ts

- Move all print* functions from commands/findings.ts into render.ts
  (the designated single rendering surface)
- Add printDeleteResult to render.ts (was only in commands/findings.ts)
- commands/findings.ts is now pure dispatch: arg parse + domain call +
  render call + exit code. All print helpers come from ../render.js
- Build clean, 37/37 tests pass
@bx33661
bx33661 merged commit d1e2a22 into main Jul 6, 2026
0 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant