Skip to content

refactor(cache): remove timestamp fields from lock#32

Merged
fbosch merged 2 commits intomasterfrom
fix/relax-timestamping
Mar 25, 2026
Merged

refactor(cache): remove timestamp fields from lock#32
fbosch merged 2 commits intomasterfrom
fix/relax-timestamping

Conversation

@fbosch
Copy link
Owner

@fbosch fbosch commented Mar 25, 2026

Summary

Eliminate timestamp tracking from lock file schema.

Motivation

It was introducing changes and possibly merge conflicts while nothing in the referenced sources was actually changed and provided no benefits.

Changes

  • Remove generatedAt from lock interface and validation
  • Remove updatedAt from source interface and validation
  • Delete timestamp generation in sync command
  • Update fixtures and tests to match schema

Summary by CodeRabbit

  • Refactor

    • Simplified the lock file format by removing generatedAt and per-source updatedAt timestamps, reducing transient metadata in emitted lock files.
  • Tests

    • Updated fixtures and test assertions to align with the simplified lock format, removing expectations for the removed timestamp fields.

Copilot AI review requested due to automatic review settings March 25, 2026 13:10
@pkg-pr-new
Copy link

pkg-pr-new bot commented Mar 25, 2026

Open in StackBlitz

npx https://pkg.pr.new/docs-cache@32

commit: 0933431

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors the docs cache lockfile schema to remove timestamp fields (generatedAt on the lock, updatedAt per source) so lockfiles are stable and don’t change due to time-based noise.

Changes:

  • Remove generatedAt / updatedAt from lockfile TypeScript interfaces and runtime validation.
  • Stop generating timestamps in the sync command when building the lock.
  • Update test fixtures and several sync-related tests to match the new schema.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tests/sync-offline-fail.test.js Removes timestamp fields from lock JSON written in offline sync tests.
tests/sync-materialize.test.js Removes timestamp fields from lock JSON written in materialization tests.
tests/lock.test.js Updates lock read/write test to no longer depend on generatedAt.
tests/fixtures/empty.docs-lock.json Removes generatedAt from fixture.
tests/fixtures/docs-lock.json Removes generatedAt and per-source updatedAt from fixture.
src/commands/sync.ts Stops generating and writing timestamps when building lock entries.
src/cache/lock.ts Updates lock/source interfaces and validateLock to drop timestamp requirements.

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

@coderabbitai
Copy link

coderabbitai bot commented Mar 25, 2026

📝 Walkthrough

Walkthrough

Removed per-lock and per-source timestamp fields: generatedAt and updatedAt were removed from the lock schema, related interfaces and generation logic were updated, and tests/fixtures were adjusted to no longer include or assert those timestamps.

Changes

Cohort / File(s) Summary
Lock structure interfaces
src/cache/lock.ts
Removed updatedAt from DocsCacheLockSource and generatedAt from DocsCacheLock; validation/parsing of those timestamp fields removed.
Lock generation logic
src/commands/sync.ts
Stopped computing/propagating a single now timestamp; buildLockSource no longer accepts/sets updatedAt; buildLock no longer sets generatedAt.
Test fixtures
tests/fixtures/docs-lock.json, tests/fixtures/empty.docs-lock.json
Removed top-level generatedAt and per-source updatedAt fields; other lock fields unchanged.
Tests
tests/lock.test.js, tests/sync-materialize.test.js, tests/sync-offline-fail.test.js, tests/edge-cases.test.js
Removed/updated assertions and test lock objects to omit generatedAt and updatedAt; adjusted expectations accordingly.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐇 I hopped through locks with nimble feet,
Removed the ticks that tracked the beat,
Now lighter files and cleaner lines,
A rabbit’s tweak — small, spry, and fine.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'refactor(cache): remove timestamp fields from lock' accurately summarizes the main change: removing timestamp fields (generatedAt and updatedAt) from the lock schema across interfaces, implementation, fixtures, and tests.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/relax-timestamping

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

@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.

🧹 Nitpick comments (1)
tests/lock.test.js (1)

49-50: Consider asserting full lock round-trip, not a single field.

Line 50 checks toolVersion, but deepEqual(parsed, lock) would better protect against accidental omissions in serialized lock fields.

♻️ Suggested test tightening
 const parsed = await module.readLock(tmpPath);
