@ubercode/channelvault 0.2.0 → 0.3.0-rc.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.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,45 @@
2
2
 
3
3
  All notable changes to `@ubercode/channelvault` are documented here. The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and the version follows [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
4
4
 
5
+ ## [0.3.0-rc.1] — 2026-11-27
6
+
7
+ Release candidate, published under the npm `next` tag.
8
+
9
+ ### Changed
10
+
11
+ - **A tree is bound to the server installation it was pulled from.** `pull` records Mirth's installation ID, and `push` refuses a tree from a different or unknown installation, even with `--force`: revision numbers from another server say nothing about this one. A tree pulled with an earlier version has no installation ID, so it needs a fresh pull (with a merge) or `adopt` before its next push. The ID is taken as Mirth gives it: a generated UUID, or any one-line name an admin set in `appdata/server.id` (such as `mirth-gov`), up to 255 characters. A pull whose installation changes while it reads the server is refused.
12
+ - Configuration-map entries are addressed by key, not position (see Fixed). An entry in `channelvault.allow.json` that allowed a finding in a configuration-map field (such as an entry's comment) no longer matches and must be added again.
13
+ - A scoped push reports the channels it redeployed, skipped and failed to redeploy separately, and refuses a redeploy whose deployment status it cannot read.
14
+ - Tree commands hold a lock on the tree, so two commands cannot change it at once.
15
+
16
+ ### Added
17
+
18
+ - `adopt <dir>`: makes a reviewed tree the baseline for another server (promotion) without writing to that server. It keeps the tree's content and placeholders, takes the destination's revisions, leaves destination-only resources alone, and has `--plan-only` and a confirmation.
19
+ - `implode` and `push` pick up new channel, library and channel-group directories without a hand-edit to `server/configuration.json`, including renamed directories. Incomplete new resources and copied ids are refused.
20
+ - README: a short procedure for the first production use.
21
+
22
+ ### Fixed
23
+
24
+ - `pull` and `explode` keep the previous tree until its replacement is complete, and an interrupted run is recovered (from a journal) before the next command reads the tree.
25
+ - `push` and `restore` recheck each resource just before writing or deleting it, and recheck the whole server after taking the backup, so edits made on the server meanwhile are refused instead of overwritten. A scoped push rechecks each channel's deployment just before redeploying it, so a channel an operator undeployed stays undeployed.
26
+ - Saving the code template library list no longer unassigns templates created on the server since the pull; deleting a library that holds such templates is refused.
27
+ - A live configuration that is empty or not shaped like one (an HTTP 200 carrying an error) is refused instead of replacing a healthy tree or feeding a push plan.
28
+ - The printed undo command after a push or restore is complete: it keeps the connection and TLS options and the backup directory, repeats `--overwrite-config-map` when it was used, and quotes arguments for the shell. `--overwrite-config-map` is refused on a scoped push.
29
+ - `diff` and the push plan compare a code template's context types as a set (Mirth lists them in a different order on each server), and treat a channel's tags and dependency links as the same whether null or absent. A tree pulled from one server no longer shows every library and channel as modified against another.
30
+ - A re-pull no longer gives configuration-map entries each other's placeholders after an earlier entry is removed from the server. Entries were addressed by position, so each one after the removed entry inherited its neighbour's placeholder name (the values in the env file stayed with the right entry). Entries are now addressed by key. A tree pulled with an affected version keeps the wrong names on re-pull: pull it into a fresh directory to regenerate them.
31
+
32
+ ## [0.2.1] — 2026-09-29
33
+
34
+ ### Fixed
35
+
36
+ - `diff` compares content: revision numbers and timestamps, which Mirth bumps on any save or restore, no longer count as differences; `diff --json` lists them as `staleRevisions`.
37
+ - Channels whose names collide once made into directory names (`Lab Feed`, `LAB FEED`) keep their directories when the server lists them in another order, as it does after a restore.
38
+ - `push` no longer refuses to update one of two channels that already share a name on the server (Mirth allows `Lab Feed` beside `LAB FEED`); only a new name or a rename is checked.
39
+
40
+ ### Added
41
+
42
+ - Tests on a production-shaped synthetic mesh (on real Mirth 4.5.2 too) and on 36 public exports from Mirth 3.0 to OIE 4.6.
43
+
5
44
  ## [0.2.0] — 2026-09-29
6
45
 
7
46
  ### Added
@@ -23,5 +62,7 @@ First release. Tested against Mirth Connect 4.5.2; the offline round trip is als
23
62
  - `backup` / `restore`: the server's own configuration XML saved as `.backup/<server>-<UTC time>.xml`, identified by Mirth's server ID, restored with a preview, an undo backup and a version check. `push` backs up first unless `--no-backup`.
24
63
  - `diff` exits 0 when the tree matches the server, 1 when it differs, 2 on error.
25
64
 
65
+ [0.3.0-rc.1]: https://github.com/MichaelLeeHobbs/channelvault/releases/tag/v0.3.0-rc.1
66
+ [0.2.1]: https://github.com/MichaelLeeHobbs/channelvault/releases/tag/v0.2.1
26
67
  [0.2.0]: https://github.com/MichaelLeeHobbs/channelvault/releases/tag/v0.2.0
27
68
  [0.1.0]: https://github.com/MichaelLeeHobbs/channelvault/releases/tag/v0.1.0
package/README.md CHANGED
@@ -15,6 +15,12 @@ npm install -g @ubercode/channelvault # then: channelvault --help
15
15
  npx @ubercode/channelvault --help # or run it without installing
16
16
  ```
17
17
 
18
+ 0.3.0 is in release candidates, published under the `next` tag; `latest` stays on 0.2.1 until 0.3.0 is final:
19
+
20
+ ```
21
+ npm install -D @ubercode/channelvault@next
22
+ ```
23
+
18
24
  ## How it works
19
25
 
20
26
  Everything centers on one in-memory representation, the **canonical config**: a plain JSON object mirroring Mirth's `serverConfiguration` document. Two adapters produce it:
@@ -35,7 +41,8 @@ The exploded tree is a projection, not a re-derivation: config is stored verbati
35
41
  - `test/xml.test.ts`, `test/xml.robustness.test.ts`: XML parse/build fixed point, entity and whitespace handling, document order, unexpected XML
36
42
  - `test/explode.test.ts`, `test/explode.paths.test.ts`: `implode(explode(c))` deep-equals `c`, byte-identical sidecars, file naming
37
43
  - `test/e2e.test.ts`: the whole pipeline on a Mirth-exported fixture (`test/fixtures`, synthetic; `test/fixtures.guard.test.ts` rejects real exports)
38
- - `test/third-party-fixtures.test.ts`: the same pipeline on mirthsync's Mirth 3.8, 4.0.1 and OIE 4.5.2 exports (`test/fixtures/third-party/mirthsync`, EPL-1.0, pinned by hash in its `SOURCE.md`)
44
+ - `test/third-party-fixtures.test.ts` and `test/third-party-corpus.test.ts`: the same pipeline on public exports from Mirth 3.0 to OIE 4.6 (mirthsync, Open Integration Engine, NextGen's FHIR examples and six other projects; `test/fixtures/third-party/<source>/`, each pinned by hash in its `SOURCE.md` with its license)
45
+ - `test/mesh.test.ts`: a synthetic, production-shaped routing mesh (`test/fixtures/serverConfiguration.mesh.xml`: 26 channels, an 18-destination hub, a 10,000-line code template, attachment handlers), generated by `scripts/fixtures/generate-mesh.ts` and exported by Mirth after every channel deployed (`node scripts/fixtures/build-mesh.mjs`)
39
46
 
40
47
  ## Layout produced by `explode` / `pull`
41
48
 
@@ -74,16 +81,18 @@ channelvault restore [file] # backup -> live server (default: ne
74
81
 
75
82
  `channelvault <command> --help` lists the flags. Server connection comes from flags or `MIRTH_HOST`, `MIRTH_PORT`, `MIRTH_USER`, `MIRTH_PASS`; prefer the env var over `--pass`, which shows up in process listings. Mirth's default certificate is self-signed; `--insecure` accepts it by turning verification off.
76
83
 
77
- `diff` exits 0 when the tree matches the server, 1 when they differ, and 2 on any error (including a bad flag), so a scheduled drift check can tell drift from an outage.
84
+ `diff` exits 0 when the tree matches the server, 1 when they differ, and 2 on any error (including a bad flag), so a scheduled drift check can tell drift from an outage. It compares content: Mirth bumps revision numbers and timestamps on any save (even an unchanged one in the Administrator) and on a restore, so those are reported as a note ("pull to update the tree's baseline") and don't count as differences.
78
85
 
79
86
  For scripts, CI and AI agents, `status`, `diff` and `push --plan-only` take `--json` and print one JSON document on stdout; errors still go to stderr with the usual exit code.
80
87
 
81
88
  - `status --json`: `{ root, source, pulledAt, engineVersion, counts }`.
82
- - `diff --json`: `{ clean, files: [{ path, change }], secretDrift, notes, patch }`, where `change` is `modified`, `only-in-tree` or `only-on-server` and `patch` is the redacted unified diff.
89
+ - `diff --json`: `{ clean, files: [{ path, change }], secretDrift, staleRevisions, notes, patch }`, where `change` is `modified`, `only-in-tree` or `only-on-server` and `patch` is the redacted unified diff.
83
90
  - `push --plan-only --json`: `{ target, mode, changes: [{ kind, op, id, label }], conflicts, serverOnly, notPushed, wouldStop }` (plus `redeploy` and `notRedeployed` with `--deploy`). `wouldStop` lists what would refuse a real push with the same flags, such as unconfirmed deletions or conflicts.
84
91
 
85
92
  `pull` and `explode` replace `server/`, `channels/`, `codeTemplates/` and `channelGroups/` in `<dir>`, so they refuse a directory that has any of those but no `channelvault.json`, an unreadable `channelvault.json`, or a `--dotenv` file inside one of those directories. All of this is checked before anything is written.
86
93
 
94
+ Replacement is staged with its metadata, ignore rules, secret history and env updates. The previous generation is retained until every swap completes; a failed swap rolls back the whole generation. After an interrupted process, the next tree command recovers the journal before reading the tree (use the same `--dotenv` selection; `status` accepts it too). Commands hold a working-tree lock, including readers. A live lock refuses another command; abandoned locks belonging to a dead process on this host are recovered. An unreadable lock or a lock from another host requires inspection before removal. The env file may be on another volume and is replaced through files beside it.
95
+
87
96
  ## Secrets and per-environment values
88
97
 
89
98
  `explode` and `pull` keep the credentials they detect out of the tree. Detection is heuristic (see below), so review a first pull of a real server before committing it. Fields named like credentials (passwords, passphrases, passcodes, tokens, secrets, API/access/private keys, and DICOM's `keyPW`, `keyStorePW` and `trustStorePW`), and every configuration-map value, become `{{env:NAME}}` placeholders, and their values go to `<dir>/.env`, which is added to the tree's `.gitignore`. `push` and `implode` fill the placeholders back in and refuse to run if any are missing, naming each one.
@@ -111,14 +120,17 @@ channelvault push ./mirth --channel "ADT Router" # just this channel (re
111
120
  channelvault push ./mirth --library Formatting --deploy # one library, then redeploy the channels using it
112
121
  ```
113
122
 
114
- - **Copies**: every channel, library and code template is saved by its `id`, and a copied directory keeps its source's. `push` refuses a tree where two resources share an id, and a save under a name another channel holds (case-insensitive), even one a delete or rename in the same push frees: push that delete or rename first. Give a copy a new UUID.
115
- - **Deletions** (a channel directory or template you removed) need `--allow-deletes`. Something created on the server since your last pull is never treated as a deletion; `push` leaves it alone and says so.
123
+ - **Copies**: `implode`, `diff`, and `push` discover new `channels/<folder>/channel.json`, `codeTemplates/<folder>/library.json`, and `channelGroups/<name>.json` files; no manual skeleton reference is needed. Code sidecars are still included through their `@file` markers. Every channel, library and code template is saved by its `id`, and a copied directory keeps its source's. Give each copy a new UUID and name, and give copied templates new IDs too. Duplicate IDs and resource paths outside the tree are refused. `push` also refuses a save under a name another channel holds (case-insensitive), even one a delete or rename in the same push frees: push that delete or rename first.
124
+ - **Deletions** (a channel directory or template you removed) need `--allow-deletes`. Something created on the server since your last pull is never treated as a deletion; `push` leaves it alone and says so. Library saves retain server-only templates and their membership, including with `--force`. Deleting a library containing unfamiliar templates is refused; pull and review them first.
116
125
  - **Conflicts**: if the server's copy has a newer revision than your tree (someone saved it in the Administrator since your last pull), `push` refuses. Pull, merge in git, and push again, or pass `--force`.
117
- - **`--deploy`** redeploys the channels that changed and the channels a changed code-template library is enabled for, but only those deployed on the server right now; it never starts a channel someone took down. Failures are reported per channel.
126
+ Push rechecks its plan after the backup and checks each resource immediately before saving or deleting it. These checks include content changes and revision resets, and library-list saves check every library. Restore and whole-server push also recheck after their backup. The check and write are separate API requests: use a single-writer change window to exclude Administrator edits and other deployment clients during production writes.
127
+ - **Installation baseline**: `pull` records Mirth's installation ID. Push refuses a different or unknown installation even with `--force`; revision numbers from another server are unrelated. For promotion, copy the tree, select destination credentials with `--dotenv`, review `channelvault adopt ./mirth --dotenv .env.prod --plan-only`, then run the same command with `--yes` instead of `--plan-only`. Adoption writes no server resources: it preserves local content and placeholders, captures destination revisions and the global-script baseline, and leaves destination-only resources unfamiliar. It rechecks the target before committing the local baseline. Review `push --plan-only` again before pushing. Older trees without an installation ID require a fresh pull with a merge, or this explicit adoption.
128
+ - **Snapshots**: live reads require the configuration wrapper, an engine version, and a valid channels collection. Present library, template and group collections are checked too. Empty or malformed success responses are refused before tree replacement or push planning; valid empty collections and plugin fields are preserved.
129
+ - **`--deploy`** redeploys the channels that changed and the channels a changed code-template library is enabled for, but only those deployed when planning and still deployed immediately before their redeploy. Channels taken down during the push are skipped and reported. Status-read failures prevent that channel's redeploy and are reported per channel. Keep a single-writer change window: Mirth's status check and deployment are separate requests.
118
130
  - After a push the tree's revision numbers are updated from the server, so `diff` and the next `push` stay clean.
119
131
  - Server settings, the configuration map, channel groups and tags are **not** pushed; `push` names them if they differ. `--whole-server` replaces the entire server configuration instead. It shows the same change list and needs the same `--allow-deletes` / `--force`, and it can't be combined with `--channel` or `--library`.
120
132
  - A tree exploded from an XML backup is refused (its shape differs from the live API's); `--ignore-origin` overrides that.
121
- - Before it changes anything, `push` backs up the server (see below) and prints the `restore` command that undoes it. `--no-backup` skips that.
133
+ - Before it changes anything, `push` backs up the server (see below) and prints a configuration undo command with the original target, TLS options, user and backup directory. It includes `--overwrite-config-map` when the push overwrites that map. Passwords are omitted; supply the server's credential through `MIRTH_PASS`. `--no-backup` skips the backup. Backups do not capture runtime deployment state; review targeted redeployment separately after a configuration undo.
122
134
  - Without a terminal, `push` needs `--yes`.
123
135
  - `--plan-only` shows the plan and what would stop it, and changes nothing: no prompt, no backup, no writes. It works without a terminal.
124
136
 
@@ -142,10 +154,18 @@ channelvault restore .backup/vns-gov-20260925T143012Z.xml --deploy
142
154
  - The preview says when the restore changes the server's name. `push --whole-server` does too.
143
155
  - A backup from a newer Mirth version is refused; an older one is converted by the server.
144
156
  - It previews the channels and templates it creates, changes and deletes, and asks before continuing (`--yes` without a terminal).
145
- - It saves the server's current configuration first, as a new backup, and prints the command that undoes the restore. That backup is the newest, so a second plain `restore` reverts the first.
157
+ - It saves the server's current configuration first, as a new backup, and prints the command that undoes the restore. That backup is the newest, so a second plain `restore` reverts the saved configuration except an overwritten configuration map: use the printed command, which repeats `--overwrite-config-map` when needed. Runtime deployment state is not captured in a configuration backup.
146
158
  - If the server changes while you confirm, nothing is restored; run it again to review the new state.
147
159
  - `--deploy` redeploys every channel afterwards; `--overwrite-config-map` also replaces the configuration map.
148
160
 
161
+ ## First production use
162
+
163
+ 1. Build and pin the reviewed revision. The integration suite exercises Mirth 4.5.2; rehearse on your own Mirth version and installed plugins in staging, with isolated connectors and destination credentials.
164
+ 2. Start with `pull`, `status`, `diff` and `push --plan-only --json`. Pull into a fresh directory, or commit/stash local edits first: pull replaces configuration content and does not merge edits. Commit the resulting tree while keeping env files and backups private.
165
+ 3. Rehearse a scoped edit and its printed configuration undo in staging. If a change overwrites the configuration map, verify that undo restores it too. Check deployed channels and message behavior separately, since configuration backups do not capture runtime state.
166
+ 4. For the first production write, use a single-writer change window and one noncritical channel with `push --channel <name>`. Review the target and plan, keep the automatic backup, and use the normal conflict checks. Promotion to another installation requires reviewed `adopt` first.
167
+ 5. After writing, inspect `diff` and the next push plan, and verify behavior in Mirth. Expand the scope after the pilot succeeds. A scoped push can stop after some resources are saved; inspect its applied count and failure before retrying or using the backup.
168
+
149
169
  ## Using channelvault with an AI agent
150
170
 
151
171
  An agent can safely edit a tree and check its work. Pushing, restoring and anything that needs `--force` should stay with a person, who reads the plan first. Paste this into the agent instructions of your configuration repository (`AGENTS.md`, `CLAUDE.md` or similar) and adjust the paths:
@@ -156,7 +176,7 @@ An agent can safely edit a tree and check its work. Pushing, restoring and anyth
156
176
  `mirth/` is a channelvault tree of our Mirth Connect server. Channel scripts are the `.js` files under `mirth/channels/<channel>/`, settings are in `channel.json`, and code templates are under `mirth/codeTemplates/<library>/`.
157
177
 
158
178
  - Edit the `.js` and `.json` files; leave `id`, `revision`, `channelvault.json` and the `{"@file": …}` / `{"@ref": …}` markers alone. A new channel or template needs its own new UUID for `id`; a copied directory keeps the old one.
159
- - Mirth runs these scripts in Rhino, not Node: no template literals, `async`/`await`, optional chaining (`?.`), classes, `require` or `import`.
179
+ - Mirth runs these scripts in Rhino, not Node: no `async`/`await`, optional chaining (`?.`), classes, `require`, `import` or shorthand object properties (`{ status }`; write `{ status: status }`). `let`, `const` and arrow functions work.
160
180
  - `{{env:NAME}}` is a placeholder for a secret kept outside git. Never replace one with a real value, and never read, print or copy `.env`, `.secrets/` or `.backup/`.
161
181
  - Check your work with `channelvault diff mirth --json` (exit 0: matches the server, 1: differs) and `channelvault push mirth --plan-only --json`, which shows what a push would change and `wouldStop` reasons.
162
182
  - Do not run `channelvault push` (other than with `--plan-only`), `restore` or `pull`, and never pass `--force`, `--allow-deletes` or `--yes`. Summarise the plan and let a person push.
@@ -170,9 +190,9 @@ MIRTH_HOST=localhost MIRTH_PORT=8443 MIRTH_USER=admin MIRTH_PASS=admin \
170
190
  channelvault pull ./work --insecure
171
191
  ```
172
192
 
173
- To try channelvault on a **real** configuration, use `docker compose -f docker-compose.isolated.yml up -d` instead: the same server with no outbound network (a deployed channel cannot reach anything), startup deploy off, and port 8443 on localhost only. `down` deletes it and everything in it.
193
+ To try channelvault on a **real** configuration, use `docker compose -f docker-compose.isolated.yml up -d` instead: the same server with no outbound network (a deployed channel cannot reach anything), startup deploy off, and port 8443 on localhost only. `down` deletes it and everything in it. It gives Mirth a 2 GB heap: with the image's default 256 MB, restoring a real configuration fails with out-of-memory errors that show only in `/opt/connect/logs/mirth.log`, not in the Administrator.
174
194
 
175
- `pnpm test:integration` creates two disposable Mirth 4.5.2 servers on random localhost ports, imports only the synthetic fixture, and drives the CLI through a promotion with different destination credentials and independent revision history. It verifies conflict refusal, an explicit override, preserved tags and unrelated channels, and a clean repeat push. It removes its containers and network on success or failure. Docker is required; unavailable servers fail the command.
195
+ `pnpm test:integration` creates two disposable Mirth 4.5.2 servers on random localhost ports and runs two suites. The mesh suite loads the production-shaped mesh and checks that a pull converges (nothing to push, no diff) before and after scoped pushes, a redeploy and a restore. The promotion suite imports the synthetic fixture and drives the CLI through a promotion with different destination credentials and independent revision history. It verifies installation refusal, reviewed target adoption, preserved tags and unrelated channels, and a clean repeat push. It removes its containers and network on success or failure. Docker is required; unavailable servers fail the command.
176
196
 
177
197
  `test/integration/live.test.ts` is an optional additional suite for a disposable server you manage yourself. It runs when `MIRTH_HOST` is set; connection failures fail the suite. It writes the server configuration, so do not point it at a production or shared server.
178
198