geometry-stratum / agents /stratum_agent
tailot's picture
update geometry-stratum bundle
4f006ca verified
Raw History Blame Contribute Delete
1.65 kB
#!/usr/bin/env python3
"""Node executable of the geometry-stratum topology.
The orchestrator starts this program once per turn, writes the incoming envelope as JSON on
stdin and reads the outgoing envelope from stdout. The behaviour is selected by --role, which
the topology sets to the node id (reader_a, reader_b, equivalence, coverage, invoker, boundary,
adversary or arbiter). Extra arguments added by the orchestrator are accepted and ignored.
The node reads and writes the same envelope as the geometry topology: the dossier of the session
travels inside the natural language field between two markers, and the claim the node makes
about its own envelope travels in smtConstraints, where the referee of the orchestrator reads
it. Nothing here decides a mathematical fact: the sentence the readers agree on is handed to
the geometry topology as a separate process and its verdict is carried back untouched.
"""
import argparse
import json
import os
import sys
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from lingologos_geostratum import agents, faults # noqa: E402
def main() -> int:
parser = argparse.ArgumentParser(description="geometry-stratum topology node")
parser.add_argument("--role", required=True, choices=sorted(agents.STEPS))
parser.add_argument("--node-id", default=None)
args, _ignored = parser.parse_known_args()
faults.from_env()
incoming = json.loads(sys.stdin.read())
outgoing = agents.run_step(args.role, incoming, args.node_id or args.role)
sys.stdout.write(json.dumps(outgoing))
return 0
if __name__ == "__main__":
sys.exit(main())