Skip to content

Commit 21ef73f

Browse files
Add a0min: minimal agent harness over the imported platonic superpotential
Imports the platonic agent verbatim from The-Interdependency/a0 @ f9470a74138da89a2d075ecf6c3241aac63923f1 (python/agents/platonic.py, platonic_regions.py, zfae.py) and wraps it in a minimal stdlib-only harness that can create any potential sub-agent by projecting a declared semantic region, with a0 spawn_caps semantics and a minimal CLI.
1 parent f69b299 commit 21ef73f

11 files changed

Lines changed: 1638 additions & 0 deletions

File tree

a0min/README.md

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
# a0min — minimal agent harness over the platonic superpotential
2+
3+
`a0min` imports the **platonic agent** from
4+
[`The-Interdependency/a0`](https://github.com/The-Interdependency/a0) and wraps
5+
it in the smallest harness that can create any of the **potential sub-agents**
6+
the superpotential declares, plus a minimal CLI.
7+
8+
## Provenance
9+
10+
| File | Imported from | Commit |
11+
|---|---|---|
12+
| `a0min/platonic/platonic.py` | `a0/python/agents/platonic.py` | `f9470a74138da89a2d075ecf6c3241aac63923f1` |
13+
| `a0min/platonic/platonic_regions.py` | `a0/python/agents/platonic_regions.py` | `f9470a74138da89a2d075ecf6c3241aac63923f1` |
14+
| `a0min/platonic/zfae.py` | `a0/python/agents/zfae.py` | `f9470a74138da89a2d075ecf6c3241aac63923f1` |
15+
16+
The imported files are copied **verbatim** and retain their a0 canonical ratios
17+
seals. Cap semantics (depth / fanout / concurrent-live, tier fallbacks, env
18+
overrides) mirror `a0/python/services/spawn_caps.py`.
19+
20+
## The superpotential and its options
21+
22+
`candidate_platonic_agent()` is the open superpotential
23+
(`a0.agent.platonic`): 13 dimensions and 11 declared semantic regions. Each
24+
region is one **potential sub-agent option**:
25+
26+
```
27+
definition, instance, run, semantic_memory, ptcna_runtime_state,
28+
run_artifacts, zfae_inference_binding, provider_relation,
29+
privacy_projection, spawn_merge, resource_need_matching
30+
```
31+
32+
Creating a sub-agent means projecting one region: selected, omitted, and
33+
unresolved dimensions stay explicit; unknown regions and unknown dimensions
34+
fail closed.
35+
36+
## Harness (library)
37+
38+
```python
39+
from a0min import Harness, SpawnCapExceeded
40+
41+
harness = Harness(tier="free") # caps from a0 spawn_caps
42+
options = harness.potential_sub_agents() # the 11 potential sub-agents
43+
44+
sub = harness.create(
45+
"definition",
46+
{"identity": {"definition_id": "def-1"}},
47+
task="minimal definition",
48+
orchestration_mode="single",
49+
cut_mode="soft",
50+
)
51+
print(sub.sub_agent_id, sub.name, sub.unresolved)
52+
53+
harness.merge(sub.sub_agent_id) # release concurrent-live slot
54+
```
55+
56+
Caps: `A0MIN_MAX_SPAWN_DEPTH` / `A0MIN_MAX_SPAWN_FANOUT` /
57+
`A0MIN_MAX_SPAWN_CONCURRENT_LIVE` env vars override tier defaults
58+
(`free=2/5/2`, `seeker=3/5/4`, `operator=4/5/8`, `patron=5/5/12`,
59+
`admin=5/5/20`).
60+
61+
## CLI
62+
63+
```bash
64+
cd a0min
65+
python3 -m a0min list # potential sub-agent options
66+
python3 -m a0min create definition \
67+
--bind 'identity={"definition_id":"def-1"}' \
68+
--task "minimal definition" --mode single --cut soft
69+
python3 -m a0min show a0z-12345678
70+
python3 -m a0min merge a0z-12345678
71+
python3 -m a0min superpotential # dump the imported superpotential
72+
python3 -m a0min caps --tier seeker
73+
```
74+
75+
Every command accepts `--json` for machine-readable output.
76+
77+
## Tests
78+
79+
```bash
80+
python3 -m unittest discover -s tests -v
81+
```
82+
83+
## Scope
84+
85+
The harness is intentionally **in-memory and stdlib-only**. It creates and
86+
tracks sub-agent records; it does not execute inference, persistence, or
87+
networking. Runtime realization (providers, PCNA forks, storage) is downstream
88+
of the projection the harness produces.

a0min/a0min/__init__.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# ratios: loc_comments=32:8 imports_exports=2:1 calls_definitions=0:0
2+
"""a0min — minimal agent harness over the imported a0 platonic superpotential.
3+
4+
Public surface:
5+
- PlatonicAgent, AgentDimension, AgentSemanticRegion, AgentProjection
6+
(imported verbatim from The-Interdependency/a0 @ f9470a74)
7+
- candidate_platonic_agent — the open superpotential with current a0 regions
8+
- Harness — creates any potential sub-agent by projecting a declared region
9+
- SubAgent, PotentialSubAgent, SpawnCapExceeded
10+
"""
11+
12+
from .harness import (
13+
SUPPORTED_CUT_MODES,
14+
SUPPORTED_ORCHESTRATION_MODES,
15+
Harness,
16+
PotentialSubAgent,
17+
SpawnCapExceeded,
18+
SubAgent,
19+
)
20+
from .platonic import (
21+
AgentDimension,
22+
AgentProjection,
23+
AgentSemanticRegion,
24+
PlatonicAgent,
25+
ZFAE_AGENT_DEF,
26+
candidate_platonic_agent,
27+
compose_name,
28+
)
29+
30+
__all__ = [
31+
"AgentDimension",
32+
"AgentSemanticRegion",
33+
"AgentProjection",
34+
"PlatonicAgent",
35+
"candidate_platonic_agent",
36+
"ZFAE_AGENT_DEF",
37+
"compose_name",
38+
"Harness",
39+
"PotentialSubAgent",
40+
"SubAgent",
41+
"SpawnCapExceeded",
42+
"SUPPORTED_ORCHESTRATION_MODES",
43+
"SUPPORTED_CUT_MODES",
44+
]
45+
# ratios: loc_comments=32:8 imports_exports=2:1 calls_definitions=0:0

a0min/a0min/__main__.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# ratios: loc_comments=2:1 imports_exports=1:0 calls_definitions=1:0
2+
"""python -m a0min entry point."""
3+
4+
from .cli import main
5+
6+
raise SystemExit(main())
7+
# ratios: loc_comments=2:1 imports_exports=1:0 calls_definitions=1:0

a0min/a0min/cli.py

Lines changed: 246 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,246 @@
1+
# ratios: loc_comments=201:10 imports_exports=8:1 calls_definitions=84:9
2+
"""Minimal CLI for the a0min agent harness.
3+
4+
Commands:
5+
list list potential sub-agent options from the superpotential
6+
create REGION create one potential sub-agent from a declared region
7+
show ID show a created sub-agent
8+
merge ID mark a created sub-agent merged
9+
superpotential dump the imported platonic superpotential
10+
caps show spawn caps for a tier
11+
12+
Every command accepts ``--json`` for machine-readable output.
13+
"""
14+
15+
from __future__ import annotations
16+
17+
import argparse
18+
import json
19+
import os
20+
import sys
21+
from pathlib import Path
22+
from typing import Any
23+
24+
from .harness import (
25+
SUPPORTED_CUT_MODES,
26+
SUPPORTED_ORCHESTRATION_MODES,
27+
Harness,
28+
SpawnCapExceeded,
29+
)
30+
31+
32+
def _build_parser() -> argparse.ArgumentParser:
33+
parser = argparse.ArgumentParser(
34+
prog="a0min",
35+
description="Minimal agent harness over the imported a0 platonic superpotential.",
36+
)
37+
parser.add_argument(
38+
"--state",
39+
default=os.environ.get("A0MIN_STATE"),
40+
help="JSON state file for created sub-agents (env: A0MIN_STATE)",
41+
)
42+
sub = parser.add_subparsers(dest="command", required=True)
43+
44+
list_parser = sub.add_parser("list", help="list potential sub-agent options")
45+
list_parser.add_argument("--json", action="store_true", dest="as_json")
46+
47+
create_parser = sub.add_parser(
48+
"create", help="create one potential sub-agent from a region"
49+
)
50+
create_parser.add_argument("region", help="declared semantic region name")
51+
create_parser.add_argument("--task", default="", help="task summary for the sub-agent")
52+
create_parser.add_argument(
53+
"--bind",
54+
action="append",
55+
default=[],
56+
metavar="K=V",
57+
help="projection binding; repeatable; values parse as JSON when possible",
58+
)
59+
create_parser.add_argument(
60+
"--mode",
61+
default="single",
62+
choices=SUPPORTED_ORCHESTRATION_MODES,
63+
help="orchestration mode (default: single)",
64+
)
65+
create_parser.add_argument(
66+
"--cut",
67+
default="soft",
68+
choices=SUPPORTED_CUT_MODES,
69+
help="cut mode (default: soft)",
70+
)
71+
create_parser.add_argument("--tier", default="free", help="spawn-cap tier")
72+
create_parser.add_argument(
73+
"--provider", action="append", default=None, help="provider tag; repeatable"
74+
)
75+
create_parser.add_argument(
76+
"--parent", default=None, help="parent sub_agent_id for depth/fanout accounting"
77+
)
78+
create_parser.add_argument("--json", action="store_true", dest="as_json")
79+
80+
show_parser = sub.add_parser("show", help="show a created sub-agent")
81+
show_parser.add_argument("sub_agent_id")
82+
show_parser.add_argument("--json", action="store_true", dest="as_json")
83+
84+
merge_parser = sub.add_parser("merge", help="mark a created sub-agent merged")
85+
merge_parser.add_argument("sub_agent_id")
86+
merge_parser.add_argument("--json", action="store_true", dest="as_json")
87+
88+
super_parser = sub.add_parser(
89+
"superpotential", help="dump the imported platonic superpotential"
90+
)
91+
super_parser.add_argument("--json", action="store_true", dest="as_json")
92+
93+
caps_parser = sub.add_parser("caps", help="show spawn caps for a tier")
94+
caps_parser.add_argument("--tier", default="free", help="spawn-cap tier")
95+
caps_parser.add_argument("--json", action="store_true", dest="as_json")
96+
97+
return parser
98+
99+
100+
def _parse_binding(text: str) -> tuple[str, Any]:
101+
key, sep, value = text.partition("=")
102+
if not sep or not key:
103+
raise ValueError(f"binding must be K=V: {text}")
104+
try:
105+
parsed = json.loads(value)
106+
except json.JSONDecodeError:
107+
parsed = value
108+
return key, parsed
109+
110+
111+
def _print_or_json(payload: Any, as_json: bool) -> None:
112+
if as_json:
113+
print(json.dumps(payload, indent=2))
114+
return
115+
if isinstance(payload, dict):
116+
for key, value in payload.items():
117+
print(f"{key}: {value}")
118+
return
119+
for item in payload:
120+
print(item)
121+
122+
123+
def _list_potential(harness: Harness, as_json: bool) -> int:
124+
options = harness.potential_sub_agents()
125+
if as_json:
126+
print(json.dumps([option.as_dict() for option in options], indent=2))
127+
return 0
128+
print(f"potential sub-agents from {harness.superpotential.agent_id}:")
129+
for option in options:
130+
print(f" {option.region}")
131+
print(f" {option.description}")
132+
print(f" dims: {', '.join(option.dimensions)}")
133+
print(f" surfaces: {', '.join(option.surfaces)}")
134+
print(
135+
f" modes: {', '.join(option.orchestration_modes)} | "
136+
f"cuts: {', '.join(option.cut_modes)}"
137+
)
138+
return 0
139+
140+
141+
def _create(harness: Harness, args: argparse.Namespace) -> int:
142+
try:
143+
bindings = dict(_parse_binding(text) for text in args.bind)
144+
parent = harness.get(args.parent) if args.parent else None
145+
sub_agent = harness.create(
146+
args.region,
147+
bindings,
148+
task=args.task,
149+
orchestration_mode=args.mode,
150+
cut_mode=args.cut,
151+
providers=args.provider,
152+
parent=parent,
153+
)
154+
except (ValueError, KeyError, SpawnCapExceeded) as exc:
155+
print(f"create failed: {exc}", file=sys.stderr)
156+
return 1
157+
if args.as_json:
158+
print(json.dumps(sub_agent.as_dict(), indent=2))
159+
return 0
160+
print(
161+
f"created {sub_agent.sub_agent_id} {sub_agent.name} "
162+
f"run={sub_agent.run_id} depth={sub_agent.depth} "
163+
f"region={sub_agent.region} mode={sub_agent.orchestration_mode} "
164+
f"cut={sub_agent.cut_mode}"
165+
)
166+
print(f" selected: {', '.join(sub_agent.selected) or '-'}")
167+
print(f" unresolved: {', '.join(sub_agent.unresolved) or '-'}")
168+
print(f" omitted: {', '.join(sub_agent.omitted) or '-'}")
169+
return 0
170+
171+
172+
def _show(harness: Harness, args: argparse.Namespace) -> int:
173+
try:
174+
sub_agent = harness.get(args.sub_agent_id)
175+
except KeyError as exc:
176+
print(f"show failed: {exc}", file=sys.stderr)
177+
return 1
178+
if args.as_json:
179+
print(json.dumps(sub_agent.as_dict(), indent=2))
180+
return 0
181+
for key, value in sub_agent.as_dict().items():
182+
print(f"{key}: {value}")
183+
return 0
184+
185+
186+
def _merge(harness: Harness, args: argparse.Namespace) -> int:
187+
try:
188+
sub_agent = harness.merge(args.sub_agent_id)
189+
except KeyError as exc:
190+
print(f"merge failed: {exc}", file=sys.stderr)
191+
return 1
192+
if args.as_json:
193+
print(json.dumps(sub_agent.as_dict(), indent=2))
194+
return 0
195+
print(f"merged {sub_agent.sub_agent_id} {sub_agent.name} (status={sub_agent.status})")
196+
return 0
197+
198+
199+
def _superpotential(harness: Harness, as_json: bool) -> int:
200+
payload = harness.superpotential_dict()
201+
if as_json:
202+
print(json.dumps(payload, indent=2))
203+
return 0
204+
print(f"superpotential: {payload['agent_id']}")
205+
for dimension in payload["dimensions"]:
206+
print(f" dimension {dimension['name']}: {dimension['description']}")
207+
for region in payload["regions"]:
208+
print(f" region {region['region']}: {region['description']}")
209+
return 0
210+
211+
212+
def main(argv: list[str] | None = None) -> int:
213+
parser = _build_parser()
214+
args = parser.parse_args(argv)
215+
216+
tier = getattr(args, "tier", "free")
217+
state_path = getattr(args, "state", None)
218+
if state_path and Path(state_path).exists():
219+
harness = Harness.load(state_path, tier=tier)
220+
else:
221+
harness = Harness(tier=tier)
222+
223+
if args.command == "list":
224+
code = _list_potential(harness, args.as_json)
225+
elif args.command == "create":
226+
code = _create(harness, args)
227+
elif args.command == "show":
228+
code = _show(harness, args)
229+
elif args.command == "merge":
230+
code = _merge(harness, args)
231+
elif args.command == "superpotential":
232+
code = _superpotential(harness, args.as_json)
233+
elif args.command == "caps":
234+
if args.as_json:
235+
print(json.dumps(harness.caps, indent=2))
236+
else:
237+
_print_or_json(harness.caps, False)
238+
code = 0
239+
else:
240+
parser.error(f"unknown command: {args.command}")
241+
code = 2
242+
243+
if state_path and code == 0:
244+
harness.save(state_path)
245+
return code
246+
# ratios: loc_comments=201:10 imports_exports=8:1 calls_definitions=84:9

0 commit comments

Comments
 (0)