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
typescriptgenerator 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
programextension, beta.module,map, generics, function types,nativeimports andunknownform a new beta extension. Every user can use it from the start. It is labelled beta indocs/surface.mdand 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; declarationmodule; generator targettypescript; model foldermodel/; scripttools/selfgen.mjs; the gate's stage-0 folder.git/land/stage0/. - Bootstrap. The generated files are committed, so
npm run buildneeds 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'ssrc/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
structwith methods, and Error subclasses becomeexception. Interfaces becomestructwithoptionalfields, and index signatures becomemap. Re-exports and generator functions are rewritten out: importers name the module that declares, and generators return lists. anybecomes a real type where it can be said, andunknownelsewhere.archec checkcounts eachunknown, so the count only goes down.asyncfunctions and a module'svarare 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.
- Where archec's TypeScript does not fit the language, archec is rewritten.
Classes become a
Consequences#
- The docs, the CLI help, the diagnostics table and the editor's
contributescan come from one model. - Generated TypeScript must stay readable: real names, comments kept, and
// @archelines back to the model. Build time, test time andarchec checkon 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. programadds 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 ofdocs/commands/) and the VS Code commands (vscode/package.json,tools/vscode-owners.json) are generated frommodel/spec/. To change one, edit the model (CONTRIBUTING.md). - Tests,
tools/,site/,vscode/srcandbridge/are not generated in this work. - Phase 3a:
tools/selfmove.mjsmoves a hand-written module ofsrc/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 indocs/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, relativenativeandlayout exact. 41 files stay hand-written. What it cost, and what phase 4 starts with, is indocs/superpowers/reports/2026-12-04-phase-3b-cost.md.