|
| 1 | +# Intake: Remove WEAVER_DEV and derive mode from metrics_repo |
| 2 | + |
| 3 | +**Change**: 260401-jufw-remove-weaver-dev-derive-mode |
| 4 | +**Created**: 2026-04-01 |
| 5 | +**Status**: Draft |
| 6 | + |
| 7 | +## Origin |
| 8 | + |
| 9 | +> User described this change with full implementation decisions pre-made from a prior discussion. The input specifies exactly which files change, what the new runtime behavior is, and which config artifacts are deleted. This is a detailed, decision-complete request. |
| 10 | +
|
| 11 | +## Why |
| 12 | + |
| 13 | +The `WEAVER_DEV` env var and `tu.default.weaver.conf` file exist solely to configure the wvrdz team's multi-mode setup. This leaks a project-specific concern (the wvrdz metrics repo URL) into the generic codebase. Additionally, having `mode` as an explicit config field creates a redundancy: `mode=multi` is meaningless without `metrics_repo`, and `metrics_repo` being set implies multi mode. Deriving `mode` from `metrics_repo` presence eliminates both the redundancy and the project-specific config machinery, making the codebase fully generic. |
| 14 | + |
| 15 | +Without this change, any fork or external user encounters a confusing `WEAVER_DEV` env var with no documentation, two defaults files with unclear selection logic, and a `mode` field that can desync from `metrics_repo`. |
| 16 | + |
| 17 | +## What Changes |
| 18 | + |
| 19 | +### 1. Remove `WEAVER_DEV` env var detection (`src/node/core/config.ts`) |
| 20 | + |
| 21 | +The `DEFAULT_CONFIG_PATH` export currently branches on `process.env.WEAVER_DEV` (line 33) to select between `tu.default.conf` and `tu.default.weaver.conf`. This branching is removed entirely. `DEFAULT_CONFIG_PATH` always resolves to `tu.default.conf`: |
| 22 | + |
| 23 | +```typescript |
| 24 | +export const DEFAULT_CONFIG_PATH = resolve(_rootDir, "tu.default.conf"); |
| 25 | +``` |
| 26 | + |
| 27 | +### 2. Add `TU_METRICS_REPO` env var (`src/node/core/config.ts`) |
| 28 | + |
| 29 | +In `readConfig()`, after merging defaults and user config, check `process.env.TU_METRICS_REPO`. If set, it overrides the config file's `metrics_repo` value: |
| 30 | + |
| 31 | +```typescript |
| 32 | +const metricsRepo = process.env.TU_METRICS_REPO || merged.metrics_repo || ""; |
| 33 | +``` |
| 34 | + |
| 35 | +This is the generic replacement for what `WEAVER_DEV` + `tu.default.weaver.conf` did. Any user or CI can set `TU_METRICS_REPO` to enable multi mode without editing config files. |
| 36 | + |
| 37 | +### 3. Derive `mode` at runtime (`src/node/core/config.ts`) |
| 38 | + |
| 39 | +Remove the explicit `mode` parsing from the merged config. Instead, derive it from `metricsRepo` presence: |
| 40 | + |
| 41 | +```typescript |
| 42 | +const mode: TuConfig["mode"] = metricsRepo !== "" ? "multi" : "single"; |
| 43 | +``` |
| 44 | + |
| 45 | +The `mode` field remains on the `TuConfig` interface so all downstream consumers (cli.ts, sync.ts, etc.) are unchanged. The `mode=` line in user config files is silently ignored (the parser still reads it but `readConfig()` no longer uses it). |
| 46 | + |
| 47 | +The existing warning for `mode=multi` without `metrics_repo` is removed since that state is now impossible. |
| 48 | + |
| 49 | +### 4. Delete `tu.default.weaver.conf` |
| 50 | + |
| 51 | +This file is deleted entirely. There is only one defaults file (`tu.default.conf`). |
| 52 | + |
| 53 | +### 5. Update `tu.default.conf` |
| 54 | + |
| 55 | +Remove the `mode = single` line. The `metrics_repo` line remains commented out (single mode by default, since no `metrics_repo` means `mode=single`). Config version stays at 2. |
| 56 | + |
| 57 | +### 6. Update `init-conf` scaffold (`src/node/core/cli.ts`) |
| 58 | + |
| 59 | +Remove the `mode` entry from `FIELD_BLOCKS` so the generated `~/.tu.conf` template does not include a `mode` line. The remaining fields are unchanged. |
| 60 | + |
| 61 | +### 7. Update `init-metrics` mode check (`src/node/core/cli.ts`) |
| 62 | + |
| 63 | +The `runInitMetrics` function currently checks `config.mode !== "multi"` and errors. After this change, `mode` is derived from `metricsRepo`, so this check naturally works: if `metrics_repo` is set, `mode` will be `multi`. The explicit error message should be updated to reference `metrics_repo` instead of `mode=multi`. |
| 64 | + |
| 65 | +### 8. Update `runSync` error message (`src/node/core/cli.ts`) |
| 66 | + |
| 67 | +The sync error message currently says "set mode=multi". Update to reference `metrics_repo` or `TU_METRICS_REPO` instead. |
| 68 | + |
| 69 | +### 9. Update tests (`src/node/core/__tests__/config.test.ts`) |
| 70 | + |
| 71 | +- Remove `WEAVER_DEV` branching in the "works with the real default conf" test (line 244). After this change, the real default conf always produces `mode=single` with empty `metricsRepo`. |
| 72 | +- Update tests that explicitly set `mode=multi` to verify that mode is now derived from `metrics_repo` presence rather than explicit `mode` field. |
| 73 | +- Add a test for `TU_METRICS_REPO` env var override. |
| 74 | +- Update the `STOCK_DEFAULTS` constant to remove the `mode = single` line. |
| 75 | +- Update the test "returns single mode when user sets mode=single" to verify that `mode` in config is ignored (metrics_repo drives mode). |
| 76 | +- Update the test "falls back to single mode when mode=multi but metrics_repo is missing" since the warning message changes (or is removed entirely). |
| 77 | + |
| 78 | +## Affected Memory |
| 79 | + |
| 80 | +- `configuration/config-system`: (modify) Remove WEAVER_DEV documentation, add TU_METRICS_REPO, document mode derivation from metrics_repo |
| 81 | + |
| 82 | +## Impact |
| 83 | + |
| 84 | +- **`src/node/core/config.ts`** — main changes: remove WEAVER_DEV branching, add TU_METRICS_REPO, derive mode from metricsRepo |
| 85 | +- **`src/node/core/cli.ts`** — update FIELD_BLOCKS (remove mode), update error messages referencing mode=multi |
| 86 | +- **`src/node/core/__tests__/config.test.ts`** — remove WEAVER_DEV branching, update mode derivation tests, add TU_METRICS_REPO test |
| 87 | +- **`tu.default.conf`** — remove mode line |
| 88 | +- **`tu.default.weaver.conf`** — delete entirely |
| 89 | +- **No breaking changes to downstream consumers** — `TuConfig.mode` field and all its usages remain identical; only the derivation logic changes |
| 90 | + |
| 91 | +## Open Questions |
| 92 | + |
| 93 | +(none) |
| 94 | + |
| 95 | +## Assumptions |
| 96 | + |
| 97 | +| # | Grade | Decision | Rationale | Scores | |
| 98 | +|---|-------|----------|-----------|--------| |
| 99 | +| 1 | Certain | Config version stays at 2 | Explicitly stated in the description; no config schema change, only behavior change | S:95 R:90 A:95 D:95 | |
| 100 | +| 2 | Certain | `TuConfig` interface keeps `mode` field | Explicitly stated; all downstream consumers unchanged | S:95 R:85 A:95 D:95 | |
| 101 | +| 3 | Certain | `mode` lines in existing user configs are silently ignored | Explicitly stated; parseConf still reads them but readConfig does not use the value | S:90 R:90 A:90 D:90 | |
| 102 | +| 4 | Certain | `TU_METRICS_REPO` takes precedence over config file `metrics_repo` | Explicitly stated in the description | S:95 R:85 A:90 D:95 | |
| 103 | +| 5 | Certain | `tu.default.weaver.conf` is deleted, not deprecated | Explicitly stated in the description | S:95 R:80 A:90 D:95 | |
| 104 | +| 6 | Certain | `brew install wvrdz/tap/tu` hardcoding in cli.ts is out of scope | Explicitly stated in the description | S:95 R:95 A:95 D:95 | |
| 105 | +| 7 | Confident | Error messages in `runInitMetrics` and `runSync` should reference `metrics_repo`/`TU_METRICS_REPO` instead of `mode=multi` | Logical consequence of removing mode from config; user can no longer "set mode=multi" | S:70 R:85 A:80 D:80 | |
| 106 | + |
| 107 | +7 assumptions (6 certain, 1 confident, 0 tentative, 0 unresolved). |
0 commit comments