Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions docs/architecture/code-index-architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -355,12 +355,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 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. |
| 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), one process per project of their reference closures, each project once; 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
Expand Down
79 changes: 59 additions & 20 deletions scripts/scip_harness/run_typescript_delta.sh
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,20 @@ PYEOF
fi
fi

# indexed_no_file <run> <status>: whether run <run> is confirmed empty, as
# scip-typescript 0.4.0 reports a process whose projects matched no input file:
# exit 1, no output, that report on stdout and nothing on stderr. A process that
# throws while indexing prints the same report, then its stack on stderr. A
# project whose tsconfig fails to load (an unknown option, an unresolvable
# extends) prints its diagnostics on stdout before the same report, so stdout
# must hold nothing else: that project has files the index would lose.
indexed_no_file() {
local part="$WORK/index.part.$1"
[[ "$2" == 1 && ! -e "$part.scip" && ! -s "$part.err" ]] \
&& grep -q '^[[:space:]]*error: no files got indexed\.' "$part.log" \
&& ! grep -qvE '^[[:space:]]*(error: no files got indexed\..*)?$' "$part.log"
}

# paths_rewrite [tsconfig...]: scip_ts_paths.py over the given configs, or
# over every workspace package's tsconfig.json when none is given; the same
# files are restored on exit.
Expand Down Expand Up @@ -161,11 +175,6 @@ JSONEOF
fi
local ws=()
[[ -n "$WORKSPACES" ]] && ws=("$WORKSPACES")
# One indexer process per member: scip-typescript walks every target in a
# single process and shares its source-file cache across them, so passing
# the whole umbrella as arguments keeps the same heap growth the root
# pass already hits. Isolated runs drop that cache between members.
local parts=() target part i=0
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
Expand All @@ -180,24 +189,54 @@ JSONEOF
fi
return
fi
for target in "${targets[@]}"; do
part="$WORK/index.part.$i.scip"
NODE_OPTIONS="--max-old-space-size=$NODE_HEAP_MB" \
"$SCIP_TYPESCRIPT" index "${ws[@]}" "$target" --output "$part" >&2
parts+=("$part")
i=$((i + 1))
done
# Always merge so a single member that followed project references
# also drops documents it does not own.
local merge_args=() t
for t in "${targets[@]}"; do
merge_args+=(--project "$t")
done
# One indexer process per project: scip-typescript shares its source-file
# cache across every target of a process, so one process over the umbrella
# keeps the heap growth of the root pass. It also indexes each referenced
# project inside the process of every member that reaches it; the plan runs
# each project of the closures once instead, a project with references
# through a generated config without them, and gives the merge each run once
# per member whose process would have indexed it, in that order. A project
# whose documents the merge would drop for every such member does not run.
local plan kind run own arg runs=() owns=() parts=() merge_args=() known_args=() t rc
for t in "${ALL_PROJECTS[@]}"; do
merge_args+=(--known-project "$t")
known_args+=(--known-project "$t")
done
plan=$("$PYTHON" "$HARNESS_DIR/scip_ts_projects.py" plan "$CHECKOUT" "${known_args[@]}" -- "${targets[@]}")
while IFS=$'\t' read -r kind run arg own; do
case "$kind" in
config) on_exit "rm -f $(printf %q "$run")" ;;
index)
runs[run]=$arg
owns[run]=$own
;;
merge)
merge_args+=(--project "$arg")
parts+=("$WORK/index.part.$run.scip")
;;
esac
done <<<"$plan"
for run in "${!runs[@]}"; do
rc=0
NODE_OPTIONS="--max-old-space-size=$NODE_HEAP_MB" \
"$SCIP_TYPESCRIPT" index "${ws[@]}" "${runs[run]}" --output "$WORK/index.part.$run.scip" \
>"$WORK/index.part.$run.log" 2>"$WORK/index.part.$run.err" || rc=$?
cat "$WORK/index.part.$run.log" "$WORK/index.part.$run.err" >&2
# A referenced project that matches no file was harmless inside a member's
# process; alone it is an empty part, which the merge reads as empty. Any
# other failure, a killed process included, fails the pass with its status.
if [[ $rc -ne 0 ]]; then
if [[ "${owns[run]}" == 0 ]] && indexed_no_file "$run" "$rc"; then
echo ">> ${runs[run]} indexed no file — read as empty" >&2
else
echo ">> scip-typescript failed on ${runs[run]} (exit $rc)" >&2
exit "$rc"
fi
fi
done
# Always merge so a member's run that followed project references also
# drops documents it does not own.
"$PYTHON" "$HARNESS_DIR/scip_merge_indexes.py" --output "$WORK/index.scip" \
"${merge_args[@]}" "${parts[@]}"
"${merge_args[@]}" "${known_args[@]}" "${parts[@]}"
}

cd "$CHECKOUT"
Expand Down
14 changes: 3 additions & 11 deletions scripts/scip_harness/scip_merge_indexes.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ def _load_harness_module(name: str) -> Any:
_ts_projects = _load_harness_module("scip_ts_projects")
project_owns = _ts_projects.project_owns
project_scope = _ts_projects.project_scope
scope_specificity = _ts_projects.scope_specificity
_converter = _load_harness_module("scip_to_delta")
_read_index = _converter._read_index
_top_level_records = _converter._top_level_records
Expand All @@ -57,21 +58,12 @@ def _load_harness_module(name: str) -> Any:
_METADATA, _DOCUMENT, _EXTERNAL_SYMBOL = 1, 2, 3


def _scope_specificity(project: str) -> int:
"""Longer directory scopes win. The root scope '.' has length 1, which
would otherwise tie a one-character member directory such as 'a'."""
scope = project_scope(project)
if scope in (".", ""):
return 0
return len(scope)


def _preferred_owner(projects: list[str], relpath: str) -> str | None:
owners = [project for project in projects if project_owns(project, relpath)]
if not owners:
return None
best_scope = max(_scope_specificity(project) for project in owners)
tied = [project for project in owners if _scope_specificity(project) == best_scope]
best_scope = max(scope_specificity(project) for project in owners)
tied = [project for project in owners if scope_specificity(project) == best_scope]
# Sibling explicit tsconfigs share a directory scope. Returning one of
# them still lets each sibling keep its documents (scopes match) while
# a shorter ancestor, such as a root tsconfig, is dropped.
Expand Down
Loading
Loading