Skip to content

feat(data-pathways)!: id-keyed pump-state commands + sources metrics shape#217

Merged
jbiskur merged 2 commits intomainfrom
feat/pump-state-source-id
Apr 23, 2026
Merged

feat(data-pathways)!: id-keyed pump-state commands + sources metrics shape#217
jbiskur merged 2 commits intomainfrom
feat/pump-state-source-id

Conversation

@jbiskur
Copy link
Copy Markdown
Contributor

@jbiskur jbiskur commented Apr 23, 2026

Summary

  • New commands DataPathwayPumpStateFetchBySourceCommand + DataPathwayPumpStateSaveBySourceCommand hit /api/v1/pump-states/:pathwayId/sources/:sourceId (GET + PUT). Legacy flowType commands stay behind for the deprecated route.
  • New DataPathwayPumpStateBySourceSchema (sourceId, flowType nullable, state union).
  • Metrics throughput shape: endpoints[url].flowTypesendpoints[url].sources (keyed by sourceId, carries flowType + optional name inline). Updated TThroughputSource and the inline heartbeat input type on DataPathwayAssignmentHeartbeatCommand.

Tracks data-pathways@3.0.0. The ! marks the metrics breaking change for downstream consumers reading pathway metrics or composing heartbeats directly.

Test plan

  • deno test --allow-all all 229 steps green (new: fetch + save by sourceId)
  • CI green

Summary by CodeRabbit

  • New Features

    • Added commands to fetch and save pump state information for individual sources within data pathways.
    • Updated throughput metrics structure for improved source-level visibility and organization.
  • Tests

    • Added test coverage for new source-level pump state operations.

…shape

Mirrors data-pathways v3.0.0:

- New commands: DataPathwayPumpStateFetchBySourceCommand +
  DataPathwayPumpStateSaveBySourceCommand hit
  /api/v1/pump-states/:pathwayId/sources/:sourceId (GET + PUT). Legacy
  flowType-based commands remain for the deprecated route.
- New contract DataPathwayPumpStateBySourceSchema carries sourceId,
  flowType (nullable — may be unknown when the source has been removed
  from the pathway config), and the state union.
- Throughput/metrics contract: endpoints[url].flowTypes →
  endpoints[url].sources (Record<sourceId, {flowType, name?, …}>).
  Updated both the exported TThroughputSource shape used in
  DataPathwayMetricsSchema and the inline heartbeat input shape on
  DataPathwayAssignmentHeartbeatCommand.
- Test coverage: new fetch + save cases for the sourceId-keyed
  commands.

BREAKING CHANGE: the metrics throughput shape renames
endpoints[url].flowTypes → endpoints[url].sources keyed by sourceId.
Consumers reading the pathway metrics endpoint or sending heartbeats
must adopt the new shape. Data-pathways v3.0.0 only accepts the new
shape.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 23, 2026

Warning

Rate limit exceeded

@jbiskur has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 2 minutes and 18 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 2 minutes and 18 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e7370af9-1d14-45dd-8d11-bd6fe45b82b8

📥 Commits

Reviewing files that changed from the base of the PR and between bbd1585 and f1ac7d3.

📒 Files selected for processing (1)
  • src/commands/data-pathways/pump-state.fetch-by-source.ts
📝 Walkthrough

Walkthrough

Restructures metrics throughput by renaming flowTypes to sources with added flowType and name fields. Introduces new pump-state command implementations for source-level operations (fetch and save) with corresponding schemas and tests, extending the Data Pathways API surface.

Changes

