Skip to content

bug(bootstrap): injects a stack-incorrect ESM extension rule as a load-bearing constraint #294

Closed

Description

@stackbilt-admin

Problem

charter bootstrap --yes on a Vite + TypeScript + React app wrote this into .ai/core.adf:

⚠ CONSTRAINTS [load-bearing]:
  - Use .js extensions for all ESM imports (never .ts in import paths)

That rule is wrong for this stack. The repo uses "moduleResolution": "Bundler" and every import is extensionless:

import { createRng } from '../simulation/random';

Adding .js extensions would be a change no tooling here asks for, and the repo's real rule is the opposite: imports carry no file extension.

Why it matters more than a wrong default

The rule is written under [load-bearing], which Charter defines as "violation causes incorrect output". A fresh agent has no way to know the constraint is a bootstrap default rather than something the maintainers asserted. The failure mode is an agent "fixing" a correct codebase to satisfy a generated rule — a governance tool actively producing drift.

I caught it only because I read the generated module before compiling. An agent bootstrapping unattended would not.

Suggested fix

Pick whichever fits the roadmap:

  1. Condition the rule on resolution mode. Emit the .js rule only when tsconfig.json has moduleResolution: node16/nodenext, or when package.json has "type": "module" without a bundler. For moduleResolution: bundler/vite.config.*, emit the inverse rule or nothing.
  2. Don't emit stack rules as [load-bearing] at bootstrap. Generated guesses could land under [advisory], or under a 📝 REVIEW: section, and get promoted by a human.
  3. Mark generated constraints with something like [unverified] until a human edits the module, so the provenance is visible.

Option 1 is the correct fix; option 3 is a cheap safety net for every other inferred rule.

Repro

# In a Vite + TS + React repo (moduleResolution: Bundler, no "type": "module")
npx @stackbilt/cli bootstrap --yes
grep -n "\.js extensions" .ai/core.adf

@stackbilt/[email protected], Node 22.14, WSL2. Detected stack was reported correctly as runtime: node, stack: react, vite, so the information needed to suppress the rule was already in hand.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions