Skip to content

Feat/phase4 fe scaffold - #16

Merged
ravin00 merged 29 commits into
mainfrom
feat/phase4-fe-scaffold
Aug 4, 2026
Merged

Feat/phase4 fe scaffold#16
ravin00 merged 29 commits into
mainfrom
feat/phase4-fe-scaffold

Conversation

@ravin00

@ravin00 ravin00 commented Aug 3, 2026

Copy link
Copy Markdown
Owner

Summary

  • Introduce IMetricEventConsumer strategy with two implementations:
    LocalJsonlTailConsumer (active in dev) and EventHubConsumer
    (Phase-8 stub, disabled).
  • The service now populates WindowStore from
    experiments/results/telemetry_*.jsonl and reports real staleness
    through /health.
  • Adds Azure Event Hubs NuGets so the stub compiles.

Test plan

  • dotnet build AFIE.slnx clean
  • dotnet test tests/AFIE.FeatureEngineering.Tests/ — ~11 passing
  • dotnet test tests/AFIE.Telemetry.Tests/ — 20 still passing
  • Smoke: append a MetricEvent to today's JSONL file, /health
    shows eventsConsumedTotal=1, workloadsTracked=1,
    sourceFileReachable=true
  • Restart the service and confirm the offset file resumes cleanly

Summary by CodeRabbit

  • New Features

    • Added a feature-engineering service for collecting bounded workload metrics and recent action history.
    • Added health monitoring with event, storage, source connectivity, and workload status details.
    • Added a health endpoint for service status checks.
    • Added containerized deployment support and local development configuration.
  • Tests

    • Added automated coverage for metric windows, concurrent event handling, capacity limits, overflow behavior, and missing workloads.

@ravin00
ravin00 requested review from Dinuda and Copilot August 3, 2026 18:23
@coderabbitai

coderabbitai Bot commented Aug 3, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@ravin00, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 48 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 3356b317-6915-4078-b581-a48e21dd4790

📥 Commits

Reviewing files that changed from the base of the PR and between 6d5aab3 and 810183a.

📒 Files selected for processing (6)
  • src/api/feature-engineering/Dockerfile
  • src/api/feature-engineering/Health/FeatureEngineeringHealthCheck.cs
  • src/api/feature-engineering/Models/FeatureEngineeringOptions.cs
  • src/api/feature-engineering/Properties/launchSettings.json
  • src/api/feature-engineering/Services/WindowStore.cs
  • tests/AFIE.FeatureEngineering.Tests/Services/WindowStoreTests.cs
📝 Walkthrough

Walkthrough

Added the AFIE.FeatureEngineering .NET 8 API and test project. The API includes bounded per-workload metric storage, action history storage, health reporting, dependency injection, configuration, and Docker support. Tests cover buffer behavior and concurrent window storage.

Changes

Feature engineering API

Layer / File(s) Summary
Bounded workload stores and validation
src/api/feature-engineering/Models/*, src/api/feature-engineering/Services/*, src/api/feature-engineering/appsettings.json, tests/AFIE.FeatureEngineering.Tests/*
Added configurable circular buffering, concurrent per-workload metric windows, action history limited to three records, and tests for ordering, overflow, missing workloads, and concurrent additions.
API wiring and health reporting
AFIE.slnx, src/api/feature-engineering/*.csproj, src/api/feature-engineering/Program.cs, src/api/feature-engineering/Health/*, src/api/feature-engineering/Dockerfile, src/api/feature-engineering/Properties/*, src/api/feature-engineering/*.http
Added the API and test projects to the solution. Registered storage and health services, mapped /health, added health response serialization, and configured local and container execution.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant HealthClient
  participant Program
  participant FeatureEngineeringHealthCheck
  participant WindowStore
  HealthClient->>Program: GET /health
  Program->>FeatureEngineeringHealthCheck: Run health check
  FeatureEngineeringHealthCheck->>WindowStore: Read workload count
  WindowStore-->>FeatureEngineeringHealthCheck: Return workload count
  FeatureEngineeringHealthCheck-->>HealthClient: Serialize health report
Loading

Possibly related PRs

  • ravin00/AFIE#14: Directly references AFIE.Contracts and its shared MetricEvent type used by WindowStore.

Suggested reviewers: dinuda

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately identifies the Phase 4 feature-engineering scaffold added by the pull request.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/phase4-fe-scaffold

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/api/feature-engineering/AFIE.FeatureEngineering.http`:
- Around line 3-4: Replace the stale weatherforecast development endpoint
references with health: update AFIE.FeatureEngineering.http lines 3-4 to request
/health, and set the http profile launchUrl at launchSettings.json line 16 and
IIS Express profile launchUrl at line 25 to health.

In `@src/api/feature-engineering/Dockerfile`:
- Around line 10-15: Update the runtime stage after EXPOSE 8080 and before
ENTRYPOINT to run the application as the image-provided non-root app user by
adding the appropriate USER directive, without creating another user or changing
the existing startup command.

In `@src/api/feature-engineering/Health/FeatureEngineeringHealthCheck.cs`:
- Around line 17-30: Update CheckHealthAsync in FeatureEngineeringHealthCheck to
evaluate the configured staleness threshold and dependency reachability before
returning a result. Return HealthCheckResult.Degraded when LastEventConsumedTime
is absent, older than the threshold, SourceFileReachable is false, or
PostgresReachable is false; otherwise preserve the existing healthy result and
diagnostic data. Follow TelemetryHealthCheck’s established health-status
contract and configuration symbols.

In `@src/api/feature-engineering/Services/WindowStore.cs`:
- Around line 13-16: Validate FeatureEngineeringOptions.WindowCapacity in the
WindowStore constructor before assigning _capacity, rejecting zero or negative
values so invalid configuration fails during construction; add a test covering
this invalid configuration path.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: a178180c-79da-4b86-a017-8137776affe3

📥 Commits

Reviewing files that changed from the base of the PR and between 26c8c84 and 813d3e3.

📒 Files selected for processing (18)
  • AFIE.slnx
  • src/api/feature-engineering/.gitkeep
  • src/api/feature-engineering/AFIE.FeatureEngineering.csproj
  • src/api/feature-engineering/AFIE.FeatureEngineering.http
  • src/api/feature-engineering/Dockerfile
  • src/api/feature-engineering/Health/FeatureEngineeringHealthCheck.cs
  • src/api/feature-engineering/Health/FeatureEngineeringHealthState.cs
  • src/api/feature-engineering/Models/ActionRecord.cs
  • src/api/feature-engineering/Models/FeatureEngineeringOptions.cs
  • src/api/feature-engineering/Program.cs
  • src/api/feature-engineering/Properties/launchSettings.json
  • src/api/feature-engineering/Services/ActionHistoryStore.cs
  • src/api/feature-engineering/Services/CircularBuffer.cs
  • src/api/feature-engineering/Services/WindowStore.cs
  • src/api/feature-engineering/appsettings.json
  • tests/AFIE.FeatureEngineering.Tests/AFIE.FeatureEngineering.Tests.csproj
  • tests/AFIE.FeatureEngineering.Tests/Services/CircularBufferTests.cs
  • tests/AFIE.FeatureEngineering.Tests/Services/WindowStoreTests.cs
💤 Files with no reviewable changes (1)
  • src/api/feature-engineering/.gitkeep

Comment thread src/api/feature-engineering/AFIE.FeatureEngineering.http Outdated
Comment thread src/api/feature-engineering/Dockerfile
Comment thread src/api/feature-engineering/Health/FeatureEngineeringHealthCheck.cs
Comment thread src/api/feature-engineering/Services/WindowStore.cs

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Introduces a new Feature Engineering API project (net8) with basic in-memory stores for recent metric windows and action history, plus an HTTP /health endpoint and unit tests for the new buffering logic.

Changes:

  • Add CircularBuffer<T> and WindowStore (and ActionHistoryStore) services for tracking per-workload recent history.
  • Add /health endpoint with JSON response and a state object to report basic counters/flags.
  • Add a new test project with unit tests for CircularBuffer<T> and WindowStore, and register projects in AFIE.slnx.

Reviewed changes

Copilot reviewed 18 out of 18 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
tests/AFIE.FeatureEngineering.Tests/Services/WindowStoreTests.cs Adds unit tests validating on-demand buffer creation, null snapshot for unknown workload, and concurrent adds.
tests/AFIE.FeatureEngineering.Tests/Services/CircularBufferTests.cs Adds unit tests for buffer insertion order, overflow behavior, empty snapshot, and ctor guard.
tests/AFIE.FeatureEngineering.Tests/AFIE.FeatureEngineering.Tests.csproj New FeatureEngineering test project definition and references.
src/api/feature-engineering/Services/WindowStore.cs Adds per-workload window store backed by ConcurrentDictionary + CircularBuffer.
src/api/feature-engineering/Services/CircularBuffer.cs Adds a lock-based fixed-capacity circular buffer with snapshot support.
src/api/feature-engineering/Services/ActionHistoryStore.cs Adds per-workload recent action history store (capacity 3).
src/api/feature-engineering/Properties/launchSettings.json Adds local launch profiles (currently pointing at a non-existent route).
src/api/feature-engineering/Program.cs Minimal app setup: options, singleton stores/state, and /health mapping.
src/api/feature-engineering/Models/FeatureEngineeringOptions.cs Adds configuration model (currently only WindowCapacity).
src/api/feature-engineering/Models/ActionRecord.cs Adds action record model.
src/api/feature-engineering/Health/FeatureEngineeringHealthState.cs Adds state container for health reporting fields.
src/api/feature-engineering/Health/FeatureEngineeringHealthCheck.cs Adds health check + JSON response writer.
src/api/feature-engineering/Dockerfile Adds container build/runtime definition for the new service.
src/api/feature-engineering/appsettings.json Adds default FeatureEngineering:WindowCapacity configuration.
src/api/feature-engineering/AFIE.FeatureEngineering.http Adds an HTTP scratch file (currently points at a non-existent route).
src/api/feature-engineering/AFIE.FeatureEngineering.csproj Adds the new FeatureEngineering web project.
src/api/feature-engineering/.gitkeep Removes placeholder file now that the directory has real content.
AFIE.slnx Registers the new API and test projects in the solution.
Suppressed comments (1)

src/api/feature-engineering/Properties/launchSettings.json:26

  • The IIS Express profile also uses launchUrl: weatherforecast, which will 404 because the app only exposes /health.
      "commandName": "IISExpress",
      "launchBrowser": true,
      "launchUrl": "weatherforecast",
      "environmentVariables": {

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/api/feature-engineering/Health/FeatureEngineeringHealthCheck.cs
Comment thread src/api/feature-engineering/AFIE.FeatureEngineering.http Outdated
Comment thread src/api/feature-engineering/Properties/launchSettings.json Outdated
Comment thread src/api/feature-engineering/Program.cs
Comment thread src/api/feature-engineering/AFIE.FeatureEngineering.csproj
Comment thread tests/AFIE.FeatureEngineering.Tests/AFIE.FeatureEngineering.Tests.csproj Outdated
ravin00 and others added 5 commits August 4, 2026 12:57
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

♻️ Duplicate comments (1)
src/api/feature-engineering/Health/FeatureEngineeringHealthCheck.cs (1)

30-34: 🩺 Stability & Availability | 🟠 Major | 🏗️ Heavy lift

Return Degraded when LastEventConsumedTime is stale.

The check only detects that no event has ever been consumed. If event consumption stops after one event, /health remains healthy indefinitely. Compare LastEventConsumedTime with the configured staleness threshold before returning Healthy.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/api/feature-engineering/Health/FeatureEngineeringHealthCheck.cs` around
lines 30 - 34, Update the health-check logic around LastEventConsumedTime to
return Degraded when the timestamp is older than the configured staleness
threshold, while retaining the existing no-events and unreachable dependency
checks. Ensure the Healthy result is reached only when the last event was
consumed within the allowed threshold.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Duplicate comments:
In `@src/api/feature-engineering/Health/FeatureEngineeringHealthCheck.cs`:
- Around line 30-34: Update the health-check logic around LastEventConsumedTime
to return Degraded when the timestamp is older than the configured staleness
threshold, while retaining the existing no-events and unreachable dependency
checks. Ensure the Healthy result is reached only when the last event was
consumed within the allowed threshold.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 7a94ce1f-7a10-45df-9a78-b4e76a43206e

📥 Commits

Reviewing files that changed from the base of the PR and between 813d3e3 and 6d5aab3.

📒 Files selected for processing (5)
  • src/api/feature-engineering/AFIE.FeatureEngineering.csproj
  • src/api/feature-engineering/AFIE.FeatureEngineering.http
  • src/api/feature-engineering/Health/FeatureEngineeringHealthCheck.cs
  • src/api/feature-engineering/Properties/launchSettings.json
  • tests/AFIE.FeatureEngineering.Tests/AFIE.FeatureEngineering.Tests.csproj
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/api/feature-engineering/Properties/launchSettings.json
  • tests/AFIE.FeatureEngineering.Tests/AFIE.FeatureEngineering.Tests.csproj

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (2)
src/api/feature-engineering/Services/ActionHistoryStore.cs (2)

11-20: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add direct tests for ActionHistoryStore.

The supplied tests cover CircularBuffer, but this class also owns workload partitioning and lookup behavior. Add tests for workload isolation, retention of the three most recent records, and an empty result for an unknown workload.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/api/feature-engineering/Services/ActionHistoryStore.cs` around lines 11 -
20, Add direct tests for ActionHistoryStore covering separate records per
workload, retention of only the three most recent records, and Recent returning
an empty array for an unknown workload. Exercise the public Record and Recent
methods and configure the store with its Capacity of three.

8-14: 🩺 Stability & Availability | 🔵 Trivial

Bound the number of workload entries.

The per-workload buffers are bounded, but _buffers is not. ActionHistoryStore is registered as a singleton in src/api/feature-engineering/Program.cs, so every distinct ActionRecord.WorkloadName remains stored until process restart. If workload names can be high-cardinality, add a maximum workload count with eviction or reject unknown workloads. Verify that the ingestion path enforces this constraint.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/api/feature-engineering/Services/ActionHistoryStore.cs` around lines 8 -
14, Bound the distinct workload entries managed by ActionHistoryStore by adding
a maximum workload count and enforcing it in Record before or during
_buffers.GetOrAdd. Evict an existing workload entry or reject new workload names
when the limit is reached, while preserving the per-workload CircularBuffer
capacity and ensuring the ingestion path cannot bypass this constraint.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@src/api/feature-engineering/Services/ActionHistoryStore.cs`:
- Around line 11-20: Add direct tests for ActionHistoryStore covering separate
records per workload, retention of only the three most recent records, and
Recent returning an empty array for an unknown workload. Exercise the public
Record and Recent methods and configure the store with its Capacity of three.
- Around line 8-14: Bound the distinct workload entries managed by
ActionHistoryStore by adding a maximum workload count and enforcing it in Record
before or during _buffers.GetOrAdd. Evict an existing workload entry or reject
new workload names when the limit is reached, while preserving the per-workload
CircularBuffer capacity and ensuring the ingestion path cannot bypass this
constraint.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: c4f9894d-59a4-4340-ab2e-a18e9834a600

📥 Commits

Reviewing files that changed from the base of the PR and between 26c8c84 and 6d5aab3.

📒 Files selected for processing (18)
  • AFIE.slnx
  • src/api/feature-engineering/.gitkeep
  • src/api/feature-engineering/AFIE.FeatureEngineering.csproj
  • src/api/feature-engineering/AFIE.FeatureEngineering.http
  • src/api/feature-engineering/Dockerfile
  • src/api/feature-engineering/Health/FeatureEngineeringHealthCheck.cs
  • src/api/feature-engineering/Health/FeatureEngineeringHealthState.cs
  • src/api/feature-engineering/Models/ActionRecord.cs
  • src/api/feature-engineering/Models/FeatureEngineeringOptions.cs
  • src/api/feature-engineering/Program.cs
  • src/api/feature-engineering/Properties/launchSettings.json
  • src/api/feature-engineering/Services/ActionHistoryStore.cs
  • src/api/feature-engineering/Services/CircularBuffer.cs
  • src/api/feature-engineering/Services/WindowStore.cs
  • src/api/feature-engineering/appsettings.json
  • tests/AFIE.FeatureEngineering.Tests/AFIE.FeatureEngineering.Tests.csproj
  • tests/AFIE.FeatureEngineering.Tests/Services/CircularBufferTests.cs
  • tests/AFIE.FeatureEngineering.Tests/Services/WindowStoreTests.cs
💤 Files with no reviewable changes (1)
  • src/api/feature-engineering/.gitkeep
🚧 Files skipped from review as they are similar to previous changes (15)
  • src/api/feature-engineering/AFIE.FeatureEngineering.http
  • src/api/feature-engineering/Properties/launchSettings.json
  • src/api/feature-engineering/Health/FeatureEngineeringHealthState.cs
  • src/api/feature-engineering/appsettings.json
  • src/api/feature-engineering/AFIE.FeatureEngineering.csproj
  • src/api/feature-engineering/Program.cs
  • src/api/feature-engineering/Health/FeatureEngineeringHealthCheck.cs
  • tests/AFIE.FeatureEngineering.Tests/Services/WindowStoreTests.cs
  • src/api/feature-engineering/Models/ActionRecord.cs
  • src/api/feature-engineering/Services/WindowStore.cs
  • AFIE.slnx
  • src/api/feature-engineering/Models/FeatureEngineeringOptions.cs
  • tests/AFIE.FeatureEngineering.Tests/AFIE.FeatureEngineering.Tests.csproj
  • src/api/feature-engineering/Services/CircularBuffer.cs
  • tests/AFIE.FeatureEngineering.Tests/Services/CircularBufferTests.cs

@ravin00
ravin00 merged commit e51996f into main Aug 4, 2026
1 check passed
@ravin00
ravin00 deleted the feat/phase4-fe-scaffold branch August 4, 2026 07:39
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.

2 participants