feat(ws-changed): workspace dependency graph + affected-package selection - #106
Merged
Conversation
Contributor
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
New first-party package
packages/ws-changedthat answers "which workspace packages does this changeset affect?" — the input for change-aware CI (run only the tests a feature branch can reach) without depending onpnpm --filter/ lerna / nx.Two concerns are deliberately separated:
What is a "package" and what depends on what? — pluggable
WorkspaceProviders, because the same repo has different dependency graphs depending on the question:pnpm— JS workspace packages frompnpm-workspace.yaml(orpackage.jsonworkspaces) + each manifest's dep maps. A dep is an internal edge whenever its name is a workspace package — everyworkspace:protocol variant (workspace:*,workspace:^,workspace:~,workspace:^1.2.3,workspace:1.2.3) and a bare semver range when a workspace package publishes under that name (how this dist-publishing monorepo references itself). Edge kinds (prod/dev/peer/optional) are selectable.pgpm— Postgres modules from each dir's<name>.controlrequires+pgpm.plan%project; out-of-workspace requires (plpgsql, extensions) recorded asexternal.glob— plain directories, no edges.registerProvider()for custom graphs — the domain-agnostic extension point.Multiple providers compose:
provider: ['pnpm','pgpm']unions the node sets by name and merges edges, so you get JS and SQL edges on the same nodes.What's affected? —
affected = changed ∪ transitive dependents:Configuration is via
confstash(ws-changed.config.{ts,js,json},.ws-changedrc*, or aws-changedkey inpackage.json), overridable per-call and per CLI flag (--provider pnpm,pgpm,--global,--include/--exclude,--config,WS_CHANGED_GLOBAL). Changed files come fromgit-changed. Zero third-party runtime deps (only the two workspace packages).CLI:
ws-changed --base origin/main [--json] [--why] [--dirs] [--changed] [--list] [--graph].WorkspaceGraphalso exposes direct/transitive dependencies & dependents, deterministic topological sort, and cycle detection (throws a readable cycle path).This is M1 of the CI/CD affected-test plan (constructive-planning#1435); the pgpm edge provider wiring into constructive-db's shard planner is later milestones.
Testing
packages/ws-changed: 60 Jest tests across 10 suites (glob expansion & matching, workspace-file parsing, both providers incl. everyworkspace:variant, graph traversal/topo/cycles, affected selection incl. root/global/--why, provider composition, confstash loading + overrides, CLI parse + run). All green.pnpm lint(eslint) andmakage build(CJS+ESM) clean.ws-changedto the CI test matrix in.github/workflows/ci.yml.packages/ws-changedimporter entry (deps already in the workspace);pnpm install --frozen-lockfileverified with pnpm 10.12.2 (CI's version).constructive-db:--provider pgpmresolves 87 modules with correct realrequiresedges.Link to Devin session: https://app.devin.ai/sessions/b4c06a1e03c840e680ba2e99a1385532
Requested by: @pyramation