farna-bootstrapper 0.0.0-stage → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/CHANGELOG.md +107 -0
  2. package/LICENSE +30 -0
  3. package/NOTICE +42 -0
  4. package/README.md +1102 -2
  5. package/SECURITY.md +65 -0
  6. package/dist/cli/commands/check.d.ts +58 -0
  7. package/dist/cli/commands/check.js +198 -0
  8. package/dist/cli/commands/generate.d.ts +75 -0
  9. package/dist/cli/commands/generate.js +218 -0
  10. package/dist/cli/commands/init.d.ts +52 -0
  11. package/dist/cli/commands/init.js +271 -0
  12. package/dist/cli/main.d.ts +2 -0
  13. package/dist/cli/main.js +51 -0
  14. package/dist/cli/program.d.ts +23 -0
  15. package/dist/cli/program.js +183 -0
  16. package/dist/compose/resolve.d.ts +161 -0
  17. package/dist/compose/resolve.js +576 -0
  18. package/dist/config/load.d.ts +4 -0
  19. package/dist/config/load.js +45 -0
  20. package/dist/config/schema.d.ts +22 -0
  21. package/dist/config/schema.js +46 -0
  22. package/dist/core/constants.d.ts +279 -0
  23. package/dist/core/constants.js +351 -0
  24. package/dist/core/errors.d.ts +44 -0
  25. package/dist/core/errors.js +75 -0
  26. package/dist/core/fs.d.ts +31 -0
  27. package/dist/core/fs.js +169 -0
  28. package/dist/core/json.d.ts +22 -0
  29. package/dist/core/json.js +174 -0
  30. package/dist/core/paths.d.ts +45 -0
  31. package/dist/core/paths.js +110 -0
  32. package/dist/core/text.d.ts +10 -0
  33. package/dist/core/text.js +27 -0
  34. package/dist/index.d.ts +10 -0
  35. package/dist/index.js +1 -0
  36. package/dist/lock/lockfile.d.ts +230 -0
  37. package/dist/lock/lockfile.js +333 -0
  38. package/dist/materialise/source-tree.d.ts +77 -0
  39. package/dist/materialise/source-tree.js +267 -0
  40. package/dist/permissions/permissions.d.ts +128 -0
  41. package/dist/permissions/permissions.js +452 -0
  42. package/dist/render/commit.d.ts +59 -0
  43. package/dist/render/commit.js +279 -0
  44. package/dist/render/generate-lock.d.ts +9 -0
  45. package/dist/render/generate-lock.js +203 -0
  46. package/dist/render/identity.d.ts +23 -0
  47. package/dist/render/identity.js +396 -0
  48. package/dist/render/orphans.d.ts +59 -0
  49. package/dist/render/orphans.js +234 -0
  50. package/dist/render/port.d.ts +96 -0
  51. package/dist/render/port.js +1 -0
  52. package/dist/render/prepare.d.ts +33 -0
  53. package/dist/render/prepare.js +139 -0
  54. package/dist/render/root-cleanliness.d.ts +28 -0
  55. package/dist/render/root-cleanliness.js +76 -0
  56. package/dist/render/stage.d.ts +36 -0
  57. package/dist/render/stage.js +92 -0
  58. package/dist/render/staging.d.ts +16 -0
  59. package/dist/render/staging.js +94 -0
  60. package/dist/render/structured.d.ts +35 -0
  61. package/dist/render/structured.js +258 -0
  62. package/dist/render/upstream.d.ts +41 -0
  63. package/dist/render/upstream.js +179 -0
  64. package/dist/report/format.d.ts +7 -0
  65. package/dist/report/format.js +97 -0
  66. package/dist/report/warnings.d.ts +21 -0
  67. package/dist/report/warnings.js +24 -0
  68. package/dist/source/digest.d.ts +18 -0
  69. package/dist/source/digest.js +77 -0
  70. package/dist/source/frontmatter.d.ts +12 -0
  71. package/dist/source/frontmatter.js +29 -0
  72. package/dist/source/load.d.ts +103 -0
  73. package/dist/source/load.js +676 -0
  74. package/dist/source/schema.d.ts +154 -0
  75. package/dist/source/schema.js +292 -0
  76. package/dist/source/yaml.d.ts +10 -0
  77. package/dist/source/yaml.js +49 -0
  78. package/dist/verify/containment.d.ts +22 -0
  79. package/dist/verify/containment.js +753 -0
  80. package/package.json +79 -4