-assert.equal(parsed.toolVersion, lock.toolVersion);
+assert.deepEqual(parsed, lock);
As per coding guidelines, “Add or update tests for behavior changes and bug fixes; prefer extending existing test coverage in `tests/` before adding new files”.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/lock.test.js` around lines 49 - 50, Replace the single-field assertion
with a full round-trip equality check: after calling module.readLock(tmpPath)
(the parsed variable) assert that parsed deeply equals the original lock object
(lock) instead of only checking parsed.toolVersion; update the test assertion to
use a deep equality matcher (e.g., deepEqual/strictDeepEqual depending on test
framework) so the entire serialized/deserialized lock is validated.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@tests/lock.test.js`:
- Around line 49-50: Replace the single-field assertion with a full round-trip
equality check: after calling module.readLock(tmpPath) (the parsed variable)
assert that parsed deeply equals the original lock object (lock) instead of only
checking parsed.toolVersion; update the test assertion to use a deep equality
matcher (e.g., deepEqual/strictDeepEqual depending on test framework) so the
entire serialized/deserialized lock is validated.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 6c7907ed-710c-4969-b336-03b4bb922c05

📥 Commits

Reviewing files that changed from the base of the PR and between 20b4dd8 and 921bcf2.

📒 Files selected for processing (7)
  • src/cache/lock.ts
  • src/commands/sync.ts
  • tests/fixtures/docs-lock.json
  • tests/fixtures/empty.docs-lock.json
  • tests/lock.test.js
  • tests/sync-materialize.test.js
  • tests/sync-offline-fail.test.js
💤 Files with no reviewable changes (4)
  • tests/fixtures/empty.docs-lock.json
  • tests/sync-materialize.test.js
  • tests/sync-offline-fail.test.js
  • src/cache/lock.ts

Copy link

@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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
tests/edge-cases.test.js (1)

241-262: ⚠️ Potential issue | 🟠 Major

This test asserts raw JSON shape, not lock-schema validation behavior.

assert.equal(parsed.toolVersion, undefined) only proves the file was written without that key. It does not verify that the lock reader/validator rejects missing required fields (toolVersion, sources). This can pass even if validation regresses.

Please assert the validation path throws (e.g., via validateLock/lock read API) for this payload instead of asserting undefined on raw JSON.parse.

As per coding guidelines: “tests/**/*.{js,ts,mjs,cjs}: Add or update tests for behavior changes and bug fixes; prefer extending existing test coverage in tests/ before adding new files”.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/edge-cases.test.js` around lines 241 - 262, The test currently only
asserts the raw JSON shape (parsed.toolVersion === undefined) instead of
verifying the lock reader/validator rejects missing required fields; update the
test to call the lock validation/read API (e.g., validateLock(invalidLock) or
await readLock(lockPath) / readLockFile(lockPath)) and assert that it throws an
error for this invalid payload; keep the existing invalidLock, lockPath and
DEFAULT_LOCK_FILENAME variables but replace the JSON.parse assertion with a
thrown-validation assertion (using your test framework's reject/throws helper)
to ensure missing toolVersion and sources are rejected.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@tests/edge-cases.test.js`:
- Around line 241-262: The test currently only asserts the raw JSON shape
(parsed.toolVersion === undefined) instead of verifying the lock
reader/validator rejects missing required fields; update the test to call the
lock validation/read API (e.g., validateLock(invalidLock) or await
readLock(lockPath) / readLockFile(lockPath)) and assert that it throws an error
for this invalid payload; keep the existing invalidLock, lockPath and
DEFAULT_LOCK_FILENAME variables but replace the JSON.parse assertion with a
thrown-validation assertion (using your test framework's reject/throws helper)
to ensure missing toolVersion and sources are rejected.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 28d79157-1d96-43d2-b543-e5a679897a1e

📥 Commits

Reviewing files that changed from the base of the PR and between 921bcf2 and 0933431.

📒 Files selected for processing (2)
  • tests/edge-cases.test.js
  • tests/lock.test.js
🚧 Files skipped from review as they are similar to previous changes (1)
  • tests/lock.test.js

@fbosch fbosch merged commit 5201395 into master Mar 25, 2026
16 checks passed
@fbosch fbosch deleted the fix/relax-timestamping branch March 25, 2026 13:25
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