Skip to content

[milestone Milestone 2] Implement computeRiskScore(events, runId) with configurable risk weights. #202

Description

@telleroutlook

🤖 Auto-filed from milestone doc bullet.

Repo: WasmAgent/open-agent-audit
Milestone: Milestone 2: Audit Core Pipeline
Bullet:

Implement computeRiskScore(events, runId) with configurable risk weights.

Problem

The computeRiskScore(events, runId) function is not yet implemented. This function is needed to calculate a risk score based on audit events, which is a core component of the audit pipeline.

Approach

Implement the computeRiskScore function that:

  1. Takes events (array of audit events) and runId (audit run identifier) as parameters
  2. Calculates a risk score based on configurable risk weights for different event types/severities
  3. Returns a numeric risk score (likely 0-100 or similar normalized scale)

The function should be implemented in packages/core/src/drift-guard/index.ts, following the existing module patterns. Risk weights should be configurable (likely via a config parameter or environment-based configuration) to allow different weightings for:

  • Event severity levels (critical, high, medium, low, info)
  • Event types/categories
  • Frequency factors

Files expected to change

  • packages/core/src/drift-guard/index.ts — Add computeRiskScore function implementation
  • packages/core/src/drift-guard/index.test.ts — Add tests for computeRiskScore function

Acceptance criteria

  • Command bun install --frozen-lockfile && bun run build && bun run test passes
  • computeRiskScore(events, runId) function is implemented and accepts the specified parameters
  • Risk weights are configurable (not hardcoded)
  • Tests cover basic functionality including different event scenarios
  • No unrelated files touched (git status --short output limited to the intended changes)

Notes for the implementer

This issue was auto-created by SweepMilestoneBulletToIssue. The bullet text is verbatim from the milestone doc. The function should integrate with the existing drift-guard module and follow the codebase's patterns for configuration and error handling.

Metadata

Metadata

Assignees

No one assigned

    Labels

    claudeBot: auto-implement this issueenrichedIssue enriched with contextneeds-humanAction required from a human operator

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions