Read the house before designing one: miakapp discover - #12
Merged
Merged
Conversation
The guide tells an agent to characterize an existing installation before writing anything, and then leaves it to do that by hand. Most houses arriving at V4 already run Node-RED with the v3 MiakAPI nodes, and their flows export already answers most of the questions: which brokers exist, which topics the devices actually use, which variables were committed, which actions users could invoke and who was allowed to invoke them. `miakapp discover --flows <path>` reads that export offline and turns it into an inventory. It needs no project file and no Home Key, because the house it reads has no V4 project yet. Three things it will not do. It never opens a socket or writes back into the export. It never drops a node silently: every type it does not model is counted and reported, so the reader knows what the inventory missed. And it never guesses which actions are physically consequential -- it lists them all and leaves that judgement to the reader. Four findings decide work that is otherwise discovered late: - the v3 initMiakapi node declares coordSecret in its defaults rather than its credentials, so Node-RED stores that secret in cleartext in flows.json instead of the encrypted flows_cred.json. If it is there, it is leaked. - the v3 handler allows an action outright when its node lists no group, so an empty allowedGroups is a grant to every signed-in user, not a deny. - a v3 name that V4 would reject has to be renamed while nobody depends on it. - a topic holding # or + is a subscription pattern, not one device. Field names come from the two real schemas: Node-RED core mqtt in, mqtt out and mqtt-broker, and the node-red-contrib-MiakAPI v3 node definitions. No real export was available to test against, so the parser recognizes nodes by type and reads only fields it knows.
This was referenced Sep 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #11 (
mathieu/agent-guide), which is itself stacked on #10. Merge order: #10, then #11, then this. Base is deliberatelymathieu/agent-guide, notmain: this editsdocs/agent-guide.md§3 andpackages/cli, neither of which exists onmain.Roadmap item F.3, discovery workflow for existing hosts, brokers, flows, devices, and services.
The gap
docs/agent-guide.md§3 tells an agent to characterize the installation before designing anything — brokers, what each device reports, what is measured versus commanded, what is physically consequential — and then leaves it to do all of that by hand. Most houses arriving at V4 already run Node-RED with the v3 MiakAPI nodes, and their flows export already answers most of those questions.What this adds
miakapp discover --flows <path>reads a Node-RED flows export offline and reports:initMiakapihome bindings;commitVariablespath as a V4 state candidate, with where its value came from (jsonata,env, literal);onUserActionid as a V4 function candidate, with the groups allowed to invoke it;sendPushNotifnode, with the audience it targeted;It needs no project file and no Home Key: the house it reads has no V4 project yet.
The two findings worth reading the diff for
secret_in_export. The v3initMiakapinode declarescoordSecretin itsdefaults, not in itscredentials(miakapi.html). Node-RED encryptscredentialsintoflows_cred.json;defaultsgo intoflows.jsonin cleartext. So every v3 house that ever exported its flows has its coordinator secret in that file. The command reports that one is present and never prints its value — there is a test asserting the secret string appears nowhere in the JSON output.unrestricted_action. The v3 handler setsallowed = trueoutright when a node lists no group (miakapi.js). An emptyallowedGroupsis therefore a grant to every signed-in user, not a deny. Porting one of those to V4 without noticing would silently widen an authorization boundary.Three things it deliberately does not do
Limits
No real V3 export was available in this workspace to test against. Field names come from the two real schemas — Node-RED core
mqtt in/mqtt out/mqtt-broker, and thenode-red-contrib-MiakAPIv3 node definitions — but the parser is deliberately tolerant: it recognizes nodes bytype, reads only fields it knows, and reports everything else. Running it against one realflows.jsonfrom the reference installation is the check I could not do.--flowstakes a path rather than stdin, and the byte ceiling is on the file rather than on structure (the strict parser ininternal/json.tsis bounded at 2,048 values for untrusted control-plane responses, which a real house exceeds in its first tab).Verification
bun run check— 244 pass, 0 fail, exit 0bun run check:packages— CLI 56 pass, component 38 pass, template 8 pass, exit 0