Skip to content

New updatedAt record for services#1428

Merged
giurgiur99 merged 3 commits into
next-4from
feat/service-updatedat-incremental-list
Jul 23, 2026
Merged

New updatedAt record for services#1428
giurgiur99 merged 3 commits into
next-4from
feat/service-updatedat-incremental-list

Conversation

@giurgiur99

@giurgiur99 giurgiur99 commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Fixes # .

Changes proposed in this PR:

  • The monitor will reconcile network-services by pulling from each node, and needs to know what changed since last crawl, but SERVICE_LIST could only filter on dateCreated before this

Summary by CodeRabbit

  • New Features

    • Added support for filtering services by an updatedSince timestamp.
    • Service listings now return jobs updated at or after the specified time, including across service statuses.
    • Service updates now record an updatedAt timestamp.
  • Bug Fixes

    • Invalid updatedSince values now return a clear bad-request response.
    • Services without update timestamps are handled consistently during filtering.

@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown

Review Change Stack

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 775f9f2d-6fec-477f-bce5-717e79b2d640

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Service jobs now record updatedAt timestamps on creation and updates. The service listing command accepts updatedSince, validates it, reads all jobs, and filters results by update time, with tests covering invalid cursors, status coverage, and missing timestamps.

Changes

Service job update tracking

Layer / File(s) Summary
Service job timestamp persistence
src/@types/C2D/ServiceOnDemand.ts, src/components/database/sqliteCompute.ts, src/test/unit/service/serviceJobsDatabase.test.ts
ServiceJob exposes optional updatedAt; SQLite stores timestamps on insertion and refreshes them on updates, with persistence tests validating both behaviors.
Incremental service listing
src/@types/commands.ts, src/components/core/service/getServices.ts, src/test/unit/service/serviceHandlers.test.ts
GetServicesCommand accepts updatedSince; the handler validates and parses it, reads all jobs, filters by updatedAt, and tests invalid and missing timestamps.

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

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant GetServicesHandler
  participant SQLiteCompute
  Client->>GetServicesHandler: Send updatedSince cursor
  GetServicesHandler->>GetServicesHandler: Validate and parse cursor
  GetServicesHandler->>SQLiteCompute: Read all service jobs
  SQLiteCompute-->>GetServicesHandler: Return jobs with updatedAt
  GetServicesHandler-->>Client: Return jobs updated since cursor
Loading

Possibly related PRs

Suggested reviewers: alexcos20, bogdanfazakas, dnsi0, andreip136

🚥 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 is concise and accurately reflects the main change: adding updatedAt support for services.
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.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/service-updatedat-incremental-list

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.

@giurgiur99

Copy link
Copy Markdown
Contributor Author

/run-security-scan

@giurgiur99

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@alexcos20 alexcos20 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

AI automated code review (Gemini 3).

Overall risk: low

Summary:
This PR successfully adds the updatedAt timestamp to service jobs and implements the ability to incrementally sync jobs via updatedSince. The implementation handles backward compatibility correctly for existing records that lack the updatedAt field, and the unit tests are comprehensive and well-written.

Comments:
• [INFO][style] There is a minor typo in the validation error message (an extra space before the colon). Consider removing it for consistency with other error formats in this file.

-          'Parameter : "updatedSince" is not a valid string'
+          'Parameter "updatedSince" is not a valid string'

• [INFO][performance] While this aligns with existing code patterns, loading all service jobs into memory via getServiceJob() to perform application-level filtering can become a performance bottleneck at scale. As a future improvement, consider pushing this filtering down to the database query layer (e.g., utilizing SQLite's JSON functions like json_extract(json, '$.updatedAt') >= ?).
• [INFO][style] Good use of the object spread syntax to cleanly inject or overwrite the updatedAt timestamp into the persisted JSON payload before saving to the database. LGTM!

@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: 1

🤖 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/components/core/service/getServices.ts`:
- Around line 63-71: Update the updatedSince validation in the service request
flow around command.updatedSince and parseFromTimestamp to reject empty strings
and non-finite parsed timestamps before the all-jobs or unfiltered paths
execute. Preserve valid ISO dates and finite Unix timestamps, and add validation
tests covering an empty cursor and an overflowing numeric cursor that must
return a 400 response.
🪄 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 Plus

Run ID: 7479e9ea-a2eb-4017-bc54-b1b174789580

📥 Commits

Reviewing files that changed from the base of the PR and between 38507db and ea9e149.

📒 Files selected for processing (6)
  • src/@types/C2D/ServiceOnDemand.ts
  • src/@types/commands.ts
  • src/components/core/service/getServices.ts
  • src/components/database/sqliteCompute.ts
  • src/test/unit/service/serviceHandlers.test.ts
  • src/test/unit/service/serviceJobsDatabase.test.ts

Comment thread src/components/core/service/getServices.ts
@giurgiur99

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@giurgiur99

Copy link
Copy Markdown
Contributor Author

/run-security-scan

@alexcos20 alexcos20 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

AI automated code review (Gemini 3).

Overall risk: low

Summary:
This PR introduces incremental fetching of services by adding an updatedAt timestamp to ServiceJobs and allowing queries via the updatedSince parameter. The implementation handles backward compatibility correctly, and adds strict validation for timestamp inputs.

Comments:
• [INFO][security] Using Number.isFinite is an excellent improvement over strictly checking for null. This prevents invalid inputs that parse to NaN or Infinity (like overflowing string numbers) from bypassing validation, avoiding potential edge cases or unexpected behaviors downstream.
• [INFO][performance] Fetching all jobs into memory via await eng.db.getServiceJob() and filtering application-side is consistent with the existing codebase logic. However, for nodes maintaining a massive number of jobs, this could eventually become a memory and processing bottleneck. Consider moving filtering to the database query level (e.g., adding indexes and query arguments for clusterHash and updatedAt) in a future architectural refactor.
• [INFO][style] Using the object spread operator ...job to inject the updatedAt timestamp inside JSON.stringify is a clean pattern. It ensures the database payload gets the new field without unintentionally mutating the original job reference in memory.

LGTM!

@giurgiur99
giurgiur99 merged commit 85fa61b into next-4 Jul 23, 2026
10 checks passed
@giurgiur99
giurgiur99 deleted the feat/service-updatedat-incremental-list branch July 23, 2026 11:05
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.

3 participants