Archive Questions

The four questions each kind's module answers so lnk archive can export and import its things. The archive module asks them, and the module layout.toml's [owners] names for the kind answers them.

Who Answers

A module owning a kind lists the four in its module.toml, as answers = ["archive.check", "archive.running", "archive.missing", "archive.adopt"], and answers each through its hidden lnk-<module> --link-answer <question> flag, one JSON line in and one out, each stating its protocol version (Questions). A kind whose module isn't installed, or doesn't answer all four, isn't exported or imported. Every answer reads and writes files alone: no network call, nothing started or stopped.

The Thing Asked About

Every question names a thing (Thing): its kind, its name and its folders, absolute, each by the key of the location it's a folder of:

{"kind": "agent", "name": "main", "folders": {"link.agents": "/home/me/Link/Agents/main", "link.agent-settings": "/home/me/Link/Safe/Agents/main"}}

At export, they're the thing's folders here. At import, archive.check is asked of the folders staged in ~/.lnk/data/archives, and the others of the folders in place, under the name chosen.

archive.check

Reads the thing's files with their owning types, refusing what they refuse, or what its files alone don't carry whole. It answers {}, or fails, saying why on stderr, which refuses the export or the whole import.

archive.running

Whether the thing is running here, so export refuses it: {"stop": "lnk agent stop --agent main"} while it runs, the command that stops it, else {}.

archive.missing

What an imported thing still needs to run here, read from its files, each with the one command that sets it up, which import names and never runs: {"needs": [{"what": "Telegram", "setup": "lnk agent connect telegram"}]}.

archive.adopt

Writes the owner's records in ~/.lnk for a thing that arrived in its folders, as a new thing, under the name chosen. It's asked {"thing": ..., "was": "main"}, was the name in the archive, and answers what to tell you and the command that starts it: {"notes": [], "next": "lnk agent start --agent work"}. When it fails, import removes the folders it placed.