Skip to content

TypeScript member runs index each referenced project once - #2008

Merged
zlareb1 merged 10 commits into
ClickHouse:mainfrom
KaloyanNaumov:pr/ts-closure-runs
Dec 3, 2026
Merged

zlareb1 merged 10 commits into
ClickHouse:mainfrom
KaloyanNaumov:pr/ts-closure-runs

Conversation

@KaloyanNaumov

@KaloyanNaumov KaloyanNaumov commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Title: TypeScript member runs index each referenced project once

Related: #1961

TL;DR: one scip-typescript process per member re-indexed every project the member references, so typescript-eslint's 36 members made 289 project runs for 37 projects. The harness now runs each project once, only for the members whose merge can keep its documents, and feeds the merge the same inputs, so the rows are identical. On typescript-eslint a full pass takes 290 s instead of 550 s and a one-package delta 18 s instead of 45 s, with a smaller largest process.

Changelog category (leave one):

  • Performance Improvement

Changelog entry (one or two sentences a user of Loom can read without the diff; the release pull request collects these into the release notes):

The TypeScript pass over a monorepo whose member projects reference each other indexes each referenced project once, and a delta no longer indexes the packages a changed member references, with the same rows and a smaller indexer process.

Why

Since #1782 the harness runs one scip-typescript process per member. scip-typescript 0.4.0 indexes every project a target references, recursively, in the same process (indexSingleProject in dist/src/main.js), and the merge then drops the copies the member does not own. On typescript-eslint, whose members are per-package tsconfig.build.json and tsconfig.spec.json files that reference the build configs of their dependencies, the 36 member processes run 289 projects; the members' closures hold 37. A delta that edits packages/utils selects utils' two configs and the root-level tsconfig.repo-config-files.json, whose closure holds 17 projects.

scip_ts_projects.py plan walks each selected member's references as the indexer does (references first, depth first, each argument once per process; a files: [] solution config is walked, not run) and returns one run per project:

  • A project with references runs through a config generated beside its own, {"extends": "./<name>"}, created exclusively under a fresh name (.scip-norefs.<random>.<name>, mkstemp). references is the one field extends does not inherit, so the program has the same files and options and the indexer stops there. The leading dot keeps the file out of * include globs; the harness removes on exit only the files the plan created, so a file already in the tree is never overwritten or deleted.
  • The merge receives each run's index once for every member whose process would have indexed it, in that order, so --project ownership and the last-copy rule see the same documents in the same order as before.
  • A pair whose documents the merge would drop is left out, and a project left with no pair does not run. The merge keeps a document for a member only when the member's scope is the document's most specific owner, so when every files and include entry of a referenced project, through its extends chain, lies in the project's directory, and that directory is outside the member's scope or inside a more specific member's, the member gets nothing from it. An entry outside the directory, or an extends the helper cannot find, keeps the pair.

A member without references gets the same single run as on main.

Shapes measured on typescript-eslint a1faa174 (scip-typescript 0.4.0, node 22, 8 GiB heap):

shape processes project runs wall peak RSS, largest process files / symbols / edges
--full, main: one process per member 36 289 550 s 0.93 GiB 1,358 / 6,628 / 4,220
--full, one process over all members 1 37 153 s 1.69 GiB 1,358 / 6,628 / 4,220, one file differs
--full, one process, --no-global-caches 1 37 135 s 2.00 GiB not converted
--full, this change 37 37 290 s 0.85 GiB identical to main, file by file
delta, one edit in packages/utils/src, main 3 33 45 s 0.79 GiB 1 / 1 / 0
the same delta, this change 4 4 18 s 0.30 GiB identical to main

The first, second and fourth rows ran at the same time on one host, and the two delta rows likewise; the third ran earlier under a lighter load, so its wall time reads low against the others. The one-process shapes are faster because the indexer's source-file cache spans every project, and that cache is the heap #1782 split the umbrella to avoid: the single process grows to 1.69 GiB here, and on the repository from #1678 the root pass needed 39 GB. --no-global-caches does not bound it (2.00 GiB). One process also writes every project's documents into one index without saying which project emitted each: split by owner path with the existing merge, it keeps the copy of packages/eslint-plugin/typings/eslint-rules.d.ts emitted by another project, so one file's rows differ from main. One process per project keeps the largest process at the largest single project, below main's, and the merge sees the same inputs.

On the repository from #1678 no member references another project: the plan gives each of its 222 members the same single run as main and writes no generated config, so the change does not alter that pass.

Scope and risk

scripts/scip_harness/scip_ts_projects.py (the plan subcommand), scripts/scip_harness/run_typescript_delta.sh (runs the plan; the merge call is unchanged), the architecture row for scip-typescript, and tests. Deltas keep their selection: only the members that own a changed path are planned. A member that shares references with a selected member but owns no changed path does not run, as before, because the merge keeps none of its documents from the selected members' runs.

Limits:

  • A referenced project runs in a process of its own. A referenced config whose include matches no file made no output inside a member's process; on its own the indexer exits 1 with "no files got indexed" and deletes its output. The plan marks each run as a member without references, which ran alone before, or not. For any other run, the part is read as empty, which the merge already accepts, only on the indexer's own report: exit 1, no output file, error: no files got indexed. as the only thing on stdout and nothing on stderr (a process that throws prints the same line, then its stack on stderr; a project whose tsconfig fails to load prints its diagnostics on stdout before the same line). Any other failure, a killed process included, stops the pass with the indexer's exit status before the merge. A later scip-typescript that words the report differently fails the pass instead of being read as empty. Only a files: [] solution config is recognised and skipped. On main a member without references that matches no file already fails the pass, and still does.
  • scip-typescript stops its package.json search at a project argument that names a directory, and a reference arrives as one. A project reached through a directory reference that has references of its own now runs through its generated config, a file, so a file of it with no package.json between it and that directory gets the package above that directory instead of an anonymous one. typescript-eslint references configs by file; the repository from The TypeScript tier cannot index a large monorepo through its root tsconfig, and every delta repeats the full cost #1678 has no references.
  • A jsconfig.json (scip-typescript adds compiler options by that name) and a project outside the checkout run as they are and still index their own references.

Compatibility, rollout and rollback

  • Wire: none.
  • Operator steps: none. The rows do not change, so no reindex is needed.
  • Rollback: revert; the next pass runs one process per member again.

Tests

  • tests/unit/test_run_typescript_delta_umbrella.py::test_full_pass_indexes_each_project_of_a_shared_closure_once: an umbrella with members packages/app and packages/lib, where app references lib and packages/app/tools, which no member names. The stub indexer follows references as scip-typescript 0.4.0 does and writes one document per project it indexes. Each tsconfig is indexed once, app through its generated config; the merged index holds the documents of app, app/tools and lib; git status --ignored is empty afterwards. On main it fails: lib is indexed twice.
  • test_run_typescript_delta_umbrella.py::test_delta_indexes_the_closure_of_the_selected_member_only: an edit in app runs app and tools, not lib, and merges app's and tools' documents; an edit in lib runs lib alone. Fails on main, where app's process also indexes lib.
  • test_run_typescript_delta_umbrella.py::test_a_referenced_project_that_matches_no_file_does_not_fail_the_pass: app references shared, whose include matches no file. The stub indexer prints 0.4.0's "no files got indexed" line, exits 1 and writes no output for a process that indexed no document. The pass completes, only app is indexed and merged, and the checkout is clean. It fails without the empty-run rule.
  • test_run_typescript_delta_umbrella.py::test_a_referenced_indexer_killed_before_its_output_fails_the_pass: the stub prints the report line, then exits 137 before writing for packages/app/tools, which no member names. The pass exits 137 and the converter is not called. Before the confirmed-empty rule the pass read that run as empty and converted (DID NOT RAISE CalledProcessError).
  • test_run_typescript_delta_umbrella.py::test_a_referenced_project_whose_tsconfig_fails_to_load_fails_the_pass: the stub prints error TS5023: Unknown compiler option 'bogusOption'., a blank line and the report line for packages/app/tools, then exits 1. The pass exits 1 and the converter is not called. With the report line alone as the test, the pass read that run as empty.
  • test_run_typescript_delta_umbrella.py::test_a_tracked_file_with_the_generated_config_name_is_left_as_it_is: a committed packages/app/.scip-norefs.tsconfig.json is byte-identical after a full pass, the checkout is clean, and the merged documents are unchanged. Before the fresh name the harness overwrote it and the exit hook deleted it (FileNotFoundError).
  • tests/unit/test_scip_ts_projects.py, nine tests for the plan: the typescript-eslint layout (a/tsconfig.build.json references b, a/tsconfig.spec.json references a's build config) gives three runs, b for itself only, and the per-member merge order; a root-level member skips its reference to a package member and keeps the root-level config it references; a reference with an include outside its directory, or an extends that cannot be found, still runs; members without references keep their runs and get no generated file; the generated config is {"extends": "./tsconfig.build.json"}, beside the config it extends under a fresh name; a files: [] config is walked and not run; a jsconfig.json runs as it is; a plan that raises midway removes the configs it already wrote. All fail on main, which has no plan.
  • Real scip-typescript 0.4.0 on typescript-eslint a1faa174, run_typescript_delta.sh in DELTA_OUT mode from main and from this branch, for the full pass and for the delta in the table: every file entry of the delta (path, symbols, edges) is identical, and the checkout is clean after each run.
  • test_scip_ts_projects.py, test_run_typescript_delta_umbrella.py, test_run_typescript_delta_projects.py, test_scip_merge_indexes.py, test_scip_ts_paths.py, test_scip_harness_windows.py, test_scip_harness_checkout_path.py, test_code_scip_ts_delta_worker.py, test_scip_to_delta_cli.py, test_tunable_constants.py and test_public_copy.py: 147 passed. ruff check, ruff format --check, bash -n, shfmt -d, the function-length gate and scripts/gates/mypy_gate.py pass; mypy on scip_ts_projects.py reports the same five errors as on main. The full unit suite was not run here; CI runs it.

AI assistance in the code (leave one; writing this description with AI is fine):

  • AI-generated (an agent wrote most of the diff): Claude Code wrote the diff and the tests. Checked: I reviewed the diff and its tests; the runs listed under Tests are the agent's.

  • I can explain every line of this diff and how it interacts with the rest of Loom.

Checklist

  • Local format, lint, type checks and focused tests pass. The full make test-unit and applicable integration results are reported by CI; a full local run is not required before pushing.
  • Generated files are regenerated in this PR, not by hand: none are affected.
  • A new migration is additive and numbered after the latest on main; no merged migration is edited: no migration.
  • A behaviour change to any file a plugin ships (hooks/, lib/, bin/, skills/, .mcp.json, the Codex plugin-defaults.json) bumps both plugin manifests' version: no plugin file changed.
  • The frontend builds (npm --prefix frontend run build) and its tests pass, if frontend/ changed: it did not.
  • Docs under docs/ describe the system as it now is, and this description names any operator steps and wire changes: the scip-typescript row in docs/architecture/code-index-architecture.md says each project of the closures is indexed once.
  • Repository text has no dates, people, host names, internal namespaces, ticket or decision numbers; the history goes in this description (tests/unit/test_public_copy.py).
  • Commits are signed off (git commit -s), as CONTRIBUTING.md asks.

Note

Medium Risk
Changes SCIP TypeScript harness orchestration and failure semantics for indexer subprocesses; output is intended to match prior merges but regressions would affect symbol/edge freshness without obvious wire changes.

Overview
Replaces one scip-typescript process per umbrella member with a planned set of runs that indexes each project in the members' reference closures exactly once, while keeping merge output identical to the old per-member behavior.

The harness now calls scip_ts_projects.py plan, which walks references like the indexer, deduplicates projects, skips runs whose documents no member would keep, and emits temporary .scip-norefs.* tsconfigs (extend the real config without references) so referenced projects are not re-walked inside every member process. run_typescript_delta.sh executes that plan, merges with the same per-member ordering as before, and treats only confirmed "no files got indexed" empty runs as harmless.

scip_merge_indexes.py now uses shared scope_specificity from the planner. Architecture docs and unit/integration tests cover closures, deltas, empty vs failed indexer exits, and cleanup of generated configs.

Reviewed by Cursor Bugbot for commit 638fc8d. Bugbot is set up for automated code reviews on this repo. Configure here.

KaloyanNaumov and others added 3 commits December 2, 2026 07:20
scip-typescript indexes every project a target references, recursively,
in the target's own process, so one process per member indexed a shared
reference once for each member that reaches it, and the merge discarded
the copies. On typescript-eslint the 36 members made 289 project runs
for 37 projects.

The harness now asks scip_ts_projects.py for a plan: each project of
the selected members' reference closures runs once, a project with
references through a generated config that extends it without them
(`references` is the one field `extends` does not inherit). The merge
gets each run's index once for every member whose process would have
indexed it, in that order, so it keeps the same documents. A member
without references runs as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Kaloyan Naumov <knaumov@gmail.com>
On a typescript-eslint delta that edits packages/utils, the selected
root-level member tsconfig.repo-config-files.json reaches every package's
build config through its references, and each ran in its own process: 18
processes, slower than the three member processes before. The merge keeps
a document for a member only when the member's scope is the document's
most specific owner, so a project whose files all lie in its own
directory, under another member's scope, gives that member nothing. The
plan leaves such a pair out, and a project with no pair left does not
run. A `files` or `include` entry outside the project's directory, or an
`extends` the helper cannot find, keeps the pair.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Kaloyan Naumov <knaumov@gmail.com>
…ipt pass

Inside a member's process a referenced project with no input was harmless:
the member's own documents kept the document count above zero. Run alone,
scip-typescript 0.4.0 exits 1 and deletes its output, which aborted the pass
for every member. The plan now marks each run as a member without references
(which ran alone before) or not, and the pass reads a failed run of the
second kind that left no output as an empty part, which the merge already
accepts. Any other failure still stops the pass.

The plan's owner check shares one scope-specificity helper with the merge
instead of keeping a second copy.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Signed-off-by: Kaloyan Naumov <knaumov@gmail.com>
@vercel

vercel Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
loom-docs Ready Ready Preview Dec 3, 2026 7:42am UTC
loom-telemetry Ready Ready Preview Dec 3, 2026 7:42am UTC

Request Review

@zlareb1 zlareb1 self-assigned this Dec 2, 2026

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

A focused harness probe reproduced a lost indexer failure and deletion of a tracked config.

KaloyanNaumov and others added 4 commits December 2, 2026 11:24
A referenced project's run that exited non-zero without an output file was
read as an empty project, so an indexer killed before it wrote (exit 137)
let the pass convert and publish an index without that project.

A run is read as empty only on scip-typescript 0.4.0's own report that its
project matched no input file: exit 1, no output, the "no files got indexed"
line on stdout and nothing on stderr. A process that throws prints the same
line, then its stack on stderr. Any other failure ends the pass with the
indexer's exit status.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Kaloyan Naumov <knaumov@gmail.com>
The config that drops a project's references was written as
.scip-norefs.<name> beside the original, overwriting a tracked file of that
name, which the exit hook then deleted.

The plan creates it exclusively under a fresh name in the same directory
(mkstemp), so `include` and `${configDir}` still resolve as before, and the
exit hook removes only the file the plan created.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Kaloyan Naumov <knaumov@gmail.com>
scip-typescript prints the diagnostics of a tsconfig it cannot load (an unknown
compiler option, an unresolvable extends) on stdout, skips the project, and
ends like an empty run: exit 1, no output, the "no files got indexed" report on
stdout, nothing on stderr. The pass read that as an empty project and dropped
its real files from the index.

A run is empty only when stdout holds nothing but the report line, so the
pass now fails with the indexer's exit status. The kill test's fake prints the
report line before it exits 137, so the test pins the status, not the output.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Signed-off-by: Kaloyan Naumov <knaumov@gmail.com>
write_plan creates the no-references configs before the shell reads any
`config` line. When a later mkstemp raises (a read-only member directory), the
shell exits under `set -e` without a cleanup hook and the earlier files stay in
the tree, each under a fresh name. write_plan now unlinks what it created and
re-raises.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Signed-off-by: Kaloyan Naumov <knaumov@gmail.com>

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

The new failure checks distinguish a genuinely empty project from an indexer failure. One temporary-file cleanup gap remains.

The helper raised before returning its path, so the caller's cleanup never saw
the file: a partial `.scip-norefs.*` config stayed in the checkout, and an
`fdopen` that failed left mkstemp's descriptor open too. The helper now closes
the descriptor and unlinks the file on any error, then re-raises.

Two tests fail after creation, one at the write and one at the open. Each
asserts the checkout holds no `.scip-norefs.*` file; the open case also asserts
the descriptor was closed, which is the state POSIX hides (it unlinks an open
file happily, so only the descriptor shows the leak).

Signed-off-by: Kaloyan Naumov <knaumov@gmail.com>
zlareb1
zlareb1 previously approved these changes Dec 2, 2026

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

The harness closes the descriptor and removes the generated config when opening or writing fails. All 53 focused project and harness tests pass. GitHub reports conflicts with main in the TypeScript harness, index merge, and umbrella test.

main changed the harness where this branch also edits, so each conflict
keeps main's structure and the branch's intent:

- run_typescript_delta.sh: main added paths_rewrite [tsconfig...], which
  rewrites only the configs the indexer is given. The branch's plan-based
  loop already calls it with the selected configs, so both functions stay,
  indexed_no_file first, each with its own body.
- scip_merge_indexes.py: main loads scip_to_delta and copies documents
  from the top-level records without decoding them. The branch's ownership
  helpers need scope_specificity, which the branch moved into
  scip_ts_projects; that import sits beside main's converter load, and the
  rest of the function is main's.
- test_run_typescript_delta_umbrella.py: the branch gave _run a scip
  parameter so a test can pass its own indexer stub; main resets the
  .tsconfig call log there. _run keeps both: the log is cleared and the
  stub is the parameter's, defaulting to _FAKE_SCIP.

docs/architecture/code-index-architecture.md merged without a conflict.

The branch's behaviour is unchanged: a generated config is closed and
removed when writing or opening it fails, and a project that indexes no
file stays an empty part.

Signed-off-by: Kaloyan Naumov <knaumov@gmail.com>
@KaloyanNaumov

Copy link
Copy Markdown
Contributor Author

Merged main. Three conflicts, all in the harness: main added paths_rewrite where this branch added indexed_no_file and git had joined them onto one closing brace; the merge-index converter takes main's byte-copy body with this branch's scope_specificity import beside it; the umbrella test keeps both main's log reset and this branch's scip parameter. 736467c

At the merged head: 504 passed across the converter, path, CLI, worker and doc-link suites. The umbrella file passes 29 on CPython 3.13 and fails on 3.12.3, which is a stdlib argparse fix between patch releases rather than this code: the plan … --known … -- targets shape is rejected on 3.12.3 and parses on 3.12.16 and 3.13.

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

The merged harness keeps the project plan and preserves each member’s ownership when it merges the index parts. The temporary config is removed if opening or writing it fails. The tests cover empty references, failed indexer runs, and cleanup.

@zlareb1
zlareb1 merged commit bef90c5 into ClickHouse:main Dec 3, 2026
80 checks passed
KaloyanNaumov added a commit to KaloyanNaumov/loom that referenced this pull request Dec 3, 2026
…ation

Upstream now plans the TypeScript pass as one run per project of the members'
reference closures (ClickHouse#2008) and gives a one-member delta's references to terms
the index does not hold a `held_edges` list (ClickHouse#2003); this branch isolates a
member whose indexer fails. The resolutions compose the two:

- scripts/scip_harness/run_typescript_delta.sh keeps the plan: one process per
  project, each project once, the merge given each run once per member. A
  member's run that exits with an error no longer ends the pass: its part is
  left out of the merge, the merge names it `--failed-project` so the paths it
  owns come back as `--failed-paths`, and the converter lists them
  (`--failed-files`) so the server keeps those rows and marks the files stale.
  A shared project of the closures (`own` 0) still fails the pass with the
  indexer's status: its documents are more than one member's input, and running
  it alone is the case upstream reads as a failure. A member killed by a signal,
  or a pass whose every member failed, fails too; a run that indexed no file is
  still read as empty.
- scripts/scip_harness/scip_to_delta.py takes upstream's `_ts_definition_unseen`
  and `_held_edges` beside this branch's `_ts_prepass(..., skips)`: a document
  that refers into a failed file is still skipped whole, and a reference to a
  term the converted index does not hold keeps its edge in `held_edges`.
- scripts/scip_harness/scip_merge_indexes.py drops the local
  `_scope_specificity` for upstream's shared `scip_ts_projects.scope_specificity`.
- tests/unit/test_run_typescript_delta_umbrella.py keeps both indexer fixtures
  (the branch's FAIL_TARGET stub and upstream's reference-following writer),
  `_run` raises CalledProcessError as upstream's failure tests read it, and
  `_run_status` keeps `extra_env` as its fifth positional argument.
- tests/unit/test_scip_ts_kind_prepass.py passes the `tier` that `apply_delta`
  now requires and its repo stand-in answers `scip_stale_marks`.
- docs: the TypeScript row of the producer table and rolling-upgrades rules 70
  and 71 name both behaviours (the branch's skipped-files rule renumbered from
  a duplicate 69).

tests/unit/test_code_scip_*.py and tests/unit/test_scip_*.py: 634 passed.
tests/unit/test_run_typescript_delta_umbrella.py: 36 passed.

Signed-off-by: Kaloyan Naumov <knaumov@gmail.com>
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