Cohort / File(s) Summary
Schema Updates
src/contracts/data-pathways.ts
Adds DataPathwayPumpStateBySourceSchema and introduces ThroughputSourceSchema, renaming endpoint metrics from flowTypes to sources with added flowType and optional name fields.
Heartbeat Metrics Update
src/commands/data-pathways/assignment.heartbeat.ts
Updates DataPathwayAssignmentHeartbeatInput to reflect renamed sources field and new flowType and name properties in throughput metrics.
Pump-State Source Commands
src/commands/data-pathways/pump-state.fetch-by-source.ts, src/commands/data-pathways/pump-state.save-by-source.ts
Implements source-level pump-state operations with GET and PUT endpoints to /api/v1/pump-states/{pathwayId}/sources/{sourceId}, schema parsing, and error handling for 404 responses.
Module Exports
src/commands/data-pathways/index.ts
Re-exports new pump-state fetch and save by source command implementations.
Tests
test/tests/commands/data-pathways.test.ts
Adds test cases for source-keyed pump-state fetch and save operations including endpoint stubs and response assertions.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐰 The pathways now have sources bright,
Pump states flow left and right,
FlowTypes dance to sources' call,
New commands fetch and save them all,
Data hops with pure delight! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the main changes: addition of id-keyed pump-state commands and a restructured metrics shape using sources instead of flow types.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/pump-state-source-id

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/commands/data-pathways/pump-state.fetch-by-source.ts`:
- Around line 27-29: The getPath method builds a URL with raw path params which
can break for IDs containing slashes or query chars; update protected override
getPath() to encode this.input.pathwayId and this.input.sourceId (e.g., via
encodeURIComponent) before interpolating them into
`/api/v1/pump-states/{pathwayId}/sources/{sourceId}` so the route is safe for
all ID values and preserves the exact parameter values.

In `@src/commands/data-pathways/pump-state.save-by-source.ts`:
- Around line 30-32: The getPath() builder currently interpolates raw user input
into the route, so special/reserved characters in input.sourceId (and pathwayId)
can break the path; update the getPath() method to URL-encode those path
parameters (e.g., apply encodeURIComponent to this.input.sourceId and
this.input.pathwayId) before inserting them into the template string so the
generated route is safe and cannot be manipulated by reserved characters.
🪄 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: defaults

Review profile: CHILL

Plan: Pro

Run ID: 2b1679bb-ddc0-4b47-990d-dcc20c690e8d

📥 Commits

Reviewing files that changed from the base of the PR and between b5bf9b8 and bbd1585.

📒 Files selected for processing (6)
  • src/commands/data-pathways/assignment.heartbeat.ts
  • src/commands/data-pathways/index.ts
  • src/commands/data-pathways/pump-state.fetch-by-source.ts
  • src/commands/data-pathways/pump-state.save-by-source.ts
  • src/contracts/data-pathways.ts
  • test/tests/commands/data-pathways.test.ts

Comment on lines +27 to +29
protected override getPath(): string {
return `/api/v1/pump-states/${this.input.pathwayId}/sources/${this.input.sourceId}`
}
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.

⚠️ Potential issue | 🟠 Major

Encode path parameters before building the source route.

Raw sourceId interpolation will misroute IDs containing path or query delimiters.

🐛 Proposed fix
   protected override getPath(): string {
-    return `/api/v1/pump-states/${this.input.pathwayId}/sources/${this.input.sourceId}`
+    const pathwayId = encodeURIComponent(this.input.pathwayId)
+    const sourceId = encodeURIComponent(this.input.sourceId)
+    return `/api/v1/pump-states/${pathwayId}/sources/${sourceId}`
   }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/commands/data-pathways/pump-state.fetch-by-source.ts` around lines 27 -
29, The getPath method builds a URL with raw path params which can break for IDs
containing slashes or query chars; update protected override getPath() to encode
this.input.pathwayId and this.input.sourceId (e.g., via encodeURIComponent)
before interpolating them into
`/api/v1/pump-states/{pathwayId}/sources/{sourceId}` so the route is safe for
all ID values and preserves the exact parameter values.

Comment on lines +30 to +32
protected override getPath(): string {
return `/api/v1/pump-states/${this.input.pathwayId}/sources/${this.input.sourceId}`
}
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.

⚠️ Potential issue | 🟠 Major

Encode path parameters before building the source route.

sourceId is a public string input; reserved characters can change the path/query and target the wrong endpoint.

🐛 Proposed fix
   protected override getPath(): string {
-    return `/api/v1/pump-states/${this.input.pathwayId}/sources/${this.input.sourceId}`
+    const pathwayId = encodeURIComponent(this.input.pathwayId)
+    const sourceId = encodeURIComponent(this.input.sourceId)
+    return `/api/v1/pump-states/${pathwayId}/sources/${sourceId}`
   }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
protected override getPath(): string {
return `/api/v1/pump-states/${this.input.pathwayId}/sources/${this.input.sourceId}`
}
protected override getPath(): string {
const pathwayId = encodeURIComponent(this.input.pathwayId)
const sourceId = encodeURIComponent(this.input.sourceId)
return `/api/v1/pump-states/${pathwayId}/sources/${sourceId}`
}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/commands/data-pathways/pump-state.save-by-source.ts` around lines 30 -
32, The getPath() builder currently interpolates raw user input into the route,
so special/reserved characters in input.sourceId (and pathwayId) can break the
path; update the getPath() method to URL-encode those path parameters (e.g.,
apply encodeURIComponent to this.input.sourceId and this.input.pathwayId) before
inserting them into the template string so the generated route is safe and
cannot be manipulated by reserved characters.

@jbiskur jbiskur merged commit 3111706 into main Apr 23, 2026
2 checks passed
@jbiskur jbiskur deleted the feat/pump-state-source-id branch April 23, 2026 15:58
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