Feat/phase4 fe scaffold - #16
Conversation
|
Warning Review limit reached
Next review available in: 48 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the 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 configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (6)
📝 WalkthroughWalkthroughAdded the ChangesFeature engineering API
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
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
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
📒 Files selected for processing (18)
AFIE.slnxsrc/api/feature-engineering/.gitkeepsrc/api/feature-engineering/AFIE.FeatureEngineering.csprojsrc/api/feature-engineering/AFIE.FeatureEngineering.httpsrc/api/feature-engineering/Dockerfilesrc/api/feature-engineering/Health/FeatureEngineeringHealthCheck.cssrc/api/feature-engineering/Health/FeatureEngineeringHealthState.cssrc/api/feature-engineering/Models/ActionRecord.cssrc/api/feature-engineering/Models/FeatureEngineeringOptions.cssrc/api/feature-engineering/Program.cssrc/api/feature-engineering/Properties/launchSettings.jsonsrc/api/feature-engineering/Services/ActionHistoryStore.cssrc/api/feature-engineering/Services/CircularBuffer.cssrc/api/feature-engineering/Services/WindowStore.cssrc/api/feature-engineering/appsettings.jsontests/AFIE.FeatureEngineering.Tests/AFIE.FeatureEngineering.Tests.csprojtests/AFIE.FeatureEngineering.Tests/Services/CircularBufferTests.cstests/AFIE.FeatureEngineering.Tests/Services/WindowStoreTests.cs
💤 Files with no reviewable changes (1)
- src/api/feature-engineering/.gitkeep
There was a problem hiding this comment.
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>andWindowStore(andActionHistoryStore) services for tracking per-workload recent history. - Add
/healthendpoint with JSON response and a state object to report basic counters/flags. - Add a new test project with unit tests for
CircularBuffer<T>andWindowStore, and register projects inAFIE.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.
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>
There was a problem hiding this comment.
♻️ Duplicate comments (1)
src/api/feature-engineering/Health/FeatureEngineeringHealthCheck.cs (1)
30-34: 🩺 Stability & Availability | 🟠 Major | 🏗️ Heavy liftReturn
DegradedwhenLastEventConsumedTimeis stale.The check only detects that no event has ever been consumed. If event consumption stops after one event,
/healthremains healthy indefinitely. CompareLastEventConsumedTimewith the configured staleness threshold before returningHealthy.🤖 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
📒 Files selected for processing (5)
src/api/feature-engineering/AFIE.FeatureEngineering.csprojsrc/api/feature-engineering/AFIE.FeatureEngineering.httpsrc/api/feature-engineering/Health/FeatureEngineeringHealthCheck.cssrc/api/feature-engineering/Properties/launchSettings.jsontests/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
There was a problem hiding this comment.
🧹 Nitpick comments (2)
src/api/feature-engineering/Services/ActionHistoryStore.cs (2)
11-20: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd 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 | 🔵 TrivialBound the number of workload entries.
The per-workload buffers are bounded, but
_buffersis not.ActionHistoryStoreis registered as a singleton insrc/api/feature-engineering/Program.cs, so every distinctActionRecord.WorkloadNameremains 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
📒 Files selected for processing (18)
AFIE.slnxsrc/api/feature-engineering/.gitkeepsrc/api/feature-engineering/AFIE.FeatureEngineering.csprojsrc/api/feature-engineering/AFIE.FeatureEngineering.httpsrc/api/feature-engineering/Dockerfilesrc/api/feature-engineering/Health/FeatureEngineeringHealthCheck.cssrc/api/feature-engineering/Health/FeatureEngineeringHealthState.cssrc/api/feature-engineering/Models/ActionRecord.cssrc/api/feature-engineering/Models/FeatureEngineeringOptions.cssrc/api/feature-engineering/Program.cssrc/api/feature-engineering/Properties/launchSettings.jsonsrc/api/feature-engineering/Services/ActionHistoryStore.cssrc/api/feature-engineering/Services/CircularBuffer.cssrc/api/feature-engineering/Services/WindowStore.cssrc/api/feature-engineering/appsettings.jsontests/AFIE.FeatureEngineering.Tests/AFIE.FeatureEngineering.Tests.csprojtests/AFIE.FeatureEngineering.Tests/Services/CircularBufferTests.cstests/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
… is greater than zero
Summary
IMetricEventConsumerstrategy with two implementations:LocalJsonlTailConsumer(active in dev) andEventHubConsumer(Phase-8 stub, disabled).
WindowStorefromexperiments/results/telemetry_*.jsonland reports real stalenessthrough
/health.Test plan
dotnet build AFIE.slnxcleandotnet test tests/AFIE.FeatureEngineering.Tests/— ~11 passingdotnet test tests/AFIE.Telemetry.Tests/— 20 still passing/healthshows
eventsConsumedTotal=1,workloadsTracked=1,sourceFileReachable=trueSummary by CodeRabbit
New Features
Tests