package/README.md CHANGED
@@ -1,3 +1,1103 @@
1
- # Temporary Holding Version
1
+ # farna-bootstrapper
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ [![CI](https://github.com/farnalabs/farna-bootstrapper/actions/workflows/ci.yml/badge.svg)](https://github.com/farnalabs/farna-bootstrapper/actions/workflows/ci.yml)
4
+
5
+ Compile named agent personas and their resources into the configuration a coding harness
6
+ actually reads, and prove that the committed output still matches the source.
7
+
8
+ ## What it is
9
+
10
+ `farna-bootstrapper` is a build-time compiler for coding-agent configuration. You declare personas
11
+ and their resources once, under `.farna/`, and it renders the files a harness reads:
12
+
13
+ - **`generate`** renders every live persona for exactly one configured target, verifies the bytes
14
+ the renderer produced, and only then writes them. It also writes `.farna/lock.json`, which records
15
+ what it owns.
16
+ - **`check`** renders the same source into a temporary directory and compares it with the
17
+ repository. Exit `0` when identical, `1` when anything drifted. It never writes.
18
+ - **`init`** creates the source root and the ignore/attribute lines generated output needs.
19
+
20
+ It is a compiler in the useful sense, not a loader:
21
+
22
+ - the output is **verified, not trusted**. Containment means equality: a renderer that drops a field,
23
+ weakens a permission, mixes two personas or invents a directive is refused before the first byte is
24
+ written. File existence is never accepted as proof.
25
+ - a capability a target cannot carry is **reported, never dropped silently**. Every permission
26
+ category is validated before anything is materialised; one the target cannot map refuses the run.
27
+ - the output is **reproducible**: no timestamps, hostnames or absolute paths in the lockfile, and the
28
+ same source produces the same bytes and the same lockfile on every machine.
29
+ - it works **offline**. Generation and checking make no network request of their own.
30
+
31
+ ## What it is not
32
+
33
+ - **Not an agent runtime, launcher or framework.** It writes configuration; it does not run an agent,
34
+ proxy a model, or manage a session. A hook, MCP server or command it writes is data that the
35
+ harness may execute later; this tool never executes it.
36
+ - **Not a model gateway or a hosted service.** There is no server, no account and no phone-home.
37
+ - **Not a telemetry collector.** There is no analytics package, no usage ping and no crash reporter,
38
+ and no dependency on Farna Control at build time or run time.
39
+ - **Not a multi-target orchestrator in this release.** Exactly one configured target is rendered per
40
+ run; more than one is refused.
41
+ - **Not a replacement for the harness.** It does not claim runtime behaviour. The README's
42
+ capability matrix states what each target carries; the harness remains the authority on what it
43
+ does with it.
44
+
45
+ ## Status
46
+
47
+ This is the first public release. It implements three commands (`init`, `generate` and
48
+ `check`), three targets (`claudecode`, `opencode` for OpenCode 2.x and `opencodev1` for OpenCode
49
+ 1.x), agent mode plus OpenCode profile mode, six resource kinds (`rule`, `permission`, `mcp`,
50
+ `skill`, `command` and `hook`) with a model class, and composition with one base persona per
51
+ composed persona. Exactly one configured target is rendered per run. Everything else is
52
+ deliberately deferred; see
53
+ [What this slice does not do](#what-this-slice-does-not-do) and
54
+ [Residual risks and known gaps](#residual-risks-and-known-gaps).
55
+
56
+ ## Quickstart
57
+
58
+ Requires **Node.js 22.22.0 or newer** and npm. Nothing needs to be installed globally.
59
+
60
+ ```sh
61
+ mkdir my-agents && cd my-agents
62
+ git init
63
+ npx farna-bootstrapper init
64
+ ```
65
+
66
+ `init` creates `.farna/config.jsonc`, the empty persona and resource directories, and the
67
+ `.gitignore` and `.gitattributes` lines generated output needs. Add one YAML file per persona and
68
+ one file per resource; [Use](#use) has a complete pair. Then:
69
+
70
+ ```sh
71
+ npx farna-bootstrapper generate # render the target and write .farna/lock.json
72
+ npx farna-bootstrapper check # exit 0 when the tree matches a fresh render
73
+ ```
74
+
75
+ Commit `.farna/` and the generated files. Running `check` in CI is the drift gate: a hand edit, a
76
+ stale render, or a source change that was never regenerated exits `1` and names the path.
77
+
78
+ ## The loop
79
+
80
+ 1. You declare personas and their resources under `.farna/`, and select one target in the config.
81
+ 2. `farna-bootstrapper generate` renders that target's artefacts and records what it wrote in
82
+ `.farna/lock.json`. Claude Code gets one whole file per persona under `.claude/agents/`; OpenCode
83
+ in agent mode gets one whole file per persona under `.opencode/agents/` and no workspace file;
84
+ OpenCode in profile mode gets the active persona's agent file, its `opencode.jsonc` at the
85
+ repository root, and its skill, command and hook output under `.opencode/`.
86
+ 3. `farna-bootstrapper check` renders the same input into a temporary directory and compares it
87
+ with the repository. Exit `0` when identical, `1` when anything drifted.
88
+
89
+ `generate` never writes until every gate has passed. Containment means equality, not substring
90
+ presence: each persona's artefact must be a non-empty markdown file whose emitted frontmatter has
91
+ exactly the keys that target writes, with matching values. Claude Code writes `name`, `description`
92
+ and `model`, plus `disallowedTools` and, only when a permission resource opts in, `tools`;
93
+ OpenCode 2.x writes `description`, `mode`, `model` and the ordered `permissions` records; OpenCode
94
+ 1.x writes `name`, `description`, `mode`, `model` and the per-tool `permission` map. The body is
95
+ exactly that persona's composed body, with one trailing newline normalised. An absent field must be absent, and an extra
96
+ field is refused: a renderer that adds a harness directive such as `permissionMode` or `hooks` is
97
+ adding a capability the persona never declared. A renderer that drops content, weakens or invents a
98
+ permission, mixes personas, prepends or appends anything of its own is refused before the first byte
99
+ reaches the repository. Every permission category is validated before anything is materialised: a
100
+ category the target cannot carry refuses the run (F011) rather than being emitted as an inert
101
+ string.
102
+
103
+ ## Requirements
104
+
105
+ - Node.js **22.22.0 or newer**
106
+ - npm
107
+ - For the `opencode` target, OpenCode **2.x** (package `@opencode/cli`, current 2.3.2, installed
108
+ from <https://opencode.ai/v2/install>). Its emitted per-agent file is the V2 shape (`description`,
109
+ `mode`, `model`, ordered `permissions` records, no `name`), its config nests servers under
110
+ `mcp.servers`, and its plugin is the `{ id, setup }` module.
111
+ - For the `opencodev1` target, OpenCode **1.x** (package `opencode-ai`, current 1.19.6). Its
112
+ emitted per-agent file is the V1 shape (`name`, `description`, `mode`, `model`, the per-tool
113
+ `permission` map), its config is the flat `mcp.<name>` map, its command frontmatter spells
114
+ `subtask`/`variant` (this product authors only `description`, which both majors share) and its
115
+ plugin is the `RulesyncHooksPlugin` module.
116
+ - The tool does not shell out to OpenCode, so a version is documented rather than probed.
117
+ - Profile mode is supported for both OpenCode targets. Agent mode works on all three targets.
118
+
119
+ ## Install
120
+
121
+ ```sh
122
+ npx farna-bootstrapper --version # run it once, without installing
123
+ npm install --save-dev farna-bootstrapper
124
+ npm install -g farna-bootstrapper
125
+ ```
126
+
127
+ The package has no `postinstall` script and makes no network request after install. `prepare` builds
128
+ `dist/` for a git install and `prepack` builds it for the published tarball; a source checkout
129
+ therefore produces a working `bin` without a manual build.
130
+
131
+ The renderer's integrity is read from exactly two npm lock records at the **install root**,
132
+ the nearest ancestor of the product package that owns a `node_modules` directory: the hidden
133
+ `<installRoot>/node_modules/.package-lock.json` and `<installRoot>/package-lock.json`. In a hoisted
134
+ npm workspace the renderer sits at `<ws>/node_modules/rulesync`, so that workspace root *is* the
135
+ install root and its record at `<ws>/package-lock.json` (and its hidden record) is read. In those
136
+ records the `packages` map is searched for the renderer's entry under a key ending in
137
+ `node_modules/<renderer>`; a nested install (`npm install --install-strategy=nested`), which
138
+ records `node_modules/farna-bootstrapper/node_modules/rulesync`, is read from those same two
139
+ records. A workspace root *above* the install root, a parent monorepo and a sibling package are not
140
+ read and may yield `W114`. Those two records are the only supported source of integrity; every
141
+ other npm layout is not promised. When more than one renderer entry matches — for example another
142
+ global package's nested copy in a shared global record — its integrity must still equal the pin: a
143
+ different tarball is refused (F010), so a stranger's entry cannot stand in for the pinned renderer.
144
+
145
+ The guarantee is exact: **the installed renderer version is enforced; the integrity is best effort
146
+ and is checked only in those two records; if no renderer entry is found there, the tool emits
147
+ `W114_RENDERER_INTEGRITY_UNVERIFIED` and does not claim a clean integrity pass.** A different
148
+ version is refused (F010, exit 5). A different npm-recorded integrity is refused the same way. When
149
+ no renderer entry exists in those records — a global or linked install that wrote no npm lockfile,
150
+ or a layout the tool does not read — or the entry has no string integrity, the version check still
151
+ applies, the run continues, and the warning says which of the two happened. That warning appears in
152
+ the human report and the `--json` warnings array, so a run never claims a clean integrity pass it
153
+ could not make. It is deliberately **not** written into `.farna/lock.json`: the lockfile records
154
+ source-derived state only (the pin, resolved resources, source-derived warnings, file hashes), and a
155
+ runtime verification result must not change the byte-compared artefact. A record that is present
156
+ but cannot be read, is a symlink or is not a regular file, or is above the 64 MiB npm-record bound,
157
+ is refused (F010) rather than treated as absent: an integrity that exists but cannot be read must
158
+ fail exactly like one that differs. The pin is provenance, not a sandbox — it does not make an
159
+ unverifiable install verified. That bound is separate from the 4 MiB bound on this product's own
160
+ derived `.farna/lock.json`, because npm's record scales with the dependency tree.
161
+
162
+ ### Supported targets
163
+
164
+ | Target id | Harness | Version | Package | Agent mode | Profile mode |
165
+ |---|---|---|---|---|---|
166
+ | `claudecode` | Claude Code | not version-probed | — | yes | not in this release |
167
+ | `opencode` | OpenCode | 2.x | `@opencode/cli` | yes | yes |
168
+ | `opencodev1` | OpenCode | 1.x | `opencode-ai` | yes | yes |
169
+
170
+ Exactly one target is configured per run; configuring `opencode` and `opencodev1` together is
171
+ `F001`. All three targets write different shapes for the same source; switching target is one
172
+ config edit (see [Targets](#targets)). The two OpenCode targets write the **same paths** in each
173
+ major's own shapes, so a switch rewrites the recorded output in place rather than orphaning it. The
174
+ tool never shells out to a harness, so a version is documented rather than detected.
175
+
176
+ ### The library entry
177
+
178
+ The package also exports its TypeScript types (`.`, `types: ./dist/index.d.ts`). In this release
179
+ that entry is types-only: the CLI is the product surface, and there is no runtime library API to
180
+ depend on. The `./package.json` subpath is exported for tooling.
181
+
182
+ ## Use
183
+
184
+ ```sh
185
+ mkdir my-agents && cd my-agents
186
+ farna-bootstrapper init
187
+ ```
188
+
189
+ `init` creates (it accepts `--json` after the command name, like `generate` and `check`, emitting
190
+ one object on stdout):
191
+
192
+ ```text
193
+ .farna/
194
+ config.jsonc
195
+ personas/
196
+ resources/
197
+ rules/
198
+ permissions/
199
+ mcp/
200
+ skills/
201
+ commands/
202
+ hooks/
203
+ .gitignore # .farna/local.jsonc, the journal, the generate lock, the staging namespace and OS metadata
204
+ .gitattributes # .farna/** and every generated path, for every target, pinned to LF
205
+ ```
206
+
207
+ The `--json` object is `schemaVersion`, `command` (`init`), `ok`, `exitCode`, `root`,
208
+ `configPath`, `created` and `updated` (the array of existing shared files this run appended to),
209
+ and `nextStep`. It reports the shared files as `created` or `updated`, and `created` names only the
210
+ directories this run actually created (a pre-existing directory is omitted); it never claims a path
211
+ it did not touch. `init` preserves the existing bytes and mode of `.gitignore` and `.gitattributes`,
212
+ appends only the missing lines, and restores both byte for byte if a later step fails.
213
+
214
+ Add one YAML file per persona under `.farna/personas/`, one Markdown file per rule under
215
+ `.farna/resources/rules/`, and one JSONC file per permission under
216
+ `.farna/resources/permissions/`. The workspace resource kinds live in their own directories:
217
+ `mcp/<id>.jsonc`, `skills/<id>/SKILL.md` (plus any extra files), `commands/<id>.md` and
218
+ `hooks/<id>.jsonc`. They are read and validated in this slice but require profile mode, so agent
219
+ mode refuses a persona that references one (F001):
220
+
221
+ ```yaml
222
+ # .farna/personas/builder.yaml
223
+ kind: persona
224
+ id: builder
225
+ displayName: Builder
226
+ purpose: Writes code, runs the tests, and follows the house conventions.
227
+ model: standard
228
+ resources:
229
+ - rule/house-style
230
+ - permission/builder-default
231
+ ```
232
+
233
+ ```yaml
234
+ # .farna/personas/builder-python.yaml
235
+ kind: persona
236
+ id: builder-python
237
+ displayName: Python Builder
238
+ purpose: Writes Python and runs the Python checks.
239
+ extends: builder
240
+ resources:
241
+ - rule/python-style
242
+ - permission/python-tools
243
+ ```
244
+
245
+ A persona may also declare **`mode`**, which selects its OpenCode agent mode: `primary` makes the
246
+ agent selectable as the main agent, `subagent` makes it callable only by another agent, and `all`
247
+ makes it both. `subagent` is the default when the key is absent. The value is source-derived and
248
+ composes with `extends`: a derived persona inherits its base's `mode`, and a child declaration
249
+ overrides it. Both OpenCode targets emit it; Claude Code has no primary/subagent distinction, so a
250
+ declared `mode` there is reported as `W117_PERSONA_MODE_IGNORED` (info) and no `mode` key is
251
+ written.
252
+
253
+ ```yaml
254
+ # .farna/personas/builder.yaml — a primary agent on an OpenCode target
255
+ kind: persona
256
+ id: builder
257
+ displayName: Builder
258
+ purpose: Writes code, runs the tests, and follows the house conventions.
259
+ mode: primary
260
+ resources:
261
+ - rule/house-style
262
+ - permission/builder-default
263
+ ```
264
+
265
+ ```markdown
266
+ ---
267
+ kind: rule
268
+ id: house-style
269
+ displayName: House style
270
+ ---
271
+
272
+ Write the smallest change that satisfies the ticket.
273
+ ```
274
+
275
+ ```jsonc
276
+ // .farna/resources/permissions/builder-default.jsonc
277
+ {
278
+ "kind": "permission",
279
+ "id": "builder-default",
280
+ "tools": {
281
+ "read": "allow",
282
+ "write": "allow",
283
+ "edit": "allow",
284
+ "shell": "allow",
285
+ "task": "deny"
286
+ }
287
+ }
288
+ ```
289
+
290
+ ```jsonc
291
+ // .farna/config.jsonc
292
+ {
293
+ "schemaVersion": 1,
294
+ "targets": { "claudecode": {} },
295
+ "models": {
296
+ "standard": { "claudecode": "claude-sonnet-4-5" }
297
+ }
298
+ }
299
+ ```
300
+
301
+ Then run:
302
+
303
+ ```sh
304
+ farna-bootstrapper generate # write the agent files and the lockfile
305
+ farna-bootstrapper generate --dry-run # print the plan, write nothing
306
+ farna-bootstrapper generate --adopt # take ownership of existing outputs (see below)
307
+ farna-bootstrapper check # prove the tree matches a fresh render
308
+ farna-bootstrapper generate --persona <id> # OpenCode profile mode, overriding the config
309
+ farna-bootstrapper check --persona <id> # check the same selection
310
+ ```
311
+
312
+ The complete flag surface:
313
+
314
+ | Command | Flag | Behaviour |
315
+ |---|---|---|
316
+ | all | `--json` | emit one JSON object on stdout and suppress the human report; a typed failure also writes its one human line to stderr |
317
+ | all | `-v, --version`, `-h, --help` | print the compiled-in version or usage; neither needs the renderer |
318
+ | `init` | `--json` | the created/updated paths and the next step |
319
+ | `generate` | `--dry-run` | print the plan and write nothing; `would-write` and `unchanged` are counted separately |
320
+ | `generate` | `--adopt` | take ownership of every existing planned managed output; required when the lockfile is missing |
321
+ | `generate` | `--persona <id>` | run profile mode as that persona; wins over `targets.<target>.active` and is not written back |
322
+ | `check` | `--persona <id>` | check the same selection |
323
+
324
+ `--persona` is the one CLI selection override. It selects profile mode and wins over
325
+ `targets.<target>.active`; see [Profile mode](#profile-mode).
326
+
327
+ `--json` is a per-command flag: place it after the command
328
+ (`farna-bootstrapper generate --json`), not before it. Every command then emits one machine-readable
329
+ object on stdout and no human report: a success is one object on stdout and nothing on stderr; a
330
+ typed failure is one object on stdout and its single human line on stderr. Every object carries
331
+ `schemaVersion`, `command`, `ok` and `exitCode`; a success object also carries the command's own
332
+ fields (`init` adds `root`, `configPath`, `created`, `updated` and `nextStep`), and a typed failure
333
+ also carries `code`, `subject` and `message`. `--dry-run` compares each managed path with the
334
+ working tree, so `unchanged` and
335
+ `would-write` are distinguished rather than every path being reported as a write. Its summary
336
+ counts the `would-write` files, not the size of the plan: a tree that already matches reports
337
+ `would write 0 file(s), N unchanged`.
338
+
339
+ A persona's rule text is joined into the body of its subagent, in canonical rule-id order, under a
340
+ `## displayName` heading. The rule body itself is never re-wrapped or re-indented. There is no
341
+ shared root rules file: the per-agent body is the only rule surface, so one persona's rules never
342
+ reach another persona's artefact.
343
+
344
+ ## Targets
345
+
346
+ Exactly one target is configured per run. Switching target is one config edit:
347
+
348
+ ```jsonc
349
+ // .farna/config.jsonc — the OpenCode 2.x target
350
+ {
351
+ "schemaVersion": 1,
352
+ "targets": { "opencode": {} },
353
+ "models": {
354
+ "standard": { "opencode": "anthropic/claude-sonnet-4-5" }
355
+ }
356
+ }
357
+ ```
358
+
359
+ ```jsonc
360
+ // .farna/config.jsonc — the OpenCode 1.x target
361
+ {
362
+ "schemaVersion": 1,
363
+ "targets": { "opencodev1": { "active": "builder" } },
364
+ "models": {
365
+ "standard": { "opencodev1": "anthropic/claude-sonnet-4-5" }
366
+ }
367
+ }
368
+ ```
369
+
370
+ A model class maps per target, so a class used on `opencodev1` needs an `opencodev1` mapping (and
371
+ one used on `opencode` needs an `opencode` mapping). Configuring both OpenCode targets at once is
372
+ `F001`: the two write the same paths and one run has one lockfile and one mode plan.
373
+
374
+ All targets are rendered by the pinned rulesync renderer; the product derives the feature set from
375
+ the materialised source instead of passing `*`, and verifies the bytes the renderer produced before
376
+ writing any of them.
377
+
378
+ ### Capability matrix
379
+
380
+ What this release actually carries. A cell is either **native** (written into the emitted
381
+ artefact), **profile only** (written at the workspace level, so it requires profile mode and exactly
382
+ one live persona), **not carried** (refused with `F001`, naming the reference; nothing is written),
383
+ or **unknown** (the harness behaviour is not verified by this release, so it is never claimed as a
384
+ tick).
385
+
386
+ | Capability | Claude Code, per agent | Claude Code, workspace | OpenCode 2.x, per agent | OpenCode 2.x, workspace | OpenCode 1.x, per agent | OpenCode 1.x, workspace |
387
+ |---|---|---|---|---|---|---|
388
+ | `rule` | native | — | native | — | native | — |
389
+ | `model` | native | — | native | — | native | — |
390
+ | `mode` (`primary`/`subagent`/`all`) | not carried (`W117`) | — | native | — | native | — |
391
+ | `permission` | native (allow-list via opt-in) | — | native (deny-list; `write` folds into `edit`, W112) | — | native (per-tool map; `write` folds into `edit`, W112) | — |
392
+ | `mcp` | not carried | — | not carried in agent mode | profile only (`mcp.servers`) | not carried in agent mode | profile only (flat `mcp.<name>`) |
393
+ | `skill` | not carried | — | not carried in agent mode | profile only | not carried in agent mode | profile only |
394
+ | `command` | not carried | — | not carried in agent mode | profile only | not carried in agent mode | profile only |
395
+ | `hook` | not carried | — | not carried in agent mode | profile only; `{ id, setup }` plugin, representable events only (W101) | not carried in agent mode | profile only; `RulesyncHooksPlugin`, representable events only (W101) |
396
+ | `temperature` | not carried (not authored) | — | not carried (not authored) | — | not carried (not authored) | — |
397
+ | `tools` (per-agent) | native (allow-list via opt-in) | — | not carried (an OpenCode allow-list cannot be expressed) | — | not carried (an OpenCode allow-list cannot be expressed) | — |
398
+
399
+ The OpenCode V1 columns record these differences from V2, each verified against rulesync 43.11.0
400
+ output in this repository's golden tests:
401
+
402
+ - **Agent frontmatter** — V1 keeps `name` and writes the per-tool `permission` map; V2 drops `name`
403
+ and writes the ordered `permissions` array. A file carrying a V2 field is read as V2 by OpenCode
404
+ 2.x, which is why a V2 agent must not carry `name`.
405
+ - **MCP config** — V1 writes the flat `mcp.<name>` map with an explicit `enabled: true`; V2 nests
406
+ servers under `mcp.servers` and omits an enabled server's toggle.
407
+ - **Commands** — V1's command frontmatter spells `subtask` and a separate `variant`; V2 spells
408
+ `subagent` and joins the variant onto `model`. This product authors only `description`, so the
409
+ emitted command frontmatter is the same on both; a `subtask`/`variant` field is refused at the
410
+ source boundary rather than being silently written in the wrong spelling.
411
+ - **Hooks plugin** — V1 writes the `RulesyncHooksPlugin` module, which OpenCode 2.x does not run;
412
+ V2 writes the `{ id, setup }` plugin, which OpenCode 1.x does not run.
413
+
414
+ Cells that are not verified by a test in this release are **unknown**, never a tick. In particular,
415
+ this release verifies the emitted bytes and their containment; it does not verify that a particular
416
+ OpenCode build honours `temperature` or per-agent `tools`, and it does not author either field, so
417
+ they are not claimed.
418
+
419
+ Two details matter more than the table:
420
+
421
+ - **OpenCode's workspace kinds are not an agent-mode loss warning.** A workspace emission would give
422
+ every persona the declaring persona's MCP server, skill, command or hook, with no per-recipient
423
+ record and no opt-out. That is not a capability the author declared for those personas, so agent
424
+ mode refuses the reference and points at profile mode instead of emitting it.
425
+ - **Claude Code's workspace kinds are absent from this release.** `claudecode` does not carry
426
+ `mcp`, `skill`, `command` or `hook` at all yet; a reference is refused rather than silently
427
+ losing it. Profile mode on `claudecode` is later work.
428
+
429
+ A full 71-target capability matrix, the `agent with loss` and `refuse` plan outcomes, and a
430
+ generated capability report page are not in this release. See
431
+ [What this slice does not do](#what-this-slice-does-not-do).
432
+
433
+ ### Output layout
434
+
435
+ ```text
436
+ claudecode, agent mode:
437
+ .claude/agents/<id>.md one whole file per persona
438
+
439
+ opencode or opencodev1, agent mode:
440
+ .opencode/agents/<id>.md one whole file per persona
441
+
442
+ opencode or opencodev1, profile mode (active: <id>):
443
+ opencode.jsonc the active persona's MCP servers, merged into the user's own keys
444
+ .opencode/agents/<id>.md only the active persona
445
+ .opencode/skills/<skill-id>/** the active persona's skills and their extra files
446
+ .opencode/commands/<id>.md the active persona's commands
447
+ .opencode/plugins/rulesync-hooks.js the active persona's carried hooks
448
+ (skills, commands and hooks are under .opencode/, not the root)
449
+
450
+ all targets:
451
+ .farna/lock.json the manifest and the source-derived warnings
452
+ ```
453
+
454
+ Every path is conditional on a declaration: a persona with no MCP server emits no
455
+ `opencode.jsonc`, one with no hooks emits no plugin, and one with no skills has no skill tree.
456
+ Agent mode writes none of the workspace paths. `check` computes the expected set independently of
457
+ what the renderer reports, so a dropped or invented file is refused rather than written.
458
+
459
+ ### Profile mode
460
+
461
+ OpenCode carries MCP servers, skills, commands and hooks at the **workspace** level, not per agent.
462
+ In agent mode a workspace emission would give every persona the declaring persona's resource, with
463
+ no per-recipient record and no opt-out. That is not a capability the author declared for those
464
+ personas, so the four kinds require profile mode: exactly one persona is live, and it owns the
465
+ workspace. Agent mode still refuses such a reference with `F001_INVALID_CONFIG`, naming the
466
+ resource, the declaring persona and "requires profile mode"; nothing is written.
467
+
468
+ Select profile mode in the config:
469
+
470
+ ```jsonc
471
+ // .farna/config.jsonc
472
+ {
473
+ "schemaVersion": 1,
474
+ "targets": {
475
+ "opencode": { "active": "builder" }
476
+ }
477
+ }
478
+ ```
479
+
480
+ Or override the committed selection for one run:
481
+
482
+ ```sh
483
+ farna-bootstrapper generate --persona reviewer
484
+ farna-bootstrapper check --persona reviewer
485
+ ```
486
+
487
+ `--persona` wins over `targets.<target>.active`. A persona that does not exist is
488
+ `F001_INVALID_CONFIG` naming the config field or `--persona`; the tool never picks a persona for
489
+ you. Agent mode is the default when no active persona is set.
490
+
491
+ **The invariant is one persona per workspace.** In profile mode only the active persona is
492
+ materialised and verified: no other persona's agent file, MCP server, skill, command or hook is
493
+ emitted, and the containment gate accepts only the active set. Every persona is still resolved, so
494
+ a broken declaration anywhere in the source is still refused; only emission is scoped to the live
495
+ persona. The lockfile records one `personas[]` entry, `mode: "profile"`, `activePersona: "<id>"` and
496
+ `notLive: [<every other persona>]`; in agent mode `mode` is `"agent"`, `activePersona` is `null`
497
+ and `notLive` is empty. `generate` and `check` print the not-live set, and `--json` carries it as
498
+ `notLive`, so a deactivated persona is never silent.
499
+
500
+ Selecting profile mode with `active` or `--persona` when the live persona declares no capability
501
+ that *requires* it (an MCP server or a hook, which OpenCode carries only at the workspace level) is
502
+ a choice, and it is reported as `W109_PROFILE_BY_CHOICE` at info severity. A skill or command is
503
+ content the target could in principle drop, so it does not force the mode.
504
+
505
+ **The profile is the repository root.** It is never a cache directory and never a subdirectory
506
+ below another config. The exact paths are in [Output layout](#output-layout).
507
+
508
+ Profile mode is supported for both OpenCode targets (`opencode` and `opencodev1`). `claudecode`
509
+ refuses an `active` value or `--persona` with `F001_INVALID_CONFIG`: its only workspace-only
510
+ capability is `command`, a content capability that does not force a profile, so profile mode there
511
+ is later work. Accepting the setting and ignoring it would be a silent no-op.
512
+
513
+ A hook OpenCode cannot represent (`session-end`, or a matcher on a non-tool event) is reported as
514
+ `W101_CAPABILITY_DROPPED` at `high` severity and is not emitted; it is never silently omitted.
515
+
516
+ #### Orphan handling
517
+
518
+ A persona switch, a removed resource or a target edit leaves output the committed lockfile records
519
+ but the current source no longer produces. `check` reports every such recorded path as
520
+ `F007_DRIFT` drift with kind `unexpected`. An unrecorded file is ordinarily ignored, because it
521
+ belongs to the user.
522
+
523
+ `check` also compares a `configDigest` recorded in the lockfile: a change to the config or to **any**
524
+ persona or resource file is drift even when the live persona renders no different byte, so an edit
525
+ to a non-live persona's declaration cannot hide. The digest covers the **raw** `config.jsonc`
526
+ bytes as well as the parsed value, so a comment or whitespace edit in the config is drift exactly
527
+ like a comment edit in a persona file.
528
+
529
+ `generate` may remove a recorded orphan, under four guards:
530
+
531
+ 1. it must exist and be a relative, escape-free path in a managed location — one of
532
+ `.claude/agents/`, `.opencode/agents/`, `.opencode/commands/`, `.opencode/skills/`,
533
+ `.opencode/plugins/`, or a target's whole root config file (`opencode.jsonc`). A recorded path
534
+ that is already **absent** is simply dropped from the new lockfile; the managed-location guard
535
+ applies only to a path that exists, so the action it prints can always be carried out;
536
+ 2. it must still be a **regular file**; a symbolic link is refused (`F003`) and never followed;
537
+ 3. its bytes must still equal the SHA-256 the lockfile recorded. The check is repeated immediately
538
+ before the `rm`, so a file changed between the preflight and the removal is refused rather than
539
+ deleted. A file edited since the last generate is refused with `F007_DRIFT`: ownership can no
540
+ longer be proven, so it is not deleted;
541
+ 4. it must be recorded. An unrecorded file is the user's and is never removed.
542
+
543
+ A structured entry (`opencode.jsonc`) owns only its `mcp` key. When the source no longer declares
544
+ an MCP server, `generate` deletes only that key in place: a file that still carries the user's own
545
+ keys is kept, with its comments, and the record is dropped; a file that holds nothing but the owned
546
+ key is removed. Once the user has removed the owned key itself the record is dropped and the file
547
+ left alone.
548
+
549
+ The whole orphan set is preflighted before anything is written, so a refusal leaves the tree
550
+ untouched. Removals happen before the new managed set is committed: a commit that then fails names
551
+ the removals it already made, so the error never claims "nothing was written" for a tree that is
552
+ partially updated. An empty directory left after removing a skill's last file is not removed: the
553
+ contract is to remove recorded regular files, not directories.
554
+
555
+ ### A missing lockfile: refuse, then adopt
556
+
557
+ The lockfile is the only proof that a path is this tool's output. When it is absent, a file at a
558
+ planned path could be this tool's earlier render or the user's own file, and the tool has no way to
559
+ tell. It therefore **refuses** rather than guessing from a file name: if `.farna/lock.json` is
560
+ missing and any planned managed output already exists, `generate` and `check` fail with
561
+ `F007_DRIFT` naming those outputs and the action `run generate --adopt`.
562
+
563
+ `generate --adopt` is the explicit adoption. It takes ownership of every existing planned managed
564
+ output: `opencode.jsonc` is merged in place so only the owned `mcp` key changes and the user's keys
565
+ and comments survive, every other planned file is overwritten with the fresh render, and the
566
+ lockfile records the result. A file **not in the plan** is neither adopted nor removed. `check`
567
+ never adopts; it only tells the user to run `generate --adopt`.
568
+
569
+ The trade-off is deliberate: with no lockfile the tool does not scan for stale renders by path. A
570
+ stale output that is not recorded and not in the plan is the user's responsibility; naming a file
571
+ is not proof that this tool wrote it.
572
+
573
+ The one unrecorded path `check` still reports is an extra file inside a **skill directory** this
574
+ tool owns (recorded or planned at `W107_OUTSIDE_OWNERSHIP`, never deleted), which is a recorded-path
575
+ question rather than a name guess. A file under a name no declaration would emit
576
+ (`.opencode/commands/custom.md`, `.opencode/skills/custom/`) is genuinely the user's and is not
577
+ reported.
578
+
579
+ MCP `env` and `headers` values are references only. A resource declares
580
+ `{ "fromEnv": "EXAMPLE_TOKEN" }`; the materialiser writes rulesync's canonical `${EXAMPLE_TOKEN}`.
581
+ A literal value in a credential position is `F002_SECRET_LITERAL` and is never echoed. An MCP
582
+ `http` URL may not carry userinfo (`F002`, never echoed); a credential-shaped query parameter
583
+ (`token`, `api_key`, `apikey`, `access_token`, `secret`, `password`) is reported as
584
+ `W115_CREDENTIAL_IN_URL` and never echoed either. A stdio `command` is the program only: whitespace
585
+ and control characters are refused (F001) with a message to put the arguments in `args`.
586
+
587
+ `args` accepts literals, because a command genuinely needs them (`-y`, `serve`, a path). A literal
588
+ that *looks like a credential* (`sk-`, `ghp_`, `glpat-`, `npm_`, `AKIA`, a JWT, or a long token-shaped
589
+ string with letters and digits) is reported as `W116_SECRET_IN_ARGS` at high severity, naming the
590
+ argument's position and never echoing the value: it would otherwise be written verbatim into
591
+ `opencode.jsonc`. A `{ "fromEnv": "NAME" }` reference inside `args` cannot be expressed — rulesync
592
+ 43.11.0 accepts only string arguments and copies them into the emitted command verbatim, so the
593
+ reference would reach the server as the unexpanded text `${NAME}` — and is refused (F001) with the
594
+ supported alternative: put the credential in `env` or `headers`.
595
+
596
+ The workspace resource kinds are **not** carried by `claudecode` either. A persona that references
597
+ one is refused (F001) rather than silently losing it.
598
+
599
+ ## Composition
600
+
601
+ `extends` names at most one base persona. Resolution is:
602
+
603
+ 1. Resolve `extends` recursively, depth at most 32; a cycle, a self-extension or a missing base
604
+ is refused (F001) and the cycle message names the whole path.
605
+ 2. The base persona's rules and permissions are unioned into the child, by `(kind, id)`.
606
+ 3. The child's own `resources` are added in declaration order. Rule bodies are deduplicated by
607
+ id; permissions are merged by category, and the stricter value wins.
608
+ 4. The model is inherited from the base or set on the persona. Two different concrete models in
609
+ one composed set are a conflict (F005), never a silent override.
610
+ 5. The composed persona's body is both rule sets, and its permission entries are the union. In
611
+ the example above `builder-python` carries both rule markers and not the reviewer's, because
612
+ the reviewer's rules were never in its chain.
613
+
614
+ `resources` may be empty. A persona with no rules has an empty composed body: its artefact carries
615
+ only its frontmatter, so a permission-only persona (a locked-down reviewer with no prose) is valid
616
+ and generates cleanly.
617
+
618
+ A composed persona is one new name. There are no multi-parent unions and no per-target branches
619
+ in the source.
620
+
621
+ ## Permissions
622
+
623
+ The canonical categories are `read`, `write`, `edit`, `shell`, `network`, `mcp`, `task` and `*`.
624
+ They are validated at plan time and mapped to the target's own form before anything is written:
625
+
626
+ | Category | Claude Code entry | OpenCode 2.x record | OpenCode 1.x map |
627
+ |---|---|---|---|
628
+ | `read` | `Read` / `Read(P)` | `{action: read}` | `read` |
629
+ | `write` | `Write` / `Write(P)` | `{action: edit}` (folds into `edit`, W112) | `edit` (folds into `edit`, W112) |
630
+ | `edit` | `Edit` / `Edit(P)` | `{action: edit}` | `edit` |
631
+ | `shell` | `Bash` / `Bash(P)` | `{action: shell}` | `bash` |
632
+ | `task` | `Agent` / `Agent(P)` | `{action: subagent}` | `task` |
633
+ | `network` | none | none | none — refused (F011, exit 3) |
634
+ | `mcp` (bare) | none | none | none — refused (F011, exit 3) |
635
+ | `*` | expands to every category | same | same — refused (F011), because it covers `network` |
636
+
637
+ On OpenCode 2.x the records are an ordered array of `{ action, resource, effect }`. `bash` is
638
+ emitted as `shell` and `task` as `subagent`. OpenCode documents last-match-wins, so order is
639
+ semantic: the catch-all is emitted first, and pattern resources keep their source declaration
640
+ order. Sorting by codepoint could put an earlier allow after a later deny and silently turn a deny
641
+ into an allow. The permission digest is order-sensitive for the same reason.
642
+
643
+ On OpenCode 1.x the same resolved map is written as the per-tool `permission` object, with
644
+ `shell` under OpenCode's own key `bash` and `task` under `task`; both OpenCode targets fold `write` into
645
+ `edit` and refuse `network` and a bare `mcp` before anything is materialised. `write` has no
646
+ OpenCode category on either target: every write-derived `allow` that no edit declaration covers is
647
+ reported as `W112_PERMISSION_LOSSY` (HIGH), including when an unrelated edit allow exists. A record
648
+ whose emitted effect is deny is never reported: it narrows, and a stricter rule must never be
649
+ presented as a loss. `ask` is emitted as `deny` on all targets and reported as
650
+ `W111_ASK_DOWNGRADED`, because none of them has a measured ask surface.
651
+
652
+ ### Allow-list vs deny-list
653
+
654
+ Claude Code's per-agent `tools` field is an **allow-list**: naming three tools removes every tool
655
+ it does not name, including `Glob`, `Grep`, `WebFetch`, `TodoWrite`, `NotebookEdit` and any tool
656
+ this product does not model. The default is therefore a **deny-list**: `allow` entries emit
657
+ nothing (the tool is available unless denied), while `deny` and an `ask` downgraded to `deny` are
658
+ emitted into `disallowedTools`. A partial allow set can never silently narrow a persona.
659
+
660
+ A permission resource may opt in with `"allowlist": true`. The resolved persona then emits the
661
+ ordered `tools` allow-list and a `W113_ALLOW_LIST_NARROWS` warning names examples of the unmodelled
662
+ tools the narrowing removes (the product does not enumerate every harness tool). The mode is persona-scoped: if any contributing resource opts in, the union of
663
+ its resolved `allow` entries becomes the allow-list. `check` applies the same rule, so a renderer
664
+ that invents or drops `tools` is refused either way. If the opt-in resolves to no `allow` entry
665
+ (every category is denied, or a deny removed the only allow), `tools` is omitted and W113 reports
666
+ that the opt-in had no effect, naming the categories that removed it; emitting `tools: []` would
667
+ remove every tool. The persona's permission digest records that same effective value.
668
+
669
+ A pattern is resolved against its category before it is emitted: if the category's winning value is
670
+ `deny` (including an `ask` downgraded to `deny`), an `allow` pattern under it is not emitted and the
671
+ drop is reported (W106) naming the pattern. Emitting both would leave the harness, not this tool,
672
+ deciding which of two contradictory entries wins. Every other category is native and maps 1:1 onto a
673
+ distinct tool, so there is no W112 on Claude Code. When two permission resources disagree on a
674
+ category, the stricter value wins and the disagreement is reported (W106). On Claude Code both
675
+ arrays are sorted alphabetically and every entry starts with the harness's capitalised tool name.
676
+
677
+ A pattern key that is a canonical array index (`"0"`, `"1"`, `"10"`, ...) is refused at the source
678
+ boundary (F001). JavaScript enumerates an object's array-index keys first, in ascending numeric
679
+ order, before every other key in declaration order, so a numeric pattern would silently move ahead
680
+ of the patterns declared before it. Order is semantic (OpenCode is last-match-wins) and the digest
681
+ would be identical for both spellings, so the tool refuses the key instead of emitting an order the
682
+ source did not declare. Spell the resource as a non-numeric pattern such as `"**/10/**"`, or choose
683
+ another key that is not a bare integer.
684
+
685
+ An OpenCode persona may not opt into the Claude Code `tools` allow-list. OpenCode's records are a
686
+ deny-list and cannot name every unmodelled tool, so `"allowlist": true` is refused (F001) on that
687
+ target rather than silently ignored.
688
+
689
+ Only harness-specific category names reach the renderer source tree; a product category name is
690
+ never written there, and a test asserts it.
691
+
692
+ Warnings are printed by `generate` and `check`. The warning set covers every resolved persona, not
693
+ only the live one: each warning names its persona, so a declaration an inactive persona makes is
694
+ still visible in profile mode. Source-derived warnings are recorded in `.farna/lock.json`.
695
+ `W107_OUTSIDE_OWNERSHIP` is reported by `check` as a drift item rather than a source warning: it
696
+ describes the working tree (an extra skill file), not the source. `W114_RENDERER_INTEGRITY_UNVERIFIED`
697
+ is a runtime verification result about the machine, so it is printed but deliberately not recorded;
698
+ recording it would make two machines with identical sources produce different lockfile bytes.
699
+
700
+ ## Warnings and exit codes
701
+
702
+ ### Warnings
703
+
704
+ A warning is a report, not a failure: it never changes what is rendered. A run that emits one still
705
+ exits `0` unless the warning records a refusal (which is a typed error, not a warning). The severity
706
+ is part of the code's definition, never set by a flag.
707
+
708
+ | Code | Default severity | What it reports |
709
+ |---|---|---|
710
+ | `W101_CAPABILITY_DROPPED` | high for a boundary capability, medium for content | A resolved capability the target cannot carry was not emitted. In profile mode this is a hook OpenCode cannot represent (`session-end`, or a matcher on a non-tool event). Never a silent omission. |
711
+ | `W106_DENY_WINS` | medium when the losing value is `allow`, otherwise info | Two permission resources disagreed on a category; the stricter value won, and the disagreement (and what it removed) is named. |
712
+ | `W107_OUTSIDE_OWNERSHIP` | low | An unrecorded file is inside a skill directory this tool owns. `check` reports it as drift; `generate` never deletes it. |
713
+ | `W109_PROFILE_BY_CHOICE` | info | Profile mode was selected although the live persona declares no capability that requires it (an MCP server or a hook). Agent mode is the default. |
714
+ | `W111_ASK_DOWNGRADED` | medium | An `ask` permission was emitted as `deny`, because no target has a measured ask surface. |
715
+ | `W112_PERMISSION_LOSSY` | high | On OpenCode, `write` folds into `edit`; a write-derived `allow` that no edit declaration covers is lost. A deny is never reported, because a stricter rule is not a loss. |
716
+ | `W113_ALLOW_LIST_NARROWS` | medium | A permission resource opted into the Claude Code `tools` allow-list, which removes every tool the product does not model. Examples of the removed tools are named; an opt-in that resolves to nothing is reported as having no effect. |
717
+ | `W114_RENDERER_INTEGRITY_UNVERIFIED` | medium | No npm lock record at the install root supplied the renderer's tarball integrity. The pinned version is still enforced; this is a provenance gap, never a clean pass. |
718
+ | `W115_CREDENTIAL_IN_URL` | high | An MCP `http` URL carries a credential-shaped query parameter (`token`, `api_key`, `apikey`, `access_token`, `secret`, `password`). The value is never echoed. |
719
+ | `W116_SECRET_IN_ARGS` | high | An MCP `args` literal looks like a credential (`sk-`, `ghp_`, `glpat-`, `npm_`, `AKIA`, a JWT, or a long token-shaped string). The value is never echoed; put the credential in `env` or `headers` instead. |
720
+ | `W117_PERSONA_MODE_IGNORED` | info | A persona declares `mode`, which Claude Code cannot carry: it has no primary/subagent mode. The persona and target are named and no `mode` key is written; the agent file is otherwise emitted in full. |
721
+
722
+ ### Exit codes
723
+
724
+ | Exit | Meaning | Codes |
725
+ |---|---|---|
726
+ | `0` | success; warnings are allowed | — |
727
+ | `1` | invalid input, an unsafe path, or drift | `F001_INVALID_CONFIG`, `F002_SECRET_LITERAL`, `F003_PATH_UNSAFE`, `F007_DRIFT` |
728
+ | `2` | a conflict between declarations | `F005_CONFLICT` |
729
+ | `3` | a requested capability is refused | `F011_PERMISSION_UNMAPPED` |
730
+ | `4` | the renderer lost or invented declared content | `F008_DECLARED_NOT_EMITTED` |
731
+ | `5` | the render or the write failed | `F009_RENDER_FAILED`, `F010_RENDERER_MISMATCH`, `F012_WRITE_FAILED` |
732
+
733
+ `check` uses exit `1` for drift and carries `F007_DRIFT` in its payload with the first drifted path
734
+ as `subject`; drift is a result, not an exception, so it is absent from the exception table. A
735
+ usage error (an unknown command or option) exits `1`. Under `--json` the human report is
736
+ suppressed: a success is one object on stdout and nothing on stderr; a typed failure is one object
737
+ on stdout and its single human line on stderr.
738
+
739
+ ## Layout
740
+
741
+ ```text
742
+ src/
743
+ cli/ Commander wiring, the three commands, and the error boundary
744
+ config/ strict JSONC config schema and loader
745
+ source/ YAML personas; markdown rules, skills and commands; JSONC permissions,
746
+ MCP servers and hooks; strict frontmatter and reference-only secrets
747
+ compose/ mode resolution, extends resolution, resource union, deny-wins merge, digests
748
+ permissions/ the canonical vocabulary and the Claude Code and OpenCode mappings
749
+ materialise/ persona and workspace resources -> rulesync source tree
750
+ render/ port.ts (the seam), upstream.ts (the only rulesync import),
751
+ identity.ts (installed vs pinned renderer), prepare.ts (the pipeline),
752
+ stage.ts (the disposable stage), commit.ts (the write), staging.ts,
753
+ orphans.ts (recorded-orphan preflight and removal), generate-lock.ts
754
+ (the atomic lock directory), structured.ts (in-place, key-level
755
+ ownership of opencode.jsonc), root-cleanliness.ts (skill-tree extras)
756
+ verify/ containment and cross-persona isolation gates
757
+ lock/ lockfile construction and validated reading
758
+ core/ constants, typed errors, paths, strict UTF-8 reads, canonical JSON
759
+ report/ text and JSON output, warning records
760
+ tests/
761
+ fixtures/demo/ the demo fixture: two personas, two rules, no permissions
762
+ fixtures/composed/ builder, builder-python (extends builder) and reviewer, with permissions
763
+ fixtures/opencode/ the OpenCode 2.x fixture: rules, permissions and the files for the refused kinds
764
+ fixtures/opencode-v1/ the OpenCode 1.x fixture, same shape on the V1 target
765
+ fixtures/profile/ OpenCode 2.x profile mode: two personas with distinct MCP, skill, command and hook
766
+ fixtures/profile-v1/ OpenCode 1.x profile mode, same source on the V1 target
767
+ golden/ every target's pinned emitted bytes, both OpenCode majors included
768
+ unit/ composition, permissions, fake and mutating renderer gates, loader, init,
769
+ check, paths, profile mode and orphan removal
770
+ integration/ the real pinned renderer
771
+ cli/ the built CLI: exit codes, JSON envelopes and drift output
772
+ scripts/ CI gates: the minimum test count, real-renderer suites and tarball contents
773
+ ```
774
+
775
+ `.farna/lock.json` records `schemaVersion`, `product` (name and version), `target` (`claudecode`,
776
+ `opencode` or `opencodev1`), `mode` (`agent` or `profile`), `activePersona` (the persona id in profile mode, `null`
777
+ in agent mode), the `renderer` identity, each **live** persona's composition base and resolved
778
+ resource ids (each with the persona that contributed it, across every loaded kind), a persona
779
+ digest, an order-sensitive permission digest, every source-derived warning, and the path, size and
780
+ SHA-256 of every managed file. It does **not** list
781
+ itself: the lockfile is built from the managed files before its own record is appended, so its own
782
+ bytes are deliberately
783
+ absent from `files`. It contains no timestamps, hostnames or absolute paths. A lockfile written
784
+ by an earlier version that recorded `W114` in `warnings[]` is repaired by one `generate`, which
785
+ drops the runtime record and rewrites the same source-derived document.
786
+
787
+ The `renderer` record is the build's **pin** (`RENDERER_PIN`), not the integrity the local package
788
+ manager wrote, and it is what `check` compares the installed package against. Two machines that
789
+ both verified their install, and a machine that could not verify its own, therefore produce
790
+ byte-identical lockfiles for the same source: `W114_RENDERER_INTEGRITY_UNVERIFIED` is reported in
791
+ the command output, never recorded in this artefact. A lockfile that recorded it made a runtime
792
+ verification result part of the byte comparison, so `check` reported `F007_DRIFT` on
793
+ `.farna/lock.json` between a verified and an unverified machine even though no source had changed.
794
+
795
+ ## Determinism
796
+
797
+ The generated bytes are the product, so they must not depend on where or when the command ran.
798
+
799
+ - **The lockfile is source-derived.** It records the product version, the target and mode, the live
800
+ persona (and the not-live set), each persona's composition and digests, the source warnings, and
801
+ each managed file's path, size and SHA-256. It records no timestamp, hostname, absolute path, user
802
+ name or process id.
803
+ - **Ordering is canonical.** Personas and resources are sorted by kind and codepoint id before
804
+ hashing or writing. Permission records are the one deliberate exception: they keep source order
805
+ because OpenCode is last-match-wins, so the digest is order-sensitive there too.
806
+ - **The renderer is pinned.** `rulesync` is pinned to exactly `43.11.0` with a tarball integrity (see
807
+ [The renderer boundary](#the-renderer-boundary)). The lockfile records the pin, not the integrity
808
+ the local package manager happened to write, so two machines that both verified their install -
809
+ and one that could not verify its own - produce the same lockfile bytes for the same source.
810
+ - **Line endings are pinned.** `init` adds `/.farna/**` and every generated path to `.gitattributes`
811
+ with `text eol=lf`, so a Windows checkout does not change a source byte (and therefore
812
+ `configDigest`) or make `check` report drift the source never declared. This repository pins its
813
+ own `.farna/**` tree the same way.
814
+ - **`check` is a byte comparison.** It re-renders into a temporary directory and compares the exact
815
+ bytes (or, for `opencode.jsonc`, the owned key's value). A file that exists is not a file that
816
+ matches.
817
+
818
+ The repository's own suites include golden byte comparisons and a two-root determinism test. Two
819
+ clean runs of the same source on one machine produce identical bytes and an identical lockfile;
820
+ cross-machine determinism follows from the same rules, and CI runs on Linux.
821
+
822
+ ## The renderer boundary
823
+
824
+ `src/render/port.ts` defines `RenderTarget`. `src/render/upstream.ts` is the only module that
825
+ imports `rulesync`, and `src/cli/main.ts` is the only place that binds the real implementation.
826
+ Unit tests use an independent fake renderer, so the failure modes the port exists to catch can be
827
+ exercised without the network or the real renderer.
828
+
829
+ `rulesync` is pinned to exactly `43.11.0` with a tarball integrity. The lockfile records that pin,
830
+ and `check` compares it with the installed package before any byte comparison. The renderer
831
+ identity policy has three parts:
832
+
833
+ 1. **Version — enforced.** A different name or version fails `F010` with exit `5`. This runs first,
834
+ so a missing integrity can never let a substituted renderer pass.
835
+ 2. **Integrity — best effort, from two records.** The installed integrity is read from exactly two
836
+ npm records at the install root (the nearest ancestor of the product package that owns a
837
+ `node_modules` directory): `node_modules/.package-lock.json` and `package-lock.json`. The
838
+ `packages` map is searched for the renderer's entry under any key ending in
839
+ `node_modules/<renderer>` (a scoped name keeps its scope in the key). A nested install records
840
+ it as `node_modules/farna-bootstrapper/node_modules/rulesync`. When more than one entry matches,
841
+ the one nested under farna-bootstrapper's own package wins, then the shallowest, then the
842
+ earlier record. In a hoisted workspace the renderer is at the workspace root, so that root is
843
+ the install root and its record is read; the search never leaves the install root beyond that,
844
+ so a workspace root above it, a parent monorepo or a sibling package records a different copy
845
+ and is never read, and cannot refuse a healthy install with a foreign integrity or verify one
846
+ it did not examine. A string integrity that was found is compared exactly with the pin; a
847
+ different one is `F010`, including when a shared record's matching entry belongs to another
848
+ package: only the pinned tarball passes.
849
+ 3. **Unverifiable — named, never silently passed.** A record that exists but cannot be read, is a
850
+ symlink or is not a regular file, or is above the 64 MiB npm-record bound, is refused `F010`
851
+ naming the record, even when the other supported record is usable. Only a genuinely absent
852
+ entry in the two supported records, or an entry with no string integrity, is
853
+ `W114_RENDERER_INTEGRITY_UNVERIFIED`: the version check still applies, the run continues, and
854
+ the warning names whether no record was found or the record had no integrity. The pin is **not**
855
+ substituted for a missing integrity and the tool never claims a clean integrity pass it could
856
+ not make.
857
+
858
+ The 64 MiB npm-record bound is deliberately separate from the 4 MiB bound on `.farna/lock.json`:
859
+ npm's record scales with the dependency tree, so a legitimate monorepo lockfile is several
860
+ megabytes. The check never degrades a known integrity to a version-only comparison. Because the
861
+ lockfile records source-derived state only, a machine that could not verify its install does not
862
+ change its bytes: `W114` is reported by the command, and verified and unverified machines produce
863
+ the same lockfile for the same source, so `check` agrees across them.
864
+
865
+ The renderer is imported **in-process**. The pin is provenance, not a sandbox: it ties the
866
+ committed bytes to a published tarball when the integrity is verifiable, but a package patched in
867
+ place with the same `package.json` and integrity is not detected, and an unverifiable install is
868
+ reported rather than blocked (see the residual list). The product never uses rulesync's `--delete`;
869
+ cleanup is ownership-scoped, and this slice never deletes a user file.
870
+
871
+ The renderer call is hermetic: its working directory is the disposable stage and its `configPath`
872
+ is a file inside that stage, so an ambient `rulesync.jsonc` (or `rulesync.local.jsonc`) in the
873
+ caller's directory cannot flip `dryRun`, `delete` or `check`. Those three options are also pinned
874
+ explicitly.
875
+
876
+ Every source directory and output path used by `generate`, `generate --dry-run` and `check` is
877
+ checked with `lstat` before use. The write and dry-run paths refuse a symbolic link wherever it
878
+ appears: `.farna`, its subdirectories, `config.jsonc`, any ancestor of a managed output path
879
+ (including `.claude` symlinked inside the repository), and a managed file itself. `check` reports
880
+ a symlinked managed file as drift instead of following it. The dry-run plan goes through the same
881
+ guard as the write path, so it cannot report a plan the real command would refuse.
882
+
883
+ `generate` preflights the whole set, sweeps its own staging namespace, stages each file as a hidden
884
+ `.<target>.farna-tmp-<pid>-<uuid>` sibling on the same filesystem, and renames only after every
885
+ write has succeeded. A caught failure before the first rename removes the staging files and the
886
+ directories this run created; if a directory cannot be removed, the diagnostic names it rather than
887
+ claiming a clean tree. A failure between renames restores the files already replaced and names any
888
+ file it could not restore. A crash or kill between renames can still leave a mixed tree; see
889
+ [Residual risks and known gaps](#residual-risks-and-known-gaps). `init` preflights `.gitignore`
890
+ before creating anything, preserves its line ending, writes the new file with `O_EXCL` under an
891
+ unpredictable name and proves it is a regular file before renaming it over `.gitignore`, and removes
892
+ what it created if it subsequently fails.
893
+
894
+ ## Examples
895
+
896
+ Three complete source trees live in [`examples/`](examples/). All are exercised by the test suite:
897
+ the built CLI generates each one in a temporary copy and `check` must exit `0`.
898
+
899
+ - [`examples/claude-code/`](examples/claude-code/) - two personas (`builder`, `reviewer`) in agent
900
+ mode on the `claudecode` target, with two rules and a real read-only reviewer restriction. Run it
901
+ with `node ../../dist/cli/main.js generate` then `check` from that directory.
902
+ - [`examples/opencode-v2/`](examples/opencode-v2/) - profile mode on the `opencode` target (OpenCode
903
+ 2.x, `@opencode/cli`): one live persona (`builder`) that owns the workspace, with a rule, a
904
+ permission set, one MCP server, one skill, one command and one hook, plus a second persona that is
905
+ resolved but not live. The MCP credential is an environment reference, not a literal.
906
+ - [`examples/opencode-v1/`](examples/opencode-v1/) - the same source tree on the `opencodev1` target
907
+ (OpenCode 1.x, `opencode-ai`): the V1 agent frontmatter, the flat `mcp` map, the V1 command
908
+ frontmatter and the `RulesyncHooksPlugin`. It writes the same paths as the V2 example.
909
+
910
+ Each example has its own README with the exact commands and the files it writes. None commits
911
+ generated output; the example is the source tree.
912
+
913
+ ## Where to look for a decision
914
+
915
+ This README is the user-facing contract and the record of the behaviour it covers. Each target's
916
+ section, the [Capability matrix](#capability-matrix), [Warnings](#warnings) and
917
+ [Residual risks and known gaps](#residual-risks-and-known-gaps) answer the questions a separate
918
+ design note would otherwise answer. If a behaviour is not explained anywhere here, open an issue
919
+ rather than inferring it from a generated file. See also [CONTRIBUTING.md](CONTRIBUTING.md) for
920
+ where a change belongs and which gates it must pass.
921
+
922
+ ## What this slice does not do
923
+
924
+ Deliberately out of scope:
925
+
926
+ - `doctor`; `agent with loss` and `refuse` as plan outcomes; profile mode on `claudecode`;
927
+ rendering more than one configured target per run; every target other than `claudecode`,
928
+ `opencode` and `opencodev1`; the full 71-target capability matrix and the capability report page
929
+ - model resources (a model is the persona's `model` class in this slice)
930
+ - carrying `mcp`, `skill`, `command` or `hook` on any target in **agent** mode; profile mode is
931
+ where those workspace capabilities belong, and agent mode still refuses them
932
+ - `patch` and `replaceWith` on a persona resource reference; `targets` filters on personas and
933
+ resources; `--strict`; `--accept-config` gating; `.farna/local.jsonc`
934
+ - removing a recorded orphan that is not in a managed location: a path outside `.claude/agents/`,
935
+ `.opencode/` or `opencode.jsonc` is refused rather than deleted, because ownership cannot be
936
+ proven; an empty directory left after a skill's last file is removed is not swept
937
+ - region ownership (`CLAUDE.md`, `AGENTS.md`); `opencode.jsonc` is the only structured file, and the
938
+ only key it owns is `mcp`. Every other managed path is a whole file or a whole tree
939
+
940
+ Recursive deletion is limited to directories the tool created. There are three sites:
941
+ `src/render/stage.ts` removes the disposable `mkdtemp` stage, and `src/render/generate-lock.ts`
942
+ removes the lock directory renamed aside on reclaim and again on release. Each deletes only a
943
+ directory this tool created; no user content is recursively deleted.
944
+
945
+ ## Residual risks and known gaps
946
+
947
+ These are deliberate limits of the current controls, stated rather than implied away:
948
+
949
+ - **TOCTOU between preflight and write.** Every ancestor is `lstat`'ed before the write, but a
950
+ symlink swapped in between that check and the `mkdir`/`rename` is not detected. Node exposes no
951
+ `openat`/`O_NOFOLLOW` equivalent, so closing this needs a separate seam.
952
+ - **Crash between renames.** A caught rename failure restores the files already replaced and names
953
+ any it could not restore. A process kill or power loss between two renames can leave a mixed tree
954
+ (some new artefact files, a stale lockfile). Re-running `generate` replaces the managed set and
955
+ rewrites the record; `check` reports the drift.
956
+ - **Renderer file-content tampering.** The renderer is imported in-process and the identity check
957
+ reads the installed package's version and the npm-recorded tarball integrity. A renderer patched
958
+ in place with the same `package.json` and the same tarball integrity is not detected. The pin is
959
+ provenance, not a sandbox.
960
+ - **Stage cleanup.** The stage lives under the canonical temporary root; the containment check uses
961
+ `path.relative`, so a Windows checkout recognises its own stage (a hardcoded `/` used to refuse it
962
+ and leak the directory), and creation failures after `mkdtemp` still reach the cleanup. If the
963
+ stage cannot be removed (for example a renderer left an unreadable subdirectory in it), the
964
+ cleanup failure is a warning naming the leftover path and never replaces the renderer's own error.
965
+ - **Lockfile read.** `.farna` must be a real directory and `.farna/lock.json` a real regular file of
966
+ at most 4 MiB, opened with `O_NOFOLLOW`. A symlink, FIFO or oversized file is a typed refusal
967
+ rather than a follow or a hang. A lockfile that is **present but malformed or of an incompatible
968
+ version** is a typed F001 naming `.farna/lock.json` with the delete-and-regenerate recovery; it is
969
+ never treated as "no records". A lockfile written before profile mode existed (no `mode`, no
970
+ `activePersona`) is still accepted and normalised to agent mode, so its recorded paths are not
971
+ silently forgotten.
972
+ - **One `generate` at a time.** `.farna/.generate.lock` is a **directory** created with `mkdir`
973
+ (atomic on every supported filesystem), its owner recorded in `pid`, around the whole read →
974
+ plan → remove → commit sequence, and released in a `finally`. A second live run is a typed F001
975
+ ("lock held"). A lock whose owner pid is dead, or that is older than the age bound, is reclaimed
976
+ by renaming it aside (only one reclaimer can win) and retrying the `mkdir`. A non-directory at the
977
+ lock path is a typed error, never "another generate is running".
978
+ - **Generated modes are explicit.** Managed files are created `0644` and managed directories
979
+ `0755`, then re-asserted with `chmod`; the process umask no longer decides whether generated
980
+ output is group- or world-writable.
981
+ - **Staging leftovers.** A killed `generate` can leave `.<target>.farna-tmp-*` siblings. They are
982
+ ignored by `check` and swept at the start of the next `generate`; a leftover in a directory the
983
+ next plan does not touch (an unplanned directory) is not swept and is left on disk. Removal is
984
+ best-effort and a leftover is never a managed path.
985
+ - **Orphan removal is preflighted, not transactional.** The whole orphan set is checked before the
986
+ first write, and removals run before the new set is committed. A filesystem failure while
987
+ removing, or a commit failure after a removal, leaves a mixed tree: the failure message names the
988
+ paths already removed, `check` reports them, and re-running `generate` completes the switch. A
989
+ recorded orphan replaced by a directory, a symlink or edited bytes is refused rather than guessed
990
+ at, and must be removed deliberately. The bytes are re-read and re-hashed immediately before each
991
+ `rm`: a file changed between the preflight and the removal is refused rather than deleted.
992
+ - **An empty directory is left after a skill's last file is removed.** Only recorded regular files
993
+ are removed; the now-empty `<skill>/` (or `scripts/`) directory is harmless and carries no
994
+ declaration.
995
+ - **The per-agent `mode` is source-derived, not implied by the render mode.** A persona's declared
996
+ `mode` (default `subagent`) is emitted on both OpenCode targets; profile mode does not promote the
997
+ live persona implicitly. Claude Code has no primary/subagent mode, so a declaration there is
998
+ reported (`W117`) and no `mode` key is written.
999
+ - **No coverage gate.** There is no coverage provider or threshold in this slice. CI runs lint,
1000
+ type-check, tests (with a minimum count and real-renderer suite assertions), a dependency audit at
1001
+ `moderate`, and a published-tarball check.
1002
+ - **Windows-specific test skips.** Four classes of test cannot run on Windows: the symlink
1003
+ regression suites (creating a symbolic link needs a privilege the runner does not grant), the
1004
+ POSIX file- and directory-mode assertions (mode bits are not meaningful on NTFS), the FIFO cases
1005
+ (Windows has no `mkfifo`-equivalent endpoint to create one), and the install-layout suite (its
1006
+ fixtures model a hoisted or nested install with symlinks). CI runs all of them on Linux; the
1007
+ guard code itself is platform-independent.
1008
+ - **Unrecorded files are not drift.** With a lockfile present, `check` compares the paths in the
1009
+ fresh plan (missing or changed) and the paths the committed lockfile records (an output the source
1010
+ no longer produces). A file the user keeps in a managed directory is not this tool's output, so it
1011
+ is neither reported nor followed; a repository may keep its own commands and its own skill
1012
+ directories. The exceptions are an extra file inside a recorded or planned skill directory
1013
+ (`W107`) and a missing lockfile, which refuses rather than guessing (see *A missing lockfile*). A
1014
+ symlink at a *managed* path is still drift, and a symlinked ancestor is still refused.
1015
+ - **The hooks plugin is verified by structure, with one provenance gap.** Containment compares the
1016
+ commands, events and matchers the plugin registers. rulesync escapes a hook command for a template
1017
+ literal (backslashes doubled, backticks and `${` prefixed with a backslash); the gate undoes that
1018
+ escaping in the inverse order before comparing, because it is the renderer's representation of the
1019
+ same command. Each command's matcher is read from the slice between the previous command and this
1020
+ one, so a matcher-less hook cannot inherit a neighbour's guard and a dropped matcher cannot be
1021
+ replaced by an earlier identical one. The parser matches rulesync 43.11.0's two registration shapes
1022
+ and cannot recognise a registration emitted as a template literal under a future renderer, so a
1023
+ plugin that keeps the same commands but changes its registration shape is caught only by `check`
1024
+ against a fresh render of the pinned renderer. A change to rulesync's generated helper code that
1025
+ keeps the same registrations is likewise caught only by `check`, not by a committed plugin
1026
+ golden.
1027
+ - **Skill extra files must be UTF-8.** The managed-output pipeline compares and writes text, so a
1028
+ binary asset inside a skill directory is refused (F001) rather than carried; decoding and
1029
+ re-encoding a valid UTF-8 file is byte-identical.
1030
+
1031
+ ## Behaviour notes
1032
+
1033
+ These are the deliberate choices a reader of the harness documentation may not expect. Each is
1034
+ rendered by the pinned renderer and verified before a byte is written.
1035
+
1036
+ - **Personas are YAML; config and permission resources are JSONC.** Config and permission files
1037
+ reject duplicate keys. Persona files are `.farna/personas/*.yaml`.
1038
+ - **A permission resource may declare `patterns`.** A resource can carry
1039
+ `patterns: { "<category>": { "<pattern>": "allow" | "ask" | "deny" } }` in addition to its bare
1040
+ category values, which emits the harness's `Bash(P)` / `Edit(P)` byte form. A numeric pattern key
1041
+ is refused because JavaScript would reorder it.
1042
+ - **A permission resource's identity is its declared `id`, not its file name.** Two permission
1043
+ files may declare the same id: identical content is deduplicated, different content is
1044
+ `F005_CONFLICT` naming both paths. A rule's identity is its file name.
1045
+ - **A model conflict is detected on the resolved concrete model id.** Two model classes that map to
1046
+ the same id do not conflict; two classes that resolve to different ids do.
1047
+ - **The OpenCode per-agent `task` category is authored as `task`.** The V2 raise path translates
1048
+ `task` to `subagent`; authoring `agent` would emit a record OpenCode does not read.
1049
+ - **An unrepresentable OpenCode hook is a reported loss, not an omission.** `session-end`, or a
1050
+ matcher on a non-tool event, is reported as `W101_CAPABILITY_DROPPED` and is not emitted.
1051
+ - **`"allowlist": true` is refused on OpenCode.** OpenCode's records are a deny-list and cannot
1052
+ name every unmodelled tool, so the Claude Code allow-list opt-in has no faithful representation.
1053
+ - **Profile mode is OpenCode-only in this release.** `claudecode` refuses `active` rather than
1054
+ accepting a setting that does nothing.
1055
+ - **The lockfile field is `activePersona`.** `mode` is `agent` or `profile`; `notLive` records the
1056
+ resolved-but-not-live personas. Both the mode and the selection are optional on read, so a
1057
+ lockfile written before profile mode existed still parses and is normalised to agent mode.
1058
+ - **`opencode.jsonc` is structured, not whole-file.** It owns the `mcp` key only and edits it in
1059
+ place, preserving the user's own keys and comments.
1060
+ - **Orphan removal is limited to recorded regular files in managed locations.** A symlink, a
1061
+ directory, an edited file or an unrecorded user file is never removed.
1062
+
1063
+ ## Develop
1064
+
1065
+ ```sh
1066
+ npm ci
1067
+ npm run lint
1068
+ npm run typecheck
1069
+ npm test
1070
+ npm run build
1071
+ npm audit --audit-level=moderate
1072
+ node scripts/assert-pack.mjs # the tarball is dist/ plus the legal files, with no source map
1073
+ npm pack --dry-run # the exact package npm would publish
1074
+ npm publish --dry-run # the publish path, without publishing
1075
+ ```
1076
+
1077
+ `npm run build` compiles `src/` to `dist/`. After a build, run the CLI with
1078
+ `node dist/cli/main.js`, or link it with `npm link` to get the `farna-bootstrapper` binary.
1079
+
1080
+ The golden tests in `tests/golden/`, the real-renderer tests in `tests/integration/` and the
1081
+ example tests in `tests/integration/examples.test.ts` drive the real, pinned renderer. They always
1082
+ run: a missing or broken `rulesync` fails collection loudly rather than skipping. CI compares the
1083
+ test files on disk with the committed `scripts/expected-test-files.json` manifest, requires every
1084
+ manifest file to have run, and fails on either difference — so a deleted suite cannot hide behind
1085
+ the total, and a new suite is a deliberate, visible manifest edit. It also enforces a minimum total
1086
+ test count (not an exact one), that no test is pending or `todo`, that `numPassedTests` accounts for
1087
+ the whole run, and that the real-renderer suites ran. CI also type-checks `tests/`, audits
1088
+ dependencies at `moderate`, and proves that `npm pack` from a tree with `dist/` moved aside still
1089
+ contains the entry points, which can only happen if `prepack` builds them, and that every path in
1090
+ the tarball is on the allowlist with no source map.
1091
+
1092
+ See [CONTRIBUTING.md](CONTRIBUTING.md) for the full gate list and the pull-request expectations.
1093
+ Maintainers publish a release by pushing a `v*` tag; `.github/workflows/release.yml` verifies the
1094
+ tag is on `main`, runs the gates, publishes the packed tarball to npm with provenance, and creates
1095
+ the GitHub Release. The publish job waits for approval on the `release` environment, whose
1096
+ `NPM_TOKEN` secret carries the npm token. See [Releasing](CONTRIBUTING.md#releasing).
1097
+
1098
+ ## Licence
1099
+
1100
+ MIT, Copyright (c) 2026 Farnalabs Ltd. See `LICENSE` and `NOTICE`. Security reports are handled
1101
+ under [SECURITY.md](SECURITY.md). This project depends on
1102
+ [rulesync](https://github.com/dyoshikawa/rulesync) (MIT, Copyright (c) 2024 dyoshikawa), used
1103
+ unmodified as a library; the third-party licence text is reproduced in `NOTICE`.