Skip to content

fix(tools): inline dotenv.parse in generate-config — kill canary CI breakage from layout sweep - #1562

Merged
joelteply merged 1 commit into
canaryfrom
fix/tools-generator-dotenv-resolution
Jun 9, 2026
Merged

fix(tools): inline dotenv.parse in generate-config — kill canary CI breakage from layout sweep#1562
joelteply merged 1 commit into
canaryfrom
fix/tools-generator-dotenv-resolution

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

What

Replace import * as dotenv from 'dotenv' in tools/generator/generate-config.ts with an inline 15-line parseEnvText function. Removes the dotenv dep entirely from this script.

Why

The layout sweep (PR #1557, task #214) moved generate-config.ts from src/generator/ to tools/generator/. Node's module resolution walks ancestors of the script location, not process.cwd(). From tools/generator/, the upward walk goes tools/generator/ -> tools/ -> / and finds no node_modules/dotenv — that module only lives at src/node_modules/dotenv (a sibling of tools/, not an ancestor).

Every TS-validation CI job has been failing on canary since the layout sweep merged:

Error: Cannot find module 'dotenv'
Require stack:
- /home/runner/work/continuum/continuum/tools/generator/generate-config.ts

Surfaced via PR #1561's failing checks (validate / ts-eslint-baseline-ratchet / verify-architectures / verify-after-rebuild). NOT caused by that PR — pre-existing canary infrastructure regression.

How

dotenv was only ever used for its .parse(text) function (pure string-to-KV transform). Inlined as parseEnvText with the same semantics:

  • KEY=value lines
  • Optional surrounding double or single quotes around the value
  • # comments + blank lines ignored

The .config() side-effect path (which mutates process.env) was never used here. Like-for-like behavioral replacement.

Doctrinal bonus

Generator scripts now have a Node-stdlib-only footprint, matching generate-version.ts's shape. No upward-walk module-resolution surprises possible. Aligns with task #209 (Node deps trimming).

Test plan

  • Local: cd src && npx tsx ../tools/generator/generate-config.ts -> "shared/config.ts unchanged" (idempotent re-run), ports + active_example resolved correctly
  • CI: validate / ts-eslint-baseline-ratchet on this branch should now produce a real signal instead of the dotenv-missing module error

Generated with Claude Code

…reakage from layout sweep

The layout sweep (PR #1557, task #214) moved `generate-config.ts`
from `src/generator/` to `tools/generator/`. Node's module resolution
walks ancestors of the SCRIPT location, not `process.cwd()`, so the
`import * as dotenv from 'dotenv'` at the top now traverses
`tools/generator/` -> `tools/` -> `/` looking for `node_modules/dotenv`
and finds nothing — `dotenv` only exists at `src/node_modules/dotenv`
(a SIBLING of `tools/`, not an ancestor).

Every TS-validation CI job that invokes
`npx tsx ../tools/generator/generate-config.ts` has been failing on
canary since the layout sweep merged:

  Error: Cannot find module 'dotenv'
  Require stack:
  - /home/runner/work/continuum/continuum/tools/generator/generate-config.ts

Surfaced via PR #1561's validate / ts-eslint-baseline-ratchet /
verify-architectures / verify-after-rebuild checks. NOT caused by
that PR's diff — pre-existing canary infra regression that has been
silently breaking every TS PR check since the layout sweep landed.

Fix: replace `dotenv.parse()` with a 15-line inline `parseEnvText`.
The script only ever called `.parse()` (the pure string-to-KV
transform), never the `.config()` side-effect path that mutates
process.env. Inline parser handles the same shape (KEY=value,
optional surrounding quotes, # comments, blank lines). Like-for-like
behavioral replacement at zero dep cost.

Doctrinal bonus: generator scripts now have a node-stdlib-only
footprint, matching `generate-version.ts`'s shape. No upward-walk
module-resolution surprises possible. Aligns with task #209
("npm start IS the headless Rust binary, period") — fewer Node deps
in the build path is unambiguously good.

Verified locally:
  cd src && npx tsx ../tools/generator/generate-config.ts
  -> "shared/config.ts unchanged" (idempotent on re-run)
  -> HTTP_PORT/WS_PORT defaults pick up correctly
  -> ACTIVE_EXAMPLE resolved from main package.json

Net diff: -1 import + 6 lines removed, +33 lines added (parseEnvText
+ doc block explaining WHY this exists). No behavior change on the
happy path.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@joelteply
joelteply merged commit e44f850 into canary Jun 9, 2026
2 checks passed
@joelteply
joelteply deleted the fix/tools-generator-dotenv-resolution branch June 9, 2026 02:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant