vacant.cli¶
Console-script entrypoint declared in pyproject.toml as
vacant = "vacant.cli:main". Each subcommand maps to a function in
vacant.cli.commands; local key / logbook persistence lives in
vacant.cli.local_store.
commands
¶
Wired CLI commands.
Each command in this module replaces the _NOT_YET stub that shipped
with P0. The local-state store at ~/.vacant/<name>/ is owned by
vacant.cli.local_store; HTTP work goes through httpx.AsyncClient
against a registry URL (env VACANT_REGISTRY_URL or --registry).
A few commands (call, attest) require remote endpoints that ship
with PR-β (vacant serve + the wired-up /v1/submit_attestation).
Those subcommands degrade gracefully with a clear not available
yet exit code so the help surface is complete and a future PR can
enable them in place. F4 acceptance only requires the commands to run
end-to-end — the remote-only features have explicit pending tickets.
init_cmd
¶
init_cmd(name: str, insecure_demo: bool = Option(False, '--insecure-demo', help='Store the Ed25519 seed in plaintext key.json (mode 0600) instead of the OS keyring. Demo / CI use only — see SECURITY.md.')) -> None
Create a fresh keypair + seed logbook for name. (P2)
Writes ~/.vacant/<name>/{key.json,logbook.jsonl,meta.json} with
file mode 0600 on the key. The Ed25519 seed is stored in the OS
keyring by default (Keychain / Secret Service / Credential
Locker); pass --insecure-demo to fall back to plaintext on
hosts without a keyring backend.
Source code in src/vacant/cli/commands.py
status_cmd
¶
Show local vacants and their lifecycle states. (P1)
Source code in src/vacant/cli/commands.py
heartbeat_cmd
¶
heartbeat_cmd(name: str | None = Option(None, '--name', help='Local vacant name; defaults to VACANT_NAME.')) -> None
Manually trigger a heartbeat tick. (P1)
Source code in src/vacant/cli/commands.py
publish_cmd
¶
publish_cmd(capability: str = Option(..., '--capability', help='Capability text to advertise.'), endpoint: str | None = Option(None, '--endpoint', help='A2A endpoint URL.'), registry: str | None = Option(None, '--registry', help='Registry URL.'), name: str | None = Option(None, '--name', help='Local vacant name.'), base_model: str | None = Option(None, '--base-model', help="Base model identifier (e.g. 'claude-sonnet-4-6'). On the first publish, omitted → defaults to 'unknown'. On a republish, omitted → preserves the stored value (Pfix3 F2)."), base_model_family: str | None = Option(None, '--base-model-family', help="Base model family (e.g. 'claude'). Same null-vs-default semantics as --base-model.")) -> None
Flip LOCAL → ACTIVE (publish halo to registry). (P4)
Source code in src/vacant/cli/commands.py
unpublish_cmd
¶
Flip ACTIVE → LOCAL (visibility=NONE). (P4)
Note: this only flips the local meta; the registry record is
not revoked over HTTP yet (the /v1/revoke_halo endpoint
requires a P6 envelope, see rpc.py). Use the python
vacant.registry.halo.revoke_halo API for full withdrawal.
Source code in src/vacant/cli/commands.py
lineage_cmd
¶
lineage_cmd(vid: str, direction: str = Option('ancestors', '--direction', help='ancestors | descendants'), depth: int = Option(8, '--depth', min=1, max=32), registry: str | None = Option(None, '--registry', help='Registry URL.')) -> None
Print the parent_id chain for vid. (P4)
Source code in src/vacant/cli/commands.py
attest_cmd
¶
attest_cmd(target_vid: str, claim: str, name: str | None = Option(None, '--name', help='Local vacant name.')) -> None
Issue a peer attestation about target_vid. (P2)
Signs a PeerAttestation and stores it in
~/.vacant/<name>/attestations_issued.jsonl. The HTTP relay to
the registry's /v1/submit_attestation endpoint lands in PR-β
(the endpoint is currently a P6-envelope stub).
Source code in src/vacant/cli/commands.py
call_cmd
¶
call_cmd(vid: str, capability: str, text: str = Option('ping', '--text', help='Body text to send.'), registry: str | None = Option(None, '--registry', help='Registry URL.'), name: str | None = Option(None, '--name', help='Local vacant name.')) -> None
Send a request to a remote vacant. (P6)
Looks up the target's CapabilityCard via the registry's
/v1/capability_card/<vid> endpoint and dispatches a signed
envelope to card.endpoint. The --endpoint direct-known mode
lands with PR-β alongside vacant serve's /card route.
Source code in src/vacant/cli/commands.py
494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 | |
serve_cmd
¶
serve_cmd(port: int = Option(8443, '--port', '-p', help='HTTP bind port.'), host: str = Option('127.0.0.1', '--host', help='HTTP bind host.'), name: str | None = Option(None, '--name', help='Local vacant name.'), mcp: bool = Option(False, '--mcp', help='Also expose an MCP stdio server.'), endpoint: str | None = Option(None, '--endpoint', help='Public endpoint URL to advertise in /card (defaults to meta.endpoint).'), public: bool = Option(False, '--public', help="Bind 0.0.0.0 instead of 127.0.0.1 so external machines can reach this vacant. Implies you've thought about firewall + TLS (use --tls-cert/--tls-key or a reverse proxy like Caddy)."), tls_cert: Path | None = Option(None, '--tls-cert', help='PEM-encoded TLS certificate. When set, uvicorn serves HTTPS.'), tls_key: Path | None = Option(None, '--tls-key', help='PEM-encoded TLS private key. Must be set together with --tls-cert.'), substrate: str | None = Option(None, '--substrate', help='LLM substrate this vacant uses to answer inbound A2A calls. mock | deterministic | anthropic | openai | ollama | gemini | mistral. Default: pure echo (no LLM).')) -> None
Start an HTTP A2A server for the local vacant. (P6)
The server listens on host:port and accepts inbound A2A
message/send requests at /a2a/message/send. The default
behaviour callback echoes the request text back, signed by the
vacant's own key — sufficient for the live-network acceptance test.
--mcp additionally launches an MCP stdio server in a worker
thread. This is what closes the "嫁接到客戶端" thesis claim: the
same vacant accepts both A2A HTTP and MCP stdio simultaneously.
--public flips the bind host from 127.0.0.1 to 0.0.0.0 so machines
on your LAN (or the public internet, if you've configured port
forwarding / Cloudflare Tunnel / Tailscale / etc.) can reach this
vacant. By default vacant serve only listens on loopback — this
flag is an explicit acknowledgement that you've thought about how
callers reach you and whether you need TLS.
--tls-cert + --tls-key pin a PEM cert + key pair so uvicorn
serves HTTPS directly. Useful for Tailscale-internal hostnames
where Tailscale already issues the cert. For public domains the
saner pattern is to terminate TLS in Caddy / nginx / Cloudflare
and leave this vacant on plain HTTP behind it — see
docs/DEPLOY_PUBLIC.md.
Source code in src/vacant/cli/commands.py
615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 | |
grow_cmd
¶
grow_cmd(port: int = Option(8443, '--port', '-p', help='HTTP bind port.'), host: str = Option('127.0.0.1', '--host', help='HTTP bind host.'), name: str | None = Option(None, '--name', help='Local vacant name.'), endpoint: str | None = Option(None, '--endpoint', help='Public endpoint URL to advertise.'), peer_review_period_s: float = Option(30.0, '--peer-review-period', help='Seconds between peer-review ticks.'), redteam_every_n: int = Option(4, '--redteam-every-n', help='Inject a red-team probe every Nth tick (0 = never).'), heartbeat_every_n: int = Option(2, '--heartbeat-every-n', help='Append a heartbeat to our logbook every Nth tick (0 = never).'), substrate: str | None = Option(None, '--substrate', help='LLM substrate this vacant uses to ANSWER incoming probes. mock | deterministic | anthropic | openai | ollama | gemini | mistral. Default: pure echo (no LLM). Real substrates need an API key.'), scorer_substrate: str | None = Option(None, '--scorer-substrate', help='LLM substrate this vacant uses to SCORE peers (3D: F/L/R per spec). Same value space as --substrate. Default: length-based heuristic. Recommended different from --substrate for cross-model diversity. Honesty + adoption come from separate channels and are NOT in the peer-review path (see architecture/components/P3_reputation.md).'), review_all_per_tick: bool = Option(False, '--review-all-per-tick', help='Every tick, review EVERY sibling instead of rotating one-per-tick. Cost is O(peers) per tick; recommended for small local networks (<= ~10 vacants) where you want tight coverage. Default is rotation mode which converges to all-peers coverage at O(1)/tick.')) -> None
Serve A2A and run the local-network grow loop.
Identical to vacant serve plus a background async task that
periodically peer-reviews siblings under the same VACANT_HOME,
injects red-team probes, and appends heartbeats to our own
logbook. Multiple vacant grow processes on the same machine
form a fully signed local vacant network — no central arbiter.
Quick start (one terminal per vacant):
vacant init alice
vacant init bob
vacant init carol
vacant grow --name alice --port 8443 &
vacant grow --name bob --port 8444 &
vacant grow --name carol --port 8445 &
# then watch ~/.vacant/
Source code in src/vacant/cli/commands.py
766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 | |
route_cmd
¶
route_cmd(prompt: str = Argument(..., help='The user task / question.'), name: str = Option('alice', '--name', help='Local vacant name to host the MCP server.'), model: str = Option('gemma4:e2b', '--model', help='Model id at the OpenAI-compatible endpoint.'), base_url: str = Option(None, '--base-url', envvar=['LLM_BASE_URL', 'OLLAMA_BASE_URL'], help='OpenAI-compat base URL (must include /v1).'), api_key: str = Option('', '--api-key', envvar=['LLM_API_KEY', 'OLLAMA_API_KEY'], help='Bearer token for the LLM endpoint (some, e.g. Ollama, accept any value).'), max_rounds: int = Option(8, '--max-rounds', help='Maximum LLM ↔ tool rounds.'), temperature: float = Option(0.0, '--temperature'), vacant_home: str | None = Option(None, '--vacant-home', envvar='VACANT_HOME', help='Override $VACANT_HOME for the spawned MCP server.'), uvx: str = Option('uvx', '--uvx', envvar='UVX', help='uvx executable to spawn `vacant mcp` with.')) -> None
ReAct-style agent loop for ANY LLM (model-agnostic).
Hermes / OpenClaw / Claude Desktop / Cursor route LLM ↔ Vacant
traffic through OpenAI function-call JSON. Models below ~7B can't
emit that format reliably, so the framework swallows the call.
vacant route is the workaround: a tiny XML-ish action protocol
that any model with /v1/chat/completions can drive.
Example::
LLM_BASE_URL=http://192.168.50.130:11434/v1 \
LLM_API_KEY=ollama \
vacant route --name alice --model gemma4:e2b \
"Translate this technical Chinese paragraph; spawn a D1 child if helpful."
Source code in src/vacant/cli/commands.py
978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 | |
mcp_cmd
¶
mcp_cmd(name: str | None = Option(None, '--name', help="Local vacant name to serve. If `--name <n>` (or env $VACANT_NAME=<n>) is set but `~/.vacant/<n>/` doesn't exist, this command exits with code 2 — it deliberately does NOT fall back to ephemeral mode to avoid silently dropping the audit chain. Run `vacant install <client>` or `vacant init <n>` to bootstrap the identity first.")) -> None
Run the vacant as a pure-stdio MCP server. (D2 / Claude Code plugin)
No HTTP, no worker threads, no uvicorn — the process IS the
MCP server. Spawned by uvx vacant mcp from the
.claude-plugin/plugin.json manifest, which is what Claude Code
calls when a user runs /plugin install vacant. EOF on stdin
(the parent closing the pipe) ends the loop.
Pfix5 runtime contract — identity resolution is strict and side-effect-free:
--name <n>or env$VACANT_NAME=<n>is set:- if
~/.vacant/<n>/exists ⇒ serve as<n> - if missing ⇒ print clear stderr error + exit 2 (does NOT silently fall back; does NOT auto-init)
- no
--nameand no$VACANT_NAME, but exactly one local vacant on disk ⇒ serve as that vacant - no
--name, no$VACANT_NAME, no local vacants ⇒ ephemeral in-memory demo + stderr WARN (this is the explicit "no identity asked for" case, not a fallback)
Why strict on case 1: when a client config pins
VACANT_NAME=alice, the operator intends for that identity to
be used. Falling back to ephemeral would mean the client thinks it
has a persistent vacant alice but every spawn is a fresh keypair —
audit chains, reputation, and the entire responsibility-layer
claim silently collapse. Better to fail loudly + point the
operator at vacant install <client> or vacant init.
Source code in src/vacant/cli/commands.py
1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 | |
install_cmd
¶
install_cmd(client: str = Argument(..., help='MCP client to register vacant with: claude-code | claude-desktop | cursor | windsurf | openclaw | hermes'), config_path: str | None = Option(None, '--config-path', help='Override the default config-file location for this client.'), name: str = Option('alice', '--name', help='VACANT_NAME env var written into the registered MCP entry (picks which `~/.vacant/<name>/` identity the spawned `vacant mcp` uses; defaults to `alice`).'), force: bool = Option(False, '--force', help="Overwrite an existing `vacant` entry in the client's config."), dry_run: bool = Option(False, '--dry-run', help='Print what would be written without touching any file.'), insecure_demo: bool = Option(False, '--insecure-demo', help='When auto-creating identity, store the Ed25519 seed in plaintext key.json (mode 0600) instead of the OS keyring. Demo / CI only — never production responsibility-layer use.'), skip_init: bool = Option(False, '--skip-init', help="Don't auto-create `~/.vacant/<name>/` if missing. Use when you'll bring your own identity (already-init'd elsewhere, or about to `vacant init` manually with custom flags).")) -> None
Register vacant as an MCP server with a local client. (Pfix5)
One unified entry point — the README's per-client one-liners (OpenClaw / Hermes / Claude Desktop / Cursor / Windsurf) all collapse to:
vacant install <client>
Pfix5 contract:
- Setup-phase: this command has side effects. By default it
ALSO bootstraps
~/.vacant/<name>/(runningvacant initfor you with OS-keyring storage) so the runtimevacant mcp --name <name>invocation that the client spawns later actually works. - Idempotent: re-running with no flags is a no-op when the
identity and the config entry both exist.
--forceoverwrites the config entry. Identity init is always skipped if the dir exists. --insecure-demoopts into plaintext key storage (no keyring backend needed).--skip-inittells the installer "I manage the identity"; leaves~/.vacant/<name>/alone.
Source code in src/vacant/cli/commands.py
1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 | |
demo_cmd
¶
demo_cmd(scenario: str, substrate: str = Option('mock', '--substrate', '-s', help='mock | deterministic | anthropic | ollama | openai | gemini | mistral | hermes | openclaw'), seed: int | None = Option(None, '--seed', help='override default seed'), tail: bool = Option(False, '--tail', help='stream demo-store events to stdout instead of running'), db_path: str | None = Option(None, '--db', help='demo store path (default: var/demo.db)')) -> None
Run a demo scenario end-to-end. (P7)
Examples:
vacant demo law_firm vacant demo law-firm --seed=42 # hyphen accepted vacant demo self_replication --substrate=anthropic vacant demo law_firm --tail # tail events from demo store
Source code in src/vacant/cli/commands.py
registry_anchor_cmd
¶
registry_anchor_cmd(epoch_id: int = Argument(..., help='Sealed epoch_id to anchor'), db: str = Option(..., '--db', help='Registry SQLite path'), repo: str = Option(..., '--repo', help='Local transparency-log git repo'), branch: str = Option('transparency-log', '--branch', help='Branch name in the transparency-log repo'), remote: str | None = Option(None, '--remote', help='Optional remote URL (`git push origin <branch>`)'), push: bool = Option(False, '--push', help='Attempt remote push after committing')) -> None
Anchor a sealed Merkle epoch root to a git transparency log.
The git repo is created if absent; epochs/{epoch_id:08d}.json
receives the operator-signed root payload, and git_commit_sha is
persisted back to the MerkleEpoch row.
Source code in src/vacant/cli/commands.py
registry_witness_statement_cmd
¶
registry_witness_statement_cmd(epoch_id: int = Argument(..., help='Sealed epoch_id'), db: str = Option(..., '--db', help='Registry SQLite path')) -> None
Print the canonical witness statement bytes (hex) for epoch_id.
A witness operator hashes + signs this with their Ed25519 key and
returns the cosignature to the registry via witness-cosign.
Source code in src/vacant/cli/commands.py
registry_witness_cosign_cmd
¶
registry_witness_cosign_cmd(epoch_id: int = Argument(..., help='Sealed epoch_id to cosign'), db: str = Option(..., '--db', help='Registry SQLite path'), name: str | None = Option(None, '--name', help='Local vacant whose key acts as the witness'), witness_id: str = Option(..., '--witness-id', help='Witness operator label (free-form, recorded on the row)')) -> None
Sign + persist a witness cosignature on a sealed epoch.
Uses the local vacant's Ed25519 key (from ~/.vacant/<name>/) as
the witness key. The cosignature is verified before insert, so
EpochWitness rows are guaranteed cryptographically valid.
Source code in src/vacant/cli/commands.py
registry_witnesses_cmd
¶
registry_witnesses_cmd(epoch_id: int = Argument(..., help='Sealed epoch_id'), db: str = Option(..., '--db', help='Registry SQLite path')) -> None
List all witness cosignatures recorded for epoch_id.
Source code in src/vacant/cli/commands.py
registry_verify_quorum_cmd
¶
registry_verify_quorum_cmd(epoch_id: int = Argument(..., help='Sealed epoch_id'), db: str = Option(..., '--db', help='Registry SQLite path'), threshold: int = Option(..., '--threshold', help='Required distinct witnesses (M)'), rootset: str = Option(..., '--rootset', help='Comma-separated hex witness pubkeys (the N candidates)')) -> None
Verify a quorum of witness cosignatures over an epoch root.
Exits 0 iff ≥ threshold distinct valid signatures from the
rootset are present on the epoch. This is the verifier surface a
third-party auditor would call.
Source code in src/vacant/cli/commands.py
peer_add_cmd
¶
peer_add_cmd(label: str = Argument(..., help='Unique label for this peer.'), endpoint: str = Argument(..., help="HTTP(S) base URL of the peer's A2A server.")) -> None
Remember a remote vacant network peer locally.
The peer can be unreachable at add time — we only record the URL.
vacant peer gossip is what actually contacts it.
Source code in src/vacant/cli/commands.py
peer_list_cmd
¶
Print every peer we know about, in insertion order.
Source code in src/vacant/cli/commands.py
peer_remove_cmd
¶
Forget a previously-added peer.
Source code in src/vacant/cli/commands.py
peer_ping_cmd
¶
peer_ping_cmd(label: str | None = Option(None, '--label', help='Only ping this label.'), timeout_s: float = Option(5.0, '--timeout', help='Per-peer timeout in seconds.')) -> None
Hit each peer's /health endpoint and print whether it answered.
Useful for diagnosing why peer gossip is skipping peers. No state
is mutated — purely a connectivity check.
Source code in src/vacant/cli/commands.py
peer_known_nodes_cmd
¶
peer_known_nodes_cmd(url: str = Option('https://raw.githubusercontent.com/cosmopig/Vacant/main/docs/known-nodes.json', '--url', help='URL of the community-maintained known-nodes seed list.'), timeout_s: float = Option(10.0, '--timeout', help='HTTP timeout in seconds.')) -> None
Fetch the community-maintained seed-node list.
Doesn't auto-add — prints the list so the operator can choose which
seeds to peer add manually. The community list is just a JSON
file in the repo: anyone can PR a seed, but no central party
decides which seed you trust.
Source code in src/vacant/cli/commands.py
registry_ots_upgrade_cmd
¶
registry_ots_upgrade_cmd(epoch_id: int = Argument(..., help='Sealed epoch_id with a pending OTS receipt'), db: str = Option(..., '--db', help='Registry SQLite path'), proof_path: str = Option(..., '--proof', help='Path to a real `.ots` proof file produced by `ots stamp`')) -> None
Replace a pending OTS receipt with a real .ots proof.
Operators run ots stamp <root> (or ots upgrade <pending>.ots)
out-of-band, then pipe the resulting file in. The store records the
real proof's BLAKE2b digest and stamps ots_upgraded_at.
Source code in src/vacant/cli/commands.py
local_store
¶
On-disk layout for local vacants (~/.vacant/<name>/).
A local vacant is the owner-side handle for a vacant: keypair stored
in the OS keyring (or a plaintext file in --insecure-demo mode), a
logbook persisted as .jsonl, and a small meta.json carrying
visibility state, capability text, and endpoint URL. Higher-level CLI
commands (vacant init, status, publish, heartbeat, attest,
call) read and write through this module.
Layout under ${VACANT_HOME:-~/.vacant}/<name>/:
key.json {"pubkey_hex": "...", "key_storage": "keyring"} (mode 0600)
or {"pubkey_hex": ..., "seed_hex": ..., "key_storage": "plaintext"}
logbook.jsonl one JSON-encoded LogEntry per line
meta.json LocalMeta — state / endpoint / capability_text / etc.
Key storage (F-D codex final blockers): the Ed25519 seed is sensitive
material — controlling it == owning the vacant. The default storage is
the OS keyring (Keychain on macOS, Secret Service on Linux, Credential
Locker on Windows) via the keyring package. The on-disk key.json
holds only the public key and a key_storage discriminator so external
tooling can verify signatures without unlocking the keychain.
If the host has no keyring backend (e.g. headless CI without DBus),
init_vacant(insecure_demo=False) raises rather than silently falling
back to plaintext. To opt into plaintext storage explicitly, pass
insecure_demo=True (the CLI surface is vacant init <name>
--insecure-demo); a stderr WARN is emitted and key.json is written
with the seed in the clear under mode 0600.
The --insecure-demo mode exists for two purposes only: live demos
where the operator is showing the file layout, and short-lived CI/test
flows. Do not use it on a host with real network exposure. See
SECURITY.md §"Local key storage" for the full risk model.
ENVELOPE_STATE_FILE
module-attribute
¶
Per-target chain state for outgoing calls (Pfix3 B6).
Keyed by target vacant_id_hex; tracks the last accepted envelope
on the request (caller → target) and response (target → caller)
chains so the next vacant call to the same target advances seq +
prev_envelope_hash correctly. Without this file the CLI defaulted
sequence_no=1 on every call → second call to a target was
rejected as replay by the server.
KEYRING_SERVICE
module-attribute
¶
service argument used for every keyring.set_password /
keyring.get_password call. Stable across versions so the OS keyring
entry survives upgrades.
LocalVacantError
¶
Bases: RuntimeError
Base class for local-store errors.
LocalVacantNotFound
¶
Bases: LocalVacantError
The named local vacant does not exist.
LocalVacantExists
¶
Bases: LocalVacantError
A local vacant with that name already exists.
LocalVacantKeyringUnavailable
¶
Bases: LocalVacantError
The default OS keyring is the fail / null backend.
Raised by init_vacant when the operator has not opted into
insecure_demo=True. The error message tells the operator how to
proceed: install a keyring backend or re-run with --insecure-demo.
LocalMeta
¶
Bases: BaseModel
Sidecar metadata. Visibility / capability / endpoint live here so
status can render them without opening the logbook.
key_storage
class-attribute
instance-attribute
¶
keyring (default, OS keyring) or plaintext (--insecure-demo).
Defaults to plaintext so LocalMeta files written before F-D
landed still load cleanly.
vacant_home
¶
Resolve the root directory: $VACANT_HOME or ~/.vacant.
vacant_dir
¶
Return the on-disk directory for vacant name. Validates the name
so callers cannot escape the home directory via path traversal.
Source code in src/vacant/cli/local_store.py
list_vacant_names
¶
Names of every initialised local vacant, sorted.
Source code in src/vacant/cli/local_store.py
current_name
¶
Resolve the active vacant: env VACANT_NAME, else the only one.
Raises LocalVacantNotFound if no vacant exists or multiple exist
without VACANT_NAME set.
Source code in src/vacant/cli/local_store.py
keyring_backend_available
¶
True iff the host's default keyring is a real backend.
The keyring library always returns some backend from
get_keyring(); on hosts without a working backend it returns
keyring.backends.fail.Keyring (a stub that raises on every
call). We detect that case by inspecting the module path so
callers can give a clear error before a write attempt fails.
Source code in src/vacant/cli/local_store.py
init_vacant
¶
init_vacant(name: str, *, insecure_demo: bool = False) -> tuple[VacantId, SigningKey]
Generate a fresh keypair and persist the local-vacant directory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Local vacant name. Validated against path traversal. |
required |
insecure_demo
|
bool
|
If True, write the Ed25519 seed in plaintext into
|
False
|
Returns:
| Type | Description |
|---|---|
tuple[VacantId, SigningKey]
|
The new |
Raises:
| Type | Description |
|---|---|
LocalVacantExists
|
If |
LocalVacantKeyringUnavailable
|
If |
LocalVacantError
|
Any other failure (path traversal, keyring write error, …). |
Source code in src/vacant/cli/local_store.py
210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 | |
persist_spawned_child
¶
persist_spawned_child(name: str, *, child_vacant_id: VacantId, child_signing_key: SigningKey, child_logbook: Logbook, parent_vacant_id: VacantId, state: str = 'LOCAL', capability_text: str | None = None) -> None
Write a spawned child vacant to disk under ~/.vacant/<name>/.
Unlike init_vacant which generates a fresh keypair, this
persists a spawned child whose keypair was already produced by
one of the vacant.runtime.spawn paths. The child's logbook is
expected to already carry a signed BIRTH entry naming the
parent. The parent's matching SPAWN entry is the caller's
responsibility (it lives in the parent's logbook, not the child's).
Stores the seed in plaintext under key.json (mode 0600). This
helper is currently used only by the vacant_spawn MCP tool,
which runs on demo / replication hosts where plaintext storage is
the established convention (parent is already --insecure-demo).
Source code in src/vacant/cli/local_store.py
load_signing_key
¶
Load the Ed25519 signing key for name.
Looks up key_storage from meta.json (or, for legacy directories
without it, infers from key.json's key_storage field, then falls
back to the plaintext seed). Raises LocalVacantNotFound if the
directory is missing entirely; raises LocalVacantError if the
keyring entry has gone missing under us (e.g. operator cleared the
Keychain after init).
Source code in src/vacant/cli/local_store.py
load_envelope_state
¶
Load the per-target chain state for vacant call.
Returns {} if the file doesn't exist yet (first call). Schema:
{
"<target_vacant_id_hex>": {
"request": {"last_seq": int, "last_hash_hex": str},
"response": {"last_seq": int, "last_hash_hex": str}
}
}
Returned as dict[str, Any] because the file is JSON: leaf
values are ints + strs and the caller knows the schema. Strict
typing would force every read site through casts without buying
safety beyond the schema docstring above.
Source code in src/vacant/cli/local_store.py
save_envelope_state
¶
Atomically persist the envelope state. Uses tempfile +
os.replace so a crashed write does not leave a half-truncated
file (would otherwise cause the next call to replay seq=1).