physics-stratum / agents /stratum_agent
tailot's picture
physics-stratum: the conversational layer over the physics topology
3a0a69b verified
Raw History Blame Contribute Delete
1.63 kB
#!/usr/bin/env python3
"""Node executable of the physics-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 physics 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 physical fact: the sentence the readers agree on is handed to the
physics 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 lgphysstratum import agents, faults # noqa: E402
def main() -> int:
parser = argparse.ArgumentParser(description="Physics-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())