Skip to content

feat: apply store changes#413

Merged
luxass merged 117 commits intomainfrom
store-changes
Dec 27, 2025
Merged

feat: apply store changes#413
luxass merged 117 commits intomainfrom
store-changes

Conversation

@luxass
Copy link
Copy Markdown
Member

@luxass luxass commented Dec 20, 2025

🔗 Linked issue

📚 Description

This PR is very big one that changes alot of things. From the CLI to the Shared package.

Ideas:

  • Add feature to exclude files from being marked as orphaned
  • Make console.info, console.log output to stderr, when --json is used.
  • Implement Less for the files get command
  • Implement files info to list info about the files

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Dec 20, 2025

⚠️ No Changeset found

Latest commit: e38c2e2

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Dec 20, 2025

Important

Review skipped

Too many files!

51 files out of 201 files are above the max files limit of 150.

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

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch store-changes

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.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Dec 20, 2025

🌏 Preview Deployments

Application Status Preview URL
API ✅ Deployed View Preview
Website ✅ Deployed View Preview

Built from commit: e38c2e24cd6d0d4f0f0ac19823c43cd68986f9bb


🤖 This comment will be updated automatically when you push new commits to this PR.

Comment thread packages/ucd-store-v2/test/integration/store-operations.test.ts Fixed
Comment thread packages/ucd-store-v2/test/integration/store-operations.test.ts Fixed
Comment thread packages/ucd-store-v2/test/integration/store-operations.test.ts Fixed
Comment thread packages/cli/src/cmd/store/status.ts Fixed
Comment thread packages/cli/src/cmd/store/status.ts Fixed
Comment thread packages/cli/src/cmd/store/verify.ts Fixed
Comment thread packages/cli/src/cmd/store/verify.ts Fixed
Comment thread packages/cli/src/cmd/store/verify.ts Fixed
Comment thread packages/cli/src/cmd/store/verify.ts Fixed
Comment thread packages/fs-bridge/test/security/http/excessive-encoding.test.ts Fixed
Comment thread packages/fs-bridge/test/security/http/mixed-attacks.test.ts Fixed
Comment thread packages/fs-bridge/test/security/node/mixed-attacks.test.ts Fixed
Comment thread packages/fs-bridge/test/security/penetration-testing.test.ts Fixed
Comment thread packages/fs-bridge/test/security/penetration-testing.test.ts Fixed
Comment thread packages/ucd-store-v2/test/integration/store-operations.test.ts Fixed
Comment thread packages/ucd-store-v2/test/integration/store-operations.test.ts Fixed
Comment thread packages/ucd-store-v2/test/integration/store-operations.test.ts Fixed
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Dec 23, 2025

📋 OpenAPI Schema Analysis

Summary

Schema Components

Change Type Count Details
🟢 Added 0 New schema components
🔴 Removed 0
🟡 Modified 1 Changed schema definitions

Overall Status

Status Result
⚠️ Breaking Changes No - No breaking changes detected

Detailed Changes

📋 Schema Components Changes

Modified Schemas (1):

  • UCDWellKnownConfig

🤖 This comment is automatically updated when you push new commits.

Updated the UCD store to utilize a lockfile instead of a manifest for version management. This change includes the introduction of lockfile-related functions, adjustments to the internal context, and modifications to various operations to read from and write to the lockfile. The bootstrap, sync, and verification processes have been adapted to ensure compatibility with the new lockfile structure, enhancing the overall organization and maintainability of the codebase.
…test coverage

This commit finalizes the refactor of the test structure by implementing reusable test helpers and updating all relevant test files to utilize the new structure. The changes include the completion of various test files, such as bootstrap, sync, and verify tests, ensuring they now leverage the new lockfile management system. Additionally, unused variables in the sync tests were addressed, improving overall test coverage and maintainability.
This commit cleans up the list and tree test files by removing unnecessary blank lines, improving readability and maintaining consistency across the test suite.
… test coverage

This commit adds a new read-only filesystem bridge for testing purposes, allowing for better control over file operations during tests. It also updates the test utilities to include this new bridge and enhances the test suite for lockfile management, ensuring comprehensive coverage of various scenarios, including integration tests for store operations and snapshot handling. Additionally, it refactors existing tests to utilize the new bridge, improving maintainability and consistency across the test suite.
This commit introduces a comprehensive redesign of the CLI store commands to align with the new ucd-store-v2 API. Key changes include the addition of new commands (sync, mirror, verify, analyze, status) and the removal of deprecated commands (repair, clean). The CLI now supports an operation-based structure, enhanced lockfile inspection capabilities, and flexible flag options such as --force and --lockfile-only. Additionally, the package dependency has been updated to include @ucdjs/ucd-store-v2, ensuring compatibility with the new API.
…issue

This commit addresses two key issues in the CLI:
1. Corrects the property paths accessed from the AnalysisReport in the analyze command to align with the actual structure.
2. Fixes the getLockfilePath function to return a relative path instead of an absolute path, resolving the double directory path issue during initialization.

Additionally, updates are made to ensure consistent usage of the new path structure across various commands, including init, mirror, and file operations. This enhances the overall functionality and reliability of the CLI commands.
…ion plan

This commit introduces a detailed plan for verifying and fixing the fs-bridge path resolution security. The plan outlines various tasks, including analyzing current implementations, evaluating API improvements, creating comprehensive test suites for different path scenarios, and conducting security audits. It aims to ensure that path traversal is prevented and that both relative and absolute paths are handled securely, enhancing the overall security and maintainability of the fs-bridge.
…ion plan

This commit marks the completion of several tasks outlined in the fs-bridge path resolution security verification plan. Key updates include the analysis of the resolveSafePath implementation, the fs-bridge node and http bridges, and the creation of comprehensive test suites for various path scenarios, including edge cases and security tests. Additionally, the plan has been updated to reflect the current status of tasks, ensuring a clear overview of progress and next steps.
This commit introduces a suite of security tests for the HTTP bridge in the fs-bridge package. Key additions include tests for path traversal prevention, URL-encoded traversal attacks, boundary enforcement for shallow and deep pathnames, and handling of excessive and mixed encoding scenarios. The tests ensure that the HTTP bridge correctly enforces security measures against various attack vectors, enhancing the overall robustness of the system. Additionally, the plan has been updated to reflect the completion of these security test implementations.
This commit finalizes the implementation of security tests for the fs-bridge, focusing on preventing path traversal attacks through various vectors, including encoded paths and recursive directory listings. New test cases ensure that both the Node and HTTP bridges effectively handle malicious input and maintain robust security measures. Additionally, the comprehensive plan has been updated to reflect the completion of these critical security enhancements.
This commit removes the outdated FS Bridge documentation and introduces a new structure for the fs-bridge documentation, including an overview, hooks system, and detailed specifications for both Node.js and HTTP bridges. The hooks system allows users to monitor and debug file system operations effectively. Additionally, comprehensive usage examples and best practices are provided to enhance user understanding and implementation of the fs-bridge package.
This commit introduces new documentation for the capabilities system and error handling patterns within the fs-bridge package. The capabilities section explains how bridges detect and assert optional operations, while the error handling section outlines various error types and best practices for managing errors during bridge operations. Additionally, links to these new sections have been added to the main fs-bridge documentation for improved accessibility.
This commit introduces the `assertWriteCapability` function to ensure that the UCD store has the necessary write permissions before performing operations. The function is integrated into the `init`, `mirror`, `sync`, and `status` commands to provide early error handling for operations requiring write access. Additionally, the documentation for the `sync` operation is updated to reflect the new behavior, emphasizing the synchronization of lockfiles with API versions and the mirroring of files. This enhancement improves the robustness and user experience of the CLI commands.
@luxass luxass marked this pull request as ready for review December 27, 2025 06:03
Copilot AI review requested due to automatic review settings December 27, 2025 06:03
Copy link
Copy Markdown
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 introduces significant changes to the store management system, transitioning from a manifest-based approach to a lockfile-based approach with snapshots. The changes span across the CLI, shared packages, and core store functionality.

  • Replaced manifest system with lockfile and per-version snapshots for improved version tracking
  • Migrated from file-tree endpoints to per-version manifest endpoints
  • Added comprehensive test utilities for lockfile and snapshot creation
  • Enhanced filter support with extractable patterns and default exclusions

Reviewed changes

