diff --git a/docs/architecture/code-index-architecture.md b/docs/architecture/code-index-architecture.md index 1573ed82c17..b35e9f7f91c 100644 --- a/docs/architecture/code-index-architecture.md +++ b/docs/architecture/code-index-architecture.md @@ -348,12 +348,12 @@ applies it. Per touched file the apply upserts what the delta emits and tombston file's `scip` rows it no longer emits; a deleted file is tombstoned whole. Re-applying a delta gives the same live set. -| Producer | Language | Watermark | Workers | How it runs | -| ----------------- | ----------------------- | ---------------- | ------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `scip-clang` | C++ | `scip_commit` | `code_scip_full`, `code_scip_delta`, `code_scip_apply` | Changed TUs (and TUs including changed headers, capped) via `run_delta.sh`; `code_scip_full` seeds the tier and re-indexes it weekly. | -| `scip-typescript` | TypeScript / JavaScript | `scip_commit_ts` | `code_scip_ts_delta` | Indexes named projects, or the members of an umbrella root tsconfig (including explicit tsconfig file references); a delta indexes only the projects that contain the window's files unless a shared config or lockfile changed, or a changed TypeScript path sits outside every member. The converter still bounds the output to the TypeScript window. | -| `scip-go` | Go | `scip_commit_go` | `code_scip_go_delta` | One build per module (`run_go_monorepo_delta.sh`). | -| `scip-python` | Python | `scip_commit_py` | `code_scip_py_delta`, `code_scip_apply` | Per-merge delta (`run_python_delta.sh`); a first run indexes the tree. | +| Producer | Language | Watermark | Workers | How it runs | +| ----------------- | ----------------------- | ---------------- | ------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `scip-clang` | C++ | `scip_commit` | `code_scip_full`, `code_scip_delta`, `code_scip_apply` | Changed TUs (and TUs including changed headers, capped) via `run_delta.sh`; `code_scip_full` seeds the tier and re-indexes it weekly. | +| `scip-typescript` | TypeScript / JavaScript | `scip_commit_ts` | `code_scip_ts_delta` | Indexes named projects, or the members of an umbrella root tsconfig (including explicit tsconfig file references); a delta indexes only the projects that contain the window's files unless a shared config or lockfile changed, or a TypeScript file no project contains changed beside one that selects a project; a window whose only changes are TypeScript files outside every project indexes none. The converter still bounds the output to the TypeScript window. | +| `scip-go` | Go | `scip_commit_go` | `code_scip_go_delta` | One build per module (`run_go_monorepo_delta.sh`). | +| `scip-python` | Python | `scip_commit_py` | `code_scip_py_delta`, `code_scip_apply` | Per-merge delta (`run_python_delta.sh`); a first run indexes the tree. | `code/domain/index/compiler_tiers.py` (`TIERS`) is the one table of watermark, label and workers per producer; status handlers and the dashboard read it. A delta worker diff --git a/scripts/scip_harness/run_typescript_delta.sh b/scripts/scip_harness/run_typescript_delta.sh index 2353888518d..0b0fa745574 100755 --- a/scripts/scip_harness/run_typescript_delta.sh +++ b/scripts/scip_harness/run_typescript_delta.sh @@ -151,9 +151,10 @@ JSONEOF if [[ ${#targets[@]} -eq 0 ]]; then # No member list: a regular root tsconfig (or a pnpm/yarn workspace) # is indexed by invoking scip-typescript on the checkout with only the - # workspace flags. An umbrella whose members were all skipped still - # writes an empty index. - if [[ ${#PROJECTS[@]} -eq 0 ]]; then + # workspace flags. A member list whose members were all skipped, or a + # delta that selected none (only TypeScript files no member owns changed), still + # writes an empty index: the root pass is what the list exists to avoid. + if [[ ${#ALL_PROJECTS[@]} -eq 0 ]]; then NODE_OPTIONS="--max-old-space-size=$NODE_HEAP_MB" \ "$SCIP_TYPESCRIPT" index "${ws[@]}" --output "$WORK/index.scip" >&2 else @@ -200,7 +201,7 @@ if [[ "$BASE" != "--full" ]]; then mapfile -t PROJECTS <<<"$filtered" else # An empty filter is a real empty selection (e.g. an unowned - # package.json). Do not keep the full member set. + # package.json or TypeScript file). Do not keep the full member set. PROJECTS=() fi # A package manifest, lockfile, or tsconfig in a selected member (or a diff --git a/scripts/scip_harness/scip_ts_projects.py b/scripts/scip_harness/scip_ts_projects.py index 48a1d08e210..d60f08a8665 100755 --- a/scripts/scip_harness/scip_ts_projects.py +++ b/scripts/scip_harness/scip_ts_projects.py @@ -6,8 +6,11 @@ workspace: scip-typescript loads every referenced project at once and can exhaust the heap. This helper expands that root to its member project directories or explicit tsconfig files, and on a delta pass keeps only the -members that contain a changed path. A change to a shared config or lockfile, -or a TypeScript path that no member owns, falls back to the full member set. +members that contain a changed path. A change to a shared config or lockfile +falls back to the full member set, and so does a TypeScript path that no +member owns when the window also selects a member or changes a manifest or +lockfile. A window whose only changes are such paths selects none: the merge +keeps a document only from a member that owns it. """ from __future__ import annotations @@ -249,8 +252,11 @@ def is_index_trigger(relpath: str) -> bool: def select_projects_for_delta(projects: list[str], changed_paths: list[str]) -> list[str]: - """Projects to index for this window. Shared config/lockfile changes, or - any TypeScript path that no named project owns, keep the full set. + """Projects to index for this window. Shared config/lockfile changes keep + the full set. A TypeScript path that no named project owns keeps the full + set when the window also selects a project or changes a manifest or + lockfile, and selects none when the window holds nothing else: the merge + would drop it from every member's index. A non-TypeScript, non-config change inside a member (a README, for example) does not select that member. @@ -269,7 +275,10 @@ def select_projects_for_delta(projects: list[str], changed_paths: list[str]) -> for path in changed_paths if is_typescript_path(path) and not any(project_owns(project, path) for project in projects) ] - if unowned_ts: + if unowned_ts and (selected or any(is_project_config_change(path) for path in changed_paths)): + # The converter reads definition kinds from the members it is given, so a + # narrower set would write fewer `calls` edges for the owned files than the + # full set does; an unowned manifest rebuilds every member, as before. return list(projects) return selected diff --git a/tests/unit/test_run_typescript_delta_umbrella.py b/tests/unit/test_run_typescript_delta_umbrella.py index 1890760170b..e125bcdffa1 100644 --- a/tests/unit/test_run_typescript_delta_umbrella.py +++ b/tests/unit/test_run_typescript_delta_umbrella.py @@ -208,6 +208,26 @@ def test_delta_with_owned_and_unowned_typescript_indexes_every_member(tmp_path: assert _targets(_runs(log)) == ["packages/app", "packages/lib"] +def test_delta_with_only_an_unowned_typescript_path_runs_no_indexer(tmp_path: Path) -> None: + """No member owns tools/build.ts, so no member index can hold it. The harness + runs no indexer, neither the members nor the checkout root, and still writes + the window's delta.""" + repo = _repo(tmp_path) + (repo / "tools").mkdir() + (repo / "tools/build.ts").write_text("export const t = 1;\n") + _git(repo, "add", "-A") + _git(repo, "-c", "user.name=t", "-c", "user.email=t@t", "commit", "-qm", "tools") + base = _git(repo, "rev-parse", "HEAD") + (repo / "tools/build.ts").write_text("export const t = 2;\n") + _git(repo, "add", "-A") + _git(repo, "-c", "user.name=t", "-c", "user.email=t@t", "commit", "-qm", "edit tools") + head = _git(repo, "rev-parse", "HEAD") + log = _run(tmp_path, repo, base, head) + assert _runs(log) == [] + assert "--changed-files" in _convert_args(log) + assert (tmp_path / "delta.json").is_file() + + def test_member_path_with_a_space_survives_full_and_delta_passes(tmp_path: Path) -> None: repo = tmp_path / "repo" files = { diff --git a/tests/unit/test_scip_ts_projects.py b/tests/unit/test_scip_ts_projects.py index 98cf5f5bab7..abd802f1596 100644 --- a/tests/unit/test_scip_ts_projects.py +++ b/tests/unit/test_scip_ts_projects.py @@ -139,9 +139,21 @@ def test_discover_preserves_explicit_tsconfig_file_references(tmp_path: Path) -> assert discover_umbrella_projects(tmp_path) == ["packages/app/tsconfig.build.json"] -def test_delta_falls_back_when_any_typescript_path_is_unowned() -> None: +def test_a_typescript_path_no_member_owns_selects_no_member() -> None: + """The merge keeps a document only from a member that owns it, so no member's + index can hold an unowned path: indexing every member for it converts nothing.""" + projects = ["packages/app", "packages/lib"] + assert select_projects_for_delta(projects, ["tools/build.ts"]) == [] + assert select_projects_for_delta(projects, ["tools/build.ts", "README.md"]) == [] + + +def test_an_unowned_path_beside_a_selecting_one_keeps_the_full_set() -> None: + """The converter reads definition kinds from every member it is given: a narrower + set would write fewer `calls` edges for the window's owned files than the full set.""" projects = ["packages/app", "packages/lib"] assert select_projects_for_delta(projects, ["packages/app/src/a.ts", "outside.ts"]) == projects + # an unowned manifest beside it rebuilds every member, as before + assert select_projects_for_delta(projects, ["tools/build.ts", "tools/package.json"]) == projects assert select_projects_for_delta( ["packages/app/tsconfig.build.json", "packages/lib"], ["packages/app/src/a.ts"],