Explications › Décisions › 010. archec is written in arche-lang

Explications › Décisions

Cette page n’est pas encore traduite : voici la version anglaise.

010. archec is written in arche-lang

The source of archec is a model in model/, and src/ is generated from it by archec itself. The pause is lifted for this work.

  • Status: Accepted and being implemented.
  • Date: 2026-12-02.
  • Supersedes: none.
  • Superseded by: none.

Context#

The user wants archec's own specification written in arche-lang, and archec generated from it, for three reasons of equal weight: to prove the language on a real program of about 198,000 lines; to stop the docs, the CLI and the editor from drifting apart; and to let someone change arche-lang by editing the model alone. Where the language is too weak, it is strengthened for every user, with no private escape for archec.

Five approaches were weighed (the design is in docs/superpowers/specs/2026-12-02-self-hosting-design.md). Modelling only the specification layer, or adding declarative behaviour, leaves goal 3 limited. Rewriting everything in the action language at once turns the language into a general-purpose one in a single leap and freezes archec while it is rewritten.

The breadth pause (005) forbids a new target and new action-language features until 1.0. The pause is lifted per request.

Decision#

  • Approach 3C. First, all of archec's structure goes into arche-lang, with bodies in TypeScript and a TypeScript generator. Then the action language grows one capability at a time, and each module moves its bodies into it once the language can say them.
  • The pause is lifted for a typescript generator target and for the action-language features this move needs. It is lifted for this work only. Each feature must make sense in a user's model, with its docs, tests and edition (004).
  • The program extension, beta. module, map, generics, function types, native imports and unknown form a new beta extension. Every user can use it from the start. It is labelled beta in docs/surface.md and stays outside the 1.0 promise until an ADR moves it in, as 009 did for others, once archec has proven it.
  • Names. Extension program; declaration module; generator target typescript; model folder model/; script tools/selfgen.mjs; the gate's stage-0 folder .git/land/stage0/.
  • Bootstrap. The generated files are committed, so npm run build needs no archec. The compiler that generates is the archec built from main before the branch (stage 0). The gate builds it locally, with no remote and no release. It checks that stage 0 generates the branch's src/ exactly as committed, and that the archec built from that generates the same again (a fixed point). If main's generator breaks, the gate keeps the last good build in .git/land/stage0/.
  • Two landings for a new capability. First archec learns it, and its model does not use it yet. Once that is on main, the model may use it. No release falls between the two.
  • Four answers from the user, 2026-12-02:
    • Where archec's TypeScript does not fit the language, archec is rewritten. Classes become a struct with methods, and Error subclasses become exception. Interfaces become struct with optional fields, and index signatures become map. Re-exports and generator functions are rewritten out: importers name the module that declares, and generators return lists.
    • any becomes a real type where it can be said, and unknown elsewhere. archec check counts each unknown, so the count only goes down. async functions and a module's var are supported properly.
    • A move is announced to the running sessions before it starts, and whoever moves the module ports the pending work on that file into the model. After the move, the gate refuses a direct edit of the generated file and names the model file to edit. One command turns a module back into hand-written code if a move goes badly.
    • Where help, docs pages, the editor and the code disagree, what the code does wins and no behaviour changes. For wording, the clearest version is chosen, and each disagreement is listed in the landing for the user to review. Visible help text will change in places.

Consequences#

  • The docs, the CLI help, the diagnostics table and the editor's contributes can come from one model.
  • Generated TypeScript must stay readable: real names, comments kept, and // @arche lines back to the model. Build time, test time and archec check on the examples must stay within 10% of before.
  • A module is generated or hand-written, never both, and the gate says which.
  • Peers who edit src/ meet the gate's refusal on moved modules. This costs them some work, and the announcement before each move is what keeps it small.
  • program adds keywords and commands that ADR 008 will have to promise if it moves in. That is decided later, in its own ADR.
  • Phase 2: the diagnostics catalogue (src/lintrules.ts), archec's commands, usage and help (src/cli/commandspec.ts, the tables of docs/commands/) and the VS Code commands (vscode/package.json, tools/vscode-owners.json) are generated from model/spec/. To change one, edit the model (CONTRIBUTING.md).
  • Tests, tools/, site/, vscode/src and bridge/ are not generated in this work.
  • Phase 3a: tools/selfmove.mjs moves a hand-written module of src/ into the model from its syntax tree. It moved the first 37 leaf files (42 are generated now). What it cost, and what stops the rest, is in docs/superpowers/reports/2026-12-03-phase-3a-cost.md: plan 3b starts there.
  • Phase 3b: 584 of 625 files of src/ are generated from the model (542 moved by the waves), with the forms of classes, re-exports, relative native and layout exact. 41 files stay hand-written. What it cost, and what phase 4 starts with, is in docs/superpowers/reports/2026-12-04-phase-3b-cost.md.