Copilot reviewed 177 out of 198 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
packages/ucd-store-v2/test/operations/analyze.test.ts Updated tests to use new test context helper and lockfile system
packages/ucd-store-v2/test/integration/store-operations.test.ts New integration tests for bootstrap→mirror→verify workflow
packages/ucd-store-v2/test/helpers/test-context.ts New test helper for creating test contexts with lockfiles
packages/ucd-store-v2/test/core/snapshot.test.ts New tests for snapshot read/write operations
packages/ucd-store-v2/test/core/lockfile.test.ts Updated lockfile tests to use new error types and paths
packages/ucd-store-v2/test/core/files.test.ts Updated to use manifest endpoint instead of file-tree
packages/ucd-store-v2/test/core/context.test.ts Updated property names from manifestPath to lockfilePath
packages/ucd-store-v2/test/core/config-discovery.test.ts New tests for config discovery and version extraction
packages/ucd-store-v2/src/types.ts Updated documentation from manifest to lockfile terminology
packages/ucd-store-v2/src/store.ts Refactored to use lockfile instead of manifest
packages/ucd-store-v2/src/setup/verify.ts Updated to use lockfile instead of manifest
packages/ucd-store-v2/src/setup/bootstrap.ts Updated to create lockfile instead of manifest
packages/ucd-store-v2/src/operations/sync.ts Major refactor to sync lockfile and mirror files
packages/ucd-store-v2/src/operations/mirror.ts Added snapshot creation and lockfile updates
packages/ucd-store-v2/src/operations/files/tree.ts Updated to use wrapTry instead of tryCatch
packages/ucd-store-v2/src/operations/files/list.ts Updated to use wrapTry instead of tryCatch
packages/ucd-store-v2/src/operations/files/get.ts Updated to use wrapTry and tryOr utilities
packages/ucd-store-v2/src/operations/analyze.ts Updated to use wrapTry and filter snapshot.json
packages/ucd-store-v2/src/factory.ts Added path resolution for basePath
packages/ucd-store-v2/src/core/files.ts Updated to use manifest endpoint instead of file-tree
packages/ucd-store-v2/src/core/context.ts Added filter pattern extraction utility
packages/ucd-store-v2/package.json Added lockfile dependency and test-utils imports
packages/test-utils/src/mock-store/handlers/well-known.ts Added per-version manifest endpoint handler
packages/test-utils/src/mock-store/handlers/file-tree.ts Updated to support version-specific file responses
packages/test-utils/src/fs-bridges/memory-fs-bridge.ts Enhanced with explicit directory support and function overrides
packages/test-utils/src/fs-bridges/read-only-bridge.ts New read-only bridge for testing
packages/shared/src/fetch/fetch.ts Added schema validation support
packages/shared/src/filter.ts Exported default exclusions constant
packages/shared/src/async/try-catch.ts Added tryOr utility and renamed tryCatch to wrapTry
packages/schemas/src/manifest.ts New schema for per-version manifests
packages/schemas/src/lockfile.ts Added filters field to lockfile schema
packages/lockfile/* New package for lockfile operations

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

// We can't proceed with the sync operation.
if (configResult.error || !configResult.data) {
// TODO: handle this error better.
throw new Error("Failed to fetch versions from API");
Copy link

Copilot AI Dec 27, 2025

Choose a reason for hiding this comment

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

The error message "Failed to fetch versions from API" is generic and doesn't provide details about why the fetch failed. Consider including the underlying error information from configResult.error if available.

Suggested change
throw new Error("Failed to fetch versions from API");
const errorDetail =
configResult.error && (configResult.error as any).message
? `: ${(configResult.error as any).message}`
: configResult.error
? `: ${String(configResult.error)}`
: "";
throw new Error(`Failed to fetch versions from API${errorDetail}`);

Copilot uses AI. Check for mistakes.
* Gets the default lockfile path for a given base path.
* The lockfile is always named `.ucd-store.lock` regardless of base path.
*
* @param {string} _basePath - Base path (unused, kept for API compatibility)
Copy link

Copilot AI Dec 27, 2025

Choose a reason for hiding this comment

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

The parameter _basePath is prefixed with underscore to indicate it's unused, but according to the JSDoc it's "kept for API compatibility". Consider either removing this parameter entirely if it's not needed for compatibility, or using a more descriptive name without the underscore prefix if it might be used in the future.

Suggested change
* @param {string} _basePath - Base path (unused, kept for API compatibility)
* @param {string} _basePath - Base path (currently unused; reserved for API stability)

Copilot uses AI. Check for mistakes.
@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented Dec 27, 2025

Greptile Summary

  • Implements major UCD store refactor from v1 to v2 with new lockfile-based architecture replacing manifest files for better version tracking and file integrity management
  • Adds comprehensive CLI enhancements including new files command suite (get, list, info), store operations (sync, mirror, verify, status), and improved JSON output handling with stderr redirection
  • Introduces new @ucdjs/lockfile package with snapshot management, comprehensive security hardening across fs-bridge package with path traversal protection, and modernizes error handling utilities from tryCatch to wrapTry

Important Files Changed

Filename Overview
packages/lockfile/src/index.ts New lockfile package providing file integrity tracking and snapshot management for UCD stores
packages/cli/src/output.ts New centralized CLI output utility implementing JSON mode with stderr redirection for console.info/log
packages/ucd-store-v2/src/store.ts Major refactor from manifest-based to lockfile-based store management with enhanced version conflict handling
packages/shared/src/async/try-catch.ts Significant expansion adding tryOr function and renaming tryCatch to wrapTry for improved error handling patterns
apps/api/vitest.config.worker.ts Deleted Cloudflare Workers-specific test configuration, potentially consolidating into main config

Confidence score: 2/5

  • This PR contains extensive changes that could introduce breaking functionality and has several concerning implementation issues
  • Score lowered due to missing imports (arraysEqual in store.ts), logical inconsistencies (commented-out assertions, debug output in production commands), potential test infrastructure breakage from worker config deletion, and incomplete refactoring patterns
  • Pay close attention to packages/ucd-store-v2/src/store.ts for missing imports, packages/cli/src/cmd/store/status.ts for unintentional debug output, and apps/api/vitest.config.worker.ts deletion impact on worker testing

Copy link
Copy Markdown

@greptile-apps greptile-apps Bot left a comment

Choose a reason for hiding this comment

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

Additional Comments (7)

  1. apps/api/vitest.config.worker.ts

    logic: Removing worker test configuration will break Cloudflare Workers-specific tests. Check that worker tests are properly configured elsewhere or that this deletion is intentional. Are the worker tests now handled by a different configuration, or should this deletion be reconsidered?

  2. packages/ucd-store-v2/package.json, line 16 (link)

    syntax: Directory path references old 'ucd-store' instead of 'ucd-store-v2' - should be updated for consistency

  3. packages/ucd-store-v2/src/types.ts, line 14-15 (link)

    syntax: Comment still references 'manifest' but should say 'lockfile' for consistency

  4. packages/test-utils/src/mock-store/utils.ts, line 103-104 (link)

    style: Comment still references the old :wildcard+ pattern but describes the correct behavior

  5. packages/cli/src/cmd/store/root.ts, line 28 (link)

    logic: Redundant condition - !isValidSubcommand(subcommand) is checked twice

  6. packages/client/test/resources/manifest.test.ts, line 58 (link)

    style: inconsistent approach - this test uses actual version interpolation while others use placeholder pattern

    Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

  7. packages/ucd-store-v2/src/operations/mirror.ts, line 225-247 (link)

    logic: The totalMetricValue variable is computed using report before report is fully assigned, causing it to use the previous iteration's values. This creates incorrect metric calculations.

197 files reviewed, 45 comments

Edit Code Review Agent Settings | Greptile

Comment thread packages/cli/test/cmd/store/verify.test.ts Outdated
Comment thread apps/api/vitest.config.ts
Comment thread packages/fs-bridge/test/security/http/excessive-encoding.test.ts
Comment thread packages/schemas/src/lockfile.ts
Comment thread packages/cli/src/cmd/store/status.ts
Comment on lines +141 to +143
await expect(
bridge.read("//etc/passwd"),
).rejects.toThrow();
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

logic: The comment suggests this should not throw a traversal error, but the test expects it to throw - clarify the expected behavior. Should protocol-relative URLs throw PathTraversalError or just file not found errors?

Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/fs-bridge/test/security/penetration-testing.test.ts
Line: 141:143

Comment:
**logic:** The comment suggests this should not throw a traversal error, but the test expects it to throw - clarify the expected behavior. Should protocol-relative URLs throw PathTraversalError or just file not found errors?

How can I resolve this? If you propose a fix, please make it concise.

Comment on lines +285 to +287
// Empty string should resolve to basePath
const exists = await bridge.exists(" ");
expect(exists).toBe(true);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

logic: This test assumes whitespace-only paths resolve to basePath directory existence - verify this behavior is intentional. Is it intentional that whitespace-only paths should return true for exists()?

Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/fs-bridge/test/security/penetration-testing.test.ts
Line: 285:287

Comment:
**logic:** This test assumes whitespace-only paths resolve to basePath directory existence - verify this behavior is intentional. Is it intentional that whitespace-only paths should return true for exists()?

How can I resolve this? If you propose a fix, please make it concise.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yes, because the underlying bridge calls resolveSafePath which trims the string, and run it trough path.normalize which causes it to be a .

Comment thread apps/api/test/routes/v1_files/$wildcard.test.ts Outdated
Comment thread apps/api/test/routes/v1_files/$wildcard.test.ts Outdated
Comment thread apps/api/test/routes/v1_files/$wildcard.test.ts Outdated
- Introduced `toMatchError` matcher for enhanced error assertions.
- Updated `vitest-setup.ts` to include the new matcher.
- Modified `tsdown.config.ts` and `base.json` to reference new matcher files.
- Adjusted `vitest.config.ts` to include the new matcher setup file.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api Changes related to the API. web Changes related to the Website.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants