diff --git a/.claude/docs/ARCHITECTURE.md b/.claude/docs/ARCHITECTURE.md index ed3690d1..cbc717f8 100644 --- a/.claude/docs/ARCHITECTURE.md +++ b/.claude/docs/ARCHITECTURE.md @@ -2,7 +2,7 @@ > **Purpose**: High-level system architecture for AI agents and developers. Read this before touching anything under `src/`. > **Stability**: Stable — update only when the architecture itself changes (new module, changed data flow), not for feature-level changes. -> Facts here were verified against the code on 2026-07-08. Items marked *[inferred]* are conclusions from structure/naming, not verified line-by-line. +> Facts here were verified against the code on 2026-07-08; the module map and every path were re-verified on 2026-11-25 (story #43) after the monorepo move and the feature-first `src/` layout (#55). Items marked *[inferred]* are conclusions from structure/naming, not verified line-by-line. ## The one-paragraph summary @@ -47,8 +47,8 @@ Three analysis modes share this pipeline: **XR** (A-Frame scene in browser/heads |---|---|---| | `features/analysis/` | The ANALYSES section: the per-mode analysis commands (file, directory, DOM, clean), the tree and its subsections (active analyses, files/project by language, analysis settings), the workspace scan and the server watcher integration | `commands/analysisCommandRegistrations.ts`, `commands/analysisCommands.ts`, `commands/{file,directory,dom}/`, `views/AnalysisSectionProvider.ts`, `sections/active-analyses/activeAnalysesCommands.ts` (Active Analyses actions and export), `sections/settings/` (one folder per setting; `chartTypeCommandFactory.ts` and the two `shared*SettingCore.ts` at its root), `workspace/workspaceSnapshotService.ts`, `workspace/workspaceFileScanner.ts`, `services/serverWatcherIntegration.ts` | | `core/analysis/` | **The analysis engine.** Pipeline: launchers, parsers, the requirement processor, sessions, session servers, watchers, refresh, the Python bridge, the scene-asset injection, the language tables | `analysisOrchestrator.ts`, `launchers/launchPipeline.ts`, `launchers/launcherXRAnalysis.ts`, `session/analysisSession.ts`, `session/sessionRegistry.ts`, `session-servers/sessionServerManager.ts`, `watchers/sessionWatcherManager.ts`, `python/executePython.ts`, `python/xrFieldSchemaService.ts`, `configuration/analysisConfigurationStorage.ts`, `languages/languageMetadata.ts`, `languages/supportedLanguages.ts` | -| `code_analysis/python/` | Python analysis backend (see `PYTHON_ANALYSIS.md`) | `main.py`, `tools/lizard_analyzer.py`, `utils/xr_field_schema.py` | -| `core/dependencies/` | Dependency-graph analysis service (see `docs/features/DEPENDENCY_GRAPH_XR.md`) | `DependencyGraphService` *[inferred name from docs]* | +| `backend/src/` (repository root, outside `src/`) | Python analysis backend (see `PYTHON_ANALYSIS.md`); copied into `dist/code_analysis/python` by webpack | `main.py`, `tools/lizard_analyzer.py`, `utils/xr_field_schema.py` | +| `core/dependencies/` | Dependency-graph analysis service (see `docs/features/DEPENDENCY_GRAPH_XR.md`) | `dependencyGraphService.ts`, `dependencyGraphModels.ts` | | `core/export/` | Analysis export: the manifest, the package transaction and the Git-revision exporter with its Python worker pool | `exportManifest.ts`, `exportPackageTransaction.ts`, `gitRevisionExporter.ts`, `gitRevisionExportCore.ts`, `gitTimelineBlobAnalyzer.ts` | | `core/history/` | Git history: comparator + Project Evolution. Both services compose a `GitAnalysisSessionContext` (catalogue, per-commit payload cache, analyze/exclude) and a `SingleJobGate` (one job at a time, last successful request); `gitAnalysisShared.ts` holds the pure helpers the export core shares | `gitRepositoryService.ts`, `historicalComparisonService.ts`, `projectEvolutionService.ts`, `gitAnalysisSessionContext.ts`, `gitAnalysisShared.ts` | | `core/charts/` | Chart template system: registry, models, dimension validation, HTML placeholder processing, the visualization configuration read by every launch | `chartRegistry.ts`, `chartModels.ts`, `xrFieldModels.ts`, `templateCharts.ts`, `chartPresentation.ts`, `getVisualizationConfiguration.ts` (lazy `require` of `settings/settingsAccessors.ts`), `processing/dimensionValidator.ts`, `processing/templateHTMLProcessor.ts`, `processing/templateProcessor.ts`, `processing/placeholders/` | @@ -78,7 +78,7 @@ Three analysis modes share this pipeline: **XR** (A-Frame scene in browser/heads **Layout** (story #55, `docs/cleanup/src-layout.md` §3; pinned by `test/tooling/srcLayout.test.cjs`): `src/` holds `extension.ts` and five layers, `app/` (composition root) → `features/` (one folder per sidebar section) → `core/` (the engine, one folder per domain) → `platform/` (VS Code host plumbing, no feature knowledge) → `shared/` (no VS Code, no domain). Folder names are kebab-case; `core/` and `features/` hold folders only; there are no re-export barrels. -**Per-feature layout convention**: `features/
/` has `commands/` (`Commands.ts`, the handlers, and `CommandRegistrations.ts`, the registration array `app/commands/registerAllCommands.ts` collects), `views/` (the `*SectionProvider.ts`, item factories and click handlers, flat), and where needed `services/`, `model/`, `runtime/`. A section with subsections nests them under `sections//` (see `features/analysis/`). Engine code that more than one feature, the servers or the analysis pipeline uses goes in `core//`, not in a feature. When adding a feature, mirror this pattern. +**Per-feature layout convention**: `features/
/` has `commands/` (`Commands.ts`, the handlers, and `CommandRegistrations.ts`, the registration array `app/commands/registerAllCommands.ts` collects), `views/` (the `*SectionProvider.ts`, item factories and click handlers, flat), and where needed `services/` and `model/`. A section with subsections nests them under `sections//` (see `features/analysis/`). Engine code that more than one feature, the servers or the analysis pipeline uses goes in `core//`, not in a feature. When adding a feature, mirror this pattern. **Folder dependencies** (stories #42, #55): which folder may import which is data in `test/tooling/folderDependencies.json`, checked by `test/tooling/dependencyDirection.test.cjs` (type imports count). A folder is the first directory under `src/`, or the first two under `core/` and `features/` (`twoLevelAreas`); the same file holds the layer order `app → features → core → platform → shared` (`layers`), which the test enforces (no upward edge, no feature importing another feature) except for the reasoned entries in `layerExceptions`. A new cross-folder direction fails the gate until it is added there; a new two-way pair also needs a written reason. The remaining pairs are each documented in that file (all inside the server/analysis subsystems: `core/server`, `core/remote-access`, `core/analysis` with `core/history`, plus `core/server`/`features/active-servers`, which is the one allow-listed upward edge). `platform/` imports no feature folder, and `core/` none besides that edge. @@ -90,7 +90,7 @@ Note: before #55 a feature was split between a feature folder and `views//templates` and shipped by the `files` allowlist; not copied into `dist/` since 1.2.1. Source code builds every template path with `resolveTemplatePath(extensionPath, …)` (`src/platform/templatePaths.ts`), never from `__dirname` (wrong from the bundle); tests use `test/helpers/templatesRoot.cjs`. | -| `test/` | All tests. `.test.cjs` unit suites (Node native runner), Python suites, language fixtures, manual HTML harnesses. See `DEVELOPMENT.md`. | +| `test/` | The extension's tests: `.test.cjs` unit suites (Node native runner), the feature baseline, the tooling ratchet, manual HTML harnesses. The Python suites, fixtures and per-language corpus live in `backend/tests/` and `backend/manual_test/`. See `DEVELOPMENT.md`. | | `resources/` | Icons and media (per-language icons, collaboration/comparison/screen assets). | | `examples/` | Bundled sample charts + data for the Babia Examples tree section. | | `scripts/` | Build utilities: `package-vsix.mjs`, `prepare-dev-extension.mjs` (the manual-metrics report tool is `backend/scripts/report-manual-metrics.py`). | | `docs/` | Human-facing feature docs, linked from the README (vsce rewrites those links to GitHub). Not shipped in the VSIX since 1.2.1. | | `backend/manual_test/` | Per-language fixtures for `npm run test:analysis` (see its README); outside this package since 1.2.1. | -| `pages/` | GitHub Pages redirect page (deployed by the only CI workflow). | +| `pages/` | GitHub Pages redirect page (deployed by `.github/workflows/deploy-pages-redirect.yml`; the gates run in `ci.yml`). | ## How future agents should use this document diff --git a/.claude/docs/DEVELOPMENT.md b/.claude/docs/DEVELOPMENT.md index d2f1fe2c..f59066bb 100644 --- a/.claude/docs/DEVELOPMENT.md +++ b/.claude/docs/DEVELOPMENT.md @@ -2,7 +2,7 @@ > **Purpose**: Build, test, run and package the extension. Read this before running any command or claiming a change "works". > **Stability**: Stable — update when scripts, launch configs, or test layers change. -> Verified against `package.json`, `.vscode/launch.json`, `.vscode/tasks.json` and `test/runners/` on 2026-07-08. +> Verified against `package.json`, `.vscode/launch.json`, `.vscode/tasks.json` and `test/runners/` on 2026-07-08; scripts, paths and the test layout re-verified on 2026-11-25 (story #43). > **Monorepo (2026-11-25):** run `npm ci` and every `npm run …` from the repository root; scripts delegate to the `code-xr` workspace in `apps/vscode-extension/`, where the paths below live (the Python backend is `backend/src/`, its tests `backend/tests/`). See `docs/monorepo.md`. @@ -16,7 +16,7 @@ | Script | What it does | When to use | |---|---|---| -| `npm run compile` | webpack build → `dist/extension.js` (+ CopyPlugin copies `src/code_analysis/python` into `dist/code_analysis/python`; `templates/` and `examples/` ship as they are, not copied, since 1.2.1) | Before F5 "workspace direct"; quick build check | +| `npm run compile` | webpack build → `dist/extension.js` (+ CopyPlugin copies `/backend/src` into `dist/code_analysis/python`; `templates/` and `examples/` ship as they are, not copied, since 1.2.1) | Before F5 "workspace direct"; quick build check | | `npm run compile:dev-host` | `compile` + `scripts/prepare-dev-extension.mjs` → stages an isolated dev copy under `.vscode-test/dev-extension` | Used automatically by the primary F5 launch config | | `npm run watch` | webpack watch mode | Iterating on TS changes | | `npm run typecheck` | `tsc --noEmit` (non-incremental) over the whole project with `tsconfig.check.json`, which extends `tsconfig.json` and adds `noUnusedLocals`, `noFallthroughCasesInSwitch`, `noImplicitReturns` and `noUnusedParameters` (an unused parameter kept for a signature is named `_x`). `compile`, `compile-tests` and webpack stay on `tsconfig.json`, so an unused symbol fails the gate but never the F5 build. Then a second pass, `tsconfig.tooling.json`: `checkJs` over `scripts/*.mjs`, `webpack.config.js` and `eslint.config.mjs` (strict except `noImplicitAny`; a JSDoc `@type` is the fix for a finding there) | Fast correctness gate; part of `test:basic` | @@ -25,14 +25,14 @@ | `npm run watch-tests` | `tsc -p . -w --outDir out`: keeps `out/` current while iterating on tests (the runner's stale-output check is per file, so this stays valid) | Iterating with `npm run test:unit` | | `npm test` = `npm run test:basic` | `typecheck` + `lint` + `compile-tests` (tsc → `out/`) + `test:unit`. Needs **no** webpack build | **The default gate. Run before declaring any change done.** | | `npm run test:unit` | `test/runners/run-node-tests.cjs` → first refuses to start if `out/` does not match `src/` (a source newer than its output, an uncompiled source, or a compiled file whose source is gone), then collects `test/**/*.test.cjs` and runs `node --test --test-isolation=none --test-concurrency=1` — **every suite in one process**, so a test must never leave global state behind | Unit/runtime tests only (fast) | -| `npm run test:python` (root `test:backend` runs the same file directly) | `backend/scripts/run-python-tests.cjs` → `unittest discover` over `backend/tests/`. A test folder **needs an `__init__.py`** or discovery skips it silently. With no interpreter it skips locally and **fails under `CI`** | After touching `src/code_analysis/python/` | +| `npm run test:python` (root `test:backend` runs the same file directly) | `backend/scripts/run-python-tests.cjs` → `unittest discover` over `backend/tests/`. A test folder **needs an `__init__.py`** or discovery skips it silently. With no interpreter it skips locally and **fails under `CI`** | After touching `backend/src/` | | `npm run lint:python` (root only) | `backend/scripts/run-ruff.cjs` → `ruff check` in `backend/` with `backend/ruff.toml`: pyflakes (`F`) plus the pycodestyle error classes `E4`/`E7`/`E9` and the modernization lock-ins of story #56 (`E722`, `UP004`, `UP008`, `UP031`, `UP032`, and `FA100`/`UP006`/`UP007`/`UP037`/`UP045`: builtin generics in annotations behind `from __future__ import annotations`, and `UP012`/`UP015`/`RUF010`; `docs/cleanup/modernization.md`), target Python 3.7, fixture corpora (`manual_test/`, `tests/fixtures/`) excluded, `E402` ignored per file (with the reason) where a module bootstraps `sys.path` before its imports. **Lint only — no formatter, no isort**: tests pin import lines and statement order. Ruff is pinned in `backend/requirements-dev.txt` (`python -m pip install -r backend/requirements-dev.txt`); a missing ruff is a failure, never a skip | After touching `backend/` | | `npm run test:all` | `test:basic` + `test:python` | Pre-release / after cross-language changes | | `npm run test:analysis` | `backend/scripts/run-analysis-tests.cjs` (venv in `backend/artifacts/analysis-test-venv`) over the `backend/manual_test/` fixtures (one per supported language); asserts XR and LivePanel produce the same `data.json`. Its venv installs the **lizard version the extension pins** (read from `backend/requirements.txt`, the generated mirror of `pythonPackageManifest.ts`) | After changing analysis output or language support | -| `npm run test:htmlanalysis` | HTML/DOM analysis tests | After touching `python/html/html_dom_parser.py` or DOM mode | +| `npm run test:htmlanalysis` | `test/runners/run-html-analysis-tests.cjs`: `test/analysis/livePanelDomIntegration.test.cjs` plus the Python suite `backend/tests/html_dom/` | After touching `backend/src/html/html_dom_parser.py` or DOM mode | | `npm run test:xr-harness` | `test/runners/run-xr-containment-harness.cjs` (browser harness, uses Playwright) | After touching table/containment runtimes | | `npm run test:xr-mode-harness` | `test/runners/run-xr-mode-cycle-harness.cjs` — static contract over `test/manual/xr-mode-cycle-harness.html`, then (with Playwright) walks the analysis selector through every mode and back, asserting the controller's view/mode state at each step | After touching the analysis-mode controller, mapping UI, historical comparison or dependency graph runtimes | -| `npm run test:project-evolution-harness` | Project Evolution playback harness | After touching project-evolution runtime | +| `npm run test:project-evolution-harness` | `test/runners/run-project-evolution-harness.cjs` — Project Evolution playback harness (screenshots under `output/project-evolution-harness/`) | After touching project-evolution runtime | | `npm run test:xr-immersive-harness` | `test/runners/run-xr-immersive-harness.cjs` — AR/VR semantics against real A-Frame: AR hide/keep sets, rig floor-align + AR recenter, pointer handover; plus a static contract over both scene templates | After touching the scene templates, pointer-policy or immersive-rig | | `npm run package` | Production webpack build (hidden source maps) | Pre-packaging | | `npm run package:vsix` | `package` + `scripts/package-vsix.mjs` → builds the `.vsix` (refuses to package without `dist/extension.js`) | Release preparation | @@ -58,18 +58,20 @@ Manual validation flow for a change: F5 → open a workspace with source files ``` test/ -├── analysis/ ~33 .test.cjs suites — runtimes (common, boats, visual style, charts, -│ tables, mapping), collaboration, historical, dependency graph, watchers… +├── analysis/ 80 .test.cjs suites — runtimes (common, boats, charts, tables, mapping), +│ collaboration, historical, dependency graph, export, watchers… ├── commands/ commandRegistry.test.cjs (unique-ID checks on synthetic arrays) + │ commandContributions.test.cjs: executes the REAL registerAllCommands under the │ fake vscode and ties it to package.json; internalCommandIds.cjs lists every │ registered-but-uncontributed command with how it is reached ├── directory_analysis/ directory-mode tests -├── logging/, python_env/, servers/, startup/, collaboration/, packaging/, utils/, +├── logging/, python_env/, servers/, startup/, collaboration/, packaging/, utils/, views/, │ visualize_data/, visualization_settings/ focused suites per subsystem +│ (126 .test.cjs files in all, 1,064 tests at the end of 1.2.1) ├── helpers/ sourceText.cjs (LF readers, assertAbsent with a mandatory canary), │ fakeVscode.cjs (scoped fake `vscode` to EXECUTE out/ modules), -│ runtimeAssembly.cjs (test-side mirror of the runtime assembler) +│ runtimeAssembly.cjs (test-side mirror of the runtime assembler), +│ logCapture.cjs, templatesRoot.cjs, sceneAssetModules.cjs ├── baseline/ the feature baseline of the cleanup epic: snapshot of the user-visible │ surface + the register of authorized removals (featureSurface.cjs --write) ├── tooling/ measureGuardrails.cjs + guardrail-baseline.json + the ratchet test; diff --git a/.claude/docs/INDEX.md b/.claude/docs/INDEX.md index ab5a8dd7..5c575933 100644 --- a/.claude/docs/INDEX.md +++ b/.claude/docs/INDEX.md @@ -3,7 +3,7 @@ > **Purpose**: The navigation hub. Every session starts here (pointed from `CLAUDE.md`) and reads *only* the documents mapped to its task. > **Stability**: Update whenever a document is added, removed, or repurposed. -> **Monorepo (2026-11-25):** paths in these docs predate the move. `src/`, `test/`, `templates/`, `scripts/`, `docs/` → `apps/vscode-extension/…`; `src/code_analysis/python/` → `backend/src/`; `test/python/` → `backend/tests/`; `manual_test/` → `backend/manual_test/` (1.2.1). Layout and rationale: `docs/monorepo.md` (repository root). +> **Monorepo (2026-11-25):** paths in these docs predate the move. `src/`, `test/`, `templates/`, `scripts/`, `docs/` → `apps/vscode-extension/…`; `src/code_analysis/python/` → `backend/src/`; `test/python/` → `backend/tests/`; `manual_test/` → `backend/manual_test/` (1.2.1). Layout and rationale: `docs/monorepo.md` (repository root). Inside `src/`, paths written before story #55 (2026-11-25: `code_analysis/`, `servers/`, `views/`, …) moved to the feature-first layers `app/ → features/ → core/ → platform/ → shared/`; translate any old path with `docs/cleanup/src-move-map.json`. ## Document inventory @@ -22,6 +22,7 @@ | `v1.2.1/DESIGN_GUARDRAILS.md` | File-level design for the safety net, the ratchet, H1/H2, the ESLint/tsc/ruff rollout, the vscode-free log sink, typing | | `v1.2.1/DESIGN_STRUCTURAL.md` | Target architecture + commit slicing for every W4/W5 refactor, each with the characterization test that must land first, and a cut order | | `v1.2.1/CRITIC_REVIEW.md` | The 38 corrections to those designs, with file:line evidence; summarized in the ROADMAP override table | +| `v1.2.1/sessions/*.md` | One log per cleanup story of epic #26 (`-.md`): commits, before/after numbers, gates, what was deliberately left, quirks for 1.3.0, the F5 checks for the maintainer. `docs/cleanup/REPORT.md` consolidates them | | `V1.2.0_STATUS.md` | Historical record of the closed 1.2.0 cycle (released 2026-07-30); source of carried-over debt. Do not rewrite | | `AI_WORKFLOWS.md` | Playbooks per task type + universal session rules | @@ -45,13 +46,18 @@ | `docs/project/ROADMAP_V1.2.0.md` | EN | v1.2.0 goals, per-area status table, delivery sequence, exit criteria | | `docs/features/DEPENDENCY_GRAPH_XR.md` | EN | Dependency-graph XR mode: architecture, 23 languages, layouts, limits | | `docs/features/HISTORICAL_COMPARISON_XR.md` | ES | Historical comparator: dual table, safe Git access, caching, limits | -| `docs/features/PROJECT_EVOLUTION_XR.md` | EN | Project Evolution "movie" mode (in progress; file currently untracked) | +| `docs/features/PROJECT_EVOLUTION_XR.md` | EN | Project Evolution "movie" mode | | `docs/features/CLOUDFLARE_REMOTE_ACCESS.md` | ES | Quick Tunnel remote access: flow, limits, authorization layer | | `docs/xr-testing/XR_DEBUG_COMMANDS.md` | EN | Browser-console debug APIs for generated XR scenes | | `THIRD_PARTY_NOTICES.md` | EN | Third-party licenses; what is and isn't bundled | | `templates/components/COMPONENTS.md` | EN | Inventory + load order of browser-side component runtimes | | `test/README.md` | EN | Test suite layout and commands | | `backend/manual_test/README.md` | EN | Per-language fixtures for `npm run test:analysis` | +| `docs/cleanup/README.md` (repository root) | EN | The v1.2.1 deep-cleanup epic (#26): story map, baseline, how "no functionality lost" is proved; links the documents below | +| `docs/cleanup/REPORT.md` | EN | **Final report of the cleanup**: findings, every story and PR, behaviour-neutrality evidence, exit criteria, what is left for 1.3.0, automated E2E results and the consolidated maintainer F5 checklist | +| `docs/cleanup/feature-baseline.md` | EN | Inventory of everything the extension contributes and does (pinned by `test/baseline/`), with the §10 verification checklist | +| `docs/cleanup/src-layout.md`, `src-move-map.json` | EN | Story #55: the feature-first `src/` layout and the old → new path map | +| `docs/cleanup/{host-boundary,modernization,sweep-outside-src,w2-revalidation}.md` | EN | Layering, idiom modernization, the sweep outside `src/`, the W2 re-validation | ## Task → reading list @@ -69,7 +75,7 @@ | **Servers / SSE / collaboration / remote** | `ARCHITECTURE.md` → `docs/features/CLOUDFLARE_REMOTE_ACCESS.md` for tunnels | `src/core/server/`, `src/features/servers/`, `src/features/active-servers/`, `core/collaboration/`, `features/collaboration/`, `core/remote-access/` | | **Build / test / tooling** | `DEVELOPMENT.md` | `scripts/`, configs | | **Docs update** | `AI_WORKFLOWS.md` §docs → `V1.2.1_STATUS.md` §carried-over debt → `V1.2.0_STATUS.md` §documentation debt | `docs/`, `.claude/docs/` | -| **Release preparation** | `V1.2.1_STATUS.md` (all) → `AI_WORKFLOWS.md` §release → `DEVELOPMENT.md` §packaging; `docs/project/ROADMAP_V1.2.0.md` only for historical exit criteria | everything user-visible | +| **Release preparation** | `V1.2.1_STATUS.md` (all) → `docs/cleanup/REPORT.md` (exit criteria, maintainer F5 checklist) → `AI_WORKFLOWS.md` §release → `DEVELOPMENT.md` §packaging; `docs/project/ROADMAP_V1.2.0.md` only for historical exit criteria | everything user-visible | ## Folders to avoid (context cost / generated) diff --git a/.claude/docs/PYTHON_ANALYSIS.md b/.claude/docs/PYTHON_ANALYSIS.md index 8f08e751..f7b78a66 100644 --- a/.claude/docs/PYTHON_ANALYSIS.md +++ b/.claude/docs/PYTHON_ANALYSIS.md @@ -2,33 +2,35 @@ > **Purpose**: Understand the only non-TypeScript subsystem — the Python engine that produces all code metrics — and its contract with the extension. > **Stability**: Stable — update when CLI modes, the field schema contract, or the venv mechanism change. -> Verified against `src/code_analysis/python/` and `src/python_env/` structure on 2026-07-08. +> Verified against `src/code_analysis/python/` and `src/python_env/` structure on 2026-07-08; paths re-verified on 2026-11-25 (story #43) against the monorepo (`backend/src/`) and the feature-first `src/` (story #55). ## Why this file exists The Python backend is a frequent source of confusion: -- It lives in `src/code_analysis/python/` but is **not compiled** — webpack's CopyPlugin copies it verbatim into `dist/code_analysis/python` at build time (excluding `*.ts` and `__pycache__`). +- It lives in `backend/src/` (outside the extension package since the monorepo move; it was `src/code_analysis/python/`) and is **not compiled** — webpack's CopyPlugin copies it verbatim into `dist/code_analysis/python` at build time (excluding `__pycache__`). In Development mode only, the extension falls back to `/backend/src` when the `dist/` copy is missing. - It runs inside a **managed virtual environment** created by the extension itself, not the system Python. - Its output schema drives TypeScript-side validation, so Python and TS must change together. ## Entry point and CLI -`src/code_analysis/python/main.py` — argparse CLI, JSON output on stdout. +`backend/src/main.py` — argparse CLI, JSON output on stdout. - `--mode {livePanel, xr, schema, dependencies}` -- `--type {file, directory, project}` +- `--type {file, directory}` (the unused `project` alias and the unread `--output` flag were removed in 1.2.1; `--target`, `--files`, `--deep`, `--cache`, `--dependency-refresh`, `--project-root` remain) +- Three more scripts are spawned directly by TypeScript: `html/html_dom_parser.py` (DOM mode), `summaryFiles/file_reanalysis_coordinator.py` (watcher re-analysis; the folder was misspelled `sumaryFiles/` until 1.2.1) and `export/git_export_analysis_worker.py` (Git export worker pool). -The TS bridge is `src/core/analysis/python/executePython.ts`, which spawns the venv's interpreter against `main.py` and parses the JSON. Progress is streamed via `python/utils/progress_logger.py` conventions. *[inferred: exact progress protocol — verify in executePython.ts if you need it]* +The TS bridge is `src/core/analysis/python/executePython.ts`, which spawns the venv's interpreter against `main.py` and parses the JSON. Progress is streamed on stderr as JSON lines (`{"progress": {...}}`, `{"debug": ...}`, `{"warning": ...}`, `{"error": ...}`) by `backend/src/utils/progress_logger.py`; `src/core/analysis/python/pythonStderrStream.ts` classifies them and `executePython.ts` reports the progress. ## Layout ``` -src/code_analysis/python/ +backend/src/ ├── main.py CLI entry; wires sys.path for subpackages ├── tools/ analyzer wrappers │ ├── lizard_analyzer.py Lizard → cyclomatic complexity, function/line counts │ ├── class_counter_analyzer.py │ └── python_comment_analyzer.py +├── export/ git_export_analysis_worker.py (Git export worker) ├── utils/ engines and shared helpers │ ├── file_analysis_engine.py / directory_analysis_engine.py │ ├── dependency_analysis_engine.py (dependency graph; tree-sitter-language-pack) @@ -44,7 +46,7 @@ src/code_analysis/python/ ## The field-schema contract (critical seam) -1. `python/utils/xr_field_schema.py` defines which metric fields exist per analysis type. +1. `backend/src/utils/xr_field_schema.py` defines which metric fields exist per analysis type. 2. TS fetches it via `main.py --mode schema`, cached/served by `src/core/analysis/python/xrFieldSchemaService.ts` (prefetched at startup by the `StartupCoordinator`). 3. `src/core/charts/processing/dimensionValidator.ts` validates user dimension mappings against that schema before launching an XR scene. @@ -52,36 +54,37 @@ src/code_analysis/python/ **Do not touch in a cleanup (audited 2026-09-18).** The contract is five hops long (`xr_field_schema.py` → `get_xr_schema` → `main.py --mode schema` → `executePython.ts` → `xrFieldSchemaService.ts` → `dimensionValidator.ts`), frozen by tests on both sides, and the schema is **persisted** in the user's `globalState` (`codeXR.analysis.xrFieldSchemaCache.v1`), so a Python-side change can be masked locally and surface later as a mapping failure. Therefore none of these is cleanup material: - `XR_SCHEMA_VERSION` — a bump invalidates every user's cached schema. -- The order, count and exact label strings of `XR_FILE_FIELDS` (13) and `XR_DIRECTORY_FIELDS` (25); `test/python/xr_schema/test_xr_schema.py` pins the counts. +- The order, count and exact label strings of `XR_FILE_FIELDS` (13) and `XR_DIRECTORY_FIELDS` (25); `backend/tests/xr_schema/test_xr_schema.py` pins the counts. - The `_text_field(…)` / `_numeric_field(…)` call syntax — `test/analysis/xrFieldSchemaIntegration.test.cjs` regex-matches five of those source lines, double quotes included. - The `build_complexity_band` thresholds (`>25`, `>10`), mirrored in `lizard_analyzer.calculate_complexity_metrics` and `summarize_function_metrics`. Three copies on purpose: de-duplicating them is a contract change, not a cleanup. - `summarize_function_metrics` — Lizard reports CCN 18, but that is `or 0` guards inside comprehensions, not branching. Leave it alone. -- Every id in `XR_DIRECTORY_FIELDS` must stay a key emitted by `utils/file_metric_summary.py`, and every id in `XR_FILE_FIELDS` a key emitted by `utils/file_analysis_engine.py` (subset checks in `test/analysis/manual_metrics_suite.py`). +- Every id in `XR_DIRECTORY_FIELDS` must stay a key emitted by `utils/file_metric_summary.py`, and every id in `XR_FILE_FIELDS` a key emitted by `utils/file_analysis_engine.py` (subset checks in `backend/tests/manual_metrics_suite.py`). Python source is also pinned on **quote style and import order** by source-text tests (`main.py`'s `choices=['livePanel', …]`, `print('=== JSON_START ===')`, the imports that follow the `sys.path` setup). No formatter, no isort. ## Virtual environment (`src/core/python-env/`, commands and tree in `src/features/python-env/`) -- `runtime/venvManager.ts` creates/verifies/reinstalls the venv; package manifest and env UI state live alongside it. User-facing commands: `codeXR.pythonEnv.*` (create/delete/status/reinitialize/verify/debug). -- Python dependencies (e.g. `lizard`, `tree-sitter-language-pack`) are installed into this venv at runtime. **Needs verification**: the exact dependency manifest location (there is no top-level `requirements.txt`; the manifest appears to live inside `src/python_env/` — confirm before changing dependencies). +- `venvManager.ts` creates/verifies/reinstalls the venv; the package manifest (`pythonPackageManifest.ts`), storage and env UI state live alongside it. User-facing commands: `codeXR.pythonEnv.*` (create/delete/status/reinitialize/verify/debug). +- Python dependencies are installed into this venv at runtime. The source of truth for the pins is `CODEXR_PYTHON_PACKAGES` in `src/core/python-env/pythonPackageManifest.ts` (`lizard` 1.17.31, `tree-sitter-language-pack` 1.8.1); `backend/requirements.txt` is its generated mirror (`npm run python:requirements`, checked by `test/python_env/pythonRequirements.test.cjs`). Note: `tree-sitter-language-pack` downloads its parser libraries from GitHub on first use (the install verification calls `get_parser("python")`). - Context key `codeXR.pythonEnv.uiLocked` gates analysis context menus while the env is being set up. ## Languages and metrics - Metrics: cyclomatic complexity (CCN), LOC/comment lines, function/class counts, parameters — primarily via **Lizard**. Dependency relations via **tree-sitter-language-pack** (pinned; confidence levels exact/best-effort/unsupported/ambiguous — see `docs/features/DEPENDENCY_GRAPH_XR.md`). -- Language support: README claims 24, dependency-graph doc and roadmap say 23, and `backend/tests/fixtures/dependency-languages/` holds ~25 fixture languages. **The source of truth is `src/core/analysis/languages/languageMetadata.ts` (TS side) + `python/utils/metric_language_contract.py` (Python side)** — check those, not the docs, when a language question matters. (Recorded as documentation debt in `V1.2.0_STATUS.md`.) +- Language support: README claims 24, dependency-graph doc and roadmap say 23, and `backend/tests/fixtures/dependency-languages/` holds ~25 fixture languages. **The source of truth is `src/core/analysis/languages/languageMetadata.ts` (TS side) + `backend/src/utils/metric_language_contract.py` (Python side: 23 languages, 48 extensions, plus HTML as DOM-only)** — check those, not the docs, when a language question matters. (Recorded as documentation debt in `V1.2.0_STATUS.md`.) ## Testing the Python side | Command | Covers | |---|---| -| `npm run test:python` | pytest-style suites in `test/python/` (dependencies, directory scanning, html_dom protocol, path normalization, xr file analysis, xr schema) | +| `npm run test:python` | `unittest` suites in `backend/tests/` (analyzers + goldens, dependencies + goldens, directory scanning, git export, html_dom protocol, path normalization, xr file analysis, xr schema): 73 tests at the end of 1.2.1. They need Python 3.10+ (two tests use 3.9/3.10 APIs), while `backend/src` itself targets 3.7 | | `npm run test:analysis` | End-to-end metric equivalence over `backend/manual_test/` fixtures (one per language); asserts XR and LivePanel produce identical `data.json` | -| `npm run test:htmlanalysis` | HTML/DOM parser | +| `npm run test:htmlanalysis` | HTML/DOM parser (`backend/tests/html_dom/` + `test/analysis/livePanelDomIntegration.test.cjs`) | +| `npm run lint:python` | `ruff check` over `backend/` (`backend/ruff.toml`, ruff pinned in `backend/requirements-dev.txt`); lint only, never a formatter | | `backend/tests/manual_metrics_suite.py` | Manual metrics suite (driven by the analysis runner) | ## How future agents should use this document -- Touching anything under `python/`? Plan the TS-side schema/validation impact first (section "field-schema contract"), then run `test:python` + `test:analysis`. +- Touching anything under `backend/src/`? Plan the TS-side schema/validation impact first (section "field-schema contract"), then run `test:python` + `test:analysis`. - Never assume system Python is used — always reason in terms of the managed venv. -- Don't edit anything under `dist/` — the Python files there are build artifacts copied from `src/`. +- Don't edit anything under `dist/` — the Python files there are build artifacts copied from `backend/src/`. diff --git a/.claude/docs/V1.2.1_STATUS.md b/.claude/docs/V1.2.1_STATUS.md index c601941c..2064d56e 100644 --- a/.claude/docs/V1.2.1_STATUS.md +++ b/.claude/docs/V1.2.1_STATUS.md @@ -1,6 +1,6 @@ # v1.2.1 Status Snapshot — Cleanup & Optimization -> **Snapshot date: 2026-09-18** (opened 2026-08-03). This is the *volatile* document for v1.2.1 — update it whenever a cleanup item lands, a measurement changes, or a new debt is found. Supersedes `V1.2.0_STATUS.md` as the active status doc; that file stays as the historical record of the 1.2.0 cycle and must not be rewritten. +> **Snapshot date: 2026-11-25** (opened 2026-08-03; programme approved 2026-09-18; cleanup epic #26 executed and verified 2026-11-25, final report `docs/cleanup/REPORT.md`). This is the *volatile* document for v1.2.1 — update it whenever a cleanup item lands, a measurement changes, or a new debt is found. Supersedes `V1.2.0_STATUS.md` as the active status doc; that file stays as the historical record of the 1.2.0 cycle and must not be rewritten. > Labels: **[confirmed]** measured/verified directly in this repo · **[self-assessed]** a doc's own claim, not independently validated · **[inferred]** conclusion from evidence · **[open]** unresolved question. ## What this version is for @@ -16,11 +16,11 @@ The backlog below was the opening hunch. On 2026-09-17/18 the whole repo was aud | Wave | What | State | |---|---|---| | W0 | Setup: tool-measured baseline, make grep trustworthy, persist the audit | **done** (2026-09-18, 5 commits) | -| W1 | Safety net: test helpers, contract/sync tests, the ratchet, H1/H2 tooling, CI | **done** (2026-09-18, 30 commits) - CI not yet run: needs a push | -| W2 | Proven deletions (unreachable files, dead declarations, authorized command removals) | **next** | -| W3 | Guardrails on (ESLint + tsc strictness staged, ruff, docs) | pending | -| W4 | Logging programme, then low-risk de-duplication and complexity | pending | -| W5 | Structural refactors, each after its characterization test | pending | +| W1 | Safety net: test helpers, contract/sync tests, the ratchet, H1/H2 tooling, CI | **done** (2026-09-18, 30 commits; CI first ran on PR #24, 2026-11-25, and blocks on Windows, Linux and macOS since #33) | +| W2 | Proven deletions (unreachable files, dead declarations, authorized command removals) | **done** (2026-11-25, stories #29-#32, PRs #45-#52) | +| W3 | Guardrails on (ESLint + tsc strictness staged, ruff, docs) | **done** (2026-11-25, story #33, PR #53) | +| W4 | Logging programme, then low-risk de-duplication and complexity | **done** (2026-11-25, stories #34-#37, #56; PRs #49, #50, #58, #61-#64) | +| W5 | Structural refactors, each after its characterization test | **done**, with the documented cuts (2026-11-25, stories #38-#42, #55; PRs #51, #54, #57, #59, #60, #65). Final verification: story #43, `docs/cleanup/REPORT.md` | Everything needed to execute it lives in **`.claude/docs/v1.2.1/`**: `ROADMAP.md` (decisions, per-commit protocol, the override table, the commit-by-commit tables, the record-only register for 1.3.0, exit criteria), `AUDIT.md` (every finding with its verdict, plus the "looks dead but is ALIVE" lists — grep it before deleting anything), `DESIGN_GUARDRAILS.md`, `DESIGN_STRUCTURAL.md`, `CRITIC_REVIEW.md`. @@ -51,7 +51,7 @@ These are the "before" numbers. Re-measure at the end of the cycle and record th | `@ts-ignore` / `@ts-expect-error` | **0** — keep it there | `grep -rn "@ts-ignore\|@ts-expect-error" src` | | `TODO` markers in `src/` + `templates/` | 30 (in 28 lines) | `grep -rn "TODO\|FIXME\|HACK" src templates` | | Unit test files | 55 | `find test -name "*.test.cjs" \| wc -l` | -| `resources/languages_icons/no_color/` | 34 MB, 25 files | `du -sh` | +| `resources/languages_icons/no_color/` | 34 MB, 25 files (**deleted** in #31, W2-67) | `du -sh` | | `resources/languages_icons/color/` | 2.8 MB | `du -sh` | | `.git` pack size | **1.03 GiB** | `git count-objects -vH` | @@ -59,22 +59,26 @@ These are the "before" numbers. Re-measure at the end of the cycle and record th The table above used grep-based commands; two of its rows under-count (52,605 lines and 193 `any` against 52,974 and 219 from the AST). From here on **one command owns the source metrics**: `npm run guardrails:measure` (`test/tooling/measureGuardrails.cjs`, TypeScript AST, counting units spelled out in the baseline's `definitions`). The committed `test/tooling/guardrail-baseline.json` is the current value of every row marked †; its git diff is the before/after of each cleanup item. -| Metric | Baseline 2026-09-18 | Now | +"Now" was re-measured at the end of the cleanup epic (story #43, 2026-11-25, `v1.2.1` at `913cb362`, Linux); the before/after per story is in `docs/cleanup/REPORT.md`. + +| Metric | Baseline 2026-09-18 | Now (2026-11-25, end of epic #26) | |---|---|---| -| `npm test` | 554 / 554 | **708 / 708** | -| `npm run test:python` · `test:analysis` | 29 / 29 · green (24 root + 3 deep fixtures) | **52 / 52** · green, now measured with the pinned lizard 1.17.31 (was 1.24.0) | -| Production `dist/extension.js` | 1,257,031 bytes, deterministic (two builds, one sha256) | **byte-identical** (`d6e5cb0da408…`) at the end of W1: nothing that ships has changed | -| VSIX | 6,450,820 bytes, 360 entries | 360 entries (package.json grew by a few script lines) | -| † Source files · lines · functions | 369 · 52,974 · 2,864 | same | -| † CCN over 10 / 15 / 20 / 30 (worst) | 81 / 31 / 10 / 6 (`buildExportManifest` 61) | same | -| † Modules unreachable from `src/extension.ts` | 54 (2,317 lines) | same | -| † `console.*` calls · console-only catch blocks | 1,646 · 65 | same | -| † `any` · suppressions | 219 · 0 | same | -| † Files over 500 lines · functions over 80 lines | 19 · 57 | same | -| † `console.log` in `templates/` (excluding xr-chart-debug) | 117 | same | +| `npm test` | 554 / 554 | **1,064 / 1,064** (126 test files) | +| `npm run test:python` · `test:analysis` | 29 / 29 · green (24 root + 3 deep fixtures) | **73 / 73** · green (24 root + 3 deep fixtures, pinned lizard 1.17.31); `test:htmlanalysis` 12 + 5; `lint:python` clean | +| Production `dist/extension.js` | 1,257,031 bytes, deterministic (two builds, one sha256) | **1,173,899 bytes** (−6.6 %): deleted modules and the 46 barrels | +| VSIX | 6,450,820 bytes, 360 entries | **4,204,772 bytes, 199 entries** (−34.8 %, −161 entries) | +| † Source files · lines · functions | 369 · 52,974 · 2,864 | **291 · 49,064 · 3,338** (smaller functions, so more of them) | +| † CCN over 10 / 15 / 20 / 30 (worst) | 81 / 31 / 10 / 6 (`buildExportManifest` 61) | **53 / 8 / 0 / 0** (worst `sampleTimeline` 20) | +| † Modules unreachable from `src/extension.ts` | 54 (2,317 lines) | **0**, waivers `[]` | +| † `console.*` calls · console-only catch blocks | 1,646 · 65 | **2** (the log sink's console fallback, the only allowlisted file) · **0** | +| † `any` · suppressions | 219 · 0 | **84** · **0** | +| † Files over 500 lines · functions over 80 lines | 19 · 57 | **13 · 36** (6 files over 600; largest `core/python-env/venvManager.ts` 850) | +| † `console.log` in `templates/` (excluding xr-chart-debug) | 117 | **31** (all behind the runtimes' debug flags) | | Text files containing a raw NUL byte | 1 | **0** | -| tsc flag fallout (`noUnusedLocals` / `noUnusedParameters` / `noImplicitReturns` / `noFallthroughCasesInSwitch`) | 55 / 17 / 0 / 0 | same | -| ESLint messages today · `no-unused-vars` · `no-require-imports` fallout | 0 · 32 · 26 | same | +| tsc flag fallout (`noUnusedLocals` / `noUnusedParameters` / `noImplicitReturns` / `noFallthroughCasesInSwitch`) | 55 / 17 / 0 / 0 | **all four on** (`tsconfig.check.json`), 0 findings | +| ESLint messages today · `no-unused-vars` · `no-require-imports` fallout | 0 · 32 · 26 | **0 errors, 158 warnings = the `--max-warnings` budget** (608 when W3 introduced it, only lowered since); `no-unused-vars`, `no-console`, `no-floating-promises`, `no-require-imports` are errors | +| Two-way dependency pairs between top-level `src/` folders | 9 (15 counting the `commands/shared` back-edges) | **4**, each with a written reason in `test/tooling/folderDependencies.json` | +| `src/` shape: folders · `index.ts` barrels · snake_case folder names | 179 · 82 · 55 | **98 · 0 · 0** (five layers `app/ features/ core/ platform/ shared/`) | Lizard — the engine the extension ships — cannot be the yardstick for TypeScript: it misses async and arrow class methods and reported none of the four worst functions. That is recorded for 1.3.0 as a product observation (the TS metrics CodeXR shows are a floor, not the value). @@ -84,6 +88,9 @@ Ranked by value-to-risk. Take **one item per session**, verify, update this doc ### 1. ESLint config barely checks anything — the highest-leverage fix [confirmed] +> **Status 2026-11-25: done** (#33, PR #53): the five rules are errors, plus `no-unused-vars`, `no-console`, `no-floating-promises` and the #56 idiom rules; warn-only budget rules counted under `--max-warnings 158`. The config is `apps/vscode-extension/eslint.config.mjs`. + + `eslint.config.mjs` defines **five rules** (`naming-convention` for imports, `curly`, `eqeqeq`, `no-throw-literal`, `semi`) and **all of them are `warn`**. There is no `no-unused-vars`, no `no-explicit-any`, no `no-floating-promises`, and the TypeScript plugin is loaded but essentially unused. **Consequence:** `npm run lint` passing today is close to meaningless, and `npm test` includes it as a gate. Dead variables, unused imports and unawaited promises pass silently — which is exactly the rot this version is supposed to remove. @@ -92,14 +99,23 @@ Ranked by value-to-risk. Take **one item per session**, verify, update this doc ### 2. Dead file: `configurationManagerExample.ts` [confirmed] +> **Status 2026-11-25: deleted** (#29, W2-11). + + `src/code_analysis/configuration/configurationManagerExample.ts` has **zero importers anywhere in `src/`** and contains 44 `console.log` calls. It is an example file that shipped into the source tree. Delete it. ### 3. `debugThemeProblem.ts` is a registered debug command [confirmed] +> **Status 2026-11-25: removed** with its two command ids (#30, W2-49; CHANGELOG `[1.2.1]` → Removed). + + `src/code_analysis/configuration/debugThemeProblem.ts` (42 `console.log`) **is** imported — `src/commands/index.ts:15` registers `DebugThemeProblem`. So it is not dead, it is a debug tool exposed to end users in the command palette. Decide deliberately: remove the command, or gate it behind a development-only condition. **Do not just delete it** — the command ID is registered and `assertUniqueCommandIds` runs over that array. ### 4. 1,261 `console.log` vs a logger nobody uses [confirmed] +> **Status 2026-11-25: done** (#34, PR #58): every diagnostic goes through `src/platform/logging/` (the logger moved there in #55); 2 `console.*` calls remain, the sink's own fallback. CHANGELOG `[1.2.1]` → Changed. + + `src/core/logging/logger.ts` exports `ScopedLogger` and `CodeXRLogger`, but only **15 files** use it against **1,261** raw `console.log` calls. For a VS Code extension this is the wrong surface: `console.log` goes to a devtools console the user never opens, not to an output channel. Worst offenders: `executePython.ts` (100), `multiServerLauncher.ts` (44), `configurationManagerExample.ts` (44, dead — see item 2), `debugThemeProblem.ts` (42), `serverControl.ts` (41), `visualizeDOMParser.ts` (35). @@ -108,12 +124,18 @@ Migrate **area by area, not repo-wide in one commit**. Start with `executePython ### 5. 34 MB of dead icons in the repo [confirmed measurement, self-assessed deadness] +> **Status 2026-11-25: done.** `no_color/` deleted (#31, W2-67); the shipped `icon.png`, `ttcn3.svg` and `default.svg` re-encoded pixel-identically and the duplicate `favicon.ico` dropped from the VSIX (#41). The visual re-export of the two PNG-in-SVG icons stays in the 1.3.0 register. + + `resources/languages_icons/no_color/` is 34 MB across 25 PNGs (~1.4 MB each). `V1.2.0_STATUS.md:132` states this set has been dead since `95f7c367` and it is already excluded from the VSIX `files` allowlist — so removing it does **not** change the published package, only the working tree and future clones. **Confirm the deadness independently** (grep for `no_color` across `src/`, `templates/`, `package.json`) before deleting. Related, and *not* dead — these ship: `color/ttcn3.svg` (1.4 MB) and `color/default.svg` (1.3 MB) are SVGs with embedded bitmaps, plus `icon.png` and `favicon.ico` at ~1.2 MB each. Re-encoding them is a real VSIX size win. Carried over from `V1.2.0_STATUS.md:132`, where the debt was flagged but deliberately not taken. ### 6. Oversized modules [confirmed] +> **Status 2026-11-25:** `collaborationRoomServer.ts` 1,174 → 560, `multiServerLauncher.ts` 677 → 275, `screenBroadcastSignalingServer.ts` 781 → 580, `handleServerActions.ts` 815 → 623 (#39), `projectEvolutionService.ts` 668 → under 500 (#38). The paths below are pre-#55 (now `src/core/server/…`, `src/features/active-servers/views/…`). Six files remain over 600 lines, each listed with its reason in `docs/cleanup/REPORT.md` (exit criteria). + + There is precedent: `httpServer.ts` went 2,102 → 487 lines by responsibility split, with byte-identical characterization (`V1.2.0_STATUS.md:513`). Same technique applies to: | File | Lines | @@ -129,6 +151,9 @@ There is precedent: `httpServer.ts` went 2,102 → 487 lines by responsibility s ### 7. 193 `any` escapes [confirmed] +> **Status 2026-11-25:** 219 (AST count) → **84**; four folders are `any`-free by lint error (`codexr/any-free-folders` in `eslint.config.mjs`). The rest is recorded for 1.3.0. + + 193 occurrences of `: any` / `as any` / `` in `src/`. Note the good news: **zero** `@ts-ignore` — the codebase never silences the compiler outright. Tighten opportunistically while working an area rather than as one mass sweep, and keep the zero at zero. ### 8. `.git` is 1.03 GiB — **propose only, do not execute** [confirmed measurement] @@ -139,6 +164,9 @@ Shrinking this requires **rewriting history** (`git filter-repo`), which changes ### 9. Known duplication — trace before touching [self-assessed, from V1.2.0_STATUS.md] +> **Status 2026-11-25:** the two active-servers folders are one (`src/features/active-servers/views/`, #55); the avatar ids are pinned by a sync test (W1); `LegacyServerConfig` / `getLegacyConfig` keep their name (now in `src/core/server/serverSettingsManager.ts`): a rename is not cleanup. + + - `src/active_servers/views/` and `src/views/active_servers/` both exist. `AI_WORKFLOWS.md:42` explicitly warns this is **historical, not accidental** — do not "clean up" the aggregation wiring without tracing imports first. - `LegacyServerConfig` / `getLegacyConfig` in `servers/storage`: live API with a bad name (`V1.2.0_STATUS.md:507`). Renaming is a real refactor, not a rename-in-place. - Avatar IDs are duplicated across 4 places: `collaborationProfile.ts`, `CODEXR_AVATAR_IDS` in the room server, `SKINS` in the browser runtime, and a regex in `clientCore.js` (`V1.2.0_STATUS.md:601`). Consolidating crosses the TS↔runtime seam — read `XR_COMPONENTS.md` first. @@ -239,3 +267,18 @@ Then pushed `v1.2.1` to `origin` at the maintainer's request. **No merge and no ### Fix: Git target behind a symlink or a Windows short path — DONE [confirmed in tests] (2026-11-25, branch `claude/project-thread-2djsoy-git-realpath`) **Found by** the first CI run (PR #24, monorepo): 8 Git tests in `gitRevisionExporter.test.cjs` / `historicalComparison.test.cjs` failed on windows-latest and macos-latest with `analysis-target-outside-repository`, never on a developer machine. **Root cause**: `GitRepositoryService.resolveTargetRelativePath` did `path.relative(repositoryRoot, targetPath)` with `repositoryRoot` from `git rev-parse --show-toplevel` (canonical) and `targetPath` as given; `os.tmpdir()` is `/var/...` -> `/private/var/...` on macOS and `C:\Users\RUNNER~1\...` on Windows, so they never shared a prefix. Users hit it with any workspace opened through a symlink/junction or a short path. **Fix**: compare `fs.realpathSync.native` of both sides (falls back to `path.resolve` when the path cannot be resolved). **Behaviour change, user-approved** (decision 2026-11-25), recorded under CHANGELOG `[1.2.1]` → Fixed. **Test**: new `historicalComparison.test.cjs` case with a junction-linked repository (fails before: `analysis-target-outside-repository`; passes after) plus a real outside-folder rejection. Gate 708/709 on Linux (the one failure is the pre-existing Windows-path assertion in the unified decorator test). + +### Epic #26 deep cleanup, closed by #43 final verification — DONE [confirmed] (2026-11-25, PRs #44-#65 into `v1.2.1`; #43 on branch `claude/project-thread-n2s3q6-final-verification`) + +**What landed**: 20 pull requests (#44-#65) executed waves W2-W5 of `v1.2.1/ROADMAP.md` plus the post-monorepo sweep, the layering work, the feature-first `src/` layout (#55) and the idiom modernization (#56). One log per story, each with its commits, before/after numbers, gates, what was left and its F5 list, in `v1.2.1/sessions/`: +`29-dead-code.md`, `30-authorized-command-removals.md`, `31-assets-media-tooling.md`, `31-python-dead-code.md`, `31-templates-runtime.md`, `32-monorepo-seams.md`, `33-guardrails.md`, `34-logging.md`, `35a-ts-pipeline.md`, `35b-ts-dedup.md`, `36-python-backend.md`, `37-runtime-dedup.md`, `38-git-services.md`, `39-server-splits.md`, `40-tree-assets.md`, `41-vsix-size.md`, `42-layering.md`, `55-src-layout.md`, `56a-modernize-py-js.md`, `56b-modernize-ts.md`. + +**Final verification (#43, on `913cb362`)**: `npm test` 1,064/1,064 (lint 0 errors, 158/158 warnings); `test:python` 73; `test:analysis` green (24 root + 3 deep fixtures); `test:htmlanalysis` 12 + 5; `lint:python` clean; the four browser harnesses pass with the CDN scripts served locally (the sandbox proxy refuses the CDNs); `package:vsix` 4,204,772 bytes / 199 files; CI green on three OSes on PR #65. The packaged VSIX was driven end to end under the fake `vscode` host with a real venv, real servers and headless Chromium (`@vscode/test-electron` cannot download VS Code here). Story #27: `test/baseline/featureBaseline.test.cjs` green without `--write`. + +**Epic before/after (`399494af` → `913cb362`)**: `src/` 369 → 291 files, 52,988 → 49,064 lines; unreachable modules 54 → 0; `console.*` 1,646 → 2; `any` 219 → 84; CCN over 20 10 → 0 (worst 61 → 20); files over 600 lines 11 → 6; folders 179 → 98, barrels 82 → 0; tests 708 → 1,064, backend 52 → 73; VSIX 6.45 MB / 360 → 4.20 MB / 199. + +**Exit criteria**: 20 of 27 met, 2 partial (complexity still a warning; CI "required" needs branch protection), 5 not met with recorded reasons (9 dead exports, `src/` 64 lines over 49,000, Python worst CCN 18 in the do-not-touch schema contract, 6 files over 600 lines, largest file 850). + +**E2E findings (older behaviour, identical on the pre-cleanup VSIX, recorded for 1.3.0)**: the Barsmap and Pie examples get 404 for `../../data/*.json` (static root is the example folder); the same target analysed in two modes at once leaves the first server's `/events` at 404 (one port per file in the file-to-server map); `babia-html`'s html2canvas throws in headless Chromium. + +**Where it is written up**: `docs/cleanup/REPORT.md` (repository root): findings, story/PR table, neutrality evidence, the §5 table, the 1.3.0 deferrals, the E2E result per feature-baseline §10 row and the **consolidated maintainer F5/VSIX checklist**, which is what remains before the release is cut. diff --git a/apps/vscode-extension/CHANGELOG.md b/apps/vscode-extension/CHANGELOG.md index eba68f68..7418cb28 100644 --- a/apps/vscode-extension/CHANGELOG.md +++ b/apps/vscode-extension/CHANGELOG.md @@ -4,12 +4,12 @@ ### CodeXR 1.2.1: Internal Code Quality -**This release adds no features.** Everything you could do in 1.2.0 you can do in 1.2.1, the same way, with the same results. What changed is on the inside: the code of the plugin itself was audited end to end and is being cleaned up so that the next versions can grow on solid ground. If you upgrade, you should notice nothing, and that is the goal. +**This release adds no features.** Everything you could do in 1.2.0 you can do in 1.2.1, the same way, with the same results. What changed is on the inside: the code of the plugin itself was audited end to end and cleaned up so that the next versions can grow on solid ground. If you upgrade, you should notice nothing, and that is the goal. #### Internal improvements - **The whole codebase was audited before anything was touched.** Every module was measured (real cyclomatic complexity, duplicated code, modules nothing imports, commands nothing can reach) and each finding was checked twice by independent reviewers before being accepted. The result is a ranked, evidence-backed cleanup plan instead of a hunch. -- **A much larger safety net.** The automated suite went from 554 to 708 checks on the extension side and from 29 to 52 on the Python analysis backend, and a large part of it now *executes* the plugin's code instead of only reading it. New checks cover the command surface against `package.json`, the logger, the language tables, the XR scene assets, the collaboration avatars, the offline historical comparison and the dependency engine, whose full output is now pinned by golden snapshots. +- **A much larger safety net.** The automated suite went from 554 to 1,064 checks on the extension side and from 29 to 73 on the Python analysis backend, and a large part of it now *executes* the plugin's code instead of only reading it. New checks cover the command surface against `package.json`, the logger, the language tables, the XR scene assets, the collaboration avatars, the offline historical comparison and the dependency engine, whose full output is now pinned by golden snapshots. - **Proof, not promises, that nothing was lost.** The shipped bundle is built deterministically and fingerprinted, so an internal change can be shown to leave it byte-for-byte identical. Code-health metrics (complexity, unused modules, leftover debug logging, loose typing) are measured automatically and can only improve from here: a change that makes any of them worse fails the build. - **Tests that cannot give a false green.** The test build now starts from a clean slate, refuses to run against stale output, and measures the per-language analysis fixtures with exactly the analyzer version the extension installs for you. - **Continuous integration.** The same gates a developer runs locally now run on Windows and Linux for every pull request. @@ -24,12 +24,13 @@ - **The hidden `codeXR.visualizeData.debugState` command.** A troubleshooting command that printed the Visualize Data state to the developer console; nothing in the sidebar, the menus or the Command Palette could run it. - **The two hidden theme debugging commands** `codexr.debug.themeConfiguration` and `codexr.debug.themeWorkflow`, together with the diagnostics module behind them. They only wrote to the developer console and nothing could run them. Theme settings are unaffected. - **The "Hello World" command** (`CodeXR.helloWorld`), a leftover from the extension template that showed a greeting and nothing else. It no longer appears in the Command Palette. +- **Four unused sample datasets** under `examples/data/` (`gdp.json`, `simple_sales.json`, `temperatures.json`, `test_functions.json`) that no BabiaXR example ever loaded. Every example in the BabiaXR Examples view opens and renders exactly as before. #### Changed -- **Smaller package.** The extension download shrinks from 6.44 MB to 4.21 MB (352 to 203 files): the scene templates and chart examples are no longer packaged twice, the `docs/` guides are no longer packaged (the README links them online, as before), a duplicate copy of the icon is gone, and the three largest icons were losslessly recompressed (pixel-identical). Every saved analysis folder also carries a 150 KB lighter page icon. Nothing you see or use changes. +- **Smaller package.** The extension download shrinks from 6.45 MB to 4.20 MB (360 to 199 files): the scene templates and chart examples are no longer packaged twice, the `docs/` guides are no longer packaged (the README links them online, as before), a duplicate copy of the icon is gone, and the three largest icons were losslessly recompressed (pixel-identical). Every saved analysis folder also carries a 150 KB lighter page icon. Nothing you see or use changes. - **"CodeXR: Debug Python Environment Failure" is no longer offered in the Command Palette.** It is a developer tool that deliberately breaks and deletes the extension's Python environment, with no confirmation. The command still exists for development use; it simply cannot be picked by accident anymore. -- **Diagnostics now go to the "CodeXR" output channel instead of the developer console.** Open *View → Output* and pick **CodeXR** to read them. Warnings and errors are always written there; step-by-step detail (which includes file paths) is written only when `codeXR.debug.verboseLogs` is on, as that setting already promised. Messages logged while the extension is still starting are no longer lost: they appear in the channel as soon as it opens. +- **Diagnostics now go to the "CodeXR" output channel instead of the developer console.** Open *View → Output* and pick **CodeXR** to read them. Warnings and errors are always written there; step-by-step detail (which includes file paths) is written only when `codeXR.debug.verboseLogs` is on, as that setting already promised. Messages logged while the extension is still starting are no longer lost: they appear in the channel as soon as it opens. The generated XR and DOM scenes and the directory LivePanel page also stop printing their routine loading and live-reload messages to the browser console; their warnings and errors are still printed there. #### Fixed @@ -38,10 +39,6 @@ - **The analysis backend loads again on Python 3.8 and 3.9.** One type annotation in the line-metrics module used syntax that only exists from Python 3.10, so on 3.8 or 3.9 every analysis failed as soon as the backend loaded, although the extension asks only for Python 3.7 or newer. The annotation now uses the older spelling; results on newer Python versions are unchanged. - A source file of the XR chart-mapping runtime contained a raw control character typed into a string. Behaviour was correct, but the file was invisible to code search and review tools. It now uses the equivalent escape sequence; the runtime value is identical. -#### Removed - -- Four sample datasets under `examples/data/` (`gdp.json`, `simple_sales.json`, `temperatures.json`, `test_functions.json`) that no BabiaXR example ever loaded. Every example in the BabiaXR Examples view opens and renders exactly as before; the package carries 8 fewer files. - ## [1.2.0] - 2026-07-30 ### CodeXR 1.2.0: "Threads, Timelines & Global Networks" diff --git a/docs/cleanup/README.md b/docs/cleanup/README.md index 770bfe9c..732aad86 100644 --- a/docs/cleanup/README.md +++ b/docs/cleanup/README.md @@ -1,6 +1,6 @@ # Code-XR deep cleanup (epic #26) -> **Status:** in progress since 2026-11-25. **Tracking:** [epic #26](https://github.com/Code-XR-Project/Code-XR/issues/26) on the TFM board. +> **Status:** done 2026-11-25: every story merged into `v1.2.1` (PRs #44-#65); the final verification, measurements and maintainer checklist are in [`REPORT.md`](REPORT.md) (#43). **Tracking:** [epic #26](https://github.com/Code-XR-Project/Code-XR/issues/26) on the TFM board. > **Branch policy:** one pull request per story, always against `v1.2.1`; nothing reaches `master` until the maintainer promotes the release. ## Why @@ -13,6 +13,7 @@ This epic executes the v1.2.1 cleanup programme approved on 2026-09-18 (`.claude | Document | What it is | |---|---| +| [`REPORT.md`](REPORT.md) | **Final report** (#43): findings by area, every story and pull request, the behaviour-neutrality evidence, the ROADMAP §5 exit criteria, the deferrals for 1.3.0, the automated E2E of the packaged VSIX and the consolidated maintainer F5 checklist. | | [`feature-baseline.md`](feature-baseline.md) | Exhaustive inventory of everything the extension has and does before the cleanup, with automated and manual verification steps (§10). The reference for "nothing was lost". | | [`w2-revalidation.md`](w2-revalidation.md) | The W2 deletion rows of the roadmap re-checked against the monorepo tree: 57 valid, 16 need amendments, 1 partly invalid (W2-29). | | [`sweep-outside-src.md`](sweep-outside-src.md) | Sweep of everything the original audit did not cover: root config, `.github/`, `.claude/`, `adr/`, `docs/`, `media/`, `pages/`, scripts, fixtures and the monorepo seams. | diff --git a/docs/cleanup/REPORT.md b/docs/cleanup/REPORT.md new file mode 100644 index 00000000..b31dd7d2 --- /dev/null +++ b/docs/cleanup/REPORT.md @@ -0,0 +1,535 @@ +# Code-XR deep cleanup (epic #26): final report + +> **Story:** [#43](https://github.com/Code-XR-Project/Code-XR/issues/43), final verification, measurements and report. It also closes [#27](https://github.com/Code-XR-Project/Code-XR/issues/27), the feature baseline verified at the end. +> **Measured on:** 2026-11-25, `v1.2.1` at `913cb362` (merge of PR #65). +> **Compared with:** `399494af`, the `v1.2.1` head before PR #44 and the epic's baseline in [`README.md`](README.md). +> **Scope of this story:** documentation and tests only. No source file changed behaviour here. + +## 1. Executive summary + +The cleanup landed as 20 pull requests (#44 to #65) against `v1.2.1`. As far as every check that can run here shows, the extension does everything it did before: +- **The gates.** All automated gates are green on the final tree: + - `npm test`: 1,064 of 1,064; + - the backend suites: 73; + - the per-language analysis fixtures, the HTML analysis suites and `ruff`; + - the four browser harnesses. +- **CI.** CI was green on PR #65 for Linux, Windows and macOS. +- **The packaged VSIX.** It was driven end to end with a real Python environment, real servers and a real Chromium. Section 8 says, row by row, what that run verified and what still needs the maintainer's F5 or VSIX check. +- **No regression found.** The end-to-end run found three oddities. Running the same checks on the pre-cleanup package gives the same result for each, so they are older behaviour, recorded for 1.3.0 in section 9. + +Headline numbers, before → after: + +| | Before (`399494af`) | After (`913cb362`) | +|---|---|---| +| TypeScript in `src/` | 369 files, 52,988 lines | 291 files, 49,064 lines | +| Modules unreachable from `extension.ts` | 54 | 0 | +| `console.*` calls in `src/` | 1,646 | 2 | +| `any` | 219 | 84 | +| Functions over CCN 20 (worst) | 10 (61) | 0 (20) | +| Files over 600 lines (largest) | 11 (1,174) | 6 (850) | +| Folders in `src/` / `index.ts` barrels | 179 / 82 | 98 / 0 | +| Extension tests / backend tests | 708 of 709 / 52 | 1,064 of 1,064 / 73 | +| VSIX | 6.45 MB, 360 files | 4.20 MB, 199 files | +| Tracked working tree | 313.5 MB, 919 files | 117.1 MB, 902 files | + +ROADMAP §5 has 27 exit criteria: +- **20 are met.** +- **2 are partial:** + - `complexity` is still an ESLint warning, not an error; + - CI is not yet "required": that needs branch protection, which only the maintainer can turn on. +- **5 are missed.** Each is missed by a recorded margin, with its reason in section 6. None of them hides a lost feature. + +**What is left before the release is cut:** the maintainer's F5 and installed-VSIX checklist in section 10, and branch protection. + +## 2. Method + +**Gates.** Each was run from the repository root after a clean `npm ci`, with Node 24 and Python 3.11. The results are in section 5. + +**Browser harnesses.** Two things in this environment stop them from running as they are: +- the proxy refuses the CDNs (A-Frame, BabiaXR, aframe-extras, environment, geometry-merger) with HTTP 403; +- the installed Chromium is build 1243, while the pinned Playwright expects 1228. + +So the four harnesses ran with a Node preload. It points Playwright at the installed headless shell and answers each CDN request from a local copy of the exact pinned version, taken from npm. The harness code and the harness pages are unchanged. + +**Before measurements.** They come from a separate worktree of `399494af`, built and packaged the same way. Every before/after pair below counts the same way on both trees. + +**E2E.** +- `@vscode/test-electron` cannot run here: the proxy refuses the VS Code download (HTTP 403). +- The fallback that the story allowed was used instead: + - The **packaged VSIX** was unzipped, and its `dist/extension.js` was loaded under the repository's fake `vscode` host (`test/helpers/fakeVscode.cjs`). + - It ran in production mode, with a fresh profile and a Git sample workspace. + - The extension created its own Python venv. + - Every page it served was opened in headless Chromium. +- **Old against new.** The rows that showed problems were re-run on the pre-cleanup VSIX, so that older behaviour can be told apart from a regression. +- **One sandbox workaround.** tree-sitter-language-pack's own downloader rejects the proxy's CA. The same parser bundle was fetched separately, checked against its published sha256 and placed in the package's cache before the venv was verified. + +**What this report does not claim.** Nobody has tested anything here by hand in VS Code. A row marked "maintainer" in section 8 has not been checked by anyone yet. + +## 3. Findings by area + +| Area | What was found | What was done | Stories | +|---|---|---|---| +| Unreachable code | 54 modules (2,317 lines) unreachable from `extension.ts`; dead declarations in live files; `configurationManagerExample.ts` | Deleted after the four-check deadness proof; 0 unreachable modules remain | #29 | +| Commands | The template's "Hello World"; two theme-debug commands; unreachable command layers | Removed. `Debug Python Environment Failure` hidden from the palette. 69 contributed and 105 registered ids pinned by a test | #30 | +| Assets and media | 34 MB of unused `no_color/` icons; about 170 MB of unused media; an empty integration-test lane and its dependencies; four sample datasets no example loaded | Deleted; the shipped icons re-encoded pixel-identically | #31, #41 | +| Monorepo seams | The backend located through paths from before the move; stale agent docs | Fixed, with a Development-mode fallback to `backend/src` | #32 | +| Python backend | 16.1% duplicated windows; a misspelled `sumaryFiles/` package; per-file stderr noise; the backend failed to load on Python 3.8 and 3.9 | Duplication down to 4.0%; renamed `summaryFiles/`; loads on 3.8+; goldens for class counting and dependencies | #31, #36, #56 | +| Browser runtimes | Duplicated LivePanel and SSE client code; a dead `htmlLiveReload.js`; an unused visual-style runtime; console chatter in user-facing scenes | De-duplicated against characterization transcripts; routine logs behind a debug flag | #31, #37, #56 | +| Guardrails | ESLint checked almost nothing; no ratchet on size or complexity; no Python linter | Strict ESLint (errors plus budgeted warnings), strict `tsc`, `ruff`, the guardrail ratchet, CI on three OSes | #33 | +| Logging | 1,646 `console.*` calls and 65 console-only catch blocks; a logger nobody used | Everything goes through `src/platform/logging/` and the CodeXR output channel; `codeXR.debug.verboseLogs` changes the verbosity live | #34 | +| TS pipeline, export, settings | Long branching functions (worst CCN 61); duplicated bridges and settings code; floating promises | Split under characterization tests; 0 floating promises, now a lint error | #35 | +| Git services | Historical comparison, project evolution and export each re-implemented revision handling (147 duplicated lines) | One shared core; 23 duplicated lines left | #38 | +| Servers | `collaborationRoomServer.ts` at 1,174 lines; duplicated HTTPS servers; the launcher reaching into the view layer | Split; the HTTPS pair is down to 28 identical lines; the launcher no longer imports the view layer | #39 | +| Sidebar and scene assets | Hand-built tree sections; asset lists repeated per scene mode | A data-driven tree from section definitions; one scene-asset descriptor table | #40 | +| Package | A 6.45 MB VSIX with copies of `templates/` and `examples/` under `dist/`, shipped `docs/` and a duplicate favicon | 4.20 MB and 199 files; packaging and startup measured | #41 | +| Layering | 9 two-way folder cycles (15 counting `commands/shared` back-edges) | 4 left, each recorded; a registry emitter with no `vscode` import | #42 | +| `src/` layout | 179 folders, 82 barrels, mixed naming | Feature-first `app/ → features/ → core/ → platform/ → shared/`; 98 kebab-case folders; 0 barrels; the move map in [`src-move-map.json`](src-move-map.json) | #55 | +| Idioms | Old TypeScript, Python and runtime patterns | Modernized and locked in by lint rules | #56 | + +## 4. Stories and pull requests + +Every pull request targeted `v1.2.1` and merged green. Each story has a session log under `.claude/docs/v1.2.1/sessions/`, which is not shipped. A log holds the story's commits, its before/after numbers, its gates, what was deliberately left and its F5 list. + +| PR | Story | What it did | Session log | +|---|---|---|---| +| #44 | #27, #28 | Safety net: feature baseline test, portable tests, the epic analysis | this folder's analysis documents | +| #45 | #31 | Dead assets and media, the empty integration lane | `31-assets-media-tooling.md` | +| #46 | #32 | Monorepo seams and stale agent docs | `32-monorepo-seams.md` | +| #47 | #30 | Scaffold, debug and unreachable commands | `30-authorized-command-removals.md` | +| #48 | #41 | Smaller VSIX | `41-vsix-size.md` | +| #49 | #31, #37 | Dead template code, runtime de-duplication | `31-templates-runtime.md`, `37-runtime-dedup.md` | +| #50 | #31, #36 | Python dead code, backend simplification | `31-python-dead-code.md`, `36-python-backend.md` | +| #51 | #38 | Historical, evolution and export services | `38-git-services.md` | +| #52 | #29 | Unreachable modules and dead declarations | `29-dead-code.md` | +| #53 | #33 | Guardrails: ESLint, `tsc`, `ruff`, CI | `33-guardrails.md` | +| #54 | #39 | Server, collaboration and broadcast splits | `39-server-splits.md` | +| #57 | #40 | Data-driven tree, scene asset table | `40-tree-assets.md` | +| #58 | #34 | Logging through the output channel | `34-logging.md` | +| #59 | #55, #56 | `src/` target tree and modernization inventory (documents only) | [`src-layout.md`](src-layout.md), [`modernization.md`](modernization.md) | +| #60 | #42 | Module layering | `42-layering.md` | +| #61 | #35 (part B) | TypeScript de-duplication; floating promises to 0 | `35b-ts-dedup.md` | +| #62 | #56 (part A) | Python and runtime idioms | `56a-modernize-py-js.md` | +| #63 | #35 (part A) | TypeScript pipeline, export and Git code | `35a-ts-pipeline.md` | +| #64 | #56 (part B) | TypeScript idioms | `56b-modernize-ts.md` | +| #65 | #55 | Feature-first `src/` layout | `55-src-layout.md` | +| this branch | #43, #27 | Final verification and this report | this document | + +## 5. Evidence that behaviour did not change + +### 5.1 Gates on the final tree (`913cb362`) + +| Gate | Result | +|---|---| +| `npm test` (typecheck, lint, compile-tests, unit) | 1,064 tests: 1,064 pass, 0 fail. `tsc --noEmit` clean. ESLint: 0 errors and 158 warnings, within `--max-warnings 158` | +| `npm run test:python` | 73 tests, OK | +| `npm run test:analysis` | 5 tests OK over 24 root and 3 deep fixtures; XR and LivePanel `data.json` identical | +| `npm run test:htmlanalysis` | 12 Node tests and 5 Python tests, OK | +| `npm run lint:python` | `ruff` 0.17.6: "All checks passed!" | +| `npm run test:xr-harness` | pass (CDN served locally, see section 2) | +| `npm run test:xr-immersive-harness` | pass (same) | +| `npm run test:xr-mode-harness` | pass (same) | +| `npm run test:project-evolution-harness` | exit 0 (same) | +| `npm run package:vsix` | `code-xr-1.2.1.vsix`: 4,204,772 bytes, 199 files; `dist/extension.js` 1,173,899 bytes | +| CI on PR #65 (head `d3463262`) | success: `npm test` on ubuntu, windows and macos; the Python suites on all three; VSIX packaging | + +**Story #27.** The feature baseline test, `test/baseline/featureBaseline.test.cjs`, runs inside `npm test` and is green without `--write`. It pins: +- the manifest: commands, menus, `when` clauses, settings; +- the command registry; +- chart types, runtimes and languages; +- the Python CLI surface. + +### 5.2 Feature baseline §10.A: the automated rows + +| Row | Result | +|---|---| +| 1-5 | Green; see 5.1 | +| 6-9: manifest, contributed ids, internal ids, menus | Pinned by `featureBaseline.test.cjs` and `test/commands/*`, all green. 69 contributed commands, 36 internal ids, and `CodeXR.helloWorld` is gone | +| 10: language contract | `23 48`. `languageMetadata.ts`, now in `src/core/analysis/languages/`, has 24 `{ name:` entries | +| 11: field schema | file: 13 fields; directory: 25; `schemaVersion` 1 | +| 12: Python CLI | See the notes below the table | +| 13-17: runtimes, server surface, sidebar, capabilities, persisted keys | Pinned by the baseline and characterization suites, all green. The paths moved in #55; [`src-move-map.json`](src-move-map.json) maps old to new | +| 18: pinned versions | Unchanged: lizard 1.17.31, tree-sitter-language-pack 1.8.1, cloudflared 2026.5.2, A-Frame 1.7.1, aframe-extras 7.5.4, babia 1.3.4, environment 1.5.0, geometry-merger 2.0.1 | +| 19: VSIX listing | See 5.3 | +| 20: guardrails | `npm run guardrails:measure` shows only improvements over the recorded baseline | +| 21: harnesses | Pass; see 5.1 | + +Row 12, the Python CLI: +- `--help` lists: + - `--mode {livePanel,xr,schema,dependencies}` and `--type {file,directory}`; + - `--target`, `--files`, `--deep`, `--cache`, `--dependency-refresh` and `--project-root`. +- The `project` type and `--output` are gone, as authorized. +- The three spawned scripts exist; `summaryFiles/` is now spelled correctly. + +### 5.3 The VSIX listing against the pre-cleanup package + +The 1.2.1 package has 161 fewer entries than the one built from `399494af`. Each removed entry falls into one of these groups. Every group was removed by name in a story, and the CHANGELOG lists it wherever a user could notice: +- **The copies under `dist/`:** `dist/templates/` (130 files) and `dist/examples/` (14). The extension reads `templates/` and `examples/` from the package root, as before. +- **Documentation:** 8 files under `docs/`. The README links to them on GitHub. +- **Sample data:** the 4 unused `examples/data/*.json` datasets. +- **A duplicate icon:** `resources/favicon.ico`. +- **Dead runtimes:** `codexrVisualStyleRuntime.js` and `htmlLiveReload.js`. +- **Dead Python:** the Python `examples/` folder and the dead `file_reanalysis_coordinator.py` under `livePanels/`. + +`sumaryFiles/` appears renamed as `summaryFiles/`. Nothing was added that the old package lacked, apart from the files the stories above renamed or moved. + +## 6. Exit criteria (ROADMAP §5) + +The "after" values come from `npm run guardrails:measure`. The "before" values come from the same scripts run on the before tree. "Before" means `399494af` unless the table says otherwise. + +| Criterion | Target | Before → after | Status | +|---|---|---|---| +| Modules unreachable from `extension.ts` | 0 | 54 → 0 | met | +| Dead exports (declarations nothing reads) | 0 | 26 → 9 | **not met.** 6 of the 9 are recorded in the session logs. 3 are new findings for 1.3.0: `DEFAULT_CONFIGURATION_FILE`, `getLanguageStats` and `ExampleLaunchConfig` | +| Commands contributed / registered / pending removal | 69 / 106 / 0 | 69 / 105 / 0, plus 2 fenced legacy aliases | met. The 106 target assumed `helloWorld` would stay registered; it was removed together with its contribution | +| Debug or scaffold commands in the palette | 0 | 0 | met | +| TypeScript lines in `src/` | ≤ 49,000 | 52,988 → 49,064 | **not met, by 64 lines** (48,773 by `wc -l`; the ratchet counts one extra line per file). The #56 lint rules and the #55 layer headers added lines on purpose | +| TS functions over CCN 30 / 20 / 15 | 0 / ≤ 3 / ≤ 12 | 6 / 10 / 31 → 0 / 0 / 8 | met | +| Worst TS CCN | ≤ 25 | 61 → 20 (`sampleTimeline`) | met | +| Python functions over CCN 15 | ≤ 4 | 1 | met | +| Worst Python CCN | ≤ 15 | 18 (`summarize_function_metrics`) | **not met.** This function builds the XR field-schema contract, which the roadmap marks do-not-touch for 1.2.1 | +| `analyze_classes` length | ≤ 160 lines | 31 lines (CCN 5) | met | +| Files over 600 lines | ≤ 4 | 11 → 6 | **not met.** The six and the reason each stays are listed after this table | +| Largest file | ≤ 700 lines | 1,174 → 850 (`venvManager.ts`) | **not met.** The venv split was cut from 1.2.1: it was too risky without a test against a real install | +| HTTPS server pair: identical lines | ≤ 30 | 212 → 28 | met. #39 reported 156 → 26 with a narrower filter; this is the corrected measure, taken the same way on both trees | +| Historical ↔ evolution: duplicated lines (window of 4) | ≤ 25 | 147 → 23 | met | +| `toPortableRelativePath` copies | 1 | 4 → 1 | met | +| Python duplicated windows (window of 6) | ≤ 6% | 16.1% → 4.0% | met | +| `console.*` in `src/` | ≤ 5 | 1,646 → 2 (the log sink's own fallback) | met | +| Console-only catch blocks | 0 | 65 → 0 | met | +| `any` | ≤ 125 | 219 → 84 | met | +| `@ts-ignore` and other suppressions | 0 | 0 → 0 | met | +| Floating promises | 0 | → 0, enforced as a lint error | met | +| ESLint rules as error | the 5 original rules, `no-unused-vars`, `no-console`, complexity | All are errors except `complexity`, which warns at 15 inside the counted budget (`--max-warnings 158`, down from 608 when W3 introduced it) | **partial.** Making `complexity` an error first needs the 8 functions over 15 split | +| `tsc` strictness flags | 4 | all 4 on | met | +| Lint scope | `src`, `test`, `scripts`, configs, runtimes | all covered | met | +| `ruff` | clean | clean | met | +| CI | green and required | green on 3 OSes, blocking in the workflow | **partial.** "Required" is a branch-protection setting that only the maintainer can turn on | +| Working tree | 34 MB smaller | 313.5 MB → 117.1 MB tracked (−196 MB) | met | + +Six files are still over 600 lines. Each stays for a stated reason: + +| File | Lines | Why it stays | +|---|---|---| +| `src/core/python-env/venvManager.ts` | 850 | Its behaviour depends on a real install, and there is no test host for that; the split is planned for 1.3.0 | +| `src/features/analysis/sections/active-analyses/activeAnalysesCommands.ts` | 802 | The export wizard could move out, but its test reads this file by path | +| `src/core/export/exportManifest.ts` | 745 | Already brought down from CCN 61; what remains is the manifest schema | +| `src/core/remote-access/remoteSessionAuthority.ts` | 631 | A security-sensitive auth flow; it is not reshaped without a tunnel test | +| `src/features/active-servers/views/handleServerActions.ts` | 623 | Down from 815 (#39); what remains is one action per server menu entry | +| `src/core/history/gitRepositoryService.ts` | 616 | The single Git access layer that #38 consolidated into | + +## 7. Epic before/after in full + +| Measure | Before (`399494af`) | After (`913cb362`) | +|---|---|---| +| TypeScript files / lines (ratchet count) / functions | 369 / 52,988 / 2,865 | 291 / 49,064 / 3,338 | +| Unreachable modules | 54 | 0 | +| `console.*` / console-only catch blocks | 1,646 / 65 | 2 / 0 | +| `any` / suppressions | 219 / 0 | 84 / 0 | +| Functions over CCN 10 / 15 / 20 / 30 | 81 / 31 / 10 / 6 | 53 / 8 / 0 / 0 | +| Functions over 80 lines | 57 | 36 | +| Files over 500 / 600 lines | 19 / 11 | 13 / 6 | +| ESLint warning budget | none | 158 | +| Two-way folder pairs | 9 | 4 | +| Folders / `index.ts` barrels | 179 / 82 | 98 / 0 | +| Folder naming: snake_case / camelCase / kebab-case | 55 / 2 / 0 | 0 / 0 / 23 | +| Test files / tests | 74 / 708 of 709 | 126 / 1,064 of 1,064 | +| Backend tests | 52 | 73 | +| VSIX bytes / entries | 6,446,832 / 360 | 4,204,772 / 199 | +| `dist/extension.js` | 1,257,156 B | 1,173,899 B | +| Tracked tree | 313.5 MB, 919 files | 117.1 MB, 902 files | +| TODO markers | 28 | 17 | + +The function count went up because long functions were split into named helpers. + +## 8. Automated E2E of the packaged VSIX + +How the run was set up: +- **The package.** `code-xr-1.2.1.vsix` was built by `npm run package:vsix` from `913cb362` and unzipped. +- **Activation.** Its `dist/extension.js` was activated under `test/helpers/fakeVscode.cjs`, in production mode, with an empty global storage. +- **The workspace.** A Git sample project with 3 commits, a tag, and a Python, a JavaScript and an HTML file. +- **What was real.** The extension created and verified its own Python venv. Its own HTTP and HTTPS servers served every page, and headless Chromium opened them. +- **Two scenario runs.** The full scenario ran once. A focused re-run then repeated the scene rows with one session per target. The focused run was also repeated on the pre-cleanup VSIX (`399494af`), to tell regressions from older behaviour. + +What the fake host cannot show stays with the maintainer: +- the rendered VS Code chrome: icons, the palette, menus and the Settings UI; +- webview panels and the native colour picker; +- the children of the ANALYSIS section, because the fake host has no `vscode.RelativePattern`, which the Files by Language watcher needs (a limitation of the test harness, not of the product); +- anything that needs two browsers, a headset or a real tunnel. + +| §10 row | Result | How | +|---|---|---| +| 22 Activation | **verified automatically** | `activate()` of the packaged bundle: 69 contributed, 105 registered, no missing id, no error toast, the CodeXR channel created. The activity-bar icon itself: maintainer | +| 22/15 Sidebar roots | **verified automatically** | The tree provider registered for `codexrTree` returns the eight roots in the 1.2.0 order. Rendering, icons, and the ANALYSIS children: maintainer | +| 23 Python environment | **partly verified** | In a clean storage the deferred startup created the venv and verified lizard and tree-sitter-language-pack. `Status` and `Verify installation` answer correctly. The UI lock while installing, Reinitialize and Delete → Create: maintainer | +| 24 Settings | **verified automatically** | Only `codeXR.debug.verboseLogs` is contributed. Toggling it through `onDidChangeConfiguration` takes `[DEBUG]` lines from 0 to 8 live. The Settings UI: maintainer | +| 25 Command Palette, 26 context menus | static only | Palette and menu `when` clauses are pinned by `featureBaseline.test.cjs`. What VS Code shows: maintainer | +| 27 All 11 analysis kinds | **verified automatically** | Each kind launched its server and opened its page, with no error toast and no `[ERROR]` line. The sidebar grew to 148 nodes. Run Last dispatched the last kind (`visualizeDOM`) and got the "already in progress" guard | +| 28 XR scene | **partly verified** | File and directory scenes load: `a-scene` loaded and rendering. `babia-queryjson`, `babia-treebuilder` and `babia-boats` are present, `CodeXR.help()` returns 26 entries, there are no page errors, and `/events` (SSE) answers 200. Field Mapping, VR/AR, the virtual screen and the guide: maintainer | +| 29 In-scene modes | **verified automatically** | `CodeXRAnalysisModeRuntime.changeAnalysis()` entered dependency-graph, historical-compare and project-evolution in the XR directory scene and returned to single, with no page error. `test:project-evolution-harness` also passes. Visual detail (layouts, movie playback): maintainer | +| 30 LivePanel | **partly verified** | The file page renders 7 table rows and the directory page 6. Status "Live Updates", `/events` 200, no page errors. The page asks for `dependency-graph.json` before any dependency analysis exists, gets a 404, and handles it (same on the pre-cleanup build). Lateral-panel mode (webview): maintainer | +| 31 DOM visualization | **served, render not verifiable here** | The page loads every runtime, attaches `babia-html` and connects SSE (200). Inside `babia-html`, html2canvas throws "Unable to find element in cloned iframe" in headless Chromium, so whether `a-scene` finishes loading is a race. It loaded in 1 of 3 runs of the new package and in the one run of the old package, with the same page errors on both. The generated scene differs from the pre-cleanup one only by the nonce, the gated live-reload logs, the runtimes changed by #37/#56 and the re-encoded favicon. The visual result and edit → update: maintainer | +| 32 Auto re-analysis | **verified automatically** (XR file) | After a function was appended to the analysed file, the open XR scene re-fetched `data.json` (200), with no error. Debounce, Auto-Analysis off, and add/delete under a directory: maintainer | +| 33 ANALYSIS settings, 34 Export Analysis Folder | maintainer | The export manifest, layout and wizard messages are pinned by characterization tests, not run end to end here | +| 35 SERVERS | **partly verified** | Start Local Server with an HTML file, launched twice, got two ports and served "Manual DOM Fixture". The configuration rows: maintainer | +| 36 ACTIVE SERVERS | **partly verified** | Stop All Servers closed 13 of 13 listening ports. Its confirmation read "Stop all 20 server(s)?" while 13 ports were open; this was not compared with 1.2.0 (see section 10, row 35). The per-server actions: maintainer | +| 37 Collaboration, 38 Screen broadcast | maintainer | They need two browsers. The room and broadcast servers are pinned by characterization tests | +| 39 Remote access | **partly verified** | Cross-network is on by default, so launches asked for the one-time cloudflared consent. Left unanswered (declined), nothing was downloaded and cross-network was switched off with its message. A real tunnel and pairing: maintainer | +| 40 BABIA EXAMPLES | **partly verified** | All 7 rows launched from their tree items, each page's `a-scene` loaded, and each has its BabiaXR components. About BabiaXR shows its info. **Barsmap and Pie get 404 for their data** (`../../data/sales.json`, `../../data/population.json`): the server's static root is the example's own folder, so the path leaves it. **The pre-cleanup VSIX behaves identically**, so this is older behaviour, not a regression; it is recorded for 1.3.0 in section 9. Confirm in VS Code: maintainer | +| 41 VISUALIZE DATA, 42 VISUALIZATION SETTINGS | maintainer | Webview and colour picker | +| 43 LEARN MORE | **verified automatically** | `openExternal` targets: the docs site, the author site and Buy Me a Coffee | +| 44 Deactivate | **verified automatically** | `deactivate()` ran with no error; every port was released. No tunnel had been started (consent declined), so the `cloudflared` part: maintainer | +| 45 Installed VSIX in VS Code | maintainer | VS Code could not be downloaded in this environment | + +The first full run surfaced one more pattern. Analysing the same file (or folder) in two modes at once gives each mode its own server. The file-to-server map keeps one port per file, so the first server answers `/events` with 404 and its page loses live reload. The focused re-run (one session per target) answers 200. The map's logic is unchanged since 1.2.0 (only its logging moved), so this is older behaviour, recorded in section 9. + +## 9. Deferred to 1.3.0 + +These items are recorded, not done. Each one names the session log that holds its detail. + +**Structure and size** +- The six files over 600 lines (section 6), starting with the `venvManager.ts` split. +- The four two-way folder pairs left after #42 and #55 (`src-layout.md`, `42-layering.md`). +- The remaining 84 `any`, and the 2,014 `var` declarations in the multi-part browser runtimes (`56a-modernize-py-js.md`). +- The 8 functions over CCN 15; once they are split, `complexity` can become an ESLint error. +- The 9 dead exports, 3 of them new (section 6). +- Roadmap rows cut from 1.2.1: W5-19, W5-41, W5-53 to W5-55, and T54 (`35b-ts-dedup.md`). +- The unused parameters that #33 marked with a `_` prefix (`33-guardrails.md`). +- The three TODO stubs in `src/features/analysis/views/handleAnalysisClicks.ts`. + +**Older behaviour found by the E2E.** All three are identical on the pre-cleanup VSIX: +- **BabiaXR examples Barsmap and Pie.** They ask for `../../data/*.json`. The server's static root is the example's own folder, so both requests get 404 and those two charts get no data. The #31 F5 check expected the data to load; it does not, before or after. +- **The same target analysed in two modes at once.** Each mode gets its own server, but the file-to-server map keeps one port per file, so the first server answers `/events` with 404 and its page loses live reload. +- **DOM visualization in headless Chromium.** `babia-html`'s html2canvas throws "Unable to find element in cloned iframe". Whether this also happens in a desktop browser is in the maintainer's checklist. + +**Behaviour quirks.** Tests pin each of these. They stay as they are because 1.2.1 changes no behaviour. + +*Servers* (`39-server-splits.md`): +- `forceStop()` on the HTTPS servers leaves the listener open. +- `stopAllServers` reads a count as a success flag. +- A registrar failure still reports `success: true`. +- "Copy Network URL" copies nothing on localhost. + +*Python backend* (`36-python-backend.md`): +- Owner inference for brace languages counts braces from the class line, so a top-level function can become a method of the class above it. +- On a `.vue` file, only the first `